PROGRAMMER'S GUIDESMPC Interface User's Manual
Back | ■
SMPC Interface User's Manual / Reference

Function specifications


Non-intback


 List
 Title

Function specifications

 Function

Master SH2 ON

 Function Name

PER_SMPC_MSH_ON

 No

1

Form
void PER_SMPC_MSH_ON (void)
input
none
output
none
Function value
none
This function is prohibited for use by users.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / MSHON

 List
 Title

Function specifications

 Function

Slave SH2 ON

 Function Name

PER_SMPC_SSH_ON

 No

2

Form
void PER_SMPC_SSH_ON (void)
input
none
output
none
Function value
none
Strict matters
This function is prohibited from being used by slave SH2.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / SSHON

 List
 Title

Function specifications

 Function

Slave SH2 OFF

 Function Name

PER_SMPC_SSH_OFF

 No

3

Form
void PER_SMPC_SSH_OFF (void)
input
none
output
none
Function value
none
Strict matters
This function must not be executed while the slave SH2 is accessing the CPU's external bus (A-BUS, B-BUS, CPU-BUS).
If run during external bus access, the entire system can hang.
The conditions for SH2 to access the external bus are as follows.

Therefore, the condition that the slave SH2 is not accessing the external bus is that the slave SH2 is operating only on the cache inside the CPU.
If it is not possible to manage the above conditions with a user program, use clock change as an alternative method.

Strict matters
This function is prohibited from being used by slave SH2.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / SSHOFF

 List
 Title

Function specifications

 Function

Sound ON

 Function Name

PER_SMPC_SND_ON

 No

Four

Form
void PER_SMPC_SND_ON (void)
input
none
output
none
Function value
none
function
Start the sound CPU (MC68EC000).
This command is used together with the sound OFF command when loading the sound driver into the sound RAM.
(If the clock change of the system library is executed, the contents of the sound RAM are not guaranteed, so it is necessary to restart the sound CPU by this command after reloading the sound driver.)

Sound CPU stop and start restrictions
The sound CPU must be stopped and there must be no non-access period of 0.5 seconds or more from the main system (SH2 side) to the sound RAM.
Stop it only for the minimum necessary period such as loading the sound driver, and restart it immediately.
Even if you do not need to use the sound CPU (MC68EC000), you need to take measures such as executing a dummy program (simply an infinite loop).
If this restriction is not observed, the operation of sound RAM and sound block cannot be guaranteed.

Reference: <DD> "HARDWARE MANUAL / SMPC User's Manual" SMPC Command / SNDON

 List
 Title

Function specifications

 Function

Sound off

 Function Name

PER_SMPC_SND_OFF

 No

Five

Form
void PER_SMPC_SND_OFF (void)
input
none
output
none
Function value
none
function
Stop the sound CPU (MC68EC000).
This command is used with the sound ON command when loading the sound driver into the sound RAM.
(When the clock change of the system library is executed, the contents of the sound RAM are not guaranteed, so it is necessary to stop the sound CPU by this command before executing the clock change.)

Strict adherence:
[Restrictions on stopping and starting the sound CPU]
The sound CPU must be stopped and there must be no non-access period of 0.5 seconds or more from the main system (SH2 side) to the sound RAM.
Stop it only for the minimum necessary period such as loading the sound driver, and restart it immediately.
Even if you do not need to use the sound CPU (MC68EC000), you need to take measures such as executing a dummy program (simply an infinite loop).
If this restriction is not observed, the operation of sound RAM and sound block cannot be guaranteed.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / SNDOFF

 List
 Title

Function specifications

 Function

CD ON

 Function Name

PER_SMPC_CD_ON

 No

6

Form
void PER_SMPC_CD_ON (void)
input
none
output
none
Function value
none
Strict matters
This function is prohibited from being used by slave SH2.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / CDON

 List
 Title

Function specifications

 Function

CD OFF

 Function Name

PER_SMPC_CD_OFF

 No

7

Form
void PER_SMPC_CD_OFF (void)
input
none
output
none
Function value
none
Strict matters
This function is prohibited from being used by slave SH2.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / CDOFF

 List
 Title

Function specifications

 Function

Whole system reset

 Function Name

PER_SMPC_SYS_RES

 No

8

Form
void PER_SMPC_SYS_RES (void)
input
none
output
none
Function value
none
Strict matters
This function is prohibited from being used by slave SH2.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / SYSRES

 List
 Title

Function specifications

 Function

NMI request

 Function Name

PER_SMPC_NMI_REQ

 No

9

