Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 316 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 109 Rev 272
1
;
1
;
2
;   Fisheye Raycasting Engine Etc. FREE3D for MENUETOS by Dieter Marfurt
2
;   Fisheye Raycasting Engine Etc. FREE3D for MENUETOS by Dieter Marfurt
3
;   Version 0.4 (requires some texture-files to compile (see Data Section))
3
;   Version 0.4 (requires some texture-files to compile (see Data Section))
4
;   dietermarfurt@angelfire.com - www.melog.ch/mos_pub/
4
;   dietermarfurt@angelfire.com - www.melog.ch/mos_pub/
5
;   Don't hit me - I'm an ASM-Newbie... since years :)
5
;   Don't hit me - I'm an ASM-Newbie... since years :)
6
;
6
;
7
;   Compile with FASM for Menuet (requires .INC files - see DATA Section)
7
;   Compile with FASM for Menuet (requires .INC files - see DATA Section)
8
;
8
;
9
;   Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
9
;   Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
10
;
10
;
11
;   !!!! Don't use GIF.INC in your apps - it's modified for FREE3D !!!!
11
;   !!!! Don't use GIF.INC in your apps - it's modified for FREE3D !!!!
12
   
12
 
13
TEX_SIZE equ 64*64*4
13
TEX_SIZE equ 64*64*4
14
ceil = sinus+16*1024
14
ceil = sinus+16*1024
15
wall = ceil+TEX_SIZE*1
15
wall = ceil+TEX_SIZE*1
16
wall2 = ceil+TEX_SIZE*2
16
wall2 = ceil+TEX_SIZE*2
17
wall3 = ceil+TEX_SIZE*3
17
wall3 = ceil+TEX_SIZE*3
18
wall4 = ceil+TEX_SIZE*4
18
wall4 = ceil+TEX_SIZE*4
19
wall5 = ceil+TEX_SIZE*5
19
wall5 = ceil+TEX_SIZE*5
20
wall6 = ceil+TEX_SIZE*6
20
wall6 = ceil+TEX_SIZE*6
21
wall7 = ceil+TEX_SIZE*7
21
wall7 = ceil+TEX_SIZE*7
22
APP_MEM equ 0x200000
22
APP_MEM equ 0x200000
23
 
23
 
24
use32
24
use32
25
   
25
 
26
               org    0x0
26
               org    0x0
27
   
27
 
28
               db     'MENUET01'              ; 8 byte id
28
               db     'MENUET01'              ; 8 byte id
29
               dd     0x01                    ; header version
29
               dd     0x01                    ; header version
30
               dd     START                   ; start of code
30
               dd     START                   ; start of code
31
               dd     I_END                   ; size of image
31
               dd     I_END                   ; size of image
32
               dd     APP_MEM;0x300000                ; memory for app
32
               dd     APP_MEM;0x300000                ; memory for app
33
               dd     APP_MEM;0x300000                ; esp
33
               dd     APP_MEM;0x300000                ; esp
34
               dd     0x0 , 0x0               ; I_Param , I_Icon
34
               dd     0x0 , 0x0               ; I_Param , I_Icon
35
include 'lang.inc'   
35
include 'lang.inc'
36
include 'macros.inc'
36
include 'macros.inc'
37
COLOR_ORDER equ OTHER	
37
COLOR_ORDER equ OTHER
38
include 'gif.inc'
38
include 'gif.inc'
39
   
39
 
40
START:                          ; start of execution
40
START:                          ; start of execution
41
		mov  esi,textures
41
		mov  esi,textures
42
		mov  edi,ceil
42
		mov  edi,ceil
43
		mov  eax,sinus
43
		mov  eax,sinus
44
		call ReadGIF
44
		call ReadGIF
45
		mov  esi,sinus
45
		mov  esi,sinus
46
		mov  ecx,360*10
46
		mov  ecx,360*10
47
		fninit
47
		fninit
48
		fld  [sindegree]   
48
		fld  [sindegree]
49
	.sinlp:	
49
	.sinlp:
50
		fst  st1
50
		fst  st1
51
		fsin
51
		fsin
52
		fmul [sindiv]
52
		fmul [sindiv]
53
		fistp dword[esi]
53
		fistp dword[esi]
54
		add  esi,4
54
		add  esi,4
55
		fadd [sininc]
55
		fadd [sininc]
56
		loop .sinlp
56
		loop .sinlp
57
    call draw_window            ; at first, draw the window
57
    call draw_window            ; at first, draw the window
58
    call draw_stuff
58
    call draw_stuff
59
   
59
 
60
gamestart:
60
gamestart:
61
;   ******* MOUSE CHECK *******
61
;   ******* MOUSE CHECK *******
62
;    mov eax,37    ; check mouse (use mouse over window to navigate)
62
;    mov eax,37    ; check mouse (use mouse over window to navigate)
63
;    mov ebx,2     ; check mousebuttons
63
;    mov ebx,2     ; check mousebuttons
64
;    int 0x40
64
;    int 0x40
65
;    cmp eax,0    ; only use mouse when button down
65
;    cmp eax,0    ; only use mouse when button down
66
;    je noneed    ; deactivated cause of disappear-bug etc.
66
;    je noneed    ; deactivated cause of disappear-bug etc.
67
    mov eax,37
67
    mov eax,37
68
    mov ebx,1     ; check mouseposition
68
    mov ebx,1     ; check mouseposition
69
    int 0x40
69
    int 0x40
70
   
70
 
71
    mov ebx,eax
71
    mov ebx,eax
72
    shr eax,16
72
    shr eax,16
73
    and eax,0x0000FFFF  ; mousex
73
    and eax,0x0000FFFF  ; mousex
74
    and ebx,0x0000FFFF  ; mousey
74
    and ebx,0x0000FFFF  ; mousey
75
   
75
 
76
    cmp eax,5  ; mouse out of window ?
76
    cmp eax,5  ; mouse out of window ?
77
    jb check_refresh  ; it will prevent an app-crash
77
    jb check_refresh  ; it will prevent an app-crash
78
    cmp ebx,22
78
    cmp ebx,22
79
    jb check_refresh
79
    jb check_refresh
80
    cmp eax, 640
80
    cmp eax, 640
81
    jg check_refresh
81
    jg check_refresh
82
    cmp ebx,501
82
    cmp ebx,501
83
    jg check_refresh
83
    jg check_refresh
84
   
84
 
85
    cmp eax,315 ; navigating?
85
    cmp eax,315 ; navigating?
86
    jb m_left
86
    jb m_left
87
    cmp eax,325 ;
87
    cmp eax,325 ;
88
    jg m_right
88
    jg m_right
89
continue:
89
continue:
90
    cmp ebx,220 ;
90
    cmp ebx,220 ;
91
    jb s_up
91
    jb s_up
92
    cmp ebx,260 ;
92
    cmp ebx,260 ;
93
    jg s_down
93
    jg s_down
94
;   ******* END OF MOUSE CHECK *******
94
;   ******* END OF MOUSE CHECK *******
95
check_refresh:
95
check_refresh:
96
   
96
 
97
;    mov eax,23  ; wait for system event with 10 ms timeout
97
;    mov eax,23  ; wait for system event with 10 ms timeout
98
;    mov ebx,1   ; thats max 100 FPS
98
;    mov ebx,1   ; thats max 100 FPS
99
    mov eax,11 ; ask no wait for full speed
99
    mov eax,11 ; ask no wait for full speed
100
    int  0x40
100
    int  0x40
101
   
101
 
102
    cmp  eax,1                  ; window redraw request ?
102
    cmp  eax,1                  ; window redraw request ?
103
    je   red2
103
    je   red2
104
    cmp  eax,2                  ; key in buffer ?
104
    cmp  eax,2                  ; key in buffer ?
105
    je   key2
105
    je   key2
106
    cmp  eax,3                  ; button in buffer ?
106
    cmp  eax,3                  ; button in buffer ?
107
    je   button2
107
    je   button2
108
   
108
 
109
    mov edi,[mouseya] ; check flag if a refresh has to be done
109
    mov edi,[mouseya] ; check flag if a refresh has to be done
110
    cmp edi,1
110
    cmp edi,1
