aboutsummaryrefslogtreecommitdiff
path: root/source/nds
diff options
context:
space:
mode:
Diffstat (limited to 'source/nds')
-rw-r--r--source/nds/displaymodes.cpp4
-rw-r--r--source/nds/entry.cpp50
-rw-r--r--source/nds/gui.c57
-rw-r--r--source/nds/gui.h3
-rw-r--r--source/nds/message.h4
5 files changed, 86 insertions, 32 deletions
diff --git a/source/nds/displaymodes.cpp b/source/nds/displaymodes.cpp
index c45f7c1..ead3c93 100644
--- a/source/nds/displaymodes.cpp
+++ b/source/nds/displaymodes.cpp
@@ -56,10 +56,10 @@ static uint16 SevenToSixScanlineResize (uint16 TopColour, uint16 BottomColour, u
;
}
-void NDSSFCDrawFrameAntialiased ()
+void NDSSFCDrawFrameAntialiased (void* screen_addr)
{
uint16 X, Y;
- uint16 *SrcTop = (uint16 *) GFX.Screen, *SrcBottom = SrcTop + 256, *Dest = (uint16 *) up_screen_addr;
+ uint16 *SrcTop = (uint16 *) GFX.Screen, *SrcBottom = SrcTop + 256, *Dest = (uint16 *) screen_addr;
for (Y = 0; Y < 224; Y += 7)
{
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp
index 456f078..1270d01 100644
--- a/source/nds/entry.cpp
+++ b/source/nds/entry.cpp
@@ -140,22 +140,29 @@ bool8 S9xInitUpdate ()
}
-extern void NDSSFCDrawFrameAntialiased();
+extern void NDSSFCDrawFrameAntialiased(void* screen_addr);
bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
{
+ void* screen_addr = emu_config.BottomScreenGame
+ ? down_screen_addr
+ : up_screen_addr;
+ SCREEN_ID screen_num = emu_config.BottomScreenGame
+ ? DOWN_SCREEN
+ : UP_SCREEN;
+
switch(game_config.graphic)
{
//Up
case 1:
#ifdef DS2_DMA
__dcache_writeback_all();
- ds2_DMAcopy_32Byte(1 /* channel: graphics */, up_screen_addr, GFX.Screen + 256 * 32 * 2, 256 * 192 * 2);
+ ds2_DMAcopy_32Byte(1 /* channel: graphics */, screen_addr, GFX.Screen + 256 * 32 * 2, 256 * 192 * 2);
ds2_DMA_wait(1);
ds2_DMA_stop(1);
#else
- memcpy(up_screen_addr, GFX.Screen+256*32*2, 256*192*2);
+ memcpy(screen_addr, GFX.Screen+256*32*2, 256*192*2);
#endif
break;
@@ -163,11 +170,11 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
case 2:
#ifdef DS2_DMA
__dcache_writeback_all();
- ds2_DMAcopy_32Byte(1 /* channel: graphics */, up_screen_addr, GFX.Screen, 256 * 192 * 2);
+ ds2_DMAcopy_32Byte(1 /* channel: graphics */, screen_addr, GFX.Screen, 256 * 192 * 2);
ds2_DMA_wait(1);
ds2_DMA_stop(1);
#else
- memcpy(up_screen_addr, GFX.Screen, 256*192*2);
+ memcpy(screen_addr, GFX.Screen, 256*192*2);
#endif
break;
@@ -175,16 +182,16 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
case 3:
#ifdef DS2_DMA
__dcache_writeback_all();
- ds2_DMAcopy_32Byte(1 /* channel: graphics */, up_screen_addr, GFX.Screen + 256 * 16 * 2, 256 * 192 * 2);
+ ds2_DMAcopy_32Byte(1 /* channel: graphics */, screen_addr, GFX.Screen + 256 * 16 * 2, 256 * 192 * 2);
ds2_DMA_wait(1);
ds2_DMA_stop(1);
#else
- memcpy(up_screen_addr, GFX.Screen+256*16*2, 256*192*2);
+ memcpy(screen_addr, GFX.Screen+256*16*2, 256*192*2);
#endif
break;
case 4:
- NDSSFCDrawFrameAntialiased ();
+ NDSSFCDrawFrameAntialiased (screen_addr);
break;
@@ -197,7 +204,7 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
register unsigned int m;
src = GFX.Screen;
- dst = (unsigned char*)up_screen_addr;
+ dst = (unsigned char*)screen_addr;
for(m = 0; m < 32; m++)
{
#ifdef DS2_DMA
@@ -214,7 +221,7 @@ bool8 S9xDeinitUpdate (int Width, int Height, bool8 /*sixteen_bit*/)
break;
}
- ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
+ ds2_flipScreen(screen_num, UP_SCREEN_UPDATE_METHOD);
// A problem with update method 1 (wait, double buffer) means that, after
// about 15 minutes of play time, the screen starts to half-redraw every
// frame. With update method 0, this is mitigated. (Method 2 is too slow.)
@@ -648,7 +655,19 @@ int sfc_main (int argc, char **argv)
S9xSetSoundMute (TRUE);
unsigned short screen[256*192];
- copy_screen((void*)screen, up_screen_addr, 0, 0, 256, 192);
+ if (FirstInvocation) {
+ memset(screen, 0, sizeof(screen));
+ }
+ else {
+ S9xDeinitUpdate(256, 224, TRUE);
+
+ void* screen_addr = emu_config.BottomScreenGame
+ ? down_screen_addr
+ : up_screen_addr;
+
+ copy_screen((void*)screen, screen_addr, 0, 0, 256, 192);
+ }
+
menu(screen, FirstInvocation);
FirstInvocation = FALSE;
game_disableAudio();
@@ -1262,10 +1281,13 @@ uint32 S9xReadJoypad (int which1)
mdelay(1);
} while (inputdata.key & KEY_LID);
ds2_wakeup();
- // Before starting to emulate again, turn off the lower
- // screen's backlight.
+ // Before starting to emulate again, turn on only the
+ // game screen's backlight.
+ SCREEN_ID screen_num = emu_config.BottomScreenGame
+ ? DOWN_SCREEN
+ : UP_SCREEN;
mdelay(100); // needed to avoid ds2_setBacklight crashing
- ds2_setBacklight(2);
+ ds2_setBacklight(3 - screen_num);
GameFrequencyCPU();
}
diff --git a/source/nds/gui.c b/source/nds/gui.c
index ca5a016..4b9c129 100644
--- a/source/nds/gui.c
+++ b/source/nds/gui.c
@@ -2728,6 +2728,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation)
char *sound_seletion[] = { (char*)&msg[MSG_AUDIO_MUTED], (char*)&msg[MSG_AUDIO_ENABLED] };
+ char *game_screen_options[] = { (char*)&msg[MSG_VIDEO_GAME_SCREEN_TOP], (char*)&msg[MSG_VIDEO_GAME_SCREEN_BOTTOM] };
+
+
// char *snap_frame_options[] = { (char*)&msg[MSG_SNAP_FRAME_0], (char*)&msg[MSG_SNAP_FRAME_1] };
// char *enable_disable_options[] = { (char*)&msg[MSG_EN_DIS_ABLE_0], (char*)&msg[MSG_EN_DIS_ABLE_1] };
@@ -2755,7 +2758,11 @@ u32 menu(u16 *screen, bool8 FirstInvocation)
&game_config.frameskip_value, 12 /* auto (0) and 0..10 (1..11) make 12 option values */, NULL, ACTION_TYPE, 5),
/* 06 */ STRING_SELECTION_OPTION(game_set_retro, NULL, &msg[FMT_AUDIO_RETRO_SOUND], on_off_options,
- &game_config.RetroSound, 2, NULL, ACTION_TYPE, 6)
+ &game_config.RetroSound, 2, NULL, ACTION_TYPE, 6),
+
+ /* 07 */ STRING_SELECTION_OPTION(NULL, NULL, &msg[FMT_VIDEO_GAME_SCREEN], game_screen_options,
+ &emu_config.BottomScreenGame, 2, NULL, PASSIVE_TYPE, 7)
+
};
MAKE_MENU(graphics, NULL, NULL, NULL, NULL, 1, 1);
@@ -3569,12 +3576,9 @@ u32 menu(u16 *screen, bool8 FirstInvocation)
}
else
{
- /*
- * It's pretty complicated. These two flips are needed because,
- * otherwise, the menu freezes if S9xAutoSaveSRAM was called after
- * loading from a save state.
- */
+ copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192);
ds2_flipScreen(UP_SCREEN, 1);
+ copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192);
ds2_flipScreen(UP_SCREEN, 1);
}
@@ -4022,14 +4026,31 @@ u32 menu(u16 *screen, bool8 FirstInvocation)
if(bg_screenp != NULL) free((void*)bg_screenp);
- ds2_clearScreen(DOWN_SCREEN, 0);
- ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
- copy_screen(up_screen_addr, (void*) screen, 0, 0, 256, 192);
- ds2_flipScreen(UP_SCREEN, UP_SCREEN_UPDATE_METHOD);
+ void* screen_addr;
+ SCREEN_ID screen_num;
+ if (emu_config.BottomScreenGame)
+ {
+ screen_addr = down_screen_addr;
+ screen_num = DOWN_SCREEN;
+ ds2_clearScreen(UP_SCREEN, 0);
+ ds2_flipScreen(UP_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
+ }
+ else
+ {
+ screen_addr = up_screen_addr;
+ screen_num = UP_SCREEN;
+ ds2_clearScreen(DOWN_SCREEN, 0);
+ ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
+ }
+
+ copy_screen(screen_addr, (void*) screen, 0, 0, 256, 192);
+ ds2_flipScreen(screen_num, UP_SCREEN_UPDATE_METHOD);
+ copy_screen(screen_addr, (void*) screen, 0, 0, 256, 192);
+ ds2_flipScreen(screen_num, UP_SCREEN_UPDATE_METHOD);
wait_Allkey_release(0);
mdelay(100); // to prevent ds2_setBacklight() from crashing
- ds2_setBacklight(2);
+ ds2_setBacklight(3 - screen_num);
GameFrequencyCPU();
@@ -4623,9 +4644,12 @@ void QuickLoadState (void)
{
char BaseName[MAX_PATH + 1];
get_savestate_filename(0, BaseName);
+ SCREEN_ID screen_num = emu_config.BottomScreenGame
+ ? DOWN_SCREEN
+ : UP_SCREEN;
mdelay(100); // needed to avoid ds2_setBacklight crashing
- ds2_setBacklight(3);
+ ds2_setBacklight((3 - DOWN_SCREEN) | (3 - screen_num));
ds2_clearScreen(DOWN_SCREEN, RGB15(0, 0, 0));
draw_message(down_screen_addr, NULL, 28, 31, 227, 165, 0);
@@ -4647,16 +4671,19 @@ void QuickLoadState (void)
ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(100); // needed to avoid ds2_setBacklight crashing
- ds2_setBacklight(2);
+ ds2_setBacklight(3 - screen_num);
}
void QuickSaveState (void)
{
char BaseName[MAX_PATH + 1];
get_savestate_filename(0, BaseName);
+ SCREEN_ID screen_num = emu_config.BottomScreenGame
+ ? DOWN_SCREEN
+ : UP_SCREEN;
mdelay(100); // needed to avoid ds2_setBacklight crashing
- ds2_setBacklight(3);
+ ds2_setBacklight((3 - DOWN_SCREEN) | (3 - screen_num));
ds2_clearScreen(DOWN_SCREEN, RGB15(0, 0, 0));
draw_message(down_screen_addr, NULL, 28, 31, 227, 165, 0);
@@ -4680,7 +4707,7 @@ void QuickSaveState (void)
ds2_flipScreen(DOWN_SCREEN, DOWN_SCREEN_UPDATE_METHOD);
mdelay(100); // needed to avoid ds2_setBacklight crashing
- ds2_setBacklight(2);
+ ds2_setBacklight(3 - screen_num);
}
void ToggleFullScreen (void)
diff --git a/source/nds/gui.h b/source/nds/gui.h
index 570afe6..980553b 100644
--- a/source/nds/gui.h
+++ b/source/nds/gui.h
@@ -86,7 +86,8 @@ struct _EMU_CONFIG
u32 HotkeyQuickLoadState;
u32 HotkeyQuickSaveState;
u32 HotkeyToggleFullScreen;
- u32 Reserved[58];
+ u32 BottomScreenGame;
+ u32 Reserved[57];
};
struct _GAME_CONFIG
diff --git a/source/nds/message.h b/source/nds/message.h
index 07799ec..98f64ab 100644
--- a/source/nds/message.h
+++ b/source/nds/message.h
@@ -37,6 +37,7 @@ enum MSG
FMT_VIDEO_ASPECT_RATIO,
FMT_VIDEO_FAST_FORWARD,
FMT_VIDEO_FRAME_SKIPPING,
+ FMT_VIDEO_GAME_SCREEN,
FMT_AUDIO_SOUND,
FMT_AUDIO_RETRO_SOUND,
FMT_SAVED_STATE_CREATE,
@@ -92,6 +93,9 @@ enum MSG
MSG_VIDEO_FRAME_SKIPPING_9,
MSG_VIDEO_FRAME_SKIPPING_10,
+ MSG_VIDEO_GAME_SCREEN_TOP,
+ MSG_VIDEO_GAME_SCREEN_BOTTOM,
+
MSG_GENERAL_OFF,
MSG_GENERAL_ON,