diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 4c771a7ed..fe9666f0e 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -2038,8 +2038,9 @@ static void GPU_RenderLine_layer(NDS_Screen * screen, u16 l) switch(gpu->setFinalColorBck_funcNum) { //for backdrops, blend isnt applied (it's illogical, isnt it?) - case 0: - case 1: + case 0: + case 1: +PLAIN_CLEAR: memset_u16_le<256>(gpu->currDst,backdrop_color); break; @@ -2047,10 +2048,12 @@ static void GPU_RenderLine_layer(NDS_Screen * screen, u16 l) case 2: if(gpu->BLDCNT & 0x20) //backdrop is selected for color effect memset_u16_le<256>(gpu->currDst,gpu->currentFadeInColors[backdrop_color]); + else goto PLAIN_CLEAR; break; case 3: if(gpu->BLDCNT & 0x20) //backdrop is selected for color effect memset_u16_le<256>(gpu->currDst,gpu->currentFadeOutColors[backdrop_color]); + else goto PLAIN_CLEAR; break; //windowed cases apparently need special treatment? why? can we not render the backdrop? how would that even work? diff --git a/desmume/src/GPU_osd.cpp b/desmume/src/GPU_osd.cpp index ae47372d3..e3c99fda2 100644 --- a/desmume/src/GPU_osd.cpp +++ b/desmume/src/GPU_osd.cpp @@ -433,9 +433,10 @@ static void TouchDisplay() { aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert } - if(nds.isTouch) { - temptouch.X = nds.scr_touchX; - temptouch.Y = nds.scr_touchY; + if(nds.isTouch) + { + temptouch.X = nds.scr_touchX / 16; + temptouch.Y = nds.scr_touchY / 16; aggDraw.hud->lineColor(255, 0, 0, 128); aggDraw.hud->line(temptouch.X - 256, temptouch.Y + 192, temptouch.X + 256, temptouch.Y + 192); //horiz aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index db3a131fb..360376578 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -4029,8 +4029,11 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) if(nds.adc_jitterctr == 25) { nds.adc_jitterctr = 0; - nds.adc_touchY ^= 16; - nds.adc_touchX ^= 16; + if (nds.stylusJitter) + { + nds.adc_touchY ^= 16; + nds.adc_touchX ^= 16; + } } if(MMU.SPI_CNT&(1<<11)) { diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 28e27252e..e49221731 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2482,6 +2482,7 @@ void NDS_Reset() nds.ConsoleType = CommonSettings.ConsoleType; nds._DebugConsole = CommonSettings.DebugConsole; nds.ensataEmulation = CommonSettings.EnsataEmulation; + nds.stylusJitter = CommonSettings.StylusJitter; nds.ensataHandshake = ENSATA_HANDSHAKE_none; nds.ensataIpcSyncCounter = 0; SetupMMU(nds.Is_DebugConsole(),nds.Is_DSI()); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 9e1132eea..bc471898e 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -177,6 +177,7 @@ struct NDSSystem u16 adc_touchX; u16 adc_touchY; s32 adc_jitterctr; + BOOL stylusJitter; //the DSI returns calibrated touch coords from its TSC (?), so we need to save these separately u16 scr_touchX; @@ -507,6 +508,7 @@ extern struct TCommonSettings { , spu_advanced(false) , StylusPressure(50) , ConsoleType(NDS_CONSOLE_TYPE_FAT) + , StylusJitter(true) { strcpy(ARM9BIOS, "biosnds9.bin"); strcpy(ARM7BIOS, "biosnds7.bin"); @@ -553,6 +555,7 @@ extern struct TCommonSettings { bool rigorous_timing; int StylusPressure; + bool StylusJitter; bool dispLayers[2][5]; diff --git a/desmume/src/lua-engine.cpp b/desmume/src/lua-engine.cpp index c7d72be79..ee47480fe 100644 --- a/desmume/src/lua-engine.cpp +++ b/desmume/src/lua-engine.cpp @@ -1856,7 +1856,7 @@ DEFINE_LUA_FUNCTION(memory_readbyterange, "address,length") { if(IsHardwareAddressValid(a)) { - unsigned char value = (unsigned char)(_MMU_read08(address) & 0xFF); + unsigned char value = (unsigned char)(_MMU_read08(a) & 0xFF); lua_pushinteger(L, value); lua_rawseti(L, -2, n); } @@ -4421,7 +4421,8 @@ static int gui_osdtext(lua_State *L) return 0; } -static int stylus_read(lua_State *L){ +DEFINE_LUA_FUNCTION(stylus_read, "") +{ lua_newtable(L); @@ -4434,7 +4435,8 @@ static int stylus_read(lua_State *L){ return 1; } -static int stylus_peek(lua_State *L){ +DEFINE_LUA_FUNCTION(stylus_peek, "") +{ lua_newtable(L); @@ -4452,7 +4454,7 @@ static int toTouchValue(int pixCoord, int maximum) pixCoord = std::min(std::max(pixCoord, 0), maximum-1); return (pixCoord << 4) & 0x0FF0; } -static int stylus_write(lua_State *L) +DEFINE_LUA_FUNCTION(stylus_write, "table") { if(movieMode == MOVIEMODE_PLAY) // don't allow tampering with a playing movie's input return 0; // (although it might be useful sometimes...) diff --git a/desmume/src/windows/hotkey.cpp b/desmume/src/windows/hotkey.cpp index 1ab72c581..6445d1972 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/desmume/src/windows/hotkey.cpp @@ -450,6 +450,18 @@ void HK_DecreasePressure(int, bool justPressed) { if(CommonSettings.StylusPressure<0) CommonSettings.StylusPressure = 0; osd->addLine("Stylus Pressure to %d%%",CommonSettings.StylusPressure); } +void HK_ToggleStylusJitter(int, bool justPressed) { + CommonSettings.StylusJitter = !CommonSettings.StylusJitter; + nds.stylusJitter = CommonSettings.StylusJitter; + WritePrivateProfileBool("Emulation", "StylusJitter", CommonSettings.StylusJitter, IniName); + osd->addLine("Stylus Jitter %s",CommonSettings.StylusJitter ? "On" : "Off"); +} + +void HK_Rotate0(int, bool justPressed) { SetRotate(MainWindow->getHWnd(), 0);} +void HK_Rotate90(int, bool justPressed) { SetRotate(MainWindow->getHWnd(), 90);} +void HK_Rotate180(int, bool justPressed) { SetRotate(MainWindow->getHWnd(), 180);} +void HK_Rotate270(int, bool justPressed) { SetRotate(MainWindow->getHWnd(), 270);} + //====================================================================================== @@ -535,6 +547,12 @@ void InitCustomKeys (SCustomKeys *keys) keys->DecreaseSpeed.page = HOTKEY_PAGE_MAIN; keys->DecreaseSpeed.key = VK_OEM_MINUS; + keys->ToggleStylusJitter.handleKeyDown = HK_ToggleStylusJitter; + keys->ToggleStylusJitter.code = "ToggleStylusJitter"; + keys->ToggleStylusJitter.name = STRW(ID_LABEL_HK61); + keys->ToggleStylusJitter.page = HOTKEY_PAGE_MAIN; + keys->ToggleStylusJitter.key = NULL; + keys->FrameLimitToggle.handleKeyDown = HK_FrameLimitToggle; keys->FrameLimitToggle.code = "FrameLimitToggle"; keys->FrameLimitToggle.name = STRW(ID_LABEL_HK8b); @@ -808,6 +826,31 @@ void InitCustomKeys (SCustomKeys *keys) keys->ResetLagCounter.page = HOTKEY_PAGE_MOVIE; keys->ResetLagCounter.key = NULL; + //Other Page ------------------------------------------------------- + keys->Rotate0.handleKeyDown = HK_Rotate0; + keys->Rotate0.code = "Rotate0"; + keys->Rotate0.name = STRW(ID_LABEL_HK57); + keys->Rotate0.page = HOTKEY_PAGE_OTHER; + keys->Rotate0.key = NULL; + + keys->Rotate90.handleKeyDown = HK_Rotate90; + keys->Rotate90.code = "Rotate90"; + keys->Rotate90.name = STRW(ID_LABEL_HK58); + keys->Rotate90.page = HOTKEY_PAGE_OTHER; + keys->Rotate90.key = NULL; + + keys->Rotate180.handleKeyDown = HK_Rotate180; + keys->Rotate180.code = "Rotate180"; + keys->Rotate180.name = STRW(ID_LABEL_HK59); + keys->Rotate180.page = HOTKEY_PAGE_OTHER; + keys->Rotate180.key = NULL; + + keys->Rotate270.handleKeyDown = HK_Rotate270; + keys->Rotate270.code = "Rotate270"; + keys->Rotate270.name = STRW(ID_LABEL_HK60); + keys->Rotate270.page = HOTKEY_PAGE_OTHER; + keys->Rotate270.key = NULL; + //StateSlots Page -------------------------------------------------- keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot; keys->NextSaveSlot.code = "NextSaveSlot"; diff --git a/desmume/src/windows/hotkey.h b/desmume/src/windows/hotkey.h index f05f3659f..d3c844138 100644 --- a/desmume/src/windows/hotkey.h +++ b/desmume/src/windows/hotkey.h @@ -30,6 +30,7 @@ enum HotkeyPage { HOTKEY_PAGE_STATE, HOTKEY_PAGE_STATE_SLOTS, HOTKEY_PAGE_TURBO, + HOTKEY_PAGE_OTHER, NUM_HOTKEY_PAGE, }; @@ -39,6 +40,7 @@ static LPCTSTR hotkeyPageTitle[] = { _T("Savestates"), _T("Savestate Slots"), _T("Turbo"), + _T("Other"), _T("NUM_HOTKEY_PAGE"), }; @@ -65,7 +67,9 @@ struct SCustomKeys SCustomKey Slot[10]; SCustomKey QuickSave, QuickLoad, NextSaveSlot, PreviousSaveSlot; - SCustomKey OpenROM, ReloadROM, Reset, Pause, FrameAdvance, FastForward, FastForwardToggle, IncreaseSpeed, DecreaseSpeed, FrameLimitToggle, Microphone, IncreasePressure, DecreasePressure; + SCustomKey Rotate0, Rotate90, Rotate180, Rotate270; + + SCustomKey OpenROM, ReloadROM, Reset, Pause, FrameAdvance, FastForward, FastForwardToggle, IncreaseSpeed, DecreaseSpeed, FrameLimitToggle, Microphone, IncreasePressure, DecreasePressure, ToggleStylusJitter; SCustomKey PlayMovie, RecordMovie, StopMovie, ToggleReadOnly; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index ddfb00021..cce747d88 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -435,8 +435,6 @@ bool romloaded = false; void SetScreenGap(int gap); -void SetRotate(HWND hwnd, int rot, bool user=true); - bool ForceRatio = true; bool SeparationBorderDrag = true; int ScreenGapColor = 0xFFFFFF; diff --git a/desmume/src/windows/main.h b/desmume/src/windows/main.h index 781816b48..29b0d2de6 100644 --- a/desmume/src/windows/main.h +++ b/desmume/src/windows/main.h @@ -41,6 +41,7 @@ void WavRecordTo(int wavmode); void WavEnd(); void UpdateToolWindows(); bool DemandLua(); +void SetRotate(HWND hwnd, int rot, bool user = true); extern bool frameCounterDisplay; extern bool FpsDisplay; diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index f4e461bc2..0028c4d1c 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -800,6 +800,11 @@ #define ID_LABEL_HK54 4519 #define ID_LABEL_HK55 4520 #define ID_LABEL_HK56 4521 +#define ID_LABEL_HK57 4522 +#define ID_LABEL_HK58 4523 +#define ID_LABEL_HK59 4524 +#define ID_LABEL_HK60 4525 +#define ID_LABEL_HK61 4526 #define IDD_MICROPHONE 5000 #define IDM_MICROPHONESETTINGS 5001 #define IDC_MICSAMPLEBROWSE 5003 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index c7b601cd0..ca064e8df 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ diff --git a/desmume/src/windows/soundView.cpp b/desmume/src/windows/soundView.cpp index ab2f99661..bdadb9f6d 100644 --- a/desmume/src/windows/soundView.cpp +++ b/desmume/src/windows/soundView.cpp @@ -361,7 +361,7 @@ static INT_PTR CALLBACK SoundView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L if(data == NULL) { data = (SoundView_DataStruct*)lParam; - SetWindowLongPtr(hDlg, DWLP_USER, (LONG)data); + SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)data); } data->hDlg = hDlg;