lucasw / amiga_assembly

Amiga assembly projects for use with Vasm
2 stars 0 forks source link

Convert images to and from raw bitplane format #1

Closed lucasw closed 6 years ago

lucasw commented 6 years ago

The current raw image is 3 planes, 3 bits or 8 possible color values per pixel. The palette is hard coded in the assembly, though in other examples this can be put into the image binary.

  ; bitplane 0
  move.l #bitplanes,d0
  move.w #$00e2,(a6)+ ; LO-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e2
  swap d0
  move.w #$00e0,(a6)+ ; HI-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e0

  ; bitplane 1
  move.l #bitplanes+40,d0
  move.w #$00e6,(a6)+ ; LO-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e6
  swap d0
  move.w #$00e4,(a6)+ ; HI-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e4

  ; bitplane 2
  move.l #bitplanes+80,d0
  move.w #$00ea,(a6)+ ; LO-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e6
  swap d0
  move.w #$00e8,(a6)+ ; HI-bits of start of bitplane
  move.w d0,(a6)+   ; go into $dff0e4
lucasw commented 6 years ago

http://computingvoyage.com/1012/creating-an-atari-st-or-amiga-picture-with-the-gimp/

http://codetapper.com/amiga/maptapper/documentation/gfx/gfx-mode/

lucasw commented 6 years ago

Gimp

First get some colors on the image otherwise the generate optimum palette will generate 1 color instead of the number requested.

Switch to indexed color mode then can view and edit color map in dialog in panel where layers and brush controls are. (Use the configure button in the upper right of it to add the color map)

It's hard to see the last color if it is white in the color map.

The colors can be edited only by clicking on them within the colormap, not the normal method of clicking on them in the widget that shows the currently active color.

Manually edit the colors to change the second digit of the hex representation to zero to approximate the 4096 4-bits per channel, though perhaps the colors will come out different than what an image would generate?

The first color will be the transparent color.

Export as raw - standard RGB or planar RRR, GGG, BBB?

Planar looks like it stores the images planes stacked vertically- so just do standard r,g,b

Palette files

A pal file is generated alongside the raw .data file

$ hexdump indexed_color_amiga.data.pal 
0000000 911d 08ff 0075 0b8c c40b 0909 00e8 e432
0000010 04d6 6eed 0000                         
0000015

Here is a palette where the first color is black and the second is white:

0000000 0000 ff00 ffff 0b8c c40b 0909 00e8 e432
0000010 04d6 6eed 0000  

Printing them out with python and they are in the right order (the ff00 above comes out correct):

[0, 0, 0]
[255, 255, 255]
[140, 11, 11]
[196, 9, 9]
[232, 0, 50]
[228, 214, 4]
[237, 110, 0]

image raw data

The raw data is exactly 320*160 bytes, meaning a byte is used per pixel regardless of the small palette sized.

And hexdump shows the values of each byte are all single digits, none exceed 7:

0006c20 0403 0302 0304 0304 0204 0304 0304 0402
0006c30 0303 0304 0304 0304 0304 0402 0302 0402
0006c40 0403 0302 0302 0402 0302 0204 0304 0203
0006c50 0403 0302 0402 0402 0303 0402 0402 0203
0006c60 0403 0302 0203 0203 0402 0302 0402 0402

Re-arrange colormap

Make sure all or none is selected when this happens, otherwise everything outside the selection will get colors shifted.

lucasw commented 6 years ago

Need to make a different version or option to the convert script to generate images with the bitplanes after the entire image (below it) instead of packed into one row (to the right)- that would be useful for horizontal wrap-around scrolling.