dispatch

A program of Instructions.

main.ngp

target { region $0080 .. $00FF ram   region $2000 .. $BFFF ram }
modules { "state.asm" }
container raw

state.asm

.section
state
        .res 1
.ends

.section
speed
        .res 1
.ends

; tag step
; Four positions of this Proc, chosen by what is in `A`. The clamp is the
; writer's: the statement indexes a table and does not check, exactly as any
; other index does not.
.proc step
        lda state
        cmp #3
        jcc @ok
        lda #3
@ok     .dispatch @idle, @walk, @run, @stop
@idle   lda #0
        jmp @set
@walk   lda #1
        jmp @set
@run    lda #4
        jmp @set
@stop   lda #0
@set    sta speed
        rts
.endp
; end step

Memory map

  1. phase00 zero page, 50 bytes
AddressBytesSectionModuleKindPhasesWaits
$2000–$20001statestatesection0
$2001–$20011speedstatesection0
$2002–$203148stepstateproc0