111
    jne gamestart
111
    jne gamestart
112
    mov [mouseya],dword 0
112
    mov [mouseya],dword 0
113
    call draw_stuff
113
    call draw_stuff
114
   
114
 
115
   
115
 
116
    jmp gamestart
116
    jmp gamestart
117
   
117
 
118
; END OF MAINLOOP
118
; END OF MAINLOOP
119
   
119
 
120
red2:                          ; redraw
120
red2:                          ; redraw
121
    call draw_window
121
    call draw_window
122
    call draw_stuff
122
    call draw_stuff
123
    jmp  gamestart
123
    jmp  gamestart
124
   
124
 
125
key2:                          ; key
125
key2:                          ; key
126
    mov  eax,2
126
    mov  eax,2
127
    int  0x40
127
    int  0x40
128
    cmp  al,1
128
    cmp  al,1
129
    je   gamestart     ; keybuffer empty
129
    je   gamestart     ; keybuffer empty
130
   
130
 
131
    cmp ah,27    ; esc=End App
131
    cmp ah,27    ; esc=End App
132
    je finish
132
    je finish
133
   
133
 
134
    cmp  ah,178  ; up
134
    cmp  ah,178  ; up
135
    je   s_up
135
    je   s_up
136
    cmp  ah,177  ; down
136
    cmp  ah,177  ; down
137
    je   s_down
137
    je   s_down
138
    cmp  ah,176  ; left
138
    cmp  ah,176  ; left
139
    je   s_left
139
    je   s_left
140
    cmp  ah,179  ; right
140
    cmp  ah,179  ; right
141
    je   s_right
141
    je   s_right
142
   
142
 
143
    jmp gamestart ; was any other key
143
    jmp gamestart ; was any other key
144
   
144
 
145
   
145
 
146
s_up:             ; walk forward (key or mouse)
146
s_up:             ; walk forward (key or mouse)
147
    mov eax,[vpx]
147
    mov eax,[vpx]
148
    mov ebx,[vpy]
148
    mov ebx,[vpy]
149
   
149
 
150
   
150
 
151
    mov ecx,[vheading]
151
    mov ecx,[vheading]
152
    imul ecx,4
152
;    imul ecx,4
153
    add ecx,sinus
153
;    add ecx,sinus
-
 
154
    lea ecx, [sinus+ecx*4]
154
    mov edi,[ecx]
155
    mov edi,[ecx]
155
   
156
 
156
    mov edx,[vheading]
157
    mov edx,[vheading]
157
    imul edx,4
158
;    imul edx,4
158
    add edx,sinus
159
;    add edx,sinus
159
    add edx,3600
160
;    add edx,3600
-
 
161
    lea edx, [sinus+3600+edx*4]
160
    cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
162
    cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
161
    jb ok200
163
    jb ok200
162
    sub edx,14400
164
    sub edx,14400
163
    ok200:
165
    ok200:
164
    mov esi,[edx]
166
    mov esi,[edx]
165
;    sal esi,1  ; edit walking speed here
167
;    sal esi,1  ; edit walking speed here
166
;    sal edi,1
168
;    sal edi,1
167
   
169
 
168
    add eax,edi ; newPx
170
    add eax,edi ; newPx
169
    add ebx,esi ; newPy
171
    add ebx,esi ; newPy
170
    mov edi,eax ; newPx / ffff
172
    mov edi,eax ; newPx / ffff
171
    mov esi,ebx ; newPy / ffff
173
    mov esi,ebx ; newPy / ffff
172
    sar edi,16
174
    sar edi,16
173
    sar esi,16
175
    sar esi,16
174
    mov ecx,esi
176
    mov ecx,esi
175
    sal ecx,5 ; equal *32
177
    sal ecx,5 ; equal *32
176
    add ecx,edi
178
;    add ecx,edi
177
    add ecx,grid
179
;    add ecx,grid
-
 
180
    lea ecx, [grid+ecx+edi]
178
    cmp [ecx],byte 0  ; collision check
181
    cmp [ecx],byte 0  ; collision check
179
    jne cannotwalk0
182
    jne cannotwalk0
180
    mov [vpx],eax
183
    mov [vpx],eax
181
    mov [vpy],ebx
184
    mov [vpy],ebx
182
    mov [mouseya],dword 1 ; set refresh flag
185
    mov [mouseya],dword 1 ; set refresh flag
183
cannotwalk0:
186
cannotwalk0:
184
    jmp check_refresh
187
    jmp check_refresh
185
   
188
 
186
s_down:                    ; walk backward
189
s_down:                    ; walk backward
187
    mov eax,[vpx]
190
    mov eax,[vpx]
188
    mov ebx,[vpy]
191
    mov ebx,[vpy]
189
   
192
 
190
    mov ecx,[vheading]
193
    mov ecx,[vheading]
191
    imul ecx,4
194
;    imul ecx,4
192
    add ecx,sinus
195
;    add ecx,sinus
-
 
196
    lea ecx, [sinus+ecx*4]
193
    mov edi,[ecx]
197
    mov edi,[ecx]
194
   
198
 
195
    mov edx,[vheading]
199
    mov edx,[vheading]
196
    imul edx,4
200
;    imul edx,4
197
    add edx,sinus
201
;    add edx,sinus
198
    add edx,3600
202
;    add edx,3600
-
 
203
    lea edx, [sinus+3600+edx*4]
199
    cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
204
    cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
200
    jb ok201
205
    jb ok201
201
    sub edx,14400
206
    sub edx,14400
202
    ok201:
207
    ok201:
203
   
208
 
204
    mov esi,[edx]
209
    mov esi,[edx]
205
;    sal esi,1  ; edit walking speed here
210
;    sal esi,1  ; edit walking speed here
206
;    sal edi,1
211
;    sal edi,1
207
   
212
 
208
    sub eax,edi ; newPx
213
    sub eax,edi ; newPx
209
    sub ebx,esi ; newPy
214
    sub ebx,esi ; newPy
210
    mov edi,eax ; newPx / ffff
215
    mov edi,eax ; newPx / ffff
211
    mov esi,ebx ; newPy / ffff
216
    mov esi,ebx ; newPy / ffff
212
    sar edi,16
217
    sar edi,16
213
    sar esi,16
218
    sar esi,16
214
    mov ecx,esi
219
    mov ecx,esi
215
    sal ecx,5
220
    sal ecx,5
216
    add ecx,edi
221
;    add ecx,edi
217
    add ecx,grid
222
;    add ecx,grid
-
 
223
    lea ecx, [grid+ecx+edi]
218
    cmp [ecx],byte 0
224
    cmp [ecx],byte 0
219
    jne cannotwalk1
225
    jne cannotwalk1
220
    mov [vpx],eax
226
    mov [vpx],eax
221
    mov [vpy],ebx
227
    mov [vpy],ebx
222
    mov [mouseya],dword 1
228
    mov [mouseya],dword 1
223
cannotwalk1:
229
cannotwalk1:
224
    jmp check_refresh
230
    jmp check_refresh
225
   
231
 
226
s_left:                                   ; turn left (key)
232
s_left:                                   ; turn left (key)
227
    mov edi,[vheading]  ; heading
233
    mov edi,[vheading]  ; heading
228
    add edi,50
234
    add edi,50
229
    cmp edi,3600
235
    cmp edi,3600
230
    jb ok_heading0
236
    jb ok_heading0
231
    sub edi,3600
237
    sub edi,3600
232
    ok_heading0:
238
    ok_heading0:
233
    mov [vheading],edi
239
    mov [vheading],edi
234
    mov [mouseya],dword 1
240
    mov [mouseya],dword 1
235
    jmp check_refresh
241
    jmp check_refresh
236
   
242
 
237
s_right:                                  ; turn right
243
s_right:                                  ; turn right
238
    mov edi,[vheading]
244
    mov edi,[vheading]
239
    sub edi,50
245
    sub edi,50
240
    cmp edi,-1
246
    cmp edi,-1
241
    jg ok_heading1
247
    jg ok_heading1
242
    add edi,3600
248
    add edi,3600
243
    ok_heading1:
249
    ok_heading1:
244
    mov [vheading],edi
250
    mov [vheading],edi
245
    mov [mouseya],dword 1
251
    mov [mouseya],dword 1
246
    jmp check_refresh
252
    jmp check_refresh
247
   
253
 
248
m_left:                                   ; turn left (mouse)
254
m_left:                                   ; turn left (mouse)
249
    mov edi,[vheading]  ; heading
255
    mov edi,[vheading]  ; heading
250
    mov ecx,315
256
    mov ecx,315
251
    sub ecx,eax
257
    sub ecx,eax
252
    sar ecx,2
258
    sar ecx,2
253
    add edi,ecx
259
    add edi,ecx
254
    cmp edi,3600
260
    cmp edi,3600
255
    jb ok_heading2
261
    jb ok_heading2
256
    sub edi,3600
262
    sub edi,3600
257
    ok_heading2:
263
    ok_heading2:
258
    mov [vheading],edi
264
    mov [vheading],edi
259
    mov [mouseya],dword 1
265
    mov [mouseya],dword 1
260
    jmp continue    ; allow both: walk and rotate
266
    jmp continue    ; allow both: walk and rotate
261
   
267
 
262
m_right:                                  ; turn right
268
m_right:                                  ; turn right
263
    mov edi,[vheading]
269
    mov edi,[vheading]
264
    sub eax,325
270
    sub eax,325
265
    sar eax,2
271
    sar eax,2
266
    sub edi,eax
272
    sub edi,eax
267
    cmp edi,-1
273
    cmp edi,-1
268
    jg ok_heading3
274
    jg ok_heading3
269
    add edi,3600
275
    add edi,3600
270
    ok_heading3:
276
    ok_heading3:
271
    mov [vheading],edi
277
    mov [vheading],edi
272
    mov [mouseya],dword 1
278
    mov [mouseya],dword 1
273
    jmp continue
279
    jmp continue
274
   
280
 
275
   
281
 
276
   
282
 
277
  button2:                       ; button
283
  button2:                       ; button
278
    mov  eax,17                  ; get id
284
    mov  eax,17                  ; get id
279
    int  0x40
285
    int  0x40
280
    cmp  ah,1                   ; button id=1 ?
286
    cmp  ah,1                   ; button id=1 ?
281
    jne  gamestart
287
    jne  gamestart
282
   
288
 
283
; eo GAME mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
289
; eo GAME mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
284
 finish:
290
 finish:
285
    mov  eax,-1                 ; close this program
291
    mov  eax,-1                 ; close this program
286
    int  0x40
292
    int  0x40
287
   
293
 
288
   
294
 
289
;   *********************************************
295
;   *********************************************
290
;   *******  WINDOW DEFINITIONS AND DRAW ********
296
;   *******  WINDOW DEFINITIONS AND DRAW ********
291
;   *********************************************
297
;   *********************************************
292
   
298
 
293
   
299
 
294
draw_window:
300
draw_window:
295
   
301
 
296
    mov  eax,12                    ; function 12:tell os about windowdraw
302
    mov  eax,12                    ; function 12:tell os about windowdraw
297
    mov  ebx,1                     ; 1, start of draw
303
    mov  ebx,1                     ; 1, start of draw
298
    int  0x40
304
    int  0x40
299
   
305
 
300
                                   ; DRAW WINDOW
306
                                   ; DRAW WINDOW
301
    mov  eax,0                     ; function 0 : define and draw window
307
    mov  eax,0                     ; function 0 : define and draw window
302
    mov  ebx,50*65536+649         ; [x start] *65536 + [x size]
308
    mov  ebx,50*65536+649         ; [x start] *65536 + [x size]
303
    mov  ecx,50*65536+504         ; [y start] *65536 + [y size]
309
    mov  ecx,50*65536+504         ; [y start] *65536 + [y size]
304
    mov  edx,0x02ffffff            ; color of work area RRGGBB,8->color gl
310
    mov  edx,0x02ffffff            ; color of work area RRGGBB,8->color gl
305
    mov  esi,0x80777777            ; color of grab bar  RRGGBB,8->color gl
311
    mov  esi,0x80777777            ; color of grab bar  RRGGBB,8->color gl
306
    mov  edi,0x00777777            ; color of frames    RRGGBB
312
    mov  edi,0x00777777            ; color of frames    RRGGBB
307
    int  0x40
313
    int  0x40
308
   
314
 
309
                                   ; WINDOW LABEL
315
                                   ; WINDOW LABEL
310
    mov  eax,4                     ; function 4 : write text to window
316
    mov  eax,4                     ; function 4 : write text to window
311
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
317
    mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
312
    mov  ecx,0x00ddeeff            ; color of text RRGGBB
318
    mov  ecx,0x00ddeeff            ; color of text RRGGBB
313
    mov  edx,labelt                ; pointer to text beginning
319
    mov  edx,labelt                ; pointer to text beginning
314
    mov  esi,labellen-labelt       ; text length
320
    mov  esi,labellen-labelt       ; text length
315
    int  0x40
321
    int  0x40
316
   
322
 
317
                                   ; CLOSE BUTTON
323
                                   ; CLOSE BUTTON
318
    mov  eax,8                     ; function 8 : define and draw button
324
    mov  eax,8                     ; function 8 : define and draw button
319
    mov  ebx,(649-19)*65536+12     ; [x start] *65536 + [x size]
325
    mov  ebx,(649-19)*65536+12     ; [x start] *65536 + [x size]
320
    mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
326
    mov  ecx,5*65536+12            ; [y start] *65536 + [y size]
321
    mov  edx,1                     ; button id
327
    mov  edx,1                     ; button id
322
    mov  esi,0x777777              ; button color RRGGBB
328
    mov  esi,0x777777              ; button color RRGGBB
323
    int  0x40
329
    int  0x40
324
   
330
 
325
   
331
 
326
    mov  eax,12                    ; function 12:tell os about windowdraw
332
    mov  eax,12                    ; function 12:tell os about windowdraw
327
    mov  ebx,2                     ; 2, end of draw
333
    mov  ebx,2                     ; 2, end of draw
328
    int  0x40
334
    int  0x40
329
   
335
 
330
    ret
336
    ret
331
   
337
 
332
;   *********************************************
338
;   *********************************************
333
;   *******       COMPUTE 3D-VIEW        ********
339
;   *******       COMPUTE 3D-VIEW        ********
334
;   *********************************************
340
;   *********************************************
335
draw_stuff:
341
draw_stuff:
336
   
342
 
337
   
343
 
338
mov [step1],dword 1
344
mov [step1],dword 1
339
;mov [step64],dword 64
345
;mov [step64],dword 64
340
    mov esi,[vheading]
346
    mov esi,[vheading]
341
    add esi,320
347
    add esi,320
342
    mov [va],esi
348
    mov [va],esi
343
    mov eax,[vheading]
349
    mov eax,[vheading]
344
    sub eax,320
350
    sub eax,320
345
    mov [vacompare],eax
351
    mov [vacompare],eax
346
;------------------------------------ CAST 640 PIXEL COLUMNS ---------------
352
;------------------------------------ CAST 640 PIXEL COLUMNS ---------------
347
; FOR A=320+heading to -319+heading step -1 (a is stored in [va])
353
; FOR A=320+heading to -319+heading step -1 (a is stored in [va])
348
;---------------------------------------------------------------------------
354
;---------------------------------------------------------------------------
349
;    mov edx,5
355
;    mov edx,5
350
    mov [vx1],dword 0  ;5  ;edx        ; init x1 ... pixelcolumn
356
    mov [vx1],dword 0  ;5  ;edx        ; init x1 ... pixelcolumn
351
for_a:
357
for_a:
352
mov edx,[vx1]
358
mov edx,[vx1]
353
mov [vx1b],edx
359
mov [vx1b],edx
354
sub [vx1b],dword 320
360
sub [vx1b],dword 320
355
    mov edx,[va]  ; a2
361
    mov edx,[va]  ; a2
356
    cmp edx,-1   ; a2 is a mod 3600
362
    cmp edx,-1   ; a2 is a mod 3600
357
    jg ok1
363
    jg ok1
358
    add edx,3600
364
    add edx,3600
359
ok1:
365
ok1:
360
    cmp edx,3600
