Re-enable Z180 internal I/O, add basic ROM which maps the Z180 internal I/O out of...
authorNick Downing <nick@ndcode.org>
Tue, 5 Mar 2019 11:50:30 +0000 (22:50 +1100)
committerNick Downing <nick@ndcode.org>
Tue, 5 Mar 2019 11:50:30 +0000 (22:50 +1100)
.gitignore
Makefile
asxxxx_build.sh [new file with mode: 0755]
roms/z180.asm [new file with mode: 0644]
sim/sim0.cpp
z180/z180ops.h

index 5df3cd3..e0a7194 100644 (file)
@@ -1,4 +1,9 @@
 *.dep
-*.dsk
+*.ihx
 *.o
+*.rel
+/asxs5p30.zip
+/asxxxx_build
+/bin
+/disks
 /fuzix_sim
index 524672e..ba9416b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,9 @@
-CPPFLAGS=-DCONFDIR=\".\" -DDISKSDIR=\".\" -I.
+CPPFLAGS=-DCONFDIR=\"conf\" -DDISKSDIR=\"disks\" -DROMSDIR=\"roms\" -I.
 CXXFLAGS=-g
 
+all: fuzix_sim roms/z180.ihx
+#bin
+
 fuzix_sim: \
 iodevices/unix_terminal.o \
 sim/config.o \
@@ -25,8 +28,16 @@ sim/simglb.o: sim/simglb.cpp
 sim/simint.o: sim/simint.cpp
 z180/z180.o: z180/z180.cpp
 
+%.rel: %.asm
+       bin/asz80 -o $<
+%.ihx: %.rel
+       bin/aslink -i $<
+%.bin: %.ihx
+       objcopy --input-target=ihex --output-target=binary $< $@
+
 clean:
        rm -f fuzix_sim iodevices/*.o sim/*.o z180/*.o
+       rm -f rom/*.bin rom/*.rel rom/*.ihx
 
 -include iodevices/unix_terminal.dep
 -include sim/iosim.dep
diff --git a/asxxxx_build.sh b/asxxxx_build.sh
new file mode 100755 (executable)
index 0000000..c398009
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# put asxs5p30.zip in current directory first
+# wget http://shop-pdp.net/_ftp/asxxxx/asxs5p30.zip
+
+rm -rf asxxxx_build
+mkdir asxxxx_build
+(cd asxxxx_build && unzip -L -a ../asxs5p30)
+(cd asxxxx_build/asxv5pxx/asxmak/linux/build && make asz80 aslink)
+mkdir --parents bin
+cp asxxxx_build/asxv5pxx/asxmak/linux/exe/as* bin
diff --git a/roms/z180.asm b/roms/z180.asm
new file mode 100644 (file)
index 0000000..f1a8dc2
--- /dev/null
@@ -0,0 +1,70 @@
+       .z180
+
+IOCR           = 0x3f
+
+CONSOLE_DATA   = 1
+
+FDC_DRIVE      = 10
+FDC_TRACK      = 11
+FDC_SECTOR_LO  = 12
+FDC_COMMAND    = 13
+FDC_STATUS     = 14
+FDC_ADDR_LO    = 15
+FDC_ADDR_HI    = 16
+FDC_SECTOR_HI  = 17
+
+MMU_INIT       = 20
+MMU_BANK_SEL   = 21
+MMU_SEG_SIZE   = 22
+MMU_WRITE_PROT = 23
+
+       ld      hl,loader
+       ld      de,0x1000
+       ld      bc,loader_end-loader
+       ldir
+       jp      0x1000
+
+loader:
+       ; use in0/out0 for internal registers
+       ld      a,0xc0
+       out0    (IOCR),a                ; remap Z180 internal I/O to c0-ff
+
+       ; use in/out for simulation registers (high address not decoded)
+       ;sub    a
+       ;out    (MMU_BANK_SEL),a        ; go to first bank (RAM)
+       ;ld     a,0xc0
+       ;out    (MMU_SEG_SIZE),a        ; 48 kbyte
+       ;ld     a,1
+       ;out    (MMU_INIT),a            ; 1 bank
+
+       ; read drive 0 track 0 sector 1 to address 0
+       sub     a
+       out     (FDC_DRIVE),a
+       out     (FDC_TRACK),a
+       ld      a,1
+       out     (FDC_SECTOR_LO),a
+       sub     a
+       out     (FDC_SECTOR_HI),a
+       out     (FDC_ADDR_LO),a
+       out     (FDC_ADDR_HI),a
+       out     (FDC_COMMAND),a
+       in      a,(FDC_STATUS)
+       or      a
+       jp      z,0
+
+       ; read has failed, print message
+       ld      hl,message-loader+0x1000
+message_loop:
+       ld      a,(hl)
+       or      a
+1$:    jr      z,1$
+       out     (CONSOLE_DATA),a
+       inc     hl
+       jr      message_loop
+
+message:
+       .ascii  'Error reading boot sector\r\n\0'
+
+loader_end:
+
+       .end
index d651fed..1a8a20a 100644 (file)
@@ -508,9 +508,6 @@ int load_core(void)
  */
 int load_file(char *s)
 {
-#if 1
- assert(false);
-#else
        char fn[LENCMD];
        BYTE fileb[5];
        register char *pfn = fn;
@@ -542,10 +539,8 @@ int load_file(char *s)
                close(fd);
                return (load_hex(fn));
        }
-#endif
 }
 
-#if 0
 /*
  *     Loader for binary images with Mostek header.
  *     Format of the first 3 bytes:
@@ -575,7 +570,11 @@ static int load_mos(int fd, char *fn)
        printf("END   : %04x\n", (unsigned int)(wrk_ram - mem_base()
                                 + readn - 1));
        printf("LOADED: %04x\n\n", readn);
+#if 1
+ static_cast<z180_device *>(cpu_dev)->m_PC.w.l = wrk_ram - mem_base();
+#else
        PC = wrk_ram - mem_base();
+#endif
        return(rc);
 }
 
@@ -653,7 +652,11 @@ static int load_hex(char *fn)
        printf("START : %04xH\n", saddr);
        printf("END   : %04xH\n", eaddr);
        printf("LOADED: %04xH (%d)\n\n", count, count);
+#if 1
+ static_cast<z180_device *>(cpu_dev)->m_PC.w.l = saddr;
+#else
        PC = saddr;
+#endif
        wrk_ram = mem_base() + saddr;
 
        return(0);
@@ -682,4 +685,3 @@ static int checksum(char *s)
        else
                return(1);
 }
-#endif
index febe58e..7abef5e 100644 (file)
  ***************************************************************/
 inline u8 z180_device::IN(u16 port)
 {
-#if 0 // temporary
        if(((port ^ IO_IOCR) & 0xffc0) == 0)
                return z180_readcontrol(port);
-#endif
        m_extra_cycles += ((IO_DCNTL & (Z180_DCNTL_IWI1 | Z180_DCNTL_IWI0)) >> 4) + 1; // external I/O wait states
        return m_iospace->read_byte(port);
 }
@@ -37,11 +35,9 @@ inline u8 z180_device::IN(u16 port)
  ***************************************************************/
 inline void z180_device::OUT(u16 port, u8 value)
 {
-#if 0 // temporary
        if (((port ^ IO_IOCR) & 0xffc0) == 0) {
                z180_writecontrol(port,value);
        } else
-#endif
        {
                m_extra_cycles += ((IO_DCNTL & (Z180_DCNTL_IWI1 | Z180_DCNTL_IWI0)) >> 4) + 1; // external I/O wait states
                m_iospace->write_byte(port, value);