Programming notes: Difference between revisions
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[programming features|Programming Features]] - <strong>Miscellaneous Programming Notes</strong> | [[programming features|Programming Features]] - <strong>Miscellaneous Programming Notes</strong> | ||
== Misc Programming Notes == | |||
=== Rainbow Mode === | |||
If | If an <strong>F1</strong> character is placed inside a quoted text string that is being sent to the user, Rainbow Mode will be enabled. | ||
In this mode, characters are displayed using the system color sequence defined in SETUP. | |||
To disable Rainbow Mode, place an <strong>F3</strong> character inside the quoted text. | |||
< | Example: | ||
<code>"{F1}Rainbow text here{F3}"</code> | |||
=== Color Sequencing === | |||
<strong> | If an <strong>F5</strong> character is placed inside a quoted text string, the cursor will advance to the <em>next color</em> in the color sequence defined in SETUP. | ||
This allows color cycling within printed output without explicitly specifying each color. | |||
=== Border Color === | |||
If an <strong>F7</strong> character is placed inside a quoted text string, the border and screen background will switch to black. | |||
To restore the normal background color and uppercase mode, execute: | |||
<code>GOSUB 13680</code> | |||
=== Sequential File Display === | |||
To | To display a sequential file located in the <em>System Files</em> area: | ||
<code>F$="filename":GOSUB 205</code> | |||
This routine opens the file, sends its contents to both the screen and modem, and then closes the file. | |||
=== Data Input from File === | |||
Sequential files used for data storage can be read using standard BASIC file input commands. | |||
Example: | |||
<code>INPUT#</code> | |||
Although machine language routines exist to perform similar functions, they are not required for most applications. Standard BASIC file I/O generally performs adequately for typical BBS modules. | |||
=== Capture User Input === | |||
Color 64 provides several routines for capturing user input. | |||
<strong> | * To input a full line typed by the user: | ||
<code>GOSUB 310</code> | |||
The result is stored in the variable <strong>I$</strong>. | |||
* To read a single character from the modem or console: | |||
<code>GOSUB 110</code> | |||
If a character was typed, it will be stored in <strong>A$</strong>. | |||
* To prompt for a Yes/No response: | |||
<code>GOSUB 1010</code> | |||
The result (<code>Y</code> or <code>N</code>) will be returned in <strong>A$</strong>. | |||
< | * To display the standard "Are you sure?" confirmation prompt: | ||
<code>GOSUB 1005</code> | |||
=== Caller Log === | |||
To store information in the caller log, use one of the following methods: | |||
<code>A$="info to save":GOSUB 8004</code> | |||
or | |||
< | <code>I$="info to save":GOSUB 8003</code> | ||
These routines append the specified information to the caller log maintained by the BBS. | |||
=== Carrier Lost Check === | |||
After user input or sequential file reads, you can test the variable <strong>P</strong> to determine if the connection has been interrupted. | |||
{| class="wikitable | Possible values of <strong>P</strong> include: | ||
* <strong>P=255</strong> – Carrier lost or timeout occurred | |||
* <strong>P=1</strong> – Caller pressed <code>CTRL/P</code> to abort | |||
It is recommended that programs include the following line after input operations: | |||
<code>IF P THEN RETURN</code> | |||
This ensures the routine exits cleanly if the caller disconnects or aborts the operation. | |||
=== Disk Error Check === | |||
To check the disk error channel after accessing a disk drive: | |||
<code>GOSUB 510</code> | |||
If an error occurred, the message will automatically be printed to both the local screen and the caller's terminal. | |||
The following variables will contain the error information: | |||
* <strong>ER</strong> – Error number | |||
* <strong>ER$</strong> – Error description | |||
* <strong>ET</strong> – Error track | |||
* <strong>ES</strong> – Error sector | |||
Some disk status codes are not automatically displayed and must be handled manually if needed: | |||
* 62 | |||
* 63 | |||
* 64 | |||
* 73 | |||
If a <em>disk full</em> condition occurs, the routine will automatically attempt to validate the disk. | |||
=== Select System Files Drive === | |||
To select the System Files drive: | |||
<code>GOSUB 481</code> | |||
=== Convert Input (I$) to Numeric Format === | |||
To convert the string stored in <strong>I$</strong> into a numeric value: | |||
<code>GOSUB 610</code> | |||
The resulting numeric value will be stored in variable <strong>I</strong>. | |||
If <strong>I$</strong> contains non-numeric characters, the resulting value of <strong>I</strong> will be <code>0</code>. | |||
=== Spare Commands === | |||
The Color 64 command system includes several "spare" command slots that can be assigned to custom programs or modules. | |||
Refer to the following table to determine which program overlay and entry line are used by each spare command. | |||
{| class="wikitable" | |||
|- | |- | ||
|+Spare Command Reference Chart | |+ Spare Command Reference Chart | ||
! Command | ! Command | ||
! Loads Program | ! Loads Program | ||
! Executes Line | ! Executes Line | ||
|- | |- | ||
| Spare 1 ( | | Spare 1 (v8.1a default: Games) | ||
| √bbs.msgs | | √bbs.msgs | ||
| 13430 | | 13430 | ||
|- | |- | ||
| Spare 2 ( | | Spare 2 (v8.1a default: User Profile) | ||
| √bbs.xfer | | √bbs.xfer | ||
| 13440 | | 13440 | ||
|- | |- | ||
| Spare 3 | | Spare 3 | ||
| √bbs. | | √bbs.ovl | ||
| 13450 | | 13450 | ||
|- | |- | ||
| Line 100: | Line 174: | ||
|- | |- | ||
| Spare 6 | | Spare 6 | ||
| √bbs. | | √bbs.ovl | ||
| 13465 | | 13465 | ||
|- | |- | ||
| Spare 7 | | Spare 7 | ||
| √bbs. | | √bbs.ovl | ||
| 13470 | | 13470 | ||
|- | |- | ||
| Spare 8 | | Spare 8 | ||
| √bbs. | | √bbs.ovl | ||
| 13475 | | 13475 | ||
|- | |- | ||
| Spare 9 | | Spare 9 | ||
| √bbs. | | √bbs.ovl | ||
| 13480 | | 13480 | ||
|} | |} | ||
As | As shown above, each overlay has at least one spare command entry point. | ||
Spare commands <strong>6 through 9</strong> all branch to <strong>√bbs.ovl</strong>, which makes it convenient to place several smaller utilities in that overlay. | |||
This design allows: | |||
* √bbs.ovl – multiple small utilities | |||
* √bbs.ov2 / √bbs.ov3 – larger programs or menus | |||
In Color 64 <strong>v8.1a</strong>, Spare Commands 1 and 2 are already assigned (can be modified, if desired): | |||
* Spare 1 – Games Menu | |||
* Spare 2 – User Profile Editor | |||
If you | If you wish to run multiple programs from a single spare command, a common approach is to implement a small menu program. For example, Spare 4 or Spare 5 can load a menu which then branches to several internal subroutines depending on the user's selection. | ||
Next section: [[ | Next section: [[generic routines|Generic Routines]] | ||
[[programming features|Programming Features]] | [[programming features|Programming Features]] | ||
Latest revision as of 13:33, 7 March 2026
Programming Features - Miscellaneous Programming Notes
Misc Programming Notes
Rainbow Mode
If an F1 character is placed inside a quoted text string that is being sent to the user, Rainbow Mode will be enabled. In this mode, characters are displayed using the system color sequence defined in SETUP.
To disable Rainbow Mode, place an F3 character inside the quoted text.
Example:
"{F1}Rainbow text here{F3}"
Color Sequencing
If an F5 character is placed inside a quoted text string, the cursor will advance to the next color in the color sequence defined in SETUP. This allows color cycling within printed output without explicitly specifying each color.
Border Color
If an F7 character is placed inside a quoted text string, the border and screen background will switch to black.
To restore the normal background color and uppercase mode, execute:
GOSUB 13680
Sequential File Display
To display a sequential file located in the System Files area:
F$="filename":GOSUB 205
This routine opens the file, sends its contents to both the screen and modem, and then closes the file.
Data Input from File
Sequential files used for data storage can be read using standard BASIC file input commands.
Example:
INPUT#
Although machine language routines exist to perform similar functions, they are not required for most applications. Standard BASIC file I/O generally performs adequately for typical BBS modules.
Capture User Input
Color 64 provides several routines for capturing user input.
- To input a full line typed by the user:
GOSUB 310
The result is stored in the variable I$.
- To read a single character from the modem or console:
GOSUB 110
If a character was typed, it will be stored in A$.
- To prompt for a Yes/No response:
GOSUB 1010The result (YorN) will be returned in A$.
- To display the standard "Are you sure?" confirmation prompt:
GOSUB 1005
Caller Log
To store information in the caller log, use one of the following methods:
A$="info to save":GOSUB 8004
or
I$="info to save":GOSUB 8003
These routines append the specified information to the caller log maintained by the BBS.
Carrier Lost Check
After user input or sequential file reads, you can test the variable P to determine if the connection has been interrupted.
Possible values of P include:
- P=255 – Carrier lost or timeout occurred
- P=1 – Caller pressed
CTRL/Pto abort
It is recommended that programs include the following line after input operations:
IF P THEN RETURN
This ensures the routine exits cleanly if the caller disconnects or aborts the operation.
Disk Error Check
To check the disk error channel after accessing a disk drive:
GOSUB 510
If an error occurred, the message will automatically be printed to both the local screen and the caller's terminal.
The following variables will contain the error information:
- ER – Error number
- ER$ – Error description
- ET – Error track
- ES – Error sector
Some disk status codes are not automatically displayed and must be handled manually if needed:
- 62
- 63
- 64
- 73
If a disk full condition occurs, the routine will automatically attempt to validate the disk.
Select System Files Drive
To select the System Files drive:
GOSUB 481
Convert Input (I$) to Numeric Format
To convert the string stored in I$ into a numeric value:
GOSUB 610
The resulting numeric value will be stored in variable I.
If I$ contains non-numeric characters, the resulting value of I will be 0.
Spare Commands
The Color 64 command system includes several "spare" command slots that can be assigned to custom programs or modules.
Refer to the following table to determine which program overlay and entry line are used by each spare command.
| Command | Loads Program | Executes Line |
|---|---|---|
| Spare 1 (v8.1a default: Games) | √bbs.msgs | 13430 |
| Spare 2 (v8.1a default: User Profile) | √bbs.xfer | 13440 |
| Spare 3 | √bbs.ovl | 13450 |
| Spare 4 | √bbs.ov2 | 13455 |
| Spare 5 | √bbs.ov3 | 13460 |
| Spare 6 | √bbs.ovl | 13465 |
| Spare 7 | √bbs.ovl | 13470 |
| Spare 8 | √bbs.ovl | 13475 |
| Spare 9 | √bbs.ovl | 13480 |
As shown above, each overlay has at least one spare command entry point. Spare commands 6 through 9 all branch to √bbs.ovl, which makes it convenient to place several smaller utilities in that overlay.
This design allows:
- √bbs.ovl – multiple small utilities
- √bbs.ov2 / √bbs.ov3 – larger programs or menus
In Color 64 v8.1a, Spare Commands 1 and 2 are already assigned (can be modified, if desired):
- Spare 1 – Games Menu
- Spare 2 – User Profile Editor
If you wish to run multiple programs from a single spare command, a common approach is to implement a small menu program. For example, Spare 4 or Spare 5 can load a menu which then branches to several internal subroutines depending on the user's selection.
Next section: Generic Routines