Japanese
HARDWARE ManualVDP1 User's Manual
BackForward
VDP1 User's Manual

Chapter 6 Command Table


■6.1 CMDCTRL (control word)

CMDCTRL specifies commands, controls the command table, inverts sprites, and specifies fixed points. CMDCTRL is 16 bits located at the command table start address +00H, and the bit configuration is as follows. Set unused bits to 0.

bit
 15
 14
 13
 12
 11
 10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 0
CMDCTRL
+00H
END JP ZP 0 0 Dir Comm

End bit: end bit(END), bit 15
Represents the drawing end command. The command selection bit is enabled when it is not a drawing end command.

Jump format : jump select(JP), bits 14 to 12
Indicates how to specify the command table to read (fetch) next.

Zoom point bit : zoom point(ZP), bits 11 to 8
Represents the zoom point (fixed point) when using the rectangle sprite drawing command. The zoom point specifies the reference point for reversing and scaling.

Character read direction bit : character read direction (Dir), bits 5 to 4
Indicates the reading direction from the character pattern table when using a texture drawing command.

Command selection bits : command select(Comm), bits 3 to 0
Represents the functionality of the command. Command selection is disabled when the end bit is the end command.

●Command

The command is determined by the end bit (END, bit 15) and command selection bits (Comm, bits 3-0) of CMDCTRL. The commands set by the end bit and command selection bit are as follows.
The command determines the contents of the VRAM command table.

Table 6.1 Commands
 END
 Comm
 function
 command
 bit 15
 3
 2
 1
 0
 0
 0
 0
 0
 0
 drawing
command
 texture
drawing command
 Standard sprite drawing command
 0
 1
 Rectangle sprite drawing command
 1
 0
 Transform sprite drawing commands
 1
 0
 0
 non-texture
drawing command
 polygon drawing commands
 0
 1
 Polyline drawing command
 1
 0
 Line drawing command
 1
 0
 0
 0
 Coordinate settings
command
 clipping coordinates
Setting command
 User clipping coordinate setting command
 1
 System clipping coordinate setting command
 1
 0
 Relative coordinate setting command
 1
 0 0 0 0
 drawing end command
 Codes other than the above
 Setting prohibited (please do not set)

●Jump format

Jump type specifies the next command table to be processed and the type of jump to that table.
When the jump format is to jump by specifying an address, set the jump destination command table address to CMDLINK (command table start address + 02H, 16 bits).

Jump format: jump mode (JP), command table start address +00H, bits 14 to 12
Specifies the jump format to the next command table to be processed. When the jump format is skip (bit 14 = 1), command table reading ends and the table is not processed.
Nesting with jump calls is one level. Jump calls within subroutines are prohibited .

000 jump next
After processing this table, it will automatically move to the next table (+20H address) (CMDLINK will be ignored)

001 Jump assign
After processing this table, migrate it to CMDLINK's table

010 jump call
After processing this table, call the CMDLINK table subroutine

011 Jump return
After processing this table, return to the main routine (CMDLINK is ignored)

100 skip next
Move to the next table (address +20H) without processing this table (CMDLINK will be ignored)

101 Skip assign
Don't process this table, migrate to CMDLINK's table

110 skip call
Call the subroutine for CMDLINK's table without processing this table

111 Skip return
Return to main routine without processing this table (CMDLINK is ignored)

If jump assignment, jump call, skip assignment, or skip call is specified, specify the address of the table to be processed next in CMDLINK.
If Jump Next, Jump Return, Skip Next, or Skip Return is specified, CMDLINK will be ignored.

●Zoom point

The zoom point specifies the fixed point of the character when enlarging/reducing the rectangular sprite. Only rectangular sprites are affected.

Zoom point: zoom point (ZP), command table start address +00H, bits 11 to 8
The zoom point specifies the fixed point of the character when enlarging or reducing the rectangular sprite. The relationship between the zoom point value and the fixed point is as follows: When the zoom point (ZP) is 0H, there is no zoom point, and it is drawn by specifying two points: the upper left coordinate and the lower right coordinate.
Please fix the zoom point to 0H for anything other than rectangular sprites.

 ZP
 code
 zoom point
 bit 11
 10
 9
 8
 0
 0
 0
 0
 0H
 Specify 2 coordinates
 0
 1
 0
 1
 5H
 top left edge
 0
 1
 1
 0
 6H
 center of top
 0
 1
 1
 1
 7H
 right edge of top
 1
 0
 0
 1
 9H
 left edge of center
 1
 0
 1
 0
 AH
 center of center
 1
 0
 1
 1
 BH
 right edge of center
 1
 1
 0
 1
 DH
 left edge of bottom edge
 1
 1
 1
 0
 EH
 center of bottom edge
 1
 1
 1
 1
 FH
 right edge of the bottom

