LIMIT &FFFF       ;(c) Dr. Stefan W. Stumpferl aka TFM of FutureSoft
ORG   &B800       ;Version for CPC6128 and 6128plus - ENGlisch
;File #OS-Var.Eng ;Contains 1015 lines (check it!) - 2024-06-11
WIDTH 120         ;Set printer to 120 columns

NOLIST
NOCODE


;------------------------------------;
; FUTURE OPERATING SYSTEM Memory Map ;
;------------------------------------/
;
; &FFFFH !====!===========================================================;
;        !  3 !         - read  > 16 KB RAM or one out of 256 ROM's       ;
;        !  3 ! block 3 - write > 16 KB RAM (V-RAM) / ST = OS ROM A..D    ;
; &C000H !====!===========================================================;
;        !  2 !         - read  > 16 KB RAM only COMMON RAM block = ST    ;
;        !  2 ! block 2 - write > 16 KB RAM only COMMON RAM block = ST    ;
; &8000H !====!===========================================================;
;        !  1 !         - read  > 16 KB RAM (1 - 257) or memory-map IO    ;
;        !  1 ! block 1 - write > 16 KB RAM see read / ST = RAM &C0       ;
; &4000H !====!===========================================================;
;        !  0 !         - read  > 16 KB RAM or L-ROM, each with charset   ;
;        !  0 ! block 0 - write > 16 KB RAM (RST vectors, IM1) / ST = RAM ;
; &0000H !====!===========================================================;
;
; ST = standart usage
;
;
; BFFF ---\
;      ----\
; BF00 -----> BE02 to BFFF 510 bytes stack (255 elements max)
;      ----/
; BE00 ---<
;      ----> BD00 to BE00 (incl.) 257 bytes INTERUPT MODE 2 vectors
; BD00 ---<
;      ----> BC00..BC7F fileheader of the actual foreground program
; BC00 ---<  BC80..BCFF fileheader of the actual background program
;      ----\
; BB00 -----\
;      ------\
; BA00 -------> B800 to BBFF 1024 bytes memory for system variables
;      ------/
; B900 -----/
;      ----/
; B800 ---<
;      ----\
; B700 -----\
;      ------\
; B600 -------\
;      --------!
; B500 --------!
;      --------!
; B400 --------! B000 to B7FF 2048 bytes text-screen buffer or applications
;      --------!
; B300 --------!
;      --------!
; B200 -------/
;      ------/
; B100 -----/
;      ----/
; B000 ---/
;
; A000-A0FF - 256 tagging bytes for FDC 0 (internal) and drive A
; A100-A1FF - 256 tagging bytes for FDC 0 (internal) and drive B
; A200-A2FF - 256 tagging bytes for FDC 0 (internal) and drive C
; A300-A3FF - 256 tagging bytes for FDC 0 (internal) and drive D
;
; A400-A4FF - 256 tagging bytes for FDC 1 (external) and drive E
; A500-A5FF - 256 tagging bytes for FDC 1 (external) and drive F
; A600-A6FF - 256 tagging bytes for FDC 1 (external) and drive G
; A700-A7FF - 256 tagging bytes for FDC 1 (external) and drive H
;
; A800-A9FF - 512 tagging bytes for hard-disc partition I
; AA00-ABFF - 512 tagging bytes for hard-disc partition J
; AC00-ADFF - 512 tagging bytes for hard-disc partition K
; AE00-AFFF - 512 tagging bytes for hard-disc partition L
;
; Composisation of one of the before 4096 file-tagging-bytes ...
; bit 0 - zero => not tagged /// one => file is tagged
; bit 1 - zero => not retagged / one => retagged (file has been used)
; bit 2 reserved
; bit 3 reserved
; bit 4 reserved
; bit 5 - RO  / RW    ;===> compatible to amsdos DIRectory (32 byte/extent DIR)
; bit 6 - DIR / SYS   ;===> compatible to amsdos DIRectory (32 DIR)
; bit 7 - ARC / NOARC ;===> compatible to amsdos DIRectory (32 DIR)


;The following EQUates are used by the Desktop and the OS

KS0XL EQU &6000 ;coordinates hardware sprite 0 of 6128plus
KS0XH EQU &6001
KS0YL EQU &6002
KS0YH EQU &6003 ;... or ...
;
P_BUF EQU &B400 ;64 bytes video-RAM-buffer (CPC6128) f. soft-sprite

FDC_MOT EQU &FA7E ;Motor-Port of all Floppy Drives
FDC0_ST EQU &FB7E ;MAIN-STATUS-REGISTER internal FDC765
FDC1_ST EQU &FBF6 ;external FDC (Vortex), other base adress!

TMS_A EQU &A000 ; tagging of disc and hard disc drives
TMS_B EQU &A100 ; standart drives A, B, (C, D) of the internal FDC765
TMS_C EQU &A200
TMS_D EQU &A300

TMS_E EQU &A400 ; drives E to F (external Vortex FDC765)
TMS_F EQU &A500
TMS_G EQU &A600
TMS_H EQU &A700

TMS_I EQU &A800 ; Dobbertin HD20 hard disc partitions I to L (20 MB)
TMS_J EQU &AA00 ; FutureOS I-L are equivalent to D-G under BASIC or CP/M
TMS_K EQU &AC00
TMS_L EQU &AE00

;Memory drive M (inactive, support partial)
;The memroy drive DIRectory data is bufferd in RAM

TAR16   EQU &1800 ;8K buffer for 32 to 16 DIR conversion
TXT_SCR EQU &B000 ;start of the 2 kb text-screen-buffer


