Skip to content

Commit

Permalink
Player displays color graphics with libcaca.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonymiller authored and anthonymiller committed Mar 23, 2009
1 parent c18ba2c commit bd17829
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
*.swp
tracker
ztlog
songs
3 changes: 2 additions & 1 deletion Makefile
@@ -1,9 +1,10 @@
LDFLAGS = $(SDL_LDFLAGS) $(NCURSES_LDFLAGS)
LDFLAGS = $(SDL_LDFLAGS) $(NCURSES_LDFLAGS) $(CACA_LDFLAGS)
CFLAGS = -Wall $(SDL_CFLAGS) $(NCURSES_CFLAGS)
CC = gcc

SDL_LDFLAGS := $(shell pkg-config --libs sdl)
NCURSES_LDFLAGS := $(shell ncurses5-config --libs)
CACA_LDFLAGS := $(shell pkg-config --libs caca)

SDL_CFLAGS := $(shell pkg-config --cflags sdl)
NCURSES_CFLAGS := $(shell ncurses5-config --cflags)
Expand Down
32 changes: 0 additions & 32 deletions ejirewt.song

This file was deleted.

138 changes: 138 additions & 0 deletions jigrog.song
@@ -0,0 +1,138 @@
musicchip tune
version 1

songline 00 01 00 00 00 00 00 00 00
songline 01 01 00 00 00 00 00 00 00
songline 02 02 00 00 00 00 00 00 00
songline 03 02 00 00 00 00 00 00 00
songline 04 01 00 03 00 04 00 00 00
songline 05 01 00 03 00 06 00 00 00
songline 06 02 00 03 00 05 00 00 00
songline 07 02 00 03 00 06 00 00 00
songline 08 01 00 00 00 04 00 00 00
songline 09 01 00 00 00 06 00 00 00
songline 0a 02 00 00 00 05 00 00 00
songline 0b 02 00 07 00 06 00 00 00
songline 0c 01 00 08 00 09 00 0a 00
songline 0d 01 00 08 00 09 00 0a 00
songline 0e 02 00 08 00 09 00 0a 00
songline 0f 02 00 08 00 09 00 0a 00

trackline 01 00 19 01 00 00 00 00
trackline 01 08 3f 01 00 00 00 00
trackline 01 0a 36 01 00 00 00 00
trackline 01 0b 3f 01 00 00 00 00
trackline 01 0d 36 01 00 00 00 00
trackline 01 0e 3f 01 00 00 00 00
trackline 01 0f 3d 01 00 00 00 00
trackline 01 11 33 01 00 00 00 00
trackline 01 12 35 01 00 00 00 00
trackline 01 14 36 01 00 00 00 00
trackline 01 15 33 01 00 00 00 00
trackline 01 18 36 01 00 00 00 00
trackline 01 1a 35 01 00 00 00 00
trackline 01 1c 3f 01 00 00 00 00
trackline 02 00 1b 01 00 00 00 00
trackline 02 08 3f 01 00 00 00 00
trackline 02 0a 36 01 00 00 00 00
trackline 02 0c 3f 01 00 00 00 00
trackline 02 0d 36 01 00 00 00 00
trackline 02 0e 3f 01 00 00 00 00
trackline 02 10 3d 01 00 00 00 00
trackline 02 11 33 01 00 00 00 00
trackline 02 12 35 01 00 00 00 00
trackline 02 14 36 01 00 00 00 00
trackline 02 15 33 01 00 00 00 00
trackline 02 18 36 01 00 00 00 00
trackline 02 1a 35 01 00 00 00 00
trackline 02 1c 3f 01 00 00 00 00
trackline 03 00 1e 02 00 00 00 00
trackline 03 08 1e 02 00 00 00 00
trackline 03 10 1e 02 00 00 00 00
trackline 03 18 1e 02 00 00 00 00
trackline 04 00 25 04 00 00 00 00
trackline 05 00 27 04 00 00 00 00
trackline 06 10 00 00 66 f7 00 00
trackline 07 00 25 02 00 00 00 00
trackline 07 04 25 02 00 00 00 00
trackline 07 08 25 02 00 00 00 00
trackline 07 0a 25 02 00 00 00 00
trackline 07 0e 25 02 00 00 00 00
trackline 07 12 25 02 00 00 00 00
trackline 07 14 25 02 00 00 00 00
trackline 07 16 25 02 00 00 00 00
trackline 07 18 25 03 00 00 00 00
trackline 07 1a 25 03 00 00 00 00
trackline 07 1c 25 03 00 00 00 00
trackline 07 1e 25 03 00 00 00 00
trackline 08 00 25 02 00 00 00 00
trackline 08 08 25 03 00 00 00 00
trackline 08 0e 25 02 00 00 00 00
trackline 08 14 25 02 00 00 00 00
trackline 08 18 25 03 00 00 00 00
trackline 09 00 36 05 00 00 00 00
trackline 09 04 35 05 00 00 00 00
trackline 09 08 33 05 00 00 00 00
trackline 09 0c 36 05 00 00 00 00
trackline 09 10 35 05 00 00 00 00
trackline 09 14 33 05 00 00 00 00
trackline 09 18 36 05 00 00 00 00
trackline 09 1c 35 05 00 00 00 00
trackline 0a 02 36 06 00 00 00 00
trackline 0a 06 35 06 00 00 00 00
trackline 0a 0a 33 06 00 00 00 00
trackline 0a 0e 36 06 00 00 00 00
trackline 0a 12 35 06 00 00 00 00
trackline 0a 16 33 06 00 00 00 00
trackline 0a 1a 36 06 00 00 00 00
trackline 0a 1e 35 06 00 00 00 00

