07-03-2004, 05:54 PM
Ok, so I made a sprite with PP256 and now I'm trying to load it with the well-known code:
But at this point:
I'm getting a "Subsrcipt out of range" error. This is a really simple question, but I just couldn't get it right...Anyone?
Code:
SUB InitImageData (FileName$, ImageArray())
IF FileName$ <> "" THEN
'***** Read image data from file *****
'Establish size of integer array required.
FileNo = FREEFILE
OPEN FileName$ FOR BINARY AS #FileNo
Ints = (LOF(FileNo) - 7) \ 2
CLOSE #FileNo
REDIM ImageArray(1 TO Ints)
'Load image data directly into array memory.
DEF SEG = VARSEG(ImageArray(1))
BLOAD FileName$, 0
DEF SEG
ELSE
'***** Read image data from DATA statements *****
'Establish size of integer array required.
READ IntCount
REDIM ImageArray(1 TO IntCount)
'READ image DATA into array.
FOR n = 1 TO IntCount
READ x
ImageArray(n) = x
NEXT n
END IF
END SUB
SUB MakeImageIndex (ImageArray(), IndexArray())
'The index will initially be built in a temporary array, allowing
'for the maximum 1000 images per file.
DIM Temp(1 TO 1000)
Ptr& = 1: IndexNo = 1: LastInt = UBOUND(ImageArray)
DO
Temp(IndexNo) = Ptr&
IndexNo = IndexNo + 1
'Evaluate descriptor of currently referenced image to
'calculate the beginning of the next image.
x& = (ImageArray(Ptr&) \ 8) * (ImageArray(Ptr& + 1)) + 4
IF x& MOD 2 THEN x& = x& + 1
Ptr& = Ptr& + (x& \ 2)
LOOP WHILE Ptr& < LastInt
LastImage = IndexNo - 1
'Copy the image index values into the actual index array.
REDIM IndexArray(1 TO LastImage)
FOR n = 1 TO LastImage
IndexArray(n) = Temp(n)
NEXT n
END SUB
REDIM Sprites(1 TO 1)
REDIM SpritesIndex( 1 TO 1)
InitImageData "C:\QB\PP256\IMAGES\HL.put", Sprites()
MakeImageIndex Sprites(), SpritesIndex ()
But at this point:
Code:
Temp(IndexNo) = Ptr&
I'm getting a "Subsrcipt out of range" error. This is a really simple question, but I just couldn't get it right...Anyone?