Strictly observed★Settings other than the above are prohibited.

Figure 6.1 Zoom point
   +1     +2      +3            
           ┃                    
   ┌─┬─┬─┬─╂─┬─┬─┬─┐            
+4 │■│ │ │■┃ │ │ │■│            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
+8 ┿■┿━┿━┿■╋━┿━┿━┿■┿ Center line
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
   │ │ │ │ ┃ │ │ │ │            
   ├─┼─┼─┼─╂─┼─┼─┼─┤            
+C │■│ │ │■┃ │ │ │■│            
   └─┴─┴─┴─╂─┴─┴─┴─┘            
           ┃                    
      center line              
 
The sum of these vertical and horizontal values is the zoom point value. 

When you specify a value other than 0 for the zoom point (ZP), the drawing position and drawing size of the sprite are determined by the zoom point (ZP), fixed point coordinates, and display width.
The fixed point of the character specified by the zoom point is drawn at the fixed point coordinates (CMDXA, CMDYA).
The drawing size is determined by the display width (CMDXB, CMDYB).
When scaling down, pixels may be thinned out and the specified fixed point may disappear.
Do not specify any value other than the one determined as the zoom point. Drawing is not guaranteed if a value other than the specified value is specified.
The length of the character size in the X direction is a multiple of 8, so even if you specify the center, strictly speaking, the fixed point will not be the center. Even if the length in the Y direction is an even number, it will not be centered.
The direction of character drawing is specified by the character read direction bit.
If the display width in the X direction is negative, it will be drawn in the X direction, which is the opposite of the direction specified by the character read bit in the X direction. If the display width in the Y direction is negative, it will be drawn in the Y direction, which is the opposite direction to the direction specified by the Y direction character read bit.

Fixed point specification
When ZP is other than 0H, specify the fixed point coordinates in CMDXA and CMDYA, and the display width in CMDXB and CMDYB.

 15
 14
 13
 12
 11
 10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 0
CMDXA +0CH sign extension Fixed point, X coordinate (XA)
CMDYA +0EH sign extension Fixed point, Y coordinate (YA)
CMDXB +10H sign extension Display, X coordinate (XB)
CMDYB +12H sign extension Display, Y coordinate (YB)

Specify 2 coordinates
When ZP is 0H, two points are specified: upper left coordinate and lower right coordinate. Specify vertex to CMDXA, CMDYA and vertex to CMDXC, CMDYC.

 15
 14
 13
 12
 11
 10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 0
CMDXA +0CH sign extension Vertex (A), X coordinate (XA)
CMDYA +0EH sign extension Vertex (A), Y coordinate (YA)
+10H :
+12H :
CMDXC +14H sign extension Vertex (C), X coordinate (XC)
CMDYC +16H sign extension Vertex (C), Y coordinate (YC)

drawing area
Specify fixed point coordinates for CMDXA and CMDYA. The fixed point specified by the zoom point (ZP) is drawn at the fixed point coordinates. The fixed point serves as the reference point when zooming the character.
Specify the display width for CMDXB and CMDYB. The display width is the drawing size.
The area in which the character is drawn is determined by the zoom point bit (ZP), fixed point coordinates, and display width. When the fixed point coordinates are (XA, YA) and the display width is (XB, YB), it will be as follows.

Figure 6.2 Drawing area
 ┌────────────────→Left end is fixed point, Left end  = XA                
 │                                          Right end = XA+XB             
 │                                                                        
 │     ┌──────────→The center is the fixed point, Left edge = XA-XB/2     
 │     │                                          Right end = XA+(XB+1)/2 
 │     │                                                                  
 │     │       ┌───Right end is fixed point, Left end  = XA-XB            
 │     │       │                             Right end = XA               
 │     │       │                                                          
