#define NULL 0
#define ACTS_MAX 32
+#define MAP_OBJ_MAX 32
#define STACK_BEGIN 0xDFFF
.se 0
.de mo_type, 1
.de mo_flags, 1
-.de mo_page, 1
.de mo_row, 1
-.de mo_dat, 4
+.de mo_dat, 2
.de mo_size, 0
dw $6
dw $7
#endmacro
+
+ ; defines a new actor
+ ; inputs:
+ ; $1: type
+ ; $2: flags
+ ; $3: p0
+ ; $4: hp
+ ; $5: armor
+#macro actdef
+ .db $1, $2, $3
+ ; placeholder for y and x
+ ; since those are set at runtime
+ .db 0, 0
+ .db $4, $5
+#endmacro
+
+ ; defines a map object
+ ; inputs:
+ ; $1: type
+ ; $2: flags
+ ; $3: row
+ ; $4: dat1
+ ; $5: dat2
+#macro modef
+ .db $1, $2, $3, $4, $5
+#endmacro
#include "ui.s"
#include "audio.s"
#include "map.s"
+#include "mapobj.s"
#include "rowpatterns.s"
#include "math.s"
#include "game.s"
call next_vblank_wait
call lcd_off
+ ld a, e
+ ld [map], a
+ ld a, d
+ ld [map+1], a
+
call map_tile_banks_load
+ call map_page_full_draw
+
call lcd_on
call vblank_wait
call enableinterrupts
; draws the current row pattern
; only call during blank
+ ; also triggers objects
map_draw_row:
ret
-
+
+ ; draws a full page of the currently selected map
+ ; inputs:
+ ; [map]
+map_page_full_draw:
+ ret
l1_map:
mapdef 0, pat_empty, NULL, bank8000, bank8800, bank8C00, bank9000
--- /dev/null
+; map objects are a list of objects
+; a map has a static list of loadable objects
+; when a row is being drawn the next object
+; is checked
+; if the row matches it is loaded into ram and executed
+; when an object is off-screen it is unloded
; player_unit (unit 0) is reserved
player_unit: .adv 0
actors: .adv act_size * ACTS_MAX
+map_objs: .adv mo_size * MAP_OBJ_MAX
- ; current page the map is on
-map_current_page: .adv 1
; current row that is being drawn
map_current_row: .adv 1
; current pattern to be drawn
map_current_pattern: .adv 2
+
+ ; current map ptr
+map: .adv 2
+ ; ptr to the next map object
+ ; that may be loaded
+map_obj_ptr: .adv 2