disasm wip

This commit is contained in:
Joshua Bell 2020-10-04 20:27:15 -07:00
parent 93ae124043
commit 420f400eb6
2 changed files with 176 additions and 97 deletions

View File

@ -169,8 +169,10 @@ L2095 := * + 1
L2099 := * + 1 L2099 := * + 1
ldy #$05 ldy #$05
sty $23 sty $23
jsr SetPrefixAndCheckSysFile
lda $1204 jsr SetPrefixAndGetFileInfo
lda file_info_params + GET_FILE_INFO_PARAMS::mod_date + 1
lsr a lsr a
sta year sta year
jsr ConvertToBCD jsr ConvertToBCD
@ -303,28 +305,29 @@ install_clock:
lda MACHID lda MACHID
ora #%00000001 ; has clock ora #%00000001 ; has clock
sta MACHID sta MACHID
bit KBD
bmi L218C bit KBD ; Key pressed?
bmi skip
lda month lda month
cmp #11 cmp #11
bcc L2176 bcc :+
bit L11FE bit L11FE
bpl L2176 bpl :+
sta $1204 sta $1204
L2176: lda $1204 : lda $1204
lsr a lsr a
cmp #(kDefaultYear .mod 100) cmp #(kDefaultYear .mod 100)
bcc L218C bcc skip
;; Two byte compare ;; Two byte compare
lda DATELO lda DATELO
cmp file_info_params + $A ; mod_date cmp file_info_params + GET_FILE_INFO_PARAMS::mod_date
lda DATELO+1 lda DATELO+1
sbc file_info_params + $A + 1 ; mod_date + 1 sbc file_info_params + GET_FILE_INFO_PARAMS::mod_date + 1
bcs L21DF bcs L21DF
L218C: bit KBDSTRB skip: bit KBDSTRB
rol L11FE rol L11FE
lda #3 lda #3
cmp month cmp month
@ -746,50 +749,68 @@ L239E:
.org $1000 .org $1000
L1000: .proc L1000
entry_ptr := $00
entry_length := $02
entries_per_block := $03
entry_num := $04
name_length := $05
ldy #$00 ldy #$00
sty read_block_block_num+1 sty read_block_block_num+1
iny iny
sty $04 sty entry_num
iny iny
sty read_block_block_num sty read_block_block_num
jsr L119F jsr ReadBlock
lda $1C23 lda block_buffer + VolumeDirectoryBlockHeader::entry_length
sta $02 sta entry_length
lda $1C24 lda block_buffer + VolumeDirectoryBlockHeader::entries_per_block
sta $03 sta entries_per_block
lda #$2B lda #<$1C2B
sta $00 sta entry_ptr
lda #$1C lda #>$1C2B
sta $01 sta entry_ptr+1
L1021: ldy #$10
lda ($00),y entries_loop:
cmp #$FF ;; SYS file?
bne L10A8 ldy #FileEntry::file_type
ldy #$00 lda (entry_ptr),y
lda ($00),y cmp #FileType::kSYS
and #$30 bne next_entry
beq L10A8
lda ($00),y ldy #0
and #$0F lda (entry_ptr),y
sta $05 and #$30 ; storage_type
beq next_entry
;; Check name
lda (entry_ptr),y
and #$0F ; name_length
sta name_length
;; Does name have ".SYSTEM" suffix?
tay tay
ldx #strlen_str_system - 1 ldx #strlen_str_system - 1
L103A: lda ($00),y : lda (entry_ptr),y
cmp str_system,x cmp str_system,x
bne L10A8 bne next_entry ; nope, continue
dey dey
dex dex
bpl L103A bpl :-
;; Is it "CLOCK.SYSTEM" (i.e. this file)?
ldy #strlen_str_clock_system ldy #strlen_str_clock_system
L1047: lda ($00),y : lda (entry_ptr),y
cmp str_clock_system,y cmp str_clock_system,y
bne L1053 bne L1053
dey dey
bne L1047 bne :-
beq L10A8 beq next_entry ; match - (but want *next* system file)
L1053: lda $05 L1053: lda $05
sta $121D sta open_pathname
sta $0280 sta $0280
inc $05 inc $05
lda msg_num lda msg_num
@ -797,70 +818,84 @@ L1053: lda $05
beq L1070 beq L1070
ldy #$03 ldy #$03
jsr L10E5 jsr L10E5
lda mach_type lda mach_type
beq L106D beq :+
iny iny
L106D: jsr ShowMessage : jsr ShowMessage
L1070: ldy #MessageCode::kRunning L1070: ldy #MessageCode::kRunning
jsr ShowMessage jsr ShowMessage
ldy #$01
L1077: lda ($00),y ldy #1
sta $121D,y : lda (entry_ptr),y
sta open_pathname,y
sta $0280,y sta $0280,y
ora #$80 ora #$80
jsr COUT jsr COUT
iny iny
cpy $05 cpy $05
bne L1077 bne :-
jsr LoadSysFile jsr LoadSysFile
lda #$00
;; Restore text window
lda #0
sta WNDTOP sta WNDTOP
lda #$18 lda #24
sta WNDBTM sta WNDBTM
jsr MON_HOME jsr MON_HOME
lda has_80col lda has_80col
beq L10A5 beq L10A5
lda #$15 lda #$15 ; ??? Mousetext?
jsr COUT jsr COUT
lda #$8D lda #HI(CR)
jsr COUT jsr COUT
L10A5: jmp PRODOS_SYS_START L10A5: jmp PRODOS_SYS_START
L10A8: clc next_entry:
lda $00 clc
adc $02 lda entry_ptr
sta $00 adc entry_length
lda $01 sta entry_ptr
adc #$00 lda entry_ptr+1
sta $01 adc #0
inc $04 sta entry_ptr+1
lda $04 inc entry_num
cmp $03 lda entry_num
cmp entries_per_block
bne L10E2 bne L10E2
ldy $1C02
ldy block_buffer + VolumeDirectoryBlockHeader::next_block
sty read_block_block_num sty read_block_block_num
lda $1C03 lda block_buffer + VolumeDirectoryBlockHeader::next_block+1
sta read_block_block_num+1 sta read_block_block_num+1
bne :+ bne :+ ; Error if next_block LSB/MSB are both 0
tya tya
bne :+ bne :+
ldy #MessageCode::kNoSysFile ldy #MessageCode::kNoSysFile
jmp ShowMessageAndMaybeChain jmp ShowMessageAndMaybeChain
: jsr L119F : jsr ReadBlock
lda #$00 lda #$00
sta $04 sta entry_num
lda #$04 lda #$04 ; skip past prev_block/next_block
sta $00 sta entry_ptr
lda #$1C lda #>block_buffer
sta $01 sta entry_ptr+1
L10E2: jmp L1021 L10E2: jmp entries_loop
L10E5: lda L11FE ;;; ???
.proc L10E5
lda L11FE
and #$03 and #$03
bne L10EE bne :+
ldy #$09 ldy #$09
L10EE: rts : rts
.endproc
.endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Call with message number in Y. ;;; Call with message number in Y.
@ -903,7 +938,7 @@ retry:
;; Fill params with current date/time. ;; Fill params with current date/time.
ldy #3 ldy #3
: lda DATELO,y : lda DATELO,y
sta file_info_params + $A,y ; mod_date sta file_info_params + GET_FILE_INFO_PARAMS::mod_date,y
dey dey
bpl :- bpl :-
@ -945,36 +980,47 @@ retry:
.endproc .endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Set prefix to most recently used device's name, and
;;; get this driver's file info (which holds current year)
;;; On error, displays the error and chains to next file.
.proc SetPrefixAndCheckSysFile .proc SetPrefixAndGetFileInfo
lda DEVNUM ; Most recently accessed device lda DEVNUM ; Most recently accessed device
sta on_line_unit_num sta on_line_unit_num
sta read_block_unit_num sta read_block_unit_num
;; Get the volume name
PRODOS_CALL MLI_ON_LINE, on_line_params PRODOS_CALL MLI_ON_LINE, on_line_params
bne ShowDiskErrorAndChain bne ShowDiskErrorAndChain
lda $120C ;; Convert to a path
and #$0F lda on_line_buffer
and #$0F ; mask off length
tay tay
iny iny
sty $120B sty set_prefix_buffer ; increase length by one...
lda #'/' lda #'/' ; for leading '/'
sta $120C sta on_line_buffer
;; Set the prefix
PRODOS_CALL MLI_SET_PREFIX, set_prefix_params PRODOS_CALL MLI_SET_PREFIX, set_prefix_params
bne ShowDiskErrorAndChain bne ShowDiskErrorAndChain
;; And get this file's info
PRODOS_CALL MLI_GET_FILE_INFO, file_info_params PRODOS_CALL MLI_GET_FILE_INFO, file_info_params
bne ShowDiskErrorAndChain bne ShowDiskErrorAndChain
rts rts
.endproc .endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Read a block
;;; On error, displays the error and chains to next file.
L119F: PRODOS_CALL MLI_READ_BLOCK, read_block_params .proc ReadBlock
PRODOS_CALL MLI_READ_BLOCK, read_block_params
bne ShowDiskErrorAndChain bne ShowDiskErrorAndChain
rts rts
.endproc
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
@ -1028,23 +1074,25 @@ on_line_params:
.byte 2 ; param_count .byte 2 ; param_count
on_line_unit_num: on_line_unit_num:
.byte $60 ; unit_num .byte $60 ; unit_num
.addr $120C ; data_buffer .addr on_line_buffer ; data_buffer
set_prefix_params: set_prefix_params:
.byte 1 ; param_count .byte 1 ; param_count
.addr $120B ; pathname .addr set_prefix_buffer ; pathname
block_buffer = $1C00
read_block_params: read_block_params:
.byte 3 ; param_count .byte 3 ; param_count
read_block_unit_num: read_block_unit_num:
.byte $60 ; unit_num .byte $60 ; unit_num
.addr $1C00 ; data_buffer .addr block_buffer ; data_buffer
read_block_block_num: read_block_block_num:
.word $0000 ; block_num .word $0000 ; block_num
open_params: open_params:
.byte 3 ; param_count .byte 3 ; param_count
.addr $121D ; pathname .addr open_pathname ; pathname
.addr $1C00 ; io_buffer .addr $1C00 ; io_buffer
open_params_ref_num: open_params_ref_num:
.byte 0 ; ref_num .byte 0 ; ref_num
@ -1078,6 +1126,10 @@ L1200:
;; buffer for variables, filename ;; buffer for variables, filename
.res 46, 0 .res 46, 0
set_prefix_buffer := $120B
on_line_buffer := set_prefix_buffer+1
open_pathname := $121D
str_system: str_system:
.byte ".SYSTEM" .byte ".SYSTEM"
strlen_str_system = .strlen(".SYSTEM") strlen_str_system = .strlen(".SYSTEM")

View File

@ -58,20 +58,47 @@ MLI_CLOSE := $CC
;;; Volume Directory Block Header structure ;;; Volume Directory Block Header structure
.scope VolumeDirectoryBlockHeader .scope VolumeDirectoryBlockHeader
prev_block := $00 prev_block = $00
next_block := $02 next_block = $02
entry_length := $23 entry_length = $23
entries_per_block := $24 entries_per_block = $24
header_length := $2B header_length = $2B
.endscope .endscope
;; File Entry structure ;; File Entry structure
.scope FileEntry .struct FileEntry
storage_type := $00 storage_type_name_length .byte
name_length := $00 file_name .res 15
file_name := $01 file_type .byte
file_type := $10 key_pointer .word
.endscope blocks_used .word
EOF .faraddr
creation .dword
version .byte
min_version .byte
access .byte
aux_type .word
last_mod .dword
header_pointer .word
.endstruct
.struct GET_FILE_INFO_PARAMS
param_count .byte
pathname .word
access .byte
file_type .byte
aux_type .word
storage_type .byte
blocks_used .word
mod_date .word
mod_time .word
create_date .word
create_time .word
.endstruct
.enum FileType
kSYS = $FF
.endenum
;;; ------------------------------------------------------------ ;;; ------------------------------------------------------------
;;; Monitor ;;; Monitor