Amstrad Extended BIOS calls
The Amstrad extended BIOS is accessed using the
USERF BIOS function. To call it, use:
CALL USERF
DEFW value
The value is a 16-bit address in memory bank 0 (user programs
normally run in bank 1). The (documented) XBIOS jumpblock starts at 0080h
and runs up to 00EEh.
Since the address of USERF may vary from
computer to computer, the following subroutine should be used to access it
in a machine-independent way:
USERF: PUSH HL
PUSH DE
LD HL,(1)
LD DE,57h
ADD HL,DE
POP DE
EX (SP),HL
RET
Frequently, these routines will require an address to be passed to them.
Unless they are being called from within Bank 0, the address should be
above 0C000h so that it is visible to the routine.
The alternate register set is preserved during the call, but the values of
the alternate registers will not be available to the called routine.
Initialise the floppy disc driver.
When called, this resets the floppy drives to their default parameters
(for 3" or 3.5" drives, depending on computer), and turns the disc motor off.
Corrupts AF,BC,DE,HL.
Set up the floppy disc driver.
Entered with: HL=address of parameter block, above 0C000h.
Corrupts AF, BC, DE and HL. The parameter block is formed:
DB motor on timeout, 10ths of a second
DB motor off timeout, 10ths of a second
DB write current off time in 10 uS units
DB head settle time, milliseconds.
DB step rate, milliseconds.
DB head unload delay in 32ms units.
DB (2*head load delay in 4ms units)+non DMA mode.
Read a floppy disc sector.
Entered with: B=CP/M bank, C=disk unit(0 or 1), D=track(0 based),
E=sector (0 based), HL=load address within bank, IX=address of drive
XDPB.
Returns: Carry set if OK, reset if error. A=error number 0-9.
BC, DE and HL are corrupted.
Error codes are:
0: Drive not ready
1: Write protected
2: Seek fail
3: Data error
4: No data
5: Missing address mark
6: Bad format
7: Unknown error
8: Media changed
9: Unsuitable media
Write a floppy disc sector.
Entered with: B=CP/M bank, C=disk unit(0 or 1), D=track(0 based),
E=sector (0 based), HL=address within bank of sector, IX=address of drive
XDPB.
Returns: Carry set if OK, reset if error. A=error
number 0-9.
BC, DE and HL are corrupted.
Verify a floppy disc sector.
Entered with: B=CP/M bank, C=disk unit(0 or 1), D=track(0 based),
E=sector (0 based), HL=address within bank of sector, IX=address of drive
XDPB.
Returns: If error: Carry reset, A=error
number 0-9. If no error, Carry set, Zero set if sector matched sector in
memory. Otherwise Zero reset. BC, DE and HL are corrupted.
Format a floppy disc track.
Entered with: B=CP/M bank, C=disk unit(0 or 1), D=track(0 based),
E=filler byte, HL=address within bank of format data, IX=address of drive
XDPB.
Returns: If error: Carry reset, A=error
number 0-9. If no error, Carry set. BC, DE and HL are corrupted.
The format data area is a list of sectors; each entry occupies four bytes.
The entry for a sector is laid out as:
DB track number
DB head number
DB sector number
DB physical sector shift. 0 => 128, 1 => 256, 2 => 512...
Log in a floppy disc.
Entered with: C=disk unit(0 or 1), IX=address of drive
XDPB.
Returns: If OK, carry set, A=format type, BC corrupt, DE=size of
double-bit allocation vector, HL=size of hash table, XDPB initialised.
If error, A=error number, BC DE HL XDPB corrupt.
Format types are:
0: PCW Single Sided Single Density
1: CPC System format
2: CPC Data format
3: PCW Double Sided Double Density
Preload an XDPB with a standard format.
Entered with: A=format IX=address of destination
XDPB.
Returns: If OK, carry set, A=format type, BC corrupt, DE=size of
double-bit allocation vector, HL=size of hash table, XDPB initialised.
If error, A=error number, BC DE HL XDPB corrupt.
Format types are:
0: PCW standard SS/SD, 173k
1: CPC System format, 169k
2: CPC Data format, 180k
3: PCW standard DS/DD, 706k
Get the drive status.
Entered with: C=disk unit(0 or 1); bit 2 of C contains head number.
Returns HL corrupt, A=uPD765a status register 3:
bit 7: ?
bit 6: Write protected
bit 5: Ready if bits 5 and 6 are zero the drive is not present.
bit 4: Track 0
bit 3: ?
bit 2: Head
bit 1: Unit high bit (always zero, Units 2-3 are not implemented).
bit 0: Unit low bit
Read a sector ID.
Entered with: C=disk unit(0 or 1); D=track(0 based); IX=address of
XDPB.
Returns: If OK, Carry set, A=physical sector number. If error,
Carry reset, A=error number. Always, BC and DE are
corrupt and HL=address of FDC output buffer:
DB number-of-result-bytes
DB result bytes
Initialise a DPB from a boot record.
Entered with: HL=address of boot
record. IX=address of DPB.
Returns: If carry set, OK, A=disc type (as for DD
LOGIN). If carry clear, A=error number. BC DE and HL
are always corrupted.
Note: This function always fails on the CPC6128.
Initialise an XDPB from a boot record.
Entered with: HL=address of boot
record. IX=address of XDPB.
Returns: If carry set, OK, A=disc type (as for DD
LOGIN). If carry clear, A=error number. BC DE and HL
are always corrupted.
Note: This function always fails on the CPC6128.
Turn the floppy drive motors on.
Preserves all registers and flags. Waits until the motors have spun up
to speed before returning.
Start countdown for turning the motors off.
Preserves all registers and flags.
Switch the floppy drive motors off immediately.
Corrupts AF, BC, DE and HL.
Execute a uPD765A read command.
Entered with: HL=address of input buffer.
DB CP/M bank
DW address of data buffer within bank
DW number of data bytes
DB number of uPD765a command bytes
DB uPD765a command bytes
Returns AF, BC, DE corrupt; HL=address of results buffer:
DB number of result bytes
DB result bytes
The floppy drive motors must be running.
Execute a uPD765A write, scan or format command.
Entered with: HL=address of input buffer.
DB CP/M bank
DW address of data buffer within bank
DW number of data bytes
DB number of uPD765a command bytes
DB uPD765a command bytes
Returns AF, BC, DE corrupt; HL=address of results buffer:
DB number of result bytes
DB result bytes
The floppy drive motors must be running.
Seek to a track.
Entered with: C=Disk unit+4*head, D=cylinder number, IX=address
of XDPB.
Initialise serial port.
Entered with: A=mode or command. If A is a mode, D=no. of stop bits,
E=parity, H=number of receiver data bits, L=number of transmitter data bits.
Corrupts AF, BC, DE and HL.
Modes:
00h - No handshake
0FFh - Handshake
0FEh - Interrupt, no handshake (on Spectrum +3, behaves as 00h).
0FDh - Interrupt, handshake (on Spectrum +3, behaves as 0FFh).
Commands:
80h - Drop DTR
7Fh - Raise DTR
7Eh - Drop RTS (no effect on Spectrum +3)
7Dh - Raise RTS (no effect on Spectrum +3)
Number of stop bits:
D=0 1 stop bit
D=1 1.5 stop bits (on Spectrum +3, behaves as D=2)
D=2 2 stop bits
Parity:
E=0 None
E=1 Odd
E=2 Even
Set SIO baud rate.
Entered with: H=receiver baudrate, L=transmitter baudrate.
Corrupts AF, BC, DE, HL.
Baud rates are numbered from 1-15; see here.
Get SIO parameters.
Returns registers containing parameters as set by CD SA INIT.
Get screen size and cursor position.
Returns:
B=top row of viewport in physical screen coordinates on CPC6128, BC is
C=left column of viewport in physical screen coordinates always zero.
D=height of viewport-1
E=width of viewport-1
H=cursor row, viewport coordinates
L=cursor column, viewport coordinates
Reset the terminal emulator.
Corrupts AF, BC, DE and HL.
Resets viewport to full screen, character set to Language 0 (USA), no
special effects, screen colours to default, cursor enabled etc. Can be
called if the screen has been altered by other programs than the CRT driver.
Is the status line enabled?
Returns: A=0 if status line disabled, 0FFh if enabled. Zero false if
status line visible, true if not visible.
On the +3, the status line can be enabled and invisible.
Turn the status line on or off.
Entered with: A=0 for off or 0FFh for on. Corrupts F, BC, DE, HL.
The status line, if enabled, displays BIOS error messages and the status of
the PCW's built-in printer. If it is disabled, BIOS error messages go to the
main screen.
A similar status line is used in DOS Plus, where it lists the names of
programs running in the background.
Set screen palette.
Entered with: A=ink id; B=colour; C=flash value.
Corrupts AF, BC, DE and HL.
- On the CPC, Ink 0 is the background, Ink 1 is the foreground. Other inks
are not used by CP/M. The colour is a value from 0-63; the flash value is
another colour. If they are different, the ink will alternate between the
two.
- On the PCW, Ink 0 is the background, Ink 1 is the foreground. Other inks
are ignored. Please let me know if you have any more information on this call for the PCW.
(See note on my homepage for the email address.)
- On the Spectrum +3, Ink 0 is the background and border, and Ink 1 is the
foreground. The colour is a value from 0-63; if the flash value differs from
the colour value, the ink is set to flash. Unlike the PCW and CPC, setting
colours with this call does not change the colours already visible onscreen.
The ink number for B on the CPC and +3 is computed thus:
Bits 0-1: Blue
Bits 2-3: Red
Bits 4-5: Green
Bits 6-7: Ignored
The RGB values are:
00 Colour is off
01 Colour is on, low intensity [CPC]/ normal intensity [Spectrum]
10 Colour is on, normal intensity
11 Colour is on, high intensity
BUG: This function does not work under PCW or +3 CP/M, because the
values in B and C are always reset to zero before they are examined.
Set screen border colour.
Entered with: B=colour, as above.
Corrupts AF, BC, DE and HL.
On the PCW, bit 7 of B is set for reversed video (dark text on light
background) and bit 6 is set if the screen is to be blank.
Set colour flash speed.
Entered with: H=time spent in main colour, L=time spent in alternative
colour, specified in 50ths of a second.
Corrupts AF and HL.
Has no effect on a Spectrum +3.
Set a keyboard expansion string.
Entered with: B=string number, 80h-9Eh; C=length of string;
HL=address of string.
Returns: If OK, Carry set. If string too long or B invalid, Carry
clear. A, BC, DE, HL corrupted.
Set what character a keypress translates to.
Entered with: B=ASCII value, C=key number, D=bitmap of shift states.
Corrupts AF and HL.
Special ASCII values are:
- PCW and Spectrum:
- 80h-9Eh: Expansion tokens
- 9Fh: Ignore this keypress
- CPC:
- 0FDh: Caps lock
- 0FEh: Shift lock
- 0FFh: Ignore
If a bit is set in the shift states bitmap, it indicates that the table for
that combination of shift keys should be modified. The bits mean:
0 - Unshifted keys
1 - SHIFT [PCW], CAPS SHIFT [Spectrum +3]
2 - ALT [PCW], SYMBOL SHIFT [Spectrum +3]
3 - SHIFT+ALT [PCW], EXTEND [Spectrum +3]
4 - EXTRA [PCW]
Get a character/key number.
On the CPC6128:
Returns C=character, B=0.
On the PCW and +3:
If OK, returns C=key number, B=shift bitmap. If not, returns carry false,
C corrupt, B=shift bitmap. Corrupts A.
The shift bitmap is:
Bit 0 ?
Bit 1 EXTRA?
Bit 2 Generated by a key repeat
Bit 3 Caps lock
Bit 4 Num lock
Bit 5 SHIFT [PCW]; CAPS [Spectrum +3]
Bit 6 Shift lock
Bit 7 ALT [PCW]; SYMB [Spectrum +3]
Simulate a keypress..
Entered with: B=shift bitmap, C=key number.
The shift bitmap is:
Bit 0 ?
Bit 1 EXTRA [PCW]; EXTEND [+3]
Bit 2 Generated by a key repeat
Bit 3 Caps lock
Bit 4 Num lock
Bit 5 SHIFT [PCW]; CAPS [Spectrum +3]
Bit 6 Shift lock
Bit 7 ALT [PCW]; SYMB [Spectrum +3]
On the CPC, this function has no effect. The main use of this function is to
change the state of Caps/Num/Shift lock; use KM KT PUT to change the lock, and
KM KT GET to swallow the simulated keypress.
On the +3, Shift lock operates on the CAPS SHIFT key.
Set the keyboard reset speed..
Entered with: H=initial delay, L=subsequent delay.
Corrupts AF.
Both delays are given in fiftieths of a second. 0 means 256, ie keys
hardly ever repeat. The initial delay takes place before a key repeats at
all; the subsequent delay takes place between further repetitions.
Get version numbers..
Returns: A=machine type, B=BIOS major version number, C=BIOS minor
version number, HL=machine specific version number.
Machine types are:
0 CPC6128
1 PCW8000/9000/10 series
3 Spectrum +3
The BIOS major version number is 2 for a PCW9512, 1 otherwise. The machine
specific version number is the ROM version for a CPC6128, and contains
information about the floppy drive types (3" or 3.5") on a PCW.
Get system information..
Returns: A=0FFh if second floppy drive fitted, otherwise 0;
B=memory size/16k; C=0FFh if serial port present, otherwise 0; HL=address
of buffer table. In recent PCW versions, DE holds information on floppy drive
types; otherwise DE is corrupt.
The buffer table holds addresses of disc buffers:
DB CP/M bank, 0FFh for end of table
DW start
DW length
Run a routine with the screen memory visible.
Entered with: BC=address of routine. DE, HL, IX and IY are passed to
it.
Returns BC corrupt; AF, DE, HL, IX, IY as returned by routine.
This routine does not exist in CPC6128 CP/M. Instead of using:
LD BC,routine
CALL USERF
DEFW 00E9h
the routine
CALL USERF
DEFW routine
should be used. On the Spectrum +3, the above calls have an identical effect.
On the PCW, however, the screen environment is unique and can only be accessed
using this function.
The screen is located at:
- CPC: 4000h in Bank 0.
- PCW: 5C00h in the screen environment, with Roller-RAM at 0B600h.
- Spectrum: 4000h in Bank 0 (left-hand half); 4000h in Bank 2 (right-hand
half).
The character sets are located at:
- CPC: 8000h in Bank 0.
- PCW: 0B800h in the screen environment.
- Spectrum: 3000h in Bank 0 (8x8 characters) and 3800h in Bank 0 (5x8 characters).
Find the address of an installable device driver.
Entered with: DE=address of name (8 characters).
Returns: Carry true if driver present, HL=address of driver in
bank 0. Else carry false, HL corrupt. Always corrupts A,BC,DE.
This routine is only present in +3 CP/M and PCW CP/M versions higher than
about 1.7. It should not be called otherwise!
The following calls are present in version 1.4 of the PCW XBIOS, and
are included simply for completeness:
00ECh: Initialise the XBIOS
00EFh: Is character device B ready to input?
00F2h: Input character from device B
00F5h: Is device B ready to output?
00F8h: Output character C to device B
00FBh: Initialise device C, B=baudrate
00FEh: Display error message, ask whether to retry, ignore or cancel.
0101h: Ask user to insert the disc for A: or B:.
0104h: Output a system message.
0107h: Used by XMOVE and MOVE.