Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: Rokkuman on December 14, 2003, 05:08:44 PM



Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 05:08:44 PM
I compiled my sprite editor. And at first it was giving me String Space Corrupt errors whenever I tried to load a file (not good). So I added Dynamic before it all, and now, when I try to load a file, the sprite editor just closes out. WTF!


Title: *grrrowl* :)
Post by: Anonymous on December 14, 2003, 05:25:51 PM
are you ABSOLUTELY sure your writing ALL data to the exact right place in memory? If so, i have no idea... i just know when i get that its USUALLY that. ;)


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 05:27:36 PM
Uh, I don't really know how to write memory to any other places...


Title: *grrrowl* :)
Post by: Anonymous on December 14, 2003, 05:32:11 PM
well i mean say ur loading a sprite to Sprite(1000).

if you do
Code:
defseg = varseg(spirte())
bload "sprite.spr", varptr(sprte(0))


or any number of simple typos like that, it can wreak major havoc... even renderins your prog unsaveabl :(

next tip: SAVE OFTEN :)


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 05:34:14 PM
Nope. If there was a typo like that, it wouldn't run in the IDE well either.

This problem only occurs when it's COMPILED though.


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 05:36:40 PM
ALRIGHT, the problem is that when I add the '$DYNAMIC bit, I get a subscript out of range error in the IDE, so when it's compiled, it just shuts off.

When '$DYNAMIC is gone however, it works fine, but won't compile.

Any ideas?


Title: *grrrowl* :)
Post by: na_th_an on December 14, 2003, 06:29:26 PM
We need scope. Post the exact SUB where this happens, post also the declaration of the array.


Title: *grrrowl* :)
Post by: barok on December 14, 2003, 07:34:27 PM
kinda reminds me of my prog i'm working on.  works fine in ide, but when i compile it won't work.  during the compiling process, it says there's over 900 bugs  :o


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 09:04:34 PM
Here's where it happens.
Code:

SUB PutSprite (X, Y, Image(), Index)

FOR A = 0 TO Image(1, Index) 'ERROR OCCURS HERE
        FOR B = 0 TO Image(0, Index) - 1
                IF GetPixelImage(B, A, Image(), Index) <> 13 THEN
                        PutPixel X + B, Y + A, GetPixelImage(B, A, Image(), Index)
                END IF
        NEXT
NEXT


END SUB


And here are the only two arrays that are interacted with by that sub.

Code:

DIM SHARED EditSprite(2000, 5)
DIM SHARED Sprite(2000, 5)


Title: *grrrowl* :)
Post by: Anonymous on December 14, 2003, 09:38:12 PM
It might help to have sample input data, and also to know what the 'index' sub itself does, too...


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 09:40:32 PM
"index" isn't a sub. It's a variable that determines which image to display from the array. And it's not going that high. As I said, it works perfectly in the IDE, but faggs up in the compilation.


Title: *grrrowl* :)
Post by: Anonymous on December 14, 2003, 09:48:32 PM
<----- Dumbass.

i meant to say 'image' but thats an array, anyways :P

maybe are your sprites not saved -AS INTEGER- ? thats one of the only things i could think of.

and... your sprites arent get, put compatible, are they? cause i thought they could only have one dimension


Title: *grrrowl* :)
Post by: Rokkuman on December 14, 2003, 11:28:23 PM
Nope, not GET and PUT compatible. And I tried putting DEFINT A-Z at the top, but I kept getting retarded "paremeter" errors.

Please help me someone. I've come too far in this program..


Title: *grrrowl* :)
Post by: Neo on December 15, 2003, 06:15:46 AM
Shouldn't you add a '-1' after the FOR A = 0 TO .... line? ;) Just saying...

Like this:
Code:
FOR A = 0 TO Image(1, Index) - 1 'ERROR OCCURS HERE


:D

Also, if you like info about the GET/PUT format, look here:
Code:
GET PUT Format
Offset  Type     Description
  0      Int      Width of the sprite * 8 (= x)
  2      Int      Height of the sprite (= y)
  ?      Byte     Pixel data, starts with upperleft corner, advancing right.


EDIT: wt is GetPixelImage ??? Btw, to make your code slightly faster, store the result of this function in a variable.


Title: *grrrowl* :)
Post by: Rokkuman on December 15, 2003, 08:24:58 AM
Quote from: "Neo"
Shouldn't you add a '-1' after the FOR A = 0 TO .... line? ;) Just saying...

Like this:
Code:
FOR A = 0 TO Image(1, Index) - 1 'ERROR OCCURS HERE


:D

Didn't work...

Quote

Also, if you like info about the GET/PUT format, look here:
Code:
GET PUT Format
Offset  Type     Description
  0      Int      Width of the sprite * 8 (= x)
  2      Int      Height of the sprite (= y)
  ?      Byte     Pixel data, starts with upperleft corner, advancing right.


