HuC6272 (KING)

Handles processing BG transfers, SCSI transfers, ADPCM transfers, and RAINBOW transfers.

Main RAM cannot be accessed directly, transfer data to KRAM with the KRAM interface

I/O Ports

Register (W)0x600
Status (R)0x600
Status 2(R)0x602
Data (R/W)0x604
Data 2(R/W)0x606

Status

BitsDescription
0 ~ 6Register selected
9Busy
10ADPCM buffer interrupt. Reading clears the interrupt.
11HSync raster interrupt. "HuC6271 transfer control register's RINT bit (reg 0x40: bit1) reset and reset again to lead this state."
12CD-ROM drive subcode interrupt. Reading clears this register's subcode or subcode register.
13SCSI DMA end interrupt. Reading clears the SCSI DMA enable register.
14SCSI block interrupt. SCSI bus reset occurs on a base phase mismatch. Reading clears SCSI reset interrupt register.
16 ~ 23SCSI status. Just like register 0x05.
24 ~ 31Sub-code

Register (SCSI-Related)

0x00   SCSI data

BitsREADWRITE
0 ~ 7SCSI dataSCSI data

0x01   SCSI initiate command

BitsREADWRITE
0BusBus
1ATN (?)ATN (?)
2SelectSelect
4AcknowledgeAcknowledge
7ResetReset

0x02   SCSI mode

BitsREADWRITE
0Sequential DMASequential DMA
1DMADMA

0x03   SCSI target command

BitsREADWRITE
0I/OI/O
1C/DC/D
2MiscMisc

0x05   SCSI bus status

BitsREADWRITE
0"Once the DMA has written to the DMA mode, this register from the output of the SCSI bus. DMA starts."
1Select
2I/O
3C/D
4Misc
5Request
6Busy
7Reset
16 ~ 23SCSI -> CPU dataCPU -> SCSI data

0x06   SCSI Input data

BitsREADWRITE
0 ~ 7Data

0x07   SCSI DMA

BitsREADWRITE
0 ~ 7Clear SCSI interruptInitiate SCSI DMA

0x08   Subcode

BitsREADWRITE
0SubcodeSubcode capture enable
1Subcode interrupt enable
2
3
4
5
6
7

0x09   SCSI DMA start address

BitsREADWRITE
0 ~ 16DMA transfer addressDMA transfer address
17A/BA/B

0x0A   SCSI DMA transfer byte count

BitsREADWRITE
00
1 ~ 17DMA transfer sizeDMA transfer size

0x0B   SCSI DMA control

BitsREADWRITE
0DMA endedDMA enable
1DMA end interrupt enable
7SCSI interface active level

Register (KRAM-Related)

0x0C   KRAM read address (Word)

KRAM read address

BitsDescription
0 ~ 17Address
18 ~ 27Increment address
31Page

0x0D   KRAM write address (Word)

KRAM write address

BitsDescription
0 ~ 17Address
18 ~ 27Increment address
31Page

0x0E   KRAM read/write (Half)

When written, writes the data to the address in 0x0C then increases it.

When read, reads the data from the address in 0x0D then increases it.

0x0F   KRAM page setup (Half)

Setup the pages of KRAM for KING

BitsDescription
0KRAM page for SCSI
8KRAM page for BG
16KRAM page for RAINBOW
24KRAM page for ADPCM

Register (BG-related)

0x10   BG mode (Half)

BG mode setting

BitsDescription
0 ~ 3BG0 mode
4 ~ 7BG1 mode
8 ~ 11BG2 mode
12 ~ 15BG3 mode

Mode values are like so:

0000Unused
00014 palette
001016 palette
0011256 palette
010064k color
010116M color
10014 palette block mode
101016 palette block mode
1011256 palette block mode

0x12   Priority (Half)

BG prioritization

BitsDescription
0 ~ 2BG0 priority
3 ~ 5BG1 priority
6 ~ 8BG2 priority
9 ~ 11BG3 priority
12BG0 rotation enable (wtf NEC)

Priority values are like so:

000Hidden
001Farthest back
010Above back
011Under first
100Farthest forward
101
110
111
Prohibited

0x13   Microprogram address (Half)

Microprogram write address

0x14   Microprogram data (Half)

Microprogram data to write. Autoincrements register 0x13.

0x15   Microprogram control (Half)

Microprogram control.

BitsDescription
0Microprogram running

