Qbasicnews.com
February 26, 2020, 01:32:21 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 [2] 3
  Print  
Author Topic: Get\Put troubles  (Read 10183 times)
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #15 on: November 24, 2005, 12:53:40 PM »

With your dim you are reserving 128.000 bytes of memory.

Read this Smiley, it will help:

http://faq.qbasicnews.com/?blast=DoubleBufferingGeneral

(aaah, the almighty FAQ)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
axipher
Ancient Guru
****
Posts: 544



« Reply #16 on: November 24, 2005, 11:16:03 PM »

im storing 128,000 bytes, so the number in the brackets should be half that of how many pixels the img is???
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #17 on: November 25, 2005, 07:45:58 AM »

You're in screen 13. You want to have an array that can hold the whole screen, which means:

width: 320
height: 200
bpp: 8 (256 colors)

Which means you need 320 * 200 * (8 / 8 ) = 64000 bytes to store the picture.
However, the PUT memoryheader is 4 bytes. So the total amount of bytes needed is: 64000 + 4 = 64004 bytes.
So if you allocate 64004 bytes, you should be fine.

Since INTEGERs are 2 bytes each, you need 64004/2 = 32002 integers.
So:
Code:
Dim Buffer(32001) As Integer

(It's 32001 because the 0 index counts too, having a total of 32002 indices).


Then you can use the array in a GET statement.
Code:
GET (0, 0)-(319, 199), Buffer
Logged
stylin
Ancient QBer
****
Posts: 445


« Reply #18 on: November 25, 2005, 09:40:31 AM »

Quote from: "Neo"
Dim Buffer(32001) As Integer

Nope. The correct number of subscripts is 32263.

Look http://forum.qbasicnews.com/viewtopic.php?t=10943&start=26 for more info.
Logged

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



WWW
« Reply #19 on: November 25, 2005, 09:43:55 AM »

LOL

Then like 100 QB games are bad coded and don't work  :roll:

You need 4 bytes for dimmensions (two stored 16 bits number) and a byte per pixel in a sprite for mode 13h. The calculation Neo did is completely correct. You have 64000 pixels that take 64000 bytes. Add 4 bytes more for dimmensions. As you are using integers, divide by 2. Substract 1 and you get 32001.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
stylin
Ancient QBer
****
Posts: 445


« Reply #20 on: November 25, 2005, 10:01:34 AM »

Quote from: "na_th_an"
LOL

Then like 100 QB games are bad coded and don't work  :roll:

Then, like, the QB documentation is wrong. Take your pick.
Logged

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



WWW
« Reply #21 on: November 25, 2005, 10:24:45 AM »

The QBasic documentation describes the general formula in which the PMAP value has to be taken in account. It works in excess guaranteeing (sp?) that the arrays will be big enough. The (x*y+4)/2 formula fails when x*y is odd. For example if you have a 5x5 image it would need 25 bytes + 4 = 29 bytes, but 29 / 2 = 14. If you DIM sprite%(13) you are not reserving the needed amount of memory.

The QB help is a "failsafe" solution providing a decent array size which will work for every videomode, but it's not the most efficient formula, memory-wise.

Anyway, following the formula:

Code:
4 + INT(((x2 - x1 + 1) * (bits-per-pixel-per-plane) + 7)/8) * planes * ((y2 - y1) + 1)


You get:

Code:
4 + INT (((319 - 0 + 1) * 8 + 7) / 8) * 1 * (199 - 0 + 1)


solving...

Code:
4 + INT ((320 * 8 + 7) / 8) * 200

4 + INT (2567 / 8) * 200

4 + 320 * 200

4 + 64000

64004


You know, this time we get the same results.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Neo
Na_th_an
*****
Posts: 2150



« Reply #22 on: November 25, 2005, 10:44:41 AM »

Quote from: "Stylin"
Nope. The correct number of subscripts is 32263.
Look http://forum.qbasicnews.com/viewtopic.php?t=10943&start=26 for more info.

Do not question me like that again. I don't like it.
In that case, you tell me what you need those 524 extra bytes for.

Oh well... I said enough... I dont feel like repeating what Nath said.
Logged
stylin
Ancient QBer
****
Posts: 445


« Reply #23 on: November 25, 2005, 10:49:09 AM »

Quote from: "na_th_an"
The QB help is a "failsafe" solution providing a decent array size which will work for every videomode, but it's not the most efficient formula, memory-wise.

I see. My apologies. I guess then it would help if the QB help would be (a little) clearer in its documentation. It's situations like these that I remember why I work in FreeBASIC now.

Quote from: "Neo"
Do not question me like that again. I don't like it.

I didn't question you.
Quote
In that case, you tell me what you need those 524 extra bytes for.

I would if I could. Seemed rather odd to me, and apparently, QB doesn't even know. :roll:
Logged

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



WWW
« Reply #24 on: November 25, 2005, 12:02:32 PM »

No need to apologise. Now I realise that my "LOL" shouldn't be there. It's me who apologises.

I think that you got the big number 'cause you used 320 and 200 instead of 319 and 199. The formula considers coordinates, not measurements.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
stylin
Ancient QBer
****
Posts: 445


« Reply #25 on: November 25, 2005, 02:32:00 PM »

Yes, I just noticed that as well. I need to stop posting at 6am - or stay clear of the QB forums.
Logged

stylin:
axipher
Ancient Guru
****
Posts: 544



« Reply #26 on: November 25, 2005, 04:12:26 PM »

well 32001 works fine, but when it fills, it still flickers... but otehr then that it works
Logged
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #27 on: November 25, 2005, 07:27:57 PM »

The only way to really stop the flickering, is to use double beffering. You can make it less noticable, by adding a strategic Wait &H3DA,8 though. Have you considered using a library?
Logged
Neo
Na_th_an
*****
Posts: 2150



« Reply #28 on: November 25, 2005, 08:16:15 PM »

Code:
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
Logged
axipher
Ancient Guru
****
Posts: 544



« Reply #29 on: November 25, 2005, 11:37:27 PM »

double buffering, well i fixed it, i simply put the PUT statement in rite before the x and y values are changed which un-draws the old img, then in the SUB where it draws it, then it draws it, and it doesnt have to change the background at all, so no more flickering, yay.

anyway, for future reference in case i need it, wat is this double buffering u speak of, i read a tutorial on it, but didnt quite understand, and the
Code:
WAIT &H3DA, 8
WAIT &H3DA, 8, 8

wat on earth does that do, u said its a wait period, is it like negative or sumtin, or wat, well im probably getting anoying, in like 6 days ive posted about 40 out of my 48 posts, and there all to do with one simple thing im trying to do, but everyone is so helpful, its awsome, good thing i looked on my old cpu wat programs it had before i formatted it and backed the qb4.0, then found a forum site for it, it all worked out, plus old school programming in dos owns anyway
Logged
Pages: 1 [2] 3
  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!