--- /dev/null
+wndleft equ $20
+wndwdth equ $21
+wndtop equ $22
+wndbtm equ $23
+ch equ $24
+cv equ $25
+gbasl equ $26
+gbash equ $27
+cursor equ $fa bit 6 shown, bit 7 enabled
+csrblnk equ $fb blink countdown
+prevch equ $fc
+state equ $fd
+prevnum equ $fe
+num equ $ff
+linebuf equ $200
+chario equ $3ea
+kbd equ $c000
+kbdstrb equ $c010
+sin.d equ $c0f0
+sout.d equ $c0f1
+serr.d equ $c0f2
+sin.s equ $c0f3
+sout.s equ $c0f4
+serr.s equ $c0f5
+slp.lo equ $c0f6
+slp.hi equ $c0f7
+s.exit equ $c0f8
+dos.lo equ $c0f9
+dos.hi equ $c0fa
+gbascalc equ $f847
+cout equ $fded
+ org $800
+ lda #0
+ sta wndleft
+ sta wndtop
+ sta ch
+ sta cv
+ lda #40
+ sta wndwdth
+ lda #24
+ sta wndbtm
+ lda #$60 rts
+ sta chario
+ lda #$80
+ sta cursor clear shown, set enable
+ lda #250
+ sta csrblnk set counter for .25s (units of 1ms)
+ lda #$d cr
+ sta prevch
+ ldx #0
+newst stx state
+loop lda sout.s
+ bpl nosout
+ lda kbd
+ bpl nosout
+ sta kbdstrb
+ and #$7f
+ sta sout.d
+ jmp loop
+nosout lda sin.s
+ bmi issin
+ lda #>1000
+ sta slp.lo
+ lda #<1000
+ sta slp.hi
+ bit cursor
+ bpl loop
+ dec csrblnk
+ bne loop
+ jsr togcsr
+ jmp loop
+issin lda sin.d
+ ldx state
+ beq state0
+ dex
+ beq state1
+ dex
+ beq state2
+ dex
+ beq state3
+ dex
+ bne notst4
+ jmp state4
+notst4 dex
+ bne notst5
+ jmp state5
+notst5 lda #1
+ sta s.exit
+state0 cmp #4 ctrl-d
+ bne notctld
+ ldy prevch
+ cpy #$d but only after cr
+ bne notctld
+ stx num use num as linebuf index
+ ldx #5
+ jmp newst
+notctld cmp #$1b esc
+ bne notesc
+ inx
+ jmp newst
+notesc sta prevch
+ jsr hidecsr
+ lda prevch
+ ora #$80
+ jsr cout
+ jsr showcsr
+ jmp loop
+state1 cmp #$5b [
+ bne newst0 invalid escape sequence
+ stx prevnum
+ stx num
+ ldx #2
+newst0 jmp newst
+state2 cmp #$3f ?
+ bne notqm
+ ldx #4
+ jmp newst1
+notqm ldy #3
+ sty state
+state3 cmp #$30 0
+ bcc newst1 invalid escape sequence
+ cmp #$3a
+ bcc digit
+ cmp #$3b ;
+ bne notscln
+ lda num
+ sta prevnum
+ stx num
+ jmp loop
+notscln cmp #$47 G
+ bne notch
+ dec num
+ jsr hidecsr
+ lda num
+ sta ch
+ jsr showcsr
+ ldx #0
+newst1 jmp newst
+notch cmp #$64 d
+ bne notcv
+ dec num
+ jsr hidecsr
+ lda num
+ sta cv
+ jsr showcsr
+ ldx #0
+ jmp newst
+notcv cmp #$72 r
+ bne newst2
+ dec prevnum
+ lda prevnum
+ sta wndtop
+ lda num
+ sta wndbtm
+newst2 jmp newst invalid escape sequence
+state4 cmp #$30 0
+ bcc newst3 invalid escape sequence
+ cmp #$3a
+ bcs notdig
+digit sec
+ sbc #$30 digit value
+ asl num
+ clc
+ adc num + num * 2
+ asl num
+ asl num
+ clc
+ adc num + num * 8
+ sta num to num
+ jmp loop
+notdig cmp #$6c l
+ beq setprv
+ cmp #$68 h
+ bne newst3 invalid escape sequence
+setprv ldy num
+ cpy #25 esc [?25l or esc [?25h
+ bne newst3
+ pha
+ jsr hidecsr
+ pla
+ ldy #0
+ cmp #$6c l
+ beq setcur
+ ldy #$80
+setcur sty cursor
+ jsr showcsr
+ ldx #0
+newst3 jmp newst
+state5 ldy num
+ cmp #$d
+ bne notcr
+ txa
+ sta linebuf,y
+ lda #>linebuf
+ sta dos.lo
+ lda #<linebuf
+ sta dos.hi
+ jmp newst
+notcr sta linebuf,y
+ iny
+ sty num
+ jmp loop
+hidecsr bit cursor
+ bvs togcsr if cursor shown, toggle
+ rts
+showcsr bit cursor
+ bpl rts0 if cursor disabled, ignore
+ bvs rts0 if cursor not shown, ignore
+togcsr lda cursor
+ eor #$40
+ sta cursor toggle currently shown flag
+ lda #250
+ sta csrblnk set counter for .25s (units of 1ms)
+ lda cv
+ jsr gbascalc
+ ldy ch
+ lda (gbasl),y
+ eor #$80
+ sta (gbasl),y
+rts0 rts
--- /dev/null
+DOS33=../dos33fsprogs/utils/dos33fs-utils/dos33
+MKDOS33FS=../dos33fsprogs/utils/dos33fs-utils/mkdos33fs
+TOK_TO_BIN=../tok_to_bin.py
+BIN_TO_TOK=../bin_to_tok.py
+TOK_TO_BAS=../tok_to_bas.py
+BAS_TO_TOK=../bas_to_tok.py
+
+.PHONY: all
+all: tone.obj bootable.dsk
+
+tone.obj: \
+tone.asm \
+tone_asm.txt \
+bootable.dsk \
+../orig/DOS_Tool_Kit_v1.0_1980_Apple.do
+ cp ../orig/DOS_Tool_Kit_v1.0_1980_Apple.do .
+ tr '\t\na-z' ' \rA-Z' <tone.asm |\
+LC_ALL=C tr '\000-\177' '\200-\377' >__temp__.asm
+ ${MKDOS33FS} __temp__.dsk
+ ${DOS33} __temp__.dsk SAVE T __temp__.asm TONE.ASM
+ rm -f ../linapple-pie/Printer.txt
+ tr '\n' '\r' <tone_asm.txt |\
+( \
+ cd ../linapple-pie && \
+ ./linapple -b -1 ../util/DOS_Tool_Kit_v1.0_1980_Apple.do -2 ../util/__temp__.dsk \
+)
+ tr -d '\r' <../linapple-pie/Printer.txt >tone.lst
+ ${DOS33} __temp__.dsk LOAD TONE.OBJ $@
+ rm DOS_Tool_Kit_v1.0_1980_Apple.do __temp__.asm __temp__.dsk
+
+bootable.dsk: ../orig/Apple_DOS_v3.3_1980_Apple.do bootable.txt
+ dd if=/dev/zero of=$@ count=35 bs=4096
+ tr '\n' '\r' <../util/bootable.txt |\
+( \
+ cd ../linapple-pie && \
+ ./linapple -b -1 ../orig/Apple_DOS_v3.3_1980_Apple.do -2 ../util/$@ \
+)
+
+clean:
+ rm -f \
+*.lst \
+*.obj \
+bootable.dsk \
+__temp__.asm \
+__temp__.dsk