;---------------------------------------------------------------------------- ; Graphic Windows for TextMode Co80 (VGA) release 1.0 ; Copyright (c) Ingo Eickmann, 1989 07/09/89 ;---------------------------------------------------------------------------- ; Assemblieren mit MASM 5.x : I. Eickmann ; MASM GWindow; Im Leuchterbruch 8 ; Getestet unter MS-DOS 3.3, Turbo Pascal V4.0 5000 K”ln 80 ;---------------------------------------------------------------------------- PAGE 65,80 TITLE Graphic Windows for TextMode Co80 (VGA) Sequencer equ 3C4h ; Adresse des Sequencer GraphicsC equ 3CEh ; Adresse des Graphics Controller Scanlines equ 16 ; Anzahl der Scanlines/Char (EGA: 14) if1 Port_out macro low,high ; Ausgabe eines Wortes an einen mov al,low ; Port (dx) mov ah,high out dx,ax endm BitPosMask macro X,Y,d_X ; Bitmaske des Pixel (X,Y) ermitteln: mov ax,0B800h ; Position in es:di, Maske in al mov es,ax mov di,4000h ; Offset des Character Definition mov ax,Y ; Tables 1 mov dl,Scanlines div dl ; Ermittlung der betroffenen Textzeile mov dl,ah mov bx,d_X mul bl mov bx,X mov cl,3 shr bx,cl ; Ermittlung der betroffenen Textspalte add ax,bx mov cl,5 shl ax,cl ; Offset des Characters im Definition xor dh,dh ; Table add ax,dx add di,ax mov cx,X ; Ermittlung der Bitmaske fr das and cl,111b ; zugeh”rige Byte im Character mov al,10000000b ; Definition Table shr al,cl endm endif code segment word public 'CODE' assume cs:code public GWindowOn ; CPU erh„lt Zugriff auf Character GWindowOn proc far ; Definition Tables (Map 2) cli mov dx,Sequencer Port_out 0,1 ; Sync. reset Port_out 1,1 ; Clocking Mode: 8 dots/char Port_out 2,100b ; CPU beschreibt Map 2 Port_out 3,4 ; Map Select Register Port_out 4,7 ; Sequential Addressing Port_out 0,3 ; Clear Sync. reset sti mov dx,GraphicsC Port_out 4,10b ; CPU liest Map 2 Port_out 5,0 ; Sequential Addressing Port_out 6,1100b ; Miscellaneous Register mov ax,1000h ; reset horz. panning mov bx,0013h int 10h ret GWindowOn endp public GWindowOff ; CPU erh„lt wieder Zugriff auf den GWindowOff proc far ; Bildschirmspeicher (Map 0 und 1) cli mov dx,Sequencer Port_out 0,1 ; Sync. reset Port_out 2,3 ; CPU beschreibt Map 0 und 1 Port_out 4,11b ; Odd/Even Addressing Port_out 0,3 ; Clear Sync. reset sti mov dx,GraphicsC Port_out 4,0 ; CPU liest Map 0 und 1 Port_out 5,10h ; Odd/Even Addressing Port_out 6,1110b ; Miscellaneous Register ret GWindowOff endp public _GWindowInit ; Ein Grafikfenster wird initialisiert _GWindowInit proc far ; Parameterbergabe fr Turbo Pascal: X1 equ [bp+16] ; Koordinaten der linken oberen Ecke Y1 equ [bp+14] d_X equ [bp+12] ; Ausdehnung des Fensters in Text- d_Y equ [bp+10] ; spalten und Textzeilen Colf equ [bp+8] ; Vordergrundfarbe Colb equ [bp+6] ; Hintergrundfarbe push bp mov bp,sp push es push di mov ax,0B800h ; Anwahl des Bildschirmspeichers mov es,ax mov ax,Y1 mov bl,80 mul bl add ax,X1 shl ax,1 ; Offset der linken oberen Ecke im mov di,ax ; Bildschirmspeicher mov ah,Colb mov cl,4 shl ah,cl or ah,Colf or ah,1000b ; Attribute Byte fr das Grafikfenster and ax,7F00h mov cx,d_Y mov dx,d_X shl dx,1 Lop2: xor bx,bx ; Schleife fr die Textzeilen Lop1: mov es:[di+bx],ax ; Schleife fr die Textspalten inc al ; Fllen aller Character Codes im add bx,2 ; Grafikfenster mit fortlaufenden cmp bx,dx ; Werten (al) jl Lop1 add di,80*2 dec cx jg Lop2 pop di pop es pop bp ret 12 ; Freigabe der Parametereintr„ge im _GWindowInit endp ; Stack public GWindowClear ; L”schen aller Bitmasken fr das GWindowClear proc far ; Grafikfenster push es push di mov ax,0B800h ; Anwahl des Videospeichers mov es,ax mov di,4000h ; Offset fr Table 1 xor ax,ax mov cx,2000h shr 1 ; Anzahl der Bytes im Char. Def. Table cld rep stosw ; šberschreiben des gesamten Bereichs pop di pop es ret GWindowClear endp public _GWindowSet ; Setzen eines Bildpunktes im Fenster _GWindowSet proc far ; Parameterbergabe fr Turbo Pascal: X equ [bp+10] ; Pixelkoordinaten Y equ [bp+8] d_X equ [bp+6] ; Breite des Fensters push bp mov bp,sp push es push di BitPosMask X,Y,d_X ; Bitmaske und Position ermitteln mov ah,es:[di] or ah,al ; Verknpfung der Maske mit dem mov es:[di],ah ; ursprnglichen Inhalt pop di pop es pop bp ret 6 _GWindowSet endp ; Freigabe der Parametereintr„ge public _GWindowReset ; Zurcksetzen eines Bildpunktes _GWindowReset proc far ; Parameterbergabe fr Turbo Pascal: X equ [bp+10] ; Pixelkoordinaten Y equ [bp+8] d_X equ [bp+6] ; Breite des Fensters push bp mov bp,sp push es push di BitPosMask X,Y,d_X ; Bitmaske und Position ermitteln mov ah,es:[di] not al and ah,al ; Verknpfung der Maske mit dem mov es:[di],ah ; ursprnglichen Inhalt pop di pop es pop bp ret 6 ; Freigabe der Parametereintr„ge _GWindowReset endp code ends end