Qbasicnews.com

Full Version: About BLOAD/BSAVE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the code to save a 320x200 screen:

Code:
DEF SEG = &HA000
BSAVE "20x20", 0, 32000
DEF SEG

And this is the code to load it back onto the screen:

Code:
DEF SEG = &HA000
BLOAD "20x20", 0
DEF SEG

But what if I want to load it into a variable rather than the screen? Does this work?

Code:
DIM a
DEF SEG = VARSEG(a)
BLOAD "20x20", 0
DEF SEG
Quote:This is the code to save a 320x200 screen:

Code:
DEF SEG = &HA000
BSAVE "20x20", 0, 32000
DEF SEG

I think that it's 64000 and not 32000 cause these are bytes and not integer:

Code:
DEF SEG = &HA000
BSAVE "20x20", 0, 64000
DEF SEG

Here's the piece of QB help refering to BSAVE:

[Image: bsave.jpeg]
Right, I forgot to mention I was experimenting with only half the screen. Anyways, the problem is this:

AliphaX: they're for accessing memory.. familiar with memory layout? (segments, offsets)
SlayersCafe2: a little
SlayersCafe2: Plasma just helped me a little
SlayersCafe2: so i understand how to use them with BSAVE
SlayersCafe2: so far i have this
SlayersCafe2: if i wanna save half the screen to a variable, i do this
SlayersCafe2:
Code:
DIM a(31999 + 4) as integer
DEF SEG = &HA000
BSAVE "image.dat", VARPTR(a), 32000
SlayersCafe2: the + 4 in the DIM is for the x,y coords, which i dont quite understand why i need them
SlayersCafe2: the def seg goes to the screen port
SlayersCafe2: and the VARPTR(a) sets the offset for the variable
SlayersCafe2: 32000 is the amount of bytes ill need to save all 320x200 pixels
AliphaX: that's kinda off
SlayersCafe2: which parts? help me understand please
AliphaX: the + 4 is for the width and height.. they need to be stored in the array, without them, PUT wouldn't know how big the image is
SlayersCafe2: how do i do that?
AliphaX: and actually, it is + 4 BYTES.. an integer is 2 bytes.. so really just + 2
SlayersCafe2: yeah but i need 2 integers
SlayersCafe2: x and y
SlayersCafe2: thats what PLasma said and it makes sense
AliphaX: yes, 1 integer for the x, 1 for the y.. so that's + 2..
SlayersCafe2: but an integer is 2 bytes
SlayersCafe2: so its 4 bytes altogether
SlayersCafe2: right?
SlayersCafe2: 2 integers * 2 bytes each = 4 bytes
AliphaX: the DIM statement creates arrays of integers, not arrays of bytes
SlayersCafe2: oh
SlayersCafe2: ok
SlayersCafe2: so its + 2?
AliphaX: yeah..
SlayersCafe2:
Code:
DIM a(31999 + 2) as integer
DEF SEG = &HA000
BSAVE "image.dat", VARPTR(a), 32000
SlayersCafe2: thyast the crrect code?
AliphaX: um..
AliphaX: are you saving directly off the screen? (you're not GET'ting the array first)
SlayersCafe2: yes, saving directly off the screen.. is it better to GET it?
AliphaX: well no, but why do you even need the array then?
SlayersCafe2: to save the screen to a variable for later use
SlayersCafe2: wait
SlayersCafe2: this is what i originally wanted to do
SlayersCafe2: save the screen to a file
SlayersCafe2: load another program... that program loads the file into a variable
AliphaX: wouldn't you just be putting it back on the screen again? what else could you do? 'cause I would just BLOAD directly to the screen
SlayersCafe2: the problem with that is i want to use this method to get 16x20 images off the screen in certain spots
SlayersCafe2: and then load them into a variable next time so i can move them around the screen and such
SlayersCafe2: the problem happens when i try to specify where to put the image when i load it
SlayersCafe2: it goes right onto the screen on the first line, in a straight line (top row) instead of a 16x20 array of pixels
SlayersCafe2: im probably using the wrong method, yes?
in the online help.
bsave, bload, get, and put.

although i'd recommend putting them in load/save/put/get functions so that you can upgrade them to ASM functions in libs later on.
Yeah, I'd like to learn ASM. But I don't know if I'll have the time or the energy... I almost learned it once... hard as hell it seemed.
Quote:Yeah, I'd like to learn ASM. But I don't know if I'll have the time or the energy... I almost learned it once... hard as hell it seemed.

I really don't like misconceptions. ASM is not hard. Its just a lil different coding-wise. You could easily translate an existing QB code in ASM is you're experienced enough. Experience is what matters. And that experience is what I don't have.

;*)