Difference between revisions of "CP/M 3.0"
(→Extra memory) |
|||
(31 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Image:cpm30boot.jpg|thumb|300px|CP/M 3.0 after boot]] | [[Image:cpm30boot.jpg|thumb|300px|CP/M 3.0 after boot]] | ||
− | CPM 3.0 (also known as CPM+) was available on the 2nd | + | CPM 3.0 (also known as CPM+) was available on the 2nd [[System_Disk]] Disc for CPC6128 but there were other implementations available. |
+ | |||
+ | == Dobbertin's implementation of CP/M+ == | ||
+ | |||
+ | * [[Dobbertin CPM+]] | ||
== Graduate Software's implementation of CP/M+ on ROM == | == Graduate Software's implementation of CP/M+ on ROM == | ||
Line 9: | Line 13: | ||
== Amstrad's implementation of CP/M+ == | == Amstrad's implementation of CP/M+ == | ||
− | Amstrad distributed CP/M+ on the side 4 of the system discs that came with the CPC6128. It provided 61K TPA. | + | Amstrad distributed CP/M+ on the side 4 of the system discs that came with the CPC6128. It requires a Dk'Tronics compatible ram expansion. It provided 61K TPA. To get 61K TPA, CPM+ uses 'C1' and 'C2' RAM configuration with TPA in the 2nd bank and the CCP, BDOS, BIOS, screen and firmware in the 1st 64KB of RAM. This arrangement allows 61KB useable for programs. |
− | + | ||
− | * Amstrad CP/M+ uses Amstrad's "System" format. This is 40 tracks, 1 side, 9 sectors per track numbered &41-&49. There are two reserved tracks, then the directory which has 64 entries | + | On side 1 of the system discs was CP/M 2.2. |
+ | |||
+ | * Amstrad CP/M+ uses Amstrad's "System" format. This is 40 tracks, 1 side, 9 sectors per track numbered &41-&49. Each sector is 512bytes. There are two reserved tracks, then the directory which has 64 entries (which occupies 4 sectors) and then the data area. | ||
* CP/M is booted using an RSX command "|CPM" which is implemented in the Amstrad disc rom (AMSDOS). | * CP/M is booted using an RSX command "|CPM" which is implemented in the Amstrad disc rom (AMSDOS). | ||
* |CPM loads track 0, side 0, sector &41 into RAM at &100-&2ff. This is the boot sector and contains the boot program. | * |CPM loads track 0, side 0, sector &41 into RAM at &100-&2ff. This is the boot sector and contains the boot program. | ||
Line 20: | Line 25: | ||
* This is then executed. (EMS contains the BIOS, BDOS and relocates and re-configures the memory. CP/M doesn't use the CP/M 2.2 BIOS from the Amstrad disc ROM.) | * This is then executed. (EMS contains the BIOS, BDOS and relocates and re-configures the memory. CP/M doesn't use the CP/M 2.2 BIOS from the Amstrad disc ROM.) | ||
+ | === Creating a minimal boot disc === | ||
+ | |||
+ | Using CPM2.2: | ||
+ | * Use disckit2 to format a vendor format disc | ||
+ | * Use BOOTGEN to put the CPM+ boot sector onto your disc. (Source is CPM+, Destination is your disk). | ||
+ | * Use FILECOPY to put C10CPM3.EMS onto your disc (FILECOPY C10CPM3.EMS. Source is CPM+, Destination is your disk). | ||
+ | * Your minimal CP/M+ disc is bootable. | ||
+ | |||
+ | Using CPM3.3: | ||
+ | * Use disckit3 to format and install the boot sector onto the disc. | ||
+ | * Use PIP to copy C10CPM3.EMS to your disc (B:=A:C10CPM3.EMS) | ||
+ | * Your minimal CP/M+ disc is bootable. | ||
+ | |||
+ | === Terminal font === | ||
+ | |||
+ | <gallery caption="CP/M 3.0 terminal font"> | ||
+ | Image:Cpmplus.png | ||
+ | </gallery> | ||
+ | |||
+ | === Console Input === | ||
+ | |||
+ | Console input (via BDOS functions) uses firmware functions and returns firmware key codes when a key is pressed. i.e. &f0 is cursor up. | ||
+ | |||
+ | === Console Output/Terminal emulation === | ||
+ | |||
+ | Console output is processed via the terminal emulation. Console output doesn't execute firmware control codes. | ||
+ | |||
+ | A simplified VT52 terminal is emulated. Home means the top-left position. | ||
+ | |||
+ | The following are supported: | ||
+ | |||
+ | ESC 0 - disable status line | ||
+ | ESC 1 - enable status line | ||
+ | ESC 2 - set language | ||
+ | ESC 3 - set screen mode | ||
+ | ESC A - cursor up | ||
+ | ESC B - cursor down | ||
+ | ESC C - cursor left | ||
+ | ESC D - cursor right | ||
+ | ESC E - clear screen and move cursor to home | ||
+ | ESC H - move cursor to home | ||
+ | ESC I - reverse line feed | ||
+ | ESC J - erase to end of screen | ||
+ | ESC K - erase to end of line | ||
+ | ESC L - insert line | ||
+ | ESC M - delete current | ||
+ | ESC N - delete character and move characters up | ||
+ | ESC Y - set cursor position | ||
+ | ESC d - erase all above | ||
+ | ESC b - set foreground | ||
+ | ESC c - set background (and border) | ||
+ | ESC e - enable cursor | ||
+ | ESC f - disable cursor | ||
+ | ESC j - save cursor pos | ||
+ | ESC k - restore cursor pos | ||
+ | ESC l - erase and above cursor | ||
+ | ESC o - erase current line | ||
+ | ESC p - invert on | ||
+ | ESC q - invert off | ||
+ | ESC r - select bright (recognised but not implemented) | ||
+ | ESC u - cancel bright (recognised but not implemented) | ||
+ | ESC v - wrap on | ||
+ | ESC w - wrap off | ||
+ | ESC x - mono mode | ||
+ | ESC y - mono c080 mode | ||
+ | |||
+ | PCW and Spectrum support viewports. This is not supported on CPC. CPC assumes a single viewport covering the entire screen and it is moved up/down using software when using insert line or delete current, but moved up using hardware otherwise. | ||
+ | |||
+ | ==== ESC 2 - set language ==== | ||
+ | |||
+ | ESC 2 <language> | ||
+ | |||
+ | <language> is 0 based. The value is anded with 7. Internally this will transfer language specific character graphics into the font for display. | ||
+ | |||
+ | |||
+ | ==== ESC 3 - set display mode ==== | ||
+ | |||
+ | Set the display mode: | ||
+ | |||
+ | ESC 3 <mode number> | ||
+ | |||
+ | <mode number> is 0 based. The value is anded with 3. | ||
+ | |||
+ | e.g. to set mode 0: | ||
+ | |||
+ | ESC,3,0 | ||
+ | |||
+ | ==== ESC b - set foreground ==== | ||
+ | |||
+ | Set the foreground (pen 1) colour: | ||
+ | |||
+ | ESC b <colour> | ||
+ | |||
+ | Colour is 0 based with 32 added. It is a 2 bits per pixel %00rrggbb colour. | ||
+ | |||
+ | ==== ESC c - set background ==== | ||
+ | |||
+ | Set the background (pen 0 and border) colour: | ||
+ | |||
+ | ESC c <colour> | ||
+ | |||
+ | Colour is 0 based with 32 added. It is a 2 bits per pixel %00rrggbb colour. | ||
+ | |||
+ | |||
+ | ==== ESC Y - set cursor position ==== | ||
+ | |||
+ | Set the cursor position: | ||
+ | |||
+ | ESC Y <y> <x> | ||
+ | |||
+ | Coordinates are relative to top-left and are 0 based with 32 added. | ||
+ | |||
+ | e.g. for x,y of 2,10: | ||
+ | |||
+ | ESC,'Y',10+32,2+32 | ||
+ | |||
+ | === Memory layout === | ||
+ | |||
+ | * 1st 64KB has Amstrad's XBIOS (callable using 'userf'), CCP, BDOS, BIOS, screen and firmware. Screen is at &4000-&7fff. Firmware is used. AMSDOS is not used. | ||
+ | ## &c1/&c2 are used, so that there is common code at &c000-&ffff. This common code has a small BDOS and BIOS. Most of the functions use trampoline code to transition to bank 0 and call into the XBIOS. | ||
+ | * 2nd 64KB has the TPA and the shared code. | ||
+ | ## Page C4 has WBOOT and BDOS jump + &100-&3f00 of the TPA. This calls to functions in Page c7. | ||
+ | ## Page C5 has &4000-&7fff of the TPA. | ||
+ | ## Page C6 has &8000-&bfff of the TPA. | ||
+ | ## Page C7 has &c000-&f2fb of the TPA. From &f2fc to &ffff is the trampoline code which transitions * to 1st bank of 64KB. | ||
+ | |||
+ | === Extra memory === | ||
+ | |||
+ | CPM+ on the CPC uses 128KB of memory. Therefore selections C4,C5,C6,C7 must be avoided if you have additional memory. Due to the design of DkTronic's compatible RAM expansions all memory accesses to additional RAM must occur from bank 0 (i.e. 'C1') and be transferred to the TPA in bank 1 (i.e. 'C2'). | ||
+ | |||
+ | Therefore access to the additional RAM follows a pattern such as this: | ||
+ | * From running CPM program in bank 1 you need to go via code in C000-FFFF to transition to bank 0. This can be done using 'userf'. | ||
+ | * Within bank 0, your extra memory access code must lie within the regions 0000-3FFF or 8000-BFFF. 4000-7FFF is where the paging will take place so is out of bounds. C000-FFFF is where the memory trampoline code is paged in and out so using this area is much harder. | ||
+ | * Remember the current memory configuration (e.g. C1,C3,C0) | ||
+ | * In bank 0 set the memory selection (e.g. 'CC') then perform your read from the extra RAM into a temporary buffer within one of the safe areas. For write you copy from a safe area into the extra memory. | ||
+ | * Then you need to restore the memory configuration (e.g. C1,C3,C0) and trampoline back to the TPA. | ||
+ | |||
+ | Therefore extra memory access on the CPC is not as fast as it could be compared to running under AMSDOS. | ||
+ | |||
+ | === Implementing a storage device driver === | ||
+ | |||
+ | Using "drvtable" gets the list of DPH addresses for each drive. This is actually fixed at FE2F and is referenced by the XBIOS. | ||
+ | |||
+ | Amstrad implemented the extended DPH in the Digital Research sample BIOS. The ten bytes before a DPH give the addresses of read/write functions: | ||
+ | |||
+ | * -10,-9 - address of sector write function | ||
+ | * -8,-7 - address of sector read function | ||
+ | * -6,-5 - address of drive select function | ||
+ | * -4,-3 - address of drive init function (never called) | ||
+ | * -2 - physical drive number (for B: this is 0 on a single-drive system and 1 on a two-drive system) | ||
+ | * -1 - drive type | ||
+ | |||
+ | The XBIOS calls these and assumes bank 0 is active. If you write a driver in TPA space you will need to transition to and from bank 1 using selbnk etc. | ||
+ | |||
+ | The parameters for the read / write functions are at 0BEF0h: | ||
+ | DB @adrv ;Selected logical drive | ||
+ | DB @rdrv ;Selected physical drive (from the byte at DPH-2) | ||
+ | DW @trk ;Track passed to SETTRK. | ||
+ | DW @sect ;Sector passed to SETSEC. | ||
+ | DW @dma ;DMA address passed to SETDMA. | ||
+ | DB @cnt ;Multiple I/O count passed to MULTIO | ||
+ | DB @dbnk ;DMA bank passed to SETBNK | ||
+ | |||
+ | === PALETTE.COM === | ||
+ | |||
+ | PALETTE is a COM program written by Locomotive Software and allows the colours to be changed. | ||
+ | The syntax is: | ||
+ | |||
+ | PALETTE <background> <foreground> | ||
+ | |||
+ | <background> and <foreground> are r,g,b colour codes with 2 bits for each colour defined in binary as r1 r0 g1 g0 b1 b0. Therefore black is 000000, bright white is 111111, white (grey) is 010101 and bright red is 110000. | ||
+ | === Links === | ||
+ | * [https://www.seasip.info/Cpm/index.html John Elliott's information about CPM 2.2 and CPM+ on the Amstrad] | ||
[[Category:CP/M]][[Category:Operating System]] | [[Category:CP/M]][[Category:Operating System]] |
Latest revision as of 07:24, 28 April 2024
CPM 3.0 (also known as CPM+) was available on the 2nd System_Disk Disc for CPC6128 but there were other implementations available.
Contents
- 1 Dobbertin's implementation of CP/M+
- 2 Graduate Software's implementation of CP/M+ on ROM
- 3 Amstrad's implementation of CP/M+
Dobbertin's implementation of CP/M+
Graduate Software's implementation of CP/M+ on ROM
Amstrad's implementation of CP/M+
Amstrad distributed CP/M+ on the side 4 of the system discs that came with the CPC6128. It requires a Dk'Tronics compatible ram expansion. It provided 61K TPA. To get 61K TPA, CPM+ uses 'C1' and 'C2' RAM configuration with TPA in the 2nd bank and the CCP, BDOS, BIOS, screen and firmware in the 1st 64KB of RAM. This arrangement allows 61KB useable for programs.
On side 1 of the system discs was CP/M 2.2.
- Amstrad CP/M+ uses Amstrad's "System" format. This is 40 tracks, 1 side, 9 sectors per track numbered &41-&49. Each sector is 512bytes. There are two reserved tracks, then the directory which has 64 entries (which occupies 4 sectors) and then the data area.
- CP/M is booted using an RSX command "|CPM" which is implemented in the Amstrad disc rom (AMSDOS).
- |CPM loads track 0, side 0, sector &41 into RAM at &100-&2ff. This is the boot sector and contains the boot program.
- The boot program then loads the directory from track 2, sector &41.
- The boot program locates a program with extension "EMS".
- This program is loaded into RAM at &c00.
- This is then executed. (EMS contains the BIOS, BDOS and relocates and re-configures the memory. CP/M doesn't use the CP/M 2.2 BIOS from the Amstrad disc ROM.)
Creating a minimal boot disc
Using CPM2.2:
- Use disckit2 to format a vendor format disc
- Use BOOTGEN to put the CPM+ boot sector onto your disc. (Source is CPM+, Destination is your disk).
- Use FILECOPY to put C10CPM3.EMS onto your disc (FILECOPY C10CPM3.EMS. Source is CPM+, Destination is your disk).
- Your minimal CP/M+ disc is bootable.
Using CPM3.3:
- Use disckit3 to format and install the boot sector onto the disc.
- Use PIP to copy C10CPM3.EMS to your disc (B:=A:C10CPM3.EMS)
- Your minimal CP/M+ disc is bootable.
Terminal font
Console Input
Console input (via BDOS functions) uses firmware functions and returns firmware key codes when a key is pressed. i.e. &f0 is cursor up.
Console Output/Terminal emulation
Console output is processed via the terminal emulation. Console output doesn't execute firmware control codes.
A simplified VT52 terminal is emulated. Home means the top-left position.
The following are supported:
ESC 0 - disable status line ESC 1 - enable status line ESC 2 - set language ESC 3 - set screen mode ESC A - cursor up ESC B - cursor down ESC C - cursor left ESC D - cursor right ESC E - clear screen and move cursor to home ESC H - move cursor to home ESC I - reverse line feed ESC J - erase to end of screen ESC K - erase to end of line ESC L - insert line ESC M - delete current ESC N - delete character and move characters up ESC Y - set cursor position ESC d - erase all above ESC b - set foreground ESC c - set background (and border) ESC e - enable cursor ESC f - disable cursor ESC j - save cursor pos ESC k - restore cursor pos ESC l - erase and above cursor ESC o - erase current line ESC p - invert on ESC q - invert off ESC r - select bright (recognised but not implemented) ESC u - cancel bright (recognised but not implemented) ESC v - wrap on ESC w - wrap off ESC x - mono mode ESC y - mono c080 mode
PCW and Spectrum support viewports. This is not supported on CPC. CPC assumes a single viewport covering the entire screen and it is moved up/down using software when using insert line or delete current, but moved up using hardware otherwise.
ESC 2 - set language
ESC 2 <language>
<language> is 0 based. The value is anded with 7. Internally this will transfer language specific character graphics into the font for display.
ESC 3 - set display mode
Set the display mode:
ESC 3 <mode number>
<mode number> is 0 based. The value is anded with 3.
e.g. to set mode 0:
ESC,3,0
ESC b - set foreground
Set the foreground (pen 1) colour:
ESC b <colour>
Colour is 0 based with 32 added. It is a 2 bits per pixel %00rrggbb colour.
ESC c - set background
Set the background (pen 0 and border) colour:
ESC c <colour>
Colour is 0 based with 32 added. It is a 2 bits per pixel %00rrggbb colour.
ESC Y - set cursor position
Set the cursor position:
ESC Y <y> <x>
Coordinates are relative to top-left and are 0 based with 32 added.
e.g. for x,y of 2,10:
ESC,'Y',10+32,2+32
Memory layout
- 1st 64KB has Amstrad's XBIOS (callable using 'userf'), CCP, BDOS, BIOS, screen and firmware. Screen is at &4000-&7fff. Firmware is used. AMSDOS is not used.
- &c1/&c2 are used, so that there is common code at &c000-&ffff. This common code has a small BDOS and BIOS. Most of the functions use trampoline code to transition to bank 0 and call into the XBIOS.
- 2nd 64KB has the TPA and the shared code.
- Page C4 has WBOOT and BDOS jump + &100-&3f00 of the TPA. This calls to functions in Page c7.
- Page C5 has &4000-&7fff of the TPA.
- Page C6 has &8000-&bfff of the TPA.
- Page C7 has &c000-&f2fb of the TPA. From &f2fc to &ffff is the trampoline code which transitions * to 1st bank of 64KB.
Extra memory
CPM+ on the CPC uses 128KB of memory. Therefore selections C4,C5,C6,C7 must be avoided if you have additional memory. Due to the design of DkTronic's compatible RAM expansions all memory accesses to additional RAM must occur from bank 0 (i.e. 'C1') and be transferred to the TPA in bank 1 (i.e. 'C2').
Therefore access to the additional RAM follows a pattern such as this:
- From running CPM program in bank 1 you need to go via code in C000-FFFF to transition to bank 0. This can be done using 'userf'.
- Within bank 0, your extra memory access code must lie within the regions 0000-3FFF or 8000-BFFF. 4000-7FFF is where the paging will take place so is out of bounds. C000-FFFF is where the memory trampoline code is paged in and out so using this area is much harder.
- Remember the current memory configuration (e.g. C1,C3,C0)
- In bank 0 set the memory selection (e.g. 'CC') then perform your read from the extra RAM into a temporary buffer within one of the safe areas. For write you copy from a safe area into the extra memory.
- Then you need to restore the memory configuration (e.g. C1,C3,C0) and trampoline back to the TPA.
Therefore extra memory access on the CPC is not as fast as it could be compared to running under AMSDOS.
Implementing a storage device driver
Using "drvtable" gets the list of DPH addresses for each drive. This is actually fixed at FE2F and is referenced by the XBIOS.
Amstrad implemented the extended DPH in the Digital Research sample BIOS. The ten bytes before a DPH give the addresses of read/write functions:
- -10,-9 - address of sector write function
- -8,-7 - address of sector read function
- -6,-5 - address of drive select function
- -4,-3 - address of drive init function (never called)
- -2 - physical drive number (for B: this is 0 on a single-drive system and 1 on a two-drive system)
- -1 - drive type
The XBIOS calls these and assumes bank 0 is active. If you write a driver in TPA space you will need to transition to and from bank 1 using selbnk etc.
The parameters for the read / write functions are at 0BEF0h:
DB @adrv ;Selected logical drive DB @rdrv ;Selected physical drive (from the byte at DPH-2) DW @trk ;Track passed to SETTRK. DW @sect ;Sector passed to SETSEC. DW @dma ;DMA address passed to SETDMA. DB @cnt ;Multiple I/O count passed to MULTIO DB @dbnk ;DMA bank passed to SETBNK
PALETTE.COM
PALETTE is a COM program written by Locomotive Software and allows the colours to be changed. The syntax is:
PALETTE <background> <foreground>
<background> and <foreground> are r,g,b colour codes with 2 bits for each colour defined in binary as r1 r0 g1 g0 b1 b0. Therefore black is 000000, bright white is 111111, white (grey) is 010101 and bright red is 110000.