366
    cmp edx,3600
361
    jb ok2
367
    jb ok2
362
    sub edx,3600
368
    sub edx,3600
363
ok2:
369
ok2:
364
   
370
 
365
; get stepx and stepy
371
; get stepx and stepy
366
    mov ecx,edx
372
;    mov ecx,edx
367
    imul ecx,4
373
;    imul ecx,4
368
    add ecx,sinus     ; pointer to stepx
374
;    add ecx,sinus     ; pointer to stepx
-
 
375
    lea ecx, [sinus+edx*4]
369
    mov esi,[ecx]
376
    mov esi,[ecx]
370
    sar esi,4         ; accuracy
377
    sar esi,4         ; accuracy
371
    mov [vstepx],esi  ; store stepx
378
    mov [vstepx],esi  ; store stepx
372
   
379
 
373
    mov esi,edx
380
;    mov esi,edx
374
    imul esi,4
381
;    imul esi,4
375
    add esi,sinus  ; pointer to stepy
382
;    add esi,sinus  ; pointer to stepy
-
 
383
;    add esi,3600
376
    add esi,3600
384
    lea esi, [sinus+3600+edx*4]
377
    cmp esi,eosinus ;cosinus taken from ((sinus plus 900) mod 3600)
385
    cmp esi,eosinus ;cosinus taken from ((sinus plus 900) mod 3600)
378
    jb ok202
386
    jb ok202
379
    sub esi,14400
387
    sub esi,14400
380
    ok202:
388
    ok202:
381
   
389
 
382
    mov ecx,[esi]
390
    mov ecx,[esi]
383
    sar ecx,4
391
    sar ecx,4
384
    mov [vstepy],ecx ; store stepy
392
    mov [vstepy],ecx ; store stepy
385
   
393
 
386
   
394
 
387
    mov eax,[vpx]    ; get Camera Position
395
    mov eax,[vpx]    ; get Camera Position
388
    mov ebx,[vpy]
396
    mov ebx,[vpy]
389
    mov [vxx],eax    ; init caster position
397
    mov [vxx],eax    ; init caster position
390
    mov [vyy],ebx
398
    mov [vyy],ebx
391
   
399
 
392
    mov edi,0        ; init L (number of raycsting-steps)
400
    mov edi,0        ; init L (number of raycsting-steps)
393
    mov [step1],dword 1  ; init Caster stepwidth for L
401
    mov [step1],dword 1  ; init Caster stepwidth for L
394
   
402
 
395
 ;  raycast a pixel column.................................
403
 ;  raycast a pixel column.................................
396
raycast:
404
raycast:
397
    add edi,[step1]  ; count caster steps
405
    add edi,[step1]  ; count caster steps
398
;jmp nodouble ; use this to prevent blinking/wobbling textures: much slower!
406
;jmp nodouble ; use this to prevent blinking/wobbling textures: much slower!
399
   
407
 
400
    cmp edi,32
408
    cmp edi,32
401
    je double
409
    je double
402
    cmp edi,512
410
    cmp edi,512
403
    je double
411
    je double
404
    cmp edi,1024
412
    cmp edi,1024
405
    je double
413
    je double
406
    jmp nodouble
414
    jmp nodouble
407
   
415
 
408
    double:
416
    double:
409
    mov edx,[step1]
417
    mov edx,[step1]
410
    sal edx,1
418
    sal edx,1
411
    mov [step1],edx
419
    mov [step1],edx
412
   
420
 
413
    mov edx,[vstepx]
421
    mov edx,[vstepx]
414
    sal edx,1
422
    sal edx,1
415
    mov [vstepx],edx
423
    mov [vstepx],edx
416
   
424
 
417
    mov edx,[vstepy]
425
    mov edx,[vstepy]
418
    sal edx,1
426
    sal edx,1
419
    mov [vstepy],edx
427
    mov [vstepy],edx
420
   
428
 
421
nodouble:
429
nodouble:
422
   
430
 
423
    mov eax,32000 ; 3600 ; determine Floors Height based on distance
431
    mov eax,32000 ; 3600 ; determine Floors Height based on distance
424
    mov edx,0
432
    mov edx,0
425
    mov ebx,edi
433
    mov ebx,edi
426
   
434
 
427
    div ebx
435
    div ebx
428
    mov esi,eax
436
    mov esi,eax
429
    mov [vdd],esi
437
    mov [vdd],esi
430
    mov edx,260
438
    mov edx,260
431
    sub edx,esi
439
    sub edx,esi
432
    mov [vh],edx
440
    mov [vh],edx
433
   
441
 
434
    cmp edx,22
442
    cmp edx,22
435
    jb no_nu_pixel
443
    jb no_nu_pixel
436
    cmp edx,259
444
    cmp edx,259
437
    jg no_nu_pixel ; draw only new pixels
445
    jg no_nu_pixel ; draw only new pixels
438
    cmp edx,[h_old]
446
    cmp edx,[h_old]
439
    je no_nu_pixel
447
    je no_nu_pixel
440
   
448
 
441
    mov eax,[vxx] ; calc floor pixel
449
    mov eax,[vxx] ; calc floor pixel
442
    mov ebx,[vyy]
450
    mov ebx,[vyy]
443
   
451
 
444
    and eax,0x0000FFFF
452
    and eax,0x0000FFFF
445
    and ebx,0x0000FFFF
453
    and ebx,0x0000FFFF
446
   
454
 
447
    shr eax,10
455
    shr eax,10
448
    shr ebx,10    ; pixel coords inside Texture x,y 64*64
456
    shr ebx,10    ; pixel coords inside Texture x,y 64*64
449
    mov [xfrac],eax
457
    mov [xfrac],eax
450
    mov [yfrac],ebx
458
    mov [yfrac],ebx
451
   
459
 
452
   
460
 
453
   
461
 
454
    ; plot floor pixel !!!!
462
    ; plot floor pixel !!!!
455
    mov [vl],edi      ; save L
463
    mov [vl],edi      ; save L
456
    mov [ytemp],esi ; remember L bzw. H
464
    mov [ytemp],esi ; remember L bzw. H
457
   
465
 
458
    mov edi,[yfrac] ; get pixel color of this floor pixel
466
    mov edi,[yfrac] ; get pixel color of this floor pixel
459
    sal edi,8
467
    sal edi,8
460
    mov esi,[xfrac]
468
    mov esi,[xfrac]
461
    sal esi,2
469
    sal esi,2
462
    add edi,esi
470
;    add edi,esi
463
    add edi,wall ; in fact its floor, just using the wall texture :)
471
;    add edi,wall ; in fact its floor, just using the wall texture :)
-
 
472
    lea edi, [wall+edi+esi]
-
 
473
 
464
    mov edx,[edi]
474
    mov edx,[edi]
465
    mov [remesi],esi
475
    mov [remesi],esi
466
   
476
 
467
    ;**** calculate pixel adress:****
477
    ;**** calculate pixel adress:****
468
    mov esi,[ytemp]
478
    mov esi,[ytemp]
469
    add esi,240
479
    add esi,240
470
    imul esi,1920
480
    imul esi,1920
471
    add esi,[vx1]
481
;    add esi,[vx1]
472
    add esi,[vx1]
482
;    add esi,[vx1]
473
    add esi,[vx1]
483
;    add esi,[vx1]
474
    add esi,0x80000
484
;    add esi,0x80000
-
 
485
    mov eax, [vx1]
-
 
486
    lea eax, [eax+eax*2]
-
 
487
    lea esi, [0x80000+eax+esi]
475
   
488
 
476
    cmp esi,0x80000+1920*480
489
    cmp esi,0x80000+1920*480
477
    jg foff0
490
    jg foff0
478
    cmp esi,0x80000
491
    cmp esi,0x80000
479
    jb foff0
492
    jb foff0
480
    ; now we have the adress of the floor-pixel color in edi
493
    ; now we have the adress of the floor-pixel color in edi
481
    ; and the adress of the pixel in the image in esi
494
    ; and the adress of the pixel in the image in esi
482
   
495
 
483
    mov edx,[edi]
496
    mov edx,[edi]
484
    ;******************** custom distance DARKEN Floor
