junglejourney

view buildrom.py @ 243:dae2a8efc58f

Corrected the instructions slightly. Added the missing instructions for the ROM cartridge version of the game.
author David Boddie <david@boddie.org.uk>
date Sun Apr 06 00:01:57 2014 +0200
parents 59f37c9e74e4
children
line source
1 #!/usr/bin/env python
3 """
4 Copyright (C) 2011 David Boddie <david@boddie.org.uk>
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 """
20 from build import *
22 if __name__ == "__main__":
24 if not 1 <= len(sys.argv) <= 3 or "-h" in sys.argv[1:] or "--help" in sys.argv[1:]:
26 sys.stderr.write("Usage: %s [<code ROM file> <loader ROM file>]\n" % sys.argv[0])
27 sys.exit(1)
29 if len(sys.argv) == 3:
30 code_rom_file = sys.argv[1]
31 loader_rom_file = sys.argv[2]
32 else:
33 code_rom_file = "junglecode.rom"
34 loader_rom_file = "jungle.rom"
36 # Memory map (code ROM)
37 #
38 # 8000 ROM header code
39 # CODE
40 # A200 CHARS (0x1280 bytes of character sprites)
41 # B480 SPRITES (0x360 bytes of tile sprites)
42 # B7E0 space
43 #
44 # Memory map (loader ROM)
45 #
46 # 8000 ROM header code
47 # 8400 title screen (0x1800 bytes including completion screen)
49 system("ophis romcode.oph " + code_rom_file)
51 romcode = open(code_rom_file, "rb").read()
53 # Add padding before the data is appended to the code.
54 romcode += (0x2200 - len(romcode))*"\x00"
56 romcode += makesprites.read_sprites(makesprites.chars)
57 romcode += makesprites.read_sprites(makesprites.tiles)
59 # Add padding after the code to make a final image size of 16K.
60 romcode += (0x4000 - len(romcode))*"\x00"
61 open(code_rom_file, "wb").write(romcode)
63 system("ophis romloader.oph " + loader_rom_file)
65 romdata = open(loader_rom_file, "rb").read()
67 # Add padding before the data is appended to the loader code.
68 romdata += (0x400 - len(romdata))*"\x00"
70 romdata += makesprites.read_sprites([makesprites.title])
71 completed = makesprites.encode(makesprites.read_sprite(makesprites.completed))
72 overlay = makesprites.read_sprite(makesprites.overlay)
73 combined = makesprites.combine(completed, overlay)
74 romdata += combined
76 romdata += (0x4000 - len(romdata))*"\x00"
78 open(loader_rom_file, "wb").write(romdata)
80 # Exit
81 sys.exit()