BIOS Cassette (or Diskette) Functions

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search

Cassette Init

 BC68 CAS_SET_SPEED     ;in: HL=upper16bit, A=lower8bit
 BC6B CAS_NOISY         ;in: A=output "Press PLAY" messages (0=yes, >0=no)

Cassette (or Diskette) Input

 BC77 CAS_IN_OPEN       ;in: HL=fname, B=fnamelen, DE=workbuf,
                        ;out: HL=header, DE=dest, BC=siz, A=type, cy=err, zf
 BC7A CAS_IN_CLOSE      ;out: DE=workbuf, cy=0=failed (no open file)
 BC7D CAS_IN_ABANDON    ;out: DE=workbuf, cy=1, z=0, A=all_closed (FFh=yes)
 BC80 CAS_IN_CHAR       ;out: A=char, cy=0=error, zf=errtype
 BC83 CAS_IN_DIRECT     ;in: HL=dest, out: HL=entrypoint, cy=0=err, zf=errtype
 BC86 CAS_RETURN        ;in: A=char (undo CAS_IN_CHAR, char back to buffer)
 BC89 CAS_TEST_EOF      ;out: CY=0=eof (end of file)

Cassette (or Diskette) Output

 BC8C CAS_OUT_OPEN      ;in: HL=fname, B=fnamelen, DE=workbuf, out: HL,cy,zf
 BC8F CAS_OUT_CLOSE     ;out: DE=workbuf, cy=0=failed (zf=errtype)
 BC92 CAS_OUT_ABANDON   ;out: DE=workbuf, cy=1, z=0, A=all_closed (FFh=yes)
 BC95 CAS_OUT_CHAR      ;in: A=char, out: cy=0=error, zf=errtype
 BC98 CAS_OUT_DIRECT    ;in: HL=src, DE=len, BC=entrypoint, A=type, out: cy/zf

Cassette (or Diskette) Catalog

 BC9B CAS_CATALOG       ;in: DE=workbuf, out: DE=workbuf, cy=0=error

Cassette Single Block Access & Motor Control

 BC9E CAS_WRITE         ;in: HL=src, DE=len, A=ID(2Ch=header, 16h=data), out?
 BCA1 CAS_READ          ;in: HL=dest, DE=len, A=ID(2Ch=header, 16h=data), out?
 BCA4 CAS_CHECK         ;in: HL=src, DE=len, A=ID(2Ch=header, 16h=data), out?
 BC6E CAS_START_MOTOR   ;out: A.bit4 old motor status (0=off, 1=on), cy=0, z=1
 BC71 CAS_STOP_MOTOR    ;out: A.bit4 old motor status (0=off, 1=on), cy=0, z=1
 BC74 CAS_RESTORE_MOTOR ;in: A.bit4 new motor status (0=off, 1=on), cy=0, z=1

Machine Pack Boot Program

 BD13 MC_BOOT_PROGRAM    ;in: HL=loader_callback, out: starts program

Loads and starts a BINARY program, typically used when typing RUN"filename.bin" under BASIC. The callback should load the program from whatever source (CAS, DISK, or elsewhere), and should then return CY=1=okay & HL=entrypoint (or HL=0000h to reboot the BASIC ROM), or CY=0=failed. If the callback returns CY=1 then the program (or BASIC ROM) is started via MC_START_PROGRAM, otherwise, when CY=0, "*** PROGRAM LOAD FAILED ***" is displayed, and the OS (ie. typically BASIC) is restarted.

Machine Pack Start Program

 BD16 MC_START_PROGRAM   ;in: HL=entrypoint (0000h=BASIC), C=ROMcfg

Starts a BINARY program, typically used when typing RUN"filename.bin" under BASIC (expecting that the file is already loaded into memory). The function resets all BIOS memory, sets SP=C000h, DE=LORAM=0040h, HL=BAS_HIRAM=ABFFh, BC=BIN_HIRAM=B0FFh, and does then call the entrypoint (incoming C:HL) via RST 18h, if incoming HL was zero then it calls 0:C006h (ie. reboots the BASIC ROM). Observe that the program is started with only the raw BIOS initialized; but without extensions like AMSDOS. To install them (if needed), the entrypoint function should set HL=BC (to deallocate BASIC RAM), then call KL_ROM_WALK (to install all extension ROMs) or, set C=07h and call KL_INIT_BACK (to install only AMSDOS).