@nataliapc/mcp-openmsx 1.1.5 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +41 -2
  2. package/dist/openmsx.js +9 -0
  3. package/dist/server.js +502 -327
  4. package/dist/utils.js +17 -0
  5. package/package.json +4 -1
  6. package/resources/audio/toc.json +31 -0
  7. package/resources/bios/Calling_BIOS_from_MSX-DOS.md +75 -0
  8. package/resources/bios/MSX2_SUBROM_BIOS_calls.md +734 -0
  9. package/resources/bios/MSX_BIOS_calls.md +1046 -0
  10. package/resources/bios/toc.json +24 -0
  11. package/resources/book--msx2-technical-handbook/Appendix1__BIOS_Listing.md +1464 -0
  12. package/resources/book--msx2-technical-handbook/Appendix2__Math-Pack.md +427 -0
  13. package/resources/book--msx2-technical-handbook/Appendix3__Bit_Block_Transfer.md +182 -0
  14. package/resources/book--msx2-technical-handbook/Appendix4__Work_Area_Listing.md +1637 -0
  15. package/resources/book--msx2-technical-handbook/Appendix5__VRAM_Map.md +145 -0
  16. package/resources/book--msx2-technical-handbook/Appendix6__IO_Map.md +128 -0
  17. package/resources/book--msx2-technical-handbook/Appendix8_10__Control_Codes_and_Escape_Sequences.md +76 -0
  18. package/resources/book--msx2-technical-handbook/Chapter1__MSX_System_Overview.md +402 -0
  19. package/resources/book--msx2-technical-handbook/Chapter2__BASIC.md +2148 -0
  20. package/resources/book--msx2-technical-handbook/Chapter3__MSX-DOS.md +2577 -0
  21. package/resources/book--msx2-technical-handbook/Chapter4a__VDP_and_Display_Screen.md +2052 -0
  22. package/resources/book--msx2-technical-handbook/Chapter4b__VDP_and_Display_Screen.md +3311 -0
  23. package/resources/book--msx2-technical-handbook/Chapter5a__Access_to_Peripherals_through_BIOS.md +2714 -0
  24. package/resources/book--msx2-technical-handbook/Chapter5b__Access_to_Peripherals_through_BIOS.md +1263 -0
  25. package/resources/book--msx2-technical-handbook/MSX_Kun_BASIC_Compiler.md +220 -0
  26. package/resources/book--msx2-technical-handbook/toc.json +82 -0
  27. package/resources/book--the-msx-red-book/the_msx_red_book.md +10349 -0
  28. package/resources/book--the-msx-red-book/toc.json +12 -0
  29. package/resources/msx-dos/MSX-DOS_2_Function_Specifications.md +1366 -0
  30. package/resources/msx-dos/MSX-DOS_2_Program_Interface_Specification.md +963 -0
  31. package/resources/msx-dos/toc.json +18 -0
  32. package/resources/msx-unapi/Ethernet_UNAPI_specification_1.1.md +369 -0
  33. package/resources/msx-unapi/Introduction_to_MSX-UNAPI.md +132 -0
  34. package/resources/msx-unapi/MSX_UNAPI_specification_1.1.md +679 -0
  35. package/resources/msx-unapi/TCP-IP_UNAPI_specification.md +2361 -0
  36. package/resources/msx-unapi/toc.json +27 -0
  37. package/resources/others/toc.json +11 -0
  38. package/resources/processors/Z80_R800_instruction_set.md +482 -0
  39. package/resources/processors/toc.json +24 -0
  40. package/resources/processors/z80-undocumented.tex +5617 -0
  41. package/resources/processors/z80_detailed_instruction_set.md +2025 -0
  42. package/resources/programming/toc.json +121 -0
  43. package/resources/system/MSX_IO_ports_overview.md +554 -0
  44. package/resources/system/toc.json +18 -0
  45. package/resources/video/V9938_Technical_Data_Book.md +3623 -0
  46. package/resources/video/V9958_Technical_Data_Book.md +417 -0
  47. package/resources/video/V9990_Programmers_Manual_Banzai.html +1582 -0
  48. package/resources/video/VDP_TMS9918A.txt +709 -0
  49. package/resources/video/toc.json +28 -0
