pinned

A program of Targets.

What the tool said

NGA5218 `belowDos` is pinned at $0800, in the reserved region `dos` /Users/waldek/Desktop/NGA/tutorial/03-targets/pinned/pinned.asm:2

main.ngp

; tag res
target {
  region        $0080 .. $00FF  ram
  region dos    $0700 .. $1FFF  reserved
  region        $2000 .. $BFFF  ram
}
; end res

modules { "pinned.asm" }

container xex

pinned.asm

;tag sec
.section absolute at $0800
belowDos
        .res 1
.ends
;end sec

.proc entry
        lda belowDos
        rts
.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, 5 bytes
AddressBytesSectionModuleKindPhasesWaits
$0800–$08001belowDospinnedsection0
$2000–$20034entrypinnedproc0

The xex

16 bytes, 2 segments, 0 unaccounted.

02container header
$2000–$2003 4 bytes at 2
$20003pinned.entrypinned.asm
$20031pinned.entrypinned.asm
$02E0–$02E1 2 bytes at 10
$02E02runad