.PHONY: maps
maps:
- ./tools/tmx2map.py assets/maps/l1.tmx > maps/spawn.inc
+ ./tools/tmx2map.py assets/maps/near_wall.tmx 1 > maps/near_wall.inc
+ ./tools/tmx2map.py assets/maps/far_wall.tmx 1 > maps/far_wall.inc
+ ./tools/tmx2map.py assets/maps/l1.tmx > maps/l1.inc
--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x0, 0x1, 0x2, 0x3, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x4, 0x5, 0x6, 0x7
+.db 0x10, 0x12, 0x12, 0x13, 0x0, 0x1, 0x2, 0x3, 0x11, 0x11, 0x11, 0x11, 0x4, 0x5, 0x6, 0x7, 0x14, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x13, 0x15, 0x21, 0x21, 0x16, 0x14, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x23, 0x25, 0x22, 0x22, 0x26, 0x24, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x23, 0x30, 0x31, 0x32, 0x33, 0x17, 0x17, 0x5a, 0x17, 0x34, 0x35, 0x36, 0x37, 0x24, 0x12, 0x12, 0x20
+.db 0x30, 0x31, 0x32, 0x33, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x34, 0x35, 0x36, 0x37
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x70, 0x71, 0x72, 0x73, 0x74, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x9, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0x5
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 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 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0x6
--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
+.db 0x0, 0x1, 0x2, 0x3, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x4, 0x5, 0x6, 0x7
+.db 0x10, 0x12, 0x12, 0x13, 0x15, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x16, 0x14, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x12, 0x10, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x20, 0x12, 0x12, 0x12, 0x20
+.db 0x10, 0x12, 0x12, 0x23, 0x25, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x26, 0x24, 0x12, 0x12, 0x20
+.db 0x30, 0x31, 0x32, 0x33, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x34, 0x35, 0x36, 0x37
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x70, 0x71, 0x72, 0x73, 0x74, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
+.db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
--- /dev/null
+; this map was generated by tmx2map.py
+
+.db 0x9, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0xd, 0x5
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
+.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf,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0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0xb, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x7
-.db 0xa, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0xe, 0x6
#define MAP_H 14
#define MAP_TILES (MAP_W * MAP_H)
+#define RENDER_BUF_W 20
+#define RENDER_BUF_H 14
+#define RENDER_BUF_TILES (RENDER_BUF_W * RENDER_BUF_H)
+
; actor type enum
.se 0
.de ACT_T_NULL, 1
l1:
mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, tile_banks_default
-#include "spawn.inc"
+#include "l1.inc"
tile_banks_default:
dw bank8000
call map_tile_banks_load
pop de
- call map_full_draw
call lcd_on
call vblank_wait
call enableinterrupts
+
+ call map_full_draw
+ call update_render
ret
; draws a full map copy into the current map view buffer
; bsed on the current location the player is facing
; the map render buffer is then written to the screen
+ ; 1) load near or far wall into render_buffer (near if forward wall is on next tile)
+ ; 2) determine exits on all other walls forward
+ ; 3) draw exits in pre-determined locations
+ ; 4) set render state
; inputs:
; [map]
+ ; returns:
+ ; render_buffer: new map data to be drawn
+ ; transferts to redraw state
map_full_draw:
+ ; draw template for now
+ ld de, far_wall
+ ld hl, render_buffer
+ ld bc, RENDER_BUF_TILES
+ call memcpy
+
+ ; 4) go to render state
+ call update_render
ret
; nop map rotuine
ld de, player
call act_can_move
ld de, player
- call nz, act_move_forward
+ call nz, player_move_forward
@not_up:
ld b, DIRDOWN
ld de, player
call act_can_move
ld de, player
- call nz, act_move_back
+ call nz, player_move_back
@not_down:
-
ret
+
+player_move_forward:
+ call act_move_forward
+ jp map_full_draw
+
+player_move_back:
+ call act_move_back
+ jp map_full_draw
; fallback tile
tile_null:
tiledef 0, 0, 0, 0
+
+far_wall:
+#include "far_wall.inc"
+
+near_wall:
+#include "near_wall.inc"
ret
+ ; draws a single tile
+ ; inputs:
+ ; de: render_buffer
+ ; hl: SCRN
+#macro update_render_draw
+ ld a, [de]
+ inc de
+ ld [hl+], a
+#endmacro
+
+update_render:
+ call disableinterrupts
+ ; TODO: this should be smooth...
+ ld b, RENDER_BUF_H ; loop counter
+ ld de, render_buffer
+ ld hl, SCRN0
+ call next_vblank_wait
+
+ ; copy buffer into SCRN0
+ ; TODO: we should do this off-screen in SCRN1 and then switch
+@render_loop:
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+ update_render_draw
+
+ call next_vblank_wait
+
+ push de
+ ld de, 12 ; next row
+ add hl, de
+ pop de
+
+ dec b
+ jp nz, @render_loop
+
+ call enableinterrupts
+ ret
+
new_game:
ld de, l1
call map_load
; ptr to last draw_tile_prep
update_tile_ptr: .adv 2
+
+render_buffer: .adv RENDER_BUF_TILES
MAP_W = 20
if len(sys.argv) < 2:
- print("Usage: tmx2map.py <source>")
+ print("Usage: tmx2map.py <source> [tile_offset]")
sys.exit(-1)
tile_offset = 97
+if len(sys.argv) > 2:
+ tile_offset = int(sys.argv[2])
+
def print_bg_data(data):
print("; this map was generated by tmx2map.py")
split = data.split(",")