-Subproject commit 0dbebcf3cabc2340d9fc5c28cabcbfda248f5be8
+Subproject commit dfacc03a9d29342f17f2a688733c6124edc841a7
.PHONY: maps
maps:
./tools/tmx2map.py assets/maps/l1.tmx > maps/l1.inc
+ ./tools/tmx2map.py assets/maps/f1r1.tmx > maps/f1r1.inc
--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0
+.db 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x2, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x2
+.db 0x0, 0x1, 0x0, 0x2, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x2
+.db 0x0, 0x0, 0x0, 0x0
+
.beginscope
ld hl, mapgen_tiles + MAP_SECTION_SIZE * MAP_SECTION_PER_ROW * MAP_SECTION_SIZE \
* $1 + MAP_SECTION_SIZE * $2
- ld bc, 0x0808 ; 8x8 fill the entire sector for now
+
+ ; TODO load different patterns for each floor
+ ld de, floor1_patterns
+ ld a, (floor1_patterns_end-floor1_patterns) / 2
+
call mapgen_make_room
.endscope
#endmacro
_mapgen_make_room_section 1, 3
ret
+ ; draws a map row (8 tiles)
+ ; inputs:
+ ; de: room pattern
+ ; hl: destination
+ ; returns:
+ ; hl: next destination
+ ; de: next de
+#macro _mapgen_make_room_draw_row
+ push hl
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+ ld a, [de]
+ ld [hl+], a
+ inc de
+
+ pop hl
+ ld bc, MAP_W
+ add hl, bc
+#endmacro
+
; generates a single rectanglular room
; the caller must ensutre hl has enough tiles in
; the y and x direction to allow the room to fit.
; places actors in the room
; inputs:
+ ; de: table of 8x8 room patterns
+ ; a: table length (must be a multiple of 2)
; hl: start position in tile map
- ; b/c: height/width of room
mapgen_make_room:
- ld de, MAP_W
-@draw_row:
- ; save original hl
- push hl
-
- ; save original w
- push bc
-
-@draw_col:
- ld a, TI_FLOOR
- ld [hl+], a
-
- dec c ; width--
- jr nz, @draw_col REL
-
- ; restore w
- ld a, b ; need to save height
- pop bc
- ld b, a
+ ; TODO: pick a room pattern
+
+ ; de = room pattern to draw
+ ld a, [de]
+ ld b, a
+ inc de
+ ld a, [de]
+ ld e, b
+ ld d, a
- pop hl
- ; go to next row
- add hl, de
- dec b ; height--
- jr nz, @draw_row REL
+ ; draw a row (8 tiles) 8 times
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
+ _mapgen_make_room_draw_row
; TODO: place actors
ret
+
+f1r1:
+#include "f1r1.inc"
+
+floor1_patterns:
+dw f1r1
+dw f1r1
+floor1_patterns_end:
; sets up the player actor
player_init:
- ld a, 2
+ ld a, 1
ld [player+act_pos_y], a
ld [player+act_pos_x], a