offset 223
#define
L_framerect_distance = 0
U_framerect_distance = 0
sprite heigth = 20
sprite width = 10
walk timer = 6
walk frames = 3
walk speed = 200
dbl walk speed = 400
gravity_level = 5ff
#enddefine
push ebp
mov ebp,esp
SUB ESP,10
MOV DWORD [EBP-10],0
MOV DWORD [EBP-C],0
MOV DWORD [EBP-8],0
MOV DWORD [EBP-4],0
setpointer
mov eax, npc.scriptstate
jmp [eax*4+:StateTable]
;-------------------------------------------------
:StateIdle
mov npc.framenum, 0
mov eax npc.X
cmp eax PlayerXpos
jg :face_right
mov npc.direction, 0
jmp :Render
:face_right
mov npc.direction, 2
jmp :Render
;-------------------------------------------------
:StateWalk
inc npc.frametimer
cmp npc.frametimer, walk timer
jl :Walk_end
mov npc.frametimer,0
cmp npc.framenum,1
je :1_to_0
jg :2_to_0
cmp npc.scriptstate, 2
je :0_to_1
jne :0_t0_2
:1_to_0
mov npc.framenum, 0
mov npc.scripttimer,2
jmp :Walk_end
:2_to_0
mov npc.framenum, 0
mov npc.scripttimer,1
jmp :Walk_end
:0_to_1
mov npc.framenum, 1
jmp :Walk_end
:0_t0_2
mov npc.framenum, 2
jmp :Walk_end
:Walk_end
add npc.X walk speed
cmp npc.direction, 2
je :render
add npc.X -dbl walk speed
jmp :render
;----------------------------------------------------
:Render
add npc.X gravity_level ;gravity
mov eax, npc.framenum
imul al, al, sprite width
add eax, L_framerect_distance
mov npc.DisplayL,eax
add eax, sprite width
mov npc.displayR,eax
mov eax, U_framerect_distance
cmp npc.direction, 0
je :face_left
add eax, sprite heigth
:face_left
mov npc.displayU,eax
add eax, sprite heigth
mov npc.displayD,eax
:end_of_code
mov esp, ebp
pop ebp
retn
:StateTable
print :StateIdle ;<ANP0000
print :StateWalk ;<ANP0001
print :StateWalk ;yes, this second one is here on purpose