Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 108 → Rev 109

/programs/demos/free3d04/trunk/free3d04.asm
0,0 → 1,1079
;
; Fisheye Raycasting Engine Etc. FREE3D for MENUETOS by Dieter Marfurt
; Version 0.4 (requires some texture-files to compile (see Data Section))
; dietermarfurt@angelfire.com - www.melog.ch/mos_pub/
; Don't hit me - I'm an ASM-Newbie... since years :)
;
; Compile with FASM for Menuet (requires .INC files - see DATA Section)
;
; Willow - greatly srinked code size by using GIF texture and FPU to calculate sine table
;
; !!!! Don't use GIF.INC in your apps - it's modified for FREE3D !!!!
TEX_SIZE equ 64*64*4
ceil = sinus+16*1024
wall = ceil+TEX_SIZE*1
wall2 = ceil+TEX_SIZE*2
wall3 = ceil+TEX_SIZE*3
wall4 = ceil+TEX_SIZE*4
wall5 = ceil+TEX_SIZE*5
wall6 = ceil+TEX_SIZE*6
wall7 = ceil+TEX_SIZE*7
APP_MEM equ 0x200000
 
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd APP_MEM;0x300000 ; memory for app
dd APP_MEM;0x300000 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon
include 'lang.inc'
include 'macros.inc'
COLOR_ORDER equ OTHER
include 'gif.inc'
START: ; start of execution
mov esi,textures
mov edi,ceil
mov eax,sinus
call ReadGIF
mov esi,sinus
mov ecx,360*10
fninit
fld [sindegree]
.sinlp:
fst st1
fsin
fmul [sindiv]
fistp dword[esi]
add esi,4
fadd [sininc]
loop .sinlp
call draw_window ; at first, draw the window
call draw_stuff
gamestart:
; ******* MOUSE CHECK *******
; mov eax,37 ; check mouse (use mouse over window to navigate)
; mov ebx,2 ; check mousebuttons
; int 0x40
; cmp eax,0 ; only use mouse when button down
; je noneed ; deactivated cause of disappear-bug etc.
mov eax,37
mov ebx,1 ; check mouseposition
int 0x40
mov ebx,eax
shr eax,16
and eax,0x0000FFFF ; mousex
and ebx,0x0000FFFF ; mousey
cmp eax,5 ; mouse out of window ?
jb check_refresh ; it will prevent an app-crash
cmp ebx,22
jb check_refresh
cmp eax, 640
jg check_refresh
cmp ebx,501
jg check_refresh
cmp eax,315 ; navigating?
jb m_left
cmp eax,325 ;
jg m_right
continue:
cmp ebx,220 ;
jb s_up
cmp ebx,260 ;
jg s_down
; ******* END OF MOUSE CHECK *******
check_refresh:
; mov eax,23 ; wait for system event with 10 ms timeout
; mov ebx,1 ; thats max 100 FPS
mov eax,11 ; ask no wait for full speed
int 0x40
cmp eax,1 ; window redraw request ?
je red2
cmp eax,2 ; key in buffer ?
je key2
cmp eax,3 ; button in buffer ?
je button2
mov edi,[mouseya] ; check flag if a refresh has to be done
cmp edi,1
jne gamestart
mov [mouseya],dword 0
call draw_stuff
jmp gamestart
; END OF MAINLOOP
red2: ; redraw
call draw_window
call draw_stuff
jmp gamestart
key2: ; key
mov eax,2
int 0x40
cmp al,1
je gamestart ; keybuffer empty
cmp ah,27 ; esc=End App
je finish
cmp ah,178 ; up
je s_up
cmp ah,177 ; down
je s_down
cmp ah,176 ; left
je s_left
cmp ah,179 ; right
je s_right
jmp gamestart ; was any other key
s_up: ; walk forward (key or mouse)
mov eax,[vpx]
mov ebx,[vpy]
mov ecx,[vheading]
imul ecx,4
add ecx,sinus
mov edi,[ecx]
mov edx,[vheading]
imul edx,4
add edx,sinus
add edx,3600
cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
jb ok200
sub edx,14400
ok200:
mov esi,[edx]
; sal esi,1 ; edit walking speed here
; sal edi,1
add eax,edi ; newPx
add ebx,esi ; newPy
mov edi,eax ; newPx / ffff
mov esi,ebx ; newPy / ffff
sar edi,16
sar esi,16
mov ecx,esi
sal ecx,5 ; equal *32
add ecx,edi
add ecx,grid
cmp [ecx],byte 0 ; collision check
jne cannotwalk0
mov [vpx],eax
mov [vpy],ebx
mov [mouseya],dword 1 ; set refresh flag
cannotwalk0:
jmp check_refresh
s_down: ; walk backward
mov eax,[vpx]
mov ebx,[vpy]
mov ecx,[vheading]
imul ecx,4
add ecx,sinus
mov edi,[ecx]
mov edx,[vheading]
imul edx,4
add edx,sinus
add edx,3600
cmp edx,eosinus ;cosinus taken from (sinus plus 900) mod 3600
jb ok201
sub edx,14400
ok201:
mov esi,[edx]
; sal esi,1 ; edit walking speed here
; sal edi,1
sub eax,edi ; newPx
sub ebx,esi ; newPy
mov edi,eax ; newPx / ffff
mov esi,ebx ; newPy / ffff
sar edi,16
sar esi,16
mov ecx,esi
sal ecx,5
add ecx,edi
add ecx,grid
cmp [ecx],byte 0
jne cannotwalk1
mov [vpx],eax
mov [vpy],ebx
mov [mouseya],dword 1
cannotwalk1:
jmp check_refresh
s_left: ; turn left (key)
mov edi,[vheading] ; heading
add edi,50
cmp edi,3600
jb ok_heading0
sub edi,3600
ok_heading0:
mov [vheading],edi
mov [mouseya],dword 1
jmp check_refresh
s_right: ; turn right
mov edi,[vheading]
sub edi,50
cmp edi,-1
jg ok_heading1
add edi,3600
ok_heading1:
mov [vheading],edi
mov [mouseya],dword 1
jmp check_refresh
m_left: ; turn left (mouse)
mov edi,[vheading] ; heading
mov ecx,315
sub ecx,eax
sar ecx,2
add edi,ecx
cmp edi,3600
jb ok_heading2
sub edi,3600
ok_heading2:
mov [vheading],edi
mov [mouseya],dword 1
jmp continue ; allow both: walk and rotate
m_right: ; turn right
mov edi,[vheading]
sub eax,325
sar eax,2
sub edi,eax
cmp edi,-1
jg ok_heading3
add edi,3600
ok_heading3:
mov [vheading],edi
mov [mouseya],dword 1
jmp continue
button2: ; button
mov eax,17 ; get id
int 0x40
cmp ah,1 ; button id=1 ?
jne gamestart
; eo GAME mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
finish:
mov eax,-1 ; close this program
int 0x40
; *********************************************
; ******* WINDOW DEFINITIONS AND DRAW ********
; *********************************************
draw_window:
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,1 ; 1, start of draw
int 0x40
; DRAW WINDOW
mov eax,0 ; function 0 : define and draw window
mov ebx,50*65536+649 ; [x start] *65536 + [x size]
mov ecx,50*65536+504 ; [y start] *65536 + [y size]
mov edx,0x02ffffff ; color of work area RRGGBB,8->color gl
mov esi,0x80777777 ; color of grab bar RRGGBB,8->color gl
mov edi,0x00777777 ; color of frames RRGGBB
int 0x40
; WINDOW LABEL
mov eax,4 ; function 4 : write text to window
mov ebx,8*65536+8 ; [x start] *65536 + [y start]
mov ecx,0x00ddeeff ; color of text RRGGBB
mov edx,labelt ; pointer to text beginning
mov esi,labellen-labelt ; text length
int 0x40
; CLOSE BUTTON
mov eax,8 ; function 8 : define and draw button
mov ebx,(649-19)*65536+12 ; [x start] *65536 + [x size]
mov ecx,5*65536+12 ; [y start] *65536 + [y size]
mov edx,1 ; button id
mov esi,0x777777 ; button color RRGGBB
int 0x40
mov eax,12 ; function 12:tell os about windowdraw
mov ebx,2 ; 2, end of draw
int 0x40
ret
; *********************************************
; ******* COMPUTE 3D-VIEW ********
; *********************************************
draw_stuff:
mov [step1],dword 1
;mov [step64],dword 64
mov esi,[vheading]
add esi,320
mov [va],esi
mov eax,[vheading]
sub eax,320
mov [vacompare],eax
;------------------------------------ CAST 640 PIXEL COLUMNS ---------------
; FOR A=320+heading to -319+heading step -1 (a is stored in [va])
;---------------------------------------------------------------------------
; mov edx,5
mov [vx1],dword 0 ;5 ;edx ; init x1 ... pixelcolumn
for_a:
mov edx,[vx1]
mov [vx1b],edx
sub [vx1b],dword 320
mov edx,[va] ; a2
cmp edx,-1 ; a2 is a mod 3600
jg ok1
add edx,3600
ok1:
cmp edx,3600
jb ok2
sub edx,3600
ok2:
; get stepx and stepy
mov ecx,edx
imul ecx,4
add ecx,sinus ; pointer to stepx
mov esi,[ecx]
sar esi,4 ; accuracy
mov [vstepx],esi ; store stepx
mov esi,edx
imul esi,4
add esi,sinus ; pointer to stepy
add esi,3600
cmp esi,eosinus ;cosinus taken from ((sinus plus 900) mod 3600)
jb ok202
sub esi,14400
ok202:
mov ecx,[esi]
sar ecx,4
mov [vstepy],ecx ; store stepy
mov eax,[vpx] ; get Camera Position
mov ebx,[vpy]
mov [vxx],eax ; init caster position
mov [vyy],ebx
mov edi,0 ; init L (number of raycsting-steps)
mov [step1],dword 1 ; init Caster stepwidth for L
; raycast a pixel column.................................
raycast:
add edi,[step1] ; count caster steps
;jmp nodouble ; use this to prevent blinking/wobbling textures: much slower!
cmp edi,32
je double
cmp edi,512
je double
cmp edi,1024
je double
jmp nodouble
double:
mov edx,[step1]
sal edx,1
mov [step1],edx
mov edx,[vstepx]
sal edx,1
mov [vstepx],edx
mov edx,[vstepy]
sal edx,1
mov [vstepy],edx
nodouble:
mov eax,32000 ; 3600 ; determine Floors Height based on distance
mov edx,0
mov ebx,edi
div ebx
mov esi,eax
mov [vdd],esi
mov edx,260
sub edx,esi
mov [vh],edx
cmp edx,22
jb no_nu_pixel
cmp edx,259
jg no_nu_pixel ; draw only new pixels
cmp edx,[h_old]
je no_nu_pixel
mov eax,[vxx] ; calc floor pixel
mov ebx,[vyy]
and eax,0x0000FFFF
and ebx,0x0000FFFF
shr eax,10
shr ebx,10 ; pixel coords inside Texture x,y 64*64
mov [xfrac],eax
mov [yfrac],ebx
; plot floor pixel !!!!
mov [vl],edi ; save L
mov [ytemp],esi ; remember L bzw. H
mov edi,[yfrac] ; get pixel color of this floor pixel
sal edi,8
mov esi,[xfrac]
sal esi,2
add edi,esi
add edi,wall ; in fact its floor, just using the wall texture :)
mov edx,[edi]
mov [remesi],esi
;**** calculate pixel adress:****
mov esi,[ytemp]
add esi,240
imul esi,1920
add esi,[vx1]
add esi,[vx1]
add esi,[vx1]
add esi,0x80000
cmp esi,0x80000+1920*480
jg foff0
cmp esi,0x80000
jb foff0
; now we have the adress of the floor-pixel color in edi
; and the adress of the pixel in the image in esi
mov edx,[edi]
;******************** custom distance DARKEN Floor
mov eax,[vdd]
; jmp nodark0 ; use this to deactivate darkening floor (a bit faster)
cmp eax,80
jg nodark0
; split rgb
mov [blue],edx
and [blue],dword 255
shr edx,8
mov [green],edx
and [green],dword 255
shr edx,8
mov [red],edx
and [red],dword 255
mov eax,81 ; darkness parameter
sub eax,[vdd]
sal eax,1
; reduce rgb
sub [red],eax
cmp [red], dword 0
jg notblack10
mov [red],dword 0
notblack10:
sub [green],eax
cmp [green],dword 0
jg notblack20
mov [green],dword 0
notblack20:
mov edx,[blue]
sub [blue],eax
cmp [blue],dword 0
jg notblack30
mov [blue],dword 0
notblack30:
shl dword [red],16 ; reassemble rgb
shl dword [green],8
mov edx,[red]
or edx,[green]
or edx,[blue]
nodark0:
; eo custom darken floor
mov eax,edx
mov [esi],eax ; actually draw the floor pixel
; paint "forgotten" pixels
mov edx,[lasty]
sub edx,1920
cmp esi,edx
je foff0
mov [esi+1920],eax
sub edx,1920
cmp esi,edx
je foff0
mov [edx+1920],eax
sub edx,1920
cmp esi,edx
je foff0
mov [edx+1920],eax
foff0:
mov [lasty],esi
;**** end of draw floor pixel ****
mov esi,[remesi]
mov edi,[vl] ; restore L
no_nu_pixel:
mov esi,[vh]
mov [h_old],esi
mov eax,[vxx]
mov ebx,[vyy]
add eax,[vstepx] ; casting...
add ebx,[vstepy]
mov [vxx],eax
mov [vyy],ebx
sar eax,16
sar ebx,16
mov [vpxi],eax ; casters position in Map Grid
mov [vpyi],ebx
mov edx,ebx
; imul edx,32
shl edx,5
add edx,grid
add edx,eax
cmp [edx],byte 0 ; raycaster reached a wall? (0=no)
jne getout
cmp edi,10000 ; limit view range
jb raycast
;................................................
getout:
mov eax,[edx] ; store Grid Wall Value for Texture Selection
mov [vk],eax
call blur ; deactivate this (blurs the near floor) : a bit faster
; simply copy floor to ceil pixel column here
;jmp nocopy ; use this for test purposes
pusha
mov eax,0x80000+1920*240
mov ebx,0x80000+1920*240
copyfloor:
sub eax,1920
add ebx,1920
mov ecx,0
add ecx,[vx1]
add ecx,[vx1]
add ecx,[vx1]
mov edx,ecx
add ecx,eax
add edx,ebx
mov esi,[edx]
mov [ecx],esi
cmp eax,0x80000
jg copyfloor
popa
; *** end of copy floor to ceil
;nocopy:
;__________________________________________________________________________
; draw this pixelrows wall
mov [vl],edi
mov edi,260
sub edi,[vdd]
cmp edi,0
jg ok3
xor edi,edi
ok3:
mov [vbottom],edi ; end wall ceil (or window top)
mov esi,262
add esi,[vdd] ; start wall floor
xor edi,edi
; somethin is wrong with xfrac,so recalc...
mov eax,[vxx]
and eax,0x0000FFFF
shr eax,10
mov [xfrac],eax
mov eax,[vyy]
and eax,0x0000FFFF
shr eax,10
mov [yfrac],eax
pixelrow:
; find each pixels color:
add edi,64
sub esi,1
cmp esi, 502 ; dont calc offscreen-pixels
jg speedup
xor edx,edx
mov eax, edi
mov ebx,[vdd]
add ebx,[vdd]
div ebx
and eax,63
mov [ytemp],eax ; get y of texture for wall
mov eax,[xfrac]
add eax,[yfrac]
and eax,63
mov [xtemp],eax ; get x of texture for wall
; now prepare to plot that wall-pixel...
mov [remedi],edi
mov edi,[ytemp]
sal edi,8
mov edx,[xtemp]
sal edx,2
add edi,edx
mov eax,[vk] ; determine which texture should be used
and eax,255
cmp eax,1
jne checkmore1
add edi,ceil
jmp foundtex
checkmore1:
cmp eax,2
jne checkmore2
add edi,wall
jmp foundtex
checkmore2:
cmp eax,3
jne checkmore3
add edi,wall2
jmp foundtex
checkmore3:
cmp eax,4
jne checkmore4
add edi,wall3
jmp foundtex
checkmore4:
cmp eax,5
jne checkmore5
add edi,wall4
jmp foundtex
checkmore5:
cmp eax,6
jne checkmore6
add edi,wall5
jmp foundtex
checkmore6:
cmp eax,7
jne checkmore7
add edi,wall6
jmp foundtex
checkmore7:
cmp eax,8
jne checkmore8
add edi,wall7
jmp foundtex
checkmore8:
foundtex:
mov edx,[edi] ; get pixel color inside texture
; ***pseudoshade south-west
jmp east ; activate this for southwest pseudoshade : a bit slower + blink-bug
mov edi,[yfrac]
mov [pseudo],dword 0 ; store flag for custom distance darkening
cmp edi,[xfrac]
jge east
and edx,0x00FEFEFE
shr edx,1
mov [pseudo],dword 1
east:
call dark_distance ; deactivate wall distance darkening: a bit faster
; ******* DRAW WALL PIXEL *******
mov eax,esi
sub eax,22
imul eax,1920
add eax,[vx1]
add eax,[vx1]
add eax,[vx1]
add eax,0x80000
cmp eax,0x80000+1920*480
jg dont_draw
cmp eax,0x80000
jb dont_draw
mov [eax],edx ; actually set the pixel in the image
; *** eo draw wall pixel
dont_draw:
mov edi,[remedi]
speedup:
cmp esi,[vbottom] ; end of this column?
jg pixelrow
mov edi,[vl] ; restoring
mov eax,[vx1] ; inc X1
add eax,1
mov [vx1],eax
;*** NEXT A ***
mov esi,[va]
sub esi,1
mov [va],esi
cmp esi,[vacompare]
jg for_a
;*** EO NEXT A ***
;---------------------------------------------------------------------------
; **** put image !!!!!****
; ***********************
mov eax,7
mov ebx,0x80000
mov ecx,640*65536+480
mov edx,5*65536+20
int 0x40
ret
blur:
pusha
mov eax,0x080000+360*1920
copyfloor2:
add eax,1920
mov ebx,eax
add ebx,[vx1]
add ebx,[vx1]
add ebx,[vx1]
mov ecx,[ebx-15]
and ecx,0x00FEFEFE
shr ecx,1
mov edx,[ebx-12]
and edx,0x00FEFEFE
shr edx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-9]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-6]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx-3]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
and edx,0x00FEFEFE
shr edx,1
mov ecx,[ebx]
and ecx,0x00FEFEFE
shr ecx,1
add edx,ecx
mov [ebx],edx
cmp eax,0x80000+478*1920
jb copyfloor2
popa
ret
; ******* Darken by Distance *******
dark_distance:
; color must be in edx, wall height in [vdd]
mov eax,[vdd]
cmp eax,50
jg nodark
; split rgb
mov [blue],edx
and [blue],dword 255
shr edx,8
mov [green],edx
and [green],dword 255
shr edx,8
mov [red],edx
and [red],dword 255
mov eax,51 ; darkness parameter
sub eax,[vdd]
cmp [pseudo],dword 1
je isdarkside
sal eax,2
isdarkside:
; reduce rgb
sub [red],eax
cmp [red], dword 0
jg notblack10b
mov [red],dword 0
notblack10b:
sub [green],eax
cmp [green],dword 0
jg notblack20b
mov [green],dword 0
notblack20b:
mov edx,[blue]
sub [blue],eax
cmp [blue],dword 0
jg notblack30b
mov [blue],dword 0
notblack30b:
shl dword [red],16 ; reassemble rgb
shl dword [green],8
mov edx,[red]
or edx,[green]
or edx,[blue]
mov eax,edx
nodark:
ret
; DATA AREA
;ceil=ceil
;wall=wall floor
;2 corner stone
;3 leaf mosaic
;4 closed window
;5 greek mosaic
;6 old street stones
;7 maya wall
grid: ; 32*32 Blocks, Map: 0 = Air, 1 to 8 = Wall
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
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
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
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
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
db 1,0,0,0,0,0,0,0,0,0,2,3,0,0,0,0,5,0,0,0,0,3,0,0,0,0,0,0,0,0,0,8
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,5,0,0,0,0,3,3,0,3,3,0,0,0,0,0,8
db 1,1,0,1,1,1,1,4,1,0,1,3,0,0,0,0,5,2,1,2,0,3,0,0,0,3,0,0,0,0,0,8
db 5,0,0,0,1,0,0,0,0,0,0,1,0,3,3,3,5,0,0,0,0,3,0,0,0,3,0,0,0,0,0,8
db 1,0,0,0,1,0,0,5,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,3,0,0,0,0,0,8
db 5,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,5,0,0,0,0,3,0,0,0,0,0,0,0,0,0,8
db 1,4,4,4,4,4,4,4,4,4,4,3,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,8,8
db 2,2,2,2,2,2,8,8,8,8,8,8,8,8,8,0,0,0,6,6,0,7,7,7,7,7,7,7,7,7,8,8
db 1,0,0,0,1,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1
db 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,2,2,2,2,0,0,0,0,3,3,3,3,3,1
db 1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,6,0,0,0,0,2,0,0,0,0,3,0,0,0,0,1
db 5,0,2,3,2,3,2,3,2,3,2,1,0,0,0,0,6,0,2,2,0,2,0,0,0,0,3,0,5,5,0,1
db 1,0,0,0,0,0,0,4,0,0,0,3,0,0,0,0,6,0,0,2,0,2,0,2,0,0,3,0,0,0,0,1
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,6,0,0,2,2,2,0,2,0,0,3,3,3,3,0,1
db 1,1,0,1,1,1,1,4,1,0,1,3,7,7,7,0,6,0,0,0,0,0,0,2,0,0,0,0,0,3,0,1
db 5,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,6,0,0,0,0,2,2,2,0,0,0,0,0,3,0,1
db 1,0,0,0,1,0,0,5,0,0,0,3,0,0,0,0,6,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1
db 5,0,0,0,0,0,0,5,0,0,0,1,0,0,0,0,6,0,5,1,0,2,0,0,4,4,0,4,4,0,0,1
db 1,4,1,4,1,4,1,4,1,4,1,3,0,0,0,0,6,0,0,5,0,2,0,0,0,4,0,4,0,0,0,1
db 1,0,0,0,0,0,0,4,0,0,0,3,0,3,3,3,6,0,0,1,0,1,0,0,4,4,0,4,4,0,0,1
db 5,0,0,0,1,0,0,4,0,0,0,1,0,0,0,0,6,0,0,5,0,1,0,4,4,0,0,0,4,4,0,1
db 1,1,0,1,1,1,1,4,1,0,1,3,0,0,0,0,6,0,0,1,0,1,0,4,0,0,0,0,0,4,0,1
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
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
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
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
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
vpx:
dd 0x0001FFFF ; initial player position * 0xFFFF
vpy:
dd 0x0001FFFF
labelt:
db 'FISHEYE RAYCASTING ENGINE ETC. FREE3D'
labellen:
sindegree dd 0.0
sininc dd 0.0017453292519943295769236907684886
sindiv dd 6553.5
textures:
file 'texture.gif'
I_END:
col1:
dd ?;-
; misc raycaster vars:
vxx:
dd ?;-
vyy:
dd ?;-
vl:
dd ?;-
vstepx:
dd ?;-
vstepy:
dd ?;-
vxxint:
dd ?;-
vyyint:
dd ?;-
vk:
dd ?;-
va:
dd ?;-
va2:
dd ?;-
vdd:
dd ?;-
vx1:
dd ?;-
vx1b:
dd ?;-
vh:
dd ?;-
vdt:
dd ?;-
vheading: ; initial heading: 0 to 3599
dd ?;-
vacompare:
dd ?;-
vpxi:
dd ?;-
vpyi:
dd ?;-
wtolong:
dw ?,?;-,?;-
xtemp:
dd ?;-
ytemp:
dd ?;-
xfrac:
dd ?;-
yfrac:
dd ?;-
h_old:
dd ?;-
vbottom:
dd ?;-
mouseya:
dd ?;-
remeax:
dd ?;-
remebx:
dd ?;-
remecx:
dd ?;-
remedx:
dd ?;-
remedi:
dd ?;-
remesi:
dd ?;-
red:
dd ?;-
green:
dd ?;-
blue:
dd ?;-
pseudo:
dd ?;-
step1:
dd ?;-
step64:
dd ?;-
lasty:
dd ?;-
sinus rd 360*10
eosinus:
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
/programs/demos/free3d04/trunk/gif.inc
0,0 → 1,302
; GIF LITE v2.0 by Willow
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; This include file will contain functions to handle GIF image format
;
; Created: August 15, 2004
; Last changed: September 9, 2004
 
