TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: DAVID ROTHSCHILD
from: HANS LUNSING
date: 1998-03-27 08:17:00
subject: Using poke

Hello David
On Sunday, 22 March 1998 21:26:00, you wrote to All:
 DR> How do I use POKE to draw pixels in screen 12? Or is there
 DR> something faster?
Here is a demonstration of two methods:
DEFINT A-Z
CONST PIXELS = 10000
SCREEN 12
DEF SEG = &HA000
REDIM BitMask%(0 TO 7)
FOR Bit% = 0 TO 7
  BitMask%(7 - Bit%) = 2 ^ Bit%
NEXT Bit%
MaxX& = 640
RANDOMIZE TIMER
CLS
' Method 1,  with set-reset register
' The Graphics Address Port is &h3CE.
' Enable raster mode by setting the Enable_Set_Reset
' register (index 1) to &hF (all planes affected)
OUT &H3CE, 1
OUT &H3CF, &HF
FOR i = 1 TO PIXELS
  X = 640 * RND
  Y = 480 * RND
  Colour = 16 * RND
  ' Load color via Set-Reset register (index 0)
  OUT &H3CE, 0
  OUT &H3CF, Colour
  ' Set Bit-Mask register (index 8) to desired pixel
  OUT &H3CE, 8
  OUT &H3CF, BitMask%(X% AND 7)
  Offset& = (MaxX& * Y% + X%) \ 8
  Byte% = PEEK(Offset&)         'Dummy read
  POKE Offset&, Byte%           'Store pixel in memory
NEXT i
'Reset registers for normal operation
'First set Bit-Mask register (8) to &hFF (all bits affected)
OUT &H3CE, 8
OUT &H3CF, &HFF
'Then set Enable_Set_Reset register (1) to 0
OUT &H3CE, 1
OUT &H3CF, 0
DO: LOOP UNTIL LEN(INKEY$)
RANDOMIZE TIMER
CLS
' Method 2, with write mode 2
' Set write mode 2 (all planes affected)
OUT &H3CE, 5
OUT &H3CF, 2
'Point to Bit_Mask register (8)
OUT &H3CE, 8
FOR i = 1 TO PIXELS
  X = 640 * RND
  Y = 480 * RND
  Colour = 16 * RND
  Offset& = (MaxX& * Y% + X%) \ 8
  ' Set Bit_Mask register to desired pixel
  OUT &H3CF, BitMask%(X% AND 7)
  POKE Offset&, Colour          'Store pixel in memory
NEXT i
'Reset registers for normal operation:
'set write mode 0 (default)
OUT &H3CE, 5
OUT &H3CF, 0
DO: LOOP UNTIL LEN(INKEY$)
SCREEN 0
END
It's not very fast. Method 2 is about as fast as PSET, and method 1 is a
bit slower. To do it fast you have to resort to assembler. And it's no
use to make an assembler procedure to draw just one pixel because
calling the procedure for every pixel will make it just as fast as PSET.
Friendly greeting you,
Hans Lunsing,           Fido     : 2:500/104.6955
                        Internet : jlunsing@doge.nl
--- Terminate 5.00/Pro 
---------------
* Origin: HCC DOSgg SW Boss West 1, ++31793317774 (2:500/104.6955)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.