ABCDE: DLI Colour Rows in MADS

Type
Graphics
Category
Display-list interrupt colour demo (assembler)
Author
Ralf Patschke
Published in
AtariAge forums, NYD 2026 thread (2026)
Year
2026
Language
6502 assembly (MADS)
Requirements
MADS (Mad Assembler) and an include file of Atari hardware equates; any 8-bit Atari to run the result

About the program

This little source was posted in 2026, in an AtariAge discussion of the NYD 2026 releases, as a teaching example. In the author's words, it reproduces "in a way simpler mode, the text graphics and some color changes in DLI". It's a good first program for anyone learning display-list interrupts (DLIs) in MADS, the Mad Assembler. It fills 11 rows of a GRAPHICS 2 (ANTIC mode 7) screen with ABCDE abcde ABCDE abcde, normal and inverse, so that every row shows all four playfield colours. One DLI then changes two of those colours 16 scanlines at a time, so each row comes out in a different shade.

What you need

  • MADS, which supplies the .proc, .rept, dta d'…' syntax and macro-instructions such as mwa, mva, phr/plr and add.
  • Hardware equates for nmien, vcount, wsync and color0–color3. As the second comment line says: "Use your own OS link file or correct the addresses". Because the colours are written inside the DLI, color0–color3 here must be the GTIA hardware registers COLPF0–COLPF3 (53270–53273, $D016–$D019), not the OS shadow registers at 708–711.

How it works

  • ant, the display list. :4 .he 70 gives four "8 blank lines" instructions. Next comes .he 80 47: one blank line with the DLI bit set ($80), followed by $47, which is mode 7 (GRAPHICS 2) with a Load Memory Scan, then the screen address .wo scr. Ten more $07 mode-7 lines follow, and finally $41 (Jump and wait for Vertical Blank) back to ant.
  • scr, the screen. dta d'ABCDE' stores internal screen codes, and the trailing * sets bit 7 (inverse). In mode 7, upper case, lower case, inverse upper and inverse lower are drawn in COLPF0, 1, 2 and 3 respectively, so each 20-character row is a colour test card. .rept 11 repeats it for 11 rows.
  • main. It points the OS display-list pointer (560) and the DLI vector VDSLST (512) at the new routines, enables DLIs with NMIEN = $C0, and parks in jmp *.
  • dli. It saves the registers (phr), sets COLPF0 to $0E (white) and COLPF1 to $0A, then loops 13 times: read VCOUNT (the current scanline ÷ 2) into COLPF2, add 20 and store that in COLPF3, then wait 16 scanlines with sixteen sta wsync. Since VCOUNT rises down the screen, each mode-7 row (16 scanlines tall) gets the next colours. A mode-7 row is exactly 16 scanlines tall, so the colour changes stay in step with the rows.

Variations to try

  • Change add 20 to another value for different colour pairs, or replace lda vcount with a table lookup for chosen colours.
  • Remove eight of the sixteen wsyncs to change colour every half row and see the split appear in the middle of the letters.

Listing

; I just reproduce in a way simpler mode, the text graphics and some color changes in DLI here.
; Use your own OS link file or correct the addresses to make this work.

    org $2000
        .proc ant
:4      .he 70
        .he 80 47
        .wo scr
:10     .he 7
        .he 41
        .wo ant
        .endp
;------------
        .proc scr
        .rept 11
        dta d'ABCDE'
        dta d'abcde'
        dta d'ABCDE'*
        dta d'abcde'*
        .endr
        .endp
;------------
        .proc main
        mwa #ant 560
        mwa #dli 512
        mva #$c0 nmien
        jmp *
        .endp
;------------
        .proc dli
        phr

        mva #$e color0
        mva #$a color1

        ldx #12
lx      lda vcount
        sta color2
        add 20
        sta color3
:16     sta wsync
        dex
        bpl lx

        plr
        rti
        .endp
;------------
        run main

Credits