]> github.com/historicalsource and other repositories - defender-1.git/commitdiff
Add Red Label build
authorRobert Hogan <robhogan@gmail.com>
Sun, 11 Jul 2021 16:43:51 +0000 (17:43 +0100)
committerRobert Hogan <robhogan@gmail.com>
Sun, 11 Jul 2021 17:11:11 +0000 (18:11 +0100)
PatchROM.py [new file with mode: 0755]
orig/WilliamsArcadeClassics/README.md [new file with mode: 0644]

index 53d3eece69f80951a7695ae351907a4d07832742..e760d00212ace93602b709568af87cb16dc7daa8 100755 (executable)
@@ -14,8 +14,10 @@ if len(sys.argv) < 2:
 romname = sys.argv[1]
 rom = open(romname, 'wb')
-rom_data = bytearray([0xff] * 0xFFFF)
-for a in sys.argv[2:]:
+romlength = int(sys.argv[2],16)
+rom_data = bytearray([0xff] * romlength)
+for a in sys.argv[3:]:
     args = a.split(',')
     fn = args[0]
     nm = args[-1:]
index 299c76143d6c21ec12fb76f8806a8a1950ef5051..a1a1fd4db79a071bdb140dd3d8af97168b37f132 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 .PHONY: all clean
 all: clean 
@@ -42,8 +43,9 @@ defender:
        ./asm6809/src/asm6809 -B src/mess0.src src/romf8.src src/romc0.src src/romc8.src\
                        -l bin/roms.lst -o bin/roms.o
+# Recreate the uncompressed ROM images in DEFENDER.EXE
 defender.rom: defender
-       ./ChainFilesToRom.py defender.rom\
+       ./ChainFilesToRom.py defender.rom 0xffff\
                bin/defa7-defb6-amode1.o,0xaeea,0x8ee9,0x0117,"amode tail"\
@@ -58,9 +60,71 @@ defender.rom: defender
                bin/defa7-defb6.o,0x0371,0xd000,0x2c60,"defa7 defb6"\
                bin/defa7-defb6.o,0x32c9,0xff58,0x0230,"defa7 defb6 2"
        echo "e15b3930a1e827bc967a3e84b3be259a  defender.rom" | md5sum -c
