TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: DON SCHULLIAN
date: 1998-03-06 16:17:00
subject: Re: pointers:help

From: d83@ath.forthnet.gr (Don Schullian)
Subject: Re: pointers:help
 
On Thu, 05 Mar 1998 06:09:28 -0500, Krogg 
wrote:
 
'==================================Subject: pointers:help
From: Krogg 
Date: Thu, 05 Mar 1998 06:09:28 -0500
--------
>I am using trypb32 and have ordered 3.5 for dos.(waiting for it
>to come in mail :) )
>
>What i want to do is make an array that is 100x100 and
>store the address for a 100x100 section of the mode 13h
>vga screen.then i can do like
>"@scrn(x,y)=pixelcolor"
>the help file says that pointers are faster than poke and peek
>and using an array would be faster than
>saying "poke 320*y+x" anyhow cause it would eliminate a multiply
>and an add.
 
Hi,
 
  You're confusing apples and oranges. If you want to address the whole 
creen
with a 2D array then you need to DIM it as ABSOLUTE. (See code, below)
 
  On the other hand, if you were to use an indexed pointer then you'd not 
eed
an array.
 
DIM S_prt AS BYTE PTR
S_ptr = &hA0000000
 
FOR X% = 0 TO 319
  FOR Y% = 0 TO 199
    Ofs% = ( Y% * 320 ) + X%
    @S_ptr[Ofs%] = ( (x%+y%) AND 255 )
  NEXT
NEXT
 
Got it?
 
  ____    _    ____      ____  _____
 |  _ \  / \  / ___) __ | ___)(_   _)
 | |_)  / _ \ \____\/  \|  _)   | |
 |____//_/ \_\(____/\__/|_|     |_|
    Reply to: d83@ath.forthnet.gr
     www.basicguru.com/schullian
 
 
-----------begin code-----------------
DEFINT A-Z
 
DIM ABSOLUTE Scrn(319,199) AS BYTE AT &hA000
 
asm mov ax,&h13                       ;chained 320x200 256 vga
asm int &h10
 
 
for x=1 to 100                        'show test pattern
  for y=1 to 100                        'It works good enuf
    scrn(x,y) = y+x                       'dont know if faster yet though
  next y                                'BTW y+x ranges from 2-200 and
next x                                'its just some diagonal lines
 
poop:
a$=inkey$                             'lame loop,but it werks.
if a$="" then goto poop
 
asm mov ax,&h03                       ;reset normal 80x25 text mode
asm int &h10
cls
?"done"
 
end
 
*** QwkNews (tm) v2.1
 * [TN71] Internet Newsgroup: alt.lang.powerbasic
--- GEcho 1.20/Pro
---------------
* Origin: Toast House Remote (1:100/561)

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™.