BBS: Inland Empire Archive Date: 03-14-92 (03:14) Number: 137 From: SCOTT WUNSCH Refer#: NONE To: STEVE HALKO Recvd: NO Subj: Direct screen writes Conf: (2) Quik_Bas
On 11 March 1992, Steve Halko wrote to Michael Malley... SH> MM>DB> There is only one thing I'm stuck on... I'd like to use SH> MM>DB>direct video for the screen writes, as opposed to LOCATEs, SH> MM>DB>since I am working with a VIEW PRINT (Right now it is SH> SH> MM>Why do that when QB 4.5 (don't know about 4.0) writes directly to the SH> MM>screen anyway? SH> SH> Actually, direct screen writes are TONS faster than LOCATE/PRINT. QB SH> uses direct screen writes, but only after wading through all the SH> internal code for LOCATE and PRINT. That is correct. The PRINT routines are very complex because they must process the control characters (eg. beep for a CHR$(7)), and they must support the display of characters in graphics mode. PDS comes with a stub file that removes all of those features, providing screen updates that are about as fast as a direct screen writing. Now, on to explanations of how to actually do it. The following QB code should work, but I haven't tested it: DEFINT A-Z 'Habit SUB DirectPRINT (Text$, Lin%, Col%, Fore%, Back%) Start% = (Lin% * 80) + Col% Colour% = (Back% * 16) + Fore% DEF SEG = &HB800 'Or &HB000 FOR X = 1 TO LEN(Text$) OffSet = (Start% + X) * 2 POKE OffSet, ASC(MID$(Text$, X, 1)) POKE OffSet + 1, Colour% NEXT X DEF SEG END SUB The DEF SEG statement sets the segment in which video memory is. Monochrome and colour adapters use different video segments, however. Monochrome uses &HB000, and colour uses &HB800. For fastest results, this routine should be written in assembly. Also, keep in mind it will cause "snow" on most CGA monitors. If you're interested, both points are addressed with some sample code in The QBNews. SH> * SLMR 2.1a * recursion, noun - see recursion. Neat tagline - I'll have to steal it! -= Scott =- ... OFFLINE 1.36 * Recursion, noun: see recursion --- Maximus 2.00 * Origin: The Green Zone - Regina, Sask, Canada (1:140/23)
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