Usa el Spinal's Movie Player para transformar los vídeos a
smf, y luego modifica la función
play_smf para que se abran dos vídeos en vez de uno, uno en cada pantalla.
#include <PA9.h>
#include <fat.h>
unsigned short screen_bitmap[49152];
void play_smf(char* filename)
{
PA_Init16bitBg(1, 3);
u32 audio_offset = 0;
u16 audio_pointer = 0;
u16 audio_size = 11500;
char* audio_buffer = (char*)malloc(sizeof(char) * audio_size * 4);
u8 video_height = 0;
u32 frame_count = 0;
u32 video_offset = 0;
u16 current_frame = 0;
u16 frame_size = 0;
char* frame_buffer = (char*)malloc(16000);
// use PAlib timers
StartTime(true);
u8 audio_timer = NewTimer(true);
u32 audio_begin = Tick(audio_timer);
u8 video_timer = NewTimer(true);
u32 video_begin = Tick(video_timer);
FILE* video_file;
video_file = fopen(filename, "rb");
// read the file header
fread(&video_height, 2, 1, video_file);
fread(&frame_count, 4, 1, video_file);
fread(&video_offset, 4, 1, video_file);
while(frame_count >= current_frame)
{
if((Tick(audio_timer) - audio_begin) >= 512)
{
audio_begin = Tick(audio_timer);
AS_SoundDefaultPlay(&audio_buffer[audio_pointer * audio_size], (u32)audio_size, 127, 64, 0, 0);
if(audio_pointer == 3) audio_pointer = 0;
else audio_pointer++;
audio_offset = (((1837 * (current_frame + 6) + 58)>>1)<<1);
fseek (video_file, audio_offset, SEEK_SET);
fread(&audio_buffer[audio_pointer * audio_size], 1, audio_size, video_file);
}
if((Tick(video_timer) - video_begin) >= 85) // 1024/12 = 85.3333333
{
video_begin = Tick(video_timer);
fseek(video_file, video_offset, SEEK_SET);
fread(&frame_size, 2, 1, video_file);
memset(frame_buffer, 0, 16000);
fread(frame_buffer, 1, frame_size, video_file);
video_offset += frame_size + 2;
memset(screen_bitmap, 0, 98304);
REG_IME = 0x00;
JPEG_DecompressImage((u8*)frame_buffer, &screen_bitmap[0], 256, 192);
DMA_Copy(screen_bitmap, (void*)PA_DrawBg[1], 256*192, DMA_16NOW)
REG_IME = 0x01;
current_frame++;
}
}
fclose (video_file);
}
int main(int argc, char ** argv)
{
PA_Init();
PA_InitASLibForSounds(AS_MODE_16CH);
AS_SetDefaultSettings(AS_PCM_16BIT, 11025, AS_SURROUND);
fatInitDefault();
play_smf("/data/excellent.smf");
while(1){}
return 0;
}
Espero que te/os sirva (a mí sí
).
PD:
Fuente