Created
July 28, 2016 02:24
-
-
Save cknave/764996985373b160a4da78671fe94a7b to your computer and use it in GitHub Desktop.
ZZT lion tick function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ | |
; Attributes: bp-based frame | |
TickLion proc far ; CODE XREF: seg001:0348p | |
; DATA XREF: InitTileTypes+263o | |
ParamPtr = dword ptr -8 | |
StepY = word ptr -4 | |
StepX = word ptr -2 | |
ParamIdx = word ptr 6 | |
push bp | |
mov bp, sp | |
mov ax, 8 | |
call CheckStack | |
sub sp, 8 | |
mov ax, [bp+ParamIdx] | |
mov dx, size ParamRecord | |
mul dx | |
mov di, ax | |
add di, BoardParams | |
mov word ptr [bp+ParamPtr], di | |
mov word ptr [bp+ParamPtr+2], ds | |
; | |
; Intelligence check | |
; | |
mov ax, 0Ah | |
push ax | |
call Random ; Get random number in [0,10) | |
mov dx, ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.Param1] ; Get intelligence | |
xor ah, ah | |
cmp ax, dx | |
jnb short loc_10A8E | |
lea di, [bp+StepX] | |
push ss | |
push di | |
lea di, [bp+StepY] | |
push ss | |
push di | |
call RandomStep | |
jmp short loc_10AB0 | |
; --------------------------------------------------------------------------- | |
loc_10A8E: ; CODE XREF: TickLion+38j | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.X] | |
xor ah, ah | |
push ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.Y] | |
xor ah, ah | |
push ax | |
lea di, [bp+StepX] | |
push ss | |
push di | |
lea di, [bp+StepY] | |
push ss | |
push di | |
call SeekStep | |
; Get the tile at the proposed destination | |
loc_10AB0: ; CODE XREF: TickLion+49j | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.Y] | |
xor ah, ah | |
add ax, [bp+StepY] | |
shl ax, 1 | |
mov cx, ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.X] | |
xor ah, ah | |
add ax, [bp+StepX] | |
mov dx, BytesPerColumn | |
mul dx | |
mov di, ax | |
add di, cx | |
mov al, [di+BoardTopLeftType] | |
xor ah, ah | |
mov dx, size TileType | |
mul dx | |
mov di, ax | |
; If it's not blocked, move to that tile | |
cmp TileTypes.Passable[di], 0 | |
jz short loc_10B0B | |
push [bp+ParamIdx] | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.X] | |
xor ah, ah | |
add ax, [bp+StepX] | |
push ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.Y] | |
xor ah, ah | |
add ax, [bp+StepY] | |
push ax | |
call MoveTile | |
jmp short loc_10B57 | |
; --------------------------------------------------------------------------- | |
; We're blocked, check if it's by the player | |
loc_10B0B: ; CODE XREF: TickLion+A3j | |
les di, [bp+ParamPtr] | |
mov al, es:[di+1] | |
xor ah, ah | |
add ax, [bp+StepY] | |
shl ax, 1 | |
mov cx, ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di] | |
xor ah, ah | |
add ax, [bp+StepX] | |
mov dx, BytesPerColumn | |
mul dx | |
mov di, ax | |
add di, cx | |
cmp byte ptr [di+BoardTopLeftType], TTPlayer | |
jnz short loc_10B57 | |
push [bp+ParamIdx] | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.X] | |
xor ah, ah | |
add ax, [bp+StepX] | |
push ax | |
les di, [bp+ParamPtr] | |
mov al, es:[di+ParamRecord.Y] | |
xor ah, ah | |
add ax, [bp+StepY] | |
push ax | |
call DieByPlayerTouch | |
loc_10B57: ; CODE XREF: TickLion+C6j | |
; TickLion+F1j | |
mov sp, bp | |
pop bp | |
retf 2 | |
TickLion endp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment