.de ACT_T_NULL, 1
.de ACT_T_PLAYER, 1
.de ACT_T_BAT, 1
+
+.def int ACT_DIR_MASK = 0b00000011
; actor struct
; stats are defined by looking up the type in a table
.de t_type, 1
.de t_flags, 1
; actor currently
- ; standing on tile
- ; 0 = player, 1-N = map actors
-.de t_actor, 1
+ ; standing on tile (ptr)
+.de t_actor, 2
.de t_p0, 1
.de t_size, 0
#define PLAYER_CURSOR_L 0x88
#define PLAYER_CURSOR_R 0x8A
+
+ ; table of direction to pick on right turn
+player_direction_turn_right:
+ .db EAST ; SOUTH
+ .db WEST ; NORTH
+ .db SOUTH ; EAST
+ .db NORTH ; WEST
+
+ ; table of directions to pick on left turn
+player_direction_turn_left:
+ .db WEST ; SOUTH
+ .db EAST ; NORTH
+ .db NORTH ; EAST
+ .db SOUTH ; WEST
+
; sets up the player actor
player_init:
ret
- ; draws the players current facing direction
- ; as a compass
-compass_draw:
- ret
-
; moves the player
; does not move out of bounds
; based on the last queued input
player_handle_move:
+ ld b, DIRLEFT
+ input_just
+ jr z, @not_left REL
+ ld hl, player_direction_turn_left
+ ld a, [player+act_dir]
+ and a, ACT_DIR_MASK
+ ld d, 0
+ ld e, a
+ add hl, de ; hl = direction table offset
+
+ ld b, [hl] ; new direction
+ ld a, [player+act_dir]
+ and a, ~ACT_DIR_MASK & 0xFF
+ or a, b
+ ld [player+act_dir], a
+@not_left:
+
+ ld b, DIRRIGHT
+ input_just
+ jr z, @not_right REL
+ ld hl, player_direction_turn_right
+ ld a, [player+act_dir]
+ and a, ACT_DIR_MASK
+ ld d, 0
+ ld e, a
+ add hl, de ; hl = direction table offset
+
+ ld b, [hl] ; new direction
+ ld a, [player+act_dir]
+ and a, ~ACT_DIR_MASK & 0xFF
+ or a, b
+ ld [player+act_dir], a
+@not_right:
+
ret
#define UI_TILE_NAME SCRN1+33
+#define TILE_SOUTH 0xEC
+#define TILE_NORTH 0xE7
+#define TILE_EAST 0xDE
+#define TILE_WEST 0xF0
+
; one tile after 'Z'
#define UI_WINDOW_BACKGROUND 0xF4
ui_draw:
ret
+compass_tiles:
+ .db TILE_SOUTH, TILE_NORTH, TILE_EAST, TILE_WEST
+
+ ; draws the players current facing direction
+ ; as a compass
+compass_draw:
+ ld a, 1
+ call oamalloc
+
+
+ ; y
+ ld a, 136
+ ld [hl+], a
+
+ ; x
+ ld a, 64
+ ld [hl+], a
+
+ ; tile
+ push hl
+ ld a, [player+act_dir]
+ and a, ACT_DIR_MASK
+
+ ld d, 0
+ ld e, a
+ ld hl, compass_tiles
+ add hl, de
+ ld a, [hl] ; a = tile
+ pop hl
+ ld [hl+], a
+
+ ; flags
+ xor a, a
+ ld [hl], a
+
+
+ ret
; turns on the lcd
lcd_on:
- ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDF_WINDOWON | LCDF_WINBANKSELECT | LCDF_OBJ_SIZE
+ ld a, LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDF_WINDOWON | LCDF_WINBANKSELECT
ld [RLCD], a
ret