04-14-2005, 11:52 AM
I want to know which libraries or routines I should use to store sprites into an integer array(s) and from what type of image file format(s) these sprites should be loaded. How to load and store sprites? I can't port Pixel Plus 256 sprite loading subs to FB since one of them contains DEF SEG statement and I don't know if that can be fixed or how. I wouldn't mind if someone could explain me in more simple terms why DEF SEG is not supported and not needed in 32-bit mode.
I so don't want to abandon Pixel Plus 256 so I need a routine that can load that format(PUT) into an integer array in FB.
I want to avoid using BMP images which have all the sprites or tiles inside them and then having to use some annoying way to load and paste sprites onto screen. I'll be honest, I don't like the way SDL solves the sprite issue(at least the way BasetFurry does it in his tutorial).
Here are the two subs from Pixel Plus 256 I mentioned if you don't know about them.
I just want to be able to use put video functions, SDL's or any other, on the most similar way
I used RelSprite with sprites stored into an integer array, if that's possible. RelSprite worked so great with PP256 PUT format. All that rect s-h-i-t in SDL seems too clumsy to me. At least now. I still don't know much about SDL.
Thanx in advance.
I so don't want to abandon Pixel Plus 256 so I need a routine that can load that format(PUT) into an integer array in FB.
I want to avoid using BMP images which have all the sprites or tiles inside them and then having to use some annoying way to load and paste sprites onto screen. I'll be honest, I don't like the way SDL solves the sprite issue(at least the way BasetFurry does it in his tutorial).
Here are the two subs from Pixel Plus 256 I mentioned if you don't know about them.
Code:
'* InitImageData() subroutine:
'* Initializes an integer array with image data - this must be done before
'* displaying an image using the PUT(graphics) statement. The calling value
'* of FileName$ dictates whether the data should be read directly from an
'* image file or from DATA statements (see below).
'*
'* Parameters:
'* FileName$ - The name of the image file to load. This must include the
'* path to the file if it does not reside in the current
'* directory. If FileName$ is an empty string (""), image
'* data is read from DATA statements.
'* ImageArray() - Dynamic, integer array to hold the image data.
'*
'* Note: Before calling InitImageData() to initialize images from DATA
'* statements, use an appropriate RESTORE statement to ensure the
'* correct DATA statements are read.
'*
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
'* MakeImageIndex() subroutine:
'* Constructs an image position index for the images held in an image array.
'*
'* Parameters:
'* ImageArray() - Dynamic, integer array holding images to be indexed.
'* IndexArray() - Dynamic, integer array to hold the index for images in
'* ImageArray().
'*
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
'this is how the subs can be used(example):
SCREEN 13
DEFINT A-Z
REDIM Set2Data(1 TO 1)
REDIM Set2Index(1 TO 1)
CALL InitImageData(Path$ + "SOMEFILE.PUT", Set2Data())
CALL MakeImageIndex(Set2Data(), Set2Index())
PUT (x, y), Set2Data(1), PSET
I used RelSprite with sprites stored into an integer array, if that's possible. RelSprite worked so great with PP256 PUT format. All that rect s-h-i-t in SDL seems too clumsy to me. At least now. I still don't know much about SDL.
Thanx in advance.