diff options
author | Nebuleon Fumika | 2013-01-07 03:26:53 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2013-01-07 03:28:22 -0500 |
commit | 8447b6304cf261f6219aa9fd4e04d99f6a76305a (patch) | |
tree | a5029a784244e14eb849913b5e04a8af2c3d9b96 | |
parent | 9bdda53d2e75c6b9e7baf83bcd2519bc2a8b49d8 (diff) | |
download | snesemu-8447b6304cf261f6219aa9fd4e04d99f6a76305a.tar.gz snesemu-8447b6304cf261f6219aa9fd4e04d99f6a76305a.tar.bz2 snesemu-8447b6304cf261f6219aa9fd4e04d99f6a76305a.zip |
Fix an off-by-one in the manual frameskip code. It would raise the sound speed by 25% if frame skip 3 (Show 1 in 4) rendered a frame early.
Optimise the controller code. I don't expect to allow remapping any time soon, because the DS has buttons for every single SNES controller button and nothing more.
-rw-r--r-- | source/nds/entry.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/nds/entry.cpp b/source/nds/entry.cpp index 58adf49..bff57b2 100644 --- a/source/nds/entry.cpp +++ b/source/nds/entry.cpp @@ -760,7 +760,7 @@ void S9xSyncSpeed () // After that little delay, what time is it? syncnow = getSysTime(); } - sync_next = syncnow + frame_time * Settings.SkipFrames; + sync_next = syncnow + frame_time * (Settings.SkipFrames + 1); } else { @@ -1049,7 +1049,7 @@ void Init_Timer (void) } - +/* const unsigned int keymap[12] = { 0x80, //KEY_A 0x8000, //KEY_B @@ -1064,6 +1064,7 @@ const unsigned int keymap[12] = { 0x40, //KEY_X 0x4000 //KEY_Y }; +*/ unsigned int S9xReadJoypad (int which1) { @@ -1077,6 +1078,7 @@ unsigned int S9xReadJoypad (int which1) ds2_setSupend(); do { ds2_getrawInput(&inputdata); + mdelay(1); } while (inputdata.key & KEY_LID); ds2_wakeup(); set_cpu_clock(clock_speed_number); @@ -1089,12 +1091,28 @@ unsigned int S9xReadJoypad (int which1) { unsigned int key; unsigned int i; - - key = 0; + + // DS -> SNES + key = (inputdata.key & KEY_A ) << 7; // 0x0001 -> 0x0080 + key |= (inputdata.key & KEY_B ) << 14; // 0x0002 -> 0x8000 + key |= (inputdata.key & KEY_SELECT) << 11; // 0x0004 -> 0x2000 + key |= (inputdata.key & KEY_START ) << 9; // 0x0008 -> 0x1000 + key |= (inputdata.key & KEY_UP ) << 5; // 0x0040 -> 0x0800 + // 0x0010 -> 0x0100; 0x0020 -> 0x0200 + // 0x0030 -> 0x0300 + key |= (inputdata.key & (KEY_RIGHT | KEY_LEFT)) << 4; + // 0x0100 -> 0x0010; 0x0200 -> 0x0020; 0x0400 -> 0x0040 + // 0x0700 -> 0x0070 + key |= (inputdata.key & (KEY_R | KEY_L | KEY_X)) >> 4; + // 0x0080 -> 0x0400; 0x0800 -> 0x4000 + // 0x0880 -> 0x4400 + key |= (inputdata.key & (KEY_DOWN | KEY_Y)) << 3; +/* for(i= 0; i < 12; i++) //remap key { key |= (inputdata.key & (1<<i)) ? keymap[i] : 0; } +*/ return (key | 0x80000000); } |