Sord M5 Documentation

Obsah
=====

Introduction .....................................................   2
Additional memory ................................................   2
When the M5 is booting  ..........................................   3
Activities triggered by a CTC #3 - system form ...................   5
ROM and RAM configuration ........................................   7
VDP memory configurations ........................................  10
Color table ......................................................  14
Keyboard table ...................................................  14
Connecting I/O devices ...........................................  15
First half ASCII table ...........................................  15
National alphabet extension ......................................  16
List of CTRL + key actions .......................................  16
System connector pinout (cartridge slot) .........................  17
Printer connector pinout .........................................  18
Joystick pinout ..................................................  18
Read from keyboard and joystick ..................................  18
Universal port 50H ...............................................  18
Tape format ......................................................  19
MONITOR ROM error codes ..........................................  20
Brief description of selected parts from Z80 programming .........  21
Programming of circuit VDP TMS9929A - videoprocessor .............  23
Programming of circuit SN76489AN - sound generator ...............  24
Programming of circuit Z80 CTC - Counter/Timer ...................  25
Programming of I8255 - Programmable Peripheral Interface .........  26
Define new devices in Basic-F ....................................  27
Numbers and adresses of commands and functions of Basic-F
 and Basic-D language ............................................  29
Separators and other delimiter words of Basic-F and Basic-D ......  32
BASIC-F variables format .........................................  33
Numbers and adresses of Basic-G and Basic-I commands
 and functions ...................................................  34
Options For M5 ...................................................  35


HEAP                                - 2 -

Introduction
************

This guide contains information that you need to know when working with a computer
SORD M5. Here are some information about the system (memory arrangement, run
system, errors, etc.), various tables, information on data recording on tape recorder
and the Z80 microprocessor.


Additional memory
*****************

The 64KBF cartridge is the 64K RAM memory type contains against popular "EM64" also BASIC-F. 
Great advantage of this module is the ability to work in eight different modes, while 64KBI
only offer 32/48/56 or 64KB RAM + enable / disable writing to lower part 28 kB RAM, where only 48/56 kB 
RAM mode can be controlled via software. In Module 64KBF is write separated from the read, write goes everytime to RAM. 
Practically it means you can write directly to RAM on adress which is covered by the ROM's active memory, 
instead of 64KBI cartridge, where it is necessary first to disconnect the ROM and then is possible 
writing to RAM on the same adresses.

The 64KRD and 64KRX memory is a expansion board with 512KB RAM DISK, 56 or 88 KB ROM DISK and 64KB RAM. 
KRD and KRX are different from each other only by occupying ROM DISK.


64KB RAM Memory Driver
===================================

EM-64, 64KBI:   OUT 6CH, 00H - mount ROM
        OUT 6CH, 01H - connect RAM
64KBF:      OUT 30H, 00000xxxB - Connect RAM or ROM, see figure
64KRD, 64KRX:   OUT 7FH, 00000000B - Connect RAM
        OUT 7FH, 11111111B - Connect ROM
        OUT 7FH, xxxxxxxxB - connect both RAM and ROM, see figure


HEAP                                - 3 -

When the M5 is booting
**********************

After turning on or restarting the computer, program stored on 0000H is executed, this is so-called ROM MONITOR. 
This program is basic computer program equipment. It is 8kB long and can not be run without modification
in RAM memory, which is allowed to write. It is due to the fact that MONITOR ROM performing RAM test routine, 
which causes a collision that is resolved by jumping to an emergency.
This problem can be resolved by modifying the RAM test routines (CHKRAM) at & 008E.

Flowchart:
=================
          +--------------------------------------+
          |                RST0                  |
          +--------------------------------------+
          |                 DI                   |
          |                 IM  2                |
          |             SP <- SYSTAK             |
          +--------------------------------------+
                             |
          +--------------------------------------+
          |                M5BOT                 |
          +--------------------------------------+
          |                 I <- 70H             |
          |       initialization of system       |
          |            variables, CTC            |
          |                  EI                  |
          |    initialization SGC, SML, VDP,     |
          |              display                 |
          +--------------------------------------+
          |     test MONITOR ROM to sum 0        |
          +--------------------------------------+
                             |
                             |
                            / \
                           /   \  -                 ***********
                          < OK? >-------------------*  Error  *
                           \   /                    ***********
                            \ /
                          +  |
                             |
          +----------------------------------------+
          | Test RAM, finding Begin and End of RAM |
          +----------------------------------------+
                             |
                             |
                            / \
                           /   \  -                 ***********
                          < OK? >-------------------*  Error  *
                           \   /                    ***********
                            \ /
                          +  |
                             |
                (1)


HEAP                                - 4 -

                (1)
                 |
       +--------------------------------------------------+
       | search for cartridge, read address IPL and start |
       +--------------------------------------------------+
                             |
                             |
                            / \   Is cartridge inserted?
                        -  /   \  +
       +------------------<  ?  >----------------------------+
       |                   \   /                             |
       |                    \ /                      +---------------+
       |                     V                       |  jump to IPL  |
       |                                             +---------------+
       |                                                     |
       |                                             ********************
       |                                             *  cartridge start *
       |                                             ********************
       |
       |            Cartridge header format
       |            -----------------------
       |
 +-----------+          +0000 +--------------------------------------+
 |  RBTCMT   |                |            identificator             |
 +-----------+          +0001 +--------------------------------------+
 | read HD   |                |            start address             |
 | from CMT  |<--------+    +0003 +--------------------------------------+
 +-----------+         |          |          IPL start address           |
      |                |    +0005 +--------------------------------------+
      |   is .VM       |          |     instruction for execute RST4     |
     / \  or .DT       |    +0008 +--------------------------------------+
    /   \  +           |          |     instruction for execute RST5     |
   <  ?  >------------>|    +000B +--------------------------------------+
    \   /              |          |      program in the cartridge        |
     \ /               |          /                                      /
      | -              |          \                                      \
      |                |          /                                      /
+-----------+          |          |                                      |
|read body  |          |    +xFFF +--------------------------------------+
+-----------+          |
      |                |    Cartridge identificator
      |                |    -----------------------
     / \  is autostart |    00 =  8 KB from 2000H
    /   \  -           |    01 =  8 KB from 4000H
   <  ?  >-------------+    02 = 16 KB from 2000H
    \   /
     \ /
      | +
      |
*************
*  jump to  *
*  record   *
*************


HEAP                                - 5 -

Activities triggered by a CTC #3
********************************

 +--------------------------------------+
 |                CTC3SP                |
 +--------------------------------------+
 |          store AF, BC, DE, HL        |
 |              false RETI              |
 |           store VDP STATUS           |
 |              test INT                |
 +--------------------------------------+
                    |
                    |
                   / \  is INT enabled ?  
               -  /   \
 +---------------<  ?  >
 |                \   /
 |                 \ /
 |                  | +
 |                  |
 |                  |
 |                 / \  sprites
 |                /   \  +                   +--------+
 |               < ON? >-------------------->| SPRPRC |--+
 |                \   /                      +--------+  |
 |                 \ /                                   |
 |                  | -                                  |
 |                  +---------------->+<-----------------+
 |                                    |
 |                                    |
 |                                   / \
 |                   +--------+  +  /   \
 |                   | hours  |<---< ON? >
 |                   +--------+     \   /
 |                       |           \ /
 |            new day   / \           | -
 |   +--------+     +  /   \          |
 |   | EVHPRC |<------<  ?  >         |
 |   +--------+        \   /          |
 |       |              \ /           |
 |       |               | -          |
 |       +-------------->|            |
 |                       |            |
 |               alarm  / \           |
 |   +--------+     +  /   \          |
 |   | ALMPRC |<------<  ?  >         |
 |   +--------+        \   /          |
 |       |              \ /           |
 |       |               | -          |
 |       |               V            |
 |       +--------------------------->|
 |                                    |
 |                             UPCNT / \
 |                +---------+    +  /   \
 |                | UPCNTSP |------< ON? >
 |                +---------+       \   /
 |                     |             \ /
 |                     |              | -
 |                     +------------->|
 |                                    |
(3)                                  (4)


HEAP                                - 6 -

(3)                                  (4)
 |                                    |
 |                             DWCNT / \
 |                +---------+    +  /   \
 |                | DWCNTSP |------< ON? >
 |                +---------+       \   /
 |                     |             \ /
 |                     |              | -
 |                     +------------->|
 |                                    |
 |                                    |            ^
 |                             RESET / \     HALT / \
 |                                  /   \  +     /   \  +    +--------+
 |                                 < ON? >------<  ?  >----->| HLTPRC |---+
 |                                  \   /        \   /       +--------+   |
 |                                   \ /          \ /                     |
 |                                    | -          | -                    |
 |                                    |            |                      |
 |                                    |     RESET / \                     |
 |                                    |          /   \  +    +--------+   |
 |                                    |         <  ?  >------| RSTPRC |-->|
 |                                    |          \   /       +--------+   |
 |                                    |           \ /                     |
 |                                    |            | -                    |
 |                                    |<-----------+<---------------------+
 |                                    |
 |                               JOY / \
 |                +---------+    +  /   \
 |                |  JOYSP  |------< ON? >
 |                +---------+       \   /
 |                     |             \ /
 |                     |              | -
 |                     +------------->|
 |                                    |
 |                               KEY / \
 |                +---------+    +  /   \
 |                |  KEYSP  |------< ON? >
 |                +---------+       \   /
 |                     |             \ /
 |                     |              | -
 |                     +------------->|
 |                                    |
 |                user events        / \
 |                +---------+    +  /   \
 |                |  UEVSP  |------< ON? >
 |                +---------+       \   /
 |                     |             \ /
 |                     |              | -
 |                     +------------->|
 |                                    |
 |                          +-------------------+
 |                          | enable interrupt  |
 |                          |    from CTC 3     |
 |                          +-------------------+
 |                                    |
 ------------------------------------>|
                                      |
                           +----------------------+
                           | restore HL,DE,BC,AF  |
                           | and return to normal |
                           |      execution       |
                           +----------------------+


