-
Notifications
You must be signed in to change notification settings - Fork 22
/
board.asm
50 lines (41 loc) · 842 Bytes
/
board.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
START_ROW EQU 2
START_COL EQU 2
BOARD_WIDTH EQU 8
BOARD_HEIGHT EQU 9
WALL EQU 1
TARGET EQU 2
Board: INCBIN "board.dat"
BoxesOn: DB 1
TARGET_CNT EQU 7
; AX = packed tile coordinates (L = row, H = col)
; returns in AX the offset into the board
GetTileOffset: SHL AL, 3
ADD AL, AH
XOR AH, AH
RET
; AX = packed tile coordinates
; sets E if the tile is a target
IsTarget: PUSH SI
CALL GetTileOffset
MOV SI, AX
CMP BYTE [Board + SI], TARGET
POP SI
RET
; AX = tile we're checking
; sets NE if we can walk
CanWalk: PUSH BX
MOV BX, AX ; backup tile
CALL CanWalkBoard
JE .done ; space has a wall
MOV AX, BX ; get tile
CALL FindBox
.done: POP BX
RET
; AX = tile we're checking
; sets NE if we can walk
CanWalkBoard: PUSH SI
CALL GetTileOffset
MOV SI, AX
CMP BYTE [Board + SI], WALL
POP SI
RET