home *** CD-ROM | disk | FTP | other *** search
- ; KAISHGC.ASM
- ;
- ; hgc, Hercules Grafik:
-
- ; hgc, öffentliche Definitionen:
- public hgc_graphmode ; 12.08.1990
- public hgc_textmode ; 12.08.1990
- public hgc_horline ; 12.08.1990
- public hgc_verline ; 12.08.1990
- public hgc_mal ; 15.08.1990
- public hgc_char ; 15.08.1990
- public hgc_text ; 15.08.1990
- public hgc_row ; 16.08.1990
- public hgc_kugel ; 16.08.1990
-
- ; hgc, Konstanten:
- hgc_adress equ 03B4h ; Port-Adressen
- hgc_data equ 03B5h
- hgc_modecont equ 03B8h
- hgc_config equ 03BFh
- hgc_graph_off equ 82h ; Port-Werte
- hgc_graph_on equ 8Ah
- hgc_text_off equ 20h
- hgc_text_on equ 28h
- hgc_graph_conf equ 3
- hgc_text_conf equ 1
- hgc_graph_seg equ 0B800h ; Segmente
- hgc_text_seg equ 0B000h
- hgc_rowbytes equ 90 ; Bytes pro Zeile
- hgc_bankbytes equ 2000h ; Bytes pro Bank
- hgc_maxbank equ 8000h ; Bytes in allen Banks
- hgc_graf_zeilen equ 16 ; Zeilen pro Zeichen im Grafikzeichensatz
- hgc_text_zeilen equ 8 ; Zeilen pro Zeichen im Textzeichensatz
- hgc_text_next equ hgc_rowbytes*(hgc_text_zeilen/(hgc_maxbank/hgc_bankbytes))-1
- hgc_graf_next equ hgc_rowbytes*(hgc_graf_zeilen/(hgc_maxbank/hgc_bankbytes))-2
-
- ; hgc, Tabellen:
- hgc_graph_value db 35h,2Dh,2Eh,07h,5Bh,02h,57h,57h,02h,03h,00h,00h
- hgc_text_value db 61h,50h,52h,0Fh,19h,06h,19h,19h,02h,0Dh,10h,00h
- hgc_banks dw 0000h,2000h,4000h,6000h
- hgc_and_tab db 07Fh,0BFh,0DFh,0EFh,0F7h,0FBh,0FDh,0FEh
- hgc_or_tab db 80h,40h,20h,10h,08h,04h,02h,01h
- hgc_kugel_data dw 06000h,0F000h,0F000h,06000h
-
- ; hgc, lokale Prozeduren:
-
- ; hgc_setmode:
- ;
- ; Parameter: CS:SI: ^ auf Port-Register-Wertetabelle
- ;
- ; verändert: AX, BX, CX, DX
- hgc_setmode proc near
- push ds
- push cs
- pop ds
- mov cx,12
- xor bl,bl
- mov dx,hgc_adress
- hgc_sm_loop:
- mov al,bl
- out dx,al
- inc dx
- lodsb
- out dx,al
- dec dx
- inc bl
- loop hgc_sm_loop
- pop ds
- ret
- hgc_setmode endp
-
- ; hgc_calcptr
- ;
- ; Parameter: AX: X-Koordinate
- ; BX: Y-Koordinate
- ;
- ; Rückgabe: ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX, BX, CX, DX
- ; SI, DI
- hgc_calcptr proc near
-
- shr ax,1 ; DI := X DIV 8
- shr ax,1
- shr ax,1
- mov di,ax
-
- mov ax,hgc_rowbytes ; + hgc_rowbytes * (Y DIV 4)
- mov cx,bx
- shr cx,1
- shr cx,1
- mul cx
- add di,ax
-
- and bx,3
- shl bx,1
- add di,cs:[bx+(offset hgc_banks)]
- mov ax,hgc_graph_seg
- mov es,ax
-
- ret
- hgc_calcptr endp
-
-
- ; hgc_setpixel
- ;
- ; Parameter: BX: Y-Koordinate im momentanen Byte (0..7)
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AL
- hgc_setpixel proc near
- cmp farbe,0
- je hgc_sp_1
- mov al,cs:[bx+(offset hgc_or_tab)]
- or es:[di],al
- ret
- hgc_sp_1:
- mov al,cs:[bx+(offset hgc_and_tab)]
- and es:[di],al
- ret
- hgc_setpixel endp
-
- ; hgc_nextline
- ;
- ; Setzt ES:DI auf die nächste Zeile
- hgc_nextline proc near
- add di,hgc_bankbytes
- cmp di,hgc_maxbank
- jb hgc_nl_fertig
- sub di,hgc_maxbank-hgc_rowbytes
- hgc_nl_fertig:
- ret
- hgc_nextline endp
-
- ; hgc_calc_graf
- ;
- ; Parameter: BH: Nummer des Zeichens
- ;
- ; Rückgabe: DS:SI: ^ auf Grafikzeichen
- ;
- ; verändert: BX
- hgc_calc_graf proc near
-
- lds si,graf_satz
- xor bl,bl
- shr bx,1
- shr bx,1
- shr bx,1
- add si,bx
-
- ret
- hgc_calc_graf endp
-
-
- ; hgc_setz_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- hgc_setz_graf_z proc near
- mov cx,hgc_graf_zeilen
- hgc_sg_loop:
- lodsw
- mov es:[di],ax
- call hgc_nextline
- loop hgc_sg_loop
-
- ret
- hgc_setz_graf_z endp
-
- ; hgc_xor_graf_z
- ;
- ; Parameter: DS:SI: ^ auf Grafikzeichen
- ; ES:DI: ^ auf Bildschirm
- hgc_xor_graf_z proc near
- mov cx,hgc_graf_zeilen
- hgc_xg_loop:
- lodsw
- xor es:[di],ax
- call hgc_nextline
- loop hgc_xg_loop
-
- ret
- hgc_xor_graf_z endp
-
- ; hgc_calc_text
- ;
- ; Parameter: AL: Nummer des Zeichens
- ;
- ; Rückgabe: DS:SI: ^ auf Grafikzeichen
- ;
- ; verändert: AX
- hgc_calc_text proc near
-
- lds si,text_satz
- xor ah,ah
- shl ax,1
- shl ax,1
- shl ax,1
- add si,ax
-
- ret
- hgc_calc_text endp
-
-
- ; hgc_setz_text_z
- ;
- ; Parameter: DS:SI: ^ auf Textzeichen
- ; ES:DI: ^ auf Bildschirm
- ;
- ; verändert: AX,CX,DI
- hgc_setz_text_z proc near
- mov cx,hgc_text_zeilen
- hgc_st_loop:
- lodsb
- mov es:[di],al
- call hgc_nextline
- loop hgc_st_loop
-
- ret
- hgc_setz_text_z endp
-
-
- hgc_graphmode proc far
- cld
- mov al,hgc_graph_off
- mov dx,hgc_modecont
- out dx,al
- mov si,offset hgc_graph_value
- call hgc_setmode
- mov al,hgc_graph_conf
- mov dx,hgc_config
- out dx,al
- cmp auto_cls,0
- je hgc_gm_no_cls
- mov ax,hgc_graph_seg
- mov es,ax
- xor ax,ax
- xor di,di
- mov cx,4000h
- rep stosw
- hgc_gm_no_cls:
- mov auto_cls,1
- mov al,hgc_graph_on
- mov dx,hgc_modecont
- out dx,al
- ret
- hgc_graphmode endp
-
-
- hgc_textmode proc far
- cld
- mov al,hgc_text_off
- mov dx,hgc_modecont
- out dx,al
- mov ax,hgc_text_seg
- mov es,ax
- xor ax,ax
- xor di,di
- mov cx,07D0h
- rep stosw
- mov si,offset hgc_text_value
- call hgc_setmode
- mov al,hgc_text_conf
- mov dx,hgc_config
- out dx,al
- mov al,hgc_text_on
- mov dx,hgc_modecont
- out dx,al
- ret
- hgc_textmode endp
-
-
- hgc_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 hgc_calcptr
- mov bx,von_x
- and bx,7
- je hgc_hl_1
-
- hgc_hl_2:
- mov bx,von_x
- cmp bx,bis_x
- je hgc_hl_fertig
- and bx,7
- je hgc_hl_3
- call hgc_setpixel
- inc von_x
- jmp short hgc_hl_2
-
- hgc_hl_3:
- inc di
-
- hgc_hl_1:
- mov cx,bis_x
- sub cx,von_x
- shr cx,1
- shr cx,1
- shr cx,1
- je hgc_hl_4
- xor al,al
- cmp farbe,0
- je hgc_hl_6
- dec al
- hgc_hl_6:
- rep stosb
-
- hgc_hl_4:
- mov bx,bis_x
- mov ax,bx
- and ax,7
- je hgc_hl_fertig
- and bx,0FFF8h
- mov von_x,bx
-
- hgc_hl_5:
- mov bx,von_x
- cmp bx,bis_x
- je hgc_hl_fertig
- and bx,7
- call hgc_setpixel
- inc von_x
- jmp short hgc_hl_5
-
- hgc_hl_fertig:
- pop bp
- ret param_bytes
- hgc_horline endp
-
-
- hgc_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 hgc_calcptr
-
- mov cx,bis_y
- inc cx
- sub cx,von_y
- mov bx,x
- and bx,7
-
- hgc_vl_loop:
- call hgc_setpixel
- call hgc_nextline
- loop hgc_vl_loop
-
- pop bp
- ret param_bytes
- hgc_verline endp
-
-
- hgc_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 hgc_calcptr
-
- cmp xorput,0
- pushf
-
- mov bh,zeichen
- call hgc_calc_graf
-
- popf
- jne hgc_mal_1
- call hgc_setz_graf_z
- jmp short hgc_mal_2
- hgc_mal_1:
- call hgc_xor_graf_z
- hgc_mal_2:
-
- pop ds
- pop bp
- ret param_bytes
- hgc_mal endp
-
-
- hgc_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 hgc_calcptr
-
- mov al,zeichen
- call hgc_calc_text
-
- call hgc_setz_text_z
-
- pop ds
- pop bp
- ret param_bytes
- hgc_char endp
-
-
-
- hgc_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
-
- hgc_tx_repl macro zahl1,zahl2
- local hgc_tx_repl_1
- cmp al,zahl1
- jne hgc_tx_repl_1
- mov al,zahl2
- jmp short hgc_tx_do
- hgc_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 hgc_calcptr
-
- mov dx,ds
- lds si,text
- lodsb
- mov cl,al
- xor ch,ch
- hgc_tx_loop:
- lodsb
- push cx
- push si
- push ds
- cmp al,129
- jb hgc_tx_do
- hgc_tx_repl 142,64 ; Ä
- hgc_tx_repl 153,96 ; Ö
- hgc_tx_repl 154,123 ; Ü
- hgc_tx_repl 132,124 ; ä
- hgc_tx_repl 148,125 ; ö
- hgc_tx_repl 129,126 ; ü
- hgc_tx_repl 225,127 ; ß
- hgc_tx_do:
- sub al,20h
- mov ds,dx
- call hgc_calc_text
- call hgc_setz_text_z
- sub di,hgc_text_next
- pop ds
- pop si
- pop cx
- loop hgc_tx_loop
-
- pop ds
- pop bp
- ret param_bytes
- hgc_text endp
-
-
- hgc_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 hgc_calcptr
-
- mov cx,40
-
- hgc_row_loop:
- push cx
-
- lodsb
- push ds
- push si
- mov bh,al
- call hgc_calc_graf
- call hgc_setz_graf_z
- sub di,hgc_graf_next
- pop si
- pop ds
- pop cx
- loop hgc_row_loop
-
- pop ds
- pop bp
- ret param_bytes
- hgc_row endp
-
-
- hgc_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 hgc_calcptr
-
- push cs
- pop ds
- mov si,offset hgc_kugel_data
-
- mov cx,4
- xor bx,bx
-
- hgc_ku_loop:
- push cx
- lodsw
- mov cx,x
- and cx,7
- shr ax,cl
- xchg al,ah
- xor es:[di],ax
- call hgc_nextline
-
- pop cx
- loop hgc_ku_loop
-
- pop ds
- pop bp
- ret param_bytes
- hgc_kugel endp
-