clean up touchscreen calibration code a little bit. this was all i did before deciding the entire firmware system needs rebooting after a release
This commit is contained in:
parent
cfc5ce2335
commit
170bc431f0
|
@ -75,8 +75,6 @@ int LagFrameFlag;
|
|||
int lastLag;
|
||||
int TotalLagFrames;
|
||||
|
||||
TSCalInfo TSCal;
|
||||
|
||||
namespace DLDI
|
||||
{
|
||||
bool tryPatch(void* data, size_t size);
|
||||
|
@ -128,20 +126,6 @@ int NDS_Init( void) {
|
|||
|
||||
WIFI_Init() ;
|
||||
|
||||
// Init calibration info
|
||||
TSCal.adc.x1 = 0x0200;
|
||||
TSCal.adc.y1 = 0x0200;
|
||||
TSCal.scr.x1 = 0x20 + 1; // calibration screen coords are 1-based,
|
||||
TSCal.scr.y1 = 0x20 + 1; // either that or NDS_getADCTouchPosX/Y are wrong.
|
||||
TSCal.adc.x2 = 0x0E00;
|
||||
TSCal.adc.y2 = 0x0800;
|
||||
TSCal.scr.x2 = 0xE0 + 1;
|
||||
TSCal.scr.y2 = 0x80 + 1;
|
||||
TSCal.adc.width = (TSCal.adc.x2 - TSCal.adc.x1);
|
||||
TSCal.adc.height = (TSCal.adc.y2 - TSCal.adc.y1);
|
||||
TSCal.scr.width = (TSCal.scr.x2 - TSCal.scr.x1);
|
||||
TSCal.scr.height = (TSCal.scr.y2 - TSCal.scr.y1);
|
||||
|
||||
cheats = new CHEATS();
|
||||
cheatSearch = new CHEATSEARCH();
|
||||
|
||||
|
@ -2441,22 +2425,6 @@ void NDS_Reset()
|
|||
_MMU_write08<ARMCPU_ARM9>(0x02FFFC40,0x1);
|
||||
_MMU_write08<ARMCPU_ARM7>(0x02FFFC40,0x1);
|
||||
|
||||
// Save touchscreen calibration info in a structure
|
||||
// so we can easily access it at any time
|
||||
TSCal.adc.x1 = _MMU_read16<ARMCPU_ARM7>(0x027FFC80 + 0x58);
|
||||
TSCal.adc.y1 = _MMU_read16<ARMCPU_ARM7>(0x027FFC80 + 0x5A);
|
||||
TSCal.scr.x1 = _MMU_read08<ARMCPU_ARM7>(0x027FFC80 + 0x5C);
|
||||
TSCal.scr.y1 = _MMU_read08<ARMCPU_ARM7>(0x027FFC80 + 0x5D);
|
||||
TSCal.adc.x2 = _MMU_read16<ARMCPU_ARM7>(0x027FFC80 + 0x5E);
|
||||
TSCal.adc.y2 = _MMU_read16<ARMCPU_ARM7>(0x027FFC80 + 0x60);
|
||||
TSCal.scr.x2 = _MMU_read08<ARMCPU_ARM7>(0x027FFC80 + 0x62);
|
||||
TSCal.scr.y2 = _MMU_read08<ARMCPU_ARM7>(0x027FFC80 + 0x63);
|
||||
|
||||
TSCal.adc.width = (TSCal.adc.x2 - TSCal.adc.x1);
|
||||
TSCal.adc.height = (TSCal.adc.y2 - TSCal.adc.y1);
|
||||
TSCal.scr.width = (TSCal.scr.x2 - TSCal.scr.x1);
|
||||
TSCal.scr.height = (TSCal.scr.y2 - TSCal.scr.y1);
|
||||
|
||||
MainScreen.offset = 0;
|
||||
SubScreen.offset = 192;
|
||||
|
||||
|
@ -2508,21 +2476,18 @@ void ClearAutoHold(void) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE u16 NDS_getADCTouchPosX(u16 scrX)
|
||||
{
|
||||
// this is a little iffy,
|
||||
// we're basically adjusting the ADC results to
|
||||
// compensate for how they will be interpreted.
|
||||
// the actual system doesn't do this transformation.
|
||||
int rv = (scrX - TSCal.scr.x1 + 1) * TSCal.adc.width / TSCal.scr.width + TSCal.adc.x1;
|
||||
int rv = (scrX - TSC_scr_x1 + 1) * (TSC_adc_x2 - TSC_adc_x1) / (TSC_scr_x2 - TSC_scr_x1) + TSC_adc_x1;
|
||||
rv = min(0xFFF, max(0, rv));
|
||||
printf("x: %d\n",rv);
|
||||
return (u16)rv;
|
||||
}
|
||||
INLINE u16 NDS_getADCTouchPosY(u16 scrY)
|
||||
{
|
||||
int rv = (scrY - TSCal.scr.y1 + 1) * TSCal.adc.height / TSCal.scr.height + TSCal.adc.y1;
|
||||
int rv = (scrY - TSC_scr_y1 + 1) * (TSC_adc_y2 - TSC_adc_y1) / (TSC_scr_y2 - TSC_scr_y1) + TSC_adc_y1;
|
||||
rv = min(0xFFF, max(0, rv));
|
||||
printf("y: %d\n",rv);
|
||||
return (u16)rv;
|
||||
}
|
||||
|
||||
|
@ -2847,7 +2812,6 @@ void NDS_suspendProcessingInput(bool suspend)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_halt() {
|
||||
//printf("halting emu: ARM9 PC=%08X/%08X, ARM7 PC=%08X/%08X\n", NDS_ARM9.R[15], NDS_ARM9.instruct_adr, NDS_ARM7.R[15], NDS_ARM7.instruct_adr);
|
||||
execute = false;
|
||||
|
|
|
@ -346,28 +346,28 @@ struct GameInfo
|
|||
bool hasRomBanner();
|
||||
};
|
||||
|
||||
typedef struct TSCalInfo
|
||||
{
|
||||
struct adc
|
||||
{
|
||||
u16 x1, x2;
|
||||
u16 y1, y2;
|
||||
u16 width;
|
||||
u16 height;
|
||||
} adc;
|
||||
|
||||
struct scr
|
||||
{
|
||||
u8 x1, x2;
|
||||
u8 y1, y2;
|
||||
u16 width;
|
||||
u16 height;
|
||||
} scr;
|
||||
|
||||
} TSCalInfo;
|
||||
|
||||
extern GameInfo gameInfo;
|
||||
|
||||
//default touchscreen calibration
|
||||
//we need some way to convert screen coordinates from the emulator to TSC coordinates
|
||||
//so we are going to assume a normal set of calibration parameters and do the reverse transformation.
|
||||
//the game will then do the normal transformation via the user's calibration parameters to get back to screen coordinates.
|
||||
//all this conversion could in principle be lossy, but we judge that it is not.
|
||||
//
|
||||
//the more historical way for desmume to do this is to attempt to use the calibration parameters in the firmware.
|
||||
//is it possible that this causes the reverse and forward transformation to roundtrip lossless without affecting the values?
|
||||
//maybe. but we really don't care about users who (mis)calibrate their firmware. we could even override the firmware calibration values
|
||||
//by patching it to prevent this.
|
||||
|
||||
static const int TSC_adc_x1 = 0x200;
|
||||
static const int TSC_adc_y1 = 0x200;
|
||||
static const int TSC_scr_x1 = 0x20 + 1; // calibration screen coords are 1-based,
|
||||
static const int TSC_scr_y1 = 0x20 + 1; // either that or NDS_getADCTouchPosX/Y are wrong.
|
||||
static const int TSC_adc_x2 = 0xe00;
|
||||
static const int TSC_adc_y2 = 0x800;
|
||||
static const int TSC_scr_x2 = 0xe0 + 1;
|
||||
static const int TSC_scr_y2 = 0x80 + 1;
|
||||
|
||||
|
||||
struct UserButtons : buttonstruct<bool>
|
||||
{
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
/* Copyright (C) 2009 DeSmuME Team
|
||||
/* Copyright (C) 2009-2010 DeSmuME Team
|
||||
|
||||
This file is part of DeSmuME
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
DeSmuME is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with DeSmuME; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "firmware.h"
|
||||
#include "NDSSystem.h"
|
||||
#include "path.h"
|
||||
|
@ -895,15 +893,14 @@ void NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config) {
|
|||
fw_config->language = 1;
|
||||
|
||||
/* default touchscreen calibration */
|
||||
fw_config->touch_cal[0].adc_x = 0x200;
|
||||
fw_config->touch_cal[0].adc_y = 0x200;
|
||||
fw_config->touch_cal[0].screen_x = 0x20 + 1; // calibration screen coords are 1-based,
|
||||
fw_config->touch_cal[0].screen_y = 0x20 + 1; // either that or NDS_getADCTouchPosX/Y are wrong.
|
||||
|
||||
fw_config->touch_cal[1].adc_x = 0xe00;
|
||||
fw_config->touch_cal[1].adc_y = 0x800;
|
||||
fw_config->touch_cal[1].screen_x = 0xe0 + 1;
|
||||
fw_config->touch_cal[1].screen_y = 0x80 + 1;
|
||||
fw_config->touch_cal[0].adc_x = TSC_adc_x1;
|
||||
fw_config->touch_cal[0].adc_y = TSC_adc_y1;
|
||||
fw_config->touch_cal[0].screen_x = TSC_scr_x1;
|
||||
fw_config->touch_cal[0].screen_y = TSC_scr_y1;
|
||||
fw_config->touch_cal[1].adc_x = TSC_adc_x2;
|
||||
fw_config->touch_cal[1].adc_y = TSC_adc_y2;
|
||||
fw_config->touch_cal[1].screen_x = TSC_scr_x2;
|
||||
fw_config->touch_cal[1].screen_y = TSC_scr_y2;
|
||||
}
|
||||
|
||||
void NDS_PatchFirmwareMAC()
|
||||
|
|
Loading…
Reference in New Issue