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

function specification


non-intoback


 one
View
table
 Title

function specification

 Function

Master SH2 ON

 Function name

PER_SMPC_MSH_ON

 No

1

Format
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

 one
View
table
 Title

function specification

 Function

Slave SH2 ON

 Function name

PER_SMPC_SSH_ON

 No

2

Format
void PER_SMPC_SSH_ON(void)
input
none
output
none
function value
none
Strict observance
Use of this function from slave SH2 is prohibited.

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

 one
View
table
 Title

function specification

 Function

Slave SH2 OFF

 Function name

PER_SMPC_SSH_OFF

 No

3

Format
void PER_SMPC_SSH_OFF(void)
input
none
output
none
function value
none
Strict observance
Do not execute this function while slave SH2 is accessing the CPU's external bus (A-BUS, B-BUS, CPU-BUS).
If executed during external bus access, the entire system may hang.
The conditions for SH2 to access the external bus are as follows.

Therefore, the condition for slave SH2 not to access the external bus is that slave SH2 operates only on the CPU's internal cache.
If it is not possible to manage the above conditions using a user program, use clock changes as an alternative method.

Strict observance
Use of this function from slave SH2 is prohibited.

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

 one
View
table
 Title

function specification

 Function

sound on

 Function name

PER_SMPC_SND_ON

 No

4

Format
void PER_SMPC_SND_ON(void)
input
none
output
none
function value
none
function
Start the sound CPU (MC68EC000).
This command is used with the sound OFF command when loading the sound driver into sound RAM.
(If you execute a system library clock change, the contents of the sound RAM are not guaranteed, so you will need to restart the sound CPU using this command after reloading the sound driver.)

Limitations on stopping and starting the sound CPU
When the sound CPU is stopped, there must not be a non-access period of 0.5 seconds or more from the main system (SH2 side) to the sound RAM.
Please 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 will need to take measures such as running a dummy program (just an infinite loop).
If these restrictions are not observed, the operation of the sound RAM and sound block cannot be guaranteed.

Reference:
"HARDWARE MANUAL/SMPC User's Manual" SMPC command/ SNDON

 one
View
table
 Title

function specification

 Function

Sound OFF

 Function name

PER_SMPC_SND_OFF

 No

5

Format
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 sound RAM.
(If you execute a system library clock change, the contents of the sound RAM are not guaranteed, so you must use this command to stop the sound CPU before executing the clock change.)

Strict observance:
[Restrictions regarding stopping and starting the sound CPU]
When the sound CPU is stopped, there must not be a non-access period of 0.5 seconds or more from the main system (SH2 side) to the sound RAM.
Please 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 will need to take measures such as running a dummy program (just an infinite loop).
If these restrictions are not observed, the operation of the sound RAM and sound block cannot be guaranteed.

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

 one
View
table
 Title

function specification

 Function

CD ON

 Function name

PER_SMPC_CD_ON

 No

6

Format
void PER_SMPC_CD_ON(void)
input
none
output
none
function value
none
Strict observance
Use of this function from slave SH2 is prohibited.

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

 one
View
table
 Title

function specification

 Function

CD OFF

 Function name

PER_SMPC_CD_OFF

 No

7

Format
void PER_SMPC_CD_OFF(void)
input
none
output
none
function value
none
Strict observance
Use of this function from slave SH2 is prohibited.

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

 one
View
table
 Title

function specification

 Function

Whole system reset

 Function name

PER_SMPC_SYS_RES

 No

8

Format
void PER_SMPC_SYS_RES(void)
input
none
output
none
function value
none
Strict observance
Use of this function from slave SH2 is prohibited.

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

 one
View
table
 Title

function specification

 Function

NMI request

 Function name

PER_SMPC_NMI_REQ

 No

9

Format
void PER_SMPC_NMI_REQ(void)
input
none
output
none
function value
none
function
Generates an NMI interrupt to 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, a boot sequence similar to when the reset button is pressed when the reset button is enabled starts. Normally, the reset button is enabled, so there is no need to use this command.
Please use it for the reset process (after the line disconnection process) in an application (when using a modem) whose reset button is always disabled.

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

 one
View
table
 Title

function specification

 Function

hot reset enable

 Function name

PER_SMPC_RES_ENA

 No

10

Format
void PER_SMPC_RES_ENA(void)
input
none
output
none
function value
none
function
Enable issuance of NMI from SMPC to master SH2 using the hot reset button.

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

 one
View
table
 Title

function specification

 Function

Hot reset disabled

 Function name

PER_SMPC_RES_DIS

 No

11

