From: Pokemonhacker <pok...@us...> - 2005-06-25 06:15:08
|
Update of /cvsroot/vba/VisualBoyAdvance/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8093 Modified Files: Cheats.cpp Log Message: - Added a very basic master code support for AR/GS/GSA/CB. It only works for arm/thumb branches (ie. 95%+ of the (m) codes). Useful for cheatcodes that need to be enable at a specific instruction (like Pokemon cheatcodes). Only one master code can be enabled (the last one on the list is enabled, the other are disabled). If no (m) codes are entered (or if they are all disabled), VBA executed the cheats on each LCD line (like it used to be on the other versions). But we strongly recommend that, from now on, you enter the full (m) code and ID code when they are avaible, to prevent any crash due from codes not working properly. - Now the VBA 16/32bits 'Codes...' accept any 'valid' memory area (from 0x02 to 0x0D). If you miss the ability to enable more than 3 GSA Rom Patching Codes (VBA 1.7.2), or to use CBA codes that could change the ROM area, you just have now to use 'Codes...' to reproduct these effects. And the VBA 8bits 'Codes...' can now access the 0x02-0x07 memory range. Index: Cheats.cpp =================================================================== RCS file: /cvsroot/vba/VisualBoyAdvance/src/Cheats.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Cheats.cpp 18 Dec 2004 23:09:56 -0000 1.25 --- Cheats.cpp 25 Jun 2005 06:14:57 -0000 1.26 *************** *** 1,5 **** // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // Copyright (C) 1999-2003 Forgotten ! // Copyright (C) 2004 Forgotten and the VBA development team // This program is free software; you can redistribute it and/or modify --- 1,5 ---- // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator. // Copyright (C) 1999-2003 Forgotten ! // Copyright (C) 2005 Forgotten and the VBA development team // This program is free software; you can redistribute it and/or modify *************** *** 193,196 **** --- 193,199 ---- #define GSA_16_BIT_MIF_LOWER_OR_EQ_U 110 #define GSA_16_BIT_MIF_HIGHER_OR_EQ_U 111 + #define MASTER_CODE 112 + #define CHEATS_16_BIT_WRITE 114 + #define CHEATS_32_BIT_WRITE 115 CheatsData cheatsList[100]; *************** *** 206,209 **** --- 209,213 ---- bool cheatsCBATableGenerated = false; u16 super = 0; + extern u32 mastercode; u8 cheatsCBACurrentSeed[12] = { *************** *** 316,320 **** #define CHEAT_PATCH_ROM_16BIT(a,v) \ ! WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v); static bool isMultilineWithData(int i) --- 320,327 ---- #define CHEAT_PATCH_ROM_16BIT(a,v) \ ! WRITE16LE(((u16 *)&rom[(a) & 0x1ffffff]), v); ! ! #define CHEAT_PATCH_ROM_32BIT(a,v) \ ! WRITE32LE(((u32 *)&rom[(a) & 0x1ffffff]), v); static bool isMultilineWithData(int i) *************** *** 435,438 **** --- 442,448 ---- case GSA_16_BIT_MIF_LOWER_OR_EQ_U: case GSA_16_BIT_MIF_HIGHER_OR_EQ_U: + case MASTER_CODE: + case CHEATS_16_BIT_WRITE: + case CHEATS_32_BIT_WRITE: return false; // the codes below have two lines of data *************** *** 559,562 **** --- 569,575 ---- case GSA_16_BIT_MIF_LOWER_OR_EQ_U: case GSA_16_BIT_MIF_HIGHER_OR_EQ_U: + case MASTER_CODE: + case CHEATS_16_BIT_WRITE: + case CHEATS_32_BIT_WRITE: return 1; case CBA_IF_KEYS_PRESSED: *************** *** 572,577 **** { bool onoff = true; ! int ticks = 1; int i; for (i = 0; i<4; i++) if (rompatch2addr [i] != 0) { --- 585,592 ---- { bool onoff = true; ! int ticks = 0; int i; + mastercode = 0; + for (i = 0; i<4; i++) if (rompatch2addr [i] != 0) { *************** *** 713,716 **** --- 728,734 ---- i++; break; + case MASTER_CODE: + mastercode = cheatsList[i].address; + break; } if (onoff) { *************** *** 1290,1293 **** --- 1308,1325 ---- } break; + case CHEATS_16_BIT_WRITE: + if ((cheatsList[i].address>>24)>=0x08) { + CHEAT_PATCH_ROM_16BIT(cheatsList[i].address, cheatsList[i].value); + } else { + CPUWriteHalfWord(cheatsList[i].address, cheatsList[i].value); + } + break; + case CHEATS_32_BIT_WRITE: + if ((cheatsList[i].address>>24)>=0x08) { + CHEAT_PATCH_ROM_32BIT(cheatsList[i].address, cheatsList[i].value); + } else { + CPUWriteMemory(cheatsList[i].address, cheatsList[i].value); + } + break; } } *************** *** 1331,1334 **** --- 1363,1372 ---- cheatsList[x].oldValue = CPUReadMemory(address); break; + case CHEATS_16_BIT_WRITE: + cheatsList[x].oldValue = CPUReadHalfWord(address); + break; + case CHEATS_32_BIT_WRITE: + cheatsList[x].oldValue = CPUReadMemory(address); + break; } cheatsNumber++; *************** *** 1352,1355 **** --- 1390,1406 ---- CPUWriteMemory(cheatsList[x].address, cheatsList[x].oldValue); break; + case CHEATS_16_BIT_WRITE: + if ((cheatsList[x].address>>24)>=0x08) { + CHEAT_PATCH_ROM_16BIT(cheatsList[x].address, cheatsList[x].oldValue); + } else { + CPUWriteHalfWord(cheatsList[x].address, cheatsList[x].oldValue); + } + break; + case CHEATS_32_BIT_WRITE: + if ((cheatsList[x].address>>24)>=0x08) { + CHEAT_PATCH_ROM_32BIT(cheatsList[x].address, cheatsList[x].oldValue); + } else { + CPUWriteMemory(cheatsList[x].address, cheatsList[x].oldValue); + } case GSA_16_BIT_ROM_PATCH: if(cheatsList[x].status & 1) { *************** *** 1360,1370 **** break; case GSA_16_BIT_ROM_PATCH2C: ! case GSA_16_BIT_ROM_PATCH2D: ! case GSA_16_BIT_ROM_PATCH2E: ! case GSA_16_BIT_ROM_PATCH2F: if(cheatsList[x].status & 1) { cheatsList[x].status &= ~1; } break; } } --- 1411,1424 ---- break; case GSA_16_BIT_ROM_PATCH2C: ! case GSA_16_BIT_ROM_PATCH2D: ! case GSA_16_BIT_ROM_PATCH2E: ! case GSA_16_BIT_ROM_PATCH2F: if(cheatsList[x].status & 1) { cheatsList[x].status &= ~1; } break; + case MASTER_CODE: + mastercode=0; + break; } } *************** *** 1388,1391 **** --- 1442,1446 ---- if(i >= 0 && i < cheatsNumber) { cheatsList[i].enabled = true; + mastercode = 0; } } *************** *** 1410,1413 **** --- 1465,1471 ---- } break; + case MASTER_CODE: + mastercode=0; + break; } cheatsList[i].enabled = false; *************** *** 1455,1460 **** switch(address >> 24) { ! case 2: ! case 3: break; default: --- 1513,1528 ---- switch(address >> 24) { ! case 0x02: ! case 0x03: ! case 0x04: ! case 0x05: ! case 0x06: ! case 0x07: ! case 0x08: ! case 0x09: ! case 0x0A: ! case 0x0B: ! case 0x0C: ! case 0x0D: break; default: *************** *** 1469,1475 **** int type = 0; if(len == 13) ! type = 1; if(len == 17) ! type = 2; cheatsAdd(code, desc, address, address, value, type, type); return true; --- 1537,1543 ---- int type = 0; if(len == 13) ! type = 114; if(len == 17) ! type = 115; cheatsAdd(code, desc, address, address, value, type, type); return true; *************** *** 1588,1591 **** --- 1656,1668 ---- int type = ((address >> 25) & 127) | ((address >> 17) & 0x80); u32 addr = (address & 0x00F00000) << 4 | (address & 0x0003FFFF); + u16 mcode = (address>>24 & 0xFF); + + if ((mcode & 0xFE) == 0xC4) + { + cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | (0x08000000), + value, 257, MASTER_CODE); + mastercode = (address & 0x1FFFFFF) | (0x08000000); + } + else switch(type) { case 0x00: *************** *** 1802,1806 **** cheatsAdd(code, desc, address, addr, value, 257, GSA_32_BIT_IF_TRUE3); break; ! case 0x47: cheatsAdd(code, desc, address, addr, value, 257, GSA_ALWAYS3); break; --- 1879,1883 ---- cheatsAdd(code, desc, address, addr, value, 257, GSA_32_BIT_IF_TRUE3); break; ! case 0x47: cheatsAdd(code, desc, address, addr, value, 257, GSA_ALWAYS3); break; *************** *** 1933,1937 **** cheatsAdd(code, desc, address, address & 0x0F0FFFFF, 0, 256, GSA_32_BIT_GS_WRITE); ! break; case 15: cheatsAdd(code, desc, address, 0, value & 0xFFFF, 256, GSA_SLOWDOWN); --- 2010,2014 ---- cheatsAdd(code, desc, address, address & 0x0F0FFFFF, 0, 256, GSA_32_BIT_GS_WRITE); ! break; case 15: cheatsAdd(code, desc, address, 0, value & 0xFFFF, 256, GSA_SLOWDOWN); *************** *** 1996,2002 **** UNKNOWN_CODE); break; ! } ! break; ! default: // unsupported code cheatsAdd(code, desc, address, address, value, 256, --- 2073,2083 ---- UNKNOWN_CODE); break; ! } ! break; ! case 0x0f: ! cheatsAdd(code, desc, address, (address & 0xFFFFFFF), value, 256, MASTER_CODE); ! mastercode = (address & 0xFFFFFFF); ! break; ! default: // unsupported code cheatsAdd(code, desc, address, address, value, 256, *************** *** 2467,2470 **** --- 2548,2555 ---- } break; + case 0x01: + cheatsAdd(code, desc, address, (address & 0x1FFFFFF) | 0x08000000, value, 512, MASTER_CODE); + mastercode = (address & 0x1FFFFFF) | 0x08000000; + break; case 0x02: cheatsAdd(code, desc, address, address & 0x0FFFFFFE, value, 512, |