LoginLogin
Might make SBS readonly: thread

SB4 pixel art

Root / General / [.]

Wubdubb94Created:
Hi Iā€™m trying to figure out how to make custom sprites without the sprite editor kind of how they made sprites on the Commodore 64 using lines of code

In SB4, graphics are stored on graphics pages (or GRPs for short), which are the different pages you can view in the graphics editor. You can also edit GRPs with code, like so: GTARGET page selects which GRP to edit. GPSET x,y,color sets a pixel on the current GRP. SPSET id,x,y,w,h creates a sprite with the given ID number using graphics from the GRP selected by SPPAGE. x, y, w, and h specify the region of the GRP that the sprite will use for its graphics. SPCHR id,x,y,w,h is like SPSET, but it changes the graphics region used by an existing sprite instead of trying to create a new sprite. SPPAGE id,page changes which GRP a sprite uses for its graphics.

This depends a lot on what you're trying to do specifically. Do you just want to store your graphics data somewhere in your program because the sprite editor is hard to use (it is, honestly), do you want to generate sprites, or something else? niconii's list of functions is really important and there's a few things I should add:
  • The default page for sprites and background characters is 4. You can also create a custom font based on the default one in page 5.
  • If you draw over or erase the default graphics in the pages, either in the editor or in your own program, you don't lose them. They're saved in a read-only file in the #SYS folder and reloaded by default when the screen is cleared with ACLS. Don't worry about it.
  • You can save and load graphics pages with SAVEG "filename",page and LOADG "filename",page
As far as storing graphics data in your program goes, I would probably use DATA blocks and run some code at startup that draws all of the sprites into page 4.

@snail_ how do I use data blocks and what code would I youse to draw a sprite?