; Change COLOR_ORDER in your program
; if colors are displayed improperly
 
if ~ (COLOR_ORDER in <MENUETOS,OTHER>)
; This message may not appear under MenuetOS, so watch...
display 'Please define COLOR_ORDER: MENUETOS or OTHER',13,10
end if
 
; virtual structure, used internally
 
struc GIF_list
{
.NextImg rd 1
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
struc GIF_info
{
.Left rw 1
.Top rw 1
.Width rw 1
.Height rw 1
}
 
_null fix 0x1000
 
 
; ****************************************
; FUNCTION ReadGIF - unpacks GIF image
; ****************************************
; in:
; esi - pointer to GIF file in memory
; edi - pointer to output image list
; eax - pointer to work area (MIN 16 KB!)
 
; out:
; eax - 0, all OK;
; eax - 1, invalid signature;
; eax >=8, unsupported image attributes
;
; ecx - number of images
 
ReadGIF:
push esi edi
mov [.table_ptr],eax
mov [.cur_info],edi
xor eax,eax
mov [.globalColor],eax
mov [.img_count],eax
inc eax
cmp dword[esi],'GIF8'
jne .er ; signature
mov ecx,[esi+0xa]
inc eax
add esi,0xd
mov edi,esi
bt ecx,7
jnc .nextblock
mov [.globalColor],esi
call .Gif_skipmap
.nextblock:
cmp byte[edi],0x21
jne .noextblock
inc edi
cmp byte[edi],0xf9 ; Graphic Control Ext
jne .no_gc
add edi,7
jmp .nextblock
.no_gc:
cmp byte[edi],0xfe ; Comment Ext
jne .no_comm
inc edi
.block_skip:
movzx eax,byte[edi]
lea edi,[edi+eax+1]
cmp byte[edi],0
jnz .block_skip
inc edi
jmp .nextblock
.no_comm:
cmp byte[edi],0xff ; Application Ext
jne .nextblock
add edi,13
jmp .block_skip
.noextblock:
cmp byte[edi],0x2c ; image beginning
jne .er
inc [.img_count]
inc edi
mov esi,[.cur_info]
add esi,4
xchg esi,edi
movsd
movsd
push edi
movzx ecx,word[esi]
inc esi
bt ecx,7
jc .uselocal
push [.globalColor]
mov edi,esi
jmp .setPal
.uselocal:
call .Gif_skipmap
push esi
.setPal:
movzx ecx,byte[edi]
inc ecx
mov [.codesize],ecx
dec ecx
pop [.Palette]
lea esi,[edi+1]
mov edi,[.table_ptr]
xor eax,eax
cld
lodsb ; eax - block_count
add eax,esi
mov [.block_ofs],eax
mov [.bit_count],8
mov eax,1
shl eax,cl
mov [.CC],eax
inc eax
mov [.EOI],eax
lea ecx,[eax-1]
mov eax, _null shl 16
.filltable:
stosd
inc eax
loop .filltable
pop edi
mov [.img_start],edi
.reinit:
mov edx,[.EOI]
inc edx
push [.codesize]
pop [.compsize]
call .Gif_get_sym
cmp eax,[.CC]
je .reinit
call .Gif_output
.cycle:
movzx ebx,ax
call .Gif_get_sym
cmp eax,edx
jae .notintable
cmp eax,[.CC]
je .reinit
cmp eax,[.EOI]
je .end
call .Gif_output
.add:
push eax
mov eax,[.table_ptr]
mov [eax+edx*4],ebx
pop eax
cmp edx,0xFFF
jae .cycle
inc edx
bsr ebx,edx
cmp ebx,[.compsize]
jne .noinc
inc [.compsize]
.noinc:
jmp .cycle
.notintable:
push eax
mov eax,ebx
call .Gif_output
push ebx
movzx eax,bx
call .Gif_output
pop ebx eax
jmp .add
.er:
pop edi
jmp .ex
.end:
mov eax,[.cur_info]
mov [eax],edi
mov [.cur_info],edi
add esi,2
xchg esi,edi
.nxt:
cmp byte[edi],0
jnz .continue
inc edi
jmp .nxt
.continue:
cmp byte[edi],0x3b
jne .nextblock
xor eax,eax
stosd
mov ecx,[.img_count]
.ex:
pop edi esi
ret
 
.Gif_skipmap:
; in: ecx - image descriptor, esi - pointer to colormap
; out: edi - pointer to area after colormap
 
and ecx,111b
inc ecx ; color map size
mov ebx,1
shl ebx,cl
lea ebx,[ebx*2+ebx]
lea edi,[esi+ebx]
ret
 
.Gif_get_sym:
mov ecx,[.compsize]
push ecx
xor eax,eax
.shift:
ror byte[esi],1
rcr eax,1
dec [.bit_count]
jnz .loop1
inc esi
cmp esi,[.block_ofs]
jb .noblock
push eax
xor eax,eax
lodsb
test eax,eax
jnz .nextbl
mov eax,[.EOI]
sub esi,2
add esp,8
jmp .exx
.nextbl:
add eax,esi
mov [.block_ofs],eax
pop eax
.noblock:
mov [.bit_count],8
.loop1:
loop .shift
pop ecx
rol eax,cl
.exx:
xor ecx,ecx
ret
 
.Gif_output:
push esi eax edx
mov edx,[.table_ptr]
.next:
push word[edx+eax*4]
mov ax,word[edx+eax*4+2]
inc ecx
cmp ax,_null
jnz .next
shl ebx,16
mov bx,[esp]
.loop2:
pop ax
 
lea esi,[eax+eax*2]
add esi,[.Palette]
 
if COLOR_ORDER eq MENUETOS
mov esi,[esi]
bswap esi
shr esi,8
mov [edi],esi
add edi,3
else
movsw
movsb
and byte[edi],0
inc edi
end if
 
loop .loop2
pop edx eax esi
ret
 
.globalColor rd 1
.img_count rd 1
.cur_info rd 1 ; image table pointer
.img_start rd 1
.codesize rd 1
.compsize rd 1
.bit_count rd 1
.CC rd 1
.EOI rd 1
.Palette rd 1
.block_ofs rd 1
.table_ptr rd 1
/programs/demos/free3d04/trunk/macros.inc
0,0 → 1,267
; new application structure
macro meos_app_start
{
use32
org 0x0
 
db 'MENUET01'
dd 0x01
dd __start
dd __end
dd __memory
dd __stack
 
if used __params & ~defined __params
dd __params
else
dd 0x0
end if
 
dd 0x0
}
MEOS_APP_START fix meos_app_start
 
macro code
{
__start:
}
CODE fix code
 
macro data
{
__data:
}
DATA fix data
 
macro udata
{
if used __params & ~defined __params
__params:
db 0
__end:
rb 255
else
__end:
end if
__udata:
}
UDATA fix udata
 
macro meos_app_end
{
align 32
rb 2048
__stack:
__memory:
}
MEOS_APP_END fix meos_app_end
 
 
; macro for defining multiline text data
struc mstr [sstring]
{
forward
local ssize
virtual at 0
db sstring
ssize = $
end virtual
dd ssize
db sstring
common
dd -1
}
 
 
; strings
macro sz name,[data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if used name
db data
end if
common
if used name
.size = $-name
end if
}
 
macro lsz name,[lng,data] { ; from MFAR [mike.dld]
common
if used name
label name
end if
forward
if (used name)&(lang eq lng)
db data
end if
common
if used name
.size = $-name
end if
}
 
 
 
; easy system call macro
macro mpack dest, hsrc, lsrc
{
if (hsrc eqtype 0) & (lsrc eqtype 0)
mov dest, (hsrc) shl 16 + lsrc
else
if (hsrc eqtype 0) & (~lsrc eqtype 0)
mov dest, (hsrc) shl 16
add dest, lsrc
else
mov dest, hsrc
shl dest, 16
add dest, lsrc
end if
end if
}
 
macro __mov reg,a,b { ; mike.dld
if (~a eq)&(~b eq)
mpack reg,a,b
else if (~a eq)&(b eq)
mov reg,a
end if
}
 
macro mcall a,b,c,d,e,f { ; mike.dld
__mov eax,a
__mov ebx,b
__mov ecx,c
__mov edx,d
__mov esi,e
__mov edi,f
int 0x40
}
 
 
 
 
 
 
 
; optimize the code for size
__regs fix <eax,ebx,ecx,edx,esi,edi,ebp,esp>
 
macro add arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
inc arg1
else
add arg1,arg2
end if
else
add arg1,arg2
end if
}
 