instrumentline 01 00 76 ff
instrumentline 01 01 2b 25
instrumentline 01 02 77 02
instrumentline 01 03 6d 20
instrumentline 01 04 69 f4
instrumentline 02 00 77 03
instrumentline 02 01 76 ff
instrumentline 02 02 74 01
instrumentline 02 03 77 02
instrumentline 02 04 64 90
instrumentline 02 05 2b 31
instrumentline 02 06 73 a0
instrumentline 02 07 66 f0
instrumentline 03 00 76 e1
instrumentline 03 01 77 03
instrumentline 03 02 74 02
instrumentline 03 03 77 02
instrumentline 03 04 64 80
instrumentline 03 05 74 02
instrumentline 03 06 77 03
instrumentline 03 07 74 0f
instrumentline 03 08 76 00
instrumentline 04 00 66 01
instrumentline 04 01 77 01
instrumentline 04 02 2b 31
instrumentline 04 03 74 02
instrumentline 04 04 2b 40
instrumentline 04 05 74 02
instrumentline 04 06 2b 44
instrumentline 04 07 74 02
instrumentline 04 08 2b 49
instrumentline 04 09 74 02
instrumentline 04 0a 40 02
instrumentline 05 00 76 ff
instrumentline 05 01 77 02
instrumentline 05 02 6d 20
instrumentline 05 03 2b 25
instrumentline 05 04 74 02
instrumentline 05 05 76 df
instrumentline 05 06 74 04
instrumentline 05 07 76 50
instrumentline 06 00 76 8f
instrumentline 06 01 77 02
instrumentline 06 02 6d 20
instrumentline 06 03 2b 25
instrumentline 06 04 74 02
instrumentline 06 05 76 6f
instrumentline 06 06 74 04
instrumentline 06 07 76 25
29 changes: 29 additions & 0 deletions pineapple
@@ -0,0 +1,29 @@

 

   

 

 

 

 ######

########

##########

##########

##########

##########

##########

 ########

######

55 changes: 53 additions & 2 deletions player.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <err.h>
#include <SDL/SDL.h>
#include <caca.h>

#include "stuff.h"

Expand All @@ -15,11 +16,33 @@ void audiocb(void *userdata, Uint8 *buf, int len) {
int main(int argc, char **argv){
SDL_AudioSpec requested, obtained;

int quit = 0;
int xo;
caca_display_t *dp;
caca_canvas_t *cv;
caca_canvas_t *pineapple;

if(SDL_Init( SDL_INIT_AUDIO ) < 0){
err(1, "Couldnt initialize SDL\n");
exit(1);
}

cv = caca_create_canvas(80, 24);
pineapple = caca_create_canvas(0, 0);
if((cv == NULL) || (pineapple == NULL)){
printf("failed to create canvas\n");
return 1;
}
xo = caca_get_canvas_width(cv) - 2;
dp = caca_create_display(cv);
caca_set_display_time(dp, 20000);
if(dp == NULL){
printf("Failed to create display\n");
return 1;
}

caca_import_file(pineapple, "./pineapple", "");

atexit(SDL_Quit);

requested.freq = 16000;
Expand All @@ -40,8 +63,36 @@ int main(int argc, char **argv){
SDL_PauseAudio(0);
//playmode = PM_PLAY;
silence();
startplaysong(1);
for(;;){}
startplaysong(0);

while(!quit)
{
caca_event_t ev;
caca_set_color_ansi(cv, caca_rand(0, 16), caca_rand(0, 16));
//caca_blit(cv, 0, 0, pineapple, NULL);
//caca_blit(cv, 55, 0, pineapple, NULL);
caca_put_str(cv, (xo - strlen("pineapple player")) / 2, 10, "pineapple player");
caca_set_color_ansi(cv, caca_rand(0, 16), caca_rand(0, 16));
caca_printf(cv, (xo - strlen("song pos -> ")) / 2, 12, "song pos -> %i", songpos);
//caca_clear_canvas(cv);

while(caca_get_event(dp, CACA_EVENT_ANY, &ev, 0))
{
if(caca_get_event_type(&ev) & CACA_EVENT_KEY_PRESS)
{
switch(caca_get_event_key_ch(&ev))
{
case 'q':
case 'Q':
case CACA_KEY_ESCAPE:
quit = 1;
break;
}
}
}
caca_refresh_display(dp);
}
caca_free_display(dp);
caca_free_canvas(cv);
return 0;
}

0 comments on commit bd17829

Please sign in to comment.