diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..530dbfd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "dc_timer.h": "c" + } +} \ No newline at end of file diff --git a/Makefile b/Makefile index 5bfcfca..bf4d5dc 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,4 @@ include $(KOS_BASE)/addons/Makefile.prefab create_kos_link: rm -f ../include/dreamroq - ln -s ../libdreamroq/include ../include/dreamroq + ln -s ../libdreamroq/include ../include/dreamroq \ No newline at end of file diff --git a/dreamroq-player.c b/dreamroq-player.c index 881a766..1cb716c 100644 --- a/dreamroq-player.c +++ b/dreamroq-player.c @@ -34,9 +34,9 @@ static int current_frame = 0; static int graphics_initialized = 0; static float video_delay; static int frame=0; -static int vid_width = 640; -static int vid_height = 480; -static const float VIDEO_RATE = 30.0f; /* Video FPS */ +static int vid_width = 320; +static int vid_height = 240; +static const float VIDEO_RATE = 25.0f; /* Video FPS */ static void snd_thd(){ do @@ -110,8 +110,8 @@ int roq_set_size(int width, int height) { ul_x = 0; ul_y = 0; - br_x = 640; - br_y = 480; + br_x = 512; + br_y = 270; @@ -206,19 +206,32 @@ int roq_set_size(int width, int height) { } int roq_quit_cb(){ - maple_device_t *cont; - cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + cont_cond_t cont; - cont_state_t *state; - state = maple_dev_status(cont); - return (state->buttons & CONT_START); + /* check controller state */ + if (cont_get_cond(maple_first_controller(), &cont)) + { + /* controller read error */ + return 1; + } + cont.buttons = ~cont.buttons; + return (cont.buttons & CONT_START); } - int roq_free_texture(){ +int roq_free_texture(){ pvr_mem_free(textures[0]); pvr_mem_free(textures[1]); } +int free_variables() { + current_frame = 0; + graphics_initialized = 0; + video_delay; + frame=0; + vid_width = 320; + vid_height = 240; +} + int roq_free_audio() { if(audio_init) { diff --git a/dreamroq-player.o b/dreamroq-player.o new file mode 100644 index 0000000..8942fb0 Binary files /dev/null and b/dreamroq-player.o differ diff --git a/dreamroqlib.c b/dreamroqlib.c index 236e7cc..eead0a4 100644 --- a/dreamroqlib.c +++ b/dreamroqlib.c @@ -364,6 +364,7 @@ static int roq_unpack_vq(unsigned char *buf, int size, unsigned int arg, int roq_play(char *filename, int loop, render_callback render_cb, audio_callback audio_cb, quit_callback quit_cb) { + pvr_init_defaults(); FILE *f; size_t file_ret; int framerate; @@ -385,7 +386,6 @@ int roq_play(char *filename, int loop, render_callback render_cb, if (file_ret != 1) { fclose(f); - printf("\nROQ_FILE_READ_FAILURE\n\n"); return ROQ_FILE_READ_FAILURE; } @@ -397,7 +397,6 @@ int roq_play(char *filename, int loop, render_callback render_cb, return ROQ_FILE_READ_FAILURE; } framerate = LE_16(&read_buffer[6]); - printf("RoQ file plays at %d frames/sec\n", framerate); /* Initialize Audio SQRT Look-Up Table */ for(i = 0; i < 128; i++) @@ -409,7 +408,6 @@ int roq_play(char *filename, int loop, render_callback render_cb, status = ROQ_SUCCESS; while (!feof(f) && status == ROQ_SUCCESS) { - printf("DreamROQ: playing frame %d\n", frameCount); frameCount++; /* if client program defined a quit callback, check if it's time * to quit */ @@ -418,7 +416,7 @@ int roq_play(char *filename, int loop, render_callback render_cb, file_ret = fread(read_buffer, CHUNK_HEADER_SIZE, 1, f); #ifdef FPSGRAPH - printf("r\n"); + #endif if (file_ret != 1) { @@ -496,9 +494,7 @@ int roq_play(char *filename, int loop, render_callback render_cb, while (state.texture_height < state.height) state.texture_height <<= 1; } - printf(" RoQ_INFO: dimensions = %dx%d, %dx%d; %d mbs, texture = %dx%d\n", - state.width, state.height, state.mb_width, state.mb_height, - state.mb_count, state.stride, state.texture_height); + state.frame[0] = (unsigned short*)malloc(state.texture_height * state.stride * sizeof(unsigned short)); state.frame[1] = (unsigned short*)malloc(state.texture_height * state.stride * sizeof(unsigned short)); state.current_frame = 0; @@ -573,7 +569,9 @@ int roq_play(char *filename, int loop, render_callback render_cb, free(state.frame[1]); roq_free_texture(); roq_free_audio(); + free_variables(); fclose(f); + pvr_shutdown(); return status; } diff --git a/dreamroqlib.o b/dreamroqlib.o new file mode 100644 index 0000000..7064151 Binary files /dev/null and b/dreamroqlib.o differ diff --git a/include/dreamroqlib.h b/include/dreamroqlib.h index 7cebc28..a559600 100644 --- a/include/dreamroqlib.h +++ b/include/dreamroqlib.h @@ -31,16 +31,16 @@ typedef int (*audio_callback)(unsigned char *buf, int samples, int channels); * Return non-zero if it's time to quite. */ typedef int (*quit_callback)(); -int roq_play(char *filename, int loop, render_callback render_cb, +extern "C" int roq_play(char *filename, int loop, render_callback render_cb, audio_callback audio_cb, quit_callback quit_cb); -int roq_set_size(int width, int height); - -int roq_render_cb(unsigned short *buf, int width, int height, int stride, int texture_height); -int roq_audio_cb(unsigned char *buf, int size, int channels); -int roq_quit_cb(); -int roq_free_texture(); -int roq_free_audio(); +extern "C" int roq_set_size(int width, int height); +extern "C" int roq_render_cb(unsigned short *buf, int width, int height, int stride, int texture_height); +extern "C" int roq_audio_cb(unsigned char *buf, int size, int channels); +extern "C" int roq_quit_cb(); +extern "C" int roq_free_texture(); +extern "C" int roq_free_audio(); +extern "C" int free_variables(); #endif /* NEWROQ_H */ diff --git a/libdcmc/snd_stream.c b/libdcmc/snd_stream.c index f90690d..193c9bf 100644 --- a/libdcmc/snd_stream.c +++ b/libdcmc/snd_stream.c @@ -271,7 +271,6 @@ snd_stream_hnd_t snd_stream_alloc(snd_stream_callback_t cb, int bufsize) { // And channels streams[hnd].ch[0] = snd_sfx_chn_alloc(); streams[hnd].ch[1] = snd_sfx_chn_alloc(); - printf("snd_stream: alloc'd channels %d/%d\n", streams[hnd].ch[0], streams[hnd].ch[1]); return hnd; } @@ -458,7 +457,6 @@ int snd_stream_poll(snd_stream_hnd_t hnd) { needed_samples = (streams[hnd].buffer_size/2) - streams[hnd].last_write_pos; /* round it a little bit */ needed_samples &= ~0x7ff; - /* printf("last_write_pos %6i, current_play_pos %6i, needed_samples %6i\n",last_write_pos,current_play_pos,needed_samples); */ //if (needed_samples > 0) { if (needed_samples ==4096) { diff --git a/libdcmc/snd_stream.o b/libdcmc/snd_stream.o index bf5a30c..054c5ea 100644 Binary files a/libdcmc/snd_stream.o and b/libdcmc/snd_stream.o differ diff --git a/libdcmc/snddrv.c b/libdcmc/snddrv.c index f9e5627..242a2ac 100644 --- a/libdcmc/snddrv.c +++ b/libdcmc/snddrv.c @@ -59,9 +59,6 @@ int snddrv_exit() { while( snddrv.drv_status != SNDDRV_STATUS_NULL ) thd_pass(); - - - printf("SNDDRV: Exited\n"); } memset( snddrv.pcm_buffer, 0, 65536+16384); @@ -94,8 +91,6 @@ static void *snddrv_callback(snd_stream_hnd_t hnd, int len, int * actual) { static int snddrv_thread() { - printf("SNDDRV: Rate - %i, Channels - %i\n", snddrv.rate, snddrv.channels); - shnd = snd_stream_alloc(snddrv_callback, SND_STREAM_BUFFER_MAX/4); snd_stream_start(shnd, snddrv.rate, snddrv.channels-1); @@ -112,8 +107,6 @@ static int snddrv_thread() { snd_stream_destroy(shnd); snd_stream_shutdown(); - printf("SNDDRV: Finished\n"); - return snddrv.drv_status; } @@ -123,12 +116,9 @@ int snddrv_start( int rate, int chans ) { snddrv.rate = rate; snddrv.channels = chans; if( snddrv.channels > 2) { - printf("SNDDRV: ERROR - Exceeds maximum channels\n"); return -1; } - printf("SNDDRV: Creating Driver Thread\n"); - snddrv.drv_status = SNDDRV_STATUS_INITIALIZING; snd_stream_init(); diff --git a/libdcmc/snddrv.o b/libdcmc/snddrv.o index 78c26d1..92d74f3 100644 Binary files a/libdcmc/snddrv.o and b/libdcmc/snddrv.o differ diff --git a/libdcmc/timer.c b/libdcmc/timer.c index fdde8be..c75afa5 100644 --- a/libdcmc/timer.c +++ b/libdcmc/timer.c @@ -28,7 +28,7 @@ void frame_delay( float AVI_video_rate, float AVI_delay, int frameCounter ) { float AVI_real_time = frameCounter / AVI_video_rate; float CPU_real_time= ( ( (float)dc_get_time()- AVI_delay ) / 1000.0f ); - //printf("AVI_real_time: %f, CPU_real_time %f\n", AVI_real_time, CPU_real_time ); + while ( CPU_real_time < AVI_real_time ) { CPU_real_time= ( ( (float)dc_get_time()- AVI_delay ) / 1000.0f ); thd_pass(); diff --git a/libdcmc/timer.o b/libdcmc/timer.o index ddefce9..950b1a9 100644 Binary files a/libdcmc/timer.o and b/libdcmc/timer.o differ diff --git a/libdreamroq.a b/libdreamroq.a index 171e8e8..97a76f7 100644 Binary files a/libdreamroq.a and b/libdreamroq.a differ diff --git a/samples/basic/Makefile b/samples/basic/Makefile index 9221b65..ed7f7ce 100644 --- a/samples/basic/Makefile +++ b/samples/basic/Makefile @@ -13,7 +13,7 @@ rm-elf: $(TARGET): $(OBJS) romdisk.o $(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \ - $(OBJS) romdisk.o $(OBJEXTRA) -lm -lkosutils -ldreamroq $(KOS_LIBS) + $(OBJS) romdisk.o $(OBJEXTRA) -lm -ldreamroq $(KOS_LIBS) romdisk.img: $(KOS_GENROMFS) -f romdisk.img -d romdisk -v diff --git a/samples/basic/basic.c b/samples/basic/basic.c index 07ad419..f7ea4da 100644 --- a/samples/basic/basic.c +++ b/samples/basic/basic.c @@ -16,8 +16,6 @@ extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); int main() { - printf("DreamROQ Demo.\n"); - vid_set_mode(DM_640x480, PM_RGB565); pvr_init_defaults(); @@ -27,6 +25,4 @@ int main() { roq_audio_cb, // default audio callback roq_quit_cb // default quit callback ); - - printf("DreamROQ video done.\n"); } diff --git a/samples/basic/dreamroq_basic.elf b/samples/basic/dreamroq_basic.elf index 1c1281b..1dd5a90 100755 Binary files a/samples/basic/dreamroq_basic.elf and b/samples/basic/dreamroq_basic.elf differ diff --git a/samples/basic/romdisk.img b/samples/basic/romdisk.img index ab85e9e..72e980a 100644 Binary files a/samples/basic/romdisk.img and b/samples/basic/romdisk.img differ diff --git a/samples/basic/romdisk.o b/samples/basic/romdisk.o index 9a27713..f8aa7e4 100644 Binary files a/samples/basic/romdisk.o and b/samples/basic/romdisk.o differ