Programming notes

From Color 64 BBS Wiki

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 1010  
 The result (Y or N) 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/P to 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.

Spare Command Reference Chart
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

Programming Features