Skip to content

Commit

Permalink
Invoker: Populate $280 same as Bitsy Bye when launching BASIS.SYSTEM
Browse files Browse the repository at this point in the history
ProDOS 2.4's Bitsy Bye populates $280 with the containing path for the
target file when invoking BASIS.SYSTEM as a fallback interpreter. The
documented ProDOS convention is to set $280 to the path to the system
file itself, but Bitsy Bye does its own thing. For better
compatibility, do the same specifically when launching BASIS.SYSTEM,
but not other interpreters.

Updated behavior comparison:

                Bitsy                DeskTop
/VOL/FILE invoked:
    Prefix      /VOL/                /VOL/
    $2006       FILE                 FILE
    $280        /VOL                 /VOL
    $380        /VOL/BASIS.SYSTEM    /VOL/BASIS.SYSTEM
/VOL/SUBDIR/FILE invoked:
    Prefix      /VOL/SUBDIR/         /VOL/SUBDIR/
    $2006       FILE                 FILE
    $280        /VOL/SUBDIR          /VOL/SUBDIR
    $380        /VOL/BASIS.SYSTEM    /VOL/BASIS.SYSTEM

Also note that Bitsy Bye has the high bits set for '/' characters in
the $280 path (i.e. $AF not $2F) and *all* characters in the $380
path. DeskTop populates both paths with high bits clear.
  • Loading branch information
inexorabletash committed Dec 29, 2024
1 parent 00f53f5 commit 62082c0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ INVOKER_PREFIX := $220 ; Prefix to set
INVOKER := $290 ; Invoke other programs
INVOKER_FILENAME := $280 ; File to invoke (PREFIX must be set)
INVOKER_INTERPRETER := $380 ; If non-empty, use path as interpreter.
INVOKER_BITSY_COMPAT := $3C1 ; bit7 = set $280 like Bitsy does
;;; ============================================================
;;; Default Font
Expand Down
9 changes: 7 additions & 2 deletions desktop/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,9 @@ sys_disk:
jsr SetCursorWatch ; before invoking

;; Assume no interpreter to start
copy #0, INVOKER_INTERPRETER
lda #0
sta INVOKER_INTERPRETER
sta INVOKER_BITSY_COMPAT

;; Easiest to assume absolute path later.
param_call MakePathAbsolute, src_path_buf
Expand Down Expand Up @@ -937,7 +939,10 @@ retry: jsr GetSrcFileInfo
;; Fallback - try BASIS.SYSTEM
fallback:
jsr CheckBasisSystem ; Is fallback BASIS.SYSTEM present?
bcc launch ; yes, continue below
IF_CC ; yes, continue below
copy #$80, INVOKER_BITSY_COMPAT
bmi launch ; always
END_IF
param_jump ShowAlertParams, AlertButtonOptions::OK, aux::str_alert_cannot_open

;; --------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions lib/invoker.s
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ load_target:
sta BITSY_SYS_PATH,x
dex
bpl :-

;; When launching BASIS.SYTEM, ProDOS 2.4's Bitsy Bye populates
;; $280 with the path containing the target file.
BITSY_DIR_PATH := $280
bit INVOKER_BITSY_COMPAT
IF_NS
ldy INVOKER_PREFIX
: lda INVOKER_PREFIX,y
sta BITSY_DIR_PATH,y
dey
bpl :-
END_IF

END_IF

;; Set return address to the QUIT call below
Expand All @@ -149,6 +162,8 @@ exit: rts

PAD_TO ::INVOKER_INTERPRETER
.res ::kPathBufferSize, 0
ASSERT_ADDRESS ::INVOKER_BITSY_COMPAT
.byte 0

;;; ============================================================

Expand Down
6 changes: 5 additions & 1 deletion selector/app.s
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ fail: jmp ClearSelectedIndex
;; Ensure it's BIN, SYS, S16 or BAS (if BS is present)

check_type:
copy #0, INVOKER_BITSY_COMPAT
lda file_info_params::file_type
cmp #FT_BASIC
bne not_basic
Expand All @@ -1591,7 +1592,10 @@ not_basic:
beq check_path

jsr CheckBasisSystem ; Is fallback BASIS.SYSTEM present?
beq check_path
IF_EQ
copy #$80, INVOKER_BITSY_COMPAT
bmi check_path ; always
END_IF

;; Don't know how to invoke
lda #AlertID::selector_unable_to_run
Expand Down

0 comments on commit 62082c0

Please sign in to comment.