summaryrefslogtreecommitdiff
path: root/kroete.inc
blob: 176c2cf3af2bda0d219181077f50e2a898dcca83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
; must be large enough, else we will get evil memory corruptions
kroete.width    equ 520
kroete.height   equ 236

;  esi			kroete data
;  edi			drawing buffer
;  [idle.data2]		direction (0 forward, != 0 backward)

kroete:
		movzx eax,word [es:edi]		; width

		mov edx,[pixel_bytes]
		imul edx,eax
		mov [tmp_var_0],edx

		movzx edx,word [es:edi+2]	; height
		inc edx
		mul edx
		shr eax,1
		mul dword [pixel_bytes]
		add edi,4
		add edi,eax

		; edi: start offset into buffer

		call [getpixel]

		cmp byte [idle.data2],0
		jnz sul3
		lea ebp,[esi+16384]
sul:
		mov bl,[es:esi]
		rol bl,2
		call doit
		rol bl,2
		call doit
		rol bl,2
		call doit
		rol bl,2
		call doit
		inc esi
		cmp esi,ebp
		jnz sul
		jmp sul5

sul3:
		lea ebp,[esi-1]
		add esi,16383
sul4:
		mov bl,[es:esi]
		xor bl,0xaa
		call doit
		ror bl,2
		call doit
		ror bl,2
		call doit
		ror bl,2
		call doit
		dec esi
		cmp esi,ebp
		jnz sul4
sul5:
		call [setpixel_a]
		ret

doit:
		xchg eax,edx
		call [getpixel]
		xchg eax,edx
		call [setpixel_a]
		xchg eax,edx

		mov edx,ebx
		and edx,3
		jmp [doit_tab+4*edx]

doit0:
		sub edi,[pixel_bytes]
		ret

doit1:
		sub edi,[tmp_var_0]
		ret

doit2:
		add edi,[pixel_bytes]
		ret

doit3:
		add edi,[tmp_var_0]
		ret

		align 4, db 0
doit_tab	dd doit0, doit1, doit2, doit3