@nataliapc/mcp-openmsx 1.1.5 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/dist/openmsx.js +9 -0
- package/dist/server.js +502 -327
- package/dist/utils.js +17 -0
- package/package.json +4 -1
- package/resources/audio/toc.json +31 -0
- package/resources/bios/Calling_BIOS_from_MSX-DOS.md +75 -0
- package/resources/bios/MSX2_SUBROM_BIOS_calls.md +734 -0
- package/resources/bios/MSX_BIOS_calls.md +1046 -0
- package/resources/bios/toc.json +24 -0
- package/resources/book--msx2-technical-handbook/Appendix1__BIOS_Listing.md +1464 -0
- package/resources/book--msx2-technical-handbook/Appendix2__Math-Pack.md +427 -0
- package/resources/book--msx2-technical-handbook/Appendix3__Bit_Block_Transfer.md +182 -0
- package/resources/book--msx2-technical-handbook/Appendix4__Work_Area_Listing.md +1637 -0
- package/resources/book--msx2-technical-handbook/Appendix5__VRAM_Map.md +145 -0
- package/resources/book--msx2-technical-handbook/Appendix6__IO_Map.md +128 -0
- package/resources/book--msx2-technical-handbook/Appendix8_10__Control_Codes_and_Escape_Sequences.md +76 -0
- package/resources/book--msx2-technical-handbook/Chapter1__MSX_System_Overview.md +402 -0
- package/resources/book--msx2-technical-handbook/Chapter2__BASIC.md +2148 -0
- package/resources/book--msx2-technical-handbook/Chapter3__MSX-DOS.md +2577 -0
- package/resources/book--msx2-technical-handbook/Chapter4a__VDP_and_Display_Screen.md +2052 -0
- package/resources/book--msx2-technical-handbook/Chapter4b__VDP_and_Display_Screen.md +3311 -0
- package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md +2714 -0
- package/resources/book--msx2-technical-handbook/Chapter5b__Access_to_Peripherals_through_BIOS.md +1263 -0
- package/resources/book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler.md +220 -0
- package/resources/book--msx2-technical-handbook/toc.json +82 -0
- package/resources/book--the-msx-red-book/the_msx_red_book.md +10349 -0
- package/resources/book--the-msx-red-book/toc.json +12 -0
- package/resources/msx-dos/MSX-DOS_2_Function_Specifications.md +1366 -0
- package/resources/msx-dos/MSX-DOS_2_Program_Interface_Specification.md +963 -0
- package/resources/msx-dos/toc.json +18 -0
- package/resources/msx-unapi/Ethernet_UNAPI_specification_1.1.md +369 -0
- package/resources/msx-unapi/Introduction_to_MSX-UNAPI.md +132 -0
- package/resources/msx-unapi/MSX_UNAPI_specification_1.1.md +679 -0
- package/resources/msx-unapi/TCP-IP_UNAPI_specification.md +2361 -0
- package/resources/msx-unapi/toc.json +27 -0
- package/resources/others/toc.json +11 -0
- package/resources/processors/Z80_R800_instruction_set.md +482 -0
- package/resources/processors/toc.json +24 -0
- package/resources/processors/z80-undocumented.tex +5617 -0
- package/resources/processors/z80_detailed_instruction_set.md +2025 -0
- package/resources/programming/toc.json +121 -0
- package/resources/system/MSX_IO_ports_overview.md +554 -0
- package/resources/system/toc.json +18 -0
- package/resources/video/V9938_Technical_Data_Book.md +3623 -0
- package/resources/video/V9958_Technical_Data_Book.md +417 -0
- package/resources/video/V9990_Programmers_Manual_Banzai.html +1582 -0
- package/resources/video/VDP_TMS9918A.txt +709 -0
- package/resources/video/toc.json +28 -0
package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md
ADDED
|
@@ -0,0 +1,2714 @@
|
|
|
1
|
+
# CHAPTER 5 - ACCESS TO PERIPHERALS THROUGH BIOS (Sections 1 to 6)
|
|
2
|
+
|
|
3
|
+
The basic philosophy of MSX is to have a standard interface, independent of machines or versions, to access peripherals through BIOS. Thus, the user should get to know about using BIOS first. In chapter 5, accessing peripherals using BIOS and the structure used for each peripheral are described.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Index
|
|
7
|
+
|
|
8
|
+
- [1. PSG AND SOUND OUTPUT](#1-psg-and-sound-output)
|
|
9
|
+
- [1.1. PSG functions](#11-psg-functions)
|
|
10
|
+
- [1.2 Access to the PSG](#12-access-to-the-psg)
|
|
11
|
+
- [1.3 Tone Generation by 1-bit Sound Port](#13-tone-generation-by-1-bit-sound-port)
|
|
12
|
+
- [1.4 Access to 1-bit Sound Port](#14-access-to-1-bit-sound-port)
|
|
13
|
+
- [2. CASSETTE INTERFACE](#2-cassette-interface)
|
|
14
|
+
- [2.1 Baud Rate](#21-baud-rate)
|
|
15
|
+
- [2.2 One bit composition](#22-one-bit-composition)
|
|
16
|
+
- [2.3 One byte composition](#23-one-byte-composition)
|
|
17
|
+
- [2.4 Header Composition](#24-header-composition)
|
|
18
|
+
- [2.5 File Formats](#25-file-formats)
|
|
19
|
+
- [2.6 Access to cassette files](#26-access-to-cassette-files)
|
|
20
|
+
- [3. KEYBOARD INTERFACE](#3-keyboard-interface)
|
|
21
|
+
- [3.1 Key Scanning](#31-key-scanning)
|
|
22
|
+
- [3.2 Character Input](#32-character-input)
|
|
23
|
+
- [3.3 Function Keys](#33-function-keys)
|
|
24
|
+
- [3.4 STOP Key During Interrupts](#34-stop-key-during-interrupts)
|
|
25
|
+
- [4. PRINTER INTERFACE](#4-printer-interface)
|
|
26
|
+
- [4.1 Print Interface Overview](#41-print-interface-overview)
|
|
27
|
+
- [4.2 Output to the MSX Standard Printer](#42-output-to-the-msx-standard-printer)
|
|
28
|
+
- [4.3 Access to the printer](#43-access-to-the-printer)
|
|
29
|
+
- [5. UNIVERSAL I/O INTERFACE](#5-universal-io-interface)
|
|
30
|
+
- [5.1 Functions of the Ports](#51-functions-of-the-ports)
|
|
31
|
+
- [5.2 Joystick Use](#52-joystick-use)
|
|
32
|
+
- [5.3 Paddle Use](#53-paddle-use)
|
|
33
|
+
- [5.4 Use of Touch Panel, Light Pen, Mouse, and Track Ball](#54-use-of-touch-panel-light-pen-mouse-and-track-ball)
|
|
34
|
+
- [6. CLOCK AND BATTERY-POWERED MEMORY](#6-clock-and-battery-powered-memory)
|
|
35
|
+
- [6.1 CLOCK-IC Functions](#61-clock-ic-functions)
|
|
36
|
+
- [6.2 Structure of the CLOCK-IC](#62-structure-of-the-clock-ic)
|
|
37
|
+
- [6.3 MODE Register Functions](#63-mode-register-functions)
|
|
38
|
+
- [6.4 TEST Register functions](#64-test-register-functions)
|
|
39
|
+
- [6.5 RESET Register Functions](#65-reset-register-functions)
|
|
40
|
+
- [6.6 Setting the Clock and Alarm](#66-setting-the-clock-and-alarm)
|
|
41
|
+
- [6.7 Contents of the Battery-powered Memory](#67-contents-of-the-battery-powered-memory)
|
|
42
|
+
- [6.8 Access to the CLOCK-IC](#68-access-to-the-clock-ic)
|
|
43
|
+
- [Changes from the original](#changes-from-the-original)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<p> </p>
|
|
47
|
+
|
|
48
|
+
## 1. PSG AND SOUND OUTPUT
|
|
49
|
+
|
|
50
|
+
MSX has the following three kinds of sound output functions, but function (3) is not installed in the standard MSX, so it is not described in this manual. This section describes functions (1) and (2).
|
|
51
|
+
|
|
52
|
+
(1) PSG sound output (3 channels, 8 octaves)
|
|
53
|
+
|
|
54
|
+
(2) Sound output by 1 bit I/O port
|
|
55
|
+
|
|
56
|
+
(3) Sound output by MSX-AUDIO (FM sound generator) - not described in this manual
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
<p> </p>
|
|
60
|
+
|
|
61
|
+
### 1.1. PSG functions
|
|
62
|
+
|
|
63
|
+
An AY-3-8910 compatible LSI is used for the MSX music play function and for BEEP tone generation. This LSI is referred to as the PSG (Programmable Sound Generator), and can generate complex music and varios tones. It has the following features:
|
|
64
|
+
|
|
65
|
+
* There are three tone generators, each of which can independently specify 4096 scales (equivalent to 8 octaves) and 16 volume levels.
|
|
66
|
+
|
|
67
|
+
* It can generate piano and organ tones by using envelope patterns. Note that, since there is only one envelope generator, the tone of only one channel can be modified fundamentally.
|
|
68
|
+
|
|
69
|
+
* With the noise generator inside, tones such as the wind or waves can easily be generated. Note that since there is only one noise generator, only one channel can generate the noise.
|
|
70
|
+
|
|
71
|
+
* Any necessary frequency, such as the tone or the envelope, is obtained by dividing the input clock (in MSX, it is defined that fc = 1.7897725 MHz). So there is no unsteady pitch or rythm.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
##### _Figure 5.1 PSG block diagram_
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
R0, R1 R7 R8
|
|
78
|
+
-------------------- ------------- ------------------------------
|
|
79
|
+
| Tone generator A | --> | | ------> | Volume control amplifier A |
|
|
80
|
+
-------------------- | | +--> ---------------------------+--
|
|
81
|
+
| | | Channel A output <--+
|
|
82
|
+
R2, R3 | Three | | R9
|
|
83
|
+
-------------------- | | | ------------------------------
|
|
84
|
+
| Tone generator B | --> | Channel | ---:--> | Volume control amplifier B |
|
|
85
|
+
-------------------- | | +--> ---------------------------+--
|
|
86
|
+
| Mixer | | Channel B output <--+
|
|
87
|
+
R4, R5 | | | R9
|
|
88
|
+
-------------------- | | | ------------------------------
|
|
89
|
+
| Tone generator C | --> | | ---:--> | Volume control amplifier C |
|
|
90
|
+
-------------------- ------------- +--> ---------------------------+--
|
|
91
|
+
^ | Channel C output <--+
|
|
92
|
+
| |
|
|
93
|
+
R6 | | R11, R12, R13
|
|
94
|
+
--------------------- ------------------------
|
|
95
|
+
| Noise generator | | Envelope generator |
|
|
96
|
+
--------------------- ------------------------
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The PSG has two additional I/O (input/output) ports used for other than tone generating functions, which are omitted in the block diagram above. MSX uses them as general-purpose I/O ports to connect to I/O devices such as joystick, a touch pad, a paddle, or a mouse. These general-purpose I/O ports are described in section 5.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
#### PSG registers
|
|
103
|
+
|
|
104
|
+
Since the PSG generates tones, the CPU simply notifies PSG when the tone is to be changed. This is done by writing values in 16 8-bit registers inside the PSG as shown in [Figure 5.2](#figure-52--psg-register-structure).
|
|
105
|
+
|
|
106
|
+
Roles and uses of these registers are described below.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
#### Setting the tone frequency (R0 to R5)
|
|
110
|
+
|
|
111
|
+
Each tone frequency of channel A, B, and C is set by R0 to R5. The input clock frequency (fc = 1.7897725 MHz) is divided by 16 and the result is the standard frequency. Each channel divides the standard frequency by the 12-bit data assigned for each, and the objective pitch is obtained. The following relation exists between 12-bit data (TP) and the tone frequency to be generated (ft).
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
ft = fc/(16 * TP)
|
|
115
|
+
= 0.11186078125/TP [MHz]
|
|
116
|
+
= 111860.78125/TP [Hz]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
A 12-bit data TP is specified for each channel by 4 high order bit coarse tune CT and 8 low order bit fine tune value FT, as shown in [Figure 5.3](#figure-53--setting-the-pitch). [Table 5.1](#table-51--setting-the-tone-frequency-scale-data) shows the register settings to make the scales.
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
##### _Figure 5.2 PSG register structure_
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
-----------------------------------------------------------------------------
|
|
126
|
+
| Bit | | | | | | | | |
|
|
127
|
+
| | B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
|
|
128
|
+
| Register | | | | | | | | |
|
|
129
|
+
|---------------------------+-----------------------------------------------|
|
|
130
|
+
| R0 | Channel A note | 8 low order bits |
|
|
131
|
+
|----------| |-----------------------------------------------|
|
|
132
|
+
| R1 | Dividing rate | x x x x | 4 high order bits |
|
|
133
|
+
|----------+----------------+-----------------------------------------------|
|
|
134
|
+
| R2 | Channel B note | 8 low order bits |
|
|
135
|
+
|----------| |-----------------------------------------------|
|
|
136
|
+
| R3 | Dividing rate | x x x x | 4 high order bits |
|
|
137
|
+
|----------+----------------+-----------------------------------------------|
|
|
138
|
+
| R4 | Channel C note | 8 low order bits |
|
|
139
|
+
|----------| |-----------------------------------------------|
|
|
140
|
+
| R5 | Dividing rate | x x x x | 4 high order bits |
|
|
141
|
+
|----------+----------------+-----------------------------------------------|
|
|
142
|
+
| R6 | Noise div. rate| x x x | |
|
|
143
|
+
|----------+----------------+-----------------------------------------------|
|
|
144
|
+
| | | IN*/OUT | NOISE* | TONE* |
|
|
145
|
+
| R7 | Enable* |-----------+-----------------+-----------------|
|
|
146
|
+
| | | IOB | IOA | C | B | A | C | B | A |
|
|
147
|
+
|----------+----------------+-----------------+-----+-----------------------|
|
|
148
|
+
| R8 | Chan. A volume | x x x | M | |
|
|
149
|
+
|----------+----------------+-----------------+-----+-----------------------|
|
|
150
|
+
| R9 | Chan. B volume | x x x | M | |
|
|
151
|
+
|----------+----------------+-----------------+-----+-----------------------|
|
|
152
|
+
| R10 | Chan. C volume | x x x | M | |
|
|
153
|
+
|----------+----------------+-----------------------------------------------|
|
|
154
|
+
| R11 | | 8 low order bits |
|
|
155
|
+
|----------| Envelope Cycle |-----------------------------------------------|
|
|
156
|
+
| R12 | | 8 high order bits |
|
|
157
|
+
|----------+----------------+-----------------------------------------------|
|
|
158
|
+
| R13 | Env. wave shape| x x x x | |
|
|
159
|
+
|----------+----------------+-----------------------------------------------|
|
|
160
|
+
| R14 | I/O port A | |
|
|
161
|
+
|----------+----------------+-----------------------------------------------|
|
|
162
|
+
| R15 | I/O port B | |
|
|
163
|
+
-----------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
NOTE: x = unused bit
|
|
166
|
+
* = inverted signal
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
##### _Figure 5.3 Setting the pitch_
|
|
170
|
+
|
|
171
|
+
```
|
|
172
|
+
-------------------------------------------------
|
|
173
|
+
R0, R2, R4 | 8 bits | --+
|
|
174
|
+
------------------------------------------------- |
|
|
175
|
+
------------------------------------------------- |
|
|
176
|
+
R0, R2, R4 | x x x x | 4 bits | |
|
|
177
|
+
------------------------------------------------- |
|
|
178
|
+
| |
|
|
179
|
+
----------------------------------------+ |
|
|
180
|
+
| |
|
|
181
|
+
V V
|
|
182
|
+
-----------------------------------------------------------------------
|
|
183
|
+
| Coarse Tune (CT) | Fine Tune (FT) |
|
|
184
|
+
-----------------------------------------------------------------------
|
|
185
|
+
| |
|
|
186
|
+
+-------------------------------- TP ---------------------------------+
|
|
187
|
+
|
|
188
|
+
[ Channel A - R0, R1 ]
|
|
189
|
+
[ Channel B - R2, R3 ]
|
|
190
|
+
[ Channel C - R4, R5 ]
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
##### _Table 5.1 Setting the tone frequency (scale data)_
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
----------------------------------------------------------------
|
|
197
|
+
| Octave | | | | | | | | |
|
|
198
|
+
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
|
199
|
+
| Note | | | | | | | | |
|
|
200
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
201
|
+
| C | D5D | 6AF | 357 | 1AC | D6 | 6B | 35 | 1B |
|
|
202
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
203
|
+
| C# | C9C | 64E | 327 | 194 | CA | 65 | 32 | 19 |
|
|
204
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
205
|
+
| D | BE7 | 5F4 | 2FA | 17D | BE | 5F | 30 | 18 |
|
|
206
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
207
|
+
| D# | B3C | 59E | 2CF | 168 | B4 | 5A | 2D | 16 |
|
|
208
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
209
|
+
| E | A9B | 54E | 2A7 | 153 | AA | 55 | 2A | 15 |
|
|
210
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
211
|
+
| F | A02 | 501 | 281 | 140 | A0 | 50 | 28 | 14 |
|
|
212
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
213
|
+
| F# | 973 | 4BA | 25D | 12E | 97 | 4C | 26 | 13 |
|
|
214
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
215
|
+
| G | 8EB | 476 | 23B | 11D | 8F | 47 | 24 | 12 |
|
|
216
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
217
|
+
| G# | 88B | 436 | 21B | 10D | 87 | 43 | 22 | 11 |
|
|
218
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
219
|
+
| A | 7F2 | 3F9 | 1FD | FE | 7F | 40 | 20 | 10 |
|
|
220
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
221
|
+
| A# | 780 | 3C0 | 1E0 | F0 | 78 | 3C | 1E | F |
|
|
222
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
223
|
+
| B | 714 | 38A | 1C5 | E3 | 71 | 39 | 1C | E |
|
|
224
|
+
----------------------------------------------------------------
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Setting the noise frequency (R6)
|
|
228
|
+
|
|
229
|
+
The noise generator is used for synthesizing explosion sounds or wave sounds. The PSG can send the noise output by the noise generator to channels A to C. Since there is only one noise generator, the same noise is sent to all channels. By changing the average frequency, various noise effects can be obtained and this is done by R6 register settings. The 5 low order bit data (NP) of this register is divides into the standard frequency (fc/16) and this determines the average frequency of the noise (fn).
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
##### _Figure 5.4 Setting the noise frequency_
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
-------------------------------------------------
|
|
236
|
+
R6 | x x x | |
|
|
237
|
+
-------------------------------------------------
|
|
238
|
+
| |
|
|
239
|
+
+------------- NP ------------+
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The following relation exists between NP and fn.
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
fn = fc/(16 * NP)
|
|
246
|
+
= 0.11186078125/NP [MHz]
|
|
247
|
+
= 111860.78125/NP [Hz]
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Since the value of NP is from 1 to 31, the average frequency of the noise can be set from 3.6kHz to 111.9kHz.
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
#### Mixing the sound (R7)
|
|
254
|
+
|
|
255
|
+
R7 is used to select the output of the tone and noise generator, or a mixture of both. As shown in [Figure 5.5](#figure-55--output-selection-for-each-channel), the 3 low order bits (B0 to B2) of R7 control the tone output and the next 3 bits (B3 to B5) control the noise output. In both cases, when the corresponding bit is 0, the output is ON and, when 1, it is OFF.
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
##### _Figure 5.5 Output selection for each channel_
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
-------------------------------------------------
|
|
262
|
+
R7 | B7 | B6 | B5 | B4 | B3 | B2 | B1 | B0 |
|
|
263
|
+
-------------------------------------------------
|
|
264
|
+
|
|
|
265
|
+
|
|
|
266
|
+
V
|
|
267
|
+
|
|
268
|
+
B7 B6 B5 B4 B3 B2 B1 B0
|
|
269
|
+
----------------- ------------------------- -------------------------
|
|
270
|
+
| Input enable* | | Noise enable* | | Tone enable* |
|
|
271
|
+
|---------------| |-----------------------| |-----------------------|
|
|
272
|
+
| B | A | | C | B | A | | C | B | A |
|
|
273
|
+
----------------- ------------------------- -------------------------
|
|
274
|
+
I/O port Noise output Tone output
|
|
275
|
+
Input - 0 ON - 0 ON - 0
|
|
276
|
+
Output - 1 OFF - 1 OFF - 1
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The 2 high order bits of R7 do not affect sound output. These are used to determine the direction of the data of two I/O ports which PSG has. When the corresponding bit is 0, the input mode is selected and, when 0, the output mode is selected. In MSX, port A is used for the input and port B for the output, so it should always be set so that bit 6 = "0" and bit 7 = "1".
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
#### Setting the volume (R8 to R10)
|
|
283
|
+
|
|
284
|
+
R8 to R10 are used to specify the volume of each channel. Two ways can be selected by these registers: specifying the fixed volume by 4-bit data (0 to 15) and generating sound effects such as vibrato or fade-out by using the envelope.
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
##### _Figure 5.6 Setting the volume_
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
-------------------------------------------------
|
|
291
|
+
R8, R9, R10 | x x x | B4 | B3 | B2 | B1 | B0 |
|
|
292
|
+
-------------------------------------------------
|
|
293
|
+
| | |
|
|
294
|
+
| +---------- L ----------+
|
|
295
|
+
|
|
|
296
|
+
V
|
|
297
|
+
Use envelope:
|
|
298
|
+
No - 0 (set volume by the value of L)
|
|
299
|
+
Yes - 1 (ignore the value of L)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
When bit 4 of these registers is "0", the envelope is not used and the 4 low order bit value L (0 to 15) of the registers specify the volume. When bit 4 is "1", the volume depends on the envelope signals and the value L is ignored.
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
#### Setting the envelope cycle (R11, R12)
|
|
306
|
+
|
|
307
|
+
R11 and R12 specify the envelope cycle in 16-bit data. The 8 high order bits are set in R12 and the 8 low order bits are set in R11.
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
##### _Figure 5.7 Setting the envelope cycle_
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
-------------------------------------------------
|
|
314
|
+
R11 | | --+
|
|
315
|
+
------------------------------------------------- |
|
|
316
|
+
------------------------------------------------- |
|
|
317
|
+
R12 | | |
|
|
318
|
+
------------------------------------------------- |
|
|
319
|
+
| |
|
|
320
|
+
---------------------------------+ |
|
|
321
|
+
| |
|
|
322
|
+
V V
|
|
323
|
+
-----------------------------------------------------------------------------
|
|
324
|
+
| Coarse Tune (CT) | Fine Tune (FT) |
|
|
325
|
+
-----------------------------------------------------------------------------
|
|
326
|
+
| |
|
|
327
|
+
+----------------------------------- EP ------------------------------------+
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
The following relation exists between the envelope cycle T and 16-bit data EP.
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
T = (256 * EP) / fc
|
|
334
|
+
= (256 * EP) / 1.787725 [MHz]
|
|
335
|
+
= 143.03493 * EP [micro second]
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### Setting the envelope pattern (R13)
|
|
339
|
+
|
|
340
|
+
R13 sets the envelope pattern by the 4 low order bit data as shown in [Figure 5.8](#figure-58--setting-the-wave-forms-of-the-envelopes). The intervals of T specified in the figure correspond to the envelope cycle specified by R11 and R12.
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
##### _Figure 5.8 Setting the wave forms of the envelopes_
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
-------------------------------------------------
|
|
347
|
+
R13 | x x x x | B3 | B2 | B1 | B0 |
|
|
348
|
+
-------------------------------------------------
|
|
349
|
+
|
|
|
350
|
+
------------------------------------+
|
|
351
|
+
|
|
|
352
|
+
V
|
|
353
|
+
---------------------------------------------------------
|
|
354
|
+
| | :\ |
|
|
355
|
+
| 0 0 x x | __: \______________________ |
|
|
356
|
+
| | |
|
|
357
|
+
| | /: |
|
|
358
|
+
| 0 1 x x | __/ :______________________ |
|
|
359
|
+
| | |
|
|
360
|
+
| | :\ :\ :\ :\ :\ :\ :\ |
|
|
361
|
+
| 1 0 0 0 | __: \: \: \: \: \: \:_ |
|
|
362
|
+
| | |
|
|
363
|
+
| | :\ |
|
|
364
|
+
| 1 0 0 1 | __: \______________________ |
|
|
365
|
+
| | |
|
|
366
|
+
| | :\ / \ / \ / \ |
|
|
367
|
+
| 1 0 1 0 | __: \ / \ / \ / |
|
|
368
|
+
| | _____________________ |
|
|
369
|
+
| | :\ : |
|
|
370
|
+
| 1 0 1 1 | __: \: |
|
|
371
|
+
| | |
|
|
372
|
+
| | /: /: /: /: /: /: |
|
|
373
|
+
| 1 1 0 0 | __/ :/ :/ :/ :/ :/ :/ |
|
|
374
|
+
| | ______________________ |
|
|
375
|
+
| | / |
|
|
376
|
+
| 1 1 0 1 | __/ |
|
|
377
|
+
| | |
|
|
378
|
+
| | / \ / \ / \ |
|
|
379
|
+
| 1 1 1 0 | __/ \ / \ / \ / |
|
|
380
|
+
| | |
|
|
381
|
+
| | /: |
|
|
382
|
+
| 1 1 1 1 | __/ :______________________ |
|
|
383
|
+
| | |
|
|
384
|
+
---------------------------------------------------------
|
|
385
|
+
| |
|
|
386
|
+
+---+
|
|
387
|
+
T
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
#### I/O port (R14, R15)
|
|
391
|
+
|
|
392
|
+
R14 and R15 are the ports to send and receive 8-bit data in parallel. MSX uses these as the general-purpose I/O interface. For more information, see section 5.
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
<p> </p>
|
|
396
|
+
|
|
397
|
+
### 1.2 Access to the PSG
|
|
398
|
+
|
|
399
|
+
For access the PSG from assembly language programs, several BIOS routines described below are available.
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
<p> </p>
|
|
403
|
+
|
|
404
|
+
#### GICINI (0090H/MAIN) - PSG initialization
|
|
405
|
+
|
|
406
|
+
* **Input**: ---
|
|
407
|
+
* **Output**: ---
|
|
408
|
+
* **Function**: initializes PSG registers and does the initial settings of the work area in which PLAY statement of BASIC is executed. Each register of PSG is set to the value as shown in [Figure 5.9](#figure-59--initial-values-of-psg-registers).
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
##### _Figure 5.9 Initial values of PSG registers_
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
-----------------------------------------------------------------------------
|
|
415
|
+
| Bit | | | | | | | | |
|
|
416
|
+
| | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
|
417
|
+
| Register | | | | | | | | |
|
|
418
|
+
|---------------------------+-----------------------------------------------|
|
|
419
|
+
| R0 | Channel A | 0 1 0 1 0 1 0 1 |
|
|
420
|
+
|----------| |-----------------------------------------------|
|
|
421
|
+
| R1 | frequency | 0 0 0 0 0 0 0 0 |
|
|
422
|
+
|----------+----------------+-----------------------------------------------|
|
|
423
|
+
| R2 | Channel B | 0 0 0 0 0 0 0 0 |
|
|
424
|
+
|----------| |-----------------------------------------------|
|
|
425
|
+
| R3 | frequency | 0 0 0 0 0 0 0 0 |
|
|
426
|
+
|----------+----------------+-----------------------------------------------|
|
|
427
|
+
| R4 | Channel C | 0 0 0 0 0 0 0 0 |
|
|
428
|
+
|----------| |-----------------------------------------------|
|
|
429
|
+
| R5 | frequency | 0 0 0 0 0 0 0 0 |
|
|
430
|
+
|----------+----------------+-----------------------------------------------|
|
|
431
|
+
| R6 | Noise frequency| 0 0 0 0 0 0 0 0 |
|
|
432
|
+
|----------+----------------+-----------------------------------------------|
|
|
433
|
+
| R7 | Channel setting| 1 0 1 1 1 0 0 0 |
|
|
434
|
+
|----------+----------------+-----------------------------------------------|
|
|
435
|
+
| R8 | Chan. A volume | 0 0 0 0 0 0 0 0 |
|
|
436
|
+
|----------+----------------+-----------------------------------------------|
|
|
437
|
+
| R9 | Chan. B volume | 0 0 0 0 0 0 0 0 |
|
|
438
|
+
|----------+----------------+-----------------------------------------------|
|
|
439
|
+
| R10 | Chan. C volume | 0 0 0 0 0 0 0 0 |
|
|
440
|
+
|----------+----------------+-----------------------------------------------|
|
|
441
|
+
| R11 | | 0 0 0 0 1 0 1 1 |
|
|
442
|
+
|----------| Envelope Cycle |-----------------------------------------------|
|
|
443
|
+
| R12 | | 0 0 0 0 0 0 0 0 |
|
|
444
|
+
|----------+----------------+-----------------------------------------------|
|
|
445
|
+
| R13 | Env. pattern | 0 0 0 0 0 0 0 0 |
|
|
446
|
+
|----------+----------------+-----------------------------------------------|
|
|
447
|
+
| R14 | I/O port A | |
|
|
448
|
+
|----------+----------------+-----------------------------------------------|
|
|
449
|
+
| R15 | I/O port B | |
|
|
450
|
+
-----------------------------------------------------------------------------
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
<p> </p>
|
|
455
|
+
|
|
456
|
+
#### WRTPSG (0093H/MAIN) - writing data in PSG registers
|
|
457
|
+
|
|
458
|
+
* **Input**:
|
|
459
|
+
* A ⟵ PSG register number
|
|
460
|
+
* E ⟵ data to be written
|
|
461
|
+
* **Output**: ---
|
|
462
|
+
* **Function**: writes the contents of the E register in the PSG register whose number is specified by the A register.
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
<p> </p>
|
|
466
|
+
|
|
467
|
+
#### RDPSG (0096H/MAIN) - reading PSG register data
|
|
468
|
+
|
|
469
|
+
* **Input**: A ⟵ PSG register number
|
|
470
|
+
* **Output**: A ⟵ contents of the specified register
|
|
471
|
+
* **Function**: reads the contents of PSG register whose number is specified by the A register and stores the value in the A register.
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
<p> </p>
|
|
475
|
+
|
|
476
|
+
#### STRTMS (0099H/MAIN) - starting the music
|
|
477
|
+
|
|
478
|
+
* **Input**: (QUEUE) ⟵ MML which is translated into the intermediate language
|
|
479
|
+
* **Output**: ---
|
|
480
|
+
* **Function**: examines whether the music is played as the background task, and plays the music which is set in the queue, if the music has not yet been played.
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
##### _List 5.1 Single tone generation_
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
;************************************************
|
|
488
|
+
;
|
|
489
|
+
; List 5.1 440 Hz tone
|
|
490
|
+
;
|
|
491
|
+
;************************************************
|
|
492
|
+
;
|
|
493
|
+
WRTPSG EQU 0093H
|
|
494
|
+
|
|
495
|
+
ORG 0B000H
|
|
496
|
+
|
|
497
|
+
;----- program start -----
|
|
498
|
+
|
|
499
|
+
LD A,7 ;Select Channel
|
|
500
|
+
LD E,00111110B ;Channel A Tone := On
|
|
501
|
+
CALL WRTPSG
|
|
502
|
+
|
|
503
|
+
LD A,8 ;Set Volume
|
|
504
|
+
LD E,10
|
|
505
|
+
CALL WRTPSG
|
|
506
|
+
|
|
507
|
+
LD A,0 ;Set Fine Tune Channel A
|
|
508
|
+
LD E,0FEH ;Data 0FEH
|
|
509
|
+
CALL WRTPSG
|
|
510
|
+
|
|
511
|
+
LD A,1 ;Set Coarse Tune Channel A
|
|
512
|
+
LD E,0 ;Data 0H
|
|
513
|
+
CALL WRTPSG
|
|
514
|
+
|
|
515
|
+
RET
|
|
516
|
+
|
|
517
|
+
END
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
<p> </p>
|
|
521
|
+
|
|
522
|
+
### 1.3 Tone Generation by 1-bit Sound Port
|
|
523
|
+
|
|
524
|
+
MSX has another sound generator in addition to the PSG. This is a simple one that generates sound by turning ON/OFF the 1-bit I/O port output repeatedly using software.
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
##### _Figure 5.10 1-bit sound port_
|
|
528
|
+
|
|
529
|
+
```
|
|
530
|
+
bit 7 6 5 4 3 2 1 0
|
|
531
|
+
-----------------------------------------
|
|
532
|
+
| . | | | | | | | |
|
|
533
|
+
--+--------------------------------------
|
|
534
|
+
| PPI port C (I/O address 0AAH)
|
|
535
|
+
|
|
|
536
|
+
|
|
|
537
|
+
:::::::::::: V
|
|
538
|
+
: PSG : ---------
|
|
539
|
+
: output :::::::>| MIX |
|
|
540
|
+
:::::::::::: ---------
|
|
541
|
+
|
|
|
542
|
+
V
|
|
543
|
+
-----
|
|
544
|
+
/ \ Speaker
|
|
545
|
+
---------
|
|
546
|
+
/ : \
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
<p> </p>
|
|
550
|
+
|
|
551
|
+
### 1.4 Access to 1-bit Sound Port
|
|
552
|
+
|
|
553
|
+
To access to the 1-bit sound port, the following BIOS routine is offered.
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
#### CHGSND (0135H/MAIN)
|
|
557
|
+
|
|
558
|
+
* **Input**: A ⟵ specification of ON/OFF (0 = OFF, others = ON)
|
|
559
|
+
* **Output**: ---
|
|
560
|
+
* **Function**: calling this routine with setting 0 in the A register turns the bit of the sound port OFF; calling it with another value turns it ON.
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
##### _List 5.2 Reading from cassette tape_
|
|
564
|
+
|
|
565
|
+
```
|
|
566
|
+
;********************************************************
|
|
567
|
+
;
|
|
568
|
+
; List 5.2 Read from cassette tape
|
|
569
|
+
;
|
|
570
|
+
; Set music tape into tape-recorder
|
|
571
|
+
; and run this program.
|
|
572
|
+
; Then your MSX will replay it.
|
|
573
|
+
;
|
|
574
|
+
;********************************************************
|
|
575
|
+
;
|
|
576
|
+
CHGSNG EQU 0135H
|
|
577
|
+
STMOTR EQU 00F3H
|
|
578
|
+
RDPSG EQU 0096H
|
|
579
|
+
BREAKX EQU 00B7H
|
|
580
|
+
|
|
581
|
+
ORG 0B000H
|
|
582
|
+
|
|
583
|
+
;----- program start ----- Note: Play tape using 1-bit sound port.
|
|
584
|
+
|
|
585
|
+
START: LD A,1 ;motor on
|
|
586
|
+
CALL STMOTR
|
|
587
|
+
|
|
588
|
+
LBL01: LD A,14 ;register 14
|
|
589
|
+
CALL RDPSG ;read PSG
|
|
590
|
+
|
|
591
|
+
AND 80H ;check CSAR
|
|
592
|
+
CALL CHGSNG ;change SOUND PORT
|
|
593
|
+
|
|
594
|
+
CALL BREAKX ;check Ctrl-STOP
|
|
595
|
+
JR NC,LBL01
|
|
596
|
+
|
|
597
|
+
XOR A ;stop cassette motor
|
|
598
|
+
CALL STMOTR
|
|
599
|
+
RET
|
|
600
|
+
|
|
601
|
+
END
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
<p> </p>
|
|
606
|
+
|
|
607
|
+
## 2. CASSETTE INTERFACE
|
|
608
|
+
|
|
609
|
+
Cassette tape recorders are the least expensive external storage devices available for the MSX. Knowledge of the cassette interface is required to treat information in cassette tapes within assembly language programs. This section offers the necessary information.
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
<p> </p>
|
|
613
|
+
|
|
614
|
+
### 2.1 Baud Rate
|
|
615
|
+
|
|
616
|
+
The following two baud rates can be used by the MSX cassette interface (see [Table 5.2](#table-52--msx-baud-rate)). When BASIC is invoked, 1200bps is set by default.
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
##### _Table 5.2 MSX baud rate_
|
|
620
|
+
|
|
621
|
+
```
|
|
622
|
+
------------------------------------------------
|
|
623
|
+
| Baud rate | Characteristics |
|
|
624
|
+
|-------------+--------------------------------|
|
|
625
|
+
| 1200 bps | Low speed / high reliability |
|
|
626
|
+
|-------------+--------------------------------|
|
|
627
|
+
| 2400 bps | High speed / low reliability |
|
|
628
|
+
------------------------------------------------
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
The baud rate is specified by the fourth parameter of the SCREEN instruction or the second parameter of the CSAVE instruction. Once the baud rate is set, it stays at that value.
|
|
632
|
+
|
|
633
|
+
```
|
|
634
|
+
SCREEN ,,,<baud rate>
|
|
635
|
+
CSAVE "filename",<baud rate>
|
|
636
|
+
(<baud rate> is 1 for 1200bps, 2 for 2400 bps)
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
<p> </p>
|
|
640
|
+
|
|
641
|
+
### 2.2 One bit composition
|
|
642
|
+
|
|
643
|
+
One bit data, the basis of I/O, is recorded as shown in [Figure 5.11](#figure-511--one-bit-composition). The pulse width is determined by counting the T-STATE of the CPU, so, while the cassette interface is active, any interrupt is inhibited.
|
|
644
|
+
|
|
645
|
+
The bit data from the cassette can be read through the seventh bit of port B of the general-purpose I/O interface (register 15 of the PSG). This function was used in the program example of [List 5.3](list-53--listing-names-of-files-saved-in-the-cassette), section 1 of chapter 5.
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
##### _Figure 5.11 One bit composition_
|
|
649
|
+
|
|
650
|
+
```
|
|
651
|
+
--------------------------------------------------------------
|
|
652
|
+
| Baud rate | Bit | Wave form |
|
|
653
|
+
|-----------+-------+----------------------------------------|
|
|
654
|
+
| | | : ----------- |
|
|
655
|
+
| | 0 | : | | (1200Hz x 1) |
|
|
656
|
+
| 1200 | | :_________| | |
|
|
657
|
+
| |-------+--:-------------------------------------|
|
|
658
|
+
| baud | | : ------ ------ |
|
|
659
|
+
| | 1 | : | | | | (2400Hz x 2) |
|
|
660
|
+
| | | :____| |____| | |
|
|
661
|
+
|-----------+-------+--:-------------------------------------|
|
|
662
|
+
| | | : ------ : |
|
|
663
|
+
| | 0 | : | | : (2400Hz x 1) |
|
|
664
|
+
| 2400 | | :____| | : |
|
|
665
|
+
| |-------+--:-------------------:-----------------|
|
|
666
|
+
| baud | | : --- --- : |
|
|
667
|
+
| | 1 | : | | | | : (4800Hz x 2) |
|
|
668
|
+
| | | :__| |__| | : |
|
|
669
|
+
-----------------------:--:-:----:---------:------------------
|
|
670
|
+
| : : : | 2963 T-states (833 micro-sec)
|
|
671
|
+
+--:-:----:---------+
|
|
672
|
+
| : : | 1491 T-states (417 micro-sec)
|
|
673
|
+
+--:-:----+
|
|
674
|
+
| : | 746 T-states (208 micro-sec)
|
|
675
|
+
+--:-+
|
|
676
|
+
| | 373 T-states (104 micro-sec)
|
|
677
|
+
+--+
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
<p> </p>
|
|
681
|
+
|
|
682
|
+
### 2.3 One byte composition
|
|
683
|
+
|
|
684
|
+
One byte data is recorded in the array of bits as shown in [Figure 5.12](#figure-512--one-byte-composition). There is one "0" bit as the start bit, followed by the 8-bit data body from LSB to MSX and by two "1" bit as the stop bits, so 11 bits are used.
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
##### _Figure 5.12 One byte composition_
|
|
688
|
+
|
|
689
|
+
```
|
|
690
|
+
LSB MSB
|
|
691
|
+
-------------------------------------------------------------------------
|
|
692
|
+
| 0 | X | X | X | X | X | X | X | X | 1 : 1 |
|
|
693
|
+
-------------------------------------------------------------------------
|
|
694
|
+
| | | |
|
|
695
|
+
+-----+-----------------------------------------------+-----------+
|
|
696
|
+
Start bit Data Stop bit
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
<p> </p>
|
|
700
|
+
|
|
701
|
+
### 2.4 Header Composition
|
|
702
|
+
|
|
703
|
+
The header is the portion where the signal of the specific frequency is recorded on the tape for a certain period. This allows the cassette tape speed to stabilize after it is started, or divides two files. There is a long header and a short header. The long header is used to wait until the motor is stabilized. The baud rate at reading the tape is determined by reading the long header. The short header is used to divide file bodies. [Table 5.3](#table-53--header-composition) shows the compositions of both.
|
|
704
|
+
|
|
705
|
+
|
|
706
|
+
##### _Table 5.3 Header composition_
|
|
707
|
+
|
|
708
|
+
```
|
|
709
|
+
------------------------------------------------------------------
|
|
710
|
+
| Baud rate | Header | Header composition |
|
|
711
|
+
|-------------+--------------+-----------------------------------|
|
|
712
|
+
| | Long header | 2400 Hz x 16000 (about 6.7 sec) |
|
|
713
|
+
| 1200 baud |--------------+-----------------------------------|
|
|
714
|
+
| | Short header | 2400 Hz x 4000 (about 1.7 sec) |
|
|
715
|
+
|-------------+--------------+-----------------------------------|
|
|
716
|
+
| | Long header | 4800 Hz x 32000 (about 6.7 sec) |
|
|
717
|
+
| 2400 baud |--------------+-----------------------------------|
|
|
718
|
+
| | Short header | 4800 Hz x 8000 (about 1.7 sec) |
|
|
719
|
+
------------------------------------------------------------------
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
<p> </p>
|
|
723
|
+
|
|
724
|
+
### 2.5 File Formats
|
|
725
|
+
|
|
726
|
+
MSX BASIC supports the following three kinds of cassette format files.
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
_(1) BASIC text file_
|
|
730
|
+
|
|
731
|
+
BASIC programs saved with the CSAVE command are recorded in this format. The file is divided into the preceding file header and the succeeding the body.
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
##### _Figure 5.13 Binary file format_
|
|
735
|
+
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
6.7 sec 10 bytes 6 bytes
|
|
739
|
+
-------------------------------------------------------------------------
|
|
740
|
+
| | | |
|
|
741
|
+
| Long header | 0D3H x 10 | File name |
|
|
742
|
+
| | | |
|
|
743
|
+
-------------------------------------------------------------------------
|
|
744
|
+
| |
|
|
745
|
+
+----------+ +------------------------------------+
|
|
746
|
+
| |
|
|
747
|
+
-----------------------------------------------------------------------------
|
|
748
|
+
| | File header | | File body | |
|
|
749
|
+
-----------------------------------------------------------------------------
|
|
750
|
+
| |
|
|
751
|
+
+-------------------------------+ +------+
|
|
752
|
+
| |
|
|
753
|
+
-------------------------------------\ \--------------------------------
|
|
754
|
+
| Short | / / | |
|
|
755
|
+
| header | BASIC program \ \ | 00H x 7 |
|
|
756
|
+
| | / / | |
|
|
757
|
+
-------------------------------------\ \--------------------------------
|
|
758
|
+
1.7 sec Any length 7 bytes
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
In the file header, ten bytes each of the value 0D3H follow after the long header and six bytes containing the file name are placed after them. In the file body, program body follows the short header and the end of the file is indicated by seven bytes of 00H.
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
_(2) ASCII text file_
|
|
765
|
+
|
|
766
|
+
BASIC programs saved in ASCII format by the SAVE command and data files created by the OPEN command are recorded in this format.
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
##### _Figure 5.14 ASCII file format_
|
|
770
|
+
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
6.7 sec 10 bytes 6 bytes
|
|
774
|
+
-------------------------------------------------------------------------
|
|
775
|
+
| | | |
|
|
776
|
+
| Long header | 0EAH x 10 | File name |
|
|
777
|
+
| | | |
|
|
778
|
+
-------------------------------------------------------------------------
|
|
779
|
+
| |
|
|
780
|
+
+----------+ +------------------------------------+
|
|
781
|
+
| |
|
|
782
|
+
-----------------------------------------------------------------------------
|
|
783
|
+
| | File header | | File body | |
|
|
784
|
+
-----------------------------------------------------------------------------
|
|
785
|
+
| |
|
|
786
|
+
+-------------------------------+ +------+
|
|
787
|
+
| |
|
|
788
|
+
-----------------------------------------------\ \----------------------
|
|
789
|
+
| | | | / / | Last |
|
|
790
|
+
| Block 1 | Block 2 | Block 3 | ..... \ \ .... | block |
|
|
791
|
+
| | | | / / | . |
|
|
792
|
+
-----------------------------------------------\ \------------+---------
|
|
793
|
+
| | |
|
|
794
|
+
+-----------+ +-----------+ CTRL+Z (EOF)
|
|
795
|
+
| | is included in data
|
|
796
|
+
------------------------------------------------
|
|
797
|
+
| Short | |
|
|
798
|
+
| header | Data | .....
|
|
799
|
+
| | |
|
|
800
|
+
------------------------------------------------
|
|
801
|
+
1.7 sec 256 bytes
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
_(3) Machine code file_
|
|
805
|
+
|
|
806
|
+
Machine code files saved by the BSAVE command are recorded in the following format. In the file header, 10 bytes each of the value 0D0H follow after the long header and 6 bytes containing the file name are placed after them.
|
|
807
|
+
|
|
808
|
+
In the file body, the starting address, the end address, and the entry address are recorded in order after the short header, and the machine codes follow after them. Since the amount of data can be calculated from the starting and ending addresses, there is no special mark for the end of the file. The entry address is the address where the program is executed when the R option of the BLOAD command is used.
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
##### _Figure 5.15 Machine code file format_
|
|
812
|
+
|
|
813
|
+
```
|
|
814
|
+
6.7 sec 10 bytes 6 bytes
|
|
815
|
+
-------------------------------------------------------------------------
|
|
816
|
+
| | | |
|
|
817
|
+
| Long header | 0D0H x 10 | File name |
|
|
818
|
+
| | | |
|
|
819
|
+
-------------------------------------------------------------------------
|
|
820
|
+
| |
|
|
821
|
+
+----------+ +------------------------------------+
|
|
822
|
+
| |
|
|
823
|
+
-----------------------------------------------------------------------------
|
|
824
|
+
| | File header | | File body | |
|
|
825
|
+
-----------------------------------------------------------------------------
|
|
826
|
+
| |
|
|
827
|
+
+-------------------------------+ +------+
|
|
828
|
+
| |
|
|
829
|
+
-------------------------------------------------------------------------
|
|
830
|
+
| Short | Top | End | Starting | |
|
|
831
|
+
| header | address | address | address | Program body |
|
|
832
|
+
| | | | | |
|
|
833
|
+
-------------------------------------------------------------------------
|
|
834
|
+
1.7 sec 2 bytes 2 bytes 2 bytes
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
<p> </p>
|
|
838
|
+
|
|
839
|
+
### 2.6 Access to cassette files
|
|
840
|
+
|
|
841
|
+
The following BIOS routines are offered to access cassette files.
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
<p> </p>
|
|
845
|
+
|
|
846
|
+
#### TAPION (00E1H/MAIN) - OPEN for read
|
|
847
|
+
|
|
848
|
+
* **Input**: ---
|
|
849
|
+
* **Output**: CY flag = ON at abnormal terminations
|
|
850
|
+
* **Function**: starts the motor of the tape recorder and reads the long header or the short headet. At the same time, the baud rate in which the file is recorded is detected and the work area is set according to it. Interrupts are inhibited.
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
<p> </p>
|
|
854
|
+
|
|
855
|
+
#### TAPIN (00E4H/MAIN) - read one byte
|
|
856
|
+
|
|
857
|
+
* **Input**: ---
|
|
858
|
+
* **Output**:
|
|
859
|
+
* A ⟵ data which has been read
|
|
860
|
+
* CY flag = ON at abnormal terminations
|
|
861
|
+
* **Function**: reads one byte of data from the tape and stores it in the A register.
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
<p> </p>
|
|
865
|
+
|
|
866
|
+
#### TAPIOF (00E7H/MAIN) - CLOSE for read
|
|
867
|
+
|
|
868
|
+
* **Input**: ---
|
|
869
|
+
* **Output**: ---
|
|
870
|
+
* **Function**: ends reading from the tape. At this point, interrupts are allowed.
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
<p> </p>
|
|
874
|
+
|
|
875
|
+
#### TAPOON (00EAH/MAIN) - OPEN for write
|
|
876
|
+
|
|
877
|
+
* **Input**: A ⟵ type of header (0 = short header, others = long header)
|
|
878
|
+
* **Output**: CY flag = ON at abnormal terminations
|
|
879
|
+
* **Function**: starts the motor of the tape recorder and writes the header of the type specified in the A register to the tape. Interrupts are inhibited.
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
<p> </p>
|
|
883
|
+
|
|
884
|
+
#### TAPOUT (00EDH/MAIN) - write one byte
|
|
885
|
+
|
|
886
|
+
* **Input**: A ⟵ data to be written
|
|
887
|
+
* **Output**: CY flag = ON at abnormal terminations
|
|
888
|
+
* **Function**: writes the contents of the A register to the tape.
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
<p> </p>
|
|
892
|
+
|
|
893
|
+
#### TAPOOF (00F0H/MAIN) - CLOSE writing
|
|
894
|
+
|
|
895
|
+
* **Input**: ---
|
|
896
|
+
* **Output**: ---
|
|
897
|
+
* **Function**: ends writing the tape. At this point, interrupts are allowed.
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
<p> </p>
|
|
901
|
+
|
|
902
|
+
#### STMOTR (00F3/MAIN) - specify the actions of the motor
|
|
903
|
+
|
|
904
|
+
* **Input**: A ⟵ action (0 = stop, 1 = start, 255 = reverse the current status)
|
|
905
|
+
* **Output**: ---
|
|
906
|
+
* **Function**: sets the status of the motor according to the value specified in the A register.
|
|
907
|
+
|
|
908
|
+
When READ/WRITE routines for the cassette files are created using these BIOS calls, only READ or WRITE, without any other action, should be done. For example, reading data from the tape and displaying it on the CRT might cause a READ error.
|
|
909
|
+
|
|
910
|
+
[List 5.3](#list-53--listing-names-of-files-saved-in-the-cassette) is a sample program which uses BIOS routines.
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
##### _List 5.3 Listing names of files saved in the cassette_
|
|
914
|
+
|
|
915
|
+
```
|
|
916
|
+
;************************************************************
|
|
917
|
+
;
|
|
918
|
+
; List 5.3 Cassette files
|
|
919
|
+
;
|
|
920
|
+
; Set cassette tape into recorder and run this program.
|
|
921
|
+
; Then all the names and attributes of the programs
|
|
922
|
+
; in that tape will be listed.
|
|
923
|
+
;
|
|
924
|
+
;************************************************************
|
|
925
|
+
;
|
|
926
|
+
CHPUT EQU 00A2H
|
|
927
|
+
TAPION EQU 00E1H
|
|
928
|
+
TAPIN EQU 00E4H
|
|
929
|
+
TAPIOF EQU 00E7H
|
|
930
|
+
|
|
931
|
+
ORG 0C000H
|
|
932
|
+
|
|
933
|
+
;----- program start ----- Note: View program names on cassette tape.
|
|
934
|
+
|
|
935
|
+
START: CALL TAPION ;motor on and read header
|
|
936
|
+
|
|
937
|
+
LD B,16
|
|
938
|
+
LD HL,WORK ;work area address
|
|
939
|
+
LBL01: PUSH HL
|
|
940
|
+
PUSH BC
|
|
941
|
+
CALL TAPIN ;read a byte of data from tape
|
|
942
|
+
POP BC
|
|
943
|
+
POP HL
|
|
944
|
+
JR C,ERROR ;set carry flag if read error
|
|
945
|
+
LD (HL),A
|
|
946
|
+
INC HL
|
|
947
|
+
DJNZ LBL01
|
|
948
|
+
|
|
949
|
+
LD HL,FILNAM ;write file name
|
|
950
|
+
CALL PUTSTR
|
|
951
|
+
LD HL,WORK+10
|
|
952
|
+
CALL PUTSTR
|
|
953
|
+
CALL CRLF
|
|
954
|
+
|
|
955
|
+
LD A,(WORK) ;check file attributes
|
|
956
|
+
|
|
957
|
+
LD HL,BINFIL
|
|
958
|
+
CP 0D3H ;check binary file
|
|
959
|
+
JR Z,LBL03
|
|
960
|
+
|
|
961
|
+
LD HL,ASCFIL
|
|
962
|
+
CP 0EAH ;check ascii file
|
|
963
|
+
JR Z,LBL03
|
|
964
|
+
|
|
965
|
+
LD HL,MACFIL
|
|
966
|
+
CP 0D0H ;check machine code file
|
|
967
|
+
JR Z,LBL03
|
|
968
|
+
|
|
969
|
+
ERROR: LD HL,ERRSTR
|
|
970
|
+
|
|
971
|
+
LBL03: CALL PUTSTR
|
|
972
|
+
CALL TAPIOF
|
|
973
|
+
RET
|
|
974
|
+
|
|
975
|
+
;----- put CRLF -----
|
|
976
|
+
|
|
977
|
+
CRLF: LD HL,STCRLF
|
|
978
|
+
CALL PUTSTR
|
|
979
|
+
RET
|
|
980
|
+
|
|
981
|
+
;----- put string -----
|
|
982
|
+
|
|
983
|
+
PUTSTR: LD A,(HL) ;get a character from strings
|
|
984
|
+
CP '$' ;check end of strings
|
|
985
|
+
RET Z
|
|
986
|
+
CALL CHPUT ;write a character to CRT
|
|
987
|
+
INC HL
|
|
988
|
+
JR PUTSTR
|
|
989
|
+
|
|
990
|
+
;----- strings data -----
|
|
991
|
+
|
|
992
|
+
FILNAM: DB 'FILE NAME :$'
|
|
993
|
+
ASCFIL: DB 'ASCII FILE',0DH,0AH,'$'
|
|
994
|
+
BINFIL: DB 'BINARY FILE',0DH,0Ah,'$'
|
|
995
|
+
MACFIL: DB 'BSAVE FILE',0DH,0AH,'$'
|
|
996
|
+
ERRSTR: DB 'TAPE READ ERROR',0DH,0AH,'$'
|
|
997
|
+
STCRLF: DB 0DH,0AH,'$'
|
|
998
|
+
|
|
999
|
+
;----- WORK AREA -----
|
|
1000
|
+
|
|
1001
|
+
WORK: DS 16,0
|
|
1002
|
+
DB '$' ;end of strings
|
|
1003
|
+
|
|
1004
|
+
END
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
|
|
1008
|
+
<p> </p>
|
|
1009
|
+
|
|
1010
|
+
## 3. KEYBOARD INTERFACE
|
|
1011
|
+
|
|
1012
|
+
Altough the MSX2 keyboard has the same design as that of the MSX1, it is more convenient to use because of the Romand-to-kana translation available for kana input. This section describes the keyboard interface of the MSX2.
|
|
1013
|
+
|
|
1014
|
+
Descriptions of the key aarangement are based on the Japanese keyboard standard; note that data is slightly different for the international MSX versions.
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
<p> </p>
|
|
1018
|
+
|
|
1019
|
+
### 3.1 Key Scanning
|
|
1020
|
+
|
|
1021
|
+
MSX uses the key matrices as shown in [Figure 5.16](#figure-516--msx-usa-version-key-matrix), [Figure 5.17](#figure-517--msx-international-version-key-matrix) and [Figure 5.17B](#figure-517b--msx-european-version-key-matrix). The key status can be obtained in real time by examining this key matrix and is available for reading input.
|
|
1022
|
+
|
|
1023
|
+
Scanning the key matrix is done by the following BIOS routine.
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
#### SNSMAT (0141H/MAIN) - reads the specified line of the key matrix
|
|
1027
|
+
|
|
1028
|
+
* **Input**: A ⟵ key matrix line to be read (0 to 10)
|
|
1029
|
+
* **Output**: A ⟵ status of the specified line of the key matrix (when pressed, the bit of the key is 0)
|
|
1030
|
+
* **Function**: specifies a line of the key matrix shown in [Figure 5.16](#figure-516--msx-usa-version-key-matrix), [Figure 5.17](#figure-517--msx-international-version-key-matrix) or [Figure 5.17B](#figure-517b--msx-european-version-key-matrix) and stores its status in the A register. The bit corresponding with the key being pressed is "0", and "1" for the key not being pressed.
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
##### _Figure 5.16 MSX USA version key matrix_
|
|
1034
|
+
|
|
1035
|
+
```
|
|
1036
|
+
MSB LSB
|
|
1037
|
+
7 6 5 4 3 2 1 0
|
|
1038
|
+
-----------------------------------------------------------------
|
|
1039
|
+
0 | B | L | | / | 1 | S | X | , |
|
|
1040
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1041
|
+
1 | V | J | = | ` | Q | A | C | N |
|
|
1042
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1043
|
+
2 | G | 8 | 0 | ] | W | F | Z | M |
|
|
1044
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1045
|
+
3 | T | I | ~ | ; | 2 | D | U | \ |
|
|
1046
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1047
|
+
4 | 6 | K | P | ' | 3 | R | 7 | H |
|
|
1048
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1049
|
+
5 | 5 | 0 | 9 | [ | 4 | E | Y | . |
|
|
1050
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1051
|
+
6 | F3 | F2 | F1 | CODE | CAPS | GRAPH | CTRL | SHIFT |
|
|
1052
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1053
|
+
7 | RETURN| SELECT| BS | STOP | TAB | ESC | F5 | F4 |
|
|
1054
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1055
|
+
8 | RIGHT | DOWN | UP | LEFT | DEL | INS | HOME | SPACE |
|
|
1056
|
+
-----------------------------------------------------------------
|
|
1057
|
+
|
|
1058
|
+
[TEN KEY]
|
|
1059
|
+
-----------------------------------------------------------------
|
|
1060
|
+
9 | 4 | 3 | 2 | 1 | 0 | option| option| option|
|
|
1061
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1062
|
+
10 | . | , | - | 9 | 8 | 7 | 6 | 5 |
|
|
1063
|
+
-----------------------------------------------------------------
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
##### _Figure 5.17 MSX International version key matrix_
|
|
1067
|
+
|
|
1068
|
+
```
|
|
1069
|
+
MSB LSB
|
|
1070
|
+
7 6 5 4 3 2 1 0
|
|
1071
|
+
-----------------------------------------------------------------
|
|
1072
|
+
0 | B | L |deadkey| / | 1 | S | X | , |
|
|
1073
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1074
|
+
1 | V | J | ^ | ] | Q | A | C | N |
|
|
1075
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1076
|
+
2 | G | 8 | 0 | [ | W | F | Z | M |
|
|
1077
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1078
|
+
3 | T | I | ~ | ; | 2 | D | U | \ |
|
|
1079
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1080
|
+
4 | 6 | K | P | : | 3 | R | 7 | H |
|
|
1081
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1082
|
+
5 | 5 | 0 | 9 | @ | 4 | E | Y | . |
|
|
1083
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1084
|
+
6 | F3 | F2 | F1 | CODE | CAPS | GRAPH | CTRL | SHIFT |
|
|
1085
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1086
|
+
7 | RETURN| SELECT| BS | STOP | TAB | ESC | F5 | F4 |
|
|
1087
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1088
|
+
8 | RIGHT | DOWN | UP | LEFT | DEL | INS | HOME | SPACE |
|
|
1089
|
+
-----------------------------------------------------------------
|
|
1090
|
+
|
|
1091
|
+
[TEN KEY]
|
|
1092
|
+
-----------------------------------------------------------------
|
|
1093
|
+
9 | 4 | 3 | 2 | 1 | 0 | option| option| option|
|
|
1094
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1095
|
+
10 | . | , | - | 9 | 8 | 7 | 6 | 5 |
|
|
1096
|
+
-----------------------------------------------------------------
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
##### _Figure 5.17B MSX European version key matrix_
|
|
1100
|
+
|
|
1101
|
+
```
|
|
1102
|
+
MSB LSB
|
|
1103
|
+
7 6 5 4 3 2 1 0
|
|
1104
|
+
-----------------------------------------------------------------
|
|
1105
|
+
0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
|
1106
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1107
|
+
1 | ; | ] | [ | \ | = | - | 9 | 8 |
|
|
1108
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1109
|
+
2 | B | A | accent| / | . | , | ` | ' |
|
|
1110
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1111
|
+
3 | J | I | H | G | F | E | D | C |
|
|
1112
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1113
|
+
4 | R | Q | P | O | N | M | L | K |
|
|
1114
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1115
|
+
5 | Z | Y | X | W | V | U | T | S |
|
|
1116
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1117
|
+
6 | F3 | F2 | F1 | CODE | CAPS | GRAPH | CTRL | SHIFT |
|
|
1118
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1119
|
+
7 | RETURN| SELECT| BS | STOP | TAB | ESC | F5 | F4 |
|
|
1120
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1121
|
+
8 | RIGHT | DOWN | UP | LEFT | DEL | INS | HOME | SPACE |
|
|
1122
|
+
-----------------------------------------------------------------
|
|
1123
|
+
|
|
1124
|
+
[TEN KEY]
|
|
1125
|
+
-----------------------------------------------------------------
|
|
1126
|
+
9 | 4 | 3 | 2 | 1 | 0 | option| option| option|
|
|
1127
|
+
|-------+-------+-------+-------+-------+-------+-------+-------|
|
|
1128
|
+
10 | . | , | - | 9 | 8 | 7 | 6 | 5 |
|
|
1129
|
+
-----------------------------------------------------------------
|
|
1130
|
+
```
|
|
1131
|
+
|
|
1132
|
+
##### _List 5.4 Use of the key scanning routine_
|
|
1133
|
+
|
|
1134
|
+
```
|
|
1135
|
+
;********************************************************
|
|
1136
|
+
;
|
|
1137
|
+
; List 5.4 scan key-matrix and display it
|
|
1138
|
+
;
|
|
1139
|
+
;********************************************************
|
|
1140
|
+
;
|
|
1141
|
+
CHPUT EQU 00A2H
|
|
1142
|
+
BREAKX EQU 00B7H
|
|
1143
|
+
POSIT EQU 00C6H
|
|
1144
|
+
SNSMAT EQU 0141H
|
|
1145
|
+
|
|
1146
|
+
ORG 0B000H
|
|
1147
|
+
|
|
1148
|
+
;----- program start ----- Note: read key matrix and display key
|
|
1149
|
+
pattern.
|
|
1150
|
+
|
|
1151
|
+
SCAN: LD C,0 ;C := line of key matrix
|
|
1152
|
+
|
|
1153
|
+
SC1: LD A,C
|
|
1154
|
+
CALL SNSMAT ;Read key matrix
|
|
1155
|
+
|
|
1156
|
+
LD B,8
|
|
1157
|
+
LD HL,BUF ;HL : = buffer address
|
|
1158
|
+
SC2: LD D,'.'
|
|
1159
|
+
RLA ;Check bit
|
|
1160
|
+
JR C,SC3
|
|
1161
|
+
LD D,'#'
|
|
1162
|
+
|
|
1163
|
+
SC3: LD (HL),D ;store '.' or '#' to buffer
|
|
1164
|
+
INC HL
|
|
1165
|
+
DJNZ SC2
|
|
1166
|
+
|
|
1167
|
+
LD H,05H ;x := 5
|
|
1168
|
+
LD L,C ;y := C+1
|
|
1169
|
+
INC L
|
|
1170
|
+
CALL POSIT ;set cursor position
|
|
1171
|
+
|
|
1172
|
+
LD B,8 ;put out bit patterns to CRT
|
|
1173
|
+
LD HL,BUF
|
|
1174
|
+
SC4: LD A,(HL)
|
|
1175
|
+
CALL CHPUT
|
|
1176
|
+
INC HL
|
|
1177
|
+
DJNZ SC4
|
|
1178
|
+
|
|
1179
|
+
CALL BREAKX ;check Ctrl-STOP
|
|
1180
|
+
RET C
|
|
1181
|
+
|
|
1182
|
+
INC C ;line No. increment
|
|
1183
|
+
LD A,C
|
|
1184
|
+
CP 09
|
|
1185
|
+
JR NZ,SC1
|
|
1186
|
+
JR SCAN
|
|
1187
|
+
|
|
1188
|
+
;----- work area -----
|
|
1189
|
+
|
|
1190
|
+
BUF: DS 8
|
|
1191
|
+
|
|
1192
|
+
END
|
|
1193
|
+
```
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
<p> </p>
|
|
1197
|
+
|
|
1198
|
+
### 3.2 Character Input
|
|
1199
|
+
|
|
1200
|
+
MSX scans the key matrix every 1/60 second using the timer interrupt and, when a key is pressed, stores the character code in the keyboard buffer as shown in [Figure 5.18](#figure-518--keyboard-ring-buffer). Key input to MSX is generally done by reading this keyboard buffer.
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
##### _Figure 5.18 Keyboard ring buffer_
|
|
1204
|
+
|
|
1205
|
+
```
|
|
1206
|
+
+----------------------------------<----------------------------------------+
|
|
1207
|
+
| KEYBUF (FBF0H, 40) |
|
|
1208
|
+
| --------------------------------------/ /-------------------------------- |
|
|
1209
|
+
+>| D | E | F | G | | | \ \ | | | A | B | C |-+
|
|
1210
|
+
--------------------------------------/ /--------------------------------
|
|
1211
|
+
^ ^
|
|
1212
|
+
| |
|
|
1213
|
+
[PUTPNT] [GETPNT]
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
GETPNT (F3FAH, 2) points to the next character to be obtained in CHGET routine.
|
|
1217
|
+
|
|
1218
|
+
PUTPNT (F3F8H, 2) points to the next location for the character to be put when the keyboard is pressed next time.
|
|
1219
|
+
|
|
1220
|
+
|
|
1221
|
+
BIOS routines having functions for key input using this keyboard buffer and functions related to it are described below. Inhibiting the timer interrupt renders them useless, of course.
|
|
1222
|
+
|
|
1223
|
+
|
|
1224
|
+
<p> </p>
|
|
1225
|
+
|
|
1226
|
+
#### CHSNS (009CH/MAIN) - checks the keyboard buffer
|
|
1227
|
+
|
|
1228
|
+
* **Input**: ---
|
|
1229
|
+
* **Output**: Z flag = ON when the buffer is empty
|
|
1230
|
+
* **Function**: examines whether any characters remain in the keyboard buffer and sets the Z flag when the buffer is empty.
|
|
1231
|
+
|
|
1232
|
+
|
|
1233
|
+
<p> </p>
|
|
1234
|
+
|
|
1235
|
+
#### CHGET (009FH/MAIN) - one character input from the keyboard buffer
|
|
1236
|
+
|
|
1237
|
+
* **Input**: ---
|
|
1238
|
+
* **Output**: A ⟵ character code
|
|
1239
|
+
* **Function**: reads one character from the keyboard buffer and stores it in the A register. When the buffer is empty, it displays the cursor and waits for a key input. While a key input is waited for, the CAPS lock, KANA lock, and Roman-to-kana translation lock are valid. The related work area is listed below. In the list, since SCNCNT and REPCNT are initialised after the execution of CHGET routine, this area should be set at each CHGET call to change the interval of the auto-repeat.
|
|
1240
|
+
|
|
1241
|
+
Work area:
|
|
1242
|
+
|
|
1243
|
+
* **CLIKSW (F3DBH, 1)**: key click sound (0 = OFF, others = ON)
|
|
1244
|
+
* **SCNCNT (F3F6H, 1)**: key scanning interval (1, normally)
|
|
1245
|
+
* **REPCNT (F3F7H, 1)**: delay until beginning auto-repeat (50, normally)
|
|
1246
|
+
* **CSTYLE (FCAAH, 1)**: figure of the cursor (0 = block, others = underline)
|
|
1247
|
+
* **CAPST (FCABH, 1)**: CAPS lock (0 = OFF, others = ON)
|
|
1248
|
+
* **DEADST (FCACH, 1)**: dead key lock
|
|
1249
|
+
* 0 = on preceding dead key
|
|
1250
|
+
* 1 = dead key
|
|
1251
|
+
* 2 = shifted dead key
|
|
1252
|
+
* 3 = code dead key
|
|
1253
|
+
* 4 = code shift dead key
|
|
1254
|
+
|
|
1255
|
+
|
|
1256
|
+
<p> </p>
|
|
1257
|
+
|
|
1258
|
+
#### KILBUF (0156H/MAIN) - empty the keyboard buffer
|
|
1259
|
+
|
|
1260
|
+
* **Input**: ---
|
|
1261
|
+
* **Output**: ---
|
|
1262
|
+
* **Function**: empties the keyboard buffer.
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
##### _List 5.5 Use of one character input routine_
|
|
1266
|
+
|
|
1267
|
+
```
|
|
1268
|
+
;********************************************************
|
|
1269
|
+
;
|
|
1270
|
+
; List 5.5 get key code
|
|
1271
|
+
;
|
|
1272
|
+
; this routine doesn't wait for key hit
|
|
1273
|
+
;
|
|
1274
|
+
;********************************************************
|
|
1275
|
+
;
|
|
1276
|
+
CHSNS EQU 009CH ;check keyboard buffer
|
|
1277
|
+
CHGET EQU 009FH ;get a character from buffer
|
|
1278
|
+
CHPUT EQU 00A2H ;put a character to screen
|
|
1279
|
+
BREAKX EQU 00B7H ;check Ctrl-STOP
|
|
1280
|
+
KILBUF EQU 0156H ;clear keyboard buffer
|
|
1281
|
+
REPCNT EQU 0F3F7H ;time interval until key-repeat
|
|
1282
|
+
KEYBUF EQU 0FBF0H ;keyboard buffer address
|
|
1283
|
+
|
|
1284
|
+
ORG 0B000H
|
|
1285
|
+
|
|
1286
|
+
;----- prgram start ----- Note: Real-time input using CHGET
|
|
1287
|
+
|
|
1288
|
+
KEY: CALL CHSNS ;check keyboard buffer
|
|
1289
|
+
JR C,KEY1
|
|
1290
|
+
|
|
1291
|
+
LD A,1
|
|
1292
|
+
LD (REPCNT),A ;not to wait until repeat
|
|
1293
|
+
CALL CHGET ;get a character (if exists)
|
|
1294
|
+
JR KEY2
|
|
1295
|
+
|
|
1296
|
+
KEY1: LD A,'-' ;A := '-'
|
|
1297
|
+
|
|
1298
|
+
KEY2: CALL CHPUT ;put the character
|
|
1299
|
+
CALL KILBUF ;clear keyboard buffer
|
|
1300
|
+
CALL BREAKX ;check Ctrl-STOP
|
|
1301
|
+
JR NC,KEY
|
|
1302
|
+
|
|
1303
|
+
END
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
|
|
1307
|
+
<p> </p>
|
|
1308
|
+
|
|
1309
|
+
#### CNVRCHR (00AB/MAIN) - graphic character operation
|
|
1310
|
+
|
|
1311
|
+
* **Input**: A ⟵ character code
|
|
1312
|
+
* **Output**:
|
|
1313
|
+
* A ⟵ translated graphic character (normal characters are not translated)
|
|
1314
|
+
* CY flag = OFF (input was the graphic header byte 01H)
|
|
1315
|
+
* CY flag = ON, Z flag = ON (input was the graphic character and was translated)
|
|
1316
|
+
* CY flag = ON, Z flag = OFF (input was the normal character and was not translated)
|
|
1317
|
+
* **Function**: executing CNVCHR after CHGET causes the graphic character to be translated to one byte code as shown in [Figure 5.19](#figure-519--graphic-character-translation-chart) and causes other character not to be translated and to be returned. Since the graphic character is represented by irregular 2-byte code with the graphic header byte (01H), annoying procedures are required for the character operations; this routine makes it somewhat easy.
|
|
1318
|
+
|
|
1319
|
+
|
|
1320
|
+
##### _Figure 5.19 Graphic character translation chart_
|
|
1321
|
+
|
|
1322
|
+
```
|
|
1323
|
+
-------------------------------------------------------------
|
|
1324
|
+
| Before | After | Before | After |
|
|
1325
|
+
| conversion | conversion | conversion | conversion |
|
|
1326
|
+
|-----------------------------+-----------------------------|
|
|
1327
|
+
| | 0150H --> 50H |
|
|
1328
|
+
| 0141H --> 41H | 0151H --> 51H |
|
|
1329
|
+
| 0142H --> 42H | 0152H --> 52H |
|
|
1330
|
+
| 0143H --> 43H | 0153H --> 53H |
|
|
1331
|
+
| 0144H --> 44H | 0154H --> 54H |
|
|
1332
|
+
| 0145H --> 45H | 0155H --> 55H |
|
|
1333
|
+
| 0146H --> 46H | 0156H --> 56H |
|
|
1334
|
+
| 0147H --> 47H | 0157H --> 57H |
|
|
1335
|
+
| 0148H --> 48H | 0158H --> 58H |
|
|
1336
|
+
| 0149H --> 49H | 0159H --> 59H |
|
|
1337
|
+
| 014AH --> 4AH | 015AH --> 5AH |
|
|
1338
|
+
| 014BH --> 4BH | 015BH --> 5BH |
|
|
1339
|
+
| 014CH --> 4CH | 015CH --> 5CH |
|
|
1340
|
+
| 014DH --> 4DH | 015DH --> 5DH |
|
|
1341
|
+
| 014EH --> 4EH | 015EH --> 5EH |
|
|
1342
|
+
| 014FH --> 4FH | 015FH --> 5FH |
|
|
1343
|
+
-------------------------------------------------------------
|
|
1344
|
+
```
|
|
1345
|
+
|
|
1346
|
+
<p> </p>
|
|
1347
|
+
|
|
1348
|
+
#### PINLIN (00AEH/MAIN) - one line input
|
|
1349
|
+
|
|
1350
|
+
* **Input**: ---
|
|
1351
|
+
* **Output**:
|
|
1352
|
+
* HL ⟵ F55DH
|
|
1353
|
+
* [F55EH] ⟵ input string (the end of te line is represented by 00H)
|
|
1354
|
+
* CY flag ⟵ terminated by STOP=ON, terminated by RETURN=OFF
|
|
1355
|
+
* **Function**: stores input string in the line buffer BUF (F55EH). All functions of the screen editing are available at the string input. Pressing RETURN or STOP causes the input to be finished. The work area is listed below.
|
|
1356
|
+
|
|
1357
|
+
Work area:
|
|
1358
|
+
|
|
1359
|
+
* **BUF (F55EH, 258)**: the line buffer where the string is stored
|
|
1360
|
+
* **LINTTB (FBB2H, 24)**: 00H when the one physiscal line is the succession of the line above
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
<p> </p>
|
|
1364
|
+
|
|
1365
|
+
#### INLIN (00B1H/MAIN) - one line input (prompt available)
|
|
1366
|
+
|
|
1367
|
+
* **Input**: ---
|
|
1368
|
+
* **Output**: same as PINLIN
|
|
1369
|
+
* **Function**: stores input string in the line buffer BUF (F55EH), as PINLIN routine. Note that the portion before the cursor location at the time when the routine begins to execute is not received. [List 5.6](#list-56--difference-between-inlin-and-pinlin) shows the difference between PINLIN and INLIN.
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
##### _List 5.6 Difference between INLIN and PINLIN_
|
|
1373
|
+
|
|
1374
|
+
```
|
|
1375
|
+
;************************************************
|
|
1376
|
+
;
|
|
1377
|
+
; List 5.6 INLIN and PINLIN
|
|
1378
|
+
;
|
|
1379
|
+
;************************************************
|
|
1380
|
+
;
|
|
1381
|
+
CHPUT EQU 00A2H
|
|
1382
|
+
INLIN EQU 00B1H
|
|
1383
|
+
PINLIN EQU 00AEH
|
|
1384
|
+
KILBUF EQU 0156H
|
|
1385
|
+
|
|
1386
|
+
BUF EQU F55EH
|
|
1387
|
+
|
|
1388
|
+
ORG 0B000H
|
|
1389
|
+
|
|
1390
|
+
;----- program start -----
|
|
1391
|
+
|
|
1392
|
+
LD HL,PRMPT1
|
|
1393
|
+
CALL PUTMSG ;put prompt message
|
|
1394
|
+
CALL INLIN ;use INLIN routine
|
|
1395
|
+
LD HL,BUF
|
|
1396
|
+
CALL PUTMSG
|
|
1397
|
+
|
|
1398
|
+
LD HL,PRMPT2
|
|
1399
|
+
CALL PUTMSG ;put prompt message
|
|
1400
|
+
CALL PINLIN ;use PINLIN routine
|
|
1401
|
+
LD HL,BUF
|
|
1402
|
+
CALL PUTMSG
|
|
1403
|
+
|
|
1404
|
+
RET
|
|
1405
|
+
|
|
1406
|
+
;----- put a string -----
|
|
1407
|
+
|
|
1408
|
+
PUTMSG: LD A,(HL)
|
|
1409
|
+
CP '$'
|
|
1410
|
+
RET Z
|
|
1411
|
+
CALL CHPUT
|
|
1412
|
+
INC HL
|
|
1413
|
+
JR PUTMSG
|
|
1414
|
+
|
|
1415
|
+
;----- string data -----
|
|
1416
|
+
|
|
1417
|
+
PRMPT1: DB 0DH,0AH,'INLIN:$'
|
|
1418
|
+
PRMPT2: DB 0DH,0AH,'PINLIN:$'
|
|
1419
|
+
|
|
1420
|
+
END
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
<p> </p>
|
|
1425
|
+
|
|
1426
|
+
### 3.3 Function Keys
|
|
1427
|
+
|
|
1428
|
+
MSX has ten function keys, which can be defined by the user at will. A 16 byte work area is allocated for the definition of each key. The following list shows their addresses.
|
|
1429
|
+
|
|
1430
|
+
* **FNKSTR (F87FH, 16)**: F1 key definition address
|
|
1431
|
+
* **+ 10H (F88FH, 16)**: F2 key definition address
|
|
1432
|
+
* **+ 20H (F89FH, 16)**: F3 key definition address
|
|
1433
|
+
* **+ 30H (F8AFH, 16)**: F4 key definition address
|
|
1434
|
+
* **+ 40H (F8BFH, 16)**: F5 key definition address
|
|
1435
|
+
* **+ 50H (F8CFH, 16)**: F6 key definition address
|
|
1436
|
+
* **+ 60H (F8DFH, 16)**: F7 key definition address
|
|
1437
|
+
* **+ 70H (F8EFH, 16)**: F8 key definition address
|
|
1438
|
+
* **+ 80H (F8FFH, 16)**: F9 key definition address
|
|
1439
|
+
* **+ 90H (F90FH, 16)**: F10 key definition address
|
|
1440
|
+
|
|
1441
|
+
Pressing a function key causes the string defined in that key to be stored in [KEYBUF]. The end of the string is indicated by 00H and a maximum of 15 keystrokes can be defined for one function key (definitions longer than 16 keystrokes are defined over more than one function key definition area). To restore the initial settings of the function keys, use the following BIOS routine.
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
#### INIFNK (003EH/MAIN) - initialize function keys
|
|
1445
|
+
|
|
1446
|
+
* **Input**: ---
|
|
1447
|
+
* **Output**: ---
|
|
1448
|
+
* **Function**: restores the function key definition to the setting when BASIC starts.
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
<p> </p>
|
|
1452
|
+
|
|
1453
|
+
### 3.4 STOP Key During Interrupts
|
|
1454
|
+
|
|
1455
|
+
CHGET, the one-character input routine described in 3.3, determines the pressed key in the timer interrupt routine. Thus, when the timer interrupt is inhibited, such as during cassette data I/O, pressed keys cannot be detected. By using the BIOS routine described below, the CTRL key + STOP key combination can be detected even when interrupts are inhibited.
|
|
1456
|
+
|
|
1457
|
+
|
|
1458
|
+
#### BREAKX (00B7H/MAIN) - CTRL + STOP detection
|
|
1459
|
+
|
|
1460
|
+
* **Input**: ---
|
|
1461
|
+
* **Output**: CY flag = ON, when CTRL + STOP is pressed
|
|
1462
|
+
* **Function**: scans keys and decides whether CTRL key and STOP key are pressed at the same time. When both are pressed, this routine sets "1" to the CY flag and returns. Otherwise, it resets "0" to the CY flag and returns. This routine is available while interrupts are inhibited.
|
|
1463
|
+
|
|
1464
|
+
|
|
1465
|
+
<p> </p>
|
|
1466
|
+
|
|
1467
|
+
## 4. PRINTER INTERFACE
|
|
1468
|
+
|
|
1469
|
+
This section describes how to access the MSX printer interface from assembly language. The information described here is helpful if the printer is going to be used to print bit image graphics.
|
|
1470
|
+
|
|
1471
|
+
|
|
1472
|
+
<p> </p>
|
|
1473
|
+
|
|
1474
|
+
### 4.1 Print Interface Overview
|
|
1475
|
+
|
|
1476
|
+
The printer interface is supported by BIOS and BASIC. MSX drives the printer through an 8-bit parallel output port and uses a handshaking method with BUSY and STROBE signals. The standard connector is also defined (Amphenol 14-pin, female side to the machine). [Figure 5.20](#figure-520--printer-interface) shows the signal lines.
|
|
1477
|
+
|
|
1478
|
+
|
|
1479
|
+
##### _Figure 5.20 Printer interface_
|
|
1480
|
+
|
|
1481
|
+
```
|
|
1482
|
+
Printer interface pin connections
|
|
1483
|
+
|
|
1484
|
+
-------------------------------------------------------------------
|
|
1485
|
+
\ ------------------------------------------- /
|
|
1486
|
+
\ | (7) | (6) | (5) | (4) | (3) | (2) | (1) | /
|
|
1487
|
+
\ --------------------------------------------------- /
|
|
1488
|
+
\ | | /
|
|
1489
|
+
\ --------------------------------------------------- /
|
|
1490
|
+
\ | (14)| (13)| (12)| (11)| (11)| (10)| (9) | /
|
|
1491
|
+
\ ------------------------------------------- /
|
|
1492
|
+
---------------------------------------------------
|
|
1493
|
+
|
|
1494
|
+
(1) ........... STROBE*
|
|
1495
|
+
(2) to (9) .... Data (b0 to b7)
|
|
1496
|
+
(11) .......... BUSY
|
|
1497
|
+
(14) .......... BGND
|
|
1498
|
+
|
|
1499
|
+
-------------------------------------------------
|
|
1500
|
+
I/O port (91H) | X | X | X | X | X | X | X | X |
|
|
1501
|
+
-------------------------------------------------
|
|
1502
|
+
Data
|
|
1503
|
+
|
|
1504
|
+
-------------------------------------------------
|
|
1505
|
+
I/O port (90H; at WRITE) | . | . | . | . | . | . | . | X |
|
|
1506
|
+
-------------------------------------------------
|
|
1507
|
+
^
|
|
1508
|
+
|
|
|
1509
|
+
STROBE* (send data when "0") ----+
|
|
1510
|
+
|
|
1511
|
+
-------------------------------------------------
|
|
1512
|
+
I/O port (90H; at READ) | . | . | . | . | . | . | X | . |
|
|
1513
|
+
-------------------------------------------------
|
|
1514
|
+
^
|
|
1515
|
+
0: Printer READY |
|
|
1516
|
+
---+
|
|
1517
|
+
1: Printer BUSY
|
|
1518
|
+
```
|
|
1519
|
+
|
|
1520
|
+
<p> </p>
|
|
1521
|
+
|
|
1522
|
+
### 4.2 Output to the MSX Standard Printer
|
|
1523
|
+
|
|
1524
|
+
If data is sent from MSX to the printer, the action depends on whether the printer receiving the data is of the MSX standard. The use of MSX standard printers is described in this section. Descriptions about other printers are in the next section.
|
|
1525
|
+
|
|
1526
|
+
An MSX standard printer can print any character that can be displayed on the screen. Special graphic characters corresponding to character codes n = 01H to 1FH can be also printed by sending the code 40H + n after the graphic character header (01H). In addition to these, the control codes shown in [Table 5.4](#table-54--control-codes-of-the-printer) can be used with MSX standard printers (see the manual of the printer for controlling a printer which has other functions such as printing Chinese characters).
|
|
1527
|
+
|
|
1528
|
+
To feed lines in MSX standard printers, send 0DH and 0AH successively. To print the bit image, send nnnn bytes data, where nnnn means four decimal figures, after the escape sequence ESC + "Snnnn". Note that, MSX has a function to transform the tab code (09H) to the adequate number of space codes (20H) for printers not having a tab function. This transformation is normally done. To print a bit image which includes the value 09H correctly, change the following work area.
|
|
1529
|
+
|
|
1530
|
+
* **RAWPRT (F418H, 1)**: replaces a tab by spaces when the contents are 00H, otherwise not.
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
##### _Table 5.4 Control codes of the printer_
|
|
1534
|
+
|
|
1535
|
+
```
|
|
1536
|
+
-----------------------------------------------------------------------------
|
|
1537
|
+
| code | function |
|
|
1538
|
+
|-----------------+---------------------------------------------------------|
|
|
1539
|
+
| 0AH | line feed |
|
|
1540
|
+
|-----------------+---------------------------------------------------------|
|
|
1541
|
+
| 0CH | form feed |
|
|
1542
|
+
|-----------------+---------------------------------------------------------|
|
|
1543
|
+
| 0DH | carriage return |
|
|
1544
|
+
|-----------------+---------------------------------------------------------|
|
|
1545
|
+
| ESC + "A" | normal line spacing |
|
|
1546
|
+
| | (spaces between lines; characters are read easily) |
|
|
1547
|
+
|-----------------+---------------------------------------------------------|
|
|
1548
|
+
| ESC + "B" | line spacing for graphics (no space between lines) |
|
|
1549
|
+
|-----------------+---------------------------------------------------------|
|
|
1550
|
+
| ESC + "Snnnn" | bit image printing |
|
|
1551
|
+
-----------------------------------------------------------------------------
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
<p> </p>
|
|
1555
|
+
|
|
1556
|
+
### 4.3 Access to the printer
|
|
1557
|
+
|
|
1558
|
+
To send output to the printer, the following BIOS routines are offered.
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
<p> </p>
|
|
1562
|
+
|
|
1563
|
+
#### LPTOUT (00A5H/MAIN)
|
|
1564
|
+
|
|
1565
|
+
* **Input**: A register ⟵ character code
|
|
1566
|
+
* **Output**: CY flag = ON at abnormal termination
|
|
1567
|
+
* **Function**: sends a character specified by the A register to the printer.
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
<p> </p>
|
|
1571
|
+
|
|
1572
|
+
#### LPTSTT (00A8/MAIN)
|
|
1573
|
+
|
|
1574
|
+
* **Input**: ---
|
|
1575
|
+
* **Output**: A register ⟵ printer status
|
|
1576
|
+
* **Function**: examines the current printer status. After calling this routine, the printer can be used when the A register is 255 and the Z flag is 0; when the A register is 0 and the Z flag is 1, the printer cannot be used.
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
<p> </p>
|
|
1580
|
+
|
|
1581
|
+
#### OUTDLP (014DH,MAIN)
|
|
1582
|
+
|
|
1583
|
+
* **Input**: A register ⟵ character code
|
|
1584
|
+
* **Output**: CY flag = ON at abnormal termination
|
|
1585
|
+
* **Function**: sends a character specified by the A register to the printer. Differences between this routine and LPTOUT routine is as following:
|
|
1586
|
+
* prints corresponding number of spaces for TAB code
|
|
1587
|
+
* transforms hiragana to katakana for printers other than MSX standard
|
|
1588
|
+
* returns Device I/O error at abnormal termination
|
|
1589
|
+
|
|
1590
|
+
<p> </p>
|
|
1591
|
+
|
|
1592
|
+
## 5. UNIVERSAL I/O INTERFACE
|
|
1593
|
+
|
|
1594
|
+
As described in section 1, the PSG used by MSX has two 8-bit I/O ports, port A and port B, in addition to the sound output function. In MSX, these two ports are connected to the universal I/O interface (joystick port) and are used to exchange data with the joystick or the paddle (see [Figure 5.21](#figure-521--universal-io-interface)). Various devices to be connected to this universal I/O interface have the necessary BIOS routine in ROM, so they are easily accessbile.
|
|
1595
|
+
|
|
1596
|
+
In this section, the funtion of each I/O device and the method for accessing with BIOS routines are described.
|
|
1597
|
+
|
|
1598
|
+
|
|
1599
|
+
##### _Figure 5.21 Universal I/O interface_
|
|
1600
|
+
|
|
1601
|
+
```
|
|
1602
|
+
Universal input/output interface -1
|
|
1603
|
+
-----------------------------------------
|
|
1604
|
+
| |
|
|
1605
|
+
| (1) (2) (3) (4) (5) -+- +5V Switching signal <---+
|
|
1606
|
+
| | (6) | (7) | (8) | (9) -----+- GND (to port B:b6) |
|
|
1607
|
+
| | | | | | | | | |
|
|
1608
|
+
----:---:---:---:---:---:---:------------ |
|
|
1609
|
+
| | | | | | | |
|
|
1610
|
+
| | | | | +---:--> To port B:b4 ------------------------- |
|
|
1611
|
+
| | | | | | | | |
|
|
1612
|
+
+---+---+---+---+-------+--------------------| | |
|
|
1613
|
+
| Switcher |--+
|
|
1614
|
+
+---+---+---+---+-------+--------------------| |
|
|
1615
|
+
| | | | | | | |
|
|
1616
|
+
| | | | | +---:--> To port B:b5 -------------------------
|
|
1617
|
+
| | | | | | | | | | | | |
|
|
1618
|
+
----:---:---:---:---:---:---:------------ (1) (2) (3) (4) (6) (7)
|
|
1619
|
+
| | | | | | | | | | | | | | | | |
|
|
1620
|
+
| (1) (2) (3) (4) (5) -+- +5V +-------------------------+
|
|
1621
|
+
| (6) (7) (8) (9) -----+- GND |
|
|
1622
|
+
| | V
|
|
1623
|
+
----------------------------------------- To port A:b0 to b5
|
|
1624
|
+
Universal input/output interface -2
|
|
1625
|
+
```
|
|
1626
|
+
|
|
1627
|
+
<p> </p>
|
|
1628
|
+
|
|
1629
|
+
### 5.1 Functions of the Ports
|
|
1630
|
+
|
|
1631
|
+
Two I/O ports of PSG are used as shown in [Figure 5.22](#figure-522-a--functions-of-psg-port-a).
|
|
1632
|
+
|
|
1633
|
+
|
|
1634
|
+
##### _Figure 5.22 (A) Functions of PSG port A_
|
|
1635
|
+
|
|
1636
|
+
```
|
|
1637
|
+
Port A (PSG#14)
|
|
1638
|
+
-------------------------------------------------
|
|
1639
|
+
| b7 | . | b5 : b4 : b3 : b2 : b1 : b0 |
|
|
1640
|
+
-------------------------------------------------
|
|
1641
|
+
| | | | | | | --+
|
|
1642
|
+
| | | | | | +--> 1st terminal | connected
|
|
1643
|
+
| | | | | +--------> 2nd terminal | to
|
|
1644
|
+
| | | | +--------------> 3rd terminal | universal
|
|
1645
|
+
| | | +--------------------> 4th terminal | I/O
|
|
1646
|
+
| | +--------------------------> 6th terminal | interface
|
|
1647
|
+
| +--------------------------------> 7th terminal |
|
|
1648
|
+
| --+
|
|
1649
|
+
+-----------------------------------> Data input from the cassette tape
|
|
1650
|
+
```
|
|
1651
|
+
|
|
1652
|
+
##### _Figure 5.22 (B) Functions of PSG port B_
|
|
1653
|
+
|
|
1654
|
+
```
|
|
1655
|
+
Port B (PSG#15)
|
|
1656
|
+
-------------------------------------------------
|
|
1657
|
+
| b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 |
|
|
1658
|
+
-------------------------------------------------
|
|
1659
|
+
| | | | | | | |
|
|
1660
|
+
| | | | +-----+-----+-----+--> Unused
|
|
1661
|
+
| | | |
|
|
1662
|
+
| | | +---> Connected to 8th terminal of univ. I/O interface 1
|
|
1663
|
+
| | +---------> Connected to 8th terminal of univ. I/O interface 2
|
|
1664
|
+
| |
|
|
1665
|
+
| +---> 0: b0-b5 of port A to be connected to univ. I/O interface 1
|
|
1666
|
+
| 1: b0-b5 of port A to be connected to univ. I/O interface 2
|
|
1667
|
+
|
|
|
1668
|
+
+---------> 0: Arabic or kana mode display lamp on
|
|
1669
|
+
1: Arabic or kana mode display lamp off
|
|
1670
|
+
```
|
|
1671
|
+
|
|
1672
|
+
<p> </p>
|
|
1673
|
+
|
|
1674
|
+
### 5.2 Joystick Use
|
|
1675
|
+
|
|
1676
|
+
Figure 5.23 shows the joystick circuit. As the circuit shows, sending "0" to the 8th terminal and reading the 1st to 4th and 6th to 7th terminals enable information about the stick and the trigger buttons to be obtained. However, it is advisable to use BIOS for accessing the joystick, in order to give portability to the program.
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
##### _Figure 5.23 Joystick circuit_
|
|
1680
|
+
|
|
1681
|
+
```
|
|
1682
|
+
\
|
|
1683
|
+
(1) O---------------o o------------+ ............. Front
|
|
1684
|
+
|
|
|
1685
|
+
\ |
|
|
1686
|
+
(2) O---------------o o------------+ ............. Back
|
|
1687
|
+
|
|
|
1688
|
+
\ |
|
|
1689
|
+
(3) O---------------o o------------+ ............. Left
|
|
1690
|
+
|
|
|
1691
|
+
\ |
|
|
1692
|
+
(4) O---------------o o------------+ ............. Right
|
|
1693
|
+
|
|
|
1694
|
+
|
|
|
1695
|
+
\ |
|
|
1696
|
+
(6) O---------------o o------------+ ............. Trigger A
|
|
1697
|
+
|
|
|
1698
|
+
\ |
|
|
1699
|
+
(7) O---------------o o------------+ ............. Trigger B
|
|
1700
|
+
|
|
|
1701
|
+
|
|
|
1702
|
+
(8) O-------------------------------+
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
The following BIOS routines are offered for accessing the joystick. These routines have similar functions to the STICK function and STRIG function of BASIC. The status of the cursor keys or the space bar, in addition to the joystick, can be read in real time.
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
<p> </p>
|
|
1709
|
+
|
|
1710
|
+
#### GTSTCK (00D5H/MAIN) - read joystick
|
|
1711
|
+
|
|
1712
|
+
* **Input**: A ⟵ joystick number (0 = cursor key, 1 and 2 = joystick)
|
|
1713
|
+
* **Output**: A ⟵ direction of joystick or cursor key
|
|
1714
|
+
* **Function**: returns the current status of the joystick or the cursor keys in the A register. The value is the same as the STICK function in BASIC.
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
<p> </p>
|
|
1718
|
+
|
|
1719
|
+
#### GTTRIG (00D8H/MAIN) - read trigger button
|
|
1720
|
+
|
|
1721
|
+
* **Input**: A ⟵ trigger button number (0 = space bar, 1 and 2 = trigger button A, 3 and 4 = trigger button B)
|
|
1722
|
+
* **Output**: A ⟵ status of trigger button or space bar (0FFH = pressed, 00H = released)
|
|
1723
|
+
* **Function**: returns the current status of the trigger buttons or the space bar in the A register. The value is 0FFH when the trigger is pressed, otherwise it is 0.
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
##### _List 5.7 Joystick use_
|
|
1727
|
+
|
|
1728
|
+
```
|
|
1729
|
+
;************************************************
|
|
1730
|
+
;
|
|
1731
|
+
; List 5.7 Joystick and trigger access
|
|
1732
|
+
;
|
|
1733
|
+
;************************************************
|
|
1734
|
+
;
|
|
1735
|
+
CHPUT EQU 00A2H
|
|
1736
|
+
BREAKX EQU 00B7H
|
|
1737
|
+
GTSTCK EQU 00D5H
|
|
1738
|
+
GTTRIG EQU 00D8H
|
|
1739
|
+
|
|
1740
|
+
ORG 0D00H
|
|
1741
|
+
|
|
1742
|
+
;----- program start ----- Note: display joystick status
|
|
1743
|
+
|
|
1744
|
+
STICK: LD A,1 ;choose joystick 1
|
|
1745
|
+
CALL GTSTCK ;read joystick status
|
|
1746
|
+
LD (WK1),A
|
|
1747
|
+
LD A,1 ;choose joystick 1
|
|
1748
|
+
CALL GTTRIG ;read trigger status
|
|
1749
|
+
|
|
1750
|
+
OR A
|
|
1751
|
+
JR Z,STCK1
|
|
1752
|
+
LD HL,WDON ;trigger ON
|
|
1753
|
+
JR STCK2
|
|
1754
|
+
STCK1: LD HL,WDOFF ;trigger OFF
|
|
1755
|
+
STCK2: CALL PUTSTR
|
|
1756
|
+
LD A,(WK1)
|
|
1757
|
+
|
|
1758
|
+
OR A
|
|
1759
|
+
JR Z,BRKCH0 ;do not use joystick
|
|
1760
|
+
LD C,0
|
|
1761
|
+
STCK3: DEC A
|
|
1762
|
+
JR NZ,STCK4
|
|
1763
|
+
INC C
|
|
1764
|
+
JR STCK3
|
|
1765
|
+
|
|
1766
|
+
STCK4: SLA C ;C := C*16
|
|
1767
|
+
SLA C
|
|
1768
|
+
SLA C
|
|
1769
|
+
SLA C
|
|
1770
|
+
LD B,0 ;Accounting Strings data address
|
|
1771
|
+
LD HL,WDSTK
|
|
1772
|
+
ADD HL,BC
|
|
1773
|
+
CALL PUTSTR
|
|
1774
|
+
|
|
1775
|
+
BRKCH0: LD A,0DH ;put carriage return
|
|
1776
|
+
CALL CHPUT ;code := 0DH
|
|
1777
|
+
|
|
1778
|
+
BRKCHK: CALL BREAKX ;break check
|
|
1779
|
+
RET C
|
|
1780
|
+
JR STICK
|
|
1781
|
+
|
|
1782
|
+
;----- put strings to screen -----
|
|
1783
|
+
|
|
1784
|
+
PUTSTR: LD A,(HL)
|
|
1785
|
+
CP '$'
|
|
1786
|
+
RET Z
|
|
1787
|
+
INC HL
|
|
1788
|
+
CALL CHPUT
|
|
1789
|
+
JR PUTSTR
|
|
1790
|
+
|
|
1791
|
+
;----- string area -----
|
|
1792
|
+
|
|
1793
|
+
WDON: DB 'Trigger ON: $'
|
|
1794
|
+
WDOFF: DB 'Trigger OFF: $'
|
|
1795
|
+
WDSTK: DB 'UP only ',0DH,0AH,'$'
|
|
1796
|
+
DB 'Up and Right ',0DH,0AH,'$'
|
|
1797
|
+
DB 'Right only ',0DH,0AH,'$'
|
|
1798
|
+
DB 'Right & Down ',0DH,0AH,'$'
|
|
1799
|
+
DB 'Down only ',0DH,0AH,'$'
|
|
1800
|
+
DB 'Down and Left',0DH,0AH,'$'
|
|
1801
|
+
DB 'Left only ',0DH,0AH,'$'
|
|
1802
|
+
DB 'Left and Up ',0DH,0AH,'$'
|
|
1803
|
+
|
|
1804
|
+
WK1: DW 0
|
|
1805
|
+
|
|
1806
|
+
END
|
|
1807
|
+
```
|
|
1808
|
+
|
|
1809
|
+
|
|
1810
|
+
<p> </p>
|
|
1811
|
+
|
|
1812
|
+
### 5.3 Paddle Use
|
|
1813
|
+
|
|
1814
|
+
Figure 5.24 shows the paddle circuit. Sending a pulse to the 8th terminal causes the single stable multi-vibrator to generate a pulse with a specified interval. This interval depends on the value of the variable register which can range from 10 to 3000 microseconds (0.01 to 3.00 ms). Measuring the pulse length enables the value in the variable register and the turning angle to be obtained.
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
##### _Figure 5.24 Paddle circuit_
|
|
1818
|
+
|
|
1819
|
+
```
|
|
1820
|
+
--+--
|
|
1821
|
+
|
|
|
1822
|
+
<_
|
|
1823
|
+
_> 150KOhm Variable Resistor
|
|
1824
|
+
<
|
|
1825
|
+
|
|
|
1826
|
+
0.04 uF |
|
|
1827
|
+
+--| |---+
|
|
1828
|
+
| |
|
|
1829
|
+
---+--------+---
|
|
1830
|
+
| |
|
|
1831
|
+
|\ | |
|
|
1832
|
+
| \ | |
|
|
1833
|
+
(8) -----| >O----O| A Q |------------- (1) (For 2, 3, 4, 6, or 7,
|
|
1834
|
+
| / | | a similar circuit
|
|
1835
|
+
|/ | | would apply)
|
|
1836
|
+
| |
|
|
1837
|
+
| |
|
|
1838
|
+
+----------| B |
|
|
1839
|
+
| | |
|
|
1840
|
+
| | | (One-shot trigger IC, LS123 compatible)
|
|
1841
|
+
| | |
|
|
1842
|
+
+5V | ----------------
|
|
1843
|
+
--+-- | O
|
|
1844
|
+
| | |
|
|
1845
|
+
+-----+-----------------+
|
|
1846
|
+
|
|
1847
|
+
____
|
|
1848
|
+
: :
|
|
1849
|
+
Input to 8 ________: :_____________________________________
|
|
1850
|
+
|
|
1851
|
+
_________________________________
|
|
1852
|
+
: :
|
|
1853
|
+
Output to 1 ________: :________
|
|
1854
|
+
|<------- 10 us to 3 ms ------->|
|
|
1855
|
+
```
|
|
1856
|
+
|
|
1857
|
+
BIOS routines for accessing the paddle are described below.
|
|
1858
|
+
|
|
1859
|
+
|
|
1860
|
+
#### GTPDL (00DEH/MAIN) - read paddle information
|
|
1861
|
+
|
|
1862
|
+
* **Input**: A ⟵ paddle number (1 to 12)
|
|
1863
|
+
* **Output**: A ⟵ turning angle (0 to 255)
|
|
1864
|
+
* **Function**: examines the status of the paddle specified in the A register and returns the result in the A register.
|
|
1865
|
+
|
|
1866
|
+
|
|
1867
|
+
<p> </p>
|
|
1868
|
+
|
|
1869
|
+
### 5.4 Use of Touch Panel, Light Pen, Mouse, and Track Ball
|
|
1870
|
+
|
|
1871
|
+
The touch panel, light pen, mouse, and track ball (cat) are accessible using the same BIOS routine. This routine is described below.
|
|
1872
|
+
|
|
1873
|
+
|
|
1874
|
+
#### GTPAD (00DBH/MAIN) - access to various I/O devices
|
|
1875
|
+
|
|
1876
|
+
* **Input**: A ⟵ device ID (0 to 19)
|
|
1877
|
+
* **Output**: A ⟵ objective information
|
|
1878
|
+
* **Function**: obtains various information as shown in [Table 5.5](#table-55--gtpad-bios-function) according to the value specified in the A register. This is the same as the PAD function of BASIC. "XXX1" in the table means the "XXX" device connected to the universal I/O interface 1; "XXX2" means the one connected to the universal I/O interface #2.
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
##### _Table 5.5 GTPAD BIOS Function_
|
|
1882
|
+
|
|
1883
|
+
```
|
|
1884
|
+
--------------------------------------------------------------------------
|
|
1885
|
+
| Device ID | Device specified | Information returned |
|
|
1886
|
+
--------------+--------------------+-------------------------------------|
|
|
1887
|
+
| 0 | | 0FFH when touching panel surface, |
|
|
1888
|
+
| | | 00H when not |
|
|
1889
|
+
|-------------| |-------------------------------------|
|
|
1890
|
+
| 1 | | X-coordinate (0 to 255) |
|
|
1891
|
+
|-------------| Touch panel 1 |-------------------------------------|
|
|
1892
|
+
| 2 | | Y-coordinate (0 to 255) |
|
|
1893
|
+
|-------------| |-------------------------------------|
|
|
1894
|
+
| 3 | | 0FFH when button is pressed, |
|
|
1895
|
+
| | | 00H when not |
|
|
1896
|
+
|-------------+--------------------+-------------------------------------|
|
|
1897
|
+
| 4 | | |
|
|
1898
|
+
|-------------| | |
|
|
1899
|
+
| 5 | | |
|
|
1900
|
+
|-------------| Touch panel 2 | Same as above |
|
|
1901
|
+
| 6 | | |
|
|
1902
|
+
|-------------| | |
|
|
1903
|
+
| 7 | | |
|
|
1904
|
+
|-------------+--------------------+-------------------------------------|
|
|
1905
|
+
| 8 | | 0FFH: valid data, |
|
|
1906
|
+
| | | 00H: invalid data |
|
|
1907
|
+
|-------------| |-------------------------------------|
|
|
1908
|
+
| 9 | | X-coordinate (0 to 255) |
|
|
1909
|
+
|-------------| Light pen |-------------------------------------|
|
|
1910
|
+
| 10 | | Y-coordinate (0 to 255) |
|
|
1911
|
+
|-------------| |-------------------------------------|
|
|
1912
|
+
| 11 | | 0FFH when switch is pressed, |
|
|
1913
|
+
| | | 00H when not |
|
|
1914
|
+
|-------------+--------------------+-------------------------------------|
|
|
1915
|
+
| 12 | | Always 0FFH |
|
|
1916
|
+
| | | (used to request for input) |
|
|
1917
|
+
|-------------| |-------------------------------------|
|
|
1918
|
+
| 13 | Mouse 1 or | X-coordinate (0 to 255) |
|
|
1919
|
+
|-------------| track ball 1 |-------------------------------------|
|
|
1920
|
+
| 14 | | Y-coordinate (0 to 255) |
|
|
1921
|
+
|-------------| |-------------------------------------|
|
|
1922
|
+
| 15 | | Always 00H |
|
|
1923
|
+
| | | (no meaning) |
|
|
1924
|
+
|-------------+--------------------+-------------------------------------|
|
|
1925
|
+
| 16 | | |
|
|
1926
|
+
|-------------| | |
|
|
1927
|
+
| 17 | Mouse 2 or | |
|
|
1928
|
+
|-------------| track ball 2 | Same as above |
|
|
1929
|
+
| 18 | | |
|
|
1930
|
+
|-------------| | |
|
|
1931
|
+
| 19 | | |
|
|
1932
|
+
--------------------------------------------------------------------------
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1935
|
+
**Note 1:** Though information of the coordinate of the light pen (A = 9, 10) and
|
|
1936
|
+
the switch (A = 11) are read at the same time when BIOS is called
|
|
1937
|
+
with A = 8, other values are valid only when the result is 0FFH.
|
|
1938
|
+
In the case that the result of BIOS which is called with A = 8 is
|
|
1939
|
+
00H, the coordinate values and the status of the switch contained
|
|
1940
|
+
after that are meaningless.
|
|
1941
|
+
|
|
1942
|
+
**Note 2:** Mouse and track ball are automatically distinguished.
|
|
1943
|
+
|
|
1944
|
+
**Note 3:** To obtain the coordinate value of the mouse or the track ball, do the
|
|
1945
|
+
input request call (A = 12 or A = 16), then execute the call to
|
|
1946
|
+
obtain the coordinate value actually. In this case, the interval of
|
|
1947
|
+
these two calls must be minimized as possible. Too much interval
|
|
1948
|
+
between the input request and the coordinate input causes the
|
|
1949
|
+
obtained data to be unreliable.
|
|
1950
|
+
|
|
1951
|
+
**Note 4:** To obtain the status of the trigger button of the mouse or the
|
|
1952
|
+
trigger button of the track ball, use [GTTRIG (00D8H/MAIN)](#gttrig-00d8hmain---read-trigger-button), not GTPAD
|
|
1953
|
+
routine.
|
|
1954
|
+
|
|
1955
|
+
|
|
1956
|
+
##### _List 5.8 Touch panel use_
|
|
1957
|
+
|
|
1958
|
+
```
|
|
1959
|
+
;************************************************
|
|
1960
|
+
;
|
|
1961
|
+
; List 5.8 touch pad access
|
|
1962
|
+
;
|
|
1963
|
+
;************************************************
|
|
1964
|
+
;
|
|
1965
|
+
BREAKX EQU 00B7H
|
|
1966
|
+
GTPAD EQU 00D8H
|
|
1967
|
+
WRTVRM EQU 004DH
|
|
1968
|
+
|
|
1969
|
+
ORG 0B000H
|
|
1970
|
+
|
|
1971
|
+
;----- program start ----- Note: Displays "*" at position specified
|
|
1972
|
+
by touch pad.
|
|
1973
|
+
|
|
1974
|
+
PAD: XOR A ;check sense
|
|
1975
|
+
CALL GTPAD
|
|
1976
|
+
OR A
|
|
1977
|
+
JR NZ,PAD1
|
|
1978
|
+
LD A,3
|
|
1979
|
+
CALL GTPAD ;break check
|
|
1980
|
+
OR A
|
|
1981
|
+
RET NZ
|
|
1982
|
+
JR PAD
|
|
1983
|
+
|
|
1984
|
+
PAD1: LD A,1 ;get X axis
|
|
1985
|
+
CALL GTPAD
|
|
1986
|
+
SRL A ;A := A/8
|
|
1987
|
+
SRL A
|
|
1988
|
+
SRL A
|
|
1989
|
+
LD (WORK),A ;reserve X axis
|
|
1990
|
+
LD A,2 ;get Y axis
|
|
1991
|
+
CALL GTPAD
|
|
1992
|
+
LD L,A ;HL := Y data (0-255)
|
|
1993
|
+
LD H,0
|
|
1994
|
+
LD C,A
|
|
1995
|
+
LD B,0
|
|
1996
|
+
ADD HL,BC ;HL := HL*3 (HL := 0-767)
|
|
1997
|
+
ADD HL,BC
|
|
1998
|
+
LD A,L
|
|
1999
|
+
AND 11100000B
|
|
2000
|
+
LD L,A
|
|
2001
|
+
LD A,(WORK)
|
|
2002
|
+
ADD A,L
|
|
2003
|
+
LD L,A
|
|
2004
|
+
LD BC,1800H ;VRAM start address
|
|
2005
|
+
ADD HL,BC
|
|
2006
|
+
LD A,2AH
|
|
2007
|
+
CALL WRTVRM ;write VRAM
|
|
2008
|
+
LD A,3
|
|
2009
|
+
CALL GTPAD ;break check
|
|
2010
|
+
OR A
|
|
2011
|
+
RET NZ
|
|
2012
|
+
JR PAD
|
|
2013
|
+
|
|
2014
|
+
;----- work area -----
|
|
2015
|
+
|
|
2016
|
+
WORK: DW 0 ;work
|
|
2017
|
+
|
|
2018
|
+
END
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
|
|
2022
|
+
##### _List 5.9 Mouse and track ball use_
|
|
2023
|
+
|
|
2024
|
+
```
|
|
2025
|
+
;************************************************
|
|
2026
|
+
;
|
|
2027
|
+
; List 5.9 mouse and track ball access
|
|
2028
|
+
;
|
|
2029
|
+
;************************************************
|
|
2030
|
+
;
|
|
2031
|
+
GTPAD EQU 00DBH
|
|
2032
|
+
WRTVRM EQU 004DH
|
|
2033
|
+
RDVRM EQU 004AH
|
|
2034
|
+
BREAKX EQU 00B7H
|
|
2035
|
+
|
|
2036
|
+
ORG 0D000H
|
|
2037
|
+
|
|
2038
|
+
;----- program start ----- Note: Displays "*" at position specified
|
|
2039
|
+
by mouse or track ball.
|
|
2040
|
+
|
|
2041
|
+
TEST: CALL VADR ;Put old data
|
|
2042
|
+
LD A,(WKOLD)
|
|
2043
|
+
CALL WRTVRM
|
|
2044
|
+
LD A,12
|
|
2045
|
+
CALL GTPAD ;Request mouse/track ball data
|
|
2046
|
+
LD A,13
|
|
2047
|
+
CALL GTPAD ;Read X val.
|
|
2048
|
+
LD (WKXVAL),A
|
|
2049
|
+
LD A,14
|
|
2050
|
+
CALL GTPAD ;Read Y val.
|
|
2051
|
+
LD (WKYVAL),A
|
|
2052
|
+
|
|
2053
|
+
LD A,(WKX)
|
|
2054
|
+
LD B,A
|
|
2055
|
+
LD A,(WKXVAL)
|
|
2056
|
+
ADD A,B
|
|
2057
|
+
CP 245 ;X<0?
|
|
2058
|
+
JR C,TEST01
|
|
2059
|
+
XOR A ;X=0
|
|
2060
|
+
JR TEST02
|
|
2061
|
+
|
|
2062
|
+
TEST01: CP 32 ;X>31?
|
|
2063
|
+
JR C,TEST02
|
|
2064
|
+
LD A,31
|
|
2065
|
+
|
|
2066
|
+
TEST02: LD (WKX),A
|
|
2067
|
+
|
|
2068
|
+
LD A,(WKY)
|
|
2069
|
+
LD B,A
|
|
2070
|
+
LD A,(WKYVAL)
|
|
2071
|
+
ADD A,B
|
|
2072
|
+
CP 245 ;Y<0?
|
|
2073
|
+
JR C,TEST03
|
|
2074
|
+
XOR A ;Y=0
|
|
2075
|
+
JR TEST04
|
|
2076
|
+
|
|
2077
|
+
TEST03: CP 24 ;Y>23?
|
|
2078
|
+
JR C,TEST04
|
|
2079
|
+
LD A,23
|
|
2080
|
+
|
|
2081
|
+
TEST04: LD (WKY),A
|
|
2082
|
+
|
|
2083
|
+
CALL VADR
|
|
2084
|
+
CALL RDVRM ;Read old data
|
|
2085
|
+
LD (WKOLD),A
|
|
2086
|
+
|
|
2087
|
+
CALL VADR
|
|
2088
|
+
LD A,2AH
|
|
2089
|
+
CALL WRTVRM ;Put cursor ("*").
|
|
2090
|
+
|
|
2091
|
+
CALL BREAKX ;Break check
|
|
2092
|
+
RET C
|
|
2093
|
+
|
|
2094
|
+
CALL WAIT
|
|
2095
|
+
|
|
2096
|
+
JR TEST
|
|
2097
|
+
|
|
2098
|
+
VADR: LD A,(WKY) ;Make SCREEN Address:
|
|
2099
|
+
LD H,A ; From X,Y axis on WORK AREA
|
|
2100
|
+
LD L,0 ; To Hl reg.
|
|
2101
|
+
SRL H
|
|
2102
|
+
RR L
|
|
2103
|
+
SRL H
|
|
2104
|
+
RR L
|
|
2105
|
+
SRL H
|
|
2106
|
+
RR L
|
|
2107
|
+
LD A,(WKX)
|
|
2108
|
+
ADD A,L ; Y=32+X
|
|
2109
|
+
LD L,A
|
|
2110
|
+
LD BC,1800H ; VRAM start address
|
|
2111
|
+
ADD HL,BC
|
|
2112
|
+
RET
|
|
2113
|
+
|
|
2114
|
+
WAIT: LD A,0 ;WAIT routine
|
|
2115
|
+
WLP1: INC A
|
|
2116
|
+
LD B,(IX+0)
|
|
2117
|
+
LD B,(IX+0)
|
|
2118
|
+
LD B,(IX+0)
|
|
2119
|
+
JR NZ,WLP1
|
|
2120
|
+
RET
|
|
2121
|
+
|
|
2122
|
+
;----- data -----
|
|
2123
|
+
|
|
2124
|
+
WKX: DB 10 ;X axis
|
|
2125
|
+
WKY: DB 10 ;Y axis
|
|
2126
|
+
WKOLD: DB 0 ;Character code on (X,Y)
|
|
2127
|
+
WKXVAL: DB 0 ;X variable
|
|
2128
|
+
WKYVAL: DB 0 ;Y variable
|
|
2129
|
+
|
|
2130
|
+
END
|
|
2131
|
+
```
|
|
2132
|
+
|
|
2133
|
+
|
|
2134
|
+
<p> </p>
|
|
2135
|
+
|
|
2136
|
+
## 6. CLOCK AND BATTERY-POWERED MEMORY
|
|
2137
|
+
|
|
2138
|
+
MSX2 uses a CLOCK-IC to for its timer function. Since this IC is battery-powered, it remains active even after MSX2 is turned off. MSX2 uses a small amount of RAM inside to set the PASSWORD or to set the screen mode at startup automatically, in addition to the CLOCK functions.
|
|
2139
|
+
|
|
2140
|
+
|
|
2141
|
+
<p> </p>
|
|
2142
|
+
|
|
2143
|
+
### 6.1 CLOCK-IC Functions
|
|
2144
|
+
|
|
2145
|
+
This IC has the following three functions:
|
|
2146
|
+
|
|
2147
|
+
|
|
2148
|
+
#### CLOCK function
|
|
2149
|
+
|
|
2150
|
+
- set/read the settings of "year, month, day, day of week, hour, minute, second"
|
|
2151
|
+
- for the expression of time, 24-hour clock/12-hour clock available
|
|
2152
|
+
- for months, months of 31 days and of 30 days are distinguished (leap years are also recognised)
|
|
2153
|
+
|
|
2154
|
+
|
|
2155
|
+
#### Alarm function
|
|
2156
|
+
|
|
2157
|
+
- when the time for alarm is set, CLOCK generates signals at that time.
|
|
2158
|
+
- the time for alarm is set as "XXday XXhour XXminute".
|
|
2159
|
+
|
|
2160
|
+
|
|
2161
|
+
#### Battery-powered memory function
|
|
2162
|
+
|
|
2163
|
+
- has 26 sets of 4-bit memory, and can be battery-powered.
|
|
2164
|
+
- MSX2 stores the following data in this memory:
|
|
2165
|
+
|
|
2166
|
+
1. adjustment value of CRT display width and height
|
|
2167
|
+
2. initial values of SCREEN, WIDTH, colour
|
|
2168
|
+
3. BEEP tone and volume
|
|
2169
|
+
4. title screen colour
|
|
2170
|
+
5. country code
|
|
2171
|
+
6. password *
|
|
2172
|
+
7. BASIC prompt *
|
|
2173
|
+
8. title caption *
|
|
2174
|
+
|
|
2175
|
+
\* (one of 6 to 8)
|
|
2176
|
+
|
|
2177
|
+
|
|
2178
|
+
<p> </p>
|
|
2179
|
+
|
|
2180
|
+
### 6.2 Structure of the CLOCK-IC
|
|
2181
|
+
|
|
2182
|
+
The CLOCK-IC has four blocks inside as shown in [Figure 5.25](#figure-525--clock-ic-structure). Each block consists of 13 sets of 4-bit registers, which are specified by addresses from 0 to 12. In addition, it has three 4-bit registers for selecting the block or controlling functions; they are specified by the addresses from 13 to 15.
|
|
2183
|
+
|
|
2184
|
+
The registers inside the block (#0 to #12) and the MODE register (#13) can be read from and written to. The TEST register (#14) and RESET register (#15) can only be written to.
|
|
2185
|
+
|
|
2186
|
+
|
|
2187
|
+
##### _Figure 5.25 Clock IC structure_
|
|
2188
|
+
|
|
2189
|
+
```
|
|
2190
|
+
BLOCK 0 BLOCK 1 BLOCK 2 BLOCK 2
|
|
2191
|
+
(CLOCK) (ALARM) (RAM-1) (RAM-2)
|
|
2192
|
+
---------------- ---------------- ---------------- ----------------
|
|
2193
|
+
| Seconds (the | | | | | | |
|
|
2194
|
+
0 | 1st decimal | | ________ | | | | |
|
|
2195
|
+
| place) | | | | | | |
|
|
2196
|
+
|--------------| |--------------| |- -| |- -|
|
|
2197
|
+
| Seconds (the | | | | | | |
|
|
2198
|
+
1 | 2nd decimal | | ________ | | | | |
|
|
2199
|
+
| place) | | | | | | |
|
|
2200
|
+
|--------------| |--------------| |- -| |- -|
|
|
2201
|
+
. | . | | . | | Any data | | Any data |
|
|
2202
|
+
. | . | | . | | | | |
|
|
2203
|
+
. | . | | . | | | | |
|
|
2204
|
+
. | . | | . | | | | |
|
|
2205
|
+
. | . | | . | | | | |
|
|
2206
|
+
|--------------| |--------------| |- -| |- -|
|
|
2207
|
+
| Year (the | | | | | | |
|
|
2208
|
+
12| 2nd decimal | | ________ | | | | |
|
|
2209
|
+
| place) | | | | | | |
|
|
2210
|
+
---------------- ---------------- ---------------- ----------------
|
|
2211
|
+
:<-- 4 bits -->: :<-- 4 bits -->: :<-- 4 bits -->: :<-- 4 bits -->:
|
|
2212
|
+
|
|
2213
|
+
|
|
2214
|
+
----------------
|
|
2215
|
+
13 | MODE |
|
|
2216
|
+
|--------------| --+
|
|
2217
|
+
14 | TEST | |
|
|
2218
|
+
|--------------| |-- Write only
|
|
2219
|
+
15 | RESET | |
|
|
2220
|
+
---------------- --+
|
|
2221
|
+
:<-- 4 bits -->:
|
|
2222
|
+
```
|
|
2223
|
+
|
|
2224
|
+
<p> </p>
|
|
2225
|
+
|
|
2226
|
+
### 6.3 MODE Register Functions
|
|
2227
|
+
|
|
2228
|
+
The MODE register has the following 3 functions:
|
|
2229
|
+
|
|
2230
|
+
|
|
2231
|
+
#### Selecting block
|
|
2232
|
+
|
|
2233
|
+
To read from or write to registers from #0 to #12, select the block to be used and then access the objective address. The 2 low order bits of the MODE register are used to select the block.
|
|
2234
|
+
|
|
2235
|
+
Registers from #13 to #15 are accessible whichever block is selected.
|
|
2236
|
+
|
|
2237
|
+
|
|
2238
|
+
#### Alarm output ON/OFF
|
|
2239
|
+
|
|
2240
|
+
To switch the alarm input ON/OFF, use bit 2 of the MODE register. Since the standard MSX2 does not support the alarm, modifying this bit causes nothing to happen in general.
|
|
2241
|
+
|
|
2242
|
+
|
|
2243
|
+
#### Terminating CLOCK count
|
|
2244
|
+
|
|
2245
|
+
By writing "0" in bit 3 of the MODE register, the count in seconds is stopped (the stages before the seconds are not stopped) and the clock function is terminated. By writing "1" in bit 3, the count is resumed.
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
##### _Figure 5.26 MODE register functions_
|
|
2249
|
+
|
|
2250
|
+
```
|
|
2251
|
+
B3 B2 B1 B0
|
|
2252
|
+
---------------------
|
|
2253
|
+
| TE | AE | M1 : M0 | MODE register (#13)
|
|
2254
|
+
---------------------
|
|
2255
|
+
| | | 00: select block 0
|
|
2256
|
+
| | | 01: select block 1
|
|
2257
|
+
| | +----> 10: select block 2
|
|
2258
|
+
| | 11: select block 3
|
|
2259
|
+
| |
|
|
2260
|
+
| +------------> 0: alarm output OFF
|
|
2261
|
+
| 1: alarm output ON
|
|
2262
|
+
|
|
|
2263
|
+
+-----------------> 0: CLOCK count stop (in seconds)
|
|
2264
|
+
1: CLOCK count start
|
|
2265
|
+
```
|
|
2266
|
+
|
|
2267
|
+
<p> </p>
|
|
2268
|
+
|
|
2269
|
+
### 6.4 TEST Register functions
|
|
2270
|
+
|
|
2271
|
+
The TEST register (#14) is used to increment the upper counter quickly and to confirm that date and time carries are done correctly. Setting "1" in each bit of the register, the pulse of 2^14 (=16384)[Hz] is directly set in day, hour, minute, and second counters.
|
|
2272
|
+
|
|
2273
|
+
|
|
2274
|
+
##### _Figure 5.27 TEST register functions_
|
|
2275
|
+
|
|
2276
|
+
```
|
|
2277
|
+
B3 B2 B1 B0
|
|
2278
|
+
---------------------
|
|
2279
|
+
| T3 | T2 | T1 | T0 | TEST register (#14)
|
|
2280
|
+
---------------------
|
|
2281
|
+
| | | |
|
|
2282
|
+
| Hours | Seconds ........ the location for the pulse to be placed
|
|
2283
|
+
Day Minutes
|
|
2284
|
+
```
|
|
2285
|
+
|
|
2286
|
+
<p> </p>
|
|
2287
|
+
|
|
2288
|
+
### 6.5 RESET Register Functions
|
|
2289
|
+
|
|
2290
|
+
The RESET register (#15) has the following functions:
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
#### Resetting the alarm
|
|
2294
|
+
|
|
2295
|
+
Setting "1" in bit 0 causes all alarm registers to be reset to 0.
|
|
2296
|
+
|
|
2297
|
+
|
|
2298
|
+
#### Setting the seconds
|
|
2299
|
+
|
|
2300
|
+
Setting "1" in bit 1 causes the stage before the seconds to be reset. Use this function to set the seconds correctly.
|
|
2301
|
+
|
|
2302
|
+
|
|
2303
|
+
#### Clock pulse ON/OFF
|
|
2304
|
+
|
|
2305
|
+
Setting "1" in bit 2 turns the 16Hz clock pulse output ON, and setting "0" in bit 3 turns the 1Hz clock pulse output ON. Note that both are not supported by the MSX2 standard.
|
|
2306
|
+
|
|
2307
|
+
|
|
2308
|
+
##### _Figure 5.28 RESET register function_
|
|
2309
|
+
|
|
2310
|
+
```
|
|
2311
|
+
B3 B2 B1 B0
|
|
2312
|
+
---------------------
|
|
2313
|
+
| C1 | C16| CR | AR | RESET register (#15)
|
|
2314
|
+
---------------------
|
|
2315
|
+
| | | |
|
|
2316
|
+
| | | +--> When "1", all alarm registers are reset
|
|
2317
|
+
| | +-------> When "1", fractions smaller than a second are reset
|
|
2318
|
+
| +------------> When "0", 16[Hz] clock pulse is ON
|
|
2319
|
+
+-----------------> When "0", 1[Hz] clock pulse is ON
|
|
2320
|
+
```
|
|
2321
|
+
|
|
2322
|
+
<p> </p>
|
|
2323
|
+
|
|
2324
|
+
### 6.6 Setting the Clock and Alarm
|
|
2325
|
+
|
|
2326
|
+
#### Setting date and time
|
|
2327
|
+
|
|
2328
|
+
Block 0 is used to set the clock. Selecting block 0 in the MODE register and writing data in the objective register causes the date and the time to be set. The current time is acquired by reading the contents of the register. See [Figure 5.29](#figure-529--setting-the-clock-and-alarm) for the meaning of the register and its address.
|
|
2329
|
+
|
|
2330
|
+
Block 1 is used to set the alarm. Note that the time of the alarm can be set only in days, hours, and minutes. Nothing happens, in general, when the time of the clock meets the time of the alarm.
|
|
2331
|
+
|
|
2332
|
+
In the clock, the year is represented by 2 digits (registers #11 and #12). In MSX-BASIC, the 2 low order digits of the year is represented by adding the offset 80 to this value. For example, after setting register #11 to 0 and register #12 to 0, the year would be 80, as "80/XX/XX", when the date is read by using the GET DATE instruction of BASIC.
|
|
2333
|
+
|
|
2334
|
+
The day of the week is represented by 0 to 6. This is only a mod 7 counter which is renewed alomg with the date, and the correspondence between the actual day of the week and the number value 0 to 6 is not defined.
|
|
2335
|
+
|
|
2336
|
+
|
|
2337
|
+
##### _Figure 5.29 Setting the CLOCK and ALARM_
|
|
2338
|
+
|
|
2339
|
+
```
|
|
2340
|
+
block 0 : CLOCK
|
|
2341
|
+
---------------------------------------------------------
|
|
2342
|
+
| | B3 | B2 | B1 | B0 |
|
|
2343
|
+
|---------------------------+---------------------------|
|
|
2344
|
+
0 | Seconds | |
|
|
2345
|
+
| (the 1st decimal place) | X X X X |
|
|
2346
|
+
|---------------------------+---------------------------|
|
|
2347
|
+
1 | Seconds | |
|
|
2348
|
+
| (the 2nd decimal place) | . X X X |
|
|
2349
|
+
|---------------------------+---------------------------|
|
|
2350
|
+
2 | Minutes | |
|
|
2351
|
+
| (the 1st decimal place) | X X X X |
|
|
2352
|
+
|---------------------------+---------------------------|
|
|
2353
|
+
3 | Minutes | |
|
|
2354
|
+
| (the 2nd decimal place) | . X X X |
|
|
2355
|
+
|---------------------------+---------------------------|
|
|
2356
|
+
4 | Hours | |
|
|
2357
|
+
| (the 1st decimal place) | X X X X |
|
|
2358
|
+
|---------------------------+---------------------------|
|
|
2359
|
+
5 | Hours | |
|
|
2360
|
+
| (the 2nd decimal place) | . . X X |
|
|
2361
|
+
|---------------------------+---------------------------|
|
|
2362
|
+
6 | Day of | |
|
|
2363
|
+
| the week | . X X X |
|
|
2364
|
+
|---------------------------+---------------------------|
|
|
2365
|
+
7 | Day | |
|
|
2366
|
+
| (the 1st decimal place) | X X X X |
|
|
2367
|
+
|---------------------------+---------------------------|
|
|
2368
|
+
8 | Day | |
|
|
2369
|
+
| (the 2nd decimal place) | . . X X |
|
|
2370
|
+
|---------------------------+---------------------------|
|
|
2371
|
+
9 | Month | |
|
|
2372
|
+
| (the 1st decimal place) | X X X X |
|
|
2373
|
+
|---------------------------+---------------------------|
|
|
2374
|
+
10 | Month | |
|
|
2375
|
+
| (the 2nd decimal place) | . . . X |
|
|
2376
|
+
|---------------------------+---------------------------|
|
|
2377
|
+
11 | Year | |
|
|
2378
|
+
| (the 1st decimal place) | X X X X |
|
|
2379
|
+
|---------------------------+---------------------------|
|
|
2380
|
+
12 | Year | |
|
|
2381
|
+
| (the 2nd decimal place) | X X X X |
|
|
2382
|
+
---------------------------------------------------------
|
|
2383
|
+
|
|
2384
|
+
block 1 : ALARM
|
|
2385
|
+
---------------------------------------------------------
|
|
2386
|
+
| | B3 | B2 | B1 | B0 |
|
|
2387
|
+
|---------------------------+---------------------------|
|
|
2388
|
+
0 | _________________ | |
|
|
2389
|
+
| | . . . . |
|
|
2390
|
+
|---------------------------+---------------------------|
|
|
2391
|
+
1 | _________________ | |
|
|
2392
|
+
| | . . . . |
|
|
2393
|
+
|---------------------------+---------------------------|
|
|
2394
|
+
2 | Minutes | |
|
|
2395
|
+
| (the 1st decimal place) | X X X X |
|
|
2396
|
+
|---------------------------+---------------------------|
|
|
2397
|
+
3 | Minutes | |
|
|
2398
|
+
| (the 2nd decimal place) | . X X X |
|
|
2399
|
+
|---------------------------+---------------------------|
|
|
2400
|
+
4 | Hours | |
|
|
2401
|
+
| (the 1st decimal place) | X X X X |
|
|
2402
|
+
|---------------------------+---------------------------|
|
|
2403
|
+
5 | Hours | |
|
|
2404
|
+
| (the 2nd decimal place) | . . X X |
|
|
2405
|
+
|---------------------------+---------------------------|
|
|
2406
|
+
6 | Day of | |
|
|
2407
|
+
| the week | . X X X |
|
|
2408
|
+
|---------------------------+---------------------------|
|
|
2409
|
+
7 | Day | |
|
|
2410
|
+
| (the 1st decimal place) | X X X X |
|
|
2411
|
+
|---------------------------+---------------------------|
|
|
2412
|
+
8 | Day | |
|
|
2413
|
+
| (the 2nd decimal place) | . . X X |
|
|
2414
|
+
|---------------------------+---------------------------|
|
|
2415
|
+
9 | _________________ | |
|
|
2416
|
+
| | . . . . |
|
|
2417
|
+
|---------------------------+---------------------------|
|
|
2418
|
+
10 | 12 or | |
|
|
2419
|
+
| 24 hours | . . . X |
|
|
2420
|
+
|---------------------------+---------------------------|
|
|
2421
|
+
11 | Leap year | |
|
|
2422
|
+
| counter | . . X X |
|
|
2423
|
+
|---------------------------+---------------------------|
|
|
2424
|
+
12 | _________________ | |
|
|
2425
|
+
| | . . . . |
|
|
2426
|
+
---------------------------------------------------------
|
|
2427
|
+
```
|
|
2428
|
+
|
|
2429
|
+
Bits indicated by an "." are always 0 and cannot be modified.
|
|
2430
|
+
|
|
2431
|
+
|
|
2432
|
+
#### Selecting 12-hour clock/24-hour clock
|
|
2433
|
+
|
|
2434
|
+
Two clocks can be selected; one is a 24-hour clock which represents one o'clock in the afternoon as 13 o'clock, and the other is a 12-hour clock which represents it as 1 p.m. Register #10 is used to select between them. As shown in [Figure 5.30](#figure-530--selecting-12-hour-clock24-hour-clock), the 12-hour clock is selected when B0 is "0" and the 24-hour clock when B0 is "1".
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
##### _Figure 5.30 Selecting 12-hour clock/24-hour clock_
|
|
2438
|
+
|
|
2439
|
+
```
|
|
2440
|
+
B3 B2 B1 B0
|
|
2441
|
+
---------------------
|
|
2442
|
+
| . | . | . | B0 | Register #10 (block 1)
|
|
2443
|
+
---------------------
|
|
2444
|
+
|
|
|
2445
|
+
+--> 0: 12-hour clock
|
|
2446
|
+
1: 24-hour clock
|
|
2447
|
+
```
|
|
2448
|
+
|
|
2449
|
+
##### _Figure 5.31 Morning/afternoon flag for 12-hour clock_
|
|
2450
|
+
|
|
2451
|
+
```
|
|
2452
|
+
B3 B2 B1 B0
|
|
2453
|
+
---------------------
|
|
2454
|
+
| . | . | B1 | X | register #5 (block 0)
|
|
2455
|
+
---------------------
|
|
2456
|
+
|
|
|
2457
|
+
+-------> 0: before noon
|
|
2458
|
+
1: after noon
|
|
2459
|
+
```
|
|
2460
|
+
|
|
2461
|
+
#### Leap year counter
|
|
2462
|
+
|
|
2463
|
+
Register #11 of block 1 is a mod 4 counter which is renewed along with the count of the year. When the 2 low order bits of this register are 00H, that is considered as a leap year and 29 days are counted in February.
|
|
2464
|
+
|
|
2465
|
+
|
|
2466
|
+
##### _Figure 5.32 Leap year determination_
|
|
2467
|
+
|
|
2468
|
+
```
|
|
2469
|
+
B3 B2 B1 B0
|
|
2470
|
+
---------------------
|
|
2471
|
+
| . | . | B1 | B0 | Register #11 (block 1)
|
|
2472
|
+
---------------------
|
|
2473
|
+
| |
|
|
2474
|
+
+----+--> Both bits 0 represents leap year.
|
|
2475
|
+
```
|
|
2476
|
+
|
|
2477
|
+
<p> </p>
|
|
2478
|
+
|
|
2479
|
+
### 6.7 Contents of the Battery-powered Memory
|
|
2480
|
+
|
|
2481
|
+
Blocks 2 and 3 of the CLOCK-IC are used as the battery-powered 4-bit x 13 memory blocks. MSX2 uses this area as shown below.
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
#### Contents of block 2
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
##### _Figure 5.33 Contents of block 2_
|
|
2488
|
+
|
|
2489
|
+
```
|
|
2490
|
+
| B3 | B2 | B1 | B0 |
|
|
2491
|
+
|-------------------------------------------------------------------|
|
|
2492
|
+
0 | ID |
|
|
2493
|
+
|-------------------------------------------------------------------|
|
|
2494
|
+
1 | Adjust X (-8 to +7) |
|
|
2495
|
+
|-------------------------------------------------------------------|
|
|
2496
|
+
2 | Adjust Y (-8 to +7) |
|
|
2497
|
+
|-------------------------------------------------------------------|
|
|
2498
|
+
3 | __________ | __________ | Interlace mode | Screen mode |
|
|
2499
|
+
|-------------------------------------------------------------------|
|
|
2500
|
+
4 | WIDTH value (Lo) |
|
|
2501
|
+
|-------------------------------------------------------------------|
|
|
2502
|
+
5 | WIDTH value (Hi) |
|
|
2503
|
+
|-------------------------------------------------------------------|
|
|
2504
|
+
6 | Foreground color |
|
|
2505
|
+
|-------------------------------------------------------------------|
|
|
2506
|
+
7 | Background color |
|
|
2507
|
+
|-------------------------------------------------------------------|
|
|
2508
|
+
8 | Border color |
|
|
2509
|
+
|-------------------------------------------------------------------|
|
|
2510
|
+
9 | Cassette speed | Printer mode | Key click | Key ON/OFF |
|
|
2511
|
+
|---------------------------------+---------------------------------|
|
|
2512
|
+
10 | BEEP tone | BEEP volume |
|
|
2513
|
+
|---------------------------------+---------------------------------|
|
|
2514
|
+
11 | __________ | __________ | Title colour |
|
|
2515
|
+
|-------------------------------------------------------------------|
|
|
2516
|
+
12 | Native code |
|
|
2517
|
+
---------------------------------------------------------------------
|
|
2518
|
+
```
|
|
2519
|
+
|
|
2520
|
+
#### Contents of block 3
|
|
2521
|
+
|
|
2522
|
+
Block 3 has three functions, depending on the contents of the ID value (register #0). [Figure 5.34](#figure-534--contents-of-block-3) shows the functions.
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
##### _Figure 5.34 Contents of block 3_
|
|
2526
|
+
|
|
2527
|
+
```
|
|
2528
|
+
ID=0: displays the title (within 6 characters) on the initial screen
|
|
2529
|
+
------------------------------------------------------
|
|
2530
|
+
0 | 0 |
|
|
2531
|
+
|----------------------------------------------------| --+
|
|
2532
|
+
1 | Lo 1 --+--- 1st character of the title | |
|
|
2533
|
+
| | | |
|
|
2534
|
+
2 | Hi 1 --+ | |
|
|
2535
|
+
|----------------------------------------------------| |
|
|
2536
|
+
. | . | |
|
|
2537
|
+
. | . | | 6 characters
|
|
2538
|
+
. | . | |
|
|
2539
|
+
|----------------------------------------------------| |
|
|
2540
|
+
11 | Lo 6 --+--- 6th character of the title | |
|
|
2541
|
+
| | | |
|
|
2542
|
+
12 | Hi 6 --+ | |
|
|
2543
|
+
------------------------------------------------------ --+
|
|
2544
|
+
|
|
2545
|
+
ID=1: sets the password
|
|
2546
|
+
------------------------------------------------------
|
|
2547
|
+
0 | 1 |
|
|
2548
|
+
|----------------------------------------------------|
|
|
2549
|
+
1 | Usage ID=1 |
|
|
2550
|
+
| |
|
|
2551
|
+
2 | Usage ID=2 |
|
|
2552
|
+
| |
|
|
2553
|
+
3 | Usage ID=3 |
|
|
2554
|
+
|----------------------------------------------------|
|
|
2555
|
+
4 | Password --+ |
|
|
2556
|
+
| | |
|
|
2557
|
+
5 | Password | Password data is stored |
|
|
2558
|
+
| |-- compressed in 4bits x 4 bits |
|
|
2559
|
+
6 | Password | |
|
|
2560
|
+
| | |
|
|
2561
|
+
7 | Password --+ |
|
|
2562
|
+
|----------------------------------------------------|
|
|
2563
|
+
8 | Key cartridge flag |
|
|
2564
|
+
|----------------------------------------------------|
|
|
2565
|
+
9 | Key cartridge value |
|
|
2566
|
+
| |
|
|
2567
|
+
10 | Key cartridge value |
|
|
2568
|
+
| |
|
|
2569
|
+
11 | Key cartridge value |
|
|
2570
|
+
| |
|
|
2571
|
+
12 | Key cartridge value |
|
|
2572
|
+
------------------------------------------------------
|
|
2573
|
+
|
|
2574
|
+
ID=2: sets the prompt on BASIC
|
|
2575
|
+
------------------------------------------------------
|
|
2576
|
+
0 | 2 |
|
|
2577
|
+
|----------------------------------------------------| --+
|
|
2578
|
+
1 | Lo 1 --+--- 1st character of the prompt | |
|
|
2579
|
+
| | | |
|
|
2580
|
+
2 | Hi 1 --+ | |
|
|
2581
|
+
|----------------------------------------------------| |
|
|
2582
|
+
. | . | |
|
|
2583
|
+
. | . | | 6 characters
|
|
2584
|
+
. | . | |
|
|
2585
|
+
|----------------------------------------------------| |
|
|
2586
|
+
11 | Lo 6 --+--- 6th character of the prompt | |
|
|
2587
|
+
| | | |
|
|
2588
|
+
12 | Hi 6 --+ | |
|
|
2589
|
+
------------------------------------------------------ --+
|
|
2590
|
+
```
|
|
2591
|
+
|
|
2592
|
+
<p> </p>
|
|
2593
|
+
|
|
2594
|
+
### 6.8 Access to the CLOCK-IC
|
|
2595
|
+
|
|
2596
|
+
The following BIOS routines are offered to access the clock and the battery-powered memory. Since these routines reside in SUB-ROM, they are called by using the inter-slot call.
|
|
2597
|
+
|
|
2598
|
+
|
|
2599
|
+
<p> </p>
|
|
2600
|
+
|
|
2601
|
+
#### REDCLK (015FH/SUB) - read CLOCK-IC data
|
|
2602
|
+
|
|
2603
|
+
* **Input**: C ⟵ CLOCK-IC address (see [Figure 5.35](#figure-535--clock-ic-register-specification-method))
|
|
2604
|
+
* **Output**: A ⟵ data obtained (only 4 low order bits valid)
|
|
2605
|
+
* **Function**: reads CLOCK-IC register in the address specified by the C register and stores in the A register. Since the address specification includes the block selection information as shown in [Figure 5.35](#figure-535--clock-ic-register-specification-method), it is not necessary to set the MODE register and then read the objective register.
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
##### _Figure 5.35 CLOCK-IC register specification method_
|
|
2609
|
+
|
|
2610
|
+
```
|
|
2611
|
+
-----------------------------------------
|
|
2612
|
+
C register | . | . | M1 : M0 | A3 : A2 : A1 : A0 |
|
|
2613
|
+
-----------------------------------------
|
|
2614
|
+
| | |
|
|
2615
|
+
+---------+-------------------+
|
|
2616
|
+
Block to be Register
|
|
2617
|
+
selected address
|
|
2618
|
+
```
|
|
2619
|
+
|
|
2620
|
+
|
|
2621
|
+
<p> </p>
|
|
2622
|
+
|
|
2623
|
+
#### WRTCLK (01F9H/SUB) - write CLOCK-IC data
|
|
2624
|
+
|
|
2625
|
+
* **Input**:
|
|
2626
|
+
* C ⟵ CLOCK-IC address (see Figure 5.35)
|
|
2627
|
+
* A ⟵ data to be written (4 low order bits)
|
|
2628
|
+
* **Output**: ---
|
|
2629
|
+
* **Function**: write the contents of the A register in the CLOCK-IC at the address specified by the C register. The address is specified in the format shown in [Figure 5.35](#figure-535--clock-ic-register-specification-method) as REDCLK.
|
|
2630
|
+
|
|
2631
|
+
|
|
2632
|
+
[List 5.10](#list-510--setting-the-prompt) shows an example of this BIOS routine.
|
|
2633
|
+
|
|
2634
|
+
|
|
2635
|
+
##### _List 5.10 Setting the prompt_
|
|
2636
|
+
|
|
2637
|
+
```
|
|
2638
|
+
;************************************************
|
|
2639
|
+
;
|
|
2640
|
+
; List 5.10 set prompt message
|
|
2641
|
+
;
|
|
2642
|
+
;************************************************
|
|
2643
|
+
;
|
|
2644
|
+
WRTCLK: EQU 01F9H
|
|
2645
|
+
EXTROM: EQU 015FH
|
|
2646
|
+
|
|
2647
|
+
ORG 0B000H
|
|
2648
|
+
|
|
2649
|
+
;----- program start ----- ;Note: Set prompt message for BASIC.
|
|
2650
|
+
|
|
2651
|
+
START: LD C,00110000B ;address data
|
|
2652
|
+
LD A,2 ;ID := prompt mode
|
|
2653
|
+
CALL WRTRAM ;write to back-up RAM
|
|
2654
|
+
|
|
2655
|
+
LD B,6 ;loop counter
|
|
2656
|
+
LD HL,STRING ;prompt data
|
|
2657
|
+
L01: LD A,(HL) ;read string data
|
|
2658
|
+
AND 0FH ;A := hi 4 bit
|
|
2659
|
+
INC C ;increment address
|
|
2660
|
+
CALL WRTRAM ;write data to back-up RAM
|
|
2661
|
+
LD A,(HL)
|
|
2662
|
+
RRCA
|
|
2663
|
+
RRCA
|
|
2664
|
+
RRCA
|
|
2665
|
+
RRCA
|
|
2666
|
+
AND 0FH
|
|
2667
|
+
INC C ;increment address
|
|
2668
|
+
CALL WRTRAM ;write low 4 bits
|
|
2669
|
+
INC HL
|
|
2670
|
+
DJNZ L01
|
|
2671
|
+
RET
|
|
2672
|
+
|
|
2673
|
+
;----- write data to back-up RAM -----
|
|
2674
|
+
|
|
2675
|
+
WRTRAM: PUSH HL
|
|
2676
|
+
PUSH BC
|
|
2677
|
+
LD IX,WRTCLK
|
|
2678
|
+
CALL EXTROM ;use interslot call
|
|
2679
|
+
POP BC
|
|
2680
|
+
POP HL
|
|
2681
|
+
RET
|
|
2682
|
+
|
|
2683
|
+
;----- string data -----
|
|
2684
|
+
|
|
2685
|
+
STRING: DB 'Ready?'
|
|
2686
|
+
|
|
2687
|
+
END
|
|
2688
|
+
```
|
|
2689
|
+
|
|
2690
|
+
## Changes from the original:
|
|
2691
|
+
|
|
2692
|
+
- In [Figure 5.2](#figure-52--psg-register-structure), unused bits are marked as "x", and inverted signals are marked with "*", for easiest readability.
|
|
2693
|
+
|
|
2694
|
+
- [Figure 5.17B](#figure-517b--msx-european-version-key-matrix) was added.
|
|
2695
|
+
|
|
2696
|
+
- In [List 5.4](#list-54--use-of-the-key-scanning-routine), the last line before the work area, "JR START", has been corrected to "JR SCAN".
|
|
2697
|
+
|
|
2698
|
+
- In [Figure 5.18](#figure-518--keyboard-ring-buffer), the addresses for GETPNT y PUTPNT were swapped. They have been corrected.
|
|
2699
|
+
|
|
2700
|
+
- In description of BIOS routines [PINLIN](#pinlin-00aehmain---one-line-input) and [INLIN](#inlin-00b1hmain---one-line-input-prompt-available), "BUF" address has been corrected from F55DH to F55EH.
|
|
2701
|
+
|
|
2702
|
+
- In [Figure 5.22](#figure-522-a--functions-of-psg-port-a) (B), "Arabaic mode display" has been changed to "Arabic or kana mode display".
|
|
2703
|
+
|
|
2704
|
+
- In description of BIOS routine [GTTRIG](#gttrig-00d8hmain---read-trigger-button), the input needed for reading B buttons has been added in the "Input" field.
|
|
2705
|
+
|
|
2706
|
+
- In [Table 5.5](#table-55--gtpad-bios-function), in the Note 4, "the trigger button of the mouse or the trigger button" has been changed to "the trigger button of the mouse or the trigger button of the track ball".
|
|
2707
|
+
|
|
2708
|
+
- In [Figure 5.29](#figure-529--setting-the-clock-and-alarm), "1200 or 2400 hours" indication has been corrected to "12 or 24 hours".
|
|
2709
|
+
|
|
2710
|
+
- In [Figure 5.32](#figure-532--leap-year-determination), "Register 3 #11" indication has been corrected to "Register #11".
|
|
2711
|
+
|
|
2712
|
+
- In [Figure 5.33](#figure-533--contents-of-block-2), "Adjust Y (8 to +7)" has been corrected to "Adjust Y (-8 to +7)".
|
|
2713
|
+
|
|
2714
|
+
- In description of BIOS routine [WRTCLK](#wrtclk-01f9hsub---write-clock-ic-data), the input needed in the A register has been added in the "Input" field.
|