Plug In: BASIC Aid - Chysn/VIC20-wAx2 GitHub Wiki
The BASIC Aid plug-in provides three utilities to renumber and link (put together) BASIC programs, and to un-NEW (a.k.a. "OLD") a BASIC program in the current stage.
Installation
.P "BA"
Usage
.U R [line [increment]]
.U L start-page [s] [s] [s] [s] [s] [s] [s]
.U O
Renumber Utility
To renumber the BASIC program in the current stage, use:
.U R [line [increment]]
where line and increment are hexadecimal bytes. line is the starting line number of the program after the renumber, and increment is the value added to the previous line.
If line is not provided, the renumbering will start at line 100. If increment is not provided, lines will increment by 10. The Renumber utility can be used to make room for additional lines of assembly if you need to add something.
1 .A 1800 LDY #"A"
2 .A * @@ TYA
3 .A * INY
4 .A * CPY #"Z"+1
5 .A * BNE @@
6 .A * RTS
.P "BA"
.U R 0A 0A
25 .A * JSR $FFD2
RUN
SYS 6144
Note: This Renumber utility only renumbers lines, as it is designed for easing assembly within BASIC. It will not renumber BASIC operands for GOTO, GOSUB, THEN, etc.
Link Utility
To link one or more BASIC programs from specified BASIC stages to the end of the program in the current BASIC stage, use:
.U L start-page [s] [s] [s] [s] [s] [s] [s]
where start-page and each s are 8-bit hexadecimal page numbers indicating the start of a BASIC stage (see Basic Stage Manager, p. 49). You may specify up to eight page numbers. The Link utility will add the BASIC program from each specified stage, in order, to the end of the current program.
Note: You may specify each stage any number of times, and you may specify the page of the current stage.
.↑ 12 NEW
10 ? "STAGE $12"
15 .A 1800 LDY #8
.↑ 20 NEW
20 ? "STAGE $20"
25 .A * STY $900F
.
↑ 2E NEW
10 ? "STAGE $2E"
15 .A * BRK
.↑ 12
.P "BA"
.U L 20 2E
.U R
LIST
RUN
SYS 6144
Notice that here the Renumber utility is run after the three stages are linked into one. This may or may not be warranted, depending on how your lines are numbered.
If you run out of memory in the current stage during the linking process, the Link utility will do these things:
- The entire command will be reverted. This means that if you specify six stages, and run out of memory on the fifth one, Link will revert your program back to its state before the Link utility was invoked.
- The Link utility will display the next memory location in the source stage that would have been copied, had memory not run out.
- An ?OUT OF MEMORY error will be displayed.
** Note:** It's okay to link into an empty stage, to build one program out of other ones.
** Note:** If you specify a stage without a BASIC program in it, Link will try its best, but you'll probably get junk. Save your nontrivial work!