4cade/res/ports/common/src/prodos.init.a

55 lines
1.4 KiB
Plaintext

;license:MIT
;(c) 2024 by 4am
;
;
; Ensure ProDOS has a current prefix, otherwise opening any file will fail,
; which is bad. If launched from Bitsy Bye, there will be no current prefix.
; In that case, we get the boot volume name, then set the prefix to that.
; PREFIX_BUFFER ($40 bytes) is clobbered but may be reused after.
;
prefix_loop
jsr PRODOS_MLI
op_prefix
!byte CMD_GETPREFIX ; self-modified
!word parm_prefix
ldx PREFIX_BUFFER
bne clear_memory_map
; get boot volume name
lda PRODOS_BOOT_UNIT
sta parm_online_unit
jsr PRODOS_MLI
!byte CMD_ONLINE
!word parm_online
lda PREFIX_BUFFER+1
and #$0F
tax
inx
stx PREFIX_BUFFER
lda #$2F
sta PREFIX_BUFFER+1
; PREFIX_BUFFER is now a length-prefixed string
; of '/' + the boot volume name
dec op_prefix ; -> CMD_SETPREFIX
bne prefix_loop ; always branches
parm_prefix
!byte 1
!word PREFIX_BUFFER
parm_online
!byte 2
parm_online_unit
!byte SELF_MODIFIED_BYTE
!word PREFIX_BUFFER+1
clear_memory_map
; clear ProDOS memory bitmap
ldx #$17
lda #$00
- sta PRODOS_MEMORY_MAP, x
dex
bpl -