;Memory from &B800 to &BBFF byte after byte
;Some bytes are just for the OS or apps
;Some bytes are very powerfull and/or important for you, Coder!

TAS_S1  DS 64 ;64 (32*2) bytes for mode 1 terminal JP-table, must lay at &B800
              ;table contains the adresses of control codes (screen mode 1)

FDC_RES DS 7 ;7 bytes RESULT phase FDC 0 and 1.

RAMCHAR DS 1 ;Screen-Mode and RAM/ROM-charset selection --> &80-&87
;
;Bit 0, 1 contain the screen mode 0..3 (MODE 0 - 2 like known from Basic)
;
;Bit 2 = 0 ==> Character set from lower ROM (banked in)
;      = 1 ==> Use RAM character set from &3800 bis &3FFF
;
;Bits 7-3 = 10000

C_POS   DS 2 ;2 bytes cursor position >> Mode 1 &BFFE-&C7FE or Mod2 &BFFF-&C7FF

AKT_ROM DS 2 ;actual selected ROM between &C000 and &FFFF, nuber 0-&FF.
             ;followed by &DF, allows a LD BC,(AKT_ROM) + OUT (C),C command

AKT_RAM DS 2 ;actual active RAM &C4..&FF or &C0 for standart-RAM.
             ;followed by &7F, allows LD BC,(AKT_ROM) + OUT (C),C instruction

TAST_R0 DS 10 ;data of the PSG keyboard lines 0..9, see docu. of OS-ROM A.

TURBO_A DS 8 ;Turbo Desk drive A, 8 control bytes, see below
TURBO_B DS 8 ;Turbo Desk drive B
TURBO_C DS 8 ;Turbo Desk drive C
TURBO_D DS 8 ;Turbo Desk drive D

TURBO_E DS 8 ;Turbo Desk drive E
TURBO_F DS 8 ;Turbo Desk drive F
TURBO_G DS 8 ;Turbo Desk drive G
TURBO_H DS 8 ;Turbo Desk drive H

TURBO_I DS 8 ;Turbo Desk drive I
TURBO_J DS 8 ;Turbo Desk drive J
TURBO_K DS 8 ;Turbo Desk drive K
TURBO_L DS 8 ;Turbo Desk drive L

TURBO_M DS 8 ;Turbo Desk drive M

;byte 0 - drive tagging byte
;
; bits 7,6,5,4 - contain disc-format number
;
; &0X ==> disc or partition is unused or has a unknown format
; &1X ==> VORTEX - Format
; &2X ==> ibm ---- Format
; &4X ==> SYSTEM - Format
; &8X ==> FutureOS Format (not used/implemented)
; &CX ==> DATA --- Format
;
; bit 3 - directory manipulated, relevant if bit 0 = 1 (drive activ)
;       = 0 ==> DIR was NOT manipulated up now, no erase, rename, save, copy ..
;       = 1 ==> DIR was manipulated through a file-operation (ERA,REN,SAVE ..)
;
; bit 2 - head-number if single-sided formats are used with a doubleside drive
;       = 0 ==> head number 0 is used
;       = 1 ==> head number 1 is used
; Beware! This function is set inactive up to now !!!
;
; bit 1 - drive status
;       = 0 ==> drive exists and is usable
;       = 1 ==> drive not existing, not connected or set not active
;
; bit 0 - drive tag byte
;       = 0 ==> not tagged / active
;       = 1 ==> drive is tagged, now it can be used
;
;byte 1 - RAM block &C4..&FF or &C0. - (32 DIR, 1-1 copy of drive-directory)
;byte 2 - start adress h.b. &40 - &7F. (32 DIR)
;byte 3 - length, high byte &00 - &40. (32 DIR)
;
;byte 4 - RAM block &C4..&FF or &C0. - (16 DIR, text ver., shown on screen)
;byte 5 - start adress page &40 - &7F. (16 DIR)
;byte 6 - length, high byte &00 - &20. (16 DIR)
;
;byte 7 - number of pages, each page shows 64 DIR-entrys


TURBO_X DS 1 ;lowest, used DIR-buffer EXT-RAM; &C0, &C4..&FF
        DS 1 ;highest free adress (high byte) &41 - &80 of above DIR-RAM
             ;e.g. &FF, &80 (CPC with 576K RAM and no DIR-Buffer)

REG_AF1 DS 2 ;register AF - CPU register buffer (used by the machine monitor)
REG_BC1 DS 2 ;register BC
REG_DE1 DS 2 ;register DE
REG_HL1 DS 2 ;register HL

REG_AF2 DS 2 ;register AF'
REG_BC2 DS 2 ;register BC'
REG_DE2 DS 2 ;register DE'
REG_HL2 DS 2 ;register HL'

REG_IX  DS 2 ;register IX
REG_IY  DS 2 ;register IY
REG_SP  DS 2 ;register SP
REG_R   DS 1 ;register R
REG_I   DS 1 ;register I ;BEWARE! never change this value! must be &BD

REG_PC  DS 2 ;register PC

REG08_0 DS 1 ;USER-register 0 (8 bit)
REG08_1 DS 1 ;USER-register 1 (8 bit)
REG08_2 DS 1 ;USER-register 2 (8 bit)
REG08_3 DS 1 ;USER-register 3 (8 bit)
REG08_4 DS 1 ;USER-register 4 (8 bit)
REG08_5 DS 1 ;USER-register 5 (8 bit)
REG08_6 DS 1 ;USER-register 6 (8 bit)
REG08_7 DS 1 ;USER-register 7 (8 bit)

