home *** CD-ROM | disk | FTP | other *** search
- Page ,132
-
- ; HERCULES (r) graphic support for QuickBASIC
- ; Code by Jeff Sumberg, Ringwood NJ (July 1987)
-
- ; To use these routines, either place the HERC.OBJ file into a user library
- ; using the Buildlib utility supplied with QuickBASIC or Link HERC.OBJ into
- ; your compiled code (BRUN or BCOM).
-
- ; To call from a QuickBASIC program there are three entry points into this
- ; program:
-
- ; Call Graphic Puts adapter card into Hercules
- ; graphic mode with page 0 enabled,
- ; in 'Half' mode (upper page is mapped
- ; off)
-
- ; Call TextMode Puts adapter card back into text mode
-
- ; Call Plot(Row,Col,Dot) Used to place dots (Pixels) on the
- ; screen. Row (X) is the horizontal
- ; axis and is from 0 to 719. Col (Y)
- ; is the vertical axis and is from
- ; 0 to 347. Dot is either a 0 or a 1
- ; and causes a pixel to appear (1) or
- ; disappear (0).
-
- ; All values in the calls MUST be INTEGER.
- ; Page 1 is not supported.
-
- ; Example:
-
- ; Call Graphic go into graphics mode
- ; For X% = 0 to 200
- ; Call Plot(X%,X%,1%) Plot 0,0 to 200,200
- ; Next X%
- ; Do
- ; Loop While Inkey$ = "" wait for a key to be hit
- ; Call TextMode return to text mode
-
- ; These routines are placed into the Public Domain, and I want nothing
- ; in return for their use. I also accept no responsibilty as to their
- ; use, misure, or inability to do as explained above. They worked for
- ; me, they should do the same for you. They were tried using a Leading
- ; Edge model D, and a ZuckerBoard Hercules clone card.
-
- ; Hercules is a trademark of Hercules Computer Technology, Inc.
- ; QuickBASIC is a trademark of Microsoft, Inc.
-
- ; Assembled using Microsoft's Macro Assembler, Version 4
-
- Public Graphic,TextMode,Plot
- ; Ports
-
- Index equ 03B4h
- Cntrl equ 03B8h
-
- ; Control Codes
-
- Scrn_on equ 8
- Grph equ 2
- Text equ 20h
-
- Pstack Struc
- DW ? ;BP
- DW ? ;Roff
- DW ? ;Rseg
- Light DW ? ;Dot value
- Yloc DW ? ;Vertical axis
- Xloc DW ? ;Horizontal Axis
- Pstack Ends
-
- Xdata Segment Public 'Data' ;Define the Data Segment
-
- Gtable DB 35h,2Dh,2Eh,07h
- DB 5Bh,02H,57h,57h
- DB 02h,03h,00h,00h
-
- Ttable DB 61h,50h,52h,0Fh
- DB 19h,06h,19h,19h
- DB 02h,0Dh,0Bh,0Ch
-
- Xdata Ends
-
- Dgroup Group Xdata ;Group our data seg in with QB's
-
- Xcode Segment Public 'Code'
- Assume CS:Xcode, DS:Dgroup
-
- Graphic Proc Far
-
- Push ES
- mov al,1
- mov dx,3BFh ;configuration switch register
- out dx,al ;Set to half mode, enable graphics mode
- Mov al,Grph
- Mov si,Offset Dgroup:Gtable
- Mov bx,0
- Mov cx,4000h
- Call Setmd
- Pop es
- Ret
-
- Graphic Endp
-
- TextMode Proc Far
-
- Push es
- Mov al,Text
- Mov si,Offset Dgroup:Ttable
- Mov bx,720h
- Mov cx,2000
- Call Setmd
- Pop es
- Ret
-
- TextMode endp
-
- Setmd Proc Near
-
- ; Sets mode to graphics or text
- ; depending on AL
- ; SI = parameter table
- ; CX = number of words to be cleared
- ; BX = blank value
-
- Push ds
- Push es
- Push ax
- Push bx
- Push cx
-
- ; change mode but without scrn_on
-
- Mov dx,cntrl
- Out dx,al
-
- ; Init 6845
-
- mov ax,ds
- mov es,ax
- mov dx,index
- mov cx,12
- xor ah,ah
- parms: mov al,ah
- out dx,al
- inc dx
- lodsb
- out dx,al
- inc ah
- dec dx
- loop parms
- pop cx
- mov ax,0B000h
- cld
- mov es,ax
- xor di,di
- pop ax
- rep stosw
-
- ; scrn_on, page 0
-
- mov dx,cntrl
- pop ax
- add al,scrn_on
- out dx,al
- pop es
- pop ds
- ret
- Setmd endp
-
- ; Dot plotting routines:
-
- ; X/Y memory location is found by:
-
- ; ((2000h * (Y Mod 4) + (90 * (y/4)) + (x / 8))
-
- Plot Proc Far
-
- Push bp ;Save Qbasics BP pointer
- mov bp,sp ;take a copy of the stack pointer
- mov ax,0B000h ;Segment of graphics page ZERO
- mov es,ax ;that goes to the extra segment reg
- mov bx,[bp].Yloc ;pick up from the stack
- mov ax,[bx] ;the Y value
- cmp ax,347
- jg Exit
- mov bl,4
- div bl ;divide it by 4
- mov cl,al ;Quotient (Used in next step)
- mov al,ah ;remainder (Mod 4 part)
- cbw ;convert remainder to a word
- mov dx,2000h
- mul dx ;multiply remainder times 2000h
- mov si,ax ; SI = 2000h * (Y Mod 4)
-
- mov al,cl ;Quotient from above
- cbw ;convert to a word
- mov dx,90
- mul dx ;multiply times 90
- mov di,ax ; DI = 90 * (Y / 4)
-
- mov bx,[bp].Xloc ;Pick up from the stack
- mov ax,[bx] ;the X value
- cmp ax,719
- jg exit
- mov bl,8
- div bl ;divide it by 8
- mov cl,ah ;save remainder (X Mod 8 part for below)
- cbw ; AX = X / 8
- Add ax,di ;add all the results together to get
- Add ax,si ;the final memory offset
- mov di,ax ; DI = Offset into display page
-
- ; Find the bit: 2 ^ (7 - (X mod 8))
-
- mov ah,cl ;get X Mod 8 (from abobe)
- mov al,7
- sub al,ah ; 7-(X Mod 8) gives us the
- mov cl,al ;shift count to the proper bit
- mov al,1 ;This is the starting bit mask to rotate
- sal al,cl ;bit position in AL is the one to alter
- mov bx,[bp].Light ;Get from the stack the parammeter that
- mov bx,[bx] ;tells us if we turn on or off the bit
- mov ah,es:[di] ;get screen memory byte
- test bl,1 ;test for turn bit on
- jz bit0 ;turn off if zero
- or ah,al ;add the bit
- jmp fini ;done
-
- bit0: not al ;flip the bits for turn off
- and ah,al ;turn off the bit
-
- fini: mov es:[di],ah ;put back
- exit: Pop BP ;restore Qbasic's original BP value
- Ret 6 ;do a FAR return chucking 3 values on stack
-
- Plot EndP
-
- Xcode ends
-
- end
-