From 6b0c90a9a3cfcf259291b4d14565f46e00c18f20 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 26 Oct 2014 17:44:22 +0200 Subject: [PATCH] megaed-sv: z80 init --- megaed-sv/main.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/megaed-sv/main.c b/megaed-sv/main.c index 4473c5c..24a2528 100644 --- a/megaed-sv/main.c +++ b/megaed-sv/main.c @@ -36,6 +36,8 @@ extern u16 start_hvc; *((volatile u16 *) (a)) #define read32(a) \ *((volatile u32 *) (a)) +#define write8(a, d) \ + *((volatile u8 *) (a)) = (d) #define write16(a, d) \ *((volatile u16 *) (a)) = (d) #define write32(a, d) \ @@ -528,6 +530,25 @@ static int do_run(OsRoutine *ed, u8 b3, int tas_sync) return -1; } +void setup_z80(void) +{ + u8 *mem = (u8 *)0xa00000; + int i; + + write8(0xa11100, 1); + write8(0xa11200, 1); + + while (read8(0xa11100) & 1) + ; + + /* must use byte access */ + for (i = 0x2000; i > 0; i--) + *mem++ = 0; + + /* console starts with reset on, busreq off, + * gens starts with busreq on, keep that for gmv.. */ +} + int main() { OsRoutine *ed; @@ -538,6 +559,10 @@ int main() ed = (OsRoutine *) *(u32 *)0x1A0; ed->memInitDmaCode(); + /* setup VDP */ + while (read16(GFX_CTRL_PORT) & 2) + ; + ed->VDP_setReg(VDP_MODE1, 0x04); ed->VDP_setReg(VDP_MODE2, 0x64); ed->VDP_setReg(VDP_AUTOINC, 2); @@ -559,11 +584,14 @@ int main() /* note: relying on ED menu's font setup here.. */ printf("\n"); - printf("version: %02x, start_hvc: %04x\n", - read8(0xa10001), start_hvc); + printf("version: %02x, hvc: %04x %04x, zbus: %d\n", + read8(0xa10001), start_hvc, read16(GFX_CTRL_PORT), + read8(0xa11100) & 1); printf("ED os/fw: %d/%d\n\n", ed->osGetOsVersion(), ed->osGetFirmVersion()); + setup_z80(); + for (;;) { if (!ed->usbRdReady()) { /* note: stop corrupts SDRAM */ -- 2.39.5