Use of memory by the Operating System

The following list of memory addresses and their uses has been compiled over a number of years, mainly from personal investigation. It does not claim to be definitive, since no accurate source seems to be available to the average computer user, and so may be inaccurate or deficient at certain points; also, some of the areas described have uses additional to those listed. We have tried to make it as accurate as possible, to enable others to use to the full those facilities which present themselves via this information.

Overview of the CPC's memory

In the following tables, the following symbols are used:

<>-not the value or bit which follows
*-this applies to all machine with a disk drive fitted
b0-bit 0
b1-bit 1
...
b15-bit 15
HB-most significant byte, hi-byte
LB-least significant byte, lo-byte

When addresses are given in the comments, they apply to the 6128. When the 464's address is different, it is given in brackets, such as at the comment for &B763.

Please note that this section of the guide has been set out with all the addresses in the leftmost column in the correct order for the 6128.

The System Variables

6128464SizeComments on the memory locations
&0000&0000&40Restart block:
&0000&0000RST 0: complete machine reset
&0008&0008RST 1: LOWJUMP: in-line two byte address: b0 to b13=address;
b14=Low ROM disabled;
b15=Upper ROM disabled
&000B&000BLOW PCHL: HL has address as RST 1
&000E&000E`JMP BC': BC has address to jump to
&0010&0010RST 2: SIDE CALL: inline two byte address: b0 to b13=address-&C000;
bl4 to b15=offset to required ROM (used between sequenced Foreground ROMs)
&0013&0013SIDE PCHL: HL has address as RST 2
&0016&0016`JMP DE': DE has address to jump to
&0018&0018RST 3: FAR CALL: inline three byte address block: bytes 1 and 2 hold the address;
byte 3 holds the ROM select address
&001B&001BFAR PCHL: as RST 3, but HL has address;
C has ROM select
&001E&001E`JMP HL': HL has address to jump to
&0020&0020RST 4: RAM LAM: LD A,(HL) from RAM with ROMs disabled
&0023&0023FAR CALL: as RST 3, but HL has address of three byte address block
&0028&0028RST 5: FIRM JUMP: inline two byte address to jump to
&0030&0030RST 6: User restart;
default to RST 0
&0038&0038RST 7: Interrupt entry (KB/Time etc)
&003B&003BExternal interrupt (default to RET)
&0040&0040&130ROM lower foreground area: BASIC input area (tokenised)
&016F&016Fend of BASIC input area.
&0170&0170BASIC working area for program, variables, etc...
&0170&0170Program area;
Variables and DEF FNs area;
Arrays area;
Free space;
end of free space;
Strings area;
end of Strings area (=HIMEM);
Space for user machine code routines;
end of user space, byte before user;
defined graphics area;
User defined graphics area;
end of UDG area;
ROM Upper reserved area, expandible during;
KL ROM WALK, including:
r*4ROM chaining blocks (arranged as follows):
&A6FC&A6FC4AMSDOS chain,ing block:
&A6FC&A6FC2address of next ROM block in chain (or &0000 if the last in chain)
&A6FE&A6FE1ROM Select address
&A6FF&A6FF1&00
&A700&A700&500AMSDOS reserved area. This area is moved down if any ROMs have numbers greater than eight (6128 only)
&A700&A7001Current drive number (0=A;
1=B)
&A701&A7011Current USER number
&A702&A7021flag?
&A703&A7032address?
&A705&A7051flag?
&A706&A7062address?
&A708&A7081OPENIN flag (&FF=closed; <>&FF=opened)
&A709&A709&20Copy of current or last Disc Directory entry for OPENIN/LOAD:
&A709&A7091USER number
&A70A&A70A8filename (padded with spaces)
&A712&A7123file extension (BAS, BIN, BAK, etc) including:
&A712&A7121b7 set = Read Only
&A713&A7131b7 set = System (ie not listed by CAT or DIR)
&A715&A715116K block sequence number for this directory entry (0 for first block; if <>0 part of a larger file)
&A716&A7162unused
&A718&A7181length of this block in 128 byte records
&A719&A71916sequence of Disc Block numbers containing file - &00 as end marker
&A729&A7291number of 128 byte records loaded so far; before loading proper: &00 for ASCII (ie nothing loaded yet); &01 for BIN or BAS files (ie header record loaded)
&A72A&A72A1
&A72B&A72B1
&A72C&A72C1OPENOUT flag (&FF=closed; <>&FF=opened)
&A72D&A72D&20Copy of current or last Disc Directory entry for OPENOUT/SAVE:
&A72D&A72D1USER number
&A72E&A72E8filename (padded with spaces)
&A736&A7363file extension ($$$ while open; correct extension when finished)
&A739&A7391flag (&00=open; &FF=closed, ie finished)
&A73A&A73A1
&A73B&A73B1flag (&00=open; &FF=closed)
&A73C&A73C1number of 128 byte records saved so far
&A73D&A73D16sequence of Disc Block numbers containing file - &00 as end marker
&A74D&A74D1number of 128 byte records saved so far
&A74E&A74E1
&A74F&A74F1
&A750&A7501flag (&00=OPENIN; &01=In Char; &02=In Direct (whole file))
&A751&A7512address of 2K buffer for ASCII, or of start of current/last block if BIN or BAS file
&A753&A7532address of next byte to read for ASCII, or of 2K buffer for BAS or BIN file
&A755&A755&45first &45 bytes of BAS/BIN file (extended header) or of extended header made for ASCII file
&A755&A7551USER number
&A756&A7568filename (padded)
&A75E&A75E3extension
&A761&A7616unused
&A767&A7671file type (&00=BASIC; &01=protected BASIC; &02=Binary; &16=ASCII)
&A768&A7682unused
&A76A&A76A2address to load file into (=actual destination), or buffer for an ASCII file
&A76C&A76C1unused for disc
&A76D&A76D2length of file in bytes (&0000 for ASCII files)
&A76F&A76F2execution address fora BIN file
&A770&A770&25unused
&A795&A7953length of actual file in bytes (as &A76D) -BAS and BIN only
&A798&A7982simple checksum of first 67 bytes of header (LB first) - BAS and BIN only
&A79A&A79A1flag (&00=OPENOUT; &01=Out Char; &02=Out Direct(whole file))
&A79B&A79B2address of 2K block if an ASCII file, or of current/last block saved if a BAS or BIN file
&A79D&A79D2address of next byte to write for ASCII files, or of 2K buffer for BAS and BIN files
&A79F&A79F&45first &45 bytes of BAS/BIN file (ie extended header)
&A79F&A79F1USER number
&A7A0&A7A08filename (padded)
&A7A8&A7A83extension
&A7AB&A7AB1flag (&00=Open)
&A7AC&A7AC1
&A7AD&A7AD1flag (&00=Open)
&A7AE&A7AE3unused
&A7B1&A7Bl1file type (&00=BASIC; &01=protected BASIC; &02=Binary; &16=ASCII)
&A7B2&A7B22unused
&A7B4&A7B42address to save file from (for BAS or BIN files), or of buffer for ASCII files
&A7B6&A7B61unused for disc
&A7B7&A7B72length of file in bytes
&A7B9&A7B92execution address for BIN files
&A7BB&A7BB&25unused
&A7DF&A7DF3length of actual file in bytes (as at &A7B7) - BAS and BIN only
&A7E2&A7E22simple checksum of first 67 bytes of header (LB first) - BAS and BIN only
&A7E4&A7E4&80buffer area for records sent to or loaded from Disc, or used in forming filename and extension
&A864&A86414*3Tape Jumpblock is stored here by AMSDOS - is moved to &BC77 etc after |TAPE
&A88B&A88B3far address used by AMSDOS RST 3s at &BC77 etc (&CD30,&07)
&A890&A890&19Drive A Extended Disc Parameter Block (XDPB):
&A890&A8902number of 128 byte records per track
&A892&A8921log2(Block size)-7 (&03=1024 bytes; &04=2048 bytes)
&A893&A8931(Block size)/128-1 (&07=1024 bytes;
&A894&A8941(Block size)/1024 (if total of blocks <256, else /2048)-1
&A895&A8952number of blocks per disc side (excluding reserved tracks)
&A897&A8972number of (directory entries)-1
&A899&A8992bit signiflcant value of number of blocks for directory (&0080=1; &00C0=2)
&A89B&A89B2number of bits in checksum =((&A894)+ 1)/4
&A89D&A89D2number of reserved tracks (&00=Data; &01=IBM; &02=System)
&A89F&A89F1number of first sector (&01=IBM; &41=System; &C1=Data)
&A8A0&A8A01number of sectors per track (Data=9; System=9; IBM=8)
&A8A1&A8Al1gap length (Read/Write)
&A8A2&A8A21gap length (Format)
&A8A3&A8A31format filler byte (&E5)
&A8A4&A8A41log2(sector size)-7 (&02=512; &03=1024)
&A8A5&A8A51records per sector
&A8A6&A8A61current track (not for use)
&A8A7&A8A710=not aligned (not for use)
&A8A8&A8A81Auto select flag (&00=Auto select; &FF= don't alter)
&A8A9&A8A9
&A8B9&A8B9
&A8D0&A8D0&19Drive B Extended Disc Parameter Block (arranged as at &A890)
&A8E9&A8E9(&17 bytes of &FF)
&A8F9&A8F9
&A900&A900(&12 bytes of &00)
&A910&A910
&A918&A9182address of area for reading directory entries for Drive A
&A91A&A91A2address of Drive A XDPB
&A91C&A91C2address of the byte after the end of Drive A XDPB
&A91E&A91E2
&A920&A920(8bytes of &00)
&A928&A9282address of area for reading directory entries for Drive B
&A92A&A92A2address of Drive B XDPB
&A92C&A92C2address of the byte after the end of Drive B XDPB
&A92E&A92E2
&A930&A930&80block of directory entries, including last file loaded
&A9B0&A9B0&200buffer for loading; usually contains last sector loaded
&ABB0&ABB0(&50 bytes of &00)
&AC00&AC00Start of BASIC Operating System reserved area:
&AC00&AC001program line redundant spaces flag (0=keep extra spaces; <>0=remove)
&AC019*3groups of 3 RET bytes (&C9) called by the Upper ROM
&AC01&AC1C1AUTO flag (0=off; <>0=on)
&AC02&AC1D2number of the next line (6128) or of the current line (464) for AUTO
&AC04&AC1F2step distance for AUTO
&AC06&AC211
&AC07&AC221
&AC081
&AC231
&AC09&AC241WIDTH (&84=132)
&AC0A&AC25
&AC0B
&AC0C&AC261FOR/NEXT flag (0=NEXT not yet used; <>0=used)
&ACOD&AC275FOR start value (real). Only 2 bytes are used if % or DEFINT variable
&AC12&AC2C2address of `: ' or of the end of program line byte after a NEXT command
&AC14&AC2E2address of LB of the line number containing WEND
&AC16&AC301WHILE/WEND flag (&41=WEND not yet used; &04=used)
&AC17&AC31
&AC18&AC322
&AClA&AC342
&AC1C&AC362address of location holding ROM routine address for KB event block
&AC1E&AC38&0CEvent Block for ON SQ(l):
&AC1E&AC382chain address to next event block; &0000 if last in chain, but &FFFF if unused
&AC20&AC3A1count
&AC21&AC3B1class: Far address, highest (ON SQ) priority, Normal & Synchronous event
&AC22&AC3C2routine address (in BASIC ROM)
&AC24&AC3E1ROM Select number (&FD ie ROM 0 enabled, Lower ROM disabled)
&AC25&AC3F1(first byte of user field)
&AC26&AC402address of the end of program line byte or `:' after `ON SQ(x) GOSUB line number' statement
&AC28&AC422address of the end of program line byte of the line before the GOSUB routine
&AC2A&AC44&0CEvent block for ON SQ(2), arranged as &AC1E onwards - second ON SQ priority
&AC36&AC50&0CEvent block for ON SQ(4), arranged as &AC1E onwards - lowest ON SQ priority
&AC42&AC5C&12Ticker and Event Block for AFTER/EVERY Timer 0
&AC42&AC5C2chain address to next event block (usually to another timer or &00FF)
&AC44&AC5E2`count down' count
&AC46&AC602recharge count (for EVERY only - &0000 if AFTER)
&AC48&AC622chain address to next ticker block
&AC4A&AC641count
&AC4B&AC651class: Far address, lowest (timer) priority, Normal and Synchronous event
&AC4C&AC662Routine address (in BASIC ROM)
&AC4E&AC681ROM Select No (&FD ie ROM 0 enabled, Lower ROM disabled)
&AC4F&AC691(first byte of user field)
&AC50&AC6A2address of the end of program line byte or `:' after statement in use when the timer `timed-out'
&AC52&AC6C2address of tbe end of program line byte of tbe line before the GOSUB routine
&AC54&AC6E&12Ticker and Event Block for AFTER/EVERY Timer 1 (3rd Timer priority) arranged as at &AC42
&AC66&AC80&12Ticker and Event Block for AFTER/EVERY Timer 2 (2nd Timer priority) arranged as at &AC42
&AC78&AC92&12Ticker and Event Block for AFTER/EVERY Timer 3 (highest priority) arranged as at &AC42
&AC8A&ACA4&100BASIC input area for lines (as typed in and not tokenised) or for INPUT
&AD8C&ADA62address of line number LB in line containing error
&AD8E&ADA82address of byte before statement containing error - ie of `:' or of HB of Line No
&AD90&ADAA1ERR (Error No)
&AD911DERR (Disc Error No)
&AD92&ADAB2as &AD8E if error is in a program (ie not if in Direct Command Mode)
&AD94&ADAD2as &AD8C if error is in a program (ie not if in Direct Command Mode)
&AD96&ADAF2address of the length LB of line specified by the `ON ERROR GOTO' command
&AD98&ADB11
&AD99&ADB2&09Current SOUND parameter block (see Firmware Jump &BCAA)
&AD99&ADB21channel andrendezvous status
&AD9A&ADB31amplitude envelope (ENV) number
&AD9B&ADB41tone envelope (ENT) number
&AD9C&ADB52tone period
&AD9E&ADB71noise period
&AD9F&ADB81initial amplitude
&ADA0&ADB92duration, or envelope repeat count
&ADA2&ADBB&10Current Amplitude or Tone Envelope parameter bloc (see &BCBC or &BCBF)
&ADA2&ADBB1number of sections (+&80 for a negative ENT number, ie the envelope is run until end of sound
&ADA3&ADBC3first section of the envelope:
&ADA3&ADBC1step count (if <&80) otherwise envelope shape (not tone envelope)
&ADA4&ADBD1step size (if step count<&80) otherwise envelope period (not tone envelope)
&ADA5&ADBE1pause time (if step count<&80) otherwise envelope period (not tone envelope)
&ADA6&ADBF3second section of the envelope, as &ADA3
&ADA9&ADC23third section of the envelope, as &ADA3
&ADAC&ADC53fourth section of the envelope, as &ADA3
&ADAF&ADC83fifth section of the envelope, as &ADA3
&ADB2&ADCB5
&ADB7&ADD0&36
&ADEB&AE042
&ADED&AE066
&ADF3&AE0C26*1table of DEFINT (&02), DEFSTR (&03) or DEFREAL default (&05), for variables `a' to `z'
&AE0D&AE26
&AE0E&AE272
&AE10&AE292
&AE12&AE2B2
&AE14&AE2D1
&AE15&AE2E2address of line number LB of last BASIC line (or &FFFF)
&AE17&AE302address of byte before next DATA item (eg comma or space)
&AE19&AE322address of next space on GOSUB etc stack, (see also &B06F)
&AE1B&AE342address of byte before current statement (&003F if in Direct Command mode)
&AE1D&AE362address of line number LB of line of current statement (&0000 if in Direct Command mode)
&AE1F&AE381trace flag (0=TROFF; <>0=TRON)
&AE20&AE391flag used with Trace (&00 if in Direct Command mode; &01 if in a program)
&AE21&AE3A
&AE22&AE3B2
&AE24&AE3D2
&AE26&AE3F2address to load cassette file to
&AE28&AE41
&AE29&AE421file type from cassette header
&AE2A&AE432file length from cassette header
&AE2C&AE451program protection flag (<>0 hides program as if protected)
&AE2D&AE4617buffer used to form binary or hexadecimal numbers before printing etc
&AE3A&AE535start of buffer used to form hexadecimal numbers before printing etc
&AE3A&AE531Key Number used with INKEY (providing the Key Number is written as a decimal)
&AE3E&AE571last byte (usually &00 or &20) of the formed binary or hexadecimal number
&AE43&AE5D13buffer used to form decimal numbers before printing etc
&AE4E&AE681last byte (usually &00 or &20) of the formed decimal number
&AE6B3
&AE511
&AE52&AE6E2
&AE541
&AE702temporary store for address after using (&AE68)
&AE55&AE722address of last used ROM or RSX JUMP instruction in its Jump Block
&AE57&AE741ROM Select number if address above is in ROM
&AE58&AE752BASIC Parser position, moved on to `: `, or the end of program line byte after a CALL or an RSX
&AE5A&AE772the resetting address for machine Stack Pointer after a CALL or an RSX
&AE5C&AE792ZONE value
&AE5D1
&AE7A1
&AE5E&AE7B2HIMEM (set by MEMORY)
&AE7D2address of the byte before the UDG area (the end of the user M/C routine area or the Strings area) if the UDG area is still present, otherwise the highest byte of Program etc area
&AE602address of highest byte of free RAM (ie last byte of UDG area)
&AE62&AE7F2address of start of ROM lower reserved area (used for tokenised lines)
&AE64&AE812address of end of ROM lower reserved area (byte before Program area)
&AE66&AE832as &AE68
&AE68&AE852address of start of Variables and DEF FNs area
&AE6A&AE872address of start of Arrays area (where next Variable or DEF FN entry is placed)
&AE6C&AE892address of start of free space (where next Array entry is placed)
&AE6E1
&AE70&AE8C&1FFGOSUB, FOR and WHILE stack. Entries are added above any existing ones in use (mixed as encountered) at address given by &B06F and must be used up in the opposite order. Completed entries are not deleted, just overwitten by the next new entry:
1(byte of &00)
2address of end of program line byte or `:' after GOSUB statement (the point to RETURN to)
2address of line number HB of line containing GOSUB
1byte of &06, ie the length of the GOSUB entry
2address of current value of control variable (in Variables area)
5value of limit (ie the TO value) - there are two bytes only for Integer FORs
5value of STEP - two bytes for Integer FORs
1sign byte (&00 for positive; &01 for negative)
2address of the end of program line byte, or `:' after the FOR statement (ie the address for the NEXT loop to restart at)
2address of line number LB of line containing FOR
2address of byte after NEXT statement (ie the address to continue at when the limit is exceeded)
2address of byte after NEXT statement again
1length byte (&16 for Real FORs; &10 for Integer FORs)
WHILE (66 max capacity):
2address of line number LB of line containing WHILE
2address of the end of program line byte or `:' after WEND statement (ie the address to continue at when the condition is false)
2address of condition after the WHILE command
1length byte of &07 - end of WHILE entry proper but:
+5value of condition (0 or -1 as a floating point value) only while the WHILE entry is the last on the stack
&B06F&B08B2address of the next space on the GOSUB etc stack (see also &AE19)
NB: The free space on the stack is also used as a workspace by various routines for values and addresses and for Variable names
&B071&B08D2address of end of free space (the byte before the Strings area)
&B073&B08F2address of end of Strings area (=HIMEM)
&B0751
&B0911
&B0922
&B076&B0942
&B078&B0962address of the highest byte of free RAM disregarding UDGs (usually &A6FB)
&B07A&B0982
&B07C&B09A2address for the next entry in the String Concatenation area
&B07E&B09C10*3concatenation area holding descriptors of strings being used
&B09C&B0BA1length of last String used
&B09D&B0BB2address of last String used
&B0BD2
&BOBF2
&B09F&BOC11type byte used with the Virtual Accumulator (&02=Integer; &03=String; &05=Real)
&B0A0&B0C25Virtual Accumulator used by the maths routines (two bytes for an Integer value; three bytes for a String Descriptor; five bytes for a Real value)
&B0A0&B0C22
&B0A2&B0C41
&B0A3&B0C52
&B0A5&B0C7&5B(&39 bytes on 464) bytes of &FF
&B100&B8E42&07, &C6
&B102&B8E62&65, &89
&B104&B8E85
&B109&B8ED5
&B10E&B8F25
&B113&B8F71DEG/RAD flag (&00=RAD; &FF=DEG)
&B114&B8DC1
&B115&B8DD1
&B116&B8DE1
&B117&B8DF1
&B118&B800&D2Area used for Cassette handling:
&B118&B8001cassette handling messages flag (0=enabled; <>O=disabled)
&B119&B8011
&B11A&B8021file IN flag (&00=closed; &02=IN file; &03=opened; &05=IN char)
&B11B&B8032address of 2K buffer for directories
&B11D&B8052address of 2K buffer for loading blocks of files - often as &B11B
&B11F&B807&40IN Channel header
&B11F&B807&10filename (padded with NULs)
&B12F&B8171number of block being loaded, or next to be loaded
&B130&B8181last block flag (&FF=last block; &00=not)
&B131&B8191file type (&00=BASIC; &01=Protected BASIC; &02=Binary; &08=Screen; &16=ASCII)
&B132&B81A2length of this block
&B134&B81C2address to load this or the next block at,or the address of the byte after last one loaded
&B136&B81E1first block flag (&FF=first block; &00=not)
&B137&B81F2total length of file (all blocks)
&B139&B8212execution address for BIN files (&0000 if not saved as such)
&B13B&B823&24not allocated
&B15F&B8471file OUT flag (&00=closed; &02=IN file; &03=opened; &05=IN char)
&B160&B8482address to start the next block save from, or the address of the buffer if it is OPENOUT
&B162&B84A2address of start of the last block saved, or the address of the buffer if it is OPENOUT
&B164&B84C&40OUT Channel Header (details as IN Channel Header):
&B164&B84C&10filename
&B174&B85C1number of the block being saved, or next to be saved
&B175&B85D1last block flag (&FF=last block; &00=not)
&B176&B85E1file type (as at &B131
&B177&B85F2length saved so far
&B179&B8612address of start of area to save, or address of buffer if it is an OPENOUT instruction
&B17B&B8631first block flag (&FF=first block; &00=not)
&B17C&B8642total length of file to be saved
&B17E&B8662execution address for BIN files (&0000 if parameter not supplied)
&B180&B868&24not allocated
&B1A4&B88C&40used to construct IN Channel header:
&B1B5&B89D1
&B1B7&B89F2
&B1B8&B8A31
&B1BE&B8A61
&B1B9&B51Dbase address for calculating relevant Sound Channel block
&B1BC&B520base address for calculating relevant Sound Channel ?
&B1BE&B522base address for calculating relevant Sound Channel ?
&B1D5&B539base address for calculating relevant Sound Channel ?
&B1E4&B8CC1
&B1E5&B8CD1synchronisation byte
&B1E6&B8CE2&55, &62
&B1E8&B8D01
&B1E9&B8D11cassette precompensation (default &06; SPEED WRITE 1 &0C @4microseconds)
&B1EA&B8D21cassette `Half a Zero' duration (default &53; SPEED WRITE 1 &29 @ 4microseconds)
&B1EB&B8D32
&B5501used by sound routines
&B5511used by sound routines
&B1ED1used by sound routines
&B1EE&B5521used by sound routines
&B1F0&BB541used by sound routines
&BB557used by sound and cassette routines
&B1F8&B55C&3FSound Channel A (1) data:
&B212&B5761number of sounds still queuing
&B213&B5771number of sounds originally queuing
&B217&B57B8first or fifth sound in Channel 1 (A) queue:
&B217&B57B1status: b0 to b2 = rendezvous with channel 1, 2 or 4; b3 = Hold; b4 = Flush
&B218&B57C1b0 to b3 = tone envelope number; b4 to b7 = volume envelope number (ie ENV number*16)
&B219&B57D2pitch
&B21B&B57F1noise
&B21C&B5801volume
&B21D&B5812duration (in 0.01 seconds)
&B21F&B5838second sound in Channel 1 queue (as &B217)
&B227&B58B8third sound in Channel 1 queue (as &B217)
&B22F&B5938fourth sound in Channel 1 queue (as &B217)
&B237&B59B&3FSound Channel B (2) data - as described at &B1F8
&B256&B5BA8first or fifth sound in Channel 2 queue (as &B217)
&B25E&B5C28second sound in Channel 2 queue (as &B217)
&B266&B5CA8third sound in Channel 2 queue (as &B217)
&B26E&B5D28fourth sound in Channel 2 queue (as &B217)
&B276&B5DA&3FSound Channel C (4) data - as described at &B1F8
&B295&B5F98first or fifth sound in Channel 4 queue (as &B217)
&B29D&B60182nd sound in Channel 4 queue (as &B217)
&B2A5&B60983rd sound in Channel 4 queue (as &B217)
&B2AD&B61184th sound in Channel 4 queue (as &B217)
&B2A6&B60Abase address for calculating relevant ENV parameter block
&B2B6&B61A15*16ENV parameter block area (each arranged as &ADA2):
&B2B6&B61A&10ENV 1
&B2C6&B62A&10ENV 2
&B2D6&B63A&10ENV 3
&B2E6&B64A&10ENV 4
&B2F6&B65A&10ENV 5
&B306&B66A&10ENV 6
&B316&B67A&10ENV 7
&B326&B68A&10ENV 8
&B336&B69A&10ENV 9
&B346&B6AA&10ENV 10
&B356&B6BA&10ENV 11
&B366&B6CA&10ENV 12
&B376&B6DA&10ENV 13
&B386&B6EA&10ENV 14
&B396&B6FA&10ENV 15
&B396&B6FAbase address for calculating relevant ENT parameter block
&B3A6&B70A15*16ENT parameter block area (each arranged as &ADA2):
&B3A6&B70A&10ENT 1
&B3B6&B71A&10ENT 2
&B3C6&B72A&10ENT 3
&B3D6&B73A&10ENT 4
&B3E6&B74A&10ENT 5
&B3F6&B75A&10ENT 6
&B406&B76A&10ENT 7
&B416&B77A&10ENT 8
&B426&B78A&10ENT 9
&B436&B79A&10ENT 10
&B446&B7AA&10ENT 11
&B456&B7BA&10ENT 12
&B466&B7CA&10ENT 13
&B476&B7DA&10ENT 14
&B486&B7EA&10ENT 15
&B496&B34C&50Normal Key Table:
Cur UCur RCur Df9f6f3Enterf.
Cur LCopyf7f8f5f1f2f0
Clr[Ret]f4\
^-@p;:/.
09oilkmj
87uyhjnSpace
65rtgfbv
43ewsdcx
12EscqTabaCapsz
[VT][LF][BS][TAB]Fire2Fire1Del
&B4E6&B39C&50Shifted Key Table:
Cur UCur RCur Df9f6f3Enterf.
Cur LCopyf7f8f5f1f2f0
Clr{Ret}f4`
£=|P+*?>
_)OILKM<
('UYHJNSpace
&%RTGFBV
$#EWSDCX
!"EscQ->ACapsZ
[VT][LF][BS][TAB]Fire2Fire1Del
&B536&B3EC&50Control Key Table:
Cur UCur RCur Df9f6f3Enterf.
Cur LCopyf7f8f5f1f2f0
Clr(ESC)Ret(GS)f4(FS)
(RS)(NUL)(DLE)
(US)(SI)(HT)(FF)(VT)(CR)
(NAK)(EM)(BS)(LF)(SO)
(DC2)(DC4)(BEL)(ACK)(STX)(SYN)
(ENQ)(ETB)(DC3)(EOT)(ETX)(CAN)
~Esc(DC1)Ins/Ovrt(SOH)S-lck(SUB)
Del
&B586&B43C10KB repeats table (each byte/bit applies to all three key tables): 1 byte is used per line of the tables; b0 to b7 give the columns (left to right), repeat if set
&B590&B446&98DEF KEY's definition area (for Keys &80 to &9F in sequence): each definition has either a single byte of &00 if it is unused/unaltered, or: byte 1: length of definition bytes 2 to x: definition, either a single key or a string of keys
&B628&B4DE1Byte after end of DEF KEY area
&B629&B4DF1
&B62A&B4E01
&B62B&B4E12address of DEF KEY area
&B62D&B4E32address of byte after end of DEF KEY area
&B62F&B4E51
&B630&B4E61
&B631&B4E71Shift lock flag (&00=off; &FF=on)
&B632&B4E81Caps lock flag (&00=off; &FF=on)
&B633&B4E91KB repeat period (SPEED KEY - default &02 @ 0.02 seconds)
&B634&B4EA1KB delay period (SPEED KEY - default &1E @ 0.02 seconds)
&B635&B4EB2*10Tables used for key scanning; bits 0 to 7 give the table columns (from left to right):
&B635&B4EB1
Cur UCur RCur Df9f6f3Enterf.
&B636&B4EC1
Cur LCopyf7f8f5f1f2f0
&B637&B4ED1
Clr[Ret]f4Shift\Ctrl
&B638&B4EE1
^-@p;:/.
&B639&B4EF1
09oilkmj
&B63A&B4F01
87uyhjnSpace
&B63B&B4F11
DownUpLeftRightFire2Fire1(Joystick 1)
65rtgfbv
&B63C&B4F21
43ewsdcx
&B63D&B4F31
12EscqTabaCapsz
&B63E&B4F41
DownUpLeftRightFire2Fire1(Joystick 2)
Del
&B63F&B4F51complement of &B635
&B640&B4F61complement of &B636
&B641&B4F71complement of &B637
&B642&B4F81complement of &B638
&B643&B4F91complement of &B639
&B644&B4FA1complement of &B63A
&B645&B4FB1complement of &B63B
&B646&B4FC1complement of &B63C
&B647&B4FD1complement of &B63D
&B648&B4FE1complement of &B63E
&B64B&B501
&B653&B5091
&B654&B5OA1
&B655&B50B1
&B656&B50C1
&B657&B50D7event block for Keyboard handling, comprises:
&B657&B50D2chain address
&B659&B50F1count
&B65A&B5101class: express event
&B65B&B5112ROM routine address: &C492
&B65D&B5131ROM select number: &FD
&B65E&B51420*2store for last keys pressed and each entry is as follows: byte 1: +0 to +10=key tables' line number; if bit 5 is set then Shift is pressed; bit 7=Control is pressed byte 2: b0 to b7=key tables' column number - see &B496 etc
&B67F&B67F2vestige from the 464?
&B686&B53C1
&B687&B53D1accumulated count of the number of keys pressed (MOD 20)
&B688&B53E1number of keys left in key buffer
&B689&B53F1accumulated count of the number of keys removed from the buffer (MOD 20)
&B68A&B5401
&B68B&B5412address of the normal key table
&B68D&B5432address of the shifted key table
&B68F&B5452address of the control key table
&B691&B5472address of the KB repeats table
&B6921
&B693&B3282ORIGIN x
&B695&B32A2ORIGIN y
&B697&B32C2graphics text x position (pixel)
&B699&B32E2graphics text y position(pixel)
&B69B&B3302graphics window x of one edge (pixel)
&B69D&B3322graphics window x of other edge (pixel)
&B69F&B3342graphics window y of one side (pixel)
&B6A1&B3362graphics window y of other side (pixel)
&B6A3&B3381GRAPHICS PEN
&B6A4&B3391GRAPHICS PAPER
&B6A5&B33A8/14(This area is 14 bytes on the 464) Used by line drawing (and other) routines, as follows:
&B6A7&B33A2x+1()
&B6A9&B33C2y/2+1()
&B6AB&B33E2y/2-x()
&B6AD&B3402
&B3422
&B6AF&B3441
&B6B0&B3451
&B6B1&B3461
&B6B21first point on drawn line flag (<>0=to be plotted; 0=don't plot)
&B6B31line MASK
&B6B41
&B2072
&B6B5&B20C1current stream number
&B6B6&B20D14/15(These areas are 15 bytes on the 464) Stream (window) 0 parameter block. These areas are arranged as &B726
&B6C4&B21C14/15stream (window) 1 parameter block
&B6D2&B22B14/15stream (window) 2 parameter block
&B6E0&B23A14/15stream (window) 3 parameter block
&B6EE&B24914/15stream (window) 4 parameter block
&B6FC&B25814/15stream (window) 5 parameter block
&B70A&B26714/15stream (window) 6 parameter block
&B718&B27614/15stream (window) 7 parameter block
&B726&B28514/15Current Stream (Window) parameter block:
&B726&B2851cursor y position (line) with respect to the whole screen (starting from 0)
&B727&B2861cursor x position (column) with respect to the whole screen (starting from 0)
&B728&B287
&B729&B2881window top line (y) with respect to the whole screen (starting from 0)
&B72A&B2891window left column (x) with respect to the whole screen (starting from 0)
&B72B&B28A1window bottom line (y) with respect to the whole screen (starting from 0)
&B72C&B28B1window right colwnn (x) with respect to the whole screen (starting from 0)
&B72D&B28C1scroll count
&B72E&B28D1cursor flag (&01=disable; &02=off; &FD=on; &FE=enable)
&B28E1
&B72F&B28F1current PEN number (encoded, not its INK number)
&B730&B2901current PAPER number (encoded, not its INK number)
&B731&B2912address of text background routine: opaque=&1392; transparent=&13A0
&B733&B2931graphics character writing flag (0=off; <>0=on)
&B734&B2941ASCII number of the first character in User Defined Graphic (UDG) matrix table
&B735&B2951UDG matrix table flag (&00=non-existent; &FF=present)
&B736&B2962address of UDG matrix table
&B738&B2982
&B758&B2B81
&B759&B2B91
&B763&B2C332*3Control Code handling routine table - each code's entry comprises: byte 1: +0 to +9=number of parameters; +&80=re-run routine at a System Reset bytes 2 and 3: address of the control code's handling routine
&B763&B2C33ASC 0: &80,&1513: NUL
&B766&B2C63ASC 1: &81,&1335: Print control code chararacter [,char]
&B769&B2C93ASC 2: &80,&1297: Disable cursor
&B76C&B2CC3ASC 3: &80,&1286: Enable cursor
&B76F&B2CF3ASC 4: &81,&0AE9: Set mode [,mode]
&B772&B2D23ASC 5: &81,&1940: Print character using graphics mode [,char]
&B775&B2D53ASC 6: &00,&1459: Enable VDU
&B778&B2D83ASC 7: &80,&14E1: Beep
&B77B&B2DB3ASC 8: &80,&1519: Back-space
&B77E&B2DE3ASC 9: &80,&151E: Step-right
&B781&B2E13ASC 10: &80,&1523: Linefeed
&B784&B2E43ASC 11: &80,&1528: Previous line
&B787&B2E73ASC 12: &80,&154F: Clear window and locate the cursor at position 1,1
&B78A&B2EA3ASC 13: &80,&153F: RETURN
&B78D&B2ED3ASC 14: &81,&12AB: Set paper [,pen]
&B790&B2F03ASC 15: &81,&12A6: Set pen [,pen]
&B793&B2F33ASC 16: &80,&155E: Delete the character at the cursor position
&B796&B2F63ASC 17: &80,&1599: Clear the line up to the current cursor position
&B799&B2F93ASC 18: &80,&158F: Clear from the cursor position to the end of the line
&B79C&B2FC3ASC 19: &80,&1578: Clear from start of the window to the cursor position
&B79F&B2FF3ASC 20: &80,&1565: Clear from the cursor position to the end of a window
&B7A2&B3023ASC 21: &80,&1452: Disable VDU
&B7A5&B3053ASC 22: &81,&14EC: Set text write mode [,mode]
&B7A8&B3083ASC 23: &81,&0C55: Set graphics draw mode [,mode]
&B7AB&B30B3ASC 24: &80,&12C6: Exchange pen and paper
&B7AE&B30E3ASC 25: &89,&150D: Define user defined character [,char,8 rows of char]
&B7B1&B3113ASC 26: &84,&1501: Define window [,left,right,top,bottom]
&B7B4&B3143ASC 27: &00,&14EB: ESC (=user)
&B7B7&B3173ASC 28: &83,&14F1: Set the pen inks [,pen,ink 1,ink 2]
&B7BA&B31A3ASC 29: &82,&14FA: Set border colours [,ink,ink2]
&B7BD&B31D3ASC 30: &80,&1539: Locate the text cursor at position 1,1
&B7C0&B3203ASC 31: &82,&1547: Locate the text cursor at [,column,line]
&B7C3&B1C81MODE number
&B7C4&B1C92screen offset
&B7C6&B1CB1screen base HB (LB taken as &00)
&B7C7&B1CC3graphics VDU write mode indirection - JP &0C74
&B1CF8list of bytes having only one bit set, from b7 down to b0
&B7D2&B1D71first flash period (SPEED INK - default &0A @ 0.02 seconds)
&B7D3&B1D81second flash period (SPEED INK - default &0A @ 0.02 seconds)
&B7D4&B1D91+16Border and Pens' First Inks (as hardware numbers):
&B7D4&B1D91hw &04 = sw 1 (blue) border
&B7D5&B1DA1hw &04 = sw 1 (blue) pen 0
&B7D6&B1DB1hw &0A = sw 24 (bright yellow) pen 1
&B7D7&B1DC1hw &13 = sw 20 (bright cyan) pen 2
&B7D8&B1DD1hw &0C = sw 6 (bright red) pen 3
&B7D9&B1DE1hw &0B = sw 26 (bright white) pen 4
&B7DA&B1DF1hw &14 = sw 0 (black) pen 5
&B7DB&B1E01hw &15 = sw 2 (bright blue) pen 6
&B7DC&B1E11hw &0D = sw 8 (bright magenta) pen 7
&B7DD&B1E21hw &06 = sw 10 (cyan) pen 8
&B7DE&B1E31hw &1E = sw 12 (yellow) pen 9
&B7DF&B1E41hw &1F = sw 14 (pale blue) pen 10
&B7E0&B1E51hw &07 = sw 16 (pink) pen 11
&B7E1&B1E61hw &12 = sw 18 (bright green) pen 12
&B7E2&B1E71hw &19 = sw 22 (pale green) pen 13
&B7E3&B1E81hw &04 = sw 1 (blue) pen 14
&B7E4&B1E91hw &17 = sw 11 (sky blue) pen 15
&B7E5&B1EA1+16Border and Pens' Second Inks (as hardware numbers):
&B7E5&B1EA1hw &04 = sw 1 (blue) border
&B7E6&B1EB1hw &04 = sw 1 (blue) pen 0
&B7E7&B1EC1hw &0A = sw 24 (bright yellow) pen 1
&B7E8&B1ED1hw &13 = sw 20 (bright cyan) pen 2
&B7E9&B1EE1hw &0C = sw 6 (bright red) pen 3
&B7EA&B1FF1hw &0B = sw 26 (bright white) pen 4
&B7EB&B1F01hw &14 = sw 0 (black) pen 5
&B7EC&B1F11hw &15 = sw 2 (bright blue) pen 6
&B7ED&B1F21hw &0D = sw 8 (bright magenta) pen 7
&B7EE&B1F31hw &06 = sw 10 (cyan) pen 8
&B7EF&B1F41hw &1E = sw 12 (yellow) pen 9
&B7F0&B1F51hw &1F = sw 14 (pale blue) pen 10
&B7F1&B1F61hw &07 = sw 16 (pink) pen 11
&B7F2&B1F71hw &12 = sw 18 (bright green) pen 12
&B7F3&B1F81hw &19 = sw 22 (pale green) pen 13
&B7F4&B1F91hw &04 = sw 1 (bright yellow) pen 14
&B7F5&B1FA1hw &17 = sw 11 (pink) pen 15
&B7F6&B1FB1
&B7F7&B1FC1
&B7F8&B1FD1
&B7F9&BlFE2
&B7FB&B2002
&B7FD
&B8021+1
&B8041number of entries in the Printer Translation Table (normally 10)
&B80520*2Printer Translation Table; each entry comprises: byte 1: screen code byte 2: pnnter code
&B8052screen &A0 printer &5E (acute accent)
&B8072screen &A1 printer &5C (\)
&B8092screen &A2 printer &7B ({)
&B80B2screen &A3 printer &23 (#)
&B80D2screen &A6 printer &40 (@)
&B80F2screen &AB printer &7C (|)
&B8112screen &AC printer &7D (})
&B8132screen &AD printer &7E (~)
&B8152screen &AE printer &5D (])
&B8172screen &AF printer &SE ([)
&B81920room for ten more translations
&B82D&B1001
&B82E&B1011
&B82F&B1022
&B831&B1041
&B832&B1052temporary store for stack pointer (SP) during interrupt handling
&B834&B107&70temporary machine stack (from &B8B3 downwards) during interrupt handling
&B8B4&B1874TIME (stored with the LB first - four bytes give >166 days; three bytes give >15 hours)
&B8B8&B18B1
&B8B9&B18C2
&B8BB&B18E2
&B8BD&B1902address of the first ticker block in chain (if any)
&B8BF&B1921Keyboard scan flag (&00=scan not needed; &01=scan needed)
&B8C0&B1932address of the first event block in chain (if any)
&B8C2&B1951
&B8C3&B196&10buffer for last RSX or RSX command name (last character has bit 7 set)
&B8D3&B1A62address of first ROM or RSX chaining block in chain
&B8D51RAM bank number
&B8D6&B1A81Upper ROM status (eg select number)
&B8D7&B1A92entry point of foreground ROM in use (eg &C006 for BASIC ROM)
&B8D9&B1AB1foreground ROM select address (0 for the BASIC ROM)
&B8DA16*2ROM entry IY value (ie the address table) - the 6128 has ROMs numbered from 0 to 15:
&B1AC7*2ROM entry IY value (ie the address table)
&B8DA2ROM 0 IY (not for the 464)
&B8DC&B1AC2ROM 1 IY
&B8DE&B1AE2ROM 2 IY
&B8E0&B1B02ROM 3 IY
&B8E2&B1B22ROM 4 IY
&B8E4&B1B42ROM 5 IY
&B8E6&B1B62ROM 6 IY
&B8E8&B1B82ROM 7 IY (usually &A700 for AMSDOS/CPM ROM)
&B8EA2ROM 8 IY (not 464)
&B8EC2ROM 9 IY (not 464)
&B8EE2ROM 10 IY (not 464)
&B8F02ROM 11 IY (not 464)
&B8F22ROM 12 IY (not 464)
&B8F42ROM 13 IY (not 464)
&B8F62ROM 14 IY (not 464)
&B8F82ROM 15 IY (not 464)
&B8FA66 bytes of &FF
&B1BA1414 bytes of &00
&B900&B90012*3High Kernel Jumpblock (on the 464 this block is 11*3 bytes in size)
&B924&B921&1C0routines used by the High Kernel Jumpblock (on the 464 this is &1C8 bytes in size)
&BAE4&BAE9bytes of &FF (&1C bytes on 6128, &17 bytes on 464)
&BB00&BB0026*3Key Manager Jumpblock
&BB4E&BB4E36*3Text VDU Jumpblock
&BBBA&BBBA23*3Graphics VDU Jumpblock
&BBFF&BBFF34*3Screen Pack Jumpblock
&BC65&BC6522*3Cassette (and Disc if fitted) Manager Jumpblock
&BCA7&BCA711*3Sound Manager Jumpblock
&BCC8&BCC825*3Kernel Jumpblock
&BD13&BD1326*3Machine Pack Jumpblock (on the 464 this block is 14*3 bytes in size)
&BD61&BD3D32*3Maths Jumpblock (on the 464 this block is 48*3 bytes in size)
&BDCD&BDCD14*3Firmware Indirections (on the 464 this block is 13*3 bytes in size
&BDF7&BDF4bytes of &00 (&09 bytes on 6128, &0C bytes on the 464) the lower limit of Machine Stack if no Disc Drive
&BE00&BE00&40&40 bytes of &FF
&BE40&BE40&4xused by the AMSDOS ROM if a disc drive is fitted (otherwise &4x bytes of &FF)
&BE40&BE402(address &A910)
&BE42&BE422address of drive A XDPB
&BE44&BE449Disc Set Up timing block:
&BE44&BE442motor on period (default &0032; fastest &0023 @ 20mS)
&BE46&BE462motor off period (default &00FA; fastest &00C8 @ 20mS)
&BE48&BE481write current off period (default &AF @ 10æS)
&BE49&BE491head settle time (default &0F @ 1mS)
&BE4A&BE4A1step rate period (default &0C; fastest &0A @ 1mS)
&BE4B&BE4B1head unload delay (default &01)
&BE4C&BE4C1b0=non DMA mode; b1 to b7=head load delay (default &03)
&BE4D&BE4D2
&BE4F&BE4F1Drive Header Information Block:
&BE4F&BE4F1last track used
&BE50&BE501head number (&00)
&BE51&BE511last sector used
&BE52&BE521log2(sector size)-7
&BE53&BE531
&BE54&BE541
&BE55&BE551
&BE56&BE561
&BE58&BE581
&BE59&BE591
&BE5D&BE5D1
&BE5E&BE5E1
&BE5F&BE5F1disc motor flag (&00=off;&01=on - strangely reversed)
&BE60&BE602address of buffer for directory entries block (&A930)
&BE62&BE622as &BE76 (ie&A9B0)
&BE64&BE642
&BE66&BE661disc retries (default &10)
&BE67&BE67&11AMSDOS Ticker and Event Block:
&BE67&BE672ticker chaining address
&BE69&BE692tick count
&BE6B&BE6B2recharge count
&BE6D&BE6D2event chaining address
&BE6F&BE6F1count
&BE70&BE701class (asynchronous event)
&BE71&BE712ROM routine address (&C9D6)
&BE73&BE731ROM select number (&07 ie the AMSDOS/CPM ROM)
&BE74&BE741last sector number used
&BE75&BE751
&BE76&BE762address of «K buffer, or of header info block (for WRlTE SECTOR etc)
&BE78&BE781disc error message flag (&00=on; &FF=off - reversed again)
&BE7D&BE7D2address of AMSDOS reserved area (&A700)
&BE7F&BE7Fxarea used by AMSDOS to copy routines into RAM for running
&BE80&BE80&80&80 bytes of &FF (limit of machine stack if disc drive fitted)
&BF00&BF00xy&xy bytes of &00)
&BFxymachine stack (in theory this stack could extend down much further)
&BFFF&BFFFupper limit of machine stack

The area from &C000 to &FFFF is taken up by the screen memory - the layout of which is illustrated below. Printed below are diagrams which show how the CPC uses the bytes of screen memory in the different MODEs. For each byte:

NB:the numbers in brackets show which bit of the pixel's pen number the screen byte bit refers to. For example in MODE 1, the 4 most significant bits of the byte hold bit 1 of the pixel's pen value and the least signifcant bits hold bit 0 of the pen value.

LINER0W0R0W1R0W2R0W3R0W4R0W5R0W6R0W7
1C000C800D000D800E000E800F000F800
2C050C850D050D850E050E850F050F850
3C0A0C8A0D0A0D8A0E0A0E8A0F0A0F8A0
4C0F0C8F0D0F0D8F0E0F0E8F0F0F0F8F0
5C140C940D140D940E140E940F140F940
6C190C990D190D990E190E990F190F990
7C1E0C9E0D1E0D9E0E1E0E9E0F1E0F9E0
8C230CA30D230DA30E230EA30F230FA30
9C280CA80D280DA80E280EA80F280FA80
10C2D0CAD0D2D0DAD0E2D0EAD0F2D0FAD0
11C320CB20D320DB20E320EB20F320FB20
12C370CB70D370DB70E370EB70F370FB70
13C3C0CBC0D3C0DBC0E3C0EBC0F3C0FBC0
14C410CC10D410DC10E410EC10F410FC10
15C460CC60D460DC60E460EC60F460FC60
16C4B0CCB0D4B0DCB0E4B0ECB0F4B0FCB0
17C500CD00D500DD00E500ED00F500FD00
18C550CD50D550DD50E550ED50F550FD50
19C5A0CDA0D5A0DDA0E5A0EDA0F5A0FDA0
20C5F0CDF0D5F0DDF0E5F0ED50F550FD50
21C640CE40D640DE40E640EE40F640FE40
22C690CE90D690DE90E690EE90F690FE90
23C6E0CEE0D6E0DEE0E6E0EEE0F6E0FEE0
24C730CF30D730DF30E730EF30F730FF30
25C780CF80D780DF80E780EF80F780FF80
spare startC7D0CFD0D7D0DFD0E7D0EFD0F7D0FFD0
spare endC7FFCFFFD7FFDFFFE7FFEFFFF7FFFFFF

Once the whole screen has been scrolled in any direction, the table will become incorrect. On scrolling, all the above addresses will have an offset (MOD &800) added, derived as follows:

If scrolled far enough, a screen row may sit across the boundaries of the screen memory area, whose bottom end will then wrap around to join up with the top (ie byte &FFFF will be followed by byte &C000 assuming the normal screen area). If before scrolling however, a window had been set up smaller than the whole screen then the table will remain accurate despite any scrolling. The `spare' areas of screen memory are filled with bytes of the relevant PAPER value each time there is a full screen CLS, and are not really available for other uses. After scrolling the spare areas may be used as screen with other bytes becoming spare.

David Cantrell, March 1996