497
    ;******************** custom distance DARKEN Floor
485
   
498
 
486
    mov eax,[vdd]
499
    mov eax,[vdd]
487
   
500
 
488
; jmp nodark0 ; use this to deactivate darkening floor (a bit faster)
501
; jmp nodark0 ; use this to deactivate darkening floor (a bit faster)
489
   
502
 
490
    cmp eax,80
503
    cmp eax,80
491
    jg nodark0
504
    jg nodark0
492
    ;                split rgb
505
    ;                split rgb
493
   
506
 
494
    mov [blue],edx
507
    mov [blue],edx
495
    and [blue],dword 255
508
    and [blue],dword 255
496
   
509
 
497
    shr edx,8
510
    shr edx,8
498
    mov [green],edx
511
    mov [green],edx
499
    and [green],dword 255
512
    and [green],dword 255
500
   
513
 
501
    shr edx,8
514
    shr edx,8
502
    mov [red],edx
515
    mov [red],edx
503
    and [red],dword 255
516
    and [red],dword 255
504
   
517
 
505
    mov eax,81    ; darkness parameter
518
    mov eax,81    ; darkness parameter
506
    sub eax,[vdd]
519
    sub eax,[vdd]
507
    sal eax,1
520
    sal eax,1
508
   
521
 
509
;                        reduce rgb
522
;                        reduce rgb
510
    sub [red],eax
523
    sub [red],eax
511
    cmp [red], dword 0
524
    cmp [red], dword 0
512
    jg notblack10
525
    jg notblack10
513
    mov [red],dword 0
526
    mov [red],dword 0
514
    notblack10:
527
    notblack10:
515
   
528
 
516
    sub [green],eax
529
    sub [green],eax
517
    cmp [green],dword 0
530
    cmp [green],dword 0
518
    jg notblack20
531
    jg notblack20
519
    mov [green],dword 0
532
    mov [green],dword 0
520
    notblack20:
533
    notblack20:
521
   
534
 
522
    mov edx,[blue]
535
    mov edx,[blue]
523
    sub [blue],eax
536
    sub [blue],eax
524
    cmp [blue],dword 0
537
    cmp [blue],dword 0
525
    jg notblack30
538
    jg notblack30
526
    mov [blue],dword 0
539
    mov [blue],dword 0
527
    notblack30:
540
    notblack30:
528
   
541
 
529
    shl dword [red],16  ; reassemble rgb
542
    shl dword [red],16  ; reassemble rgb
530
    shl dword [green],8
543
    shl dword [green],8
531
    mov edx,[red]
544
    mov edx,[red]
532
    or edx,[green]
545
    or edx,[green]
533
    or edx,[blue]
546
    or edx,[blue]
534
   
547
 
535
nodark0:
548
nodark0:
536
;   eo custom darken floor
549
;   eo custom darken floor
537
   
550
 
538
   
551
 
539
    mov eax,edx
552
    mov eax,edx
540
    mov [esi],eax ; actually draw the floor pixel
553
    mov [esi],eax ; actually draw the floor pixel
541
   
554
 
542
 ; paint "forgotten" pixels
555
 ; paint "forgotten" pixels
543
   
556
 
544
    mov edx,[lasty]
557
    mov edx,[lasty]
545
    sub edx,1920
558
    sub edx,1920
546
    cmp esi,edx
559
    cmp esi,edx
547
    je foff0
560
    je foff0
548
    mov [esi+1920],eax
561
    mov [esi+1920],eax
549
   
562
 
550
    sub edx,1920
563
    sub edx,1920
551
    cmp esi,edx
564
    cmp esi,edx
552
    je foff0
565
    je foff0
553
    mov [edx+1920],eax
566
    mov [edx+1920],eax
554
   
567
 
555
    sub edx,1920
568
    sub edx,1920
556
    cmp esi,edx
569
    cmp esi,edx
557
    je foff0
570
    je foff0
558
    mov [edx+1920],eax
571
    mov [edx+1920],eax
559
   
572
 
560
foff0:
573
foff0:
561
mov [lasty],esi
574
mov [lasty],esi
562
;**** end of draw floor pixel ****
575
;**** end of draw floor pixel ****
563
   
576
 
564
    mov esi,[remesi]
577
    mov esi,[remesi]
565
    mov edi,[vl] ; restore L
578
    mov edi,[vl] ; restore L
566
   
579
 
567
no_nu_pixel:
580
no_nu_pixel:
568
   
581
 
569
   
582
 
570
    mov esi,[vh]
583
    mov esi,[vh]
571
    mov [h_old],esi
584
    mov [h_old],esi
572
   
585
 
573
    mov eax,[vxx]
586
    mov eax,[vxx]
574
    mov ebx,[vyy]
587
    mov ebx,[vyy]
575
   
588
 
576
    add eax,[vstepx]  ; casting...
589
    add eax,[vstepx]  ; casting...
577
    add ebx,[vstepy]
590
    add ebx,[vstepy]
578
   
591
 
579
    mov [vxx],eax
592
    mov [vxx],eax
580
    mov [vyy],ebx
593
    mov [vyy],ebx
581
   
594
 
582
    sar eax,16
595
    sar eax,16
583
    sar ebx,16
596
    sar ebx,16
584
   
597
 
585
    mov [vpxi],eax    ; casters position in Map Grid
598
    mov [vpxi],eax    ; casters position in Map Grid
586
    mov [vpyi],ebx
599
    mov [vpyi],ebx
587
   
600
 
588
    mov edx,ebx
601
    mov edx,ebx
589
;    imul edx,32
602
;    imul edx,32
590
    shl edx,5
603
    shl edx,5
591
    add edx,grid
604
;    add edx,grid
592
    add edx,eax
605
;    add edx,eax
-
 
606
    lea edx, [grid+edx+eax]
-
 
607
 
593
    cmp [edx],byte 0   ; raycaster reached a wall? (0=no)
608
    cmp [edx],byte 0   ; raycaster reached a wall? (0=no)
594
    jne getout
609
    jne getout
595
    cmp edi,10000        ; limit view range
610
    cmp edi,10000        ; limit view range
596
    jb raycast
611
    jb raycast
597
;................................................
612
;................................................
598
getout:
613
getout:
599
    mov eax,[edx]      ; store Grid Wall Value for Texture Selection
614
    mov eax,[edx]      ; store Grid Wall Value for Texture Selection
600
    mov [vk],eax
615
    mov [vk],eax
601
   
616
 
602
 call blur  ; deactivate this (blurs the near floor) : a bit faster
617
 call blur  ; deactivate this (blurs the near floor) : a bit faster
603
   
618
 
604
; simply copy floor to ceil pixel column here
619
; simply copy floor to ceil pixel column here
605
;jmp nocopy ; use this for test purposes
620
;jmp nocopy ; use this for test purposes
606
   
621
 
607
    pusha
622
    pusha
608
    mov eax,0x80000+1920*240
623
    mov eax,0x80000+1920*240
609
    mov ebx,0x80000+1920*240
624
    mov ebx,0x80000+1920*240
610
   
625
 
611
copyfloor:
626
copyfloor:
612
    sub eax,1920
627
    sub eax,1920
613
    add ebx,1920
628
    add ebx,1920
614
   
629
 
615
    mov ecx,0
630
;    mov ecx,0
616
    add ecx,[vx1]
631
;    add ecx,[vx1]
617
    add ecx,[vx1]
632
;    add ecx,[vx1]
-
 
633
;    add ecx,[vx1]
-
 
634
    mov ecx, [vx1]
618
    add ecx,[vx1]
635
    lea ecx, [ecx+ecx*2]
619
   
636
 
-
 
637
;    mov edx,ecx
-
 
638
;    add ecx,eax
-
 
639
;    add edx,ebx
620
    mov edx,ecx
640
    lea edx, [ecx+ebx]
621
    add ecx,eax
-
 
622
    add edx,ebx
641
    add ecx,eax
623
   
642
 
624
    mov esi,[edx]
643
    mov esi,[edx]
625
    mov [ecx],esi
644
    mov [ecx],esi
626
   
645
 
627
    cmp eax,0x80000
646
    cmp eax,0x80000
