- int i, u;
- unsigned int addr;
-
- for (i = 0; i < PicoPatchCount; i++)
- {
- addr = PicoPatches[i].addr;
- if (addr < Pico.romsize)
- {
- if (PicoPatches[i].active)
- *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data;
- else {
- // if current addr is not patched by older patch, write back original val
- for (u = 0; u < i; u++)
- if (PicoPatches[u].addr == addr) break;
- if (u == i)
- *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old;
- }
- // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr,
- // *(unsigned short *)(Pico.rom + addr));
- }
- else
- {
- /* TODO? */
- }
- }
+ int i, u;
+ unsigned int addr;
+
+ for (i = 0; i < PicoPatchCount; i++)
+ {
+ addr = PicoPatches[i].addr;
+
+ if (addr < Pico.romsize)
+ {
+ if (PicoPatches[i].active)
+ {
+ if (!(PicoIn.AHW & PAHW_SMS))
+ *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data;
+ else if (!PicoPatches[i].comp || PicoPatches[i].comp == *(char *)(Pico.rom + addr))
+ *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data;
+ }
+ else
+ {
+ // if current addr is not patched by older patch, write back original val
+ for (u = 0; u < i; u++)
+ if (PicoPatches[u].addr == addr) break;
+ if (u == i)
+ {
+ if (!(PicoIn.AHW & PAHW_SMS))
+ *(unsigned short *)(Pico.rom + addr) = PicoPatches[i].data_old;
+ else
+ *(char *)(Pico.rom + addr) = (char) PicoPatches[i].data_old;
+ }
+ }
+ // fprintf(stderr, "patched %i: %06x:%04x\n", PicoPatches[i].active, addr,
+ // *(unsigned short *)(Pico.rom + addr));
+ }
+ else
+ {
+ if (PicoPatches[i].active)
+ {
+ if (!(PicoIn.AHW & PAHW_SMS))
+ m68k_write16(addr,PicoPatches[i].data);
+ else
+ ;// wrong: PicoWrite8_z80(addr,PicoPatches[i].data);
+ }
+ else
+ {
+ // if current addr is not patched by older patch, write back original val
+ for (u = 0; u < i; u++)
+ if (PicoPatches[u].addr == addr) break;
+ if (u == i)
+ {
+ if (!(PicoIn.AHW & PAHW_SMS))
+ m68k_write16(PicoPatches[i].addr,PicoPatches[i].data_old);
+ else
+ ;// wrong: PicoWrite8_z80(PicoPatches[i].addr,PicoPatches[i].data_old);
+ }
+ }
+ }
+ }