From: dave@powerbasic.com (Dave Navarro)
Subject: Re: Graphics primitives and inline asm sources.
' Mode 13h routines for PowerBASIC
' by Dave Navarro, Jr.
' Last Revision: February 5, 1995
DEFINT A-Z 'Required for all numeric functions, forces PB to not
'include floating point in the executable
SUB vMode(BYVAL bool) PUBLIC
IF bool THEN 'if non-zero
bool = &H13 ' set mode 13h
ELSE
bool = &H03 'otherwise give us text mode
END IF
! push DS ; save DS for PowerBASIC
! mov AX, bool ; put the mode value in AX
! int &H10 ; call BIOS
! pop DS ; restore DS
END SUB
SUB vCLS(BYVAL vcolor) PUBLIC
! push DS ; save DS
! mov AX, &H0A000 ; VGA buffer at A000:0000
! mov ES, AX ; put segment in ES
! xor DI, DI ; point DI to start of buffer
! mov CX, 32000 ; buffer is 64k, use 32k of words, they're faster
! mov AX, vcolor ; put color in AX
! mov AH, AL ; and AH
! rep stosw ; fill the whole screen
! pop DS ; restore DS
END SUB
SUB vPSET(BYVAL x, BYVAL y, BYVAL vcolor) PUBLIC
! push DS ; save DS for PowerBASIC
! mov AX, &H0A000 ; VGA buffer at A000:0000
! mov DS, AX ; put segment in DS
! mov AX, y ; put Y in AX
! mov BX, 320 ; there are 320 pixels per line
! mul BX ; AX = AX * BX
! add AX, x ; add X location
! mov SI, AX ; point SI at pixel
! mov AX, vcolor ; put color in AX
! mov DS:[SI], AL ; put pixel on the screen
! pop DS ; restore DS
END SUB
FUNCTION vPGET(BYVAL x, BYVAL y) PUBLIC
! push DS ; save DS for PowerBASIC
! mov AX, &H0A000 ; VGA buffer at A000:0000
! mov DS, AX ; put segment in DS
! mov AX, y ; put Y in AX
! mov BX, 320 ; there are 320 pixels per line
! mul BX ; AX = AX * BX
! add AX, x ; add X location
! mov SI, AX ; point SI at pixel
! mov AL, DS:[SI] ; get pixel from the screen
! xor AH, AH ; clear AH
! mov FUNCTION, AX ; return pixel value
! pop DS ; restore DS
END FUNCTION
' "image?" must be a byte array. To calculate the array size, multiply the
' total rows by the total columns and add 4.
SUB vGET(BYVAL x1, BYVAL y1, BYVAL x2, BYVAL y2, image?) PUBLIC
DECR x2, x1 ' convert X2 to total columns
DECR y2, y1 ' convert Y2 to total rows
Continued with next message...
*** QwkNews (tm) v2.1
* [TN71] Toast House Import
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/561)
|