diff --git a/desmume/ChangeLog b/desmume/ChangeLog index 5fc72ea33..1fe3b459b 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -28,6 +28,7 @@ - Add RTC implementations (not fully) [CrazyMax] - Rewrite VRAM mapping control and render (old save states broken) [CrazyMax] - Add a GUI hud system; start adding some HUD elements + - Add functions for a lid open/close. Holding key (default "Backspace" in Windows port) while game is freeze/non freeze. [CrazyMax] Mac OS X port: - Fixed: Filenames and paths with unicode characters now work. [Jeff] - Fixed: Load state from file button works again. [Jeff] diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 6e7b51851..1bfb977c1 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -33,10 +33,15 @@ #include "ROMReader.h" #include "gfx3d.h" +#include "debug.h" + #ifdef _WIN32 #include "./windows/disView.h" #endif +static BOOL LidClosed = FALSE; +static u8 LidKeyCount = 0; + /* the count of bytes copied from the firmware into memory */ #define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70 @@ -489,6 +494,9 @@ void NDS_Reset( void) MMU_write16(1, 0x04000130, 0x3FF); MMU_write8(1, 0x04000136, 0x43); + LidClosed = FALSE; + LidKeyCount = 0; + /* * Setup a copy of the firmware user settings in memory. * (this is what the DS firmware would do). @@ -1590,7 +1598,7 @@ u32 NDS_exec(s32 nb) } } - if(MMU.reg_IE[0]&(1<<21)) + if(MMU.reg_IE[ARMCPU_ARM9]&(1<<21)) NDS_makeARM9Int(21); // GX geometry if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0])) @@ -1641,12 +1649,13 @@ void NDS_setPadFromMovie(u16 pad) FIX(pad,9), FIX(pad,10), FIX(pad,11), - FIX(pad,12) + FIX(pad,12), + FIX(pad,13) ); #undef FIX } -void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G) +void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F) { //this macro is the opposite of what you would expect @@ -1665,6 +1674,7 @@ void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,b int w = FIX(W); int e = FIX(E); int g = FIX(G); + int f = FIX(F); u16 pad = (0 | ((a) >> 7) | @@ -1681,17 +1691,31 @@ void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,b ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] = (u16)pad; ((u16 *)MMU.ARM7_REG)[0x130>>1] = (u16)pad; - u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x00F0) | + u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x0070) | ((x) >> 7) | ((y) >> 6) | ((g) >> 4) | 0x0034; + + // todo: mute sound when Lided close + if (!f) + { + LidKeyCount++; + if (LidKeyCount > 50) + { + LidKeyCount = 0; + LidClosed = (!LidClosed) & 0x01; + if (!LidClosed) + NDS_makeARM7Int(22); + } + } else LidKeyCount = 0; + + if (LidClosed) padExt |= 1 << 7; ((u16 *)MMU.ARM7_REG)[0x136>>1] = (u16)padExt; - //put into the format we want for the movie system - //RLDUTSBAYXWEG + //RLDUTSBAYXWEGF #undef FIX #define FIX(b) (b?1:0) @@ -1708,6 +1732,7 @@ void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,b w = FIX(W); e = FIX(E); g = FIX(G); + f = FIX(F); nds.pad = @@ -1723,7 +1748,8 @@ void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,b (FIX(x)<<9)| (FIX(w)<<10)| (FIX(e)<<11)| - (FIX(g)<<12); + (FIX(g)<<12)| + (FIX(f)<<13); // TODO: low power IRQ } diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 217486496..f12175f83 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -189,7 +189,7 @@ NDS_header * NDS_getROMHeader(void); void NDS_setTouchPos(u16 x, u16 y); void NDS_releaseTouch(void); -void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G); +void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F); void NDS_setPadFromMovie(u16 pad); int NDS_LoadROM(const char *filename, int bmtype, u32 bmsize, diff --git a/desmume/src/windows/inputdx.cpp b/desmume/src/windows/inputdx.cpp index 0fe73a9a9..3166d9772 100644 --- a/desmume/src/windows/inputdx.cpp +++ b/desmume/src/windows/inputdx.cpp @@ -188,6 +188,8 @@ const char *DIJoyNames[0x04] = { "JUp", "JDown", "JLeft", "JRight" }; #define KEY_X 10 #define KEY_Y 11 #define KEY_DEBUG 12 +#define KEY_FOLD 13 +#define KEY_POWER 14 char *keyPadNames [MAXKEYPAD] = { "A", "B", "SELECT", "START", @@ -415,8 +417,9 @@ void NDS_inputPost(BOOL paused, LPSTR buf) bool W = (buf[keyPad[KEY_L]] & 0x80)!=0; bool E = (buf[keyPad[KEY_R]] & 0x80)!=0; bool G = (buf[keyPad[KEY_DEBUG]] & 0x80)!=0; + bool F = (buf[keyPad[KEY_FOLD]] & 0x80)!=0; - NDS_setPad( R, L, D, U, T, S, B, A, Y, X, W, E, G); + NDS_setPad( R, L, D, U, T, S, B, A, Y, X, W, E, G, F); } // TODO diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index f2dccb8d3..7cac1fd72 100644 --- a/desmume/src/windows/resources.rc +++ b/desmume/src/windows/resources.rc @@ -1267,7 +1267,7 @@ BEGIN EDITTEXT IDC_EDIT10,268,7,50,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_EDIT11,248,30,34,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_EDIT12,285,30,30,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY - EDITTEXT IDC_EDIT13,7,127,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + EDITTEXT IDC_EDIT13,7,127,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_EDIT14,95,127,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED EDITTEXT IDC_EDIT15,28,30,34,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED PUSHBUTTON "OK",IDOK,205,127,50,14 @@ -1287,7 +1287,7 @@ BEGIN LTEXT "L",IDC_STATIC,60,10,8,8 LTEXT "right",IDC_STATIC,63,73,16,8 LTEXT "power",IDC_STATIC,36,46,21,8,WS_DISABLED - LTEXT "open/close fold",IDC_STATIC,36,129,50,8,WS_DISABLED + LTEXT "open/close lid",IDC_STATIC,36,129,44,8 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,95,41,141,77 LTEXT "debug",IDC_STATIC,123,129,21,8,WS_DISABLED END