+# Recreate the binaries in the Red Label ROM board from the objects we assembled in
+# the 'defender' section above. Store them in the 'redlabel' directory.
+redlabel: defender
+       $(shell mkdir -p $(REDLABEL))
+       # defend.1
+       ./ChainFilesToRom.py redlabel/defend.1 0x800\
+               bin/defa7-defb6-amode1.o,0xb001,0x0000,0x0800,"defa7"
+       echo "c9eb365411ca8452debe66e7b7657f44  redlabel/defend.1" | md5sum -c
+       # defend.2
+       ./ChainFilesToRom.py redlabel/defend.2 0x1000\
+               bin/defa7-defb6-amode1.o,0xc001,0x0000,0x1000,"defa7"
+       ./PatchROM.py redlabel/defend.2\
+               0x07c5,'27fc'
+       echo "5e85f9851217645508c36cf33762342f  redlabel/defend.2" | md5sum -c
+       # defend.3
+       ./ChainFilesToRom.py redlabel/defend.3 0x1000\
+               bin/defa7-defb6-amode1.o,0xd001,0x0000,0x0c60,"defa7"\
+               bin/samexap7.o,0x0001,0x0c60,0x02f8,"samexap"\
+               bin/defa7-defb6-amode1.o,0xdf59,0x0f58,0x0230,"defa7"
+       echo "f20a652ed2f1497fe899c414d15245a8  redlabel/defend.3" | md5sum -c
+       # defend.4
+       ./ChainFilesToRom.py redlabel/defend.4 0x0800\
+               bin/defa7-defb6-amode1.o,0xb801,0x0000,0x0800,"defa7"
+       echo "a652dd9a550e1d33f55e76ba954f8999  redlabel/defend.4" | md5sum -c
+       # defend.6
+       ./ChainFilesToRom.py redlabel/defend.6 0x0800\
+               bin/blk71.o,0x0001,0x0000,0x0772,"blk71"\
+               bin/roms.o,0xa779,0x0778,0x0088,"romc0"
+       ./PatchROM.py redlabel/defend.6\
+               0x0772,'000000000000'\
+               0x00de,'afb4'\
+               0x07f0,'17'
+       echo "fadaacee0e506f701ea3e61dfa23c548  redlabel/defend.6" | md5sum -c
+       # defend.7
+       ./ChainFilesToRom.py redlabel/defend.7 0x0800\
+               bin/roms.o,0xa001,0x0000,0x0800,"roms"
+       echo "5b9d4e0664e01c48560b05d5941ee908  redlabel/defend.7" | md5sum -c
+       # defend.8
+       ./ChainFilesToRom.py redlabel/defend.8 0x0800\
+               bin/roms.o,0x0001,0x0000,0x0800,"roms"
+       echo "dd4d18f5d3d14ab94f09b05335da3bf4  redlabel/defend.8" | md5sum -c
+       # defend.9
+       ./ChainFilesToRom.py redlabel/defend.9 0x0800\
+               bin/defa7-defb6-amode1.o,0x0001,0x0000,0x0800,"defa7"
+       echo "3de0cf05f6ee1fd7da6ccaba93fce3fc  redlabel/defend.9" | md5sum -c
+       # defend.10
+       ./ChainFilesToRom.py redlabel/defend.10 0x0800\
+               bin/roms.o,0xa801,0x0000,0x0800,"roms"
+       ./PatchROM.py redlabel/defend.10\
+               0x07f0,'4a'
+       echo "7bd2ddcb4ce8c5ceb8150b61cb2a2335  redlabel/defend.10" | md5sum -c
+       # defend.11
+       ./ChainFilesToRom.py redlabel/defend.11 0x0800\
+               bin/roms.o,0x0801,0x0000,0x0800,"roms"\
+               orig/defender-redlabel/defend.11,0x0451,0x0450,0x0800,"roms"
+       echo "0fda70334d594b58cd26ad032be16c4b  redlabel/defend.11" | md5sum -c
+       # defend.12
+       ./ChainFilesToRom.py redlabel/defend.12 0x0800\
+               bin/defa7-defb6-amode1.o,0x0801,0x0000,0x0800,"defa7"\
+               bin/defa7-defb6-amode1.o,0xaeea,0x06e9,0x0117,"amode tail"
+       echo "8115fdb8540e93d38e036f007e19459a  redlabel/defend.12" | md5sum -c
        -rm bin/*.o
        -rm bin/*.lst
diff --git a/PatchROM.py b/PatchROM.py
new file mode 100755 (executable)
index 0000000..999496d
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env python3
+Patch a rom file with the given bytes at the given position
+import sys
+import os
+if len(sys.argv) < 2:
+    print("Not enough filenames given")
+    exit()
+romname = sys.argv[1]
+bs = bytearray(open(romname, 'rb').read())
+for a in sys.argv[2:]:
+    args = a.split(',')
+    to = int(args[0],16)
+    p = bytearray.fromhex(args[1])
+    bs[to:to+len(p)] = p
+# Write the patched bytes
+rom = open(romname, 'wb')
index e0a2ca08e442c327688f7b0e5869278093fd0606..06b8b5cd29fe5f626ba15ca354c3673b4f6820e9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ The source code can be compiled into an executable that you can run it in Window
   * [Build the assembler toolchain](#build-the-assembler-toolchain)
   * [Build Defender](#build-defender)
 * [Play Defender](#play-defender)
-* [Notes on the Source Code](#notes-on-the-source-code)
+* [Notes on the Source Code, ROM Files, and the Physical Circuit Boards](#notes-on-the-source-code-rom-files-and-the-physical-circuit-boards)
 <!-- vim-markdown-toc -->
 ## Build Instructions
@@ -48,27 +48,39 @@ cd ..
 ### Build Defender
-To build the rom image `defender.rom`:
+To build the rom image `defender.rom` that is embedded in the [Williams Arcade
+Classics]() release of [`defender.exe`] (orig/WilliamsArcadeClassics):
-make defender
+make defender.rom
+To build the Red Label rom files (see below for more information on what these are), do:
+make redlabel
+These will get written to a directory called `redlabel`.
 ## Play Defender
 Coming soon.
-## Notes on the Source Code
+## Notes on the Source Code, ROM Files, and the Physical Circuit Boards
-The source code in [src](src) was originally retrieved from https://github.com/historical-source/defender. It is
-the code for the 'Red Label' version of the game. There were four versions of the game released: White Label, Blue Label,
-Green Label, and Red Label; in that order. Each release was a circuit board with the compiled code split across a 
-number of different ROM chip. This image of the Red Label ROM board from [Scott Tunstall's site](https://www.robotron-2084.co.uk/techwilliamshardwareid.html)
-gives you an idea of what such a board looks like:
+The source code in [src](src) was originally retrieved from
+https://github.com/historical-source/defender. It is the code for the 'Red
+Label' version of the game. There were four versions of the game released:
+White Label, Blue Label, Green Label, and Red Label, in that order. Each
+release was a circuit board with the compiled code split across a number of
+different ROM chips, also referred to as 'ICs'. This image of the Red Label ROM
+board from [Scott Tunstall's
+site](https://www.robotron-2084.co.uk/techwilliamshardwareid.html) gives you an
+idea of what such a board looks like:
-<img src="orig/D8572.jpg" size=250>
+<img src="orig/D8572.jpg" size=250> <img src="orig/RedLabelROMBoardSchema.png" size=250>
-If you compare this image to [the file listing for the Red Label roms](orig/defender-redlabel) you'll notice that the missing chip on the board corresponds
-to a missing file `defend.5`:
+If you compare this image to [the file listing for the Red Label
+roms](orig/defender-redlabel) you'll notice that the missing chip on the board
+corresponds to a missing file `defend.5`:
 [robert@mwenge-desktop defender-redlabel (master)]$ ls -al
 total 64
@@ -96,7 +108,7 @@ chart lists the part numbers for each chip and confirms that IC5 (i.e. `defend.5
 <img src="orig/RedLabelRomChart.png" size="300">
-When we assemble the Defender source with `make roms` we create a bunch of
+When we assemble the Defender source with `make redlabel` we create a bunch of
 object files and then split them across the 11 files to match the 11 in the Red
 Label ROM dump listing above.
@@ -196,6 +208,27 @@ the ROM, meaning that one will overwrite the other. This explains why the main g
 twice, once with attract mode (`amode1.src`) and once without: they wanted a binary with some segments
 overwritten with attract mode features and one without. We achieve this ourselves by modifying the source
 to compile and place the attract mode code to position `$2000` in memory, and when we later split the
-object files into the `defend[x].bin` files pick the chunk of code we're interested in.
+object files into the `defend.x` files pick the chunk of code we're interested in.
+This table shows how the contents of each ROM chip relates back to the compiled code.
+ROM Chip| Part Number|File Name|Build Binary|Start Position in Build Binary|End Position in Build Binary
+| --- | --- | --- | --- | --- | --- |
+IC1|A5343-09636 |defend.1|bin/defa7-defb6-amode1.o|0xb000|0xb800
+IC2|A5343-09637 |defend.2|bin/defa7-defb6-amode1.o|0xc000|0xd000
+IC3|A5343-09638 |defend.3|bin/defa7-defb6-amode1.o|0xd000|0xdc60
+IC3|A5343-09638 |defend.3|bin/samexpa7.o|0x0000|0x02f8
+IC3|A5343-09638 |defend.3|bin/defa7-defb6-amode1.o|0xdf59|0x0230
+IC4|A5343-09639 |defend.4|bin/defa7-defb6-amode1.o|0xb800|0x0800
+IC5|Not Used||||
+IC6|A5343-09640 |defend.6|bin/blk71.o|0x0000|0x0772
+IC6|A5343-09640 |defend.6|bin/roms.o|0xa778|0x0088
+IC7|A5343-09641 |defend.7|bin/roms.o|0xa000|0x0800
+IC8|A5343-09642 |defend.8|bin/roms.o|0x0000|0x0800
+IC9|A5343-09642 |defend.9|bin/roms.o|0x0000|0x0800
+IC10|A5343-09643 |defend.10|bin/roms.o|0xa800|0x0800
+IC11|A5343-09644 |defend.11|bin/roms.o|0x0800|0x0800
+IC11|A5343-09644 |defend.11|Unknown||0x0800
+IC12|A5343-09645 |defend.12|bin/defa7-defb6-amode1.o|0x0800|0x0800
+IC12|A5343-09645 |defend.12|bin/defa7-defb6-amode1.o|0xaee9|0x0117
diff --git a/orig/WilliamsArcadeClassics/README.md b/orig/WilliamsArcadeClassics/README.md
new file mode 100644 (file)
index 0000000..53d5bd2
--- /dev/null
@@ -0,0 +1,9 @@
+Compile romgrab as follows:
+gcc -o romgrab romgrab.c
+Then run:
+./romgrab  DEFENDER.EXE -d -v -o defender.rom
+This will extract the uncompressed ROM images to `defender.rom`.