New graphics upload: Sprite Editor

All aspects of programming on the Commander X16.
Post Reply
User avatar
Daedalus
Posts: 232
Joined: Fri Nov 11, 2022 3:03 am

New graphics upload: Sprite Editor

Post by Daedalus »




Sprite Editor




View File






This runs on the latest emulator only and will not run on the "Web Emulator." As such, there is no "Try it now" button. You need to download the emulator if you don't have it. When the emulator is updated in the future, I will update this program as well. Currently, the latest emulator is version R41.

Preliminary version of my Sprite Editor. It has the minimum basic features needed to create sprite files and edit their sprite and palette data. Sprites are stored in a binary file with the extension .SPR that contains a header 6 bytes long as follows:

Byte 1 and 2: set to 0. Byte 3: Bits Per Pixel, Can be 4 or 8. Byte 4: Width, can be 8, 16, 32, or 64. Byte 5: Height, can be 8, 16, 32, or 64. Byte 6: Frames, Can be 1 to 6.

In this release, ONLY 4 bpp, 32 pixel width, 32 pixel height are supported. Those values can be set otherwise, but will have no effect.

After the header, The palette is in the next 32 bytes. It is 2 bytes per entry stored in the same format as the VERA stores it's palette entries. The sprites themselves follow the palette in sequential order.

The file is loaded into a 16K buffer in VERA ram. In future releases, the maximum number of frames for an individual sprite strip will by determined by how many sprites of the specified size will fit into that buffer. All sprites in the file share the same palette, and are intended to be "animation frames" for a single on screen sprite.

Controls:

The Sprite Editor is mostly controlled by the mouse, there are currently no key press controls except when the file name field when it is in edit mode. (See "file name field" below.)

Controls are visually cued in that they are white text with a light grey background. Hovering the mouse over a control cause the text to turn yellow, clicking on the control activates it's function. All of the controls are asynchronous,  meaning that the application's main event dispatch loop does not stop when a control is in use.

On the left side, the topmost control is the FILE NAME field. Clicking it puts it in edit mode and shows a flashing cursor. Typing text into the field inserts text at the cursor, there currently is no "overwrite" mode. The usable control keys are DELETE, which deletes the character at the cursor and moves the ones after it to the left, BACKSPACE, which deletes the character at the cursor and then moves the cursor one space to the left, LEFT ARROW and RIGHT ARROW, which moves the cursor left and right, and ENTER, which turns off edit mode and makes the new file name usable by the LOAD and SAVE buttons. Pressing LOAD or SAVE while the editor is still on will use the original file name.

Note, all of the controls that are buttons use both the left and right mouse button. The left button increases the value, the right button decreases the value as appropriate.

LOAD Loads the sprite strip indicated by the file name.

SAVE Saves the current sprite strip to the file specified.

BPP Sets the Bits Per Pixel of the sprites in the strip. Legal values are 4 and 8. Currently, only 4 is used.

WIDTH Sets the width of the sprites in the strip. Legal values are 8, 16, 32, or 64. Currently, only 32 is used.

 HEIGHT Sets the height of the sprites in the strip. Legal values are 8, 16, 32, or 64. Currently, only 32 is used.

FRAMES Sets the number of frames in the strip. Currently, the values 1 to 6 are legal and will be used. A future version will increase that.

RESET Currently does nothing. A future version will use this button to reset the sprite strip and sprite editor after changes to the BPP, WIDTH, and HEIGHT are made.

To the right of the above buttons is the Sprite Strip. Hovering the mouse over it will cause a yellow box to show around it. Clicking on an active sprite in the strip will transfer that sprite to the Sprite Editor control.

On the bottom right, to the left of the palette display:

P This sets the Palette Page. The VERA palette has 256 entries, and is divided into 16 16 entry pages. By default, the editor uses Palette Page 'F' (15 in decimal.) to hold the 16 entry palette for the current sprite strip. Pressing the left or right mouse button will cycle the pages through all available pages.

The Palette Display is also a control. Hovering the mouse over it will cause a yellow box to display around it. Left clicking on a palette entry will transfer that color's RGB entries to the RGB controls above the Palette Display, and will also transfer the color itself into the Foreground Color box to the left of the RGB controls. Right clicking on a palette entry will transfer that color to the Background Color to the far right.

RGB Controls the values directly above the buttons the edit the RGB components of the selected palette entry. The range of an individual entry is 0 to 15 (0 to F on the display, which is in hexadecimal.)

In the upper right is the Sprite Editor control itself. When the mouse is over it, the X,Y coordinates of the mouse in the sprite are displayed. On left click, the Foreground color if set into that pixel, on right click, the Background Color is set into the pixel. The Sprite Strip will update in real time as the colors are edited.






 
User avatar
Daedalus
Posts: 232
Joined: Fri Nov 11, 2022 3:03 am

New graphics upload: Sprite Editor

Post by Daedalus »


Hmm. I tried to add a "Try it now" button, but the display is garbled. The version of the emulator my program is targeting is .41

Edited to add: I downloaded it to be sure it does indeed work with the .41 emulator, and it does. So I removed the "try it now" button.

Edmond D
Posts: 501
Joined: Thu Aug 19, 2021 1:42 am

New graphics upload: Sprite Editor

Post by Edmond D »



On 12/10/2022 at 4:48 PM, Daedalus said:




Hmm. I tried to add a "Try it now" button, but the display is garbled. The version of the emulator my program is targeting is .41



The online emulator is at version 38, and there were changes in the vera between that version and version 41. 



I believe that updating the emulator is in the plans, but the bulk of the existing software library would need to be modified to work with the new version. I forecast when the X16 is released there will be a surge of updates in the software library, with some programs being orphaned. I also hope that the online emulator, the downloadable emulator and the actual x16 will be as similar as possible then, accepting that there will be some differences given the differences in the underlying hardware.

Disabling the try it now button was the right thing to do for the moment.  



 

TomXP411
Posts: 1807
Joined: Tue May 19, 2020 8:49 pm

New graphics upload: Sprite Editor

Post by TomXP411 »



On 12/10/2022 at 4:48 PM, Daedalus said:




Hmm. I tried to add a "Try it now" button, but the display is garbled. The version of the emulator my program is targeting is .41



Edited to add: I downloaded it to be sure it does indeed work with the .41 emulator, and it does. So I removed the "try it now" button.



Yup. Don't use Try It Now for new uploads. In fact, this feature will likely not be available on the new web site, since the design has changed since the Try It Now was introduced.

User avatar
Daedalus
Posts: 232
Joined: Fri Nov 11, 2022 3:03 am

New graphics upload: Sprite Editor

Post by Daedalus »


It occurs to me (After looking at the categories more closely.) that I should have put this in "Dev Tools."

Is there a way to move it over to there? I plan on uploading more in this vein, more tools and libraries to use them.

TomXP411
Posts: 1807
Joined: Tue May 19, 2020 8:49 pm

New graphics upload: Sprite Editor

Post by TomXP411 »



On 12/12/2022 at 5:21 PM, Daedalus said:




It occurs to me (After looking at the categories more closely.) that I should have put this in "Dev Tools."



Is there a way to move it over to there? I plan on uploading more in this vein, more tools and libraries to use them.



No problem. Either message one of us directly, or "report" your post and ask to have it moved to the appropriate category. I've already moved your upload, so it should now be in dev tools.

Post Reply