Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
smpc.h File Reference

System Management & Peripheral Control. More...

Go to the source code of this file.

Data Structures

struct  jo_peripheral
 Digital peripheral data (gamepad). More...
struct  jo_peripheral_analog
 Analog peripheral data (racing wheel, mission stick, 3D pad). More...
struct  jo_peripheral_pointer
 Pointing peripheral data (mouse). More...
struct  jo_peripheral_keyboard
 Keyboard data. More...
struct  jo_smpc_status
 SMPC status (Internal usage). More...

Macros

#define JO_PERIPHERAL_ID_NOT_CONNECTED
 Peripheral ID: nothing connected.
#define JO_PERIPHERAL_ID_STANDARD_PAD
 Peripheral ID: standard pad.
#define JO_PERIPHERAL_ID_RACING_WHEEL
 Peripheral ID: racing wheel.
#define JO_PERIPHERAL_ID_MISSION_STICK
 Peripheral ID: mission stick.
#define JO_PERIPHERAL_ID_NIGHTS_PAD
 Peripheral ID: 3D pad (NiGHTS pad).
#define JO_PERIPHERAL_ID_MOUSE
 Peripheral ID: mouse.
#define JO_PERIPHERAL_ID_SHUTTLE_MOUSE
 Peripheral ID: shuttle mouse.
#define JO_PERIPHERAL_ID_KEYBOARD
 Peripheral ID: keyboard.
#define JO_PERIPHERAL_KEYBOARD_CAPS_LOCK
 Keyboard condition: caps lock is on.
#define JO_PERIPHERAL_KEYBOARD_NUM_LOCK
 Keyboard condition: num lock is on.
#define JO_PERIPHERAL_KEYBOARD_SCROLL_LOCK
 Keyboard condition: scroll lock is on.
#define JO_PERIPHERAL_KEYBOARD_MAKE
 Keyboard condition: a key is pressed (make).
#define JO_PERIPHERAL_KEYBOARD_BREAK
 Keyboard condition: a key is released (break).
#define JO_SMPC_PERIPHERAL_PER_PORT
 Number of peripherals per port (with a multitap).

Enumerations

enum  jo_smpc_command {
  EnableMasterCPU , EnableSlaveCPU , DisableSlaveCPU , EnableSoundCPU ,
  DisableSoundCPU , EnableCD , DisableCD , EnableNetlink ,
  DisableNetlink , SystemReset , ChangeSystemClockSpeed352 , ChangeSystemClockSpeed320 ,
  FetchStatusAndPeripheralData , SetRTCDateAndTime , SetSMPCMemory , SendNMIRequestToMasterCPU ,
  EnableReset , DisableReset
}
 SMPC Commands. More...
enum  jo_smpc_memory_address {
  CommandRegister , StatusRegister , StatusFlag , InputRegister0 ,
  InputRegister1 , InputRegister2 , InputRegister3 , InputRegister4 ,
  InputRegister5 , InputRegister6 , OutputRegister0 , OutputRegister1 ,
  OutputRegister2 , OutputRegister3 , OutputRegister4 , OutputRegister5 ,
  OutputRegister6 , OutputRegister7 , OutputRegister8 , OutputRegister9 ,
  OutputRegister10 , OutputRegister11 , OutputRegister12 , OutputRegister13 ,
  OutputRegister14 , OutputRegister15 , OutputRegister16 , OutputRegister17 ,
  OutputRegister18 , OutputRegister19 , OutputRegister20 , OutputRegister21 ,
  OutputRegister22 , OutputRegister23 , OutputRegister24 , OutputRegister25 ,
  OutputRegister26 , OutputRegister27 , OutputRegister28 , OutputRegister29 ,
  OutputRegister30 , OutputRegister31 , PortDataRegister1 , PortDataRegister2 ,
  DataDirectionRegister1 , DataDirectionRegister2 , InputOutputSelectRegister , ExternalLatchEnableRegister
}

Functions

static __jo_force_inline void jo_smpc_write_byte (jo_smpc_memory_address addr, unsigned char data)
static __jo_force_inline unsigned char jo_smpc_read_byte (jo_smpc_memory_address addr)
static __jo_force_inline void jo_smpc_wait (void)
static __jo_force_inline void jo_smpc_begin_command (void)
static __jo_force_inline void jo_smpc_end_command (jo_smpc_command command)
void __jo_smpc_command (const jo_smpc_command command)
 Send a command to the SMPC and wait for the end of the command (Internal usage).

Variables