HEAP                                - 7 -

ROM and RAM configuration
*************************

Standard ROM and RAM configuration 
===================================

Address      Description        KB

FFFF +----------------------------+ 64 \
     |                | 62  |
F000 |                | 60  |
     |                | 58  |
E000 |                | 56  |
     |                | 54  |
D000 |                | 52  |
     |                | 50  |
C000 |        DRAM in EM-5        | 48   > 32kB
     |                | 46  |
B000 |                | 44  |
     |                | 42  |
A000 |                | 40  |
     |                | 38  |
9000 |                | 36  |   +-----------------------------+
     |                | 34  |   | RAM in BG and BF cartridges |
8000 |----------------------------| 32 <        +-----------------------------+
     |     4kB internal RAM       | 30  >  4kB
7000 |----------------------------| 28  <   <--- 6FFF for Basic-F
     |                | 26  |
6000 |                | 24  |   <--- 5FFF for Basic-G
     |                | 22  |
5000 |      BASIC language ROM    | 20  |
     |                | 18   > 20kB
4000 |        in cartridges       | 16  |   <--- 3FFF for Basic-I
     |                | 14  |
3000 |                | 12  |
     |                | 10  |
2000 |----------------------------|  8 <
     |                |  6  |
1000 |   Monitor ROM in SORD M5   |  4   >  8kB
     |                |  2  |
0000 +----------------------------+  0 /


HEAP                                - 8 -

ROM and RAM configuration for SORD M5 + 64 KBF cartridge
========================================================

Address     Description     KB        Description

FFFF +----------------------------+ 64
     |                | 62
F000 |                | 60
     |                | 58
E000 |                | 56
     |                | 54
D000 |                | 52
     |                | 50
C000 |      32KB RAM      | 48
     |                | 46
B000 |                | 44
     |                | 42
A000 |                | 40
     |                | 38
9000 |                | 36
     |                | 34
8000 |----------------------------| 32 +----------------------------+
     |     4KB internal RAM       | 30 |                |
7000 |----------------------------| 28 |                |
     |                | 26 |                |
6000 |                | 24 |                |
     |                | 22 |                |
5000 |                | 20 |                |
     |     ROM Basic-F        | 18 |                |
4000 |                | 16 |      32KB RAM      |
     |                | 14 |                |
3000 |                | 12 |                |
     |                | 10 |                |
2000 |----------------------------|  8 |                |
     |                |  6 |                |
1000 |   Monitor ROM in SORD M5   |  4 |                |
     |                |  2 |                |
0000 +----------------------------+  0 +----------------------------+


Memory configurations (modes) for SORD M5 with 64KBF cartridge
--------------------------------------------------------------
Switching between memory modes is done by "OUT &30,mode" instruction.

MODE    READ                    WRITE
----------------------------------------------------------------------
 00 8 KB MON + 20 KB BF + 36 KB RAM     28 KB DIS + 36 KB RAM
 01 64 KB RAM               64 KB RAM
 02 8 KB MON + 56 KB RAM            64 KB RAM
 03 64 KB RAM               28 KB DIS + 36 KB RAM
 04 64 KB RAM               16 KB DIS + 48 KB RAM
 05 8 KB MON + 20 KB BF + 36 KB RAM     64 KB RAM
 06 8 KB MON + 20 KB DIS + 36 KB RAM    64 KB RAM
 07 64 KB DIS               64 KB DIS


HEAP                                - 9 -

Memory configurations (modes) for SORD M5 with 64KRX board
==========================================================

        on KRX    in computer   in computer    on KRX       on KRX
FFFF +----------+ +----------+ +----------+ +----------+ +----------+
     |          |                           |          | |          |
     |          |                           | EPROM 16K| | EPROM 16K|
     |          |                           |        5 | |        7 |
C000 |   DRAM   |                           +----------+ +----------+
     |          |                           |          | |          |
     |          |                           | EPROM 16K| | EPROM 16K|
     |          |                           |        4 | |        6 |
7FFF +----------+ +----------+              +----------+ +----------+
                  |   SRAM   |             
7000 +----------+ +----------+             
     |          |             
6000 |          |                           +----------+
     |          |                           |          |
5000 |          |                           | EPROM 8K |
     |          |                           |        3 |
4000 |          |              +----------+ +----------+
     |          |              |          |
3000 |   DRAM   |              | EPROM 8K |
     |          |              |        2 |
2000 |          |              +----------+
     |          |              |          |
1000 |          |              | EPROM 8K |
     |          |              |        1 |
0000 +----------+ +----------+ +----------+ +----------+ +----------+

1 - MONITOR ROM
2 - WINDOWS + BASIC-F 3th. part
3 - BASIC-I
4 - 2. part BASIC-F + 1st. part BASIC-F
5 - 1. part BASIC-G + 2nd. part BASIC-G
6 - 1. part MSX 1.C
7 - 2. part MSX 1.C

Note: on position 3 may be also static RAM 8KB with battery backup!

After switch on, SRAM + 1,2,3,4,5 or SRAM + 1,2,3,6,7 is connected.
Switching between 4,5 and 6,7 is provided by mechanical switch, switching ROM/RAM 
is provided by instruction OUT (7FH),A, where in A every bit describes 8KB of memory
(status: 0=RAM, 1=ROM, bit: 0=1, 1=2, 2=3, 3=always SRAM, 4=4, 5=5, 6=6, 7=7 ).

For BASIC languages:

0000           2000        7000       FFFF
+-------------------------------------+
| ROM or RAM   |          RAM         |
|   MONITOR    |  BASIC-x  |  free    |
+-------------------------------------+

For MSX 1.C:

0000      8000      FFFF
+-------------------+
|        RAM        |
| MSX 1.C |  free   |
+-------------------+

MONITOR ROM uses RAM 7000H-72FFH for system variables. This RAM
must be available after switch on. Basic languages use RAM area up to 7383H (BI),
745AH (BG) a 77F2H (BF). System MSX set 3 bytes from 8000 to zero and area from F0A0h-F37FH
and F380H-FFFFH use for own system buffers and variables.


HEAP                                - 10 -

VDP memory configurations
*************************

VRAM configuration in TEXT mode
===============================

Configuration is valid for configuration with both screens in TEXT mode. 
If one is in GI mode, see chapter 3.2.

Address      Description        KB

0000 +----------------------------+  0 \
     |                | |
     |                | |
     \                \ |
     /                / |
     \      Free memory 10KB      \  > 10240 bytes
     /                / |
     \                \ |
     |                | |
     |                | |
2800 |----------------------------| 10 <
     |                | |
     |                | |
     |   Character shapes (font)  | |
2C00 |      for screen 0      | 11   > 2048 bytes
     |                | |
     |                | |
     |                | |
3000 |----------------------------| 12 <
     |                | |
     |                | |
     |   Character shapes (font)  | |
3400 |       for screen 1     | 13   > 2048 bytes
     |                | |
     |                | |
     |                | |
3800 |----------------------------| 14 <
     |       screen 0 content     | |
     |   (character ASCII codes)  |  >  960 bytes
3BC0 |----------------------------| |
     |    Free memory 64 bytes    |  >   64 bytes
3C00 |----------------------------| 15 <
     |     screen 1 content   | |
     |   (character ASCII codes)  |  >  960 bytes
3FC0 |----------------------------| |
     |    Free memory 64 bytes    |  >   64 bytes
3FFF +----------------------------+ 16 /


HEAP                                - 11 -

VRAM configuration in GI mode
=============================
Configuration is valid for configuration with both screens in GI mode. 
If is one screen in TEXT mode, for this screen content area is TEXT mode configuration valid.


Address      description        KB

0000 +----------------------------+  0 \
     |                | |
     |                | |
     \                \ |
     /                / |
     \      Free memory 8KB   \  > 8192 bytu
     /                / |
     \                \ |
     |                | |
     |                | |
2000 |----------------------------|  8 <
     |                | |
     |                | |
     |     Sprite shapes for      | |
2400 |      screen 0 and 1    |  9   > 2048 bytu
     |                | |
     |                | |
     |                | |
2800 |----------------------------| 10 <
     |                | |
     |                | |
     |   Character shapes (font)  | |
2C00 |        for screen 0    | 11   > 2048 bytu
     |                | |
     |                | |
     |                | |
3000 |----------------------------| 12 <
     |                | |
     |                | |
     |   Character shapes (font)  | |
3400 |       for screen 1     | 13   > 2048 bytu
     |                | |
     |                | |
     |                | |
3800 |----------------------------| 14 /
     \                \
     /  see VRAM config in GI     /
     \      from &3800            \
     /                /
3FFF |----------------------------| 16


VRAM configuration in GII mode
==============================

Configuration is valid for configuration if one from screens is in GII mode. 
For second screen is valid that, what is for the mode in which it is.


