+Contents

Main manual

Precautions for Hardware

1. CPU clock

The CPU clock is 3.579545 MHz.

2. Memory area unusable area

⦾ DFF0H to DFFFH

When a ROM of 1 M or greater is used, the area for bank switching, and so on, is located between FFF0H and FFFH. This area is used for reading (using images) bank data, so do not use it as a normal work area. For this reason, it is necessary to set the stack pointer in such a way that the stack does not use this area.

Example:

LD SP, 0DFF0H

⦾ E000H to FFFFH (excluding the area for bank switching, and so on)

This area contains the C000H to 0FFFH RAM image. Do not access an image from this area but from the C000H to DFFFH area instead.

3. VDP initialization

Sometimes, when the power is switched ON, the reset of the CPU is canceled while the VDP remains reset. In order to prevent this, confirm that the value of the V counter in the VDP has become B0H and then access the data.

Example:

INIWAIT:
  IN A,(07EH) ; READ V-COUNTER
  CP 0B0H
  JP NZ,INIWAIT
  RET

4. Interrupt

An interrupt is synchronized with the video timming (at the completion of the effective area or at an arbitrary vertical position).

This interrupt uses the Z80 mode 1 interrupt, hence "IM 1" is executed at the beginning of the program. A return from an interrupt routine is "RET".

System control port

☆ Indicates the state after a power-on reset.

(1) I/O port 00H (Read Only)

D7D6D5D4D3D2D1D0
STTNJAPNNTS*****
STT
This is an input from the START/PAUSE button.
0: Switch ON
1: Switch OFF
NJAP
0: This is the domestic (Japan) mode
1: This is the overseas mode.
NNTS
0: This is the NTSC mode.
1: This is the PAL mode.

(2) I/O port 01H (Read/Write)

D7D6D5D4D3D2D1D0
*PC6PC5PC4PC3PC2PC1PC0

This port is used to read/write data when the EXT connector is used as a 7-bit input/output port. (The value after a power-on reset is indeterminate.)

(3) I/O port 02H (Read/Write)

D7D6D5D4D3D2D1D0
NINTDPC6DPC5DPC4DPC3DPC2DPC1DPC0
DPC6 to DPC0
0: PCx becomes the output.
☆ 1: PCx becomes the input.
NINT
0: When PC6 is input, an NMI is generated at the fall of PC6.
☆ 1: The above operation is disabled.

(4) I/O port 03H (Read/Write)

D7D6D5D4D3D2D1D0
TD7TD6TD5TD4TD3TD2TD1TD0
TD7 to TD0
Used to set the send data during serial communications.

(5) I/O port 04H (Read Only)

D7D6D5D4D3D2D1D0
RD7RD6RD5RD4RD3RD2RD1RD0
R07 to RD0
The receive data is set during serial communications.

(6) I/O port 05H (Read/Write)

Serial communications mode setting

D7D6D5D4D3D2D1D0
BS1BS0RGNTONINTFRERRXROTXFL
TXFL (Read)
☆ 0: The next send data is written.
1: The send data cannot be written yet.
RXRD (Read)
☆ 0: There is no receive data.
1: There is receive data.
FRER (Read)
☆ 0: There is no framing error.
1: There is a framing error.
INT (Read/Write)
☆ 0: The following operation is disabled.
1: An NMI is generated when data is received.
* An operation such as that of I/O port 02H is unnecessary.
TON (Read/Write)
☆ 0: Sending is disabled.
1: Sending is enabled. (PC4 is forcibly made the output.)
RON (Read/Write)
☆ 0: Receive disable.
1: Receive enable. (PCS is forcibly made the input.)
BS1, BS0
Baud rate setting
 BS1BS0Baud rate (bps)
004800
 012400
 101200
 11300

(7) I/O port 06H (Write Only)

Left-right distribution of sound

D7D6D5D4D3D2D1D0
NOSLTN3LTN2LTN1LNOSRTN3RTN2RTN1R
TN1R
0: The output of TONE 1 to the right is disabled.
☆ 1: The output of TONE 1 to the right is enabled.
TN2R
0: The output of TONE 2 to the right is disabled.
☆ 1: The output of TONE 2 to the right is enabled.
TN3R
0: The output of TONE 3 to the right is disabled.
☆ 1: The output of TONE 3 to the right is enabled.
NOSR
0: The output of NOISE to the right is disabled.
1: The output of NOISE to the right is enabled.
TN1L
0: The output of TONE 1 to the left is disabled.
☆ 1: The output of TONE 1 to the left is enabled.
TN2L
0: The output of TGNE 2 to the left is disabled.
☆ 1: The output of TONE 2 to the left is enabled.
TN3L
0: The output of TONE 3 to the left is disabled
☆ 1: The output of TONE 3 to the left is enabled.
NOSL
0: The output of NOISE to the left is disabled.
☆ 1: The output of NOISE to the right is enabled.

(8) Loader access (development board only)

D7D6D5D4D3D2D1D0 
LD7LD6LD5LD4LD3LD2LD1LD0I/O port 30H (Read)
LD7 - LD0
8-bit data which is read from the printer port
D7D6D5D4D3D2D1D0 
00000CLRBUSYNSTBI/O port 31H (Read)
NSTB
STROBE signal input (active Low)
BUSY
BUSY signal input (active High)
CLR
Loader clear button input (active Low)
When this button is pressed, LD7 to LD0 all become "0", the ACK signal becomes High, and BUSY signal becomes Low.
D7D6D5D4D3D2D1D0 
*******ACKI/O port 30H (Write)
ACK
0: The ACK signal becomes High.
1: The ACK signal becomes Low (active).

(9) JOYSTICK board (Read Only)

D7D6D5D4D3D2D1D0 
DWEUPETR1TL1RI1LEIDW1UP1I/O port DCH
THE***TRETLERIELEEI/O port DDH
UP1
1P UP switch
DW1
1P DOWN switch
LE1
1P LEFT switch
R11
1P RIGHT switch
TL1
1P TRIGGER left button
TR-1
1P TRIGGER right button
UPE
EXT UP switch
DWE
EXT DOWN switch
LEE
EXT LEFT switch
RIE
EXT RIGHT switch
TLE
EXT TRIGGER left button
TRE
EXT TRIGGER right button
THE
EXT (Same as PC6 input

One bit is read to port as "1" when either there is nothing connected to the terminal or the corresponding switch is not pressed, and is read as "0" when the switch is pressed.

Material

Using the ROM bank switching and backup RAM

In this model, the capacity of the memory can variy between 1 and 4 Hegabits by bank switching.

Note:

Area 0
0000 to 3FFF
Area 1
4000 to 7FFF
Area 2
8000 to BFFF

The size of one bank is 16 Kbyte. The banks are arranged sequentially in the ROM without overlapping.

A. When the memory capacity is 1 Megabit

Area 0 is fixed to bank 0 (first 16 KBytes of the ROM), and area 1 is fixed to bank 1.

Area 2 enables the banks to be switched over by setting a value in register FFFFH.

D7D6D5D4D3D2D1D0 
000001/01/01/0FFFFH

For bank 0, set 00H (same bank as for area 0).

For bank 7, set 07H.

B. If the capacity is 2 MBytes or more, or a backup RAM is provided

(1) Bank control register (FFFCH)

D7D6D5D4D3D2D1D0 
0/10000/101/01/0FFFCH
Write protect Work RAM selectionROM/external RAM selection Bank number offset
Bank number offset
All of the banks for areas 0 to 2 area shifted by 1 bank group (8 banks) time the value 1 to 3 is set here. If an offset number causes a bank number to exceed 1FH(31), it goes Bank 0. The value set here will become valid when it is subsequently set in one of bank registers 0 to 2.
Switching between ROM/external RAM

When 0: The ROM (bank) is assigned to area 2.
When 1: The external RAM is assigned to area 2 (when an external RAM exists).
Work RAM selection
If 1 is set here, normal access to the work RAM (C000H to DFFFH) of the main body will be prevented. Be sure, therefore, to set 0.
WRITE PROTECT
If 1 is set here when the development RAM board is used, data re-write will not take place. Set 0 in mass-production machines.

(2) Bank register 0 (FFFDH)

0000H to 02FFH of area 0 is fixed to bank 0. Bank selection of other areas can be performed by setting a value at FFFDH.

D7D6D5D4D3D2D1D0 
0000/10/11/01/01/0FFFDH

(3) Bank register 1 (FFFEH)

A Bank selection can.be performed in area 1 by setting a value in FFFEH.

D7D6D5D4D3D2D1D0 
0000/10/11/01/01/0FFFEH

(4) Bank register 2 (FFFFH)

A bank selection can be performed in area 2 by setting a value in FFFFH.

D7D6D5D4D3D2D1D0 
0000/10/11/01/01/0FFFFH

Caution:

The above registers are not initialized when the power is switched on. For this reason, be sure to initialize them program in 0 to 3FFFH.. (The first 1 KByte is fixed for this purpose.)

Sometimes, the work RAM cannot be accessed normally, hence the work RAM (and also sub-routines, ) are allowed to be used after this initialization. When using a backup RAM, do not use the first and last addresses because there is a possibility of the data being changed when the power is switched on.

Example

ORG OOOOOH
DI
IM 1
LD SP,0DFF0H
LD A,000H
LD (0FFFCH),A
LD A,000H
LD (0FFFDH),A
LD A,001H
LD (0FFFEH),A
LD A,002H
LD (0FFFFH),A
// ...

MEMORY MAPPING

MEMORY MAP

0000 ┌───────────────────────────┐
     │Cartridge                  |
     |                           |
     |Area 0                     |
4000 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     |Cartridge                  |
     |                           |
     |Area 1                     |
8000 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     |Cartridge                  |
     |                           |
     |Area 2                     |
C000 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     |8 Kbyte work RAM           |
     |                           |
E000 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     |Top image                  |
     |                           |
FFFF └───────────────────────────┘

I/O MAP

00 ┌───────────────────────────┐
   │00,01,02,03,04,05 and 06   |
   |: Used with system control.|
   |                           |
40 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
   |7E -- Read                 |
   |      : V counter          |
   |7F -- Read                 |
   |      : H counter          |
   |7F -- Write                |
   |      : PSG                |
   |                           |
80 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
   |BE and BF                  |
   |: Used with VDP            |
   |                           |
C0 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
   |DC and DD                  |
   |: Used as JOYSTICK inputs. |
   |                           |
FF └───────────────────────────┘

Never access data using an image address.

PSG Manual

The PSG (Programmable Sound Generator) contains three tone generators and one noise generator. Each of the tone and noise generators can be distributed left and right, enabling a pseudo stereo effect to be generated. (See "System Control Port".)

Control of the PSG itself, which is described below, is performed by means of the write operation to I/O area 7FH.

The basic clock is 3.579545 MHz. The data to be sent from the CPU is immediately latched in the PSG, hence there is no need for a wait. The sound output goes OFF in the case of a power-on reset. Design the software so that the output goes OFF at the beginning of the program as well.

[1] Tone generator

Each tone generator consists of a frequency setting section (programmable counter) and a level setting section (programmable attenuator).

(1) Method of calculating the 10-bit frequency division ratio n

At the frequency setting section, the basic clock is frequency-divided to 1/32. This is further frequency divided by the tone counter set by the 10 bits F9 (MSB: top bit) to F0 (LSB: bottom bit).

Consequently, the basic clock frequency is divided by 32, then the desired frequency can be output by setting the value obtained by dividing the frequency-divided clock by the desired frequency in F9 to F0.

n = N/(32 x f)

Where:

(2) Tone frequency setting

Set the 10-bit frequency division ratio (F9 to F0) in the tone counter in order to obtain the desired frequency. The 1st and 2nd bytes are identified by means of the top bit.

1st byte2nd byte
D7D6D5D4D3D2D1D0D7D6D5D4D3D2D1D0
*REG. ADDR.n* n
1R2R1R0F3F2F1F00xF9F8F7F6F5F4
R2R1R0Control register allocation1st
000Tone generator 18x
010Tone generator 2Ax
100Tone generator 3Cx

Frequency division ratio with respect to the output frequency

(3) Example of frequency setting

Consider an example in which the basic clock frequency is 3.579545 MHz and the desired frequency of 440 Hz is output from TONE 1. (corresponding to "A" on the musical scale)

a. Calculation of frequency division ratio n

n = N/(32 x f)
  = 3579545/(32 x 440)
  = 254.229

n is a 10-bit integer, hence the nearest integral value is 254.

Consequently, the frequency actually output is

f = N/(32 x n)
  = 3579545/(32 x 254)
  = 440.397 (Hz)

Here, the pitch error ΔC is obtained according to the following equation.

ΔC = {(f' - f)/f}/(['1280']√2-1)
   = {(440.397-440)/440}/(['1280']√2-1)
   = (0.397/440)/0.000578 = 1.56

b. Oata sent to PSG

n = 254 = 0011111110B

1st byte2nd byte
*REG. ADDR.n* n
1R2R1R0F3F2F1F00xF9F8F7F6F5F4
D7D6D5D4D3D2D1D0D7D6D5D4D3D2D1D0
100011100x001111

(4) Tone level setting

The frequency set by the tone generator is sent to the level setting section where the volume level is set. The level setting section is a programmable attenuator which enables the volume leve to be set in 16 steps from 0 d8 to OFF according to a 4-bit attenuation value.

1st byte only

D7D6D5D4D3D2D1D0
*REG. ADDR.ATT. DATA
1R2R1R0A3A2A1A0
R2R1R0Control register allocationHEX
001Tone 1 attenuation9x
011Tone 2 attenuationBx
101Tone 3 attenuationDx

Attenuation

(db)A3 A2 A1 A0HEX
00 0 0 0x0
20 0 0 1x1
40 0 1 0x2
60 0 1 1x3
80 1 0 0x4
100 1 0 1x5
120 1 1 0x6
140 1 1 1x7
161 0 0 0x8
181 0 0 1x9
201 0 1 0xA
221 0 1 1xB
241 1 0 0xC
261 1 0 1xD
281 1 1 0xE
OFF1 1 1 1xF

[2] Noise generator

The noise generator consists of a noise generator circuit and a level setting section. The source of the noise supplied from the noise generator circuit is a shift register with EX-OR feedback. Each time the noise control register changes, the shift register is cleared.

The shift clock of this shift register is determined by four modes that are in turn determined by NF0 and NF1. If NF0 = NF1 = 0, for example, the shift clock becomes (N/32)/16. In this case, if FB = 0, this shift clock will be frequency-divided by 16, resulting in synchronous noise of a frequency of N/(32 x 16 x 16). If FB = 1, the shift register will be driven by this shift clock with EX-OR feedback, resulting in the generation of white noise.

(1) Noise generator circuit control

1st byte only

D7D6D5D4D3D2D1D0
*REG. ADDR.  SHIFT
1110xFBNF1NF0
FBNoise Generation
0Synchronous Noise
1White noise
NF1NF0Shift clockk
00(N/32)/k16
01(N/32)/k32
10(N/32)/k64
11Tone generator 3At this time, the tone of the noise can be varied continuously

a. Synchronous noise (FB = 0)

When 0NF0 = NF1 = Value other than 1

When NFO = NF1 = 1 (Control by tone 3)

b.White Noise (FB = 1)

Spectrum when NF0 = 0 NF1 = 1 n=1

(2) Noise level setting

1st byte only

D7D6D5D4D3D2D1D0
*REG. ADDR.ATT. DATA
1111A3A2A1A0

[3] Register address feed

PSG uses the three bits R2 to RO of the 1st byte to judge which control register the data has been sent from.

R2R1R0Control register allocation1st
000Tone 1 frequency division ratio8x
001Tone 1 attenuation9x
010Tone 2 frequency division ratioAx
011Tone 2 attenuationBx
100Tone 3 frequency division ratioCx
101Tone 3 attenuationDx
110Noise generator circuit controlEx
111noise attenuationFx

[4] Correlation between the sound elements and PSG

Sound elementPhysical elementCorrelation with PSG
Pitch of soundFrequency[1] - (2) Tone frequency setting, [2]` - (1) Noise generator circuit control
ToneHermonic componentsThis is mainly related to wave length. In the tone generation mode, the PSG can output three frequencies simultaneously from only a 50% duty pulse waveform. Consequently, by combining attenuation control with this mode, the harmonic components can be controlled. In the synchronous noise mode, a 6.25% duty pulse waveform.
Strength of toneAmplitudeAs described in [1] - (3) and [2]` - (2), the attenuation of the three tones and noise can be controlled by 4-bit data.
Way in which sound is emitted.Envelope The wave length at left can be realized by using external data to control each attenuation. This can be done in the range where the 4-bit attenuation data is rewritten and envelope sequence control performed at each step. The tone and noise frequencies can be controlled by the range in which component control can be performed.

Relation between musical interval and frequency division ratio for scale divided equally into 12 parts (basic clock: 3.579545 MHz)

Musical interva1Frequency division ratioHEXPSG output [Hz]Actual frequency [Hz]
A 21017X9 3F109.991110.000
A♯2S60X0 3C116.522116.541
B 2906XA 38123.467123.471
C 3855X7 35130.832130.813
C♯3807X7 32138.613138.591
D 3762XA 2F146.799146.832
D♯3719XF 2C155.578155.563
E 3679X7 2A164.744164.814
F 3641X1 28174.510174.614
F♯3605X0 25134.894184.997
G 3571XB 23195.904195.998
G♯3539XB 21207.534207.652
A 3508XC 1F220.199220.000
A♯3480X0 1E233.044233.082
B 3453X5 1C246.934246.942
C 4428XC 1A261.357261.626
C♯4404XA 19276.884277.183
D 4381XD 17293.598293.665
D♯4360X8 16310.725311.127
E 4339X3 15329.973329.628
F 4320X0 1A349.565349.228
F♯4302XE 12370.400369.994
G 4285XD 11392.495391.995
G♯4269XD 10415.840415.305
A 4254XE 0F440.397440.000
A♯4240X0 0F466.087466.164
B 4226X2 0E494.960493.883
C 5214X6 00522.715523.251
C♯5202XA 0C553.767554.365
D 5190XE 0B588.742587.330
D♯5180X4 0B621.450622.254
E 5170XA 0A658.005659.255
F 5160X0 0A699.131698.456
F♯5151X7 09740.801739.989
G 5143XF 08782.244763.991
G♯5135X7 08828.600830.609
A 5127XF 07880.795880.000
A♯5120X8 07932.174932.328
B 5113X1 07989.920987.767
C 6107XB 061045.4291046.502
C♯6101X5 061107.5341108.731
D 695XF 051177.4841174.659
D♯690XA 051242.8991244.508
E 685X5 051316.0111318.510
F 680X0 051398.2621396.913
F♯676XC 0A1471.6541479.978
G 671X7 0A1575.5061567.982
G♯667X3 0A1669.5661661.219
A 664X0 0A1747.8271760.000
A♯660XC 031864.3491864.655
B 657X9 031962.4731975.533

1st is the 1st byte 2nd is the 2nd byte

The upper limit is 3579545/32-1

If a frequency of no greater than that generated by the tone generator is output, the outputs shown in the table below will be obtained due to the synchronous noise mode of the noise generator section. (Basic clock: 3.579545 MHz)

Musical intervalFrequency division ratioHEX (TONE3)PSG output [Hz]Actual frequency [Hz]
C 0428CC 1A16.33516.352
C♯0404C4 1917.30517.324
D 0381C0 1718.35013.354
D♯0360C8 1619.42019.445
E 0339C3 1520.62320.602
F 0320C0 1421.84821.827
F♯0302CE 1223.15023.125
G 0285CD 1124.53124.500
G♯0269CD 1025.99025.957
A 0254CE 0F27.52527.500
A♯0240C0 0F29.13029.135
B 0226C2 0E30.93530.868
C 1214C6 0D32.67032.703
C♯1202CA 0C34.61034.648
D 1190CE 0B36.79636.708
D♯1180C4 0B38.84138.891
E 1170CA 0A41.12541.203
F 1160C0 0A43.69643.654
F♯1151C7 0946.30046.249
G 1143CF 0848.89048.999
G♯1135C7 0851.78751.913
A 1127CF 0755.05055.000
A♯1120C8 0758.26158.270
B 1113C1 0761.87061.735
C 2107CB 0665.33965.406
C♯2101C5 0669.22169.296
D 295CF 0573.59373.416
D♯290CA 0577.68177.782
E 285C5 0582.25182.407
F 280C0 0587.39187.307
Fv276CC 0491.99192.499
G 271C7 0498.46997.999
G♯267C3 04104.348103.826

Supplementary description for manual

A. System control port

(3) I/O port 02H (Read/Write)

Addition:

An NMI is enabled after the execution of one command from when the port is set to "0". This is to prevent the hMI from becoming active once again in the NMI routine. Normally, therefore, perform the following processing.

NMI:
  ...
  LD A,11XXXXXXB
  OUT (002H),A
  LD A,01XXXXXXB
  OUT (002H),A
  R£TN ; An hMI is enabled after this command.

B. System control port

(6) I/O port 05H (Read/Write)

Mode setting for serial communications

Addition

When using this function (serial communications NMI), set NINT of I/O port 02H to the disable state ("1"). An NMI will be generated at the fall of the pulse at the NMI terminal. If, however, a serial communications NMI is generated, the NMI terminal will go LOW, preventing the next NMI from becoming active. The NMI terminal is made HIGH as a result of reading the data of I/O port 04H, so read the data each time an NMI is generated. If it is conceivable that the NMI terminal may already be LOW at the start of the communications, perform a "dummy" read operation once.

(7) I/O port 06H (Write Only)

Left-right distribution of sound

Supplementary explanation

When the headphones are plugged in, the output from the speaker is cut off and instead the sound will be heard in stereo from the headphones. When the earphones are not plugged in, the sound will be heard from the speaker in monaural. In the latter case, the distribution of the sound from all channels (three tones 4 noise) will be enabled. If the output from the left and right channels was disabled not by attenuator control but by distribution, the sound will not be heard from the headphones but will.be.heard from the speaker. To turn off both the left and right channels of the speaker, use the PSG.

C. Communications

(1) Connecting the communications cable

Cross-connect the game gear communications cable as shown below.

Communications connector

1PC0To opposite side PC2
2PC1To opposite side PC3
3PC2To opposite side PC0
4PC3To opposite side PCI
5+5V 
6PC4To opposite side PCS
7PC6To opposite side PC8
8GNDTo opposite side GND
9PC5To opposite side PC4
10NC 

(2) Parallel communications

PC0 to PCS can be set to an arbitrary input or output by means of the control register of the I/O port. 8e sure to set the connecting terminals so that the terminal on one side is the output, and that on the opposite side is the input. (Never make the terminals on both sides the output.) In the case of parallel communications, control the exchange of data either by polling using software (check the data), or by applying an interrupt (NMI) using PC6. When applying an NMI using PC6, however, it is necessary to take noise into account because an NMI will be generated by a momentary change in PC6.

(3) Serial communications

Serial communications can be performed in one of two single directions, from PC4 (output from one’s own side) → PCS (input to opposite side), or from PC5 (input to one’s own side) <- PC4 (output from opposite side). Serial and parallel conversion and interrupt (WI) generation (when data is received) accompanying the receiving or sending of data take place automatically when the hardware is connected to these terminals. To perform serial communications, set TON and RON of I/O port OSH to "1". By doing this. PC4 will automatically become the output, and PC5 the input. These settings will take priority over the PC4 and PC5 input/output settings. 8its other than those of PC4 and PC5 will become the settings of I/O port 02H. (Like (2). never make both terminals the output.) When performing serial communications only, be sure to set NINT of I/O port 02H to prevent PC6 from generating an NMI.

(4) Coexistence of parallel and serial communications

When performing serial communications, PC4 and PCS are used to send and receive serial data. Parallel communications can be performed using the bits other than these. An NMI can be generated by PCS and also by receiving of serial data. In the former case, care must be taken because PC6 goes not have a data receiving flag such as the serial RXR0. The blocks of the circuit used to generate these NMI are shown below.

An NMI is generated when one of the two reset flip-flops is set. (This is because an NMI is generated not when the pulse level is LOW but when the pulse falls.) It should be appreciated that it is necessary to reset the set flip-flop so that the next NMI can be generated.

VDP Manual

(1) GAME GEAR FEATURES

(2) Effective area and CO display area

This VDP was initially designed on the basis of a TV (NTSC) format, hence only a portion of the picture created by the VDP is displayed on the LCD. This relationship is shown in the figure below.

Consequently, when a developing board or TV adapter is installed, the LCO display part will appear on part of the screen, and the backdrop color will be displayed on the remaining part. (Set to a color approaching that of a game screen.) When the screen is ON and timing is in the effective area, the VDP will generate an image, hence (even for a part which is not displayed on the LCD) if timing is within this area, the game program will be subjected to various restrictions (wait condition, etc.).

(3) Image display

Note: In the following description, there are bits that are fixed at "0" or "1" and should remain in this default position.

(1) Access to VDP

It is necessary to set data in the VDP register, color RAM, VRAM, and so on in order to display an image on the screen. This is because data cannot be accessed directly from the CPU, and must be accessed instead via the VDP assigned to the I/O port.

a. Reading the status register

The status register indicates various states of the VDP. It can read the CPU by reading the I/O port BFH. This register can read the CPU at any time without any need to take account of the VDP delay.

D7D6D5D4D3D2D1D0 
F9SCMeaninglessI/O port BFH
Interrupt flag (F)

This flag is "1" when the effective area is completed. If, at this time, the IE bit of the VDP register #1 is set to "1", the interrupt line from the VDP to the CPU will become Low, causing an interrupt to be applied (generally called a V interrupt). If the program leaves the interrupt routine in this state, the interrupt will be applied again immediately (an interrupt of Z80 will not occur at the edge of plus, hence the status register will be read at the beginning of the interrupt routine and the flag will be reset.

Example

  ORG 00038H
  PUSH AF
  IN A,(08FH) ; RESET STATUS FLAG
  ...
  POP AF
  EI
  RET
9th sprite (9S)

If the 9th and higher sprites exist on the same horizontal line (in the effective area), and the interrupt flag (F) is "O", the 9S bit will be set to "1". (within the effective area)

Collision flag

This flag is set t0 "1" if dots of color codes other than 0, of two or more sprites collide (coincide). --In the effective area

b. Writing to VDP registers (#0 to #10)

A selection of the display mode or other functions and also data for each base address setting are written to the VDP registers (write-only registers). Data transfer from the CPU takes place in the following format. Data can be written to these registers without any need to take account of VDP delay.

 b7b6b5b4b3b2b1b0
First byte: Data set in the register (I/O port BFH)D7D6D5D4D3D2D1D0
Second byte: Register selection (I/O port BFH)1000R3R2R1R0

To set data in a VDP register, the data is inputted in the first byte. The second byte is used to indicate the register where the data is to be transferred.

The bottom four bits (R3 to R0) of the second byte designate the data transfer destination registers (#O to #10). b7 must be "1" and b6 to b4 must be "0". Never attempt to access registers that do not exist (#11 to #15).

Example: When setting E0H in register #1

   [IN A,(0BFH)] ; INITIALIZE
    LD A,0E0H
    OUT (0BFH),A ; OATA
    LD A,081H
    OUT (0BFH),A ; REGISTER NO.

Consequently, if data is written in the correct sequence, [IN A, (OBFH)] in the previous example can be omitted. Here, it is necessary to takes steps to prevent the CPU from accepting an interrupt while data is being written to a register or VRAM address setting is being carried out (described later). If an interrupt is applied after the first byte has been sent, the data will fail to be transferred correctly if the status register is read during the interrupt (the second byte written after the program leaves the interrupt routine will be received as the first byte.

[Page 5 missing]

d. Reading from VRAM

The CPU reads data from the VRAM via the VDP. The addresses are auto-incremented. (See sub-section "Writing to VRAM".)

 b7b6b5b4b3b2b1b0
First byte: Address set-up (I/O port BFH)A7A6A5A4A3A2A1A0
Second byte: Address set-up (I/O port BFH)00A13A12A11A10A9A8
Third byte: Write data (I/O port BEH) Necessary number of repetitionsD7D6D5D4D3D2D1D0

The bottom eight bits of the VRAM address are set up by the first byte.

The top six bits are set up by the second byte. Be sure to set b7 and b6 to "0".

The data is read by the third byte.

Once the address register has been set up, the data will be incremented automatically each time the third byte data is transferred.

Example: Write two addresses continuously from VRAM address 0000H. (effective area & screen ON)

    LD A,000H
    OUT (0BFH),A
    LD A,000H
    OUT (0BFH),A
    PUSH IX       ; WAIT 15 CLOCK
    POP IX        ; WAIT 14 CLOCK    TOTAL 29 CLOCK
    IN A,(0BEH)
    PUSH IX       ; WAIT
    POP IX        ; WAIT
    IN A,(0BEH)
    PUSH IX       ; WAIT
    POP IX        ; WAIT

e. VRAM special access

If data is written to a VRAM using address auto increment, it will be written to a continuous address. Data can be written to discrete addresses by dummy reading it. Observe the wait conditions while a screen is being displayed in the effective area.

Example: Write 256 bytes 01H to each address from VRAM address 3800H. (effective area & screen ON)

    LD A,000H
    OUT (0BFH),A
    LD A,078H
    OUT (0BFH),A
    LD B,000H
LOOP:
    LD A,001H     ;        7 CLOCK    TOTAL 41 CLOCK
    OUT (0BEH),A  ;       11 CLOCK
    PUSH IX       ; WAIT  15 CLOCK
    POP IX        ; WAIT  14 CLOCK    TOTAL 29 CLOCK
    IN A,(0BE1)
    PUSH AF       ;       11 CLOCK
    POP AF        ;       10 CLOCK
    DJNZ LOOP     ;       13 CLOCK

f. Writing to the color RAM

The VDP contains a 12-bit x 32-word color RAM. This color RAM is a write-only RAM. The CPU transfers data to the color RAM via the VDP, using an auto increment address register.

 b7b6b5b4b3b2b1b0
First byte: Address set-up (I/O port BFH)00A5A4A3A2A1A0
Second byte: 0C0H set-up (I/O port BFH)11000000
Third byte: Write data (I/O port BEH)
Repetition of write necessary number of times
(For even addresses)G3G2G1G0R3R2R1R0
 (For odd addresses)0000B3B2B1B0

The first byte sets up five bits of the color RAM address.

The second byte always sets COH.

The third byte transfers data.

Once the address register is set up, it is automatically incremented each time the third byte of data is transferred. The color RAM has two addresses (even and odd addresses) which comprise a single color (12 bits). Normally, therefore, the even address is set up, then the R & G data and B data are set in that sequence. Actual writing of data to the color RAM takes place when data is set in the odd address (12 bits of data are written). Note, however, that when the odd address is set up and B data written, the R & G data previously set will be written.

Example :

Write 0FH & 00H (bright red) and F0H & 00H (bright green) from color RAM address 04H. (effective area & screen ON)

    LD A,004H
    OUT (0BFH),A
    LD A,0C0H
    OUT (0BFH),A
    LD A,00FH
    OUT (0BEH),A
    PUSH AF         ; WAIT  11 CLOCK
    POP AF          ; WAIT  10 CLOCK
    LD A,000H       ;        7 CLOCK    TOTAL 28 CLOCK
    OUT (0BEH),A
    PUSH AF         ; WAIT
    POP AF          ; WAIT
    LD A,0F0H
    OUT (0BEH),A
    PUSH AF         ; WAIT
    POP AF          ; WAIT
    LD A,000H
    OUT (0BEH),A
    PUSH IX         ; WAIT  15 CLOCK
    POP IX          ; WAIT  14 CLOCK    TOTAL 29 CLOCK

the screen will flicker. This cannot be avoided even by setting the BLANK bit to "0" to turn the screen OFF. For this reason, write data to the color RAM during V blanking.

(2) VDP register (write only)

a. Register #0, register #1

(These two registers are reset to "0" at power switch-on.)

 D7D6D5D4D3D2D1D0
Register #0HVS00IE1EC110
Register #11BLANKIE000SIZE0
EC (Early Clock)
0: Normal
1: The horizontal position of all sprites shifts eight dots to the left.
IE, IE1 (Interrupt Enable)
IE is an interrupt enable bit used at the completion of the effective area.
0: Disable
1: Enable
IE1 is an interrupt enable bit used at an arbitrary vertical position.
0: Disable
1: Enable
HVS
0: Normal
1: The two cells at the right end of the LCD screen are not scrolled in the vertical direction.\\ * A horizontal scroll is not disabled.
SIZE
0: Normal
1: The sprite size becomes 8 x 16 dots. In this case, the top seven bits of the character No. are enabled (number of definitions = 128 kinds).
BLANK
0: Nothing is displayed on the screen. In this case, the backdrop color is displayed, and the wait used for VDP access is unnecessary.
1: An image is displayed on the screen.
* The screen display can be turned ON and OFF at any time.

b. Register #2

(This register is not reset at power switch-on, hence its contents are indeterminate.)

This register determines the base address (starting address) of the pattern name table in the VRAM. The pattern name table requires 32 cells (horizontal) x 28 cells (vertical) x 2 bytes = 1792 (700H) bytes. The relation between the set data and the base address is shewn below.

D7D6D5D4D3D2D1D0 
1111XXX1Register #2
  
Base addressXXX00000000000
 A13A12A11A10A9A8A7A6A5A4A3A2A1A0

((Data)- F1H) x 400H = Base address

Set dataBase address
F1H0000H
F3H0800H
F5H1000H
F7H1800H
F9H2000H
FBH2800H
FDH3000H
FFH3800H

Normally FFH is set and the pattern name table started from 3800H.

c. Register #3

(This register is not reset at power switch-on, hence ks contents are indeterminate.)

Be sure to set FFH in this register with a program.

d. Register #4

(This register is not reset at power switch-on, hence its contents are indeterminate.)

Be sure to set FFH in this register with a program.

e. Register #5

(This register is not reset at power switch-on, hence its contents are indeterminate.)

This register determinates the base address of the sprite attribute table in the VRAM.

The sprite attribute table consists of 256 (100H) bytes. The relation between the set data and the base address is shown below.

D7D6D5D4D3D2D1D0 
1XXXXXX1Register #5
  
Base addressXXX00000000000
 A13A12A11A10A9A8A7A6A5A4A3A2A1A0

((Data)- 81H) x 80H = Base address

DataBase addr
81H0000H
83H0100H
85H0200H
87H0300H
89H0400H
8BH0500H
8DH0600H
8FH0700H
91H0800H
93H0900H
95H0A00H
97H0B00H
99H0C00H
9BH0D00H
9DH0E00H
9FH0F00H
A1H1000H
A3H1100H
A5H1200H
A7H1300H
A9H1400H
ABH1500H
ADH1600H
AFH1700H
B1H1800H
B3H1900H
B5H1A00H
B7H1B00H
B9H1C00H
BBH1D00H
BDH1E00H
BFH1F00H
C1H2000H
C3H2100H
C5H2200H
C7H2300H
C9H2400H
CBH2500H
CDH2600H
CFH2700H
D1H2800H
D3H2900H
D5H2A00H
D7H2B00H
D9H2C00H
DBH2D00H
DDH2E00H
DFH2F00H
E1H3000H
E3H3100H
E5H3200H
E7H3300H
E9H3400H
EBH3500H
EDH3600H
EFH3700H
F1H3800H
F3H3900H
F5H3A00H
F7H3B00H
F9H3C00H
FBH3D00H
FDH3E00H
FFH3F00H

f. Register #6

(This register is not reset at power switch-on, hence its contents are indeterminate.)

This register determines the base address of the sprite generator table. The relation between the set data and the base address is shown below.

D7D6D5D4D3D2D1D0 
11111X11Register #6
  
Base addressX0000000000000
 A13A12A11A10A9A8A7A6A5A4A3A2A1A0

((Data)- F8H) x 80CH = Base address

Set data8ase address
FBH0000H
FFH2000H

g. Register #7

(This register is set to "0" at power switch-on.)

They are used to set the backdrop color.

D7D6D5D4D3D2D1D0
0000C3C2C1C0

There are 40H addresses in the color RAM. Of the 16 sets of color data in addresses 20H to 3FH (palette 1 side), the sets designated by the bottom four bits (C3 to C0) of this register constitute the backdrop color.

h. Register #8

(This register is set to "0" at power switch-on.)

It is used to set the horizontal scroll.

D7D6D5D4D3D2D1D0
HS7HS6HS5HS4HS3HS2HS1HS0

Each time a value of 1 is set in this register, the scroll screen moves one dot to the right in the horizontal direction. The number of dots in the horizontal direction in the virtual area is 256. Consequently, if a value of -1 (FFH) is set, the screen will move one dot to the left in the horizontal direction. This register is effective only for the scroll screen. It has no effect on sprites. The value written to this register is latched at the timing of the H counter F4H (see " (5) H counter, V counter"), then becomes active. Consequently, horizontal scrolling can be performed one line at a time by using an interrupt at an arbitrary vertical position to re-write the data.

i. Register #9

(This register is set to "O" at power switch-on.)

It is used to set the vertical scroll.

D7D6D5D4D3D2D1D0
VS7VS6VS5VS4VS3VS2VS1VS0

Each time a value of 1 is set in this register, the scroll screen moves one dot in the upward direction. The number of dots in the vertical direction in the virtual area is 224. Consequently, if a value of 224 or more is set, the screen will scroll in the upward direction by an amount corresponding to that value minus 224. Also, the value that was set in this register immediately in front of the effective area (for line 511) will become effective during that frame, preventing the vertical scroll from being changed while display timing.

j. Register #10

(This register is set to "1" at power switch-on.)

It is used to control an interrupt at an arbitrary vertical position.

D7D6D5D4D3D2D1D0
VC7VC6VC5VC4VC3VC2VC1VC0

The value set in this register is loaded in the down counter in the VDP. This counter counts down each line. When the count is 0, an interrupt is generated.

A count-down takes place only for the line in the effective area and the line immediately preceding it (line 511). For other lines, the down counter simply continues to load the value written to this register without counting down or generating an interrupt. This interrupt is generated during H blanking (H counter F4H), and the value in the register at this time is loaded once again to the down counter.

When 00H is set in the register, an interrupt is generated at every line, and when 01H is set in the register, an interrupt is generated at every second line.

As an example, consider a method of horizontal scrolling as shewn in the figure below.

  1. After completion of the effective area, set "1" in IE1 of register #0, and set 0BH in register #10. These values continue to be loaded in the down counter until line 511 appears.
  2. An interrupt is generated after line 10 has been scanned. 0BH will be loaded in the down counter once again. The status register is read and the interrupt cleared (this takes place each time), and 00H is set in register #10.
  3. An interrupt is generated after line 22 has been scanned. 00H is leaded in the down counter. 03H is set in register #8 as the horizontal scroll. (It becomes effective for the first time when the next H counter F4H arrives.)
  4. An interrupt is generated after line 23 has been scanned. 00H is leaded in the down counter once again. The interrupt is generated at the timing of the H counter F4H, hence the horizontal scroll 02H set in 3) is also effective at this time. 05H is set in register #8 as the horizontal scroll.
  5. An interrupt is applied after line 24 has been scanned by the horizontal scroll 03H. 00H is loaded in the down counter. The horizontal scroll 05H is effective. 07H is set in register #8, and 5CH (92) is set in register #10.
  6. An interrupt is applied after line 25 has been scanned by the horizontal scroll 05H. A horizontal scroll of 07H is effective, and 5CH is loaded in the down counter. 00H is set in register #10.
  7. The next interrupt is applied after line 118 has been scanned. 00H is loaded in the down counter, then an interrupt is applied at each line. 05H is set in register #8.
  8. An interrupt is applied after line 119, and horizontal scroll 05H becomes effective. The horizontal scroll up to now is 07H. 0BH is set in register #8. Subsequently, "0" is set in IE1 and the interrupt is disabled.
┌───────────────────────────┐ Line 24 horizontal scroll: 03H
|┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄| Line 25 horizontal scroll: 05H
│Horizontal scroll between  |
| line 26 and line 119: 07H |
|                           |
|┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄| Line 120 horizontal scroll: 08H
|Horizontal scroll between  |
| line 121 and line 167: 08H|
|                           |
└───────────────────────────┘ Line 167

(3) Standard VRAM mapping

Example: Setting the register

    LD HL,TBLREG
    LD B,11
    LD C,080H
LOPP:
    LD A,(HL)
    INC HL
    OUT (0BFH),A
    LD A,C
    INC C
    OUT (0BFH),A
    DJNZ LOOP
    RET

TBLREG:
    DEFB 036H,0E0H,0FFH,0FFH,0FFH,0FFH,0FFH,000H
    DEFB 003H,006H,001H
0000 ┌───────────────────────────┐
     | Pattern generator table   |
     | ( to 37FFH )              |
     |                           |
2000 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     | Sprite generator table    |
     | ( to 37FFH )              |
     |                           |
     | Shared part               |
     |                           |
3800 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     | Pattern name table;       |
     | Two bytes per cell        |
3F00 |┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄|
     |Sprite attribute table     |
3FFF └───────────────────────────┘

(4) Scroll screen display

a. Pattern name table

         |←                               32 rows                              →|
       ──┼──────────────────────────────────────────────────────────────────────┤
       ↑ |  0 (1st byte, 2nd byte).......................................... 31 |
         | 32 .............................................................. 63 |
         | 64  65  66  67  68  69 ...................... 90  91  92  93  94  95 |
         |  .                     ┌────────────────────┐                      . |
         |  . Virtual area        | 102............121 | (When scrolling      . |
         |  . 32 rows x 29 lines  | 134............153 |  is not taking place). |
         |  .                     |                    |                      . |
         |  .                     | LCD display area   |                      . |
28 lines |  .                     | 20 rows x 18 lines |                      . |
         |  .                     |                    |                      . |
         |  .                     | 514............623 |                      . |
         |  .                     | 645............665 |                      . |
         |  .                     └────────────────────┘                      . |
         | 672 673 674 675 676 677 .................... 689 699 700 701 702 703 |
         | 704 ............................................................ 735 |
         | 736 ............................................................ 767 |
         | 768 ............................................................ 799 |
         | 800 ............................................................ 831 |
         | 832 ............................................................ 863 |
       ↓ | 864 ............................................................ 895 |
       ──┴──────────────────────────────────────────────────────────────────────┘

The pattern name table starts from the position determined by register #2. Two bytes correspond to one cell of the scroll screen. These bytes are arranged in the sequence byte 1, byte 2. A pattern name table consisting of 32 x 28 x 2 = 1792 (700H) bytes is used for the virtual area. Part of this is used for the the LCD.

A description is given below of the contents of the two bytes which correspond to each cell.

 D7D6D5D4D3D2D1D0
Byte 1CH7CH6CH5CH4CH3CH2CH1CH0
Byte 2***PRICPTRVVRVHCH8
CH0 to CH8
Set the No. of the character to be displayed on the cell, in these nine bits.
RVH
0: Normal
1: The cell character pattern is left-right reversed.
RVV
0: Normal
1: The cell character pattern is up-down reversed.
CPT
This is the color palette select bit.
0: Selects color palette 0 (color RAM addresses 00H to 1FH)
1: Selects color palette 1 (color RAM addresses 20H to 3FH)
PRI
0: Normal (The sprites are displayed at the over of the scroll screen.)
1: When the color code setting for the scroll-screen dots is other than 0, the scroll screen is prioritized over sprites.
D7 to D5 of byte 2
The data in this part is not used in the hardware. hence it can be used in software, such as for flags.

b. Pattern generator table

The pattern generator table always starts from address 0000H. Eight dots in the horizontal direction are represented by four bytes, and one character is represented by 4 x 8 = 32 (20H) bytes.

32 bytes correspond to the color code pattern of the characters, as shown in the example below. (Please be aware that the respective dots constitute a color code which is represented by the four bits C3 to C0.)

Example:

      Pattern generator                                  Character color code pattern
   07  06  05  04  03  02  01  00                      Left                      Right
   ┌───┬───┬───┬───┬───┬───┬───┬───┐    ───────────   ┌───┬───┬───┬───┬───┬───┬───┬───┐
 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | C0             0 | F | E | D | C | 3 | 2 | 1 | 0 |
   ├───┼───┼───┼───┼───┼───┼───┼───┤         ┌─────   ├───┼───┼───┼───┼───┼───┼───┼───┤
 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | C1      |        ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎
   ├───┼───┼───┼───┼───┼───┼───┼───┤         |        ├╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┤
 2 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | C2      |        ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎
   ├───┼───┼───┼───┼───┼───┼───┼───┤         |        ├╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┤
 3 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | C3      |        ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎
   ├───┼───┼───┼───┼───┼───┼───┼───┤    ─────┘        ├╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┤
   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎                  ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎
   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎                  ├╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┼╌╌╌┤
   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎                  ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎   ╎
   ├───┼───┼───┼───┼───┼───┼───┼───┤    ───────────   ├───┼───┼───┼───┼───┼───┼───┼───┤
28 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | C0             7 | 7 | B | D | E | 8 | 4 | 2 | 1 |
   ├───┼───┼───┼───┼───┼───┼───┼───┤         ┌─────   └───┴───┴───┴───┴───┴───┴───┴───┘
29 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | C1      |
   ├───┼───┼───┼───┼───┼───┼───┼───┤         |
30 | 1 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | C2      |
   ├───┼───┼───┼───┼───┼───┼───┼───┤         |
31 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | C3      |
   └───┴───┴───┴───┴───┴───┴───┴───┘    ─────┘

In other words, if an address consisting of 32 bytes is divided as follows,

Group 0
0, 4, 8, 12, 16, 20, 24, 28
Group 1
1, 5, 9, 13, 17, 21, 25, 29
Group 2
2, 6, 10, 14, 18, 22, 26, 30
Group 3
3, 7, 11, 15, 19, 23, 27, 31

A pattern will be obtained in which Group 0 corresponds to the 0th bit of the color code, Group 1 to the 1st bit, Ground 2 to the 2nd bit, and Group 3 to the 3rd bit. (These groups can be considered to correspond to four planes.)

                                   ┌────────────────┐
                                   |    0th byte    |
                         ┌─────────┴──────┬─────────┤
                         |    1st byte    |         ╎
               ┌─────────┴──────┬─────────┤ Group 0 ╎
               |    2nd byte    |         ╎  (C0)   ╎
 ──  ┌─────────┴──────┬─────────┤ Group 1 ╎         ╎
 ↑   |    3rd byte    |         ╎  (C1)   ╎─────────┤
     ├────────────────┤ Group 2 ╎         ╎28th byte|
 8   ╎                ╎  (C2)   ╎─────────┼─────────┘
dots ╎  Group 3 (C3)  ╎         ╎29th byte|
     ╎                ╎─────────┼─────────┘
     ╎                ╎30th byte|
     ├────────────────┼─────────┘
 ↓   |   31st byte    |
 ──  └────────────────┘
     |←    8 dots    →|

Example: Character color code pattern assuming that the following data was input from address 0000H, the pattern of the color code of character 0 will change as follows.

DataColor code pattern from character 0
ADDRESS+0+1+2+3LeftRight
0000AACCF0F00 FEDC3210
0004010204081 00008421
0008102040802 84210000
000C0F0FF0F03 CCCC3333
0010008180004 60000002
00143F00F0005 44551111
0018556678806 87654321
001CE1D2B4787 7BDE8421

c. Color Ram

When the color code pattern is determined by the pattern generator table, RGB data will be read from the corresponding color RAM, resulting in a character color pattern. The color RAM has a capacity of 12 bits x 32 words, and the color code expresses A4 to A1 of the color RAM addresses. A5 is determined by the palette. In the case of a scroll screen character, it is determined by the CPT bit of the second byte in the pattern name table. Four bits each of the 12-bit data are assigned to R, G and B, respectively, enabling a total of 4096 colors to be displayed. Thirty two colors from these 4096 colors are set and displayed with the palettes and color codes.

Palette 0

Color code Color RAM data
Address C3 C2 C1 C0 Component
00H 0 0 0 0 Red & Green
01H Blue
... ... ...
1EH 1 1 1 1 Red & Green
1FH Blue

Palette 1

Color code Color RAM data
Address C3 C2 C1 C0 Component
20H 0 0 0 0 Red & Green
21H Blue
... ... ...
3EH 1 1 1 1 Red & Green
3FH Blue

The relationship between the color RAM data and color is shown below.

Even addressesOdd addressesColor
00H00HBlack
0FH00HBright red
F0H00HBright green
00H0FHBright blue
FFH0FHWhite

(5) Displaying sprites

a. Sprite attribute table

A maximum of 64 sprites, each defined by vertical position, horizontal position and character No., can be displayed, hence the sprite attribute table uses 3 x 64 = 192 bytes. An actual sprite attribute table consists of an area of 256 bytes, 64 bytes of which are unused. At a vertical position, D0H has the meaning of an end code, hence if D0H is written to a vertical position, the display of all subsequent sprites will be disabled. To prevent a particular sprite from being displayed, set E0H in the corresponding vertical position.

When the base address of the sprite attribute table is address 3F00H

3F00 ┌─────────────────┐
     | Vertical posi   | (Sprite 0)
     ├─────────────────┤
     | Vertical posi   | (Sprite 1)
     ├─────────────────┤
     ╎                 ╎
     ╎      ╎          ╎
     ╎      ╎          ╎
     ╎                 ╎
     ├─────────────────┤
     | Vertical posi   | (Sprite 62)
     ├─────────────────┤
     | Vertical posi   | (Sprite 63)
     ├─────────────────┤
3F40 ╎ Unused          ╎
     ╎   (64 bytes)    ╎
     ╎                 ╎
     ╎                 ╎
     ├─────────────────┤
3F80 | Horizontal posi | (Sprite 0)
     ├─────────────────┤
     | Character No.   | (Sprite 0)
     ├─────────────────┤
     | Horizontal posi | (Sprite 1)
     ├─────────────────┤
     | Character No.   | (Sprite 1)
     ├─────────────────┤
     ╎                 ╎
     ╎      ╎          ╎
     ╎      ╎          ╎
     ╎                 ╎
     ├─────────────────┤
     | Horizontal posi | (Sprite 63)
     ├─────────────────┤
3FFF | Character No.   | (Sprite 63)
     └─────────────────┘

b. Sprite generator table

The base address of the sprite generator table is determined by register #6. Apart from this, the sprite generator functions in the same way as the pattern generator table. Here too, each 20H is allocated to one sprite character.

c. Color RAM

The color RAM is treated in exactly the same way as the scroll screen except for the fact that the palette on the 1 side is always selected. The part corresponding to color code 0 is transparent, even if color data is set in it.

d. Sprite coordinates

          Horizontal position
          30H                       CFH
      17H ┌───────────────────────────┐
          | LCD display area          |
Vertical  |       (scroll screen)     |
position  | (horizontal position,     |
          |       vertical position)  |
          |         ↓                 |
          |         ┌──┐              |
          |         |  |              |
          |         ├──┤              |
          |         ╎  ╎              |
          |         └╌╌┘              |
          |                           |
      A6H └───────────────────────────┘

The coordinate system of a sprite is as shown in the figure at left.

It is displayed so that the dot at the top left of the sprite is located at the top (horizontal position, vertical position). This also applies for a size of 8 x 16 dots.

When the horizontal position is outside the range 30H to CFH, the sprite exists in the effective area. Also, in the case of the vertical position, the sprite exists in the effective area so long as it is in the range FFH to 16H and A7 to BEH.

e. SIZE bit

If "1" is set in the SIZE bit, an 8 x 16 dot (vertical length) sprite will be displayed. In this case, the top seven bits of the character No. set in the sprite attribute table will be effective. If the number of character No. is b7b6b5b4b3b2b10 (or b7b6b5b4b2b11; b0 is ineffective), the character b7b6b5b4b3b2b10 will be displayed in the position of A, and the character of b7b6b5b4b3b2bl1 in the position of B.

        |←  8 dots  →|
      ──┼────────────┤
      ↑ |            |
        |            |
        |     A      |
        |            |
        |            |
16 dots ├────────────┤
        |            |
        |            |
        |     B      |
        |            |
      ↓ |            |
      ──┴────────────┘

f. Sprite display limits

╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌┌───┐╌╌╌╌╌╌╌╌╌╌╌╌╌┌───┐╌
               | 3 |                   | 1 |             | 2 |             | 2 |   ↓
╌╌╌╌╌╌╌╌╌┌───┐╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌
         | 4 | |   |                   |   |             |   |             |   |
╌╌╌╌╌╌╌╌╌├───┤╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌┌───┐╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌
         |   | |   |                   |   |             |   | |12 |       |   |   ↑
╌╌╌┌───┐╌├───┤╌├───┤╌╌╌╌╌╌╌┌───┐╌┌───┐╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌├───┤╌╌╌╌╌╌╌├───┤╌  R
   |11 | |   | |   |       | 8 | | 0 | |   |             |   | |▒▒▒|       |   |   a
╌╌╌├───┤╌├───┤╌└───┘╌╌╌╌╌╌╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌├───┤╌┌───┐╌├───┤╌  s
   |   | |   |             |   | |   | |   |             |   | |▒▒▒| | 5 | |   |   t
╌╌╌├───┤╌├───┤╌╌╌╌╌╌╌┌───┐╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌┌───┐╌├───┤╌├───┤╌├───┤╌├───┤╌  e
   |▒▒▒| |   |       |▒▒▒| |   | |   | |   |       | 7 | |   | |▒▒▒| |   | |   |   r
╌╌╌├───┤╌├───┤╌┌───┐╌├───┤╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌
   |▒▒▒| |   | |▒▒▒| |▒▒▒| |   | |   | |   |       |   | |   | |▒▒▒| |   | |   |   L
╌╌╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌└───┘╌╌╌╌╌╌╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌  i
   |▒▒▒| |   | |▒▒▒| | 9 | |   | |   |             |   | |   | |▒▒▒| |   | |   |   n
╌╌╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌└───┘╌├───┤╌├───┤╌└───┘╌  e
   |   | |   | |10 | |   | |   | |   |             |   |       |▒▒▒| |   |       
╌╌╌├───┤╌└───┘╌├───┤╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌├───┤╌├───┤╌╌╌╌╌╌╌
   |   |       |   | |   | |   | |   |             |   |       |   | |   |       
╌╌╌├───┤╌╌╌╌╌╌╌├───┤╌├───┤╌├───┤╌├───┤╌╌╌╌╌╌╌╌╌╌╌╌╌├───┤╌╌╌╌╌╌╌└───┘╌├───┤╌╌╌╌╌╌╌
  →|   |← Max 8 dots

 ┌───┐
 |▒▒▒| The shaded areas become transparent, and the background pattern is displayed
 └───┘

(6) H counter, V counter

The VDP displays an image based on the H counter and the V counter. The H and V counter values can also be read from the CPU. The value of the H counter is effective only when a special clock pulse.

The H counter corresponds to dots, and the V counter corresponds to lines. Both are 9-bit counters. The CPU reads the top eight bits of the H counter, and reads the bottom eight bits of the V counter.

These data can be read at any time.

a. H counter

Reads I/O port 7FH (PSG control in the case of a write operation).

Two dots are equivalent to one count, and three counts are equivalent to four CPU clock pulses. (1H = 342 dots = 171 counts = 228 CPU clock pulses)

F4H                                     F3H
┌─────┬─────────────────────────────┬─────┐
|  FFH╎00H                       93H╎E9H  |
|     ╎     20H             6FH     ╎     |
|     ╎     ┌─────────────────┐     ╎     |
|     ╎     |LCD display area |     ╎     | 
|     ╎     |                 |     ╎     | 
      ↑                             ↑
Counter no. jumps             Counter no. jumps 
from FFH to 00H               from 93H to E9H

b. V counter

Reads I/O port 7EH

One line is equivalent to one count.

(1 FRAME = 262 lines)

D8H ┌───────────────────────
    |         
FFH | Counter no. jumps from FFH to 00H
00H ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
    |
    |       18H ┌───────────
    |           | LCD display area
    |           |
    |           |
    |           |
    |       A7H └───────────
    |
DAH | Counter no. jumps from DAH to D5H
D5H ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
D7H └───────────────────────

VDP manual END




Return to top
0.107s