home *** CD-ROM | disk | FTP | other *** search
- ; KAISEGA.ASM
- ;
- ; ega, EGA Grafik:
-
- ; ega, öffentliche Definitionen:
- public ega_graphmode ; 17.08.1990
- public ega_textmode ; 18.08.1990
- public ega_palette ; 18.08.1990
- public ega_horline ; 17.08.1990
- public ega_verline ; 17.08.1990
- public ega_mal ; 18.08.1990
- public ega_char ; 18.08.1990
- public ega_text ; 18.08.1990
- public ega_row ; 18.08.1990
- public ega_kugel ; 18.08.1990
- public ega_scroll ; 18.08.1990
-
- ; ega, Konstanten:
- ega_adress equ 03CEh ; Ports
- ega_data equ 03CFh
- ega_graph_seg equ 0A000h ; Segment
- ega_rowbytes equ 80 ; Bytes pro Zeile
- ega_graf_zeilen equ 16 ; Zeilen pro Zeichen im Grafikzeichensatz
- ega_text_zeilen equ 8 ; Zeilen pro Zeichen im Textzeichensatz
- ega_text_next equ ega_rowbytes*ega_text_zeilen-1
- ega_graf_next equ ega_rowbytes*ega_graf_zeilen-2
- ega_bankused equ 28000
-
- ; ega, lokale Prozeduren:
-
- ; ega_calcptr
- ;
- ; Parameter: AX: X-Koordinate
- ; BX: Y-Koordinate
- ;
- ; Rückgabe: ES:DI: ^ auf Bildschirm
- ;
- ; verändert: DX
- ega_calcptr proc near
-
- shr ax,1
- shr ax,1
- shr ax,1
- mov di,ax
- mov ax,ega_graph_seg
- mov es,ax
- mov ax,ega_rowbytes
- mul bx
- add di,ax
-
- ret
- ega_calcptr endp
-
-
- ; ega_farbe
- ;
- ; verändert: AX,DX
- ega_farbe proc near
- mov dx,ega_adress
- mov al,1
- mov ah,farbe
- xor ah,0Fh
- out dx,ax
- mov ax,0FF08h
- out dx,ax
- ret
- ega_farbe endp
-
-
- ; ega_setpixel
- ;
- ; Parameter: BX: Y-Koordinate im momentanen Byte (0..7)
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX,DX
- ega_setpixel proc near
- mov al,es:[di]
- mov ah,cs:[bx+(offset hgc_or_tab)]
- mov al,8
- mov dx,ega_adress
- out dx,ax
- mov es:[di],ah
- ret
- ega_setpixel endp
-
- ; ega_calc_graf
- ;
- ; Parameter: BH: Nummer des Zeichens
- ;
- ; Rückgabe: DS:SI: ^ auf Grafikzeichen
- ;
- ; verändert: BX
- ega_calc_graf proc near
-
- lds si,graf_satz
- xor bl,bl
- shr bx,1
- add si,bx
-
- ret
- ega_calc_graf endp
-
-
- ; ega_setz_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- ; DX: ega_adress
- ega_setz_graf_z proc near
- mov cx,ega_graf_zeilen
- mov dx,ega_adress
- ega_sg_loop1:
- push cx
- mov cx,4
- mov bx,1
- ega_sg_loop2:
- mov al,1
- mov ah,bl
- xor ah,0Fh
- out dx,ax
- mov al,es:[di]
- lodsb
- mov es:[di],al
- mov al,es:[di+1]
- lodsb
- mov es:[di+1],al
- shl bx,1
- mov ax,1003h
- out dx,ax
- loop ega_sg_loop2
-
- mov ax,0003h
- out dx,ax
- add di,ega_rowbytes
- pop cx
- loop ega_sg_loop1
-
- ret
- ega_setz_graf_z endp
-
- ; ega_xor_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- ; DX: ega_adress
- ega_xor_graf_z proc near
- mov cx,ega_graf_zeilen
- mov dx,ega_adress
- mov ax,1803h
- out dx,ax
- ega_xg_loop1:
- push cx
- mov cx,4
- mov bx,1
- ega_xg_loop2:
- mov al,1
- mov ah,bl
- xor ah,0Fh
- out dx,ax
- mov al,es:[di]
- lodsb
- mov es:[di],al
- mov al,es:[di+1]
- lodsb
- mov es:[di+1],al
- shl bx,1
- loop ega_xg_loop2
-
- add di,ega_rowbytes
- pop cx
- loop ega_xg_loop1
-
- mov ax,0003h
- out dx,ax
- ret
- ega_xor_graf_z endp
-
- ; ega_setz_text_z
- ;
- ; Parameter: DS:SI: ^ auf Textzeichen
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX,CX,DI
- ega_setz_text_z proc near
- mov cx,ega_text_zeilen
- ega_st_loop:
- lodsb
- mov es:[di],al
- add di,ega_rowbytes
- loop ega_st_loop
-
- ret
- ega_setz_text_z endp
-
-
- ;
- ; ega, globale Prozeduren:
- ;
- ega_palette proc far
- les dx,palette
- mov ax,1002h
- int 10h
- ret
- ega_palette endp
-
-
- ega_graphmode proc far
- mov ax,10h
- int 10h
- call ega_palette
- mov dx,ega_adress
- mov ax,00005h
- out dx,ax
- mov ax,00003h
- out dx,ax
- xor ax,ax
- out dx,ax
- ret
- ega_graphmode endp
-
-
- ega_textmode proc far
- mov ax,3
- int 10h
- mov ah,1
- mov cx,1000h
- int 10h
- call ega_palette
- ret
- ega_textmode endp
-
-
- ega_horline proc far
- lng = 6 ; BP + Rücksprung-AD
- y = word ptr [bp+lng]
- bis_x = word ptr [bp+lng+2]
- von_x = word ptr [bp+lng+4]
- param_bytes = 6
- push bp
- mov bp,sp
- cld
- inc bis_x
-
- call ega_farbe
-
- mov ax,von_x
- mov bx,y
- call ega_calcptr
-
- mov bx,von_x
- and bx,7
- je ega_hl_1
-
- ega_hl_2:
- mov bx,von_x
- cmp bx,bis_x
- je ega_hl_fertig
- and bx,7
- je ega_hl_3
- call ega_setpixel
- inc von_x
- jmp short ega_hl_2
-
- ega_hl_3:
- inc di
-
- ega_hl_1:
- call ega_farbe
- mov bx,bis_x
- sub bx,von_x
- shr bx,1
- shr bx,1
- shr bx,1
- je ega_hl_4
- mov cx,bx
- mov al,0FFh
- rep stosb
-
- ega_hl_4:
- mov bx,bis_x
- mov ax,bx
- and ax,7
- je ega_hl_fertig
- and bx,0FFF8h
- mov von_x,bx
-
- ega_hl_5:
- mov bx,von_x
- cmp bx,bis_x
- je ega_hl_fertig
- and bx,7
- call ega_setpixel
- inc von_x
- jmp short ega_hl_5
-
- ega_hl_fertig:
- pop bp
- ret param_bytes
- ega_horline endp
-
-
- ega_verline proc far
- lng = 6 ; BP + Rücksprung-AD
- bis_y = word ptr [bp+lng]
- von_y = word ptr [bp+lng+2]
- x = word ptr [bp+lng+4]
- param_bytes = 6
- push bp
- mov bp,sp
- cld
- call ega_farbe
-
- mov ax,x
- mov bx,von_y
- call ega_calcptr
-
- mov cx,bis_y
- inc cx
- sub cx,von_y
- mov bx,x
- and bx,7
-
- ega_vl_loop:
- call ega_setpixel
- add di,ega_rowbytes
- loop ega_vl_loop
-
- pop bp
- ret param_bytes
- ega_verline endp
-
-
- ega_mal proc far
- lng = 6 ; BP + Rücksprung-AD
- zeichen = byte ptr [bp+lng]
- y = word ptr [bp+lng+2]
- x = byte ptr [bp+lng+4]
- param_bytes = 6
- push bp
- mov bp,sp
- push ds
- cld
- call ega_farbe
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call ega_calcptr
-
- cmp xorput,0
- pushf
- mov bh,zeichen
- call ega_calc_graf
- popf
- jne ega_mal_1
- call ega_setz_graf_z
- jmp short ega_mal_2
- ega_mal_1:
- call ega_xor_graf_z
-
- ega_mal_2:
- pop ds
- pop bp
- ret param_bytes
- ega_mal endp
-
-
- ega_char proc far
- lng = 6 ; BP + Rücksprung-AD
- zeichen = byte ptr [bp+lng]
- y = word ptr [bp+lng+2]
- x = byte ptr [bp+lng+4]
- param_bytes = 6
- push bp
- mov bp,sp
- push ds
- call ega_farbe
- cld
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call ega_calcptr
-
- mov al,zeichen
- call hgc_calc_text
-
- call ega_setz_text_z
-
- pop ds
- pop bp
- ret param_bytes
- ega_char endp
-
-
- ega_text proc far
- lng = 6 ; BP + Rücksprung-AD
- text = [bp+lng]
- y = word ptr [bp+lng+4]
- x = byte ptr [bp+lng+6]
- param_bytes = 8
-
- ega_tx_repl macro zahl1,zahl2
- local ega_tx_repl_1
- cmp al,zahl1
- jne ega_tx_repl_1
- mov al,zahl2
- jmp short ega_tx_do
- ega_tx_repl_1:
- endm
-
- push bp
- mov bp,sp
- push ds
- call ega_farbe
- cld
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call ega_calcptr
-
- mov dx,ds
- lds si,text
- lodsb
- mov cl,al
- xor ch,ch
- ega_tx_loop:
- lodsb
- push cx
- push si
- push ds
- cmp al,129
- jb ega_tx_do
- ega_tx_repl 142,64 ; Ä
- ega_tx_repl 153,96 ; Ö
- ega_tx_repl 154,123 ; Ü
- ega_tx_repl 132,124 ; ä
- ega_tx_repl 148,125 ; ö
- ega_tx_repl 129,126 ; ü
- ega_tx_repl 225,127 ; ß
- ega_tx_do:
- sub al,20h
- mov ds,dx
- call hgc_calc_text
- call ega_setz_text_z
- sub di,ega_text_next
- pop ds
- pop si
- pop cx
- loop ega_tx_loop
-
- pop ds
- pop bp
- ret param_bytes
- ega_text endp
-
-
- ega_row proc far
- lng = 6 ; BP + Rücksprung-AD
- y = byte ptr ss:[bp+lng]
- param_bytes = 2
-
- push bp
- mov bp,sp
- push ds
- call ega_farbe
- cld
-
- mov al,y
- add al,feld_oben
- xor ah,ah
- mov cl,40
- mul cl
- add ax,offset spielfeld
- mov si,ax
-
- mov ax,feld_x
- mov bx,c_y
- call ega_calcptr
-
- mov cx,40
-
- ega_row_loop:
- push cx
-
- lodsb
- push ds
- push si
- mov bh,al
- call ega_calc_graf
- call ega_setz_graf_z
- sub di,ega_graf_next
- pop si
- pop ds
- pop cx
- loop ega_row_loop
-
- pop ds
- pop bp
- ret param_bytes
- ega_row endp
-
-
- ega_kugel proc far
- lng = 6 ; BP + Rücksprung-AD
- y = word ptr ss:[bp+lng]
- x = word ptr ss:[bp+lng+2]
- param_bytes = 4
- push bp
- mov bp,sp
- push ds
- call ega_farbe
- cld
-
- mov ax,1803h
- out dx,ax
- mov ax,x
- mov bx,y
- call ega_calcptr
-
- push cs
- pop ds
- mov si,offset hgc_kugel_data
-
- mov cx,4
- xor bx,bx
-
- ega_ku_loop:
- push cx
- mov al,es:[di]
- lodsw
- mov cx,x
- and cx,7
- shr ax,cl
- xchg al,ah
- mov es:[di],al
- mov al,es:[di+1]
- mov es:[di+1],ah
- add di,ega_rowbytes
-
- pop cx
- loop ega_ku_loop
-
- pop ds
- pop bp
- ret param_bytes
- ega_kugel endp
-
-
- ega_scroll proc far
- lng = 6 ; BP + Rücksprung-AD
- bytes = word ptr ss:[bp+lng]
- bis_y = word ptr ss:[bp+lng+2]
- von_y = word ptr ss:[bp+lng+4]
- param_bytes = 4
-
- push bp
- mov bp,sp
- push ds
-
- xor ax,ax
- mov bx,von_y
- call ega_calcptr
- mov si,di
- push es
- pop ds
- xor ax,ax
- mov bx,bis_y
- call ega_calcptr
-
- mov ax,von_y
- cmp ax,bis_y
- jb ega_sc_1
- cld
- jmp short ega_sc_2
- ega_sc_1:
- std
- add si,bytes
- dec si
- add di,bytes
- dec di
-
- ega_sc_2:
- call ega_farbe
- mov ax,0105h
- out dx,ax
- mov cx,bytes
- rep movsb
-
- mov ax,0005h
- out dx,ax
- pop ds
- pop bp
- ret param_bytes
- ega_scroll endp