0x16   Background scroll mode (Half)

Mode 0 is a single background area. Mode 1 is an endless background (looping?).

BitsDescription
0BG0's scroll mode
1BG1's scroll mode
2BG2's scroll mode
3BG3's scroll mode

0x20   BG0 BAT Address (Half)

BG0 BAT address. This is the address divided by 1024.

0x21   BG0 CG Address (Half)

BG0 CG address. This is the address divided by 1024.

0x22   BG0sub BAT Address (Half)

BG0sub BAT address. This is the address divided by 1024.

0x23   BG0sub CG Address (Half)

BG0sub CG address. This is the address divided by 1024.

0x24   BG1 BAT Address (Half)

BG1 BAT address. This is the address divided by 1024.

0x25   BG1 CG Address (Half)

BG1 CG address. This is the address divided by 1024.

0x26   BG2 BAT Address (Half)

BG2 BAT address. This is the address divided by 1024.

0x27   BG2 CG Address (Half)

BG2 CG address. This is the address divided by 1024.

0x28   BG3 BAT Address (Half)

BG3 BAT address. This is the address divided by 1024.

0x29   BG3 CG Address (Half)

BG3 CG address. This is the address divided by 1024.

0x2C   BG0 size (Half)

Specify BG0 size

BitsDescription
0 ~ 3Height
4 ~ 7Width
8 ~ 11Sub Height
12 ~ 15Sub Width

Size values are like so:

BitsDescription
00118 px
010016 px
010132 px
011064 px
0111128 px
1000256 px
1001512 px
10101024 px (only valid for BG0)

0x2D   BG1 size (Half)

Specify BG1 Size. Same settings as 0x2C, except no sub size.

0x2E   BG2 size (Half)

Specify BG2 Size. Same settings as 0x2C, except no sub size.

0x2F   BG3 size (Half)

Specify BG3 Size. Same settings as 0x2C, except no sub size.

0x30   BG0 X scroll (Half)

The X coordinate of the upper-left corner of BG0.

0x31   BG0 Y scroll (Half)

The Y coordinate of the upper-left corner of BG0.

0x32   BG1 X scroll (Half)

The X coordinate of the upper-left corner of BG1.

0x33   BG1 Y scroll (Half)

The Y coordinate of the upper-left corner of BG1.

0x34   BG2 X scroll (Half)

The X coordinate of the upper-left corner of BG2.

0x35   BG2 Y scroll (Half)

The Y coordinate of the upper-left corner of BG2.

0x36   BG3 X scroll (Half)

The X coordinate of the upper-left corner of BG3.

0x37   BG3 Y scroll (Half)

The Y coordinate of the upper-left corner of BG3.

0x38   BG affine coefficient A (half)

Value is calculated like this, where a is the X zoom factor, and r is counter-clockwise rotation angle.

n = (1/a)*cos(r)

The value (n) is stored in an 8.8 fixed point format.

0x39   BG affine coefficient B (half)

Value is calculated like this, where b is the Y zoom factor, and r is counter-clockwise rotation angle.

n = -(1/b)*sin(r)

The value (n) is stored in an 8.8 fixed point format.

0x3A   BG affine coefficient C (half)

Value is calculated like this, where a is the X zoom factor, and r is counter-clockwise rotation angle.

n = (1/a)*sin(r)

The value (n) is stored in an 8.8 fixed point format.

0x3B   BG affine coefficient D (half)

Value is calculated like this, where b is the Y zoom factor, and r is counter-clockwise rotation angle.

n = (1/b)*cos(r)

The value (n) is stored in an 8.8 fixed point format.

0x3C   BG affine center, X (half)

BG affine rotation center's X coordinate. Coordinate is relative to the center.

0x3D   BG affine center, Y (half)

BG affine rotation center's Y coordinate. Coordinate is relative to the center.

Register (RAINBOW-related)

0x40   RAINBOW transfer control (half)

BitsDescription
0Enable RAINBOW transfer
1Interrupt on raster (specified by register 0x44) hit

0x41   RAINBOW KRAM transfer address (word)

Address of KRAM to transfer data to RAINBOW.

0x42   RAINBOW transfer start raster (half)

Start RAINBOW transfer at this raster count (0 ~ 261).

0x43   RAINBOW transfer block count (half)

Specifies the number of blocks of data RAINBOW transfers (1 block == 16 dots?) (0 ~ 31).

0x44   RAINBOW interrupt raster (half)

When the raster reaches this count, and if the interrupt bit in 0x40 is enabled, an interrupt is fired.

Register (ADPCM-related)

0x50   ADPCM control (half)

BitsDescription
0Channel 0 play
1Channel 1 play
2 ~ 3Sampling rate 00 = 31.47kHz
01 = 15.73kHz
10 = 7.87kHz
11 = 3.93kHz

0x51   ADPCM channel 0 control (half)

When in ring buffer mode, the buffer contents are looped. Sequential mode uses streaming (I think?)

BitsDescription
0Buffer Mode 0 = Sequential
1 = Ring
1End interrupt 0 = Disabled
1 = Allow
2Intermediate interrupt 0 = Disabled
1 = Allow

0x52   ADPCM channel 1 control (half)

Just like 0x51 but for channel 1.

0x53   ADPCM status (half)

Reading contents of this register clears the flags.

Interrupt is level-triggered, and must be cleared in the handler to prevent an infinite loop.

BitsDescription
0Channel 0 end interrupt
1Channel 0 intermediate interrupt
2Channel 1 end interrupt
3Channel 1 intermediate interrupt

0x58   ADPCM channel 0 start address (half)

Starting address, divided by 256.

0x59   ADPCM channel 0 end address (word)

End address, no division. If in ring buffer mode, start address is reloaded when this is hit. If in sequential mode, playing is stopped and the play bit in register 0x50 is reset.

0x5A   ADPCM channel 0 intermediate address (half)

Intermediate address, divided by 64. Used only if the intermediate interrupt bit in the channel's control is enabled.

0x5C   ADPCM channel 1 start address (half)

Same contents as 0x58 for channel 1

0x5D   ADPCM channel 1 end address (word)

Same contents as 0x59 for channel 1

0x5E   ADPCM channel 1 intermediate address (half)

Same contents as 0x5A for channel 1

Microprogram

KING's BG is generated by a microprogram. The microprogram is a program in KRAM that describes how to output KING backgrounds.

The microprogram is 16 half words long. Addresses 0 ~ 7 are the A bank address (?). Addresses 8 ~ 15 is the B bank address (?).

Microprogramming opcode dissection

BitsDescription
0 ~ 2Offset
Offset of the data to access.
If bit5 is set, this will always be 0.
3 ~ 4Data access types 00 = CG data is accessed
01 = BAT data associated to that CG data is accessed
10 = BAT data is accessed
11 = ???
5Rotation flag
This bit is 1 when you do rotation.
6 ~ 7BG surface number
Which BG will be operated upon.
8NOP flag
When this bit is 1, the opcode will still be parsed, but nothing will occur.

Limit

It is not possible to describe a microprogram that operates across banks.

16M color screen if it contains the rotation process can be done.

Non-rotating plane data width per 1dot 16bit or less. For example, 64k color screen and create a two-sided, three sides to create a color screen 256.

BG0 cannot be rotated.

Common Microprograms

16M color mode / 64k color mode microprogram

CodeOperation
0000+0 from CG is accessed
0001+1 from CG is accessed
0002+2 from CG is accessed
0003+3 from CG is accessed
0004+4 from CG is accessed
0005+5 from CG is accessed
0006+6 from CG is accessed
0007+7 from CG is accessed

256 color mode microprogram

CodeOperation
0000+0 from CG is accessed
0001+1 from CG is accessed
0002+2 from CG is accessed
0003+3 from CG is accessed

16 color mode microprogram

CodeOperation
0000+0 from CG is accessed
0001+1 from CG is accessed

4 color mode microprogram

CodeOperation
0000+0 from CG is accessed

256 color block mode microprogram

CodeOperation
0010+0 from BAT read
0100NOP
0008+0 from BAT CG is accessed
0009+1 from BAT CG is accessed
000A+2 from BAT CG is accessed
000B+3 from BAT CG is accessed

16 color block mode microprogram

CodeOperation
0010+0 from BAT read
0100NOP
0008+0 from BAT CG is accessed
0009+1 from BAT CG is accessed

4 color block mode microprogram

CodeOperation
0010+0 from BAT read
0100NOP
0008+0 from BAT CG is accessed

Plane rotation microprogram

CodeOperation
0020Process rotation
0020Process rotation
0020Process rotation
0020Process rotation
0020Process rotation
0020Process rotation
0020Process rotation
0020Process rotation

[TOP]