Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BSave/BLoad

Status
Not open for further replies.

Stainnd

Programmer
Jul 9, 2001
65
US
Following the advice of many people, I've decided to try and implement BSave/Bload in my mapping technique (read my last post if you're not sure). Anyway, to get straight to the point...I wrote a program to BSave. Then I tried BLoading it in another program. However my 10x10 sprite only loaded 10x3. So I tried BLoading in the same program, and it loaded the entire sprite. What's up w/ this? I included the code for both programs.

Program 1:

DIM floor(50)
CHDIR "C:\qbasic\GFXFiles"
ON ERROR GOTO Handler
SCREEN 13
FOR y = 1 TO 10
FOR x = 1 TO 10
READ clr
PSET (x, y), clr
NEXT: NEXT
GET (0, 0)-(10, 10), floor
CLS
DEF SEG = VARSEG(floor(0))
CHDIR "gfx"
BSAVE "floor.gfx", 0, 50
DEF SEG

DATA 07,08,08,08,08,08,08,08,08,08
DATA 08,07,07,07,07,07,07,07,07,07
DATA 08,07,07,01,07,07,07,07,07,07
DATA 08,07,07,02,07,07,07,07,07,07
DATA 08,07,07,03,07,07,07,07,07,07
DATA 08,07,07,04,07,07,07,07,07,07
DATA 08,07,07,05,07,07,07,07,07,07
DATA 08,07,07,06,07,07,07,07,07,07
DATA 08,07,07,08,07,07,07,07,07,07
DATA 08,07,07,09,07,07,07,07,07,07

Handler:
SELECT CASE ERR
CASE 76
MKDIR "gfx"
RESUME
END SELECT


Program 2:

DIM floor(50)
SCREEN 13
DEF SEG = VARSEG(floor(0))
CHDIR "C:\qbasic\GFXFiles\gfx"
BLOAD "floor.gfx", 0
DEF SEG
PUT (0, 0), floor, PSET


Please help -Mike
 
Make your floor variable larger. Try DIM floor(120) and change the BSAVE line to BSAVE "floor.gfx",0,120
Alos, if you are drawing with two loops starting at 1, you need to start the GET command at 1,1 also.
I don't think you need the DIM line in program two.
 
As far as I know, there's a way to figure out how many bytes you will need for your sprite depending on the screen and the sprite dimension.

4+(((((x2-x+1)/biteXpixel)+7)*plans*(y2-y+1))/8)

For exemple, a sprite that is 10x10 in screen 7 whould look like this:

numberOfBites = (((10-1+1)/8)+7)*4*(10-1+1)
NumberOfBytes = (numberOfBites/8)+4 '4 bytes for Qbasic

You should also add PRINT ERR into your Handler sub to get track of possible other errors.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top