This commit is contained in:
Joshua Bell 2017-12-09 13:00:27 -08:00
parent ba96487609
commit 00a2275346

189
b.s
View File

@ -6,6 +6,8 @@
L0060 := $0060 L0060 := $0060
RESETVEC := $3F2
RAMRDOFF := $C002 RAMRDOFF := $C002
RAMRDON := $C003 RAMRDON := $C003
RAMWRTOFF := $C004 RAMWRTOFF := $C004
@ -25,16 +27,20 @@ COUT := $FDED
SETINV := $FE80 SETINV := $FE80
SETNORM := $FE84 SETNORM := $FE84
ZP_HPOS := $24
ZP_TMASK := $32
COL80HPOS := $057B COL80HPOS := $057B
;;; ProDOS
BITMAP := $BF58
BITMAP_SIZE := $18
;;; ASCII
ASCII_TAB := $9 ASCII_TAB := $9
ASCII_DOWN := $A ASCII_DOWN := $A ; down arrow
ASCII_UP := $B ASCII_UP := $B ; up arrow
ASCII_RETURN := $D ASCII_CR := $D
ASCII_SYN := $16 ; scroll up
ASCII_ETB := $17 ; scroll down
ASCII_EM := $19 ; move cursor to upper left
ASCII_ESCAPE := $1B ASCII_ESCAPE := $1B
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
@ -52,6 +58,8 @@ ASCII_ESCAPE := $1B
.byte 0 .byte 0
.endmacro .endmacro
;;; ------------------------------------------------------------
;;; Entry point
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;; Loads at $2000 but executed at $1000. ;; Loads at $2000 but executed at $1000.
@ -61,35 +69,50 @@ ASCII_ESCAPE := $1B
L2000: jmp install_and_quit L2000: jmp install_and_quit
install_src := * install_src := *
;;; ------------------------------------------------------------
;;; Selector
;;; ------------------------------------------------------------
.org $1000 .org $1000
.proc bbb .proc bbb
prefix := $280 ; length-prefixed prefix := $280 ; length-prefixed
;; filenames at $1400 - each is length byte + 15 byte buffer
read_buffer := $2000 ; Also, start location for launched SYS files filenames := $1400 ; each is length + 15 bytes
read_buffer := $2000 ; Also, start location for launched SYS files
current_entry := $67 ; index of current entry
num_entries := $68 ; length of |filenames|
current_entry := $67 curr_len := $69 ; length of current entry name
num_entries := $68 curr_ptr := $6C ; address of current entry name (in |filenames|)
page_start := $73
top_row := 2 page_start := $73 ; index of first entry shown on screen
bottom_row := 21
top_row := 2 ; first row used on screen
bottom_row := 21 ; last row used on screen
;;; ------------------------------------------------------------
cld ; ProDOS protocol for QUIT routine
lda ROMINNW ; Page in ROM for reads, writes ignored
;; Point reset vector at this routine
stz RESETVEC
lda #>bbb
sta RESETVEC+1
cld
lda ROMINNW
stz $03F2
lda #$10
sta $03F3
jsr SETPWRC jsr SETPWRC
lda #$A0 lda #$A0
jsr LC300 jsr LC300 ; Activate 80-Column Firmware
ldx #$17
L1016: stz $BF58,x ;; Update system bitmap
ldx #BITMAP_SIZE-1 ; zero it all out
: stz BITMAP,x ; zero it all out...
dex dex
bpl L1016 bpl :-
inc $BF6F inc BITMAP+BITMAP_SIZE-1 ; protect global page itself
lda #$CF lda #$CF
sta $BF58 sta $BF58
lda #$02 lda #$02
@ -154,7 +177,7 @@ L109A: lda $2023,x
lda $70 lda $70
ora $71 ora $71
bne L10B5 bne L10B5
L10B3: bra L1129 L10B3: bra finish_read
L10B5: bit $71 L10B5: bit $71
bmi L10B3 bmi L10B3
L10B9: lda $63 L10B9: lda $63
@ -196,28 +219,29 @@ L10F8: ror $201E
bne L10B5 bne L10B5
L1108: ldx num_entries L1108: ldx num_entries
cpx #$80 cpx #$80
bcs L1129 bcs finish_read
sta $74,x sta $74,x
jsr L1258 jsr update_curr_ptr
ldy #$0F ldy #$0F
L1115: lda read_buffer,y L1115: lda read_buffer,y
sta ($6C),y sta (curr_ptr),y
dey dey
bpl L1115 bpl L1115
iny iny
and #$0F and #$0F
sta ($6C),y sta (curr_ptr),y
inc num_entries inc num_entries
bne L10B5 bne L10B5
L1126: jmp L1032 L1126: jmp L1032
L1129: MLI_CALL CLOSE, close_params finish_read:
MLI_CALL CLOSE, close_params
bcs L1126 bcs L1126
;; TEXT : HOME : VTAB 23 draw_screen:
jsr MON_SETTXT jsr MON_SETTXT ; TEXT
jsr MON_HOME jsr MON_HOME ; HOME
lda #23 ; line 23 lda #23 ; VTAB 23
jsr MON_TABV jsr MON_TABV
;; Print help text ;; Print help text
@ -225,7 +249,8 @@ L1129: MLI_CALL CLOSE, close_params
lda #20 ; HTAB 20 lda #20 ; HTAB 20
jsr cout_string_hpos jsr cout_string_hpos
jsr L12AD ;; Draw prefix
jsr home
ldx #0 ldx #0
: lda prefix+1,x : lda prefix+1,x
beq L1153 beq L1153
@ -257,32 +282,36 @@ L116F: jsr draw_current_line
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
.proc on_up .proc on_up
jsr draw_current_line ; show current line jsr draw_current_line ; clear inverse selection
ldx current_entry ldx current_entry
beq draw_current_line_inv ; first one? just redraw beq draw_current_line_inv ; first one? just redraw
dec current_entry ; go to previous dec current_entry ; go to previous
lda $25
cmp #top_row lda CV
bne draw_current_line_inv cmp #top_row ; at the top?
dec page_start bne draw_current_line_inv ; if not, just draw
lda #$16 ; code output ??? dec page_start ; yes, adjust page and
lda #ASCII_SYN ; scroll screen up
bne draw_current_line_with_char bne draw_current_line_with_char
.endproc .endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
.proc on_down .proc on_down
jsr draw_current_line jsr draw_current_line ; clear inverse selection
ldx current_entry ldx current_entry
inx inx
cpx num_entries cpx num_entries ; past the limit?
bcs draw_current_line_inv bcs draw_current_line_inv ; yes, just redraw
stx current_entry stx current_entry ; go to next
lda $25
cmp #bottom_row lda CV
bne draw_current_line_inv cmp #bottom_row ; at the bottom?
inc page_start bne draw_current_line_inv ; if not, just draw
lda #$17 ; code output ??? inc page_start ; yes, adjust page and
lda #ASCII_ETB ; scroll screen down
;; fall through ;; fall through
.endproc .endproc
@ -306,7 +335,7 @@ draw_current_line_inv:
ldx num_entries ldx num_entries
beq :+ ; no up/down/return if empty beq :+ ; no up/down/return if empty
cmp #HI(ASCII_RETURN) cmp #HI(ASCII_CR)
beq on_return beq on_return
cmp #HI(ASCII_DOWN) cmp #HI(ASCII_DOWN)
beq on_down beq on_down
@ -352,14 +381,14 @@ L11F1: jmp L1059
MLI_CALL SET_PREFIX, set_prefix_params MLI_CALL SET_PREFIX, set_prefix_params
bcs next_drive bcs next_drive
ldx current_entry ldx current_entry
jsr L1258 jsr update_curr_ptr
ldx prefix ldx prefix
: iny : iny
lda ($6C),y lda (curr_ptr),y
inx inx
sta prefix,x sta prefix,x
cpy $69 cpy curr_len
bcc :- bcc :-
stx prefix stx prefix
@ -397,7 +426,7 @@ L11F1: jmp L1059
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
cout_string_hpos: cout_string_hpos:
sta ZP_HPOS sta CH
.proc cout_string .proc cout_string
lda help_string,y lda help_string,y
@ -410,26 +439,30 @@ done: rts
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;; Compute offset to name in directory listing ??? ;; Compute address/length of curr_ptr/curr_len
L1258: stz $6D ;; Call with entry index in X.
.proc update_curr_ptr
stz curr_ptr+1
txa txa
asl a asl a
rol $6D rol curr_ptr+1
asl a asl a
rol $6D rol curr_ptr+1
asl a asl a
rol $6D rol curr_ptr+1
asl a asl a
rol $6D rol curr_ptr+1
sta $6C sta curr_ptr
lda #$14 lda #>filenames
clc clc
adc $6D adc curr_ptr+1
sta $6D sta curr_ptr+1
ldy #$00 ldy #0
lda ($6C),y lda (curr_ptr),y
sta $69 sta curr_len
rts rts
.endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
@ -448,22 +481,24 @@ draw_current_line:
lda $74,x lda $74,x
bmi L1299 bmi L1299
stz COL80HPOS stz COL80HPOS
lda ZP_TMASK lda INVFLG
pha pha
ldy #(folder_string - string_start) ; Draw folder glyphs ldy #(folder_string - string_start) ; Draw folder glyphs
jsr cout_string jsr cout_string
pla pla
sta ZP_TMASK sta INVFLG
L1299: jsr L12A9 L1299: jsr space
jsr L1258 jsr update_curr_ptr
L129F: iny L129F: iny
lda ($6C),y lda (curr_ptr),y
jsr ascii_cout jsr ascii_cout
cpy $69 cpy curr_len
bcc L129F bcc L129F
L12A9: lda #HI(' ')
space: lda #HI(' ')
bne cout ; implicit RTS bne cout ; implicit RTS
L12AD: lda #$99 ; Ctrl+Y ??
home: lda #HI(ASCII_EM) ; move cursor to top left
;; Sets high bit before calling COUT ;; Sets high bit before calling COUT
ascii_cout: ascii_cout:
@ -544,6 +579,8 @@ trans: .word 0
.org $2402 .org $2402
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Installer
;;; ------------------------------------------------------------
.proc install_and_quit .proc install_and_quit
jsr install jsr install