-
Notifications
You must be signed in to change notification settings - Fork 0
Keyboard buffer
Malo-Archimbaud edited this page Dec 11, 2023
·
2 revisions
Keyboard buffer
This function improves the Keyboard code. It implements a buffer when a key is input. It allows the player to move more efficiently around the maze. The key input is kept in memory when a key is pressed. Then, thanks to the collision system, Pac-Man will move in the input direction only when possible. This function is based on the same model as the collision code.
- Same as the keyboard function
- Same as the collision function
There is no return value, as the function is used to change Pac-Man position.
call getCorners
mov ax, [corner0X]
mov bx, [corner0Y]
mov [checkedCornerX], ax
mov [checkedCornerY], bx
call getTileAbsPos
mov si, MazeModel
add si, [tileAbsPos]
sub si, 1
cmp byte[si], 0x0B
je .NoLeft
cmp byte[si], 0x06
je .NoLeft
cmp byte[si], 0x08
je .NoLeft
cmp byte[si], 0x02
je .NoLeft
cmp byte[si], 0x04
je .NoLeft
mov ax, [corner1X]
mov bx, [corner1Y]
mov [checkedCornerX], ax
mov [checkedCornerY], bx
call getTileAbsPos
mov si, MazeModel
add si, [tileAbsPos]
sub si, 1
cmp byte[si], 0x0B
je .NoLeft
cmp byte[si], 0x06
je .NoLeft
cmp byte[si], 0x08
je .NoLeft
cmp byte[si], 0x02
je .NoLeft
cmp byte[si], 0x04
je .NoLeft
mov ax, [corner2X]
mov bx, [corner2Y]
mov [checkedCornerX], ax
mov [checkedCornerY], bx
call getTileAbsPos
mov si, MazeModel
add si, [tileAbsPos]
sub si, 1
cmp byte[si], 0x0B
je .NoLeft
cmp byte[si], 0x06
je .NoLeft
cmp byte[si], 0x08
je .NoLeft
cmp byte[si], 0x02
je .NoLeft
cmp byte[si], 0x04
je .NoLeft
mov ax, [corner3X]
mov bx, [corner3Y]
mov [checkedCornerX], ax
mov [checkedCornerY], bx
call getTileAbsPos
mov si, MazeModel
add si, [tileAbsPos]
sub si, 1
cmp byte[si], 0x0B
je .NoLeft
cmp byte[si], 0x06
je .NoLeft
cmp byte[si], 0x08
je .NoLeft
cmp byte[si], 0x02
je .NoLeft
cmp byte[si], 0x04
je .NoLeft
In this case, the program gets all the corners. Then it checks corner by corner if there is a wall that can block moving to the left. It is the same model as the collision system.
None
None
Same as keyboard
None
Malo ARCHIMBAUD