Skip to content

Commit 12b4ae4

Browse files
Add CHAIN command. For #8
Also reworks the general run/load logic a bit.
1 parent 4ba42d9 commit 12b4ae4

File tree

7 files changed

+125
-61
lines changed

7 files changed

+125
-61
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This is a version of Steve Wozniak's Integer BASIC for the Apple II, with a wrap
77
* `SAVE path` saves the current program as an `INT` program file.
88
* `LOAD path` loads an `INT` program file.
99
* `RUN path` loads and runs an `INT` program file.
10+
* `CHAIN path` loads and runs an `INT` program file, without clearing variables.
1011
* `PREFIX` shows the current ProDOS prefix.
1112
* `PREFIX path` sets the current ProDOS prefix.
1213
* `CAT` or `CATALOG` shows the contents of the current directory.

intbasic.system.s

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

208206
done_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:
670659
syn: ldy #<intbasic::ErrMsg02 ;"SYNTAX"
671660
jmp intbasic::ERRMESS
672661

673-
NUM_CMDS = 17
662+
NUM_CMDS = 18
674663

675664
cmdtable:
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
714705
cmdproclo:
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
716707
cmdprochi:
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

720711
cmdparse:
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:
11011098
ret: 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", *)

package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ package () {
3737
add_file "out/intbasic.system.SYS" "IntBASIC.system#FF0000"
3838
add_file "res/PRODOS.SYS" "PRODOS#FF0000"
3939
add_file "res/WOZ.BREAKOUT.INT" "WOZ.BREAKOUT#FA0000"
40-
add_file "res/TESTS.INT" "TESTS#FA0000"
40+
add_file "res/APPLEVISION.INT" "APPLEVISION#FA0000"
4141
add_file "out/readme" "README#040000"
4242

4343
rm -r "$PACKDIR"

res/APPLEVISION.INT

5.82 KB
Binary file not shown.

res/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ Files in this directory are included in disk images.
22

33
* `PRODOS.SYS` - from ProDOS 2.4.2 (https://prodos8.com/)
44
* `WOZ.BREAKOUT.INT` - is the original published version
5-
* `TESTS.INT` - integration tests; the source is in `tests.txt`. To update:
5+
* `tests.txt` - integration tests. To run:
66
* `make && make package`
77
* `pbcopy < res/tests.txt`
88
* Launch Virtual ][
99
* mount `out/intbasic_system.2mg` & boot it
1010
* Paste at the `>` prompt
11-
* `SAVE TESTS`
12-
* Quit Virtual ][
13-
* `cadius EXTRACTFILE out/intbasic_system.2mg /INTBASIC/TESTS res`
14-
* `mv res/TESTS#FA0000 res/TESTS.INT`

res/TESTS.INT

-2.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)