@@ -199,11 +199,9 @@ done_banner:
199199 bmi done_path
200200
201201 lda #OPC_JMP_abs
202- LDXY #reloc__QuitCmd
202+ LDXY #reloc__QuitFromIntBASIC
203203 sta reloc + (intbasic__WARM - BASIC_START)
204204 STXY reloc + (intbasic__WARM+1 - BASIC_START)
205- sta reloc + (intbasic__ERRMESS - BASIC_START)
206- STXY reloc + (intbasic__ERRMESS+1 - BASIC_START)
207205
208206done_path:
209207
@@ -270,40 +268,30 @@ done_path:
270268;;; Load program (if given) and invoke Integer BASIC
271269
272270.proc Initialize
273- ;; Do we have a path?
274- lda PATHBUF
275- bne have_path
276-
277- ;; No, just show with prompt
278- jsr ColdStart
279271 jsr SwapZP ; ProDOS > IntBASIC
280- jmp intbasic ::WARM
281-
282- ;; --------------------------------------------------
283- ;; Have path
272+ jsr intbasic ::COLD
273+ LDXY #OUR_HIMEM
274+ STXY intbasic::HIMEM
275+ jsr intbasic ::NEW ; reset PP, PV, stacks
276+ jsr SwapZP ; IntBASIC > ProDOS
284277
285- have_path:
278+ ;; Do we have a path?
279+ lda PATHBUF
280+ beq warm
286281 jsr LoadINTFile
287- bne quit
282+ bne warm
283+
284+ ;; Run it
288285 jsr SwapZP ; ProDOS > IntBASIC
289286 jmp intbasic ::RUN
290287
291- quit: jmp QuitCmd ; fail - just QUIT back to ProDOS
288+ ;; Show prompt
289+ warm: jsr SwapZP ; ProDOS > IntBASIC
290+ jmp intbasic ::WARM
292291.endproc ; Initialize
293292
294293;;; ============================================================
295294
296- .proc ColdStart
297- jsr SwapZP ; ProDOS > IntBASIC
298- jsr intbasic ::COLD
299- LDXY #OUR_HIMEM
300- STXY intbasic::HIMEM
301- jsr intbasic ::NEW ; reset PP, PV, stacks
302- jmp SwapZP ; IntBASIC > ProDOS
303- .endproc ; ColdStart
304-
305- ;;; ============================================================
306-
307295;;; Input: Path to load in `PATHBUF`
308296;;; Output: ProDOS error code in A ($00 = success)
309297;;; Assert: ProDOS ZP swapped in
@@ -332,8 +320,9 @@ open:
332320 ;; In theory we should check geteof_eof+2 and fail
333321 ;; if > 64k, but how would such a file be created?
334322
335- ;; At this point we're committed - reset HIMEM etc.
336- jsr ColdStart
323+ ;; At this point we're committed - reset HIMEM
324+ LDXY #OUR_HIMEM
325+ STXY intbasic::HIMEM
337326
338327 ;; Set up zero page locations for the calculation
339328 jsr SwapZP ; ProDOS > IntBASIC
@@ -670,7 +659,7 @@ dispatch:
670659syn: ldy #<intbasic::ErrMsg02 ;"SYNTAX"
671660 jmp intbasic ::ERRMESS
672661
673- NUM_CMDS = 17
662+ NUM_CMDS = 18
674663
675664cmdtable:
676665 scrcode "RUN" ; must be 0 for special handling
@@ -681,6 +670,8 @@ cmdtable:
681670 .byte 0
682671 scrcode "LOAD"
683672 .byte 0
673+ scrcode "CHAIN"
674+ .byte 0
684675 scrcode "PREFIX"
685676 .byte 0
686677 scrcode "CATALOG" ; must precede "CAT"
@@ -712,16 +703,17 @@ cmdtable:
712703 MonCmd := 0 ; ignored
713704 NomonCmd := 0
714705cmdproclo:
715- .byte <RunCmd,<QuitCmd,<SaveCmd,<LoadCmd,<PrefixCmd,<CatCmd,<CatCmd,<DeleteCmd,<RenameCmd,<BSaveCmd,<BLoadCmd,<BRunCmd,<PRCmd,<MonCmd,<NomonCmd,<LockCmd,<UnlockCmd
706+ .byte <RunCmd,<QuitCmd,<SaveCmd,<LoadCmd,<ChainCmd,< PrefixCmd,<CatCmd,<CatCmd,<DeleteCmd,<RenameCmd,<BSaveCmd,<BLoadCmd,<BRunCmd,<PRCmd,<MonCmd,<NomonCmd,<LockCmd,<UnlockCmd
716707cmdprochi:
717- .byte >RunCmd,>QuitCmd,>SaveCmd,>LoadCmd,>PrefixCmd,>CatCmd,>CatCmd,>DeleteCmd,>RenameCmd,>BSaveCmd,>BLoadCmd,>BRunCmd,>PRCmd,>MonCmd,>NomonCmd,>LockCmd,>UnlockCmd
708+ .byte >RunCmd,>QuitCmd,>SaveCmd,>LoadCmd,>ChainCmd,> PrefixCmd,>CatCmd,>CatCmd,>DeleteCmd,>RenameCmd,>BSaveCmd,>BLoadCmd,>BRunCmd,>PRCmd,>MonCmd,>NomonCmd,>LockCmd,>UnlockCmd
718709 .assert * - cmdproclo = NUM_CMDS * 2, error, "table size"
719710
720711cmdparse:
721712 .byte ParseFlags::path | ParseFlags::path_opt ; RUN
722713 .byte 0 ; BYE
723714 .byte ParseFlags::path ; SAVE
724715 .byte ParseFlags::path ; LOAD
716+ .byte ParseFlags::path ; CHAIN
725717 .byte ParseFlags::path | ParseFlags::path_opt ; PREFIX
726718 .byte ParseFlags::path | ParseFlags::path_opt ; CATALOG
727719 .byte ParseFlags::path | ParseFlags::path_opt ; CAT
@@ -1053,6 +1045,11 @@ seen_params:
10531045;;; ============================================================
10541046;;; "BYE"
10551047
1048+ .proc QuitFromIntBASIC
1049+ jsr SwapZP ; IntBASIC > ProDOS
1050+ .assert * = QuitCmd, error, "fall through"
1051+ .endproc
1052+
10561053.proc QuitCmd
10571054 MLI_CALL QUIT, quit_params
10581055 brk
@@ -1101,6 +1098,19 @@ seen_params:
11011098ret: rts
11021099.endproc ; LoadCmd
11031100
1101+ ;;; ============================================================
1102+ ;;; "CHAIN pathname"
1103+
1104+ .proc ChainCmd
1105+ jsr LoadINTFile
1106+ bne ret
1107+
1108+ jsr SwapZP ; ProDOS > IntBASIC
1109+ jmp intbasic ::RUNWARM
1110+
1111+ ret: rts
1112+ .endproc ; LoadCmd
1113+
11041114;;; ============================================================
11051115;;; "RUN pathname"
11061116
@@ -1109,6 +1119,8 @@ ret: rts
11091119 bne LoadCmd ::ret
11101120
11111121 jsr SwapZP ; ProDOS > IntBASIC
1122+ LDXY intbasic::LOMEM ; reset vars
1123+ STXY intbasic::PV
11121124 jmp intbasic ::RUN
11131125.endproc ; RunCmd
11141126
@@ -1635,12 +1647,11 @@ output_state:
16351647
16361648 ;; Exports
16371649 reloc__Initialize := reloc::Initialize
1638- reloc__QuitCmd := reloc::QuitCmd
1650+ reloc__QuitFromIntBASIC := reloc::QuitFromIntBASIC
16391651 reloc__CommandHook := reloc::CommandHook
16401652 reloc__HookCSW := reloc::HookCSW
16411653 intbasic__GETCMD := reloc::intbasic::GETCMD
16421654 intbasic__WARM := reloc::intbasic::WARM
1643- intbasic__ERRMESS := reloc::intbasic::ERRMESS
16441655
16451656 .assert * <= MLI, error, "collision"
16461657 .out .sprintf("MEM: $%04X end of Command Handler" , *)
0 commit comments