Table of Contents

Firmware summary

The Firmware Jumpblock is the recommended method of communicating with the routines in the lower ROM - it is used by BASIC, and it should also be used by other programs. The reason for using the jumpblock is that the routines in the lower ROM are located at different positions on the different machines. The entries in the jumpblock, however, are all in the same place - the instructions in the jumpblock redirect the computer to the correct place in the lower ROM.

Thus, providing a program uses the jumpblock, it should work on any CPC computer. By altering the firmware jumpblock it is possible to make the computer run a different routine from normal. This could either be a different routine in the lower or upper ROM, or a routine written by the user - this is known as 'patching the jumpblock'. It is worth noting that because BASIC uses the firmware jumpblock quite heavily, it is possible to alter the effect of BASIC commands.

The following example will change the effect of calling SCR SET MODE (&BC0E) - instead of changing the mode, any calls to this location will print the letter 'A'. The first thing to do is to assemble the piece of code that will be used to print the letter - this is printed below and starts at &4000.

	ORG &4000
	LD A,65      ; 65 IS ASCII FOR 'A'
	CALL &BB5A   ; TXT OUTPUT
	RET          ; RETURN FROM SUBROUTINE

The jumpblock entry for SCR SET MODE is now patched so that it reroutes all calls to &BC0E away from the lower ROM and to our custom routine at &4000. This is done by changing the bytes at &BC0E, &BC0F and &BC10 to &C3, &00, &40 respectively (ie JP &4000). Any calls to &BC0E or MODE commands will now print the letter A instead of changing mode.

The indirections jumpblock contains a small number of routines which are called by the rest of the firmware. By altering this jumpblock, it is possible to alter the way in which the firmware operates on a large scale - thus it is not always necessary to patch large numbers of entries in the firmware jumpblock.

There are two jumpblocks which are to do with the Kernel (ie the high and low Kernel jumpblocks). The high jumpblock allows ROM states and interrupts to be altered, and also controls the introduction of RSXs. The low jumpblock contains general routines and restart instructions which are used by the computer for its own purposes.

LowKernel Jumpblock

Additionnal informations can be found in SOFT968.

&0000 - RESET ENTRY

Resets the computer as if it has just been switched on.

Exit

This routine is never returned from.

Notes

After initialisation of the hardware and firmware, control is handed over to ROM 0 (usually BASIC).

&0008 - LOW JUMP

Jumps to a routine in either the lower ROM or low RAM.

Entry
Exit

Notes

The RST &08 instruction is followed by a two byte low address, which is defined as follows:

This command is used by the majority of entries in the main firmware jumpblock.

	rst &08		 ; LOW JUMP
	dw low_address	 ; address where to jump

&000B - KL LOW PCHL

Jumps to a routine in either the lower ROM or low RAM

Entry
Exit

* The registers are as set by the routine in the lower ROM or RAM or are returned unaltered.

Notes

The two byte low address in the HL register pair is defined as follows:

	ld hl,low_address	 ; address where to jump
	call &0B		 ; KL LOW PCHL

&000E - PCBC INSTRUCTION

Jumps to the specified address.

Entry
Exit

&0010 - SIDE CALL

Calls a routine in ROM, in a group of up to four foreground ROMs

Entry
Exit

Notes

The RST &10 instruction is followed by a two byte side address, which is defined as follows:

	rst &10		 ; SIDE CALL
	dw call_address	 ; address to call

&0013 - KL SIDE PCHL

Calls a routine in another ROM.

Entry
Exit

Notes

The two byte side address is defined as follows:

&0016 - PCDE INSTRUCTION

Jumps to the specified address.

Entry
Exit

&0018 - FAR CALL

Calls a routine anywhere in ROM or ROM.

Entry
Exit

Notes

The RST &18 instruction is followed by a two byte in-line address. At this address, there is a three byte far address, which is defined as follows:

When it is retumed from, the ROM selection and state are restored to their settings before the RST 3 command.

&001B - KL FAR PCHL

Calls a routine, given by the far address in HL & C, anywhere in RAM or ROM.

Entry
Exit

Notes

See FAR CALL above for more details on the ROM select byte.

&001E - PCHL INSTRUCTION

Jumps to the specified address.

Entry
Exit

&0020 - RAM LAM

Puts the contents of a RAM memory location into the A register.

Entry
Exit

Notes

This routine always reads from RAM, even if the upper or lower ROM is enabled.

&0023 - KL FAR CALL

Calls a routine anywhere in RAM or ROM.

Entry
Exit

Notes

See FAR CALL for more details on the three byte far address.

&0028 - FIRM JUMP

Jumps to a routine in either the lower ROM or the central 32K of RAM.

Entry
Exit

Notes

The RST &28 instruction is followed by a two byte address, which is the address to jump to; before the jump is made, the lower ROM is enabled, and is disabled when the destination routine is returned from.

&0030 - USER RESTART

This is an RST instruction that may be set aside by the user for any purpose.

Entry

Defined by the user.

Exit

Defined by the user.

Notes

The bytes from &0030 to &0037 are available for the user to put their own code in if they wish.

&0038 - INTERRUPT ENTRY

Deals with normal interrupts.

Exit

Notes

The RST &38 instruction must not be used by the user; any external interrupts that are generated by hardware on the expansion port will be dealt with by the EXT INTERRUPT routine.

&003B - EXT INTERRUPT

This area is set aside for dealing with external interrupts that are generated by any extra hardware.

Exit

Notes

If any external hardware is going to generate interrupts, then the user must patch the area from &003B to &003F so that the computer can deal with the external interrupt; when an external interrupt occurs, the lower ROM is disabled and the code at &003B is called; the default external interrupt routine at &003B simply returns, and this will cause the computer to hang because the interrupt will continue to exist!

HighKernel Jumpblock

Additionnal informations can be found in SOFT968.

&B900 - KL U ROM ENABLE

Enables the current upper ROM.

Exit

Notes

After this routine has been called, all reading from addresses between &C000 and &FFFF refers to the upper ROM, and not the top 16K of RAM which is usually the screen memory; any writing to these addresses still affects the RAM as, by its nature, ROM cannot be written to.

&B903 - KL U ROM DISABLE

Disables the upper ROM.

Exit

Notes

After this routine has been called, all reading from addresses between &C000 and &FFFF refers to the top 16K of RAM which is usually the screen memory.

&B906 - KL L ROM ENABLE

Enables the lower ROM.

Exit

Notes

After this routine has been called, all reading from addresses between &0000 and &4000 refers to the lower ROM, and not the bottom 16K of RAM; any writing to these addresses still affects the RAM as a ROM cannot be written to; the lower ROM is automatically enabled when a firmware routine is called, and is then disabled when the routine returns.

&B909 - KL L ROM DISABLE

Disables the lower ROM.

Exit

Notes

After this routine has been called, all reading from addresses between &0000 and &4000 refers to the bottom 16K of RAM; the lower ROM is automatically enabled when a firmware routine is called, and is then disabled when the routine returns.

&B90C - KL ROM RESTORE

Restores the ROM to its previous state.

Entry
Exit

Notes

The previous four routines all return values in the A register which are suitable for use by KL ROM RESTORE.

&B90F - KL ROM SELECT

Selects an upper ROM and also enables it.

Entry
Exit

&B912 - KL CURR SELECTION

Gets the ROM select address of the current ROM.

Exit

&B915 - KL PROBE ROM

Gets the class and version of a specified ROM.

Entry
Exit

Notes

The ROM class may be one of ine following:

&B918 - KL ROM DESELECT

Selects the previous upper ROM and sets its state.

Entry
Exit

Notes

This routine reverses the action of KL ROM SELECT, and uses the values that it returns in B and C.

&B91B - KL LDIR

Switches off the upper and lower ROMs, and moves a block of memory.

Entry

As for a standard LDIR instruction:

Exit

&B91E - KL LDDR

Switches off the upper and lower ROMs, amd moves a block of memory.

Entry

As for a standard LDDR instruction:

Exit

&B921 - KL POLL SYNCHRONOUS

Tests whether an event with a higher priority than the current event is waiting to be dealt with.

Exit

In either case:

&B92A - KL SCAN NEEDED

Ensures that the keyboard is scanned when the next ticker interrupt occurs.

Exit

Notes

This routine is useful for scanning the keyboard when interrupts are disabled and normal key scanning is not occuring.

The Key Manager

The Key Manager is the pack associated with the keyboard. All the attributes of the keyboard are generated and controlled by the Key Manager. These attributes include repeat speed, shift and control keys, function keys and key translation. The joysticks are also scanned by the Key Manager.

&BB00 - KM INITIALISE

Initialises the Key Manager and sets up everything as it is when the computer is first switched on:

See also the routine KM RESET below.

Exit

&BB03 - KM RESET

Resets the Key Manager; the key buffer is emptied and all current keys/characters are ignored.

Exit

Notes

See also KM INITIALISE above: on the 664 or 6128, the key buffer can also be cleared separately by calling the KM FLUSH routine.

&BB06 - KM WAIT CHAR

Waits for the next character from the keyboard buffer.

Exit

&BB09 - KM READ CHAR

Tests to see if a character is available from the keyboard buffer, but doesn't wait for one to become available.

Exit

In both cases, the other registers are preserved.

&BB0C - KM CHAR RETURN

Saves a character for the next use of KM WAIT CHAR or KM READ CHAR.

Entry
Exit

&BB0F - KM SET EXPAND

Assigns a string to a key code.

Entry
Exit

In either case:

&BB12 - KM GET EXPAND

Reads a character from an expanded string of characters.

Entry
Exit

In either case:

&BB15 - KM EXP BUFFER

Sets aside a buffer area for character expansion strings.

Entry
Exit

In either case, A, BC, DE and HL are corrupt.

Notes

The buffer must be in the central 32K of RAM and must be at least 49 bytes long.

&BB18 - KM WAIT KEY

Waits for a key to be pressed - this routine does not expand any expansion tokens.

Exit

&BB1B - KM READ KEY

Tests whether a key is available from the keyboard.

Exit

In either case, the other registers are preserved.

Notes

Any expansion tokens are not expanded.

&BB1E - KM TEST KEY

Tests if a particular key (or joystick direction or button) is pressed.

Entry
Exit

In either case:

Notes

After calling this, C will hold the state of shift and control:

&BB21 - KM GET STATE

Gets the state of the Shift and Caps locks.

Exit

Whatever the outcome, all the other registers are preserved.

&BB24 - KM GET JOYSTICK

Reads the present state of any joysticks attached.

Exit

Notes

The joystick states are bit significant and are as follows:

The bits are set when the corresponding buttons or directions are operated.

&BB27 - KM SET TRANSLATE

Sets the token or character that is assigned to a key when neither Shift nor Control are pressed.

Entry
Exit

Notes

Special values for B are as follows:

&BB2A - KM GET TRANSLATE

Finds out what token or character will be assigned to a key when neither Shift nor Control are pressed.

Entry
Exit

Notes

See KM SET TRANSLATE for special values that can be returned.

&BB2D - KM SET SHIFT

Sets the token or character that will be assigned to a key when Shift is pressed as well.

Entry
Exit

Notes

See KM SET TRANSLATE for special values that can be set.

&BB30 - KM GET SHIFT

Finds out what token/character will be assigned to a key when Shift is pressed as well.

Entry
Exit

Notes

See KM SET TRANSLATE for special values that can be returned.

&BB33 - KM SET CONTROL

Sets the token or character that will be assigned to a key when Control is pressed as well.

Entry
Exit

Notes

See KM SET TRANSLATE for special values that can be set.

&BB36 - KM GET CONTROL

Finds out what token or character will be assigned to a key when Control is pressed as well.

Entry
Exit

Notes

See KM SET TRANSLATE for special values that can be set.

&BB39 - KM SET REPEAT

Sets whether a key may repeat or not.

Entry
Exit

&BB3C - KM GET REPEAT

Finds out whether a key is set to repeat or not.

Entry
Exit

In either case:

&BB3F - KM SET DELAY

Sets the time that elapses before the first repeat, and also set the repeat speed.

Entry
Exit

Notes

The values for the times are given in 1/50th seconds, and a value of 0 counts as 256.

&BB42 - KM GET DELAY

Finds out the time that elapses before the first repeat and also the repeat speed.

Exit

&BB45 - KM ARM BREAK

Arms the Break mechanism.

Entry
Exit

&BB48 - KM DISARM BREAK

Disables the Break mechanism.

Exit

&BB4B - KM BREAK EVENT

Generates a Break interrupt if a Break routine has been specified by KM ARM BREAK.

Exit

The Text VDU

The Text VDU is a character based screen driver. It controls 8 different streams each of which can have an area of screen allocated to it (a window). The Text VDU allows characters to be written to the screen and read from the screen. It also treats certain 'characters' as 'control codes' which can have various effects, from moving the cursor to setting the colour of an ink.

&BB4E - TXT INITIALISE

Initialise the text VDU to its settings when the computer is switched on:

Exit

&BB51 - TXT RESET

Resets the text VDU indirections and the control code table.

Exit

&BB54 - TXT VDU ENABLE

Allows characters to be printed on the screen in the current stream.

Exit

&BB57 - TXT VDU DISABLE

Prevents characters from being printed to the current stream.

Exit

&BB5A - TXT OUTPUT

Output a character or control code (&00 to &1F) to the screen.

Entry
Exit

Notes

Any control codes are obeyed and nothing is printed if the VDU is disabled; characters are printed using the TXT OUT ACTION indirection; if using graphics printing mode, then control codes are printed and not obeyed.

&BB5D - TXT WR CHAR

Print a character at the current cursor position - control codes are printed and not obeyed.

Entry
Exit

Notes

This routine uses the TXT WRITE CHAR indirection to put the character on the screen.

&BB60 - TXT RD CHAR

Read a character from the screen at the current cursor position.

Exit

In either case, the other flags are corrupt, and all registers are preserved.

Notes

This routine uses the TXT UNWRITE indirection.

&BB63 - TXT SET GRAPHIC

Enables or disables graphics print character mode.

Entry
Exit

Notes

When turned on, control codes are printed and not obeyed; characters are printed by GRA WR CHAR.

&BB66 - TXT WIN ENABLE

Sets the boundaries of the current text window - uses physical coordinates.

Entry
Exit

Notes

The window is not cleared but the cursor is moved to the top left corner of the window.

&BB69 - TXT GET WINDOW

Returns the size of the current window - returns physical coordinates.

Exit

&BB6C - TXT CLEAR WINDOW

Clears the window (of the current stream) and moves the cursor to the top left corner of the window.

Exit

&BB6F - TXT SET COLUMN

Sets the cursor's horizontal position.

Entry
Exit

Notes

See also TXT SET CURSOR.

&BB72 - TXT SET ROW

Sets the cursor's vertical position.

Entry
Exit

Notes

See also TXT SET CURSOR.

&BB75 - TXT SET CURSOR

Sets the cursor's vertical and horizontal position.

Entry
Exit

Notes

See also TXT SET COLUMN and TXT SET ROW.

&BB78 - TXT GET CURSOR

Gets the cursor's current position.

Exit

Notes

The roll count is increased when the screen is scrolled down, and is decreased when it is scrolled up.

&BB7B - TXT CUR ENABLE

Allows the text cursor to be displayed (if it is allowed by TXT CUR ON) - intended for use by the user.

Exit

&BB7E - TXT CUR DISABLE

Prevents the text cursor from being displayed -intended for use by the user.

Exit

&BB81 - TXT CUR ON

Allows the text cursor to be displayed - intended for use by the operating system.

Exit

&BB84 - TXT CUR OFF

Prevents the text cursor from being displayed -intended for use by the operating system.

Exit

&BB87 - TXT VALIDATE

Checks whether a cursor position is within the current window.

Entry
Exit

&BB8A - TXT PLACE CURSOR

Puts a 'cursor blob' on the screen at the current cursor position.

Exit

Notes

It is possible to have more than one cursor in a window (see also TXT DRAW CURSOR); do not use this routine twice without using TXT REMOVE CURSOR between.

&BB8D - TXT REMOVE CURSOR

Removes a 'cursor blob' from the current cursor position.

Exit

Notes

This should be used only to remove cursors created by TXT PLACE CURSOR, but see also TXT UNDRAW CURSOR.

&BB90 - TXT SET PEN

Sets the foreground PEN for the current stream.

Entry
Exit

&BB93 - TXT GET PEN

Gets the foreground PEN for the current stream.

Exit

&BB96 - TXT SET PAPER

Sets the background PAPER for the current stream.

Entry
Exit

&BB99 - TXT GET PAPER

Gets the background PAPER for the current stream.

Exit

&BB9C - TXT INVERSE

Swaps the current PEN and PAPER colours over for the current stream.

Exit

&BB9F - TXT SET BACK

Sets the character write mode to either opaque or transparent.

Entry
Exit

Notes

Setting the character write mode has no effects on the graphics VDU.

&BBA2 - TXT GET BACK

Gets the character write mode for the current stream.

Exit

&BBA5 - TXT GET MATRIX

Gets the address of a character matrix.

Entry
Exit

In either case:

Notes

The character matrix is stored in 8 bytes; the first byte is for the top row of the character, and the last byte refers to the bottom row of the character; bit 7 of a byte refers to the leftmost pixel of a line, and bit 0 refers to the rightmost pixel in Mode 2..

&BBA8 - TXT SET MATRIX

Installs a matrix for a user-defined character.

Entry
Exit

&BBAB - TXT SET M TABLE

Sets the address of a user-defined matrix table.

Entry
Exit

&BBAE - TXT GET M TABLE

Gets the address of a user-defined matrix table.

Exit

See TXT SET M TABLE above for details of the values that can be returned.

&BBB1 - TXT GET CONTROLS

Gets the address of the control code table.

Exit

Notes

The table has 32 entries, and each entry has three bytes: byte 1 is the number of parameters needed by the control code, bytes 2 and 3 are the address of the routine, in the Lower ROM, to execute the control code.

&BBB4 - TXT STR SELECT

Selects a new VDU text stream.

Entry
Exit

&BBB7 - TXT SWAP STREAMS

Swaps the states of two stream attribute tables.

Entry
Exit

Notes

The foreground pen and paper, the window size, the cursor position, the character write mode and graphic character mode are all exchanged between the two streams.

The Graphics VDU

The Graphics VDU allows individual pixels (dots) on the screen to be set or tested and lines to be drawn. The plotting takes place on an ideal screen that is always 640 points wide and 400 points high. This means that more than one point on the ideal screen will map onto a particular pixel on the real screen. The width of the ideal screen (640 points) is chosen to be the horizontal number of pixels on the screen in the highest resolution mode (mode 2). The height of the ideal screen (400 points) is chosen to be twice the vertical number of pixels on the screen in all modes. This ensures that the aspect ratio of the screen is approximately unity, i.e. a circle looks circular and not elliptical.

&BBBA - GRA INITIALISE

Initialises the graphics VDU to its default set-up (ie its set-up when the computer is switched on).

Exit

Notes

Sets the graphics indirections to their defaults, sets the graphic paper to text pen 0 and the graphic pen to text pen 1, reset the graphics origin and move the graphics cursor to the bottom left of the screen, reset the graphics window and write mode to their defaults.

&BBBD - GRA RESET

Resets the graphics VDU.

Exit

Notes

Resets the graphics indirections and the graphics write mode to their defaults.

&BBC0 - GRA MOVE ABSOLUTE

Moves the graphics cursor to an absolute screen position.

Entry
Exit

&BBC3 - GRA MOVE RELATIVE

Moves the graphics cursor to a point relative to its present screen position.

Entry
Exit

&BBC6 - GRA ASK CURSOR

Gets the graphics cursor's current position.

Exit

&BBC9 - GRA SET ORIGIN

Sets the graphics user origin's screen position.

Entry
Exit

&BBCC - GRA GET ORIGIN

Gets the graphics user origin's screen position.

Exit

&BBCF - GRA WIN WIDTH

Sets the left and right edges of the graphics window.

Entry
Exit

Notes

The default window covers the entire screen and is restored to its default when the mode is changed; used in conjunction with GRA WIN HEIGHT.

&BBD2 - GRA WIN HEIGHT

Sets the top and bottom edges of the graphics window.

Entry
Exit

Notes

See GRA WIN WIDTH for further details.

&BBD5 - GRA GET W WIDTH

Gets the left and right edges of the graphics window.

Exit

&BBD8 - GRA GET W HEIGHT

Gets the top and bottom edges of the graphics window.

Exit

&BBDB - GRA CLEAR WINDOW

Clears the graphics window to the graphics paper colour and moves the cursor back to the user origin.

Exit

&BBDE - GRA SET PEN

Sets the graphics PEN.

Entry
Exit

&BBE1 - GRA GET PEN

Gets the graphics PEN.

Exit

&BBE4 - GRA SET PAPER

Sets the graphics PAPER.

Entry
Exit

&BBE7 - GRA GET PAPER

Gets the graphics PAPER.

Exit

&BBEA - GRA PLOT ABSOLUTE

Plots a point at an absolute user coordinate, using the GRA PLOT indirection.

Entry
Exit

&BBED - GRA PLOT RELATIVE

Plots a point at a position relative to the current graphics cursor, using the GRA PLOT indirection.

Entry
Exit

&BBF0 - GRA TEST ABSOLUTE

Moves to an absolute position, and tests the point there using the GRA TEST indirection.

Entry
Exit

&BBF3 - GRA TEST RELATIVE

Moves to a position relative to the current position, and tests the point there using the GRA TEST indirection.

Entry
Exit

&BBF6 - GRA LINE ABSOLUTE

Draws a line from the current graphics position to an absolute position, using GRA LINE.

Entry
Exit

Notes

The line will be plotted in the current graphics pen colour (may be masked to produce a dotted line on a 6128).

&BBF9 - GRA LINE RELATIVE

Draws a line from the current graphics position to a relative screen position, using GRA LINE.

Entry
Exit

Notes

See GRA LINE ABSOLUTE above for details of how the line is plotted.

&BBFC - GRA WR CHAR

Writes a character onto the screen at the current graphics position.

Entry
Exit

Notes

As in BASIC, all characters including control codes are printed; the character is printed with its top left comer at the current graphics position; the graphics position is moved one character width to the right so that it is ready for another character to be printed.

The Screen Pack

The Screen Pack is used by the Text and Graphics VDUs to access the hardware of the screen. It also controls the features of the screen that affect both the Text VDU and Graphics VDU, such as what mode the screen is in.

&BBFF - SCR INITIALISE

Initialises the Screen Pack to the default values used when the computer is first switched on.

Exit

Notes

All screen indirections are restored to their default settings, as are inks and flashing speeds; the mode is switched to MODE 1 and the screen is cleared with PEN 0; the screen address is moved to &C000 and the screen offset is set to zero.

&BC02 - SCR RESET

Resets the Screen Pack's indirections, flashing speeds and inks to their default values.

Exit

&BC05 - SCR SET OFFSET

Sets the screen offset to the specified values - this can cause the screen to scroll.

Entry
Exit

Notes

The screen offset is reset to 0 whenever its mode is set, or it is cleared by SCR CLEAR (but not BASIC's CLS).

&BC08 - SCR SET BASE

Sets the location in memory of the screen - effectively can only be &C000 or &4000.

Entry
Exit

Notes

The screen memory can only be set at 16K intervals (ie &0000, &4000, &8000, &C000) and when the computer is first switched on the 16K of screen memory is located at &C000).

&BC0B - SCR GET LOCATION

Gets the location of the screen memory and also the screen offset.

Exit

&BC0E - SCR SET MODE

Sets the screen mode.

Entry
Exit

Notes

The windows are set to cover the whole screen and the graphics origin is set to the bottom left corner of the screen; in addition, the current stream is set to zero, and the screen offset is zeroed.

&BC11 - SCR GET MODE

Gets the current screen mode.

Exit

&BC14 - SCR CLEAR

Clears the whole of the screen.

Exit

&BC17 - SCR CHAR LIMITS

Gets the size of the whole screen in terms of the numbers of characters that can be displayed.

Exit

&BC1A - SCR CHAR POSITION

Gets the memory address of the top left corner of a specified character position.

Entry
Exit

&BC1D - SCR DOT POSITION

Gets the memory address of a pixel at a specified screen position.

Entry
Exit

&BC20 - SCR NEXT BYTE

Calculates the screen address of the byte to the right of the specified screen address (may be on the next line).

Entry
Exit

&BC23 - SCR PREV BYTE

Calculates the screen address of the byte to the left of the specified screen address (this address may actually be on the previous line).

Entry
Exit

&BC26 - SCR NEXT LINE

Calculates the screen address of the byte below the specified screen address.

Entry
Exit

&BC29 - SCR PREV LINE

Calculates the screen address of the byte above the specified screen address.

Entry
Exit

&BC2C - SCR INK ENCODE

Converts a PEN to provide a mask which, if applied to a screen byte, will convert all of the pixels in the byte to the appropriate PEN.

Entry
Exit

Notes

The mask returned is different in each of the screen modes.

&BC2F - SCR INK DECODE

Converts a PEN mask into the PEN number (see SCR INK ENCODE for the reverse process).

Entry
Exit

&BC32 - SCR SET INK

Sets the colours of a PEN - if the two values supplied are different then the colours will alternate (flash).

Entry
Exit

&BC35 - SCR GET INK

Gets the colours of a PEN.

Entry
Exit

&BC38 - SCR SET BORDER

Sets the colours of the border - again if two different values are supplied, the border will flash.

Entry
Exit

&BC3B - SCR GET BORDER

Gets the colours of the border.

Exit

&BC3E - SCR SET FLASHING

Sets the speed with which the border's and PENs colours flash.

Entry
Exit

Notes

The length of time that each colour is shown is measured in 1/50ths of a second, and a value of 0 is taken to mean 256 * 1/50 seconds - the default value is 10 * 1/50 seconds.

&BC41 - SCR GET FLASHING

Gets the periods with which the colours of the border and PENs flash.

Exit

Notes

See SCR SET FLASHING for the units of time used.

&BC44 - SCR FILL BOX

Fills an area of the screen with an ink - this only works for 'character-sized' blocks of screen.

Entry
Exit

&BC17 - SCR FLOOD BOX

Fills an area of the screen with an ink - this only works for 'byte-sized' blocks of screen.

Entry
Exit

Notes

The whole of the area to be filled must lie on the screen otherwise unpredictable results may occur.

&BC4A - SCR CHAR INVERT

Inverts a character's colours; all pixels in one PEN's colour are printed in another PEN's colour, and vice versa.

Entry
Exit

.

&BC4D - SCR HW ROLL

Scrolls the entire screen up or down by eight pixel rows (ie one character line).

Entry
Exit

Notes

This alters the screen offset; to roll down, B must hold zero, and to roll upwards B must be non-zero.

&BC50 - SCR SW ROLL

Scrolls part of the screen up or down by eight pixel lines - only for 'character-sized' blocks of the screen.

Entry
Exit

Notes

The area of the screen is moved by copying it; to roll down, B must hold zero, and to roll upwards B must be non-zero; this routine uses physical roordinates.

&BC53 - SCR UNPACK

Changes a character matrix from its eight byte standard form into a set of pixel masks which are suitable for the current mode - four *8 bytes are needed in mode 0, two *8 bytes in mode 1, and 8 bytes in mode 2.

Entry
Exit

&BC56 - SCR REPACK

Changes a set of pixel masks (for the current mode) into a standard eight byte character matrix.

Entry
Exit

&BC59 - SCR ACCESS

Sets the screen write mode for graphics.

Entry
Exit

Notes

The fill mode means that the ink that plotting was requested in is the ink that appears on the screen; in XOR mode, the specified ink is XORed with ink that is at that point on the screen already before plotting; a similar situation occurs with the AND and OR modes.

&BC5C - SCR PIXELS

Puts a pixel or pixels on the screen regardless of the write mode specified by SCR ACCESS above.

Entry
Exit

&BC5F - SCR HORIZONTAL

Draws a honzontal line on the screen using the current graphics write mode.

Entry
Exit

Notes

The start X-coordinate must be less than the end X-coordinate.

&BC62 - SCR VERTICAL

Draws a vertical line on the screen using the current graphics write mode.

Entry
Exit

The Cassette/AMSDOS Manager

Some of these routines are only applicable to the cassette manager. Where a disc version exists it is indicated by an asterisk (*) next to the command name. These disc version jumpblocks are automatically installed by the Disc Operating System on switch on.

&BC65 - CAS INITIALISE

Initialises the cassette manager.

Exit

Notes

Both read and write streams are closed. Tape messages are switched on and the default speed is reselected

&BC68 - CAS SET SPEED

Sets the speed at which the cassette manager saves programs.

Entry
Exit

Notes

The value in HL is the length of time that half a zero bit is written as; a “one” bit is twice the length of a “zero” bit; the default values (ie SPEED WRITE 0) are 333 microseconds (HL) and 25 microseconds (A) for SPEED WRITE 1, the values are given as 107 microseconds and 50 microseconds respectively.

&BC6B - CAS NOISY

Enables or disables the display of cassette handling messages.

Entry
Exit

&BC6E - CAS START MOTOR

Switches on the tape motor.

Exit

&BC71 - CAS STOP MOTOR

Switches off the tape motor.

Exit

&BC74 - CAS RESTORE MOTOR

Resets the tape motor to its previous state.

Entry
Exit

&BC77 - *CAS IN OPEN

Opens an input buffer and reads the first block of the file.

Entry
Exit

Notes

A filename of zero length means “read the next file on the tape”. The stream remains open until it is closed by either CAS IN CLOSE or CAS IN ABANDON.

Disc: Similar to tape except that if there is no header on the file, then a fake header is put into memory by this routine.

&BC7A - *CAS IN CLOSE

Closes an input file.

Exit

Disc: All the above applies, but also if the file failed to close for any other reason, then Carry is false, Zero is true and A contains an error number.

In all cases the drive motor is turned off immediately.

&BC7D - *CAS IN ABANDON

Abandons an input file.

Exit

Disc: All the above applies for the disc routine.

&BC80 - *CAS IN CHAR

Reads in a single byte from a file.

Exit

Disc: All the above applies for the disc routine.

&BC83 - *CAS IN DIRECT

Reads an entire file directly into memory.

Entry
Exit

Notes

This routine cannot be used once CAS IN CHAR has been used.

Disc: All the above applies to the disc routine.

&BC86 - *CAS RETURN

Puts the last byte read back into the input buffer so that it can be read again at a later time.

Exit

Notes

The routine can only return the last byte read and at least one byte must have been read.

Disc: All the above applies to the disc routine.

&BC89 - *CAS TEST EOF

Tests whether the end of file has been encountered.

Exit

Disc: All the above applies to the disc routine.

&BC8C - *CAS OUT OPEN

Opens an output file

Entry
Exit

Notes

The buffer is used to store the contents of a file block before it is actually written to tape.

Disc: The same as for tape except that the filename must be present in its usual AMSDOS format.

&BC8F - *CAS OUT CLOSE

Closes an output file.

Exit

Notes

The last block of a file is written only when this routine is called; if writing the file is to be abandoned, then CAS OUT ABANDON should be used instead.

Disc: All the above applies to the disc routine.

&BC92 - *CAS OUT ABANDON

Abandons an output file.

Exit

Notes

When using this routine, the current last block of the file is not written to the tape.

Disc: Similar to the tape routine; if more than 16K of a file has been written to the disc, then the first 16K of the file will exist on the disc with a file extension of .$$$ because each 16K section of the file requires a separate directory entry.

&BC95 - *CAS OUT CHAR

Writes a single byte to a file.

Entry
Exit

Notes

If the 2K buffer is full of data then it is written to the tape before the new character is placed in the buffer; it is important to call CAS OUT CLOSE when all the data has been sent to the file so that the last block is written to the tape.

Disc: All the above applies to the disc routine.

&BC98 - *CAS OUT DIRECT

Writes an entire file directly to tape.

Entry
Exit

Notes

This routine cannot be used once CAS OUT CHAR has been used.

Disc: All the above applies to the disc routine.

&BC9B - *CAS CATALOG

Creates a catalogue of all the files on the tape.

Entry
Exit

Notes

This routine is only left when the ESC key is pressed (cassette only) and is identical to BASIC's CAT command.

Disc: All tbe above applies, except that a sorted list of files is displayed; system files are not listed by this routine.

&BC9E - CAS WRITE

Writes data to the tape in one long file (ie not in 2K blocks).

Entry
Exit

Notes

For header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and also turns off interrupts whilst writing data.

&BCA1 - CAS READ

Reads data from the tape in one long file (ie as originally written by CAS WRITE only).

Entry
Exit

Notes

For header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and turns off interrupts whilst reading data.

&BCA4 - CAS CHECK

Compares the contents of memory with a file record (ie header or data) on tape.

Entry
Exit

Notes

For header records the sync character is &2C, and for data it is &16; this routine starts and stops the cassette motor and turns off interrupts whilst reading data; does not have to read the whole of a record, but must start at the beginning.

The Sound Manager

&BCA7 - SOUND RESET

Resets the sound manager by clearing the sound queues and abandoning any current sounds.

Exit

&BCAA - SOUND

Adds a sound to the sound queue of a channel.

Entry
Exit

Notes

The bytes required to define the sound are as follows:

&BCAD - SOUND CHECK

Gets the status of a sound channel.

Entry
Exit

Notes

The channel status returned is bit significant, as follows:

&BCB0 - SOUND ARM EVENT

Sets up an event which will be activated when a space occurs in a sound queue.

Entry
Exit

Notes

The event block must be initialised by KL INIT EVENT and is disarmed when the event itself is run.

&BCB3 - SOUND RELEASE

Allows the playing of sounds on specific channels that had been stopped by SOUND HOLD.

Entry
Exit

&BCB6 - SOUND HOLD

Immediately stops all sound output (on all channels).

Exit

Notes

When the sounds are restarted, they will begin from exactly the same place that they were stopped.

&BCB9 - SOUND CONTINUE

Restarts all sound output (on all channels).

Exit

&BCBC - SOUND AMPL ENVELOPE

Sets up a volume envelope.

Entry
Exit

Notes

All the rules of enevelopes in BASIC also apply; the block of the data for the envelope is set up as follows:

Each section of the envelope has three bytes set out as follows:

See also SOUND TONE ENVELOPE below.

&BCBF - SOUND TONE ENVELOPE

Sets up a tone envelope.

Entry
Exit

Notes

All the rules of envelopes in BASIC also apply; the block of the data for the envelope is set up as follows:

Each section of the envelope has three bytes set out as follows:

See also SOUND AMPL ENVELOPE above.

&BCC2 - SOUND A ADDRESS

Gets the address of the data block associated with a volume envelope.

Entry
Exit

&BCC5 - SOUND T ADDRESS

Gets the address of the data block associated with a tone envelope.

Entry
Exit

The Kernel

&BCC8 - KL CHOKE OFF

Clears all event queues and timer lists, with the exception of keyboard scanning and sound routines.

Exit

&BCCB - KL ROM WALK

Finds and initialises all background ROMs.

Entry
Exit

Notes

This routine looks at the ROM select addresses from 0 to 15 (1 to 7 for the 464) and calls the initialisation routine of any ROMs present; these routines may reserve memory by adjusting DE and HL before returning control to KL ROM WALK, and the ROM is then added to the list of command handling routines.

&BCCE - KL INIT BACK

Finds and initialises a specific background ROM.

Entry
Exit

Notes

The ROM select address must be in the range of 0 to 15 (or 1 to 7 for the 464) although address 7 is tor the AMSDOS/CPM ROM if present. The ROM's initialisation routine is then called and some memory may be reserved for the ROM by adjusting the values of DE and HL before returning control to KL INlT BACK.

&BCD1 - KL LOG EXT

Logs on a new RSX to the firmware.

Entry
Exit

&BCD4 - KL FIND COMMAND

Searches an RSX, background ROM or foreground ROM, to find a command in its table.

Entry
Exit

Notes

The command names should be in upper case and the last character should have &80 added to it; the sequence of searching is RSXs, then ROMs with lower numbers before ROMs with higher numbers.

&BCD7 - KL NEW FRAME FLY

Sets up a frame flyback event block which will be acted on whenever a frame flyback occurs.

Entry
Exit

&BCDA - KL ADD FRAME FLY

Adds an existing but deleted frame flyback event block to the list of routines run when a frame flyback occurs.

Entry
Exit

&BCDD - KL DEL FRAME FLY

Removes a frame flyback event block from the list of routines which are mn when a frame flyback occurs.

Entry
Exit

&BCE0 - KL NEW FAST TICKER

Sets up a fast ticker event block which will be run whenever the 1/300th second ticker interrupt occurs.

Entry
Exit

&BCE3 - KL ADD FAST TICKER

Adds an existing but deleted fast ticker event block to the list of routines which are run when the 1/300th sec ticker interrupt occurs.

Entry
Exit

&BCE6 - KL DEL FAST TICKER

Removes a fast ticker event block from the list of routines run when the 1/300th sec ticker interrupt occurs.

Entry
Exit

&BCE9 - KL ADD TICKER

Sets up a ticker event block which will be run whenever a 1/50th second ticker interrupt occurs.

Entry
Exit

Notes

Every 1/50th of a second all the tick blocks are looked at and their counter is decreased by 1; when the counter reaches zero, the event is 'kicked' and the counter is loaded with the value in BC; any tick block with a counter of 0 is ignored, and therefore if the value in BC is 0, the event will be kicked only once and ignored after that.

&BCEC - KL DEL TICKER

Removes a ticker event block from the list of routines that are run when a l/50th sec ticker interrupt occurs.

Entry
Exit

&BCEF - KL INIT EVENT

Initialises an event block.

Entry
Exit

Notes

The event class is derived as follows:

&BCF2 - KL EVENT

Kicks an event block.

Entry
Exit

&BCF5 - KL SYNC RESET

Clears the synchronous event queue.

Exit

Notes

When using this routine, all events that are waiting to be dealt with are simply discarded.

&BCF8 - KL DEL SYNCHRONOUS

Removes a synchronous event from the event queue.

Entry
Exit

&BCFB - KL NEXT SYNC

Finds out if there is a synchronous event with a higher priority.

Exit

&BCFE - KL DO SYNC

Runs a synchronous event routine.

Entry
Exit

Notes

See KL DONE SYNC below.

&BD01 - KL DONE SYNC

Finishes running a synchronous event routine.

Entry
Exit

Notes

When an event that is waiting to be processed has been found by KL NEXT SYNC, the event routine should be run by KL DO SYNC; after this KL DONE SYNC should be called so that the event counter can be decreased - if the counter is greater than zero then the event is placed back on the synchronous event queue.

&BD04 - KL EVENT DISABLE

Disables normal synchronous events.

Exit

&BD07 - KL EVENT ENABLE

Enables normal synchronous events.

Exit

&BD0A - KL DISARM EVENT

Disarms a specific event and stops it from occurring.

Entry
Exit

Notes

This routine should be used to disarm only asynchronous events; see also KL DEL SYNCHRONOUS.

&BD0D - KL TIME PLEASE

Returns the time that has elapsed since the computer was switched on or reset (in 1/300ths of a second).

Exit

Notes

D holds the most signifilcant byte of the time elapsed, and L holds the least significant; the four byte count overflows after approximately l66 days have elapsed.

&BD10 - KL TIME SET

Sets the elapsed time (in 1/300ths of a second).

Entry
Exit

The Machine Pack

&BD13 - MC BOOT PROGRAM

Loads a program into RAM and then executes it.

Entry
Exit

Control is handed over to the program and so the routine is not returned from.

Notes

The routine to run the program should be in the central block of memory, and should obey the following exit conditions:

In either case, A, BC, DE, IX, IY and the other flags are all corrupt. Should the program fail to load, control is returned to the previous foreground program.

&BD16 - MC START PROGRAM

Runs a foreground program.

Entry
Exit

Control is handed over to the program and so the routine is not returned from.

&BD19 - MC WAIT FLYBACK

Waits until a frame flyback occurs.

Exit

Notes

When the frame flyback occurs the screen is not being written to and so the screen can be manipulated during this period without any flickering or ghosting on the screen.

&BD1C - MC SET MODE

Sets the screen mode.

Entry
Exit

Notes

Although this routine changes the screen mode it does not inform the routines which write to the screen that the mode has been changed; therefore these routines will write to the screen as if the mode had not been changed; however as the hardware is now interpreting these signals differently, unusual effects may occur.

&BD1F - MC SCREEN OFFSET

Sets the screen offset.

Entry
Exit

Notes

As with MC SET MODE, this routine changes the hardware setting without telling the routines that write to the screen; therefore these routines may cause unpredictable effects if called; the default screen base is &C0.

&BD22 - MC CLEAR INKS

Sets all the PENs and the border to one colour, so making it seem as if the screen has been cleared.

Entry
Exit

Notes

The ink vector takes the following form:

The values for the colours are all given as hardware values.

&BD25 - MC SET INKS

Sets the colours of all the PENs and the border.

Entry
Exit

Notes

The ink vector takes the following form:

The values for the colours are all given as hardware values; the routine sets all sixteen PEN's.

&BD28 - MC RESET PRINTER

Sets the MC WAIT PRINTER indirection to its original routine.

Exit

&BD2B - MC PRINT CHAR

Sends a character to the printer and detects if it is busy for too long (more than 0.4 seconds).

Entry
Exit

Notes

This routine uses the MC WAIT PRINTER indirection.

&BD2E - MC BUSY PRINTER

Tests to see if the printer is busy.

Exit

&BD31 - MC SEND PRINTER

Sends a character to the printer, which must not be busy.

Entry
Exit

&BD34 - MC SOUND REGISTER

Sends data to a sound chip register

Entry
Exit

AF and BC are corrupt, and all other registers are preserved.

&BD37 - JUMP RESTORE

Restores the jumpblock to its default state.

Exit

Notes

This routine does not affect the indirections jumpblock, but restores all entries in the main jumpblock.

&BD3A - KM SET LOCKS

Turns the shift and caps locks on and off.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

Notes

In this routine, &00 means turned off, and &FF means turned on.

&BD3D - KM FLUSH

Empties the key buffer.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Exit

Notes

This routine also discards any current expansion string.

&BD40 - TXT ASK STATE

Gets the VDU and cursor state.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Exit

Notes

The value in the A register is bit significant, as follows:

&BD43 - GRA DEFAULT

Sets the graphics VDU to its default mode.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Exit

Notes

Sets the background to opaque, the first point of line is plotted, lines aren't dotted, and the write mode is force.

&BD46 - GRA SET BACK

Sets the graphics background mode to either opaque or transparent.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

&BD49 - GRA SET FIRST

Sets whether the first point of a line is plotted or not.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

&BD4C - GRA SET LINE MASK

Sets how the points in a line are plotted - ie defines whether a line is dotted or not.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

Notes

The first point in the line corresponds to bit 7 of the line mask and after bit 0 the mask repeats; if a bit is set then that point will be plotted; the mask is always applied from left to right, or from bottom to top.

&BD4F - GRA FROM USER

Converts user coordinates into base coordinates.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

&BD52 - GRA FILL

Fills an area of the screen starting from the current graphics position and extending until it reaches either the edge of the window or a pixel set to the PEN.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

Notes

The buffer is used to store complex areas to fill, which are remembered and filled when the basic shape has been done; each entry in the buffer uses seven bytes and so the more complex the shape the larger the buffer; if it runs out of space to store these complex areas, it will fill what it can and then return with Carry false.

&BD55 - SCR SET POSITION

Sets the screen base and offset without telling the hardware.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

&BD58 - MC PRINT TRANSLATION

Sets how ASCII characters will be translated before being sent to the printer.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

Notes

The first byte in the table is the number of entries. Each entry requires two bytes, as follows:

&BD5B - KL BANK SWITCH

Sets which RAM banks are being accessed by the Z80.

This vector is only available on firmware V2 and later (CPC664, CPC6128, 464Plus, 6128Plus and GX-4000).

Entry
Exit

The Firmware Indirections

&BDCD - TXT DRAW CURSOR

Places the cursor on the screen, if the cursor is enabled.

Exit

Notes

The cursor is an inverse blob which appears at the current text position.

&BDD0 - TXT UNDRAW CURSOR

Removes the cursor from the screen, if the cursor is enabled.

Exit

&BDD3 - TXT WRITE CHAR

Writes a character onto the screen.

Entry
Exit

&BDD6 - TXT UNWRITE

Reads a character from the screen.

Entry
Exit

Notes

This routine works by comparing the image on the screen with the character matrices; therefore if the character matrices have been altered the routine may not find a readable a character.

&BDD9 - TXT OUT ACTION

Writes a character to the screen or obeys a control code (&00 to &1F).

Entry
Exit

Notes

Control codes may take a maximum of nine parameters. When a control code is found, the required number of parameters is read into the control code buffer, and then the control code is acted upon; if the graphics character write mode is enabled, then characters and codes are printed using the graphics VDU; when using the graphics VDU control codes are printed and not obeyed.

&BDDC - GRA PLOT

Plots a point in the current graphics PEN.

Entry
Exit

Notes

This routine uses the SCR WRITE indirection to write the point to the screen.

&BDDF - GRA TEST

Tests a point and finds out what PEN it is set to. ==Entry==

Exit

Notes

This routine uses the SCR READ indirection to test a point on the screen.

&BDE2 - GRA LINE

Draws a line in the current graphics PEN, from the current graphics position to the specified point.

Entry
Exit

Notes

This routine uses the SCR WRITE indirection to write the points of the line on the screen.

&BDE5 - SCR READ

Reads a pixel from the screen and returns its decoded PEN.

Entry
Exit

Notes

The mask should be for a single pixel, and is dependent on the screen mode.

&BDE8 - SCR WRITE

Writes one or more pixels to the screen.

Entry
Exit

Notes

The mask should determine which pixels in the screen byte are to be plotted.

&BDEB - SCR MODE CLEAR

Fills the entire screen memory with &00, which clears the screen to PEN 0.

Exit

&BDEE - KM TEST BREAK

Tests if the ESC key has been pressed, and acts accordingly.

Entry
Exit

Notes

&BDF1 - MC WAIT PRINTER

Sends a character to the printer if it is not busy

Entry
Exit

&BDF4 - KM SCAN KEYS

Scans the keyboard every 1/50th of a second, and updates the status of all keys.

Entry
Exit

The Maths Firmware

&BD61 - MOVE REAL

(&BD3D for the 464)
Copies the five bytes that are pointed to by DE to the location held in HL.

Entry
Exit

Notes

For the 464 only, A holds the exponent byte of the real value when the routine is exited.

&BD64 - INTEGER TO REAL

(&BD40 for the 464)
Converts an integer value into a real value.

Entry
Exit

&BD67 - BINARY TO REAL

(&BD43 for the 464)
Converts a four byte binary value into a real value at the same location.

Entry
Exit

Notes

A four byte binary value is an unsigned integer up to &FFFFFFFF and is stored with the least significant byte first, and with the most significant byte last.

&BD6A - REAL TO INTEGER

(&BD46 for the 464)
Converts a real value, rounding it into an unsigned integer value held in HL.

Entry
Exit

Notes

This rounds the decimal part down if it is less than 0.5, but rounds up if it is greater than, or equal to 0.5

&BD6D - REAL TO BINARY

(&BD49 for the 464)
Converts a real value, rounding it into a four byte binary value at the same location.

Entry
Exit

Notes

See REAL TO INTEGER for details of how the values are rounded up or down.

&BD70 - REAL FIX

(&BD4C for the 464)
Performs an equivalent of BASIC's FIX function on a real value, leaving the result as a four byte binary value at the same location.

Entry
Exit

Notes

FIX removes any decimal part of the value, rounding down whether positive or negative - see the BASIC handbook for more details on the FIX command.

&BD73 - REAL INT

(&BD4F for the 464)
Performs an equivalent of BASIC's INT function on a real value, leaving the result as a four byte binary value at the same location

Entry
Exit

Notes

INT removes any decimal part of the value, rounding down if the number is positive, but rounding up if it is negative.

&BD76 - INTERNAL SUBROUTINE

not useful (&BD52 for the 464)

&BD79 REAL *10^A

(&BD55 for the 464)
Multiplies a real value by 10 to the power of the value in the A register, leaving the result at the same location.

Entry
Exit

&BD7C - REAL ADDITION

(&BD58 for the 464)
Adds two real values, and leaves the result in lieu of the first real number.

Entry
Exit

&BD82 - REAL REVERSE SUBTRACTION

(&BD5E for the 464)
Subtracts the first real value from the second real value, and leaves the result in lieu of the first number.

Entry
Exit

&BD85 - REAL MULTIPLICATION

(&BD61 for the 464)
Multiplies two real values together, and leaves the result in lieu of the first number.

Entry
Exit

&BD88 - REAL DIVISION

(&BD64 for the 464)
Divides the first real value by the second real value, and leaves the result in lieu of the first number.

Entry
Exit

&BD8E - REAL COMPARISON

(&BD6A for the 464)
Compares two real values.

Entry
Exit

Notes

After this routine has been called, the value in A depends on the result of the comparison as follows:

&BD91 - REAL UNARY MINUS

(&BD6D for the 464)
Reverses the sign of a real value.

Entry
Exit

&BD94 - REAL SIGNUM/SGN

(&BD70 for the 464)
Tests a real value, and compares it with zero.

Entry
Exit

Notes

After this routine has been called, the value in A depends on the result of the comparison as follows:

&BD97 - SET ANGLE MODE

(&BD73 for the 464)
Sets the angular calculation mode to either degrees (DEG) or radians (RAD).

Entry
Exit

&BD9A - REAL PI

(&BD76 for the 464)
Places the real value of pi at a given memory location.

Entry
Exit

&BD9D - REAL SQR

(&BD79 for the 464)
Calculates the square root of a real value, leaving the result in lieu of the real value.

Entry
Exit

&BDA0 - REAL POWER

(&BD7C for the 464)
Raises the first real value to the power of the second real value, leaving the result in lieu of the first real value.

Entry
Exit

&BDA3 - REAL LOG

(&BD7F for the 464)
Returns the naperian logarithm (to base e) of a real value, leaving the result in lieu of the real value.

Entry
Exit

&BDA6 - REAL LOG 10

(&BD82 for the 464)
Returns the logarithm (to base 10) of a real value, leaving the result in lieu of the real value.

Entry
Exit

&BDA9 - REAL EXP

(&BD85 for the 464)
Returns the antilogarithm (base e) of a real value, leaving the result in lieu of the real value.

Entry
Exit

Notes

See the BASIC handbook for details of EXP.

&BDAC - REAL SINE

(&BD88 for the 464)
Returns the sine of a real value, leaving the result in lieu of the real value.

Entry
Exit

&BDAF - REAL COSINE

(&BD8B for the 464)
Returns the cosine of a real value, leaving a the result in lieu of the real value.

Entry
Exit

&BDB2 - REAL TANGENT

(&BD8E for the 464)
Returns the tangent of a real value, leaving the result in lieu of the real value.

Entry
Exit

&BDB5 - REAL ARCTANGENT

(&BD91 for the 464)
Returns the arctangent of a real value, leaving the result in lieu of the real value.

Entry
Exit

All of the above routines to calculate sine, cosine, tangent and arctangent are slightly inaccuarate.

&BDB8 - INTERNAL SUBROUTINE

not useful (&BD94 for the 464)

&BDBB - INTERNAL SUBROUTINE

not useful (&BD97 for the 464)

&BDBE - INTERNAL SUBROUTINE

not useful (&BD9A for the 464)

Maths Routines for the 464 only

&BD5B - REAL SUBTRACTION

Subtracts the second real value from the first real value, and leaves the result in lieu of the first number.

Entry
Exit

&BD67 - REAL EXPONENT ADDITION

Adds the value of the A register to the exponent byte of a real number.

Entry
Exit

&BD9D - INTERNAL SUBROUTINE

not useful

&BDA0 - INTERNAL SUBROUTINE

not useful

&BDA3 - INTERNAL SUBROUTINE

not useful

&BDA6 - INTERNAL SUBROUTINE

not useful

&BDA9 - INTERNAL SUBROUTINE

not useful

&BDAC - INTEGER ADDITION

Adds two signed integer values.

Entry
Exit

&BDAF - INTEGER SUBTRACTION

Subtracts the second signed integer value from the first signed integer value.

Entry
Exit

&BDB2 - INTEGER REVERSE SUBTRACTION

Subtracts the first signed integer value from the second signed integer value.

Entry
Exit

&BDB5 - INTEGER MULTIPLICATION

Multiplies two signed integer values together, and leaves the result in lieu of the first number.

Entry
Exit

Notes

Multiplication of signed integers does not produce the same result as with unsigned integers.

&BDB8 - INTEGER DIVISION

Divides the first signed integer value by the second signed integer value.

Entry
Exit

Notes

Division of signed integers does not produce the same result as with unsigned integers

&BDBB - INTEGER DIVISION 2

Divides the first signed integer value by the second signed integer value.

Entry
Exit

Notes

Division of signed integers does not produce the same result as with unsigned integers.

&BDBE - INTERNAL SUBROUTINE

not useful

&BDC1 - INTERNAL SUBROUTINE

not useful

&BDC4 - INTEGER COMPARISON

Compares two signed integer values.

Entry
Exit

Notes

After this routine has been called, the value in A depends on the result of the comparison as follows:

With signed integers, the range of values runs from &8000 (-32768) via zero to &7FFF (+32767) and so any value which is greater than &8000 is considered as being less than a value of &7FFF or less.

&BDC7 - INTEGER UNARY MINUS

Reverses the sign of an integer value (by subtracting it from &10000).

Entry
Exit

&BDCA - INTEGER SIGNUM/SGN

Tests a signed integer value.

Entry
Exit

Notes

After this routine has been called, the value in A depends on the result of the comparison as follows:

See INTEGER COMPARISON for more details on the way that signed integers are laid out.

Subroutines for the 664 and 6128 only

&BD5E - TEXT INPUT

Allows upto 255 characters to be input from the keyboard into a buffer.

Entry

A NUL character must be placed after any characters already present, or at the start of the buffer if there is no text

Exit

Notes

This routine prints any existing contents of the buffer (upto the NUL character) and then echoes any keys used; it allows full line editing with the cursor keys and DEL, etc. It is exited only by use of ENTER or ESC.

&BD7F - REAL RND

Creates a new RND real value at a location pointed to by HL.

Entry
Exit

&BD8B - REAL RND(0)

Returns the last RND value created, and puts it in a location pointed to by HL.

Entry
Exit

Notes

See the BASIC handbook for more details on RND(0).

AMSDOS and BIOS Firmware

&C033 - BIOS SET MESSAGE

Enables or disables disc error messages

Entry
Exit

Notes

Enabling and disabling the messages can also be achieved by poking &BE78 with &00 or &FF.

&C036 - BIOS SETUP DISC

Sets the parameters which effect the disc speed.

Entry
Exit

Notes

The parameter block is arranged as follows:

&C039 - BIOS SELECT FORMAT

Sets a format for a disc.

Entry
Exit

Notes

To select one of the normal disc formats, the following values should be put into the A register:

This routine sets the extended disc parameter block (XDPB) at &A890 to &A8A8. To set other formats, the XDPB must be altered directly.

&C03C - BIOS READ SECTOR

Reads a sector from a disc into memory.

Entry
Exit

In either case, the other flags are corrupt, and all other registers are preserved.

&C03F - BIOS WRITE SECTOR

Writes a sector from memory onto disc.

Entry
Exit

In either case, the other flags are corrupt, and all other registers are preserved.

&C042 - BIOS FORMAT TRACK

Formats a complete track, inserts sectors, and fills the track with bytes of &E5.

Entry
Exit

In either case, the other flags are corrupt, and all the other registers are preserved.

Notes

The header information block is laid out as follows:

Header information blocks must be set up contiguously for every sector on the track, and in the same sequence that they are to be laid down (eg &C1, &C6, &C2, &C7, &C3, &C8, &C4, &C9, &C5).

&C045 - BIOS MOVE TRACK

Moves the disc drive head to the specified track.

Entry
Exit

In both cases, the other flags are corrupt, and all other registers are preserved.

Notes

There is normally no need to call this routine as READ SECTOR, WRITE SECTOR and FORMAT TRACK automatically move the head to the correct position

&C048 - BIOS GET STATUS

Returns the status of the specified drive.

Entry
Exit

In either case, the other flags are preserved, and all other registers are preserved.

Notes

The status byte indicates the drive's status as follows:

&C04B - BIOS SET RETRY COUNT

Sets the number of times the operation is retried in the event of disc error.

Entry
Exit

Notes

The default setting is &10, and the minimum setting is &01; the number of retries can also be altered by poking &BE66 with the required value.

&C56C - GET SECTOR DATA

Gets the data of a sector on the current track.

Entry
Exit

In either case, A and the other flags are corrupt, and all other registers are preserved.

Notes

The track number is held at &BE4F, the head number is held at &BE50, the sector number is held at &BE51, and the log2(sector size)-7 is held at &BE52; disc parameters do not need to be set to the format of the disc; this routine is best used with the disc error messages turned off.