BBS: Inland Empire Archive Date: 02-19-93 (14:40) Number: 275 From: BRIAN MCLAUGHLIN Refer#: NONE To: ZACK JONES Recvd: NO Subj: Demo of ASM screen fill Conf: (2) Quik_Bas
ZJ>I'd like to see what it would look like in ASM - no need
ZJ>to worry about moni
ZJ>checking - I just want to see how it's done in asm.
OK, Zack. This was tested with QB 4.5, an XT clone(!) and an SVGA monitor.
(Written for MASM 5.1)
; >----------------- SNIP HERE -----------------------<
comment|
This routine is very limited. ALL it does is demonstrate how to fill a
screen with a single character in the indicated colors. It passes its
parameters both by value (BYVAL) and by reference (the default), just to
illustrate both methods. It should be the fastest thing going!
1. This routine assumes the active display page is 0. This is the QB default,
so unless you have changed the active display page, don't worry.
2. It assumes a screen size of 25 rows by 80 columns.
3. If this routine is used with an old CGA it WILL cause onscreen snow!
4. The cursor is in NOT updated, changed, moved or messed with in any way.
5. The background/foreground colors are passed as one integer, the color
attribute. If you don't care about blinking, the simple BASIC formula for
combining the colors into an attribute is:
Attr% = FG% + 16 * BG%.
If you require blinking use this formula:
Attr% = (FG% AND 16) * 8 + ((BG% AND 7) * 16) + (FG% AND 15)
6. You must pass the segment address of the video memory. On monochrome
monitors this value should be &HB000, for color monitors this value
should be &HB800.
Declare it: DECLARE SUB FillScrn (FillChar%, Attr%, BYVAL VidSeg%)
^^^^^^^^^^^^^^^^notice!
end comment|
.MODEL MEDIUM, BASIC
.CODE
FillScrn PROC USES ES DI, Char:WORD, Attr:WORD, VidSeg:WORD
Mov AX, VidSeg ; since VidSeg can't go directly into ES
Mov ES, AX ; make the transfer through AX
Xor DI, DI ; ES:DI points at start of display page 0
Mov BX, Char ; BX = address where Char can be found
Mov AL, Byte Ptr [BX] ; put value of Char into AL
Mov BX, Attr ; BX = address where Attr can be found
Mov AH, Byte Ptr [BX] ; put value of Attr into AH
Mov CX, 2000 ; we'll repeat Stosw 2000 times
Cld ; clear direction flag for forward write
Rep Stosw ; put char+attr into video buffer CX times
Ret ; return to sender!
FillScrn ENDP
END
; >------------------- THAT'S ALL FOLKS --------------------<
Have fun playing with this, Zack and everyone.
* SLMR 2.0 * Guns don't kill people - bullets kill people.
--- WM v2.07/91-0012
* Origin: Com-Dat BBS Hillsboro, OR. HST (503) 681-0543 (1:105/314)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET