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.

My implementation of CP/M on the PCW16 supports calls from TE_ASK up to BANK2_RUN_ROUTINE.

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.

DD INIT - 0080h

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.


DD SETUP - 0083h

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.

[Recent PCW versions only] If HL=0, set up only one drive - the one whose number is given in C. DE holds the address of the parameter block.


DD READ SECTOR - 0086h

Read a floppy disc sector.

Entered with: B=CP/M bank, C=disc 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

DD WRITE SECTOR - 0089h

Write a floppy disc sector.

Entered with: B=CP/M bank, C=disc 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.


DD CHECK SECTOR - 008Ch

Verify a floppy disc sector.

Entered with: B=CP/M bank, C=disc 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.


DD FORMAT - 008Fh

Format a floppy disc track.

Entered with: B=CP/M bank, C=disc 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...

DD LOGIN - 0092h

Log in a floppy disc.

Entered with: C=disc 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

DD SEL FORMAT - 0095h

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 

DD DRIVE STATUS - 0098h

Get the drive status.

Entered with: C=disc 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

DD READ ID - 009Bh

Read a sector ID.

Entered with: C=disc 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

DD L DPB - 009Eh

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.


DD L XDPB - 00A1h

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.


DD L ON MOTOR - 00A4h

Turn the floppy drive motors on.

Preserves all registers and flags. Waits until the motors have spun up to speed before returning.


DD L T OFF MOTOR - 00A7h

Start countdown for turning the motors off.

Preserves all registers and flags.


DD L OFF MOTOR - 00AAh

Switch the floppy drive motors off immediately.

Corrupts AF, BC, DE and HL.


DD L READ - 00ADh

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.

DD L WRITE - 00B0h

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.

DD L SEEK - 00B3h

Seek to a track.

Entered with: C=disc unit+4*head, D=cylinder number, IX=address of XDPB.


CD SA INIT - 00B6h

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

CD SA BAUD - 00B9h

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.


CD SA PARAMS - 00BCh

Get SIO parameters.

Returns registers containing parameters as set by CD SA INIT.


TE ASK - 00BFh

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

Implemented on the PCW16.


TE RESET - 00C2h

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.

Implemented on the PCW16.


TE STL ASK - 00C5h

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.

Implemented on the PCW16, though nothing is ever displayed on the status line.


TE STL ON OFF - 00C8h

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.

Implemented on the PCW16, though nothing is ever displayed on the status line.


TE SET INK - 00CBh

Set screen palette.

Entered with: A=ink id; B=colour; C=flash value.

Corrupts AF, BC, DE and HL.

The ink number for B on the CPC, +3 and PCW16 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 and PCW16]
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.

TE SET BORDER - 00CEh

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.

Implemented on the PCW16.


TE SET SPEED - 00D1h

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 or a PCW16.


KM SET EXPAND - 00D4h

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.

Implemented on the PCW16.


KM SET KEY - 00D7h

Set what character a keypress translates to.

Entered with: B=ASCII value, C=key number, D=bitmap of shift states.

Corrupts AF and HL.

On the PCW16, the key number is the Rosanne code corresponding to that keynumber and shift state (except for keypad keys).

Special ASCII values are:

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 & PCW16], CAPS SHIFT   [Spectrum +3]
2 - ALT   [PCW],         SYMBOL SHIFT [Spectrum +3], CTRL       [PCW16]
3 - SHIFT+ALT [PCW],     EXTEND       [Spectrum +3], SHIFT+CTRL [PCW16]
4 - EXTRA [PCW],                                     TASK       [PCW16]

KM KT GET - 00DAh

Get a character/key number.

On the CPC6128:

Returns C=character, B=0.

On the PCW and +3:

If key pressed, 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   not defined
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]

On the PCW16:

If key pressed, returns C=keycode, B=Rosanne shift state. If not, returns BC corrupt. Always corrupts A.


KM KT PUT - 00DDh

Simulate a keypress..

Entered with: B=shift bitmap, C=key number.

On the +3 and PCW, the shift bitmap is:

Bit 0   not defined
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. The PCW shift lock is implemented in hardware and so cannot be changed by this call.

On the +3, Shift lock operates on the CAPS SHIFT key.

On the PCW16, B and C are a Rosanne shift bitmap and keycode respectively. The Caps/Num/Shift locks are not implemented.


KM SET SPEED - 00E0h

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.

Implemented on the PCW16.


CD VERSION - 00E3h

Get version numbers. Supported on the PCW16..

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
65 PCW16 (65 = 'A', ie "Anne")
The BIOS major version number is 2 for a PCW9512 or 9512+, 1 otherwise.

On a CPC6128, the machine specific version number is the ROM version.

On recent versions of PCW CP/M, H=0 and L is a bitmap of hardware detected:

On earlier PCW versions this word is zero.

On the PCW16, the machine specific version number is the address in bank 0 of a zero-terminated ASCII string containing the Rosanne version.


CD INFO - 00E6h

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; DE corrupt; HL=address of buffer table.

The buffer table holds addresses of disc buffers:

	DB	CP/M bank, 0FFh for end of table
	DW	start
	DW	length

Implemented on the PCW16, but HL returns 0.

On recent PCW versions, DE is not in fact corrupt, but holds flags for the two floppy drives (E = flags for A: D = flags for B:). The flags seem to be:


SCR RUN ROUTINE - 00E9h

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:

The character sets are located at:


FIND FID - 00ECh

Find the address of an installable device driver. Supported on the PCW16.

Entered with: DE=address of name (8 characters).

Returns: Carry true if driver present, HL=address of driver in bank 0 (PCW16: bank 2). Else carry false, HL corrupt. Always corrupts A,BC,DE.

This routine is only present in +3 CP/M, PCW CP/M versions higher than about 1.7, and PCW16 CP/M. It should not be called otherwise!

Some FID names you can try are:

^Z^Z^Z^Z^Z^Z^Z^Z
This somewhat oddly-named FID (the name is 8 bytes containing 1Ah) is the Cirtech hard disc driver. It has this name because it is inserted into memory by the Cirtech boot file (HD.SYS) rather than the FID loader. It doesn't exist on disc and doesn't have a filename.
HDRIVER
This is Cirtech's hard disc driver if you booted from a floppy containing HDRIVER.FID. I have had to use this technique once to repair a damaged EMT file on my hard drive.
MASTER
Although I have never seen this, I believe this is the file which allows a PCW to act as the master computer on a LocoLink connection (with another PCW as the slave).
RAMDISC
Spectrum +3 RAM disc driver.
SAVER
PCW or Spectrum +3 screensaver.
SERIAL
Spectrum +3 8250 UART driver, for third-party modem interfaces
ADRIVE
PCW16 floppy disc driver
MDRIVE
PCW16 RAMdisc driver
CRTPLUS
PCW16 screen and keyboard driver; versions also exist for Spectrum and PCW.

FID file format


[PCW16] BANK2 RUN ROUTINE - 00EFh

Run a routine with bank 2 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 works identically to SCR RUN ROUTINE, but calls code in bank 2.


PCW v1.4 extra calls

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.

PCW v1.15 extra calls

The following calls are present in version 1.15 of the PCW XBIOS, and are included for completeness and for comparison with the 1.4 calls above:

00EFh:  ?
00F2h:  Initialise the XBIOS.
00F5h:  SVC_D_CHANGED - report that
        the disc in drive B may have been changed.
00F8h:  ?
00FBh:  Display error message, ask whether to retry, ignore or cancel.
00FEh:  Ask user to insert the disc for A: or B:.
0101h:  Output a system message.
0104h:  Used by XMOVE and MOVE.

Return to archive listing