parent
92ed51bf70
commit
4b44c06b8d
9 changed files with 544 additions and 909 deletions
@ -1,38 +1,45 @@ |
||||
# Put the filename of the output binary here
|
||||
TARGET = dreamroq-player.elf
|
||||
DIR=$(PWD)
|
||||
|
||||
# List all of your C files here, but change the extension to ".o"
|
||||
OBJS = dreamroq-player.o dreamroqlib.o
|
||||
|
||||
all: rm-elf $(TARGET) |
||||
|
||||
include $(KOS_BASE)/Makefile.rules |
||||
|
||||
clean: |
||||
-rm -f $(TARGET) $(OBJS)
|
||||
|
||||
rm-elf: |
||||
-rm -f $(TARGET)
|
||||
|
||||
# If you don't need a ROMDISK, then remove "romdisk.o" from the next few
|
||||
# lines. Also change the -l arguments to include everything you need,
|
||||
# such as -lmp3, etc.. these will need to go _before_ $(KOS_LIBS)
|
||||
$(TARGET): $(OBJS) |
||||
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
|
||||
$(OBJS) $(OBJEXTRA) $(KOS_LIBS)
|
||||
|
||||
cd: $(TARGET) $(OBJS) |
||||
#elf transform ---- make sure the *.elf name matches your .elf file.
|
||||
sh-elf-objcopy -R .stack -O binary $(TARGET) output.bin
|
||||
#scraming process
|
||||
$(KOS_BASE)/utils/scramble/scramble output.bin 1ST_READ.bin
|
||||
#creating iso -> -o outputname.iso
|
||||
mkisofs -C 0,11702 -V DC_GAME -G IP.BIN -r -J -l -m '*.o' -x $(DIR)/builds -o $(DIR)/builds/$(TARGET).iso $(DIR)
|
||||
|
||||
run: $(CD) |
||||
lxdream builds/$(TARGET).iso
|
||||
|
||||
dist: |
||||
rm -f $(OBJS) romdisk.o romdisk.img
|
||||
$(KOS_STRIP) $(TARGET)
|
||||
# Put the filename of the output binary here
|
||||
TARGET = dreamroq-player.elf
|
||||
PROJECT_NAME = dreamroq_ph3nom
|
||||
DIR=$(PWD)
|
||||
|
||||
# List all of your C files here, but change the extension to ".o"
|
||||
OBJS = dreamroq-player.o dreamroqlib.o
|
||||
|
||||
#AICA Audio Driver
|
||||
KOS_CFLAGS += -I. -Ilibdcmc/
|
||||
OBJS += libdcmc/snddrv.o
|
||||
|
||||
#PVR Video Driver
|
||||
OBJS += libdcmc/pvrdrv.o
|
||||
|
||||
all: rm-elf $(TARGET) |
||||
|
||||
include $(KOS_BASE)/Makefile.rules |
||||
|
||||
clean: |
||||
-rm -f $(TARGET) $(OBJS)
|
||||
|
||||
rm-elf: |
||||
-rm -f $(TARGET)
|
||||
|
||||
# If you don't need a ROMDISK, then remove "romdisk.o" from the next few
|
||||
# lines. Also change the -l arguments to include everything you need,
|
||||
# such as -lmp3, etc.. these will need to go _before_ $(KOS_LIBS)
|
||||
$(TARGET): $(OBJS) |
||||
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
|
||||
$(OBJS) $(OBJEXTRA) $(KOS_LIBS)
|
||||
|
||||
run: $(TARGET) |
||||
$(KOS_LOADER) $(TARGET)
|
||||
|
||||
cd: $(TARGET) |
||||
@sh-elf-objcopy -R .stack -O binary $(TARGET) output.bin
|
||||
@$(KOS_BASE)/utils/scramble/scramble output.bin 1ST_READ.BIN
|
||||
@mkisofs -C 0,11702 -V Reaperi_Cycle -G $(KOS_BASE)/IP.BIN -r -J -l -m '*.o' -o ../$(PROJECT_NAME).iso $(DIR)
|
||||
@$(KOS_BASE)/utils/cdi4dc/cdi4dc ../$(PROJECT_NAME).iso ../$(PROJECT_NAME).cdi -d > cdi4dc.log
|
||||
../redream ../$(PROJECT_NAME).cdi
|
||||
|
||||
dist: |
||||
rm -f $(OBJS) romdisk.o romdisk.img
|
||||
$(KOS_STRIP) $(TARGET)
|
||||
|
@ -1,82 +1,131 @@ |
||||
# Dreamroq Library |
||||
|
||||
_This is a fork of the original project, we're currently trying to have the video play at the desired framerate._ |
||||
|
||||
### Introduction |
||||
|
||||
Dreamroq is a RoQ playback library designed for the Sega Dreamcast video |
||||
game console. |
||||
|
||||
RoQ is a relatively simple video file format developed for video-heavy |
||||
CD-ROM games. Read more about the format here: |
||||
|
||||
http://wiki.multimedia.cx/index.php?title=RoQ |
||||
|
||||
The Dreamroq library includes a player component that is designed to run |
||||
under the KallistiOS (KOS) open source operating system. Read more about |
||||
KOS at: |
||||
|
||||
http://gamedev.allusion.net/softprj/kos/ |
||||
|
||||
The library also includes a sample testing utility that can be built |
||||
and executed on Unix systems. This utility is useful for debugging and |
||||
validation. |
||||
|
||||
RoQ sample files can be found at: |
||||
|
||||
http://samples.mplayerhq.hu/game-formats/idroq/ |
||||
|
||||
RoQ files can also be created using the Switchblade encoder: |
||||
|
||||
http://icculus.org/~riot/ |
||||
|
||||
Or by using FFmpeg: |
||||
|
||||
`ffmpeg -i input_video.mp4 -o output_video.roq` |
||||
|
||||
http://ffmpeg.org/ |
||||
|
||||
|
||||
### License |
||||
Dreamroq is meant to be license-compatible with the rest of the KallistiOS |
||||
operating system, which is a BSD-style open source license. You can read |
||||
the specific text in LICENSE.KOS. |
||||
|
||||
|
||||
### Building (KOS) |
||||
|
||||
`make` |
||||
|
||||
This is a standard KOS Makefile which assumes that a KOS build environment |
||||
is available. This is covered in the KOS documentation. This step will |
||||
build a file named dreamroq-player.elf which can be loaded onto a Dreamcast |
||||
console via standard means (also outside the scope of this document). |
||||
|
||||
The file dreamcast-player.c contains a hardcoded RoQ file path in its |
||||
main function. It is best if this points to a file burned on an optical |
||||
disc. It is also viable to build a small RoQ file as a ROM disk into the |
||||
ELF file (which is well supported in KOS) and load the file from the '/rd' |
||||
mount point. |
||||
|
||||
|
||||
### Bugs, Issues, and Future Development |
||||
|
||||
The player is just a proof of concept at this point. It doesn't try to |
||||
render frames with proper timing-- it just plays them as fast as possible |
||||
(which often isn't very fast, mostly due to the I/O bottleneck). |
||||
|
||||
If the RoQ video is taller than it is wide, expect some odd rendering. |
||||
|
||||
The API between the library and the client app leaves a bit to be desired. |
||||
Notably absent is some proper initialization and teardown mechanism. |
||||
Currently, the first call to the render callback initializes the PVR buffers |
||||
but they are never explicitly freed. |
||||
|
||||
|
||||
### Credits |
||||
|
||||
Library originally written by Mike Melanson (mike -at- multimedia.cx) |
||||
|
||||
Audio support added by Josh "PH3NOM" Pearson ([email protected]) |
||||
|
||||
Audio and framerate fix by MrNeo240 and lerabot |
||||
Dreamroq by Mike Melanson (mike -at- multimedia.cx) |
||||
R2 update by Josh Pearson ([email protected]) |
||||
|
||||
Introduction |
||||
============ |
||||
Dreamroq is a RoQ playback library designed for the Sega Dreamcast video |
||||
game console. |
||||
|
||||
RoQ is a relatively simple video file format developed for video-heavy |
||||
CD-ROM games. Read more about the format here: |
||||
|
||||
http://wiki.multimedia.cx/index.php?title=RoQ |
||||
|
||||
The Dreamroq library includes a player component that is designed to run |
||||
under the KallistiOS (KOS) open source operating system. Read more about |
||||
KOS at: |
||||
|
||||
http://gamedev.allusion.net/softprj/kos/ |
||||
|
||||
The library also includes a sample testing utility that can be built |
||||
and executed on Unix systems. This utility is useful for debugging and |
||||
validation. |
||||
|
||||
RoQ sample files can be found at: |
||||
|
||||
http://samples.mplayerhq.hu/game-formats/idroq/ |
||||
|
||||
RoQ files can also be created using the Switchblade encoder: |
||||
|
||||
http://icculus.org/~riot/ |
||||
|
||||
A version of Switchblade is also included in FFmpeg and many derivative |
||||
programs: |
||||
|
||||
http://ffmpeg.org/ |
||||
|
||||
|
||||
License |
||||
======= |
||||
Dreamroq is meant to be license-compatible with the rest of the KallistiOS |
||||
operating system, which is a BSD-style open source license. You can read |
||||
the specific text in LICENSE.KOS. |
||||
|
||||
|
||||
Building (Unix) |
||||
=============== |
||||
To build and test on Linux/Mac OS X/Cygwin, simply type: |
||||
|
||||
make |
||||
|
||||
in the source directory. This will build the executable test-dreamroq. This |
||||
utility has the following usage: |
||||
|
||||
./test-dreamroq <file.roq> |
||||
|
||||
This will decode the RoQ file from the command line into a series of PNM |
||||
files in the current working directory (watch out-- this could take up a |
||||
lot of disk space). |
||||
|
||||
|
||||
Building (KOS) |
||||
============== |
||||
There are 2 Makefiles included with Dreamroq. The first -- implicitly |
||||
invoked when running a bare 'make' command as seen in the "Building (Unix)" |
||||
section -- builds the test utility. The second Makefile is Makefile.KOS, |
||||
invoked with: |
||||
|
||||
make -f Makefile.KOS |
||||
|
||||
This is a standard KOS Makefile which assumes that a KOS build environment |
||||
is available. This is covered in the KOS documentation. This step will |
||||
build a file named dreamroq-player.elf which can be loaded onto a Dreamcast |
||||
console via standard means (also outside the scope of this document). |
||||
|
||||
The file dreamcast-player.c contains a hardcoded RoQ file path in its |
||||
main function. It is best if this points to a file burned on an optical |
||||
disc. It is also viable to build a small RoQ file as a ROM disk into the |
||||
ELF file (which is well supported in KOS) and load the file from the '/rd' |
||||
mount point. |
||||
|
||||
|
||||
Bugs, Issues, and Future Development |
||||
==================================== |
||||
|
||||
:R2 Release by PH3NOM: |
||||
|
||||
I have updated the dreamroq library to support decoding of DPCM |
||||
audio samples encoded in the RoQ stream. |
||||
|
||||
The KOS Dreamcast player has been updated to support streaming |
||||
of the decoded samples, directly using the Dreamcast's AICA |
||||
audio hardware, running in a seperate thread. |
||||
|
||||
DMA transfers to the PVR and rendering of the frame is executed |
||||
in a seperate thread, so the decoder can continue to process the |
||||
next frame while the current frame is being processed by the PVR. |
||||
|
||||
Furthermore, a frame-rate timer has been implemented, so the video |
||||
should be played back at correct speed. Also, the allocated PVR |
||||
memory is now freed on exit of the player. |
||||
|
||||
==================================== |
||||
/* deprecated */ |
||||
The library only does video playback; no sound right now. |
||||
|
||||
The video decoder is not 100% correct yet. You will likely notice a few |
||||
artifacts which need to be ironed out. |
||||
|
||||
Many of the video rendering modes could be optimized slightly by copying |
||||
pairs of pixels as 32-bit units. This should work on any mode except motion |
||||
compensated blocks; the latter could experience alignment issues which |
||||
the DC's SH-4 can't handle. |
||||
|
||||
The library is a tad slow. Profiling indicates that the main bottleneck |
||||
is loading data from disc; the video decoder itself is pretty fast. The |
||||
player might benefit by moving data loading (I/O-bound operation) into a |
||||
separate thread. For that matter, the phase which sends the decoded |
||||
texture to the graphics hardware via DMA and renders it should also be |
||||
in a separate thread. |
||||
|
||||
The player is just a proof of concept at this point. It doesn't try to |
||||
render frames with proper timing-- it just plays them as fast as possible |
||||
(which often isn't very fast, mostly due to the I/O bottleneck). |
||||
|
||||
If the RoQ video is taller than it is wide, expect some odd rendering. |
||||
|
||||
The API between the library and the client app leaves a bit to be desired. |
||||
Notably absent is some proper initialization and teardown mechanism. |
||||
Currently, the first call to the render callback initializes the PVR buffers |
||||
but they are never explicitly freed. |
||||
|
||||
|
@ -1,152 +1,193 @@ |
||||
/*
|
||||
* Dreamroq by Mike Melanson |
||||
* |
||||
* This is the sample Dreamcast player app, designed to be run under |
||||
* the KallistiOS operating system. |
||||
*/ |
||||
|
||||
#include <kos.h> |
||||
|
||||
#include "dreamroqlib.h" |
||||
|
||||
static pvr_ptr_t textures[2]; |
||||
static int current_frame = 0; |
||||
|
||||
static int render_cb(void *buf_ptr, int width, int height, int stride, |
||||
int texture_height, int colorspace) |
||||
{ |
||||
pvr_poly_cxt_t cxt; |
||||
static pvr_poly_hdr_t hdr[2]; |
||||
static pvr_vertex_t vert[4]; |
||||
unsigned short *buf = (unsigned short*)buf_ptr; |
||||
|
||||
float ratio; |
||||
/* screen coordinates of upper left and bottom right corners */ |
||||
static int ul_x, ul_y, br_x, br_y; |
||||
static int graphics_initialized = 0; |
||||
|
||||
if (colorspace != ROQ_RGB565) |
||||
return ROQ_RENDER_PROBLEM; |
||||
|
||||
/* on first call, initialize textures and drawing coordinates */ |
||||
if (!graphics_initialized) |
||||
{ |
||||
textures[0] = pvr_mem_malloc(stride * texture_height * 2); |
||||
textures[1] = pvr_mem_malloc(stride * texture_height * 2); |
||||
if (!textures[0] || !textures[1]) |
||||
{ |
||||
return ROQ_RENDER_PROBLEM; |
||||
} |
||||
|
||||
/* Precompile the poly headers */ |
||||
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED, stride, texture_height, textures[0], PVR_FILTER_NONE); |
||||
pvr_poly_compile(&hdr[0], &cxt); |
||||
pvr_poly_cxt_txr(&cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED, stride, texture_height, textures[1], PVR_FILTER_NONE); |
||||
pvr_poly_compile(&hdr[1], &cxt); |
||||
|
||||
/* this only works if width ratio <= height ratio */ |
||||
ratio = 640.0 / width; |
||||
ul_x = 0; |
||||
br_x = (ratio * stride); |
||||
ul_y = ((480 - ratio * height) / 2); |
||||
br_y = ul_y + ratio * texture_height; |
||||
|
||||
/* Things common to vertices */ |
||||
vert[0].z = vert[1].z = vert[2].z = vert[3].z = 1.0f; |
||||
vert[0].argb = vert[1].argb = vert[2].argb = vert[3].argb = PVR_PACK_COLOR(1.0f, 1.0f, 1.0f, 1.0f); |
||||
vert[0].oargb = vert[1].oargb = vert[2].oargb = vert[3].oargb = 0; |
||||
vert[0].flags = vert[1].flags = vert[2].flags = PVR_CMD_VERTEX; |
||||
vert[3].flags = PVR_CMD_VERTEX_EOL; |
||||
|
||||
vert[0].x = ul_x; |
||||
vert[0].y = ul_y; |
||||
vert[0].u = 0.0; |
||||
vert[0].v = 0.0; |
||||
|
||||
vert[1].x = br_x; |
||||
vert[1].y = ul_y; |
||||
vert[1].u = 1.0; |
||||
vert[1].v = 0.0; |
||||
|
||||
vert[2].x = ul_x; |
||||
vert[2].y = br_y; |
||||
vert[2].u = 0.0; |
||||
vert[2].v = 1.0; |
||||
|
||||
vert[3].x = br_x; |
||||
vert[3].y = br_y; |
||||
vert[3].u = 1.0; |
||||
vert[3].v = 1.0; |
||||
|
||||
graphics_initialized = 1; |
||||
} |
||||
|
||||
/* send the video frame as a texture over to video RAM */ |
||||
pvr_txr_load(buf, textures[current_frame], stride * texture_height * 2); |
||||
|
||||
pvr_wait_ready(); |
||||
pvr_scene_begin(); |
||||
pvr_list_begin(PVR_LIST_OP_POLY); |
||||
|
||||
pvr_prim(&hdr[current_frame], sizeof(pvr_poly_hdr_t)); |
||||
pvr_prim(&vert[0], sizeof(pvr_vertex_t)); |
||||
pvr_prim(&vert[1], sizeof(pvr_vertex_t)); |
||||
pvr_prim(&vert[2], sizeof(pvr_vertex_t)); |
||||
pvr_prim(&vert[3], sizeof(pvr_vertex_t)); |
||||
|
||||
pvr_list_finish(); |
||||
pvr_scene_finish(); |
||||
|
||||
if (current_frame) |
||||
current_frame = 0; |
||||
else |
||||
current_frame = 1; |
||||
|
||||
return ROQ_SUCCESS; |
||||
} |
||||
|
||||
int audio_cb(unsigned char *buf_rgb565, int samples, int channels) |
||||
{ |
||||
return ROQ_SUCCESS; |
||||
} |
||||
|
||||
static int quit_cb() |
||||
{ |
||||
maple_device_t *cont; //Controller
|
||||
cont_state_t *state; //State of inputs
|
||||
/* check controller state */ |
||||
state = maple_dev_status(cont); |
||||
|
||||
// If the state/controller is unavailable
|
||||
if(!state) { |
||||
printf("Error reading controller\n"); |
||||
return(0); |
||||
} |
||||
|
||||
state->buttons = ~state->buttons; |
||||
return (state->buttons & CONT_START); |
||||
} |
||||
|
||||
int finish_cb() |
||||
{ |
||||
return ROQ_SUCCESS; |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
int status; |
||||
roq_callbacks_t cbs; |
||||
|
||||
cbs.render_cb = render_cb; |
||||
cbs.audio_cb = audio_cb; |
||||
cbs.quit_cb = quit_cb; |
||||
cbs.finish_cb = finish_cb; |
||||
|
||||
vid_set_mode(DM_640x480_NTSC_IL, PM_RGB565); |
||||
pvr_init_defaults(); |
||||
|
||||
status = dreamroq_play("/cd/cube_v1.roq", ROQ_RGB565, 1, &cbs); |
||||
printf("dreamroq_play() status = %d\n", status); |
||||
|
||||
return 0; |
||||
} |
||||
/*
|
||||
* Dreamroq by Mike Melanson |
||||
* Updated by Josh Pearson to add audio support |
||||
* |
||||
* This is the sample Dreamcast player app, designed to be run under |
||||
* the KallistiOS operating system. |
||||
*/ |
||||
|
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#include <string.h> |
||||
|
||||
#include <dc/maple.h> |
||||
#include <dc/maple/controller.h> |
||||
#include <kos/mutex.h> |
||||
#include <kos/thread.h> |
||||
|
||||
#include "dreamroqlib.h" |
||||
|
||||
#include "pvr_driver.h" |
||||
#include "snddrv.h" |
||||
|
||||
/* Audio Global variables */ |
||||
#define PCM_BUF_SIZE 1024*1024 |
||||
static unsigned char *pcm_buf = NULL; |
||||
static int pcm_size = 0; |
||||
static int audio_init = 0; |
||||
static mutex_t * pcm_mut; |
||||
static long samples_done = 0; |
||||
|
||||
/* Video Global variables */ |
||||
static int graphics_initialized = 0; |
||||
static int frame=0; |
||||
static kthread_t * render_thread; /* Video thread */ |
||||
static volatile int render_thd = 0; /* Video thread status */ |
||||
static const float VIDEO_RATE = 30.0f; /* Video FPS */ |
||||
|
||||
/* PVR Driver Handle */ |
||||
static struct pvr_frame roq_vram_ptr; |
||||
static struct pvr_frame_vertex roq_vram_vertex; |
||||
|
||||
static float ATS = 0, VTS = 0; /* A/V Timestamps For Synchronization */ |
||||
|
||||
/* This is called by the AICA Sound Driver when it needs more samples */ |
||||
void *audio_drv_cb ( snd_stream_hnd_t hnd, int pcm_needed, int * pcm_done ) |
||||
{ |
||||
/* Wait for RoQ Decoder to produce enough samples */ |
||||
while( pcm_size < pcm_needed ) |
||||
thd_pass(); |
||||
|
||||
/* Copy the Requested PCM Samples to the AICA Driver */ |
||||
mutex_lock( pcm_mut ); |
||||
memcpy( snddrv.pcm_buffer, pcm_buf, pcm_needed ); |
||||
pcm_size -= pcm_needed; |
||||
memmove( pcm_buf, pcm_buf+pcm_needed, pcm_size ); |
||||
mutex_unlock( pcm_mut ); |
||||
|
||||
samples_done += pcm_needed; /* Record the Audio Time Stamp */ |
||||
ATS = (samples_done/(double)snddrv.rate)/((double)snddrv.channels*2.0); |
||||
|
||||
snddrv.pcm_ptr = snddrv.pcm_buffer; |
||||
*pcm_done = pcm_needed; |
||||
|
||||
return snddrv.pcm_ptr; /* Return the requested samples to the AICA driver */ |
||||
} |
||||
|
||||
static int audio_cb( unsigned char *buf, int size, int channels) |
||||
{ |
||||
if(!audio_init) |
||||
{ |
||||
/* allocate PCM buffer */ |
||||
pcm_buf = malloc(PCM_BUF_SIZE); |
||||
if( pcm_buf == NULL ) |
||||
return ROQ_NO_MEMORY; |
||||
|
||||
/* Start AICA Driver */ |
||||
snddrv_start_cb( 22050, channels, audio_drv_cb ); |
||||
snddrv.dec_status = SNDDEC_STATUS_STREAMING; |
||||
|
||||
/* Create a mutex to handle the double-threaded buffer */ |
||||
mutex_init(pcm_mut, MUTEX_TYPE_NORMAL); |
||||
|
||||
|
||||
audio_init=1; |
||||
} |
||||
|
||||
/* Copy the decoded PCM samples to our local PCM buffer */ |
||||
mutex_lock( pcm_mut ); |
||||
memcpy(pcm_buf+pcm_size, buf, size); |
||||
pcm_size += size; |
||||
mutex_unlock( pcm_mut ); |
||||
|
||||
return ROQ_SUCCESS; |
||||
} |
||||
|
||||
static void *video_thd(void *ptr) |
||||
{ |
||||
render_thd=1; /* Signal Thread is active */ |
||||
|
||||
/* Match the Auido and Video Time Stamps */ |
||||
VTS = ++frame / VIDEO_RATE; |
||||
while( ATS < VTS ) thd_pass(); |
||||
|
||||
/* Draw the frame using the PVR */ |
||||
pvr_draw_frame_dma(&roq_vram_ptr); |
||||
printf("Rendered Frame %u\n", frame); |
||||
render_thd=0; /* Signal Thread is finished */ |
||||
} |
||||
|
||||
static int render_cb(unsigned short *buf, int width, int height, int stride, |
||||
int texture_height) |
||||
{ |
||||
/* on first call, initialize textures and drawing coordinates */ |
||||
if (!graphics_initialized) |
||||
{ |
||||
/* Allocate VRAM for current texture */ |
||||
pvr_malloc( &roq_vram_ptr, width, height ); |
||||
|
||||
/* Compile the PVR Driver Handle */ |
||||
//pvr_resize_resolution( roq_vram_ptr, &roq_vram_vertex );
|
||||
pvr_set_resolution( roq_vram_ptr, 0, 0, 640, 480, &roq_vram_vertex ); |
||||
pvr_compile_poly(roq_vram_vertex, &roq_vram_ptr, |
||||
PVR_LIST_OP_POLY, PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED, 10.0f); |
||||
|
||||
graphics_initialized = 1; |
||||
} |
||||
|
||||
/* Wait for last frame to finish render */ |
||||
while(render_thd) |
||||
thd_pass(); |
||||
|
||||
/* Current decoded frame */ |
||||
pvr_dma_load( (unsigned char *)buf, &roq_vram_ptr); |
||||
|
||||
/* Create a thread to render the current frame */ |
||||
//Try 1 onr 0 for first arg
|
||||
render_thread = thd_create(0, video_thd, NULL); |
||||
|
||||
return ROQ_SUCCESS; |
||||
} |
||||
|
||||
maple_device_t *cont; //Controller
|
||||
cont_state_t *state; //State of inputs
|
||||
static int quit_cb() |
||||
{ |
||||
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); |
||||
/* check controller state */ |
||||
state = maple_dev_status(cont); |
||||
|
||||
// If the state/controller is unavailable
|
||||
if(!state) { |
||||
printf("Error reading controller\n"); |
||||
return(0); |
||||
} |
||||
|
||||
state->buttons = ~state->buttons; |
||||
return (state->buttons & CONT_START); |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
int status=0; |
||||
|
||||
vid_set_mode(DM_640x480, PM_RGB565); |
||||
pvr_init_defaults(); |
||||
pvr_dma_init(); |
||||
|
||||
printf("dreamroq_play(C) Multimedia Mike Melanson & Josh PH3NOM Pearson 2011\n"); |
||||
|
||||
/* To disable a callback, simply replace the function name by 0 */ |
||||
status = dreamroq_play("/cd/sample.roq", 1, render_cb, 0, 0); |
||||
|
||||
printf("dreamroq_play() status = %d\n", status); |
||||
|
||||
if(audio_init) |
||||
{ |
||||
free( pcm_buf ); |
||||
pcm_buf = NULL; |
||||
pcm_size = 0; |
||||
samples_done = 0; |
||||
mutex_destroy(pcm_mut); /* Destroy the PCM mutex */ |
||||
snddrv_exit(); /* Exit the AICA Driver */ |
||||
} |
||||
|
||||
if(graphics_initialized) |
||||
{ |
||||
pvr_free( &roq_vram_ptr ); /* Free the PVR memory */ |
||||
} |
||||
|
||||
pvr_dma_shutdown(); |
||||
|
||||
return 0; |
||||
} |
||||
|
Binary file not shown.