Form
void PER_SMPC_NMI_REQ (void)
input
none
output
none
Function value
none
function
Generates an NMI interrupt for master SH2.
By executing this command, it is possible to generate an NMI interrupt unconditionally even if the reset button is disabled.
When an NMI interrupt occurs, the same boot sequence as when the reset button on the main unit is pressed is started when the reset button is enabled. Normally, the reset button is valid, so there is no need to use this command.
Use this for reset processing (after the line disconnection processing is completed) in an application (when using a modem) in which the reset button is always disabled.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / NMIREQ

 List
 Title

Function specifications

 Function

Hot reset enable

 Function Name

PER_SMPC_RES_ENA

 No

Ten

Form
void PER_SMPC_RES_ENA (void)
input
none
output
none
Function value
none
function
Enables the issue of NMI from SMPC to master SH2 by the hot reset button.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / RESENAB

 List
 Title

Function specifications

 Function

Hot reset disable

 Function Name

PER_SMPC_RES_DIS

 No

11

Form
void PER_SMPC_RES_DIS (void)
input
none
output
none
Function value
none
function
Disables the issuance of NMI from SMPC to master SH2 by the reset button on the main unit.
Be sure to use this command to disable the reset button when using the backup library and when using the modem.
Also, do not disable the reset button for purposes other than the above.

reference:
"HARDWARE MANUAL / SMPC User's Manual" SMPC Command / RESDISA

 List
 Title

Function specifications

 Function

SMPC memory settings

 Function Name

PER_SMPC_SET_SM

 No

12

Form
void PER_SMPC_SET_SM (Uint32 input_dt)
input
input_dt: SMPC memory
For the meaning of each bit value, refer to System Data Output Data Type.
output
none
Function value
none
function
Set the SMPC memory. The SMPC memory is an area commonly used by applications and BOOT ROMs, so be sure to observe the data format.
Please refer to here for the data that needs to be changed / referenced on the application side and the data that cannot be changed.

reference:
"HARDWARE MANUAL / SMPC User's Manual"
■ 2.4 Non-reset system management command

 List
 Title

Function specifications

 Function

Time setting

 Function Name

PER_SMPC_SET_TIM

 No

13

Form
void PER_SMPC_SET_TIM (Uint8 * input_dt)
input
input_dt: time

Input format
 bit7 bit4
 bit3 bit0
 input_dt [0]
 Second tenth place
 First place in seconds
 input_dt [1]
 Tenth place
 1st place
 input_dt [2]
 10th place
 No. 1 at the time
 input_dt [3]
 10th place per day
 No. 1 in the day
 input_dt [4]
 Day of the week (0-6)
 Month (1H ~ CH)
 input_dt [5]
 10th year of the Christian era
 First place in the Christian era
 input_dt [6]
 Year 1000
 100th year of the Christian era
output
none
Function value
none
function
Set the time.

reference:
"HARDWARE MANUAL / SMPC User's Manual" ■ 2.5 RTC command

Intoback


 List
 Title

Function specifications

 Function

Intoback initialization

 Function Name

PER_LInit

 No

14

Form
Uint32 PER_LInit (PerKind kind, PerNum num, PerSize max_size, void * work, Uint8 v_blank)
input

PerKind kind:
Intoback type

PerNum num:
Required number of peripherals

PerSize max_size:
Maximum value of peripheral size to get
It is recommended to specify an even size.
Details: How to calculate the work area

Uint32 work [worksize / 4]:
Work area ...
Used for peripheral data acquisition. Be sure to declare it as a global variable.

Uint8 v_blank:
V-BLANK Skip count.
Specify the value obtained by subtracting 1 from the processing unit of the entire game.
(Specify 1 for 2 frame units) Specify 0 if you do not need to skip.
Example of use
err_code = PER_LInit (kind, num, max_size, (void *) work, v_blank);
output
none
Function value
Execution state
 Constant
 explanation
 PER_INT_ERR
 The intoback command could not be issued.
 PER_INT_OK
 The into-back command has been issued.
function
Initializes and issues the into-back command, and registers SMPC interrupts. Please be sure to observe the strict adherence.
Set NULL or 0 for parameters that are not required.
Execute it at least once before executing PER_LGetPer (), PER_GetTim (), PER_GetSys ().
Strict matters
This function is prohibited from being used by slave SH2.

Strict matters
This function cannot be executed in interrupt processing.
Be sure to execute it in the main process.
Generally, execute immediately after V blank OUT processing.

