dos33fsprogs/bot_demo/commands.s

323 lines
4.5 KiB
ArmAsm
Raw Normal View History

2020-11-11 03:07:19 +00:00
TXTTAB = $67
PRGEND = $AF
VARTAB = $69
2020-11-09 05:02:33 +00:00
CURLIN = $75
ERRFLG = $D8
TXTPTR = $B8
CHRGET = $00B1
2020-11-11 03:07:19 +00:00
SCRTCH = $D64B
2020-11-09 05:02:33 +00:00
RESTART = $D43C
2020-11-15 03:45:18 +00:00
FIX_LINKS = $D4F2
2020-11-09 05:02:33 +00:00
INLIN2 = $D52E
PARSE_INPUT_LINE = $d559
TRACE_ = $D805
load_file:
2020-11-15 03:45:18 +00:00
;=================
2020-11-09 05:03:24 +00:00
;=================
; run list command
2020-11-15 03:45:18 +00:00
;=================
;=================
2020-11-09 05:02:33 +00:00
do_list:
2020-11-15 03:45:18 +00:00
; try to get things back to normal
2020-11-11 03:07:19 +00:00
bit SET_TEXT
2020-11-15 03:45:18 +00:00
bit LORES
2020-11-11 03:07:19 +00:00
bit PAGE0
2020-11-15 03:45:18 +00:00
bit TEXTGR
lda #0
sta $C00C ; disable 80 column display
sta $C000 ; disable 80 column memory mapping
sta $C05F ; clear annunicator 3 (double hires)
jsr SETNORM
2020-11-15 03:45:18 +00:00
jsr TEXT
2020-11-11 03:07:19 +00:00
jsr HOME
2020-11-17 16:25:05 +00:00
; clear HGR/HGR2 to black
lda #64 ; draw to page2
sta $E6
jsr $F3F2 ; clear to black
lda #32 ; draw to page1
sta $E6
jsr $F3F2 ; clear to black
2020-11-09 05:03:24 +00:00
lda #<list_string
sta cti_smc+1
lda #>list_string
sta cti_smc+2
jsr copy_to_input
jsr display_title
2020-11-09 05:03:24 +00:00
jmp run_command
2020-11-11 03:07:19 +00:00
; want to list from 0 to ffff
;LINNUM = $50
; lda #$00
; sta LINNUM
; sta LINNUM+1
;
; jsr $D61A ; FINDLIN, gets line in LOWTR
;
; lda #$ff
; sta LINNUM
; sta LINNUM+1
;
; jsr $d6da ; LIST_0
; jsr $d6cc ; LIST_0
;
; rts
2020-11-15 03:45:18 +00:00
;=================
;=================
; display title
;=================
;=================
display_title:
lda #' '
ldx #39
top_loop:
sta $6d0,X
dex
bpl top_loop
lda which_file
sec
sbc #1 ; blurgh hack
asl
tay
lda title_list,Y
sta middle_smc+1
lda title_list+1,Y
sta middle_smc+2
ldx #0
middle_loop:
middle_smc:
lda $dede,X
eor #$80
sta $750,X
inx
cpx #40
bne middle_loop
lda #' '
ldx #39
bottom_loop:
sta $7d0,X
dex
bpl bottom_loop
rts
2020-11-15 03:45:18 +00:00
;=============================
;=============================
2020-11-09 05:03:24 +00:00
; run run command
; a do-run-run, a do-run-run
2020-11-15 03:45:18 +00:00
;=============================
;=============================
2020-11-09 05:03:24 +00:00
do_run:
2020-11-18 03:05:43 +00:00
lda which_file ; is actually +1 at this point
cmp #5 ; raster
beq no_home
cmp #7
bcs no_home
2020-11-11 03:07:19 +00:00
jsr HOME
2020-11-18 03:05:43 +00:00
no_home:
2020-11-11 03:07:19 +00:00
2020-11-09 05:03:24 +00:00
lda #<run_string
sta cti_smc+1
2020-11-11 03:07:19 +00:00
lda #>run_string
sta cti_smc+2
2020-11-09 05:03:24 +00:00
jsr copy_to_input
2020-11-09 05:02:33 +00:00
jmp run_command
2020-11-09 05:03:24 +00:00
;=====================
; copy_to_input
; copies NUL terminator too
copy_to_input:
ldx #0
cti_loop:
cti_smc:
lda $1234,X
sta $200,X
beq done_copy
inx
bne cti_loop
done_copy:
rts
list_string:
.byte "LIST",0
run_string:
.byte "RUN",0
2020-11-09 05:02:33 +00:00
run_command:
; calls MON_GETLN
; length in X
; nul terminates
; turns off sign bits
;(Y,X) points at buffer - 1 (so $1FF?)
; jsr INLIN2
; stx TXTPTR ; set up CHRGET to scan the line
; sty TXTPTR+1
; lsr ERRFLG ;clear flag
; jsr CHRGET
; tax
; beq RESTART ;empty line
;d450: a2 ff ldx #$ff ;$ff in hi-byte of CURLIN means
;d452: 86 76 stx CURLIN+1 ; we are in direct mode
;d454: 90 06 bcc NUMBERED_LINE ;CHRGET saw digit, numbered line
;d456: 20 59 d5 jsr PARSE_INPUT_LINE ;no number, so parse it
;d459: 4c 05 d8 jmp TRACE_ ;and try executing it
ldx #$ff
stx TXTPTR
ldy #$1
sty TXTPTR+1
jsr CHRGET
ldx #$ff
stx CURLIN+1
jsr PARSE_INPUT_LINE
jmp TRACE_
2020-11-11 03:07:19 +00:00
;============================
;============================
; do_load
;============================
;============================
do_load:
jsr SCRTCH ; runs "NEW"
; messes with stack :(
lda which_file
asl
asl
tax
lda file_list,X
sta get_size_smc1+1
lda file_list+1,X
sta get_size_smc1+2
clc
lda file_list,X
adc #1
sta get_size_smc2+1
lda file_list+1,X
adc #0
sta get_size_smc2+2
clc
lda file_list,X
adc #2
sta do_load_smc1+1
lda file_list+1,X
adc #0
sta do_load_smc1+2
lda #<($801)
sta do_load_smc2+1
lda #>($801)
sta do_load_smc2+2
get_size_smc1:
lda $dede
sta file_size
get_size_smc2:
lda $dede
sta file_size+1
; always is 0?
lda #0
sta $800
do_load_loop:
do_load_smc1:
lda $dede
do_load_smc2:
sta $0800
inc do_load_smc1+1
bne no_load1_oflo
inc do_load_smc1+2
no_load1_oflo:
inc do_load_smc2+1
bne no_load2_oflo
inc do_load_smc2+2
no_load2_oflo:
lda do_load_smc1+1
cmp file_list+2,X
bne do_load_loop
lda do_load_smc1+2
cmp file_list+3,X
bne do_load_loop
; done with file list, increment
inc which_file
; update all the values
; this is actually from the DOS3.3 code, roughly starting at $A413
; add length to SOP / ASSOP
; TXTTAB $67 -- start of program
; need to add the size and store it in PRGEND $AF and VARTAB $69
clc
lda file_size
ldy file_size+1
adc TXTTAB
tax
tya
adc TXTTAB+1 ; A:X is now end of basic prog
; skip the error check
sta PRGEND+1
sta VARTAB+1
stx PRGEND
stx VARTAB
2020-11-15 03:45:18 +00:00
jmp FIX_LINKS ; FIX_LINKS
2020-11-11 03:07:19 +00:00
file_size: .word $dede
which_file: .byte $0