Sad mac, yay!

This commit is contained in:
Jeroen Domburg 2017-03-03 16:29:47 +08:00
parent ad726c6e80
commit 1dd8ded327
3 changed files with 21 additions and 13 deletions

View File

@ -2,8 +2,8 @@ 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 OBJ:=$(MUSASHI_GEN_SRC:%.x=%.o) musashi/m68kcpu.o main.o emu.o disp.o
#musashi/m68kdasm.o #musashi/m68kdasm.o
CFLAGS=-Wall -I. -I./musashi -ggdb CFLAGS=-Wall -I. -I./musashi -ggdb `sdl2-config --cflags`
LDFLAGS= LDFLAGS=`sdl2-config --libs`
$(TARGET): $(OBJ) $(TARGET): $(OBJ)
$(CC) -o $(@) $(CFLAGS) $(LDFLAGS) $^ $(CC) -o $(@) $(CFLAGS) $(LDFLAGS) $^

8
disp.c
View File

@ -1,6 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL/SDL.h> #include <SDL2/SDL.h>
const int SCREEN_WIDTH = 512; const int SCREEN_WIDTH = 512;
const int SCREEN_HEIGHT = 342; const int SCREEN_HEIGHT = 342;
@ -25,12 +25,12 @@ void dispInit() {
void dispDraw(char *mem) { void dispDraw(char *mem) {
int x, y, z; int x, y, z;
uint32_t pixels=drwsurf->pixels;
SDL_LockSurface(drwsurf); SDL_LockSurface(drwsurf);
uint32_t *pixels=(uint32_t*)drwsurf->pixels;
for (y=0; y<SCREEN_HEIGHT; y++) { for (y=0; y<SCREEN_HEIGHT; y++) {
for (x=0; x<SCREEN_WIDTH; x+=8) { for (x=0; x<SCREEN_WIDTH; x+=8) {
for (z=1; z!=0x100; z++) { for (z=0x80; z!=0; z>>=1) {
if (*mem&z) *pixels=0xFFFFFF; else *pixels=0; if (*mem&z) *pixels=0xFF000000; else *pixels=0xFFFFFFFF;
pixels++; pixels++;
} }
mem++; mem++;

22
emu.c
View File

@ -17,17 +17,20 @@ 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;
unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC); unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC);
if (rom_remap && address < TME_ROMSIZE) { if (rom_remap && address < 0x400000) {
ret=macRom[address]; ret=macRom[address & (TME_ROMSIZE-1)];
} else if (address < TME_RAMSIZE) { } else if (rom_remap && address > 0x600000 && address <= 0xA00000) {
ret=macRam[address]; ret=macRam[address & (TME_RAMSIZE-1)];
} else if (address < 0x400000) {
ret=macRam[address & (TME_RAMSIZE-1)];
} else if (address>0x400000 && address<0x41FFFF) { } else if (address>0x400000 && address<0x41FFFF) {
int romAdr=address-0x400000; 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)]; ret=macRom[romAdr&(TME_ROMSIZE-1)];
// rom_remap=0; //HACK
} else { } else {
printf("PC %x: Read from %x\n", pc, address); printf("PC %x: Read from %x\n", pc, address);
ret=0xff; ret=rand();
} }
// printf("Rd %x = %x\n", address, ret); // printf("Rd %x = %x\n", address, ret);
return ret; return ret;
@ -35,8 +38,10 @@ unsigned int m68k_read_memory_8(unsigned int address) {
void m68k_write_memory_8(unsigned int address, unsigned int value) { void m68k_write_memory_8(unsigned int address, unsigned int value) {
unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC); unsigned int pc=m68k_get_reg(NULL, M68K_REG_PC);
if (address < TME_RAMSIZE) { if (address < 0x400000) {
macRam[address]=value; macRam[address & (TME_RAMSIZE-1)]=value;
} else if (rom_remap && address > 0x600000 && address <= 0xA00000) {
macRam[address & (TME_RAMSIZE-1)]=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);
} }
@ -46,6 +51,7 @@ void m68k_write_memory_8(unsigned int address, unsigned int value) {
void tmeStartEmu(void *rom) { void tmeStartEmu(void *rom) {
macRom=rom; macRom=rom;
macRam=malloc(TME_RAMSIZE); macRam=malloc(TME_RAMSIZE);
for (int x=0; x<TME_RAMSIZE; x++) macRam[x]=x;
rom_remap=1; rom_remap=1;
m68k_init(); m68k_init();
m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_set_cpu_type(M68K_CPU_TYPE_68000);
@ -54,6 +60,8 @@ void tmeStartEmu(void *rom) {
while(1) { while(1) {
m68k_execute(8000000/60); m68k_execute(8000000/60);
dispDraw(&macRam[0x1A700]); dispDraw(&macRam[0x1A700]);
printf("Int!\n");
// m68k_set_irq(2);
} }
} }