Adresa       Obsah          KB

0000 +----------------------------+  0 \
     |     Character colors in    | |
0400 |  upper part of the screen  |  1   > 2048 bytes
     |                | |
0800 |............................|  2 <
     |     Character colors in    | |
0C00 | middle part of the screen  |  3   > 2048 bytes
     |                | |
1000 |............................|  4 <
     |     Character colors in    | |
1400 |  lower part of the screen  |  5   > 2048 bytes
     |                | |
1800 |----------------------------|  6 <
     |                | |
1C00 |       see note         |  7   > 2048 bytes
     |                | |
2000 |----------------------------|  8 <
     |      Character shapes      | |
2400 |  upper part of the screen  |  9   > 2048 bytes
     |                | |
2800 |............................| 10 <
     |      Character shapes      | |
2C00 | middle part of the screen  | 11   > 2048 bytes
     |                | |
3000 |............................| 12 <
     |      Character shapes      | |
3400 |  lower part of the screen  | 13   > 2048 bytes
     |                | |
3800 |----------------------------| 14 /
     \                \
     /  see VRAM config in GI     /
     \      from address &3800    \
     /                /
3FFF |----------------------------| 16


Note:
---------
&1800 to &1FFF:
Sprite shapes for screen 0 and 1 and also character shapes table for the opposite screen.
( ie. screen without GII mode). If program prints text into GII screen, character shapes are from this table.


HEAP                                - 13 -

VRAM configuration from address &3800 in GI mode
================================================ 

Memory configuration is valid if both screens are in GI mode. If one of them
is in TEXT mode, configuration is valid for area from &3800 to &3BFF ( screen 0 ),
or &3C00 to &3FFF ( screen 1 ) configuration for TEXT mode. If one of screens is in GII mode, 
only 768 + 128 bytes is used and rest is free.

Address      Description        KB

3800 |----------------------------| 14 \
     |                | |
3880 |                | |
     |                | |
3900 |                | |
     |     screen 0 content   | |
3980 |   (character ASCII codes)  |  >  768 bytes
     |                | |
3A00 |                | |
     |                | |
3A80 |                | |
     |                | |
3B00 |----------------------------|    <
     |  Sprite table - screen 0   |  >  128 bytes
3B80 |----------------------------|    <
     |  Color table for screen 0  |  >   32 bytes
3BA0 |----------------------------|    <
     |    free memory 96 bytes    |  >   96 bytes
3C00 |----------------------------| 15 <
     |                | |
3C80 |                | |
     |                | |
3D00 |                | |
     |     screen 1 content   | |
3D80 |   (character ASCII codes)  |  >  768 bytes
     |                | |
3E00 |                | |
     |                | |
3E80 |                | |
     |                | |
3F00 |----------------------------|    <
     |   Sprite table - screen 1  |  >  128 bytes
3F80 |----------------------------|    <
     |  Color table for screen 1  |  >   32 bytes
3FA0 |----------------------------|    <
     |    Free memory 96 bytes    |  >   96 bytes
3FFF |----------------------------| 16 /


HEAP                                - 14 -

Color table
***********

00 - 0 - no color ( transparent )
01 - 1 - black
02 - 2 - green
03 - 3 - light green
04 - 4 - deep blue
05 - 5 - light blue
06 - 6 - deep red
07 - 7 - cyan
08 - 8 - red
09 - 9 - light red
10 - A - deep yellow
11 - B - light yellow
12 - C - deep green
13 - D - purple
14 - E - gray
15 - F - white

Keyboard table
**************

Command PRINT PEEK(&702A) returns values modifiing keys ( 01 to 08 )
and PRINT PEEK(&702B) returns values character keys ( 09 to 56 ).

   ,----.----.----.----.----.----.----.----.----.----.----.----.----.-----.
   | 1  | 2  | 3  | 4  | 5  | 6  | 7  | 8  | 9  | 0  | -  | ^  | \  |     |
   | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 41 | 42 | 43 | 44 | 48 |RESET|
   `----'----'----'----'----'----'----'----'----'----'----'----'----'-----'
,----.----.----.----.----.----.----.----.----.----.----.----.----.--------.
|FUNC| Q  | W  | E  | R  | T  | Y  | U  | I  | O  | P  | @  | [  | RETURN |
| 02 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 49 | 50 | 51 | 52 |   08   |
`----'----'----'----'----'----'----'----'----'----'----'----'----'--------'
 ,----.----.----.----.----.----.----.----.----.----.----.----.----.-------.
 |CTRL| A  | S  | D  | F  | G  | H  | J  | K  | L  | ;  | :  | ]  | SPACE |
 | 01 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 53 | 54 | 55 | 56 |   07  |
 `----'----'----'----'----'----'----'----'----'----'----'----'----'-------'
  ,--------.----.----.----.----.----.----.----.----.----.----.----.-------.
  | SHIFT  | Z  | X  | C  | V  | B  | N  | M  | +  | .  | /  | _  | SHIFT |
  |   04   | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 |   08  |
  `-------'----'----'----'----'----'----'----'----'----'----'----- -------


HEAP                                - 15 -

Connecting I/O devices
**********************

port        device

00 to 03    CTC #0 to #3
10 and 11   VDP
20      SGC
30 to 37    keyboard and joystick
40 and 50   centronics for PRT and universal port ( tape, relay, <RESET> )
60 to 63    reserved for SIO
70 to 73    reserved for PIO
80 to FF    free, unused in original SORD M5

Ports &60 a &70 may be used for ROM/RAM switching and for RAM DISK.
Specific use may vary according to the hardware design, (they are not the factory products, 
they are the SORD fan designs).


First half ASCII table
**********************

00 00   - znak null 43 2B + - plus       86 56 V
01 01 A - inverse A 44 2C , - comma      87 57 W
02 02 B - inverse B 45 2D - - minus      88 58 X
03 03 C - inverse C 46 2E . - dot        89 59 Y
04 04 D - inverse D 47 2F / - slash      90 5A Z
05 05 E - inverse E 48 30 0          91 5B [ - left square bracket
06 06 F - inverse F 49 31 1          92 5C \ - backslash
07 07 G - inverse G 50 32 2          93 5D ] - right square bracket
08 08 H - inverse H 51 33 3          94 5E ^ - power
09 09 I - inverse I 52 34 4          95 5F _ - underline
10 0A J - inverse J 53 35 5          96 60 ` - reversed apostrophe
11 0B K - inverse K 54 36 6          97 61 a
12 0C L - inverse L 55 37 7          98 62 b
13 0D M - inverse M 56 38 8          99 63 c
14 0E N - inverse N 57 39 9         100 64 d
15 0F O - inverse O 58 3A : - colon     101 65 e
16 10 P - inverse P 59 3B ; - semicolon 102 66 f
17 11 Q - inverse Q 60 3C < - less than 103 67 g
18 12 R - inverse R 61 3D = - equal     104 68 h
19 13 S - inverse S 62 3E > - greater than  105 69 i
20 14 T - inverse T 63 3F ? - question  106 6A j
21 15 U - inverse U 64 40 @ - at        107 6B k
22 16 V - inverse V 65 41 A         108 6C l
23 17 W - inverse W 66 42 B         109 6D m
24 18 X - inverse X 67 43 C         110 6E n
25 19 Y - inverse Y 68 44 D         111 6F o
26 1A Z - inverse Z 69 45 E         112 70 p
27 1B   - cursor    70 46 F         113 71 q
28 1C   - right arrow   71 47 G         114 72 r
29 1D   - left arrow    72 48 H         115 73 s
30 1E   - up arrrow 73 49 I         116 74 t
31 1F   - down arrow    74 4A J         117 75 u
32 20   - space     75 4B K         118 76 v
33 21 ! - exclamation   76 4C L         119 77 w
34 22 " - quotation 77 4D M         120 78 x
35 23 # - maltese cross 78 4E N         121 79 y
36 24 $ - string,dollar 79 4F O         122 7A z
37 25 % - percentage    80 50 P         123 7B { - left folded parenthesis
38 26 & - and       81 51 Q         124 7C | - wide colon
39 27 ' - apostrophe    82 52 R         125 7D } - right folded parenthesis
40 28 ( - left bracket  83 53 S         126 7E ~ - tilde
41 29 ) - right bracket 84 54 T         127 7F   - triangle
42 2A * - asterisk  85 55 U         128 80   - filled square 8*8


HEAP                                - 16 -

National alphabet extension
***************************

At ASCII codes A0h to DFh in M5 are characters of national alphabet (full CS alphabet
is not available). For local needs so called LZR standard was created for characters with diacritics marks
and some math symbols.

A0: sum             B0: umlauts O   C0: space           D0: umlauts o
A1: long A          B1: O w. circumflex C1: long a          D1: o with circumflex
A2: umlauts A       B2: R with a hook   C2: umlauts a       D2: r with a hook
A3: C with a hook   B3: S with a hook   C3: c with a hook   D3: s with a hook
A4: D with a hook   B4: T with a hook   C4: d with a hook   D4: t with a hook
A5: long E          B5: long U          C5: long e          D5: long u
A6: E with a hook   B6: U with a ring   C6: e with a hook   D6: u with a ring
A7: umlauts E       B7: umlauts U   C7: umlauts e       D7: umlauts u
A8: hook            B8: long R          C8: tilde       D8: long r
A9: long I          B9: long Y          C9: long i          D9: long y
AA: comma           BA: Z with a hook   CA: umlaut      DA: z with a hook
AB: ring            BB: <=              CB: circumflex      DB: alpha
AC: L with a hook   BC: degrees         CC: l with a hook   DC: beta
AD: approx      BD: =>              CD: square root     DD: pound
AE: N with a hook   BE: not equal       CE: n with a hook   DE: pi
AF: long O          BF: plusminus       CF: long o          DF: fi (diameter)


List of CTRL + key actions
**************************

code    char    routine action

00      DSPCH3  do nothing
01  A   DSPCH3  do nothing
02  B   STCSD   cursor to beginning of line
03  C   SCRDW   roll down
04  D   SCRLF   roll left
05  E   SCRUP   roll up
06  F   SCRRG   roll right
07  G   BEL bell
08  H   DELTC   delete character
09  I   TABLT   tabulator
0A  J   LFEED   next row
0B  K   HOHEP   cursor home
0C  L   CLRSC   clear screen ( not from keyboard )
0D  M   CRETL   cursor to beginning of line and LF
0E  N   SNTCSD  cursor to beginning of next line
0F  O   STOVRM  overwrite mode
10  P   STINSM  insert mode
11  Q   MMODE   MCOLOR
12  R   GMODE   GII
13  S   CMODE   GI
14  T   TMODE   TEXT
15  U   NRMSC   return to screen page 0
16  V   REVSC   swap screens
17  W   CRETL   equal to CTRL M
18  X   CANCL   delete to end of the row
19  Y   RVDSPP  view to opposite screen
1A  Z   RVWRTP  cursor to opposite screen
1B  [   DSPCH3  ESC - do nothing
1C  ;   RGTAW   cursor right
1D  :   LFTAW   cursor left
1E  @   UPRAW   cursor up
1F  _   LWRAW   cursor down


HEAP                                - 17 -

CTRL codes on SMEP computers
****************************

code    character meaning

00  NUL empty character
01  SOH start of header
02  STX start of text
03  ETX end of text
04  EOT end of transmission
05  ENQ question
06  ACK acknowledgment
07  BEL bell
08  BS  back space
09  HT  horizontal tab
0A  LF  line feed
0B  VT  vertical tab
0C  FF  form feed
0D  CR  carriage return
0E  SO  rusky registr
0F  SI  latinsky registr
10  DLE autoregistr
11  DC1 ridici znak 1
12  DC2 ridici znak 2
13  DC3 ridici znak 3
14  DC4 ridici znak 4
15  NAK neuspesne potvrzeni
16  SYN synchronizace
17  ETB konec bloku
18  CAN zruseni
19  EM  konec media
1A  SUB substituce
1B  ESC autoregistr 2
1C  FS  oddelovac souboru
1D  GS  oddelovac skupin
1E  RS  oddelovac zaznamu
1F  US  oddelovac prvku
20  SP  space


System connector pinout (cartridge slot)
****************************************

 28 27 26 25 24         05 04 03 02 01
,--+--+--+--+--+- ... -+--+--+--+--+--.
|  |  |  |  |  |       |  |  |  |  |  | B      view from above
+--+--+--+--+--+- ... -+--+--+--+--+--+
|  |  |  |  |  |       |  |  |  |  |  | A
`--+--+--+--+--+- ... -+--+--+--+--+--'

    A      B         A      B         A      B         A      B     
