From: <ze...@us...> - 2010-03-30 08:34:07
|
Revision: 3453 http://desmume.svn.sourceforge.net/desmume/?rev=3453&view=rev Author: zeromus Date: 2010-03-30 08:34:01 +0000 (Tue, 30 Mar 2010) Log Message: ----------- add emulation for spi power management device system power-off and add power management device to savestates Modified Paths: -------------- trunk/desmume/src/MMU.cpp trunk/desmume/src/saves.cpp Modified: trunk/desmume/src/MMU.cpp =================================================================== --- trunk/desmume/src/MMU.cpp 2010-03-30 06:34:08 UTC (rev 3452) +++ trunk/desmume/src/MMU.cpp 2010-03-30 08:34:01 UTC (rev 3453) @@ -3825,13 +3825,35 @@ } else { + u16 reg = MMU.powerMan_CntReg&0x7F; + reg &= 0x7; + if(reg==5 || reg==6 || reg==7) reg = 4; + + //(let's start with emulating a DS lite, since it is the more complex case) if(MMU.powerMan_CntReg & 0x80) { - val = MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3]; + //read + val = MMU.powerMan_Reg[reg]; } else { - MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3] = (u8)val; + //write + MMU.powerMan_Reg[reg] = (u8)val; + + enum PM_Bits //from libnds + { + PM_SOUND_AMP = BIT(0) , /*!< \brief Power the sound hardware (needed to hear stuff in GBA mode too) */ + PM_SOUND_MUTE = BIT(1), /*!< \brief Mute the main speakers, headphone output will still work. */ + PM_BACKLIGHT_BOTTOM = BIT(2), /*!< \brief Enable the top backlight if set */ + PM_BACKLIGHT_TOP = BIT(3) , /*!< \brief Enable the bottom backlight if set */ + PM_SYSTEM_PWR = BIT(6) , /*!< \brief Turn the power *off* if set */ + }; + + //our totally pathetic register handling, only the one thing we've wanted so far + if(MMU.powerMan_Reg[0]&PM_SYSTEM_PWR) { + printf("SYSTEM POWERED OFF VIA ARM7 SPI POWER DEVICE\n"); + emu_halt(); + } } MMU.powerMan_CntRegWritten = FALSE; @@ -4628,4 +4650,3 @@ //print_memory_profiling( void) { //} //#endif /* End of PROFILE_MEMORY_ACCESS area */ - Modified: trunk/desmume/src/saves.cpp =================================================================== --- trunk/desmume/src/saves.cpp 2010-03-30 06:34:08 UTC (rev 3452) +++ trunk/desmume/src/saves.cpp 2010-03-30 08:34:01 UTC (rev 3453) @@ -248,6 +248,10 @@ { "FDHD", 4, 1, &disp_fifo.head}, { "FDTL", 4, 1, &disp_fifo.tail}, { "FDBF", 4, 0x6000, disp_fifo.buf}, + + { "PMCN", 1, 1, &MMU.powerMan_CntReg}, + { "PMCW", 4, 1, &MMU.powerMan_CntRegWritten}, + { "PMCR", 1, 4, &MMU.powerMan_Reg}, { 0 } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |