Qbasicnews.com
December 10, 2019, 07:35:43 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: VPage array...  (Read 5281 times)
R@dioman
Ancient QBer
****
Posts: 410



« on: January 27, 2003, 04:21:28 AM »

How many cells in my array [ex: myarray(*cells*)] should have to make a virtual page of one screen. I always use VPage(31999) but that's for a large scroller. And how do I calculate the space necessary for x number of screens held in the array or the buffer if you like. Oh, and a better word for cell. Thanks Smiley

P.S. What's going on with all the posts? Spring cleaning? :wink:
Logged

toonski84
__/--\__
*****
Posts: 2567



« Reply #1 on: January 27, 2003, 07:43:25 AM »

the forum was attacked by some people who knew a bug in phpbb2 and most were deleted.

the number of bytes, bits, whatever is what you need to know.  in mode 13h, or any 256 color mode, each pixel takes up one byte.  since the smallest unit qb has (short of string * 1) is an integer, that takes up two bytes.  so think here:

1 (byte per pixel) * 320 (width of screen) * 200 (height of screen) / 2 (bytes per integer) = 32000

since 0 is an array unit too, 31999 is sufficient.

HOWEVER:  you dont get a lot of memory in pure does.  dos has a 640k memory limit and qb a 64k one (if you dont use $dynamic).  if you need to use more than one off screen buffer, or if your program is graphic-intensive in general look into using ems memory.
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #2 on: January 27, 2003, 08:23:16 AM »

To make a scroller you DONT need a huge offscreen buffer!! (well, you could do it that way, but it would be SLOW AND MEMORY KILLING).

With your vpage%(32001) buffer you have enough. What you should do is only draw the portion of the game map which the player should see. It is easy to do using tiles.

Check out relsoft's scrolling tutorial to find out.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #3 on: January 27, 2003, 11:35:25 AM »

data (in mode 13) in an array that you can use with GET and PUT, you need 64,004 bytes.  (There are 4 extra bytes for size information at the front of the array
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
ak00ma
Ancient Guru
****
Posts: 669



« Reply #4 on: January 27, 2003, 02:28:05 PM »

...or in QB words:

dim shared buffer(32001)
Logged

B 4 EVER
toonski84
__/--\__
*****
Posts: 2567



« Reply #5 on: January 27, 2003, 08:44:20 PM »

true dat, my mistake.  forgot about the width/height specs.
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
R@dioman
Ancient QBer
****
Posts: 410



« Reply #6 on: January 27, 2003, 08:46:37 PM »

Suppose I have a map arranged like so where 1 square is one screen and the star is the player, where if he passes the screen the other map loads:

|------|------|
      *
|------|------|

This is a non-scrollable map. If it were scrollable, I understand how to use the screen buffer now. So I would have the left map in memory, then when the player passes the screen boundary, I would clear my map array, reallocate the array to use the second map, then draw the map blah blah blah. Would I have to use $dynamic to reallocate my array which the reallocation would reside in a subroutine? I hear it gets tricky using $dynamic variables. Is there a good tutorial out there which explains proper usage of dynamic array allocation?
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #7 on: January 28, 2003, 11:57:35 AM »

It is not very tricky. Also, if you don't use $DYNAMIC, you will get out of memory very soon.

If the map you are gonna load is the same size as the previous, you don't need to reallocate your arrays, just overwrite the values. If it isn't, ERASE will clear your array and REDIM will give it new dimensions. Not so tricky Wink

About tuts, sorry but I don't know... Maybe another poster could help.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!