628
    jg copyfloor
647
    jg copyfloor
629
   
648
 
630
    popa
649
    popa
631
; *** end of copy floor to ceil
650
; *** end of copy floor to ceil
632
;nocopy:
651
;nocopy:
633
;__________________________________________________________________________
652
;__________________________________________________________________________
634
   
653
 
635
   
654
 
636
; draw this pixelrows wall
655
; draw this pixelrows wall
637
    mov [vl],edi
656
    mov [vl],edi
638
   
657
 
639
    mov edi,260
658
    mov edi,260
640
    sub edi,[vdd]
659
    sub edi,[vdd]
641
    cmp edi,0
660
    cmp edi,0
642
    jg ok3
661
    jg ok3
643
    xor edi,edi
662
    xor edi,edi
644
    ok3:
663
    ok3:
645
    mov [vbottom],edi  ; end wall ceil (or window top)
664
    mov [vbottom],edi  ; end wall ceil (or window top)
646
   
665
 
647
    mov esi,262
666
    mov esi,262
648
    add esi,[vdd]  ; start wall floor
667
    add esi,[vdd]  ; start wall floor
649
   
668
 
650
    xor edi,edi
669
    xor edi,edi
651
   
670
 
652
; somethin is wrong with xfrac,so recalc...
671
; somethin is wrong with xfrac,so recalc...
653
   
672
 
654
    mov eax,[vxx]
673
    mov eax,[vxx]
655
    and eax,0x0000FFFF
674
    and eax,0x0000FFFF
656
    shr eax,10
675
    shr eax,10
657
    mov [xfrac],eax
676
    mov [xfrac],eax
658
   
677
 
659
    mov eax,[vyy]
678
    mov eax,[vyy]
660
    and eax,0x0000FFFF
679
    and eax,0x0000FFFF
661
    shr eax,10
680
    shr eax,10
662
    mov [yfrac],eax
681
    mov [yfrac],eax
663
   
682
 
664
    pixelrow:
683
    pixelrow:
665
   
684
 
666
; find each pixels color:
685
; find each pixels color:
667
   
686
 
668
    add edi,64
687
    add edi,64
669
    sub esi,1
688
    sub esi,1
670
    cmp esi, 502  ; dont calc offscreen-pixels
689
    cmp esi, 502  ; dont calc offscreen-pixels
671
    jg speedup
690
    jg speedup
672
   
691
 
673
    xor edx,edx
692
    xor edx,edx
674
    mov eax, edi
693
    mov eax, edi
675
    mov ebx,[vdd]
694
    mov ebx,[vdd]
676
    add ebx,[vdd]
695
;    add ebx,[vdd]
-
 
696
    add ebx, ebx
677
    div ebx
697
    div ebx
678
    and eax,63
698
    and eax,63
679
    mov [ytemp],eax   ; get y of texture for wall
699
    mov [ytemp],eax   ; get y of texture for wall
680
   
700
 
681
    mov eax,[xfrac]
701
    mov eax,[xfrac]
682
    add eax,[yfrac]
702
    add eax,[yfrac]
683
   
703
 
684
    and eax,63
704
    and eax,63
685
    mov [xtemp],eax   ; get x of texture for wall
705
    mov [xtemp],eax   ; get x of texture for wall
686
   
706
 
687
    ; now prepare to plot that wall-pixel...
707
    ; now prepare to plot that wall-pixel...
688
    mov [remedi],edi
708
    mov [remedi],edi
689
   
709
 
690
    mov edi,[ytemp]
710
    mov edi,[ytemp]
691
    sal edi,8
711
    sal edi,8
692
    mov edx,[xtemp]
712
    mov edx,[xtemp]
693
    sal edx,2
713
    sal edx,2
694
    add edi,edx
714
    add edi,edx
695
   
715
 
696
    mov eax,[vk] ; determine which texture should be used
716
    mov eax,[vk] ; determine which texture should be used
697
    and eax,255
717
    and eax,255
698
   
718
 
699
    cmp eax,1
719
    cmp eax,1
700
    jne checkmore1
720
    jne checkmore1
701
    add edi,ceil
721
    add edi,ceil
702
    jmp foundtex
722
    jmp foundtex
703
    checkmore1:
723
    checkmore1:
704
   
724
 
705
    cmp eax,2
725
    cmp eax,2
706
    jne checkmore2
726
    jne checkmore2
707
    add edi,wall
727
    add edi,wall
708
    jmp foundtex
728
    jmp foundtex
709
    checkmore2:
729
    checkmore2:
710
   
730
 
711
    cmp eax,3
731
    cmp eax,3
712
    jne checkmore3
732
    jne checkmore3
713
    add edi,wall2
733
    add edi,wall2
714
    jmp foundtex
734
    jmp foundtex
715
    checkmore3:
735
    checkmore3:
716
   
736
 
717
    cmp eax,4
737
    cmp eax,4
718
    jne checkmore4
738
    jne checkmore4
719
    add edi,wall3
739
    add edi,wall3
720
    jmp foundtex
740
    jmp foundtex
721
    checkmore4:
741
    checkmore4:
722
   
742
 
723
    cmp eax,5
743
    cmp eax,5
724
    jne checkmore5
744
    jne checkmore5
725
    add edi,wall4
745
    add edi,wall4
726
    jmp foundtex
746
    jmp foundtex
727
    checkmore5:
747
    checkmore5:
728
   
748
 
729
    cmp eax,6
749
    cmp eax,6
730
    jne checkmore6
750
    jne checkmore6
731
    add edi,wall5
751
    add edi,wall5
732
    jmp foundtex
752
    jmp foundtex
733
    checkmore6:
753
    checkmore6:
734
   
754
 
735
    cmp eax,7
755
    cmp eax,7
736
    jne checkmore7
756
    jne checkmore7
737
    add edi,wall6
757
    add edi,wall6
738
    jmp foundtex
758
    jmp foundtex
739
    checkmore7:
759
    checkmore7:
740
   
760
 
741
    cmp eax,8
761
    cmp eax,8
742
    jne checkmore8
762
    jne checkmore8
743
    add edi,wall7
763
    add edi,wall7
744
    jmp foundtex
764
    jmp foundtex
745
    checkmore8:
765
    checkmore8:
746
   
766
 
747
    foundtex:
767
    foundtex:
748
   
768
 
749
    mov edx,[edi]    ; get pixel color inside texture
769
    mov edx,[edi]    ; get pixel color inside texture
750
   
770
 
751
; ***pseudoshade south-west
771
; ***pseudoshade south-west
752
jmp east ; activate this for southwest pseudoshade : a bit slower + blink-bug
772
jmp east ; activate this for southwest pseudoshade : a bit slower + blink-bug
753
    mov edi,[yfrac]
773
    mov edi,[yfrac]
754
    mov [pseudo],dword 0 ; store flag for custom distance darkening
774
    mov [pseudo],dword 0 ; store flag for custom distance darkening
755
    cmp edi,[xfrac]
775
    cmp edi,[xfrac]
756
    jge east
776
    jge east
757
    and edx,0x00FEFEFE
777
    and edx,0x00FEFEFE
758
    shr edx,1
778
    shr edx,1
759
    mov [pseudo],dword 1
779
    mov [pseudo],dword 1
760
east:
780
east:
761
   
781
 
762
 call dark_distance ; deactivate wall distance darkening: a bit faster
782
 call dark_distance ; deactivate wall distance darkening: a bit faster
763
   
783
 
764
; ******* DRAW WALL PIXEL *******
784
; ******* DRAW WALL PIXEL *******
765
    mov eax,esi
785
    mov eax,esi
766
    sub eax,22
786
;    sub eax,22
-
 
787
    lea eax, [esi-22]
767
    imul eax,1920
788
    imul eax,1920
768
    add eax,[vx1]
789
;    add eax,[vx1]
769
    add eax,[vx1]
790
;    add eax,[vx1]
770
    add eax,[vx1]
791
;    add eax,[vx1]
771
    add eax,0x80000
792
;    add eax,0x80000
-
 
793
    mov ebx, [vx1]
-
 
794
    lea ebx, [ebx+ebx*2]
-
 
795
    lea eax, [eax+0x80000+ebx]