jo_peripheral __jo_smpc_peripherals [(15) *2]
 Peripherals (Internal usage): 15 entries for port 1 followed by 15 entries for port 2.
jo_smpc_status __jo_smpc_status
 SMPC status, refreshed every frame (Internal usage).

Detailed Description

System Management & Peripheral Control.

Author
Johannes Fetz
Remarks
The SMPC (System Management & Peripheral Control) is a Hitachi 4-bit MCU with built-in program ROM.
The actual part number is HD404920FS, but the chip is branded with a Sega custom part number of 315-5744.
Bug
No known bugs.

Data Structure Documentation

◆ jo_peripheral

struct jo_peripheral

Digital peripheral data (gamepad).

Remarks
Buttons are active low: a bit at 0 means pressed
Data Fields
unsigned short data
unsigned char id
unsigned short pull
unsigned short push
unsigned int reserved[4]
unsigned char size

◆ jo_peripheral_analog

struct jo_peripheral_analog

Analog peripheral data (racing wheel, mission stick, 3D pad).

Remarks
Inherits from jo_peripheral (cast friendly)
Data Fields
unsigned short data
unsigned char id
unsigned short pull
unsigned short push
unsigned int reserved[3]
unsigned char size
unsigned char w
unsigned char x
unsigned char y
unsigned char z

◆ jo_peripheral_pointer

struct jo_peripheral_pointer

Pointing peripheral data (mouse).

Remarks
Inherits from jo_peripheral (cast friendly)
Data Fields
unsigned short data
unsigned char id
unsigned short pull
unsigned short push
unsigned int reserved[3]
unsigned char size
short x
short y

◆ jo_peripheral_keyboard

struct jo_peripheral_keyboard

Keyboard data.

Remarks
Inherits from jo_peripheral (cast friendly)
Data Fields
unsigned char code
unsigned char condition
unsigned short data
unsigned char id
unsigned short pull
unsigned short push
unsigned short reserved1
unsigned int reserved2[3]
unsigned char size

◆ jo_smpc_status

struct jo_smpc_status

SMPC status (Internal usage).

Data Fields
unsigned char area_code
unsigned char cartridge_code
unsigned char cond
unsigned char day
unsigned char hour
unsigned char minute
unsigned char month
unsigned char second
unsigned int smpc_memory
unsigned short system_status
unsigned short year

Macro Definition Documentation

◆ JO_PERIPHERAL_ID_KEYBOARD

#define JO_PERIPHERAL_ID_KEYBOARD

Peripheral ID: keyboard.

◆ JO_PERIPHERAL_ID_MISSION_STICK

#define JO_PERIPHERAL_ID_MISSION_STICK

Peripheral ID: mission stick.

◆ JO_PERIPHERAL_ID_MOUSE

#define JO_PERIPHERAL_ID_MOUSE

Peripheral ID: mouse.

◆ JO_PERIPHERAL_ID_NIGHTS_PAD

#define JO_PERIPHERAL_ID_NIGHTS_PAD

Peripheral ID: 3D pad (NiGHTS pad).

◆ JO_PERIPHERAL_ID_NOT_CONNECTED

#define JO_PERIPHERAL_ID_NOT_CONNECTED

Peripheral ID: nothing connected.

◆ JO_PERIPHERAL_ID_RACING_WHEEL

#define JO_PERIPHERAL_ID_RACING_WHEEL

Peripheral ID: racing wheel.

◆ JO_PERIPHERAL_ID_SHUTTLE_MOUSE

#define JO_PERIPHERAL_ID_SHUTTLE_MOUSE

Peripheral ID: shuttle mouse.

◆ JO_PERIPHERAL_ID_STANDARD_PAD

#define JO_PERIPHERAL_ID_STANDARD_PAD

Peripheral ID: standard pad.

◆ JO_PERIPHERAL_KEYBOARD_BREAK

#define JO_PERIPHERAL_KEYBOARD_BREAK

Keyboard condition: a key is released (break).

◆ JO_PERIPHERAL_KEYBOARD_CAPS_LOCK

#define JO_PERIPHERAL_KEYBOARD_CAPS_LOCK

Keyboard condition: caps lock is on.

◆ JO_PERIPHERAL_KEYBOARD_MAKE

#define JO_PERIPHERAL_KEYBOARD_MAKE

Keyboard condition: a key is pressed (make).

◆ JO_PERIPHERAL_KEYBOARD_NUM_LOCK

#define JO_PERIPHERAL_KEYBOARD_NUM_LOCK

Keyboard condition: num lock is on.

