Upgrading to macplus... but now it will not boot :/

This commit is contained in:
Jeroen Domburg 2017-03-04 22:06:00 +08:00
parent 460baa1a7b
commit af3b3f98cc
8 changed files with 59 additions and 16 deletions

View File

@ -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`

View File

@ -1,5 +1,8 @@
#define TME_ROMSIZE (64*1024)
#define TME_ROMSIZE (128*1024)
#define TME_RAMSIZE (128*1024)
#define TME_RAMSIZE (512*1024)
#define TME_SCREENBUF (TME_RAMSIZE-0x5900)
#define TME_SCREENBUF_ALT (TME_RAMSIZE-0xd900)

20
emu.c
View File

@ -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<TME_RAMSIZE; x++) macRam[x]=x;
for (int x=0; x<TME_RAMSIZE; x++) macRam[x]=0xaa;
rom_remap=1;
viaClear(VIA_PORTA, 0x7F);
viaSet(VIA_PORTA, 0x80);
@ -95,7 +99,7 @@ void tmeStartEmu(void *rom) {
m68k_execute(GRAN);
viaStep(GRAN);
}
dispDraw(&macRam[video_remap?0x12700:0x1A700]);
dispDraw(&macRam[video_remap?TME_SCREENBUF_ALT:TME_SCREENBUF]);
frame++;
ca1^=1;
viaControlWrite(VIA_CA1, ca1);

4
iwm.c
View File

@ -27,7 +27,7 @@ void iwmWrite(unsigned int addr, unsigned int val) {
iwmAccess(addr);
int reg=iwmLines&(IWM_Q7|IWM_Q6);
if (reg==0xC0) iwmModeReg=val;
printf("IWM write %x (iwm reg %x) val %x\n", addr, reg, val);
// printf("IWM write %x (iwm reg %x) val %x\n", addr, reg, val);
}
unsigned int iwmRead(unsigned int addr) {
@ -49,6 +49,6 @@ unsigned int iwmRead(unsigned int addr) {
if (iwmLines&IWM_ENABLE) val|=0x20; //enable
val|=iwmModeReg&0x1F;
}
printf("IWM read %x (iwm reg %x) val %x\n", addr, reg, val);
// printf("IWM read %x (iwm reg %x) val %x\n", addr, reg, val);
return val;
}

7
main.c
View File

@ -10,9 +10,14 @@
static void *loadRom(char *file) {
int i;
char *ret=malloc(TME_ROMSIZE);
int f=open(file, O_RDONLY);
read(f, ret, TME_ROMSIZE);
i=read(f, ret, TME_ROMSIZE);
if (i!=TME_ROMSIZE) {
perror("reading rom");
exit(1);
}
return ret;
}

27
ncr.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdint.h>
#include <stdio.h>
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);
}

4
ncr.h Normal file
View File

@ -0,0 +1,4 @@
unsigned int ncrRead(unsigned int addr, unsigned int dack);
void ncrWrite(unsigned int addr,unsigned int dack, unsigned int val);

4
via.c
View File

@ -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;