EDIT: wt is GetPixelImage ??? Btw, to make your code slightly faster, store the result of this function in a variable.

Get pixel image is what gets the color of the pixel. The problem is that it is giving me subscript out of range, ONLY when I add '$DYNAMIC.


Title: *grrrowl* :)
Post by: Neo on December 15, 2003, 09:23:11 AM
Hrmm. Ok.

Please post what the Image() array actually is and what it contains. Furthermore, please post the full code of the GetPixelImage and PutPixel routine.

This way, we might be able to find you a solution :)

BTW: Please choose an other topic-title next time ;)


Title: *grrrowl* :)
Post by: na_th_an on December 15, 2003, 11:52:10 AM
The error comes in array Image, which is received as a parameter inside the SUB. Now you show me two SHARED arrays, so I understand that you are calling that sub passing one of those two SHARED arrays as a parameter...

Then, why are those variables SHARED, if you are passing them as parameters? This can be the error.


Title: *grrrowl* :)
Post by: Rokkuman on December 15, 2003, 12:07:27 PM
Who to the wha' to the how?

Ok, let's see if my inferior brain can comprehend that. :)

The reason that it's SHARED is because whenever I don't share it, the variable isn't received in the subs. I hope that helped.

Neo: I'll get that code once I get back home. And sure, I'll change the title. :)


Title: *grrrowl* :)
Post by: na_th_an on December 15, 2003, 12:26:00 PM
If it is shared, you don't need to pass it as a parameter.


Title: *grrrowl* :)
Post by: Rokkuman on December 15, 2003, 04:26:05 PM
Nooooooooooooooooooo... :)

Ok, "Sprite" and "EditSprite" are dimmed as arrays

In the sub, that perimeter is used to input WHICH array you're using. In this program, Sprite and EditSprite are being used.

But the thing is, I'm tried DIMMING both sprites at unrealistic amounts, and it still keeps pimping on me...


Title: *grrrowl* :)
Post by: na_th_an on December 15, 2003, 05:08:22 PM
Well, then don't DIM them as SHARED. Why sharing them if you are gonna pass them as parameters?

Or try ("""try""") this:

Code:
DEFINT A-Z

'$DYNAMIC

DIM SHARED Sprite(0, 0)
DIM SHARED EditSprite(0, 0)

REDIM Sprite(2000, 5)
REDIM EditSprite(2000, 5)


This could be a memory problem as well. 2001x6x2x2 = 48024 bytes. Maybe you are running outta mem.


Title: *grrrowl* :)
Post by: Rokkuman on December 15, 2003, 05:29:55 PM
Well, I tried that, and it didn't do anything.

I also reduced the arrays to (10,1) and it STILL gave me that error. BTW, this seems to be happening whenever the program asks for anything having to do with an array...

Haminahaminahaminahaminahaminahaminahaminahaminahamina.


Title: *grrrowl* :)
Post by: adosorken on December 15, 2003, 06:23:44 PM
Quote from: "barok"
kinda reminds me of my prog i'm working on.  works fine in ide, but when i compile it won't work.  during the compiling process, it says there's over 900 bugs  :o

I know this isn't answering the main question in the thread, but hellwifit :)

Split your program into modules. You have likely exceeded the code size for one segment.


Title: *grrrowl* :)
Post by: na_th_an on December 15, 2003, 08:08:43 PM
Lol! Rockuman, you are having exactly the same problems that Clarita and me are having with her new engine... We are having to do lotsa turnarounds.

Yeah, code size, and too much data allocated. Trust me, screw that shared stuff and pass the arrays as a parameters everywhere


Title: *grrrowl* :)
Post by: Agamemnus on December 15, 2003, 08:35:40 PM
hmmmmmmmm..........

What is the maximum size of your sprites? 40x50?

Why is your x and y the first two pixels?

Code:

DIM SHARED editSprite(1999, 4)
DIM SHARED sprite(1999, 4)
DIM SHARED imageParameters(1, 4)

SUB putSprite (x, y, image(), index)
DIM dy AS INTEGER, dx AS INTEGER
FOR dy = 0 TO imageParameters(0, index)
FOR dx = 0 TO imageParameters(1, index)
IF getPixelimage(x, y, image(), index) <> 13 THEN '13 = mask color
putPixel x + dx, y + dy, getPixelImage(dx, dy, image(), index)
END IF
NEXT dx, dy
END SUB


Title: *grrrowl* :)
Post by: Rokkuman on December 16, 2003, 12:47:44 PM
I have no idea what you're asking with "Why are the first pixels x and y"... If you're asking about the first two numbers in the array, they're reserved fro height and width.

It's made for 60x60, but I reduced the DIM size. And the size I'm using at the moment is 35x35, so there shouldn't be a problem.

I'll try adding DIM in the sub as soon as I get home.


Title: *grrrowl* :)
Post by: Agamemnus on December 16, 2003, 03:20:15 PM
point is that you mite be using them as pixels as well...