From 7d493c16c4a88f9c6f2f127de8981e7c7029f0f5 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 4 May 2009 05:58:48 +0000 Subject: [PATCH] revert stuff i didnt mean to checkin --- src/MMU.cpp | 193 +++++++++++++----------- src/MMU.h | 46 +++--- src/NDSSystem.cpp | 251 +++++++++++++++----------------- src/armcpu.cpp | 61 ++++---- src/armcpu.h | 9 +- src/saves.cpp | 24 +-- src/thumb_instructions.cpp | 3 - src/windows/DeSmuME_2005.vcproj | 1 - src/windows/DeSmuME_2008.vcproj | 3 +- src/windows/ginfo.cpp | 56 +++---- src/windows/ram_search.cpp | 1 - src/windows/ramwatch.cpp | 1 - 12 files changed, 317 insertions(+), 332 deletions(-) diff --git a/src/MMU.cpp b/src/MMU.cpp index 602e4e6ba..df08ab890 100644 --- a/src/MMU.cpp +++ b/src/MMU.cpp @@ -97,19 +97,7 @@ static const int save_types[7][2] = { {MC_TYPE_FLASH,MC_SIZE_4MBITS} }; -//Card rom & ram - -u16 SPI_CNT; -u16 SPI_CMD; -u16 AUX_SPI_CNT; -u16 AUX_SPI_CMD; - -u32 rom_mask = 0; - -u32 DMASrc[2][4]; -u32 DMADst[2][4]; - -u16 partie; +u16 partie = 1; u32 _MMU_MAIN_MEM_MASK = 0x3FFFFF; #define ROM_MASK 3 @@ -190,7 +178,6 @@ void mmu_log_debug_ARM7(u32 adr, const char *fmt, ...) #define DUP16(x) x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x MMU_struct MMU; -MMU_static_struct MMU_static; u8 * MMU_struct::MMU_MEM[2][256] = { //arm9 @@ -371,15 +358,6 @@ static FORCEINLINE u32 MMU_LCDmap(u32 addr, bool& unmapped) { unmapped = false; - if(addr==0x6201dc0) - { - int zzz=9; - } - if((addr&0x0F000000)==0x06000000 && PROCNUM==1) - { - printf("%08x\n",addr); - } - //in case the address is entirely outside of the interesting ranges if(addr < 0x06000000) return addr; if(addr >= 0x07000000) return addr; @@ -549,7 +527,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) u8 en = VRAMBankCnt & 0x80; if(!en) return; - int mst,ofs=0; + int mst,ofs; switch(bank) { case VRAM_BANK_A: case VRAM_BANK_B: @@ -563,7 +541,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //ABG vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); break; case 2: //AOBJ @@ -571,7 +549,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) switch(ofs) { case 0: case 1: - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+ofs*8); break; default: @@ -597,7 +575,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //ABG vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); break; case 2: //arm7 @@ -619,7 +597,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) ARM9Mem.texInfo.textureSlotAddr[ofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); break; case 4: //BGB or BOBJ - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); if(bank == VRAM_BANK_C) { vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; MMU_vram_arm9(bank,VRAM_PAGE_BBG); //BBG @@ -641,11 +619,11 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //ABG vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_ABG); break; case 2: //AOBJ - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; MMU_vram_arm9(bank,VRAM_PAGE_AOBJ); break; @@ -681,13 +659,13 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //ABG vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs); MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs+2); //unexpected mirroring (required by spyro eternal night) break; case 2: //AOBJ vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs); MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs+2); //unexpected mirroring - I have no proof, but it is inferred from the ABG above break; @@ -729,7 +707,7 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //BBG vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_BBG); MMU_vram_arm9(bank,VRAM_PAGE_BBG + 4); //unexpected mirroring break; @@ -754,13 +732,13 @@ static inline void MMU_VRAMmapRefreshBank(const int bank) break; case 1: //BBG vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_BBG+2); MMU_vram_arm9(bank,VRAM_PAGE_BBG+3); //unexpected mirroring break; case 2: //BOBJ vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJ; - //MMU_vram_lcdc(bank); + MMU_vram_lcdc(bank); MMU_vram_arm9(bank,VRAM_PAGE_BOBJ); break; case 3: //B OBJ extended palette @@ -914,20 +892,33 @@ void MMU_Init(void) { LOG("MMU init\n"); - MMU_clearMem(); + memset(&MMU, 0, sizeof(MMU_struct)); - MMU_static.CART_ROM = MMU.UNUSED_RAM; + MMU.CART_ROM = MMU.UNUSED_RAM; for(i = 0x80; i<0xA0; ++i) { - MMU_struct::MMU_MEM[0][i] = MMU_static.CART_ROM; - MMU_struct::MMU_MEM[1][i] = MMU_static.CART_ROM; + MMU_struct::MMU_MEM[0][i] = MMU.CART_ROM; + MMU_struct::MMU_MEM[1][i] = MMU.CART_ROM; } - mc_init(&MMU_static.fw, MC_TYPE_FLASH); /* init fw device */ - mc_alloc(&MMU_static.fw, NDS_FW_SIZE_V1); - MMU_static.fw.fp = NULL; + MMU.DTCMRegion = 0x027C0000; + MMU.ITCMRegion = 0x00000000; + IPC_FIFOinit(ARMCPU_ARM9); + IPC_FIFOinit(ARMCPU_ARM7); + GFX_FIFOclear(); + DISP_FIFOinit(); + + mc_init(&MMU.fw, MC_TYPE_FLASH); /* init fw device */ + mc_alloc(&MMU.fw, NDS_FW_SIZE_V1); + MMU.fw.fp = NULL; + + // Init Backup Memory device, this should really be done when the rom is loaded + mc_init(&MMU.bupmem, MC_TYPE_AUTODETECT); + mc_alloc(&MMU.bupmem, 1); + MMU.bupmem.fp = NULL; + rtcInit(); addonsInit(); if(Mic_Init() == FALSE) INFO("Microphone init failed.\n"); @@ -937,51 +928,77 @@ void MMU_Init(void) { void MMU_DeInit(void) { LOG("MMU deinit\n"); - if (MMU_static.fw.fp) - fclose(MMU_static.fw.fp); - mc_free(&MMU_static.fw); - if (MMU_static.bupmem.fp) - fclose(MMU_static.bupmem.fp); - mc_free(&MMU_static.bupmem); + if (MMU.fw.fp) + fclose(MMU.fw.fp); + mc_free(&MMU.fw); + if (MMU.bupmem.fp) + fclose(MMU.bupmem.fp); + mc_free(&MMU.bupmem); addonsClose(); Mic_DeInit(); } +//Card rom & ram + +u16 SPI_CNT = 0; +u16 SPI_CMD = 0; +u16 AUX_SPI_CNT = 0; +u16 AUX_SPI_CMD = 0; + +u32 rom_mask = 0; + +u32 DMASrc[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; +u32 DMADst[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; + void MMU_clearMem() { - printf("-------------------------clear---\n"); + memset(ARM9Mem.ARM9_DTCM, 0, sizeof(ARM9Mem.ARM9_DTCM)); + memset(ARM9Mem.ARM9_ITCM, 0, sizeof(ARM9Mem.ARM9_ITCM)); + memset(ARM9Mem.ARM9_LCD, 0, sizeof(ARM9Mem.ARM9_LCD)); + memset(ARM9Mem.ARM9_OAM, 0, sizeof(ARM9Mem.ARM9_OAM)); + memset(ARM9Mem.ARM9_REG, 0, sizeof(ARM9Mem.ARM9_REG)); + memset(ARM9Mem.ARM9_VMEM, 0, sizeof(ARM9Mem.ARM9_VMEM)); + memset(ARM9Mem.MAIN_MEM, 0, sizeof(ARM9Mem.MAIN_MEM)); - partie = 1; - - memset(&ARM9Mem,0,sizeof(ARM9Mem)); - memset(&MMU,0,sizeof(MMU)); - - //things which used to be only static initialized, now cleared here - memset(DMASrc,0,sizeof(DMASrc)); - memset(DMADst,0,sizeof(DMADst)); - SPI_CNT = 0; - SPI_CMD = 0; - AUX_SPI_CNT = 0; - AUX_SPI_CMD = 0; - - MMU_VRAM_unmap_all(); - - //reset gpu system - MainScreen.offset = 0; - SubScreen.offset = 192; - if(osdA != NULL) osdA->setOffset(MainScreen.offset); - if(osdB != NULL) osdB->setOffset(SubScreen.offset); + memset(ARM9Mem.blank_memory, 0, sizeof(ARM9Mem.blank_memory)); + memset(MMU.ARM7_ERAM, 0, sizeof(MMU.ARM7_ERAM)); + memset(MMU.ARM7_REG, 0, sizeof(MMU.ARM7_REG)); + IPC_FIFOinit(ARMCPU_ARM9); IPC_FIFOinit(ARMCPU_ARM7); GFX_FIFOclear(); DISP_FIFOinit(); - - //------- - //setup non-zero registers + MMU.DTCMRegion = 0x027C0000; + MMU.ITCMRegion = 0x00000000; + + memset(MMU.timer, 0, sizeof(u16) * 2 * 4); + memset(MMU.timerMODE, 0, sizeof(s32) * 2 * 4); + memset(MMU.timerON, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerRUN, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerReload, 0, sizeof(u16) * 2 * 4); + + memset(MMU.reg_IME, 0, sizeof(u32) * 2); + memset(MMU.reg_IE, 0, sizeof(u32) * 2); + memset(MMU.reg_IF, 0, sizeof(u32) * 2); + + memset(MMU.DMAStartTime, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMACycle, 0, sizeof(s32) * 2 * 4); + memset(MMU.DMACrt, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMAing, 0, sizeof(BOOL) * 2 * 4); + + memset(MMU.dscard, 0, sizeof(nds_dscard) * 2); + // Enable the sound speakers T1WriteWord(MMU.ARM7_REG, 0x304, 0x0001); + + MainScreen.offset = 0; + SubScreen.offset = 192; + osdA->setOffset(MainScreen.offset); + osdB->setOffset(SubScreen.offset); + + MMU_VRAM_unmap_all(); MMU.powerMan_CntReg = 0x00; MMU.powerMan_CntRegWritten = FALSE; @@ -990,15 +1007,17 @@ void MMU_clearMem() MMU.powerMan_Reg[2] = 0x01; MMU.powerMan_Reg[3] = 0x00; - MMU.DTCMRegion = 0x027C0000; - MMU.ITCMRegion = 0x00000000; + rtcInit(); + partie = 1; + addonsReset(); + Mic_Reset(); } void MMU_setRom(u8 * rom, u32 mask) { unsigned int i; - MMU_static.CART_ROM = rom; - MMU_static.CART_ROM_MASK = mask; + MMU.CART_ROM = rom; + MMU.CART_ROM_MASK = mask; for(i = 0x80; i<0xA0; ++i) { @@ -1013,7 +1032,7 @@ void MMU_setRom(u8 * rom, u32 mask) void MMU_unsetRom() { unsigned int i; - MMU_static.CART_ROM=MMU.UNUSED_RAM; + MMU.CART_ROM=MMU.UNUSED_RAM; for(i = 0x80; i<0xA0; ++i) { @@ -2201,14 +2220,14 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) AUX_SPI_CNT = val; if (val == 0) - mc_reset_com(&MMU_static.bupmem); /* reset backup memory device communication */ + mc_reset_com(&MMU.bupmem); /* reset backup memory device communication */ return; case REG_AUXSPIDATA: if(val!=0) AUX_SPI_CMD = val & 0xFF; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU_static.bupmem, val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); return; case REG_DISPA_BG0CNT : //GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val); @@ -3379,7 +3398,7 @@ u32 FASTCALL _MMU_ARM9_read32(u32 adr) { MMU.dscard[ARMCPU_ARM9].address = (0x8000 + (MMU.dscard[ARMCPU_ARM9].address&0x1FF)); } - val = T1ReadLong(MMU_static.CART_ROM, MMU.dscard[ARMCPU_ARM9].address & MMU_static.CART_ROM_MASK); + val = T1ReadLong(MMU.CART_ROM, MMU.dscard[ARMCPU_ARM9].address & MMU.CART_ROM_MASK); } break; @@ -3544,14 +3563,14 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) AUX_SPI_CNT = val; if (val == 0) - mc_reset_com(&MMU_static.bupmem); // reset backup memory device communication + mc_reset_com(&MMU.bupmem); // reset backup memory device communication return; case REG_AUXSPIDATA: if(val!=0) AUX_SPI_CMD = val & 0xFF; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU_static.bupmem, val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); return; case REG_SPICNT : @@ -3570,11 +3589,11 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) } } - //MMU_static.fw.com == 0; // reset fw device communication + //MMU.fw.com == 0; // reset fw device communication if ( reset_firmware) { // reset fw device communication - mc_reset_com(&MMU_static.fw); + mc_reset_com(&MMU.fw); } SPI_CNT = val; @@ -3622,7 +3641,7 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); break; } - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU_static.fw, val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, val)); return; case 2 : @@ -4378,7 +4397,7 @@ u32 FASTCALL _MMU_ARM7_read32(u32 adr) case 0xB7: { /* TODO: prevent read if the address is out of range */ - val = T1ReadLong(MMU_static.CART_ROM, MMU.dscard[ARMCPU_ARM7].address); + val = T1ReadLong(MMU.CART_ROM, MMU.dscard[ARMCPU_ARM7].address); } break; @@ -4497,5 +4516,5 @@ void mmu_select_savetype(int type, int *bmemtype, u32 *bmemsize) { if (type<0 || type > 6) return; *bmemtype=save_types[type][0]; *bmemsize=save_types[type][1]; - mc_realloc(&MMU_static.bupmem, *bmemtype, *bmemsize); + mc_realloc(&MMU.bupmem, *bmemtype, *bmemsize); } diff --git a/src/MMU.h b/src/MMU.h index d445f1e4b..cb81e178b 100644 --- a/src/MMU.h +++ b/src/MMU.h @@ -47,39 +47,34 @@ typedef const u32 TWaitState; -struct MMU_static_struct { - - //Card rom - u8 * CART_ROM; - u32 CART_ROM_MASK; - - memory_chip_t fw; - memory_chip_t bupmem; - -}; - struct MMU_struct { //ARM7 mem u8 ARM7_BIOS[0x4000]; u8 ARM7_ERAM[0x10000]; u8 ARM7_REG[0x10000]; u8 ARM7_WIRAM[0x10000]; - u8 CART_RAM[0x10000]; - //this is here so that we can trap glitchy emulator code - //which is accessing offsets 5,6,7 of unused ram due to unaligned accesses - //(also since the emulator doesn't prevent unaligned accesses) - u8 MORE_UNUSED_RAM[4]; - //Shared ram - u8 SWIRAM[0x8000]; - //Unused ram - u8 UNUSED_RAM[4]; // VRAM mapping u8 VRAM_MAP[4][32]; u32 LCD_VRAM_ADDR[10]; u8 LCDCenable[10]; - + //Shared ram + u8 SWIRAM[0x8000]; + + //Card rom & ram + u8 * CART_ROM; + u32 CART_ROM_MASK; + u8 CART_RAM[0x10000]; + + //Unused ram + u8 UNUSED_RAM[4]; + + //this is here so that we can trap glitchy emulator code + //which is accessing offsets 5,6,7 of unused ram due to unaligned accesses + //(also since the emulator doesn't prevent unaligned accesses) + u8 MORE_UNUSED_RAM[4]; + static u8 * MMU_MEM[2][256]; static u32 MMU_MASK[2][256]; @@ -120,14 +115,17 @@ struct MMU_struct { u8 powerMan_CntReg; BOOL powerMan_CntRegWritten; u8 powerMan_Reg[4]; - + + memory_chip_t fw; + memory_chip_t bupmem; + nds_dscard dscard[2]; u32 CheckTimers; - u32 CheckDMAs; + u32 CheckDMAs; + }; extern MMU_struct MMU; -extern MMU_static_struct MMU_static; struct armcpu_memory_iface { diff --git a/src/NDSSystem.cpp b/src/NDSSystem.cpp index 98aff87fc..0e43eee93 100644 --- a/src/NDSSystem.cpp +++ b/src/NDSSystem.cpp @@ -41,9 +41,6 @@ #include "debug.h" #include "cheatSystem.h" #include "movie.h" -#include "rtc.h" -#include "mic.h" -#include "addons.h" #ifdef _WIN32 #include "./windows/disView.h" @@ -56,7 +53,7 @@ static Driver _stub_driver; Driver* driver = &_stub_driver; std::string InputDisplayString; -static BOOL LidClosed; +static BOOL LidClosed = FALSE; static u8 countLid = 0; char pathToROM[MAX_PATH]; char pathFilenameToROMwithoutExt[MAX_PATH]; @@ -492,17 +489,21 @@ struct armcpu_ctrl_iface **arm7_ctrl_iface) { #else int NDS_Init( void) { #endif + nds.ARM9Cycle = 0; + nds.ARM7Cycle = 0; + nds.cycles = 0; + nds.idleFrameCounter = 0; + memset(nds.runCycleCollector,0,sizeof(nds.runCycleCollector)); MMU_Init(); + nds.nextHBlank = 3168; + nds.VCount = 0; + nds.lignerendu = FALSE; + + nds.sleeping = FALSE; if (Screen_Init(GFXCORE_DUMMY) != 0) return -1; - //reset gpu system - MainScreen.offset = 0; - SubScreen.offset = 192; - osdA->setOffset(MainScreen.offset); - osdB->setOffset(SubScreen.offset); - gfx3d_init(); #ifdef GDB_STUB @@ -529,7 +530,7 @@ int NDS_Init( void) { } void NDS_DeInit(void) { - if(MMU_static.CART_ROM != MMU.UNUSED_RAM) + if(MMU.CART_ROM != MMU.UNUSED_RAM) NDS_FreeROM(); nds.nextHBlank = 3168; @@ -555,45 +556,45 @@ NDS_header * NDS_getROMHeader(void) { NDS_header * header = new NDS_header; - memcpy(header->gameTile, MMU_static.CART_ROM, 12); - memcpy(header->gameCode, MMU_static.CART_ROM + 12, 4); - header->makerCode = T1ReadWord(MMU_static.CART_ROM, 16); - header->unitCode = MMU_static.CART_ROM[18]; - header->deviceCode = MMU_static.CART_ROM[19]; - header->cardSize = MMU_static.CART_ROM[20]; - memcpy(header->cardInfo, MMU_static.CART_ROM + 21, 8); - header->flags = MMU_static.CART_ROM[29]; - header->ARM9src = T1ReadLong(MMU_static.CART_ROM, 32); - header->ARM9exe = T1ReadLong(MMU_static.CART_ROM, 36); - header->ARM9cpy = T1ReadLong(MMU_static.CART_ROM, 40); - header->ARM9binSize = T1ReadLong(MMU_static.CART_ROM, 44); - header->ARM7src = T1ReadLong(MMU_static.CART_ROM, 48); - header->ARM7exe = T1ReadLong(MMU_static.CART_ROM, 52); - header->ARM7cpy = T1ReadLong(MMU_static.CART_ROM, 56); - header->ARM7binSize = T1ReadLong(MMU_static.CART_ROM, 60); - header->FNameTblOff = T1ReadLong(MMU_static.CART_ROM, 64); - header->FNameTblSize = T1ReadLong(MMU_static.CART_ROM, 68); - header->FATOff = T1ReadLong(MMU_static.CART_ROM, 72); - header->FATSize = T1ReadLong(MMU_static.CART_ROM, 76); - header->ARM9OverlayOff = T1ReadLong(MMU_static.CART_ROM, 80); - header->ARM9OverlaySize = T1ReadLong(MMU_static.CART_ROM, 84); - header->ARM7OverlayOff = T1ReadLong(MMU_static.CART_ROM, 88); - header->ARM7OverlaySize = T1ReadLong(MMU_static.CART_ROM, 92); - header->unknown2a = T1ReadLong(MMU_static.CART_ROM, 96); - header->unknown2b = T1ReadLong(MMU_static.CART_ROM, 100); - header->IconOff = T1ReadLong(MMU_static.CART_ROM, 104); - header->CRC16 = T1ReadWord(MMU_static.CART_ROM, 108); - header->ROMtimeout = T1ReadWord(MMU_static.CART_ROM, 110); - header->ARM9unk = T1ReadLong(MMU_static.CART_ROM, 112); - header->ARM7unk = T1ReadLong(MMU_static.CART_ROM, 116); - memcpy(header->unknown3c, MMU_static.CART_ROM + 120, 8); - header->ROMSize = T1ReadLong(MMU_static.CART_ROM, 128); - header->HeaderSize = T1ReadLong(MMU_static.CART_ROM, 132); - memcpy(header->unknown5, MMU_static.CART_ROM + 136, 56); - memcpy(header->logo, MMU_static.CART_ROM + 192, 156); - header->logoCRC16 = T1ReadWord(MMU_static.CART_ROM, 348); - header->headerCRC16 = T1ReadWord(MMU_static.CART_ROM, 350); - memcpy(header->reserved, MMU_static.CART_ROM + 352, 160); + memcpy(header->gameTile, MMU.CART_ROM, 12); + memcpy(header->gameCode, MMU.CART_ROM + 12, 4); + header->makerCode = T1ReadWord(MMU.CART_ROM, 16); + header->unitCode = MMU.CART_ROM[18]; + header->deviceCode = MMU.CART_ROM[19]; + header->cardSize = MMU.CART_ROM[20]; + memcpy(header->cardInfo, MMU.CART_ROM + 21, 8); + header->flags = MMU.CART_ROM[29]; + header->ARM9src = T1ReadLong(MMU.CART_ROM, 32); + header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36); + header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40); + header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44); + header->ARM7src = T1ReadLong(MMU.CART_ROM, 48); + header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52); + header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56); + header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60); + header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64); + header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68); + header->FATOff = T1ReadLong(MMU.CART_ROM, 72); + header->FATSize = T1ReadLong(MMU.CART_ROM, 76); + header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80); + header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84); + header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88); + header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92); + header->unknown2a = T1ReadLong(MMU.CART_ROM, 96); + header->unknown2b = T1ReadLong(MMU.CART_ROM, 100); + header->IconOff = T1ReadLong(MMU.CART_ROM, 104); + header->CRC16 = T1ReadWord(MMU.CART_ROM, 108); + header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110); + header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112); + header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116); + memcpy(header->unknown3c, MMU.CART_ROM + 120, 8); + header->ROMSize = T1ReadLong(MMU.CART_ROM, 128); + header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132); + memcpy(header->unknown5, MMU.CART_ROM + 136, 56); + memcpy(header->logo, MMU.CART_ROM + 192, 156); + header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348); + header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350); + memcpy(header->reserved, MMU.CART_ROM + 352, 160); return header; } @@ -797,7 +798,7 @@ int NDS_LoadROM( const char *filename, int bmtype, u32 bmsize, // Make sure old ROM is freed first(at least this way we won't be eating // up a ton of ram before the old ROM is freed) - if(MMU_static.CART_ROM != MMU.UNUSED_RAM) + if(MMU.CART_ROM != MMU.UNUSED_RAM) NDS_FreeROM(); data = new u8[mask + 1]; @@ -831,8 +832,8 @@ int NDS_LoadROM( const char *filename, int bmtype, u32 bmsize, strcpy(buf, pathFilenameToROMwithoutExt); strcat(buf, ".sav"); // DeSmuME memory card :) - mc_realloc(&MMU_static.bupmem, bmtype, bmsize); - mc_load_file(&MMU_static.bupmem, buf); + mc_realloc(&MMU.bupmem, bmtype, bmsize); + mc_load_file(&MMU.bupmem, buf); memset(buf, 0, MAX_PATH); strcpy(buf, pathFilenameToROMwithoutExt); @@ -846,8 +847,8 @@ int NDS_LoadROM( const char *filename, int bmtype, u32 bmsize, void MovieSRAM() { - int bmtype = MMU_static.bupmem.type; - u32 bmsize = MMU_static.bupmem.size; + int bmtype = MMU.bupmem.type; + u32 bmsize = MMU.bupmem.size; char buf[MAX_PATH]; @@ -859,19 +860,18 @@ void MovieSRAM() strcat(buf, "movie"); } - mc_realloc(&MMU_static.bupmem,MC_TYPE_AUTODETECT,0); - //mc_realloc(&MMU_static.bupmem, bmtype, bmsize); - mc_load_file(&MMU_static.bupmem, buf); + mc_realloc(&MMU.bupmem, bmtype, bmsize); + mc_load_file(&MMU.bupmem, buf); } void NDS_FreeROM(void) { - if (MMU_static.CART_ROM != MMU.UNUSED_RAM) - delete [] MMU_static.CART_ROM; + if (MMU.CART_ROM != MMU.UNUSED_RAM) + delete [] MMU.CART_ROM; MMU_unsetRom(); - if (MMU_static.bupmem.fp) - fclose(MMU_static.bupmem.fp); - MMU_static.bupmem.fp = NULL; + if (MMU.bupmem.fp) + fclose(MMU.bupmem.fp); + MMU.bupmem.fp = NULL; } void NDS_Reset( void) @@ -886,12 +886,12 @@ void NDS_Reset( void) if (!header) return ; - if (MMU_static.bupmem.fp) + if (MMU.bupmem.fp) { - fclose(MMU_static.bupmem.fp); - MMU_static.bupmem.fp = NULL; + fclose(MMU.bupmem.fp); + MMU.bupmem.fp = NULL; } - + lagframecounter=0; LagFrameFlag=0; lastLag=0; @@ -900,11 +900,6 @@ void NDS_Reset( void) currFrameCounter=0; MMU_clearMem(); - //things formerly from MMU_clearMem before we changed it to do less: - rtcInit(); - addonsReset(); - Mic_Reset(); - //------------ //ARM7 BIOS IRQ HANDLER if(CommonSettings.UseExtBIOS == true) @@ -993,7 +988,7 @@ void NDS_Reset( void) for(i = 0; i < (header->ARM9binSize>>2); ++i) { - _MMU_write32(dst, T1ReadLong(MMU_static.CART_ROM, src)); + _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); dst += 4; src += 4; } @@ -1003,7 +998,7 @@ void NDS_Reset( void) for(i = 0; i < (header->ARM7binSize>>2); ++i) { - _MMU_write32(dst, T1ReadLong(MMU_static.CART_ROM, src)); + _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); dst += 4; src += 4; } @@ -1015,8 +1010,6 @@ void NDS_Reset( void) nds.ARM9Cycle = 0; nds.ARM7Cycle = 0; nds.cycles = 0; - nds.idleFrameCounter = 0; - memset(nds.runCycleCollector,0,sizeof(nds.runCycleCollector)); memset(nds.timerCycle, 0, sizeof(s32) * 2 * 4); memset(nds.timerOver, 0, sizeof(BOOL) * 2 * 4); nds.nextHBlank = 3168; @@ -1024,7 +1017,6 @@ void NDS_Reset( void) nds.old = 0; nds.diff = 0; nds.lignerendu = FALSE; - nds.sleeping = FALSE; nds.touchX = nds.touchY = 0; nds.isTouch = 0; nds.debugConsole = CommonSettings.DebugConsole; @@ -1045,7 +1037,7 @@ void NDS_Reset( void) u8 temp_buffer[NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT]; int fw_index; - if ( copy_firmware_user_data( temp_buffer, MMU_static.fw.data)) { + if ( copy_firmware_user_data( temp_buffer, MMU.fw.data)) { for ( fw_index = 0; fw_index < NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT; fw_index++) _MMU_write08(0x027FFC80 + fw_index, temp_buffer[fw_index]); } @@ -1054,11 +1046,11 @@ void NDS_Reset( void) // Copy the whole header to Main RAM 0x27FFE00 on startup. // Reference: http://nocash.emubase.de/gbatek.htm#dscartridgeheader for (i = 0; i < ((0x170+0x90)/4); i++) { - _MMU_write32(0x027FFE00+i*4, LE_TO_LOCAL_32(((u32*)MMU_static.CART_ROM)[i])); + _MMU_write32(0x027FFE00+i*4, LE_TO_LOCAL_32(((u32*)MMU.CART_ROM)[i])); } // Write the header checksum to memory (the firmware needs it to see the cart) - _MMU_write16(0x027FF808, T1ReadWord(MMU_static.CART_ROM, 0x15E)); + _MMU_write16(0x027FF808, T1ReadWord(MMU.CART_ROM, 0x15E)); MainScreen.offset = 0; SubScreen.offset = 192; @@ -1083,7 +1075,7 @@ void NDS_Reset( void) } #endif - memcpy(FW_Mac, (MMU_static.fw.data + 0x36), 6); + memcpy(FW_Mac, (MMU.fw.data + 0x36), 6); } int NDS_ImportSave(const char *filename) @@ -1092,7 +1084,7 @@ int NDS_ImportSave(const char *filename) return 0; if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0) - return mc_load_duc(&MMU_static.bupmem, filename); + return mc_load_duc(&MMU.bupmem, filename); return 0; } @@ -1423,85 +1415,85 @@ int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings) /* * Create the firmware header */ - memset( MMU_static.fw.data, 0, 0x40000); + memset( MMU.fw.data, 0, 0x40000); /* firmware identifier */ - MMU_static.fw.data[0x8] = 'M'; - MMU_static.fw.data[0x8 + 1] = 'A'; - MMU_static.fw.data[0x8 + 2] = 'C'; - MMU_static.fw.data[0x8 + 3] = 'P'; + MMU.fw.data[0x8] = 'M'; + MMU.fw.data[0x8 + 1] = 'A'; + MMU.fw.data[0x8 + 2] = 'C'; + MMU.fw.data[0x8 + 3] = 'P'; /* DS type */ if ( user_settings->ds_type == NDS_FW_DS_TYPE_LITE) - MMU_static.fw.data[0x1d] = 0x20; + MMU.fw.data[0x1d] = 0x20; else - MMU_static.fw.data[0x1d] = 0xff; + MMU.fw.data[0x1d] = 0xff; /* User Settings offset 0x3fe00 / 8 */ - MMU_static.fw.data[0x20] = 0xc0; - MMU_static.fw.data[0x21] = 0x7f; + MMU.fw.data[0x20] = 0xc0; + MMU.fw.data[0x21] = 0x7f; /* * User settings (at 0x3FE00 and 0x3FF00) */ - fill_user_data_area( user_settings, &MMU_static.fw.data[ 0x3FE00], 0); - fill_user_data_area( user_settings, &MMU_static.fw.data[ 0x3FF00], 1); + fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FE00], 0); + fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FF00], 1); /* Wifi config length */ - MMU_static.fw.data[0x2C] = 0x38; - MMU_static.fw.data[0x2D] = 0x01; + MMU.fw.data[0x2C] = 0x38; + MMU.fw.data[0x2D] = 0x01; - MMU_static.fw.data[0x2E] = 0x00; + MMU.fw.data[0x2E] = 0x00; /* Wifi version */ - MMU_static.fw.data[0x2F] = 0x00; + MMU.fw.data[0x2F] = 0x00; /* MAC address */ - memcpy((MMU_static.fw.data + 0x36), FW_Mac, sizeof(FW_Mac)); + memcpy((MMU.fw.data + 0x36), FW_Mac, sizeof(FW_Mac)); /* Enabled channels */ - MMU_static.fw.data[0x3C] = 0xFE; - MMU_static.fw.data[0x3D] = 0x3F; + MMU.fw.data[0x3C] = 0xFE; + MMU.fw.data[0x3D] = 0x3F; - MMU_static.fw.data[0x3E] = 0xFF; - MMU_static.fw.data[0x3F] = 0xFF; + MMU.fw.data[0x3E] = 0xFF; + MMU.fw.data[0x3F] = 0xFF; /* RF related */ - MMU_static.fw.data[0x40] = 0x02; - MMU_static.fw.data[0x41] = 0x18; - MMU_static.fw.data[0x42] = 0x0C; + MMU.fw.data[0x40] = 0x02; + MMU.fw.data[0x41] = 0x18; + MMU.fw.data[0x42] = 0x0C; - MMU_static.fw.data[0x43] = 0x01; + MMU.fw.data[0x43] = 0x01; /* Wifi I/O init values */ - memcpy((MMU_static.fw.data + 0x44), FW_WIFIInit, sizeof(FW_WIFIInit)); + memcpy((MMU.fw.data + 0x44), FW_WIFIInit, sizeof(FW_WIFIInit)); /* Wifi BB init values */ - memcpy((MMU_static.fw.data + 0x64), FW_BBInit, sizeof(FW_BBInit)); + memcpy((MMU.fw.data + 0x64), FW_BBInit, sizeof(FW_BBInit)); /* Wifi RF init values */ - memcpy((MMU_static.fw.data + 0xCE), FW_RFInit, sizeof(FW_RFInit)); + memcpy((MMU.fw.data + 0xCE), FW_RFInit, sizeof(FW_RFInit)); /* Wifi channel-related init values */ - memcpy((MMU_static.fw.data + 0xF2), FW_RFChannel, sizeof(FW_RFChannel)); - memcpy((MMU_static.fw.data + 0x146), FW_BBChannel, sizeof(FW_BBChannel)); - memset((MMU_static.fw.data + 0x154), 0x10, 0xE); + memcpy((MMU.fw.data + 0xF2), FW_RFChannel, sizeof(FW_RFChannel)); + memcpy((MMU.fw.data + 0x146), FW_BBChannel, sizeof(FW_BBChannel)); + memset((MMU.fw.data + 0x154), 0x10, 0xE); /* WFC profiles */ - memcpy((MMU_static.fw.data + 0x3FA40), &FW_WFCProfile1, sizeof(FW_WFCProfile)); - memcpy((MMU_static.fw.data + 0x3FB40), &FW_WFCProfile2, sizeof(FW_WFCProfile)); - memcpy((MMU_static.fw.data + 0x3FC40), &FW_WFCProfile3, sizeof(FW_WFCProfile)); - (*(u16*)(MMU_static.fw.data + 0x3FAFE)) = (u16)calc_CRC16(0, (MMU_static.fw.data + 0x3FA00), 0xFE); - (*(u16*)(MMU_static.fw.data + 0x3FBFE)) = (u16)calc_CRC16(0, (MMU_static.fw.data + 0x3FB00), 0xFE); - (*(u16*)(MMU_static.fw.data + 0x3FCFE)) = (u16)calc_CRC16(0, (MMU_static.fw.data + 0x3FC00), 0xFE); + memcpy((MMU.fw.data + 0x3FA40), &FW_WFCProfile1, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FB40), &FW_WFCProfile2, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FC40), &FW_WFCProfile3, sizeof(FW_WFCProfile)); + (*(u16*)(MMU.fw.data + 0x3FAFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FA00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FBFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FB00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FCFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FC00), 0xFE); - MMU_static.fw.data[0x162] = 0x19; - memset((MMU_static.fw.data + 0x163), 0xFF, 0x9D); + MMU.fw.data[0x162] = 0x19; + memset((MMU.fw.data + 0x163), 0xFF, 0x9D); /* Wifi settings CRC16 */ - (*(u16*)(MMU_static.fw.data + 0x2A)) = calc_CRC16(0, (MMU_static.fw.data + 0x2C), 0x138); + (*(u16*)(MMU.fw.data + 0x2A)) = calc_CRC16(0, (MMU.fw.data + 0x2C), 0x138); return TRUE ; } @@ -1554,26 +1546,26 @@ int NDS_LoadFirmware(const char *filename) unsigned long size; //FILE *file; - if ((MMU_static.fw.fp = fopen(filename, "rb+")) == NULL) + if ((MMU.fw.fp = fopen(filename, "rb+")) == NULL) return -1; - fseek(MMU_static.fw.fp, 0, SEEK_END); - size = ftell(MMU_static.fw.fp); - fseek(MMU_static.fw.fp, 0, SEEK_SET); + fseek(MMU.fw.fp, 0, SEEK_END); + size = ftell(MMU.fw.fp); + fseek(MMU.fw.fp, 0, SEEK_SET); - if(size > MMU_static.fw.size) + if(size > MMU.fw.size) { - fclose(MMU_static.fw.fp); + fclose(MMU.fw.fp); fw_success = FALSE; return -1; } - i = fread(MMU_static.fw.data, size, 1, MMU_static.fw.fp); + i = fread(MMU.fw.data, size, 1, MMU.fw.fp); //fclose(file); INFO("Firmware: decrypting NDS firmware %s...\n", filename); - if(decryptFirmware(MMU_static.fw.data) == FALSE) + if(decryptFirmware(MMU.fw.data) == FALSE) { INFO("Firmware: decryption failed.\n"); fw_success = FALSE; @@ -1728,7 +1720,6 @@ u32 NDS_exec(s32 nb) { if(!nds.lignerendu) { - printf("%04d %03d: %08X\n",currFrameCounter,nds.VCount,NDS_ARM9.instruct_adr); T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 2); T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 2); NDS_ARM9HBlankInt(); diff --git a/src/armcpu.cpp b/src/armcpu.cpp index d3ca0e817..31db6a191 100644 --- a/src/armcpu.cpp +++ b/src/armcpu.cpp @@ -28,7 +28,7 @@ #include "bios.h" #include "debug.h" #include "Disassembler.h" -#include "ndssystem.h" + template static u32 armcpu_prefetch(); @@ -179,12 +179,6 @@ int armcpu_new( armcpu_t *armcpu, u32 id, int armcpu_new( armcpu_t *armcpu, u32 id) #endif { - if(armcpu->initialized) return 0; - armcpu->initialized = true; - - for(int i = 0; i < 16; ++i) - armcpu->coproc[i] = NULL; - armcpu->proc_ID = id; #ifdef GDB_STUB @@ -214,15 +208,6 @@ void armcpu_init(armcpu_t *armcpu, u32 adr) { u32 i; - //TODO - breaks gdb stub - if(armcpu->coproc[15]) free(armcpu->coproc[15]); - u32 proc_ID = armcpu->proc_ID; - //memset(armcpu,0,sizeof(armcpu_t)); - armcpu->initialized = true; - armcpu->proc_ID = proc_ID; - - armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu); - armcpu->LDTBit = (armcpu->proc_ID==0); //Si ARM9 utiliser le syte v5 pour le load armcpu->intVector = 0xFFFF0000 * (armcpu->proc_ID==0); armcpu->waitIRQ = FALSE; @@ -230,10 +215,18 @@ void armcpu_init(armcpu_t *armcpu, u32 adr) armcpu->newIrqFlags = 0; - #ifdef GDB_STUB - armcpu->irq_flag = 0; - #endif +#ifdef GDB_STUB + armcpu->irq_flag = 0; +#endif + if(armcpu->coproc[15]) free(armcpu->coproc[15]); + + for(i = 0; i < 15; ++i) + { + armcpu->R[i] = 0; + armcpu->coproc[i] = NULL; + } + armcpu->CPSR.val = armcpu->SPSR.val = SYS; armcpu->R13_usr = armcpu->R14_usr = 0; @@ -245,18 +238,20 @@ void armcpu_init(armcpu_t *armcpu, u32 adr) armcpu->SPSR_svc.val = armcpu->SPSR_abt.val = armcpu->SPSR_und.val = armcpu->SPSR_irq.val = armcpu->SPSR_fiq.val = 0; - #ifdef GDB_STUB - armcpu->instruct_adr = adr; - armcpu->R[15] = adr + 8; - #else - armcpu->R[15] = adr; - #endif +#ifdef GDB_STUB + armcpu->instruct_adr = adr; + armcpu->R[15] = adr + 8; +#else + armcpu->R[15] = adr; +#endif armcpu->next_instruction = adr; - #ifndef GDB_STUB - armcpu_prefetch(armcpu); - #endif + armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu); + +#ifndef GDB_STUB + armcpu_prefetch(armcpu); +#endif } u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode) @@ -485,8 +480,6 @@ BOOL armcpu_irqException(armcpu_t *armcpu) return TRUE; } -#define WANTASMLISTING - BOOL armcpu_flagIrq( armcpu_t *armcpu) { if(armcpu->CPSR.bits.I) return FALSE; @@ -531,13 +524,9 @@ u32 armcpu_exec() { if(PROCNUM==0) { #ifdef WANTASMLISTING - extern int currFrameCounter; char txt[128]; - if(currFrameCounter>26) - { - // des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt); - // printf("%04d %03d %08d: %X: %X - %s\n", currFrameCounter,nds.VCount,nds.cycles, ARMPROC.instruct_adr,ARMPROC.instruction, txt); - } + des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt); + printf("%X: %X - %s\n", ARMPROC.instruct_adr,ARMPROC.instruction, txt); #endif c += arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)](); } diff --git a/src/armcpu.h b/src/armcpu.h index b8a038572..ff45635ca 100644 --- a/src/armcpu.h +++ b/src/armcpu.h @@ -156,13 +156,8 @@ struct armcpu_ctrl_iface { typedef void* armcp_t; -struct armcpu_t +typedef struct armcpu_t { - armcpu_t() - : initialized(false) - {} - - bool initialized; u32 proc_ID; u32 instruction; //4 u32 instruct_adr; //8 @@ -212,7 +207,7 @@ struct armcpu_t /** the ctrl interface */ struct armcpu_ctrl_iface ctrl_iface; #endif -}; +} armcpu_t; #ifdef GDB_STUB int armcpu_new( armcpu_t *armcpu, u32 id, struct armcpu_memory_iface *mem_if, diff --git a/src/saves.cpp b/src/saves.cpp index e1a492105..084993354 100644 --- a/src/saves.cpp +++ b/src/saves.cpp @@ -218,11 +218,11 @@ SFORMAT SF_MMU[]={ //we are skipping the firmware, because we really don't want to save the firmware to the savestate //but, we will need to think about the philosophy of this. //should we perhaps hash the current firmware and save it, so that we can match it against the loader's firmware? - { "BUCO", 1, 1, &MMU_static.bupmem.com}, - { "BUAD", 4, 1, &MMU_static.bupmem.addr}, - { "BUAS", 1, 1, &MMU_static.bupmem.addr_shift}, - { "BUAZ", 1, 1, &MMU_static.bupmem.addr_size}, - { "BUWE", 4, 1, &MMU_static.bupmem.write_enable}, + { "BUCO", 1, 1, &MMU.bupmem.com}, + { "BUAD", 4, 1, &MMU.bupmem.addr}, + { "BUAS", 1, 1, &MMU.bupmem.addr_shift}, + { "BUAZ", 1, 1, &MMU.bupmem.addr_size}, + { "BUWE", 4, 1, &MMU.bupmem.write_enable}, //writeable_buffer ??? //end memory chips @@ -257,9 +257,9 @@ static void mmu_savestate(std::ostream* os) //version write32le(1,os); - write32le(MMU_static.bupmem.type,os); - write32le(MMU_static.bupmem.size,os); - os->write((char*)MMU_static.bupmem.data,MMU_static.bupmem.size); + write32le(MMU.bupmem.type,os); + write32le(MMU.bupmem.size,os); + os->write((char*)MMU.bupmem.data,MMU.bupmem.size); } static bool mmu_loadstate(std::istream* is, int size) @@ -277,8 +277,8 @@ static bool mmu_loadstate(std::istream* is, int size) //it would silently fail if there was a size mismatch SAV_silent_fail_flag = true; if(read32le(&bupmem_size,is) != 1) return false; - //if(bupmem_size != MMU_static.bupmem.size) return false; //mismatch between current initialized and saved size - mc_realloc(&MMU_static.bupmem,MC_TYPE_AUTODETECT,bupmem_size); + //if(bupmem_size != MMU.bupmem.size) return false; //mismatch between current initialized and saved size + mc_realloc(&MMU.bupmem,MC_TYPE_AUTODETECT,bupmem_size); } else { @@ -286,10 +286,10 @@ static bool mmu_loadstate(std::istream* is, int size) int bupmem_type; if(read32le(&bupmem_type,is) != 1) return false; if(read32le(&bupmem_size,is) != 1) return false; - mc_realloc(&MMU_static.bupmem,bupmem_type,bupmem_size); + mc_realloc(&MMU.bupmem,bupmem_type,bupmem_size); } - is->read((char*)MMU_static.bupmem.data,bupmem_size); + is->read((char*)MMU.bupmem.data,bupmem_size); if(is->fail()) return false; return true; diff --git a/src/thumb_instructions.cpp b/src/thumb_instructions.cpp index da7048c1e..dfea7e859 100644 --- a/src/thumb_instructions.cpp +++ b/src/thumb_instructions.cpp @@ -893,9 +893,6 @@ TEMPLATE static u32 FASTCALL OP_B_COND() TEMPLATE static u32 FASTCALL OP_SWI_THUMB() { - if(cpu->proc_ID==0) { - int zzz=9; - } if(cpu->swi_tab) { //zero 25-dec-2008 - in arm, we were masking to 0x1F. //this is probably safer since an invalid opcode could crash the emu diff --git a/src/windows/DeSmuME_2005.vcproj b/src/windows/DeSmuME_2005.vcproj index ffedbf405..674e3a5c2 100644 --- a/src/windows/DeSmuME_2005.vcproj +++ b/src/windows/DeSmuME_2005.vcproj @@ -53,7 +53,6 @@ AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;BETA_VERSION;SPU_INTERPOLATE;HAVE_LIBZ;HAVE_LIBZZIP;NOMINMAX;DEBUG;WANTPROGINFO;EXPERIMENTAL_WIFI" ExceptionHandling="1" - BasicRuntimeChecks="0" BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" FloatingPointModel="2" diff --git a/src/windows/DeSmuME_2008.vcproj b/src/windows/DeSmuME_2008.vcproj index 4bb0b174f..5d6b88010 100644 --- a/src/windows/DeSmuME_2008.vcproj +++ b/src/windows/DeSmuME_2008.vcproj @@ -54,8 +54,7 @@ AdditionalIncludeDirectories=".;..;.\zlib123;.\zziplib;.\winpcap" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX;EXPERIMENTAL_WIFI;HAVE_LIBZZIP;HAVE_LIBZ" ExceptionHandling="1" - BasicRuntimeChecks="3" - BufferSecurityCheck="true" + BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" FloatingPointModel="2" DebugInformationFormat="4" diff --git a/src/windows/ginfo.cpp b/src/windows/ginfo.cpp index 052f64970..717dc8edc 100644 --- a/src/windows/ginfo.cpp +++ b/src/windows/ginfo.cpp @@ -87,35 +87,35 @@ LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam) hdc = BeginPaint(hDlg, &ps); - icontitleOffset = T1ReadLong(MMU_static.CART_ROM, 0x68); + icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); if(icontitleOffset >= 0x8000) { - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x240 + (0x100 * win_fw_config.language)); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240 + (0x100 * win_fw_config.language)); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x240); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x340); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x340); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x440); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x440); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x540); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x540); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x640); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x640); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), text); - utf16text = (wchar_t*)(MMU_static.CART_ROM + icontitleOffset + 0x740); + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x740); sprintf(text, "%ws", utf16text); SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), text); } @@ -132,69 +132,69 @@ LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam) } - memcpy(text, MMU_static.CART_ROM, 12); + memcpy(text, MMU.CART_ROM, 12); text[12] = '\0'; SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMETITLE), text); - memcpy(text, (MMU_static.CART_ROM+0xC), 4); + memcpy(text, (MMU.CART_ROM+0xC), 4); text[4] = '\0'; SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMECODE), text); - memcpy(text, (MMU_static.CART_ROM+0x10), 2); + memcpy(text, (MMU.CART_ROM+0x10), 2); text[2] = '\0'; SetWindowText(GetDlgItem(hDlg, IDC_GI_MAKERCODE), text); - val = T1ReadByte(MMU_static.CART_ROM, 0x14); + val = T1ReadByte(MMU.CART_ROM, 0x14); sprintf(text, "%i kilobytes", (0x80 << val)); SetWindowText(GetDlgItem(hDlg, IDC_GI_CHIPSIZE), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x20); + val = T1ReadLong(MMU.CART_ROM, 0x20); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ROM), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x24); + val = T1ReadLong(MMU.CART_ROM, 0x24); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ENTRY), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x28); + val = T1ReadLong(MMU.CART_ROM, 0x28); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9START), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x2C); + val = T1ReadLong(MMU.CART_ROM, 0x2C); sprintf(text, "%i bytes", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9SIZE), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x30); + val = T1ReadLong(MMU.CART_ROM, 0x30); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ROM), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x34); + val = T1ReadLong(MMU.CART_ROM, 0x34); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ENTRY), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x38); + val = T1ReadLong(MMU.CART_ROM, 0x38); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7START), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x3C); + val = T1ReadLong(MMU.CART_ROM, 0x3C); sprintf(text, "%i bytes", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7SIZE), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x40); + val = T1ReadLong(MMU.CART_ROM, 0x40); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTOFS), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x44); + val = T1ReadLong(MMU.CART_ROM, 0x44); sprintf(text, "%i bytes", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTSIZE), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x48); + val = T1ReadLong(MMU.CART_ROM, 0x48); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_FATOFS), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x4C); + val = T1ReadLong(MMU.CART_ROM, 0x4C); sprintf(text, "%i bytes", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_FATSIZE), text); @@ -202,7 +202,7 @@ LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam) sprintf(text, "0x%08X", icontitleOffset); SetWindowText(GetDlgItem(hDlg, IDC_GI_ICONTITLEOFS), text); - val = T1ReadLong(MMU_static.CART_ROM, 0x80); + val = T1ReadLong(MMU.CART_ROM, 0x80); sprintf(text, "0x%08X", val); SetWindowText(GetDlgItem(hDlg, IDC_GI_USEDROMSIZE), text); @@ -279,7 +279,7 @@ LRESULT GInfo_IconBoxPaint(HWND hCtl, WPARAM wParam, LPARAM lParam) bmph.bV4Width = 32; bmph.bV4Height = -32; - icontitleOffset = T1ReadLong(MMU_static.CART_ROM, 0x68); + icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); if(icontitleOffset >= 0x8000) { @@ -292,14 +292,14 @@ LRESULT GInfo_IconBoxPaint(HWND hCtl, WPARAM wParam, LPARAM lParam) int tiley = (y % 8); int mapoffset = ((tilenum * 64) + (tiley * 8) + tilex); - u8 val = T1ReadByte(MMU_static.CART_ROM, (icontitleOffset + 0x20 + (mapoffset>>1))); + u8 val = T1ReadByte(MMU.CART_ROM, (icontitleOffset + 0x20 + (mapoffset>>1))); if(mapoffset & 1) val = ((val >> 4) & 0xF); else val = (val & 0xF); - icon[(y * 32) + x] = T1ReadWord(MMU_static.CART_ROM, (icontitleOffset + 0x220 + (val<<1))); + icon[(y * 32) + x] = T1ReadWord(MMU.CART_ROM, (icontitleOffset + 0x220 + (val<<1))); } } diff --git a/src/windows/ram_search.cpp b/src/windows/ram_search.cpp index ee63b707a..ad40237c6 100644 --- a/src/windows/ram_search.cpp +++ b/src/windows/ram_search.cpp @@ -31,7 +31,6 @@ #include "ramwatch.h" #include "ram_search.h" -#include "main.h" #include #include #include "ramwatch.h" diff --git a/src/windows/ramwatch.cpp b/src/windows/ramwatch.cpp index 5136609fc..c2f9a2bed 100644 --- a/src/windows/ramwatch.cpp +++ b/src/windows/ramwatch.cpp @@ -4,7 +4,6 @@ #include "NDSSystem.h" #include "ramwatch.h" #include "ram_search.h" -#include "main.h" #include #include #include