+Stephen Posted February 16, 2023 Share Posted February 16, 2023 I had not planned on releasing this so early but at the request of Yaron, I've decided to put it out early. It's a simple little program which will load an 8-bpp BMP image and allow an export of a VBXE palette (in 2 formats)*, and RAW image. Alternately, it can load RAW image files and palettes. Any open image can have its palette changed. Many more features are planned. The ZIP file includes an executable and a help file along with some sample data. It is a .NET application, which should run on both Windows and Linux machines (using Mono). Please let me know if there are any issues. I've only tested on one other machine as I never intended this to be released yet. * Current source code examples assume the palette is stored as 256 bytes R, 256 bytes G, 256 bytes B because it's easier (and faster) code. BUT - I had two issues with this. 1st of all, it is not how BMP images store their palette. 2nd - the code was self modifying so cannot run from ROM. Because of this, I wrote a routine to load in the data assuming linear RGB triplets. Spoiler VBXEditor.zip 11 Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted February 17, 2023 Share Posted February 17, 2023 Great work @Stephen 1 Quote Link to comment Share on other sites More sharing options...
candle Posted February 20, 2023 Share Posted February 20, 2023 On 2/16/2023 at 10:22 PM, Stephen said: Current source code examples assume the palette is stored as 256 bytes R, 256 bytes G, 256 bytes B because it's easier (and faster) code. BUT - I had two issues with this. 1st of all, it is not how BMP images store their palette. 2nd - the code was self modifying so cannot run from ROM. Because of this, I wrote a routine to load in the data assuming linear RGB triplets. Well, it just happends I got all the tools for this written already from my PC demoscene days thus examples were using either dap or dat format (dap - data and palette) these tools were never published though since they were written in assembly to work under dos, and in order to use them, one need to resort to dosbox or similiar virtualisation 2 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted February 20, 2023 Author Share Posted February 20, 2023 2 hours ago, candle said: Well, it just happends I got all the tools for this written already from my PC demoscene days thus examples were using either dap or dat format (dap - data and palette) these tools were never published though since they were written in assembly to work under dos, and in order to use them, one need to resort to dosbox or similiar virtualisation Cool - it's definitely faster and more compact/elegant code when done that way. All of this stuff I am doing is very basic, but I'm teaching myself 6502 as I go along, so it was a fun little challenge to implement reading the linear palette. BTW - it was awesome when I found the hidden message in the fonts.raw file of your scroll.asm demo. Thanks for sharing the source, it's what gt me started on all this. Quote Link to comment Share on other sites More sharing options...
Thelen Posted February 20, 2023 Share Posted February 20, 2023 Cool, I also did a RGB extractor for this in 2009 in Freebasic which I'm still using today 🙂 - but I was to lazy to do a raw bmp pixel data extractor.. - at the moment I'm using a hex editor for this rip out the pixel data, so this will save really some time! Do I need to mirror the BMP, or does your program this? Thanks! 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted February 20, 2023 Author Share Posted February 20, 2023 3 hours ago, Thelen said: Do I need to mirror the BMP, or does your program this? I invert the image so the nice thing is, what you see on a PC is exactly what you'll see when loading directly into the VBXE. 1 Quote Link to comment Share on other sites More sharing options...
Thelen Posted February 21, 2023 Share Posted February 21, 2023 Just tested your software, works terrific!! 1 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted February 21, 2023 Author Share Posted February 21, 2023 I'll have an update in a day or two to support outputting graphics for 640 pixel format as well as palette editing. 1 Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted February 21, 2023 Share Posted February 21, 2023 good work guys. in my other thread of black belt i was exploring VBXE i was using a python script that extract palette and raw data from an image and compress it. So the produced script produces 3 files: 1. pallete.bin 2. orig.bin 3. compressed.bin In my project i just add palette and compressed files (as original is very big - over 30K), and decompress it in run time into VBXE memory. As the owner of the script is @popmilo and since the script has gone though some iterations, i'll let him share the python file . Quote Link to comment Share on other sites More sharing options...
popmilo Posted February 21, 2023 Share Posted February 21, 2023 Hi guys, nice tools you have there Here's script that Yaron mentioned. It extracts pixels and palette from indexed png image and produces binary data for: 1. Palette in sequence of reds, greens, blues so it can easily be copied into vbxe palette. Like if there are 6 colors in palette, there will be 6 bytes for red componente, 6 green and 6 blue, total of 18 bytes binary. 2. "sprites.bin" with raw pixel values that you can blit to screen and get your sprites. 3. "sprites_compressed.bin" in custom compression similar to rle, with each byte being made from two 4 bit nibbles, "number of pixels" and "pixel color". Works pretty well with only limit being only 16 possible colors per image. If you would want to combine more than one png into single vbxe palette and gfx data, you would have to append colors as new data is added with also changing pixel values to fit new expanded palettes. For single png in 16 colors it just works. Cheers! Vladimir vbxe_converter.zip 3 Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted February 21, 2023 Share Posted February 21, 2023 thanks @popmilo Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted February 22, 2023 Share Posted February 22, 2023 On 2/20/2023 at 9:01 PM, Thelen said: Cool, I also did a RGB extractor for this in 2009 in Freebasic which I'm still using today 🙂 - but I was to lazy to do a raw bmp pixel data extractor.. - at the moment I'm using a hex editor for this rip out the pixel data, so this will save really some time! Do I need to mirror the BMP, or does your program this? Thanks! Me using PureBasic for ages for tooling… not into C or C++. Lazarus (Pascal) could be similar but for 10+ Years I stuck to PB. 2 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted February 25, 2023 Author Share Posted February 25, 2023 OK - due to some new things I needed, expect a new version this weekend. New features are: Ability to export in "packed pixel" mode, for showing graphics in 640-pixel mode. I don't yet have the ability to re-import these. I'll try to add that before I make the next release. Ability to export multiple (and different sized) .raw files from a single imported image. This will allow a background image and a sprite sheet to share the same palette but be different sizes. Terrible UI for this at the moment. I have to get the help file updated and wire in some sort of UI for the multi-export before I can post an update. 3 Quote Link to comment Share on other sites More sharing options...
Thelen Posted May 9, 2023 Share Posted May 9, 2023 On 2/16/2023 at 10:22 PM, Stephen said: Current source code examples assume the palette is stored as 256 bytes R, 256 bytes G, 256 bytes B because it's easier (and faster) code. BUT - I had two issues with this. 1st of all, it is not how BMP images store their palette. 2nd - the code was self modifying so cannot run from ROM. Because of this, I wrote a routine to load in the data assuming linear RGB triplets. Reveal hidden contents Hi Stephen, is it possible to get/use your sourcecode 'VBXE_SetPalette2' function which is in the hidden content? 🙂 (couldn't find it in your .zip file) I'm too lazy to type it over from the image and OCR messes things up... 🙂 Quote Link to comment Share on other sites More sharing options...
+Stephen Posted May 9, 2023 Author Share Posted May 9, 2023 34 minutes ago, Thelen said: Hi Stephen, is it possible to get/use your sourcecode 'VBXE_SetPalette2' function which is in the hidden content? 🙂 (couldn't find it in your .zip file) I'm too lazy to type it over from the image and OCR messes things up... 🙂 Sure thing. Apologies for formatting - cannot get this POS forum to properly format any of my asm. ;-------------------------------------------------------- ; VBXE_SetPalette2 - sets palette ; A - palette number ; Y_Register - palette pointer - Data MUST be page aligned ; NOTE: This code can run from ROM ; The palette is stored as 256 RGB triplets VBXE_SetPalette2 vbsta VBXE_PSEL ; Set Palette 1 lda #0 vbsta VBXE_CSEL ; Start at colour 0 tay LoadPal1_1 lda (Y_Register),y sta VBXE_CR ; set the red component iny beq OverFlow1 ; since 256 / 3 is not even, we must skip to next section and resume at CG lda (Y_Register),y sta VBXE_CG ; set the green component iny lda (Y_Register),y sta VBXE_CB ; set the blue component and increment CSEL iny bne LoadPal1_1 ; copy a page LoadPal1_2 lda (Y_Register),y sta VBXE_CR ; set the red component iny beq LoadPal1_3 LP1_2_G lda (Y_Register),y sta VBXE_CG ; set the green component iny beq OverFlow2 ; since 256 / 3 is not even, we must skip to next section and resume at CB lda (Y_Register),y sta VBXE_CB ; set the blue component and increment CSEL iny bne LoadPal1_2 ; copy a page LoadPal1_3 lda (Y_Register),y sta VBXE_CR ; set the red component iny lda (Y_Register),y sta VBXE_CG ; set the green component iny LP1_3_B lda (Y_Register),y sta VBXE_CB ; set the blue component and increment CSEL iny bne LoadPal1_3 ; copy a page rts OverFlow1 inc Y_Register + 1 jmp LP1_2_G OverFlow2 inc Y_Register + 1 jmp LP1_3_B Quote Link to comment Share on other sites More sharing options...
Thelen Posted May 9, 2023 Share Posted May 9, 2023 26 minutes ago, Stephen said: Sure thing. Apologies for formatting Thanks! And no problem 🙂 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.