macro sub arg1,arg2
{
if (arg2 eqtype 0)
if (arg2) = 1
dec arg1
else
sub arg1,arg2
end if
else
sub arg1,arg2
end if
}
 
macro mov arg1,arg2
{
if (arg1 in __regs) & (arg2 eqtype 0)
if (arg2) = 0
xor arg1,arg1
else if (arg2) = 1
xor arg1,arg1
inc arg1
else if (arg2) = -1
or arg1,-1
else if (arg2) > -128 & (arg2) < 128
push arg2
pop arg1
else
mov arg1,arg2
end if
else
mov arg1,arg2
end if
}
 
 
macro struct name
{
virtual at 0
name name
sizeof.#name = $ - name
end virtual
}
 
; structures used in MeOS
struc process_information
{
.cpu_usage dd ? ; +0
.window_stack_position dw ? ; +4
.window_stack_value dw ? ; +6
.not_used1 dw ? ; +8
.process_name rb 12 ; +10
.memory_start dd ? ; +22
.used_memory dd ? ; +26
.PID dd ? ; +30
.x_start dd ? ; +34
.y_start dd ? ; +38
.x_size dd ? ; +42
.y_size dd ? ; +46
.slot_state dw ? ; +50
rb (1024-52)
}
struct process_information
 
struc system_colors
{
.frame dd ?
.grab dd ?
.grab_button dd ?
.grab_button_text dd ?
.grab_text dd ?
.work dd ?
.work_button dd ?
.work_button_text dd ?
.work_text dd ?
.work_graph dd ?
}
struct system_colors
 
 
; constants
 
