From 98965bac9937f9c870b80ccc76984af1230e0f13 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 7 Nov 2010 04:02:38 +0000 Subject: [PATCH] emulate temperature register* * the temperature is always 309 kelvins --- desmume/src/MMU.cpp | 58 +++++++++++++++++++++++++++++------------ desmume/src/registers.h | 8 ++++++ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index a4b5fc41c..2e785b02a 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -3720,13 +3720,43 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) return; case 2 : - //printf("%08X\n",MMU.SPI_CMD); - switch(MMU.SPI_CMD & 0x70) + printf("%08X\n",MMU.SPI_CMD); + switch(MMU.SPI_CMD&0xFC) { - case 0x00 : - val = 0; + case TSC_MEASURE_TEMP1: + if(spicnt & 0x800) + { + if(partie) + { + val = ((716<<3)&0x7FF); + partie = 0; + break; + } + val = (716>>5); + partie = 1; + break; + } + val = ((716<<3)&0x7FF); + partie = 1; break; - case 0x10 : + case TSC_MEASURE_TEMP2: + if(spicnt & 0x800) + { + if(partie) + { + val = ((865<<3)&0x7FF); + partie = 0; + break; + } + val = (865>>5); + partie = 1; + break; + } + val = ((865<<3)&0x7FF); + partie = 1; + break; + + case TSC_MEASURE_Y: //emu_halt(); if(MMU.SPI_CNT&(1<<11)) { @@ -3741,22 +3771,19 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) partie = 1; break; } - val = ((nds.touchY<<3)&0x7FF); - partie = 1; - break; - case 0x20 : - val = 0; + val = ((nds.touchY<<3)&0x7FF); + partie = 1; break; - case 0x30: //Z1 + case TSC_MEASURE_Z1: //Z1 //used for pressure calculation - must be nonzero or else some softwares will think the stylus is up. if(nds.isTouch) val = 2048; else val = 0; break; - case 0x40: //Z2 + case TSC_MEASURE_Z2: //Z2 //used for pressure calculation. we dont support pressure calculation so just return something. val = 2048; break; - case 0x50: + case TSC_MEASURE_X: if(spicnt & 0x800) { if(partie) @@ -3772,15 +3799,12 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) val = ((nds.touchX<<3)&0x7FF); partie = 1; break; - case 0x60 : + case TSC_MEASURE_AUX: if(!(val & 0x80)) val = (Mic_ReadSample() & 0xFF); else val = 0; break; - case 0x70 : - val = 0; - break; } break; diff --git a/desmume/src/registers.h b/desmume/src/registers.h index c6b42efb4..319fa5469 100644 --- a/desmume/src/registers.h +++ b/desmume/src/registers.h @@ -406,5 +406,13 @@ #define IRQ_MASK_ARM7_SPI (1<<23) #define IRQ_MASK_ARM7_WIFI (1<<24) +#define TSC_MEASURE_TEMP1 0x84 +#define TSC_MEASURE_Y 0x90 +#define TSC_MEASURE_BATTERY 0xA4 +#define TSC_MEASURE_Z1 0xB4 +#define TSC_MEASURE_Z2 0xC4 +#define TSC_MEASURE_X 0xD0 +#define TSC_MEASURE_AUX 0xE4 +#define TSC_MEASURE_TEMP2 0xF4 #endif