Add forgotten /util directory, forgotten files /terminal/gr_terminal.asm and /termina...
authorNick Downing <nick.downing@lifx.co>
Tue, 14 Nov 2023 02:49:29 +0000 (13:49 +1100)
committerNick Downing <nick@ndcode.org>
Tue, 14 Nov 2023 03:21:49 +0000 (14:21 +1100)
.gitignore
terminal/gr_terminal.asm [new file with mode: 0644]
terminal/gr_terminal_asm.txt [new file with mode: 0644]
util/Makefile [new file with mode: 0644]
util/bootable.txt [new file with mode: 0644]
util/tone.asm [new file with mode: 0644]
util/tone_asm.txt [new file with mode: 0644]

index 1411d1e..81f544d 100644 (file)
@@ -26,6 +26,8 @@ __pycache__
 /orig/Apple_DOS_v3.3_1980_Apple.do
 /orig/DOS_Tool_Kit_v1.0_1980_Apple.do
 /orig/Lemonade_Stand_1979_Apple.do
+/orig/apple2.rom
+/orig/apple_ii+_rom.zip
 /ribbit/bootable.dsk
 /ribbit/ribbit.bas
 /ribbit/ribbit_tone.asm
@@ -37,4 +39,5 @@ __pycache__
 /test/lemonade_music.bas
 /tok_to_bas.py
 /t_def.py
+/util/bootable.dsk
 /y_tab.py
diff --git a/terminal/gr_terminal.asm b/terminal/gr_terminal.asm
new file mode 100644 (file)
index 0000000..ba655d0
--- /dev/null
@@ -0,0 +1,220 @@
+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
diff --git a/terminal/gr_terminal_asm.txt b/terminal/gr_terminal_asm.txt
new file mode 100644 (file)
index 0000000..04ea3a2
--- /dev/null
@@ -0,0 +1,5 @@
+BRUN EDASM.OBJ
+PR#1
+DR 2
+ASM GR TERMINAL.ASM,GR TERMINAL.OBJ
+
diff --git a/util/Makefile b/util/Makefile
new file mode 100644 (file)
index 0000000..73063d9
--- /dev/null
@@ -0,0 +1,45 @@
+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
diff --git a/util/bootable.txt b/util/bootable.txt
new file mode 100644 (file)
index 0000000..b027cda
--- /dev/null
@@ -0,0 +1,4 @@
+NEW
+10 HOME
+20 PRINT "HELLO"
+INIT HELLO,D2
diff --git a/util/tone.asm b/util/tone.asm
new file mode 100644 (file)
index 0000000..ee672e8
--- /dev/null
@@ -0,0 +1,26 @@
+spkr   equ     $c030
+       org     $300
+rest   lda     #0
+       sta     freql
+       sta     freqh
+tone   ldx     #0
+durl   equ     *-1
+       ldy     #0
+durh   equ     *-1
+loop   lda     #0
+freql  equ     *-1
+       adc     #0
+countl equ     *-1
+       sta     countl
+       lda     #0
+freqh  equ     *-1
+       adc     #0
+counth equ     *-1
+       sta     counth
+       bcc     nospkr
+       lda     spkr
+nospkr inx
+       bne     loop
+       iny
+       bne     loop
+       rts
diff --git a/util/tone_asm.txt b/util/tone_asm.txt
new file mode 100644 (file)
index 0000000..f51e61c
--- /dev/null
@@ -0,0 +1,5 @@
+BRUN EDASM.OBJ
+PR#1
+DR 2
+ASM TONE.ASM,TONE.OBJ
+