Qbasicnews.com

Full Version: Help With Graphics BLOAD BSAVE
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey, I would like to know about freebasic with bitmap images, not .bmp files.

I remember some documents that cover read data statements to load a bitmap to the screen and also working with BLOAD and BSAVE to save the data to a file in binary form. I also remember that qbasic supported page filpping with screen mode 7 and screen mode 13 allowed higher possible colors with no page filpping.

After going over the graphics doc included with freebasic, I'm finding it a little hard to follow for this method of making Side Scrollers, RPGs, etc...has this way been tossed aside do to coding with DirectX and OpenGL?

With that being said, can freebasic allow you to do it the old way and if so, what changes do you need to make as a programmer to the code old code for it to compile correctly with fbc?

1: BLOAD and BSAVE an image file such as 10x10 with Read Data.
2: Which screen mode must be set and what information needs to be added for seting up the screen mode?

Code:
qbasic code that worked

screen 13 '320x200
aSize = 10 * 10 / 2 + 1
dim image(aSize) as integer

x1=10
y1=10

'place bitmap on screen
for y = 1 to y1
for x = 1 to x1
read z
pset (x,y)z
next y
next x

'grab bitmap
get (1,1)-(10,10),image
bSize = 10 * 10 + 4

'save bitmap
DEF SEG = VARSEG(image(0))
bsave "image.pix", VARPTR(image(0)), bSize

Data "0,0,0,0,0,0,0,0,0,0" 'etc...10 across 10 down
....
....
....
Data "0,0,0,0,0,0,0,0,0,0"

Then you would make another file, use the BLOAD to load that image.pix into memory and on to the screen etc...

My question is how do you convert this qb code to make it work on fbc?

Thanks...
I don't know what more I could add for getting help on this.

I'd get an error message on the compiler expression expected for SEG.

Is the BLOAD BSAVE setup of diffrent or what could be wrong if the code seems to look fine?
Firstly...be patient. You didn't get through an evening. People have real lives, and are helping you out for no apparant benefit.

Secondly, as I know, the inbuilt graphics functions fully support QB's formats. The screen modes are emulated perfectly, and therefore, you can pretty much use the same code. I dont have time to look over it, but have you actually tried to compile it? What errors do you recieve? What version of freebasic or FBIDE? etc. etc. this is the kind of information you need to give.
From the small portion of code you posted, here are the only changes I think should make it to work:
  • Change "image" with "image(0)" as target for GET. This applies also to PUT if you use it later in your code. When FB 0.12 will be out, this limitation will not be present and you'll be able to use just "image" as in QB.
  • BSAVE has a bug in FB 0.11, as the compiler expects no commas to separate arguments. This has been fixed in CVS, but until 0.12 is officially out you should use
    Code:
    ' Note no commas separate the arguments!
    BSAVE "image.pix" VARPTR(image(0)) bsize
Oh, and in FB screen 13 can have any number of offscreen pages... check the docs on the SCREEN function.
Achieving old-school scrolling in FB is easy: PUT supports clipping, transparency and is MMX-optimized, and you can use SCREENSET/SCREENCOPY to achieve double-buffering.
First off,

I didn't add a second reply until one day relaps. Which in turn about 21 views have been seen with no reply.

Second,

that statement about people having real lives is sort of insulting to me. I realize everyone has jobs and I work around my busy days. Learning freebasic is a hobby to me since it got me back interested in how you coded with qb.

Third, yes I tried to compile it, what kind of question is that?

I have the FB 0.11
since this FB is in test I didn't realize people would get bent out of shape helping. Helping shouldn't be viewed as a task rather as a friendly suggestion to help others understand how something works so the whole community of programmers can do something fun.

Thort those in such ways is simply saying your not welcome and we don't care if you can't understand something even if you spent a few days of your spare time. When someone ask me for help I do what I can and don't give them a message to make them feel low.

Lillo

Thanks for your help
I'll go over the example and read over the DOCs again.

I'm just trying to figure out what works and doesn't with freebasic so I can start putting together something fun. Even if it's a simple game to someone that has already learn how to do it with freebasic.

