Multi-tile pseudo code

offset 46A0D9



#define
LBound = [ebp-4]
RBound = [ebp-8]
DBound = [ebp-C]
Pos = [ebp-10]
Vel = [ebp-14]
flags = [ebp-18]
type = [ebp+8]
npcoff = [ebp+C]
tileX = [ebp+10]
tileY = [ebp+14]
X-pos = [ecx]
Y-pos = [ecx+4]
X-vel = [ecx]
Y-vel = [ecx+4]
SETPOS = mov ecx, [ebp-10]
SETVEL = mov ecx, [ebp-14]
graba = mov eax,
grabc = mov ecx,
grabd = mov edx,
#enddefine
; npc npcoff, or null (then use player values)
; types: 1-2 = /, 3 = /45*, 4-5 = \, 6 = \45*, 0 = _
; +0 is x-pos, +4 is y-pos, +8 is x-vel, +c is y-vel
	push ebp
	mov ebp,esp
	sub esp, 1c
	mov flags, 0
	cmp npcoff, 0; if we're quote...
	jne :A
	grabc 49e654
	graba [ecx+28]
	mov LBound, eax;[49e67c]
	graba [ecx+30]
	mov RBound, eax;[49E684]
	graba [ecx+34]
	mov DBound, eax;[49E688]
	mov Pos, ecx;49e654
	add ecx, 18
	mov Vel, ecx;
	jmp :B
:A	
	grabc npcoff
	add ecx, 70
	graba [ecx+c]
	mov LBound, eax;+7c
	graba [ecx+14]
	mov RBound, eax;+84
	graba [ecx+18]
	mov DBound, eax;+88
	sub ecx, 68
	mov Pos, ecx
	add ecx, 8
	mov Vel, ecx
:B	
	SETVEL
	cmp y-vel, -1
	jg :Range
	cmp type, 0
	je :END
	cmp type, 3
	jg :A1
	cmp x-vel, 40
	jg :Range
	jmp :END
:A1
	cmp x-vel, -40
	jl :Range
	jmp :END
:Range
	SETPOS
	graba tileX
	shl eax, 4
	sub eax, 8
	shl eax, 9
	data 8b 11	;grabd, x-pos
	cmp edx, eax
	jl :END
	add eax, 2000
	cmp edx, eax
	jg :END		;done left-right checks
	cmp type, 0
	jne :C		;if tile 0...
	graba tileY
	shl eax, 4
	sub eax, 8
	shl eax, 9
	jmp :D
:C
	graba tileX
	shl eax, 0d
	data 2b 01;	sub eax, x-pos
	grabd tileY
	shl edx, 0d
	cmp type, 3
	jg :E		;if tile 1-3...
	data 81 4d e8 00 00 08 00	;or flags, 80000
	cmp type, 3
	je :F		;if tile 1-2...
	sar eax, 1
	add edx, eax
	graba edx
	cmp type, 2
	je :G		;if tile 1
	add eax, 800
	jmp :D
:G
	sub eax, 800
	jmp :D
:F
	add edx, eax
	sub edx, 200
	graba edx
	jmp :D
:F2
	add edx, eax
	sub edx, 380
	graba edx
	jmp :D
:E
	data 81 4d e8 00 00 01 00	;or flags, 10000
	neg eax
	cmp type, 6
	je :F2		;if tile 4-5
	sar eax, 1
	add edx, eax
	graba edx
	cmp type, 4
	je :G		;if tile 5
	add eax, 800
:D
	grabd tileY
	shl edx, 0D
	sub edx, 1000
	cmp eax, edx
	jge :limit
	mov eax, edx
:limit
	grabd y-pos
	add edx, DBound
	cmp edx, eax
	jl :END
	add eax, A00
	cmp edx, eax
	jge :END
	sub eax, A00
	sub eax, DBound
	mov y-pos, eax
	cmp npcoff, 0
	jne :L
	grabd [49E650]
	and edx, 1
	je :H
	cmp type, 0
	je :H
	cmp type, 3
	jg :I
	cmp type, 3
	je :J
	data 83 29 0b	;sub x-pos, 0B 	;if tile 1-2
	add y-pos, 6
	SETVEL
	data 83 29 0A	;sub x-vel, 0A
	jmp :H
:J
	data 83 29 1b	;sub x-pos, 1B
	add y-pos, 1b
	SETVEL
	data 83 29 1A	;sub x-vel, 1A
	jmp :H
:I
	cmp type, 6
	je :K
	data 83 01 0b	;add x-pos, 0B 	;if tile 4-5
	add y-pos, 6
	SETVEL
	data 83 01 0A	;add x-vel, 0A
	jmp :H
:K
	data 83 01 1b	;add x-pos, 1B
	add y-pos, 1b
	SETVEL
	data 83 01 1A	;add x-vel, 1A
:H
	SETVEL
	cmp x-vel, 2ff
	JLE :X
	mov x-vel, 2ff
:X
	cmp x-vel, -2ff
	jge :Y
	mov x-vel, -2ff
:Y
	cmp y-vel, 400
	jle :L
	push 1
	push 17
	call 420640
	add esp, 8
:L
	SETVEL
	cmp y-vel, 0
	jle :M
	mov y-vel, 0
:M
	data 83 4d e8 08	;or flags, 8
:END
	graba flags
	cmp npcoff, 0
	je :END2
	SETPOS
	data 09 41 FC		;or [ecx-4], eax
:END2
	data 5e		;pop esi
	mov esp, ebp
	pop ebp
	retn
Advertisements

2 responses to “Multi-tile pseudo code

  1. Pingback: Scripting the town « WTF Story progress & updates.

  2. Tryda

    How do you type in stuff like that code. What do you get or need to?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s