01:-12V   -12V   10:  D1     D6   19:  A0    A15   28: RST    CLK
02:+12V   +12V   11:  D0     D7   20: WAIT   MRQ
03:+12V   +12V   12:  A7     A8   21:ROMDS   RFSH
04: +5V    +5V   13:  A6     A9   22: ROM0   ROM1
05: +5V    +5V   14:  A5    A10   23: ROM2   EXM
06: GND    GND   15:  A4    A11   24: MRD    MWR
07: GND    GND   16:  A3    A12   25: IORD   IOWR
08:  D3     D4   17:  A2    A13   26:EXIOA  EXIOB
09:  D2     D5   18:  A1    A14   27:EXINT  EXCLK


HEAP                                - 18 -

Printer connector pinout
************************

  15  13  11  9   7   5   3   1
,---+---+---+---+---+---+---+---.
| NC|GND| NC| D6| D4| D2| D0|STB|
+---+---+---+---+---+---+---+---+   view from back
| NC|GND|BUS| D7| D5| D3| D1|GND|
`---+---+---+---+---+---+---+---'
  16  14  12  10  8   6   4   2  


Joystick pinout
***************
                                 connector 
,---------------------------------------------*------O 2  (+)   1  o  o  6
|   ,-----------------------------------------|------O 3        4 o    o 5
|   |    ,------------------------------------|------O 4        3  o/\o  2
|   |    |    ,--------------------------*----|------O 5        in computer
|   |    |    |                          |    |
up left down right <- directional keys  ATA  ATB <- attack buttons
|   |    |    |                          |    |  <- here are diodes connected
`---*----*----*--------------------------|----|------O 6
                                         `----*------O 1  (-)

Read from keyboard and joystick
*******************************

    7       6       5       4       3       2       1       0    bit/port
,-------+-------+-------+-------+-------+-------+-------+-------.
| ENTER | SPACE |  ---  |  ---  |P.SHIFT|L.SHIFT| FUNC  | CTRL  | 30
+-------+-------+-------+-------+-------+-------+-------+-------+
|   8   |   7   |   6   |   5   |   4   |   3   |   2   |   1   | 31
+-------+-------+-------+-------+-------+-------+-------+-------+
|   I   |   U   |   Y   |   T   |   R   |   E   |   W   |   Q   | 32
+-------+-------+-------+-------+-------+-------+-------+-------+
|   K   |   J   |   H   |   G   |   F   |   D   |   S   |   A   | 33
+-------+-------+-------+-------+-------+-------+-------+-------+
|   ,   |   M   |   N   |   B   |   V   |   C   |   X   |   Z   | 34
+-------+-------+-------+-------+-------+-------+-------+-------+
|   \   |   _   |   /   |   .   |   ^   |   -   |   0   |   9   | 35
+-------+-------+-------+-------+-------+-------+-------+-------+
|   ]   |   :   |   ;   |   L   |   [   |   @   |   P   |   O   | 36
+-------+-------+-------+-------+-------+-------+-------+-------+
| P.JOY | P.JOY | P.JOY | P.JOY | L.JOY | L.JOY | L.JOY | L.JOY | 37
|   |   |  <--  |   ^   |  -->  |   |   |  <--  |   ^   |  -->  |
|   v   |       |   |   |       |   v   |       |   |   |       |
`-------+-------+-------+-------+-------+-------+-------+-------'

Fire, attack buttons are connected to keys 1, 2, 5 a 6 on the keyboard.

Universal port 50H
******************

+----------+--------------------+-------------------------------+
|   bit    | input      | output            |
| 76543210 +--------------------+-------------------------------+
| 00000001 | input OLD from Tape| SAVE on Tape and DSTB na PRT  |
| 00000010 | BUSY from PRT  | STS na PRT and relay      |
| 00000100 | COM for PRT    | ---               |
| 10000000 | key <RESET>    | ---               |
+----------+--------------------+-------------------------------+


HEAP                                - 19 -

Tape format
***********

+---------------------------------------------------------------- . . . ------------------+
| without signal | initial whistle   | HD    | IBG     | data  |         | IBG     | EOF  |
| 4 sec          | 8000 oscillations | block | whistle | block |         | whistle | block|
+---------------------------------------------------------------- . . . ------------------+

HD block                    Data block
========                    ==========

+----------------------------------+    +----------------------------------+
| IDENT | count of| DATA | SUM     |    | IDENT | count of | DATA | SUM    |
|   | bytes   |  HD  |         |    |   | bytes    |      |        |
+----------------------------------+    +----------------------------------+

Format of HD block ( IDT - header )
===================================

00 +--------------------------------------+   Tvar atributu
   |        attribute         |   ~~~~~~~~~~~~~
01 +--------------------------------------+    0          1
   |        record name       |   0    data BASIC     program .CM
   |        maximum 9 characters      |   1    only load      load with autostart
   |      otherwise terminated with 00    |   2    cont. data     file .DT
0A +--------------------------------------+   3    CPU        VRAM
   |        loading address       |   4    without attr.  with attr.
0C +--------------------------------------+   5 \
   |        data length       |   6  > data type
0E +--------------------------------------+   7 /
   |        start address         |
10 +--------------------------------------+   data types
   |        extended attribute    |   ~~~~~~~~~~
11 +--------------------------------------+
   |                      |   20   BI
   |        unused space          |   40   FC
   |                      |   60   BG
1F +--------------------------------------+   80   BF


byte format
===========
start bit = 0, stop bit = 1, example for E5h

*    0    *  1  *  1  *  1  *    0    *    0    *  1  *    0    *  1  *  1
+----+    +--+  +--+  +--+  +----+    +----+    +--+  +----+    +--+  +--+
|    |    |  |  |  |  |  |  |    |    |    |    |  |  |    |    |  |  |  |
|    |    |  |  |  |  |  |  |    |    |    |    |  |  |    |    |  |  |  |  |
+    +----+  +--+  +--+  +--+    +----+    +----+  +--+    +----+  +--+  +--+
start bit                                 stop bit

IBG - whistle before record uncontinuous data with 512 or 3600 pulses length
IDENT   - identification byte   'H' - HD
                'D' - DATA
                'F' - FILE
                'E' - EOF

IBG whistle length determination
===============================
for CALL is the value in C
IBG = C*256+C [ pulses ]


HEAP                                - 20 -

MONITOR ROM error codes
***********************

name    code    type            from

   -    7C  3B  unused          from user
.OVIEW  7D  3C  outside VIEW        MVACS, RDSCH
.CATRG  7E  3D  range overflow      GTSTEP
.SPRDA  7F  3E  sprite otside screen    MVSPA, MVSPR, GTSPRC
.ACMIU  80  3F  unused
.CHKSM  81  40  control sum error   BLOAD, RFIDC, LOADC
.BREAK  82  41  RESET           BSAVE, BLOAD, RFIDC, LOADC
.FINUM  83  42  different name      RFIDC, BLOAD
.BUFFL  84  43  buffer overflow     RDSTM,FUNC,EDTLN,ACELN,PTKDT,LOADC
.DADOT  85  44  EOF found, no data  BLODD, GTKDT, LOADC
.ILGDM  86  45  wrong display mode  STICOL
.TIMOT  87  46  time overflow       ACECH, WTKDTC, EDTLN, ACELN
.SPRPOS 88  47  sprite out of range MVSPA, GTSPOS, MVSPR, GTSPPC
.ILGCM  89  48  error in parameter      VIEW,STCHR,RDCHR,PLAY,ETREIT,GTSTEP
.SPNFD  8A  49  sprite error        GTSPLC
.EVNRD  8B  4A  operation not allowed   STRTDC, STRTUC
.ILGEL  8C  4B  other block     BLOAD, LOADC
   -    8D  4C  unused

meaning:
The programs in the MONITOR ROM call the individual routines in which they are, in case of error, 
the fault routine ensures that the relay is switched off, enable interrupts, drop back address (beware!) 
and return the number of error in the accumulator. The routine where the error occurred does not work,
the process is handed to a subroutine, which is evaluated by the CY state as it has continue.


HEAP                                - 21 -

Brief description of selected parts from Z80 programming
********************************************************

Registers
=========

AF, BC, DE, HL, IX a IY are the register pairs
AF', BC', DE' a HL' are the mirror register pairs
register pairs AF, BC, DE a HL are composed from two registers 
( register pair AF from register A and from register F ... etc. )
R is Refresh register
I is Interrupt register

Bits in F register meaning:
 S   - sign: the result of the operation < 0
 Z   - zero: the result of the operation = 0
 H   - half: for DAA during transfer inside number
 P/V - parity/overflow for logic/arithmetic operations
 N   - subtract: if the last operation was subtract
 C   - carry: 9th bit of byte ( also known as CY )


Writing a condition
===================

Common condition "if NN {operator} QQ then RET" is easy:

IFTHEN: LD  A,NN
    CP  QQ  ;if NN ?? QQ then RET
;and now one from options follows
    RET Z   ;if NN =  QQ then RET
    RET NZ  ;if NN <> QQ then RET
    RET C   ;if NN <  QQ then RET
    RET NC  ;if NN => QQ then RET
;where NN and QQ are one byte numbers ( or register contents ).

Generally -                 - checks :

IF NN =  QQ THEN Z=1, CY=0 ELSE Z=0, CY=X   ; >> Z  <<
IF NN <> QQ THEN Z=0, CY=X ELSE Z=1, CY=0   ; >> NZ <<
IF NN <  QQ THEN Z=0, CY=1 ELSE Z=X, CY=0   ; >> C  <<
IF NN => QQ THEN Z=X, CY=0 ELSE Z=0, CY=1   ; >> NC <<

( note: X meaning status according QQ a NN )

Test one bit is similar:

IF BIT=1 THEN Z=0 ELSE Z=1          ; >> NZ <<
and:
IF BIT=0 THEN Z=1 ELSE Z=0          ; >> Z  <<

example:

TSTBIT: LD  HL,FLAG
    BIT 2,(HL)      ;Go back if 2nd bit of
    RET NZ      ;FLAG variable set to 1
    ...


HEAP                                - 22 -

Relational operations
=====================

Relational operations is written ( for example ) as follows ( result is stored in A register ):

LD  A,#05   ;Vysledky:  #05 - 0000 0101
        ;       #06 - 0000 0110
        ;       ---------------
AND A,#06   ; #05 AND #06 = #04 - 0000 0100
OR  A,#06   ; #05 OR  #06 = #07 - 0000 0111
XOR A,#06   ; #05 XOR #06 = #03 - 0000 0011
NEG     ;         = #FB - 1111 1011

All relational operations set CY=0. If we need to know if in register A is zero, 
we need to use instruction OR A. Zero returns result ( yes/no ).


Arithmetic operations
=====================

Example:
    ADC A,NN    ; A:=A+NN+CY
    ADD A,NN    ; A:=A+NN
    SBC A,NN    ; A:=A-NN-CY
    SUB A,NN    ; A:=A-NN
    DEC A   ; A:=A-1
    INC A   ; A:=A+1

    DAA     ; HEX --> BCD


Rotation of byte
================

Instead, rotation means simply moving individual bits in one byte in the 
given direction (left, right), whereby the bit that is ejected out of 
the byte is always copied to CY and eventually to a bit at the other end of the byte. 
The RL (rotate left) and RLC (rotate left carry) instructions are as follows:


     7 6 5 4 3 2 1 0       CY            7 6 5 4 3 2 1 0        CY
    .-.-.-.-.-.-.-.-.     .-.           .-.-.-.-.-.-.-.-.      .-.
.-- |1|0|0|1|0|1|1|0| <-- |1| <--.  .-- |0|0|0|1|0|1|1|1| <--. |1| <--.
|   `-`-`-`-`-`-`-`-'     `-'    |  |   `-`-`-`-`-`-`-`-'    | `-'    |
`---------------->---------------'  `---------------->-------+--------'

RL  - before "10010110 1" and after "00101101 1".
RLC - before "00010111 1" and after "00101110 0".

        ; 76543210 CY   move bit -
        ; ABCDEFGH X    
RL  A   ; BCDEFGHX A  - left via CY
RLC A   ; BCDEFGHA A  - left, 7th to CY
RR  A   ; XABCDEFG H  - right via CY
RRC A   ; HABCDEFG H  - right, bit nr. 0 to CY
SLA A   ; BCDEFGH0 A  - left, 0 to bit nr. 0, 7th to CY
SLIA    A   ; BCDEFGH1 A  - left, 1 to bit nr. 0, 7th to CY
SRA A   ; AABCDEFG H  - right, 7th saved
SRL A   ; 0ABCDEFG H  - right, 0 to 7th, bit nr. 0 do CY


HEAP                                - 23 -

VDP TMS9929A - videoprocessor
*****************************

VDP data port ( I/O port 10H )
==============================
Read/Write port for transfer one byte from VRAM or to VRAM on specified address. 
After READ/WRITE operation  address is incremented automatically.

VDP command port ( I/O port 11H )
=================================

Status register
---------------
The first 3 bits of this register are automatically reset as 0 when the register is read or when the VDP is reset. It ensues that the status register should only be read when an interrupt is pending, otherwise an interrupt could be missed.

7 - 1 = This bit is set to 1 at the end of the raster scan of the last line of the display area (i.e. before drawing the bottom margin). If interrupts are enabled (by bit 2 in VDP register 1), the INT* pin is low when this bit is 1 and high when it's 0. This is why the status register should be read after each frame, in order to clear the interrupt and be ready to receive the interrupt at the end of the next frame. Also, if bit 2 in VR1 is cleared and set again while status bit 0 is set, an interrupt is issued immediately.

6 - 1 = is the coincidence bit. It is set when two sprites or more have at least one overlapping "on" pixel. This occurs even if the sprite color is transparent. Note that coincidence is checked only every 1/60th of second (1/50th of a second for the TMS9929A), thus if you change sprite positions during that time a coincidence could be missed.

5 - 1 = signals that there are 5 or more sprites on a given pixel row. Only the topmost four will be displayed.

4 to 0 - contain the number of the 5th sprite on a pixel line, if any. This number is only meaningfull if bit 2 is set as 1 (else it may contain the number of the last displayed sprite, but no guaranty). If such a situation occurs more than once, the 5th sprite listed is the one closest to the top of the screen. 

Bits for write:
If bit 7 is set, then bits 2 to 0 represents number of VDP register, to which 
write will be performed. If bit 7 is zero, then  bits 5 to 0 contains VRAM
address, to which the VDP is set, with bit 6 specifying whether the VDP is
to be read or written - 0 = read, 1 = write. Attention! First, the data is
sent or the lower half of the address (bits 7 through 0 have no special
significance) and only the register number or the upper half of the address
is transmitted (bits 7 and 6 are as defined above).

Meaning of the VDP registry:

    7       6       5       4       3       2       1       0    bit/register
