home *** CD-ROM | disk | FTP | other *** search
- ;[]------------------------------------------------------------------------[]
- ;| |
- ;| (c) 1993,1994 by Marc van Shaney , aka Kaya Memisoglu |
- ;| |
- ;| Dieser Assembler-Source-Code unterliegt dem Urheberrecht von Kaya |
- ;| Memisoglu und darf auch nur mit seiner schriftlichen Genehmigung |
- ;| in kommerziellen Programmen verwendet werden. |
- ;| Ich übernehme keinerlei Verantwortung für eventuelle Schäden,die dieses |
- ;| Programm verursacht. |
- ;| |
- ;| |
- ;| 18.1.1994 Kaya Memisoglu |
- ;| |
- ;[]------------------------------------------------------------------------[]
-
-
-
- P386
-
- LOCALS
- VGA_Width equ 320
- VGA_Height equ 200
- Font_Width equ 8
- Font_Height equ 12
- Black equ 240
- Background equ 0
- TRUE equ 1
- FALSE equ -1
-
-
- .MODEL USE16 LARGE
- .Code
-
-
-
- PUBLIC C Clear_Frame
- Clear_Frame PROC FAR
- ARG frame:dword,farbe:byte
- push bp
- mov bp,sp
- push di
-
- les di,frame
- mov ah,[farbe]
- mov al,ah ;Farbe einladen
- rol eax,16
- mov al,[farbe]
- mov ah,al
- mov cx,03e80h ;Bank löschen (DoppelWortweise !!!)
- rep stosd
-
- pop di
- pop bp
- retf
- Clear_Frame ENDP
-
-
-
-
-
-
-
-
-
- PUBLIC C FDraw_Text
- FDraw_Text PROC FAR
- ARG frame:dword,x:word,y:word,string:dword,farbe:byte
- push bp
- mov bp,sp
- push si
- push di
-
- les di,[frame] ;Frame in ES:DI
- mov dl,[farbe]
- mov cx,[y]
- fastimul bx,cx,VGA_Width
- add di,bx ;ES:DI points to destination
- add di,[x]
- lgs bp,[string]
-
- @@Schleife212: ;Buchstabenschleife
- movzx ax,byte ptr gs:[bp] ;AX=Zeichen
- or al,al
- jz short @@Font_End
- fastimul si,ax,Font_Height
- add si,OFFSET STDFONT
-
- mov dh,Font_Height
- @@Font_V_Loop: ;Zeilenschleife
- lods byte ptr cs:[si] ;Bitmuster in AL geladen
- mov cx,Font_Width-1
- @@Font_H_Loop: ;Punktschleife
- bt ax,cx
- jnc short @@Weiter233
- mov [es:di],dl ;Punkt setzen
- @@Weiter233:
- inc di
- inc dl
- dec cx
- jns short @@Font_H_Loop
-
- sub dl,Font_Width-1
- add di,VGA_Width-Font_Width
- dec dh
- jnz short @@Font_V_Loop
-
- sub di,Font_Height*VGA_Width-Font_Width
- sub dl,Font_Height
- inc bp
- jmp short @@Schleife212
-
- @@Font_End:
- pop di
- pop si
- pop bp
- retf
- FDraw_Text ENDP
-
-
-
-
-
-
-
- PUBLIC C FDraw_Scroller
- FDraw_Scroller PROC FAR
- ARG frame:dword,y:word,string:dword,farbe:byte,pos:word
- push bp
- mov bp,sp
- push di
- push si
-
- les di,[frame] ;Frame in ES:DI
- mov ax,[pos]
- xor dx,dx
- mov ax,[pos]
- mov bx,Font_Width
- idiv bx ;AX holds first char to draw
- ;DX holds pixels to draw from this char
- mov bx,0 ;BX holds screen-row
- sub bx,dx ;We are in the negative
- mov cx,[y]
- fastimul si,cx,VGA_Width
- add di,si ;ES:DI points to destination
- sub di,dx
- mov dl,[farbe]
- lgs bp,[string]
- add bp,ax ;GS:BP points to first char to draw
-
-
- Schleife212: ;Buchstabenschleife
- movzx ax,byte ptr gs:[bp] ;AX=Zeichen
- or al,al
- jz short Font_End
- fastimul si,ax,Font_Height
- add si,OFFSET STDFONT
-
- mov dh,Font_Height
- Font_V_Loop: ;Zeilenschleife
- lods byte ptr cs:[si] ;Bitmuster in AL geladen
- mov cx,Font_Width-1
- Font_H_Loop: ;Punktschleife
- cmp bx,VGA_Width-1
- ja short Weiter233
- bt ax,cx
- jnc short Weiter233
- mov [es:di],dl ;Punkt setzen
- Weiter233:
- inc di
- inc dl
- inc bx
- dec cx
- jns short Font_H_Loop
-
- sub dl,Font_Width-1
- add di,VGA_Width-Font_Width
- sub bx,Font_Width
- dec dh
- jnz short Font_V_Loop
-
- sub di,Font_Height*VGA_Width-Font_Width
- sub dl,Font_Height
- add bx,Font_Width
- cmp bx,VGA_Width
- ja short Font_End
- inc bp
- jmp short Schleife212
-
- Font_End:
- pop si
- pop di
- pop bp
- retf
- FDraw_Scroller ENDP
-
-
-
-
-
-
-
- PUBLIC C FPut_Sprite
- FPut_Sprite PROC FAR
- ARG frame:dword,x1:word,y1:word,mem:dword
- push bp
- mov bp,sp
- push si
- push di
-
- les di,frame
- lfs si,mem ;Startadresse des Spritespeichers in FS:SI
-
- mov ax,[y1] ;ax=y1
- mov bx,VGA_Width
- mul bx
- add ax,[x1]
- add di,ax ;Startadresse jetzt in BX:DI
-
- mov dx,[fs:si] ;x2 Laden
- sub bx,dx ;diff=VGA_Width-Breite
- shr dx,2 ;Breite/4 jetzt in DX
- mov cx,[fs:si+2] ;Höhe in CX Laden
- add si,16 ;2 Bytes weiter
-
- Schleife767:
- push cx ;CX sichern
- mov cx,dx ;Breite/4 in CX
- Schleife742:
- lods dword ptr [fs:si] ;In EAX FS:SI einladen
- cmp al,Background
- je short Weiter747
- mov [es:di],al
-
- Weiter747:
- cmp ah,Background
- je short Weiter748
- mov [es:di+1],ah
-
- Weiter748:
- rol eax,16
- cmp al,Background
- je short Weiter749
- mov [es:di+2],al
-
- Weiter749:
- cmp ah,Background
- je short Weiter750
- mov [es:di+3],ah
-
- Weiter750:
- add di,4
- loop Schleife742
-
- End_Put_Sprite:
- pop cx ;In CX wieder Höhe holen
- add di,bx
- loop Schleife767
-
- pop di
- pop si
- pop bp
- retf
- FPut_Sprite ENDP
-
-
-
-
-
- PUBLIC C FPut_Image
- FPut_Image PROC FAR
- ARG frame:dword,x1:word,y1:word,mem:dword
- push bp
- mov bp,sp
- push si
- push di
-
- les di,frame
- lfs si,mem ;Startadresse des Spritespeichers in FS:SI
-
- mov ax,[y1] ;ax=y1
- mov bx,VGA_Width
- mul bx
- add ax,[x1]
- add di,ax ;Startadresse jetzt in ES:DI
-
- mov dx,[fs:si] ;x2 Laden
- sub bx,dx ;BX=VGA_Width-Breite
- shr dx,2 ;Breite/4 jetzt in DX
- mov ax,[fs:si+2] ;Höhe in CX Laden
- add si,16 ;2 Bytes weiter
-
- Schleife752:
- mov cx,dx ;Breite/4 in CX
- rep movs dword ptr [es:di],[fs:si]
- add di,bx
- dec ax
- jnz short Schleife752
-
- pop di
- pop si
- pop bp
- retf
- FPut_Image ENDP
-
-
-
-
-
- Row_Size dw ?
- PUBLIC C FZoom_Sprite
- FZoom_Sprite PROC FAR
- ARG frame:dword,x1:word,y1:word,x2:word,y2:word,mem:dword
- push bp
- mov bp,sp
- push si
- push di
-
- cld
- les di,[frame] ;Framebuffer
- lfs si,[mem] ;Startadresse des Spritespeichers in FS:SI
-
- movzx ebx,[y2]
- sub bx,[y1]
- inc bx ;Final Height in EBX
- fastimul cx,[y1],VGA_Width
- add cx,[x1]
- add di,cx ;Startadresse jetzt in ES:DI
-
- movzx ecx,[x2]
- sub cx,[x1]
- inc cx ;Final Width
- mov cs:[Row_Size],cx
- push ecx ;Save Final width for later...
- sub cx,VGA_Width
- neg cx
- mov word ptr cs:[@@4-2],cx ;Save in code
-
- pop ecx
- xor edx,edx
- mov ax,word ptr fs:[si] ;Source width
- shl eax,16 ;Fixed-point shift
- div ecx
- mov word ptr cs:[@@5-2],ax ;Save fractional part
- shr eax,16
- mov word ptr cs:[@@6-2],ax ;Save integer part
-
- xor edx,edx
- mov ax,word ptr fs:[si+2] ;Now comes the height
- shl eax,16
- div ebx ;Divide by final height
- mov word ptr cs:[@@2-2],ax ;Fractional part
- shr eax,16
- mov cx,fs:[si] ;AX*Width
- mul cx
- mov word ptr cs:[@@1-2],ax
- mov word ptr cs:[@@3-2],cx
-
- add si,16 ;Skip over header
- xor dx,dx
- Zoom_Y_Loop:
- push si
- mov cx,cs:[Row_Size]
- xor bp,bp
- Zoom_X_Loop:
- mov al,fs:[si] ;Get one byte
- add bp,1234h ;Fractional part of x in BP
- @@5: adc si,1234h
- @@6: cmp al,0
- je short No_Pixel
- mov es:[di],al
- No_Pixel: inc di
- dec cx ;CX ist x-counter
- jnz short Zoom_X_Loop
-
- pop si
- add si,1234h ;Row-Increment
- @@1: add dx,1234h ;Fractional part of y in DX
- @@2: jnc @@3
- add si,1234h ;Add one row
- @@3: add di,1234h ;Next scan-line
- @@4: dec bx ;BX is y-counter
- jnz short Zoom_Y_Loop
-
- pop di
- pop si
- pop bp
- retf
- FZoom_Sprite ENDP
-
-
-
-
- ;============================================================================
- ;= =
- ;= =
- ;= Hier sind alle Special-effects =
- ;= =
- ;= =
- ;= =
- ;= =
- ;= =
- ;============================================================================
-
-
-
-
- Noise dd 1
- MULTIPLIER equ 015a4e35h
- INCREMENT equ 1
-
- RAND MACRO
- mov eax,cs:[Noise]
- mov edx,MULTIPLIER
- mul edx
- shrd eax,edx,16
- add eax,INCREMENT
- mov cs:[Noise],eax
- ENDM
-
-
- SinTable db 0, 24, 49, 74, 97,120,141,161,180,197,212,224,235,244
- db 250,253,255,253,250,244,235,224,212,197,180,161,141,120
- db 97, 74, 49, 24
- Water_Pos dw 0
- PUBLIC C FDraw_Water
- FDraw_Water PROC FAR
- ARG frame:dword,y:word,len:word
- push bp
- mov bp,sp
- push si
- push di
-
- les di,[frame]
- lfs si,[frame]
- mov bx,cs:[Water_Pos]
-
- mov ax,[y]
- fastimul cx,ax,VGA_Width
- add di,cx
- add si,cx
- sub si,VGA_Width
-
- mov bp,[len]
- Schleife971:
- movzx ax,cs:[bx+ OFFSET SinTable]
- sub ax,127
- sar ax,4
- add si,ax
- mov cx,VGA_Width/4
- rep movs dword ptr [es:di],[fs:si]
- sub si,ax
- sub si,3*VGA_Width
- inc bx
- and bx,1fh
- dec bp
- jnz short Schleife971
-
- inc cs:[Water_Pos]
- and cs:[Water_Pos],1fh
- pop di
- pop si
- pop bp
- retf
- FDraw_Water ENDP
-
-
-
-
-
- PUBLIC C FMove_Fire
- FMove_Fire PROC
- ARG Fire:dword
- push bp
- mov bp,sp
- cld
- push si
- push di
-
- les di,[Fire]
- mov bp,es:[di+2] ;Height in BP
- push di ;Save for later
- add di,16 ;Jump over Header+ 1 byte
-
- ; sub bp,2
- shr bp,1 ;Only each second row will be processed
- Fire_HLoop:
- mov cx,160 ;2*2 pixel blocks are used
- Fire_WLoop:
- movzx ax,es:[di]
- movzx dx,es:[di+2]
- add ax,dx
- mov dl,es:[di-2]
- add ax,dx
- mov dl,es:[di+2*320]
- add ax,dx
- mov dl,es:[di+2*320-2]
- add ax,dx
- mov dl,es:[di+2*320+2]
- add ax,dx
- mov dl,es:[di+4*320]
- add ax,dx
- add ax,dx
- shr ax,3
- jz short No_Decrement
- dec al
- No_Decrement:
- mov ah,al
- mov es:[di+320],ax
- stosw
- dec cx
- jnz short Fire_WLoop
-
- add di,320 ;Skip one line
- dec bp
- jnz short Fire_HLoop
-
- pop di ;ES:DI points again to header
- mov cx,es:[di+2] ;Height of Flames
- fastimul ax,cx,320 ;AX holds size of bitmap
- add di,ax ;This is the last pixel
- sub di,640-16 ;ES:DI points to last line
- push di
- mov cx,160
- New_Line:
- RAND
- and ax,7f7fh
- mov es:[di+320],ax
- stosw
- dec cx
- jnz short New_Line
- pop di ;ES:DI points again to last Line
- mov cx,40
- New_Fire:
- RAND
- and eax,0ffffh
- fastimul ebx,eax,320
- shr ebx,16
- mov dword ptr es:[di+bx-2],09f9f9f9fh
- mov word ptr es:[di+bx+2],09f9fh
- dec cx
- jnz short New_Fire
-
-
- pop di
- pop si
- pop bp
- retf
- FMove_Fire ENDP
-
-
-
-
-
- PUBLIC C FWrite_in_Fire
- FWrite_in_Fire PROC FAR
- ARG fire:dword,x:word,y:word,string:dword,farbe:byte
- push bp
- mov bp,sp
- push di
- push si
-
- les di,[fire] ;Frame in ES:DI
- mov dl,[farbe]
- mov dh,dl
- mov cx,[y]
- fastimul bx,cx,2*VGA_Width
- add di,bx ;ES:DI points to destination
- add di,[x]
- add di,[x]
- add di,16 ;Skip header
- lgs bp,[string]
-
- @@Schleife212: ;Buchstabenschleife
- movzx ax,byte ptr gs:[bp] ;AX=Zeichen
- or al,al
- jz short @@Font_End
- fastimul si,ax,Font_Height
- add si,OFFSET STDFONT
-
- mov ah,Font_Height
- @@Font_V_Loop: ;Zeilenschleife
- lods byte ptr cs:[si] ;Bitmuster in AL geladen
- mov cx,Font_Width-1
- @@Font_H_Loop: ;Punktschleife
- bt ax,cx
- jnc short @@Weiter233
- mov [es:di],dx ;Punkt setzen
- mov [es:di+VGA_Width],dx
- @@Weiter233:
- add di,2
- add dx,0101h
- dec cx
- jns short @@Font_H_Loop
-
- add di,2*VGA_Width-2*Font_Width
- sub dx,(Font_Width-1)*0101h
- dec ah
- jnz short @@Font_V_Loop
-
- sub di,2*Font_Height*VGA_Width-2*Font_Width
- sub dx,Font_Height*0101h
- inc bp
- jmp short @@Schleife212
-
- @@Font_End:
- pop si
- pop di
- pop bp
- retf
- FWrite_in_Fire ENDP
-
-
-
-
-
- PUBLIC C FDraw_Oscilloscope
- FDraw_Oscilloscope PROC FAR
- ARG frame:dword,x:word,y:word,len:word,mem:dword,farbe:byte
- push bp
- mov bp,sp
- push di
- push si
-
- les di,frame ;In ES:DI ist der Puffer
- lfs si,mem ;In FS:SI sind die Daten
-
- mov ax,[y]
- fastimul bx,ax,VGA_Width
- add bx,[x]
- add di,bx ;In ES:DI ist jetzt die mittlere Koordinate
- mov al,[farbe]
-
- mov cx,len
- Schleife851:
- movsx dx,[FS:SI]
- xor dx,01111111b ;Es muß umgedreht werden !
- sar dx,2
- fastimul bx,dx,VGA_Width
- mov byte ptr [es:di+bx],al
- inc di
- inc si
- loop Schleife851
-
- pop si
- pop di
- pop bp
- retf
- FDraw_Oscilloscope ENDP
-
-
-
-
-
- include 8x12font.inc
- END
-
-
-