Format
void PER_SMPC_RES_DIS(void)
input
none
output
none
function value
none
function
Disables issuance of NMI from SMPC to master SH2 using the main unit reset button.
Be sure to use this command to disable the reset button when using a backup library or modem.
Also, do not disable the reset button for any purpose other than the above.

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

 one
View
table
 Title

function specification

 Function

SMPC memory settings

 Function name

PER_SMPC_SET_SM

 No

12

Format
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
Configure SMPC memory. SMPC memory is an area commonly used by applications and BOOT ROM, so be sure to follow the data format .
For information on data that must be changed/referenced on the application side and data that cannot be changed, please see here .

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

 one
View
table
 Title

function specification

 Function

Time setting

 Function name

PER_SMPC_SET_TIM

 No

13

Format
void PER_SMPC_SET_TIM(Uint8 *input_dt)
input
input_dt: Time

Input format
 bit7 bit4
 bit3 bit0
 input_dt[0]
 tens of seconds
 Second place
 input_dt[1]
 decile
 1st place
 input_dt[2]
 10th place
 First place at the time
 input_dt[3]
 10th place
 No. 1 in a day
 input_dt[4]
 Day of the week (0-6)
 Month (1H~CH)
 input_dt[5]
 Western calendar year number 10
 First place in the Western calendar
 input_dt[6]
 Western calendar year thousandth rank
 Western calendar year 100th place
output
none
function value
none
function
Set the time.

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

into back


 one
View
table
 Title

function specification

 Function

Intoback initialization

 Function name

PER_LInit

 No

14

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

PerKind kind:
Into back type

PerNum num:
Number of required peripherals

PerSize max_size:
Maximum peripheral size to obtain
We recommend specifying an even size .
Details: How to calculate work area

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

Uint8 v_blank:
V-BLANK skip number.
Specify the value minus 1 from the processing unit of the entire game.
(Specify 1 for 2 frame units) If there is no need to skip, please specify 0.
Example of use
err_code = PER_LInit( kind, num, max_size, (void *)work, v_blank);
output
none
function value
running state
 constant
 explanation
 PER_INT_ERR
 Unable to issue intoback command.
 PER_INT_OK
 I was able to issue an intoback command.
function
Initializes and issues intoback commands, and registers SMPC interrupts. Please be sure to strictly follow the rules .
Please set NULL or 0 for unnecessary parameters.
Please execute it at least once before executing PER_LGetPer(), PER_GetTim(), PER_GetSys().
Strict observance
Use of this function from slave SH2 is prohibited.

Strict observance
This function is prohibited from execution within interrupt processing.
Be sure to execute it within the main process.
Generally, execute it immediately after V blank OUT processing.

●How to calculate work area
worksize = (num * (max_size + 2) * 2) + max_size
The value of max_size that you need to ensure depends on the peripherals you use.
The data size for each peripheral is as follows.

 peripheral
 Data size
 digital device
 2
 analog device
 3-9
 handle
 3
 Mission STICK (3 axes)
 5
 Mission STICK (6 axes)
 9
 Multi controller (analog)
 6
 pointing device
 3
 keyboard device
 4
 megadrive 3 button pad
 1
 megadrive 6 button pad
 2

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

example)
If 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 → up to the 3rd byte, so it can't be referenced

●About specifying an even number for 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 allocated in memory on even boundaries.
When performing word access to peripheral data, be sure to specify an even size.
Similarly, when performing longword access, specify in multiples of 4.

●About the setting unit of V-BLANK skip number
If there are 2 or more frames (set 1 or more in the V-BLANK skip number set with the PER_LInit function), this library acquires peripherals only for the last frame.
With this specification, peripheral data for intermediate frames is not acquired, so edges (previously unpressed and currently pressed buttons) may not be detected.
If severe edge checking is required, set the V-BLANK skip count to 0 and execute the PER_LGetPer function at every interrupt.

●PER_LInit() execution failure
PER_LInit() does not always succeed when run, and may fail.
Be sure to check the function value of PER_LInit() and perform retry processing.
If it fails, you must run PER_LInit() again.
However, re-execution within the same frame is prohibited, so
Please try again.


 one
View
table
 Title

function specification

 Function

Peripheral data acquisition

 Function name

PER_LGetPer

 No

15

Format
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 for main unit terminal 1
mul_info[1]: Multi-tap information of main unit terminal 2
function value
Execution result
 constant
 explanation
 PER_INT_ERR
 Unable to issue intoback command.
 PER_INT_OK
 I was able to issue an intoback command.
function
Issues an intback command and retrieves peripheral data.
Before executing this function, instruct PER_LInit() to obtain peripheral data (PER_KD_PER or PER_KD_PERTIM).
If peripheral data acquisition is not instructed, NULL will be output to the peripheral data address.

