Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : Program to make your own "MAP"-files

Posted: 03:19pm
01 Aug 2025
Copy link to clipboard
Peter63
Regular Member

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
 
Posted: 03:39pm
01 Aug 2025
Copy link to clipboard
Amnesie
Guru

Wow! This is amazing!

What a great tool you have made!


Greetings
Daniel
 
Posted: 03:46pm
01 Aug 2025
Copy link to clipboard
Amnesie
Guru

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
 
Posted: 04:05pm
01 Aug 2025
Copy link to clipboard
Peter63
Regular Member

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
 
Posted: 04:22pm
01 Aug 2025
Copy link to clipboard
Amnesie
Guru

  Quote  
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.


Yes, absolutely!

  Quote  
I had to lock White and Black, otherwise it would not be possible to read the program text on the screen.


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
 
Posted: 06:02pm
01 Aug 2025
Copy link to clipboard
Martin H.
Guru


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.
 
Posted: 06:42pm
01 Aug 2025
Copy link to clipboard
Amnesie
Guru

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
 
Posted: 06:47pm
01 Aug 2025
Copy link to clipboard
Peter63
Regular Member

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
 
Posted: 06:53pm
01 Aug 2025
Copy link to clipboard
Peter63
Regular Member

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
 
Posted: 01:42am
02 Aug 2025
Copy link to clipboard
Peter63
Regular Member

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
 
Posted: 04:15am
02 Aug 2025
Copy link to clipboard
Martin H.
Guru


  Peter63 said  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


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
  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
I hope this helps, give it a try.
  Peter63 said  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...

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 pixels

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

Cheers
 Martin
Edited 2025-08-02 15:13 by Martin H.
 


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025