ref: 5ea5c3cd1df2baf4463914f3873a322068d15429
parent: a154952ad1179d0bf348aed94c05f0504bb7820b
author: Jean-André Santoni <jean.andre.santoni@gmail.com>
date: Tue Jul 2 10:45:18 EDT 2024
mem = rom + ram
--- a/dat.h
+++ b/dat.h
@@ -11,7 +11,7 @@
extern uint16_t ram[32768];
extern uint8_t *prg;
extern uint8_t *rom;
-extern int nprg;
+extern uint8_t *mem;
extern uint8_t *sram;
extern uint32_t sramctl, sram0, sram1;
--- a/mem.c
+++ b/mem.c
@@ -28,10 +28,10 @@
printf("z80read %x\n", a);uint16_t v;
- if (a < 0x8000)
+ if (a < 0xC000)
return rom[a];
else
- printf("z80read > 0x8000 %x\n", a);+ return mem[a];
}
void
@@ -49,6 +49,30 @@
printf("z80write > 0xE000 %x %x\n", a, v);rom[a] = v;
rom[a - 0x2000] = v;
+
+ switch (a)
+ {+ case 0xFFFC:
+ {+ printf("Persistent RAM");+ break;
+ }
+ case 0xFFFD:
+ {+ printf("Switch mapper slot 0 to %d\n", v);+ break;
+ }
+ case 0xFFFE:
+ {+ printf("Switch mapper slot 1 to %d\n", v);+ break;
+ }
+ case 0xFFFF:
+ {+ printf("Switch mapper slot 2 to %d\n", v);+ break;
+ }
+ }
}
}
--- a/sms.c
+++ b/sms.c
@@ -15,23 +15,25 @@
uint32_t r[16], pc, curpc;
extern uint16_t spc, scurpc, sp;
uint32_t asp, irq, stop;
-int nprg;
uint8_t *sram;
uint32_t sramctl, nsram, sram0, sram1;
int doflush = 0;
-uint8_t header[0x7fff];
-uint8_t *prg = NULL;
+// uint8_t header[0x7fff];
+// uint8_t *prg = NULL;
uint8_t *rom = NULL;
+uint8_t *mem = NULL;
uint32_t pic[256*224] = {0};void
loadrom(const uint8_t *data)
{- memcpy(header, data, sizeof(header));
- prg = malloc(49152);
- memcpy(prg, data+sizeof(header), 49152);
- rom = malloc(49152);
- memcpy(rom, data, 49152);
+ // memcpy(header, data, sizeof(header));
+ // prg = malloc(0xC000);
+ // memcpy(prg, data+sizeof(header), 0xC000);
+ rom = malloc(0xC000);
+ memcpy(rom, data, 0xC000);
+ mem = malloc(0xC000+0x8000);
+ memcpy(mem, rom, 0xC000);
spc = 0;
}
@@ -86,6 +88,8 @@
{}
+int counter = 0;
+
void
retro_run(void)
{@@ -92,11 +96,12 @@
input_poll_cb();
process_inputs();
- while(!doflush){+ // while(!doflush){+ printf("%d ================================\n", counter++);z80step();
- }
+ // }
video_cb(pic, 256, 224, 256*4);
- //audioout();
+ // audioout();
doflush = 0;
}
--
⑨