![]() |
Forum Index : Microcontroller and PC projects : Program to make your own "MAP"-files
Author | Message | ||||
Peter63 Regular Member ![]() Joined: 28/07/2017 Location: SwedenPosts: 97 |
Hello RGB colors are quite interesting when you look at them more closely. I have made a program that makes it a little easier to make your own "MAP" files. The program is useful as it is today, but there are probably things that could be done differently. I'll leave it as it is today to see what kind of comments there will be. The program is written for PicoMiteHDMI MMBasic USB RP2350A Edition V6.00.03 and uses mouse and keyboard. ![]() CTRL+C to exit the program test-map.zip /Peter63 |
||||
Amnesie Guru ![]() Joined: 30/06/2020 Location: GermanyPosts: 675 |
Wow! This is amazing! What a great tool you have made! Greetings Daniel |
||||
Amnesie Guru ![]() Joined: 30/06/2020 Location: GermanyPosts: 675 |
I have only one small suggestion: I use a colour palette in which black isn't complete black, but RGB(20, 12, 28) like in this demosntration of the colour palette I am using (this is not mine, nor made by me!): ![]() original source But I think there is indeed a justification for also make "black" adjustable. This is my favourite 16 colour palette, even for games it offers many many options. In your version it seems I can't change black. Same for white! But as said: this is a great piece of software you made! Wow! I LOVE those sliders! Greetings Daniel Edited 2025-08-02 01:51 by Amnesie |
||||
Peter63 Regular Member ![]() Joined: 28/07/2017 Location: SwedenPosts: 97 |
The program is written for 640x480 HDMI (Mode 3), I forgot to mention this. But should work on VGA 640x480 Choosing the right color can sometimes be crucial in how you experience a program or application. I was a little interested in using "DrawBars" to set the RGB values, thinking that this should be easy and cool. You get a different feeling of what happens to the color when changing the value with "DrawBars". But you can also type the values directly. I had to lock White and Black, otherwise it would not be possible to read the program text on the screen. /Peter63 |
||||
Amnesie Guru ![]() Joined: 30/06/2020 Location: GermanyPosts: 675 |
Yes, absolutely! Ah ok, I didn't thought about that. Ok, it isn't hard to add those two values later by hand. I played a bit with the program and can't find any problems so far! Great experience! Greetings Daniel Edited 2025-08-02 02:23 by Amnesie |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1236 |
Nice Peter, this reads the Colors from a 4 Bit uncompressed BMP Files and sets the Map 'PICO 2 HDMI only 'Reads and shows 4 Bit uncompressed BMP Files in up to 640x480 resolution ' and sets the Colors using the MAP Command Data "kingtut.bmp","W95Beta.bmp","koeln_4bit.bmp","end" MODE 2 Map reset:Map set CLS Dim integer w,h,hi,f,cl,c,scr,xr2 Do Read File$:If file$="end" Then Exit Do Map reset Open file$ For input As #1 read_BMP_Header Map set MODE 2+(h>240) hi=MM.VRES xr2=MM.HRES/2 scr=MM.Info(WRITEBUFF) yofs=(hi-h)/2 yofs=hi-yofs Seek #1,of+1 For y=yofs To (yofs-h)+1 Step -1 ss=scr+(y*xr2) For x=0 To w-1 Step 2 c=Asc(Input$(1,1)) c=(c<<4)+(c>>4):Poke byte ss+(x/2),c Next Next Close #1 Pause 5000 Loop Sub read_BMP_Header Local l$ WStart= &H13 Hstart= &H17 MPStart= 55 'read offset of Picture data Seek #1,11 l$=Input$(1,1):of=Asc(l$) l$=Input$(1,1):Inc of,256*(Asc(l$)) 'read Picture width Seek #1,WStart l$=Input$(1,1):W=Asc(l$) l$=Input$(1,1):Inc w,256*(Asc(l$)) 'read Picture height Seek #1,HStart l$=Input$(1,1):h=Asc(l$) l$=Input$(1,1):Inc h,256*(Asc(l$)) 'write the Color data to Map Seek #1,MPStart For F=0 To 15 l$=Input$(1,1):B=Asc(l$) l$=Input$(1,1):G=Asc(l$) l$=Input$(1,1):R=Asc(l$) l$=Input$(1,1)'fillbyte Map(f)=RGB(R,G,B) Next End Sub The matching Pictures and Bas File are here maptest.zip Have Fun Martin Edited 2025-08-02 04:06 by Martin H. 'no comment |
||||
Amnesie Guru ![]() Joined: 30/06/2020 Location: GermanyPosts: 675 |
You guys are insane! ![]() One nice & usful program after another! Martin, this becomes handy when I play with my iamge experiments on the HDMI version. ![]() Greetings Daniel |
||||
Peter63 Regular Member ![]() Joined: 28/07/2017 Location: SwedenPosts: 97 |
Martin Ok, I tested and the program displayed "kingtut.bmp" OK, but then it stopped and was interrupted with the following alarm... [25] c=Asc(Input$(1,1)) Error : SDcard not configured Don't really know the reason... ![]() /Peter63 |
||||
Peter63 Regular Member ![]() Joined: 28/07/2017 Location: SwedenPosts: 97 |
Maybe because I'm running the program from a subdirectory? > files B:/MartinH/maptest 19:43 01-08-2025 38528 kingtut.bmp 19:41 01-08-2025 153728 Koeln_4bit.bmp 19:56 01-08-2025 1347 maptest.bas 19:49 01-08-2025 153728 W95Beta.bmp 0 directories, 4 files > ??? /Peter63 |
||||
Peter63 Regular Member ![]() Joined: 28/07/2017 Location: SwedenPosts: 97 |
Martin I suspect that the BMP files you load in may not be too large. Just a theory, I have no proof that this is the case, but the effects I get lean in that direction. In the Manual it just says: MM.INFO(WRITEBUFF) Returns the address in memory of the current buffer used for drawing commands. But it doesn't say how big the buffer is... But whatever, I like the idea of setting MAP this way. /Peter63 |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1236 |
Here is a version of the loop that works without writing directly to the image memory, but of course takes longer. For y=yofs To yofs-h-2 Step -1 I hope this helps, give it a try.For x=0 To w-1 Step 2 c=asc(Input$(1,1)) Pixel x,y,Map(c>>4):Pixel x+1,y,Map(c And 15) Next Next this should not be necessary as the size is known. If you have an image with a resolution of 320 × 240 pixels and 4-bit color depth, here’s how you calculate the required memory size: 1. Total number of pixels: 320×240=76,800 pixel 2. Memory per pixel: 4 bits per pixel = 0.5 bytes per pixel (Since 1 byte = 8 bits, 4 bits = ½ byte) 3. Total memory needed: 76,800×0.5=38,400 bytes If we double the size of the image (mode 3), the memory requirement quadruples ![]() Cheers Martin Edited 2025-08-02 20:47 by Martin H. 'no comment |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |