Amiga 500 Custom Screenmodes: OCS 160x128 2 bitplane chunky

UNFINISHED DRAFT, COME BACK LATER!!!

Introduction

With this article, I'd like to cover a ScreenMode that little known, yet fairly useful and fast for some kinds of effects. It can be seen in the Rotozoomer included in the Traschcan 3 diskmag intro.

This ScreenMode is actually a merger of 2 previous ScreenModes, the 1 bitplane chunky used in the World of Commodore demo by Sanity and the 6 bitplane chunky used in the Dawn intro by Artwork.

Plotting independent pixels in 1 Bitplane

The first step is really simple, first the memory and screen configuration:

    • One memory area A to draw a 320x128 pixel bitplane.
    • 1 active bitplane and BPL1PTR pointing to A.
    • A copper that stretches the bitplane to 2x vertical, by alternating BPLMODx to -40 and 0 in even and odd lines.

We want to have a way to easily plot 2 physical pixels in one operation -- this is doable using the following bit of code. Its working principle is to decompose the X coord into 2 parts, one to identify byte to modify (d0 in the example) and another for the bits inside the the byte (d2 in the example).

; d0 = x

; d1 = y

; a0 = start of screen area

plotpixel1:

lea plotpixel1_table,a1

muls.w #40,d1

add.l d1,a0 ; a0 = start of scanline

move.w d0,d2

and.w #3,d2 ; d2 = pixels to draw inside a byte, from 0 to 3

eor.w d2,d0

lsr.w #2,d0 ; d0 = byte offset inside scanline

move.b (a1,d2.w),d3

or.b d3,(a0,d0.w)

rts

plotpixel1_table:

dc.b $c0 ; bits = 11 00 00 00

dc.b $30 ; bits = 00 11 00 00

dc.b $0c ; bits = 00 00 11 00

dc.b $03 ; bits = 00 00 00 11

Plotting independent pixels in 2 Bitplanes

We have to do a more complex memory and screen configuration:

    • One memory area A to draw one 320x128 pixel bitplane.
    • One memory area B to draw one 320x128 pixel bitplane, filled with the binary pattern %0101010101
    • 3 active bitplanes:
      • First one, pointing to A.
      • Second one, pointing to A again (very important!!).
      • Third one, pointing to B.
    • A copper to:
      • Stretch the bitplane to 2x vertical, by alternating BPLMODx to -40 and 0 in even and odd lines.
      • Sets BPLCON1 to $0010 -- so that we keep the odd bitplanes as-is, and scroll the even bitplanes 1 pixel to the right

In this format, we will use 8 palette entries to simulate a 4 color screen, we get these combinations:

And finally, we need a more complex version of the routine above, so that it can plot the correct color at the correct place:

; d0 = x

; d1 = y

; d3 = color 0-3

; a0 = start of screen area

plotpixe2:

lea plotpixel2_table,a1

lea colorexpand,a2

muls.w #40,d1

add.l d1,a0 ; a0 = start of scanline

move.w d0,d2

and.w #3,d2 ; d2 = pixels to draw inside a byte, from 0 to 3

eor.w d2,d0

lsr.w #2,d0 ; d0 = byte offset inside scanline

move.b (a2,d3.w),d3 ; expand wanted color to all possible positions...

and.b (a1,d2.w),d3 ; ... and keep only the position we want to change.

or.b d3,(a0,d0.w)

rts

color_expand_table:

dc.b $00 ; bits = 00 00 00 00

dc.b $55 ; bits = 01 01 01 01

dc.b $aa ; bits = 10 10 10 10

dc.b $ff ; bits = 11 11 11 11

plotpixel2_table:

dc.b $c0 ; bits = 11 00 00 00

dc.b $30 ; bits = 00 11 00 00

dc.b $0c ; bits = 00 00 11 00

dc.b $03 ; bits = 00 00 00 11