,-------+-------+-------+-------+-------+-------+-------+-------.
|   0   |   0   |   0   |   0   |   0   |   0   |  M3   | EXTVI | R0
+-------+-------+-------+-------+-------+-------+-------+-------+
| VRAM  | BLANK | INTEN |  M1   |  M2   |   0   | SIZE  |  MAG  | R1
+-------+-------+-------+-------+-------+-------+-------+-------+
|   0   |   0   |   0   |   0   |        screen address         | R2
+-------+-------+-------+-------+-------+-------+-------+-------+
|                      color table address                      | R3
+-------+-------+-------+-------+-------+-------+-------+-------+
|   0   |   0   |   0   |   0   |   0   | char. shapes address  | R4
+-------+-------+-------+-------+-------+-------+-------+-------+
|   0   |                  sprite table address                 | R5
+-------+-------+-------+-------+-------+-------+-------+-------+
|   0   |   0   |   0   |   0   |   0   | sprite shapes address | R6
+-------+-------+-------+-------+-------+-------+-------+-------+
|         FCOL                  |              BCOL             | R7
`-------+-------+-------+-------+-------+-------+-------+-------'

Bits meaning:
EXTVI    - 0 = disable external video
VRAM     - type of VRAM chips: 0 = 4027 ; 1 = 4108 / 4116
BLANK    - 0 = blank screen, only BCOL is visible
INTEN    - 0 = interrupt disable
SIZE     - 0 = 8*8, 1 = 16*16
MAG      - 0 = std. size 1 = 2x magnified
M1 M2 M3 - videomode select
 0  0  0  GI
 0  0  1  GII
 0  1  0  MCOL
 1  0  0  TEXT
             High      Low                  register
R2=address/400H - 00xx xx00 0000 0000 -> 0000 0000 0000 xxxx
R3=address/40H  - 00xx xxxx xx00 0000 -> 0000 0000 xxxx xxxx
R4=address/800H - 00xx x000 0000 0000 -> 0000 0000 0000 0xxx
R5=address/80H  - 00xx xxx0 0000 0000 -> 0000 0000 000x xxxx
R6=address/800H - 00xx x000 0000 0000 -> 0000 0000 0000 0xxx


HEAP                                - 24 -

SN76489AN - sound generator
***************************

SGC data port ( I/O port 20H )
==============================
SGC contains three sound generators. Channels 0 to 2 are for tone, channel 3 is for noise.

Bits for write  
        - first byte:
If bit 7 is set, then bits 6 and 5 always determines channel SGC, for write operation is performed. 
Bit 4 determines if frequency =0 or attenuation=1 is written. 
Bits 3 to 0 contains attenuation or by write into channel 0 to 2 contains lower half of frequency. 
For channel 3 determines bit 2 periodical noise =0 or white noise =1 and bits 1 and 0 determines frequency.
        - 2nd byte:
if bit 7 is 0, then bits 5 to 0 contains upper half of frequency.

Programming SGC:

1. byte  2.byte
1000nnnn 0Xnnnnnn - set channel 0 to frequency n
1010nnnn 0Xnnnnnn - set channel 1 to frequency n
1100nnnn 0Xnnnnnn - set channel 2 to frequency n

1110Xp00 - set noise channel to frequency F0/512
1110Xp01 - set noise channel to frequency F0/1024
1110Xp10 - set noise channel to frequency F0/2048
1110Xp11 - set noise channel to same frequency, as channel 2


1ch1zzzz - set attenuation zzzz for channel ch. 
    Attenuation:
    zzzz:
            0000 - 0 dB
            0001 - 2 dB
            0010 - 4 dB
            0100 - 7 dB
            1000 - 12.5 dB
            1111 - silence


HEAP                                - 25 -

Programming Z80 CTC - counter
*****************************

control word:

.----+----+----+----+----+----+----+----.
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
`----+----+----+----+----+----+----+----'

D0: =0 V byte select ( channel 0 ) only
    =1 P byte select

Byte format:

.----+----+----+----+----+----+----+----.
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
`----+----+----+----+----+----+----+----'
  \_______ _______/
          V
   interrupt vector - LSB of interrupt vector

D1,D2: channel number,  0 - 0 0 - channel number
            1 - 0 1
            2 - 1 0
            3 - 1 1

Format of P byte:

.----+----+----+----+----+----+----+----.
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
`----+----+----+----+----+----+----+----'

D7: =0 interrupt disable for CPU
    =1 interrupts enable for CPU
D6: =0 counter - CTC channel functionig as counter
    =1 timer - CTC channel functioning as timer
D5: =0 system clock division by 256 ( timer mode )
    =0 system clock division by 16 
D4: =0 clock 
    =1 trigger - channel will be started
D3: =0 external trigger ( timer mode )
    =1 auto trigger 
D2: =0 no will TC - does not follow TC byte
    =1 load TC - nasleduje TC byte
D1: =0 stop channel
    =1 cont - continue channel

Format of TC byte:

