Happy Mac!

This commit is contained in:
Jeroen Domburg 2017-03-03 20:27:22 +08:00
parent 5ac2e47a73
commit 5e88ad2df0
4 changed files with 118 additions and 16 deletions

View File

@ -1,6 +1,6 @@
TARGET:=tme TARGET:=tme
MUSASHI_GEN_SRC:=musashi/m68kops.c musashi/m68kopac.c musashi/m68kopdm.c musashi/m68kopnz.c 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 OBJ:=$(MUSASHI_GEN_SRC:%.x=%.o) musashi/m68kcpu.o main.o emu.o disp.o iwm.o via.o
#musashi/m68kdasm.o #musashi/m68kdasm.o
CFLAGS=-Wall -I. -I./musashi -ggdb `sdl2-config --cflags` CFLAGS=-Wall -I. -I./musashi -ggdb `sdl2-config --cflags`
LDFLAGS=`sdl2-config --libs` LDFLAGS=`sdl2-config --libs`

31
emu.c
View File

@ -8,22 +8,13 @@
#include "config.h" #include "config.h"
#include "m68k.h" #include "m68k.h"
#include "disp.h" #include "disp.h"
#include "iwm.h"
#include "via.h"
unsigned char *macRom; unsigned char *macRom;
unsigned char *macRam; unsigned char *macRam;
void viaWrite(unsigned int addr, unsigned int val) { int rom_remap, video_remap=0, audio_remap=0;
printf("VIA write %x val %x\n", addr, val);
}
unsigned int viaRead(unsigned int addr) {
unsigned int val=0;
printf("VIA read %x val %x\n", addr, val);
return val;
}
int rom_remap;
unsigned int m68k_read_memory_8(unsigned int address) { unsigned int m68k_read_memory_8(unsigned int address) {
unsigned int ret; unsigned int ret;
@ -44,7 +35,7 @@ unsigned int m68k_read_memory_8(unsigned int address) {
} else if (address >= 0xE80000 && address < 0xf00000) { } else if (address >= 0xE80000 && address < 0xf00000) {
ret=viaRead((address>>8)&0xf); ret=viaRead((address>>8)&0xf);
} else if (address >= 0xc00000 && address < 0xe00000) { } else if (address >= 0xc00000 && address < 0xe00000) {
ret=iwmRead((address>>8)&0xf); ret=iwmRead((address>>9)&0xf);
} else { } else {
printf("PC %x: Read from %x\n", pc, address); printf("PC %x: Read from %x\n", pc, address);
ret=0xaa; ret=0xaa;
@ -62,7 +53,7 @@ void m68k_write_memory_8(unsigned int address, unsigned int value) {
} else if (address >= 0xE80000 && address < 0xf00000) { } else if (address >= 0xE80000 && address < 0xf00000) {
viaWrite((address>>8)&0xf, value); viaWrite((address>>8)&0xf, value);
} else if (address >= 0xc00000 && address < 0xe00000) { } else if (address >= 0xc00000 && address < 0xe00000) {
iwmWrite((address>>8)&0xf, value); iwmWrite((address>>9)&0xf, value);
} else { } else {
printf("PC %x: Write to %x: %x\n", pc, address, value); printf("PC %x: Write to %x: %x\n", pc, address, value);
} }
@ -80,7 +71,7 @@ void tmeStartEmu(void *rom) {
dispInit(); dispInit();
while(1) { while(1) {
m68k_execute(8000000/60); m68k_execute(8000000/60);
dispDraw(&macRam[0x1A700]); dispDraw(&macRam[video_remap?0x12700:0x1A700]);
// printf("Int!\n"); // printf("Int!\n");
// m68k_set_irq(2); // m68k_set_irq(2);
} }
@ -112,3 +103,13 @@ void m68k_write_memory_16(unsigned int address, unsigned int value) {
m68k_write_memory_8(address, (value>>8)&0xff); m68k_write_memory_8(address, (value>>8)&0xff);
m68k_write_memory_8(address+1, value&0xff); m68k_write_memory_8(address+1, value&0xff);
} }
void viaCbPortAWrite(unsigned int val) {
video_remap=(val&(1<<6))?1:0;
rom_remap=(val&(1<<4))?1:0;
audio_remap=(val&(1<<3))?1:0;
}
void viaCbPortBWrite(unsigned int val) {
}

99
via.c Normal file
View File

@ -0,0 +1,99 @@
#include <stdio.h>
#include <stdint.h>
#include "via.h"
#include "m68k.h"
void viaCbPortAWrite(unsigned int val);
void viaCbPortBWrite(unsigned int val);
typedef struct {
uint8_t ddra;
uint8_t ddrb;
} Via;
static Via via;
void viaWrite(unsigned int addr, unsigned int val) {
if (addr==0x0) {
//ORB
} else if (addr==0x1) {
//ORA
viaCbPortAWrite(val);
} else if (addr==0x2) {
//DDRB
via.ddrb=val;
} else if (addr==0x3) {
//DDRA
via.ddra=val;
} else if (addr==0x4) {
//T1L-L
} else if (addr==0x5) {
//T1C-H
} else if (addr==0x6) {
//T1L-L
} else if (addr==0x7) {
//T1L-H
} else if (addr==0x8) {
//T2L-l
} else if (addr==0x9) {
//T2C-H
} else if (addr==0xa) {
//SR
} else if (addr==0xb) {
//ACR
} else if (addr==0xc) {
//PCR
} else if (addr==0xd) {
//IFR
} else if (addr==0xe) {
//IER
} else if (addr==0xf) {
//ORA
}
printf("VIA write %x val %x\n", addr, val);
}
unsigned int viaRead(unsigned int addr) {
unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC);
unsigned int val=0;
if (addr==0x0) {
//ORB
} else if (addr==0x1) {
//ORA
} else if (addr==0x2) {
//DDRB
val=via.ddrb;
} else if (addr==0x3) {
//DDRA
val=via.ddra;
} else if (addr==0x4) {
//T1L-L
} else if (addr==0x5) {
//T1C-H
} else if (addr==0x6) {
//T1L-L
} else if (addr==0x7) {
//T1L-H
} else if (addr==0x8) {
//T2L-l
} else if (addr==0x9) {
//T2C-H
} else if (addr==0xa) {
//SR
} else if (addr==0xb) {
//ACR
} else if (addr==0xc) {
//PCR
} else if (addr==0xd) {
//IFR
} else if (addr==0xe) {
//IER
} else if (addr==0xf) {
//ORA
}
printf("PC %x VIA read %x val %x\n", pc, addr, val);
return val;
}

2
via.h Normal file
View File

@ -0,0 +1,2 @@
void viaWrite(unsigned int addr, unsigned int val);
unsigned int viaRead(unsigned int addr);