◆ JO_PERIPHERAL_KEYBOARD_SCROLL_LOCK

#define JO_PERIPHERAL_KEYBOARD_SCROLL_LOCK

Keyboard condition: scroll lock is on.

◆ JO_SMPC_PERIPHERAL_PER_PORT

#define JO_SMPC_PERIPHERAL_PER_PORT

Number of peripherals per port (with a multitap).

Enumeration Type Documentation

◆ jo_smpc_command

SMPC Commands.

Enumerator
EnableMasterCPU 

Resets and enables the SH-2 Master CPU.

EnableSlaveCPU 

Resets and enables the SH-2 Slave CPU.

DisableSlaveCPU 

Disables the SH-2 Slave CPU.

EnableSoundCPU 

Resets and enables the Motorola C68K (sound) CPU.

DisableSoundCPU 

Disables the Motorola C68K (sound) CPU.

EnableCD 

Resets and enables the CD Block.

DisableCD 

Disables the CD Block.

EnableNetlink 

Resets and enables Netlink execution.

DisableNetlink 

Disables Netlink execution.

SystemReset 

Resets the System.

ChangeSystemClockSpeed352 

Changes the system clockspeed.

ChangeSystemClockSpeed320 

Changes the system clockspeed.

FetchStatusAndPeripheralData 

Fetches the SMPC status and peripheral data.

SetRTCDateAndTime 

Sets the date and time for the RTC.

SetSMPCMemory 

Sets the 4-byte battery-backed memory contained on the SMPC(which is used by the bios for language settings, etc.

SendNMIRequestToMasterCPU 

Sends an NMI request to the Master SH2.

EnableReset 

Enables NMI requests to be sent when the Reset button is pressed.

DisableReset 

Disables NMI requests to be sent when the Reset button is pressed.

◆ jo_smpc_memory_address

Enumerator
CommandRegister 

The command that's supposed to be issued by the SMPC.

StatusRegister 

Status Register.

StatusFlag 

Status Flag. Shows the status of the SMPC command. Normally you set this to 1 when issuing out a command, and then the SMPC clears it when it's finished.

InputRegister0 

Input registers for command issuing. Whatever data the SMPC needs for processing command goes here.

InputRegister1 
InputRegister2 
InputRegister3 
InputRegister4 
InputRegister5 
InputRegister6 
OutputRegister0 

Ouput Register for the command. If it supports it, it'll output any return data here.

OutputRegister1 
OutputRegister2 
OutputRegister3 
OutputRegister4 
OutputRegister5 
OutputRegister6 
OutputRegister7 
OutputRegister8 
OutputRegister9 
OutputRegister10 
OutputRegister11 
OutputRegister12 
OutputRegister13 
OutputRegister14 
OutputRegister15 
OutputRegister16 
OutputRegister17 
OutputRegister18 
OutputRegister19 
OutputRegister20 
OutputRegister21 
OutputRegister22 
OutputRegister23 
OutputRegister24 
OutputRegister25 
OutputRegister26 
OutputRegister27 
OutputRegister28 
OutputRegister29 
OutputRegister30 
OutputRegister31 
PortDataRegister1 
PortDataRegister2 
DataDirectionRegister1 
DataDirectionRegister2 
InputOutputSelectRegister 
ExternalLatchEnableRegister 

Function Documentation

◆ __jo_smpc_command()

void __jo_smpc_command ( const jo_smpc_command command)

Send a command to the SMPC and wait for the end of the command (Internal usage).

Parameters
commandSMPC command

◆ jo_smpc_begin_command()

__jo_force_inline void jo_smpc_begin_command ( void )
static

◆ jo_smpc_end_command()

__jo_force_inline void jo_smpc_end_command ( jo_smpc_command command)
static

◆ jo_smpc_read_byte()

__jo_force_inline unsigned char jo_smpc_read_byte ( jo_smpc_memory_address addr)
static

◆ jo_smpc_wait()

__jo_force_inline void jo_smpc_wait ( void )
static

◆ jo_smpc_write_byte()

__jo_force_inline void jo_smpc_write_byte ( jo_smpc_memory_address addr,
unsigned char data )
static

Variable Documentation

◆ __jo_smpc_peripherals

jo_peripheral __jo_smpc_peripherals[(15) *2]
extern

Peripherals (Internal usage): 15 entries for port 1 followed by 15 entries for port 2.

◆ __jo_smpc_status

jo_smpc_status __jo_smpc_status
extern

SMPC status, refreshed every frame (Internal usage).