@nataliapc/mcp-openmsx 1.1.4 → 1.1.8
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 +46 -2
- package/dist/openmsx.js +11 -1
- package/dist/server.js +343 -123
- package/dist/utils.js +43 -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
|
@@ -0,0 +1,3311 @@
|
|
|
1
|
+
# CHAPTER 4 - VDP AND DISPLAY SCREEN (Section 6)
|
|
2
|
+
|
|
3
|
+
## 6. VDP COMMAND USAGE
|
|
4
|
+
|
|
5
|
+
MSX-VIDEO can execute basic graphic operations, which are called VDP commands. These are done by accessing special harware and are available in the GRAPHIC 4 to GRAPHIC 7 modes. These graphic commands have been made easy to implement, requiring only that the necessary parameters be set in the proper registers before invoking them. This section describes these VDP commands.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<p> </p>
|
|
9
|
+
|
|
10
|
+
## Index
|
|
11
|
+
|
|
12
|
+
- [6. VDP COMMAND USAGE](#6-vdp-command-usage)
|
|
13
|
+
- [6.1 Coordinate System of VDP Commands](#61-coordinate-system-of-vdp-commands)
|
|
14
|
+
- [6.2 VDP Commands](#62-vdp-commands)
|
|
15
|
+
- [6.3 Logical Operations](#63-logical-operations)
|
|
16
|
+
- [6.4 Area Specification](#64-area-specification)
|
|
17
|
+
- [6.5 Use of Each Command](#65-use-of-each-command)
|
|
18
|
+
- [6.5.1 HMMC (CPU -> VRAM high-speed transfer)](#651-hmmc-cpu---vram-high-speed-transfer)
|
|
19
|
+
- [6.5.2 YMMM (high-speed transfer between VRAM in Y direction)](#652-ymmm-high-speed-transfer-between-vram-in-y-direction)
|
|
20
|
+
- [6.5.3 HMMM (high-speed transfer between VRAM)](#653--hmmm-high-speed-transfer-between-vram)
|
|
21
|
+
- [6.5.4 HMMV (painting the rectangle in high speed)](#654-hmmv-painting-the-rectangle-in-high-speed)
|
|
22
|
+
- [6.5.5 LMMC (CPU -> VRAM logical transfer)](#655-lmmc-cpu---vram-logical-transfer)
|
|
23
|
+
- [6.5.6 LMCM (VRAM - CPU logical transfer)](#656-lmcm-vram---cpu-logical-transfer)
|
|
24
|
+
- [6.5.7. LMMM (VRAM->VRAM logical transfer)](#657-lmmm-vram-vram-logical-transfer)
|
|
25
|
+
- [6.5.8 LMMV (VRAM logical paint)](#658-lmmv-vram-logical-paint)
|
|
26
|
+
- [6.5.9 LINE (drawing a line)](#659-line-drawing-a-line)
|
|
27
|
+
- [6.5.10 SRCH (colour code search)](#6510-srch-colour-code-search)
|
|
28
|
+
- [6.5.11 PSET (drawing a point)](#6511-pset-drawing-a-point)
|
|
29
|
+
- [6.5.12 POINT (reading a colour code)](#6512-point-reading-a-colour-code)
|
|
30
|
+
- [6.6 Speeding Up Commands](#66-speeding-up-commands)
|
|
31
|
+
- [6.7 Register Status at Command Termination](#67-register-status-at-command-termination)
|
|
32
|
+
- [Changes from the original](#changes-from-the-original)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<p> </p>
|
|
36
|
+
|
|
37
|
+
### 6.1 Coordinate System of VDP Commands
|
|
38
|
+
|
|
39
|
+
When VDP commands are executed, the location of the source and destination points are represented as (X, Y) coordinates as shown in [Figure 4.72](#figure-472--coordinate-system-of-vram). When commands are executed, there is no page division and the entire 128K bytes VRAM is placed in a large coordinate system.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
##### _Figure 4.72 Coordinate system of VRAM_
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
GRAPHIC 4 (SCREEN 5) GRAPHIC 5 (SCREEN 6)
|
|
46
|
+
------------------------------ 00000H ------------------------------
|
|
47
|
+
| (0,0) (255,0) | | | (0,0) (511,0) |
|
|
48
|
+
| Page 0 | | | Page 0 |
|
|
49
|
+
| (0,255) (255,255) | | | (0,255) (511,255) |
|
|
50
|
+
|----------------------------| 08000H |----------------------------|
|
|
51
|
+
| (0,256) (255,256) | | | (0,256) (511,256) |
|
|
52
|
+
| Page 1 | | | Page 1 |
|
|
53
|
+
| (0,511) (255,511) | | | (0,511) (511,511) |
|
|
54
|
+
|----------------------------| 10000H |----------------------------|
|
|
55
|
+
| (0,512) (255,512) | | | (0,512) (511,512) |
|
|
56
|
+
| Page 2 | | | Page 2 |
|
|
57
|
+
| (0,767) (255,767) | | | (0,767) (511,767) |
|
|
58
|
+
|----------------------------| 18000H |----------------------------|
|
|
59
|
+
| (0,768) (255,768) | | | (0,768) (511,768) |
|
|
60
|
+
| Page 3 | | | Page 3 |
|
|
61
|
+
| (0,1023) (255,1023) | | | (0,1023) (511,1023) |
|
|
62
|
+
------------------------------ 1FFFFH ------------------------------
|
|
63
|
+
|
|
64
|
+
GRAPHIC 7 (SCREEN 8) GRAPHIC 6 (SCREEN 7)
|
|
65
|
+
------------------------------ 00000H ------------------------------
|
|
66
|
+
| (0,0) (255,0) | | | (0,0) (511,0) |
|
|
67
|
+
| Page 0 | | | Page 0 |
|
|
68
|
+
| (0,255) (255,255) | | | (0,255) (511,255) |
|
|
69
|
+
|----------------------------| 10000H |----------------------------|
|
|
70
|
+
| (0,256) (255,256) | | | (0,256) (511,256) |
|
|
71
|
+
| Page 1 | | | Page 1 |
|
|
72
|
+
| (0,511) (255,511) | | | (0,511) (511,511) |
|
|
73
|
+
------------------------------ 1FFFFH ------------------------------
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<p> </p>
|
|
77
|
+
|
|
78
|
+
### 6.2 VDP Commands
|
|
79
|
+
|
|
80
|
+
There are 12 types of VDP commands which can be executed by MSX-VIDEO. These are shown in [Table 4.5](#table-45--list-of-vdp-commands).
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
##### _Table 4.5 List of VDP commands_
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
----------------------------------------------------------------------------
|
|
87
|
+
| Command name | Destination | Source | Units | Mnemonic | R#46 (4 hi ord) |
|
|
88
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
89
|
+
| | VRAM | CPU | bytes | HMMC | 1 1 1 1 |
|
|
90
|
+
| High speed | VRAM | VRAM | bytes | YMMM | 1 1 1 0 |
|
|
91
|
+
| move | VRAM | VRAM | bytes | HMMM | 1 1 0 1 |
|
|
92
|
+
| | VRAM | VDP | bytes | HMMV | 1 1 0 0 |
|
|
93
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
94
|
+
| | VRAM | CPU | dots | LMMC | 1 0 1 1 |
|
|
95
|
+
| Logical | CPU | VRAM | dots | LMCM | 1 0 1 0 |
|
|
96
|
+
| move | VRAM | VRAM | dots | LMMM | 1 0 0 1 |
|
|
97
|
+
| | VRAM | VDP | dots | LMMV | 1 0 0 0 |
|
|
98
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
99
|
+
| Line | VRAM | VDP | dots | LINE | 0 1 1 1 |
|
|
100
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
101
|
+
| Search | VRAM | VDP | dots | SRCH | 0 1 1 0 |
|
|
102
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
103
|
+
| Pset | VRAM | VDP | dots | PSET | 0 1 0 1 |
|
|
104
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
105
|
+
| Point | VDP | VRAM | dots | POINT | 0 1 0 0 |
|
|
106
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
107
|
+
| | ---- | ---- | ----- | ---- | 0 0 1 1 |
|
|
108
|
+
| Reserved | ---- | ---- | ----- | ---- | 0 0 1 0 |
|
|
109
|
+
| | ---- | ---- | ----- | ---- | 0 0 0 1 |
|
|
110
|
+
|--------------+-------------+--------+-------+----------+-----------------|
|
|
111
|
+
| Stop | ---- | ---- | ----- | ---- | 0 0 0 0 |
|
|
112
|
+
----------------------------------------------------------------------------
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
* When data is written in R#46 (Command register), MSX-VIDEO begins to execute the command after setting 1 to bit 0 (CE/Command Execute) of the status register S#2. Necessary parameters should be set in register R#32 to R#45 before the command is executed.
|
|
116
|
+
|
|
117
|
+
* When the execution of the command ends, CE becomes 0.
|
|
118
|
+
|
|
119
|
+
* To stop the execution of the command, execute STOP command.
|
|
120
|
+
|
|
121
|
+
* Actions of the commands are guaranteed only in the bitmap modes (GRAPHIC 4 to GRAPHIC 7).
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
<p> </p>
|
|
125
|
+
|
|
126
|
+
### 6.3 Logical Operations
|
|
127
|
+
|
|
128
|
+
When commands are executed, various logical operations can be done between data in VRAM and the specified data. Each operation will be done according to the rules listed in [Table 4.6](#table-46--list-of-logical-operations).
|
|
129
|
+
|
|
130
|
+
In the table, SC represents the source color and DC represents the destination colour. IMP, AND, OR, EOR and NOT write the result of each operation to the destination. In operations whose names are preceded by "T", dots which correspond with SC=0 are not the objects of the operations and remains as DC. Using these operations enables only colour portions of two figures to be overlapped, so they are especially effective for animations.
|
|
131
|
+
|
|
132
|
+
[List 4.7](#list-47--example-of-the-logical-operation-with-t) shows an example of these operations.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
##### _Table 4.6 List of logical operations_
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
-------------------------------------------------------------------------
|
|
139
|
+
| Logical name | |L03 L02 L01 L00|
|
|
140
|
+
|--------------+----------------------------------------+---------------|
|
|
141
|
+
| | | |
|
|
142
|
+
| IMP | DC=SC | 0 0 0 0 |
|
|
143
|
+
| | | |
|
|
144
|
+
| AND | DC=SCxDC | 0 0 0 1 |
|
|
145
|
+
| | | |
|
|
146
|
+
| OR | DC=SC+DC | 0 0 1 0 |
|
|
147
|
+
| | __ __ | |
|
|
148
|
+
| EOR | DC=SCxDC+SCxDC | 0 0 1 1 |
|
|
149
|
+
| | __ | |
|
|
150
|
+
| NOT | DC=SC | 0 1 0 0 |
|
|
151
|
+
| | | |
|
|
152
|
+
| ---- | | 0 1 0 1 |
|
|
153
|
+
| | | |
|
|
154
|
+
| ---- | | 0 1 1 0 |
|
|
155
|
+
| | | |
|
|
156
|
+
| ---- | | 0 1 1 1 |
|
|
157
|
+
| | | |
|
|
158
|
+
|--------------+----------------------------------------+---------------|
|
|
159
|
+
| | | |
|
|
160
|
+
| TIMP | if SC=0 then DC=DC else DC=SC | 1 0 0 0 |
|
|
161
|
+
| | | |
|
|
162
|
+
| TAND | if SC=0 then DC=DC else DC=SCxDC | 1 0 0 1 |
|
|
163
|
+
| | | |
|
|
164
|
+
| TOR | if SC=0 then DC=DC else DC=SC+DC | 1 0 1 0 |
|
|
165
|
+
| | __ __ | |
|
|
166
|
+
| TEOR | if SC=0 then DC=DC else DC=SCxDC+SCxDC | 1 0 1 1 |
|
|
167
|
+
| | __ | |
|
|
168
|
+
| TNOT | if SC=0 then DC=DC else DC=SC | 1 1 0 0 |
|
|
169
|
+
| | | |
|
|
170
|
+
| ---- | | 1 1 0 1 |
|
|
171
|
+
| | | |
|
|
172
|
+
| ---- | | 1 1 1 0 |
|
|
173
|
+
| | | |
|
|
174
|
+
| ---- | | 1 1 1 1 |
|
|
175
|
+
| | | |
|
|
176
|
+
-------------------------------------------------------------------------
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
* SC = Source colour code
|
|
180
|
+
* DC = Destination colour code
|
|
181
|
+
* EOR = Exclusive OR
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
##### _List 4.7 Example of the logical operation with T_
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
1000 '***********************************************************
|
|
188
|
+
1010 ' List 4.7 logical operation with T
|
|
189
|
+
1020 '***********************************************************
|
|
190
|
+
1030 '
|
|
191
|
+
1040 SCREEN8 : COLOR 15,0,0 : CLS
|
|
192
|
+
1050 DIM A%(3587)
|
|
193
|
+
1060 '
|
|
194
|
+
1070 LINE (50,50)-(60,100),48,B : PAINT (51,51),156,48
|
|
195
|
+
1080 CIRCLE (55,30),30,255 : PAINT (55,30),240,255
|
|
196
|
+
1090 COPY(20,0)-(90,100) TO A%
|
|
197
|
+
1100 CLS
|
|
198
|
+
1110 '
|
|
199
|
+
1120 R=RND(-TIME)
|
|
200
|
+
1130 FOR Y=0 TO 100 STEP 3
|
|
201
|
+
1140 X=INT(RND(1)*186)
|
|
202
|
+
1150 COPY A% TO (X,Y),,TPSET
|
|
203
|
+
1160 NEXT
|
|
204
|
+
1170 '
|
|
205
|
+
1180 GOTO 1180
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
<p> </p>
|
|
210
|
+
|
|
211
|
+
### 6.4 Area Specification
|
|
212
|
+
|
|
213
|
+
AREA-MOVE commands are for transferring screen data inside areas surrounded by a rectangle. The area to be transferred is specified by one vertex and the length of each side of the rectangle as shown in [Figure 4.73](#figure-473--area-specification). SX and SY represent the basic point of the rectangle to be transferred and NX and NY represent the lengt of each side in dots. The two bits, DIX and DIY, are for the direction of transferring data (the meaning of DIX and DIY depends on the type of command). The point where the area is to be transferred is specified in DX and DY.
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
##### _Figure 4.73 Area specification_
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
----------------------------------------------------------------
|
|
220
|
+
| |
|
|
221
|
+
| (SX,SY) |
|
|
222
|
+
| x----------------- --> |
|
|
223
|
+
| | | DIX |
|
|
224
|
+
| | | |
|
|
225
|
+
| | | |
|
|
226
|
+
| | | |
|
|
227
|
+
| ------------------ --+ |
|
|
228
|
+
| | DIY | |
|
|
229
|
+
| V | |
|
|
230
|
+
| | (DX,DY) |
|
|
231
|
+
| +-> x----------------- |
|
|
232
|
+
| | | |
|
|
233
|
+
| | | |
|
|
234
|
+
| | | |
|
|
235
|
+
| | | |
|
|
236
|
+
| ------------------ |
|
|
237
|
+
| |
|
|
238
|
+
----------------------------------------------------------------
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
<p> </p>
|
|
242
|
+
|
|
243
|
+
### 6.5 Use of Each Command
|
|
244
|
+
|
|
245
|
+
Commands are clasified into three types, high-speed transfer commands, logical transfer commands, and drawing commands. This section describes the commands and their use.
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
<p> </p>
|
|
249
|
+
|
|
250
|
+
#### 6.5.1 HMMC (CPU -> VRAM high-speed transfer)
|
|
251
|
+
|
|
252
|
+
Data is transferred into the specified area of VRAM from the CPU (see [Figure 4.74](#figure-474--action-of-hmmc-command)). Logical operations cannot be specified. Data is transferred in bytes in high-speed transfer commands such as HMMC. Note that the low order bit of the X-coordinate is not referred to in GRAPHIC 4, or 6 modes. The two low order bits are not referred to in GRAPHIC 5 mode (see [Figure 4.75](#figure-475--dots-not-to-be-referred-to)).
|
|
253
|
+
|
|
254
|
+
Set the parameters as shown in [Figure 4.76](#figure-476--register-settings-of-hmmc-command) to the appropriate registers. At this point, write only the first byte of data to be transferred from the CPU in R#44. Writing the command code F0H in R#46 causes the command to be executed, and UMSX-VIDEO receives data from R#44 and writes it to VRAM, then waits for data from the CPU.
|
|
255
|
+
|
|
256
|
+
The CPU writes data after the second byte in R#44. Note that data should be transferred after MSX-VIDEO can receive data (in the case that TR bit is "1"), referring to TR bit of S#2. When the CE bit of S#2 is "0", this means that all data has been transferred (see figure 4.77). [List 4.8](#list-48--example-of-hmmc-command-execution) shows an example of using HMMC.
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
##### _Figure 4.74 Action of HMMC command_
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
VRAM or expansion RAM
|
|
263
|
+
---------------------------------------------------
|
|
264
|
+
| | MSX-VIDEO CPU
|
|
265
|
+
| | ------- -------
|
|
266
|
+
| (DX,DY) | | | | |
|
|
267
|
+
| x------------------------ --> DIX | | | | |
|
|
268
|
+
| | NX | | | | | |
|
|
269
|
+
| | NY |<----------------+----| |-----| |
|
|
270
|
+
| | | | | | | |
|
|
271
|
+
| ------------------------- | | | | |
|
|
272
|
+
| | DIY | | | | |
|
|
273
|
+
| V | | | | |
|
|
274
|
+
| | ------- -------
|
|
275
|
+
| |
|
|
276
|
+
---------------------------------------------------
|
|
277
|
+
|
|
278
|
+
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
|
|
279
|
+
|
|
280
|
+
NX: number of dots to be transferred in X direction (0 to 511)*
|
|
281
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
282
|
+
|
|
283
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
284
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
285
|
+
|
|
286
|
+
DX: destination origin X-coordinate (0 to 511)*
|
|
287
|
+
DY: destination origin Y-coordinate (0 to 1023)
|
|
288
|
+
|
|
289
|
+
CLR (R#44:Colour register): 1st byte of data to be transferred
|
|
290
|
+
|
|
291
|
+
* The one low-order bit for GRAPHIC 4 and 6 modes,
|
|
292
|
+
or two low-order bits for GRAPHIC 5 mode of the DX and NX registers are ignored.
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
##### _Figure 4.75 Dots not to be referred to_
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
300
|
+
-----------------------------------------
|
|
301
|
+
GRAPHIC 4 | : : : | : : : |
|
|
302
|
+
-----------------------------------------
|
|
303
|
+
(1) (2)
|
|
304
|
+
Since 1 VRAM byte represents 2 dots, 1 low order bit of X-coordinate is not referred to.
|
|
305
|
+
|
|
306
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
307
|
+
-----------------------------------------
|
|
308
|
+
GRAPHIC 5 | : | : | : | : |
|
|
309
|
+
-----------------------------------------
|
|
310
|
+
(1) (2) (3) (4)
|
|
311
|
+
Since 1 VRAM byte represents 4 dots, 2 low order bits of X-coordinate are not referred to.
|
|
312
|
+
|
|
313
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
314
|
+
-----------------------------------------
|
|
315
|
+
GRAPHIC 6 | : : : | : : : |
|
|
316
|
+
-----------------------------------------
|
|
317
|
+
(1) (2)
|
|
318
|
+
Since 1 VRAM byte represents 2 dots, 1 low order bit of X-coordinate is not referred to.
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
##### _Figure 4.76 Register settings of HMMC command_
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
> HMMC register setup
|
|
325
|
+
|
|
326
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
327
|
+
-----------------------------------------
|
|
328
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
329
|
+
----------------------------------------- DX ---+
|
|
330
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
331
|
+
----------------------------------------- |
|
|
332
|
+
| destination origin
|
|
333
|
+
----------------------------------------- |
|
|
334
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
335
|
+
----------------------------------------- DY ---+
|
|
336
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
337
|
+
-----------------------------------------
|
|
338
|
+
|
|
339
|
+
-----------------------------------------
|
|
340
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
341
|
+
----------------------------------------- NX ⟶ Number of dots in X direction to be transferred
|
|
342
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
343
|
+
-----------------------------------------
|
|
344
|
+
|
|
345
|
+
-----------------------------------------
|
|
346
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
347
|
+
----------------------------------------- NY ⟶ Number of dots in Y direction to be transferred
|
|
348
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
349
|
+
-----------------------------------------
|
|
350
|
+
|
|
351
|
+
----------------------------------------- --+
|
|
352
|
+
R#44 | CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
353
|
+
----------------------------------------- |
|
|
354
|
+
| | | |
|
|
355
|
+
+-------------------+-------------------+ |
|
|
356
|
+
X=2N X=2N+1 (N=0, 1, ..., 127) |
|
|
357
|
+
|
|
|
358
|
+
----------------------------------------- |
|
|
359
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 5) | data to be transferred
|
|
360
|
+
----------------------------------------- |
|
|
361
|
+
| | | | | |
|
|
362
|
+
+---------+---------+---------+---------+ |
|
|
363
|
+
X=4N X=4N+1 X=4N+2 X=4N+3 (N=0, 1, ..., 127) |
|
|
364
|
+
|
|
|
365
|
+
----------------------------------------- |
|
|
366
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
367
|
+
----------------------------------------- --+
|
|
368
|
+
1 byte per dot
|
|
369
|
+
|
|
370
|
+
-----------------------------------------
|
|
371
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
|
|
372
|
+
-----------------------------------------
|
|
373
|
+
| | direction (X)
|
|
374
|
+
| |
|
|
375
|
+
| +-> direction (Y)
|
|
376
|
+
|
|
|
377
|
+
+-----------> select destination memory
|
|
378
|
+
|
|
379
|
+
> HMMC command execution
|
|
380
|
+
|
|
381
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
382
|
+
-----------------------------------------
|
|
383
|
+
R#46 | 1 | 1 | 1 | 1 | -- | -- | -- | -- | CMR
|
|
384
|
+
-----------------------------------------
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
##### _Figure 4.77 HMMC command execution flow chart_
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
/-------------------\
|
|
391
|
+
| HMMC start |
|
|
392
|
+
\-------------------/
|
|
393
|
+
|
|
|
394
|
+
---------------------
|
|
395
|
+
| register setup |
|
|
396
|
+
---------------------
|
|
397
|
+
|
|
|
398
|
+
---------------------
|
|
399
|
+
| command execution |
|
|
400
|
+
---------------------
|
|
401
|
+
|
|
|
402
|
+
+---------------->|
|
|
403
|
+
| |
|
|
404
|
+
| ---------------------------
|
|
405
|
+
| | Read status register #2 |
|
|
406
|
+
| ---------------------------
|
|
407
|
+
| |
|
|
408
|
+
| //////////+\\\\\\\\\\ Yes (CE bit = 0)
|
|
409
|
+
| | command end? |-------------------+
|
|
410
|
+
| \\\\\\\\\\+////////// |
|
|
411
|
+
| | No (CE bit = 1) |
|
|
412
|
+
| //////////+\\\\\\\\\\ |
|
|
413
|
+
|<------| transfer? | |
|
|
414
|
+
| No \\\\\\\\\\+////////// |
|
|
415
|
+
| (TR bit=0) | Yes (TR bit = 1) |
|
|
416
|
+
| --------------------- |
|
|
417
|
+
| | transfer data | |
|
|
418
|
+
| --------------------- |
|
|
419
|
+
| | |
|
|
420
|
+
+-----------------+ |
|
|
421
|
+
|
|
|
422
|
+
+-----------------------------+
|
|
423
|
+
|
|
|
424
|
+
V
|
|
425
|
+
/--------------------\
|
|
426
|
+
| HMMC end |
|
|
427
|
+
\--------------------/
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
##### _List 4.8 Example of HMMC command execution_
|
|
431
|
+
|
|
432
|
+
```
|
|
433
|
+
;****************************************************************
|
|
434
|
+
; List 4.8 HMMC sample
|
|
435
|
+
; to use, set H, L, D, E, IX and go
|
|
436
|
+
; RAM (IX) ⟶ VRAM (H,L)-(D,E)
|
|
437
|
+
;****************************************************************
|
|
438
|
+
;
|
|
439
|
+
RDVDP: EQU 0006H
|
|
440
|
+
WRVDP: EQU 0007H
|
|
441
|
+
|
|
442
|
+
;----- program start -----
|
|
443
|
+
|
|
444
|
+
HMMC: DI ;disable interrupt
|
|
445
|
+
CALL WAIT.VDP ;wait end of command
|
|
446
|
+
|
|
447
|
+
LD A,(WRVDP)
|
|
448
|
+
LD C,A
|
|
449
|
+
INC C ;C := PORT#1's address
|
|
450
|
+
LD A,36
|
|
451
|
+
OUT (C),A
|
|
452
|
+
LD A,17+80H
|
|
453
|
+
OUT (C),A ;R#17 := 36
|
|
454
|
+
|
|
455
|
+
INC C
|
|
456
|
+
INC C ;C := PORT#3's address
|
|
457
|
+
XOR A
|
|
458
|
+
OUT (C),H ;DX
|
|
459
|
+
OUT (C),A
|
|
460
|
+
OUT (C),L ;DY
|
|
461
|
+
OUT (C),A
|
|
462
|
+
|
|
463
|
+
LD A,H ;make NX and DIX
|
|
464
|
+
SUB A
|
|
465
|
+
LD D,00000100B
|
|
466
|
+
JR NC,HMMC1
|
|
467
|
+
LD D,00000000B
|
|
468
|
+
NEG
|
|
469
|
+
HMMC1: LD H,A ;H := NX , D := DIX
|
|
470
|
+
|
|
471
|
+
LD A,L
|
|
472
|
+
SUB A
|
|
473
|
+
LD E,00001000B
|
|
474
|
+
JR NC,HMMC2
|
|
475
|
+
LD E,00000000B
|
|
476
|
+
NEG
|
|
477
|
+
HMMC2: LD L,A ;L := NY , E := DIY
|
|
478
|
+
|
|
479
|
+
XOR A
|
|
480
|
+
OUT (C),H ;NX
|
|
481
|
+
OUT (C),A
|
|
482
|
+
OUT (C),L ;NY
|
|
483
|
+
OUT (C),A
|
|
484
|
+
LD H,(IX+0)
|
|
485
|
+
OUT (C),H ;first DATA
|
|
486
|
+
LD A,D
|
|
487
|
+
OR E
|
|
488
|
+
OUT (C),A ;DIX and DIY
|
|
489
|
+
LD A,0F0H
|
|
490
|
+
OUT (C),A ;HMMC command
|
|
491
|
+
|
|
492
|
+
LD A,(WRVDP)
|
|
493
|
+
LD C,A ;C := PORT#1's address
|
|
494
|
+
INC C
|
|
495
|
+
LD A,44+80H
|
|
496
|
+
OUT (C),A
|
|
497
|
+
LD A,17+80H
|
|
498
|
+
OUT (C),A
|
|
499
|
+
INC C
|
|
500
|
+
INC C
|
|
501
|
+
|
|
502
|
+
LOOP: LD A,2
|
|
503
|
+
CALL GET.STATUS
|
|
504
|
+
BIT 0,A ;check CE bit
|
|
505
|
+
JR Z,EXIT
|
|
506
|
+
BIT 7,A ;check TR bit
|
|
507
|
+
JR Z,LOOP
|
|
508
|
+
INC IX
|
|
509
|
+
LD A,(IX+0)
|
|
510
|
+
OUT (C),A
|
|
511
|
+
JR LOOP
|
|
512
|
+
|
|
513
|
+
EXIT: LD A,0
|
|
514
|
+
CALL GET.STATUS ;when exit, you must select S#0
|
|
515
|
+
EI
|
|
516
|
+
RET
|
|
517
|
+
|
|
518
|
+
GET.STATUS: ;read status register specified by A
|
|
519
|
+
PUSH BC
|
|
520
|
+
LD BC,(WRVDP)
|
|
521
|
+
INC C
|
|
522
|
+
OUT (C),A
|
|
523
|
+
LD A,8FH
|
|
524
|
+
OUT (C),A
|
|
525
|
+
LD BC,(RDVDP)
|
|
526
|
+
INC C
|
|
527
|
+
IN A,(C)
|
|
528
|
+
POP BC
|
|
529
|
+
RET
|
|
530
|
+
|
|
531
|
+
WAIT.VDP: ;wait VDP ready
|
|
532
|
+
LD A,2
|
|
533
|
+
CALL GET.STATUS
|
|
534
|
+
AND 1
|
|
535
|
+
JR NZ,WAIT.VDP
|
|
536
|
+
XOR A
|
|
537
|
+
CALL GET.STATUS
|
|
538
|
+
RET
|
|
539
|
+
|
|
540
|
+
END
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
<p> </p>
|
|
544
|
+
|
|
545
|
+
#### 6.5.2 YMMM (high-speed transfer between VRAM in Y direction)
|
|
546
|
+
|
|
547
|
+
Data from a specified VRAM area is transferred into another area in VRAM. Note that transfers using this command can only be done in the Y direction (see [Figure 4.78](#figure-478--actions-of-ymmm-command)).
|
|
548
|
+
|
|
549
|
+
After setting the data as shown in [Figure 4.79](#figure-479--register-settings-of-ymmm-command) in the proper registers, writing command code E0H in R#46 causes the command to be executed. When the CE bit of S#2 is "1", it indicates that the command is currently being executed. [List 4.9](#list-49--example-of-ymmm-command-execution) shows an example of using YMMM.
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
##### _Figure 4.78 Actions of YMMM command_
|
|
553
|
+
|
|
554
|
+
```
|
|
555
|
+
VRAM or expansion RAM
|
|
556
|
+
---------------------------------------------------
|
|
557
|
+
| |
|
|
558
|
+
| (DX,DY) |
|
|
559
|
+
| x------------------------|
|
|
560
|
+
| | |
|
|
561
|
+
| | |
|
|
562
|
+
| | |
|
|
563
|
+
| -------------------------|
|
|
564
|
+
| ^ |
|
|
565
|
+
| | |
|
|
566
|
+
| | |
|
|
567
|
+
| (DX,SY) |
|
|
568
|
+
| x------------------------| ⟶ DIX
|
|
569
|
+
| | |
|
|
570
|
+
| | NY |
|
|
571
|
+
| | |
|
|
572
|
+
| -------------------------|
|
|
573
|
+
| | DIY |
|
|
574
|
+
| V |
|
|
575
|
+
---------------------------------------------------
|
|
576
|
+
|
|
577
|
+
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
|
|
578
|
+
|
|
579
|
+
SY: source origin Y-coordinate (0 to 1023)
|
|
580
|
+
|
|
581
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
582
|
+
|
|
583
|
+
DIX: set which to be transferred, to te right end or to the left end of the
|
|
584
|
+
screen from the source origin 0 = right, 1 = left
|
|
585
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
586
|
+
|
|
587
|
+
DX: destination origin X-coordinate (0 to 511)*
|
|
588
|
+
DY: destination origin Y-coordinate (0 to 1023)
|
|
589
|
+
|
|
590
|
+
* The one low-order bit for GRAPHIC 4 and 6 modes,
|
|
591
|
+
or two low-order bits for GRAPHIC 5 mode of the DX register are ignored.
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
##### _Figure 4.79 Register settings of YMMM command_
|
|
595
|
+
|
|
596
|
+
```
|
|
597
|
+
> YMMM register setup
|
|
598
|
+
|
|
599
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
600
|
+
-----------------------------------------
|
|
601
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0|
|
|
602
|
+
----------------------------------------- SY ⟶ source origin
|
|
603
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
604
|
+
-----------------------------------------
|
|
605
|
+
|
|
606
|
+
-----------------------------------------
|
|
607
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
608
|
+
----------------------------------------- DX ⟶ destination and source origin
|
|
609
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8|
|
|
610
|
+
-----------------------------------------
|
|
611
|
+
|
|
612
|
+
-----------------------------------------
|
|
613
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0|
|
|
614
|
+
----------------------------------------- DY ⟶ destination origin
|
|
615
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
616
|
+
-----------------------------------------
|
|
617
|
+
|
|
618
|
+
-----------------------------------------
|
|
619
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
620
|
+
----------------------------------------- NY ⟶ number of dots to be transferred in Y direction
|
|
621
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
622
|
+
-----------------------------------------
|
|
623
|
+
|
|
624
|
+
-----------------------------------------
|
|
625
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
|
|
626
|
+
-----------------------------------------
|
|
627
|
+
| | direction (X)
|
|
628
|
+
| |
|
|
629
|
+
| +-> direction (Y)
|
|
630
|
+
|
|
|
631
|
+
+-----------> select destination memory
|
|
632
|
+
|
|
633
|
+
> YMMM command execution
|
|
634
|
+
|
|
635
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
636
|
+
-----------------------------------------
|
|
637
|
+
R#46 | 1 | 1 | 1 | 0 | -- | -- | -- | -- | CMR
|
|
638
|
+
-----------------------------------------
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
##### _List 4.9 Example of YMMM command execution_
|
|
642
|
+
|
|
643
|
+
```
|
|
644
|
+
;****************************************************************
|
|
645
|
+
; List 4.9 YMMM sample
|
|
646
|
+
; to use, set L, E, B, C, D(bit 2) and go
|
|
647
|
+
; VRAM (B,L)-(*,E) ⟶ VRAM (B,C)
|
|
648
|
+
; DIX must be set in D(bit 2)
|
|
649
|
+
;****************************************************************
|
|
650
|
+
;
|
|
651
|
+
RDVDP: EQU 0006H
|
|
652
|
+
WRVDP: EQU 0007H
|
|
653
|
+
|
|
654
|
+
;----- program start -----
|
|
655
|
+
|
|
656
|
+
YMMM: DI ;disable interrupt
|
|
657
|
+
PUSH BC ;save destination
|
|
658
|
+
CALL WAIT.VDP ;wait end of command
|
|
659
|
+
|
|
660
|
+
LD A,(WRVDP)
|
|
661
|
+
LD C,A
|
|
662
|
+
INC C ;C := PORT#1's address
|
|
663
|
+
LD A,34
|
|
664
|
+
OUT (C),A
|
|
665
|
+
LD A,17+80H
|
|
666
|
+
OUT (C),A ;R#17 := 34
|
|
667
|
+
|
|
668
|
+
INC C
|
|
669
|
+
INC C ;C := PORT#3's address
|
|
670
|
+
XOR A
|
|
671
|
+
OUT (C),L ;SY
|
|
672
|
+
OUT (C),A
|
|
673
|
+
|
|
674
|
+
LD A,L ;make NY and DIY
|
|
675
|
+
SUB A
|
|
676
|
+
LD E,00001000B
|
|
677
|
+
JP NC,YMMM1
|
|
678
|
+
LD E,00000000B
|
|
679
|
+
NEG
|
|
680
|
+
YMMM1: LD L,A ;L := NY , D := DIY
|
|
681
|
+
|
|
682
|
+
LD A,D
|
|
683
|
+
OR E
|
|
684
|
+
|
|
685
|
+
POP DE ;restore DX,DY
|
|
686
|
+
PUSH AF ;save DIX,DIY
|
|
687
|
+
XOR A
|
|
688
|
+
OUT (C),D ;DX
|
|
689
|
+
OUT (C),A
|
|
690
|
+
OUT (C),E ;DY
|
|
691
|
+
OUT (C),A
|
|
692
|
+
OUT (C),A ;dummy
|
|
693
|
+
OUT (C),A ;dummy
|
|
694
|
+
OUT (C),L ;NY
|
|
695
|
+
OUT (C),A
|
|
696
|
+
OUT (C),A ;dummy
|
|
697
|
+
POP AF
|
|
698
|
+
OUT (C),A ;DIX and DIY
|
|
699
|
+
LD A,11100000B ;YMMM command
|
|
700
|
+
OUT (C),A
|
|
701
|
+
|
|
702
|
+
EI
|
|
703
|
+
RET
|
|
704
|
+
|
|
705
|
+
GET.STATUS:
|
|
706
|
+
PUSH BC
|
|
707
|
+
LD BC,(WRVDP)
|
|
708
|
+
INC C
|
|
709
|
+
OUT (C),A
|
|
710
|
+
LD A,8FH
|
|
711
|
+
OUT (C),A
|
|
712
|
+
LD BC,(RDVDP)
|
|
713
|
+
INC C
|
|
714
|
+
IN A,(C)
|
|
715
|
+
POP BC
|
|
716
|
+
RET
|
|
717
|
+
|
|
718
|
+
WAIT.VDP:
|
|
719
|
+
LD A,2
|
|
720
|
+
CALL GET.STATUS
|
|
721
|
+
AND 1
|
|
722
|
+
JP NZ,WAIT.VDP
|
|
723
|
+
XOR A
|
|
724
|
+
CALL GET.STATUS
|
|
725
|
+
RET
|
|
726
|
+
|
|
727
|
+
END
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
<p> </p>
|
|
731
|
+
|
|
732
|
+
#### 6.5.3 HMMM (high-speed transfer between VRAM)
|
|
733
|
+
|
|
734
|
+
Data of specified VRAM area is transferred into another area in VRAM (see [Figure 4.80](#figure-480--actions-of-hmmm-command)).
|
|
735
|
+
|
|
736
|
+
After setting the parameters as shown in [Figure 4.81](#figure-481--register-settings-of-hmmm-command), writing D0H in R#46 causes the command to be executed. While the command is being executed, CE bit of S#2 is "1". [List 4.10](#list-410--example-of-hmmm-command-execution) shows an example of using HMMM.
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
##### _Figure 4.80 Actions of HMMM command_
|
|
740
|
+
|
|
741
|
+
```
|
|
742
|
+
VRAM or expansion RAM
|
|
743
|
+
----------------------------------------------------------------
|
|
744
|
+
| |
|
|
745
|
+
| (SX,SY) |
|
|
746
|
+
| ------------------ --> |
|
|
747
|
+
| | NX | DIX |
|
|
748
|
+
| | | |
|
|
749
|
+
| | NY | |
|
|
750
|
+
| | | |
|
|
751
|
+
| ------------------ --+ |
|
|
752
|
+
| | DIY | |
|
|
753
|
+
| V | |
|
|
754
|
+
| | (DX,DY) |
|
|
755
|
+
| +-> ------------------ |
|
|
756
|
+
| | | |
|
|
757
|
+
| | | |
|
|
758
|
+
| | | |
|
|
759
|
+
| | | |
|
|
760
|
+
| ------------------ |
|
|
761
|
+
| |
|
|
762
|
+
----------------------------------------------------------------
|
|
763
|
+
|
|
764
|
+
MXS: select the source memory 0 = VRAM, 1 = expansion RAM
|
|
765
|
+
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
|
|
766
|
+
|
|
767
|
+
SX: source origin X-coordinate (0 to 511)*
|
|
768
|
+
SY: source origin Y-coordinate (0 to 1023)
|
|
769
|
+
|
|
770
|
+
NX: number of dots to be transferred in X direction (0 to 511)*
|
|
771
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
772
|
+
|
|
773
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
774
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
775
|
+
|
|
776
|
+
DX: destination origin X-coordinate (0 to 511)*
|
|
777
|
+
DY: destination origin Y-coordinate (0 to 1023)
|
|
778
|
+
|
|
779
|
+
* The one low-order bit for GRAPHIC 4 and 6 modes,
|
|
780
|
+
or two low-order bits for GRAPHIC 5 mode of the SX, DX, and NX register are ignored.
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
##### _Figure 4.81 Register settings of HMMM command_
|
|
784
|
+
|
|
785
|
+
```
|
|
786
|
+
> HMMM register setup
|
|
787
|
+
|
|
788
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
789
|
+
-----------------------------------------
|
|
790
|
+
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|
|
791
|
+
|----+----+----+----+----+----+----+----| SX ---+
|
|
792
|
+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
|
|
793
|
+
----------------------------------------- |
|
|
794
|
+
| source origin
|
|
795
|
+
----------------------------------------- |
|
|
796
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|
|
797
|
+
|----+----+----+----+----+----+----+----| SY ---+
|
|
798
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
799
|
+
-----------------------------------------
|
|
800
|
+
|
|
801
|
+
-----------------------------------------
|
|
802
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
803
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
804
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
805
|
+
----------------------------------------- |
|
|
806
|
+
| destination origin
|
|
807
|
+
----------------------------------------- |
|
|
808
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
809
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
810
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
811
|
+
-----------------------------------------
|
|
812
|
+
|
|
813
|
+
-----------------------------------------
|
|
814
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
815
|
+
|----+----+----+----+----+----+----+----| NX ⟶ Number of dots in X direction to be transferred
|
|
816
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
817
|
+
-----------------------------------------
|
|
818
|
+
|
|
819
|
+
-----------------------------------------
|
|
820
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
821
|
+
|----+----+----+----+----+----+----+----| NY ⟶ Number of dots in Y direction to be transferred
|
|
822
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
823
|
+
-----------------------------------------
|
|
824
|
+
|
|
825
|
+
-----------------------------------------
|
|
826
|
+
R#45 | 0 | -- | MXD| MXS| DIY| DIX| -- | -- | ARG (Argument register)
|
|
827
|
+
-----------------------------------------
|
|
828
|
+
| | | direction (X)
|
|
829
|
+
| | |
|
|
830
|
+
| | +-> direction (Y)
|
|
831
|
+
| |
|
|
832
|
+
| +------> select source memory
|
|
833
|
+
|
|
|
834
|
+
+-----------> select destination memory
|
|
835
|
+
|
|
836
|
+
> HMMM command execution
|
|
837
|
+
|
|
838
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
839
|
+
-----------------------------------------
|
|
840
|
+
R#46 | 1 | 1 | 0 | 1 | -- | -- | -- | -- | CMR
|
|
841
|
+
-----------------------------------------
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
##### _List 4.10 Example of HMMM command execution_
|
|
845
|
+
|
|
846
|
+
```
|
|
847
|
+
;****************************************************************
|
|
848
|
+
; List 4.10 HMMM sample
|
|
849
|
+
; to use, set H, L, D, E, B, C and go
|
|
850
|
+
; VRAM (H,L)-(D,E) ⟶ VRAM (B,C)
|
|
851
|
+
; DIX must be set in D(bit 2)
|
|
852
|
+
;****************************************************************
|
|
853
|
+
;
|
|
854
|
+
RDVDP: EQU 0006H
|
|
855
|
+
WRVDP: EQU 0007H
|
|
856
|
+
|
|
857
|
+
;----- program start -----
|
|
858
|
+
|
|
859
|
+
HMMM: DI ;disable interrupt
|
|
860
|
+
PUSH BC ;save destination
|
|
861
|
+
CALL WAIT.VDP ;wait end of command
|
|
862
|
+
|
|
863
|
+
LD A,(WRVDP)
|
|
864
|
+
LD C,A
|
|
865
|
+
INC C ;C := PORT#1's address
|
|
866
|
+
LD A,32
|
|
867
|
+
OUT (C),A
|
|
868
|
+
LD A,80H+17
|
|
869
|
+
OUT (C),A ;R#17 := 32
|
|
870
|
+
|
|
871
|
+
INC C
|
|
872
|
+
INC C ;C := PORT#3's address
|
|
873
|
+
XOR A
|
|
874
|
+
OUT (C),H ;SX
|
|
875
|
+
OUT (C),A
|
|
876
|
+
OUT (C),L ;SY
|
|
877
|
+
OUT (C),A
|
|
878
|
+
|
|
879
|
+
LD A,H ;make NX and DIX
|
|
880
|
+
SUB A
|
|
881
|
+
LD D,00000100B
|
|
882
|
+
JP NC,HMMM1
|
|
883
|
+
LD D,00000000B
|
|
884
|
+
NEG
|
|
885
|
+
HMMM1: LD H,A ;H := NX , D := DIX
|
|
886
|
+
|
|
887
|
+
LD A,L ;make NY and DIY
|
|
888
|
+
SUB A
|
|
889
|
+
LD E,00001000B
|
|
890
|
+
JP NC,HMMM2
|
|
891
|
+
LD E,00000000B
|
|
892
|
+
NEG
|
|
893
|
+
HMMM2: LD L,A ;L := NY , E := DIY
|
|
894
|
+
|
|
895
|
+
LD A,D
|
|
896
|
+
OR E
|
|
897
|
+
POP DE ;restore DX,DY
|
|
898
|
+
PUSH AF ;save DIX,DIY
|
|
899
|
+
XOR A
|
|
900
|
+
OUT (C),D ;DX
|
|
901
|
+
OUT (C),A
|
|
902
|
+
OUT (C),E ;DY
|
|
903
|
+
OUT (C),A
|
|
904
|
+
OUT (C),H ;NX
|
|
905
|
+
OUT (C),A
|
|
906
|
+
OUT (C),L ;NY
|
|
907
|
+
OUT (C),A
|
|
908
|
+
OUT (C),A ;dummy
|
|
909
|
+
POP AF
|
|
910
|
+
OUT (C),A ;DIX and DIY
|
|
911
|
+
|
|
912
|
+
LD A,11010000B ;HMMM command
|
|
913
|
+
OUT (C),A
|
|
914
|
+
|
|
915
|
+
EI
|
|
916
|
+
RET
|
|
917
|
+
|
|
918
|
+
GET.STATUS:
|
|
919
|
+
PUSH BC
|
|
920
|
+
LD BC,(WRVDP)
|
|
921
|
+
INC C
|
|
922
|
+
OUT (C),A
|
|
923
|
+
LD A,8FH
|
|
924
|
+
OUT (C),A
|
|
925
|
+
LD BC,(RDVDP)
|
|
926
|
+
INC C
|
|
927
|
+
IN A,(C)
|
|
928
|
+
POP BC
|
|
929
|
+
RET
|
|
930
|
+
|
|
931
|
+
WAIT.VDP:
|
|
932
|
+
LD A,2
|
|
933
|
+
CALL GET.STATUS
|
|
934
|
+
AND 1
|
|
935
|
+
JP NZ,WAIT.VDP
|
|
936
|
+
XOR A
|
|
937
|
+
CALL GET.STATUS
|
|
938
|
+
RET
|
|
939
|
+
|
|
940
|
+
END
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
<p> </p>
|
|
944
|
+
|
|
945
|
+
#### 6.5.4 HMMV (painting the rectangle in high speed)
|
|
946
|
+
|
|
947
|
+
Each byte of data in the specified VRAM area is painted by the specified colour code (see [Figure 4.82](#figure-482--actions-of-hmmc-command))
|
|
948
|
+
|
|
949
|
+
After setting the parameters as shown in [Figure 4.83](#figure-483--register-settings-of-hmmv-command), writing C0H in R#46 causes the command to be executed. While the command is being executed, the CE bit of S#2 is 1. [List 4.11](#list-411--example-of-hmmv-command-execution) shows an example of using HMMV.
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
##### _Figure 4.82 Actions of HMMC command_
|
|
953
|
+
|
|
954
|
+
```
|
|
955
|
+
VRAM or expansion RAM
|
|
956
|
+
---------------------------------------------------
|
|
957
|
+
| | MSX-VIDEO
|
|
958
|
+
| | -------
|
|
959
|
+
| (DX,DY) | | |
|
|
960
|
+
| x------------------------ --> DIX | | |
|
|
961
|
+
| | NX | | | |
|
|
962
|
+
| | NY |<----------------+----| |
|
|
963
|
+
| | | | | |
|
|
964
|
+
| ------------------------- | | |
|
|
965
|
+
| | DIY | | |
|
|
966
|
+
| V | | |
|
|
967
|
+
| | -------
|
|
968
|
+
| |
|
|
969
|
+
---------------------------------------------------
|
|
970
|
+
|
|
971
|
+
MXD: select memory 0 = VRAM, 1 = expansion RAM
|
|
972
|
+
|
|
973
|
+
NX: number of dots to be painted in X direction (0 to 511)*
|
|
974
|
+
NY: number of dots to be painted in Y direction (0 to 1023)
|
|
975
|
+
|
|
976
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
977
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
978
|
+
|
|
979
|
+
DX: origin X-coordinate (0 to 511)*
|
|
980
|
+
DY: origin Y-coordinate (0 to 1023)
|
|
981
|
+
|
|
982
|
+
CLR (R#44:Colour register): Painted data
|
|
983
|
+
|
|
984
|
+
* The one low-order bit for GRAPHIC 4 and 6 modes,
|
|
985
|
+
or two low-order bits for GRAPHIC 5 mode of the DX and NX registers are ignored.
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
##### _Figure 4.83 Register settings of HMMV command_
|
|
989
|
+
|
|
990
|
+
```
|
|
991
|
+
> HMMV register setup
|
|
992
|
+
|
|
993
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
994
|
+
-----------------------------------------
|
|
995
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
996
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
997
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
998
|
+
----------------------------------------- |
|
|
999
|
+
| origin
|
|
1000
|
+
----------------------------------------- |
|
|
1001
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
1002
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
1003
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
1004
|
+
-----------------------------------------
|
|
1005
|
+
|
|
1006
|
+
-----------------------------------------
|
|
1007
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
1008
|
+
|----+----+----+----+----+----+----+----| NX ⟶ number of dots in X direction to be painted
|
|
1009
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
1010
|
+
-----------------------------------------
|
|
1011
|
+
|
|
1012
|
+
-----------------------------------------
|
|
1013
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
1014
|
+
|----+----+----+----+----+----+----+----| NY ⟶ number of dots inY direction to be painted
|
|
1015
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
1016
|
+
-----------------------------------------
|
|
1017
|
+
|
|
1018
|
+
----------------------------------------- --+
|
|
1019
|
+
R#44 | CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
1020
|
+
----------------------------------------- |
|
|
1021
|
+
| | | |
|
|
1022
|
+
+-------------------+-------------------+ |
|
|
1023
|
+
X=2N X=2N+1 (N=0, 1, ..., 127) |
|
|
1024
|
+
|
|
|
1025
|
+
----------------------------------------- |
|
|
1026
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 5) | data to be painted
|
|
1027
|
+
----------------------------------------- |
|
|
1028
|
+
| | | | | |
|
|
1029
|
+
+---------+---------+---------+---------+ |
|
|
1030
|
+
X=4N X=4N+1 X=4N+2 X=4N+3 (N=0, 1, ..., 127) |
|
|
1031
|
+
|
|
|
1032
|
+
----------------------------------------- |
|
|
1033
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
1034
|
+
----------------------------------------- --+
|
|
1035
|
+
1 byte / dot
|
|
1036
|
+
|
|
1037
|
+
-----------------------------------------
|
|
1038
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
|
|
1039
|
+
-----------------------------------------
|
|
1040
|
+
| | painting direction (X)
|
|
1041
|
+
| |
|
|
1042
|
+
| +-> painting direction (Y)
|
|
1043
|
+
|
|
|
1044
|
+
+-----------> memory selection
|
|
1045
|
+
|
|
1046
|
+
> HMMV command execution
|
|
1047
|
+
|
|
1048
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1049
|
+
-----------------------------------------
|
|
1050
|
+
R#46 | 1 | 1 | 0 | 0 | -- | -- | -- | -- | CMR
|
|
1051
|
+
-----------------------------------------
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
##### _List 4.11 Example of HMMV command execution_
|
|
1055
|
+
|
|
1056
|
+
```
|
|
1057
|
+
;****************************************************************
|
|
1058
|
+
; List 4.11 HMMV sample
|
|
1059
|
+
; to use, set H, L, D, E, B and go
|
|
1060
|
+
; B ⟶ VRAM (H,L)-(D,E) fill
|
|
1061
|
+
;****************************************************************
|
|
1062
|
+
;
|
|
1063
|
+
RDVDP: EQU 0006H
|
|
1064
|
+
WRVDP: EQU 0007H
|
|
1065
|
+
|
|
1066
|
+
;----- program start -----
|
|
1067
|
+
|
|
1068
|
+
HMMV: DI ;disable interrupt
|
|
1069
|
+
CALL WAIT.VDP ;wait end of command
|
|
1070
|
+
|
|
1071
|
+
LD A,(WRVDP)
|
|
1072
|
+
LD C,A
|
|
1073
|
+
INC C ;C := PORT#1's address
|
|
1074
|
+
LD A,36
|
|
1075
|
+
OUT (C),A
|
|
1076
|
+
LD A,80H+17
|
|
1077
|
+
OUT (C),A ;R#17 := 36
|
|
1078
|
+
|
|
1079
|
+
INC C
|
|
1080
|
+
INC C ;C := PORT#3's address
|
|
1081
|
+
XOR A
|
|
1082
|
+
OUT (C),H ;DX
|
|
1083
|
+
OUT (C),A
|
|
1084
|
+
OUT (C),L ;DY
|
|
1085
|
+
OUT (C),A
|
|
1086
|
+
|
|
1087
|
+
LD A,H ;make NX and DIX
|
|
1088
|
+
SUB A
|
|
1089
|
+
LD D,00000100B
|
|
1090
|
+
JP NC,HMMV1
|
|
1091
|
+
LD D,00000000B
|
|
1092
|
+
NEG
|
|
1093
|
+
HMMV1: LD H,A ;H := NX
|
|
1094
|
+
|
|
1095
|
+
LD A,L ;make NY and DIY
|
|
1096
|
+
SUB A
|
|
1097
|
+
LD E,00001000B
|
|
1098
|
+
JP NC,HMMV2
|
|
1099
|
+
LD E,00000000B
|
|
1100
|
+
NEG
|
|
1101
|
+
HMMV2: OUT (C),H
|
|
1102
|
+
LD H,A ;H := NY
|
|
1103
|
+
|
|
1104
|
+
XOR A
|
|
1105
|
+
OUT (C),A
|
|
1106
|
+
OUT (C),H
|
|
1107
|
+
OUT (C),A
|
|
1108
|
+
OUT (C),B ;fill data
|
|
1109
|
+
XOR A
|
|
1110
|
+
OR D
|
|
1111
|
+
OR E
|
|
1112
|
+
OUT (C),A ;DIX and DIY
|
|
1113
|
+
|
|
1114
|
+
LD A,11000000B ;HMMV command
|
|
1115
|
+
OUT (C),A
|
|
1116
|
+
|
|
1117
|
+
EI
|
|
1118
|
+
RET
|
|
1119
|
+
|
|
1120
|
+
GET.STATUS:
|
|
1121
|
+
PUSH BC
|
|
1122
|
+
LD BC,(WRVDP)
|
|
1123
|
+
INC C
|
|
1124
|
+
OUT (C),A
|
|
1125
|
+
LD A,8FH
|
|
1126
|
+
OUT (C),A
|
|
1127
|
+
LD BC,(RDVDP)
|
|
1128
|
+
INC C
|
|
1129
|
+
IN A,(C)
|
|
1130
|
+
POP BC
|
|
1131
|
+
RET
|
|
1132
|
+
|
|
1133
|
+
WAIT.VDP:
|
|
1134
|
+
LD A,2
|
|
1135
|
+
CALL GET.STATUS
|
|
1136
|
+
AND 1
|
|
1137
|
+
JP NZ,WAIT.VDP
|
|
1138
|
+
XOR A
|
|
1139
|
+
CALL GET.STATUS
|
|
1140
|
+
RET
|
|
1141
|
+
|
|
1142
|
+
END
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
|
|
1146
|
+
<p> </p>
|
|
1147
|
+
|
|
1148
|
+
#### 6.5.5 LMMC (CPU -> VRAM logical transfer)
|
|
1149
|
+
|
|
1150
|
+
Data is transferred from the CPU to thespecified VRAM area in dots (see [Figure 4.84](#figure-484--action-of-lmmc-command)). Logical operations with the source can be specified. In the logical transfer commands, such as LMMC, data is transfered in dots and one byte is required for the information of one pixel in all screen modes.
|
|
1151
|
+
|
|
1152
|
+
After setting the data as shown in [Figure 4.85](#figure-485--register-settings-of-lmmc-command), write command code B0H in R#46. At this point, logical operations can be specified by using the 4 low order bits of the command register. Data is transferred with reference to the TR and CE bit of S#2, as in HMMC (see [Figure 4.86](#figure-486--lmmc-command-execution-flow-chart)). [List 4.12](#list-412--example-of-lmmc-command-execution) shows an example of using LMMC.
|
|
1153
|
+
|
|
1154
|
+
|
|
1155
|
+
##### _Figure 4.84 Action of LMMC command_
|
|
1156
|
+
|
|
1157
|
+
```
|
|
1158
|
+
VRAM or expansion RAM
|
|
1159
|
+
---------------------------------------------------
|
|
1160
|
+
| | MSX-VIDEO CPU
|
|
1161
|
+
| | ------- -------
|
|
1162
|
+
| (DX,DY) | | | | |
|
|
1163
|
+
| x------------------------ --> DIX | | | | |
|
|
1164
|
+
| | NX | | | | | |
|
|
1165
|
+
| | NY |<----------------+----| |-----| |
|
|
1166
|
+
| | | | | | | |
|
|
1167
|
+
| ------------------------- | | | | |
|
|
1168
|
+
| | DIY | | | | |
|
|
1169
|
+
| V | | | | |
|
|
1170
|
+
| | ------- -------
|
|
1171
|
+
| |
|
|
1172
|
+
---------------------------------------------------
|
|
1173
|
+
|
|
1174
|
+
MXD: select destination memory 0 = VRAM, 1 = expansion RAM
|
|
1175
|
+
|
|
1176
|
+
NX: number of dots to be transferred in X direction (0 to 511)
|
|
1177
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
1178
|
+
|
|
1179
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
1180
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
1181
|
+
|
|
1182
|
+
DX: destination origin X-coordinate (0 to 511)
|
|
1183
|
+
DY: destination origin Y-coordinate (0 to 1023)
|
|
1184
|
+
|
|
1185
|
+
CLR (R#44:Colour register): 1st byte of data to be transferred
|
|
1186
|
+
```
|
|
1187
|
+
|
|
1188
|
+
##### _Figure 4.85 Register settings of LMMC command_
|
|
1189
|
+
|
|
1190
|
+
```
|
|
1191
|
+
> LMMC register setup
|
|
1192
|
+
|
|
1193
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1194
|
+
-----------------------------------------
|
|
1195
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
1196
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
1197
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
1198
|
+
----------------------------------------- |
|
|
1199
|
+
| destination origin
|
|
1200
|
+
----------------------------------------- |
|
|
1201
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
1202
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
1203
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
1204
|
+
-----------------------------------------
|
|
1205
|
+
|
|
1206
|
+
-----------------------------------------
|
|
1207
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
1208
|
+
|----+----+----+----+----+----+----+----| NX ⟶ Number of dots in X direction to be transferred
|
|
1209
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
1210
|
+
-----------------------------------------
|
|
1211
|
+
|
|
1212
|
+
-----------------------------------------
|
|
1213
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
1214
|
+
|----+----+----+----+----+----+----+----| NY ⟶ Number of dots in Y direction to be transferred
|
|
1215
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
1216
|
+
-----------------------------------------
|
|
1217
|
+
|
|
1218
|
+
----------------------------------------- --+
|
|
1219
|
+
R#44 | -- | -- | -- | -- | CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
1220
|
+
----------------------------------------- |
|
|
1221
|
+
|
|
|
1222
|
+
----------------------------------------- |
|
|
1223
|
+
| -- | -- | -- | -- | -- | -- | CR1| CR0| CLR (GRAPHIC 5) | data to be transferred
|
|
1224
|
+
----------------------------------------- |
|
|
1225
|
+
|
|
|
1226
|
+
----------------------------------------- |
|
|
1227
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
1228
|
+
----------------------------------------- --+
|
|
1229
|
+
|
|
1230
|
+
-----------------------------------------
|
|
1231
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
|
|
1232
|
+
-----------------------------------------
|
|
1233
|
+
| | direction (X)
|
|
1234
|
+
| |
|
|
1235
|
+
| +-> direction (Y)
|
|
1236
|
+
|
|
|
1237
|
+
+-----------> select destination memory
|
|
1238
|
+
|
|
1239
|
+
> LMMC command execution
|
|
1240
|
+
|
|
1241
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1242
|
+
-----------------------------------------
|
|
1243
|
+
R#46 | 1 | 0 | 1 | 1 | L03| L02| L01| L00| CMR
|
|
1244
|
+
-----------------------------------------
|
|
1245
|
+
| |
|
|
1246
|
+
+-------------------+
|
|
1247
|
+
Logical operation
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
##### _Figure 4.86 LMMC command execution flow chart_
|
|
1251
|
+
|
|
1252
|
+
```
|
|
1253
|
+
/-------------------\
|
|
1254
|
+
| LMMC start |
|
|
1255
|
+
\-------------------/
|
|
1256
|
+
|
|
|
1257
|
+
---------------------
|
|
1258
|
+
| register setup |
|
|
1259
|
+
---------------------
|
|
1260
|
+
|
|
|
1261
|
+
---------------------
|
|
1262
|
+
| command execution |
|
|
1263
|
+
---------------------
|
|
1264
|
+
|
|
|
1265
|
+
+---------------->|
|
|
1266
|
+
| |
|
|
1267
|
+
| ---------------------------
|
|
1268
|
+
| | read status register #2 |
|
|
1269
|
+
| ---------------------------
|
|
1270
|
+
| |
|
|
1271
|
+
| //////////+\\\\\\\\\\ Yes (CE bit = 0)
|
|
1272
|
+
| | command end? |-------------------+
|
|
1273
|
+
| \\\\\\\\\\+////////// |
|
|
1274
|
+
| | No (CE bit = 1) |
|
|
1275
|
+
| //////////+\\\\\\\\\\ |
|
|
1276
|
+
|<------| transfer? | |
|
|
1277
|
+
| No \\\\\\\\\\+////////// |
|
|
1278
|
+
| (TR bit=0) | Yes (TR bit = 1) |
|
|
1279
|
+
| --------------------- |
|
|
1280
|
+
| | transfer data | |
|
|
1281
|
+
| --------------------- |
|
|
1282
|
+
| | |
|
|
1283
|
+
+-----------------+ |
|
|
1284
|
+
|
|
|
1285
|
+
+-----------------------------+
|
|
1286
|
+
|
|
|
1287
|
+
V
|
|
1288
|
+
/--------------------\
|
|
1289
|
+
| LMMC end |
|
|
1290
|
+
\--------------------/
|
|
1291
|
+
```
|
|
1292
|
+
|
|
1293
|
+
##### _List 4.12 Example of LMMC command execution_
|
|
1294
|
+
|
|
1295
|
+
```
|
|
1296
|
+
;****************************************************************
|
|
1297
|
+
; List 4.12 LMMC sample
|
|
1298
|
+
; to use, set H, L, D, E, IX, A and go
|
|
1299
|
+
; RAM (IX) ⟶ VRAM (H,L)-(D,E) (logi-OP : A)
|
|
1300
|
+
;****************************************************************
|
|
1301
|
+
;
|
|
1302
|
+
RDVDP: EQU 0006H
|
|
1303
|
+
WRVDP: EQU 0007H
|
|
1304
|
+
|
|
1305
|
+
;----- program start -----
|
|
1306
|
+
|
|
1307
|
+
LMMC: DI ;disable interrupt
|
|
1308
|
+
LD B,A ;B := LOGICAL OPERATION
|
|
1309
|
+
CALL WAIT.VDP ;wait end of command
|
|
1310
|
+
|
|
1311
|
+
LD A,(WRVDP)
|
|
1312
|
+
LD C,A
|
|
1313
|
+
INC C ;C := PORT#1's address
|
|
1314
|
+
LD A,36
|
|
1315
|
+
OUT (C),A
|
|
1316
|
+
LD A,80H+17
|
|
1317
|
+
OUT (C),A ;R#17 := 36
|
|
1318
|
+
|
|
1319
|
+
INC C
|
|
1320
|
+
INC C ;C := PORT#3's address
|
|
1321
|
+
XOR A
|
|
1322
|
+
OUT (C),H ;DX
|
|
1323
|
+
OUT (C),A
|
|
1324
|
+
OUT (C),L ;DY
|
|
1325
|
+
OUT (C),A
|
|
1326
|
+
|
|
1327
|
+
LD A,H ;make NX and DIX
|
|
1328
|
+
SUB A
|
|
1329
|
+
LD D,00000100B
|
|
1330
|
+
JR NC,LMMC1
|
|
1331
|
+
LD D,00000000B
|
|
1332
|
+
NEG
|
|
1333
|
+
LMMC1: LD H,A ;H := NX , D := DIX
|
|
1334
|
+
|
|
1335
|
+
LD A,L
|
|
1336
|
+
SUB A
|
|
1337
|
+
LD E,00001000B
|
|
1338
|
+
JR NC,LMMC2
|
|
1339
|
+
LD E,00000000B
|
|
1340
|
+
NEG
|
|
1341
|
+
LMMC2: LD L,A ;L := NY , E := DIY
|
|
1342
|
+
|
|
1343
|
+
XOR A
|
|
1344
|
+
OUT (C),H ;NX
|
|
1345
|
+
OUT (C),A
|
|
1346
|
+
OUT (C),L ;NY
|
|
1347
|
+
OUT (C),A
|
|
1348
|
+
LD A,(IX+0)
|
|
1349
|
+
OUT (C),A ;first DATA
|
|
1350
|
+
LD A,D
|
|
1351
|
+
OR E
|
|
1352
|
+
OUT (C),A ;DIX and DIY
|
|
1353
|
+
|
|
1354
|
+
LD A,B ;A := LOGICAL OPERATION
|
|
1355
|
+
OR 10110000B ;LMMC command
|
|
1356
|
+
OUT (C),A
|
|
1357
|
+
|
|
1358
|
+
DEC C
|
|
1359
|
+
DEC C
|
|
1360
|
+
|
|
1361
|
+
LOOP: LD A,2
|
|
1362
|
+
CALL GET.STATUS
|
|
1363
|
+
BIT 0,A ;check CE bit
|
|
1364
|
+
JP Z,EXIT
|
|
1365
|
+
BIT 7,A ;check TR bit
|
|
1366
|
+
JP Z,LOOP
|
|
1367
|
+
INC IX
|
|
1368
|
+
LD A,(IX+0)
|
|
1369
|
+
OUT (C),A
|
|
1370
|
+
JR LOOP
|
|
1371
|
+
|
|
1372
|
+
EXIT: LD A,0
|
|
1373
|
+
CALL GET.STATUS
|
|
1374
|
+
|
|
1375
|
+
EI
|
|
1376
|
+
RET
|
|
1377
|
+
|
|
1378
|
+
GET.STATUS:
|
|
1379
|
+
PUSH BC
|
|
1380
|
+
LD BC,(WRVDP)
|
|
1381
|
+
INC C
|
|
1382
|
+
OUT (C),A
|
|
1383
|
+
LD A,8FH
|
|
1384
|
+
OUT (C),A
|
|
1385
|
+
LD BC,(RDVDP)
|
|
1386
|
+
INC C
|
|
1387
|
+
IN A,(C)
|
|
1388
|
+
POP BC
|
|
1389
|
+
RET
|
|
1390
|
+
|
|
1391
|
+
WAIT.VDP:
|
|
1392
|
+
LD A,2
|
|
1393
|
+
CALL GET.STATUS
|
|
1394
|
+
AND 1
|
|
1395
|
+
JR NZ,WAIT.VDP
|
|
1396
|
+
XOR A
|
|
1397
|
+
CALL GET.STATUS
|
|
1398
|
+
RET
|
|
1399
|
+
|
|
1400
|
+
END
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
|
|
1404
|
+
<p> </p>
|
|
1405
|
+
|
|
1406
|
+
#### 6.5.6 LMCM (VRAM - CPU logical transfer)
|
|
1407
|
+
|
|
1408
|
+
Data is transferred from the specified VRAM area to CPU in dots (see [Figure 4.87](#figure-487--action-of-lmcm-command))
|
|
1409
|
+
|
|
1410
|
+
After setting the parameters as shown in [Figure 4.88](#figure-488--register-settings-of-lmcm-command), writing command code A0H in R#46 causes the command to be executed and data to be transferred from MSX-VIDEO. The CPU refers to the TR bit of S#2 and, since data of MSX-VIDEO has been prepared if this bit is "1", the CPU reads data from S#7. When CE bit of S#2 is "0", data comes to the end (see [Figure 4.89](#figure-489--lmcm-command-execution-flow-chart)). [List 4.13](#list-413--example-of-lmcm-command-execution) shows an example of using LMCM.
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
##### _Figure 4.87 Action of LMCM command_
|
|
1414
|
+
|
|
1415
|
+
```
|
|
1416
|
+
VRAM or expansion RAM
|
|
1417
|
+
---------------------------------------------------
|
|
1418
|
+
| | MSX-VIDEO CPU
|
|
1419
|
+
| | ------- -------
|
|
1420
|
+
| (SX,SY) | | | | |
|
|
1421
|
+
| x------------------------ --> DIX | | | | |
|
|
1422
|
+
| | NX | | | | | |
|
|
1423
|
+
| | NY |-----------------+--->| |---->| |
|
|
1424
|
+
| | | | | | | |
|
|
1425
|
+
| ------------------------- | | | | |
|
|
1426
|
+
| | DIY | | | | |
|
|
1427
|
+
| V | | | | |
|
|
1428
|
+
| | ------- -------
|
|
1429
|
+
| |
|
|
1430
|
+
---------------------------------------------------
|
|
1431
|
+
|
|
1432
|
+
MXS: select source memory 0 = VRAM, 1 = expansion RAM
|
|
1433
|
+
|
|
1434
|
+
SX: source origin X-coordinate (0 to 511)
|
|
1435
|
+
SY: source origin Y-coordinate (0 to 1023)
|
|
1436
|
+
|
|
1437
|
+
NX: number of dots to be transferred in X direction (0 to 511)
|
|
1438
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
1439
|
+
|
|
1440
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
1441
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
1442
|
+
```
|
|
1443
|
+
|
|
1444
|
+
##### _Figure 4.88 Register settings of LMCM command_
|
|
1445
|
+
|
|
1446
|
+
```
|
|
1447
|
+
> LMCM register setup
|
|
1448
|
+
|
|
1449
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1450
|
+
-----------------------------------------
|
|
1451
|
+
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|
|
1452
|
+
|----+----+----+----+----+----+----+----| SX ---+
|
|
1453
|
+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
|
|
1454
|
+
----------------------------------------- |
|
|
1455
|
+
| source origin
|
|
1456
|
+
----------------------------------------- |
|
|
1457
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|
|
1458
|
+
|----+----+----+----+----+----+----+----| SY ---+
|
|
1459
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
1460
|
+
-----------------------------------------
|
|
1461
|
+
|
|
1462
|
+
-----------------------------------------
|
|
1463
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
1464
|
+
|----+----+----+----+----+----+----+----| NX ⟶ Number of dots in X direction to be transferred
|
|
1465
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
1466
|
+
-----------------------------------------
|
|
1467
|
+
|
|
1468
|
+
-----------------------------------------
|
|
1469
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
1470
|
+
|----+----+----+----+----+----+----+----| NY ⟶ Number of dots in Y direction to be transferred
|
|
1471
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
1472
|
+
-----------------------------------------
|
|
1473
|
+
|
|
1474
|
+
-----------------------------------------
|
|
1475
|
+
R#45 | 0 | -- | -- | MXS| DIY| DIX| -- | -- | ARG (Argument register)
|
|
1476
|
+
-----------------------------------------
|
|
1477
|
+
| | direction (X)
|
|
1478
|
+
| |
|
|
1479
|
+
| +-> direction (Y)
|
|
1480
|
+
|
|
|
1481
|
+
+------> select source memory
|
|
1482
|
+
|
|
1483
|
+
> LMCM command execution
|
|
1484
|
+
|
|
1485
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1486
|
+
-----------------------------------------
|
|
1487
|
+
R#46 | 1 | 0 | 1 | 0 | -- | -- | -- | -- | CMR
|
|
1488
|
+
-----------------------------------------
|
|
1489
|
+
|
|
1490
|
+
-----------------------------------------
|
|
1491
|
+
S#7 | 0 | 0 | 0 | 0 | C3 | C2 | C1 | C0 | status register(GRAPHIC4,6)
|
|
1492
|
+
-----------------------------------------
|
|
1493
|
+
|
|
1494
|
+
-----------------------------------------
|
|
1495
|
+
S#7 | 0 | 0 | 0 | 0 | 0 | 0 | C1 | C0 | status register (GRAPHIC 5)
|
|
1496
|
+
-----------------------------------------
|
|
1497
|
+
|
|
1498
|
+
-----------------------------------------
|
|
1499
|
+
S#7 | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | status register (GRAPHIC 7)
|
|
1500
|
+
-----------------------------------------
|
|
1501
|
+
```
|
|
1502
|
+
|
|
1503
|
+
##### _Figure 4.89 LMCM command execution flow chart_
|
|
1504
|
+
|
|
1505
|
+
```
|
|
1506
|
+
/-------------------\
|
|
1507
|
+
| LMCM start |
|
|
1508
|
+
\-------------------/
|
|
1509
|
+
|
|
|
1510
|
+
---------------------
|
|
1511
|
+
| register setup |
|
|
1512
|
+
---------------------
|
|
1513
|
+
|
|
|
1514
|
+
---------------------
|
|
1515
|
+
| command execution |
|
|
1516
|
+
---------------------
|
|
1517
|
+
|
|
|
1518
|
+
+---------------->|
|
|
1519
|
+
| |
|
|
1520
|
+
| ---------------------------
|
|
1521
|
+
| | read status register #2 |
|
|
1522
|
+
| ---------------------------
|
|
1523
|
+
| |
|
|
1524
|
+
| //////////+\\\\\\\\\\ No (TR bit = 0)
|
|
1525
|
+
| | data prepared? |-------------------+
|
|
1526
|
+
| \\\\\\\\\\+////////// |
|
|
1527
|
+
| | Yes (TR bit = 1) |
|
|
1528
|
+
| | |
|
|
1529
|
+
| --------------------------- |
|
|
1530
|
+
| | read status register #7 | |
|
|
1531
|
+
| --------------------------- |
|
|
1532
|
+
| | |
|
|
1533
|
+
| |<----------------------------+
|
|
1534
|
+
| |
|
|
1535
|
+
| //////////+\\\\\\\\\\
|
|
1536
|
+
+-------| command end? |
|
|
1537
|
+
No \\\\\\\\\\+//////////
|
|
1538
|
+
(CE bit=1) | Yes (CE bit = 0)
|
|
1539
|
+
|
|
|
1540
|
+
V
|
|
1541
|
+
/--------------------\
|
|
1542
|
+
| LMCM end |
|
|
1543
|
+
\--------------------/
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
**Note 1:** Read status register #7 in "register setup", since TR bit should be reset before the command execution.
|
|
1547
|
+
|
|
1548
|
+
**Note 2:** Though last data was set in register #7 and TR bit was 1, the command would end inside of the MSX-VIDEO and CE would be zero.
|
|
1549
|
+
|
|
1550
|
+
|
|
1551
|
+
##### _List 4.13 Example of LMCM command execution_
|
|
1552
|
+
|
|
1553
|
+
```
|
|
1554
|
+
;****************************************************************
|
|
1555
|
+
; List 4.13 LMCM sample
|
|
1556
|
+
; to use, set H, L, D, E, IX, A and go
|
|
1557
|
+
; VRAM (H,L)-(D,E) ⟶ RAM (IX)
|
|
1558
|
+
;****************************************************************
|
|
1559
|
+
;
|
|
1560
|
+
RDVDP: EQU 0006H
|
|
1561
|
+
WRVDP: EQU 0007H
|
|
1562
|
+
|
|
1563
|
+
;----- program start -----
|
|
1564
|
+
|
|
1565
|
+
LMCM: DI ;disable interrupt
|
|
1566
|
+
LD B,A ;B := LOGICAL OPERATION
|
|
1567
|
+
CALL WAIT.VDP ;wait end of command
|
|
1568
|
+
|
|
1569
|
+
LD A,(WRVDP)
|
|
1570
|
+
LD C,A
|
|
1571
|
+
INC C ;C := PORT#1's address
|
|
1572
|
+
LD A,32
|
|
1573
|
+
OUT (C),A
|
|
1574
|
+
LD A,80H+17
|
|
1575
|
+
OUT (C),A ;R#17 := 32
|
|
1576
|
+
INC C
|
|
1577
|
+
INC C ;C := PORT#3's address
|
|
1578
|
+
XOR A
|
|
1579
|
+
OUT (C),H ;SX
|
|
1580
|
+
OUT (C),A
|
|
1581
|
+
OUT (C),L ;SY
|
|
1582
|
+
OUT (C),A
|
|
1583
|
+
OUT (C),A ;dummy
|
|
1584
|
+
OUT (C),A ;dummy
|
|
1585
|
+
OUT (C),A ;dummy
|
|
1586
|
+
OUT (C),A ;dummy
|
|
1587
|
+
LD A,H ;make NX and DIX
|
|
1588
|
+
SUB A
|
|
1589
|
+
LD D,00000100B
|
|
1590
|
+
JR NC,LMCM1
|
|
1591
|
+
LD D,00000000B
|
|
1592
|
+
NEG
|
|
1593
|
+
LMCM1: LD H,A ;H := NX , D := DIX
|
|
1594
|
+
|
|
1595
|
+
LD A,L
|
|
1596
|
+
SUB A
|
|
1597
|
+
LD E,00001000B
|
|
1598
|
+
JR NC,LMCM2
|
|
1599
|
+
LD E,00000000B
|
|
1600
|
+
NEG
|
|
1601
|
+
LMCM2: LD L,A ;L := NY , E := DIY
|
|
1602
|
+
|
|
1603
|
+
XOR A
|
|
1604
|
+
OUT (C),H ;NX
|
|
1605
|
+
OUT (C),A
|
|
1606
|
+
OUT (C),L ;NY
|
|
1607
|
+
OUT (C),A
|
|
1608
|
+
LD A,(IX+0)
|
|
1609
|
+
OUT (C),A ;dummy
|
|
1610
|
+
LD A,D
|
|
1611
|
+
OR E
|
|
1612
|
+
OUT (C),A ;DIX and DIY
|
|
1613
|
+
LD A,7
|
|
1614
|
+
CALL GET.STATUS
|
|
1615
|
+
LD A,B ;A := LOGICAL OPERATION
|
|
1616
|
+
OR 10100000B ;LMCM command
|
|
1617
|
+
OUT (C),A
|
|
1618
|
+
LD A,(RDVDP)
|
|
1619
|
+
LD C,A ;C := PORT#1's address
|
|
1620
|
+
LOOP: LD A,2
|
|
1621
|
+
CALL GET.STATUS
|
|
1622
|
+
BIT 0,A ;check CE bit
|
|
1623
|
+
JP Z,EXIT
|
|
1624
|
+
BIT 7,A ;check TR bit
|
|
1625
|
+
JP Z,LOOP
|
|
1626
|
+
LD A,7
|
|
1627
|
+
CALL GET.STATUS
|
|
1628
|
+
LD (IX+0),A
|
|
1629
|
+
INC IX
|
|
1630
|
+
JR LOOP
|
|
1631
|
+
|
|
1632
|
+
EXIT: LD A,0
|
|
1633
|
+
CALL GET.STATUS
|
|
1634
|
+
EI
|
|
1635
|
+
RET
|
|
1636
|
+
|
|
1637
|
+
GET.STATUS:
|
|
1638
|
+
PUSH BC
|
|
1639
|
+
LD BC,(WRVDP)
|
|
1640
|
+
INC C
|
|
1641
|
+
OUT (C),A
|
|
1642
|
+
LD A,8FH
|
|
1643
|
+
OUT (C),A
|
|
1644
|
+
LD BC,(RDVDP)
|
|
1645
|
+
INC C
|
|
1646
|
+
IN A,(C)
|
|
1647
|
+
POP BC
|
|
1648
|
+
RET
|
|
1649
|
+
|
|
1650
|
+
WAIT.VDP:
|
|
1651
|
+
LD A,2
|
|
1652
|
+
CALL GET.STATUS
|
|
1653
|
+
AND 1
|
|
1654
|
+
JR NZ,WAIT.VDP
|
|
1655
|
+
XOR A
|
|
1656
|
+
CALL GET.STATUS
|
|
1657
|
+
RET
|
|
1658
|
+
|
|
1659
|
+
END
|
|
1660
|
+
```
|
|
1661
|
+
|
|
1662
|
+
|
|
1663
|
+
<p> </p>
|
|
1664
|
+
|
|
1665
|
+
#### 6.5.7. LMMM (VRAM->VRAM logical transfer)
|
|
1666
|
+
|
|
1667
|
+
Data of the specified VRAM area is transferred into another VRAM area in dots (see figure 4.9)
|
|
1668
|
+
|
|
1669
|
+
After setting the parameters as shown in [Figure 4.91](#figure-491--register-settings-of-lmmm-command), writing command code 9XH (X means a logical operation) in R#46 causes the command to be executed. While the CE bit of S#2 is "1", the command is being executed. [List 4.14](#list-414--example-of-lmmm-command-execution) shows an example of using LMMM.
|
|
1670
|
+
|
|
1671
|
+
|
|
1672
|
+
##### _Figure 4.90 Actions of LMMM command_
|
|
1673
|
+
|
|
1674
|
+
```
|
|
1675
|
+
VRAM or expansion RAM
|
|
1676
|
+
----------------------------------------------------------------
|
|
1677
|
+
| |
|
|
1678
|
+
| (SX,SY) |
|
|
1679
|
+
| ------------------ --> |
|
|
1680
|
+
| | NX | DIX |
|
|
1681
|
+
| | | |
|
|
1682
|
+
| | NY | |
|
|
1683
|
+
| | | |
|
|
1684
|
+
| ------------------ --+ |
|
|
1685
|
+
| | DIY | |
|
|
1686
|
+
| V | |
|
|
1687
|
+
| | (DX,DY) |
|
|
1688
|
+
| +-> ------------------ |
|
|
1689
|
+
| | | |
|
|
1690
|
+
| | | |
|
|
1691
|
+
| | | |
|
|
1692
|
+
| | | |
|
|
1693
|
+
| ------------------ |
|
|
1694
|
+
| |
|
|
1695
|
+
----------------------------------------------------------------
|
|
1696
|
+
|
|
1697
|
+
MXS: select the source memory 0 = VRAM, 1 = expansion RAM
|
|
1698
|
+
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
|
|
1699
|
+
|
|
1700
|
+
SX: source origin X-coordinate (0 to 511)
|
|
1701
|
+
SY: source origin Y-coordinate (0 to 1023)
|
|
1702
|
+
|
|
1703
|
+
NX: number of dots to be transferred in X direction (0 to 511)
|
|
1704
|
+
NY: number of dots to be transferred in Y direction (0 to 1023)
|
|
1705
|
+
|
|
1706
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
1707
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
1708
|
+
|
|
1709
|
+
DX: destination origin X-coordinate (0 to 511)
|
|
1710
|
+
DY: destination origin Y-coordinate (0 to 1023)
|
|
1711
|
+
```
|
|
1712
|
+
|
|
1713
|
+
##### _Figure 4.91 Register settings of LMMM command_
|
|
1714
|
+
|
|
1715
|
+
```
|
|
1716
|
+
> LMMM register setup
|
|
1717
|
+
|
|
1718
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1719
|
+
-----------------------------------------
|
|
1720
|
+
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|
|
1721
|
+
|----+----+----+----+----+----+----+----| SX ---+
|
|
1722
|
+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
|
|
1723
|
+
----------------------------------------- |
|
|
1724
|
+
| source origin
|
|
1725
|
+
----------------------------------------- |
|
|
1726
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|
|
1727
|
+
|----+----+----+----+----+----+----+----| SY ---+
|
|
1728
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
1729
|
+
|
|
1730
|
+
-----------------------------------------
|
|
1731
|
+
|
|
1732
|
+
-----------------------------------------
|
|
1733
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
1734
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
1735
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
1736
|
+
----------------------------------------- |
|
|
1737
|
+
| destination origin
|
|
1738
|
+
----------------------------------------- |
|
|
1739
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
1740
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
1741
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
1742
|
+
-----------------------------------------
|
|
1743
|
+
|
|
1744
|
+
-----------------------------------------
|
|
1745
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0| Number of dots in
|
|
1746
|
+
|----+----+----+----+----+----+----+----| NX ⟶ X direction to be
|
|
1747
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8| transferred
|
|
1748
|
+
-----------------------------------------
|
|
1749
|
+
|
|
1750
|
+
-----------------------------------------
|
|
1751
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0| Number of dots in
|
|
1752
|
+
|----+----+----+----+----+----+----+----| NY ⟶ Y direction to be
|
|
1753
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8| transferred
|
|
1754
|
+
-----------------------------------------
|
|
1755
|
+
|
|
1756
|
+
-----------------------------------------
|
|
1757
|
+
R#45 | 0 | -- | MXD| MXS| DIY| DIX| -- | -- | ARG (Argument register)
|
|
1758
|
+
-----------------------------------------
|
|
1759
|
+
| | | direction (X)
|
|
1760
|
+
| | |
|
|
1761
|
+
| | +-> direction (Y)
|
|
1762
|
+
| |
|
|
1763
|
+
| +------> select source memory
|
|
1764
|
+
|
|
|
1765
|
+
+-----------> select destination memory
|
|
1766
|
+
|
|
1767
|
+
> LMMM command execution
|
|
1768
|
+
|
|
1769
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1770
|
+
-----------------------------------------
|
|
1771
|
+
R#46 | 1 | 0 | 0 | 1 | L03| L02| L01| L00| CMR
|
|
1772
|
+
-----------------------------------------
|
|
1773
|
+
| |
|
|
1774
|
+
+-------------------+
|
|
1775
|
+
Logical operation
|
|
1776
|
+
```
|
|
1777
|
+
|
|
1778
|
+
##### _List 4.14 Example of LMMM command execution_
|
|
1779
|
+
|
|
1780
|
+
```
|
|
1781
|
+
;****************************************************************
|
|
1782
|
+
; List 4.14 LMMM sample
|
|
1783
|
+
; to use, set H, L, D, E, B, C, A and go
|
|
1784
|
+
; VRAM (H,L)-(D,E) ⟶ VRAM (B,C) (logi-OP : A)
|
|
1785
|
+
;****************************************************************
|
|
1786
|
+
;
|
|
1787
|
+
RDVDP: EQU 0006H
|
|
1788
|
+
WRVDP: EQU 0007H
|
|
1789
|
+
|
|
1790
|
+
;----- program start -----
|
|
1791
|
+
|
|
1792
|
+
LMMM: DI ;disable interrupt
|
|
1793
|
+
PUSH AF ;save LOGICAL OPERATION
|
|
1794
|
+
PUSH BC ;save DESTINATION
|
|
1795
|
+
CALL WAIT.VDP ;wait end of command
|
|
1796
|
+
|
|
1797
|
+
LD A,(WRVDP)
|
|
1798
|
+
LD C,A
|
|
1799
|
+
INC C ;C := PORT#1's address
|
|
1800
|
+
LD A,32
|
|
1801
|
+
OUT (C),A
|
|
1802
|
+
LD A,80H+17
|
|
1803
|
+
OUT (C),A ;R#17 := 32
|
|
1804
|
+
|
|
1805
|
+
INC C
|
|
1806
|
+
INC C ;C := PORT#3's address
|
|
1807
|
+
XOR A
|
|
1808
|
+
OUT (C),H ;SX
|
|
1809
|
+
OUT (C),A
|
|
1810
|
+
OUT (C),L ;SY
|
|
1811
|
+
OUT (C),A
|
|
1812
|
+
|
|
1813
|
+
LD A,H ;make NX and DIX
|
|
1814
|
+
SUB A
|
|
1815
|
+
LD D,00000100B
|
|
1816
|
+
JP NC,LMMM1
|
|
1817
|
+
LD D,00000000B
|
|
1818
|
+
NEG
|
|
1819
|
+
LMMM1: LD H,A ;H := NX , D := DIX
|
|
1820
|
+
|
|
1821
|
+
LD A,L ;make NY and DIY
|
|
1822
|
+
SUB A
|
|
1823
|
+
LD E,00001000B
|
|
1824
|
+
JP NC,LMMM2
|
|
1825
|
+
LD E,00000000B
|
|
1826
|
+
NEG
|
|
1827
|
+
LMMM2: LD L,A ;L := NY , E := DIY
|
|
1828
|
+
|
|
1829
|
+
LD A,D
|
|
1830
|
+
OR E
|
|
1831
|
+
POP DE ;restore DX,DY
|
|
1832
|
+
PUSH AF ;save DIX,DIY
|
|
1833
|
+
XOR A
|
|
1834
|
+
OUT (C),D ;DX
|
|
1835
|
+
OUT (C),A
|
|
1836
|
+
OUT (C),E ;DY
|
|
1837
|
+
OUT (C),A
|
|
1838
|
+
OUT (C),H ;NX
|
|
1839
|
+
OUT (C),A
|
|
1840
|
+
OUT (C),L ;NY
|
|
1841
|
+
OUT (C),A
|
|
1842
|
+
OUT (C),A ;dummy
|
|
1843
|
+
POP AF
|
|
1844
|
+
OUT (C),A ;DIX and DIY
|
|
1845
|
+
|
|
1846
|
+
POP AF ;A := LOGICAL OPERATION
|
|
1847
|
+
OR 10010000B ;LMMM command
|
|
1848
|
+
OUT (C),A
|
|
1849
|
+
|
|
1850
|
+
EI
|
|
1851
|
+
RET
|
|
1852
|
+
|
|
1853
|
+
GET.STATUS:
|
|
1854
|
+
PUSH BC
|
|
1855
|
+
LD BC,(WRVDP)
|
|
1856
|
+
INC C
|
|
1857
|
+
OUT (C),A
|
|
1858
|
+
LD A,8FH
|
|
1859
|
+
OUT (C),A
|
|
1860
|
+
LD BC,(RDVDP)
|
|
1861
|
+
INC C
|
|
1862
|
+
IN A,(C)
|
|
1863
|
+
POP BC
|
|
1864
|
+
RET
|
|
1865
|
+
|
|
1866
|
+
WAIT.VDP:
|
|
1867
|
+
LD A,2
|
|
1868
|
+
CALL GET.STATUS
|
|
1869
|
+
AND 1
|
|
1870
|
+
JP NZ,WAIT.VDP
|
|
1871
|
+
XOR A
|
|
1872
|
+
CALL GET.STATUS
|
|
1873
|
+
RET
|
|
1874
|
+
|
|
1875
|
+
END
|
|
1876
|
+
```
|
|
1877
|
+
|
|
1878
|
+
|
|
1879
|
+
<p> </p>
|
|
1880
|
+
|
|
1881
|
+
#### 6.5.8 LMMV (VRAM logical paint)
|
|
1882
|
+
|
|
1883
|
+
The specified VRAM area is painted by the colour code in dots (see [Figure 4.92](#figure-492--actions-of-lmmv-command)). Logical operations between data in VRAM and the specified data are allowed.
|
|
1884
|
+
|
|
1885
|
+
After setting the parameters as shown in [Figure 4.93](#figure-493--register-settings-of-lmmv-command), writing command code 8Xh (X means a logical operation) in R#46 causes the command to be executed. While the CE bit of S#2 is "1", the command is being executed. [List 4.15](#list-415--example-of-lmmv-command-execution) shows an example of using LMMV.
|
|
1886
|
+
|
|
1887
|
+
|
|
1888
|
+
##### _Figure 4.92 Actions of LMMV command_
|
|
1889
|
+
|
|
1890
|
+
```
|
|
1891
|
+
VRAM or expansion RAM
|
|
1892
|
+
---------------------------------------------------
|
|
1893
|
+
| | MSX-VIDEO
|
|
1894
|
+
| | -------
|
|
1895
|
+
| (DX,DY) | | |
|
|
1896
|
+
| x------------------------ --> DIX | | |
|
|
1897
|
+
| | NX | | | |
|
|
1898
|
+
| | NY |<----------------+----| |
|
|
1899
|
+
| | | | | |
|
|
1900
|
+
| ------------------------- | | |
|
|
1901
|
+
| | DIY | | |
|
|
1902
|
+
| V | | |
|
|
1903
|
+
| | -------
|
|
1904
|
+
| |
|
|
1905
|
+
---------------------------------------------------
|
|
1906
|
+
|
|
1907
|
+
MXD: select memory 0 = VRAM, 1 = expansion RAM
|
|
1908
|
+
|
|
1909
|
+
NX: number of dots to be painted in X direction (0 to 511)
|
|
1910
|
+
NY: number of dots to be painted in Y direction (0 to 1023)
|
|
1911
|
+
|
|
1912
|
+
DIX: direction of NX from the origin 0 = right, 1 = left
|
|
1913
|
+
DIY: direction of NY from the origin 0 = below, 1 = above
|
|
1914
|
+
|
|
1915
|
+
DX: origin X-coordinate (0 to 511)
|
|
1916
|
+
DY: origin Y-coordinate (0 to 1023)
|
|
1917
|
+
|
|
1918
|
+
CLR (R#44:Colour register): Painted data
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1921
|
+
##### _Figure 4.93 Register settings of LMMV command_
|
|
1922
|
+
|
|
1923
|
+
```
|
|
1924
|
+
> LMMV register setup
|
|
1925
|
+
|
|
1926
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1927
|
+
-----------------------------------------
|
|
1928
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
1929
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
1930
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
1931
|
+
----------------------------------------- |
|
|
1932
|
+
| origin
|
|
1933
|
+
----------------------------------------- |
|
|
1934
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
1935
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
1936
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
1937
|
+
-----------------------------------------
|
|
1938
|
+
|
|
1939
|
+
-----------------------------------------
|
|
1940
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
1941
|
+
|----+----+----+----+----+----+----+----| NX ⟶ number of dots in X direction to be painted
|
|
1942
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
1943
|
+
-----------------------------------------
|
|
1944
|
+
|
|
1945
|
+
-----------------------------------------
|
|
1946
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
1947
|
+
|----+----+----+----+----+----+----+----| NY ⟶ number of dots in Y direction to be painted
|
|
1948
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
1949
|
+
-----------------------------------------
|
|
1950
|
+
|
|
1951
|
+
----------------------------------------- --+
|
|
1952
|
+
R#44 | 0 | 0 | 0 | 0 | CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
1953
|
+
----------------------------------------- |
|
|
1954
|
+
|
|
|
1955
|
+
----------------------------------------- |
|
|
1956
|
+
| 0 | 0 | 0 | 0 | 0 | 0 | CR1| CR0| CLR (GRAPHIC 5) | data to be transferred
|
|
1957
|
+
----------------------------------------- |
|
|
1958
|
+
|
|
|
1959
|
+
----------------------------------------- |
|
|
1960
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
1961
|
+
----------------------------------------- --+
|
|
1962
|
+
|
|
1963
|
+
-----------------------------------------
|
|
1964
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
|
|
1965
|
+
-----------------------------------------
|
|
1966
|
+
| | painting direction (X)
|
|
1967
|
+
| |
|
|
1968
|
+
| +-> painting direction (Y)
|
|
1969
|
+
|
|
|
1970
|
+
+-----------> memory selection
|
|
1971
|
+
|
|
1972
|
+
> LMMV command execution
|
|
1973
|
+
|
|
1974
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
1975
|
+
-----------------------------------------
|
|
1976
|
+
R#46 | 1 | 0 | 0 | 0 | L03| L03| L01| L00| CMR
|
|
1977
|
+
-----------------------------------------
|
|
1978
|
+
| |
|
|
1979
|
+
+-------------------+
|
|
1980
|
+
Logical operation
|
|
1981
|
+
```
|
|
1982
|
+
|
|
1983
|
+
##### _List 4.15 Example of LMMV command execution_
|
|
1984
|
+
|
|
1985
|
+
```
|
|
1986
|
+
;****************************************************************
|
|
1987
|
+
; List 4.15 LMMV sample
|
|
1988
|
+
; to use, set H, L, D, E, B, A and go
|
|
1989
|
+
; data B ⟶ fill VRAM (H,L)-(D,E) (logi-op : A)
|
|
1990
|
+
;****************************************************************
|
|
1991
|
+
;
|
|
1992
|
+
RDVDP: EQU 0006H
|
|
1993
|
+
WRVDP: EQU 0007H
|
|
1994
|
+
|
|
1995
|
+
;----- program start -----
|
|
1996
|
+
|
|
1997
|
+
LMMV: DI ;disable interrupt
|
|
1998
|
+
PUSH AF ;save LOGICAL OPERATION
|
|
1999
|
+
PUSH BC ;save FILL DATA
|
|
2000
|
+
CALL WAIT.VDP ;wait end of command
|
|
2001
|
+
|
|
2002
|
+
LD A,(WRVDP)
|
|
2003
|
+
LD C,A
|
|
2004
|
+
INC C ;C := PORT#1's address
|
|
2005
|
+
LD A,36
|
|
2006
|
+
OUT (C),A
|
|
2007
|
+
LD A,80H+17
|
|
2008
|
+
OUT (C),A ;R#17 := 36
|
|
2009
|
+
|
|
2010
|
+
INC C
|
|
2011
|
+
INC C ;C := PORT#3's address
|
|
2012
|
+
XOR A
|
|
2013
|
+
OUT (C),H ;DX
|
|
2014
|
+
OUT (C),A
|
|
2015
|
+
OUT (C),L ;DY
|
|
2016
|
+
OUT (C),A
|
|
2017
|
+
|
|
2018
|
+
LD A,H ;make NX and DIX
|
|
2019
|
+
SUB A
|
|
2020
|
+
LD D,00000100B
|
|
2021
|
+
JP NC,LMMV1
|
|
2022
|
+
LD D,00000000B
|
|
2023
|
+
NEG
|
|
2024
|
+
LMMV1: LD H,A ;H := NX , D := DIX
|
|
2025
|
+
|
|
2026
|
+
LD A,L ;make NY and DIY
|
|
2027
|
+
SUB A
|
|
2028
|
+
LD E,00001000B
|
|
2029
|
+
JP NC,LMMV2
|
|
2030
|
+
LD E,00000000B
|
|
2031
|
+
NEG
|
|
2032
|
+
LMMV2: LD L,A ;L := NY , E := DIY
|
|
2033
|
+
|
|
2034
|
+
XOR A
|
|
2035
|
+
OUT (C),H ;NX
|
|
2036
|
+
OUT (C),A
|
|
2037
|
+
OUT (C),L ;NY
|
|
2038
|
+
OUT (C),A
|
|
2039
|
+
POP AF
|
|
2040
|
+
OUT (C),A ;FILL DATA
|
|
2041
|
+
LD A,D
|
|
2042
|
+
OR E
|
|
2043
|
+
OUT (C),A ;DIX and DIY
|
|
2044
|
+
|
|
2045
|
+
POP AF ;restore LOGICAL OPERATION
|
|
2046
|
+
OR A,10000000B ;LMMV command
|
|
2047
|
+
OUT (C),A
|
|
2048
|
+
|
|
2049
|
+
EI
|
|
2050
|
+
RET
|
|
2051
|
+
|
|
2052
|
+
GET.STATUS:
|
|
2053
|
+
PUSH BC
|
|
2054
|
+
LD BC,(WRVDP)
|
|
2055
|
+
INC C
|
|
2056
|
+
OUT (C),A
|
|
2057
|
+
LD A,8FH
|
|
2058
|
+
OUT (C),A
|
|
2059
|
+
LD BC,(RDVDP)
|
|
2060
|
+
INC C
|
|
2061
|
+
IN A,(C)
|
|
2062
|
+
POP BC
|
|
2063
|
+
RET
|
|
2064
|
+
|
|
2065
|
+
WAIT.VDP:
|
|
2066
|
+
LD A,2
|
|
2067
|
+
CALL GET.STATUS
|
|
2068
|
+
AND 1
|
|
2069
|
+
JP NZ,WAIT.VDP
|
|
2070
|
+
XOR A
|
|
2071
|
+
CALL GET.STATUS
|
|
2072
|
+
RET
|
|
2073
|
+
|
|
2074
|
+
END
|
|
2075
|
+
```
|
|
2076
|
+
|
|
2077
|
+
|
|
2078
|
+
<p> </p>
|
|
2079
|
+
|
|
2080
|
+
#### 6.5.9 LINE (drawing a line)
|
|
2081
|
+
|
|
2082
|
+
Lines can be drawn between any coordinates in VRAM. The parameters to be specified include the (X,Y) coordinates of the starting point and the X and Y lengths in units to the ending point (see [Figure 4.94](#figure-494--actions-of-line-command)). Logical operations between data in VRAM and the specified data are allowed.
|
|
2083
|
+
|
|
2084
|
+
After setting the parameters as shown in [Figure 4.94](#figure-494--actions-of-line-command), writing command code 7XH (X means a logical operation) in R#46 causes the command to be executed. While the CE bit of S#2 is "1", the command is being executed. [List 4.16](#list-416--example-of-line-command-execution) shows an example of using LINE.
|
|
2085
|
+
|
|
2086
|
+
|
|
2087
|
+
##### _Figure 4.94 Actions of LINE command_
|
|
2088
|
+
|
|
2089
|
+
```
|
|
2090
|
+
VRAM or expansion RAM
|
|
2091
|
+
---------------------------------------------------
|
|
2092
|
+
| |
|
|
2093
|
+
| / : ^ |
|
|
2094
|
+
| / : | |
|
|
2095
|
+
| / : DIY |
|
|
2096
|
+
| / : |
|
|
2097
|
+
| / Min : |
|
|
2098
|
+
| / : |
|
|
2099
|
+
| / : |
|
|
2100
|
+
| / Maj : |
|
|
2101
|
+
| x................. -> DIX |
|
|
2102
|
+
| (DX,DY) |
|
|
2103
|
+
| |
|
|
2104
|
+
---------------------------------------------------
|
|
2105
|
+
|
|
2106
|
+
MXD: select memory 0 = VRAM, 1 = expansion RAM
|
|
2107
|
+
|
|
2108
|
+
Maj: number of dots of major side (0 to 1023)
|
|
2109
|
+
Maj: number of dots of minor side (0 to 512)
|
|
2110
|
+
|
|
2111
|
+
MAJ: 0 = The major side is parallel to X axis
|
|
2112
|
+
MAJ: 1 = The major side is parallel to Y axis,
|
|
2113
|
+
or the major side = the minor side
|
|
2114
|
+
|
|
2115
|
+
DIX: direction of the end from the origin 0 = right, 1 = left
|
|
2116
|
+
DIY: direction of the end from the origin 0 = below, 1 = above
|
|
2117
|
+
|
|
2118
|
+
DX: origin X-coordinate (0 to 511)
|
|
2119
|
+
DY: origin Y-coordinate (0 to 1023)
|
|
2120
|
+
|
|
2121
|
+
CLR (R#44:Colour register): Line colour data
|
|
2122
|
+
```
|
|
2123
|
+
|
|
2124
|
+
##### _Figure 4.95 Register settings of LINE command_
|
|
2125
|
+
|
|
2126
|
+
```
|
|
2127
|
+
> LINE register setup
|
|
2128
|
+
|
|
2129
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2130
|
+
-----------------------------------------
|
|
2131
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
2132
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
2133
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
2134
|
+
----------------------------------------- |
|
|
2135
|
+
| origin
|
|
2136
|
+
----------------------------------------- |
|
|
2137
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
2138
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
2139
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
2140
|
+
-----------------------------------------
|
|
2141
|
+
|
|
2142
|
+
-----------------------------------------
|
|
2143
|
+
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0|
|
|
2144
|
+
|----+----+----+----+----+----+----+----| Maj (NX) -> number of dots of the major side
|
|
2145
|
+
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8|
|
|
2146
|
+
-----------------------------------------
|
|
2147
|
+
|
|
2148
|
+
-----------------------------------------
|
|
2149
|
+
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0|
|
|
2150
|
+
|----+----+----+----+----+----+----+----| Min (NY) -> number of dots of the minor side
|
|
2151
|
+
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8|
|
|
2152
|
+
-----------------------------------------
|
|
2153
|
+
|
|
2154
|
+
----------------------------------------- --+
|
|
2155
|
+
R#44 | 0 | 0 | 0 | 0 | CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
2156
|
+
----------------------------------------- |
|
|
2157
|
+
|
|
|
2158
|
+
----------------------------------------- |
|
|
2159
|
+
| 0 | 0 | 0 | 0 | 0 | 0 | CR1| CR0| CLR (GRAPHIC 5) | colour code data
|
|
2160
|
+
----------------------------------------- |
|
|
2161
|
+
|
|
|
2162
|
+
----------------------------------------- |
|
|
2163
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
2164
|
+
----------------------------------------- --+
|
|
2165
|
+
|
|
2166
|
+
-----------------------------------------
|
|
2167
|
+
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | MAJ| ARG (Argument register)
|
|
2168
|
+
-----------------------------------------
|
|
2169
|
+
| | | major side selection
|
|
2170
|
+
| | V
|
|
2171
|
+
| | direction to the end (X)
|
|
2172
|
+
| |
|
|
2173
|
+
| +-> direction to the end (Y)
|
|
2174
|
+
|
|
|
2175
|
+
+-----------> memory selection
|
|
2176
|
+
|
|
2177
|
+
> LINE command execution
|
|
2178
|
+
|
|
2179
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2180
|
+
-----------------------------------------
|
|
2181
|
+
R#46 | 0 | 1 | 1 | 1 | L03| L03| L01| L00| CMR
|
|
2182
|
+
-----------------------------------------
|
|
2183
|
+
| |
|
|
2184
|
+
+-------------------+
|
|
2185
|
+
Logical operation
|
|
2186
|
+
```
|
|
2187
|
+
|
|
2188
|
+
##### _List 4.16 Example of LINE command execution_
|
|
2189
|
+
|
|
2190
|
+
```
|
|
2191
|
+
;****************************************************************
|
|
2192
|
+
; List 4.16 LINE sample
|
|
2193
|
+
; to use, set H, L, D, E, B, A and go
|
|
2194
|
+
; draw LINE (H,L)-(D,E) with color B, log-op A
|
|
2195
|
+
;****************************************************************
|
|
2196
|
+
;
|
|
2197
|
+
RDVDP: EQU 0006H
|
|
2198
|
+
WRVDP: EQU 0007H
|
|
2199
|
+
|
|
2200
|
+
;----- program start -----
|
|
2201
|
+
|
|
2202
|
+
LINE: DI ;disable interrupt
|
|
2203
|
+
PUSH AF ;save LOGICAL OPERATION
|
|
2204
|
+
PUSH BC ;save COLOR
|
|
2205
|
+
CALL WAIT.VDP ;wait end of command
|
|
2206
|
+
LD A,(WRVDP)
|
|
2207
|
+
LD C,A
|
|
2208
|
+
INC C ;C := PORT#1's address
|
|
2209
|
+
LD A,36
|
|
2210
|
+
OUT (C),A
|
|
2211
|
+
LD A,80H+17
|
|
2212
|
+
OUT (C),A ;R#17 := 36
|
|
2213
|
+
|
|
2214
|
+
INC C
|
|
2215
|
+
INC C ;C := PORT#3's address
|
|
2216
|
+
XOR A
|
|
2217
|
+
OUT (C),H ;DX
|
|
2218
|
+
OUT (C),A
|
|
2219
|
+
OUT (C),L ;DY
|
|
2220
|
+
OUT (C),A
|
|
2221
|
+
|
|
2222
|
+
LD A,H ;make DX and DIX
|
|
2223
|
+
SUB D
|
|
2224
|
+
LD D,00000100B
|
|
2225
|
+
JP NC,LINE1
|
|
2226
|
+
LD D,00000000B
|
|
2227
|
+
NEG
|
|
2228
|
+
LINE1: LD H,A ;H := DX , D := DIX
|
|
2229
|
+
|
|
2230
|
+
LD A,L ;make DY and DIY
|
|
2231
|
+
SUB E
|
|
2232
|
+
LD E,00001000B
|
|
2233
|
+
JP NC,LINE2
|
|
2234
|
+
LD E,00000000B
|
|
2235
|
+
NEG
|
|
2236
|
+
LINE2: LD L,A ;L := DY , E := DIY
|
|
2237
|
+
|
|
2238
|
+
CP H ;make Maj and Min
|
|
2239
|
+
JP C,LINE3
|
|
2240
|
+
XOR A
|
|
2241
|
+
OUT (C),L ;long side
|
|
2242
|
+
OUT (C),A
|
|
2243
|
+
OUT (C),H ;short side
|
|
2244
|
+
OUT (C),A
|
|
2245
|
+
LD A,00000001B ;MAJ := 1
|
|
2246
|
+
JP LINE4
|
|
2247
|
+
|
|
2248
|
+
LINE3: XOR A
|
|
2249
|
+
OUT (C),H ;NX
|
|
2250
|
+
OUT (C),A
|
|
2251
|
+
OUT (C),L ;NY
|
|
2252
|
+
OUT (C),A
|
|
2253
|
+
LD A,00000000B ;MAJ := 0
|
|
2254
|
+
|
|
2255
|
+
LINE4: OR D
|
|
2256
|
+
OR E ;A := DIX , DIY , MAJ
|
|
2257
|
+
POP HL ;H := COLOR
|
|
2258
|
+
OUT (C),H
|
|
2259
|
+
OUT (C),A
|
|
2260
|
+
POP AF ;A := LOGICAL OPERATION
|
|
2261
|
+
OR 01110000B
|
|
2262
|
+
OUT (C),A
|
|
2263
|
+
LD A,8FH
|
|
2264
|
+
OUT (C),A
|
|
2265
|
+
EI
|
|
2266
|
+
RET
|
|
2267
|
+
|
|
2268
|
+
GET.STATUS:
|
|
2269
|
+
PUSH BC
|
|
2270
|
+
LD BC,(WRVDP)
|
|
2271
|
+
INC C
|
|
2272
|
+
OUT (C),A
|
|
2273
|
+
LD A,8FH
|
|
2274
|
+
OUT (C),A
|
|
2275
|
+
LD BC,(RDVDP)
|
|
2276
|
+
INC C
|
|
2277
|
+
IN A,(C)
|
|
2278
|
+
POP BC
|
|
2279
|
+
RET
|
|
2280
|
+
|
|
2281
|
+
WAIT.VDP:
|
|
2282
|
+
LD A,2
|
|
2283
|
+
CALL GET.STATUS
|
|
2284
|
+
AND 1
|
|
2285
|
+
JP NZ,WAIT.VDP
|
|
2286
|
+
XOR A
|
|
2287
|
+
CALL GET.STATUS
|
|
2288
|
+
RET
|
|
2289
|
+
|
|
2290
|
+
END
|
|
2291
|
+
```
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
<p> </p>
|
|
2295
|
+
|
|
2296
|
+
#### 6.5.10 SRCH (colour code search)
|
|
2297
|
+
|
|
2298
|
+
SRCH searches for the existence of the specified colour from any coordinate on VRAM to the right or the left (see figure 4.96). This is very useful for paint routines.
|
|
2299
|
+
|
|
2300
|
+
After setting the parameters as shown in [Figure 4.97](#figure-497--register-settings-of-srch-command), writing 60H in R#46 causes the command to be executed. The command terminates when the objective colour is found or when it cannot be found after searching for it to the screen edge. While the CE bit of S#2 is "1", the command is being executed (see [Figure 4.98](#figure-498--srch-command-execution-flowchart)).
|
|
2301
|
+
|
|
2302
|
+
After the command ends, the objective colour code is stored in S#8 and S#9. [List 4.17](#list-417--example-of-srch-command-execution) shows an example of using SRCH.
|
|
2303
|
+
|
|
2304
|
+
|
|
2305
|
+
##### _Figure 4.96 Actions of SRCH command_
|
|
2306
|
+
|
|
2307
|
+
```
|
|
2308
|
+
VRAM or expansion RAM
|
|
2309
|
+
---------------------------------------------------
|
|
2310
|
+
| |
|
|
2311
|
+
| |
|
|
2312
|
+
| |
|
|
2313
|
+
| |
|
|
2314
|
+
| (SX,SY) DIX |
|
|
2315
|
+
| x......................>x |
|
|
2316
|
+
| Border |
|
|
2317
|
+
| colour |
|
|
2318
|
+
| point |
|
|
2319
|
+
| |
|
|
2320
|
+
| |
|
|
2321
|
+
| |
|
|
2322
|
+
---------------------------------------------------
|
|
2323
|
+
|
|
2324
|
+
MXD: memory selection for the seacrh 0 = VRAM, 1 = expansion RAM
|
|
2325
|
+
|
|
2326
|
+
SX: search origin X-coordinate (0 to 511)
|
|
2327
|
+
SY: search origin Y-coordinate (0 to 1023)
|
|
2328
|
+
|
|
2329
|
+
DIX: direction for the search from the origin 0 = right, 1 = left
|
|
2330
|
+
|
|
2331
|
+
EQ: 0 = ends the execution when the border colour is found
|
|
2332
|
+
1 = ends the execution when the colour is found other than the
|
|
2333
|
+
border colour
|
|
2334
|
+
|
|
2335
|
+
CLR (R#44:Colour register): border colour
|
|
2336
|
+
```
|
|
2337
|
+
|
|
2338
|
+
##### _Figure 4.97 Register settings of SRCH command_
|
|
2339
|
+
|
|
2340
|
+
```
|
|
2341
|
+
> SRCH register setup
|
|
2342
|
+
|
|
2343
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2344
|
+
-----------------------------------------
|
|
2345
|
+
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|
|
2346
|
+
|----+----+----+----+----+----+----+----| SX ---+
|
|
2347
|
+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
|
|
2348
|
+
----------------------------------------- |
|
|
2349
|
+
| search origin
|
|
2350
|
+
----------------------------------------- |
|
|
2351
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|
|
2352
|
+
|----+----+----+----+----+----+----+----| SY ---+
|
|
2353
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
2354
|
+
-----------------------------------------
|
|
2355
|
+
|
|
2356
|
+
----------------------------------------- --+
|
|
2357
|
+
R#44 | 0 | 0 | 0 | 0 | CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
2358
|
+
----------------------------------------- |
|
|
2359
|
+
|
|
|
2360
|
+
----------------------------------------- |
|
|
2361
|
+
| 0 | 0 | 0 | 0 | 0 | 0 | CR1| CR0| CLR (GRAPHIC 5) | border colour
|
|
2362
|
+
----------------------------------------- |
|
|
2363
|
+
|
|
|
2364
|
+
----------------------------------------- |
|
|
2365
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
2366
|
+
----------------------------------------- --+
|
|
2367
|
+
|
|
2368
|
+
-----------------------------------------
|
|
2369
|
+
R#45 | -- | -- | MXD| -- | -- | DIX| EQ | -- | ARG (Argument register)
|
|
2370
|
+
-----------------------------------------
|
|
2371
|
+
| | the condition for terminating
|
|
2372
|
+
| | the execution
|
|
2373
|
+
| V
|
|
2374
|
+
| search direction (X)
|
|
2375
|
+
|
|
|
2376
|
+
+-----------> memory selection for the search
|
|
2377
|
+
|
|
2378
|
+
> SRCH command execution
|
|
2379
|
+
|
|
2380
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2381
|
+
-----------------------------------------
|
|
2382
|
+
R#46 | 0 | 1 | 1 | 0 | -- | -- | -- | -- | CMR
|
|
2383
|
+
-----------------------------------------
|
|
2384
|
+
|
|
2385
|
+
-----------------------------------------
|
|
2386
|
+
S#2 | -- | -- | -- | BO | -- | -- | -- | CE | CMR
|
|
2387
|
+
-----------------------------------------
|
|
2388
|
+
| when the command ends : 0
|
|
2389
|
+
|
|
|
2390
|
+
+-------> when the border colour is found : 1
|
|
2391
|
+
|
|
2392
|
+
-----------------------------------------
|
|
2393
|
+
S#8 | BX7| BX6| BX5| BX4| BX3| BX2| BX1| BX0|
|
|
2394
|
+
----------------------------------------- X-coordinate when the border colour is found
|
|
2395
|
+
S#9 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | BX8|
|
|
2396
|
+
-----------------------------------------
|
|
2397
|
+
```
|
|
2398
|
+
|
|
2399
|
+
##### _Figure 4.98 SRCH command execution flowchart_
|
|
2400
|
+
|
|
2401
|
+
```
|
|
2402
|
+
/-------------------\
|
|
2403
|
+
| SRCH start |
|
|
2404
|
+
\-------------------/
|
|
2405
|
+
|
|
|
2406
|
+
---------------------
|
|
2407
|
+
| register setup |
|
|
2408
|
+
---------------------
|
|
2409
|
+
|
|
|
2410
|
+
---------------------
|
|
2411
|
+
| command execution |
|
|
2412
|
+
---------------------
|
|
2413
|
+
|
|
|
2414
|
+
+---------------->|
|
|
2415
|
+
| |
|
|
2416
|
+
| ---------------------------
|
|
2417
|
+
| | Read status register #2 |
|
|
2418
|
+
| ---------------------------
|
|
2419
|
+
| |
|
|
2420
|
+
| //////////+\\\\\\\\\\
|
|
2421
|
+
+-------| command end? |
|
|
2422
|
+
No \\\\\\\\\\+//////////
|
|
2423
|
+
(CE bit = 1) |
|
|
2424
|
+
| Yes (CE bit = 0)
|
|
2425
|
+
|
|
|
2426
|
+
/////////////+\\\\\\\\\\\\\
|
|
2427
|
+
+----| Is border colour found? |
|
|
2428
|
+
| \\\\\\\\\\\\\+/////////////
|
|
2429
|
+
| No |
|
|
2430
|
+
| (BO bit = 0) | Yes (BO bit = 1)
|
|
2431
|
+
| |
|
|
2432
|
+
| ---------------------------
|
|
2433
|
+
| | Read status register #8 |
|
|
2434
|
+
| ---------------------------
|
|
2435
|
+
| |
|
|
2436
|
+
| ---------------------------
|
|
2437
|
+
| | Read status register #2 |
|
|
2438
|
+
| ---------------------------
|
|
2439
|
+
| |
|
|
2440
|
+
+---------------->|
|
|
2441
|
+
|
|
|
2442
|
+
V
|
|
2443
|
+
/--------------------\
|
|
2444
|
+
| SRCH end |
|
|
2445
|
+
\--------------------/
|
|
2446
|
+
```
|
|
2447
|
+
|
|
2448
|
+
##### _List 4.17 Example of SRCH command execution_
|
|
2449
|
+
|
|
2450
|
+
```
|
|
2451
|
+
;****************************************************************
|
|
2452
|
+
; List 4.17 SRCH sample
|
|
2453
|
+
; to use, set H, L, E, A as follows
|
|
2454
|
+
; srch (x:H, y:L, color:E, arg(reg#45) : A)
|
|
2455
|
+
; returns: Z (not found)
|
|
2456
|
+
; NZ (A := X)
|
|
2457
|
+
;****************************************************************
|
|
2458
|
+
;
|
|
2459
|
+
RDVDP: EQU 0006H
|
|
2460
|
+
WRVDP: EQU 0007H
|
|
2461
|
+
|
|
2462
|
+
;----- program start -----
|
|
2463
|
+
|
|
2464
|
+
SRCH: DI ;disable interrupt
|
|
2465
|
+
PUSH AF ;save arg
|
|
2466
|
+
CALL WAIT.VDP
|
|
2467
|
+
|
|
2468
|
+
LD A,(WRVDP)
|
|
2469
|
+
LD C,A
|
|
2470
|
+
INC C ;C := PORT#1's address
|
|
2471
|
+
|
|
2472
|
+
LD D,0
|
|
2473
|
+
LD A,32+80H
|
|
2474
|
+
OUT (C),H
|
|
2475
|
+
OUT (C),A ;R#32 := H
|
|
2476
|
+
INC A
|
|
2477
|
+
OUT (C),D
|
|
2478
|
+
OUT (C),A ;R#33 := 0
|
|
2479
|
+
INC A
|
|
2480
|
+
OUT (C),L
|
|
2481
|
+
OUT (C),A ;R#34 := L
|
|
2482
|
+
INC A
|
|
2483
|
+
OUT (C),D
|
|
2484
|
+
OUT (C),A ;R#35 := 0
|
|
2485
|
+
LD A,44+80H
|
|
2486
|
+
OUT (C),E
|
|
2487
|
+
OUT (C),A ;R#44 := E
|
|
2488
|
+
INC A
|
|
2489
|
+
LD E,A
|
|
2490
|
+
POP AF ;A := ARG
|
|
2491
|
+
OUT (C),A
|
|
2492
|
+
OUT (C),E ;R#45 := A
|
|
2493
|
+
|
|
2494
|
+
LD A,01100000B
|
|
2495
|
+
OUT (C),A
|
|
2496
|
+
INC E
|
|
2497
|
+
OUT (C),E ;R#46 := SRCH command
|
|
2498
|
+
|
|
2499
|
+
LOOP: LD A,2
|
|
2500
|
+
CALL GET.STATUS
|
|
2501
|
+
BIT 0,A
|
|
2502
|
+
JP NZ,LOOP
|
|
2503
|
+
LD E,A
|
|
2504
|
+
LD A,8
|
|
2505
|
+
CALL GET.STATUS
|
|
2506
|
+
LD D,A
|
|
2507
|
+
LD A,9
|
|
2508
|
+
CALL GET.STATUS
|
|
2509
|
+
LD A,D
|
|
2510
|
+
BIT 4,E
|
|
2511
|
+
|
|
2512
|
+
EI
|
|
2513
|
+
RET
|
|
2514
|
+
|
|
2515
|
+
GET.STATUS:
|
|
2516
|
+
PUSH BC
|
|
2517
|
+
LD BC,(WRVDP)
|
|
2518
|
+
INC C
|
|
2519
|
+
OUT (C),A
|
|
2520
|
+
LD A,8FH
|
|
2521
|
+
OUT (C),A
|
|
2522
|
+
LD BC,(RDVDP)
|
|
2523
|
+
INC C
|
|
2524
|
+
IN A,(C)
|
|
2525
|
+
POP BC
|
|
2526
|
+
RET
|
|
2527
|
+
|
|
2528
|
+
WAIT.VDP:
|
|
2529
|
+
LD A,2
|
|
2530
|
+
CALL GET.STATUS
|
|
2531
|
+
AND 1
|
|
2532
|
+
JP NZ,WAIT.VDP
|
|
2533
|
+
XOR A
|
|
2534
|
+
CALL GET.STATUS
|
|
2535
|
+
RET
|
|
2536
|
+
|
|
2537
|
+
END
|
|
2538
|
+
```
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
##### _List 4.18 Simple PAINT routine using SRCH and LINE_
|
|
2542
|
+
|
|
2543
|
+
```
|
|
2544
|
+
;****************************************************************
|
|
2545
|
+
; List 4.18 SRCH and LINE sample
|
|
2546
|
+
; search color to right and left,
|
|
2547
|
+
; then draw line between the two points
|
|
2548
|
+
;****************************************************************
|
|
2549
|
+
;
|
|
2550
|
+
EXTRN SRCH
|
|
2551
|
+
EXTRN LINE
|
|
2552
|
+
|
|
2553
|
+
Y EQU 0A800H
|
|
2554
|
+
X EQU 0A801H
|
|
2555
|
+
COL EQU 0A802H
|
|
2556
|
+
ARG EQU 0A803H
|
|
2557
|
+
PCOL EQU 0A804H
|
|
2558
|
+
|
|
2559
|
+
;----- program start -----
|
|
2560
|
+
|
|
2561
|
+
MAIN: LD (STK),SP
|
|
2562
|
+
LD SP,AREA
|
|
2563
|
+
LD HL,(Y)
|
|
2564
|
+
LD A,(COL)
|
|
2565
|
+
LD E,A
|
|
2566
|
+
LD A,(ARG)
|
|
2567
|
+
PUSH HL
|
|
2568
|
+
PUSH DE
|
|
2569
|
+
SET 2,A
|
|
2570
|
+
CALL SRCH
|
|
2571
|
+
POP DE
|
|
2572
|
+
POP HL
|
|
2573
|
+
JP NZ,S1
|
|
2574
|
+
LD A,(X)
|
|
2575
|
+
DEC A
|
|
2576
|
+
S1: INC A
|
|
2577
|
+
PUSH AF
|
|
2578
|
+
LD A,(ARG)
|
|
2579
|
+
RES 2,A
|
|
2580
|
+
CALL SRCH
|
|
2581
|
+
JP NZ,S2
|
|
2582
|
+
LD A,(X)
|
|
2583
|
+
INC A
|
|
2584
|
+
S2: DEC A
|
|
2585
|
+
LD D,A
|
|
2586
|
+
POP AF
|
|
2587
|
+
LD H,A
|
|
2588
|
+
LD A,(Y)
|
|
2589
|
+
LD L,A
|
|
2590
|
+
LD E,A
|
|
2591
|
+
LD A,(PCOL)
|
|
2592
|
+
LD B,A
|
|
2593
|
+
LD A,0 ;PSET
|
|
2594
|
+
CALL LINE
|
|
2595
|
+
LD SP,(STK)
|
|
2596
|
+
RET
|
|
2597
|
+
|
|
2598
|
+
;----- work area -----
|
|
2599
|
+
|
|
2600
|
+
STK: DS 2
|
|
2601
|
+
DS 200
|
|
2602
|
+
AREA: $
|
|
2603
|
+
|
|
2604
|
+
END
|
|
2605
|
+
```
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
##### _List 4.19 Example of the use of simple PAINT routine_
|
|
2609
|
+
|
|
2610
|
+
```
|
|
2611
|
+
1000 '***********************************************
|
|
2612
|
+
1010 ' List 4.19 SRCH and LINE sample
|
|
2613
|
+
1020 ' Operate cursor while holding down the space bar.
|
|
2614
|
+
1030 '***********************************************
|
|
2615
|
+
1040 '
|
|
2616
|
+
1050 SCREEN 5
|
|
2617
|
+
1060 FOR I=0 TO 50:LINE -(RND(1)*255,RND(1)*211),15:NEXT
|
|
2618
|
+
1070 I=&HA000 :DEF USR=I
|
|
2619
|
+
1080 READ A$
|
|
2620
|
+
1090 IF A$="END" THEN 1130
|
|
2621
|
+
1100 POKE I,VAL("&H"+A$):I=I+1
|
|
2622
|
+
1110 READ A$
|
|
2623
|
+
1120 GOTO 1090
|
|
2624
|
+
1130 X=128:Y=100:COL=15:PCOL=2:ARG=0
|
|
2625
|
+
1140 CURS=0
|
|
2626
|
+
1150 A=STICK(0)
|
|
2627
|
+
1160 CURS=(CURS+1) AND 1
|
|
2628
|
+
1170 LINE (X-5,I)-(X+5,I),15,,XOR
|
|
2629
|
+
1180 LINE (X,Y-5)-(X,Y+5),15,,XOR
|
|
2630
|
+
1190 IF CURS=1 THEN 1290
|
|
2631
|
+
1200 IF A=1 THEN Y=Y-1
|
|
2632
|
+
1210 IF A=2 THEN Y=Y-1:X=X+1
|
|
2633
|
+
1220 IF A=3 THEN X=X+1
|
|
2634
|
+
1230 IF A=4 THEN X=X+1:Y=Y+1
|
|
2635
|
+
1240 IF A=5 THEN Y=Y+1
|
|
2636
|
+
1250 IF A=6 THEN Y=Y+1:X=X-1
|
|
2637
|
+
1260 IF A=7 THEN X=X-1
|
|
2638
|
+
1270 IF A=8 THEN X=X-1:Y=Y-1
|
|
2639
|
+
1280 IF STRIG(9) THEN GOSUB 1300
|
|
2640
|
+
1290 GOTO 1150
|
|
2641
|
+
1300 POKE &HA800,Y
|
|
2642
|
+
1310 POKE &HA801,X
|
|
2643
|
+
1320 POKE &HA802,COL
|
|
2644
|
+
1330 POKE &HA803,ARG
|
|
2645
|
+
1340 POKE &HA804,PCOL
|
|
2646
|
+
1350 A=USR(0)
|
|
2647
|
+
1360 RETURN
|
|
2648
|
+
1370 DATA ED,73,80,A8,31,4A,A9,2A,00,A8,3A,02
|
|
2649
|
+
1380 DATA A8,5F,3A,03,A8,E5,D5,CB,D7,CD,AD
|
|
2650
|
+
1390 DATA A0,D1,E1,C2,21,A0,3A,01,A8
|
|
2651
|
+
1400 DATA 3D,3C,F5,3A,03,A8,CB,97,CD,AD,A0,C2
|
|
2652
|
+
1410 DATA 32,A0,3A,01,AB,3C,3D,57,F1,67,3A
|
|
2653
|
+
1420 DATA 00,A8,6F,5F,3A,04,A8,47,3E
|
|
2654
|
+
1430 DATA 00,CD,49,A0,ED,7B,80,A8,C9,F3,F5,CD
|
|
2655
|
+
1440 DATA 0D,A1,C5,3A,06,00,4F,0C,3E,24,ED
|
|
2656
|
+
1450 DATA 79,3E,91,ED,79,0C,0C,AF,ED
|
|
2657
|
+
1460 DATA 61,ED,79,ED,69,ED,79,7C,92,16,04,D2
|
|
2658
|
+
1470 DATA 72,A0,16,00,ED,44,67,7D,93,1E,08
|
|
2659
|
+
1480 DATA D2,7E,A0,1E,00,ED,44,BC,DA
|
|
2660
|
+
1490 DATA 90,A0,ED,79,AF,ED,79,ED,61,ED,79,26
|
|
2661
|
+
1500 DATA 01,C3,9C,A0,ED,61,67,AF,ED,79,ED
|
|
2662
|
+
1510 DATA 61,ED,79,26,00,7C,B2,B3,E1
|
|
2663
|
+
1520 DATA ED,61,ED,79,F1,E6,0F,F6,70,ED,79,FB
|
|
2664
|
+
1530 DATA C9,F5,F3,CD,0D,A1,ED,4B,06,00,0C
|
|
2665
|
+
1540 DATA 3E,A0,16,00,ED,61,ED,79,3C
|
|
2666
|
+
1550 DATA ED,51,ED,79,3C,ED,69,ED,79,3C,ED,51
|
|
2667
|
+
1560 DATA ED,79,3E,AC,ED,59,ED,79,3C,5F,F1
|
|
2668
|
+
1570 DATA ED,79,ED,59,3E,60,ED,79,1C
|
|
2669
|
+
1580 DATA ED,59,3E,02,CD,FD,A0,CB,47,C2,E2,A0
|
|
2670
|
+
1590 DATA 5F,3E,08,CD,FD,A0,57,3E,00,CD,FD
|
|
2671
|
+
1600 DATA A0,7A,CB,63,FB,C9,C5,ED,4B
|
|
2672
|
+
1610 DATA 06,00,0C,ED,79,3E,8F,ED,79,ED,78,C1
|
|
2673
|
+
1620 DATA C9,3E,02,CD,FD,A0,E6,01,C2,0D,A1
|
|
2674
|
+
1630 DATA AF,CD,FD,A0,C9,END
|
|
2675
|
+
```
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
<p> </p>
|
|
2679
|
+
|
|
2680
|
+
#### 6.5.11 PSET (drawing a point)
|
|
2681
|
+
|
|
2682
|
+
A point is drawn at any coordinate in VRAM (see figure 4.99).
|
|
2683
|
+
|
|
2684
|
+
After setting the parameters as shown in [Figure 4.100](#figure-4100--register-settings-of-pset-command), writing 5XH (X means a logical operation) in R#46 causes the command to be executed. While the CE bit of S#2 is "1", the command is being executed. [List 4.20](#list-420--example-of-pset-command-execution) shows an example of using PSET.
|
|
2685
|
+
|
|
2686
|
+
|
|
2687
|
+
##### _Figure 4.99 Actions of PSET command_
|
|
2688
|
+
|
|
2689
|
+
```
|
|
2690
|
+
VRAM or expansion RAM
|
|
2691
|
+
---------------------------------------------------
|
|
2692
|
+
| |
|
|
2693
|
+
| |
|
|
2694
|
+
| |
|
|
2695
|
+
| |
|
|
2696
|
+
| (DX,DY) |
|
|
2697
|
+
| x |
|
|
2698
|
+
| |
|
|
2699
|
+
| |
|
|
2700
|
+
| |
|
|
2701
|
+
| |
|
|
2702
|
+
| |
|
|
2703
|
+
| |
|
|
2704
|
+
---------------------------------------------------
|
|
2705
|
+
|
|
2706
|
+
MXD: memory selection 0 = VRAM, 1 = expansion RAM
|
|
2707
|
+
|
|
2708
|
+
DX: origin X-coordinate (0 to 511)
|
|
2709
|
+
DY: origin Y-coordinate (0 to 1023)
|
|
2710
|
+
|
|
2711
|
+
CLR (R#44:Colour register): point colour
|
|
2712
|
+
```
|
|
2713
|
+
|
|
2714
|
+
##### _Figure 4.100 Register settings of PSET command_
|
|
2715
|
+
|
|
2716
|
+
```
|
|
2717
|
+
> PSET register setup
|
|
2718
|
+
|
|
2719
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2720
|
+
-----------------------------------------
|
|
2721
|
+
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|
|
2722
|
+
|----+----+----+----+----+----+----+----| DX ---+
|
|
2723
|
+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
|
|
2724
|
+
----------------------------------------- |
|
|
2725
|
+
| origin
|
|
2726
|
+
----------------------------------------- |
|
|
2727
|
+
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|
|
2728
|
+
|----+----+----+----+----+----+----+----| DY ---+
|
|
2729
|
+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
|
|
2730
|
+
-----------------------------------------
|
|
2731
|
+
|
|
2732
|
+
----------------------------------------- --+
|
|
2733
|
+
R#44 | 0 | 0 | 0 | 0 | CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |
|
|
2734
|
+
----------------------------------------- |
|
|
2735
|
+
|
|
|
2736
|
+
----------------------------------------- |
|
|
2737
|
+
| 0 | 0 | 0 | 0 | 0 | 0 | CR1| CR0| CLR (GRAPHIC 5) | colour code data
|
|
2738
|
+
----------------------------------------- |
|
|
2739
|
+
|
|
|
2740
|
+
----------------------------------------- |
|
|
2741
|
+
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |
|
|
2742
|
+
----------------------------------------- --+
|
|
2743
|
+
|
|
2744
|
+
-----------------------------------------
|
|
2745
|
+
R#45 | 0 | -- | MXD| -- | -- | -- | -- | -- | ARG (Argument register)
|
|
2746
|
+
-----------------------------------------
|
|
2747
|
+
|
|
|
2748
|
+
+-----------> memory selection
|
|
2749
|
+
|
|
2750
|
+
> PSET command execution
|
|
2751
|
+
|
|
2752
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2753
|
+
-----------------------------------------
|
|
2754
|
+
R#46 | 0 | 1 | 0 | 1 | L03| L02| L01| L00| CMR
|
|
2755
|
+
-----------------------------------------
|
|
2756
|
+
| |
|
|
2757
|
+
+-------------------+
|
|
2758
|
+
Logical operation
|
|
2759
|
+
```
|
|
2760
|
+
|
|
2761
|
+
##### _List 4.20 Example of PSET command execution_
|
|
2762
|
+
|
|
2763
|
+
```
|
|
2764
|
+
;****************************************************************
|
|
2765
|
+
; List 4.20 PSET sample
|
|
2766
|
+
; to use, set H, L, E, A as follows
|
|
2767
|
+
; pset (x:H, y:L), color:E, logi-OP:A
|
|
2768
|
+
;****************************************************************
|
|
2769
|
+
;
|
|
2770
|
+
PUBLIC PSET
|
|
2771
|
+
|
|
2772
|
+
RDVDP: EQU 0006H
|
|
2773
|
+
WRVDP: EQU 0007H
|
|
2774
|
+
|
|
2775
|
+
;----- program start -----
|
|
2776
|
+
|
|
2777
|
+
PSET: DI
|
|
2778
|
+
PUSH AF
|
|
2779
|
+
CALL WAIT.VDP
|
|
2780
|
+
LD BC,(WRVDP)
|
|
2781
|
+
|
|
2782
|
+
INC C
|
|
2783
|
+
LD A,36
|
|
2784
|
+
OUT (C),A
|
|
2785
|
+
LD A,80H+17
|
|
2786
|
+
OUT (C),A
|
|
2787
|
+
|
|
2788
|
+
PUSH BC
|
|
2789
|
+
INC C
|
|
2790
|
+
INC C
|
|
2791
|
+
XOR A
|
|
2792
|
+
OUT (C),H
|
|
2793
|
+
OUT (C),A
|
|
2794
|
+
OUT (C),L
|
|
2795
|
+
OUT (C),A
|
|
2796
|
+
POP BC
|
|
2797
|
+
|
|
2798
|
+
LD A,44
|
|
2799
|
+
OUT (C),A
|
|
2800
|
+
LD A,80H+17
|
|
2801
|
+
OUT (C),A
|
|
2802
|
+
|
|
2803
|
+
INC C
|
|
2804
|
+
INC C
|
|
2805
|
+
OUT (C),E
|
|
2806
|
+
XOR A
|
|
2807
|
+
OUT (C),A
|
|
2808
|
+
|
|
2809
|
+
LD E,01010000B
|
|
2810
|
+
POP AF
|
|
2811
|
+
OR E
|
|
2812
|
+
OUT (C),A
|
|
2813
|
+
|
|
2814
|
+
EI
|
|
2815
|
+
RET
|
|
2816
|
+
|
|
2817
|
+
GET.STATUS:
|
|
2818
|
+
PUSH BC
|
|
2819
|
+
LD BC,(WRVDP)
|
|
2820
|
+
INC C
|
|
2821
|
+
OUT (C),A
|
|
2822
|
+
LD A,8FH
|
|
2823
|
+
OUT (C),A
|
|
2824
|
+
LD BC,(RDVDP)
|
|
2825
|
+
INC C
|
|
2826
|
+
IN A,(C)
|
|
2827
|
+
POP BC
|
|
2828
|
+
RET
|
|
2829
|
+
|
|
2830
|
+
WAIT.VDP:
|
|
2831
|
+
LD A,2
|
|
2832
|
+
CALL GET.STATUS
|
|
2833
|
+
AND 1
|
|
2834
|
+
JP NZ,WAIT.VDP
|
|
2835
|
+
XOR A
|
|
2836
|
+
CALL GET.STATUS
|
|
2837
|
+
RET
|
|
2838
|
+
|
|
2839
|
+
END
|
|
2840
|
+
```
|
|
2841
|
+
|
|
2842
|
+
|
|
2843
|
+
<p> </p>
|
|
2844
|
+
|
|
2845
|
+
#### 6.5.12 POINT (reading a colour code)
|
|
2846
|
+
|
|
2847
|
+
POINT reads the colour code in any coordinate of VRAM (see [Figure 4.101](#figure-4101--actions-of-point-command)).
|
|
2848
|
+
|
|
2849
|
+
After setting the parameters as shown in [Figure 4.102](#figure-4102--register-settings-of-point-command), writing 40H in R#46 causes the command to be executed. While the CE bit of S#2 is "1", the command is being executed. After the command terminates, the colour code of the specified coordinate is set in S#7. [List 4.21](#list-421--example-of-point-command-execution) shows an example of using POINT.
|
|
2850
|
+
|
|
2851
|
+
|
|
2852
|
+
##### _Figure 4.101 Actions of POINT command_
|
|
2853
|
+
|
|
2854
|
+
```
|
|
2855
|
+
VRAM or expansion RAM
|
|
2856
|
+
---------------------------------------------------
|
|
2857
|
+
| |
|
|
2858
|
+
| |
|
|
2859
|
+
| |
|
|
2860
|
+
| |
|
|
2861
|
+
| (SX,SY) |
|
|
2862
|
+
| x |
|
|
2863
|
+
| |
|
|
2864
|
+
| |
|
|
2865
|
+
| |
|
|
2866
|
+
| |
|
|
2867
|
+
| |
|
|
2868
|
+
| |
|
|
2869
|
+
---------------------------------------------------
|
|
2870
|
+
|
|
2871
|
+
MXD: memory selection 0 = VRAM, 1 = expansion RAM
|
|
2872
|
+
|
|
2873
|
+
SX: origin X-coordinate (0 to 511)
|
|
2874
|
+
SY: origin Y-coordinate (0 to 1023)
|
|
2875
|
+
```
|
|
2876
|
+
|
|
2877
|
+
##### _Figure 4.102 Register settings of POINT command_
|
|
2878
|
+
|
|
2879
|
+
```
|
|
2880
|
+
> POINT register setup
|
|
2881
|
+
|
|
2882
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2883
|
+
-----------------------------------------
|
|
2884
|
+
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|
|
2885
|
+
|----+----+----+----+----+----+----+----| SX ---+
|
|
2886
|
+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
|
|
2887
|
+
----------------------------------------- |
|
|
2888
|
+
| origin
|
|
2889
|
+
----------------------------------------- |
|
|
2890
|
+
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|
|
2891
|
+
|----+----+----+----+----+----+----+----| SY ---+
|
|
2892
|
+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
|
|
2893
|
+
-----------------------------------------
|
|
2894
|
+
|
|
2895
|
+
-----------------------------------------
|
|
2896
|
+
R#45 | -- | -- | -- | MXS| -- | -- | -- | -- | ARG (Argument register)
|
|
2897
|
+
-----------------------------------------
|
|
2898
|
+
|
|
|
2899
|
+
+-----------> memory selection
|
|
2900
|
+
|
|
2901
|
+
> POINT command execution
|
|
2902
|
+
|
|
2903
|
+
MSB 7 6 5 4 3 2 1 0 LSB
|
|
2904
|
+
-----------------------------------------
|
|
2905
|
+
R#46 | 0 | 1 | 0 | 0 | -- | -- | -- | -- | CMR
|
|
2906
|
+
-----------------------------------------
|
|
2907
|
+
|
|
2908
|
+
-----------------------------------------
|
|
2909
|
+
S#2 | -- | -- | -- | -- | -- | -- | -- | CE | CMR
|
|
2910
|
+
-----------------------------------------
|
|
2911
|
+
when the command ends : 0
|
|
2912
|
+
|
|
2913
|
+
----------------------------------------- --+
|
|
2914
|
+
S#7 | 0 | 0 | 0 | 0 | C3 | C2 | C1 | C0 | CL (GRAPHIC 4,6) |
|
|
2915
|
+
----------------------------------------- |
|
|
2916
|
+
|
|
|
2917
|
+
----------------------------------------- |
|
|
2918
|
+
| 0 | 0 | 0 | 0 | 0 | 0 | C1 | C0 | CL (GRAPHIC 5) | colour code data
|
|
2919
|
+
----------------------------------------- |
|
|
2920
|
+
|
|
|
2921
|
+
----------------------------------------- |
|
|
2922
|
+
| C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | CL (GRAPHIC 7) |
|
|
2923
|
+
----------------------------------------- --+
|
|
2924
|
+
```
|
|
2925
|
+
|
|
2926
|
+
##### _List 4.21 Example of POINT command execution_
|
|
2927
|
+
|
|
2928
|
+
```
|
|
2929
|
+
;****************************************************************
|
|
2930
|
+
; List 4.21 POINT sample
|
|
2931
|
+
; to use, set H, L as follows
|
|
2932
|
+
; POINT ( x:H, y:L )
|
|
2933
|
+
; returns: A := COLOR CODE
|
|
2934
|
+
;****************************************************************
|
|
2935
|
+
;
|
|
2936
|
+
PUBLIC POINT
|
|
2937
|
+
|
|
2938
|
+
RDVDP: EQU 0006H
|
|
2939
|
+
WRVDP: EQU 0007H
|
|
2940
|
+
|
|
2941
|
+
;----- program start -----
|
|
2942
|
+
|
|
2943
|
+
POINT: DI
|
|
2944
|
+
CALL WAIT.VDP
|
|
2945
|
+
|
|
2946
|
+
LD A,(WRVDP)
|
|
2947
|
+
LD C,A
|
|
2948
|
+
|
|
2949
|
+
INC C
|
|
2950
|
+
LD A,32
|
|
2951
|
+
OUT (C),A
|
|
2952
|
+
LD A,80H+17
|
|
2953
|
+
OUT (C),A
|
|
2954
|
+
|
|
2955
|
+
INC C
|
|
2956
|
+
INC C
|
|
2957
|
+
XOR A
|
|
2958
|
+
OUT (C),H
|
|
2959
|
+
OUT (C),A
|
|
2960
|
+
OUT (C),L
|
|
2961
|
+
OUT (C),A
|
|
2962
|
+
|
|
2963
|
+
DEC C
|
|
2964
|
+
DEC C
|
|
2965
|
+
OUT (C),A
|
|
2966
|
+
LD A,80H+45
|
|
2967
|
+
OUT (C),A
|
|
2968
|
+
LD A,01000000B
|
|
2969
|
+
OUT (C),A
|
|
2970
|
+
LD A,80H+46
|
|
2971
|
+
OUT (C),A
|
|
2972
|
+
CALL WAIT.VDP
|
|
2973
|
+
LD A,7
|
|
2974
|
+
CALL GET.STATUS
|
|
2975
|
+
PUSH AF
|
|
2976
|
+
XOR A
|
|
2977
|
+
CALL GET.STATUS
|
|
2978
|
+
POP AF
|
|
2979
|
+
|
|
2980
|
+
EI
|
|
2981
|
+
RET
|
|
2982
|
+
|
|
2983
|
+
GET.STATUS:
|
|
2984
|
+
PUSH BC
|
|
2985
|
+
LD BC,(WRVDP)
|
|
2986
|
+
INC C
|
|
2987
|
+
OUT (C),A
|
|
2988
|
+
LD A,8FH
|
|
2989
|
+
OUT (C),A
|
|
2990
|
+
LD BC,(RDVDP)
|
|
2991
|
+
INC C
|
|
2992
|
+
IN A,(C)
|
|
2993
|
+
POP BC
|
|
2994
|
+
RET
|
|
2995
|
+
|
|
2996
|
+
WAIT.VDP:
|
|
2997
|
+
LD A,2
|
|
2998
|
+
CALL GET.STATUS
|
|
2999
|
+
AND 1
|
|
3000
|
+
JP NZ,WAIT.VDP
|
|
3001
|
+
XOR A
|
|
3002
|
+
CALL GET.STATUS
|
|
3003
|
+
RET
|
|
3004
|
+
|
|
3005
|
+
END
|
|
3006
|
+
```
|
|
3007
|
+
|
|
3008
|
+
|
|
3009
|
+
##### _List 4.22 PAINT routine using PSET and POINT_
|
|
3010
|
+
|
|
3011
|
+
```
|
|
3012
|
+
;****************************************************************
|
|
3013
|
+
; List 4.22 paint routine using PSET and POINT
|
|
3014
|
+
; ENTRY: X:H, Y:L, BORDER COLOR:D, PAINT COLOR:E
|
|
3015
|
+
;****************************************************************
|
|
3016
|
+
;
|
|
3017
|
+
EXTRN PSET
|
|
3018
|
+
EXTRN POINT
|
|
3019
|
+
|
|
3020
|
+
Q.LENGTH EQU 256*2*2
|
|
3021
|
+
MAX.Y EQU 211
|
|
3022
|
+
|
|
3023
|
+
;----- paint main routine -----
|
|
3024
|
+
|
|
3025
|
+
PAINT: CALL POINT
|
|
3026
|
+
CP D
|
|
3027
|
+
RET Z
|
|
3028
|
+
CALL INIT.Q
|
|
3029
|
+
LD (COL),DE
|
|
3030
|
+
CALL PUT.Q
|
|
3031
|
+
LD A,(COL)
|
|
3032
|
+
LD E,A
|
|
3033
|
+
XOR A ;logi-OP : PSET
|
|
3034
|
+
CALL PSET
|
|
3035
|
+
PAINT0: CALL GET.Q
|
|
3036
|
+
RET C
|
|
3037
|
+
INC H
|
|
3038
|
+
CALL NZ,PAINT.SUB
|
|
3039
|
+
DEC H
|
|
3040
|
+
JP Z,PAINT1
|
|
3041
|
+
DEC H
|
|
3042
|
+
CALL PAINT.SUB
|
|
3043
|
+
INC H
|
|
3044
|
+
PAINT1: DEC L
|
|
3045
|
+
LD A,-1
|
|
3046
|
+
CP L
|
|
3047
|
+
CALL NZ,PAINT.SUB
|
|
3048
|
+
INC L
|
|
3049
|
+
INC L
|
|
3050
|
+
LD A,MAX.Y
|
|
3051
|
+
CP L
|
|
3052
|
+
CALL NC,PAINT.SUB
|
|
3053
|
+
JP PAINT0
|
|
3054
|
+
|
|
3055
|
+
;----- check point and pset -----
|
|
3056
|
+
|
|
3057
|
+
PAINT.SUB:
|
|
3058
|
+
CALL POINT
|
|
3059
|
+
LD D,A
|
|
3060
|
+
LD A,(BORD)
|
|
3061
|
+
CP D
|
|
3062
|
+
RET Z
|
|
3063
|
+
LD A,(COL)
|
|
3064
|
+
CP D
|
|
3065
|
+
RET Z
|
|
3066
|
+
LD E,A
|
|
3067
|
+
XOR A
|
|
3068
|
+
CALL PSET
|
|
3069
|
+
CALL PUT.Q
|
|
3070
|
+
RET
|
|
3071
|
+
|
|
3072
|
+
;----- init Q.BUFFER pointer -----
|
|
3073
|
+
|
|
3074
|
+
INIT.Q:
|
|
3075
|
+
PUSH HL
|
|
3076
|
+
LD HL,Q.BUF
|
|
3077
|
+
LD (Q.TOP),HL
|
|
3078
|
+
LD (Q.BTM),HL
|
|
3079
|
+
POP HL
|
|
3080
|
+
RET
|
|
3081
|
+
|
|
3082
|
+
;----- put point to Q.BUF (X:H , Y:L) -----
|
|
3083
|
+
|
|
3084
|
+
PUT.Q:
|
|
3085
|
+
EX DE,HL
|
|
3086
|
+
LD HL,(Q.TOP)
|
|
3087
|
+
LD BC,Q.BUF+Q.LENGTH+1
|
|
3088
|
+
OR A ;clear CARRY
|
|
3089
|
+
PUSH HL
|
|
3090
|
+
SBC HL,BC
|
|
3091
|
+
POP HL
|
|
3092
|
+
JP C,PUT.Q1
|
|
3093
|
+
LD HL,Q.BUF
|
|
3094
|
+
PUT.Q1:
|
|
3095
|
+
LD (HL),D
|
|
3096
|
+
INC HL
|
|
3097
|
+
LD (HL),E
|
|
3098
|
+
INC HL
|
|
3099
|
+
LD (Q.TOP),HL
|
|
3100
|
+
EX DE,HL
|
|
3101
|
+
RET
|
|
3102
|
+
|
|
3103
|
+
;----- take point data to D, E -----
|
|
3104
|
+
; returns: NC H:x, L:y
|
|
3105
|
+
; C buffer empty
|
|
3106
|
+
|
|
3107
|
+
GET.Q: LD HL,(Q.BTM)
|
|
3108
|
+
LD BC,(Q.TOP)
|
|
3109
|
+
OR A
|
|
3110
|
+
SBC HL,BC
|
|
3111
|
+
JP NZ,GET.Q0
|
|
3112
|
+
SCF
|
|
3113
|
+
RET
|
|
3114
|
+
|
|
3115
|
+
GET.Q0: LD HL,(Q.BTM)
|
|
3116
|
+
LD BC,Q.BUF+Q.LENGTH+1
|
|
3117
|
+
OR A
|
|
3118
|
+
PUSH HL
|
|
3119
|
+
SBC HL,BC
|
|
3120
|
+
POP HL
|
|
3121
|
+
JP C,GET.Q1
|
|
3122
|
+
|
|
3123
|
+
LD HL,Q.BUF
|
|
3124
|
+
GET.Q1: LD D,(HL)
|
|
3125
|
+
INC HL
|
|
3126
|
+
LD E,(HL)
|
|
3127
|
+
INC HL
|
|
3128
|
+
LD (Q.BTM),HL
|
|
3129
|
+
OR A
|
|
3130
|
+
EX DE,HL
|
|
3131
|
+
RET
|
|
3132
|
+
|
|
3133
|
+
;----- work area -----
|
|
3134
|
+
|
|
3135
|
+
COL DS 1
|
|
3136
|
+
BORD DS 1
|
|
3137
|
+
Q.TOP DS 2
|
|
3138
|
+
Q.BTM DS 2
|
|
3139
|
+
Q.BUF DS Q.LENGTH
|
|
3140
|
+
|
|
3141
|
+
END
|
|
3142
|
+
```
|
|
3143
|
+
|
|
3144
|
+
|
|
3145
|
+
##### _List 4.23 Example of using the PAINT routine_
|
|
3146
|
+
|
|
3147
|
+
```
|
|
3148
|
+
1000 '***********************************************
|
|
3149
|
+
1010 ' List 4.23 paint routine using POINT and PSET
|
|
3150
|
+
1020 ' Position cursor at beginnig of paint area and press the space bar.
|
|
3151
|
+
1030 '***********************************************
|
|
3152
|
+
1040 '
|
|
3153
|
+
1050 SCREEN 5
|
|
3154
|
+
1060 FOR I=0 TO 50
|
|
3155
|
+
1070 LINE -(RND(1)*255,RND(1)*211),15
|
|
3156
|
+
1080 NEXT
|
|
3157
|
+
1090 I=&HA000 :DEF USR=I
|
|
3158
|
+
1100 READ A$
|
|
3159
|
+
1110 IF A$="END" THEN 1150
|
|
3160
|
+
1120 POKE I,VAL("&H"+A$):I=I+1
|
|
3161
|
+
1130 READ A$
|
|
3162
|
+
1140 GOTO 1110
|
|
3163
|
+
1150 X=128:Y=100:COL=15:PCOL=2
|
|
3164
|
+
1160 CURS=0
|
|
3165
|
+
1170 A=STICK(0)
|
|
3166
|
+
1180 CURS=(CURS+1) AND 1
|
|
3167
|
+
1190 LINE (X-5,Y)-(X+5,Y),15,,XOR
|
|
3168
|
+
1200 LINE (X,Y-5)-(X,Y+5),15,,XOR
|
|
3169
|
+
1210 IF CURS=1 THEN 1310
|
|
3170
|
+
1220 IF A=1 THEN Y=Y-1
|
|
3171
|
+
1230 IF A=2 THEN Y=Y-1:X=X+1
|
|
3172
|
+
1240 IF A=3 THEN X=X+1
|
|
3173
|
+
1250 IF A=4 THEN X=X+1:Y=Y+1
|
|
3174
|
+
1260 IF A=5 THEN Y=Y+1
|
|
3175
|
+
1270 IF A=6 THEN Y=Y+1:X=X-1
|
|
3176
|
+
1280 IF A=7 THEN X=X-1
|
|
3177
|
+
1290 IF A=8 THEN X=X-1:Y=Y-1
|
|
3178
|
+
1300 IF STRIG(0) THEN GOSUB 1320
|
|
3179
|
+
1310 GOTO 1170
|
|
3180
|
+
1320 POKE &HA8CA,Y
|
|
3181
|
+
1330 POKE &HA8CB,X
|
|
3182
|
+
1340 POKE &HA8CD,COL
|
|
3183
|
+
1350 POKE &HA8CC,PCOL
|
|
3184
|
+
1360 A=USR(0)
|
|
3185
|
+
1370 RETURN
|
|
3186
|
+
1380 DATA ED,73,00,A8,31,CA,A8,2A,CA,A8,ED,5B,CC,A8,CD,67
|
|
3187
|
+
1390 DATA A0,ED,7B,00,A8,C9,E5,21,D4,A8,22,D0,A8,22,D2,A8
|
|
3188
|
+
1400 DATA E1,C9,EB,2A,D0,A8,01,D5,AC,B7,E5,ED,42,E1,DA,34
|
|
3189
|
+
1410 DATA A0,21,D4,A8,72,23,73,23,22,D0,A8,EB,C9,2A,D2,A8
|
|
3190
|
+
1420 DATA ED,4B,D0,A8,B7,ED,42,C2,4C,A0,37,C9,2A,D2,A8,01
|
|
3191
|
+
1430 DATA D5,AC,B7,E5,ED,42,E1,DA,5D,A0,21,D4,A8,56,23,5E
|
|
3192
|
+
1440 DATA 23,22,D2,A8,B7,EB,C9,CD,B8,A0,BA,C8,CD,16,A0,ED
|
|
3193
|
+
1450 DATA 53,CE,A8,CD,22,A0,3A,CE,A8,5F,AF,CD,F4,A0,CD,3D
|
|
3194
|
+
1460 DATA A0,D8,24,C4,A1,A0,25,CA,8F,A0,25,CD,A1,A0,24,2D
|
|
3195
|
+
1470 DATA 3E,FF,BD,C4,A1,A0,2C,2C,3E,D3,BD,D4,A1,A0,C3,7E
|
|
3196
|
+
1480 DATA A0,CD,B8,A0,57,3A,CF,A8,BA,C8,3A,CE,A8,BA,C8,5F
|
|
3197
|
+
1490 DATA AF,CD,F4,A0,CD,22,A0,C9,F3,CD,3A,A1,ED,4B,06,00
|
|
3198
|
+
1500 DATA 0C,3E,20,ED,79,3E,91,ED,79,0C,0C,AF,ED,61,ED,79
|
|
3199
|
+
1510 DATA ED,69,ED,79,0D,0D,ED,79,3E,AD,ED,79,3E,40,ED,79
|
|
3200
|
+
1520 DATA 3E,AE,ED,79,CD,3A,A1,3E,07,CD,2A,A1,F5,AF,CD,2A
|
|
3201
|
+
1530 DATA A1,F1,FB,C9,F3,F5,CD,3A,A1,ED,4B,06,00,0C,3E,24
|
|
3202
|
+
1540 DATA ED,79,3E,91,ED,79,C5,0C,0C,AF,ED,61,ED,79,ED,69
|
|
3203
|
+
1550 DATA ED,79,C1,3E,2C,ED,79,3E,91,ED,79,0C,0C,ED,59,AF
|
|
3204
|
+
1560 DATA ED,79,1E,50,F1,B3,ED,79,FB,C9,C5,ED,4B,06,00,0C
|
|
3205
|
+
1570 DATA ED,79,3E,8F,ED,79,ED,78,C1,C9,3E,02,CD,2A,A1,E6
|
|
3206
|
+
1580 DATA 01,C2,3A,A1,AF,CD,2A,A1,C9
|
|
3207
|
+
1590 DATA END
|
|
3208
|
+
```
|
|
3209
|
+
|
|
3210
|
+
|
|
3211
|
+
<p> </p>
|
|
3212
|
+
|
|
3213
|
+
### 6.6 Speeding Up Commands
|
|
3214
|
+
|
|
3215
|
+
MSX-VIDEO performs various screen management duties in addition to executing the specified commands. Sometimes the command execution speed seems to be a bit slow because of this. Thus, by discarding these operations, the speed of the command executions can be made faster. This can be done using the following method.
|
|
3216
|
+
|
|
3217
|
+
|
|
3218
|
+
#### 1. Sprite display inhibition
|
|
3219
|
+
|
|
3220
|
+
This method is useful since speedup can be realised while the screen remains displayed. Set "1" to bit 1 of R#8.
|
|
3221
|
+
|
|
3222
|
+
|
|
3223
|
+
#### 2. Screen display inhibition
|
|
3224
|
+
|
|
3225
|
+
This method cannot be used frequently except in the case of initialising the screen, since the screen fades out in this mode. Set "1" to bit 6 of R#1.
|
|
3226
|
+
|
|
3227
|
+
|
|
3228
|
+
<p> </p>
|
|
3229
|
+
|
|
3230
|
+
### 6.7 Register Status at Command Termination
|
|
3231
|
+
|
|
3232
|
+
[Table 4.7](#table-47--register-status-at-command-termination) shows the register status at the command termination for each command.
|
|
3233
|
+
|
|
3234
|
+
When the number of dots to be executed in Y direction assumes N, the values of SY*, DY*, and NYB can be calculated as follows:
|
|
3235
|
+
|
|
3236
|
+
```
|
|
3237
|
+
SY*=SY+N, DY*=DY+N .................... when DIY bit is 0
|
|
3238
|
+
SY*=SY-N, DY*=DY-N .................... when DIY bit is 1
|
|
3239
|
+
NYB=NY-N
|
|
3240
|
+
```
|
|
3241
|
+
*Note:* when MAJ bit is 0 in LINE, N = N - 1.
|
|
3242
|
+
|
|
3243
|
+
|
|
3244
|
+
##### _Table 4.7 Register status at command termination_
|
|
3245
|
+
|
|
3246
|
+
```
|
|
3247
|
+
----------------------------------------------------------------------------
|
|
3248
|
+
| command name | SX | SY | DX | DY | NX | NY | CLR |CMR H|CMR L| ARG |
|
|
3249
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3250
|
+
| HMMC | --- | --- | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3251
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3252
|
+
| YMMM | --- | . | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3253
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3254
|
+
| HMMM | --- | . | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3255
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3256
|
+
| HMMV | --- | --- | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3257
|
+
----------------------------------------------------------------------------
|
|
3258
|
+
----------------------------------------------------------------------------
|
|
3259
|
+
| LMMC | --- | --- | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3260
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3261
|
+
| LMCM | --- | . | --- | --- | --- | # | . | 0 | --- | --- |
|
|
3262
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3263
|
+
| LMMM | --- | . | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3264
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3265
|
+
| LMMV | --- | --- | --- | . | --- | # | --- | 0 | --- | --- |
|
|
3266
|
+
----------------------------------------------------------------------------
|
|
3267
|
+
----------------------------------------------------------------------------
|
|
3268
|
+
| LINE | --- | --- | --- | . | --- | --- | --- | 0 | --- | --- |
|
|
3269
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3270
|
+
| SRCH | --- | --- | --- | --- | --- | --- | --- | 0 | --- | --- |
|
|
3271
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3272
|
+
| PSET | --- | --- | --- | --- | --- | --- | --- | 0 | --- | --- |
|
|
3273
|
+
|--------------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----|
|
|
3274
|
+
| POINT | --- | --- | --- | --- | --- | --- | . | 0 | --- | --- |
|
|
3275
|
+
----------------------------------------------------------------------------
|
|
3276
|
+
|
|
3277
|
+
--- : no change
|
|
3278
|
+
. : coordinate (SY*, DY*) and the colour code at the command termination
|
|
3279
|
+
# : the number of counts (NYB), when the screen edge is fetched
|
|
3280
|
+
```
|
|
3281
|
+
|
|
3282
|
+
|
|
3283
|
+
## Changes from the original
|
|
3284
|
+
|
|
3285
|
+
- In [Figure 4.72](#figure-472--coordinate-system-of-vram), last "10000H" is corrected to "1FFFFH".
|
|
3286
|
+
|
|
3287
|
+
- In [Table 4.6](#table-46--list-of-logical-operations), in TEOR line, "else DC+..." is corrected to "else DC=..."
|
|
3288
|
+
|
|
3289
|
+
- In [Figure 4.76](#figure-476--register-settings-of-hmmc-command), in R#45 figure, DIX and DIY bits have been placed correctly (they were inverted in the original).
|
|
3290
|
+
|
|
3291
|
+
- In [Figure 4.79](#figure-479--register-settings-of-ymmm-command), in R#42 and R#43 explanation, "NY -> of dots..." has been changed to "NY -> number of dots..."
|
|
3292
|
+
|
|
3293
|
+
- In [List 4.9](#list-49--example-of-ymmm-command-execution), in the line with the comment "YMMM command", 11010000 bitfield has been corrected to 11100000.
|
|
3294
|
+
|
|
3295
|
+
- In [Figure 4.84](#figure-484--action-of-lmmc-command), "*" mark removed from the explanation of NX.
|
|
3296
|
+
|
|
3297
|
+
- In [Figure 4.85](#figure-485--register-settings-of-lmmc-command), in R#45 explanation, "select source memory" text has been corrected to "select destination memory".
|
|
3298
|
+
|
|
3299
|
+
- In [List 4.13](#list-413--example-of-lmcm-command-execution), labels beginning with "LMMC" have been corrected to "LMCM".
|
|
3300
|
+
|
|
3301
|
+
- In [List 4.15](#list-415--example-of-lmmv-command-execution), in the line with the comment "NY", the "OUT (C),H" instruction has been corrected to "OUT (C),L".
|
|
3302
|
+
|
|
3303
|
+
- In [section 6.5.9](#659-line-drawing-a-line), the explanation of usage of the LINE command was mixed wih other text. It has been corrected.
|
|
3304
|
+
|
|
3305
|
+
- In [Figure 4.94](#figure-494--actions-of-line-command), a line explaining the meaning of R#44 has been added.
|
|
3306
|
+
|
|
3307
|
+
- In [Figure 4.97](#figure-497--register-settings-of-srch-command), BX9 bit has been supressed in S#9 figure.
|
|
3308
|
+
|
|
3309
|
+
- In [Figure 4.99](#figure-499--actions-of-pset-command), a line explaining the meaning of R#44 has been added.
|
|
3310
|
+
|
|
3311
|
+
- In [Table 4.7](#table-47--register-status-at-command-termination), "CLR L" has been corrected to "CMR L".
|