Qbasicnews.com
December 08, 2019, 06:03:01 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: poke and pset  (Read 6476 times)
tox_von
New Member

Posts: 8


« on: September 29, 2008, 11:40:19 AM »

is there any way to use poke or pset without using 4 for loops(one for x,y of sprite and map theres too much lag)

using data.get put this can be done with two for loops and theres no lag but i want to store tiles in a dat file and this cant use data statements i dont think.

im using vics tutorials as a base for graphics
Logged
Clippy
Member
*
Posts: 84



« Reply #1 on: September 29, 2008, 01:09:25 PM »

Is this a FB question? There is a section for that stuff.

PSET only needs X and Y loops. Color would need some kind of data read because you generally cannot define it in a loop.  I don't know what you mean by Data files. You can make data files using WRITE # to hold comma separated variables just like DATA statements.

What has a map got to do with the tiles? You can GET and BSAVE tile data in an array. Creating each tile at program start or during a program will definately slow things down. Try making the tiles first and saving them in BSAVE. Then you can BLOAD them at program start into a graphics array. You can store several tiles in one Array by indexing them.

Ted
« Last Edit: September 29, 2008, 03:55:27 PM by Clippy » Logged

tox_von
New Member

Posts: 8


« Reply #2 on: October 04, 2008, 10:09:53 AM »

i figured out the bsave way but i got a dos memory error and it crashes. how do i stop this?

i couldnt find any examples of how to use writeto make a sprite/tile using the pset read get thing that makes sprites. how do i?
Logged
Clippy
Member
*
Posts: 84



« Reply #3 on: October 04, 2008, 01:07:19 PM »

Memory use depends on the size of the program and the size of any Arrays. I usually use a graphics array of up to 27K. It can be reused for a number of BLOADs and PUTs.

If the module code is large, try breaking some of it up into real SUB procedures.
QB4.5 has a better track record than Qbasic for memory problems. You can also break the program into several modules and use CHAIN or LINK them together.

How large is the BAS file?

Ted
Logged

tox_von
New Member

Posts: 8


« Reply #4 on: October 04, 2008, 01:21:42 PM »

no just using sample in help and changed it to one sprite only
Logged
Clippy
Member
*
Posts: 84



« Reply #5 on: October 05, 2008, 01:06:13 PM »

Post your code and explain more please.
Logged

Clippy
Member
*
Posts: 84



« Reply #6 on: October 06, 2008, 03:45:53 PM »

Waddaya mean? Just SAVE the BAS file AS Text readable by other programs. Open it  Notepad by right clicking it and EDIT in the mouse menu! I don't want to download files.

Ted
Logged

tox_von
New Member

Posts: 8


« Reply #7 on: October 07, 2008, 04:00:21 AM »

This is what i did for the bsave,bload thing and it causes the dos memory error sometimes 2nd or third load.


BSAVE

DIM sprite1(1 TO 675)
SCREEN 13

FOR y = 1 TO 13
FOR x = 1 TO 15
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (1, 1)-(15, 13), sprite1

DEF SEG = VARSEG(sprite1(1))
BSAVE "sprite1.GRH", VARPTR(sprite1(1)), 2700
DEF SEG


'grass
DATA 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10,10,02,10,10,10
DATA 10,10,10,10,10,10,10,10,10,10,02,10,10,10,10
DATA 10,10,10,02,10,10,10,02,10,10,02,10,10,10,10
DATA 10,10,10,10,02,10,02,10,10,10,10,10,10,10,10
DATA 02,10,10,10,02,10,02,10,10,10,02,10,10,10,10
DATA 10,02,10,10,02,10,02,10,10,02,10,10,02,10,10
DATA 10,10,02,02,10,02,10,10,10,02,10,02,10,10,10
DATA 10,10,10,10,10,10,10,10,10,02,10,02,10,10,10
DATA 02,02,10,10,02,10,10,10,02,02,02,10,10,10,10
DATA 10,10,02,02,10,10,10,10,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,02,02,10,10,10,10,10,10,10
DATA 10,10,10,10,10,10,02,10,10,10,10,10,10,10,10

BLOAD

DIM sprite1(1 TO 60)
SCREEN 13
DEF SEG = VARSEG(sprite1(1))
BLOAD "sprite1.GRH", VARPTR(sprite1(1))
DEF SEG             
PUT (100, 10), sprite1


Logged
Ralph
Ancient Guru
****
Posts: 544


« Reply #8 on: October 07, 2008, 02:19:01 PM »

tox_von :

I ran your program, exactly as you posted it.  The BLOAD program ran fine the first time, than it gave me an error, and I had to close QB down and start anew.

Now, I changed your first line from
DIM sprite1(1 TO 60)
to
DIM sprite1(1 TO 675)
and it ran fine eight times in a row!


Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
tox_von
New Member

Posts: 8


« Reply #9 on: October 08, 2008, 09:32:44 AM »

thanks i tried this and it worked

is this the best/stablist  way to do tiles or is there some other way more common people use?


i still dont know this question.
i couldnt find any examples of how to use write to make a sprite/tile using the pset read get thing that makes sprites. how do i?
Logged
Ralph
Ancient Guru
****
Posts: 544


« Reply #10 on: October 08, 2008, 02:24:02 PM »

I am not an expert on the necessary size for sprite-saving arrays, and, if you are running out of memory and have many sprites in arrays, you will have to look up the available information on this, which is great.  So, from my limited use and knowledge, here are some beginning pointers:

In your BSAVE code snippet, you dimensioned your array as
DIM sprite1(1 TO 675)
Since you are saving a sprite that is 15 values wide and 13 values high, your array only needs to have 15*13 = 195 elements.  So, I used, with perfect results:
DIM sprite1(1 to 195)

Next, in your BSAVE line, you show:
BSAVE "sprite1.GRH", VARPTR(sprite1(1)), 2700
Since the array now only has 195 elements, its length is only 195+4=199 bytes long, so, I used, with perfect results:
BSAVE "sprite1.GRH", VARPTR(sprite1(1)), 199
Note: If you use the length as a one of the values 195, 196, 197, or to 198, you will get an incomplete sprite when you BLOAD the sprite array!

In your BLOAD snippet, of course, you must also dimension your array to match the dimension used in the BSAVE snippet, so, the DIM line must be:
DIM sprite1(1 to 195)

Also, you must not forget to include, in the BLOAD snippet, the line,
SCREEN 13
somewhere before you use any graphics commands.  I like to include it a the very beginning, as the first line.
 
As to your two questions,
"is this the best/stablist  way to do tiles or is there some other way more common people use?"
and
" couldnt find any examples of how to use write to make a sprite/tile using the pset read get thing that makes sprites. how do i?"
I don't really know what the answers might be.  I'm sure that someone else will be able to reply to that.
« Last Edit: October 08, 2008, 02:28:29 PM by Ralph » Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
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!