REG16_0 DS 2 ;USER-register 0 (16 bit)
REG16_1 DS 2 ;USER-register 1 (16 bit)
REG16_2 DS 2 ;USER-register 2 (16 bit)
REG16_3 DS 2 ;USER-register 3 (16 bit)
REG16_4 DS 2 ;USER-register 4 (16 bit)
REG16_5 DS 2 ;USER-register 5 (16 bit)
REG16_6 DS 2 ;USER-register 6 (16 bit)
REG16_7 DS 2 ;USER-register 7 (16 bit)
REG16_8 DS 2 ;USER-register 8 (16 bit)
REG16_9 DS 2 ;USER-register 9 (16 bit)

REG32_0 DS 4 ;USER-register 0 (32 bit)
REG32_1 DS 4 ;USER-register 1 (32 bit)

TAS_S2 DS 64 ;64 (32*2) bytes for Mode 2 control code adresses
             ;must lay at &B900

TMD_A DS 2 ; number of files of drive A (INTERNAL FDC765)
TMD_B DS 2 ; these variables are used by Turbo-Desk
TMD_C DS 2 ; they give the number of files of the corresponding drive
TMD_D DS 2
TMD_E DS 2 ; (EXTERNAL FDC765 from VORTEX)
TMD_F DS 2 ; the FDC from the Vortex F1-S or F1-D drives is called EXTERNAL FDC
TMD_G DS 2
TMD_H DS 2
TMD_I DS 2 ; (HD 20MB)
TMD_J DS 2 ; 20 MB Dobbertin hard disc
TMD_K DS 2 ; every partition I-L has 5 MB
TMD_L DS 2
TMD_M DS 2 ;memory drive

;the following 8 bytes contain the Dobbertin-Real-time-clock data. The OS-ROM
;version of the SETUP bytes contains the date of the OS generation instead.
;
UHR_00  DS 1 ;byte 0 ==> 0.1 and 0.01 seconds
UHR_SEK DS 1 ;byte 1 ==> seconds
UHR_MIN DS 1 ;byte 2 ==> minutes
UHR_STU DS 1 ;byte 3 ==> hours
UHR_WOT DS 1 ;byte 4 ==> day of the week 1-7, 1=sunday. Clear bit 5 starts RTC!
UHR_TAG DS 1 ;byte 5 ==> day of nonth
UHR_MON DS 1 ;byte 6 ==> month
UHR_JAR DS 1 ;byte 7 ==> year (ten and one digits)

UHR_ROM DS 2 ;ROM number of the Dobbertin / dxs or M4 board RTC
             ;followed by the byte &DF, which allows LD BC,(UHR_ROM), OUT (C),C

MAX_CRX DS 1 ;X = temp. max. chars per line, MAXIMUM 104
MAX_CRY DS 1 ;Y = temp. max. lines per page, MAXIMUM  40

MAX_RAM DS 1 ;number of all free 16K expansion-RAM-blocks, which are adressed
             ;from E-RAM &C4 upwards, without any break. - sometimes used -

ADROM_X DS 1 ;Number of the FutureOS X-ROM from which the OS was called

ADROM_A DS 2 ;Number of FutureOS ROM A, followed by byte &DF
             ;Allows LD BC,,(ADROM_A) + OUT (C),C

FREEZE  DS 1 ;Bit 7 > Albireo mouse token // Bits 6-0 > free

ANALOX  DS 1 ;delay for Analog-Joystick horizontal. - 6128plus -
ANALOY  DS 1 ;delay for Analog-Joystick vertical.   - 6128plus -

DIRIN   DS 1 ;DIRectory is buffered (drive) // &FF ==> NO DIR has been read.


; Configuraton and setup bytes
; ============================
;
; Bits being marked with an 'A' at the left will be 'A'utomatically set
; when the FutureOS is started. 'U' is set by the User, 'F' by FutureSoft
;
;U Bit 0 = 0 ==> Values will be entered in the HEXadecimal number system
;U       = 1 ==> Values will be entered in the ... DECimal number system
;
;A Bit 1 = 0 ==> no Albireo connected
;A       = 1 =====> Albireo connected
;
;A Bit 2 = 0 ==> no PlayCity connected
;A       = 1 =====> PlayCity connected
;
;U Bit 3 = 0 ==> no MultiPlay connected
;U       = 1 =====> MultiPlay connected
;
;U Bit 4 = 0 ==> SPARtan MODE OFF. Normal display of the Desktop-Icons
;U       = 1 ==> SPARtan MODE  ON. Minimal display of the Desktop-Icons
;
;U bit 5 = 0 ==> no DigiBlaster connected
;U       = 1 =====> DigiBlaster connected
;
;  bit 6 = 0 ==> no WizCat Net connected
;        = 1 =====> WizCat Net connected
;
;  bit 7 = 0 ==> no M4-WiFi connected
;        = 1 =====> M4-WiFi connected
;
KF_MED  DS 1 ; %MWDSMPAN - Network, Digi-Blaster, SPARtan, MP, PCity, Albi, Hex


;A bit 0 = 0 ==> no external FDC connected.
;A       = 1 ==> Vortex (F1-D, F1-S) FDC connected.
;
;A bit 1 = 0 ==> no internal FDC connected
;A         1 ==> internal FDC connected (CPC464 -> DDI-1 or Dobbertin)
;
;A bit 2 = 0 ==> no CPC Booster(+)
;A       = 1 ==> CPC Booster(+) connected
;
;  bit 3 = 0 ==> no Vortex HD connected
;        = 1 ==> Vortex Winchester connected
;
;A bit 4 = 0 ==> no hard-disc HD20 connected
;A       = 1 ==> Dobbertin harddisc HD20 connected
;
;U bit 5 = 0 ==> no tape connected
;U       = 1 =====> tape connected
;
;  bit 6 = 0 ==> no real-time-clock (Dobbertin / dxs or M4 board) connected
;        = 1 =====> real-time-clock (Dobbertin / dxs or M4 board) connected
;
;  bit 7 = 0 ==> no real-time-clock (Happy computer special-edition)
;        = 1 =====> real-time-clock (Happy computer special-edition)
;
KF_FDHD DS 1 ; %HTKHVBIE ;FDC external/internal, HD type, RTC connected


; bit 0 = 0 ==> no internal drive (DS 0 - drive A) connected
;       = 1 =====> internal drive (DS 0 - drive A) connected
; bit 1 = 0 internal drive (DS 0 - drive A) has 40 tracks
;       = 1 internal drive (DS 0 - drive A) has 80 tracks
; bit 2 = 0 internal drive (DS 0 - drive A) is single-sided
;       = 1 internal drive (DS 0 - drive A) is double-sided
; bit 3 = 0 internal drive (DS 0 - drive A) is a Floppy Emulator
;       = 1 internal drive (DS 0 - drive A) has 3, 3.5, 5.25 inches
;
; bit 4 = 0 ==> no internal drive (DS 1 - drive B) connected
;       = 1 =====> internal drive (DS 1 - drive B) connected
; bit 5 = 0 internal drive (DS 1 - drive B) has 40 tracks
;       = 1 internal drive (DS 1 - drive B) has 80 tracks
; bit 6 = 0 internal drive (DS 1 - drive B) is single-sided
;       = 1 internal drive (DS 1 - drive B) is double-sided
; bit 7 = 0 internal drive (DS 1 - drive B) is a Floppy Emulator
;       = 1 internal drive (DS 1 - drive B) has 3, 3.5, 5.25 inches
;
KF_AB DS 1 ; %11111001 ; drive's A and B of the internal FDC


; bit 0 = 0 ==> no internal drive (DS 2 - drive C) connected
;       = 1 =====> internal drive (DS 2 - drive C) connected
; bit 1 = 0 internal drive (DS 2 - drive C) has 40 tracks
;       = 1 internal drive (DS 2 - drive C) has 80 tracks
; bit 2 = 0 internal drive (DS 2 - drive C) is single-sided
;       = 1 internal drive (DS 2 - drive C) is double-sided
; bit 3 = 0 internal drive (DS 2 - drive C) is a Floppy Emulator
;       = 1 internal drive (DS 2 - drive C) has 3, 3.5, 5.25 inches
;
; bit 4 = 0 ==> no internal drive (DS 3 - drive D) connected
;       = 1 =====> internal drive (DS 3 - drive D) connected
; bit 5 = 0 internal drive (DS 3 - drive D) has 40 tracks
;       = 1 internal drive (DS 3 - drive D) has 80 tracks
; bit 6 = 0 internal drive (DS 3 - drive D) is single-sided
;       = 1 internal drive (DS 3 - drive D) is double-sided
; bit 7 = 0 internal drive (DS 3 - drive D) is a Floppy Emulator
;       = 1 internal drive (DS 3 - drive D) has 3, 3.5, 5.25 inches
;
KF_CD DS 1 ; %00000000 ; drive's C and D of the internal FDC


; bit 0 = 0 ==> no external drive (DS 0 - drive E) connected
;       = 1 =====> external drive (DS 0 - drive E) connected
; bit 1 = 0 external drive (DS 0 - drive E) has 40 tracks
;       = 1 external drive (DS 0 - drive E) has 80 tracks
; bit 2 = 0 external drive (DS 0 - drive E) is single-sided
;       = 1 external drive (DS 0 - drive E) is double-sided
; bit 3 = 0 external drive (DS 0 - drive E) is a Floppy Emulator
;       = 1 external drive (DS 0 - drive E) has 3, 3.5, 5.25 inches
;
; bit 4 = 0 ==> no external drive (DS 1 - drive F) connected
;       = 1 =====> external drive (DS 1 - drive F) connected
; bit 5 = 0 external drive (DS 1 - drive F) has 40 tracks
;       = 1 external drive (DS 1 - drive F) has 80 tracks
; bit 6 = 0 external drive (DS 1 - drive F) is single-sided
;       = 1 external drive (DS 1 - drive F) is double-sided
; bit 7 = 0 external drive (DS 1 - drive F) is a Floppy Emulator
;       = 1 external drive (DS 1 - drive F) has 3, 3.5, 5.25 inches
;
KF_EF DS 1 ; %11111111 ; drive's E and F of the external FDC (Vortex)


; bit 0 = 0 ==> no external drive (DS 2 - drive G) connected
;       = 1 =====> external drive (DS 2 - drive G) connected
; bit 1 = 0 external drive (DS 2 - drive G) has 40 tracks
;       = 1 external drive (DS 2 - drive G) has 80 tracks
; bit 2 = 0 external drive (DS 2 - drive G) is single-sided
;       = 1 external drive (DS 2 - drive G) is double-sided
; bit 3 = 0 external drive (DS 2 - drive G) is a Floppy Emulator
;       = 1 external drive (DS 0 - drive G) has 3, 3.5, 5.25 inches
;
; bit 4 = 0 ==> no external drive (DS 3 - drive H) connected
;       = 1 =====> external drive (DS 3 - drive H) connected
; bit 5 = 0 external drive (DS 3 - drive H) has 40 tracks
;       = 1 external drive (DS 3 - drive H) has 80 tracks
; bit 6 = 0 external drive (DS 3 - drive H) is single-sided
;       = 1 external drive (DS 3 - drive H) is double-sided
; bit 7 = 0 external drive (DS 3 - drive H) is a Floppy Emulator
;       = 1 external drive (DS 3 - drive H) has 3, 3.5, 5.25 inches
;
KF_GH DS 1 ; %00000000 ; drive's G and H of the external FDC


;Since 2024.06.11 unused
;
KF_MEM  DS 1


;A bit 0 = 0 ==> no serial interface connected, at all
;A       = 1 =====> serial interface connected, in general
;A bit 1 = 0 ==> no Schneider-interface (Z80-STI) connected
;A       = 1 =====> Schneider-interface (Z80-STI) connected
;A bit 2 = 0 ==> no Amstrad-interface (Z80-SIO) connected
;A       = 1 =====> Amstrad-interface (Z80-SIO) connected
;  bit 3 = 0 ==> no Vortex-interface (Z80-SIO) connected
;        = 1 =====> Vortex-interface (Z80-SIO) connected
;  bit 4 = 0 ==> no RS232C-Valcom-interface (Z80-SIO) connected
;        = 1 =====> RS232C-Valcom-interface (Z80-SIO) connected
;A bit 5 = 0 ==> no USIfAC-interface (PIC16F1579) connected
;A       = 1 =====> USIfAC-interface (PIC16F1579) connected
;
;U bit 6 = 0 ==> 7 bit printerport (original)
;U       = 1 ==> 8 bit printerport (6128plus or 8. bit patch)
;
;U bit 7 = 0 ==> Green screen or S/W monitor connected
;U       = 1 ==> RGB Color-monitor connected
;
KF_SIO  DS 1 ;Serial interfaces, printer and monitor


; 2,1,0 = 000 = 0 ==> CPC464
;       = 001 = 1 ==> CPC664
;       = 010 = 2 ==> CPC6128
;       = 011 = 3 ==> 464plus
;       = 100 = 4 ==> 6128plus
;       = 101 = 5 ==> GX4000 conversion
;       = 110 = 6 ==> C-One
;       = 111 = 7 ==> T-Rex1
;
;U 5,4,3 = 00 0 = 0 ==> OS user has German mother tongue
;U       = 00 1 = 1 ==> French
;U       = 01 0 = 2 ==> English
;U       = 01 1 = 3 ==> Greek
;U       = 10 0 = 4 ==> Spanish
;U       = 10 1 = 5 ==> Dutch
;U       = 11 0 = 6 ==> reserved
;U       = 11 1 = 7 ==> reserved
;
;A  7,6 = 00 = 0 ==> no CPC-IDE / X-MASS, no SYMBiFACE II/III connected
;A      = 01 = 1 ==> CPC-IDE / X-MASS connected
;A      = 10 = 2 ==> SYMBiFACE II connected
;A      = 11 = 3 ==> SYMBiFACE III connected
;
KF_CPC  DS 1 ;CPC type, language and IDE device


;A Bit 0 = 0 ==> M4 SD card inactive / not connected
;A       = 1 ==> Directory of M4 SD card read, buffered and usable
;
;A Bit 1 = 0 ==> no LambdaSpeak speech synthesiser connected
;A       = 1 =====> LambdaSpeak speech synthesiser connected
;
;A Bit 2 = 0 ==> no Amstrad SSA-1 speech synthesiser connected
;A       = 1 =====> Amstrad SSA-1 speech synthesiser connected
;
;A Bit 3 = 0 ==> no dk'tronics speech synthesiser connected
;A       = 1 =====> dk'tronics speech synthesiser connected
;
;U Bit 4 = 0 ==> DIRectories will be read on click at DIR Icon (like usually)
;U       = 1 ==> DIRectories will be auto-read after tagging a drive Icon
;
;F Bit 5 = 0 ==> Personal FutureOS version
;F       = 1 ==> Generic version of FutureOS
;
;U Bit 6 = 0 ==> Date & Time are shown as Icons (middle)
;U       = 1 ==> Date & Time are shown as characters (bottom)
;
;A Bit 7 = 0 ==> no Nova nvRAM/RTC connected
;A       = 1 =====> Nova nvRAM/RTC connected
;
KF_VERS DS 1 ;Format Time/Date, Gen/Pers, Auto-DIR, Speech Synth.


; Bits 15-0 = 16 Bit User number
;
KF_OSUN DS 2 ; &0100 ;Personal User Identification number 0..65535


;Desktop-bytes for SCRI and TAG_DIR
;(TD... variables), don't change.

TDRAM DS 1 ;RAM block (16er DIR) of actual drive
TDHST DS 1 ;Highbyte startadr. 16er DIR
TDANZ DS 1 ;number of total 1K pages of the DIR of the actual shown drive
TDAKT DS 1 ;actual 1K page (Desktop shows it at the moment)
TDLWK DS 1 ;act. drive (whoose DIR is shown)

MO_ST DS 1 ;MOtor STatus, normal &00 user can switch drive-motors on/off
           ; = &00 => all drive-motors OFF (or ON on demand/command)
           ; = &FF => drive-motors always running (not recommended, but faster)

TAST_N DS 80 ;80 bytes for ASCII chars, key-matrix 10 * 8, NORMAL-level

;The following 32 bytes represent the 32 expansion-RAMs (16K per E-RAM)
;The E-RAMs are banked between &4000 and &7FFF. They're numbered &C4,&C5..&FF
;
; bit 7 !==> = 1 ==> RAM contains a loaded file.
; bit 6 !==> = 1 ==> RAM contains a multitasking program.
; bit 5 !==> = 1 ==> ??? reserved!!!
; bit 4 !==> = 1 ==> RAM is reserved for the user, OS ignores block, eg RAMdisc
; bit 3 !==> = 1 ==> RAM is used as a SHORTTIME buffer
;                    Therefore you can use it freely
; bit 2 !==> = 1 ==> RAM is used as LONGTIME buffer.
;                    e.g. printer-buffer, soft-memory-floppy, old 64K ect.
; bit 1 !==> = 1 ==> RAM contains a DIRectory buffer.
; bit 0 !==> = 0 ==> RAM not connected. /// = 1 ==> RAM is connected.
;
; Only one of the bits 1..7 can be set, they define the purpose of the RAM
;
; RAMs with the status &01 or &09 are free usable, don't use the others.
;
XRAM_C4 DS 1 ;32 eXpansion RAMs - one byte for every 16K block E-RAM.
XRAM_C5 DS 1
XRAM_C6 DS 1
XRAM_C7 DS 1

XRAM_CC DS 1
XRAM_CD DS 1
XRAM_CE DS 1
XRAM_CF DS 1

XRAM_D4 DS 1
XRAM_D5 DS 1
XRAM_D6 DS 1
XRAM_D7 DS 1

XRAM_DC DS 1
XRAM_DD DS 1
XRAM_DE DS 1
XRAM_DF DS 1

XRAM_E4 DS 1
XRAM_E5 DS 1
XRAM_E6 DS 1
XRAM_E7 DS 1

XRAM_EC DS 1
XRAM_ED DS 1
XRAM_EE DS 1
XRAM_EF DS 1

XRAM_F4 DS 1
XRAM_F5 DS 1
XRAM_F6 DS 1
XRAM_F7 DS 1

XRAM_FC DS 1
XRAM_FD DS 1
XRAM_FE DS 1
XRAM_FF DS 1

             ;Machine MONitor variables
MON_ROM DS 1 ;&82 ==> lower ROM active /// &86 lower RAM active in machine mon.
MON_RAM DS 1 ;RAM &C0,&C4..&C7,&CC..&CF,,&F4..&F7,&FC..&FF used by machine mon.
MON_MMB DS 1 ;&A0 ==> memory mapped I/O inactive /// &B8 ==> mm I/O active """.

            ;variable key-wait time, see ROM-A documentation, routine XWART
VZ_MOD DS 1 ;delay mode = 0 => start-delay, else continuation-dalay
VZ_AG  DS 2 ;start-delay, general (reload value)
VZ_AA  DS 2 ;start-delay, residual delay-time
VZ_FG  DS 2 ;continuation-delay, general (reload value)
VZ_FA  DS 2 ;continuation-delay, residual delay-time

FDCLSA DS 1 ;actual try of read/write FDC 0/1 (variable)
FDCLSV DS 1 ;number of total read/write trys before error-message occurs

DEFINT DS 1 ;Bit 7 = 0 ==> Interrupts off, DI // = 1 ==> Interrupts active, EI

M4_ERAM DS 1 ;E-RAM of the DIRectory of the M4 SD card (&C4-&FF)

TAST_S DS 80 ;80 bytes for ASCII chars, key-matrix 10 * 8, SHIFT-level

;Step-rate-time of all drives - internal (FDC0) & external (FDC1) controller
;
;&A0 => 12 Milli-seconds Step-rate-time (most 3 inch drives, some are faster)
;&E0 =>  4 Milli-seconds Step-rate-time (most 3.5 / 5.25 inch drives)
;
;----------> A ! B ! C ! D ! E ! F ! G ! H <
DSWZ DS 8 ; &A0,&E0,&E0,&E0,&E0,&E0,&E0,&E0

OK_ADR DS 2 ;ADRess, which is called throug the OK icon, &????
OK_ATE DS 2 ;The sum of this value and (OK_ADR) must be &FFFF
OK_BLK DS 2 ;E-RAM used through the OK icon, &7F00 + &C0,&C4,&C5,..,&FF
OK_BTE DS 2 ;The sum of this value and (OK_BLK) must be &FFFF

DS 6 ;6128plus ... or ...

;KS0XL DS 1 ;Coordinates Sprite 0 for
;KS0XH DS 1 ;CPC6128
;KS0YL DS 1
;KS0YH DS 1
;P_POS DS 2 ;SSP(SoftSpritePosition) of CPC464-6128 / &C000..&FF7F

;Reads data of Dobbbertin RTC into RAM at UHR_00 / alternatively M4 RTC
;manipulated; AF, BC, DE, HL and 8 bytes RAM from UHR_00

LUHR LD BC,(UHR_ROM)

 OUT  (C),C
 LD   A,(&C004)
 LD   DE,&C000
 LD   HL,&C001
 CALL KOAS
 CALL KOAS
 LD   E,4
 JP   RDUK

TAST_C DS 80 ;80 bytes for ASCII chars of key-matrix 10 * 8  CONTROL-level

RDUK LD HL,UHR_00
     LD B,8
RDUL LD A,(DE)

 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  (HL),C
 INC HL

 DJNZ RDUL
 LD   BC,(AKT_ROM)
 OUT  (C),C
 RET

TAST_SC DS 80 ;80 bytes for ASCII chars of key-matrix 10 * 8  SHI/CONT-level

KOAS LD A,(HL)

 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 RET

CAPS DS 1 ;bit 7 Control / bit 6 Caps-Lock / bit 5 Shift (0 = OFF, 1 = ON)

I_ADR DS 2 ;ADRess called through the I icon &????
I_ATE DS 2 ;The sum of this value and (I_ADR) must be &FFFF
I_BLK DS 2 ;RAM which is activated when I icon is used, &7F00 + &C0,&C4,..,&FF
I_BTE DS 2 ;The sum of this value and (I_BLK) must be &FFFF

DRUMEM DS 1 ;printer-spooler, first E-RAM block &C4,..,&FF
DRUBAZ DS 1 ;number of direct following E-RAM blocks 0..31 for spooler

MMFMEM DS 1 ;first E-RAM block of RAM-drive, &C4,..,&FF
MMFBAZ DS 1 ;number of direct following E-RAM blocks 0..31 for RAM-drive M

HI_MEM DS 2 ;shows the upper free RAM byte, =< &9FFF - used sometimes -

AUH_00  DS 1 ;8 bytes, equivalent to UHR_00, but older, see there
AUH_SEK DS 1 ;this bytes contains the old
AUH_MIN DS 1 ;time bytes, before the last read
AUH_STU DS 1
AUH_WOT DS 1
AUH_TAG DS 1
AUH_MON DS 1
AUH_JAR DS 1

WECK_ST DS 1 ;=&00 ==> no alarm // &FF ==> alarm active
WECK_ZS DS 1 ;second of alarm-timer
WECK_ZM DS 1 ;minute
WECK_ZH DS 1 ;hour

BILD_SS DS 2 ;Start-adr screen-saver, if installed
BILD_RB DS 1 ;RAM-block screen-saver, if installed
BILD_ST DS 1 ;=&00 ==> no screen-saver // &FF ==> screen-saver loaded & active

L_RAM DS 1 ;number of E-RAM in which the LOW-RAM (&0000-&3FFF) is buffered
           ;= 0 => no buffer // = &C0, &C4-&FF (physical E-RAM) => L-RAM buffer

BORDER DS 1 ;hardware-color-values

INK_0 DS 1 ;hardware-color-value INK 0 (backgground)
INK_1 DS 1 ;hardware-color-value INK 1 (pen 1)
INK_2 DS 1 ;hardware-color-value INK 2 (pen 2)
INK_3 DS 1 ;hardware-color-value INK 3 (pen 3)

BSS_WW DS 2 ;screen-saver reload-time-waiting-value, constant
BSS_WA DS 2 ;actual screen-saver waiting value, decreasing

HGB_RB DS 1 ;RAM &C4..&FF, 16KB background-picture (Mode 2), if loaded, else 0
HGB_ST DS 1 ;status of background-pict, &00 => no picture, &FF => pic loaded

FDC_ERR DS 2 ;Adr. FDC765-error-handler
FDE_RAM DS 2 ;phys. error-handler-RAM, followed by &7F-&78.

X4RXE DS 1 ;Bit 7 = 0 no E-RAM through &7EFx usable
           ;      = 1 E-RAM through &7EFx usable
;---------/
;Bit 6 = 0 no E-RAM &7EEx
;      = 1 E-RAM &7EEx connected
;
;Bit 5 = 0 no E-RAM &7EDx
;      = 1 E-RAM &7EDx connected
;
;Bit 4 = 0 no E-RAM &7ECx
;      = 1 E-RAM &7ECx connected
;
;Bits 3, 2 are reserved
;
;Bit 1 = 0 -no- E-RAM at &7EC4-7 only (but look at bit 4!)
;      = 1 64KB E-RAM at &7EC4-7 usable
;
;Bit 0 = 0 no E-RAM above 512 KB
;      = 1 more than 512 KB E-RAM connected to CPC!

X4RDC DS 1 ;Bit 7 = 0 no E-RAM &7CFx
           ;      = 1 E-RAM &7CFx connected
;---------/
;Bit 6 = 0 no E-RAM &7CEx
;      = 1 E-RAM &7CEx connected
;
;Bit 5 = 0 no E-RAM &7CDx
;      = 1 E-RAM &7CDx connected
;
;Bit 4 = 0 no E-RAM &7CCx
;      = 1 E-RAM &7CCx connected
;
;Bit 3 = 0 no E-RAM &7DFx
;      = 1 E-RAM &7DFx connected
;
;Bit 2 = 0 no E-RAM &7DEx
;      = 1 E-RAM &7DEx connected
;
;Bit 1 = 0 no E-RAM &7DDx
;      = 1 E-RAM &7DDx connected
;
;Bit 0 = 0 no E-RAM &7DCx
;      = 1 E-RAM &7DCx connected

X4RBA DS 1 ;Bit 7 = 0 no E-RAM &7AFx
           ;      = 1 E-RAM &7AFx connected
;---------/
;Bit 6 = 0 no E-RAM &7AEx
;      = 1 E-RAM &7AEx connected
;
;Bit 5 = 0 no E-RAM &7ADx
;      = 1 E-RAM &7ADx connected
;
;Bit 4 = 0 no E-RAM &7ACx
;      = 1 E-RAM &7ACx connected
;
;Bit 3 = 0 no E-RAM &7BFx
;      = 1 E-RAM &7BFx connected
;
;Bit 2 = 0 no E-RAM &7BEx
;      = 1 E-RAM &7BEx connected
;
;Bit 1 = 0 no E-RAM &7BDx
;      = 1 E-RAM &7BDx connected
;
;Bit 0 = 0 no E-RAM &7BCx
;      = 1 E-RAM &7BCx connected

X4R98 DS 1 ;Bit 7 = 0 no E-RAM &78Fx
           ;      = 1 E-RAM &78Fx connected
;---------/
;Bit 6 = 0 no E-RAM &78Ex
;      = 1 E-RAM &78Ex connected
;
;Bit 5 = 0 no E-RAM &78Dx
;      = 1 E-RAM &78Dx connected
;
;Bit 4 = 0 no E-RAM &78Cx
;      = 1 E-RAM &78Cx connected
;
;Bit 3 = 0 no E-RAM &79Fx
;      = 1 E-RAM &79Fx connected
;
;Bit 2 = 0 no E-RAM &79Ex
;      = 1 E-RAM &79Ex connected
;
;Bit 1 = 0 no E-RAM &79Dx
;      = 1 E-RAM &79Dx connected
;
;Bit 0 = 0 no E-RAM &79Cx
;      = 1 E-RAM &79Cx connected

X4RAM DS 28 ;CPC has more than 512 KB E-RAM? Then it's managed that way...
            ;224 bits for 16 KB RAM each, = 0 RAM not used, = 1 RAM used
;-----------/
;1.Byte, 1. Bit -> Block &7EC4
;1.Byte, 2. Bit -> Block &7EC5
;1.Byte, 3. Bit -> Block &7EC6
;1.Byte, 4. Bit -> Block &7EC7
;
;...
;
;28.Byte, 6. Bit -> Block &78FD
;28.Byte, 7. Bit -> Block &78FE
;28.Byte, 8. Bit -> Block &78FF

JT_JH DS 1 ;actual century in BCD e.g. &20 means year 20?? (&21 => 21??)
F2AMS DS 1 ;= &FF -> RET to AmsDOS, else RESET at END

HEGP2 DS 1 ;Bit 0 = 0 no Hegotron Grafpad 2 connected
           ;      = 1 Hegotron Grafpad 2 IS connected
           ;
           ;Bit 1 = 0 Grafpad is INaktive
           ;      = 1 Grafpad is AKTIVE


IDE_XR DS 1 ;ROM number of IDE or M4 XROM (&01-&FF) or &00 (no XROM)


IDE DS 1 ; = &00 --> No IDE device connected
         ;
;--------/
;Bit 7 = 0 --> IDE8255 selected
;      = 1 --> CPC-IDE selected
;
;Bit 6 = 0 --> no IDE8255
;      = 1 --> IDE8255 connected
;
;Bit 5 = 0 --> no CPC-IDE
;      = 1 --> CPC-IDE connected
;
;Bit 4 = 0 --> &00 --> IDE device 0 selected (look at Bit 7)
;      = 1 --> &10 --> IDE device 1 selected (look at Bit 7)
;
;
;Bit 3 = 0 --> CPC-IDE device 0 works with LBA 28
;      = 1 --> CPC-IDE device 0 works with LBA 48
;
;Bit 2 = 0 --> CPC-IDE dev.1 uses LBA28
;      = 1 --> CPC-IDE dev.1 uses LBA48
;
;Bit 1 = 0 --> IDE8255 dev.0 uses LBA28
;      = 1 --> IDE8255 dev.0 uses LBA48
;
;Bit 0 = 0 --> IDE8255 dev.1 uses LBA28
;      = 1 --> IDE8255 dev.1 uses LBA48

IDE_DEV DS 1 ; = &00 --> No IDE device connected
             ;
;------------/
;Bit 7 = 0 --> 
;      = 1 --> 
;
;Bit 6 = 0 --> 
;      = 1 --> 
;
;Bit 5 = 0 --> 
;      = 1 --> 
;
;Bit 4 = 0 --> 
;      = 1 --> 
;
;
;Bit 3 = 0 --> CPC-IDE device 0 missing (Master)
;      = 1 --> CPC-IDE device 0 ready to use
;
;Bit 2 = 0 --> CPC-IDE dev.1 missing (Slave)
;      = 1 --> CPC-IDE dev.1 ready to use
;
;Bit 1 = 0 --> IDE8255 dev.0 missing
;      = 1 --> IDE8255 dev.0 ready to use
;
;Bit 0 = 0 --> IDE8255 dev.1 missing
;      = 1 --> IDE8255 dev.1 ready to use

IDE_RAM DS 1 ;16 KB RAM used as hard disc cache (&C4..&FF)

IDE_SECNT DS 1 ;Sector Count (### NOT USED)

IDE_00_07 DS 1 ;4 or 6 bytes pointing to actual 512 byte LBA28 or LBA48 sector
IDE_08_15 DS 1
IDE_16_23 DS 1 ;LBA28 uses IDE_00_07 to IDE_24_31 (4 bytes)
IDE_24_31 DS 1

IDE_32_39 DS 1 ;LBA48 uses IDE_00_07 to IDE_40_47 (6 bytes)
IDE_40_47 DS 1

;Write Dobbertin Smartwatch data from RAM to clock / alternatively M4 RTC
;
;DE = 8 bytes which contain time and date, Dobbertin compatible
;manipulated; AF, BC, E, HL, BC', DE', HL' and ROM-select
;ROM from (AKT_ROM) will be switched on

SUHR EXX

 LD BC,(UHR_ROM):OUT (C),C
 LD A,(&C004)
 LD DE,&C000
 LD HL,&C001
 CALL KOAS
 CALL KOAS
 EXX
 LD BC,&0800
 LD H,&C0

SUGL LD A,(DE):SCF
SUNB RR A:JR Z,SUZZ

 LD L,C
 RL L
 LD L,(HL)
 JR SUNB

SUZZ INC E

 DJNZ SUGL
 LD BC,(AKT_ROM):OUT (C),C
 RET


ZZEND DS 0 ;variable must be &BC00 !!! (test it)


LIST
DUMP
