Skip to content

Keyboard buffer

Malo-Archimbaud edited this page Dec 11, 2023 · 2 revisions

Function name:

Keyboard buffer

Description:

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.

Parameters:

  • Same as the keyboard function
  • Same as the collision function

Return value:

There is no return value, as the function is used to change Pac-Man position.

Usage example:

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.

Important Notes

None

Modification History

None

Test cases

Same as keyboard

Additional documentation

None

Author

Malo ARCHIMBAUD