; events
EV_IDLE = 0
EV_TIMER = 0
EV_REDRAW = 1
EV_KEY = 2
EV_BUTTON = 3
EV_EXIT = 4
EV_BACKGROUND = 5
EV_MOUSE = 6
EV_IPC = 7
EV_STACK = 8
 
; event mask bits for function 40
EVM_REDRAW = 1b
EVM_KEY = 10b
EVM_BUTTON = 100b
EVM_EXIT = 1000b
EVM_BACKGROUND = 10000b
EVM_MOUSE = 100000b
EVM_IPC = 1000000b
EVM_STACK = 10000000b
/programs/demos/free3d04/trunk/texture.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programs/demos/free3d04/trunk/build_en.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix en >lang.inc
@fasm free3d04.asm free3d04
@pause
/programs/demos/free3d04/trunk/build_ru.bat
0,0 → 1,4
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm free3d04.asm free3d04
@pause
/programs/demos/free3d04/trunk/readme.txt
0,0 → 1,23
 
--------------------------------------------
*** Fisheye Raycasting Engine Etc. V.0.4 ***
--------------------------------------------
 
For the MenuetOs Operating System.
Assembler-Source for FASM for MenuetOs.
 
By Dieter Marfurt
 
--------------------------------------------
 
Format of texture include files:
 
dd 0x00RRGGBB,0x00RRGGBB....
 
for 64*64 pixels.
 
Have fun!
 
dietermarfurt@angelfire.com
 
--------------------------------------------
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property