@@ -0,0 +1,3623 @@
1
+ # V9938 MSX-VIDEO - Technical Data Book Programmer's Guide
2
+
3
+ © 1985 ASCII CORP. / NIPPON GAKKI CO., LTD.
4
+
5
+ ## NOTE FROM THE EDITOR
6
+
7
+ This important technical book - including preface, dated back to 1985, had been
8
+ reworked and modified appropriately in order to give more detailed explanation of how V9938 chip works and how to effectively program the system based on it.
9
+
10
+ While MSX gave up to the IBM PC standard as a computing platform in early 1990s, it is still one of the powerful specimens in the field of 8-bit home entertainment and hobbyist platforms. It is argued that modern PC architecture origins at the MSX standard; and it is clear that initiative, taken by Microsoft and ASCII by institutionalizing software and hardware compatibility was taken in further developments on the IT market.
11
+
12
+ V9938 is one of the most popular video-processors in the family of Texas Instruments original chips, improved by a group of companies from Japan and US. Its follower, V9958, was a VDP chip for limited release of MSX2+ and MSX Turbo-R machines, and the last VDP in the family, V9990, can only be found in add-on cartridges.
13
+
14
+ The book is provided in PDF format and is searchable to allow internet search engines indexing it so that potential readers would easily find it.
15
+
16
+ December, 2010 Eugeny Brychkov
17
+
18
+ Rev. 1.00 (Jan 06, 2011): Initial release
19
+ Rev. 1.01 (Jan 27, 2011): corrections per Daemos et al.
20
+ Rev. 1.01a (Mar 06, 2011): corrections per ARTRAG et al.
21
+ Rev. 1.01b (June 02, 2015): corrections per yzi and ARTRAG
22
+ Rev. 1.02 (June 30, 2025): converted to Markdown per NataliaPC
23
+
24
+ Please log issues with this document to the following MSX Resource Center thread:
25
+ http://www.msx.org/forumtopic12176.html
26
+
27
+ ## PREFACE
28
+
29
+ The V9938 introduced in this manual is a Very Large-Scale Integrated Circuit (VLSI) that was developed as a video Display Processor (VDP) for the MSX2. The MSX personal computer standard was introduced in 1983 by ASCII Corporation and Microsoft Incorporated. At present, the MSX is manufactured and marketed worldwide. In order to strengthen some of the functions of the original MSX, the MSX2 standard was developed in 1985. In addition to being software-compatible with the MSX, the MSX2 supports new media and has video processing capabilities that are not available on conventional 8-bit personal computers.
30
+
31
+ To make the MSX2 a reality, two requirements for the Video Processor were: upward compatibility with the existing TMS9918A (the VDP for the MSX) software and increased number of functions. The V9938 was developed through the joint efforts of ASCII Corporation, Microsoft Incorporated, and YAMAHA.
32
+
33
+ The following functions are supported on the V9938:
34
+ - Full bit-mapped mode
35
+ - 80-column text display
36
+ - Access using X- and Y-coordinates for easier programming; the X-Y coordinates are independent of the screen mode
37
+ - Fundamental hardware commands to decrease the processing time and reduce programming complexity
38
+ - Digitize and external synchronization
39
+ - Color palette (9 bits x 16 patterns)
40
+ - Linear RGB video output
41
+ - More sprites per horizontal line
42
+
43
+ Because the V9938 has the above functions, it provides superior video capabilities that make it possible for its use in a variety of applications, including the MSX2. CAPTAIN terminals and NAPLPS terminals using the V9938 have already been developed. We hope that the V9938 will be a standard video processing device on a worldwide basis.
44
+
45
+ This manual was written to explain how to set parameters of the v9938 and is a reference for developing applications and system software for it. We are pleased that you have chosen to develop software for the V9938 and that you have referred to this manual for assistance.
46
+
47
+ Finally, we would like to express our deep gratitude to the people at NTT as well as other related manufacturers for their valuable opinions which contributed to the development of the V9938.
48
+
49
+ August, 1985 ASCII Corporation
50
+
51
+ ## CONTENTS
52
+
53
+ - [DEFINITIONS](#definitions)
54
+ - [BASIC INPUT AND OUTPUT](#basic-input-and-output)
55
+ - [Accessing the Control Registers](#accessing-the-control-registers)
56
+ - [Direct access to VDP registers](#direct-access-to-vdp-registers)
57
+ - [Indirect access to registers through R#17 (Control Register Pointer)](#indirect-access-to-registers-through-r17-control-register-pointer)
58
+ - [Accessing the Palette Registers](#accessing-the-palette-registers)
59
+ - [Accessing the Status Registers](#accessing-the-status-registers)
60
+ - [Accessing the Video RAM](#accessing-the-video-ram-vram)
61
+ - [REGISTER FUNCTIONS](#register-functions)
62
+ - [Control registers](#control-registers)
63
+ - [Mode registers](#mode-registers)
64
+ - [Table Base address registers](#table-base-address-registers)
65
+ - [Color registers](#color-registers)
66
+ - [Display registers](#display-registers)
67
+ - [Access registers](#access-registers)
68
+ - [Command registers](#command-registers)
69
+ - [Status registers #0 to #9](#status-registers-0-to-9)
70
+ - [SCREEN MODES](#screen-modes)
71
+ - [TEXT1 mode](#text1-mode)
72
+ - [TEXT2 mode](#text2-mode)
73
+ - [MULTICOLOR (MC) mode](#multicolor-mc-mode)
74
+ - [GRAPHIC1 (G1) mode](#graphic1-g1-mode)
75
+ - [GRAPHIC2 (G2) and GRAPHIC3 (G3) modes](#graphic2-g2-and-graphic3-g3-modes)
76
+ - [GRAPHIC4 (G4) mode](#graphic4-g4-mode)
77
+ - [GRAPHIC5 (G5) mode](#graphic5-g5-mode)
78
+ - [GRAPHIC6 (G6) mode](#graphic6-g6-mode)
79
+ - [GRAPHIC7 (G7) mode](#graphic7-g7-mode)
80
+ - [COMMANDS]()
81
+ - [Types of Commands](#types-of-commands)
82
+ - [Page concept](#page-concept)
83
+ - [Logical Operations](#logical-operations)
84
+ - [Explanations of Commands](#explanation-of-the-commands)
85
+ - [HMMC (High-speed move CPU to VRAM)](#hmmc-high-speed-move-cpu-to-vram)
86
+ - [YMMM (High speed move VRAM to VRAM, y only)](#ymmm-high-speed-move-vram-to-vram-y-coordinate-only)
87
+ - [HMMM (High speed move VRAM to VRAM)](#hmmm-high-speed-move-vram-to-vram)
88
+ - [HMMV (High-speed move VDP to VRAM)](#hmmv-high-speed-move-vdp-to-vram)
89
+ - [LMMC (Logical move CPU to VRAM)](#lmmc-logical-move-cpu-to-vram)
90
+ - [LMCM (Logical move VRAM to CPU)](#lmcm-logical-move-vram-to-cpu)
91
+ - [LMMM (Logical move VRAM to VRAM)](#lmmm-logical-move-vram-to-vram)
92
+ - [LMMV (logical move VDP to VRAM)](#lmmv-logical-move-vdp-to-vram)
93
+ - [LINE](#line)
94
+ - [SRCH](#srch)
95
+ - [PSET](#pset)
96
+ - [POINT](#point)
97
+ - [Speeding up the processing of commands](#speeding-up-the-processing-of-vdp-commands)
98
+ - [States of the registers after command execution](#states-of-the-registers-after-command-execution)
99
+ - [SPRITES](#sprites)
100
+ - [Sprite mode 1 (G1, G2, MC)](#sprite-mode-1-g1-g2-mc)
101
+ - [Sprite mode 2 (G3, G4, G5, G6, G7)](#sprite-mode-2-g3--g7)
102
+ - [Special rules for sprite color settings](#special-rules-for-sprite-color-settings)
103
+ - [SPECIAL FUNCTIONS](#special-functions)
104
+ - [Alternate display of two graphics screen pages](#alternate-display-of-two-graphic-screen-pages)
105
+ - [Displaying two graphics screens at 60Hz](#displaying-two-graphics-screens-at-60hz)
106
+ - [Interlace display](#interlace-display)
107
+
108
+ ## DEFINITIONS
109
+
110
+ ### A
111
+
112
+ #### Attribute
113
+ The property of an object, which controls how object looks like on the screen. Attribute can be a color, position of an object, or control which pixel should have specific color.
114
+
115
+ ### B
116
+
117
+ #### Background
118
+ Is an object or property which is perceived to be in the background to another property or object. For example, for a character displayed on the screen the pixels of its image is said to have foreground color, while other pixels to have background color. In case of sprites, they may be said to appear in the foregrou nd to the font patterns, as sprites overlap images of the font. See also Foreground.
119
+
120
+ ### C
121
+
122
+ #### Collision
123
+ Sprites are said to collide when their dots having color code 1 (simply saying - dots identified with binary 1s in their sprite pattern generator table) overlap. In some circumstances such behavior may be changed in favor or mixing sprite colors to have pseudo-multi-colored sprites.
124
+
125
+ #### Color
126
+ A property of the pixel on the screen. Color of the pixel may come from various sources: from global color register, from pattern color table or from sprite color table. Colors can also be coded in the palette registers through setup of red, green and blue components - in this case, if color table of the patterns and sprites remain unchanged, actual colors, associated with them, may be different.
127
+
128
+ #### Command
129
+ A special sequence of VDP operations, a kind of hardware acceleration. Command is expected to streamline CPU-VDP-VRAM operations, unload CPU and increase data transfer speed.
130
+
131
+ ### E
132
+
133
+ #### Expansion RAM
134
+ This random access memory is used to store non-displayed data or register information, and is not necessary for proper operation of the VDP. Maximal size or expansion RAM is 64K bytes. Due to specific purposes of this RAM, it is rarely used in applications.
135
+
136
+ ### L
137
+
138
+ #### Layout
139
+ A map of patterns or sprites which identify where to display specific object or which object should be displayed in specific position. In case of patterns (font), Pattern generator Table identifies the appearance of font, but in order to display these patterns in specific position, programmer should put its number into Pattern Layout Table in respective location.
140
+
141
+ ### O
142
+
143
+ #### Object
144
+ Font patterns or a sprite.
145
+
146
+ ### P
147
+
148
+ #### Pattern
149
+ A property of an object identifying how object looks like. Object can be a font pattern or a sprite pattern. Pattern may be represented by one byte or 8 bytes in different modes; its contents codes colors of the pixels displayed. For some modes, 8 bits (one byte) can code 8 pixels - 0 for background color and 1 for foreground color, in other modes 8 bits can code 4 pixels - with colors 0, 1, 2, and 3. To display font patterns on the screen it may not be enough to set its pattern, but also put its pattern number into the layout map. VDP, when displaying the picture, reads the number of pattern to display, and then refers to its actual image to font pattern generator table.
150
+
151
+ #### Port
152
+ Is a physical latch with specific system address for CPU reads and writes to communicate with VDP. VDP has four ports, port #0 is a read/write data port, port #1 is write register set-up port, port #2 is write palette port, and port #3 is write register data port.
153
+
154
+ ### R
155
+
156
+ #### Register
157
+ Register is a static place within VDP for control information about VDP's mode, screen property etc. Registers can be Status, Video or Command. They can be accessed directly or indirectly. Access to the registers is made through consecutive writes to specific VDP ports, thus in order not to break the order and thus successful completion of specific operation, programmer should disable interrupts.
158
+
159
+ #### RGB
160
+ Abbreviation for base colors Red, Green and Blue. It may be used to describe hardware wiring with three analog signals; or to describe a color composition for the pixel. Note that when coding RGB in VDP palette registers programmer uses 3 bits for every base color, and when coding RGB in GRAPHIC 7 mode red and green occupy 3 bits each, but blue occupies only 2 bits.
161
+
162
+ ### T
163
+
164
+ #### Tile
165
+ Same as font pattern .
166
+
167
+ ### V
168
+
169
+ #### VRAM
170
+ Video Random Access Memory is a set of memory cells used by VDP to keep information about picture displayed on the screen. VRAM is accessed for picture displaying purposes as well as for picture modifications. Picture displaying occurs continuously when VDP is enabled. V9938 may have 16K to 128K VRAM, and depending on the memory organization and size may not be able to function properly in specific modes. See description of register R#8's bit VR for more information.
171
+
172
+ ## BASIC INPUT AND OUTPUT
173
+
174
+ ### Accessing the Control Registers
175
+
176
+ V9938 has 4 ports: port #0 - port #3; port number is selected by VDP address lines A0 and A1. Table below also shows port address allocation for MSX compatible machine.
177
+
178
+ ||A1|A0|Operation|Primary MSX port (Hex)|
179
+ |---|:-:|:-:|---|:-:|
180
+ |Port #0|0|0|VRAM Data (R/W)|98h|
181
+ |Port #1|0|1|Status Register (R)<br>VRAM Address (W)<br>Register set-up (W)|99h|
182
+ |Port #2|1|0|Palette registers (W)|9Ah|
183
+ |Port #3|1|1|Register indirect addressing (W)|9Bh|
184
+
185
+ There are two ways to set data in the MSX-VIDEO control registers (R#0 to R#46).
186
+
187
+ #### Direct access to VDP registers
188
+
189
+ Output the data and the register number in sequence to port #1. The order of reads
190
+ and writes to/from VDP ports is vitally important, thus you should keep in mind that this
191
+ order can be potentially interrupted by CPU interrupt routine which can write to or read
192
+ from VDP port(s) and thus break the proper sequence. In case of Z80 CPU, use DI
193
+ (disable interrupts) at the start and EI (enable interrupts) at the end of VDP your access
194
+ code.
195
+
196
+ Data byte is written first (bits D0-D7), and register number is written next to data
197
+ byte (bits R0-R5). If interrupt involving VDP operations will occur between these two
198
+ operations, it may cause unpredictable results.
199
+ ```
200
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
201
+ +----+----+----+----+----+----+----+----+
202
+ Port #1 first byte | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data
203
+ +====+====+====+====+====+====+====+====+
204
+ Port #1 second byte | 1 | 0 | R5 | R4 | R3 | R2 | R1 | R0 | Register #
205
+ +----+----+----+----+----+----+----+----+
206
+ ```
207
+
208
+ #### Indirect access to registers through R#17 (Control Register Pointer)
209
+
210
+ Set the register number in R#17 using direct addressing and then send data to Port #3. MSB of the value written to R#17 (AII) controls auto-incrementing of the register number. If auto-incrementing is enabled, after each data read or write control register pointer is incremented; if auto-incrementing is disabled then pointer value in R#17 remains unchanged. Auto-increment mode is useful for bulk read or update of VDP registers.
211
+
212
+ _**Note:** data in register R#17 can not be changed by indirect addressing._
213
+ ```
214
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
215
+ +-----+----+----+----+----+----+----+----+
216
+ Register #17 | AII | 0 | R5 | R4 | R3 | R2 | R1 | R0 | Register #
217
+ +-----+----+----+----+----+----+----+----+
218
+ |
219
+ +-- 0: Auto-increment is enabled
220
+ +-- 1: Auto-increment is disabled
221
+
222
+ +----+----+----+----+----+----+----+----+
223
+ Port #3 1st byte | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data
224
+ +====+====+====+====+====+====+====+====+
225
+ Port #3 2nd byte | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data
226
+ +====+====+====+====+====+====+====+====+
227
+ : ... :
228
+ +====+====+====+====+====+====+====+====+
229
+ Port #3 n byte | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data
230
+ +----+----+----+----+----+----+----+----+
231
+ ```
232
+
233
+ ### Accessing the Palette Registers
234
+ To set data in the MSX-VIDEO palette registers (P#0 to P#15) you must first set the palette register number in register R#16 (Color palette address pointer) and subsequently write two bytes of data (in specific order) into port #2. Every color consists of 3 sets of 3 bits: red, green and blue component (value 0...7).
235
+
236
+ _**Note:** after writing pair of data to port #2 palette register number (pointer) in register R#16 auto-increments._
237
+ ```
238
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
239
+ +----+----+----+----+----+----+----+----+
240
+ Register #16 | 0 | 0 | 0 | 0 | C3 | C2 | C1 | C0 | Palette #
241
+ +====+====+====+====+====+====+====+====+
242
+ Port #2 1st byte | 0 | Red data | 0 | Blue data | Data 1
243
+ +====+====+====+====+====+====+====+====+
244
+ Port #2 2nd byte | 0 | 0 | 0 | 0 | 0 | Green data | Data 2
245
+ +----+----+----+----+----+----+----+----+
246
+ ```
247
+
248
+ ### Accessing the status registers
249
+
250
+ To read the status registers of MSX-VIDEO (S#0 to S#9) you must first set the
251
+ register number in R#15 (Status register pointer) and then read data from port #1.
252
+ ```
253
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
254
+ +----+----+----+----+----+----+----+----+
255
+ Register #15 (write) | 0 | 0 | 0 | 0 | S3 | S2 | S1 | S0 | Stat Reg #
256
+ +====+====+====+====+====+====+====+====+
257
+ Port #1 data (read) | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data read
258
+ +----+----+----+----+----+----+----+----+
259
+ ```
260
+
261
+ ### Accessing the Video RAM (VRAM)
262
+
263
+ A video RAM of 128K bytes plus an expansion RAM of 64K bytes can be attached to
264
+ the VDP. Memory map is shown below. Address 1FFFFh ↑
265
+ ```
266
+ Address
267
+ +-----------------+ ·········
268
+ | | 1FFFFh
269
+ | |
270
+ | | 10000h
271
+ +-----------------+ ········· +-----------------+
272
+ | | 0FFFFh | |
273
+ | | | |
274
+ | | 00000h | |
275
+ +-----------------+ ········· +-----------------+
276
+ Video RAM Expansion RAM
277
+ (used for display) (for data I/O registers)
278
+ ```
279
+ To access memory, use the following procedure:
280
+ 1. Switch respective bank (VRAM or expansion RAM)
281
+ 2. Set the address counter A16 to A14
282
+ 3. Set the address counter A7 to A0
283
+ 4. Set the address counter A13 to A8, and specify if following data command will be
284
+ read or write
285
+ 5. Read or write data to the memory
286
+
287
+ #### Step 1: Switching banks (VRAM to expansion RAM)
288
+
289
+ Applications are used to work with Video RAM, thus re-specification of the bank is rarely necessary. It will be required if your application will need to access expansion RAM. After performing necessary operations on expansion RAM, ensure that you map the Video RAM back.
290
+ ```
291
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
292
+ +-----+-----+-----+-----+-----+-----+-----+-----+
293
+ Register #45 | 0 | MXC | MXD | MXS | DIY | DIX | EQ | MAJ | Argument
294
+ +-----+-----+-----+-----+-----+-----+-----+-----+ register
295
+ | (ARG)
296
+ +--> 0: Video RAM
297
+ +--> 1: Expansion RAM
298
+ ```
299
+
300
+ #### Step 2: Setting the address counter A16 to A14
301
+
302
+ VDP can logically address 128K bytes in the address range of 00000h-1FFFFh through
303
+ 16 address bits A16...A0. At this step we set up bits A16...A14 writing them into register R#14 (VRAM access base address register).
304
+ ```
305
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
306
+ +-----+-----+-----+-----+-----+-----+-----+-----+
307
+ Register #14 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | Base reg
308
+ +-----+-----+-----+-----+-----+-----+-----+-----+
309
+ ```
310
+
311
+ #### Step 3: Setting the address counter A7 to A0
312
+
313
+ Set the low-order eight bits A7...A0 of the address counter by writing data to port #1.
314
+ ```
315
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
316
+ +-----+-----+-----+-----+-----+-----+-----+-----+
317
+ Port #1 | A7 | A6 | A5 | A4 | A3 | A2 | A1 | A0 | A7...A0
318
+ +-----+-----+-----+-----+-----+-----+-----+-----+
319
+ ```
320
+
321
+ #### Step 4: Setting the address counter A13 to A8 and operation mode
322
+
323
+ Set the remaining six bits A13...A8 of the address counter by writing data to the port #1. You also should specify which memory operation will follow - read or write. It is very important, as if you specify that next operation will be a "read", VDP will pre-fetch value from the memory (specified by the address set up earlier) and will get ready for CPU data read.
324
+ If you will not do so and issue read command, VDP may not get enough timeslot to read data from the VRAM and CPU may get invalid data.
325
+ If you specify that next command will be a "write", then VDP does not do pre-fetch and waits for write instead.
326
+ ```
327
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
328
+ +-----+-----+-----+-----+-----+-----+-----+-----+
329
+ Port #1 | 0 | W | A13 | A12 | A11 | A10 | A9 | A8 | A13...A8
330
+ +-----+-----+-----+-----+-----+-----+-----+-----+
331
+ |
332
+ +--> 0: Next command is "Data Read"
333
+ +--> 1: Next command is "Data Write"
334
+ ```
335
+
336
+ #### Step 5: Reading or writing data to memory
337
+
338
+ It is important to know that after every data read or data write operation from port #0 address counter is being incremented. It is very useful when you need to read from or write to the memory in sequential manner. However you should mind the timing, ensuring that VDP has enough time to write cached data or read requested data. Please refer to the data sheet for timings.
339
+ ```
340
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
341
+ +-----+-----+-----+-----+-----+-----+-----+-----+
342
+ Port #0 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 | Data Addr ++
343
+ +-----+-----+-----+-----+-----+-----+-----+-----+
344
+ ```
345
+
346
+ ## REGISTER FUNCTIONS
347
+
348
+ ### Control registers #0 to #23 / #32 to #46
349
+
350
+ #### Mode registers
351
+
352
+ ```
353
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
354
+ +-----+-----+-----+-----+-----+-----+-----+-----+
355
+ R#0 | 0 | DG | IE2 | IE1 | M5 | M4 | M3 | 0 | Mode R#0
356
+ +=====+=====+=====+=====+=====+=====+=====+=====+
357
+ R#1 | 0 | BL | IE0 | M1 | M2 | 0 | SI | MAG | Mode R#1
358
+ +=====+=====+=====+=====+=====+=====+=====+=====+
359
+ R#8 | MS | LP | TP | CB | VR | 0 | SPD | BW | Mode R#8
360
+ +=====+=====+=====+=====+=====+=====+=====+=====+
361
+ R#9 | LN | 0 | S1 | S0 | IL | E0 | *NT | DC | Mode R#9
362
+ +-----+-----+-----+-----+-----+-----+-----+-----+
363
+ ```
364
+ _**Note:** \* Indicates negative logic_
365
+
366
+ |Register|Values|
367
+ |:-:|---|
368
+ | R#0 | `DG` Digitize mode: sets the color bus to the input or output mode.<br>`IE2` Enables interrupts from Light pen.<br>`IE1` Enables interrupt from horizontal retrace.<br>`M5` Screen mode flag (see Screen Modes chapter).<br>`M4` Screen mode flag (see Screen Modes chapter).<br>`M3` Screen mode flag (see Screen Modes chapter).|
369
+ | R#1 | `BL` Blank screen: if set to 1, screen display is enabled. If set to 0, screen display is disabled and no VRAM read operations are performed.<br>`IE0` Enables interrupt from vertical retrace M1 Screen mode flag (see Screen Modes chapter).<br>**M2** Screen mode flag (see Screen Modes chapter).<br>`SI` Sprite size: when set to 1, sprite size is 16\*16. If set to 0, sprite size is 8\*8.<br>`MAG` Sprite enlarging: If set to 1, sprites are enlarged (double size).|
370
+ | R#8 | `MS` Mouse: when set to 1, sets the color bus into input mode and enables mouse. If set to 1, sets color bus into output mode and disables mouse.<br>`LP` Light pen: when set to 1, enables light pen.<br>`TP` Sets the color of code 0 to the color of the palette.<br>`CB` Color bus: when set to 1, sets color bus into input mode. If set to 0, sets color bus into output mode.<br>`VR` Selects the type and organization of VRAM. If set to 1, VRAM is 64Kx1Bit or 64Kx4bits. If set to 0, VRAM is 16Kx1Bit or 16Kx4Bits. Affects how VDP performs refresh on DRAM chips.<br>`SPD` Sprite disable: if set to 1, sprites are not displayed and related VRAM reads are not performed.<br>`BW` Black/White: if set to 1, output is grayscale in 32 tones.|
371
+ | R#9 | `LN` Line: if set to 1, vertical dot count is set to 212. If set to 0, vertical dot count is 192.<br>`S1` Selects simultaneous mode.<br>`S0` Selects simultaneous mode.<br>`IL` Interlace: if set to 1, interlace; if set to 0, non-interlace mode.<br>`EO` Even/Odd screens: When set to 1, displays two graphic screens interchangeably by even/odd field; if set to 0, displays same graphic screen by even/odd field.<br>`*NT` (RGB output only) If set to 1, PAL mode (313 lines, 50Hz); if set to 0, NTSC mode (262 lines, 60Hz).<br>`DC` Dot clock: If set to 1, \*DLCLK is in input mode; if set to 0, \*DLCKL is in output mode.|
372
+
373
+ #### Table Base address registers
374
+
375
+ When displaying information on the screen, VDP uses color, pattern, sprite and other information from video RAM. It is important to set proper starting addresses of such VRAM locations by writing to specified table base address registers.
376
+
377
+ _**Note:** you should ensure that unused bits are set to 0. Further in the book bit set to "0" will mean that this bit has to be set to 0, "1" will mean that this bit has to be set to 1, and "\*" will mean that value of the bit does not matter._
378
+
379
+ ```
380
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
381
+ +-----+-----+-----+-----+-----+-----+-----+-----+
382
+ R#2 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | A10 | Pattern layout table
383
+ +=====+=====+=====+=====+=====+=====+=====+=====+
384
+ R#3 | A13 | A12 | A11 | A10 | A9 | A8 | A7 | A6 | Color table low
385
+ +=====+=====+=====+=====+=====+=====+=====+=====+
386
+ R#10 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | Color table high
387
+ +=====+=====+=====+=====+=====+=====+=====+=====+
388
+ R#4 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Pattern generator table
389
+ +=====+=====+=====+=====+=====+=====+=====+=====+
390
+ R#5 | A14 | A13 | A12 | A11 | A10 | A9 | A8 | A7 | Sprite attribute table low
391
+ +=====+=====+=====+=====+=====+=====+=====+=====+
392
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high
393
+ +=====+=====+=====+=====+=====+=====+=====+=====+
394
+ R#6 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Sprite pattern generator table
395
+ +-----+-----+-----+-----+-----+-----+-----+-----+
396
+ ```
397
+
398
+ #### Color registers
399
+
400
+ Color registers are used to control MSX-VIDEO text and background screen colors, blinking and other functions.
401
+
402
+ ```
403
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
404
+ +-----+-----+-----+-----+-----+-----+-----+-----+
405
+ R#7 | TC3 | TC2 | TC1 | TC0 | BD3 | BD2 | BD1 | BD0 | Text & screen margin color
406
+ +=====+=====+=====+=====+=====+=====+=====+=====+
407
+ R#12 | T23 | T22 | T21 | T20 | BC3 | BC2 | BC1 | BC0 | Text & background blink color
408
+ +-----+-----+-----+-----+-----+-----+-----+-----+
409
+ ```
410
+ |Names|Description|
411
+ |:-:|---|
412
+ |`TC3`..`TC0`|Text color in TEXT1 and TEXT2 modes.|
413
+ |`BD3`..`BD0`|Screen margin / backdrop color.|
414
+ |`T23`..`T20`|Blink foreground color (part 1).|
415
+ |`BC3`..`BC0`|Blink background color (part 0).|
416
+
417
+ In TEXT2 mode, if attributes for blinking are set, color set in this register R#12 and in register R#7 are displayed alternatively (blinked).
418
+
419
+ ```
420
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
421
+ +-----+-----+-----+-----+-----+-----+-----+-----+
422
+ R#13 | ON3 | ON2 | ON1 | ON0 | OF3 | OF2 | OF1 | OF0 | Blinking period register
423
+ +-----+-----+-----+-----+-----+-----+-----+-----+
424
+ ```
425
+ |Names|Description|
426
+ |:-:|---|
427
+ |`ON3`..`ON0`|Display time for even page.|
428
+ |`OF3`..`OF0`|Display time for odd page.|
429
+
430
+
431
+ In the TEXT2 mode and in bit map modes of GRAPHIC4 to GRAPHIC7 two pages can be alternatively displayed (blinked). Write to this register R#13 in order for blinking to start.
432
+
433
+ ```
434
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
435
+ +-----+-----+-----+-----+-----+-----+-----+-----+
436
+ R#20 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | Color burst register 1
437
+ +=====+=====+=====+=====+=====+=====+=====+=====+
438
+ R#21 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | Color burst register 2
439
+ +=====+=====+=====+=====+=====+=====+=====+=====+
440
+ R#22 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | Color burst register 3
441
+ +-----+-----+-----+-----+-----+-----+-----+-----+
442
+ ```
443
+
444
+ The above values of color burst registers are preset on power-on. If all the bits in all three registers are set to 0, color burst of the composite video is not performed. If values are returned to above values, VDP will start generating normal color burst signal.
445
+
446
+ #### Display registers
447
+
448
+ The display registers are used to control display position on the screen.
449
+
450
+ ```
451
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
452
+ +-----+-----+-----+-----+-----+-----+-----+-----+
453
+ R#18 | V3 | V2 | V1 | V0 | H3 | H2 | H1 | H0 | Display adjust register
454
+ +-----+-----+-----+-----+-----+-----+-----+-----+
455
+ ```
456
+
457
+ Register #18 controls horizontal and vertical alignment on the screen. Please refer to the table below.
458
+
459
+ ||7|...|1|0|15|...|8|
460
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
461
+ | **H** |Left|...|...|Center|...|...|Right|
462
+ | **V** |Top|...|...|Center|...|...|Bottom|
463
+
464
+ ```
465
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
466
+ +-----+-----+-----+-----+-----+-----+-----+-----+
467
+ R#23 | DO7 | DO6 | DO5 | DO4 | DO3 | DO2 | DO1 | DO0 | Vertical offset register
468
+ +-----+-----+-----+-----+-----+-----+-----+-----+
469
+ ```
470
+
471
+ This register R#23 sets the value of the first line to display on the screen. Virtual screen size is 256 lines, visible vertical screen size can be 192 or 212 depending on LN bit of register R#9. Setting R#23 to value other than 0 may display un-initialized parts of the memory which may look as garbage. Display of virtual screen is performed in cycle, meaning that when increasing value of R#23 top of virtual screen appears at the bottom of visible screen.
472
+
473
+ ```
474
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
475
+ +-----+-----+-----+-----+-----+-----+-----+-----+
476
+ R#19 | IL7 | IL6 | IL5 | IL4 | IL3 | IL2 | IL1 | IL0 | Interrupt line register
477
+ +-----+-----+-----+-----+-----+-----+-----+-----+
478
+ ```
479
+
480
+ VDP generates interrupt when it starts to display respective scan line if bit 4 "IE1" of register R#0 is set to 1. Write a value to this register R#19, and when VDP will start displaying the specified line, it will set bit 0 "FH" of status register S#1 to 1.
481
+
482
+ #### Access registers
483
+
484
+ Access registers is the set of registers used for accessing other VDP registers or VRAM.
485
+ These registers include R#14, R#15, R#16 and R#17.
486
+
487
+ ```
488
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
489
+ +-----+-----+-----+-----+-----+-----+-----+-----+
490
+ R#14 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | VRAM access base register
491
+ +-----+-----+-----+-----+-----+-----+-----+-----+
492
+ ```
493
+ R#14 contains three senior bits of VRAM access address. In all modes, except GRAPHIC1, GRAPHIC2, MULTICOLOR and TEXT1, if there's a carry flag from A13 the value in this register is automatically incremented.
494
+
495
+ ```
496
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
497
+ +-----+-----+-----+-----+-----+-----+-----+-----+
498
+ R#15 | 0 | 0 | 0 | 0 | S3 | S2 | S1 | S0 | Status register pointer
499
+ +-----+-----+-----+-----+-----+-----+-----+-----+
500
+ ```
501
+ R#15 points to the respective status register (S#0...S#9) to be read.
502
+
503
+ ```
504
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
505
+ +-----+-----+-----+-----+-----+-----+-----+-----+
506
+ R#16 | 0 | 0 | 0 | 0 | C3 | C2 | C1 | C0 | Color palette address register
507
+ +-----+-----+-----+-----+-----+-----+-----+-----+
508
+ ```
509
+ R#16 points to the respective color palette register (P#0...P#15) to be accessed.
510
+
511
+ ```
512
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
513
+ +-----+-----+-----+-----+-----+-----+-----+-----+
514
+ R#17 | AII | 0 | RS5 | RS4 | RS3 | RS2 | RS1 | RS0 | Control register pointer
515
+ +-----+-----+-----+-----+-----+-----+-----+-----+
516
+ ```
517
+ R#17 is a register used in indirect access to other VDP registers. It also has auto-increment flag (AII) which is used to control increment of value in this register.
518
+
519
+ #### Command registers
520
+ The following command registers are used when executing a command on the MSX-VIDEO. Details on the use of these command registers will be presented in later chapter.
521
+
522
+ ```
523
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
524
+ +-----+-----+-----+-----+-----+-----+-----+-----+
525
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | Source X low register
526
+ +=====+=====+=====+=====+=====+=====+=====+=====+
527
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 | Source X high register
528
+ +=====+=====+=====+=====+=====+=====+=====+=====+
529
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | Source Y low register
530
+ +=====+=====+=====+=====+=====+=====+=====+=====+
531
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 | Source Y high register
532
+ +=====+=====+=====+=====+=====+=====+=====+=====+
533
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | Destination X low register
534
+ +=====+=====+=====+=====+=====+=====+=====+=====+
535
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 | Destination X high register
536
+ +=====+=====+=====+=====+=====+=====+=====+=====+
537
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | Destination Y low register
538
+ +=====+=====+=====+=====+=====+=====+=====+=====+
539
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 | Destination Y high register
540
+ +=====+=====+=====+=====+=====+=====+=====+=====+
541
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | Dots Number X low register
542
+ +=====+=====+=====+=====+=====+=====+=====+=====+
543
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 | Dots Number X high register
544
+ +=====+=====+=====+=====+=====+=====+=====+=====+
545
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | Dots Number Y low register
546
+ +=====+=====+=====+=====+=====+=====+=====+=====+
547
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 | Dots Number Y high register
548
+ +=====+=====+=====+=====+=====+=====+=====+=====+
549
+ R#44 | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | Color register
550
+ +=====+=====+=====+=====+=====+=====+=====+=====+
551
+ R#45 | 0 | MXC | MXD | MXS | DIY | DIX | EQ | MAJ | Argument register
552
+ +=====+=====+=====+=====+=====+=====+=====+=====+
553
+ R#46 | CM3 | CM2 | CM1 | CM0 | LO3 | LO2 | LO1 | LO0 | Command register
554
+ +-----+-----+-----+-----+-----+-----+-----+-----+
555
+ ```
556
+
557
+ ### Status registers #0 to #9
558
+
559
+ The following status registers are read-only registers for VDP status reporting. Let's consider each register.
560
+
561
+ ```
562
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
563
+ +-----+-----+-----+-----+-----+-----+-----+-----+
564
+ S#0 | F | 5S | C | 5SN | Status register 0
565
+ +-----+-----+-----+-----+-----+-----+-----+-----+
566
+ ```
567
+ |Bits|Names|Description|
568
+ |:-:|:-:|---|
569
+ |7|`F`|**Vertical scan interrupt flag:** When S#0 is read, this flag is reset.|
570
+ |6|`5S`|**Flag for 5th sprite:** Five (or nine in G3...G7 modes) sprites are aligned on the same horizontal line.|
571
+ |5|`C`|**Collision flag:** Two sprites have collided.|
572
+ |4..0|`5SN`|The number of 5<sup>th</sup> (or 9<sup>th</sup> in G3...G7 modes) sprite.|
573
+
574
+ ```
575
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
576
+ +-----+-----+-----+-----+-----+-----+-----+-----+
577
+ S#1 | FL | LPS | ID# | FH | Status register 1
578
+ +-----+-----+-----+-----+-----+-----+-----+-----+
579
+ ```
580
+ |Bits|Names|Description|
581
+ |:-:|:-:|---|
582
+ |7|`FL`|**Light pen:** Is set if light pen detects light. If IE2 is set, interrupt is generated. Reset when S#1 is read.<br>**Mouse 2:** Is set if second button of mouse was pressed.<br>This flag is not reset when reading status register S#1.|
583
+ |6|`LPS`|**Light pen button:** Is set when light pen button is pressed.<br>**Mouse 1:** Is set if first button of mouse was pressed.<br>This flag is not reset when reading status register S#1 in both set-ups.|
584
+ |5..1|`ID#`|The identification number of the VDP chip.|
585
+ |0|`FH`|**Horizontal scan interrupt flag:** Is set if VDP scans line specified in register R#19. If IE1 is set, interrupt is generated. FH is reset when S#1 is read.|
586
+
587
+ ```
588
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
589
+ +-----+-----+-----+-----+-----+-----+-----+-----+
590
+ S#2 | TR | VR | HR | BD | 1 | 1 | EO | CE | Status register 2
591
+ +-----+-----+-----+-----+-----+-----+-----+-----+
592
+ ```
593
+
594
+ |Bits|Names|Description|
595
+ |:-:|:-:|---|
596
+ |7|`TR`|**Transfer ready flag:** If set to 1, indicates to the CPU that VDP is ready for next transfer. A value of 0 means that VDP is not ready.|
597
+ |6|`VR`|**Vertical retrace flag:** Is set during scanning of VBLANK area of the screen, i.e. during vertical retrace plus while lower and upper borders of the screen are drawn.|
598
+ |5|`HR`|**Horizontal retrace flag:** Is set during scanning of HBLANK area of the screen, i.e. when right and left borders of the screen are drawn.|
599
+ |4|`BD`|**Color detect flag:** When the search command is executed, this flag is set if specified color was detected.|
600
+ |3..2|`1`|Reserved bits, always set to 1.|
601
+ |1|`EO`|**Display field flag:** If set to 0, indicates the first field. If set to 1, indicates the second field.|
602
+ |0|`CE`|**Command execution flag:** If set to 1, indicates that VDP is busy executing a command. If set to 0, indicates that VDP is ready for the next command.|
603
+
604
+ ```
605
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
606
+ +-----+-----+-----+-----+-----+-----+-----+-----+
607
+ S#3 | X7 | X6 | X5 | X4 | X3 | X2 | X1 | X0 | Column register low
608
+ +=====+=====+=====+=====+=====+=====+=====+=====+
609
+ S#4 | 1 | 1 | 1 | 1 | 1 | 1 | EO | X8 | Column register high
610
+ +=====+=====+=====+=====+=====+=====+=====+=====+
611
+ S#5 | Y7 | Y6 | Y5 | Y4 | Y3 | Y2 | Y1 | Y0 | Row register low
612
+ +=====+=====+=====+=====+=====+=====+=====+=====+
613
+ S#6 | 1 | 1 | 1 | 1 | 1 | 1 | EO | Y8 | Row register high
614
+ +-----+-----+-----+-----+-----+-----+-----+-----+
615
+ ```
616
+
617
+ The above registers S#3...S#6 contain coordinate information about collision location of the sprites, or location of light pen, or relative movement of the mouse.
618
+
619
+ ```
620
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
621
+ +-----+-----+-----+-----+-----+-----+-----+-----+
622
+ S#7 | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | Color register
623
+ +-----+-----+-----+-----+-----+-----+-----+-----+
624
+ ```
625
+
626
+ This color register is used when executing commands "POINT" and "VRAM to CPU" and contains VRAM data.
627
+
628
+ ```
629
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
630
+ +-----+-----+-----+-----+-----+-----+-----+-----+
631
+ S#8 | BX7 | BX6 | BX5 | BX4 | BX3 | BX2 | BX1 | BX0 | Coded color X register low
632
+ +=====+=====+=====+=====+=====+=====+=====+=====+
633
+ S#9 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | BX8 | Coded color X register high
634
+ +-----+-----+-----+-----+-----+-----+-----+-----+
635
+ ```
636
+
637
+ When the search command is executed and coded color had been detected (see R#2), these registers contains its X coordinate.
638
+
639
+ ## SCREEN MODES
640
+
641
+ ### TEXT1 mode
642
+
643
+ | Characteristics ||
644
+ |---|---|
645
+ | Pattern size (w\*h) | 6 dots \* 8 dots |
646
+ | Patterns | 256 types |
647
+ | Screen size (w\*h) | 40 \* 24 patterns |
648
+ | Pattern colors | Two colors out of 512 (per screen) |
649
+ | VRAM area per screen | 4K bytes |
650
+
651
+ | Controls ||
652
+ |---|---|
653
+ | Pattern font | VRAM pattern generator table |
654
+ | Screen pattern location | VRAM pattern name table |
655
+ | Pattern color code 1 | High-order four bits of R#7 |
656
+ | Pattern color code 0 | Low-order four bits of R#7 |
657
+ | Background color code | Low-order four bits of R#7 |
658
+
659
+
660
+ | Mode flags ||||||
661
+ |---|---|---|---|---|---|
662
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
663
+ | Value |0|0|0|0|1|
664
+
665
+ | MSX system default values |||
666
+ |---|---|---|
667
+ | BASIC SCREEN number | Pattern generator | Pattern layout |
668
+ | 0, width 1..40 | 00800h..00FFFh | 00000h..003BFh |
669
+
670
+ #### Pattern Generator Table
671
+
672
+ The pattern generator table is a location in VRAM that stores patterns (font). Each pattern has number from PN0 to PN255. The font displayed on the screen for each pattern is constructed from 8 bytes, with 6 high-order bits displayed and 2 low-order bits not displayed. Pattern generator table base is stored in the register R#4.
673
+
674
+ Example of pattern generator table is provided below.
675
+
676
+ | Offset |7|6|5|4|3|2|1|0||
677
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
678
+ | 0 | | |█| | | | | | Pattern number 0 (PN0) |
679
+ | 1 | |█| |█| | | | ||
680
+ | 2 |█| | | |█| | | ||
681
+ | 3 |█| | | |█| | | ||
682
+ | 4 |█|█|█|█|█| | | ||
683
+ | 5 |█| | | |█| | | ||
684
+ | 6 |█| | | |█| | | ||
685
+ | 7 | | | | | | | | ||
686
+ | 8 |█|█|█|█| | | | | Pattern number 1 (PN1) |
687
+ | 9 |█| | | |█| | | ||
688
+ | 10 |█| | | |█| | | ||
689
+ | 11 |█|█|█|█| | | | ||
690
+ | 12 |█| | | |█| | | ||
691
+ | 13 |█| | | |█| | | ||
692
+ | 14 |█|█|█|█| | | | ||
693
+ | 15 | | | | | | | | ||
694
+ |...| | | | | | | | |...|
695
+ |2040|█| |█| |█| | | | Pattern number 255 (PN255) |
696
+ |2041| |█| |█| |█| | ||
697
+ |2042|█| |█| |█| | | ||
698
+ |2043| |█| |█| |█| | ||
699
+ |2044|█| |█| |█| | | ||
700
+ |2045| |█| |█| |█| | ||
701
+ |2046|█| |█| |█| | | ||
702
+ |2047| |█| |█| |█| | ||
703
+
704
+ #### Pattern Layout Table settings
705
+
706
+ The pattern layout table is a map of the screen (per screen image). Every location of the screen contains code of the pattern displayed at respective location. This table has 40\*24 (960) locations where defined patterns can be displayed. Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) with address 0 in the picture below.
707
+
708
+ ```
709
+ +----------------------------------------------+
710
+ | Columns |
711
+ +-----+-----+-----+-----+-----+-----+-----+----+
712
+ | 0 | 1 | 2 | 3 | ... | ... | 39 | ←X |
713
+ +---+----+-----+-----+-----+-----+-----+-----+-----+----+
714
+ | | 0 | 0 1 2 3 ... ... 39 |
715
+ | | 1 | 40 41 42 43 ... ... 79 |
716
+ | R | .. | ... ... ... ... ... ... ... |
717
+ | o | 22 | 880 881 882 883 ... ... 919 |
718
+ | w | 23 | 920 921 922 923 ... ... 959 |
719
+ | s +----+-----------------------------------------+
720
+ | | Y↑ |
721
+ +---+----+
722
+ ```
723
+
724
+ #### Color register settings
725
+
726
+ Color settings are located in the register R#7. Bits TC3...TC0 specify pattern color code of the pixels identified as "1" in the bitmap values of pattern generator table, bits BD3...BD0 specify pattern color code of the pixels identified as "0" in the bitmap values of pattern generator table as well as screen border color.
727
+
728
+ _**Note:** screen border color is the same as the pattern backdrop color in TEXT1 mode._
729
+
730
+ #### Example of VRAM allocation for TEXT1 mode
731
+
732
+ ```
733
+ 00000h +-------------------+ R#2: 0 A16 A15 A14 A13 A12 A11 A10
734
+ | Pattern layout |
735
+ | table 0 |
736
+ 003BFh +-------------------+
737
+ : :
738
+ 00800h +-------------------+ R#4: 0 0 A16 A15 A14 A13 A12 A11
739
+ | Pattern generator |
740
+ | table 0 |
741
+ 00FFFh | |
742
+ 01000h +-------------------+ R#2: 0 A16 A15 A14 A13 A12 A11 A10
743
+ | Pattern layout |
744
+ | table 1 |
745
+ 013BFh +-------------------+
746
+ : :
747
+ 01800h +-------------------+ R#4: 0 0 A16 A15 A14 A13 A12 A11
748
+ | Pattern generator |
749
+ | table 1 |
750
+ | |
751
+ 01FFFh +-------------------+
752
+ : : 32 pages may be allocated in
753
+ : : the same manner if VDP has
754
+ 1FFFFh +-------------------+ 128KB attached to it.
755
+ ```
756
+
757
+ ### TEXT2 mode
758
+
759
+ | Characteristics ||
760
+ |---|---|
761
+ | Pattern size (w\*h) | 6 dots \* 8 dots |
762
+ | Patterns | 256 types
763
+ | Screen size (w\*h) | 80 \* 24 patterns if LN bit of R#9 set to 0<br>80 \* 26.5 patterns if LN bit of R#9 set to 1 |
764
+ | Pattern colors | Two colors out of 512 (per screen), four if using blinking |
765
+ | VRAM area per screen | 8K bytes |
766
+
767
+ | Controls ||
768
+ |---|---|
769
+ | Pattern font | VRAM pattern generator table |
770
+ | Screen pattern location | VRAM pattern name table |
771
+ | Pattern color code 1 | High-order four bits of R#7 |
772
+ | Pattern color code 0 | Low-order four bits of R#7 |
773
+ | Background color code | Low-order four bits of R#7 |
774
+ | Blinking pattern color code 1 | High-order four bits of R#12 |
775
+ | Blinking pattern color code 0 | Low-order four bits of R#12 |
776
+
777
+ | Mode flags ||||||
778
+ |---|:-:|:-:|:-:|:-:|:-:|
779
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
780
+ | Value |0|1|0|0|1|
781
+
782
+ | Other flags ||
783
+ |---|---|
784
+ | LN bit of R#9 | 0: 24 lines displayed<br>1: 26.5 lines displayed |
785
+
786
+ | MSX system default values ||||
787
+ |---|---|---|---|
788
+ | BASIC SCREEN number | Pattern generator | Pattern layout | Pattern color table |
789
+ | 0, width 41..80 | 01000h..017FFh | 00000h..0077Fh<br>00000h..0086Fh | 00800h..008EFh<br>00800h..0090Dh |
790
+
791
+ #### Pattern Generator Table
792
+
793
+ Organization of pattern generator table is the same as in TEXT1 mode. Register R#4 defines base address of the table.
794
+
795
+ #### Pattern layout table settings
796
+
797
+ The pattern layout table is a map of the screen (per screen image). Every location of the screen contains code of the pattern displayed at respective location. This table has 80\*27 (2160) locations where defined patterns can be displayed. Pattern layout table base address is stored in register R#2 (see below), and corresponds to the cell (0, 0) with address 0 in the picture below. Note that if LN bit of R#9 is set to 1, then 26 lines are displayed, plus an upper half of 27<sup>th</sup> pattern line is displayed.
798
+
799
+ ```
800
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
801
+ +-----+-----+-----+-----+-----+-----+-----+-----+
802
+ R#2 | 0 | A16 | A15 | A14 | A13 | A12 | 1 | 1 | Pattern layout table
803
+ +-----+-----+-----+-----+-----+-----+-----+-----+
804
+ ```
805
+
806
+ Screen mapping of pattern layout table is provided below.
807
+
808
+ ```
809
+ +----------------------------------------------+
810
+ | Columns |
811
+ +-----+-----+-----+-----+-----+-----+-----+----+
812
+ | 0 | 1 | 2 | 3 | ... | ... | 79 | ←X |
813
+ +---+----+-----+-----+-----+-----+-----+-----+-----+----+
814
+ | | 0 | 0 1 2 3 ... ... 79 |
815
+ | | 1 | 80 81 82 83 ... ... 159 |
816
+ | R | .. | ... ... ... ... ... ... ... |
817
+ | o | 25 | 2000 2001 2002 2003 ... ... 2079 |
818
+ | w | 26 | 2080 2081 2082 2083 ... ... 2159 |
819
+ | s +----+-----------------------------------------+
820
+ | | Y↑ |
821
+ +---+----+
822
+ ```
823
+
824
+ #### Color table settings
825
+
826
+ Each position on the screen has separate bit for the blinking attribute, and if this bits is set to 1, blinking will be applied to the pattern placed in this area in the pattern layout table. Table start address is set in registers R#3 and R#10.
827
+
828
+ ```
829
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
830
+ +-----+-----+-----+-----+-----+-----+-----+-----+
831
+ R#3 | A13 | A12 | A11 | A10 | A9 | 1 | 1 | 1 | Color table
832
+ +=====+=====+=====+=====+=====+=====+=====+=====+ base address
833
+ R#10 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | registers
834
+ +-----+-----+-----+-----+-----+-----+-----+-----+
835
+ ```
836
+
837
+ Screen mapping of color table is provided below.
838
+
839
+ ```
840
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
841
+ +-----+-----+-----+-----+-----+-----+-----+-----+
842
+ 0 | 0,0 | 1,0 | 2,0 | 3,0 | 4,0 | 5,0 | 6,0 | 7,0 |
843
+ +-----+-----+-----+-----+-----+-----+-----+-----+
844
+ 1 | 8,0 | 9,0 |10,0 |11,0 |12,0 |13,0 |14,0 |15,0 |
845
+ +-----+-----+-----+-----+-----+-----+-----+-----+
846
+ : ··· : ··· : ··· : ··· : ··· : ··· : ··· : ··· :
847
+ +-----+-----+-----+-----+-----+-----+-----+-----+
848
+ 269 |72,26|73,26|74,26|75,26|76,26|77,26|78,26|79,26|
849
+ +-----+-----+-----+-----+-----+-----+-----+-----+
850
+ ```
851
+
852
+ #### Color register settings
853
+
854
+ Color settings are located in the registers R#7 and R#12.
855
+ Bits TC3..TC0 of R#7 specify pattern color code of the pixels identified as "1" in the bitmap values of pattern generator table, bits BD3..BD0 specify pattern color code of the pixels identified as "0" in the bitmap values of pattern generator table as well as screen border color. Alternate blinking color is set in R#12.
856
+
857
+ _**Note:** screen border color is the same as the pattern backdrop color in TEXT2 mode._
858
+
859
+ #### Blink register settings
860
+
861
+ Color codes set in registers R#7 and R#12 will be alternately displayed; programmer can control period of blinking (time on and time off) through register R#13.
862
+
863
+ ```
864
+ +---------------+ +--------
865
+ | R#12 | R#7 | R#12
866
+ ----+ +---------------+
867
+ <---On time---> <---Off time--->
868
+
869
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
870
+ +-----+-----+-----+-----+-----+-----+-----+-----+
871
+ R#13 | ON3 | ON2 | ON1 | ON0 | OF3 | OF2 | OF1 | OF0 | Blinking color register
872
+ +-----+-----+-----+-----+-----+-----+-----+-----+
873
+ | On time | Off time |
874
+ ```
875
+
876
+ The NTSC timing data is provided in the table below.
877
+
878
+ | Delay data (binary) | Time (ms) | Delay data (binary) | Time (ms) |
879
+ |:-:|--:|:-:|--:|
880
+ | 0 0 0 0 | 0.0 | 1 0 0 0 | 1335.1 |
881
+ | 0 0 0 1 | 166.9 | 1 0 0 1 | 1509.9 |
882
+ | 0 0 1 0 | 333.8 | 1 0 1 0 | 1668.8 |
883
+ | 0 0 1 1 | 500.6 | 1 0 1 1 | 1835.7 |
884
+ | 0 1 0 0 | 667.5 | 1 1 0 0 | 2002.6 |
885
+ | 0 1 0 1 | 834.4 | 1 1 0 1 | 2169.5 |
886
+ | 0 1 1 0 | 1001.3 | 1 1 1 0 | 2336.3 |
887
+ | 0 1 1 1 | 1168.2 | 1 1 1 1 | 2503.2 |
888
+
889
+ #### Example of VRAM allocation for TEXT2 mode
890
+
891
+ ```
892
+ 00000h +-------------------+
893
+ | Pattern layout | R#2: 0 0 0 0 0 0 1 1
894
+ | table 0 |
895
+ 00870h +-------------------+ R#3: 0 0 1 0 1 1 1 1
896
+ : :
897
+ 00A00h +-------------------+ R#10: 0 0 0 0 0 0 0 0
898
+ | Color table 1 |
899
+ | | R#4: 0 0 0 0 0 0 1 0
900
+ 00B0Eh +-------------------+
901
+ : :
902
+ 01000h +-------------------+
903
+ | Pattern generator |
904
+ | table 0 |
905
+ | |
906
+ 01800h +-------------------+
907
+ : :
908
+ 02000h +-------------------+
909
+ | Pattern layout |
910
+ | table 1 |
911
+ 02870h +-------------------+
912
+ : :
913
+ 02A00h +-------------------+
914
+ | Color table 1 |
915
+ | |
916
+ 02B0Eh +-------------------+
917
+ : :
918
+ 03000h +-------------------+
919
+ | Pattern generator |
920
+ | table 1 |
921
+ | |
922
+ 03800h +-------------------+
923
+ : :
924
+ 04000h +-------------------+
925
+ : : 16 pages may be allocated in
926
+ : : the same manner if VDP has
927
+ 1FFFFh +-------------------+ 128KB attached to it.
928
+ ```
929
+
930
+ ### MULTICOLOR (MC) mode
931
+
932
+ | Characteristics ||
933
+ |---|---|
934
+ | Screen composition (w\*h) | 64 \* 48 color blocks |
935
+ | Color blocks | Sixteen colors out of 512 colors |
936
+ | Sprite mode | Sprite mode 1 |
937
+ | VRAM area per screen | 4K bytes |
938
+
939
+ | Controls ||
940
+ |---|---|
941
+ | Color block color code | VRAM pattern generator table |
942
+ | Color block location | VRAM pattern name table |
943
+ | Background color code | Low-order four bits of R#7 |
944
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
945
+
946
+ | Mode flags ||||||
947
+ |---|:-:|:-:|:-:|:-:|:-:|
948
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
949
+ | Value |0|0|0|1|0|
950
+
951
+ | MSX system default values |||||
952
+ |---|---|---|---|---|
953
+ | BASIC SCREEN number | Pattern generator | Pattern layout | Sprite patterns | Sprite attributes |
954
+ | 3 | 00000h..007FFh | 00800h..00AFFh | 03800h..03FFFh | 01B00..01B7Fh |
955
+
956
+ #### Pattern Generator Table
957
+
958
+ Each pattern is made up of four color blocks. These patterns are of size of 8*8 for the screen display of 256\*192 dots.
959
+
960
+ For each block A, B, C, and D sixteen colors can be specified. Two bytes are used for each pattern.
961
+
962
+ ```
963
+ <------ 8 dots ----->
964
+ +---------+---------+ ^
965
+ | | | |
966
+ | Block A | Block B | |
967
+ | | | |
968
+ +---------+---------+ 8 dots
969
+ | | | |
970
+ | Block C | Block D | |
971
+ | | | |
972
+ +---------+---------+ v
973
+
974
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
975
+ +-----------------------+-----------------------+
976
+ | Color code A | Color Code B |
977
+ +=======================+=======================+
978
+ | Color code C | Color Code D |
979
+ +-----------------------+-----------------------+
980
+ ```
981
+ There're four color blocks (8 bytes) for each pattern layout location. Specific color block is used to display depending on the y-coordinate.
982
+
983
+ ```
984
+ MSB 7 6 5 4 3 2 1 0 LSB
985
+ +---+---+ +--------------+--------------+
986
+ | A | B | | Color code A | Color code B | Color of the pattern when
987
+ +---+---+ +--------------+--------------+ y=0, 4, 8, 12, 16 or 20
988
+ | C | D | | Color code A | Color code B |
989
+ +---+---+ +--------------+--------------+
990
+
991
+ +---+---+ +--------------+--------------+
992
+ | E | F | | Color code E | Color code F | Color of the pattern when
993
+ +---+---+ +--------------+--------------+ y=1, 5, 9, 13, 17 or 21
994
+ | G | H | | Color code G | Color code H |
995
+ +---+---+ +--------------+--------------+
996
+
997
+ +---+---+ +--------------+--------------+
998
+ | I | J | | Color code I | Color code J | Color of the pattern when
999
+ +---+---+ +--------------+--------------+ y=2, 6, 10, 14, 18 or 22
1000
+ | K | L | | Color code K | Color code L |
1001
+ +---+---+ +--------------+--------------+
1002
+
1003
+ +---+---+ +--------------+--------------+
1004
+ | M | N | | Color code M | Color code N | Color of the pattern when
1005
+ +---+---+ +--------------+--------------+ y=3, 7, 11, 15, 19 or 23
1006
+ | O | P | | Color code O | Color code P |
1007
+ +---+---+ +--------------+--------------+
1008
+ ```
1009
+ Start of the pattern generator table should be set in register R#4.
1010
+
1011
+ #### Pattern layout table settings
1012
+
1013
+ The pattern layout table is a map of the screen (per screen image), containing one byte for each screen location. Each byte specifies unique pattern number. Start of the pattern name table should be set in register R#2.
1014
+
1015
+ ```
1016
+ +----------------------------------------------+
1017
+ | Columns |
1018
+ +-----+-----+-----+-----+-----+-----+-----+----+
1019
+ | 0 | 1 | 2 | 3 | ... | ... | 31 | ←X |
1020
+ +---+----+-----+-----+-----+-----+-----+-----+-----+----+
1021
+ | | 0 | 0 1 2 3 ... ... 31 |
1022
+ | | 1 | 32 33 34 35 ... ... 63 |
1023
+ | R | .. | ... ... ... ... ... ... ... |
1024
+ | o | 22 | 704 705 706 707 ... ... 735 |
1025
+ | w | 23 | 736 737 738 739 ... ... 767 |
1026
+ | s +----+-----------------------------------------+
1027
+ | | Y↑ |
1028
+ +---+----+
1029
+ ```
1030
+
1031
+ #### Color register settings
1032
+
1033
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1034
+
1035
+ #### Sprite settings
1036
+
1037
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 1".
1038
+
1039
+ #### Example of VRAM allocation for MULTICOLOR mode
1040
+
1041
+ ```
1042
+ 00000h +-------------------+
1043
+ | Sprite generator |
1044
+ | table 0 |
1045
+ 00400h +-------------------+
1046
+ | Pattern layout |
1047
+ | table 0 |
1048
+ | |
1049
+ 00700h +-------------------+
1050
+ | Sprite attribute |
1051
+ | table 0 |
1052
+ 00780h +-------------------+
1053
+ : :
1054
+ 00800h +-------------------+
1055
+ | Pattern generator |
1056
+ | table 0 |
1057
+ | |
1058
+ 01000h +-------------------+
1059
+ : : 32 pages may be allocated in
1060
+ : : the same manner if VDP has
1061
+ 1FFFFh +-------------------+ 128KB attached to it.
1062
+ ```
1063
+
1064
+ ### GRAPHIC1 (G1) mode
1065
+
1066
+ | Characteristics ||
1067
+ |---|---|
1068
+ | Pattern size (w\*h) | 8 dots \* 8 dots |
1069
+ | Patterns | 256 types |
1070
+ | Screen size (w\*h) | 32 \* 24 patterns (256 \* 192 pixels) |
1071
+ | Pattern colors | 16 colors out of 512 (per screen) |
1072
+ | Sprite mode | Sprite mode 1 |
1073
+ | VRAM area per screen | 4K bytes |
1074
+
1075
+ | Controls ||
1076
+ |---|---|
1077
+ | Pattern font | VRAM pattern generator table |
1078
+ | Screen pattern location | VRAM pattern name table |
1079
+ | Pattern color codes 1 & 0 | Specified as a group for each 8-bit pattern in color table |
1080
+ | Background color code | Low-order four bits of R#7 |
1081
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1082
+
1083
+ | Mode flags ||||||
1084
+ |---|:-:|:-:|:-:|:-:|:-:|
1085
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1086
+ | Value |0|0|0|0|0|0|
1087
+
1088
+ | MSX system default values ||||||
1089
+ |---|---|---|---|---|---|
1090
+ | BASIC SCREEN number | Pattern generator | Pattern layout | Pattern colors | Sprite patterns | Sprite attributes |
1091
+ | 1 | 00000h..017FFh | 01800h..01AFFh | 02000h..0201Fh | 03800h..03FFFh | 01B00..01B7Fh |
1092
+
1093
+ #### Pattern Generator Table
1094
+
1095
+ The pattern generator table is a location in VRAM that stores patterns (font). Each pattern has number from PN0 to PN255. The font displayed on the screen for each pattern is constructed from 8 bytes, with all 8 bits of each byte displayed. Pattern generator table base is stored in the register R#4. Example of pattern generator table is provided below.
1096
+
1097
+ | Offset |7|6|5|4|3|2|1|0||
1098
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|
1099
+ | 0 | | |█|█|█| | | | Pattern number 0 (PN0) |
1100
+ | 1 | |█| | | |█| | ||
1101
+ | 2 |█| | | | | |█| ||
1102
+ | 3 |█| | | | | |█| ||
1103
+ | 4 |█|█|█|█|█|█|█| ||
1104
+ | 5 |█| | | | | |█| ||
1105
+ | 6 |█| | | | | |█| ||
1106
+ | 7 | | | | | | | | ||
1107
+ | 8 |█|█|█|█|█|█| | | Pattern number 1 (PN1) |
1108
+ | 9 |█| | | | | |█| ||
1109
+ | 10 |█| | | | | |█| ||
1110
+ | 11 |█|█|█|█|█|█| | ||
1111
+ | 12 |█| | | | | |█| ||
1112
+ | 13 |█| | | | | |█| ||
1113
+ | 14 |█|█|█|█|█|█| | ||
1114
+ | 15 | | | | | | | | ||
1115
+ |...| | | | | | | | |...|
1116
+ |2040|█| |█| |█| |█| | Pattern number 255 (PN255) |
1117
+ |2041| |█| |█| |█| |█||
1118
+ |2042|█| |█| |█| |█| ||
1119
+ |2043| |█| |█| |█| |█||
1120
+ |2044|█| |█| |█| |█| ||
1121
+ |2045| |█| |█| |█| |█||
1122
+ |2046|█| |█| |█| |█| ||
1123
+ |2047| |█| |█| |█| |█||
1124
+
1125
+ #### Pattern layout table settings
1126
+
1127
+ The pattern layout table is a map of the screen (per screen image). Every byte location of the screen contains code of the pattern displayed at respective location. This table has 32*24 (767) locations where defined patterns can be displayed. Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) with address 0 in the picture below.
1128
+
1129
+ ```
1130
+ +----------------------------------------------+
1131
+ | Columns |
1132
+ +-----+-----+-----+-----+-----+-----+-----+----+
1133
+ | 0 | 1 | 2 | 3 | ... | ... | 31 | ←X |
1134
+ +---+----+-----+-----+-----+-----+-----+-----+-----+----+
1135
+ | | 0 | 0 1 2 3 ... ... 31 |
1136
+ | | 1 | 32 33 34 35 ... ... 63 |
1137
+ | R | .. | ... ... ... ... ... ... ... |
1138
+ | o | 22 | 704 705 706 707 ... ... 735 |
1139
+ | w | 23 | 736 737 738 739 ... ... 767 |
1140
+ | s +----+-----------------------------------------+
1141
+ | | Y↑ |
1142
+ +---+----+
1143
+ ```
1144
+
1145
+ #### Color register settings
1146
+
1147
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1148
+
1149
+ #### Color table settings
1150
+
1151
+ Table start address is set in registers R#3 and R#10.
1152
+
1153
+ ```
1154
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1155
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1156
+ R#3 | A13 | A12 | A11 | A10 | A9 | A8 | A7 | A6 | Color table
1157
+ +=====+=====+=====+=====+=====+=====+=====+=====+ base address
1158
+ R#10 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | registers
1159
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1160
+ ```
1161
+
1162
+ Color table size is 32 bytes, each byte organized in the same way as register R#7 (FC is foreground color, BC is background color). Patterns 0..7 are assigned the first color from color table, patterns 8..15 are assigned second color from the color table, etc, and patterns F8h...FFh are assigned 31st color from the color table. Color table map is provided below.
1163
+
1164
+ ```
1165
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1166
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1167
+ 0 | FC3 | FC2 | FC1 | FC0 | BC3 | BC2 | BC1 | BC0 | Color for patterns 0..7
1168
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1169
+ 1 | FC3 | FC2 | FC1 | FC0 | BC3 | BC2 | BC1 | BC0 | Color for patterns 8..F
1170
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1171
+ : :
1172
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1173
+ 31 | FC3 | FC2 | FC1 | FC0 | BC3 | BC2 | BC1 | BC0 | Color for patterns F8..FF
1174
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1175
+ ```
1176
+
1177
+ #### Sprite settings
1178
+
1179
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 1".
1180
+
1181
+ #### Example of VRAM allocation for GRAPHIC1 mode
1182
+
1183
+ ```
1184
+ 00000h +-------------------+
1185
+ | Sprite generator |
1186
+ | table 0 |
1187
+ 00400h +-------------------+
1188
+ | Pattern layout |
1189
+ | table 0 |
1190
+ | |
1191
+ 00700h +-------------------+
1192
+ | Sprite attribute |
1193
+ | table 0 |
1194
+ 00780h +-------------------+
1195
+ : :
1196
+ 00800h +-------------------+
1197
+ | Pattern generator |
1198
+ | table 0 |
1199
+ | |
1200
+ 01000h +-------------------+
1201
+ : : 32 pages may be allocated in
1202
+ : : the same manner if VDP has
1203
+ 1FFFFh +-------------------+ 128KB attached to it.
1204
+ ```
1205
+
1206
+ ### GRAPHIC2 (G2) and GRAPHIC3 (G3) modes
1207
+
1208
+ | Characteristics ||
1209
+ |---|---|
1210
+ | Pattern size (w\*h) 8 dots \* 8 dots |
1211
+ | Patterns | 768 types (256 per ⅓ of the screen) |
1212
+ | Screen size (w\*h) | 32 \* 24 patterns (256 \* 192 pixels) |
1213
+ | Pattern colors | 16 colors out of 512 (per screen) |
1214
+ | Sprite mode(*) | Sprite mode 1 (GRAPHIC 2)<br>Sprite mode 2 (GRAPHIC 3) |
1215
+ | VRAM area per screen | 16K bytes |
1216
+
1217
+ (\*) GRAPHIC modes 2 and 3 are identical except for sprite modes.
1218
+
1219
+ | Controls ||
1220
+ |---|---|
1221
+ | Pattern font | VRAM pattern generator table |
1222
+ | Screen pattern location | VRAM pattern name table |
1223
+ | Pattern color codes 1 & 0 | Specified in pattern color table for 8-pixel groups |
1224
+ | Background color code | Low-order four bits of R#7 |
1225
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1226
+
1227
+ | Mode flags: GRAPHIC2 ||||||
1228
+ |---|:-:|:-:|:-:|:-:|:-:|
1229
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1230
+ | Value |0|0|1|0|0|
1231
+
1232
+ | Mode flags: GRAPHIC3 ||||||
1233
+ |---|:-:|:-:|:-:|:-:|:-:|
1234
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1235
+ | Value |0|1|0|0|0|
1236
+
1237
+ | MSX system default values |||||||
1238
+ |---|---|---|---|---|---|---|
1239
+ | BASIC SCREEN number | Pattern generator | Pattern layout | Pattern colors | Sprite patterns | Sprite attributes | Sprite colors |
1240
+ |G2: 2<br>G3: 4|00000h..017FFh|01800h..01AFFh|02000h..037FFh|03800h..03FFFh|01B00..01B7Fh<br>01E00h..01E7Fh|01C00h..01DFFh|
1241
+
1242
+ #### Screen map and pattern tables
1243
+
1244
+ Unlike in other modes, in this mode screen is divided vertically into three logical parts. Every part has its own pattern generator and pattern color tables, but all of them share the same pattern layout table, one after another. Screen map is provided below.
1245
+
1246
+ ```
1247
+ +----------------------------------------------+
1248
+ | Columns |
1249
+ +-----+-----+-----+-----+-----+-----+-----+----+
1250
+ | 0 | 1 | 2 | 3 | ··· | ··· | 31 | ←X |
1251
+ +---+----+-----+-----+-----+-----+-----+-----+-----+----+
1252
+ | | 0 | 0,0 1,0 2,0 3,0 ··· ··· 31,0 |
1253
+ | | 1 | 0,1 1,1 2,1 3,1 ··· ··· 31,1 | Upper ⅓ of
1254
+ | | ·· | ··· ··· ··· ··· ··· ··· ··· | the screen
1255
+ | | 7 | 0,7 1,7 2,7 3,7 ... ... 31,7 |
1256
+ | +----+-----------------------------------------+ · · · · · ·
1257
+ | R | 8 | 0,8 1,8 2,8 3,8 ··· ··· 31,8 | Middle ⅓ of
1258
+ | o | ·· | ··· ··· ··· ··· ··· ··· ··· | the screen
1259
+ | w | 15 | 0,15 1,15 2,15 3,15 ··· ··· 31,15|
1260
+ | s +----+-----------------------------------------+ · · · · · ·
1261
+ | | 16 | 0,16 1,16 2,16 3,16 ··· ··· 31,16|
1262
+ | | ·· | ··· ··· ··· ··· ··· ··· ··· | Lower ⅓ of
1263
+ | | 22 | 0,22 1,22 2,22 3,22 ··· ··· 31,22| the screen
1264
+ | | 23 | 0,23 1,23 2,23 3,23 ··· ··· 31,23|
1265
+ | +----+-----------------------------------------+ · · · · · ·
1266
+ | | Y↑ |
1267
+ +---+----+
1268
+ ```
1269
+
1270
+ ```
1271
+ Pattern genetator table
1272
+ (base address): : : :
1273
+ 00000h +-------------------------+ +-------------------------+
1274
+ | Pattern images upper ⅓ | | Pattern colors upper ⅓ |
1275
+ | of the screen (256) | | of the screen (256) |
1276
+ 00800h +-------------------------+ +-------------------------+
1277
+ | Pattern images middle ⅓ | | Pattern colors middle ⅓ |
1278
+ | of the screen (256) | | of the screen (256) |
1279
+ 01000h +-------------------------+ +-------------------------+
1280
+ | Pattern images lower ⅓ | | Pattern colors lower ⅓ |
1281
+ | of the screen (256) | | of the screen (256) |
1282
+ 01800h +-------------------------+ +-------------------------+
1283
+ : : : |
1284
+ ```
1285
+
1286
+ #### Pattern Tables
1287
+
1288
+ The pattern generator table is a location in VRAM that stores patterns (font). Each pattern has number from PN0 to PN255, for every ⅓ of the screen. The font displayed on the screen for each pattern is constructed from 8 bytes, with all 8 bits of each byte displayed. Pattern generator table base is stored in the register R#4.
1289
+
1290
+ ```
1291
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1292
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1293
+ R#4 | 0 | 0 | A16 | A15 | A14 | A13 | 1 | 1 | Pattern generator
1294
+ +-----+-----+-----+-----+-----+-----+-----+-----+ table base address
1295
+ ```
1296
+
1297
+ The pattern layout table is a map of the screen (per screen image). Every byte location of the screen contains code of the pattern displayed at respective location. This table has three 32\*8 locations (upper, middle and lower) arranged consecutively where defined patterns can be displayed. Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) with address 0 in the picture below. Example of pattern generator table is provided below. Color table identifies color 1 (upper four bits: Fh) and color 0 (lower four bits: 0h) for every row of the pattern.
1298
+
1299
+ | Offset |7|6|5|4|3|2|1|0||7|6|5|4|3|2|1|0|
1300
+ |:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|---|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
1301
+ | 0 | | |█| | | | | | Pattern |1|1|1|1|0|0|0|0|
1302
+ | 1 | |█| |█| | | | | number 0 |1|1|1|1|0|0|0|0|
1303
+ | 2 |█| | | |█| | | | (PN0) |1|1|1|1|0|0|0|0|
1304
+ | 3 |█| | | |█| | | ||1|1|1|1|0|0|0|0|
1305
+ | 4 |█|█|█|█|█| | | ||1|1|1|1|0|0|0|0|
1306
+ | 5 |█| | | |█| | | ||1|1|1|1|0|0|0|0|
1307
+ | 6 |█| | | |█| | | ||1|1|1|1|0|0|0|0|
1308
+ | 7 | | | | | | | | ||1|1|1|1|0|0|0|0|
1309
+ | 8 |█|█|█|█| | | | | Pattern |1|1|1|1|0|0|0|0|
1310
+ | 9 |█| | | |█| | | | number 1 |1|1|1|1|0|0|0|0|
1311
+ | 10 |█| | | |█| | | | (PN1) |1|1|1|1|0|0|0|0|
1312
+ | 11 |█|█|█|█| | | | ||1|1|1|1|0|0|0|0|
1313
+ | 12 |█| | | |█| | | ||1|1|1|1|0|0|0|0|
1314
+ | 13 |█| | | |█| | | ||1|1|1|1|0|0|0|0|
1315
+ | 14 |█|█|█|█| | | | ||1|1|1|1|0|0|0|0|
1316
+ | 15 | | | | | | | | ||1|1|1|1|0|0|0|0|
1317
+ |...| | | | | | | | |...||||...|||||
1318
+ |2040|█| |█| |█| | | | Pattern |1|1|1|1|0|0|0|0|
1319
+ |2041| |█| |█| |█| | | number 255|1|1|1|1|0|0|0|0|
1320
+ |2042|█| |█| |█| | | | (PN255) |1|1|1|1|0|0|0|0|
1321
+ |2043| |█| |█| |█| | ||1|1|1|1|0|0|0|0|
1322
+ |2044|█| |█| |█| | | ||1|1|1|1|0|0|0|0|
1323
+ |2045| |█| |█| |█| | ||1|1|1|1|0|0|0|0|
1324
+ |2046|█| |█| |█| | | ||1|1|1|1|0|0|0|0|
1325
+ |2047| |█| |█| |█| | ||1|1|1|1|0|0|0|0|
1326
+
1327
+ #### Color table settings
1328
+
1329
+ Table start address is set in registers R#3 and R#10.
1330
+
1331
+ ```
1332
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1333
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1334
+ R#3 | A13 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | Color table
1335
+ +=====+=====+=====+=====+=====+=====+=====+=====+ base address
1336
+ R#10 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | A14 | registers
1337
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1338
+ ```
1339
+
1340
+ #### Color register settings
1341
+
1342
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1343
+
1344
+ #### Sprite settings
1345
+
1346
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites in GRAPHIC2 mode, please refer to section "Sprite mode 1"; for details about sprites in GRAPHIC3 mode, please refer to section "Sprite mode 2".
1347
+
1348
+ #### Example of VRAM allocation for GRAPHIC2 and GRAPHIC3 modes
1349
+
1350
+ ```
1351
+ 00000h +-------------------+
1352
+ | Pattern generator |
1353
+ | table upper |
1354
+ 00800h +-------------------+
1355
+ | Pattern generator | GRAPHIC2 mode GRAPHIC3 mode
1356
+ | table middle | / +----------------+ 01800h +----------------+ 01800h
1357
+ 01000h +-------------------+ / | Sprite Pattern | | Sprite Pattern |
1358
+ | Pattern generator | / | table | | table |
1359
+ | table lower | / +----------------+ 01C00h +----------------+ 01C00h
1360
+ 01800h +-------------------+/ | Sprite attrib. | | Sprite color |
1361
+ : : | table | | table |
1362
+ : : +----------------+ 01C80h +----------------+ 01E00h
1363
+ 02000h +-------------------+\ : : | Sprite attrib. |
1364
+ | Pattern color | \ : : | table |
1365
+ | table upper | \ : : +----------------+ 01E80h
1366
+ 02800h +-------------------+ \ : : : :
1367
+ | Pattern color | \ +----------------+ 02000h +----------------+ 02000h
1368
+ | table middle |
1369
+ 03000h +-------------------+
1370
+ | Pattern color |
1371
+ | table lower |
1372
+ 03800h +-------------------+
1373
+ | Pattern layout |
1374
+ | table |
1375
+ 04000h +-------------------+
1376
+ : : 8 pages may be allocated in
1377
+ : : the same manner if VDP has
1378
+ 1FFFFh +-------------------+ 128KB attached to it.
1379
+ ```
1380
+
1381
+ ### GRAPHIC4 (G4) mode
1382
+
1383
+ | Characteristics ||
1384
+ |---|---|
1385
+ | Bit-mapped Graphics mode ||
1386
+ | Screen size (w\*h) | 256 \* 192 pixels if LN bit of R#9 set to 0<br>256 \* 212 pixels if LN bit of R#9 set to 1 |
1387
+ | Pattern colors | 16 colors out of 512 (per screen) |
1388
+ | Sprite mode | Sprite mode 2 |
1389
+ | VRAM area per screen | 32K bytes |
1390
+
1391
+ | Controls ||
1392
+ |---|---|
1393
+ | Graphics | VRAM pattern name table |
1394
+ | Background color code | Low-order four bits of R#7 |
1395
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1396
+
1397
+ | Mode flags ||||||
1398
+ |---|:-:|:-:|:-:|:-:|:-:|
1399
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1400
+ | Value |0|1|1|0|0|
1401
+
1402
+ | MSX system default values ||||||
1403
+ |---|---|---|---|---|---|
1404
+ | BASIC SCREEN number | Pattern layout<br>(bitmap) | Sprite patterns | Sprite attributes | Sprite colors |
1405
+ | 5 | 00000h..069FFh | 07800h..07FFFh | 07600h..0767Fh | 07400h..075FFh |
1406
+
1407
+ #### Pattern layout table settings
1408
+
1409
+ The pattern layout table is a map of the screen (per screen image). Every byte location of the screen contains color codes for two dots. This is bitmap graphics mode, and there's no pattern generator table.
1410
+
1411
+ ```
1412
+ +--------------------------------------------------------+
1413
+ | Columns |
1414
+ +-------+-------+-------+-------+-----+-----+-------+----+
1415
+ | 0 | 1 | 2 | 3 | ··· | ··· | 255 | ←X |
1416
+ +---+-----+-------+-------+-------+-------+-----+-----+-------+----+
1417
+ | | 0 | 0,0 1,0 2,0 3,0 ··· ··· 255,0 |
1418
+ | | 1 | 0,1 1,1 2,1 3,1 ··· ··· 255,1 |
1419
+ | R | ··· | ··· ··· ··· ··· ··· ··· ··· |
1420
+ | o | 191 | 0,191 1,191 2,191 3,191 ··· ··· 255,191| LN=0
1421
+ | w | ··· | ··· ··· ··· ··· ··· ··· ··· |
1422
+ | s | 211 | 0,211 1,211 2,211 3,211 ··· ··· 255,211| LN=1
1423
+ | +-----+---------------------------------------------------+
1424
+ | | Y↑ |
1425
+ +---+-----+
1426
+ ```
1427
+
1428
+ ```
1429
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1430
+ +--------------------------+--------------------------+ Base address
1431
+ 0 | Color code for (0,0) | Color code for (1,0) |
1432
+ 1 | Color code for (2,0) | Color code for (3,0) |
1433
+ : : :
1434
+ 127 | Color code for (254,0) | Color code for (255,0) |
1435
+ 128 | Color code for (0,1) | Color code for (1,1) |
1436
+ : : :
1437
+ 27134| Color code for (252,211) | Color code for (253,211) |
1438
+ 27135| Color code for (254,211) | Color code for (255,211) |
1439
+ +--------------------------+--------------------------+
1440
+ ```
1441
+
1442
+ Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) in the picture above.
1443
+
1444
+ ```
1445
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1446
+ +-----+-----+-----+-----+-----+-----+-----+-----+ Pattern layout
1447
+ R#2 | 0 | A16 | A15 | 1 | 1 | 1 | 1 | 1 | table base
1448
+ +-----+-----+-----+-----+-----+-----+-----+-----+ address
1449
+ ```
1450
+
1451
+ #### Color register settings
1452
+
1453
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1454
+
1455
+ #### Sprite settings
1456
+
1457
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 2".
1458
+
1459
+ ```
1460
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1461
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1462
+ R#5 | A14 | A13 | A12 | A11 | A10 | 1 | 1 | 1 | Sprite attribute table low
1463
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1464
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high
1465
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1466
+ R#6 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Sprite pattern generator table
1467
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1468
+ ```
1469
+
1470
+ #### Example of VRAM allocation for GRAPHIC4 mode
1471
+
1472
+ ```
1473
+ 00000h +-------------------+
1474
+ | Pattern name |
1475
+ | table |
1476
+ 02000h +-------------------+
1477
+ | |
1478
+ | |
1479
+ 04000h +-------------------+
1480
+ | |
1481
+ | 192 lines | / +-------------------------------+ 07000h
1482
+ 06000h + - - - - - - - - - + / | Sprite pattern table |
1483
+ | 212 lines | / +-------------------------------+ 07800h
1484
+ 06A00h +-------------------+ / | Sprite color table |
1485
+ | | / +-------------------------------+ 07A00h
1486
+ 07000h +-------------------+/ | Sprite attribute table |
1487
+ | | +-------------------------------+ 07A80h
1488
+ | | : :
1489
+ 08000h +-------------------+------ +-------------------------------+ 08000h
1490
+ : :
1491
+ : : 4 pages may be allocated in
1492
+ : : the same manner if VDP has
1493
+ 1FFFFh +-------------------+ 128KB attached to it.
1494
+ ```
1495
+
1496
+ ### GRAPHIC5 (G5) mode
1497
+
1498
+ | Characteristics ||
1499
+ |---|---|
1500
+ | Bit-mapped Graphics mode ||
1501
+ | Screen size (w\*h) | 512 \* 192 pixels if LN bit of R#9 set to 0<br>512 \* 212 pixels if LN bit of R#9 set to 1 |
1502
+ | Pattern colors | 4 colors out of 512 (per screen) |
1503
+ | Sprite mode | Sprite mode 2 |
1504
+ | VRAM area per screen | 32K bytes |
1505
+
1506
+ | Controls ||
1507
+ |---|---|
1508
+ | Graphics | VRAM pattern name table |
1509
+ | Background color code | Low-order four bits of R#7 |
1510
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1511
+
1512
+ | Mode flags ||||||
1513
+ |---|:-:|:-:|:-:|:-:|:-:|
1514
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1515
+ | Value |1|0|0|0|0|
1516
+
1517
+ | MSX system default values |||||
1518
+ |---|---|---|---|---|
1519
+ | BASIC SCREEN number | Pattern layout<br>(bitmap) | Sprite patterns | Sprite attributes | Sprite colors |
1520
+ | 6 | 00000h..069FFh | 07800h..07FFFh | 07600h..0767Fh | 07400h..075FFh |
1521
+
1522
+ #### Pattern layout table settings
1523
+
1524
+ The pattern layout table is a map of the screen (per screen image). Every byte
1525
+ location of the screen contains color codes for four dots. This is bitmap graphics mode, and there's no pattern generator table.
1526
+
1527
+ ```
1528
+ +--------------------------------------------------------+
1529
+ | Columns |
1530
+ +-------+-------+-------+-------+-----+-----+-------+----+
1531
+ | 0 | 1 | 2 | 3 | ··· | ··· | 511 | ←X |
1532
+ +---+-----+-------+-------+-------+-------+-----+-----+-------+----+
1533
+ | | 0 | 0,0 1,0 2,0 3,0 ··· ··· 511,0 |
1534
+ | | 1 | 0,1 1,1 2,1 3,1 ··· ··· 511,1 |
1535
+ | R | ··· | ··· ··· ··· ··· ··· ··· ··· |
1536
+ | o | 191 | 0,191 1,191 2,191 3,191 ··· ··· 511,191| LN=0
1537
+ | w | ··· | ··· ··· ··· ··· ··· ··· ··· |
1538
+ | s | 211 | 0,211 1,211 2,211 3,211 ··· ··· 511,211| LN=1
1539
+ | +-----+---------------------------------------------------+
1540
+ | | Y↑ |
1541
+ +---+-----+
1542
+ ```
1543
+
1544
+ ```
1545
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1546
+ +----------------------+----------------------+----------------------+----------------------+ Base address
1547
+ 0 | Color code (0,0) | Color code (1,0) | Color code (2,0) | Color code (3,0) |
1548
+ 1 | Color code (4,0) | Color code (5,0) | Color code (6,0) | Color code (7,0) |
1549
+ : : : : :
1550
+ 127 | Color code (508,0) | Color code (509,0) | Color code (510,0) | Color code (511,0) |
1551
+ 128 | Color code (0,1) | Color code (1,1) | Color code (2,1) | Color code (3,1) |
1552
+ : : : : :
1553
+ 27135| Color code (508,211) | Color code (509,211) | Color code (510,211) | Color code (511,211) |
1554
+ +----------------------+----------------------+----------------------+----------------------+
1555
+ ```
1556
+
1557
+ Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) in the picture above.
1558
+
1559
+ ```
1560
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1561
+ +-----+-----+-----+-----+-----+-----+-----+-----+ Pattern layout
1562
+ R#2 | 0 | A16 | A15 | 1 | 1 | 1 | 1 | 1 | table base
1563
+ +-----+-----+-----+-----+-----+-----+-----+-----+ address
1564
+ ```
1565
+
1566
+ #### Color register settings
1567
+
1568
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1569
+
1570
+ #### Sprite settings
1571
+
1572
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 2"
1573
+
1574
+ ```
1575
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1576
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1577
+ R#5 | A14 | A13 | A12 | A11 | A10 | 1 | 1 | 1 | Sprite attribute table low
1578
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1579
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high
1580
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1581
+ R#6 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Sprite pattern generator table
1582
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1583
+ ```
1584
+
1585
+ #### Hardware tiling function
1586
+
1587
+ VDP can only display 4 solid colors in G5 mode however pixels are so small that combination of two pixels from the set of those 4 solid colors possible produces another visible color, a mixture of the applied two.
1588
+
1589
+ This feature is only available in G5 mode, and is applied to the sprites and to the screen border color. G5 has 512 pixels in its X-axis, but sprites' X-coordinate is between 0 and 255. This means that for single sprite dot there're two font pattern dots, and from forn pattern point of view sprite of 8\*8 has size of 16\*8.
1590
+
1591
+ SM2 sprite color table uses 4 bits for each line of sprite. For every dot in sprite pattern table defined as "1" in sprite image bitmap, lower two bits from this 4-bit set define color of odd pixels of the sprite, and higher two bits from this set define color of even pixels of the sprite.
1592
+
1593
+ In the example above imagine that palette color 1 is set to red (█ 7, 0, 0) and color 3
1594
+ set to blue (░ 0, 0, 7).
1595
+
1596
+ ```
1597
+ Sprite representation
1598
+ Sprite pattern 8*8 in G5 mode (8*8)
1599
+ 7 6 5 4 3 2 1 0 0011223344556677
1600
+ +---------------+ +----------------+
1601
+ | █ █ | | █░█░ |
1602
+ | █ █ █ █ █ █ | | █░█░█░█░█░█░ |
1603
+ |█ █ █ █ █ █| |█░█░█░ █░█░█░|
1604
+ |█ █ █ █ █ █| |█░█░ █░█░ █░█░|
1605
+ |█ █ █ █ █ █| |█░█░ █░█░ █░█░|
1606
+ |█ █ █ █ █ █| |█░█░█░ █░█░█░|
1607
+ | █ █ █ █ █ █ | | █░█░█░█░█░█░ |
1608
+ | █ █ | | █░█░ |
1609
+ +---------------+ +----------------+
1610
+
1611
+ Sprite colors How sprite is perceived
1612
+ 7 6 5 4 3 2 1 0 by the user (pink)
1613
+ +-----------------+ +----------------+
1614
+ |X X X 0 0 1 1 1| | ▓▓▓▓ |
1615
+ |X X X 0 0 1 1 1| | ▓▓▓▓▓▓▓▓▓▓▓▓ |
1616
+ |X X X 0 0 1 1 1| |▓▓▓▓▓▓ ▓▓▓▓▓▓|
1617
+ |X X X 0 0 1 1 1| |▓▓▓▓ ▓▓▓▓ ▓▓▓▓|
1618
+ |X X X 0 0 1 1 1| |▓▓▓▓ ▓▓▓▓ ▓▓▓▓|
1619
+ |X X X 0 0 1 1 1| |▓▓▓▓▓▓ ▓▓▓▓▓▓|
1620
+ |X X X 0 0 1 1 1| | ▓▓▓▓▓▓▓▓▓▓▓▓ |
1621
+ |X X X 0 0 1 1 1| | ▓▓▓▓ |
1622
+ +-----------------+ +----------------+
1623
+ ```
1624
+
1625
+ #### Example of VRAM allocation for GRAPHIC5 mode
1626
+
1627
+ ```
1628
+ 00000h +-------------------+
1629
+ | Pattern name |
1630
+ | table |
1631
+ 02000h +-------------------+
1632
+ | |
1633
+ | |
1634
+ 04000h +-------------------+
1635
+ | |
1636
+ | 192 lines | / +-------------------------------+ 07000h
1637
+ 06000h + - - - - - - - - - + / | Sprite pattern table |
1638
+ | 212 lines | / +-------------------------------+ 07800h
1639
+ 06A00h +-------------------+ / | Sprite color table |
1640
+ | | / +-------------------------------+ 07A00h
1641
+ 07000h +-------------------+/ | Sprite attribute table |
1642
+ | | +-------------------------------+ 07A80h
1643
+ | | : :
1644
+ 08000h +-------------------+------ +-------------------------------+ 08000h
1645
+ : :
1646
+ : : 4 pages may be allocated in
1647
+ : : the same manner if VDP has
1648
+ 1FFFFh +-------------------+ 128KB attached to it.
1649
+ ```
1650
+
1651
+ ### GRAPHIC6 (G6) mode
1652
+
1653
+ | Characteristics ||
1654
+ |---|---|
1655
+ | Bit-mapped Graphics mode ||
1656
+ | Screen size (w\*h) | 512 \* 192 pixels if LN bit of R#9 set to 0<br>512 \* 212 pixels if LN bit of R#9 set to 1 |
1657
+ | Pattern colors | 16 colors out of 512 (per screen) |
1658
+ | Sprite mode | Sprite mode 2 |
1659
+ | VRAM area per screen | 64K bytes |
1660
+
1661
+ | Controls ||
1662
+ |---|---|
1663
+ | Graphics | VRAM pattern name table |
1664
+ | Background color code | Low-order four bits of R#7 |
1665
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1666
+
1667
+ | Mode flags ||||||
1668
+ |---|:-:|:-:|:-:|:-:|:-:|
1669
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1670
+ | Value |1|0|1|0|0|
1671
+
1672
+ | MSX system default values ||||||
1673
+ |---|---|---|---|---|---|
1674
+ | BASIC SCREEN number | Pattern layout<br>(bitmap) | Sprite patterns | Sprite attributes | Sprite colors |
1675
+ | 7 | 00000h..0D3FFh | 0F000h..0F7FFh | 0FA00h..0FA7Fh | 0F800h..0F9FFh |
1676
+
1677
+ #### Pattern layout table settings
1678
+
1679
+ The pattern layout table is a map of the screen (per screen image). Every byte
1680
+ location of the screen contains color codes for two dots. This is bitmap graphics mode, and there's no pattern generator table.
1681
+
1682
+ ```
1683
+ +--------------------------------------------------------+
1684
+ | Columns |
1685
+ +-------+-------+-------+-------+-----+-----+-------+----+
1686
+ | 0 | 1 | 2 | 3 | ··· | ··· | 511 | ←X |
1687
+ +---+-----+-------+-------+-------+-------+-----+-----+-------+----+
1688
+ | | 0 | 0,0 1,0 2,0 3,0 ··· ··· 511,0 |
1689
+ | | 1 | 0,1 1,1 2,1 3,1 ··· ··· 511,1 |
1690
+ | R | ··· | ··· ··· ··· ··· ··· ··· ··· |
1691
+ | o | 191 | 0,191 1,191 2,191 3,191 ··· ··· 511,191| LN=0
1692
+ | w | ··· | ··· ··· ··· ··· ··· ··· ··· |
1693
+ | s | 211 | 0,211 1,211 2,211 3,211 ··· ··· 511,211| LN=1
1694
+ | +-----+---------------------------------------------------+
1695
+ | | Y↑ |
1696
+ +---+-----+
1697
+ ```
1698
+
1699
+ ```
1700
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1701
+ +--------------------------+--------------------------+ Base address
1702
+ 0 | Color code for (0,0) | Color code for (1,0) |
1703
+ 1 | Color code for (2,0) | Color code for (3,0) |
1704
+ : : :
1705
+ 127 | Color code for (510,0) | Color code for (511,0) |
1706
+ 128 | Color code for (0,1) | Color code for (1,1) |
1707
+ : : :
1708
+ 54270| Color code for (508,211) | Color code for (509,211) |
1709
+ 54271| Color code for (510,211) | Color code for (511,211) |
1710
+ +--------------------------+--------------------------+
1711
+ ```
1712
+
1713
+ Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) in the picture above.
1714
+
1715
+ ```
1716
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1717
+ +-----+-----+-----+-----+-----+-----+-----+-----+ Pattern layout
1718
+ R#2 | 0 | A16 | 1 | 1 | 1 | 1 | 1 | 1 | table base
1719
+ +-----+-----+-----+-----+-----+-----+-----+-----+ address
1720
+ ```
1721
+
1722
+ #### Color register settings
1723
+
1724
+ You can set color of the margin of the screen (backdrop color) specifying BD3..BD0 bits in register R#7. Note that bits TC3..TC0 of R#7 are ignored.
1725
+
1726
+ #### Sprite settings
1727
+
1728
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 2"
1729
+
1730
+ ```
1731
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1732
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1733
+ R#5 | A14 | A13 | A12 | A11 | A10 | 1 | 1 | 1 | Sprite attribute table low
1734
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1735
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high
1736
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1737
+ R#6 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Sprite pattern generator table
1738
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1739
+ ```
1740
+
1741
+ #### Example of VRAM allocation for GRAPHIC4 mode
1742
+
1743
+ ```
1744
+ 00000h +-------------------+
1745
+ | Pattern name |
1746
+ | table |
1747
+ 04000h +-------------------+
1748
+ | |
1749
+ | |
1750
+ 08000h +-------------------+
1751
+ | |
1752
+ | 192 lines | / +-------------------------------+ 0F000h
1753
+ 0C000h + - - - - - - - - - + / | Sprite pattern table |
1754
+ | 212 lines | / +-------------------------------+ 0F800h
1755
+ 0D400h +-------------------+ / | Sprite color table |
1756
+ | | / +-------------------------------+ 0FA00h
1757
+ 0F000h +-------------------+/ | Sprite attribute table |
1758
+ | | +-------------------------------+ 0FA80h
1759
+ | | : :
1760
+ 10000h +-------------------+------ +-------------------------------+ 10000h
1761
+ : :
1762
+ : : 2 pages may be allocated in
1763
+ : : the same manner if VDP has
1764
+ 1FFFFh +-------------------+ 128KB attached to it.
1765
+ ```
1766
+
1767
+ ### GRAPHIC7 (G7) mode
1768
+
1769
+ | Characteristics ||
1770
+ |---|---|
1771
+ | Bit-mapped Graphics mode ||
1772
+ | Screen size (w\*h) | 256 \* 192 pixels if LN bit of R#9 set to 0<br>256 \* 212 pixels if LN bit of R#9 set to 1 |
1773
+ | Pattern colors | 256 colors (per screen) |
1774
+ | Sprite mode | Sprite mode 2 |
1775
+ | VRAM area per screen | 64K bytes |
1776
+
1777
+ | Controls ||
1778
+ |---|---|
1779
+ | Graphics | VRAM pattern name table |
1780
+ | Background color code | Low-order four bits of R#7 |
1781
+ | Sprites | VRAM sprite attribute table<br>VRAM sprite pattern table |
1782
+
1783
+ | Mode flags ||||||
1784
+ |---|:-:|:-:|:-:|:-:|:-:|
1785
+ | Bit | M5 (R#0) | M4 (R#0) | M3 (R#0) | M2 (R#1) | M1 (R#1) |
1786
+ | Value |1|1|1|0|0|
1787
+
1788
+ | MSX system default values |||||
1789
+ |---|---|---|---|---|
1790
+ | BASIC SCREEN number | Pattern layout<br>(bitmap) | Sprite patterns | Sprite attributes | Sprite colors |
1791
+ | 8 | 00000h..0D3FFh | 0F000h..0F7FFh | 0FA00h..0FA7Fh | 0F800h..0F9FFh |
1792
+
1793
+ #### Pattern layout table settings
1794
+
1795
+ The pattern layout table is a map of the screen (per screen image). Every byte location of the screen contains color code for one single dot. This is bitmap graphics mode, and there's no pattern generator table.
1796
+
1797
+ ```
1798
+ +--------------------------------------------------------+
1799
+ | Columns |
1800
+ +-------+-------+-------+-------+-----+-----+-------+----+
1801
+ | 0 | 1 | 2 | 3 | ··· | ··· | 255 | ←X |
1802
+ +---+-----+-------+-------+-------+-------+-----+-----+-------+----+
1803
+ | | 0 | 0,0 1,0 2,0 3,0 ··· ··· 255,0 |
1804
+ | | 1 | 0,1 1,1 2,1 3,1 ··· ··· 255,1 |
1805
+ | R | ··· | ··· ··· ··· ··· ··· ··· ··· |
1806
+ | o | 191 | 0,191 1,191 2,191 3,191 ··· ··· 255,191| LN=0
1807
+ | w | ··· | ··· ··· ··· ··· ··· ··· ··· |
1808
+ | s | 211 | 0,211 1,211 2,211 3,211 ··· ··· 255,211| LN=1
1809
+ | +-----+---------------------------------------------------+
1810
+ | | Y↑ |
1811
+ +---+-----+
1812
+ ```
1813
+
1814
+ ```
1815
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1816
+ +-----------+-----------+--------+ Base address
1817
+ 0 | Color code for (0,0) |
1818
+ 1 | Color code for (2,0) |
1819
+ : : : :
1820
+ :-----------+-----------+--------:
1821
+ : Green | Red | Blue :
1822
+ :-----------+-----------+--------:
1823
+ : : : :
1824
+ 255 | Color code for (255,0) |
1825
+ 256 | Color code for (0,1) |
1826
+ : : : :
1827
+ 54270| Color code for (254,211) |
1828
+ 54271| Color code for (255,211) |
1829
+ +-----------+-----------+--------+
1830
+ ```
1831
+
1832
+ Pattern layout table base address is stored in register R#2, and corresponds to the cell (0, 0) in the picture above.
1833
+
1834
+ ```
1835
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1836
+ +-----+-----+-----+-----+-----+-----+-----+-----+ Pattern layout
1837
+ R#2 | 0 | 0 | A16 | 1 | 1 | 1 | 1 | 1 | table base
1838
+ +-----+-----+-----+-----+-----+-----+-----+-----+ address
1839
+ ```
1840
+
1841
+ _**Note** that in G6 and G7 modes location of bit A16 differs._
1842
+
1843
+ #### Color register settings
1844
+
1845
+ You can set color of the margin of the screen (backdrop color) specifying all the 8 bits in register R#7 (256 possible colors in total).
1846
+
1847
+ ```
1848
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1849
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1850
+ R#7 | DB7 | DB6 | DB5 | DB4 | DB3 | DB2 | DB1 | DB0 | Screen margin color
1851
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1852
+ Screen margin / backdrop color
1853
+ ```
1854
+
1855
+ #### Sprite settings
1856
+
1857
+ Set the start address of the sprite attribute table in registers R#5 and R#11; set start address of the sprite pattern generator table in register R#6. For details about sprites please refer to section "Sprite mode 2"
1858
+
1859
+ ```
1860
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
1861
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1862
+ R#5 | A14 | A13 | A12 | A11 | A10 | 1 | 1 | 1 | Sprite attribute table low
1863
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1864
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high
1865
+ +=====+=====+=====+=====+=====+=====+=====+=====+
1866
+ R#6 | 0 | 0 | A16 | A15 | A14 | A13 | A12 | A11 | Sprite pattern generator table
1867
+ +-----+-----+-----+-----+-----+-----+-----+-----+
1868
+ ```
1869
+
1870
+ #### Example of VRAM allocation for GRAPHIC7 mode
1871
+
1872
+ ```
1873
+ 00000h +-------------------+
1874
+ | Pattern name |
1875
+ | table |
1876
+ 04000h +-------------------+
1877
+ | |
1878
+ | |
1879
+ 08000h +-------------------+
1880
+ | |
1881
+ | 192 lines | / +-------------------------------+ 0F000h
1882
+ 0C000h + - - - - - - - - - + / | Sprite pattern table |
1883
+ | 212 lines | / +-------------------------------+ 0F800h
1884
+ 0D400h +-------------------+ / | Sprite color table |
1885
+ | | / +-------------------------------+ 0FA00h
1886
+ 0F000h +-------------------+/ | Sprite attribute table |
1887
+ | | +-------------------------------+ 0FA80h
1888
+ | | : :
1889
+ 10000h +-------------------+------ +-------------------------------+ 10000h
1890
+ : :
1891
+ : : 2 pages may be allocated in
1892
+ : : the same manner if VDP has
1893
+ 1FFFFh +-------------------+ 128KB attached to it.
1894
+ ```
1895
+
1896
+ ## COMMANDS
1897
+
1898
+ ### Types of commands
1899
+
1900
+ Commands are used to perform specific complex operations on the video memory, and thus on the image displayed on the screen. See the list of available commands in the table below.
1901
+
1902
+ | Command name | Destination | Source | Unit | Mnemonic | CM3 | CM2 | CM1 | CM0 |
1903
+ |---|---|---|---|---|---|---|---|---|
1904
+ |High-speed move|VRAM|CPU|Byte|HMMC(*)|1|1|1|1|
1905
+ |High-speed move|VRAM|VRAM|Byte|YMMM(*)|1|1|1|0|
1906
+ |High-speed move|VRAM|VRAM|Byte|HMMM|1|1|0|1|
1907
+ |High-speed move|VRAM|VDP|Byte|HMMV|1|1|0|0|
1908
+ |Logical move|VRAM|CPU|Dot|LMMC|1|0|1|1|
1909
+ |Logical move|CPU|VRAM|Dot|LMCM|1|0|1|0|
1910
+ |Logical move|VRAM|VRAM|Dot|LMMM|1|0|0|1|
1911
+ |Logical move|VRAM|VDP|Dot|LMMV|1|0|0|0|
1912
+ |Line|VRAM|VDP|Dot|LINE|0|1|1|1|
1913
+ |Search|VRAM|VDP|Dot|SRCH|0|1|1|0|
1914
+ |Pset|VRAM|VDP|Dot|PSET|0|1|0|1|
1915
+ |Point|VDP|VRAM|Dot|POINT|0|1|0|0|
1916
+ |Invalid|||||0|0|1|1|
1917
+ |Invalid|||||0|0|1|0|
1918
+ |Invalid|||||0|0|0|1|
1919
+ |Stop||||STOP|0|0|0|0|
1920
+
1921
+ _(*) In G4 and G6 modes, the lower one bit, and in G5 mode, the lower two bits are lost in registers related to X-coordinate (DX, NX)._
1922
+
1923
+ The process of execution of VDP commands consists of several steps:
1924
+
1925
+ - Ensure that current mode is G4 - G7. In other modes result is not guaranteed.
1926
+ - Check the bit 0 (CE, command execution) flag in status register S#2 to be 0. If it's 1, then previous command is in progress and program needs to wait for completion or issue STOP command.
1927
+ - Set necessary parameters for command execution in registers R#32 to R#45 as necessary. It is easy to write whole the set of values to registers using indirect register addressing mode with auto-increment turned on.
1928
+ - Write command code to the R#46 (CMR, command register).
1929
+ - Wait till command execution is completed by checking bit 0 (CE) of S#2 to be 0.
1930
+ - If current command needs to be aborted, execute STOP command.
1931
+
1932
+ ### Page concept
1933
+
1934
+ As we have already seen, programmer can have several options to place tables in the video memory by altering base address registers. In some modes there're more options (like in Text 1 there're 32 options and in GRAPHICS7 there're only 2 options). This introduces a concept of the page defined by where VDP currently operates and where it takes information for picture display from. Page concept is stricter in relation to VDP ommands. VRAM access is defined by X and Y coordinates, and not by physical address within VRAM. Coordinate X is specified by 9 bits, and can be in range of 0..511, coordinate Y is specified by 10 bits, and can be in range of 0..1023. See the table below for VRAM paging in various video modes.
1935
+
1936
+ ```
1937
+ GRAPHIC4 Address GRAPHIC5
1938
+ +-------------------+ 00000h +-------------------+
1939
+ |(0,0) (255,0)| |(0,0) (511,0)|
1940
+ | Page 0 | | Page 0 |
1941
+ |(0,255) (255,255)| |(0,255) (511,255)|
1942
+ +-------------------+ 08000h +-------------------+
1943
+ |(0,256) (255,256)| |(0,256) (511,256)|
1944
+ | Page 1 | | Page 1 |
1945
+ |(0,511) (255,511)| |(0,511) (511,511)|
1946
+ +-------------------+ 10000h +-------------------+
1947
+ |(0,512) (255,512)| |(0,512) (511,512)|
1948
+ | Page 2 | | Page 2 |
1949
+ |(0,767) (255,767)| |(0,767) (511,767)|
1950
+ +-------------------+ 18000h +-------------------+
1951
+ |(0,768) (255,768)| |(0,768) (511,768)|
1952
+ | Page 3 | | Page 3 |
1953
+ |(0,1023) (255,1023)| |(0,1023) (511,1023)|
1954
+ +-------------------+ 1FFFFh +-------------------+
1955
+
1956
+ GRAPHIC7 Address GRAPHIC6
1957
+ +-------------------+ 00000h +-------------------+
1958
+ |(0,0) (255,0)| |(0,0) (511,0)|
1959
+ | Page 0 | | Page 0 |
1960
+ |(0,255) (255,255)| |(0,255) (511,255)|
1961
+ +-------------------+ 10000h +-------------------+
1962
+ |(0,256) (255,256)| |(0,256) (511,256)|
1963
+ | Page 1 | | Page 1 |
1964
+ |(0,511) (255,511)| |(0,511) (511,511)|
1965
+ +-------------------+ 1FFFFh +-------------------+
1966
+ ```
1967
+
1968
+ In G4 and G5 modes there're four pages; in G6 and G7 modes there're only two pages. For example, setting Y coordinate in G5 mode to 658 will automatically choose page #2 with specific translated initial VRAM address.
1969
+
1970
+ Note that VDP is capable of displaying maximum of 212 lines, and programmer has an option to use register R#23 to set visible screen window position within active page.
1971
+
1972
+ ### Logical operations
1973
+
1974
+ When executing logical commands LINE, PSET and LOGICAL MOVE, it is possible to define logical operation to be done on the color of the pixels. The four bits identifying the logical operation should be written in lower four bits of R#46 (command register) together with the command code.
1975
+
1976
+ | Name | Operation | LO3 | LO2 | LO1 | LO0 |
1977
+ |---|---|---|---|---|---|
1978
+ |IMP|DC=SC|0|0|0|0|
1979
+ |AND|DC=SC&DC|0|0|0|1|
1980
+ |OR|DC=SC|DC|0|0|1|0|
1981
+ |XOR|DC=SC^DC|0|0|1|1|
1982
+ |NOT|DC=!SC|0|1|0|0|
1983
+ |Invalid||0|1|0|1|
1984
+ |Invalid||0|1|1|0|
1985
+ |Invalid||0|1|1|1|
1986
+ |TIMP|If SC=0 then DC=DC<br>else DC=SC|1|0|0|0|
1987
+ |TAND|If SC=0 then DC=DC<br>else DC=SC&DC|1|0|0|1|
1988
+ |TOR|If SC=0 then DC=DC<br>else DC=SC\|DC|1|0|1|0|
1989
+ |TXOR|If SC=0 then DC=DC<br>else DC=SC^DC|1|0|1|1|
1990
+ |TNOT|If SC=0 then DC=DC<br>else DC=!SC|1|1|0|0|
1991
+ |Invalid||1|1|0|1|
1992
+ |Invalid||1|1|1|0|
1993
+ |Invalid||1|1|1|1|
1994
+
1995
+ _*SC = source color code._
1996
+ _*DC = destination color code._
1997
+
1998
+ ### Explanation of the commands
1999
+
2000
+ #### HMMC (High speed move CPU to VRAM)
2001
+
2002
+ HMMC command is used to transfer data from the CPU to video or expansion RAM into a specified rectangular area through VDP. When using this command, note the limitation on the X coordinate in various modes (255 or 511).
2003
+
2004
+ ```
2005
+ Video or expansion RAM
2006
+ +-------------------------+
2007
+ | (DX,DY) |
2008
+ | +-----------+ |
2009
+ +-----+ +-----+ | | NX | |
2010
+ | CPU | ---> | VDP | --------> |NY |→ DIX |
2011
+ +-----+ +-----+ | | | |
2012
+ | +-----------+ |
2013
+ | ↓ DIY |
2014
+ +-------------------------+
2015
+ ```
2016
+
2017
+ ##### HMMC execution order
2018
+
2019
+ **Step 1:** Set necessary coordinates in command registers.
2020
+
2021
+ ```
2022
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2023
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2024
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX(*): Destination X
2025
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2026
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2027
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2028
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination Y
2029
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2030
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2031
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2032
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX(*): Number of dots in X-axis
2033
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2034
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2035
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2036
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2037
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2038
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2039
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2040
+ ```
2041
+
2042
+ _(*)_ In G4 and G6 modes, the lower one bit, and in G5 mode, the lower two bits are lost in registers related to X-coordinate (DX, NX).
2043
+
2044
+ **Step 2:** Set color register value
2045
+
2046
+ The first byte transferred from CPU after starting executing the HMMC command should be located in color register R#44 (CLR). Format of color data depends on the graphics mode.
2047
+
2048
+ ```
2049
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2050
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2051
+ R#44 | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G4, G6 (N=0..127)
2052
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2053
+ X=2N X=2N+1
2054
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2055
+ | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G5 (N=0...127)
2056
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2057
+ X=4N X=4N+1 X=4N+2 X=4N+3
2058
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2059
+ | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G7
2060
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2061
+ X=N (One dot)
2062
+ ```
2063
+
2064
+ **Step 3:** Select destination memory and direction from base coordinate
2065
+
2066
+ ```
2067
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2068
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2069
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | - |
2070
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2071
+ | | |
2072
+ | | +---> X direction: 0:Right 1:Left
2073
+ | +---------> Y direction: 0:Down 1:Up
2074
+ +---------------------> Memory type: 0:VRAM 1:ExpRAM
2075
+ ```
2076
+
2077
+ **Step 4:** Execute the command
2078
+
2079
+ ```
2080
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2081
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2082
+ R#46 | 1 | 1 | 1 | 1 | - | - | - | - | HMMC cmd
2083
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2084
+ ```
2085
+
2086
+ **Step 5:** Send data and wait for completion
2087
+
2088
+ While command is being executed by VDP, CE bit of status register S#2 will be set to 1. When command is complete, it will be reset to 0.
2089
+
2090
+ When VDP sets TR bit of status register S#2 to "1" application can send next data to the VDP color register R#44 (CLR). If TR bit is 0, then appl ication should not send data and wait till TR bit is set to 1 or terminate the command if needed.
2091
+
2092
+ ##### Flowchart of HMMC execution from CPU point of view
2093
+
2094
+ ```
2095
+ ( HMMC )
2096
+ |
2097
+ V
2098
+ [Set up VDP registers]
2099
+ |
2100
+ V
2101
+ [Execute command]
2102
+ |
2103
+ V
2104
+ +---->[Read status S#2]
2105
+ | |
2106
+ | V Yes(CE=0)
2107
+ | {End of command?}------+
2108
+ | | No(CE=1) |
2109
+ | No(TR=0) V |
2110
+ |<----{Transmit ready?} |
2111
+ | | Yes(TR=1) |
2112
+ | V |
2113
+ +---[Data transmit R#44] |
2114
+ |
2115
+ (HMMC End)<---------+
2116
+ ```
2117
+
2118
+ #### YMMM (High speed move VRAM to VRAM, Y coordinate only)
2119
+
2120
+ YMMM command is used to transfer data from the area specified by DX, SY, NY, DIX, DIY and the right (or left) edge of the screen, in the Y-direction determined by DY.
2121
+
2122
+ ```
2123
+ Video or expansion RAM
2124
+ +-------------------------+
2125
+ | |
2126
+ | (DX,DY)+-----------+
2127
+ | | | → DIX
2128
+ | +-----------+
2129
+ | ↑ ↑ ↑ ↑ |
2130
+ | (DX,SY)+-----------+
2131
+ | |NY |
2132
+ +-------------+-----------+
2133
+ ↓ DIY
2134
+ ```
2135
+
2136
+ ##### YMMM execution order
2137
+
2138
+ **Step 1:** Set necessary coordinates in command registers.
2139
+
2140
+ ```
2141
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2142
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2143
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Source transfer point Y
2144
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2145
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
2146
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2147
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX(*): Source transfer point X
2148
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2149
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2150
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2151
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination transfer point Y
2152
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2153
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2154
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2155
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2156
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2157
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2158
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2159
+ ```
2160
+
2161
+ _(*) In G4 and G6 modes, the lower one bit, and in G5 mode, the lower two bits are lost in registers related to X-coordinate (DX, NX)._
2162
+
2163
+ **Step 2:** Select destination memory and direction from base coordinate
2164
+
2165
+ ```
2166
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2167
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2168
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | - |
2169
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2170
+ | | |
2171
+ | | +---> X direction: 0:Right 1:Left
2172
+ | +---------> Y direction: 0:Down 1:Up
2173
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2174
+ ```
2175
+
2176
+ **Step 3:** Execute the command
2177
+
2178
+ ```
2179
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2180
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2181
+ R#46 | 1 | 1 | 1 | 0 | - | - | - | - | YMMM cmd
2182
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2183
+ ```
2184
+
2185
+ **Step 4:** Wait for command execution completion
2186
+
2187
+ While command is being executed by VDP, CE bit of status register S#2 will be set to 1. When command is complete, it will be reset to 0.
2188
+
2189
+ #### HMMM (High speed move VRAM to VRAM)
2190
+
2191
+ HMMM command is used to transfer data from one specific rectangular area in VRAM of expansion RAM to another area within VRAM of expansion RAM. Note the limitation on the X coordinate, which is dependent on the current graphics mode (255 or 511).
2192
+
2193
+ ```
2194
+ Video or expansion RAM
2195
+ +-------------------------+
2196
+ | NX |
2197
+ |(SX,SY)+-----+ |
2198
+ | NY| |------+ |
2199
+ | +-----+ V | → DIX
2200
+ | (DX,DY)+-----+ |
2201
+ | | | |
2202
+ | +-----+ |
2203
+ +-------------------------+
2204
+ ↓ DIY
2205
+ ```
2206
+
2207
+ ##### HMMM execution order
2208
+
2209
+ **Step 1:** Set necessary coordinates in command registers
2210
+
2211
+ ```
2212
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2213
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2214
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | SX(*): Source transfer point X
2215
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2216
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 |
2217
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2218
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Source transfer point Y
2219
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2220
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
2221
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2222
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX(*):Destination transfer point X
2223
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2224
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2225
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2226
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination transfer point Y
2227
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2228
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2229
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2230
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX(*): Number of dots in x-axis
2231
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2232
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2233
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2234
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2235
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2236
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2237
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2238
+ ```
2239
+
2240
+ _(*) In G4 and G6 modes, the lower one bit, and in G5 mode, the lower two bits are lost in registers related to X-coordinate (DX, NX)._
2241
+
2242
+ **Step 2:** Select destination memory and direction from base coordinate
2243
+
2244
+ ```
2245
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2246
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2247
+ R#45 | 0 | - | MXD | MXS | DIY | DIX | - | - |
2248
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2249
+ | | | |
2250
+ | | | +---> X direction: 0:Right 1:Left
2251
+ | | +---------> Y direction: 0:Down 1:Up
2252
+ | +---------------> Source type: 0:VRAM 1:ExpRAM
2253
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2254
+ ```
2255
+
2256
+ **Step 3:** Execute the command
2257
+
2258
+ ```
2259
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2260
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2261
+ R#46 | 1 | 1 | 0 | 1 | - | - | - | - | HMMM cmd
2262
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2263
+ ```
2264
+
2265
+ **Step 4:** Wait for command execution completion
2266
+
2267
+ While command is being executed by VDP, CE bit of status register S#2 will be set to 1. When command is complete, it will be reset to 0.
2268
+
2269
+ #### HMMV (High speed move VDP to VRAM)
2270
+
2271
+ HMMV command is used to paint in a sp ecific rectangular area in the VRAM or expansion RAM. When using this command, note the limitation on the X coordinate in various modes (255 or 511).
2272
+
2273
+ ```
2274
+ Video or expansion RAM
2275
+ +-------------------------+
2276
+ | (DX,DY) |
2277
+ | +-----------+ |
2278
+ +-----+ | | NX | |
2279
+ | VDP | --------> |NY |→ DIX |
2280
+ +-----+ | | | |
2281
+ | +-----------+ |
2282
+ | ↓ DIY |
2283
+ +-------------------------+
2284
+ ```
2285
+
2286
+ ##### HMMV execution order
2287
+
2288
+ **Step 1:** Set necessary coordinates in command registers
2289
+
2290
+ ```
2291
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2292
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2293
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX(*): Destination X
2294
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2295
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2296
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2297
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination Y
2298
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2299
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2300
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2301
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX(*): Number of dots in X-axis
2302
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2303
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2304
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2305
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2306
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2307
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2308
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2309
+ ```
2310
+
2311
+ _(*) In G4 and G6 modes, the lower one bit, and in G5 mode, the lower two bits are lost in registers related to X-coordinate (DX, NX)._
2312
+
2313
+ **Step 2:** Set color register value
2314
+
2315
+ The first byte transferred from CPU after starting executing the HMMC command should be located in color register R#44 (CLR). Format of color data depends on the graphics mode.
2316
+
2317
+ ```
2318
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2319
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2320
+ R#44 | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G4, G6 (N=0..127)
2321
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2322
+ X=2N X=2N+1
2323
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2324
+ | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G5 (N=0...127)
2325
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2326
+ X=4N X=4N+1 X=4N+2 X=4N+3
2327
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2328
+ | CH3 | CH2 | CH1 | CH0 | CL3 | CL2 | CL1 | CL0 | G7
2329
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2330
+ X=N (One dot)
2331
+ ```
2332
+
2333
+ **Step 3:** Select destination memory and direction from base coordinate
2334
+
2335
+ ```
2336
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2337
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2338
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | - |
2339
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2340
+ | | |
2341
+ | | +---> X direction: 0:Right 1:Left
2342
+ | +---------> Y direction: 0:Down 1:Up
2343
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2344
+ ```
2345
+
2346
+ **Step 4:** Execute the command
2347
+
2348
+ ```
2349
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2350
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2351
+ R#46 | 1 | 1 | 0 | 0 | - | - | - | - | HMMV cmd
2352
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2353
+ ```
2354
+
2355
+ **Step 5:** Wait for command execution completion
2356
+
2357
+ While command is being executed by VDP, CE bit of status register S#2 will be set to 1. When command is complete, it will be reset to 0.
2358
+
2359
+ #### LMMC (Logical move CPU to VRAM)
2360
+
2361
+ LMMC command is used to transfer data from the CPU to video or expansion RAM into a specified rectangular area through VDP. The units used are dots.
2362
+
2363
+ ```
2364
+ Video or expansion RAM
2365
+ +-------------------------+
2366
+ | (DX,DY) |
2367
+ | +-----------+ |
2368
+ +-----+ +-----+ | | NX | |
2369
+ | CPU | ---> | VDP | --------> |NY |→ DIX |
2370
+ +-----+ +-----+ | | | |
2371
+ | +-----------+ |
2372
+ | ↓ DIY |
2373
+ +-------------------------+
2374
+ ```
2375
+
2376
+ ##### LMMC execution order
2377
+
2378
+ **Step 1:** Set necessary coordinates in command registers
2379
+
2380
+ ```
2381
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2382
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2383
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX: Destination X (0...511)
2384
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2385
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2386
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2387
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination Y (0...1023)
2388
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2389
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2390
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2391
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX: Number of dots in X-axis
2392
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2393
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2394
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2395
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2396
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2397
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2398
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2399
+ ```
2400
+
2401
+ **Step 2:** Set color register value
2402
+
2403
+ The first byte transferred from CPU after starting executing the LMMC command should be located in color register R#44 (CLR). Format of color data depends on the graphics mode.
2404
+
2405
+ ```
2406
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2407
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2408
+ R#44 | - | - | - | - | CR3 | CR2 | CR1 | CR0 | G4, G6
2409
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2410
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2411
+ | - | - | - | - | - | - | CR1 | CR0 | G5
2412
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2413
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2414
+ | CR7 | CR6 | CR5 | CR4 | CR3 | CR2 | CR1 | CR0 | G7
2415
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2416
+ ```
2417
+
2418
+ **Step 3:** Select destination memory and direction from base coordinate
2419
+
2420
+ ```
2421
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2422
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2423
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | - |
2424
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2425
+ | | |
2426
+ | | +---> X direction: 0:Right 1:Left
2427
+ | +---------> Y direction: 0:Down 1:Up
2428
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2429
+ ```
2430
+
2431
+ **Step 4:** Execute the LMMC command
2432
+
2433
+ ```
2434
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2435
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2436
+ R#46 | 1 | 0 | 1 | 1 | OP3 | OP2 | OP1 | OP0 | LMMC cmd
2437
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2438
+ Logical operation
2439
+ ```
2440
+
2441
+ **Step 5:** Send data and wait for completion
2442
+
2443
+ While command is being executed by VDP, CE bit of status register S#2 will be set to 1. When command is complete, it will be reset to 0.
2444
+
2445
+ When VDP sets TR bit of status register S#2 to "1" application can send next data to the VDP color register R#44 (CLR). If TR bit is 0, then appl ication should not send data and wait till TR bit is set to 1 or terminate the command if needed.
2446
+
2447
+ ##### Flowchart of LMMC execution from CPU point of view
2448
+
2449
+ ```
2450
+ ( LMMC )
2451
+ |
2452
+ V
2453
+ [Set up VDP registers]
2454
+ |
2455
+ V
2456
+ [Execute command]
2457
+ |
2458
+ V
2459
+ +---->[Read status S#2]
2460
+ | |
2461
+ | V Yes(CE=0)
2462
+ | {End of command?}------+
2463
+ | | No(CE=1) |
2464
+ | No(TR=0) V |
2465
+ |<----{Transmit ready?} |
2466
+ | | Yes(TR=1) |
2467
+ | V |
2468
+ +---[Data transmit R#44] |
2469
+ |
2470
+ (LMMC End)<---------+
2471
+ ```
2472
+
2473
+ #### LMCM (Logical move VRAM to CPU)
2474
+
2475
+ LMCM command is used to transfer data from the video or expansion RAM in a specified rectangular area to the CPU through VDP. The units used are dots.
2476
+
2477
+ ```
2478
+ Video or expansion RAM
2479
+ +-------------------------+
2480
+ | (SX,SY) |
2481
+ | +-----------+ |
2482
+ +-----+ +-----+ | | NX | |
2483
+ | CPU | <--- | VDP | <-------- |NY |→ DIX |
2484
+ +-----+ +-----+ | | | |
2485
+ | +-----------+ |
2486
+ | ↓ DIY |
2487
+ +-------------------------+
2488
+ ```
2489
+
2490
+ ##### LMCM execution order
2491
+
2492
+ **Step 1:** Set necessary coordinates in command registers
2493
+
2494
+ ```
2495
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2496
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2497
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | SX: Source X (0...511)
2498
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2499
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 |
2500
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2501
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Source Y (0...1023)
2502
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2503
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
2504
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2505
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX: Number of dots in X-axis
2506
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2507
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2508
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2509
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2510
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2511
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2512
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2513
+ ```
2514
+
2515
+ **Step 2:** Select source memory and direction from base coordinate
2516
+
2517
+ ```
2518
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2519
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2520
+ R#45 | 0 | - | - | MXS | DIY | DIX | - | - |
2521
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2522
+ | | |
2523
+ | | +---> X direction: 0:Right 1:Left
2524
+ | +---------> Y direction: 0:Down 1:Up
2525
+ +---------------> Source type: 0:VRAM 1:ExpRAM
2526
+ ```
2527
+
2528
+ **Step 3:** Clear the TR flag
2529
+
2530
+ Read the value from status register S#7. This step is required in order to clear the TR flag. Please refer to flowchart in this section for the LMCM command.
2531
+
2532
+ **Step 4:** Execute the LMCM command
2533
+
2534
+ ```
2535
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2536
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2537
+ R#46 | 1 | 0 | 1 | 0 | - | - | - | - | LMCM cmd
2538
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2539
+ ```
2540
+
2541
+ **Step 5:** Read dot color code and check command end
2542
+
2543
+ Use status register S#7 to get the color code of the dot. Format of color data depends on the graphics mode.
2544
+
2545
+ ```
2546
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2547
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2548
+ S#7 | - | - | - | - | C3 | C3 | C1 | C0 | G4, G6
2549
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2550
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2551
+ | - | - | - | - | - | - | C1 | C0 | G5
2552
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2553
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2554
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
2555
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2556
+ ```
2557
+
2558
+ Check CE bit of status register S#2 for command completion. CE set to 0 is the only sign of the completed LMCM command.
2559
+
2560
+ ##### Flowchart of LMCM execution from CPU point of view
2561
+
2562
+ ```
2563
+ ( LMCM )
2564
+ |
2565
+ V
2566
+ [Set up VDP registers*]
2567
+ |
2568
+ V
2569
+ [Execute command]
2570
+ |
2571
+ V
2572
+ +---->[Read status S#2]
2573
+ | |
2574
+ | V No(TR=0)
2575
+ | {Transmit ready?}------+
2576
+ | | Yes(TR=1) |
2577
+ | No(TR=0) V |
2578
+ | [Read status S#7] |
2579
+ | | |
2580
+ | No(CE=0) V |
2581
+ +-------{Command end?}<------+
2582
+ | Yes(CE=1)
2583
+ V
2584
+ (LMCM End)
2585
+ ```
2586
+ *TR must be cleared before command execution.
2587
+
2588
+ #### LMMM (Logical move VRAM to VRAM)
2589
+
2590
+ LMMM command is used to transfer data from one specific rectangular area in VRAM of expansion RAM to another area within VRAM of expansion RAM. The units used are dots
2591
+
2592
+ ```
2593
+ Video or expansion RAM
2594
+ +-------------------------+
2595
+ | NX |
2596
+ |(SX,SY)+-----+ |
2597
+ | NY| |------+ |
2598
+ | +-----+ V | → DIX
2599
+ | (DX,DY)+-----+ |
2600
+ | | | |
2601
+ | +-----+ |
2602
+ +-------------------------+
2603
+ ↓ DIY
2604
+ ```
2605
+
2606
+ ##### LMMM execution order
2607
+
2608
+ **Step 1:** Set necessary coordinates in command registers
2609
+
2610
+ ```
2611
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2612
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2613
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | SX: Source transfer point X
2614
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2615
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 |
2616
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2617
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Source transfer point Y
2618
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2619
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
2620
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2621
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX: Destination transfer point X
2622
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2623
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2624
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2625
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination transfer point Y
2626
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2627
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2628
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2629
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX: Number of dots in x-axis
2630
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2631
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2632
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2633
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2634
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2635
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2636
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2637
+ ```
2638
+
2639
+ **Step 2:** Select destination memory and direction from base coordinate
2640
+
2641
+ ```
2642
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2643
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2644
+ R#45 | 0 | - | MXD | MXS | DIY | DIX | - | - |
2645
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2646
+ | | | |
2647
+ | | | +---> X direction: 0:Right 1:Left
2648
+ | | +---------> Y direction: 0:Down 1:Up
2649
+ | +---------------> Source type: 0:VRAM 1:ExpRAM
2650
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2651
+ ```
2652
+
2653
+ **Step 3:** Define logical operation and execute the command
2654
+
2655
+ ```
2656
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2657
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2658
+ R#46 | 1 | 0 | 0 | 1 | OP3 | OP2 | OP1 | OP0 | LMMM cmd
2659
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2660
+ Logical operation
2661
+ ```
2662
+
2663
+ **Step 4:** Check for command completion
2664
+
2665
+ CPU should check CE bit of status register S#2 to identify if VDP has completed execution of the command. When command is being executed, CE bit is set to 1; when command is complete, CE bit will be reset to 0.
2666
+
2667
+ #### LMMV (Logical move VDP to VRAM)
2668
+
2669
+ LMMV command is used to paint in a sp ecific rectangular area in the VRAM or expansion RAM. The units used are dots.
2670
+
2671
+ ```
2672
+ Video or expansion RAM
2673
+ +-------------------------+
2674
+ | (DX,DY) |
2675
+ | +-----------+ |
2676
+ +-----+ | | NX | |
2677
+ | VDP | --------> |NY |→ DIX |
2678
+ +-----+ | | | |
2679
+ | +-----------+ |
2680
+ | ↓ DIY |
2681
+ +-------------------------+
2682
+ ```
2683
+
2684
+ ##### LMMV execution order
2685
+
2686
+ **Step 1:** Set necessary coordinates in command registers
2687
+
2688
+ ```
2689
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2690
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2691
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX: Destination X (dots)
2692
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2693
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2694
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2695
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Destination Y (dots)
2696
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2697
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2698
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2699
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | NX: Number of dots in X-axis
2700
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2701
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2702
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2703
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | NY: Number of dots in Y-axis
2704
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2705
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2706
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2707
+ ```
2708
+
2709
+ **Step 2:** Set color register value
2710
+
2711
+ The color code to use when painting an area should be located in color register R#44 (CLR). Format of color data depends on the graphics mode.
2712
+
2713
+ ```
2714
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2715
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2716
+ R#44 | - | - | - | - | C3 | C2 | C1 | C0 | G4, G6
2717
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2718
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2719
+ | - | - | - | - | - | - | C1 | C0 | G5
2720
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2721
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2722
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
2723
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2724
+ ```
2725
+
2726
+ **Step 3:** Select destination memory and direction from base coordinate
2727
+
2728
+ ```
2729
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2730
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2731
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | - |
2732
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2733
+ | | |
2734
+ | | +---> X direction: 0:Right 1:Left
2735
+ | +---------> Y direction: 0:Down 1:Up
2736
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2737
+ ```
2738
+
2739
+ **Step 4:** Execute the command
2740
+
2741
+ ```
2742
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2743
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2744
+ R#46 | 1 | 0 | 0 | 0 | - | - | - | - | LMMV cmd
2745
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2746
+ ```
2747
+
2748
+ **Step 5:** Check for command completion
2749
+
2750
+ CPU should check CE bit of status register S#2 to identify if VDP has completed execution of the command. When command is being executed, CE bit is set to 1; when command is complete, CE bit will be reset to 0.
2751
+
2752
+ #### LINE
2753
+
2754
+ LINE command is used to draw straight line in VRAM of expansion RAM. The line drawn is the hypotenuse of the triangle defined by the "long" and "short" sides. The distances are defined from the single starting point. Words "long" and "short" are used to identify respective sets of registers to use to define triangle's sides: long side is defined in registers R#40 and R#41 (by 10 bits MJ9..MJ0 with value in the range 0..1023) and short side is defined in registers R#42 and R#43 (by 9 bits MI8..MI0 with value in the range 0..511). The units used are dots.
2755
+
2756
+ ```
2757
+ Video or expansion RAM
2758
+ +-------------------------+
2759
+ | · |
2760
+ | · |
2761
+ | · Min | → DIX
2762
+ | · |
2763
+ | (DX,DY)· |
2764
+ | Maj |
2765
+ +-------------------------+
2766
+ ↑ DIY
2767
+ ```
2768
+
2769
+ **Step 1:** Set necessary coordinates in command registers
2770
+
2771
+ ```
2772
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2773
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2774
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX: Starting point X
2775
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2776
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2777
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2778
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Starting point Y
2779
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2780
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2781
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2782
+ R#40 | NX7 | NX6 | NX5 | NX4 | NX3 | NX2 | NX1 | NX0 | Maj (NX): long side dots num
2783
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2784
+ R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8 |
2785
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2786
+ R#42 | NY7 | NY6 | NY5 | NY4 | NY3 | NY2 | NY1 | NY0 | Min (NY): short side dots num
2787
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2788
+ R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9 | NY8 |
2789
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2790
+ ```
2791
+
2792
+ **Step 2:** Set color register value
2793
+
2794
+ Color of the resulting line mask is coded in color register R#44 (CLR). Format of color data depends on the graphics mode.
2795
+
2796
+ ```
2797
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2798
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2799
+ R#44 | - | - | - | - | C3 | C2 | C1 | C0 | G4, G6
2800
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2801
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2802
+ | - | - | - | - | - | - | C1 | C0 | G5
2803
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2804
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2805
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
2806
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2807
+ ```
2808
+
2809
+ **Step 3:** Select destination memory, direction from base coordinate and orientation
2810
+
2811
+ Bit MAJ of the register R#45 controls which coordinate is defined in registers R#40-R#43. If this bit is 0, then long side (NY) defines triangle's side by X-axis and short side (NX) defines triangle's side by Y-axis; if this bit is 1, then long side (NY) defines triangle's side by Y-axis and short side (NX) defines triangle's side by X-axis.
2812
+
2813
+ ```
2814
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2815
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2816
+ R#45 | 0 | - | MXD | - | DIY | DIX | - | MAJ |
2817
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2818
+ | | | |
2819
+ | | | v
2820
+ | | | Long/short axis definition: 0:LongX 1:LongY
2821
+ | | +---> X direction: 0:Right 1:Left
2822
+ | +---------> Y direction: 0:Down 1:Up
2823
+ +---------------------> Destination type: 0:VRAM 1:ExpRAM
2824
+ ```
2825
+
2826
+ **Step 4:** Define logical operation and execute the command
2827
+
2828
+ ```
2829
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2830
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2831
+ R#46 | 0 | 1 | 1 | 1 | LO3 | LO2 | LO1 | LO0 | LINE cmd
2832
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2833
+ Logical operation
2834
+ ```
2835
+
2836
+ **Step 5:** Check for command completion
2837
+
2838
+ CPU should check CE bit of status register S#2 to identify if VDP has completed execution of the command. When command is being executed, CE bit is set to 1; when command is complete, CE bit will be reset to 0.
2839
+
2840
+ #### SRCH
2841
+
2842
+ SRCH command is used to search for the specific color in VRAM of expansion RAM to the right or left of the starting point. The units used are dots.
2843
+
2844
+ ```
2845
+ Video or expansion RAM
2846
+ +-------------------------+
2847
+ | |
2848
+ | (SX,SY) DIX→ |
2849
+ | X----------------->X |
2850
+ | Border color |
2851
+ | point |
2852
+ | |
2853
+ +-------------------------+
2854
+ ```
2855
+
2856
+ **Step 1:** Set necessary coordinates in command registers
2857
+
2858
+ ```
2859
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2860
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2861
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | SX: Starting point X
2862
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2863
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 |
2864
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2865
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Starting point Y
2866
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2867
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
2868
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2869
+ ```
2870
+
2871
+ **Step 2:** Set color register value
2872
+
2873
+ Color to search for should be coded in color register R#44 (CLR). Format of color data depends on the graphics mode.
2874
+
2875
+ ```
2876
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2877
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2878
+ R#44 | - | - | - | - | C3 | C2 | C1 | C0 | G4, G6
2879
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2880
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2881
+ | - | - | - | - | - | - | C1 | C0 | G5
2882
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2883
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2884
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
2885
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2886
+ ```
2887
+
2888
+ **Step 3:** Select destination memory, direction from base coordinate and orientation
2889
+
2890
+ Bit EQ of the register R#45 controls search stop condition. If it is set to 1, then SRCH command terminates when color, equal to R#44 coded color, is found; if it is set to 0, then SRCH command terminates when any other than R#44 coded color is found.
2891
+
2892
+ ```
2893
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2894
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2895
+ R#45 | 0 | - | MXD | - | - | DIX | EQ | - |
2896
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2897
+ | | |
2898
+ | | +---> Stop condition: 0:NeqStop 1:EqStop
2899
+ | +---------> X search direction: 0:Right 1:Left
2900
+ +---------------------------> Destination type: 0:VRAM 1:ExpRAM
2901
+ ```
2902
+
2903
+ **Step 4:** Execute the command
2904
+
2905
+ ```
2906
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2907
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2908
+ R#46 | 0 | 1 | 1 | 0 | - | - | - | - | SRCH cmd
2909
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2910
+ ```
2911
+
2912
+ **Step 5:** Check for command termination or completion, and X-coordinate
2913
+
2914
+ Flag BD of the status register S#2 is se t if coded color in register R#44 was found, otherwise this bit is reset. Current value of the X-coordinate can be read from the status registers S#8 and S#9.
2915
+
2916
+ ```
2917
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2918
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2919
+ S#2 | - | - | - | BD | - | - | - | CE |
2920
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2921
+ | |
2922
+ | +---> Set to 0 at the end or
2923
+ | termination of the command.
2924
+ +---------------------------> Set to 1 if coded color is found
2925
+ ```
2926
+
2927
+ ```
2928
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2929
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2930
+ S#8 | BX7 | BX6 | BX5 | BX4 | BX3 | BX2 | BX1 | BX0 | Current X-coordinate
2931
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2932
+ S#9 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | BX8 |
2933
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2934
+ ```
2935
+
2936
+ ##### Flowchart of SRCH execution from CPU point of view
2937
+
2938
+ ```
2939
+ ( SRCH )
2940
+ |
2941
+ V
2942
+ [Set up VDP registers]
2943
+ |
2944
+ V
2945
+ [Execute command]
2946
+ |
2947
+ V
2948
+ [Read status S#2]<-----+
2949
+ | |
2950
+ V No(CE=1) |
2951
+ {End of command?}------+
2952
+ Yes(CE=0) |
2953
+ V No(BD=0)
2954
+ {Color found?}-------+
2955
+ Yes(BD=1) | |
2956
+ V |
2957
+ [Read status S#8 ans S#9] |
2958
+ | |
2959
+ V |
2960
+ (SRCH End)<---------+
2961
+ ```
2962
+
2963
+ #### PSET
2964
+
2965
+ PSET command is used to draw a dot in VRAM of expansion RAM. Programmer can select logical operation on the existing color of the dot in the specified location. The units used are dots.
2966
+
2967
+ ```
2968
+ Video or expansion RAM
2969
+ +-------------------------+
2970
+ | |
2971
+ | (DX,DY) |
2972
+ | X |
2973
+ | |
2974
+ | |
2975
+ | |
2976
+ +-------------------------+
2977
+ ```
2978
+
2979
+ ##### PSET execution order
2980
+
2981
+ **Step 1:** Set necessary coordinates in command registers
2982
+
2983
+ ```
2984
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
2985
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2986
+ R#36 | DX7 | DX6 | DX5 | DX4 | DX3 | DX2 | DX1 | DX0 | DX: Target point X
2987
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2988
+ R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8 |
2989
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2990
+ R#38 | DY7 | DY6 | DY5 | DY4 | DY3 | DY2 | DY1 | DY0 | DY: Target point Y
2991
+ +=====+=====+=====+=====+=====+=====+=====+=====+
2992
+ R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9 | DY8 |
2993
+ +-----+-----+-----+-----+-----+-----+-----+-----+
2994
+ ```
2995
+
2996
+ **Step 2:** Set color register value
2997
+
2998
+ Color of the dot should be coded in color register R#44 (CLR). Format of color data depends on the graphics mode. It is possible to do logical operation on the existing and new color of the defined dot through coding the code of logical operation in the CMR.
2999
+
3000
+ ```
3001
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3002
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3003
+ R#44 | - | - | - | - | C3 | C2 | C1 | C0 | G4, G6
3004
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3005
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3006
+ | - | - | - | - | - | - | C1 | C0 | G5
3007
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3008
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3009
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
3010
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3011
+ ```
3012
+
3013
+ **Step 3:** Select destination memory
3014
+
3015
+ ```
3016
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3017
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3018
+ R#45 | 0 | - | MXD | - | - | - | - | - |
3019
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3020
+ |
3021
+ +---------------------------> Destination type: 0:VRAM 1:ExpRAM
3022
+ ```
3023
+
3024
+ **Step 4:** Define logical operation and execute the command
3025
+
3026
+ ```
3027
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3028
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3029
+ R#46 | 0 | 1 | 0 | 1 | LO3 | LO2 | LO1 | LO0 | PSET cmd
3030
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3031
+ Logical operation
3032
+ ```
3033
+
3034
+ **Step 5:** Check for command completion
3035
+
3036
+ CPU should check CE bit of status register S#2 to identify if VDP has completed execution of the command. When command is being executed, CE bit is set to 1; when command is complete, CE bit will be reset to 0.
3037
+
3038
+ #### POINT
3039
+
3040
+ POINT command is used to read the color of the specified dot located in VRAM of expansion RAM. The units used are dots.
3041
+
3042
+ ```
3043
+ Video or expansion RAM
3044
+ +-------------------------+
3045
+ | |
3046
+ | (SX,SY) |
3047
+ | X |
3048
+ | |
3049
+ | |
3050
+ | |
3051
+ +-------------------------+
3052
+ ```
3053
+
3054
+ ##### POINT execution order
3055
+
3056
+ **Step 1:** Set necessary coordinates in command registers
3057
+
3058
+ ```
3059
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3060
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3061
+ R#32 | SX7 | SX6 | SX5 | SX4 | SX3 | SX2 | SX1 | SX0 | SX: Source point X
3062
+ +=====+=====+=====+=====+=====+=====+=====+=====+
3063
+ R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8 |
3064
+ +=====+=====+=====+=====+=====+=====+=====+=====+
3065
+ R#34 | SY7 | SY6 | SY5 | SY4 | SY3 | SY2 | SY1 | SY0 | SY: Source point Y
3066
+ +=====+=====+=====+=====+=====+=====+=====+=====+
3067
+ R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9 | SY8 |
3068
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3069
+ ```
3070
+
3071
+ **Step 2:** Select destination memory
3072
+
3073
+ ```
3074
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3075
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3076
+ R#45 | 0 | - | - | MXS | - | - | - | - |
3077
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3078
+ |
3079
+ +---------------------> Source type: 0:VRAM 1:ExpRAM
3080
+ ```
3081
+
3082
+ **Step 3:** Execute the command
3083
+
3084
+ ```
3085
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3086
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3087
+ R#46 | 0 | 1 | 0 | 0 | - | - | - | - | POINT cmd
3088
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3089
+ ```
3090
+
3091
+ **Step 4:** Check for command completion
3092
+
3093
+ CPU should check CE bit of status register S#2 to identify if VDP has completed execution of the command. When command is being executed, CE bit is set to 1; when command is complete, CE bit will be reset to 0. After completion of the command, source dot color code can be read from status register S#7. Note that format of the data in various graphics mode differs.
3094
+
3095
+ ```
3096
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3097
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3098
+ S#7 | - | - | - | - | C3 | C3 | C1 | C0 | G4, G6
3099
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3100
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3101
+ | - | - | - | - | - | - | C1 | C0 | G5
3102
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3103
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3104
+ | C7 | C6 | C5 | C4 | C3 | C2 | C1 | C0 | G7
3105
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3106
+ ```
3107
+
3108
+ ### Speeding up the processing of VDP commands
3109
+
3110
+ Programmer can use two methods to speed up VDP hardware acceleration commands. Use of both methods is related to decreasing VDP access to the VRAM and freeing available VRAM time slots for command execution.
3111
+ - **Disabling sprites:** setting register R#8 bit SPD to 1 disables sprite processing.
3112
+ - **Disabling screen display:** setting register R#1 bit BL to 0 will completely disable screen display freeing significant memory access time for command execution.
3113
+
3114
+ ### States of the registers after command execution
3115
+
3116
+ Setting up VDP registers for command execution is a significant task for programmer and CPU, and it will be wise to use already existing values in the registers for the next command execution or for further work with video memory. For this purpose programmer should know the resulting states of most important VDP registers. Please see the table below. Note that if program is going to use sequence of the VDP commands which use resulting values of registers from previous commands, it is important to disable interrupts so that interrupt handler routing would not accidentally change values in VDP registers and thus break the whole command sequence.
3117
+
3118
+ CMR H is a higher nibble of the command register R#46; CMR L is a lower nibble of the command register r#46. ARG is an argument register R#45.
3119
+
3120
+ The resulting values of SY*, DY* and NY* are in dots and can be calculated using equations below:
3121
+ - If DIY=0 then SY*=SY+N; DY*=DY+N
3122
+ - If DIY=1 then SY*=SY-N; DY*=DY-N
3123
+ - NY*=NY-N
3124
+ - (LINE command ==> if MAJ=0 then N=N-1)
3125
+
3126
+ ||SX|SY|DX|DY|NX|NY|CLR|CMR H|CMR L|ARG|
3127
+ |---|---|---|---|---|---|---|---|-----|-----|---|
3128
+ |HMMC|-|-|-|⏺|-|#|-|0|-|-|
3129
+ |YMMM|-|⏺|-|⏺|-|#|-|0|-|-|
3130
+ |HMMM|-|⏺|-|⏺|-|#|-|0|-|-|
3131
+ |HMMV|-|-|-|⏺|-|#|-|0|-|-|
3132
+ |LMMC|-|-|-|⏺|-|#|-|0|-|-|
3133
+ |LMCM|-|⏺|-|-|-|#|-|0|-|-|
3134
+ |LMMM|-|⏺|-|⏺|-|#|-|0|-|-|
3135
+ |LMMV|-|-|-|⏺|-|#|-|0|-|-|
3136
+ |LINE|-|-|-|⏺|-|-|-|0|-|-|
3137
+ |SRCH|-|-|-|-|-|-|-|0|-|-|
3138
+ |PSET|-|-|-|-|-|-|-|0|-|-|
3139
+ |POINT|-|-|-|-|-|-|⏺|0|-|-|
3140
+
3141
+ Legend:
3142
+ \- Unchanged
3143
+ ⏺ Coordinate at the command end (SY*, DY*) or color code
3144
+ \# Count (NY*) when the end of the screen was detected
3145
+
3146
+ ## SPRITES
3147
+
3148
+ MSX-VIDEO can display up to 32 sprites on the screen. Depending on the sprite mode, sprite sizes can be 8\*8 or 16\*16 dots. X-axis coordinate of sprite location is always between 0..255, and this means that in graphics modes with 512 dots on the X-axis single sprite's dot occupy two horizontal dots of the screen.
3149
+
3150
+ Sprites can be placed anywhere on the screen. Sprites are processed independently of and do not affect other graphics. They can be independently switched on or off.
3151
+
3152
+ The following diagram conceptually shows how sprites are displayed. Note that visible screen area may have 192 or 212 pixels depending on the setting of LN bit of register R#9, and visible screen area can be vertically scrolled using vertical offset register R#23.
3153
+
3154
+ ```
3155
+ (0,255*) (255,255*)
3156
+ +-------------------------+
3157
+ | (X,Y) |
3158
+ | +---+ |
3159
+ | | | +-··+
3160
+ | +---+ | :
3161
+ | Sprite +-··+
3162
+ | |
3163
+ | +---+ Visible area |
3164
+ +-: :-------------------+ (255,191) or (255,211)
3165
+ | +···+ Invisible area |
3166
+ | |
3167
+ +-------------------------+
3168
+ (0,254) (255,254)
3169
+ ```
3170
+ \* They Y-coordinate of the upper edge of the sprite screen is 255
3171
+
3172
+ The MSX-VIDEO can work in two sprite display modes. Respective mode is selected during initialization of the screen mode.
3173
+ - Sprite mode 1: GRAPHIC1, GRAPHIC2, MULTICOLOR
3174
+ - Sprite mode 2: GRAPHIC3 ... GRAPHIC7
3175
+
3176
+ Sprites are not available in TEXT1 and TEXT2 modes.
3177
+
3178
+ ### SPRITE MODE 1 (G1, G2, MC)
3179
+
3180
+ While there's a room for 256 sprite patterns in sprite pattern generator table, VDP is only capable of displaying 32 sprites (#0..#31) - limiting factor is sprite attribute table which can hold attributes for 32 active sprites only.
3181
+
3182
+ Up to 4 sprites can be displayed on a single horizontal line, and from the set of displayed sprites on this line, the sprites with higher priority will be displayed, and the overlapping portions of lower priority sprites will not be displayed. Lower sprite numbers are assigned higher priority, with #0 is of highest priority and #31 is of lowest priority.
3183
+
3184
+ ```
3185
+ +-------------------------------------------+
3186
+ | |
3187
+ | +---+ +---+ +---+ |
3188
+ | | 0 | +---+ +---+ | 3 | : 4 : + · + |
3189
+ | +---+ | 1 | | 2 | +---+ + · + : 5 : |
3190
+ | +---+ +---+ +---+ |
3191
+ | |
3192
+ +-------------------------------------------+
3193
+ ```
3194
+
3195
+ When two sprites collide (their pattern color 1 portions have overlapped), status register's S#0 bit 5 "C" is set to 1.
3196
+
3197
+ If there're more than 4 sprites on the single horizontal line, bit 6 of the status register S#0 "5S" is set to 1, and the lower order 5 bits of this status register S#0 will contain the number of the fifth sprite.
3198
+
3199
+ #### Global sprite attributes and tables (SM1)
3200
+
3201
+ Register R#1 contains two controls for sprites, allowing magnification and quadruple sprite pattern size.
3202
+
3203
+ ```
3204
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3205
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3206
+ R#1 | 0 | BL | IE0 | M1 | M2 | 0 | SI | MAG | Mode R#1
3207
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3208
+ | |
3209
+ | +--> Sprite magnification: 0:8*8 1:16*16
3210
+ +--------> Sprite size: 0:Normal 1:Double Sprite
3211
+ ```
3212
+
3213
+ Sprites are defined by two tables: sprite pattern generator table, which controls the appearance of the dots within the sprite (being on "1" or off "0") and sprite attribute table, which controls positioning, used pattern number and the sprite color.
3214
+
3215
+ #### Sprite attribute table (SM1)
3216
+
3217
+ The sprite attribute table is an area in the VRAM that defines display coordinates for all the possible 32 sprites, their colors, pattern numbers used for display and some other flags. Each sprite has four bytes of attribute data, making up 128 bytes (80h) of the memory.
3218
+
3219
+ ```
3220
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3221
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3222
+ 0 | Y-coordinate (0..255) | Attribute area
3223
+ +-----+-----+-----+-----+-----+-----+-----+-----+ for sprite #0
3224
+ 1 | X-coordinate (0..255) |
3225
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3226
+ 2 | Pattern number (0..255) |
3227
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3228
+ 3 | EC | - | - | - | Color code |
3229
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3230
+ : :
3231
+ : :
3232
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3233
+ 124 | Y-coordinate (0..255) | Attribute area
3234
+ +-----+-----+-----+-----+-----+-----+-----+-----+ for sprite #31
3235
+ 125 | X-coordinate (0..255) |
3236
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3237
+ 126 | Pattern number (0..255) |
3238
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3239
+ 127 | EC | - | - | - | Color code |
3240
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3241
+ ```
3242
+
3243
+ Y-coordinate defines the vertical position of the sprite. Note that if Y is equal to 208 (D0h), all lower priority sprites will not be displayed. It is important to know that when using vertical offset register R#23 to scroll the visible area of the screen, sprite with the Y-coordinate of 208 will not be displayed and in order to display sprite in this area on the scrolled screen programmer should use Y-coordinate equal to 207 or 209.
3244
+
3245
+ Pattern number specifies which pattern from sprite pattern generator table to use to display the sprite bitmap image. If 8\*8 dots sprite size is selected, there're 256 patterns available, but if 16\*16 dots sprite size is selected, there there're only 64 patterns available. In 16\*16 mode two lower-order bits of the pattern number are not used (and they can hold any value).
3246
+
3247
+ Color code specifies color for pattern color 1 (of the dots which are set to "1" in the sprite bitmap image). The dots which are set to "0" in the sprite bitmap image will appear transparent.
3248
+
3249
+ EC (Early clock) is used to offset sprite by 32 dots to the left. This feature is useful when programmer needs to put sprite to the left off the screen.
3250
+
3251
+ #### Sprite pattern generator table (SM1)
3252
+
3253
+ Sprite pattern generator table is an area in the VRAM specifying the sprite patterns (appearance). Base address of this table should be set in register R#6.
3254
+
3255
+ Eight bytes are used for each pattern, and whole table occupies 2048 bytes (800h) for all the 256 patterns possible. Each pattern is assigned the number, #0 to #255. If sprite size of 8\*8 is selected (SI=0) then each displayed sprite has one pattern; if sprite size of 16\*16 is selected (SI=1) then each sprite is comprised of four patterns.
3256
+
3257
+ ```
3258
+ LSB 7 6 5 4 3 2 1 0 MSB
3259
+ +---------------+
3260
+ (B) 0 | |
3261
+ 1 | |
3262
+ 2 | |
3263
+ 3 | | Bitmap for
3264
+ 4 | | pattern #0
3265
+ 5 | |
3266
+ 6 | |
3267
+ 7 | |
3268
+ +---------------+
3269
+ : :
3270
+ : :
3271
+ +---------------+
3272
+ 2040 | |
3273
+ 2041 | |
3274
+ 2042 | |
3275
+ 2043 | | Bitmap for
3276
+ 2044 | | pattern #255
3277
+ 2045 | |
3278
+ 2046 | |
3279
+ 2047 | |
3280
+ +---------------+
3281
+ ```
3282
+
3283
+ #### Example of the sprite pattern generator table
3284
+
3285
+ ```
3286
+ 8*8 sprite representation 16*16 sprite representation
3287
+ 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
3288
+ Offset +---------------+ +-------------------------------+
3289
+ 0 | █| P | █ █ |
3290
+ 1 | █ █ █| a | █ █ █ █ █ █ |
3291
+ 2 | █ █ █ █ █| t | █ █ █ █ █ █ █ █ █ █ |
3292
+ 3 | █ █ █ | t | █ █ █ █ █ █ |
3293
+ 4 | █ █ █| e | █ █ █ █ █ █ |
3294
+ 5 | █ █ █| r | █ █ █ █ █ █ |
3295
+ 6 | █ █ █ | n | █ █ █ █ █ █ |
3296
+ 7 | █ █ █ █ █| # | █ █ █ █ █ █ █ █ █ █ |
3297
+ +---------------+ 0 | █ █ █ █ █ █ █ █ █ █ █ █ |
3298
+ | █ █ █ █ █ █ █ █ █ █ █ █ █ █ |
3299
+ +---------------+ |█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █|
3300
+ 0 | █ █ █ █ █ █| P |█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █|
3301
+ 1 | █ █ █ █ █ █ █| a | █ █ █ █ █ █ █ █ |
3302
+ 2 |█ █ █ █ █ █ █ █| t | █ █ █ █ |
3303
+ 3 |█ █ █ █ █ █ █ █| t | |
3304
+ 4 | █ █ █ █ | e | |
3305
+ 5 | █ █ | r +-------------------------------+
3306
+ 6 | | n
3307
+ 7 | | # 16*16 sprite size mode pattern layout
3308
+ +---------------+ 1
3309
+ +--------+--------+
3310
+ +---------------+ | | |
3311
+ 0 |█ | P | #0 | #2 |
3312
+ 1 |█ █ █ | a | | |
3313
+ 2 |█ █ █ █ █ | t +--------+--------+
3314
+ 3 | █ █ █ | t | | |
3315
+ 4 |█ █ █ | e | #1 | #3 |
3316
+ 5 |█ █ █ | r | | |
3317
+ 6 | █ █ █ | n +--------+--------+
3318
+ 7 |█ █ █ █ █ | #
3319
+ +---------------+ 2
3320
+ Remember that in 16*16 sprite size
3321
+ +---------------+ mode two least significant bits of pattern
3322
+ 0 |█ █ █ █ █ █ | P number are not used, and setting sprite
3323
+ 1 |█ █ █ █ █ █ █ | a pattern number 3 will display the same
3324
+ 2 |█ █ █ █ █ █ █ █| t sprite image as setting sprite pattern
3325
+ 3 |█ █ █ █ █ █ █ █| t numbers 0, 1 and 2
3326
+ 4 | █ █ █ █ | e
3327
+ 5 | █ █ | r
3328
+ 6 | | n
3329
+ 7 | | #
3330
+ +---------------+ 3
3331
+ ```
3332
+
3333
+ ### SPRITE MODE 2 (G3 ... G7)
3334
+
3335
+ While there's a room for 256 sprite patterns in sprite pattern generator table, VDP is only capable of displaying 32 sprites (#0...#31) - limiting factor is sprite attribute table which can hold attributes for 32 active sprites only.
3336
+
3337
+ Up to 8 sprites can be displayed on a single horizontal line, and from the set of displayed sprites on this line, the sprites with higher priority will be displayed, and the overlapping portions of lower priority sprites will not be displayed. Lower sprite numbers are assigned higher priority, with #0 is of highest priority and #31 is of lowest priority.
3338
+
3339
+ ```
3340
+ +----------------------------------------------------------------+
3341
+ | |
3342
+ | +---+ +---+ +---+ +---+ +---+ |
3343
+ | | 0 | +---+ +---+ | 3 | | 4 | | 5 | +---+ | 7 | + · + |
3344
+ | +---+ | 1 | | 2 | +---+ +---+ +---+ | 6 | +---+ : 8 : |
3345
+ | +---+ +---+ +---+ +---+ |
3346
+ | |
3347
+ +----------------------------------------------------------------+
3348
+ ```
3349
+
3350
+ When two sprites collide (their solid "1" portions have overlapped), status register's S#0 bit 5 "C" is set to 1, and the coordinates of the collision can be read from status registers S#3..S#5.
3351
+
3352
+ If there're more than 8 sprites on the single horizontal line, bit 6 of the status register S#0 "5S" is set to 1, and the lower order 5 bits of this status register S#0 will contain the number of the ninth sprite.
3353
+
3354
+ The colors of the sprite are specified for each horizontal line.
3355
+
3356
+ The sprite priority may be cancelled by setting bit "CC" in the attribute table for specific line of the sprite, and if sprites overlap, logical "OR" will be done on the colors of the sprites. Therefore, while in sprite mode 1 sprites may only have two colors (color code 1 and transparent), in sprite mode 2 four colors may be displayed.
3357
+
3358
+ #### Global sprite attributes and tables (SM2)
3359
+
3360
+ Register R#1 contains two controls for sprites, allowing magnification and quadruple sprite pattern size. Register R#8 contains one control bit, "SPD", which allows disabling and enabling sprite display.
3361
+
3362
+ ```
3363
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3364
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3365
+ R#1 | 0 | BL | IE0 | M1 | M2 | 0 | SI | MAG |
3366
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3367
+ | |
3368
+ | +--> Sprite magnification: 0:8*8 1:16*16
3369
+ +--------> Sprite size: 0:Normal 1:Double Sprite
3370
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3371
+ R#8 | MS | LP | TP | CB | VR | 0 | SPD | BW |
3372
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3373
+ |
3374
+ +---> Sprite display control: 0:Enable 1:Disable
3375
+ ```
3376
+
3377
+ Sprites are defined by three tables: sprite pattern generator table, which controls the appearance of the dots within the sprite (being on "1" or off "0"), sprite color table, which control colors of the sprite lines and other attributes, and sprite attribute table, which controls positioning and used pattern number.
3378
+
3379
+ #### Sprite attribute table (SM2)
3380
+
3381
+ The sprite attribute table is an area in the VRAM that defines display coordinates for all the possible 32 sprites, pattern numbers used for display and some other flags. Each sprite has four bytes of attribute data, making up 128 bytes (80h) of the memory.
3382
+
3383
+ ```
3384
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3385
+ +----+----+----+----+----+----+----+----+
3386
+ 0 | Y-coordinate (0..255) | Attribute area
3387
+ +----+----+----+----+----+----+----+----+ for sprite #0
3388
+ 1 | X-coordinate (0..255) |
3389
+ +----+----+----+----+----+----+----+----+
3390
+ 2 | Pattern number (0..255) |
3391
+ +----+----+----+----+----+----+----+----+
3392
+ 3 | Reserved |
3393
+ +----+----+----+----+----+----+----+----+
3394
+ : :
3395
+ : :
3396
+ +----+----+----+----+----+----+----+----+
3397
+ 124 | Y-coordinate (0..255) | Attribute area
3398
+ +----+----+----+----+----+----+----+----+ for sprite #31
3399
+ 125 | X-coordinate (0..255) |
3400
+ +----+----+----+----+----+----+----+----+
3401
+ 126 | Pattern number (0..255) |
3402
+ +----+----+----+----+----+----+----+----+
3403
+ 127 | Reserved |
3404
+ +----+----+----+----+----+----+----+----+
3405
+ ```
3406
+
3407
+ Y-coordinate defines the vertical position of the sprite. Note that if Y is equal to 216 (D8h), all lower priority sprites will not be displayed. It is important to know that when using vertical offset register R#23 to scroll the visible area of the screen, sprite with the Y-coordinate of 216 will not be displayed and in order to display sprite in this area on the scrolled screen programmer should use Y=coordinate equal to 215 or 217.
3408
+
3409
+ Pattern number specifies which pattern from sprite pattern generator table to use to display the sprite bitmap image. If 8\*8 dots sprite size is selected, there're 256 patterns available, but if 16\*16 dots sprite size is selected, there there're only 64 patterns available. In 16\*16 mode two lower-order bits of the pattern number are not used (and they can hold any value).
3410
+
3411
+ Color code is not used in sprite mode 2, and the respective area in the table is
3412
+ reserved.
3413
+
3414
+ ```
3415
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3416
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3417
+ R#5 | A14 | A13 | A12 | A11 | A10 | 1 | X | X | Sprite attribute table low (SM2)
3418
+ +=====+=====+=====+=====+=====+=====+=====+=====+
3419
+ R#11 | 0 | 0 | 0 | 0 | 0 | 0 | A16 | A15 | Sprite attribute table high (SM2)
3420
+ +-----+-----+-----+-----+-----+-----+-----+-----+
3421
+ ```
3422
+
3423
+ #### Sprite pattern generator table (SM2)
3424
+
3425
+ Sprite pattern generator table is an area in the VRAM specifying the sprite patterns (appearance). Base address of this table should be set in register R#6.
3426
+
3427
+ Sprite pattern generator table is designed the same way as in SPRITE MODE 1 (SM1); please refer to respective section for the example. Eight bytes are used for each pattern, and whole table occupies 2048 bytes (800h) for all the 256 patterns possible. Each pattern is assigned the number, #0 to #255. If sprite size of 8\*8 is selected (SI=0) then each displayed sprite has one pattern; if sprite size of 16\*16 is selected (SI=1) then each sprite is comprised of four patterns.
3428
+
3429
+ ```
3430
+ LSB 7 6 5 4 3 2 1 0 MSB
3431
+ +---------------+
3432
+ (B) 0 | |
3433
+ 1 | |
3434
+ 2 | |
3435
+ 3 | | Bitmap for
3436
+ 4 | | pattern #0
3437
+ 5 | |
3438
+ 6 | |
3439
+ 7 | |
3440
+ +---------------+
3441
+ : :
3442
+ : :
3443
+ +---------------+
3444
+ 2040 | |
3445
+ 2041 | |
3446
+ 2042 | |
3447
+ 2043 | | Bitmap for
3448
+ 2044 | | pattern #255
3449
+ 2045 | |
3450
+ 2046 | |
3451
+ 2047 | |
3452
+ +---------------+
3453
+ ```
3454
+
3455
+ #### Sprite color table (SM2)
3456
+
3457
+ In SPRITE MODE 2 (SM2) the sprite color table specifies sprite colors for each sprite line. Note that sprite color 0 (i.e. the dots having "0" for them in sprite pattern generator table) is transparent unless TP bit of register R#8 is set. Each entry also defines sprite priority, collision detection, and early clock sprite display options.
3458
+
3459
+ The base address of the sprite color table is calculated using base address of the sprite attribute table: sprite color table is located "strictly above" the sprite attribute table, having base address of sprite attribute table minus 512 (200h).
3460
+
3461
+ Every sprite is assigned 16 color entries in the sprite color table. If 8\*8 sprite size mode is selected, only first 8 color bytes are used for every sprite, with another 8 being not used. If 16\*16 sprite size mode is selected, then all 16 color bytes are used.
3462
+
3463
+ ```
3464
+ MSB b7 b6 b5 b4 b3 b2 b1 b0 LSB
3465
+ +-----+-----+-----+-----+-----------------------+ \
3466
+ 0 | EC | CC | IC | 0 | Color code | Line 1 |
3467
+ +=====+=====+=====+=====+=======================+ |
3468
+ 1 | EC | CC | IC | 0 | Color code | Line 2 | Colors for
3469
+ +-----+-----+-----+-----+-----------------------+ | sprite #0
3470
+ : : |
3471
+ +-----+-----+-----+-----+-----------------------+ |
3472
+ 15 | EC | CC | IC | 0 | Color code | Line 16 |
3473
+ +-----+-----+-----+-----+-----------------------+ /
3474
+ : :
3475
+ +-----+-----+-----+-----+-----------------------+ \
3476
+ 496 | EC | CC | IC | 0 | Color code | Line 1 |
3477
+ +-----+-----+-----+-----+-----------------------+ | Colors for
3478
+ : : | sprite #31
3479
+ +-----+-----+-----+-----+-----------------------+ |
3480
+ 511 | EC | CC | IC | 0 | Color code | Line 16 |
3481
+ +-----+-----+-----+-----+-----------------------+ /
3482
+ | | | |
3483
+ | | | +---> Color code for each line (0..15)
3484
+ | | +---> Line collision detect: 0:Detect 1:NoDetect
3485
+ | +---------> Sprite priority control: 0:Enable 1:Disable
3486
+ +---------------> Shift left 32 dots: 0:NoShift 1:ShiftLeft
3487
+ ```
3488
+
3489
+ #### Priority mechanism and multicolored sprite combinations (SM2)
3490
+
3491
+ In sprite mode 2 (SM2), if the "CC" bit of the sprite color table entry is set to 1, the sprite priority mechanism is cancelled for the specified line. Collision mechanism does not work, mixing color codes of the lines of affected sprites using "OR" logical operation.
3492
+
3493
+ This logical color mixing will work for sprite N if its affected line has CC bit set, and this line will collide with the line of another sprite which has CC bit reset to "0" and has lower number (N-1, N-2, ..., 0 - i.e. higher priority).
3494
+
3495
+ Moreover, the line of the sprite having CC bit set to "1" will not be displayed at all if there will be no lower number sprite with the line with CC bit set to "0" at the same screen line.
3496
+
3497
+ Please see below for the example for the sprite combination displayed in seven colors.
3498
+
3499
+ ```
3500
+ +----------+ · · +
3501
+ | | : Sprite #N
3502
+ | | : Color code 8
3503
+ | | : CC = all set to 0
3504
+ | 8 | :
3505
+ | | :
3506
+ | | :
3507
+ | | :
3508
+ +----------+ · · +
3509
+
3510
+ + · · +----------+
3511
+ : | | Sprite #N+1
3512
+ : | | Color code 4
3513
+ : | 4 | CC = all set to 1
3514
+ : | |
3515
+ : | |
3516
+ : +----------+
3517
+ : :
3518
+ + · · · · · · · ·+
3519
+
3520
+ + · · · · · · · ·+
3521
+ : | Sprite #N+2
3522
+ : +--------+ Color code 2
3523
+ : | | CC = all set to 1
3524
+ : | |
3525
+ : | 2 |
3526
+ : | |
3527
+ : | |
3528
+ + · · · +--------+
3529
+
3530
+ Resulting images in SM1 and SM2 modes (all sprites are placed at the same X, Y)
3531
+ +-----+----+-----+ +----------+-----+
3532
+ | | 12 | 4 | | | |
3533
+ | | +--+-----+ | | |
3534
+ | | | | | | | 4 |
3535
+ | 8 | |14| 6 | | 8 | |
3536
+ | | | | | | | |
3537
+ | +-+--+-----+ | +-----+
3538
+ | |10| 2 | | | 2 |
3539
+ +-------+--+-----+ +----------+-----+
3540
+ SM2: CC flag is used, SM1: collision detection
3541
+ no collision detection, turned on.
3542
+ color mixing.
3543
+ ```
3544
+
3545
+ #### Sprite collision
3546
+
3547
+ If CC bit is set to 0 and two sprites overlap with their color code 1 (the dots of two sprites defined by "1" in their bitmap), a sprite collision event occur, and bit 5 ("C") of status register S#0 will be set to "1". This bit will be reset when S#0 is read.
3548
+
3549
+ When collision occurs and neither mouse flag (MO) nor the light pen flag (LP) of the register R#8 are set, status registers S#3 to S#6 will contain coordinates of the collision.
3550
+
3551
+ When status register S#5 is read, all the contents of registers S#3 to S#6 are reset. This means that program should read status registers S#3, S#4 and S#6 before reading status register S#5. Collision coordinates can be calculated using the following formulas:
3552
+ ```
3553
+ X (S#4,S#3), Y (S#6,S#5)
3554
+ XC=X-12 YC=Y-8
3555
+ ```
3556
+
3557
+ ### Special rules for sprite color settings
3558
+
3559
+ #### Sprite colors in GRAPHIC7 mode
3560
+
3561
+ In all graphic modes except GRAPHIC7 mode, sprite display color is determined by the values in palette registers.
3562
+
3563
+ In GRAPHIC7 mode the sprite colors are fixed and are not related to contents of palette registers. Table below show these effective values:
3564
+
3565
+ Color code = C3 C2 C1 C0
3566
+ Green = G2 G1 G0
3567
+ Red = R2 R1 R0
3568
+ Blue = B2 B1 B0
3569
+
3570
+ |C3|C2|C1|C0||G2|G1|G0||R2|R1|R0||B2|B1|B0|
3571
+ |---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3572
+ |0|0|0|0||0|0|0||0|0|0||0|0|0|
3573
+ |0|0|0|1||0|0|0||0|0|0||0|1|0|
3574
+ |0|0|1|0||0|0|0||0|1|1||0|0|0|
3575
+ |0|0|1|1||0|0|0||0|1|1||0|1|0|
3576
+ |0|1|0|0||0|1|1||0|0|0||0|0|0|
3577
+ |0|1|0|1||0|1|1||0|0|0||0|1|0|
3578
+ |0|1|1|0||0|1|1||0|1|1||0|0|0|
3579
+ |0|1|1|1||0|1|1||0|1|1||0|1|0|
3580
+ |1|0|0|0||1|0|0||1|1|1||0|1|0|
3581
+ |1|0|0|1||0|0|0||0|0|0||1|1|1|
3582
+ |1|0|1|0||0|0|0||1|1|1||0|0|0|
3583
+ |1|0|1|1||0|0|0||1|1|1||1|1|1|
3584
+ |1|1|0|0||1|1|1||0|0|0||0|0|0|
3585
+ |1|1|0|1||1|1|1||0|0|0||1|1|1|
3586
+ |1|1|1|0||1|1|1||1|1|1||0|0|0|
3587
+ |1|1|1|1||1|1|1||1|1|1||1|1|1|
3588
+
3589
+ #### Sprite transparency
3590
+
3591
+ The state of bit 5 "TP" of register R#8 affects how sprites are displayed, and affects color code 0.
3592
+
3593
+ |TP bit value|Behavior|
3594
+ |---|---|
3595
+ |TP=0|Color code 0 will be treated as transparent and invisible.<br>All the dots corresponding to “0” bit value in sprite bitmap will be transparent.<br>These dots are considered as non-existent and will not cause collision event.|
3596
+ |TP=1|Color code 0 will be the code corresponding to color #0 in the palette register.<br>Note that in GRAPHIC7 mode, value of color #0 is predefined and equal to G=0, R=0 and B=0.<br>If sprites will overlap with the dots corresponding to “0” bit value in their sprite bitmap, collision event will be generated.|
3597
+
3598
+ ## SPECIAL FUNCTIONS
3599
+
3600
+ ### Alternate display of two graphic screen pages
3601
+
3602
+ Two graphics screen pages may be alternatively displayed in G4 to G7 modes automatically. In G4 and G5 modes, the following pages can be displayed alternatively: page 0 and page 1, and page 2 and page3. In G6 and G7 modes, pages 0 and 1 will be alternatively displayed. Please refer to chapter 6.2 for description of page concept.
3603
+
3604
+ ```
3605
+ G4/G5 modes: G6/G7 modes:
3606
+ +--------+ +--------+
3607
+ | Page 0 | | |
3608
+ |········| | Page 0 |
3609
+ | Page 1 | | |
3610
+ +--------+ |········|
3611
+ | Page 2 | | |
3612
+ |········| | Page 1 |
3613
+ | Page 3 | | |
3614
+ +--------+ +--------+
3615
+ ```
3616
+
3617
+ ### Displaying two graphics screens at 60Hz
3618
+
3619
+ Bit 2 "EO" of register R#9 can be used for displaying two graphics screens alternately at 60Hz. Set the odd page pattern layout table in register R#2. Then set bit 2 of register R#9 to 1.
3620
+
3621
+ ### Interlace display
3622
+
3623
+ This function displays the first and the second fields on the same page: set the bit 3 "IL" of the register R#9, to 1. To display even page in the first field and odd page in second field, set odd page in pattern layout table register R#2, and set both bits 2 "EO" and 3 "IL" in register R#9, to 1.