registers

A program of Targets.

main.ngp

target {
  region          $0080 .. $00FF  ram
  region          $2000 .. $BFFF  ram

; tag registers
  region COLBK    $D01A .. $D01A  register
  register COLPF2 $D018
  register WSYNC  $D40A
  register VCOUNT $D40B
; end registers
}

modules { "rainbow.asm" }

container xex

rainbow.asm

.proc entry
@top    lda VCOUNT
        jne @top

        ldx #0
@line   sta WSYNC
        stx COLBK
        stx COLPF2
        inx
        cpx #240
        jcc @line

        jmp @top
.endp
load.asm nga.load
; What a `.xex` decodes with while it loads: without storage its transformed
; Sections, and compressed its segments. See
; docs/decisions/0235-a-xex-decodes-in-place-while-it-loads.md and
; docs/decisions/0259-a-xex-may-be-compressed-segment-by-segment.md.
ngaLoadPtr .ztemp 2

.macro ngaLoadRead
        ldy #0
        lda (ngaLoadPtr),y
        inc ngaLoadPtr
        bne @same
        inc ngaLoadPtr+1
@same
.endm

; Where the loader puts the form it has just written, and the destination.
.export ngaUnpackFrom, ngaUnpackTo
.section root
ngaUnpackFrom .res 2
ngaUnpackTo   .res 2
.ends

; What lies hidden under a ROM is written into memory nothing holds yet with a
; table in front of it — how many pieces, the ROMs to put back, then where each
; is, where it goes and how long it is — and moved with every ROM out and the
; interrupts masked. See
; docs/decisions/0241-bytes-kept-for-a-later-phase-may-lie-hidden-under-a-rom.md.
.export ngaUnder, ngaUnderTable, ngaUnderPutBack
.section root
ngaUnderTable .res 2
.ends
.section root
ngaUnderPutBack .res 1
.ends
ngaUnderAt    .ztemp 2
ngaUnderFrom  .ztemp 2
ngaUnderTo    .ztemp 2
ngaUnderLeft  .ztemp 2
ngaUnderCount .ztemp 1
ngaUnderRoms  .ztemp 1
.proc ngaUnder, root
        nga.mask
        lda #0
        nga.select
        lda ngaUnderTable
        sta ngaUnderAt
        lda ngaUnderTable+1
        sta ngaUnderAt+1
        ldy #0
        lda (ngaUnderAt),y
        sta ngaUnderCount
        iny
        lda (ngaUnderAt),y
        sta ngaUnderRoms
        ldx #2
piece   jsr take
        sta ngaUnderFrom
        jsr take
        sta ngaUnderFrom+1
        jsr take
        sta ngaUnderTo
        jsr take
        sta ngaUnderTo+1
        jsr take
        sta ngaUnderLeft
        jsr take
        sta ngaUnderLeft+1
        ldy #0
move    lda ngaUnderLeft
        ora ngaUnderLeft+1
        beq moved
        lda (ngaUnderFrom),y
        sta (ngaUnderTo),y
        inc ngaUnderFrom
        bne from
        inc ngaUnderFrom+1
from    inc ngaUnderTo
        bne to
        inc ngaUnderTo+1
to      lda ngaUnderLeft
        bne left
        dec ngaUnderLeft+1
left    dec ngaUnderLeft
        jmp move
moved   dec ngaUnderCount
        bne piece
        lda ngaUnderRoms
        nga.select
        nga.unmask
        rts

; The next byte of the table, which X walks from its third.
take    txa
        tay
        lda (ngaUnderAt),y
        inx
        rts
.endp

Memory map

  1. (implicit)0 zero page, 24 bytes
AddressBytesSectionModuleKindPhasesWaits
$2000–$201724entryrainbowproc0

The xex

36 bytes, 2 segments, 0 unaccounted.

02container header
$2000–$2017 24 bytes at 2
$20003rainbow.entryrainbow.asm
$20032rainbow.entryrainbow.asm
$20052rainbow.entryrainbow.asm
$20073rainbow.entryrainbow.asm
$200A3rainbow.entryrainbow.asm
$200D3rainbow.entryrainbow.asm
$20101rainbow.entryrainbow.asm
$20112rainbow.entryrainbow.asm
$20132rainbow.entryrainbow.asm
$20153rainbow.entryrainbow.asm
$02E0–$02E1 2 bytes at 30
$02E02runad