z80 is alive
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 21 Jan 2024 08:17:16 +0000 (10:17 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sun, 21 Jan 2024 08:17:16 +0000 (10:17 +0200)
src/hwregs.h
src/main.c
src/part_dna.c
src/z80.c
src/z80/main.asm
src/z80prog.s

index 2ab7591..22aec5d 100644 (file)
@@ -44,7 +44,7 @@
 #define Z80_MEMMODE                    REG16PTR(0xa11000)
 #define Z80_BUSREQ                     REG16PTR(0xa11100)
 #define Z80_RESET                      REG16PTR(0xa11200)
-#define Z80_MEM                                ((uint8_t*)0xa00000)
+#define Z80_MEM                                ((volatile uint8_t*)0xa00000)
 
 #define VDP_DATA               REG16PTR(VDP_DATA_PORT)
 #define VDP_CTL                        REG16PTR(VDP_CTL_PORT)
index 81e60f8..bfb9d15 100644 (file)
@@ -36,6 +36,15 @@ int main(void)
        part->start();
 
        for(;;) {
+               unsigned char val;
+               z80_grab_bus();
+               while(!z80_have_bus());
+               val = Z80_MEM[0x1ffc];
+               dbgval[3] = (uint32_t)val << 8;
+               val = Z80_MEM[0x1ffd];
+               dbgval[3] |= val;
+               z80_release_bus();
+
                dbg_setcursor(32, 0);
                for(i=0; i<4; i++) {
                        printf("%04x\n", (unsigned int)dbgval[i]);
index af6bc98..76968cb 100644 (file)
@@ -90,8 +90,6 @@ static void particle(int x, int y, int pixsz)
                16
        };
 
-       dbgval[0] = pixsz;
-
        if(pixsz <= 2) {
                szlevel = 0;
                pixsz = 2;
@@ -111,9 +109,6 @@ static void particle(int x, int y, int pixsz)
                pixsz = 32;
        }
 
-       dbgval[1] = szlevel;
-       dbgval[2] = tile;
-
        offs = offstab[pixsz];
 
        switch(szlevel) {
@@ -143,6 +138,4 @@ static void particle(int x, int y, int pixsz)
                spr_add(x - invoffs, y - invoffs, VDP_TILENAME(tile, 1, VDP_TILE_FG | VDP_TILE_HVFLIP), SPR_SIZE(2, 2));
                break;
        }
-
-       dbgval[3] = offs;
 }
index 32ce82e..2c342ff 100644 (file)
--- a/src/z80.c
+++ b/src/z80.c
@@ -13,12 +13,12 @@ void z80_init(void)
        while(!z80_have_bus());
 
        src = z80prog;
-       dest = Z80_MEM;
+       dest = (unsigned char*)Z80_MEM;
        for(i=0; i<z80proglen; i++) {
                *dest++ = *src++;
        }
 
-       z80_reset(1);
        z80_release_bus();
+       z80_reset(1);
        z80_reset(0);
 }
index 0caba8a..1238b54 100644 (file)
@@ -1,17 +1,18 @@
        include "sndregs.inc"
 
        section .vect
-       jp main
-
-       org 38h
+       jr main         ; RST 0
+       dc 6,0
+       dc 6*8, 0       ; RST [1, 7]
        jp vblank_isr
 
 TESTDATA_LEN equ 43
+IPC    equ $1ffc
 
        section .text
 main:  di
-       ld sp, $2000
        im 1
+       ld sp, $1ff0
        call init
        ; iy is left with YMADDR
        ld (iy), YM_OPER
@@ -53,19 +54,19 @@ init:
        ret
 
 ymwait:
-       ld hl, YMADDR
-.wait: ld a, (hl)
+       ld a, (YMADDR)
        bit 7, a
-       jr z, .wait
+       jr nz, ymwait
        ret
 
-
 vblank_isr:
        ex af, af'
        exx
 
        ld hl, frame
        inc (hl)
+       ld a, (hl)
+       ld (IPC+1), a
 
        exx
        ex af, af'
index cb4c961..c34a115 100644 (file)
@@ -7,4 +7,4 @@ z80prog:
        .incbin "z80.bin"
        .align 2
 z80proglen:
-       .long z80prog - z80proglen
+       .long z80proglen - z80prog