┌─┬─┬─┬─┬─┬─┬─┬─┐                                                         
│■│ │ │■│ │ │ │■│─→Top side is fixed point, Top side   = YA               
├─┼─┼─┼─┼─┼─┼─┼─┤                           Lower side = YA + YB          
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│■│ │ │■│ │ │ │■│─→Fixed point in the center, Upper side = YA-YB/2        
├─┼─┼─┼─┼─┼─┼─┼─┤                             Lower side = YA+(YB+1)/2    
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│ │ │ │ │ │ │ │ │                                                         
├─┼─┼─┼─┼─┼─┼─┼─┤                                                         
│■│ │ │■│ │ │ │■│─→Lower side is fixed point, Upper side = YA-YB          
└─┴─┴─┴─┴─┴─┴─┴─┘                             Bottom     = YA             

[Note] Fractions below the decimal point are rounded down.

Zoom point and drawing area
When the fixed point coordinates are (100, 50) and the display width is (40, 30), the coordinates of each vertex are as follows. However, there is no specification for vertical or horizontal reversal. When the zoom point (ZP) is 0H, the vertex is (100, 50) and the vertex is (140, 80).

Figure 6.3 Zoom point and drawing area
ZP=0
(100,50) 
   ┏━━━━━━━━┓     
   ┃        ┃     
   ┃        ┃     
   ┃        ┃     
   ┃        ┃     
   ┃        ┃     
   ┗━━━━━━━━┛     
          (140,80)


ZP=5H                ZP=6H               ZP=7H            
(100,50)  (140,50)  (80,50)   (120,50)  (60,50)   (100,50)
   ┏┿━━━━━━━┓          ┏━━━┿━━━━┓          ┏━━━━━━━┿┓     
   ╂■───────╂          ╂───■────╂          ╂───────■╂     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┗┿━━━━━━━┛          ┗━━━┿━━━━┛          ┗━━━━━━━┿┛     
(100,80)  (140,80)  (80,80)   (140,80)  (60,80)   (100,80)


ZP=9H                ZP=AH(10)           ZP=BH(11)
(100,35)  (140,35)  (80,35)   (120,35)  (60,35)   (100,35)
   ┏┿━━━━━━━┓          ┏━━━┿━━━━┓          ┏━━━━━━━┿┓     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ╂■───────╂          ╂───■────╂          ╂───────■╂     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┗┿━━━━━━━┛          ┗━━━┿━━━━┛          ┗━━━━━━━┿┛     
(100,65)  (140,65)  (80,65)   (140,65)  (60,65)   (100,65)


ZP=DH(13)            ZP=EH(14)           ZP=FH(15) 
(100,20)  (140,20)  (80,20)   (120,20)  (60,20)   (100,20)
   ┏┿━━━━━━━┓          ┏━━━┿━━━━┓          ┏━━━━━━━┿┓     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ┃│       ┃          ┃   │    ┃          ┃       │┃     
   ╂■───────╂          ╂───■────╂          ╂───────■╂     
   ┗┿━━━━━━━┛          ┗━━━┿━━━━┛          ┗━━━━━━━┿┛     
(100,50)  (140,50)  (80,50)   (140,50)  (60,50)   (100,50)

●Character read direction

You can specify the character read direction. With this specification, you can flip the character vertically or horizontally.

Character read direction bit: character read direction (Dir), command table start address +00H, bits 5, 4
Specify the character pattern read direction. You can instruct to invert vertically, invert horizontally, or invert horizontally and vertically at the same time.
When bit 5 is 0, the vertical (Y) direction is drawn as is, without being flipped vertically. When set to 1, the drawing is flipped upside down.
When bit 4 is 0, the image is drawn in the horizontal (X) direction without being reversed horizontally. When set to 1, the drawing is flipped left and right.
When bits 4 and 5 are both 0, the character pattern is drawn without inversion. When bits 4 and 5 are both 1, the drawing is reversed vertically and horizontally.
Please fix the character read direction to 00B except for sprites.

 Dir
 Inversion processing
 Y
 X
 0
 0
 not reversed
 0
 1
 Flip left and right
 1
 0
 Flip upside down
 1
 1
 Flip vertically and horizontally

Figure 6.4 Character read direction


BackForward
HARDWARE ManualVDP1 User's Manual
Copyright SEGA ENTERPRISES, LTD., 1997