From 89432abf12b403eee44ceb62382381312daf3c92 Mon Sep 17 00:00:00 2001 From: Romain Dolbeau Date: Tue, 1 Aug 2023 10:26:10 +0200 Subject: [PATCH] preliminary RAM expansion patch --- RomPatcher/IIsiExtraMemory/Makefile | 41 +++++++++++++++++++++ RomPatcher/IIsiExtraMemory/input.txt | 3 ++ RomPatcher/IIsiExtraMemory/rompatch.s | 51 +++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 RomPatcher/IIsiExtraMemory/Makefile create mode 100644 RomPatcher/IIsiExtraMemory/input.txt create mode 100644 RomPatcher/IIsiExtraMemory/rompatch.s diff --git a/RomPatcher/IIsiExtraMemory/Makefile b/RomPatcher/IIsiExtraMemory/Makefile new file mode 100644 index 0000000..01a2f08 --- /dev/null +++ b/RomPatcher/IIsiExtraMemory/Makefile @@ -0,0 +1,41 @@ +RETRO68=/home/dolbeau/Retro68/build/toolchain +AS=${RETRO68}/bin/m68k-apple-macos-as +CC=${RETRO68}/bin/m68k-apple-macos-gcc +LD=${RETRO68}/bin/m68k-apple-macos-ld +STRIP=${RETRO68}/bin/m68k-apple-macos-strip +OBJCOPY=${RETRO68}/bin/m68k-apple-macos-objcopy +NM=${RETRO68}/bin/m68k-apple-macos-nm + +HOSTCC=gcc +HOSTCFLAGS=-O2 + +ARCHFLAGS=-march=68020 -mcpu=68020 +CFLAGS=-O2 -mpcrel + +GENLINK=../patcher/genlink +PATCHER=../patcher/patcher + +all: IIsi.ROM + +show: rompatch.elf + $(NM) $< | sort + +IIsi.ROM: ../IIsiRemoveChecksumCheck/IIsi.ROM rompatch.raw input.txt + /bin/cp ../IIsiRemoveChecksumCheck/IIsi.ROM IIsi.ROM + ${PATCHER} -i rompatch.raw -p IIsi.ROM -d input.txt + +linker.ld: input.txt rompatch.s + ${GENLINK} -d $< >| $@ + $(shell for X in `grep .section rompatch.s | awk '{ print $$2 }' `; do grep -q $$X linker.ld || echo " $$X has no entry in linker.ld" && /bin/false; done) + +rompatch.o: rompatch.s + ${AS} ${ARCHFLAGS} $< -o $@ -a > rompatch.l + +rompatch.elf: linker.ld rompatch.o ${CSRC:.c=.o} # linker script must be first + ${LD} -o $@ -T $^ + +rompatch.raw: rompatch.elf + ${OBJCOPY} $^ $@ --input-target=elf32-m68k --output-target=binary + +clean: + rm -f res.inc ${CSRC_ASM} *.o rompatch.srec rompatch.raw rompatch.dir rompatch.l VidRom*.s diff --git a/RomPatcher/IIsiExtraMemory/input.txt b/RomPatcher/IIsiExtraMemory/input.txt new file mode 100644 index 0000000..368041f --- /dev/null +++ b/RomPatcher/IIsiExtraMemory/input.txt @@ -0,0 +1,3 @@ +0x00396e, 32, raminfo +0x003cc4, 316, gary +0x0419e8, 20, findinfopatch diff --git a/RomPatcher/IIsiExtraMemory/rompatch.s b/RomPatcher/IIsiExtraMemory/rompatch.s new file mode 100644 index 0000000..1b6e67d --- /dev/null +++ b/RomPatcher/IIsiExtraMemory/rompatch.s @@ -0,0 +1,51 @@ + MAPBASE=0x20000000 + MAPSIZE=0x0f000000 + MAPEND=MAPBASE+MAPSIZE + +/* ************************************************************************ */ + /* updated table */ + .section .text.raminfo + .long MAPBASE + .long MAPEND + .long 0x04000000 + .long 0x08000000 + .long 0x00000000 + .long 0x04000000 + .long 0xFFFFFFFF + .long 0xFFFFFFFF + +/* ************************************************************************ */ + .section .text.gary +fixchunk: /* 316 bytes available */ + /* recreate the table but with one more chunk, as the original code assumes two chunks and turns them into three */ + + move.l %D4,(%A1)+ + move.l %D5,(%A1)+ + move.l %D2,(%A1)+ + move.l %D3,(%A1)+ + + add.l %D5,%D4 + move.l %D4,(%A1)+ + move.l %D1,(%A1)+ + + /* here comes the bonus */ + move.l #MAPBASE,(%A1)+ + move.l #MAPSIZE,(%A1)+ + /* here ends the bonus */ + + moveq #-1,%D4 + move.l %D4,(%A1)+ + move.l %D4,(%A1)+ + + jmp (%pc,returnfindinfopatch) + +/* ************************************************************************ */ + .section .text.findinfopatch +findinfopatch: /* 20 bytes available */ + jmp (%pc,fixchunk) + + .section .text.returnfindinfopatch +returnfindinfopatch: + /* */ + + .end