static inline void S9xApplyCheat_ex(unsigned int start, unsigned int num) { unsigned int i, m; unsigned int address, len; for(i = 0; i < num; i++) { address = Cheat.c[start+i].address; len = Cheat.c[start+i].part_len; int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK; unsigned char *ptr = Memory.Map [block]; if(1 == len) { if (ptr >= (uint8 *) CMemory::MAP_LAST) *(ptr + (address & 0xffff)) = Cheat.c[start+i].byte; else S9xSetByte (Cheat.c[start+i].byte, address); } else { for(m= 0; m < len; m++) { if (ptr >= (uint8 *) CMemory::MAP_LAST) *(ptr + (address & 0xffff)) = Cheat.c[start+i].name[m]; else S9xSetByte (Cheat.c[start+i].name[m], address); } } } }
void asm_S9xSetByte(uint32 Address,uint8 value) { #ifdef __debug_c_io__ printf("sb\n"); #endif S9xSetByte(value,Address); }
static void S9xSetByteFree (uint8 byte, uint32 address) { int32 Cycles = CPU.Cycles; int32 NextEvent = CPU.NextEvent; CPU.NextEvent = 0x7FFFFFFF; S9xSetByte(byte, address); CPU.NextEvent = NextEvent; CPU.Cycles = Cycles; }
void S9xRemoveCheat (uint32 which1) { if (Cheat.c [which1].saved) { uint32 address = Cheat.c [which1].address; int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK; uint8 *ptr = Memory.Map [block]; if (ptr >= (uint8 *) CMemory::MAP_LAST) *(ptr + (address & 0xffff)) = Cheat.c [which1].saved_byte; else S9xSetByte (address, Cheat.c [which1].saved_byte, &CPU); }