772
   
796
 
773
    cmp eax,0x80000+1920*480
797
    cmp eax,0x80000+1920*480
774
    jg dont_draw
798
    jg dont_draw
775
    cmp eax,0x80000
799
    cmp eax,0x80000
776
    jb dont_draw
800
    jb dont_draw
777
    mov [eax],edx ; actually set the pixel in the image
801
    mov [eax],edx ; actually set the pixel in the image
778
; *** eo draw wall pixel
802
; *** eo draw wall pixel
779
dont_draw:
803
dont_draw:
780
    mov edi,[remedi]
804
    mov edi,[remedi]
781
speedup:
805
speedup:
782
    cmp esi,[vbottom]  ; end of this column?
806
    cmp esi,[vbottom]  ; end of this column?
783
    jg pixelrow
807
    jg pixelrow
784
   
808
 
785
    mov edi,[vl]  ; restoring
809
    mov edi,[vl]  ; restoring
786
    mov eax,[vx1] ; inc X1
810
    mov eax,[vx1] ; inc X1
787
    add eax,1
811
    add eax,1
788
    mov [vx1],eax
812
    mov [vx1],eax
789
   
813
 
790
    ;*** NEXT A ***
814
    ;*** NEXT A ***
791
    mov esi,[va]
815
    mov esi,[va]
792
    sub esi,1
816
    sub esi,1
793
    mov [va],esi
817
    mov [va],esi
794
    cmp esi,[vacompare]
818
    cmp esi,[vacompare]
795
    jg for_a
819
    jg for_a
796
    ;*** EO NEXT A ***
820
    ;*** EO NEXT A ***
797
;---------------------------------------------------------------------------
821
;---------------------------------------------------------------------------
798
   
822
 
799
   
823
 
800
; **** put image !!!!!****
824
; **** put image !!!!!****
801
; ***********************
825
; ***********************
802
    mov eax,7
826
    mov eax,7
803
    mov ebx,0x80000
827
    mov ebx,0x80000
804
    mov ecx,640*65536+480
828
    mov ecx,640*65536+480
805
    mov edx,5*65536+20
829
    mov edx,5*65536+20
806
    int 0x40
830
    int 0x40
807
   
831
 
808
    ret
832
    ret
809
   
833
 
810
blur:
834
blur:
811
   
835
 
812
pusha
836
pusha
813
mov eax,0x080000+360*1920
837
mov eax,0x080000+360*1920
814
   
838
 
815
copyfloor2:
839
copyfloor2:
816
    add eax,1920
840
    add eax,1920
817
    mov ebx,eax
841
;    mov ebx,eax
818
    add ebx,[vx1]
842
;    add ebx,[vx1]
819
    add ebx,[vx1]
843
;    add ebx,[vx1]
820
    add ebx,[vx1]
844
;    add ebx,[vx1]
-
 
845
    mov ebx,[vx1]
-
 
846
    lea ebx, [ebx+ebx*2]
-
 
847
    add ebx, eax
-
 
848
 
821
   
849
 
822
    mov ecx,[ebx-15]
850
    mov ecx,[ebx-15]
823
    and ecx,0x00FEFEFE
851
    and ecx,0x00FEFEFE
824
    shr ecx,1
852
    shr ecx,1
825
    mov edx,[ebx-12]
853
    mov edx,[ebx-12]
826
    and edx,0x00FEFEFE
854
    and edx,0x00FEFEFE
827
    shr edx,1
855
    shr edx,1
828
    add edx,ecx
856
    add edx,ecx
829
    and edx,0x00FEFEFE
857
    and edx,0x00FEFEFE
830
    shr edx,1
858
    shr edx,1
831
   
859
 
832
     mov ecx,[ebx-9]
860
     mov ecx,[ebx-9]
833
     and ecx,0x00FEFEFE
861
     and ecx,0x00FEFEFE
834
     shr ecx,1
862
     shr ecx,1
835
     add edx,ecx
863
     add edx,ecx
836
   
864
 
837
      and edx,0x00FEFEFE
865
      and edx,0x00FEFEFE
838
      shr edx,1
866
      shr edx,1
839
   
867
 
840
      mov ecx,[ebx-6]
868
      mov ecx,[ebx-6]
841
      and ecx,0x00FEFEFE
869
      and ecx,0x00FEFEFE
842
      shr ecx,1
870
      shr ecx,1
843
      add edx,ecx
871
      add edx,ecx
844
   
872
 
845
       and edx,0x00FEFEFE
873
       and edx,0x00FEFEFE
846
       shr edx,1
874
       shr edx,1
847
   
875
 
848
       mov ecx,[ebx-3]
876
       mov ecx,[ebx-3]
849
       and ecx,0x00FEFEFE
877
       and ecx,0x00FEFEFE
850
       shr ecx,1
878
       shr ecx,1
851
       add edx,ecx
879
       add edx,ecx
852
   
880
 
853
        and edx,0x00FEFEFE
881
        and edx,0x00FEFEFE
854
        shr edx,1
882
        shr edx,1
855
   
883
 
856
        mov ecx,[ebx]
884
        mov ecx,[ebx]
857
        and ecx,0x00FEFEFE
885
        and ecx,0x00FEFEFE
858
        shr ecx,1
886
        shr ecx,1
859
        add edx,ecx
887
        add edx,ecx
860
   
888
 
861
    mov [ebx],edx
889
    mov [ebx],edx
862
   
890
 
863
    cmp eax,0x80000+478*1920
891
    cmp eax,0x80000+478*1920
864
    jb copyfloor2
892
    jb copyfloor2
865
   
893
 
866
popa
894
popa
867
   
895
 
868
ret
896
ret
869
   
897
 
870
   
898
 
871
   
899
 
872
; ******* Darken by Distance *******
900
; ******* Darken by Distance *******
873
dark_distance:
901
dark_distance:
874
   
902
 
875
; color must be in edx, wall height in [vdd]
903
; color must be in edx, wall height in [vdd]
876
   
904
 
877
    mov eax,[vdd]
905
    mov eax,[vdd]
878
    cmp eax,50
906
    cmp eax,50
879
    jg nodark
907
    jg nodark
880
    ;                split rgb
908
    ;                split rgb
881
   
909
 
882
    mov [blue],edx
910
    mov [blue],edx
883
    and [blue],dword 255
911
    and [blue],dword 255
884
   
912
 
885
    shr edx,8
913
    shr edx,8
886
    mov [green],edx
914
    mov [green],edx
887
    and [green],dword 255
915
    and [green],dword 255
888
   
916
 
889
    shr edx,8
917
    shr edx,8
890
    mov [red],edx
918
    mov [red],edx
891
    and [red],dword 255
919
    and [red],dword 255
892
   
920
 
893
    mov eax,51    ; darkness parameter
921
    mov eax,51    ; darkness parameter
894
    sub eax,[vdd]
922
    sub eax,[vdd]
895
    cmp [pseudo],dword 1
923
    cmp [pseudo],dword 1
896
    je isdarkside
924
    je isdarkside
897
    sal eax,2
925
    sal eax,2
898
isdarkside:
926
isdarkside:
899
   
927
 
900
;                        reduce rgb
928
;                        reduce rgb
901
    sub [red],eax
929
    sub [red],eax
902
    cmp [red], dword 0
930
    cmp [red], dword 0
903
    jg notblack10b
931
    jg notblack10b
904
    mov [red],dword 0
932
    mov [red],dword 0
905
    notblack10b:
933
    notblack10b:
906
   
934
 
907
    sub [green],eax
935
    sub [green],eax
908
    cmp [green],dword 0
936
    cmp [green],dword 0
909
    jg notblack20b
937
    jg notblack20b
910
    mov [green],dword 0
938
    mov [green],dword 0
911
    notblack20b:
939
    notblack20b:
912
   
940
 
913
    mov edx,[blue]
941
    mov edx,[blue]
914
    sub [blue],eax
942
    sub [blue],eax
915
    cmp [blue],dword 0
943
    cmp [blue],dword 0
916
    jg notblack30b
944
    jg notblack30b
917
    mov [blue],dword 0
945
    mov [blue],dword 0
918
    notblack30b:
946
    notblack30b:
919
   
947
 
920
    shl dword [red],16 ; reassemble rgb
948
    shl dword [red],16 ; reassemble rgb
921
    shl dword [green],8
949
    shl dword [green],8
922
    mov edx,[red]
950
    mov edx,[red]
923
    or edx,[green]
951
    or edx,[green]
924
    or edx,[blue]
952
    or edx,[blue]
925
    mov eax,edx
953
    mov eax,edx
926
   
954
 
927
nodark:
955
nodark:
928
   
956
 
929
    ret
957
    ret
930
   
958
 
931
   
959
 
932
; DATA AREA
960
; DATA AREA
933
   
961
 
934
;ceil=ceil
962
;ceil=ceil
935
;wall=wall floor
963
;wall=wall floor
936
;2 corner stone
964
;2 corner stone
937
;3 leaf mosaic
965
;3 leaf mosaic
938
;4 closed window
966
;4 closed window
939
;5 greek mosaic
967
;5 greek mosaic
940
;6 old street stones
968
;6 old street stones
941
;7 maya wall
969
;7 maya wall
942
   
970
 
943
grid:  ; 32*32 Blocks, Map: 0 = Air, 1 to 8 = Wall
971
grid:  ; 32*32 Blocks, Map: 0 = Air, 1 to 8 = Wall
944
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
972
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
945
db 1,0,0,0,1,0,0,0,0,0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8
973
db 1,0,0,0,1,0,0,0,0,0,0,3,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,8,8
946
db 5,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8
974
db 5,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8
947
db 1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1,0,0,0,0,3,3,3,3,0,0,0,0,0,0,8
975
db 1,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1,0,0,0,0,3,3,3,3,0,0,0,0,0,0,8
948
db 5,0,1,2,3,4,5,6,7,8,2,1,3,3,3,0,5,0,2,1,2,3,0,0,0,0,0,0,0,0,0,8
976
db 5,0,1,2,3,4,5,6,7,8,2,1,3,3,3,0,5,0,2,1,2,3,0,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4,0,1
999
db 5,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,6,0,0,5,0,1,0,4,0,0,0,0,0,4,0,1
972
db 1,0,0,0,1,0,0,5,0,0,0,3,0,0,0,0,6,1,5,1,0,1,0,4,4,0,0,0,4,4,0,1
1000
db 1,0,0,0,1,0,0,5,0,0,0,3,0,0,0,0,6,1,5,1,0,1,0,4,4,0,0,0,4,4,0,1
973
db 5,0,0,0,0,0,0,5,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,4,4,4,4,4,0,0,1
1001
db 5,0,0,0,0,0,0,5,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,4,4,4,4,4,0,0,1
974
db 1,4,1,4,1,4,1,4,1,4,1,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1
1002
db 1,4,1,4,1,4,1,4,1,4,1,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1
975
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1003
db 2,1,2,1,2,1,2,1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
976
   
1004
 
977
vpx:
1005
vpx:
978
dd 0x0001FFFF ; initial player position * 0xFFFF
1006
dd 0x0001FFFF ; initial player position * 0xFFFF
979
 vpy:
1007
 vpy:
980
dd 0x0001FFFF
1008
dd 0x0001FFFF
981
   
1009
 
982
labelt:
1010
labelt:
983
      db   'FISHEYE RAYCASTING ENGINE ETC. FREE3D'
1011
      db   'FISHEYE RAYCASTING ENGINE ETC. FREE3D'
984
   
1012
 
985
labellen:
1013
labellen:
986
sindegree dd 0.0
1014
sindegree dd 0.0
987
sininc    dd 0.0017453292519943295769236907684886
1015
sininc    dd 0.0017453292519943295769236907684886
988
sindiv    dd 6553.5   
1016
sindiv    dd 6553.5
989
textures:
1017
textures:
990
	file 'texture.gif'
1018
	file 'texture.gif'
-
 
1019
 
991
I_END:
1020
align 4
992
   
1021
 
993
col1:
1022
col1:
994
 dd ?;-
1023
 dd ?;-
995
; misc raycaster vars:
1024
; misc raycaster vars:
996
vxx:
1025
vxx:
997
 dd ?;-
1026
 dd ?;-
998
vyy:
1027
vyy:
999
 dd ?;-
1028
 dd ?;-
1000
vl:
1029
vl:
1001
 dd ?;-
1030
 dd ?;-
1002
vstepx:
1031
vstepx:
1003
 dd ?;-
1032
 dd ?;-
1004
vstepy:
1033
vstepy:
1005
 dd ?;-
1034
 dd ?;-
1006
vxxint:
1035
vxxint:
1007
 dd ?;-
1036
 dd ?;-
1008
vyyint:
1037
vyyint:
1009
 dd ?;-
1038
 dd ?;-
1010
vk:
1039
vk:
1011
 dd ?;-
1040
 dd ?;-
1012
va:
1041
va:
1013
 dd ?;-
1042
 dd ?;-
1014
va2:
1043
va2:
1015
 dd ?;-
1044
 dd ?;-
1016
vdd:
1045
vdd:
1017
 dd ?;-
1046
 dd ?;-
1018
vx1:
1047
vx1:
1019
 dd ?;-
1048
 dd ?;-
1020
vx1b:
1049
vx1b:
1021
 dd ?;-
1050
 dd ?;-
1022
vh:
1051
vh:
1023
 dd ?;-
1052
 dd ?;-
1024
vdt:
1053
vdt:
1025
 dd ?;-
1054
 dd ?;-
1026
vheading: ; initial heading: 0 to 3599
1055
vheading: ; initial heading: 0 to 3599
1027
 dd ?;-
1056
 dd ?;-
1028
vacompare:
1057
vacompare:
1029
 dd ?;-
1058
 dd ?;-
1030
vpxi:
1059
vpxi:
1031
 dd ?;-
1060
 dd ?;-
1032
vpyi:
1061
vpyi:
1033
 dd ?;-
1062
 dd ?;-
1034
wtolong:
1063
wtolong:
1035
 dw ?,?;-,?;-
1064
 dw ?,?;-,?;-
1036
   
1065
 
1037
xtemp:
1066
xtemp:
1038
 dd ?;-
1067
 dd ?;-
1039
ytemp:
1068
ytemp:
1040
 dd ?;-
1069
 dd ?;-
1041
xfrac:
1070
xfrac:
1042
 dd ?;-
1071
 dd ?;-
1043
yfrac:
1072
yfrac:
1044
 dd ?;-
1073
 dd ?;-
1045
h_old:
1074
h_old:
1046
 dd ?;-
1075
 dd ?;-
1047
vbottom:
1076
vbottom:
1048
 dd ?;-
1077
 dd ?;-
1049
mouseya:
1078
mouseya:
1050
 dd ?;-
1079
 dd ?;-
1051
remeax:
1080
remeax:
1052
 dd ?;-
1081
 dd ?;-
1053
remebx:
1082
remebx:
1054
 dd ?;-
1083
 dd ?;-
1055
remecx:
1084
remecx:
1056
 dd ?;-
1085
 dd ?;-
1057
remedx:
1086
remedx:
1058
 dd ?;-
1087
 dd ?;-
1059
remedi:
1088
remedi:
1060
 dd ?;-
1089
 dd ?;-
1061
remesi:
1090
remesi:
1062
 dd ?;-
1091
 dd ?;-
1063
red:
1092
red:
1064
 dd ?;-
1093
 dd ?;-
1065
green:
1094
green:
1066
 dd ?;-
1095
 dd ?;-
1067
blue:
1096
blue:
1068
 dd ?;-
1097
 dd ?;-
1069
pseudo:
1098
pseudo:
1070
 dd ?;-
1099
 dd ?;-
1071
step1:
1100
step1:
1072
 dd ?;-
1101
 dd ?;-
1073
step64:
1102
step64:
1074
 dd ?;-
1103
 dd ?;-
1075
lasty:
1104
lasty:
1076
 dd ?;-
1105
 dd ?;-
-
 
1106
 
1077
   
1107
I_END:
1078
sinus rd 360*10 
1108
sinus rd 360*10
1079
eosinus:
1109
eosinus: