-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
th-4b.txt
3357 lines (2763 loc) · 122 KB
/
th-4b.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MSX2 TECHNICAL HANDBOOK
-----------------------
Edited by: ASCII Systems Division
Published by: ASCII Coprporation - JAPAN
First edition: March 1987
Text file typed by: Nestor Soriano (Konami Man) - SPAIN
March 1997
Changes from the original:
- In Figure 4.72, last "10000H" is corrected to "1FFFFH".
- In Table 4.6, in TEOR line, "else DC+..." is corrected to "else DC=..."
- In Figure 4.76, in R#45 figure, DIX and DIY bits have been placed
correctly (they were inverted in the original).
- In Figure 4.79, in R#42 and R#43 explanation, "NY -> of dots..." has been
changed to "NY -> number of dots..."
- In List 4.9, in the line with the comment "YMMM command", 11010000 bitfield
has been corrected to 11100000.
- In Figure 4.84, "*" mark removed from the explanation of NX.
- In Figure 4.85, in R#45 explanation, "select source memory" text has been
corrected to "select destination memory".
- In List 4.13, labels beginning with "LMMC" have been corrected to "LMCM".
- In List 4.15, in the line with the comment "NY", the "OUT (C),H"
instruction has been corrected to "OUT (C),L".
- In section 6.5.9, the explanation of usage of the LINE command was mixed
wih other text. It has been corrected.
- In Figure 4.94, a line explaining the meaning of R#44 has been added.
- In Figure 4.97, BX9 bit has been supressed in S#9 figure.
- In Figure 4.99, a line explaining the meaning of R#44 has been added.
- In Table 4.7, "CLR L" has been corrected to "CMR L".
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
CHAPTER 4 - VDP AND DISPLAY SCREEN (Part 6)
6. VDP COMMAND USAGE
MSX-VIDEO can execute basic graphic operations, which are called VDP
commands. These are done by accessing special harware and are available in
the GRAPHIC 4 to GRAPHIC 7 modes. These graphic commands have been made easy
to implement, requiring only that the necessary parameters be set in the
proper registers before invoking them. This section describes these VDP
commands.
6.1 Coordinate System of VDP Commands
When VDP commands are executed, the location of the source and destination
points are represented as (X, Y) coordinates as shown in Figure 4.72. When
commands are executed, there is no page division and the entire 128K bytes
VRAM is placed in a large coordinate system.
Figure 4.72 Coordinate system of VRAM
GRAPHIC 4 (SCREEN 5) GRAPHIC 5 (SCREEN 6)
------------------------------ 00000H ------------------------------
| (0,0) (255,0) | | | (0,0) (511,0) |
| Page 0 | | | Page 0 |
| (0,255) (255,255) | | | (0,255) (511,255) |
|----------------------------| 08000H |----------------------------|
| (0,256) (255,256) | | | (0,256) (511,256) |
| Page 1 | | | Page 1 |
| (0,511) (255,511) | | | (0,511) (511,511) |
|----------------------------| 10000H |----------------------------|
| (0,512) (255,512) | | | (0,512) (511,512) |
| Page 2 | | | Page 2 |
| (0,767) (255,767) | | | (0,767) (511,767) |
|----------------------------| 18000H |----------------------------|
| (0,768) (255,768) | | | (0,768) (511,768) |
| Page 3 | | | Page 3 |
| (0,1023) (255,1023) | | | (0,1023) (511,1023) |
------------------------------ 1FFFFH ------------------------------
GRAPHIC 7 (SCREEN 8) GRAPHIC 6 (SCREEN 7)
------------------------------ 00000H ------------------------------
| (0,0) (255,0) | | | (0,0) (511,0) |
| Page 0 | | | Page 0 |
| (0,255) (255,255) | | | (0,255) (511,255) |
|----------------------------| 10000H |----------------------------|
| (0,256) (255,256) | | | (0,256) (511,256) |
| Page 1 | | | Page 1 |
| (0,511) (255,511) | | | (0,511) (511,511) |
------------------------------ 1FFFFH ------------------------------
6.2 VDP Commands
There are 12 types of VDP commands which can be executed by MSX-VIDEO. These
are shown in Table 4.5.
Table 4.5 List of VDP commands
----------------------------------------------------------------------------
| Command name | Destination | Source | Units | Mnemonic | R#46 (4 hi ord) |
|--------------+-------------+--------+-------+----------+-----------------|
| | VRAM | CPU | bytes | HMMC | 1 1 1 1 |
| High speed | VRAM | VRAM | bytes | YMMM | 1 1 1 0 |
| move | VRAM | VRAM | bytes | HMMM | 1 1 0 1 |
| | VRAM | VDP | bytes | HMMV | 1 1 0 0 |
|--------------+-------------+--------+-------+----------+-----------------|
| | VRAM | CPU | dots | LMMC | 1 0 1 1 |
| Logical | CPU | VRAM | dots | LMCM | 1 0 1 0 |
| move | VRAM | VRAM | dots | LMMM | 1 0 0 1 |
| | VRAM | VDP | dots | LMMV | 1 0 0 0 |
|--------------+-------------+--------+-------+----------+-----------------|
| Line | VRAM | VDP | dots | LINE | 0 1 1 1 |
|--------------+-------------+--------+-------+----------+-----------------|
| Search | VRAM | VDP | dots | SRCH | 0 1 1 0 |
|--------------+-------------+--------+-------+----------+-----------------|
| Pset | VRAM | VDP | dots | PSET | 0 1 0 1 |
|--------------+-------------+--------+-------+----------+-----------------|
| Point | VDP | VRAM | dots | POINT | 0 1 0 0 |
|--------------+-------------+--------+-------+----------+-----------------|
| | ---- | ---- | ----- | ---- | 0 0 1 1 |
| Reserved | ---- | ---- | ----- | ---- | 0 0 1 0 |
| | ---- | ---- | ----- | ---- | 0 0 0 1 |
|--------------+-------------+--------+-------+----------+-----------------|
| Stop | ---- | ---- | ----- | ---- | 0 0 0 0 |
----------------------------------------------------------------------------
* When data is written in R#46 (Command register), MSX-VIDEO begins to
execute the command after setting 1 to bit 0 (CE/Command Execute) of the
status register S#2. Necessary parameters should be set in register R#32 to
R#45 before the command is executed.
* When the execution of the command ends, CE becomes 0.
* To stop the execution of the command, execute STOP command.
* Actions of the commands are guaranteed only in the bitmap modes (GRAPHIC 4
to GRAPHIC 7).
6.3 Logical Operations
When commands are executed, various logical operations can be done between
data in VRAM and the specified data. Each operation will be done according to
the rules listed in Table 4.6.
In the table, SC represents the source color and DC represents the
destination colour. IMP, AND, OR, EOR and NOT write the result of each
operation to the destination. In operations whose names are preceded by "T",
dots which correspond with SC=0 are not the objects of the operations and
remains as DC. Using these operations enables only colour portions of two
figures to be overlapped, so they are especially effective for animations.
List 4.7 shows an example of these operations.
Table 4.6 List of logical operations
-------------------------------------------------------------------------
| Logical name | |L03 L02 L01 L00|
|--------------+----------------------------------------+---------------|
| | | |
| IMP | DC=SC | 0 0 0 0 |
| | | |
| AND | DC=SCxDC | 0 0 0 1 |
| | | |
| OR | DC=SC+DC | 0 0 1 0 |
| | __ __ | |
| EOR | DC=SCxDC+SCxDC | 0 0 1 1 |
| | __ | |
| NOT | DC=SC | 0 1 0 0 |
| | | |
| ---- | | 0 1 0 1 |
| | | |
| ---- | | 0 1 1 0 |
| | | |
| ---- | | 0 1 1 1 |
| | | |
|--------------+----------------------------------------+---------------|
| | | |
| TIMP | if SC=0 then DC=DC else DC=SC | 1 0 0 0 |
| | | |
| TAND | if SC=0 then DC=DC else DC=SCxDC | 1 0 0 1 |
| | | |
| TOR | if SC=0 then DC=DC else DC=SC+DC | 1 0 1 0 |
| | __ __ | |
| TEOR | if SC=0 then DC=DC else DC=SCxDC+SCxDC | 1 0 1 1 |
| | __ | |
| TNOT | if SC=0 then DC=DC else DC=SC | 1 1 0 0 |
| | | |
| ---- | | 1 1 0 1 |
| | | |
| ---- | | 1 1 1 0 |
| | | |
| ---- | | 1 1 1 1 |
| | | |
-------------------------------------------------------------------------
* SC = Source colour code
* DC = Destination colour code
* EOR = Exclusive OR
List 4.7 Example of the logical operation with T
=========================================================================
1000 '***********************************************************
1010 ' List 4.7 logical operation with T
1020 '***********************************************************
1030 '
1040 SCREEN8 : COLOR 15,0,0 : CLS
1050 DIM A%(3587)
1060 '
1070 LINE (50,50)-(60,100),48,B : PAINT (51,51),156,48
1080 CIRCLE (55,30),30,255 : PAINT (55,30),240,255
1090 COPY(20,0)-(90,100) TO A%
1100 CLS
1110 '
1120 R=RND(-TIME)
1130 FOR Y=0 TO 100 STEP 3
1140 X=INT(RND(1)*186)
1150 COPY A% TO (X,Y),,TPSET
1160 NEXT
1170 '
1180 GOTO 1180
=========================================================================
6.4 Area Specification
AREA-MOVE commands are for transferring screen data inside areas surrounded
by a rectangle. The area to be transferred is specified by one vertex and the
length of each side of the rectangle as shown in Figure 4.73. SX and SY
represent the basic point of the rectangle to be transferred and NX and NY
represent the lengt of each side in dots. The two bits, DIX and DIY, are for
the direction of transferring data (the meaning of DIX and DIY depends on the
type of command). The point where the area is to be transferred is specified
in DX and DY.
Figure 4.73 Area specification
----------------------------------------------------------------
| |
| (SX,SY) |
| x----------------- --> |
| | | DIX |
| | | |
| | | |
| | | |
| ------------------ --+ |
| | DIY | |
| V | |
| | (DX,DY) |
| +-> x----------------- |
| | | |
| | | |
| | | |
| | | |
| ------------------ |
| |
----------------------------------------------------------------
6.5 Use of Each Command
Commands are clasified into three types, high-speed transfer commands,
logical transfer commands, and drawing commands. This section describes the
commands and their use.
6.5.1 HMMC (CPU -> VRAM high-speed transfer)
Data is transferred into the specified area of VRAM from the CPU (see Figure
4.74). Logical operations cannot be specified. Data is transferred in bytes
in high-speed transfer commands such as HMMC. Note that the low order bit of
the X-coordinate is not referred to in GRAPHIC 4, or 6 modes. The two low
order bits are not referred to in GRAPHIC 5 mode (see Figure 4.75).
Set the parameters as shown in Figure 4.76 to the appropriate registers. At
this point, write only the first byte of data to be transferred from the CPU
in R#44. Writing the command code F0H in R#46 causes the command to be
executed, and UMSX-VIDEO receives data from R#44 and writes it to VRAM, then
waits for data from the CPU.
The CPU writes data after the second byte in R#44. Note that data should be
transferred after MSX-VIDEO can receive data (in the case that TR bit is
"1"), referring to TR bit of S#2. When the CE bit of S#2 is "0", this means
that all data has been transferred (see figure 4.77). List 4.8 shows an
example of using HMMC.
Figure 4.74 Action of HMMC command
VRAM or expansion RAM
---------------------------------------------------
| | MSX-VIDEO CPU
| | ------- -------
| (DX,DY) | | | | |
| x------------------------ --> DIX | | | | |
| | NX | | | | | |
| | NY |<----------------+----| |-----| |
| | | | | | | |
| ------------------------- | | | | |
| | DIY | | | | |
| V | | | | |
| | ------- -------
| |
---------------------------------------------------
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
NX: number of dots to be transferred in X direction (0 to 511)*
NY: number of dots to be transferred in Y direction (0 to 1023)
DIX: direction of NX from the origin 0 = right, 1 = left
DIY: direction of NY from the origin 0 = below, 1 = above
DX: destination origin X-coordinate (0 to 511)*
DY: destination origin Y-coordinate (0 to 1023)
CLR (R#44:Colour register): 1st byte of data to be transferred
* The one low-order bit for GRAPHIC 4 and 6 modes, or two low-order bits for
GRAPHIC 5 mode of the DX and NX registers are ignored.
Figure 4.75 Dots not to be referred to
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
GRAPHIC 4 | : : : | : : : |
-----------------------------------------
(1) (2)
Since 1 VRAM byte represents 2 dots, 1 low order bit of X-coordinate is not
referred to.
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
GRAPHIC 5 | : | : | : | : |
-----------------------------------------
(1) (2) (3) (4)
Since 1 VRAM byte represents 4 dots, 2 low order bits of X-coordinate are not
referred to.
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
GRAPHIC 6 | : : : | : : : |
-----------------------------------------
(1) (2)
Since 1 VRAM byte represents 2 dots, 1 low order bit of X-coordinate is not
referred to.
Figure 4.76 Register settings of HMMC command
> HMMC register setup
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
----------------------------------------- DX ---+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
----------------------------------------- |
| destination origin
----------------------------------------- |
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
----------------------------------------- DY ---+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
-----------------------------------------
-----------------------------------------
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0| Number of dots in
----------------------------------------- NX ---> X direction to be
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8| transferred
-----------------------------------------
-----------------------------------------
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0| Number of dots in
----------------------------------------- NY ---> Y direction to be
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8| transferred
-----------------------------------------
----------------------------------------- --+d
R#44 | CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 4,6) |a
----------------------------------------- |t
| | | |a
+-------------------+-------------------+ |
X=2N X=2N+1 (N=0, 1, ..., 127) |t
|o
----------------------------------------- |
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 5) |b
----------------------------------------- |e
| | | | | |
+---------+---------+---------+---------+ |t
X=4N X=4N+1 X=4N+2 X=4N+3 (N=0, 1, ..., 127) |r
|a
----------------------------------------- |n
| CR7| CR6| CR5| CR4| CR3| CR2| CR1| CR0| CLR (GRAPHIC 7) |s
----------------------------------------- --+f.
1 byte per dot
-----------------------------------------
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
-----------------------------------------
| | direction (X)
| |
| +-> direction (Y)
|
+-----------> select destination memory
> HMMC command execution
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#46 | 1 | 1 | 1 | 1 | -- | -- | -- | -- | CMR
-----------------------------------------
Figure 4.77 HMMC command execution flow chart
/-------------------\
| HMMC start |
\-------------------/
|
---------------------
| register setup |
---------------------
|
---------------------
| command execution |
---------------------
|
+---------------->|
| |
| ---------------------------
| | Read status register #2 |
| ---------------------------
| |
| //////////+\\\\\\\\\\ Yes (CE bit = 0)
| | command end? |-------------------+
| \\\\\\\\\\+////////// |
| | No (CE bit = 1) |
| //////////+\\\\\\\\\\ |
|<------| transfer? | |
| No \\\\\\\\\\+////////// |
| (TR bit=0) | Yes (TR bit = 1) |
| --------------------- |
| | transfer data | |
| --------------------- |
| | |
+-----------------+ |
|
+-----------------------------+
|
V
/--------------------\
| HMMC end |
\--------------------/
List 4.8 Example of HMMC command execution
=========================================================================
;****************************************************************
; List 4.8 HMMC sample
; to use, set H, L, D, E, IX and go
; RAM (IX) ---> VRAM (H,L)-(D,E)
;****************************************************************
;
RDVDP: EQU 0006H
WRVDP: EQU 0007H
;----- program start -----
HMMC: DI ;disable interrupt
CALL WAIT.VDP ;wait end of command
LD A,(WRVDP)
LD C,A
INC C ;C := PORT#1's address
LD A,36
OUT (C),A
LD A,17+80H
OUT (C),A ;R#17 := 36
INC C
INC C ;C := PORT#3's address
XOR A
OUT (C),H ;DX
OUT (C),A
OUT (C),L ;DY
OUT (C),A
LD A,H ;make NX and DIX
SUB A
LD D,00000100B
JR NC,HMMC1
LD D,00000000B
NEG
HMMC1: LD H,A ;H := NX , D := DIX
LD A,L
SUB A
LD E,00001000B
JR NC,HMMC2
LD E,00000000B
NEG
HMMC2: LD L,A ;L := NY , E := DIY
XOR A
OUT (C),H ;NX
OUT (C),A
OUT (C),L ;NY
OUT (C),A
LD H,(IX+0)
OUT (C),H ;first DATA
LD A,D
OR E
OUT (C),A ;DIX and DIY
LD A,0F0H
OUT (C),A ;HMMC command
LD A,(WRVDP)
LD C,A ;C := PORT#1's address
INC C
LD A,44+80H
OUT (C),A
LD A,17+80H
OUT (C),A
INC C
INC C
LOOP: LD A,2
CALL GET.STATUS
BIT 0,A ;check CE bit
JR Z,EXIT
BIT 7,A ;check TR bit
JR Z,LOOP
INC IX
LD A,(IX+0)
OUT (C),A
JR LOOP
EXIT: LD A,0
CALL GET.STATUS ;when exit, you must select S#0
EI
RET
GET.STATUS: ;read status register specified by A
PUSH BC
LD BC,(WRVDP)
INC C
OUT (C),A
LD A,8FH
OUT (C),A
LD BC,(RDVDP)
INC C
IN A,(C)
POP BC
RET
WAIT.VDP: ;wait VDP ready
LD A,2
CALL GET.STATUS
AND 1
JR NZ,WAIT.VDP
XOR A
CALL GET.STATUS
RET
END
=========================================================================
6.5.2 YMMM (high-speed transfer between VRAM in Y direction)
Data from a specified VRAM area is transferred into another area in VRAM.
Note that transfers using this command can only be done in the Y direction
(see Figure 4.78).
After setting the data as shown in Figure 4.79 in the proper registers,
writing command code E0H in R#46 causes the command to be executed. When the
CE bit of S#2 is "1", it indicates that the command is currently being
executed. List 4.9 shows an example of using YMMM.
Figure 4.78 Actions of YMMM command
VRAM or expansion RAM
---------------------------------------------------
| |
| (DX,DY) |
| x------------------------|
| | |
| | |
| | |
| -------------------------|
| ^ |
| | |
| | |
| (DX,SY) |
| x------------------------| --> DIX
| | |
| | NY |
| | |
| -------------------------|
| | DIY |
| V |
---------------------------------------------------
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
SY: source origin Y-coordinate (0 to 1023)
NY: number of dots to be transferred in Y direction (0 to 1023)
DIX: set which to be transferred, to te right end or to the left end of the
screen from the source origin 0 = right, 1 = left
DIY: direction of NY from the origin 0 = below, 1 = above
DX: destination origin X-coordinate (0 to 511)*
DY: destination origin Y-coordinate (0 to 1023)
* The one low-order bit for GRAPHIC 4 and 6 modes, or two low-order bits for
GRAPHIC 5 mode of the DX register are ignored.
Figure 4.79 Register settings of YMMM command
> YMMM register setup
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0|
----------------------------------------- SY --> source origin
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
-----------------------------------------
-----------------------------------------
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
----------------------------------------- DX --> destination and
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| source origin
-----------------------------------------
-----------------------------------------
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0|
----------------------------------------- DY --> destination origin
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
-----------------------------------------
-----------------------------------------
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0| number of dots to
----------------------------------------- NY ---> be transferred in
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8| Y direction
-----------------------------------------
-----------------------------------------
R#45 | 0 | -- | MXD| -- | DIY| DIX| -- | -- | ARG (Argument register)
-----------------------------------------
| | direction (X)
| |
| +-> direction (Y)
|
+-----------> select destination memory
> YMMM command execution
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#46 | 1 | 1 | 1 | 0 | -- | -- | -- | -- | CMR
-----------------------------------------
List 4.9 Example of YMMM command execution
=========================================================================
;****************************************************************
; List 4.9 YMMM sample
; to use, set L, E, B, C, D(bit 2) and go
; VRAM (B,L)-(*,E) ---> VRAM (B,C)
; DIX must be set in D(bit 2)
;****************************************************************
;
RDVDP: EQU 0006H
WRVDP: EQU 0007H
;----- program start -----
YMMM: DI ;disable interrupt
PUSH BC ;save destination
CALL WAIT.VDP ;wait end of command
LD A,(WRVDP)
LD C,A
INC C ;C := PORT#1's address
LD A,34
OUT (C),A
LD A,17+80H
OUT (C),A ;R#17 := 34
INC C
INC C ;C := PORT#3's address
XOR A
OUT (C),L ;SY
OUT (C),A
LD A,L ;make NY and DIY
SUB A
LD E,00001000B
JP NC,YMMM1
LD E,00000000B
NEG
YMMM1: LD L,A ;L := NY , D := DIY
LD A,D
OR E
POP DE ;restore DX,DY
PUSH AF ;save DIX,DIY
XOR A
OUT (C),D ;DX
OUT (C),A
OUT (C),E ;DY
OUT (C),A
OUT (C),A ;dummy
OUT (C),A ;dummy
OUT (C),L ;NY
OUT (C),A
OUT (C),A ;dummy
POP AF
OUT (C),A ;DIX and DIY
LD A,11100000B ;YMMM command
OUT (C),A
EI
RET
GET.STATUS:
PUSH BC
LD BC,(WRVDP)
INC C
OUT (C),A
LD A,8FH
OUT (C),A
LD BC,(RDVDP)
INC C
IN A,(C)
POP BC
RET
WAIT.VDP:
LD A,2
CALL GET.STATUS
AND 1
JP NZ,WAIT.VDP
XOR A
CALL GET.STATUS
RET
END
=========================================================================
6.5.3 HMMM (high-speed transfer between VRAM)
Data of specified VRAM area is transferred into another area in VRAM (see
Figure 4.80).
After setting the parameters as shown in Figure 4.81, writing D0H in R#46
causes the command to be executed. While the command is being executed, CE
bit of S#2 is "1". List 4.10 shows an example of using HMMM.
Figure 4.80 Actions of HMMM command
VRAM or expansion RAM
----------------------------------------------------------------
| |
| (SX,SY) |
| ------------------ --> |
| | NX | DIX |
| | | |
| | NY | |
| | | |
| ------------------ --+ |
| | DIY | |
| V | |
| | (DX,DY) |
| +-> ------------------ |
| | | |
| | | |
| | | |
| | | |
| ------------------ |
| |
----------------------------------------------------------------
MXS: select the source memory 0 = VRAM, 1 = expansion RAM
MXD: select the destination memory 0 = VRAM, 1 = expansion RAM
SX: source origin X-coordinate (0 to 511)*
SY: source origin Y-coordinate (0 to 1023)
NX: number of dots to be transferred in X direction (0 to 511)*
NY: number of dots to be transferred in Y direction (0 to 1023)
DIX: direction of NX from the origin 0 = right, 1 = left
DIY: direction of NY from the origin 0 = below, 1 = above
DX: destination origin X-coordinate (0 to 511)*
DY: destination origin Y-coordinate (0 to 1023)
* The one low-order bit for GRAPHIC 4 and 6 modes, or two low-order bits for
GRAPHIC 5 mode of the SX, DX, and NX register are ignored.
Figure 4.81 Register settings of HMMM command
> HMMM register setup
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#32 | SX7| SX6| SX5| SX4| SX3| SX2| SX1| SX0|
|----+----+----+----+----+----+----+----| SX ---+
R#33 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | SX8| |
----------------------------------------- |
| source origin
----------------------------------------- |
R#34 | SY7| SY6| SY5| SY4| SY3| SY2| SY1| SY0| |
|----+----+----+----+----+----+----+----| SY ---+
R#35 | 0 | 0 | 0 | 0 | 0 | 0 | SY9| SY8|
-----------------------------------------
-----------------------------------------
R#36 | DX7| DX6| DX5| DX4| DX3| DX2| DX1| DX0|
|----+----+----+----+----+----+----+----| DX ---+
R#37 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | DX8| |
----------------------------------------- |
| destination origin
----------------------------------------- |
R#38 | DY7| DY6| DY5| DY4| DY3| DY2| DY1| DY0| |
|----+----+----+----+----+----+----+----| DY ---+
R#39 | 0 | 0 | 0 | 0 | 0 | 0 | DY9| DY8|
-----------------------------------------
-----------------------------------------
R#40 | NX7| NX6| NX5| NX4| NX3| NX2| NX1| NX0| Number of dots in
|----+----+----+----+----+----+----+----| NX ---> X direction to be
R#41 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NX8| transferred
-----------------------------------------
-----------------------------------------
R#42 | NY7| NY6| NY5| NY4| NY3| NY2| NY1| NY0| Number of dots in
|----+----+----+----+----+----+----+----| NY ---> Y direction to be
R#43 | 0 | 0 | 0 | 0 | 0 | 0 | NY9| NY8| transferred
-----------------------------------------
-----------------------------------------
R#45 | 0 | -- | MXD| MXS| DIY| DIX| -- | -- | ARG (Argument register)
-----------------------------------------
| | | direction (X)
| | |
| | +-> direction (Y)
| |
| +------> select source memory
|
+-----------> select destination memory
> HMMM command execution
MSB 7 6 5 4 3 2 1 0 LSB
-----------------------------------------
R#46 | 1 | 1 | 0 | 1 | -- | -- | -- | -- | CMR
-----------------------------------------
List 4.10 Example of HMMM command execution
=========================================================================
;****************************************************************
; List 4.10 HMMM sample
; to use, set H, L, D, E, B, C and go
; VRAM (H,L)-(D,E) ---> VRAM (B,C)
; DIX must be set in D(bit 2)
;****************************************************************
;
RDVDP: EQU 0006H
WRVDP: EQU 0007H
;----- program start -----
HMMM: DI ;disable interrupt
PUSH BC ;save destination
CALL WAIT.VDP ;wait end of command
LD A,(WRVDP)
LD C,A
INC C ;C := PORT#1's address
LD A,32
OUT (C),A
LD A,80H+17
OUT (C),A ;R#17 := 32
INC C
INC C ;C := PORT#3's address
XOR A
OUT (C),H ;SX
OUT (C),A
OUT (C),L ;SY
OUT (C),A
LD A,H ;make NX and DIX
SUB A
LD D,00000100B
JP NC,HMMM1
LD D,00000000B
NEG
HMMM1: LD H,A ;H := NX , D := DIX
LD A,L ;make NY and DIY
SUB A
LD E,00001000B
JP NC,HMMM2
LD E,00000000B
NEG
HMMM2: LD L,A ;L := NY , E := DIY
LD A,D
OR E
POP DE ;restore DX,DY
PUSH AF ;save DIX,DIY
XOR A
OUT (C),D ;DX
OUT (C),A
OUT (C),E ;DY
OUT (C),A
OUT (C),H ;NX
OUT (C),A
OUT (C),L ;NY
OUT (C),A
OUT (C),A ;dummy
POP AF
OUT (C),A ;DIX and DIY
LD A,11010000B ;HMMM command
OUT (C),A
EI
RET
GET.STATUS:
PUSH BC
LD BC,(WRVDP)
INC C
OUT (C),A
LD A,8FH
OUT (C),A
LD BC,(RDVDP)
INC C
IN A,(C)
POP BC
RET
WAIT.VDP:
LD A,2
CALL GET.STATUS
AND 1
JP NZ,WAIT.VDP
XOR A
CALL GET.STATUS
RET
END
=========================================================================
6.5.4 HMMV (painting the rectangle in high speed)
Each byte of data in the specified VRAM area is painted by the specified
colour code (see Figure 4.82)
After setting the parameters as shown in Figure 4.83, writing C0H in R#46