tiles:
./tools/png2chr.py assets/tiles0.png > tiles/tileset0.inc
./tools/png2chr.py assets/tiles1.png > tiles/tileset1.inc
+
+.PHONY: maps
+maps:
+ ./tools/tms2map.py assets/maps/base.tmx base_room > maps/base_room.s
--- /dev/null
+base_room_bg:
+.db 0x60, 0x62, 0x62, 0x64, 0x40, 0x40, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x46, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe2, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x40, 0x40, 0x44, 0x4a, 0x4a, 0x6e
+base_room_flags:
+.db 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1
; base room
; this can be copied and modified
; by the map gen
-base_room:
-.db TCORNUL, TWALLU1, TWALLU1, TDOORUL, TFLOOR1, TFLOOR1, TDOORUR, TWALLU1, TWALLU1, TCORNUR
-.db TWALLL1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TWALLR1
-.db TDOORRL, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TDOORLL
-.db TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1
-.db TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1
-.db TDOORRR, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TDOORLR
-.db TWALLL1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TFLOOR1, TWALLR1
-.db TCORNBOL, TWALLD1, TWALLD1, TDOORDL, TFLOOR1, TFLOOR1, TDOORDR, TWALLD1, TWALLD1, TCORNBOR
- ; tile flags for the room
-base_room_flags:
-.db RF_WALL, RF_WALL, RF_WALL, RF_WALL, 0, 0, RF_WALL, RF_WALL, RF_WALL, RF_WALL
-.db RF_WALL, 0, 0, 0, 0, 0, 0, 0, 0, RF_WALL
-.db RF_WALL, 0, 0, 0, 0, 0, 0, 0, 0, RF_WALL
-.db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-.db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-.db RF_WALL, 0, 0, 0, 0, 0, 0, 0, 0, RF_WALL
-.db RF_WALL, 0, 0, 0, 0, 0, 0, 0, 0, RF_WALL
-.db RF_WALL, RF_WALL, RF_WALL, RF_WALL, 0, 0, RF_WALL, RF_WALL, RF_WALL, RF_WALL
+#include "./maps/base_room.s"
; initial test map
- ldlo a, base_room
+ ldlo a, base_room_bg
ld [curr_room], a
- ldhi a, base_room
+ ldhi a, base_room_bg
ld [curr_room+1], a
ldlo a, base_room_flags
--- /dev/null
+#!/usr/bin/env python
+
+import sys
+import os
+import xml.etree.ElementTree as ET
+
+if len(sys.argv) < 3:
+ print("Usage: tmx2map.py <source> <map name>")
+ sys.exit(-1)
+
+src = sys.argv[1]
+name = sys.argv[2]
+
+def print_data(data, name, layer):
+ print(name + "_" + layer + ":")
+ print(".db ", end = '');
+ split = data.split(",")
+ for i, byte in enumerate(split):
+ val = int(byte)
+ if val > 0:
+ val -= 1
+ if layer == "bg":
+ og = val
+ val = 0x800 + ((val * 16) << 2)
+ val = (val & 0x0FF0) >> 4
+ val -= int(2 * og % 16)
+
+ end = ', '
+ if i == len(split) - 1:
+ end = '\n'
+ print(hex(val), end=end)
+
+def convert(src, name):
+ tree = ET.parse(src)
+ root = tree.getroot()
+ for child in root:
+ if child.tag == "layer":
+ for data in child:
+ print_data(data.text, name, child.attrib['name'])
+
+
+
+convert(src, name)