diff --git a/Makefile b/Makefile index a05e1c8..6e95da8 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ TARGET:=tme MUSASHI_GEN_SRC:=musashi/m68kops.c musashi/m68kopac.c musashi/m68kopdm.c musashi/m68kopnz.c -OBJ:=$(MUSASHI_GEN_SRC:%.x=%.o) musashi/m68kcpu.o main.o emu.o disp.o iwm.o via.o rtc.o +OBJ:=$(MUSASHI_GEN_SRC:%.x=%.o) musashi/m68kcpu.o main.o emu.o disp.o iwm.o via.o rtc.o ncr.o #musashi/m68kdasm.o CFLAGS=-Wall -I. -I./musashi -Og -ggdb `sdl2-config --cflags` LDFLAGS=`sdl2-config --libs` diff --git a/config.h b/config.h index fa9e87c..ccb39b0 100644 --- a/config.h +++ b/config.h @@ -1,5 +1,8 @@ -#define TME_ROMSIZE (64*1024) +#define TME_ROMSIZE (128*1024) -#define TME_RAMSIZE (128*1024) \ No newline at end of file +#define TME_RAMSIZE (512*1024) + +#define TME_SCREENBUF (TME_RAMSIZE-0x5900) +#define TME_SCREENBUF_ALT (TME_RAMSIZE-0xd900) diff --git a/emu.c b/emu.c index 695276c..25a2539 100644 --- a/emu.c +++ b/emu.c @@ -12,6 +12,7 @@ #include "iwm.h" #include "via.h" #include "rtc.h" +#include "ncr.h" unsigned char *macRom; unsigned char *macRam; @@ -28,19 +29,20 @@ unsigned int m68k_read_memory_8(unsigned int address) { ret=macRam[address & (TME_RAMSIZE-1)]; } } else if (address >= 0x600000 && address < 0xA00000) { - ret=macRam[address & (TME_RAMSIZE-1)]; + ret=macRam[(address-0x600000) & (TME_RAMSIZE-1)]; } else if (address >= 0x400000 && address<0x41FFFF) { int romAdr=address-0x400000; - if (romAdr>TME_ROMSIZE) printf("PC %x:Huh? Read from ROM mirror (%x)\n", pc, address); + if (romAdr>=TME_ROMSIZE) printf("PC %x:Huh? Read from ROM mirror (%x)\n", pc, address); ret=macRom[romAdr&(TME_ROMSIZE-1)]; -// rom_remap=0; //HACK } else if (address >= 0xE80000 && address < 0xf00000) { ret=viaRead((address>>9)&0xf); } else if (address >= 0xc00000 && address < 0xe00000) { ret=iwmRead((address>>9)&0xf); + } else if (address >= 0x580000 && address < 0x600000) { + ret=ncrRead((address>>4)&0x7, (address>>7)&1); } else { printf("PC %x: Read from %x\n", pc, address); - ret=0xaa; + ret=0xff; } // printf("Rd %x = %x\n", address, ret); return ret; @@ -48,14 +50,16 @@ unsigned int m68k_read_memory_8(unsigned int address) { void m68k_write_memory_8(unsigned int address, unsigned int value) { unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC); - if (address < 0x400000) { + if (address < 0x400000 && !rom_remap) { macRam[address & (TME_RAMSIZE-1)]=value; } else if (address >= 0x600000 && address < 0xA00000) { - macRam[address & (TME_RAMSIZE-1)]=value; + macRam[(address-0x600000) & (TME_RAMSIZE-1)]=value; } else if (address >= 0xE80000 && address < 0xf00000) { viaWrite((address>>9)&0xf, value); } else if (address >= 0xc00000 && address < 0xe00000) { iwmWrite((address>>9)&0xf, value); + } else if (address >= 0x580000 && address < 0x600000) { + ncrWrite((address>>4)&0x7, (address>>7)&1, value); } else { printf("PC %x: Write to %x: %x\n", pc, address, value); } @@ -82,7 +86,7 @@ void tmeStartEmu(void *rom) { int x, frame=0; macRom=rom; macRam=malloc(TME_RAMSIZE); - for (int x=0; x +#include + + +static const char* const regNamesR[]={ + "CURSCSIDATA","INITIATORCMD", "MODE", "TARGETCMD", "CURSCSISTATUS", + "BUSANDSTATUS", "INPUTDATA", "RESETPARINT" +}; + +static const char* const regNamesW[]={ + "OUTDATA","INITIATORCMD", "MODE", "TARGETCMD", "SELECTENA", + "STARTDMASEND", "STARTDMATARRECV", "STARTDMAINITRECV" +}; + + +unsigned int ncrRead(unsigned int addr, unsigned int dack) { + unsigned int ret=0; + + printf("SCSI: read %s val %x (dack %d)\n", regNamesR[addr], ret, dack); + return ret; +} + + +void ncrWrite(unsigned int addr, unsigned int dack, unsigned int val) { + + printf("SCSI: write %s val %x (dack %d)\n", regNamesW[addr], val, dack); +} diff --git a/ncr.h b/ncr.h new file mode 100644 index 0000000..33a226c --- /dev/null +++ b/ncr.h @@ -0,0 +1,4 @@ + + +unsigned int ncrRead(unsigned int addr, unsigned int dack); +void ncrWrite(unsigned int addr,unsigned int dack, unsigned int val); diff --git a/via.c b/via.c index b29aff6..91da3a6 100644 --- a/via.c +++ b/via.c @@ -156,7 +156,7 @@ void viaWrite(unsigned int addr, unsigned int val) { viaCheckIrq(); } else if (addr==0xa) { //SR - printf("6522: Unimplemented: Write %x to SR?\n", val); +// printf("6522: Unimplemented: Write %x to SR?\n", val); } else if (addr==0xb) { //ACR via.acr=val; @@ -225,7 +225,7 @@ unsigned int viaRead(unsigned int addr) { val=via.timer2>>8; } else if (addr==0xa) { //SR - printf("6522: Unimplemented: Read from SR?\n"); +// printf("6522: Unimplemented: Read from SR?\n"); } else if (addr==0xb) { //ACR val=via.acr;