home *** CD-ROM | disk | FTP | other *** search
- ; KAISCGA.ASM
- ;
- ; cga, CGA Grafik:
-
- ; cga, öffentliche Definitionen:
- public cga_graphmode ; 17.08.1990
- public cga_textmode ; 17.08.1990
- public cga_horline ; 17.08.1990
- public cga_verline ; 17.08.1990
- public cga_mal ; 17.08.1990
- public cga_char ; 17.08.1990
- public cga_text ; 17.08.1990
- public cga_row ; 17.08.1990
- public cga_kugel ; 17.08.1990
- public cga_save ; 17.08.1990
- public cga_restore ; 17.08.1990
-
- ; cga, Konstanten:
- cga_graph_seg equ 0B800h ; Segmente
- cga_rowbytes equ 80 ; Bytes pro Zeile
- cga_bankbytes equ 2000h ; Bytes pro Bank
- cga_bankused equ 4000 ; benutze Words pro Bank
- cga_maxbank equ 4000h ; Bytes in allen Banks
- cga_graf_zeilen equ 16 ; Zeilen pro Zeichen im Grafikzeichensatz
- cga_text_zeilen equ 8 ; Zeilen pro Zeichen im Textzeichensatz
- cga_text_next equ cga_rowbytes*(cga_text_zeilen/(cga_maxbank/cga_bankbytes))-1
- cga_graf_next equ cga_rowbytes*(cga_graf_zeilen/(cga_maxbank/cga_bankbytes))-2
-
- ; cga, lokale Prozeduren:
-
- ; cga_calcptr
- ;
- ; Parameter: AX: X-Koordinate
- ; BX: Y-Koordinate
- ;
- ; Rückgabe: ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX, BX, CX, DX
- ; SI, DI
- cga_calcptr proc near
-
- shr ax,1 ; DI := X DIV 8
- shr ax,1
- shr ax,1
- mov di,ax
-
- mov ax,cga_rowbytes ; + cga_rowbytes * (Y DIV 2)
- mov cx,bx
- shr cx,1
- mul cx
- add di,ax
-
- and bx,1
- shl bx,1
- add di,cs:[bx+(offset hgc_banks)]
- mov ax,cga_graph_seg
- mov es,ax
-
- ret
- cga_calcptr endp
-
-
- ; cga_setpixel
- ;
- ; Parameter: BX: Y-Koordinate im momentanen Byte (0..7)
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AL
- cga_setpixel proc near
- cmp farbe,0
- je cga_sp_1
- mov al,cs:[bx+(offset hgc_or_tab)]
- or es:[di],al
- ret
- cga_sp_1:
- mov al,cs:[bx+(offset hgc_and_tab)]
- and es:[di],al
- ret
- cga_setpixel endp
-
- ; cga_nextline
- ;
- ; Setzt ES:DI auf die nächste Zeile
- cga_nextline proc near
- add di,cga_bankbytes
- cmp di,cga_maxbank
- jb cga_nl_fertig
- sub di,cga_maxbank-cga_rowbytes
- cga_nl_fertig:
- ret
- cga_nextline endp
-
- ; cga_setz_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- cga_setz_graf_z proc near
- mov cx,cga_graf_zeilen
- cga_sg_loop:
- lodsw
- mov es:[di],ax
- call cga_nextline
- loop cga_sg_loop
-
- ret
- cga_setz_graf_z endp
-
- ; cga_xor_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- cga_xor_graf_z proc near
- mov cx,cga_graf_zeilen
- cga_xg_loop:
- lodsw
- xor es:[di],ax
- call cga_nextline
- loop cga_xg_loop
-
- ret
- cga_xor_graf_z endp
-
- ; cga_setz_text_z
- ;
- ; Parameter: DS:SI: ^ auf Textzeichen
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX,CX,DI
- cga_setz_text_z proc near
- mov cx,cga_text_zeilen
- cga_st_loop:
- lodsb
- mov es:[di],al
- call cga_nextline
- loop cga_st_loop
-
- ret
- cga_setz_text_z endp
-
-
- cga_graphmode proc far
- mov ax,6
- int 10h
- ret
- cga_graphmode endp
-
-
- cga_textmode proc far
- mov ax,3
- int 10h
- mov ah,1
- mov cx,1000h
- int 10h
- ret
- cga_textmode endp
-
-
- cga_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
-
- mov ax,von_x
- mov bx,y
- call cga_calcptr
- xor dl,dl
- cmp farbe,0
- je cga_hl_6
- dec dl
- cga_hl_6:
- mov bx,von_x
- and bx,7
- je cga_hl_1
-
- cga_hl_2:
- mov bx,von_x
- cmp bx,bis_x
- je cga_hl_fertig
- and bx,7
- je cga_hl_3
- call cga_setpixel
- inc von_x
- jmp short cga_hl_2
-
- cga_hl_3:
- inc di
-
- cga_hl_1:
- mov bx,bis_x
- sub bx,von_x
- shr bx,1
- shr bx,1
- shr bx,1
- je cga_hl_4
- mov cx,bx
- mov al,dl
- rep stosb
-
- cga_hl_4:
- mov bx,bis_x
- mov ax,bx
- and ax,7
- je cga_hl_fertig
- and bx,0FFF8h
- mov von_x,bx
-
- cga_hl_5:
- mov bx,von_x
- cmp bx,bis_x
- je cga_hl_fertig
- and bx,7
- call cga_setpixel
- inc von_x
- jmp short cga_hl_5
-
- cga_hl_fertig:
- pop bp
- ret param_bytes
- cga_horline endp
-
-
- cga_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
-
- mov ax,x
- mov bx,von_y
- call cga_calcptr
-
- mov cx,bis_y
- inc cx
- sub cx,von_y
- mov bx,x
- and bx,7
-
- cga_vl_loop:
- call cga_setpixel
- call cga_nextline
- loop cga_vl_loop
-
- pop bp
- ret param_bytes
- cga_verline endp
-
-
- cga_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
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call cga_calcptr
-
- cmp xorput,0
- pushf
-
- mov bh,zeichen
- call hgc_calc_graf
-
- popf
- jne cga_mal_1
- call cga_setz_graf_z
- jmp short cga_mal_2
- cga_mal_1:
- call cga_xor_graf_z
- cga_mal_2:
-
- pop ds
- pop bp
- ret param_bytes
- cga_mal endp
-
-
- cga_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
- cld
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call cga_calcptr
-
- mov al,zeichen
- call hgc_calc_text
-
- call cga_setz_text_z
-
- pop ds
- pop bp
- ret param_bytes
- cga_char endp
-
-
-
- cga_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
-
- cga_tx_repl macro zahl1,zahl2
- local cga_tx_repl_1
- cmp al,zahl1
- jne cga_tx_repl_1
- mov al,zahl2
- jmp short cga_tx_do
- cga_tx_repl_1:
- endm
-
- push bp
- mov bp,sp
- push ds
- cld
-
- mov al,x
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- mov bx,y
- call cga_calcptr
-
- mov dx,ds
- lds si,text
- lodsb
- mov cl,al
- xor ch,ch
- cga_tx_loop:
- lodsb
- push cx
- push si
- push ds
- cmp al,129
- jb cga_tx_do
- cga_tx_repl 142,64 ; Ä
- cga_tx_repl 153,96 ; Ö
- cga_tx_repl 154,123 ; Ü
- cga_tx_repl 132,124 ; ä
- cga_tx_repl 148,125 ; ö
- cga_tx_repl 129,126 ; ü
- cga_tx_repl 225,127 ; ß
- cga_tx_do:
- sub al,20h
- mov ds,dx
- call hgc_calc_text
- call cga_setz_text_z
- sub di,cga_text_next
- pop ds
- pop si
- pop cx
- loop cga_tx_loop
-
- pop ds
- pop bp
- ret param_bytes
- cga_text endp
-
-
- cga_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
- 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 cga_calcptr
-
- mov cx,40
-
- cga_row_loop:
- push cx
-
- lodsb
- push ds
- push si
- mov bh,al
- call hgc_calc_graf
- call cga_setz_graf_z
- sub di,cga_graf_next
- pop si
- pop ds
- pop cx
- loop cga_row_loop
-
- pop ds
- pop bp
- ret param_bytes
- cga_row endp
-
-
- cga_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
- cld
-
- mov ax,x
- mov bx,y
- call cga_calcptr
-
- push cs
- pop ds
- mov si,offset hgc_kugel_data
-
- mov cx,4
- xor bx,bx
-
- cga_ku_loop:
- push cx
- lodsw
- mov cx,x
- and cx,7
- shr ax,cl
- xchg al,ah
- xor es:[di],ax
- call cga_nextline
-
- pop cx
- loop cga_ku_loop
-
- pop ds
- pop bp
- ret param_bytes
- cga_kugel endp
-
-
- cga_save proc far
- lng = 6 ; BP + Rücksprung-AD
- buffer = ss:[bp+lng]
- param_bytes = 4
-
- push bp
- mov bp,sp
- push ds
-
- les di,buffer
- mov bx,cga_graph_seg
- mov ds,bx
- xor si,si
- mov cx,cga_bankused
- rep movsw
- add bx,(cga_bankbytes/10h)
- mov ds,bx
- xor si,si
- mov cx,cga_bankused
- rep movsw
-
- pop ds
- pop bp
- ret param_bytes
- cga_save endp
-
-
- cga_restore proc far
- lng = 6 ; BP + Rücksprung-AD
- buffer = ss:[bp+lng]
- param_bytes = 4
-
- push bp
- mov bp,sp
- push ds
-
- lds si,buffer
- mov bx,cga_graph_seg
- mov es,bx
- xor di,di
- mov cx,cga_bankused
- rep movsw
- add bx,(cga_bankbytes/10h)
- mov es,bx
- xor di,di
- mov cx,cga_bankused
- rep movsw
-
- pop ds
- pop bp
- ret param_bytes
- cga_restore endp