.----+----+----+----+----+----+----+----.
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
`----+----+----+----+----+----+----+----'

D7-D0: data 00 to FFh for timer counter


HEAP                                - 26 -

Programming of circuit I8255 - paralell port
********************************************

I8255 circuit is used in PI-5 PIO module.

OUT &70,data or INP(&70) - read/write - port A
OUT &71,data or INP(&71) - read/write - port B
OUT &72,data or INP(&72) - read/write - port C
OUT &73,CWR              - control word

CWR:
====
mode of operation
-------------------
bit
0   - C3-C0, 1=IN, 0=OUT
1   - B7-B0, 1=IN, 0=OUT
2   - operation mode for C3-C0 a B7-B0, 0=0, 1=1
3   - C7-C4, 1=IN, 0=OUT
4   - A7-A0, 1=IN, 0=OUT
5,6 - operation mode for C7-C4 a A7-A0, 00=0, 01=1, 1X=2
7   - 1 ( performing choice of operation mode )

set/reset bits
------------------------
bit
0     - 0=bit reset, 1=bit set
        0 1 2 3 4 5 6 7 - number of bit
1     - 0 1 0 1 0 1 0 1 - B0
2     - 1 1 0 0 1 1 0 0 - B1
3     - 0 0 0 0 1 1 1 1 - B2
4,5,6 - ignored
7     - 0 ( performing set/reset of bit )

operation mode 0
----------------
+---------+---+---+---+---+
| 4 3 1 0 | A | Ch| B | Cl|
+---------+---+---+---+---+
| 0 0 0 0 | O | O | O | O |
| 0 0 0 1 | O | O | O | I |
| 0 0 1 0 | O | O | I | O |
| 0 0 1 1 | O | O | I | I |
| 0 1 0 0 | O | I | O | O |
| 0 1 0 1 | O | I | O | I |
| 0 1 1 0 | O | I | I | O |
| 0 1 1 1 | O | I | I | I |
| 1 0 0 0 | I | O | O | O |
| 1 0 0 1 | I | O | O | I |
| 1 0 1 0 | I | O | I | O |
| 1 0 1 1 | I | O | I | I |
| 1 1 0 0 | I | I | O | O |
| 1 1 0 1 | I | I | O | I |
| 1 1 1 0 | I | I | I | O |
| 1 1 1 1 | I | I | I | I |
+---------+---+---+---+---+


HEAP                                - 27 -

Define new devices in Basic-F
*****************************

Beginning table of devices in BF:

609D    DB  IDENT
    DW  ADRDAL
    DS  3
    DW  OPEN,CLOSE,PRINT,PUT,INPUT,GET,RECORD,FIND
.
.
.
ADRDAL  DB  IDENT
.
.
.

IDENT   - Bits:

0 ... 0 = valid device          1 = invalid device
1 ... 0 = not "FX:";            1 = is "FX:"
2 ... 0 =               1 = 
3 ... 0 = CLOSE before new OPEN;    1 = OPEN can be repeated
4 ... 0 = not "FX:";            1 = driver "FX:" ????
5 ... 0 =               1 = 
6 ... 0 = not "FX:";            1 = channel choice is sent
7 ... 0 = device is available;      1 = device is ignored

The last device in RAM.

73CE    DB  IDENT   / 80h - ignored /
    DW  ADRDAL  / 0000h - none /

Table at 73CEh is only end.

OPEN "DEV:NAME" [ FOR { INPUT / OUTPUT / APPEND } ] AS #CHANNEL

( #0 is open automatically for "CNS:", therefore CLOSE #0 must be performed before use )

7369            ;table of 16 channels, which may be OPENed at the same time
    DB  type of device ( 0FFh = channel closed, i.e. free )
    DB  number of driver
    DB  number of FX channel
    DW  address of device definition
    DB  print location

These bytes fill correctly with the OPEN command.

If we want to ignore some function in the definition of the device, use address 5EE5h .


OPEN:
-----
input: A,D,BC

A  D            IX - base address of channel (IX+2) is available
-----
09 53   FOR is missing  BC - RECORD length ( implicit 256 )
04 22   FOR INPUT
0A 31   FOR OUTPUT
0A 37   FOR APPEND

The other routines do not check if they should be used with respect to the FOR.

PRINT, PUT, INPUT, GET:
-----------------------
input: HL,B,E,SYSFMT,DIFLGA,IX

HL - address from or where
B - maximum length or count
E - (IX+2) from channel table
SYSFMT bit: 0 - VRAM/RAM,
        1 - VERIFY/OLD
DIFLGA bit: 1 - display/execute CTRL codes

output: HL,B,A

HL - address after last processed code
B - number of unprocessed codes
A - last processed code

PRINT and INPUT:
end with code 00 ( not recorded ) or 0Dh ( recorded ).

RECORD:
-------
input: BC,E,IX

BC - number after RECORD
E - (IX+2) from channel table

meaning only for "FX:" - diskette formating

CLOSE:
------
input: E,IX

E - (IX+2) from channel table

write 0FFh to channel table

FIND:
-----
react to separators in PRINT ( tabulator ). 
Not used from outside, find a print position

In all routines, the output parameter is CY, it signals an error, the error code 
expects Basic-F in register A and closes all the channels with it.

SAVE = OPEN + PUT + CLOSE
VSAVE = SET 0,(SYSFMT) + SAVE
OLD = OPEN + GET + CLOSE


HEAP                                - 29 -

Numbers and adresses of commands and functions of Basic-F and Basic-D language
******************************************************************************

name    code    BD  BF  label

err-2   00  79B5    2762    .ERRS
REM 01  49BF    49BF    .REMN
! or '  02  49BF    49BF    .REM!
err-2   03  79B5    2762    .ERRS
DATA    04  49BF    49BF    .DATA
$   05  4353    4353    .LABL
err-2   06  79B5    2762    .ERRS
err-2   07  79B5    2762    .ERRS
err-2   08  79B5    2762    .ERRS
err-2   09  79B5    2762    .ERRS
AUTO    0A  435A    435A    .AUTO
CLEAR   0B  438C    438C    .CLEA
CLIST   0C  7BD2    441E    .CLST
CONT    0D  43E2    43E2    .CONT
DEL 0E  4401    4401    .DEL
KILL    0F  5D89    5D89    .KILL
LIST    10  7BCF    441B    .LIST
NEW 11  44CA    44CA    .NEW
OLD 12  7B9A    4726    .OLD
RENUM   13  4506    4506    .RENM
RUN 14  7B2C    45A5    .RUN
SAVE    15  4645    4645    .SAVE
STEP    16  45FB    45FB    .STEP
TAPE    17  4614    4614    .TAPE
TRACE   18  45FE    45FE    .TRCE
TYPE    19  4626    4626    .TYPE
VERIFY  1A  7B86    4717    .VRFY
VSAVE   1B  7B37    46BA    .VSAV
CHAIN   1C  473D    473D    .CAIN
CLOSE   1D  5079    5079    .CLSE
CONSOLE 1E  5025    5025    .CONS
DIM 1F  4938    4938    .DIM
END 20  4A09    4A09    .END
FOR 21  4A22    4A22    .FOR
GET 22  5152    5152    .GET
GOSUB   23  4B9C    4B9C    .GSUB
GOTO    24  4BA9    4BA9    .GOTO
IF  25  4BC8    4BC8    .IF
INPUT   26  4DA6    4DA6    .INPT
LEN 27  5071    5071    .LEN
LET 28  4C19    4C19    .LET
(LET)   29  4C19    4C19    .LETN
NEXT    2A  4B05    4B05    .NEXT
ON  2B  7CF2    4C6E    .ON
OPEN    2C  5096    5096    .OPEN
PRINT   2D  4CE2    4CE2    .PRNT
PUT 2E  5120    5120    .PUT
RANDOMIZE 2F    3F4B    3F4B    .RAND
READ    30  4E0B    4E0B    .READ
RECORD  31  517B    517B    .RCRD
REPEAT  32  4F82    4F82    .RPAT
RESTORE 33  4F70    4F70    .RSTR
RETURN  34  4F01    4F01    .RSME
RETURN  35  4F13    4F13    .RETN
STOP    36  4FB0    4FB0    .STOP
SWAP    37  4FD9    4FD9    .SWAP
THETA   38  5862    5862    .THTA


HEAP                                - 30 -

UNTIL   39  4F8F    4F8F    .UNTL
BCOL    3A  5205    5205    .BCOL
CLS 3B  51A1    51A1    .CLS
COLOR   3C  520E    520E    .CLOR
DRAW    3D  5319    5319    .DRAW
FCOL    3E  51F9    51F9    .FCOL
GINIT   3F  804D    6287    .GNIT
GMODE   40  52EC    52EC    .GMDE
GMOVE   41  530B    530B    .GMVE
LOC 42  5246    5246    .LOC
LOCATE  43  51CA    51CA    .LCTE
MAG 44  51EA    51EA    .MAG
PAINT   45  5342    5342    .PAIN
PLOT    46  5311    5311    .PLOT
SCOD    47  51D0    51D0    .SCOD
SCOL    48  51D5    51D5    .SCOL
STCHR   49  5288    5288    .STCH
VIEW    4A  51AB    51AB    .VIEW
CALL    4B  56B8    56B8    .CALL
EVENT   4C  7D20    56D1    .EVNT
EXE 4D  5804    5804    .EXE
FX  4E  6D14    6D14    .FX
GCOPY   4F  536B    536B    .GCPY
OUT 50  5796    5796    .OUT
POKE    51  57A4    57A4    .POKE
POKEW   52  5904    5904    .PKEW
SG  53  5708    5708    .SG
SLEEP   54  5750    5750    .SLEP
VPOKE   55  57B2    57B2    .VPKE
WAIT    56  5785    5785    .WAIT
NOLIST  57  44ED    44ED    .NLST
DEF 58  7D5A        .DEF
WHILE   59  7E1F        .WHLE
WEND    5A  7E61        .WEND
PUSH    5B  7D99        .PUSH
POP 5C  7DDD        .POP
BAR 5D  7FFC        .BAR
BOX 5E  8001        .BOX
CIRCLE  5F  800C        .CRCL
JOINT   60  7F69        .JONT
MOVE    61  7F93        .MOVE
ERASE   62  7F53        .ERAS
ESCRN   63  7EB4        .ESCR
MPRINT  64  7F18        .MPRT
PLAY    65  80BD        .PLAY
PMODE   66  80EF        .PMDE
TIME$   67  8162        .TIM$
ALARM$  68  8159        .ALM$
ALARM   69  7D35        .ALRM
COINC   6A  7D03        .CONC
ERROR   6B  8152        .ERRO
KEY 6C  7D0A        .KEY
LINE    6D  7E72        .LINE
OUTW    6E  819C        .OUTW
FILES   6F  81AE        .FILS
err-2   70  79B5    2762    .ERRS

err-2   00  79B5    2762    .ERRS
ABS 01  537F    537F    .ABS
ATN 02  5379    5379    .ATN
CDBL    03  53FA    53FA    .CDBL
CINT    04  5400    5400    .CINT


HEAP                                - 31 -

COS 05  3C0E    3C0E    .COS
EXP 06  3A7B    3A7B    .EXP
FIX 07  3849    3849    .FIX
INT 08  3853    3853    .INT
LN  09  38C0    38C0    .LN
LOG 0A  379D    379D    .LOG
PI  0B  5389    5389    .PI
RND 0C  538F    538F    .RND
SGN 0D  53C0    53C0    .SGN
SIN 0E  3C15    3C15    .SIN
SQR 0F  39DE    39DE    .SQR
TAN 10  3D17    3D17    .TAN
XCHG    11  53DD    53DD    .XCHG
ASCII   12  5425    5425    .ASCI
CHR$    13  5505    5505    .CHR$
HEX$    14  5513    5513    .HEX$
INSTR   15  5434    5434    .INST
LEFT$   16  5494    5494    .LET$
LEN 17  54FD    54FD    .LEN
MID$    18  54B6    54B6    .MID$
NUM$    19  83A2    5556    .NUM$
RDST$   1A  567E    567E    .RDS$
RIGHT$  1B  54A2    54A2    .RGH$
RPT$    1C  5524    5524    .RPT$
VAL 1D  565B    565B    .VAL
CALC    1E  57C3    57C3    .CALC
ERR 1F  584E    584E    .ERR
ERRL    20  5855    5855    .ERRL
ERRL$   21  585B    585B    .ERR$
FRE 22  5869    5869    .FRE
INKEY$  23  58BA    58BA    .INK$
INP 24  58E9    58E9    .INP
PEEK    25  58F2    58F2    .PEEK
PEEKW   26  5919    5919    .PEKW
REG 27  53E5    53E5    .REG
TIME    28  58CD    58CD    .TIME
VARPTR  29  58D3    58D3    .VPTR
VPEEK   2A  58F9    58F9    .VPEK
POS 2B  8403        .POS
RCRT    2C  8423        .RCRT
MRCRT$  2D  872A        .MRC$
RDCHR$  2E  86F8        .RDC$
COLOR   2F  83DA        .COLR
DIST    30  85F4        .DIST
DRCT    31  85D8        .DRCT
POINT   32  8431        .PONT
COINC   33  8449        .CINC
LINK    34  8694        .LINK
POST    35  86C9        .POST
SPRITE  36  866B        .SPRT
STATUS  37  86BB        .STTS
INKEY   38  873F        .INKE
PLAY    39  8754        .PLAY
TIME$   3A  87E4        .TME$
ASW 3B  87B6        .ASW
ICOS    3C  8792        .ICOS
INPW    3D  8814        .INPW
ISIN    3E  878D        .ISIN
JOY 3F  87CB        .JOY


HEAP                                - 32 -

Separators and other delimiter words of Basic-F and Basic-D
***********************************************************

code    word

80  VARIABLE%   B0  OR      E0  ALARM
81          B1  XOR     E1  KEY
82  VARIABLE#   B2          E2
83          B3          E3
84  VARIABLE$   B4          E4
85          B5          E5
86          B6          E6
87          B7          E7
88  constant%   B8          E8
89          B9          E9
8A  constant#   BA          EA
8B          BB          EB
8C  constant$   BC          EC
8D          BD  (       ED
8E          BE  )       EE
8F  constant&   BF  NOT     EF
90  FN.%        C0  row number  F0
91          C1  row address F1
92  FN.#        C2  label       F2
93          C3          F3
94  FN.$        C4  TAB     F4
95          C5  CURSOR      F5
96          C6          F6
97          C7          F7
98          C8  ON      F8
99          C9  OFF     F9
9A          CA  TO      FA
9B          CB  IN      FB
9C          CC  #       FC  ELSE
9D          CD  @       FD  THEN
9E          CE  ,       FE  :
9F          CF  ;       FF  <CR>
A0          D0  STEP
A1  ^       D1  RECORD
A2  *       D2  MODE
A3  /       D3  DBL
A4          D4  STR
A5  MOD     D5  GOSUB
A6  +       D6  GOTO
A7  -       D7  RESTORE
A8  =       D8  ERROR
A9          D9  EVENT
AA  <       DA  FOR
AB  <=      DB  AS
AC  >       DC  INPUT
AD  >=      DD  OUTPUT
AE  <>      DE  APPEND
AF  AND     DF  ALL


HEAP                                - 33 -

BASIC-F variables format
************************

a) number variables - simple VARIABLE:
   ATR + NAME + HODNOTA
                    - array type VARIABLE:
   ATR + NAME + LENGTH + DIM + LISTofDIM + VALUE

b) string variables - simple VARIABLE:
   ATR + NAME + LENM + TEXT
                      - array type VARIABLE:
   ATR + NAME + LENGTH + DIM + LISTofDIM + LENM + TEXT

Explanatory Notes:
==================

ATR - 1 byte, meaning:
---------------------------------------------+
bit |  0  |  1  |  2  |  3  |  4   5   6   7 |
----+-----+-----+-----+-----+----------------+
0   | INT |  -  |  -  |  -  | without meaning|
1   |  -  | DBL | STR | arr.|                |
----+-----+-----+-----+-----+----------------+
NAME - 1 byte length + ASCII
VALUE - 2 or 8 bytes according of type
LENGTH - 2 bytes - offset to next variable
DIM - 1 byte - number of dimensions
LISTofDIM - max. of dimensions
TEXT - delka textu ( 1 byte ) + vlastni text ( ASCII )
LENM - 1 byte - offset to next variable


HEAP                                - 34 -

Numbers and adresses of Basic-G and Basic-I commands and functions
******************************************************************

NAME    code  is in BI? name    code  is in BI? name    code  is in BI?

MID$    41  +   MOD 83  +   POKE    CA  +
LEFT$   42  +   +   84  +   VPOKE   CB  +
RIGHT$  43  +   -   85  +   OUT CC  +
RPT$    44  +   <   86  +   CLS CD  +
POS 45  +   =   87  +   MPRINT  CE
LEN 46  +   >   88  +   PRINT   CF  +
VAL 47  +   AND 89  +   MAG D0  +
ASCII   48  +   XOR 8A  +   CLEAR   D1  +
CHR$    49  +   OR  8B  +   FCOL    D2
NUM$    4A  +   (   8C  +   BCOL    D3
HEX$    4B  +   )   8D  +   ERASE   D4
LINK    4C      NOT 8E  +   POKEW   D5
SGN 4D  +               OUTW    D6
ABS 4E  +   TRACE   A0  +   LOCATE  D7
RND 4F  +   AUTO    A1  +   VSAVE   D8
INP 50  +   TAPE    A2  +   CIRCLE  D9
PEEK    51  +   CONT    A3  +   WAIT    DA
VPEEK   52  +   DEL A4  +   SLEEP   DB
PEEKW   53      LIST    A5  +   JOINT   DC
INPW    54      RENUM   A6      PMODE   DD
VARPTR  55      NEW A7  +   GMODE   DE
INKEY$  56  +   OLD A8  +   PLOT    DF
COLOR   57      CHAIN   A9  +   MOVE    E0
PLAY    58      RUN AA  +   GMOVE   E1
TIME    59  +   SAVE    AB  +   GINIT   E2
FRE 5A  +   VERIFY  AC  +   PAINT   E3
ERR 5B  +   PUSH    AD      GCOPY   E4
ERRL    5C  +   POP AE      DRAW    E5
ERRL$   5D  +   REM AF  +   BOX E6
JOY 5E      END B0  +   CONSOLE E7
RCRT    5F      FOR B1  +   BAR E8
TIME$   60      NEXT    B2  +   SG  E9
RDCHR$  61      REPEAT  B3      KEY EA
DRCT    62      UNTIL   B4      OFF EB
DIST    63      RESUME  B5      SKIP    EC
RETL    64      IF  B6  +   LISTC   ED
            LET B7  +   ELIST   EE
ASW 67      GOTO    B8  +   ELISTC  EF
INKEY   68      GOSUB   B9  +   ON  F0
            RETURN  BA  +   ERROR   F1
POST    6A      READ    BB  +   @   F2
POINT   6B      RESTORE BC  +   ALARM   F3
STATUS  6C      DATA    BD  +   !   F4
COINC   6D      CALL    BE  +   ESCRN   F5
SPRITE  6E      STOP    BF  +   STEP    F6  +
SIN 6F      DIM C0  +   IN  F7  +
COS 70      INPUT   C1  +   THEN    F8  +
XCHG    71      VIEW    C2  +   ELSE    F9  +
MRCRT$  72      EVENT   C3      TO  FA  +
INSTR   73      ALARM$  C4      #   FB  +
CURSOR  7F  +   RANDOMIZE C5    +   ,   FC  +
TAB 7E  +   LOC C6  +   ;   FD  +
^   80  +   STCHR   C7  +   :   FE  +
*   81  +   SCOL    C8  +   CR  FF  +
/   82  +   SCOD    C9  +   


HEAP                                - 35 -

Options For M5
**************

DR-5: Data Recorder ( cassette tape recorder ) for M5
PT-5: 80 Character width-normal character size 160, character width-small cha-
 racter size.It is a silent printer with the speed of 60 characters per second
EB-5: Extension memory box with 3 slots
EC-5: Extension memory card with 2 slots
EM-5: DRAM 32 kB. Additional memory
FD-5: 3" micro floppy disc drive. 320 kB ( both sides ).Work with system disc
 and data disc
PI-5: Parallel interface ( interface between EB5 + FD5 or others )
SI-5: Serial interface ( interface between EB5 and other computers )
BASIC-I CARTRIDGE: for beginners
BASIC-G CARTRIDGE: High graphic capability with 16 different colours and high
 synthesizer music capability, with 6 octaves and intermediary tones. 3 tone
 chord available
BASIC-F CARTRIDGE: With high arithmetic and graphics capability
FALC CARTRIDGE: Spreadsheet programme just 10 commands to control
GAME CARTRIDGE: 12 games to choose.
 GRC1   Tank Battalion
 GRC2   Step Up
 GRC3   Guttang Cottong
 GRC4   Heavy Boxing
 GRC5   Super Cobra
 GRC6   Real Tennis
 GRC7   Poo Yan
 GRC8   Word Maze
 GRC9   Wonder Hole
 GRC10  Up Up Balloon
 GRC/B1 Fruit Search
 GRC/B2 Dragon Attack
LANGUAGE EDUCATION PROGRAMME: ( Cassette tape ) Designed for 8-10 year old
 students. Domestic and foreign languages available
P. EDITOR: ( Cassette tape ) Cassette tape for drawings
BASIC G DEMO: ( Cassette tape ) Demonstration programme for BASIC G
GAMES CASSETTES: 8 cassette tapes to choose ( each cassette tape has 2 games )
 GCT1  Snaky / Barrier Attack
 GCT2  Jogging / Side Winder
 GCT3  Solitaire / Tower Of Hanoi
 GCT4  Three Circles / Number Search
 GCT5  Black Jack / Slot Machine
 GCT6  Mini Star Trek / Last Day Of The Earth
 GCT7  Biorhythm Diagnosis / Music Tone
 GCT8  Cowboy / Barricade
 GCT11 Baseball / Zac Banic
       TV Adjust
TV-5: Colour T.V. ( for G PAL )
JP-5: Joy pads for games. Note: Game may also be played using M5 keyboard only
CA-5: Travel case
MANUALS: ( in English )
 M5 Users Guide, M5 Basic I Manual, M5 Basic G Manual, M5 Basic F Manual
 M5 Falc Manual, M5 Personal Manual, M5 Creative Manual, M5 Monitor Handling


HEAP                                - 36 -


                  H E A P


            According to different materials
            and based on their own experience
            composed and wrote it LZR Soft.
            In Kladno 1991.
            Issue first, number of prints -
            according to need. Printed on
            LA120 printer from DEC.



                02-SEP-91


Additional CTC Channel 0-3 Vector Usage:

address value name attribute
------- | ------- | ------- | -------------------------- ----------------------------
7000      186C      IVCTC0  Address for interrupt from channel 0 of the Z80 CTC circuit.
                    It is used for the Z80 SIO circuit when the module is connected
                    SI-5. Otherwise it is free and can be used

7002      1861      IVCTC1  Address for interrupt from channel 1 of the Z80 CTC circuit
                    the most frequent use of sound generator (SML interpreter and BG
                    at PLAY). It is often used for timing peripherals

7004      186C      IVCTC2  Z80 CTC circuit breakout address 2.
                    It is used as the CLOCK for the Z80 SIO circuit, if module SI-5 is
                    connected. Otherwise it is free and can be used

7006      01DF      IVCTC3  Address for interrupts from channel 3 of the Z80 CTC.Used for 
                    contact with the VDP video-processor, user-
                    interrupts, keyboards, joypads, ... It is always used

                