minor fixes to audio/video engines

This commit is contained in:
ekeeke31 2009-03-06 15:57:31 +00:00
parent 99e00b8fe3
commit 70eedd9505
2 changed files with 26 additions and 23 deletions

View File

@ -55,7 +55,7 @@ static u8 audioStarted;
In 60Hz modes, VSYNC period is longer than default DMA period so it requires different sync. In 60Hz modes, VSYNC period is longer than default DMA period so it requires different sync.
***/ ***/
static void AudioDmaCallback() static void AudioDmaCallback(void)
{ {
frameticker++; frameticker++;
} }
@ -81,7 +81,7 @@ void ogc_audio__init(void)
This function retrieves samples for the frame then set the next DMA parameters This function retrieves samples for the frame then set the next DMA parameters
Parameters will be taken in account only when current DMA operation is over Parameters will be taken in account only when current DMA operation is over
***/ ***/
void ogc_audio__update() void ogc_audio__update(void)
{ {
u32 size = dma_len; u32 size = dma_len;
@ -124,15 +124,19 @@ void ogc_audio__update()
void ogc_audio__start(void) void ogc_audio__start(void)
{ {
/* initialize default DMA length */ /* initialize default DMA length */
/* PAL (50Hz): 20000 us period --> 960 samples/frame at 48kHz */ /* PAL (50Hz): 20000 us period --> 960 samples/frame @48kHz */
/* NTSC (60Hz): 16667 us period --> 800 samples/frame at 48kHz */ /* NTSC (60Hz): 16667 us period --> 800 samples/frame @48kHz */
dma_len = vdp_pal ? 960 : 800; dma_len = vdp_pal ? 960 : 800;
dma_sync = 0; dma_sync = 0;
mixbuffer = 0; mixbuffer = 0;
delta = 0; delta = 0;
/* reset sound buffers */
memset(soundbuffer, 0, 2 * 3840);
/* default case: we use DMA interrupt to synchronize frame emulation */ /* default case: we use DMA interrupt to synchronize frame emulation */
if (vdp_pal | gc_pal) AUDIO_RegisterDMACallback (AudioDmaCallback); AUDIO_RegisterDMACallback(NULL);
if (vdp_pal | gc_pal) AUDIO_RegisterDMACallback(AudioDmaCallback);
/* 60hz video mode requires synchronization with Video interrupt */ /* 60hz video mode requires synchronization with Video interrupt */
/* VSYNC period is 16715 us which is approx. 802.32 samples */ /* VSYNC period is 16715 us which is approx. 802.32 samples */
@ -150,8 +154,6 @@ void ogc_audio__start(void)
***/ ***/
void ogc_audio__stop(void) void ogc_audio__stop(void)
{ {
AUDIO_RegisterDMACallback(NULL);
AUDIO_StopDMA (); AUDIO_StopDMA ();
memset(soundbuffer, 0, 2 * 3840);
audioStarted = 0; audioStarted = 0;
} }

View File

@ -402,6 +402,7 @@ static void gxResetView(GXRModeObj *tvmode)
GX_SetFieldMode(tvmode->field_rendering, ((tvmode->viHeight == 2 * tvmode->xfbHeight) ? GX_ENABLE : GX_DISABLE)); GX_SetFieldMode(tvmode->field_rendering, ((tvmode->viHeight == 2 * tvmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
guOrtho(p, tvmode->efbHeight/2, -(tvmode->efbHeight/2), -(tvmode->fbWidth/2), tvmode->fbWidth/2, 100, 1000); guOrtho(p, tvmode->efbHeight/2, -(tvmode->efbHeight/2), -(tvmode->fbWidth/2), tvmode->fbWidth/2, 100, 1000);
GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC); GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC);
GX_Flush();
} }
/* Reset GX/VI scaler */ /* Reset GX/VI scaler */
@ -532,7 +533,7 @@ void ogc_video__stop(void)
} }
/* Update Video settings */ /* Update Video settings */
void ogc_video__start() void ogc_video__start(void)
{ {
/* 50Hz/60Hz mode */ /* 50Hz/60Hz mode */
if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) gc_pal = 1; if ((config.tv_mode == 1) || ((config.tv_mode == 2) && vdp_pal)) gc_pal = 1;
@ -591,7 +592,7 @@ void ogc_video__start()
} }
/* GX render update */ /* GX render update */
void ogc_video__update() void ogc_video__update(void)
{ {
/* check if display has changed */ /* check if display has changed */
if (bitmap.viewport.changed) if (bitmap.viewport.changed)
@ -603,12 +604,12 @@ void ogc_video__update()
u32 vheight = bitmap.viewport.h + 2 * bitmap.viewport.y; u32 vheight = bitmap.viewport.h + 2 * bitmap.viewport.y;
/* special cases */ /* special cases */
if (config.render && interlaced) vheight *= 2; if (config.render && interlaced) vheight = vheight << 1;
if (config.ntsc) vwidth = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(vwidth) : SMS_NTSC_OUT_WIDTH(vwidth); if (config.ntsc) vwidth = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(vwidth) : SMS_NTSC_OUT_WIDTH(vwidth);
/* texels size must be multiple of 4 */ /* texels size must be multiple of 4 */
vwidth = (vwidth / 4) * 4; vwidth = (vwidth >> 2) << 2;
vheight = (vheight / 4) * 4; vheight = (vheight >> 2) << 2;
/* initialize texture object */ /* initialize texture object */
GXTexObj texobj; GXTexObj texobj;
@ -623,29 +624,28 @@ void ogc_video__update()
/* load texture object */ /* load texture object */
GX_LoadTexObj(&texobj, GX_TEXMAP0); GX_LoadTexObj(&texobj, GX_TEXMAP0);
/* select TV mode */ /* reset TV mode */
if (config.render) rmode = tvmodes[gc_pal*3 + 2]; if (config.render) rmode = tvmodes[gc_pal*3 + 2];
else rmode = tvmodes[gc_pal*3 + interlaced]; else rmode = tvmodes[gc_pal*3 + interlaced];
/* reset aspect ratio */ /* reset aspect ratio */
gxResetScale(vwidth,vheight); gxResetScale(vwidth,vheight);
/* reset GX */ /* reconfigure VI */
gxResetView(rmode);
/* configure VI */
VIDEO_Configure(rmode); VIDEO_Configure(rmode);
VIDEO_Flush(); VIDEO_Flush();
VIDEO_WaitVSync(); VIDEO_WaitVSync();
if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync(); if (rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
else while (VIDEO_GetNextField() != odd_frame) VIDEO_WaitVSync(); else while (VIDEO_GetNextField() != odd_frame) VIDEO_WaitVSync();
if (frameticker > 1) frameticker = 1; if (frameticker > 1) frameticker = 1;
/* reset GX */
gxResetView(rmode);
} }
/* texture is now directly mapped by the line renderer */ /* texture is now directly mapped by the line renderer */
/* update texture cache */ /* force texture cache update */
DCFlushRange(texturemem, TEX_SIZE); DCFlushRange(texturemem, TEX_SIZE);
GX_InvalidateTexAll(); GX_InvalidateTexAll();
@ -653,14 +653,15 @@ void ogc_video__update()
draw_square(); draw_square();
GX_DrawDone(); GX_DrawDone();
/* swap XFB */ /* swap XFB then copy EFB to XFB */
whichfb ^= 1; whichfb ^= 1;
GX_CopyDisp(xfb[whichfb], GX_TRUE);
GX_Flush();
/* set next XFB */
VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_SetNextFramebuffer(xfb[whichfb]);
VIDEO_Flush(); VIDEO_Flush();
/* copy EFB to XFB */
GX_CopyDisp(xfb[whichfb], GX_TRUE);
GX_Flush();
} }
/* Initialize VIDEO subsystem */ /* Initialize VIDEO subsystem */