junglejourney
view buildrom.py @ 216:cdceac4f5ea8
Started working on a ROM-based version of the game.
Removed a generated file.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Sun Oct 16 18:25:22 2011 +0200 |
| parents | |
| children | 59f37c9e74e4 |
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:
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
37 #
38 # 8000 ROM header code
39 # CODE
40 #
41 # 8000 ROM header code
42 # 8300 title screen (0x1800 bytes including completion screen)
43 #
44 # 9B00 CHARS (0x1280 bytes of character sprites)
45 # AD80 SPRITES (0x360 bytes of tile sprites)
46 # B0E0 space
48 system("ophis romcode.oph " + code_rom_file)
50 # Add padding after the code to make a final image size of 16K.
51 romcode = open("junglecode.rom", "rb").read()
52 romcode += (0x4000 - len(romcode))*"\x00"
53 open(code_rom_file, "wb").write(romcode)
55 system("ophis romloader.oph " + loader_rom_file)
57 romdata = open(loader_rom_file, "rb").read()
59 # Add padding before the data is appended to the loader code.
60 romdata += (0x300 - len(romdata))*"\x00"
62 data = makesprites.read_sprites([makesprites.title])
63 completed = makesprites.encode(makesprites.read_sprite(makesprites.completed))
64 overlay = makesprites.read_sprite(makesprites.overlay)
65 combined = makesprites.combine(completed, overlay)
66 romdata += combined
68 romdata += makesprites.read_sprites(makesprites.tiles)
69 romdata += makesprites.read_sprites(makesprites.chars)
70 romdata += (0x4000 - len(romdata))*"\x00"
72 open(loader_rom_file, "wb").write(romdata)
74 # Exit
75 sys.exit()
