Identify states

This commit is contained in:
Joshua Bell 2017-12-09 09:03:44 -08:00
parent e13d9f0e60
commit 7042ad9901

191
b.s
View File

@ -1,21 +1,19 @@
;;; Disassembly of BYE.SYSTEM (Bird's Better Bye)
.setcpu "65C02" .setcpu "65C02"
.include "apple2.inc"
.include "prodos.inc" .include "prodos.inc"
L0060 := $0060 L0060 := $0060
KBD := $C000
RAMRDOFF := $C002 RAMRDOFF := $C002
RAMRDON := $C003 RAMRDON := $C003
RAMWRTOFF := $C004 RAMWRTOFF := $C004
RAMWRTON := $C005 RAMWRTON := $C005
ALTZPOFF := $C008 ALTZPOFF := $C008
ALTZPON := $C009 ALTZPON := $C009
KBDSTRB := $C010
ROMIN := $C081
ROMINNW := $C082 ROMINNW := $C082
ROMINWB1 := $C089 ROMINWB1 := $C089
LCBANK1 := $C08B
LC300 := $C300 LC300 := $C300
MON_SETTXT := $FB39 MON_SETTXT := $FB39
@ -27,6 +25,33 @@ COUT := $FDED
SETINV := $FE80 SETINV := $FE80
SETNORM := $FE84 SETNORM := $FE84
ZP_HPOS := $24
ASCII_TAB := $9
ASCII_DOWN := $A
ASCII_UP := $B
ASCII_RETURN := $D
ASCII_ESCAPE := $1B
;;; ------------------------------------------------------------
.define HI(char) (char|$80)
.macro HIASCII arg
.repeat .strlen(arg), i
.byte .strat(arg, i) | $80
.endrep
.endmacro
.macro HIASCIIZ arg
HIASCII arg
.byte 0
.endmacro
;;; ------------------------------------------------------------
;; Loads at $2000 but executed at $1000.
.org $2000 .org $2000
@ -41,6 +66,12 @@ L2000: jmp install_and_quit
read_buffer := $2000 ; Also, start location for launched SYS files read_buffer := $2000 ; Also, start location for launched SYS files
current_entry := $67
num_entries := $68
rows_per_screen := 21
current_line := $73
cld cld
lda ROMINNW lda ROMINNW
stz $03F2 stz $03F2
@ -96,7 +127,7 @@ L1059: stx prefix ; truncate prefix to length x
jmp keyboard_loop jmp keyboard_loop
L107F: inc $6B ; ??? L107F: inc $6B ; ???
stz $68 stz num_entries
lda open_params_ref_num lda open_params_ref_num
sta read_params_ref_num sta read_params_ref_num
sta $61 sta $61
@ -158,7 +189,7 @@ L10F8: ror $201E
beq L1108 beq L1108
cmp #$FF cmp #$FF
bne L10B5 bne L10B5
L1108: ldx $68 L1108: ldx num_entries
cpx #$80 cpx #$80
bcs L1129 bcs L1129
sta $74,x sta $74,x
@ -171,31 +202,37 @@ L1115: lda read_buffer,y
iny iny
and #$0F and #$0F
sta ($6C),y sta ($6C),y
inc $68 inc num_entries
bne L10B5 bne L10B5
L1126: jmp L1032 L1126: jmp L1032
L1129: MLI_CALL CLOSE, close_params L1129: MLI_CALL CLOSE, close_params
bcs L1126 bcs L1126
;; TEXT : HOME : VTAB 23
jsr MON_SETTXT jsr MON_SETTXT
jsr MON_HOME jsr MON_HOME
lda #$17 lda #23 ; line 23
jsr MON_TABV jsr MON_TABV
ldy #$00
lda #$14 ;; Print help text
jsr L124A ldy #0
lda #20 ; HTAB 20
jsr cout_string_hpos
jsr L12AD jsr L12AD
ldx #$00 ldx #0
L1148: lda prefix+1,x : lda prefix+1,x
beq L1153 beq L1153
jsr L12AF jsr L12AF
inx inx
bne L1148 bne :-
L1153: stz $67
stz $73 L1153: stz current_entry
lda $68 stz current_line
lda num_entries
beq keyboard_loop beq keyboard_loop
cmp #$15 cmp #rows_per_screen
bcc L1161 bcc L1161
lda #$14 lda #$14
L1161: sta $6A L1161: sta $6A
@ -205,57 +242,68 @@ L1161: sta $6A
lda #$16 lda #$16
sta $21 sta $21
sta $23 sta $23
L116F: jsr L1277 L116F: jsr draw_current_line
inc $67 inc current_entry
dec $6A dec $6A
bne L116F bne L116F
stz $67 stz current_entry
beq L11AA beq draw_current_line_inv
on_up: jsr L1277 .proc on_up
ldx $67 jsr draw_current_line ; show current line
beq L11AA ldx current_entry
dec $67 beq draw_current_line_inv
dec current_entry
lda $25 lda $25
cmp #$02 cmp #$02
bne L11AA bne draw_current_line_inv
dec $73 dec current_line
lda #$16 lda #$16 ; code output ???
bne L11A7 bne draw_current_line_with_char
.endproc
on_down: .proc on_down
jsr L1277 jsr draw_current_line
ldx $67 ldx current_entry
inx inx
cpx $68 cpx num_entries
bcs L11AA bcs draw_current_line_inv
stx $67 stx current_entry
lda $25 lda $25
cmp #$15 cmp #rows_per_screen
bne L11AA bne draw_current_line_inv
inc $73 inc current_line
lda #$17 lda #$17 ; code output ???
;; fall through
.endproc
draw_current_line_with_char:
jsr COUT
draw_current_line_inv:
jsr SETINV
jsr draw_current_line
;; fall through
;;; ------------------------------------------------------------
L11A7: jsr COUT
L11AA: jsr SETINV
jsr L1277
keyboard_loop: keyboard_loop:
lda KBD lda KBD
bpl keyboard_loop bpl keyboard_loop
sta KBDSTRB sta KBDSTRB
jsr SETNORM jsr SETNORM
ldx $68 ldx num_entries
beq L11CB beq L11CB
cmp #$8D ; Return cmp #HI(ASCII_RETURN)
beq on_return beq on_return
cmp #$8A ; Down Arrow cmp #HI(ASCII_DOWN)
beq on_down beq on_down
cmp #$8B ; Up Arrow cmp #HI(ASCII_UP)
beq on_up beq on_up
L11CB: cmp #$89 ; Tab L11CB: cmp #HI(ASCII_TAB)
beq next_drive beq next_drive
cmp #$9B ; Esc cmp #HI(ASCII_ESCAPE)
bne keyboard_loop bne keyboard_loop
jsr L11DA jsr L11DA
@ -280,7 +328,7 @@ L11F1: jmp L1059
on_return: on_return:
MLI_CALL SET_PREFIX, set_prefix_params MLI_CALL SET_PREFIX, set_prefix_params
bcs next_drive bcs next_drive
ldx $67 ldx current_entry
jsr L1258 jsr L1258
ldx prefix ldx prefix
@ -292,10 +340,12 @@ on_return:
bcc :- bcc :-
stx prefix stx prefix
ldy $67 ldy current_entry
lda $74,y lda $74,y
bpl L11F0 ; is directory??? bpl L11F0 ; is directory???
;;; ------------------------------------------------------------
.proc launch_sys_file .proc launch_sys_file
jsr MON_SETTXT jsr MON_SETTXT
jsr MON_HOME jsr MON_HOME
@ -317,7 +367,10 @@ on_return:
jmp read_buffer ; Invoke the loaded code jmp read_buffer ; Invoke the loaded code
.endproc .endproc
L124A: sta $24 ;;; ------------------------------------------------------------
cout_string_hpos:
sta ZP_HPOS
cout_string: cout_string:
lda help_string,y lda help_string,y
@ -347,12 +400,13 @@ L1258: stz $6D
sta $69 sta $69
rts rts
L1277: lda #$02 draw_current_line:
lda #$02
sta $057B sta $057B
ldx $67 ldx current_entry
txa txa
sec sec
sbc $73 sbc current_line
inc a inc a
inc a inc a
jsr MON_TABV jsr MON_TABV
@ -378,21 +432,18 @@ L12AD: lda #$99
L12AF: ora #$80 L12AF: ora #$80
L12B1: jmp COUT L12B1: jmp COUT
;;; ------------------------------------------------------------
.proc do_read .proc do_read
MLI_CALL READ, read_params MLI_CALL READ, read_params
rts rts
.endproc .endproc
.macro HIASCII arg ;;; ------------------------------------------------------------
.repeat .strlen(arg), i
.byte .strat(arg, i) | $80
.endrep
.endmacro
string_start := * string_start := *
.proc help_string .proc help_string
HIASCII "RETURN: Select | TAB: Chg Vol | ESC: Back" HIASCIIZ "RETURN: Select | TAB: Chg Vol | ESC: Back"
.byte 0 ; null terminated
.endproc .endproc
;; Mousetext sequence: Enable, folder left, folder right, disable ;; Mousetext sequence: Enable, folder left, folder right, disable
@ -401,6 +452,8 @@ L12B1: jmp COUT
.byte 0 ; null terminated .byte 0 ; null terminated
.endproc .endproc
;;; ------------------------------------------------------------
.proc open_params .proc open_params
params: .byte 3 params: .byte 3
path: .addr prefix path: .addr prefix
@ -436,6 +489,8 @@ trans: .word 0
read_params_ref_num := read_params::ref_num read_params_ref_num := read_params::ref_num
read_params_request := read_params::request read_params_request := read_params::request
;;; ------------------------------------------------------------
.res 192, 0 .res 192, 0
.byte $00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00,$00,$00,$00
@ -450,16 +505,22 @@ trans: .word 0
.assert .sizeof(bbb) = $3FF, error, "Expected size is $3FF" .assert .sizeof(bbb) = $3FF, error, "Expected size is $3FF"
.org $2402 .org $2402
install_and_quit: ;;; ------------------------------------------------------------
.proc install_and_quit
jsr install jsr install
MLI_CALL QUIT, quit_params MLI_CALL QUIT, params
.proc quit_params
.proc params
params: .byte 4 params: .byte 4
type: .byte 0 type: .byte 0
res1: .word 0 res1: .word 0
res2: .byte 0 res2: .byte 0
res3: .addr 0 res3: .addr 0
.endproc .endproc
.endproc
;;; ------------------------------------------------------------
.proc install .proc install
src := install_src src := install_src