Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:47 28 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: I can't work out how to save and then load 8-bit graphics

     Page 2 of 2    
Author Message
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 10:38am 06 Feb 2024
Copy link to clipboard 
Print this post

  PeteCotton said  When saving the bitmap from GIMP it jams a bunch of extra data in there which messes up the previous load logic.

In GIMP, you can select what's saved and which kind of BMP (or other image file format).

John
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 316
Posted: 04:56pm 06 Feb 2024
Copy link to clipboard 
Print this post

  phil99 said  Gimp has possibly added it's own 256 word palette.
From memory the header has a word that tells at what byte number the bitmap data starts. If you can find that the changed header length won't matter.

From the "BMP File Format" link it's at offset &h000A.


Thanks Phil - you are 100% correct. There are two jump addresses in the BMP file header, one that specifies the location of the start of the pixel data, and another that specifies the size of the header (and therefore where the colour data starts).

In my first cut off the code these were fixed lengths, because I was always saving all 256 colours. Then I realised that GIMP was doing something extra, so the latest version of the Load subroutine takes those two jump indexes into account and should now work for all 8 bit non-compressed BMPs.

  JohnS said  In GIMP, you can select what's saved and which kind of BMP (or other image file format).

John


Thanks John. You are right, and I did select the non-compressed 8-bit format, but as mentioned above to Phil, I was being lazy/slack in my original implementation.    The latest version takes into account the variable header sizes now.

  matherp said  There is a bug in the current version of ReadBuffer which is used both by the pixel function and the save image command. If the R, G, or B value of the pixel is > 224 then the read will wrap due to a scaling error. I think you picked this up earlier. I'll post a fix on the CMM2 beta thread later today


Right - that explains the weird effect I was seeing at the start of this thread. Thanks once again for being on top of all of this and for the ongoing support. It is always appreciated.
 
joker
Newbie

Joined: 06/02/2024
Location: Germany
Posts: 18
Posted: 01:43pm 09 Feb 2024
Copy link to clipboard 
Print this post

Hello,
I'm new to this forum and I build my CMM2 end of November last year. I'm interested in bringing retro games to the CMM2. (See AirRescue)
I stumbled upon the same issues with colormaps and if this thread would have been there one month earlier it had safed me a lot of time. Ñow some of my findings which I hope are an addition to this topic:
1. The clut of the microcontroller is a write only function. I wondered a bit that map() always return the same value for a speific entry until I found the remark in the user manual. But this I suppose you know already
2. To compensate that the clut cannot be read back, the firmware has stored a default colomap. This default map is used whenever a picture is loaded. Own modifications to the clut are ignored. Therefore, you cannot control the color register used
3. So the only way to load pictures with dedicated color indicees is 'load data" as already explained in this thread.
4. With gimp you can save a picture in "raw" format. This gives you the pure colors of the picture or the map indicates if your picture was indexed. But don't forget to delete the alpha channel. Otherwise you get two bytes per pixel.
5. I wrote a proxy library that allows me to maintain the colormap and also read the colors back. I hope this will give me the ability to unleash the power of indexed pictures.

Sorry for the long text  

Matthias
 
PeteCotton

Guru

Joined: 13/08/2020
Location: Canada
Posts: 316
Posted: 04:09pm 09 Feb 2024
Copy link to clipboard 
Print this post

  joker said  Hello,
.......
Matthias


A very warm welcome to the forum Matthias! And welcome to the wonderful world of the CMM2. I am also passionate about bringing retro games to the CMM2. It is the perfect platform for retro game design (IMHO), and balances just the right amount of power where incredible things are possible, but not always easy. In a world of desktop computers with almost unlimited graphics power - it's great to have to work on a system that requires old school techniques.

The Load8BitBMP subroutine above will load the clut from the file format. But yes, when saving I had to "remember" the colours separately.

I'm excited to see what you produce. Please share your progress here - it's always very interesting to see what others are doing with the hardware.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3015
Posted: 04:47pm 09 Feb 2024
Copy link to clipboard 
Print this post

Indeed, welcome to the forum, and thanks for your contribution.

I had never seen the word, "clut", before, so:

Urban Dictionary: clut --CLUT is an acronym for "Color Lookup Table". CLUTs are also referred to as palettes.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
joker
Newbie

Joined: 06/02/2024
Location: Germany
Posts: 18
Posted: 08:00pm 16 Mar 2024
Copy link to clipboard 
Print this post

Hello,
Thanks for the warm welcome.

My first game on the CMM2 was Air Rescue (https://github.com/grimm-git/airrescue).
It was also published beginning of 2024 on CMM2.fun.

My current project is an interpretation of Fort Apocalypse. I name it "Fort Micromite" and first level is already playable. I think I will publish it as work in progress on Github the next days.

It will use a custom palette with color cycling. Therefore, I was interested in this thread.

Best Regards
 Matthias
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024