Again thanks.
Well I tried the suggested changes. When compile with fb0.11
I get this error

tester.bas (30):error 10: Expected '=', found : 'SEG'

here is the code without changes.
Code:
REM save a 10 x 10 bitmap to a binary file.

SCREEN 13
arraySize = 10 * 10 / 2 + 1
DIM image(arraySize)  AS INTEGER
xl = 10: yl = 10

DATA 4,4,4,4,4,4,4,4,4,4
DATA 4,7,8,8,8,8,8,8,7,4
DATA 4,8,7,7,8,7,8,8,7,4
DATA 4,7,7,8,7,8,7,8,7,4
DATA 4,7,8,7,8,7,8,8,7,4
DATA 4,7,8,8,7,8,8,8,7,4
DATA 4,7,8,7,8,7,8,8,7,4
DATA 4,7,8,7,7,8,8,8,7,4
DATA 4,7,8,7,8,8,8,8,7,4
DATA 4,4,4,4,4,4,4,4,4,4


FOR y = 1 TO yl
FOR x = 1 TO xl
READ Z
PSET (x, y), Z
NEXT
NEXT

GET (1, 1)-(10, 10), image
BsaveSize = 10 * 10 + 4
DEF SEG = VARSEG(image(0))
BSAVE "image.gfx", VARPTR(image(0)), BsaveSize
CLEAR
END
here is the code with changes
Code:
REM save a 10 x 10 bitmap to a binary file.

SCREEN 13
arraySize = 10 * 10 / 2 + 1
DIM image(arraySize)  AS INTEGER
xl = 10: yl = 10

DATA 4,4,4,4,4,4,4,4,4,4
DATA 4,7,8,8,8,8,8,8,7,4
DATA 4,8,7,7,8,7,8,8,7,4
DATA 4,7,7,8,7,8,7,8,7,4
DATA 4,7,8,7,8,7,8,8,7,4
DATA 4,7,8,8,7,8,8,8,7,4
DATA 4,7,8,7,8,7,8,8,7,4
DATA 4,7,8,7,7,8,8,8,7,4
DATA 4,7,8,7,8,8,8,8,7,4
DATA 4,4,4,4,4,4,4,4,4,4


FOR y = 1 TO yl
FOR x = 1 TO xl
READ Z
PSET (x, y), Z
NEXT
NEXT

GET (1, 1)-(10, 10), image(0)
BsaveSize = 10 * 10 + 4
DEF SEG = VARSEG(image(0))
BSAVE "image.gfx" VARPTR(image(0)) BsaveSize
CLEAR
END
Still same error.

Again, thanks for any help.
remove you varseg commands FB is 32 flat memorey not real mode
there no such thing as segments anymore.

also remove DEF SEG because like i said there no much thing as segment in FB.

this should all be explained in lillo documentation on bsave and bload.
Quote:First off, I didn't add a second reply until one day relaps

Second, that statement about people having real lives is sort of insulting to me.

Third, yes I tried to compile it, what kind of question is that?

1. Five hours between posts is not one "elapsed" day. Chill out, calm down, take a deep breath, go for a walk.

2. Most everyone else in the freeBASIC forum here could be considered hobbiets also. This is not a pay-for-use helpdesk system, we all help each other out when we know the answer.

3. You asked how to convert the code. You received an answer that QB code should be compatible and not need converting and were asked if you had already tried compiling it.
If you make a search for lillo and documentation in this forum, you should find a variety of convenient formats that the documentation is availible in.

It seems obvious you have not read the manual in too much detail, this kind of stuff is written in there.
Well thanks for the help.

Although the time stamp is wrong and I know there is 24 hours in a day.

Anyhow all I have is qbasic and the freebasic. I know of no other way to test the program code from qbasic to freebasic without trying to compile it. The use of the word convert "might" have been miss leading and I should have used change.

As for the Doc, the only ones I have are the ones that came with the freebasic. So how was I to know there was a manual that Lillo wrote in the first place.

Well it doesn't matter, I'm calm and have been calm.

I'll do a search for this manual.

Again thanks
Pages: 1 2