● Work area calculation method
worksize = (num * (max_size + 2) * 2) + max_size
The value of max_size that you need to reserve depends on the peripheral you are using.
The data size for each peripheral is as follows.

 Peripheral
 Data size
 Digital device
 2
 Analog devices
 3-9
 Handle
 3
 Mission STICK (3 axes)
 Five
 Mission STICK (6 axes)
 9
 Multi controller (analog)
 6
 pointing device
 3
 Keyboard device
 Four
 Mega drive 3 button pad
 1
 Mega drive 6 button pad
 2

If a peripheral with a data size larger than the set size is connected, the data after max_size cannot be referenced.
Data before size can be referenced without any problem.

example)
When an analog device is connected when size = 2

"Digital information" in the analog device-> up to the 2nd byte, so it can be referenced "Analog information" in the analog device-> 3rd byte or later, so it cannot be referenced

● About even number specification of max_size
We recommend that you specify max_size as an even number.
The reason is that the peripheral data output by the library is placed in memory on even boundaries.
For word access to peripheral data, be sure to specify an even size.
Similarly, for longword access, specify a multiple of 4.

● About the setting unit of the number of V-BLANK skips
In the case of 2 frames or more (1 or more is set in the number of V-BLANK skips set by the PER_LInit function), this library acquires peripherals only for the last frame.
With this specification, since the peripheral data of the frame in the middle is not acquired, it may not be possible to detect the edge (previously unpressed, currently pressed button).
If you need to check for severe edges, set the number of V-BLANK skips to 0 and execute the PER_LGetPer function for each interrupt.

● Execution failure of PER_LInit ()
PER_LInit () does not always succeed at run time, and it can fail.
Be sure to check the function value of PER_LInit () and perform retry processing.
If it fails, you will need to run PER_LInit () again.
However, re-execution within the same frame is prohibited, so after the next frame
Please try again.


 List
 Title

Function specifications

 Function

Peripheral data acquisition

 Function Name

PER_LGetPer

 No

15

Form
Uint32 PER_LGetPer ( PerGetPer ** output_dt, PerMulInfo ** mul_info)
input
none
output
output_dt: Peripheral data acquisition address (NULL = could not be acquired)
mul_info: Multi-tap information acquisition address (NULL = could not be acquired)
mul_info [0]: Multi-tap information of main unit terminal 1
mul_info [1]: Multi-tap information of main unit terminal 2
Function value
Execution result
 Constant
 explanation
 PER_INT_ERR
 The intoback command could not be issued.
 PER_INT_OK
 The into-back command has been issued.
function
Issue an into-back command and acquire peripheral data.
Before executing this function, instruct PER_LInit () to acquire peripheral data (PER_KD_PER or PER_KD_PERTIM) and execute it.
If you do not instruct to acquire peripheral data, NULL is output to the peripheral data address.

how to use
PerGetPer * output_dt
PerMulInfo * mul_info
err_code = PER_LGetPer (& output_dt, & mul_info);
Strict matters
This function is prohibited from being used by slave SH2.

Strict matters
The execution timing is limited to the following period.
"300 μs after the start of the V blank to the end of the V blank"

Note 1: Execution timing of library function
Note the following points when registering this function in the V-BLANK-OUT interrupt.

If the execution timing of the SCL_VblankEnd function is late, the sprite frame change will be the next timing, and the screen movement will be slow.

Note 2: Guarantee range of output peripheral data

Therefore, when referencing peripheral data, be sure to determine the reference range from the number of multi-tap connectors.

[Connected / Not Connected Check Procedure]
1) Check the connection status of the main unit terminal 1 from the multi-tap information.
     When mul_info [0] .id == 0xF0 and mul_info [0] .con == 0x00 → Main unit terminal 1 is not connected.
          The first one of the peripheral data is an indefinite value.
          The data of the main body terminal 2 starts from the following data.
     When mul_info [0] .id! = 0xF0 and mul_info [0] .con == 0x00 → Main unit terminal 1 is connected to a peripheral that does not support SMPC.
          The first one of the peripheral data is an indefinite value.
          The data of the main body terminal 2 starts from the following data.
     When mul_info [0] .id == 0xF0 and mul_info [0] .con == 0x01 → Main unit terminal 1 is directly connected to the SMPC compatible peripheral.
          The first one of the peripheral data is valid.
          The data of the main body terminal 2 starts from the following data.
     When mul_info [0] .id! = 0xF0 and mul_info [0] .con> 0x01 → Main unit terminal 1 is a multi-tap connection (the number of connectors is mul_info [0] .con)
          Valid for the number of connectors from the beginning of the peripheral data Check the connection status of each terminal of the tap from the peripheral type and peripheral size of each terminal. The data of the main body terminal 2 starts from the data next to the main body terminal 1.

2) Check the connection status of the main unit terminal 2 from the multi-tap information by the same method as above.

3) When connecting with multi-tap, check the connection of each terminal by the following method.
     Peripheral type == PER_ID_NCON_UNKNOWN and
     Peripheral size == PER_SIZE_NCON_15
       → Not connected.
     Peripheral type == PER_ID_NCON_UNKNOWN and
     Peripheral size! = PER_SIZE_NCON_15
       → SMPC non-compatible peripherals are connected.
     Other than the above → SMPC compatible peripherals are connected

Peripheral data output specifications
1. Data structure per peripheral
  + -Peripheral type
  | + -Peripheral size
  | | +-DATA1
  | | | + -DATA2 DATAn- +
  | | | | |
+ ---- + ---- + ---- + ---- + + ---- +
TP | SZ | D1 | D2 | .............. | Dn |
+ ---- + ---- + ---- + ---- + + ---- +
 <->
  1 Byte
 <-------------------------------------->
      (n + 2) Byte n is equal to max_size specified by PER_LInit () ・ DATA1 ・ ・ ・ DATA n (n Byte)
    Peripheral data For the data format of each device,
       See Device information data type.

2. Data structure of the entire peripheral data
The above data is output for the number of connectors on the main unit terminal.
Refer to the multi-tap information for the number of connectors on the main unit terminals.

Specific example of output data
·Connection Status
Body terminal 1 = not connected
Body terminal 2 = digital device
・ Output result
Array 0 = indefinite
Array 1 = Digital device
Multi-tap information
Main unit terminal 1 Multi-tap ID = PER_MID_NCON_ONE (meaning not connected)
Main unit terminal 1 Number of connectors = PER_MCON_NCON_UNKNOWN (meaning not connected)
Main unit terminal 2 Multi-tap ID = PER_MID_NCON_ONE (meaning direct connection)
Main unit terminal 2 Number of connectors = 01

troubleshooting
1. Peripheral data cannot be acquired.
Between V-BLANK OUT and the next V-BLANK IN. ..

* There are two interrupt priorities, the hardware eigenvalue and the system library setting value.
See the System Library and SCU Hardware Manual and the System Library section for more information.

2. The peripheral connected to the multi-tap suddenly becomes inoperable.
It has been confirmed that when acquiring peripheral information in this library, it suddenly becomes impossible to operate peripherals via multi-tap. At this time, the information that the peripheral is not connected is returned from the library, and it will not return to the normal state until the peripheral or multi-tap is removed and reinserted. This phenomenon occurs when the processing in the V blank is heavy.

(Data transfer to V-RAM, etc.)

Change to reduce the processing during V blank.

If this phenomenon cannot be avoided, take the following measures.

If the above changes still cause the problem, re-execute the PER_LInit function when the status "Not connected" is returned.

(If "Not connected" is returned even after repeating several times, please consider that it is really unconnected.)


 List
 Title

Function specifications

 Function

Get time

 Function Name

PER_GET_TIM

 No

16

Form
Uint8 * PER_GET_TIM (void)
input
none
output
none
Function value
Time data address
function
Acquires time data. It is necessary to instruct PER_LInit () to acquire peripheral data + time acquisition (PER_KD_PERTIM) and execute it at least one frame before executing this function.

 List
 Title

Function specifications

 Function

System data acquisition

 Function Name

PER_GET_SYS

 No

17

Form
PerGetSys * PER_GET_SYS (void)
input
none
output
none
Function value
System data address (NULL = could not be obtained)
function
Acquire system data. Instruct PER_LInit () to acquire system data (PER_KD_SYS) one frame before executing this function, and execute it at least once. (If execution of PER_LInit fails, execute PER_LInit () again.)
SMPC memory is included in the system data. The SMPC memory is an area commonly used by applications and BOOT ROMs, so be sure to observe the data format.
Please refer to here for the data that needs to be changed / referenced on the application side and the data that cannot be changed.


others


 List
 Title

Function specifications

 Function

Get hot reset

 Function Name

PER_GET_HOT_RES

 No

18

Form
Uint8 PER_GET_HOT_RES (void)
input
none
output
none
Function value
Hot reset state address
 Constant
 explanation
 PER_HOT_RES_ON
 Hot reset ON
 PER_HOT_RES_OFF
 Hot reset OFF
function
Gets the hot reset state. You can run this function at any time.
The update is running PER_LGetPer ().

Back | ■
PROGRAMMER'S GUIDESystem Program User's Manual
Copyright SEGA ENTERPRISES, LTD., 1997