PC Engine Hardware : CPU

The HuC6280 is a 8-bit microprocessor similar to the popular 6502 and 65C02 CPU's. It contains a 65C02 core to which have been added several new instructions, and a few internal peripheral functions such as an interrupt controller, a MMU, a TIMER, a 8-bit parallel I/O port, and a PSG.

Memory Mapping :

The HuC6280 has a 64 KB logical address space and a 2 MB physical address space. To access this entire memory space, the HuC6280 uses a MMU (Memory Managment Unit) that splits the memory space in segment of 8 KB. The logical address space is splitted as follow :

page 0$0000-$1FFF
page 1$2000-$3FFF
page 2$4000-$5FFF
page 3$6000-$7FFF
page 4$8000-$9FFF
page 5$A000-$BFFF
page 6$C000-$DFFF
page 7$E000-$FFFF

Each logical 8 KB segment (or page) is associated to a 8-bit register (MPR0-7) that contains the index of the 8 KB segment (or bank) in physical memory to map in this page. Two special instructions are used to access these registers :

TAMi, transfer the content of the accumulator (A) into a MPR register (0 - 7).

TMAi, transfer a MPR register into the accumulator.

Bank Map :

$00-$7FROM
$F7battery backed RAM
$F8work RAM
$FFhardware I/O page

You are free to map banks anywhere into the 8 pages, but a sort of standard has been defined, all the games seem to use it, so it was used in all the MagicKit's tools too. Here's how banks are mapped by default :

page 0bank $FF (I/O)
page 1bank $F8 (RAM)
page 2user definable
page 3
page 4
page 5
page 6
page 7bank $00

Note : After a RESET bank $00 is automaticaly mapped into page 7.

TIMER

The TIMER base frequency is 6.992 KHz.

TIMER counter register
$0C00 R/W bit 7 : (unused)
bit 6-0 : 7-bit down counter

TIMER control register
$0C01  /W bit 7-1 : (unused)
bit 0 : start/stop bit (0 = off, 1 = on)

An interrupt is raised when the counter generates a carry, in other words, when the counter is to be decremented and its value is zero.

Gamepad

Gamepad I/O port
$1000  /W bit 7-2 : (unused)
bit 1 : gamepad CLR line
bit 0 : gamepad SEL line
$1000 R/ bit 7 : (unused)
bit 6 : country bit (1 = JPN, 0 = USA)
bit 5-4 : (unused)
bit 3-0 : gamepad 4-bit data

Interrupts :

Interrupt disable register
$1402 R/W bit 7-3 : (unused)
bit 2 : TIMER
bit 1 : IRQ1 (VDC)
bit 0 : IRQ2 (external int.)
  1 to disable an interrupt, 0 to enable it.

Interrupt status register
$1403 R/ bit 7-3 : (unused)
bit 2 : TIMER
bit 1 : IRQ1 (VDC)
bit 0 : IRQ2 (external int.)
  Set to 1 when an interrupt is waiting.
$1403  /W bit 7-0 : (unused)
  A write to this register will acknowledge the internal TIMER interrupt.

Note : Don't forget to write to the status register at the end of the TIMER interrupt handler, otherwise you will get infinite interrupts.

Interrupt vectors :

$FFF6IRQ2 (BRK and external int.)
$FFF8IRQ1 (VDC)
$FFFATIMER
$FFFCNMI
$FFFERESET