how to use
PerGetPer *output_dt
PerMulInfo *mul_info
err_code = PER_LGetPer( &output_dt, &mul_info);
Strict observance
Use of this function from slave SH2 is prohibited.

Strict observance
Execution timing is limited to the following periods:
"300μ seconds after the start of V blank to the end of V blank"

Note 1: Execution timing of library functions
When registering this function to the V-BLANK-OUT interrupt, please note the following points.

If the execution timing of the SCL_VblankEnd function is slow, the sprite frame change will occur at the next timing, resulting in slow screen movement.

Note 2: Guaranteed range of peripheral data output

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

[Connection/unconnection check procedure]
1) Check the connection status of 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 piece of peripheral data has an undefined value.
          The data on main body terminal 2 starts from the next data.
     If 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 piece of peripheral data has an undefined value.
          The data on main body terminal 2 starts from the next data.
     When mul_info[0].id == 0xF0 and mul_info[0].con == 0x01 → Main unit terminal 1 is a direct connection to an SMPC compatible peripheral.
          The first one of the peripheral data is valid.
          The data on main body terminal 2 starts from the next data.
     If mul_info[0].id != 0xF0 and mul_info[0].con > 0x01 → Main unit terminal 1 is multi-tap connected (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 main body terminal 2 starts from the data after the data of main body terminal 1.

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

3) When making multi-tap connections, check the connection of each terminal using 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
       → A peripheral that does not support SMPC is connected.
     Other than 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 in PER_LInit()

・DATA1・・・DATAn( n Byte )
    Peripheral data
       For the data format of each device, please refer to the
       Device information data type.

2. Data structure of the entire peripheral data
The above data will be output for the number of connectors on the main body terminal.
Please refer to the multi-tap information for the number of connectors on the main unit terminals.

Specific example of output data
·Connection Status
Main unit terminal 1 = not connected
Main unit terminal 2 = digital device
・Output result
Array 0 = indeterminate
array 1 = digital device
Multi-tap information
Main unit terminal 1 multi-tap ID = PER_MID_NCON_ONE (meaning not connected)
Number of main unit terminals 1 connector = PER_MCON_NCON_UNKNOWN (meaning not connected)
Main unit terminal 2 multi-tap ID = PER_MID_NCON_ONE (meaning direct connection)
Number of main body terminals 2 connectors = 01

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

* There are two types of interrupt priority: a hardware specific value and a system library setting value.
For more information, please refer to the System Library and SCU hardware manual and the System Library section.

2. Peripherals connected to Multitap suddenly become inoperable.
When acquiring peripheral information with this library, we have confirmed a phenomenon where operations on the peripheral via multi-tap suddenly become impossible. At this time, the library returns information that the peripheral is not connected, and the state will not return to normal until the peripheral or multitap is unplugged and reconnected. This phenomenon occurs when processing during V blanking is heavy.

(Data transfer to V-RAM, etc.)

Please change to reduce processing during V blank.

If this problem still cannot be avoided, take the following measures.

If the problem still occurs even after making the above changes, please execute the PER_LInit function again when the "Not connected" status is returned.

(If "Not connected" is returned even after repeating several times, please assume that it is truly not connected.)


 one
View
table
 Title

function specification

 Function

Get time

 Function name

PER_GET_TIM

 No

16

Format
Uint8 *PER_GET_TIM(void)
input
none
output
none
function value
time data address
function
Acquires time data. At least one frame before executing this function, it is necessary to instruct PER_LInit() to acquire peripheral data + time (PER_KD_PERTIM) and execute it.

 one
View
table
 Title

function specification

 Function

System data acquisition

 Function name

PER_GET_SYS

 No

17

Format
PerGetSys *PER_GET_SYS(void)
input
none
output
none
function value
System data address (NULL = could not be obtained)
function
Acquire system data. One frame before executing this function, instruct PER_LInit() to acquire system data (PER_KD_SYS) and execute it at least once. (If execution of PER_LInit fails, please execute PER_LInit() again.)
System data includes SMPC memory. SMPC memory is an area commonly used by applications and BOOT ROM, so be sure to follow the data format .
For information on data that must be changed/referenced by the application and data that cannot be changed, please see here .


others


 one
View
table
 Title

function specification

 Function

Get hot reset

 Function name

PER_GET_HOT_RES

 No

18

Format
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
Get hot reset status. This function can be executed at any time.
The update is executed by PER_LGetPer().

Back | ■
PROGRAMMER'S GUIDESystem program user's manual
Copyright SEGA ENTERPRISES, LTD., 1997