Denise Amiga Custom Chip

Sprites

Programming

SPRPOS and SPRCTL

These are some funky data structures:

snippet.asm
; @param 1 x value, can be address lookup
; @param 2 y value, can be address lookup
; @param 3 write location, sprite header
; @side-effect destroys D1,D2,advances write position
SetSPRPOS MACRO
  MOVEQ #0,D1
  MOVE.W \2,D1
  AND.W #$FF,D1
  LSL.W #8,D1
 
  MOVE.W \1,D2
  AND.W #$1FE,D2
  LSR.W #1,D2
  ADD.W D2,D1
 
  MOVE.W D1,(\3)+
  ENDM
 
; @param 1 x value, can be address lookup
; @param 2 y value, can be address lookup
; @param 3 y stop value, can be address lookup
; @param 4 1 if attached, 0 if not
; @param 5 write location, sprite header
; @side-effect destroys D1,D2,advances write position
SetSPRCTL MACRO
  MOVEQ #0,D1
  MOVE.W \3,D1
  AND.W #$FF,D1
  LSL.W #8,D1
 
  MOVE.W \2,D2
  AND.W #$100,D2
  LSR.W #6,D2
  ADD.W D2,D1
 
  MOVE.W \3,D2
  AND.W #$100,D2
  LSR.W #7,D2
  ADD.W D2,D1
 
  MOVE.W \1,D2
  AND.W #$1,D2
  ADD.W D2,D1
 
  MOVE.W #\4,D2
  LSL.W #7,D2
  ADD.W D2,D1
 
  MOVE.W D1,(\5)+
  ENDM

Building in Linux using Krita, LibreSprite, and Amigeconv

Tools

Process

  • Draw the pixel art in Krita. You can use animation frames if you like. Reference images will scale down properly so you can use a full-size animation as a reference.
  • Export individual frames of the animation
  • Import the images into LibreSprite. When you load the first image in a sequence, it will offer to import all of them as animation frames.
  • Ensure the Sprite > Color Mode is Indexed (No dithering)
  • Rearrange the palette. It works like moving cells in a spreadsheet:
    • Click a color
    • Move the mouse to the color edge. The cursor becomes an arrow cross.
    • Move the color to the new location.
    • Click “Remap”
  • Export the animation as PNG frames
  • Use Amigeconv to convert each PNG to a sprite. In my case I was making 32 pixel wide attached sprites, so you'll get the multiple bitplanes next to each other. Some splitting in code will be in order.
    • ~/Downloads/amigeconv-v1.0.8-linux-amd64 -f sprite -w 32 -d 4 -a ../frame0000-out-test.png runner1.spr
  • Verify it with Okteta: https://apps.kde.org/okteta/

Display Generation

TODO: clean this up


  • Agnus knows the horizontal and vertical beam positions
  • Agnus updates VPOS and VHPOS
  • Agnus sends HSYNC and VSYNC
  • Agnus sends bitplane data to Denise one word of bitplane bits at a time
    • Denise doesn't have Chip RAM access
  • Denise has the color registers
  • Denise just happens to output the correct color at the time when Agnus changes the register
  • HSYNC, VSYNC, and colors just happen to work out on video output
  • HSYNC, VSYNC, and colors are combined together for composite

Useful bugs

7 bitplanes in OCS

If you set BPLCON0 to 7 bitplanes, Agnus thinks this is only 4 bitplanes and will only send those over DMA, but Denise will render 5. You can then set BPL5DAT manually