General Notice When using this document, keep the following in mind: ntial 1. This document is confidential. By accepting this document you acknowledge that you are bound by the terms set forth in the non-disclosure and confidentiality agreement signed separately and /in the possession of SEGA. If you have not signed such a non-disclosure agreement, please contact SEGA immediately and return this document to SEGA. 2. This document may include technical inaccuracies or typographical errors. Changes are periodi- cally made to the information herein; these changes will be incorporated in new versions of the program(s) described in this document at any time. de document. SEGA may make improvements and/or changes in the product(s) and/or the 3. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document without SEGA’S written permission. Request for copies of this document and for technical information about SEGA products must be made to your authorized SEGA Technical Services representative. nfi 4. No license is granted by implication or otherwise under any patents, copyrights, trademarks, or other intellectual property rights of SEGA Enterprises, Ltd., SEGA of America, Inc., or any third party. describe herein. Co 5. Software, circuitry, and other examples described herein are meant merely to indicate the character- istics and performance of SEGA’s products. SEGA assumes no responsibility for any intellectual property claims or other problems that may result from applications based on the examples 6. It is possible that this document may contain reference to, or information about, SEGA products (development hardware/software) or services that are not provided in countries other than Japan. Such references/information must not be construed to mean that SEGA intends to provide such SEGA products or services in countries other than Japan. Any reference of a SEGA licensed prod- GA uct/program in this document is not intended to state or simply that you can use only SEGA’s licensed products/programs. Any functionally equivalent hardware/software can be used instead. 7. SEGA will not be held responsible for any damage to the user that may result from accidents or any other reasons during operation of the user’s equipment, or programs according to this document. NOTE: A reader's comment/correction form is provided with this document. Please address comments to : SE SEGA of America, Inc., Developer Technical Support (att. Evelyn Merritt) 150 Shoreline Drive, Redwood City, CA 94065 SEGA may use or distribute whatever information you supply in any way it believes appropriate without incurring any obligation to you. (6/27/95- 002) TM ntial de nfi Co GA SMPC User's Manual SE Doc. # ST-169-R1-072694 © 1994 SEGA. All Rights Reserved. READER CORRECTION/COMMENT SHEET Keep us updated! nti If you should come across any incorrect or outdated information while reading through the attached document, or come up with any questions or comments, please let us know so that we can make the al required changes in subsequent revisions. Simply fill out all information below and return this form to the Developer Technical Support Manager at the address below. Please make more copies of this form if more space is needed. Thank you. General Information: Your Name Phone Document number Document name Corrections: Chpt. pg. # ST-169-R1-072694 SMPC User's Manual Correction de Date nfi Co GA Questions/comments: SE Fax: Where to send your corrections: (415) 802-1440 Attn: Sr. Coordinator, Technical Publications Group Mail: SEGA OF AMERICA Attn: Sr. Coordinator, Technical Publications Group 130 Shoreline Dr. Redwood City, CA 94065 Introduction Explanation of Terminology The terminology used in this manual is explained below. SMPC (System Manager & Peripheral Control) ntial Controls peripheral equipment interfaces, such as SATURN system reset control, control PAD, etc. The SMPC also has RTC (Real Time Clock) functions that can be backed up with a battery, making it possible to set and acquire calendar time. SCSP (Saturn Custom Sound Processor) DSP (Digital Signal Processor) de Sound source LSI for multi-function games that integrate PCM sound source and sound DSP. High-speed calculation circuit used primarily for calculations (multiplication and addition). VDP1 (Video Display Processor 1) VDP2 (Video Display Processor 2) nfi The LSI that controls the drawing of sprites and polygons. VRAM and a frame buffer are connected to the VDP1. These use the draw commands transferred to the VRAM from the CPU and execute drawing in the frame buffer. Then the draw data from the frame buffer is trans- ferred to the VDP2 and displayed on a display device at the request from the VDP2. PLL (Phase Locked Loop) Co Contains scroll screen control functions and priority functions. All of the clock types (CPU, system control, image draw/display, sound, etc., clock generator) of the SATURN system. GA SE i SCU (System Control Unit) Contains a CPU I/F, A-Bus I/F, and B-Bus I/F controller and smoothly transfers data between the various buses. The SCU also contains an internal DMA controller, interrupt controller, and Main CPU nti DSP to perform DMA control, interrupt control, and high-speed calculation processing. Contains a 32-bit RISC CPU SH-2 that controls the entire system. MC68EC000 al A sound control CPU with a SCSP that has SCSP control functions. V-BLANK-IN One of the three types of blanking interrupts. V-BLANK-IN shows the screen display end timing. V-BLANK-OUT de One of the three types of blanking interrupts. V-BLANK-OUT shows the screen display start timing. H-BLANK-IN nfi One of the three types of blanking interrupts. H-BLANK-IN shows the display end timing of one line. Peripheral Peripheral equipment connected to SATURN, such as control PAD, mouse, and keyboard. Co GA SE ii Symbols Used in this Manual The following symbols are used in this manual. Binary nti Shown by a “B” placed at the end. For example, 100B. When only 1 bit is used, however, the “B” is abbreviated. Hexadecimal Shown by an “H” at the end. For example, 00H or FF H. al Units Shows that 1 KB is 1,024 bytes. Thus, 1 MB is 1,048,576 bytes. MSB and LSB de In the structure of bytes and words, the left is the Most Significant Bit (MSB) and the right is the Least Significant Bit (LSB). Undefined Bit Undefined bits in the sound source register or DSP register are shown by “—.” (R) Signifies a read dedicated register. (W) Signifies a write dedicated register. nfi (R/W) Co Signifies a register in which both reading and writing are possible. BCD Binary Coded Decimal. GA SE iii Table of Contents Introduction ............................................................................................................................... (i) nti Explanation of Terminology ................................................................................................ (i) Symbols Used in this Manual ............................................................................................ (iii) al Table of Contents .................................................................................................................... (iv) List of Figures .................................................................................................................... (v) List of Tables .................................................................................................................... (vi) Section 1 Overview ................................................................................................................... 1 1.1 System Configuration ................................................................................................... 2 1.2 SH-2 Interface .............................................................................................................. 5 de Section 2 SMPC Commands ................................................................................................... 11 2.1 SMPC Command List ................................................................................................ 12 2.2 Command Issue ......................................................................................................... 13 2.3 Resetable System Management Commands ............................................................ 21 2.4 Non-Resetable System Management Commands..................................................... 35 nfi 2.5 RTC Commands ........................................................................................................ 45 Section 3 Peripheral Control .................................................................................................. 47 3.1 Peripheral Control Mode ............................................................................................ 48 3.2 SATURN Peripheral Standard Formats ..................................................................... 76 3.3 Support Peripheral Data Format in SMPC Control Mode ...........................................81 Co 3.4 Support Peripheral Data Format in SH-2 Direct Mode................................................86 Index ........................................................................................................................................ 104 GA SE iv List of Figures Section 1 Overview Figure 1.1 Figure 1.2 Figure 1.3 Figure 1.4 nti SMPC System Configuration ........................................................................ 2 Standard Digital PAD for SATURN ................................................................ 4 SH-2 Interface Register Address Map........................................................... 5 al Parallel I/O Register Address Map ................................................................ 7 Section 2 SMPC Commands Figure 2.1 Type A Command Flow ............................................................................... 14 Figure 2.2 Type B Command Flow ............................................................................... 14 Figure 2.3 Type C Command Flow ............................................................................... 15 Figure 2.4 Type D Command Flow ............................................................................... 16 Figure 2.5 Figure 2.6 Figure 2.7 de INTBACK Command Issue Timing .............................................................. 18 INTBACK Command Issue Timing After SYSRES, CKCHG320, CKCHG352 Command Execution ...........................................18 Issue of Other Commands .......................................................................... 19 Section 3 Peripheral Control Figure 3.1 Figure 3.2 Figure 3.3 Figure 3.4 Figure 3.5 Figure 3.6 nfi SMPC Control Mode Block Diagram ........................................................... 48 SMPC Control Mode Setting Example ........................................................ 49 All Peripheral Data Acquisition Sequence ................................................... 51 Peripheral Data Acquisition Cancel Sequence Due to Break Request ........ 52 Overview of Peripheral Data Collection Time Optimization.......................... 55 IREG0 (During INTBACK Command Execution) ......................................... 58 Figure 3.7 Figure 3.8 Figure 3.9 Co IREG0 (During Continue and Break Requests) ...........................................58 IREG1.......................................................................................................... 59 IREG2.......................................................................................................... 60 Figure 3.10 Result Parameter Standard Configuration Acquired Using INTBACK Command ......................................................................... 62 Figure 3.11 Result Parameter Configuration when One Port Is 0 Byte Mode ............................................................................. 63 Figure 3.12 Peripheral Data Configuration ..................................................................... 65 Figure 3.13 Peripheral Control Status ............................................................................ 66 GA Figure 3.14 Port Status Configuration ........................................................................... 67 Figure 3.15 SATURN Peripheral ID Configuration ......................................................... 69 Figure 3.16 Peripheral Data Configuration 1 .................................................................. 70 Figure 3.17 Peripheral Data Configuration 2 .................................................................. 71 Figure 3.18 Peripheral Data Configuration 3 .................................................................. 71 Figure 3.19 SATURN Peripheral ID when Tap Unconnected ..........................................73 Figure 3.20 SATURN Peripheral ID when Tap Unknown ............................................... 73 Figure 3.21 SH-2 Direct Mode Block Diagram ............................................................... 74 SE Figure 3.22 SH-2 Direct Mode Setting Example ............................................................ 75 v List of Tables Section 1 Overview Table 1.1 Table 1.2 Table 1.3 Table 1.4 Table 1.5 nti Initialization Status During Power On ............................................................. 3 SMPC Functions ............................................................................................. 3 DDR Functions ............................................................................................... 7 al IOSEL Functions ............................................................................................ 8 EXLE Functions .............................................................................................. 9 Section 2 SMPC Commands Table 2.1 Resetable System Management Commands ................................................12 Table 2.2 Non-Resetable System Management Commands ........................................12 Table 2.3 RTC Commands ........................................................................................... 12 Table 2.4 Table 2.5 de Command Issue Types ................................................................................. 13 SH-2 Command Issue Limitations ................................................................ 20 Section 3 Peripheral Control Table 3.1 Table 3.2 Table 3.3 Parallel I/O Register Default Values During Power On..................................49 Continue and Break Issue Conditions .......................................................... 50 Example Acquisition Command Parameter Setting Table 3.4 Table 3.5 Table 3.6 nfi When Only Peripheral Data Is Required ...................................................... 54 Command Parameter Setting Conditions and Peripheral Data Configuration ...................................................................... 64 Relation Between the Number of Connections and Peripherals ...................67 Relation Between Connected Peripherals and Multitap ID ...........................68 Table 3.7 Multitap ID and Number of Connections....................................................... 68 Table 3.8 Table 3.9 Co Combinations of Peripheral Data Size and Port Mode ..................................70 Combinations of Peripheral Data Size and Port Mode ..................................73 Table 3.10 SATURN Digital Device Standard Format .................................................... 76 Table 3.11 SATURN Analog Device Standard Format ................................................... 77 Table 3.12 SATURN Pointing Device Standard Format ................................................. 78 Table 3.13 SATURN Keyboard Device Standard Format ................................................79 Table 3.14 Mega Drive 3-Button PAD Data Format in SMPC Control Mode...................81 Table 3.15 Mega Drive 6-Button PAD Data Format in SMPC Control Mode...................81 GA Table 3.16 SATURN Mouse Data Format in SMPC Control Mode .................................82 Table 3.17 SEGA Tap Port Status in SMPC Control Mode .............................................82 Table 3.18 SATURN Standard PAD Data Format in SMPC Control Mode .....................82 Table 3.19 SATURN Analog Joystick Data Format in SMPC Control Mode ...................83 Table 3.20 SATURN Keyboard Data Format in SMPC Control Mode .............................83 Table 3.21 SATURN 6P Multitap Port Status ................................................................. 85 Table 3.22 Relationship Between Port Bit Number and Port Bit Name ...........................86 Table 3.23 Port Direction Register Setting Value During Mega Drive Peripheral ID Acquisition .............................................................................. 87 SE Table 3.24 Mega Drive Peripheral ID for Each Peripheral ..............................................88 Table 3.25 Mega Drive 3-Button PAD Data Format for SH-2 Direct Mode ......................90 Table 3.26 Mega Drive 6-Button PAD Data Format for SH-2 Direct Mode ......................90 Table 3.27 Data Format During SATURN Mouse Power On Reset for SH-2 Direct Mode ......................................................................................... 91 Table 3.28 Data Format During SATURN Mouse Reset for SH-2 Direct Mode .............. 92 vi Table 3.29 Data Format During SATURN Mouse Data Request for SH-2 Direct Mode ....... 93 Table 3.30 Data Format During SEGA Tap Power On Reset for SH-2 Direct Mode ............ 94 nti Table 3.31 Data Format During SEGA Tap Data Request for SH-2 Direct Mode ................ 95 Table 3.32 Connected Peripherals and ID ........................................................................... 95 Table 3.33 Mega Drive 3-Button PAD Data Format During Connection to SEGA Tap ......... 96 Table 3.34 Mega Drive 6-Button PAD Data Format During Connection to SEGA Tap ......... 96 Table 3.35 Table 3.36 Table 3.37 Table 3.38 Table 3.39 al SEGA Mouse Data Format During Connection to SEGA Tap ............................ 96 SATURN Standard PAD Data Format for SH-2 Direct Mode ............................. 97 SATURN Analog Joystick Data Format for SH-2 Direct Mode ........................... 98 SATURN Keyboard Data Format for SH-2 Direct Mode ................................... 100 SATURN 6P Multitap Data Format for SH-2 Direct Mode ................................ 103 de nfi Co GA SE vii Section 1 Overview ntial de nfi Co GA Section 1 Contents 1.1 System Configuration.................................... 2 SE Functions ....................................................... 3 PAD ................................................................ 4 1.2 SH-2 Interface ............................................... 5 SH-2 Interface Registers ............................... 5 Parallel I/O Registers .................................... 7 SMPC User's Manual 1 1.1 System Configuration The SMPC manages SATURN system reset control when the power is turned on and NMI requests to the master SH-2 when the reset button is pushed. In addition, nti commands from SH-2 turn each LSI on and off, sets and acquires calendar time, and collects data from peripherals. Also, the clock change command switches the hori- zontal resolution to and from 320 dots and 352 dots. al Control Address Data SMPC Bus Bus Bus RES Address Buffer Data SH I/F de IOSEL CDRES MSHRES MSHNMI SSHRES To CD Block MSH-2 NMI Buffer nfi4-bit CPU Core I/O I/O SSHNMI SNDRES SYSRES DOTSEL RES SSH-2 NMI Co VDP1 VDP2 RES RES Peripheral Peripheral PLL GA SCSP RES MC68EC000 SCU RES SE Figure 1.1 SMPC System Configuration 2 The SMPC has two sets of 7-bit parallel I/O ports. Access to I/O ports is controlled by the SMPC’s internal firmware and there are two access methods that can be se- lected: the SMPC control mode which outputs collected data to the SMPC output Table 1.1 Initialization Status During Power On nti register (OREG), and the SH-2 direct mode which has direct access from the SH-2. For details regarding the SMPC control mode and SH-2 direct mode, refer to Section 3. al During power on, the SATURN internal units are initialized as shown in Table 1.1. Status Description Sound CPU OFF Status A reset enters the sound CPU. Output by a power on vector by the SNDON command. VDP1, VDP2, SCU, SCSP A status where access from the SH-2 is possible. ON Status Slave SH OFF Status DOT SEL OFF Status CD Block ON Status de A reset enters the slave SH-2. Output by a power on vector by the SSHON command. The PLL oscillation frequency is in the 320 mode (NTSC: 26.8741 MHz, PAL: 26.6875 MHz) and the VDP1, VDP2 and SH-2 are run at this frequency. Changed to run in 352 mode (NTSC: 28.6364 MHz, PAL: 28.4375 MHz) by the CKCHG352 command. A status where access from the SH-2 is possible. Functions nfi The SMPC has three major functions: Real Time Clock (RTC), System Manager (SM), Co and Peripheral Control (PC). The SMPC’s main functions are shown in Table 1.2. Table 1.2 SMPC Functions RTC (Real Time Clock) • Time setting and acquisition from SH-2. • Automatic update of date, day, time (Battery backup is possible when main power off) SM • Sound CPU on and off (System Management) • Master SH-2 and slave SH-2 on and off GA • System reset control • Clock switching (PLL switching) • Power on reset • NMI request to master SH-2 when front panel button is pushed down. PC • Can support peripheral with SATURN peripheral (Peripheral Control) interface specifications. • Automatic collection of peripheral data from control PAD, mouse, etc. • Also supports Mega Drive peripherals (3-button, 6- SE button, SEGA tap) (a conversion adapter is required, however) SMPC User's Manual 3 PAD The SATURN digital standard PAD has up, down, left, right, A, B, C, X, Y, Z, L, R, and Start buttons. ntial de nfi Co Figure 1.2 Standard Digital PAD for SATURN GA SE 4 1.2 SH-2 Interface SH-2 Interface Registers Figure 1.3 shows the SH-2 interface register address map. nti The SH-2 interface registers are registers that are used to receive commands, com- mand parameters, and status display from the SH-2 and to output result parameters. 2010001FH b it7 COMREG b it0 W al R : Read Only b it7 b it0 W : Write Only 20100061H R R/W: Read/Write SR b it0 20100063H 20100001H 20100003H 20100005H b it7 IREG0 IREG1 IREG2 SF R/W b it0 de 20100007H 20100009H 2010000BH 2010000DH b it7 IREG3 IREG4 IREG5 IREG6 nfi b it0 W b it7 b it0 20100021H 20100023H 20100025H 20100027H 20100029H 2010002BH Co OREG0 OREG1 OREG2 OREG3 OREG4 OREG5 20100041H 20100043H 20100045H 20100047H 20100049H 2010004BH OREG16 OREG17 OREG18 OREG19 OREG20 OREG21 2010002DH OREG6 2010004DH OREG22 2010002FH 2010004FH GA OREG7 OREG23 R R 20100031H OREG8 20100051H OREG24 20100033H OREG9 20100053H OREG25 20100035H OREG10 20100055H OREG26 20100037H OREG11 20100057H OREG27 20100039H OREG12 20100059H OREG28 2010003BH OREG13 2010005BH OREG29 SE 2010003DH OREG14 2010005DH OREG30 2010003FH OREG15 2010005FH OREG31 Only byte access is possible for all registers. Figure 1.3 SH-2 Interface Register Address Map SMPC User's Manual 5 The details on SH-2 interface registers are as follows: COMREG (W): COMmand REGister commands, and RTC commands. Use byte access from the SH-2. nti This is an 8-bit register used to receive commands from the SH-2. At the same time a command is written, the SMPC interprets and executes the command. The SMPC has resetable system management commands, non-resetable system management SR (R): Status REGister al This 8-bit register is used to display the status after SMPC command execution. A read from the SH-2 can be done at any time regardless of the command being issued. For peripheral control, each peripheral control status is shown. Use byte access from the SH-2. SF (R/W): Status Flag de This flag controls command issue. Flag set is performed by the SH-2 before com- mand issue and the flag is reset by the SMPC when the command is ended. When from the SH-2, only set is possible, and when setting, write to 01H. During read, all bits except bit0 are undefined. Using this flag makes it possible to control the dual issue of commands. IREG0~IREG6 (W): Input REGister 0~6 nfi These 8-bit registers are used to receive command parameters from the SH-2. The SMPC has 7 IREG registers. Use byte access from the SH-2. Co OREG0~OREG31 (R): Output REGister 0~31 These 8-bit registers are used to used to output result parameter and peripheral data to the SH-2. The SMPC has 32 OREG which are used when reading the cartridge code, area code, peripheral data, current time, etc. Use byte access from the SH-2. GA SE 6 Parallel I/O Registers These registers are used to control the peripheral interface inside the SMPC. Figure 1.4 shows parallel I/O register address map. Write-only registers cannot be read, so caution regarding this is required. 20100075H 20100079H b it6 PDR1 DDR1 b it0 R/W W ntial 20100077H 2010007BH b it6 PDR2 DDR2 b it0 R/W W b it1 b it0 2010007DH IOSEL2 IOSEL1 W W : Write Only 2010007FH EXLE2 EXLE1 W de Only byte access is allowed to all the registers. Figure 1.4 Parallel I/O Register Address Map R/W: Read/Write DDR1 (W): Data Direction Register 1 nfi This is a 7-bit register used for setting, in bit units, the peripheral port 1 (P1) I/O direction. “0” is written to set for input and “1” is written to set for output. Please use byte access from the SH-2. DDR2 (W): Data Direction Register 2 0 Co This is a 7-bit register used for setting, in bit units, the peripheral port 2 (P2) I/O direction. “0” is written to set for input and “1” is written to set for output. Please use byte access from the SH-2. Table 1.3 DDR Functions Bit Function Input Setting (Initial Value) 1 Output Setting GA PDR1 (R or W): Port Data Register 1 The PDR1 is a 7-bit register that is used to store peripheral port 1 (P1) data. Whether all the PDR1 bits are at the input port or the output port is determined by DDR1 setting. The port terminal status that is set to output can be changed by writing data in this register. The port terminal status that is set to input can be changed by read- ing this register. Also, for ports set to output, the value written in to the PDR1 is read out rather than the terminal status. Please use byte access from the SH-2. SE SMPC User's Manual 7 PDR2 (R or W): Port Data Register 2 The PDR2 is a 7-bit register that is used to store peripheral port 2 (P2) data. Whether all the PDR2 bits are at the input port or the output port is determined by DDR2 IOSEL1 (W): I/O SELect 1 nti setting. The port terminal status that is set to output can be changed by writing data in this register. The port terminal status that is set to input can be changed by read- ing this register. Also, for ports set to output, the value written in to the PDR2 is read al out rather than the terminal status. Please use byte access from the SH-2. The peripheral port 1 (P1) is set to SMPC control mode or SH-2 direct mode. Writing “0” specifies the SMPC control mode and writing “1” specifies the SH-2 direct mode. Use byte access from the SH-2. IOSEL2 (W): I/O SELect 2 de The peripheral port 2 (P2) is set to SMPC control mode or SH-2 direct mode. Writing “0” specifies the SMPC control mode and writing “1” specifies the SH-2 direct mode. Use byte access from the SH-2. Table 1.4 IOSEL Functions Bit 0 1 nfiFunction Sets to SMPC control mode (Initial Value) Sets to SH-2 direct mode For details regarding each mode, refer to Section 3. EXLE1 (W): EXternal Latch Enable 1 Use byte access from the SH-2. Co The peripheral port 1 (P1) bit 6 is a setting bit that is used for PAD interrupt and VDP2 external latch input. It is disabled by writing “0,” and the peripheral port 1 bit 6 is normally set as an I/O port. It is enabled by writing “1,” which allows the pe- ripheral port 1 bit 6 to be used for PAD interrupt input or VDP2 external latch input. GA SE 8 EXLE2 (W): EXternal Latch Enable 2 The peripheral port 2 (P2) bit 6 is a setting bit that is used for PAD interrupt and VDP2 external latch input. It is disabled by writing “0,” and the peripheral port 1 bit Use byte access from the SH-2. nti 6 is normally set as an I/O port. It is enabled by writing “1,” which allows the pe- ripheral port 1 bit 6 to be used for PAD interrupt input or VDP2 external latch input. Table 1.5 EXLE Functions Bit 0 Disable (Initial Value) Function al 1 Enable EXLE is multiplexed in I/O port bit 6. Therefore, when using EXLE, the DDR1 and PAD Interrupt.) de DDR2 bit 6 must be set to input. (Refer to VDP2 external latch functions and SCU nfi Co GA SE SMPC User's Manual 9 (This page is blank in the original Japanese document.) ntial de nfi Co GA SE 10 Chapter 2 SMPC Commands ntial de nfi Co GA Section 2 Contents 2.1 SMPC Command List .............................................. 12 2.2 Command Issue ....................................................... 13 SE Command Issue Method.......................................... 13 Command Issue Timing ........................................... 17 Command Issue Limitations .................................... 19 2.3 Resetable System Management Commands ........... 21 2.4 Non-Resetable System Management Commands ... 35 2.5 RTC Commands ...................................................... 45 SMPC User's Manual 11 2.1 SMPC Command List SMPC commands are divided into three types; resetable system management com- mands, non-resetable system management commands, and RTC commands. Each of these commands is shown below. Table 2.1 Resetable System Management Commands Command Command SMPC ntial Execution Time No Command Name SR IREG OREG sec Abbreviation Code Interrupt min max 1 Master SH-2 ON MSHON 00 H Unused Unused Unused 31 30µ 2 Slave SH-2 ON 3 Slave SH-2 OFF 4 Sound ON 5 Sound OFF 6 CD ON SSHON SSHOFF SNDON SNDOFF CDON 02 H 03 H 06 H 07 H 08 H Unused Unused Unused Unused Unused deUnused Unused Unused Unused Unused Unused Unused Unused Unused Unused 31 31 31 31 31 30µ 30µ 30µ 30µ 40µ 7 CD OFF 8 Reset Entire System 9 Clock Change 352 Mode 10 Clock Change 320 Mode 11 NMI Request CDOFF SYSRES CKCHG352 CKCHG320 NMIREQ 09 H 0D H 0E H 0F H 18 H nfi Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused Unused 31 31 31 31 31 40µ 100m+ α 100m+ α 100m+ α 30µ 12 Reset Enable 13 Reset Disable Co RESENAB RESDISA 19 H 1A H Table 2.2 Non-Resetable System Management Commands Unused Unused Unused Unused Unused Unused 31 31 30µ 30µ Execution Time Command SMPC sec No Command Name Command Code Interrupt SR IREG OREG Abbreviation min max 1 Interrupt Back No GA 2 SMPC Memory Setting Table 2.3 RTC Commands Command Name INTBACK SETSMEM Command Command 10H 17H Used Unused Unused SMPC Used SR IREG 0~2 0~3 OREG 0~31 31 40 µ Execution Time sec 320m Abbreviation Code Interrupt min max SE 1 Time Setting SETTIME 16H Unused Unused 0~6 31 70 µ 12 2.2 Command Issue For commands to the SMPC, to issue commands when the command parameter is and write the command code in the SMPC command register. nti required after setting the SMPC status flag (SF) to “1,” set the command parameter, al When the SMPC command is issued, be careful of dual command issue. Prevention of dual issue of commands to the SMPC can be done using the SMPC status flag. When this flag is “1,” the SMPC is busy. When executing the command, verify that the status flag is “0” and then execute the command after setting “1.” The SMPC resets the status flag to “0” when the command is completed. Command Execution Method (1) de SMPC commands are classified by issue procedure and result parameter acquisition method according to the type of command execution contents, command parameter, and result parameter. These types and corresponding commands are shown in Table 2.4, and example issue methods for each type are shown in Figures 2.1 through 2.5. Type A This command resets the master SH-2 after command issue or changes to (2) (3) (4) Type B Type C Type D nfi exception processing, such as NMI. This command does not require the command parameter to be reset and the result parameter is not returned (except for OREG31, however). This command requires the command parameter to be reset and the result parameter is not returned (except for OREG31, however). This command requires the command parameter to be reset and the result parameter is returned, and also requires a SMPC interrupt at the time the Co result parameter is ready. Table 2.4 Command Issue Types Type Command A MSHON, SYSRES, NMIREQ, CKCHG352, CKCHG320 B SSHON, SSHOFF, SNDON, SNDOFF, CDON, CDOFF, RESENAB, RESDISA C SETTIME, SETSMEM D INTBACK GA SE SMPC User's Manual 13 START Waits for SF to be Reset Sets SF ntial Reads Command Code in COMREG deEndless Loop Waiting for exception handling. nfi Figure 2.1 Type A Command Flow Co START Waits for SF to be Reset Sets SF GA Reads Command Code in COMREG END SE Figure 2.2 Type B Command Flow 14 START Waits for SF to be Reset ntial Resets SF Sets the Command Parameter COMREG de in IREG Writes Command Code in nfi END Figure 2.3 Type C Command Flow Co GA SE SMPC User's Manual 15 START Waits for SF to be Reset ntial Set SF Sets the Command Parameter in IREG Writes Command Code in COMREG de END nfi SMPC Interrupt Processing START Co Clear Interrupt Flag Look at SR and Receive OREG Result Parameter Depending on Peripheral Status, Issue Continue or Break to SMPC (Refer to Chapter 3 for Details) GA Interrupt Processing END Figure 2.4 Type D Command Flow SE Note: A routine similar to the SMPC interrupt routine can be executed by masking the SMPC routine (SMPC interrupt is not used) and conducting polling after the SMPC interrupt flag or SF clear is conducted. 16 Command Issue Timing The SMPC uses the V-BLANK-IN interrupt to execute internal tasks. At this time, issuing commands for 300 ms from V-BLANK-IN is prohibited. or Section 3 “Peripheral Control.” nti Also, the INTBACK command that is used to acquire the SMPC statuses and periph- eral data has stricter issue timing than other commands. For details regarding the al INTBACK command, refer to 2.4 “Non-Resetable System Management Commands” • Items Common to Command Issue Timing As mentioned above, issuing commands for 300 µs from V-BLANK-IN is prohibited. • INTBACK Command de The INTBACK command begins collecting peripheral data at V-BLANK-OUT. To begin collecting peripheral data at V-BLANK-OUT, the INTBACK command must be issued in the period prior to V-BLANK-OUT after 300 µs following V-BLANK- IN.. nfi Figure 2.5 shows the INTBACK command execution timing. The INTBACK command is used in the following three ways. 1) To acquire only the SMPC status. 2) To collect peripheral data after acquiring the SMPC status. 3) To acquire only peripheral data. Co When executing (2) “To collect peripheral data after acquiring the SMPC status,” a SMPC interrupt is generated at the time the SMPC status is OREG and a request for result parameter acquisition is made to the SH-2. The SMPC begins collecting peripheral data after the SH-2 makes a continue request. Here, even though a continue request has been issued after SMPC status acquisi- tion, it is still necessary to issue an INTBACK command and request continue to begin collecting peripheral data at V-BLANK-OUT. GA SMPC status acquisition ends approximately 300 µs after INTBACK command issue, and a SMPC interrupt request is sent to the SMPC. SE SMPC User's Manual 17 300 µ S : INTBACK Command Issue Period V-BLANK During V-BLANK ntial V-BLANK-IN V-BLANK-OUT Figure 2.5 INTBACK Command Issue Timing • INTBACK Command Issue Timing after SYSRES, CKCHG320, CKCHG352 Command Execution are executed. de The command execution time for the above commands requires 100 msec or more. When an INTBACK command is issued after one of these commands is executed, wait to execute them until the next V-BLANK-IN. Figure 2.6 shows the INTBACK command issue timing after the SYSRES, CKCHG320, and CKCHG352 commands The SYSRES, CKCHG320, and CKCHG352 commands must be issued 300 µs after V-BLANK-IN and before the next V-BLANK-IN. nfi : INTBACK Command Issue Period Co SYSRES, CKCHG320, CKCHG352 Commands Command End 100 msec or More V-BLANK V-BLANK-IN Figure 2.6 INTBACK Command Issue Timing After SYSRES, CKCHG320, and GA CKCHG352 Command Execution. • Issue Timing for Other Commands When an INTBACK command is not issued in the same frame after one of the other commands is executed, the command must be issued 300 µs after V-BLANK-IN and before the next V-BLANK-IN. When an INTBACK command is issued in the same frame as one of the other commands that is issued 300 µs after V-BLANK-IN and before the next V-BLANK-IN, issue the INTBACK command before V-BLANK-OUT. SE Figure 2.7 shows the issue timing of other commands. 18 Other Command Issue in Frame that Does Not Issue INTBACK Command V-BLANK 300 µs nti : Other Command Issue Period al Other Command Issue in Frame that Issues INTBACK Command : Other Command Issue Period 300 µs : INTBACK Command Issue Period V-BLANK de V-BLANK-IN Command Issue Limitations nfi Figure 2.7 Issue of Other Commands Following is an explanation of limitations when issuing commands. Co • When conducting command issue processing for the SMPC, a maximum effort shall be made to conduct single tasks. If multiple issues are being processed, problems, such asdual command issue, could occur, which could cause the SMPC error or a deadlock to occur. When multiple tasks have to be executed, and when a command must be issued to the SMPC, always perform these executions by adding exclusion controls that do not generate dual command issue between tasks to the above described com mand issue methods. GA • When commands are issued sequentially, always verify the status flag to make sure commands are not dually issued and only issue the next command after the previous command issue has finished. • Perform real-time clock count up once every second. Also, conduct a detection of the SMPC’s internal reset button immediately after V-BLANK-IN. If a command is issued while this processing is being conducted, this processing time will be added to the command processing time, so be careful because this will change the SEcommand processing time. • SMPC commands can be issued from either the master or slave SH-2, but there are commands for which issue is limited, such as when system operation is stopped. Table 2.5 shows the SH-2 command issue limitations. SMPC User's Manual 19 Table 2.5 SH-2 Command Issue Limitations No. Command Name Command Command Execution Command Execution Abbreviation from Master SH-2 from Slave SH-2 1 Master SH-2 ON MSHON O O 2 3 4 5 6 7 8 9 Slave SH-2 ON Slave SH-2 OFF Sound ON Sound OFF CD ON CD OFF System Overall Reset Clock Change 352 SSHON SSHOFF SNDON SNDOFF CDON CDOFF SYSRES CKCHG352 O O O O O O O O ntial X X O O O O O X 10 Clock Change 320 CKCHG320 O X 11 NMI Request NMIREQ O O 12 Reset Enable RESENAB O O 13 Reset Disable RESDISA O O 14 15 16 Interrupt Back SMPC Memory Setting Time Setting INTBACK SETSMEM SETTIME deO O O X O O nfi Co GA SE 20 2.3 Resetable System Management Commands The details for the resetable system management commands are given in table mands. nti format. The way to view the command tables and precaution items are given below. In addition, a status flag is used for each command to control the dual issue of com- SMPC Interrupt al The word “generation” means that a SMPC interrupt is generated by the SH-2 via the SCU when the command ends. In addition, the interrupt can be enabled or disabled by so setting the SCU. IREG, OREG de • Shows the details of the IREG and OREG used by commands. • A command parameter is a parameter that is set in IREG before the command is issued. • A result parameter is a parameter that is set in OREG before the command is executed. it possible to determine: nfi • Result parameter OREG31 is set when the SMPC begins command processing. The command code is output to OREG31. Also using it as a status flag (SF) makes Which command is executing Which command has finished (SF=1) (SF=0) Execution Time Co Shows the execution time calculated from the number of SMPC internal firmware steps. When there is a collision with an internal task, such as an RTC increment, the command execution time is changed, so the minimum and maximum range values are given. GA SE SMPC User's Manual 21 Command NO. 1 MSHON Master SH-2 ON Code 00 H SMPC Interrupt Function Generation Not Possible Description IREG Unused Turns on master SH-2. OREG 31 nti Execution Time al max XXX min 30 µsec Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 0 0 0 0 bit0 0 Co GA Remarks SE 22 Command NO. 2 SSHON Slave SH-2 ON Code 02 H SMPC Interrupt Function Generation Not Possible Description IREG Unused Turns on slave SH-2. OREG 31 nti Execution al Time max XXX min 30 µsec Command None Parameter de Result Parameter nfi OREG31 2010005F H bit7 0 0 0 0 0 0 1 bit0 0 Co GA Remarks SE SMPC User's Manual 23 Command NO. 3 SSHOFF Slave SH-2 OFF Code 03 H nti SMPC Generation Execution max min IREG Unused OREG 31 Interrupt Not Possible Time XXX 30 µsec Function Turns off slave SH-2. Description Command Parameter None al de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 0 0 0 1 bit0 1 Co GA Remarks SE 24 Command NO. 4 SNDON Sound ON Code 06 H nti SMPC Generation Execution max min Interrupt Not Possible IREG Unused OREG 31 Time XXX 30 µsec Function Turns on the sound CPU (MC68EC000). Description Command Parameter None al de Result Parameter nfi OREG31 2010005F H bit7 0 0 0 0 0 1 1 bit0 0 Co GA Remarks SE SMPC User's Manual 25 Command NO. 5 SNDOFF Sound OFF Code 07 H SMPC Interrupt Function Generation Not Possible Description IREG Unused OREG Turns off the sound CPU (MC68EC000). 31 nti Execution Time al max XXX min 30 µsec Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 0 0 1 1 bit0 1 Co GA Remarks Even if the sound CPU is turned off using this command, the sound memory SE contents (4M DRAM) will be preserved. 26 Command NO. 6 CDON CD ON Code 08 H SMPC Interrupt Function Generation Not Possible Description IREG Turns on CD. Unused OREG 31 nti Execution al Time max XXX min 40 µsec Command None Parameter de Result Parameter nfi OREG31 2010005F H bit7 0 0 0 0 1 0 0 bit0 0 Co GA Remarks SE SMPC User's Manual 27 Command NO. 7 CDOFF CD OFF Code 09 H SMPC Interrupt Function Generation Not Possible Description IREG Turns off CD. Unused OREG 31 nti Execution Time al max XXX min 40 µsec Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 0 1 0 0 bit0 1 Co GA Remarks The execution of this command will cause the CD buffer (DRAM) value not to be retained. SE 28 Command NO. 8 SYSRES Entire System Reset Code 0D H α SMPC Interrupt Function Generation Not Possible Description IREG Unused Resets the entire SATURN system. OREG 31 ntial Execution Time 100 msec + Command None Parameter de Result Parameter OREG31 2010005F Hnfi bit7 0 0 0 0 1 1 0 bit0 1 Co GA Remarks Execution of this command resets (initializes) all functions, causes the SH-2 to run the SE power on vecter, and starts up the boot ROM. None of the memory, except for 256 Kbit battery backup RAM, will be retained. SMPC User's Manual 29 Command NO. 9 CKCHG352 Clock Change 352 Mode Code 0EH α SMPC Interrupt Function Generation Not Possible Description IREG Unused OREG 31 nti Execution Time Switch the SATURN system clock from 320 mode to 352 mode. al 100 msec + Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 0 1 1 1 bit0 0 Co Remarks GA Issuing this command from an application is prohibited. Call the clock change routine in the SATURN boot ROM. When clock change routine is called, all LSI will become as follows. SE • VDP1, VDP2, SCU, SCSP: Default value during power on. • Master SH-2: Return from boot ROM clock change routine. • Slave SH-2: OFF • CD block: Retained • Work RAM: Retained • VRAM: Not retained 30 Command NO. 10 CKCHG320 Clock Change 320 Mode Code 0FH α SMPC Interrupt Function Generation Not Possible Description IREG Unused OREG 31 nti Execution Time Switch the SATURN system clock from 352 mode to 320 mode. al 100 msec + Command None Parameter de Result Parameter nfi OREG31 2010005F H bit7 0 0 0 0 1 1 1 bit0 1 Co GA Remarks Issuing this command from an application is prohibited. Call the clock change routine in the SATURN boot ROM. When clock change routine is called, all LSI will become as follows. SE • VDP1, VDP2, SCU, SCSP: Default value during power on. • Master SH-2: Return from boot ROM clock change routine. • Slave SH-2: OFF • CD block: Retained • Work RAM: Retained • VRAM: Not retained SMPC User's Manual 31 Command NO. 11 NMIREQ NMI Request Code 18 H SMPC Interrupt Generation Not Possible Function Description IREG Unused OREG Sends NMI request to master SH-2. 31 nti Execution Time al max XXX min 30 µsec Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 1 1 0 0 bit0 0 Co GA Remarks NMI is requested unconditionally even if disabled by the RESDISA command. SE 32 Command NO. 12 RESENAB Reset Enable Code 19 H nti SMPC Generation Execution max min IREG Unused OREG 31 Interrupt Not Possible Time XXX 30 µ sec Function This is a command to enable NMI generation. Description Command Parameter al In SATURN, NMI is generated when the main unit panel reset button is pushed. When power is on, the default is set disabled. None de Result Parameter nfi OREG31 2010005F H bit7 0 0 0 1 1 0 0 bit0 1 Co GA Remarks NMI is generated when the reset button is pushed during the 3VINT period to SE prevent chattering. SMPC User's Manual 33 Command NO. 13 RESDISA Reset Disable Code 1AH nti SMPC Generation Execution max min IREG Unused OREG 31 Interrupt Not Possible Time XXX 30 µ sec Function This is a command to disable NMI generation. al Description In SATURN, generates NMI when main unit panel reset button is pushed. The defaut is "disabled" when the power is turned on. Command None Parameter de Result Parameter OREG31 2010005F H nfi bit7 0 0 0 1 1 0 1 bit0 0 Co Remarks GA The reset switch is only shown by the SR (status register) RESB bit (bit4) and does not output an NMI to the master SH-2. The RESB bit shows the button SE status at V-BLANK-IN. 34 2.4 Non-Resetable System Management Commands The details for the non-resetable system management commands are given in table format. nti The way to view the command tables and precaution items are given below. Also, a al status flag is used for each command to control dual command issue. SMPC Interrupt The word “generation” means that a SMPC interrupt is generated by the SH-2 via the SCU when the command ends. In addition, the interrupt can be enabled or disabled by setting the SCU. IREG, OREG de • Shows the details of the IREG and OREG used by commands. • A command parameter is a parameter that is set in IREG before the command is issued. • A result parameter is a parameter that is set in OREG before the command is executed. nfi • Result parameter OREG31 is set when the SMPC begins command processing. The command code is output to OREG31. Also using it as a status flag (SF) makes it possible to determine: Which command is executing Which command has finished (SF=1) (SF=0) Execution Time Co Shows the execution time calculated from the number of SMPC internal firmware steps. When there is a collision with an internal task, such as a RTC increment, the command execution time is changed, so the minimum and maximum range values are given. GA SE SMPC User's Manual 35 Command NO. 1 INTBACK Interrupt Back (SMPC Status Acquisition) Code 10 H SMPC Interrupt Function Description Generation IREG 0~2 OREG 0 ~31 nti Execution Time al max 320 msec min XXX Acquires the SMPC status and peripheral data. Here status acquisition will be explained. The acquisition of peripheral data will be explained in Section 3. Command Here, the INTBACK command's command parameter during peripheral Parameter data acquisition is also displayed. explained next after result parameter. de Refer to command parameter on the next page. The command parameter setting method during SMPC status acquisition is Result Parameter nfi The result parameter is explained after the command parameter. Here, the result parameter, which is limited by the SMPC status acquisition is displayed. Co GA SE Remarks 36 Command Parameter bit7 bit0 IREG0 20100001 H nti SMPC Status Acquisition Switch (00H or 01 H) Initial Value: Not Specified Write Only IREG0: SMPC Status Acquisition Switch Setting Value IREG0 Setting Value Explanation al 00H Does not return data for time, cartridge code, area code, terminal status, SMEM, or reset button mode. 01H Returns data for time, cartridge code, area code, terminal status, SMEM, or reset button mode. been set. de When using the INTBACK command, be sure one of the above setting values has IREG0 is also used to control peripherals. Refer to Section 3 for details regarding peripheral control. IREG1 20100003H Bit7, 6: Port 2 Mode nfi bit7 W W W W bit4 P2MD1 P2MD0 P1MD1 P1MD0 bit3 PEN 0 OPE Unde. Unde. Unde. Unde. Unde. Unde. Unde. Unde. W --- W --- bit0 0 Bit7 P2MD1 0 0 1 1 Co Bit 6 P2MD0 0 1 0 1 15-Byte Mode 255-Byte Mode Explanation SEGA RESERVED (Setting Restricted) 0-Byte Mode GA Bit5, 4: Port 1 Mode Bit5 Bit 4 Explanation P1MD1 P1MD0 0 0 15-Byte Mode 0 1 255-Byte Mode 1 0 SEGA RESERVED (Setting Restricted) 1 1 0-Byte Mode SE SMPC User's Manual 37 Bit3: Peripheral Data Enable PEN Bit3 0 1 Explanation Peripheral Data Not Returned Peripheral Data Returned Bit1: Acquisition Time Optimization ntial Bit1 Explanation OPE 0 Peripheral Data Acquisition Time Optimized 1 Peripheral Data Acquisition Time not Optimized IREG2 bit7 de F0H bit0 20100005H nfi Initial Value: Not Specified Write Only When executing the INTBACK command, be sure to set F0H in IREG2. Co GA SE 38 Result Parameter bit7 bit4 bit3 bit0 SR 20100061H 0 1 PDE RESB --- --- --- --- •PDE •RESB 0: No remaining peripheral data. 1: Remaining peripheral data. 0: Reset button off. 1: Reset button on. ntial Read can be performed without regard for the INTBACK command. bit7 bit4 bit3 bit0 OREG0 20100021H STE RESD --- --- --- --- --- --- •STE 0: Not SETTIME after SMPC cold reset Note 1 1: SETTIME is done after SMPC cold reset Note 1 •RESD 0: Reset enable de 1: Reset disable (default) Note 1: SMPC cold reset is generated under the following conditions. (1) When the reset switch inside the SATURN backside battery box is pressed. (2) When the main power is on while a battery is not installed or is dead. (3) When a battery is installed while the power is off. bit7 bit0 OREG1 20100023H OREG2 20100025H OREG3 20100027H nfi Year 1000s Place Year 10s Place Day Note 2 Year 100s Place Year 1s Place Month (Hexadecimal) Note 3 (BCD) (BCD) Co Note 2: Day 0H: Sun 1H: Mon 2H: Tue 3 H: Wed 4H: Thur 5H: Fri 6H: Sat Note 3: Month 1H: Jan 2 H: Feb 3H: Mar 4 H: Apr 5H: May 6 H: Jun 7H: July 8H: Aug 9 H: Sep AH: Oct BH: Nov CH: Dec OREG4 20100029H bit7 Days 10s Place Days 1s Place bit0 (BCD) OREG5 2010002B H Hrs. 10s Place Hrs. 1s Place (BCD) GA OREG6 2010002DH OREG7 2010002F H OREG8 20100031H 0 Min. 10s Place •CTG1: Cartridge Code 1 Sec. 10s Place 0 0 0 0 Min. 1s Place Sec. 1s Place 0 CTG1 CTG0 (BCD) (BCD) •CTG0: Cartridge Code 0 SE SMPC User's Manual 39 bit7 bit0 bit7 bit0 nti OREG9 Area Code (00H~0FH) 20100033H OREG9 Area Code (00H~0FH) 20100033H Area Code al Code Area Code Area Major Country Names, Etc. Code0H Use Prohibited Area Major Country Names, Etc. 0H1H Japan Area Use Prohibited Japan 1H Asia NTSC 2H Japan Area area Taiwan, Japan Philippines 3H SEGA RESERVED Asia NTSC Area Taiwan, Philippines 2H North RESERVED 4H SEGA America area U.S.A., Canada, Mexico 3H 5H North Central/S. America NTSC area BrazilMexico America Area U.S.A., Canada, 4H Korea areaAmerica NTSC Area Brazil 6H Central/S. South Korea 5H 6H 7H 8H 9H BH 7H Korea SEGAArea SEGARESERVED 8H SEGA SEGARESERVED 9H SEGA AH Asia SEGAPAL area SEGA BH Asia AH RESERVED RESERVED RESERVED RESERVED RESERVED PAL Area Europe PAL CH SEGA PAL South Korea area, etc. RESERVED Central/S. DH Europe Amercia PAL area Area, etc. de East Asia, China, Middle East East Asia, China, Middle East Europe, Australia, South Africa Europe, Australia, South Africa CH DH E HH F OREG10 Central/S. EH SEGA FH Use SEGAProhibited Use Prohibited 20100035H America PAL Area RESERVED RESERVED bit7 nfi System Status 1 bit0 System OREG10 •b7 0B •b6 DOTSEL Signal Note •b5 1B 20100035H •b4 1B •b3 MSHNMI Signal •b2 1B System •b1 SYSRES •b7 0B •b40:1B Status 1Signal Note: Status 1 (Status of Control Signals Output System (Status DOTSEL •b6The DOTSEL •b31:MSHNMI 320 352 Signal Co Control Signals •b0ofSNDRES Note •b5 signal is Signal •b2 1B •b1 SYSRES Signal •b0 SNDRES Signal currently 0: OFF by SMPCStatus 1 1 :ON) Signal Output by SMPC 0: OFF 1 :ON) 1B shown in the screen mode (horizontal resolution). Note: The DOTSEL signal is currently shown in the screen mode (horizontal resolution). 0: 320 1: 352 bit7 bit0 •b7 GA OREG11 20100037H System Status 2 (Status of Control Signals Output by SMPC 0: OFF 1 :ON) OREG11 Status 2 (Status bit7 RESERVED •b6 CDRES Signal •b5 RESERVED 20100037H •b4 RESERVED •b3 RESERVED •b2 RESERVED •b1 RESERVED System •b0 RESERVED of Control Signals Output by SMPC 0: OFF 1 :ON) •b7 RESERVED •b6 CDRES Signal •b5 RESERVED System Status 2 System Status 2 bit0 •b4 RESERVED •b3 RESERVED •b2 RESERVED SE •b1 RESERVED •b0 RESERVED 40 bit7 bit0 OREG12 20100039H SMEM 1 Saved Data OREG13 2010003BH OREG14 2010003D H OREG15 2010003F H bit7 nti SMEM 2 Saved Data SMEM 3 Saved Data al SMEM 4 Saved Data bit0 OREG31 2010005FH 0 0 0 0 0 0 0 0 With peripheral data, however, the command code (OREG31) could be overwritten. de nfi Co GA SE SMPC User's Manual 41 How to Use INTBACK Command when Acquiring SMPC Status There are three ways the INTBACK command can be used. 1) 2) 3) Acquire only SMPC status. Acquire peripheral data after acquiring SMPC status. Acquire only peripheral data. ntial This section primarily explains how to acquire SMPC status. Here, acquiring status using methods 1) and 2) are explained. For an explanation regarding peripheral data acquisition, refer to Section 3. Method for Acquiring Only SMPC Status execute the INTBACK command. de When acquiring status only, set the command parameter as shown below, and IREG IREG0 Setting Value 01H Description All data for time, cartridge code, area code, terminal status, SMEM, and reset button mode is returned. IREG1 00H nfi Terminal 2 mode (P2MD1, P2MD0)=00B 15-byte mode Terminal 1 mode (P1MD1, P1MD0)=00B 15-byte mode Peripheral data enable (PEN)=0B Peripheral data not returned Acquisition time optimization (OPE)=0B Performs IREG2 F0H Co peripheral acquisition time optimization. Set F0H without conditions. This setting can clear the SF, ends the INTBACK command, and acquires the result data. Also, when the command ends, a SMPC interrupt request is sent. The execution time is from minimum TBD to maximum TBD. GA SE 42 Method for Acquiring Peripheral Data After Acquiring SMPC Status set to the value desired for the application. nti When acquiring peripheral data after acquiring SMPC status acquisition, set the command parameter as shown below and issue the INTBACK command. The IREG1 setting value can be IREG Setting Value al Description All data for time, cartridge code, area code, terminal IREG0 01H status, SMEM, and reset button mode is returned. IREG1 08H Terminal 2 mode (P2MD1, P2MD0)=00B 15-byte mode Terminal 1 mode (P1MD1, P1MD0)=00B 15-byte mode IREG2 F0H returned de Peripheral data enable (PEN)=1B Peripheral data Acquisition time optimization (OPE)=0B Performs peripheral acquisition time optimization. Set F0H without conditions. nfi This setting executes the SMPC command and requests a SMPC interrupt when the result parameter is set. When the SMPC interrupt is requested, the SF is changed to busy "1." The execution time from command issue to result parameter setting completion is minimum TBD to maximum TBD. After the result parameter for the status is acquired, the value of the IREG0 bit7 is changed, then the SMPC understands this as continue and continues acquiring peripheral data. Co This method is effective for use with applications that acquire all status types for each frame and that acquire peripheral data. GA SE SMPC User's Manual 43 Command NO. 2 SETSMEM SMPC Memory Setting Code 17 H SMPC Interrupt Function Generation Possible Description IREG 0 ~3 OREG 31 Execution Time The SMPC has a 4-byte battery backupable memory (SMEM) This command sets data to the SMEM. ntial max XXX min 40 µsec Command Parameter bit7 bit0 IREG0 20100001H IREG1 20100003H IREG2 20100005H de Setting Data to SMEM1 Setting Data to SMEM2 Setting Data to SMEM3 Result Parameter IREG3 20100007H OREG31 2010005F H nfi bit7 0 0 Setting Data to SMEM4 0 1 0 1 1 bit0 1 Remarks Co • The SMEM contents are cleared to 0 when the SMPC is cold reset. A SMPC cold reset is generated under the following conditions. (1) When the reset switch in the SATURN backside battery box is pushed. (2) When the main power is turned on while no battery is installed or when the battery is dead. (3) Cleared to 0 when a battery is installed while the power is off. Becomes 0 after the main power is first turned on. • With the SETSMEM command, 4 bytes can be set at the same time. When the contents are updated, use the INTBACK command to read, modify, or GA write the currently saved data. • If the power is turned off when the SETSMEM command is issued: (1) All data is updated when the SETSMEM command internal processing is executed first by the power off sequence. (2) When the power off sequence is executed first, the data before the command was issued is saved. SE 44 2.5 RTC Commands The details for the RTC commands are given in table format. The way to view the each command to control dual command issue. nti command tables and precaution items are given below. Also, a status flag is used for SMPC Interrupt al The word “generation” means that a SMPC interrupt is generated by the SH-2 via the SCU when the command ends. In addition, the interrupt can be enabled or disabled by setting the SCU. IREG, OREG issued. de • Shows the details of the IREG and OREG used by commands. • A command parameter is a parameter that is set in IREG before the command is • A result parameter is a parameter that is set in OREG before the command is executed. • Result parameter OREG31 is set when the SMPC begins command processing. it possible to determine: nfi The command code is output to OREG31. Also using it as a status flag (SF) makes Which command is executing Which command has finished (SF=1) (SF=0) Execution Time are given. Co Shows the execution time calculated from the number of SMPC internal firmware steps. When there is a collision with an internal task, such as a RTC increment, the command execution time is changed, so the minimum and maximum range values GA SE SMPC User's Manual 45 Command NO. 1 SETTIME Time Setting Code 16 H SMPC Interrupt Function Command Interrupt Generation Description Parameter Not Possible IREG Sets the RTC time. 0~6 bit7 OREG 31 Execution bit4 bit3 nti Time al max XXX 70 µsec bit0 min IREG0 20100001H Year 1000s Place Year 100s Place (BCD) IREG1 20100003H Year 10s Place Year 1s Place (BCD) IREG2 20100005H IREG3 20100007H IREG4 20100009H Day Note 1 Days 10s Place Hour 10s Place de Month (Hexadecimal) Note 2 Days 1s Place Hour 1s Place (BCD) (BCD) IREG5 2010000BH IREG6 2010000DH nfi Minute 10s Place Second 10s Place Minute 1s Place Second 1s Place (BCD) (BCD) Co Note 1: Days 0H: Sun. 1H: Mon. 2 H: Tue. 3 H: Wed. 4H : Thur. 5H : Fri. 6H: Sat. Note 2: Month 1H: Jan 2 H: Feb 3H: Mar 4 H: Apr 5H: May 6 H: Jun 7H: July 8H: Aug 9 H: Sep AH: Oct BH: Nov CH: Dec Result bit7 bit0 Parameter OREG031 25FC00BC H 0 0 0 1 0 1 1 0 Remarks GA • • The time is initialized to "12/31/93 Friday 23:59:59" and the count is started during SMPC cold reset. The SMPC cold reset is generated under the following conditions. (1) When the reset switch in the SATURN background battery box is pushed down. (2) When the battery is not installed or is dead and the main power is on. (3) When 0 cleared when the battery is installed when the power is off. When data that does not actually exist, a day higher than 7, a month higher than 12, a date for a month not supported (correction is made for leap years SE until 2099), hours above 24, minutes above 60, or seconds above 60 are set, the set value or the count up value becomes undefined. • If the SETTIME command is issued while the power is off: (1) All data is updated if the SETTIME command internal processing is executed before the power off sequence. (2) The data before command issuance is preserved when the power off sequence is executed first. 46 Chapter 3 Peripheral Control ntial de nfi Co GA Section 3 Contents 3.1 Peripheral Control Mode....................................................................................... 48 SMPC Control Mode............................................................................................. 48 INTBACK Command Use Method for SMPC Control Mode Peripheral Data Collection Time Optimization ....................................... 53 .......................................................... 55 INTBACK Command's Command Parameters During Peripheral Data Acquisition INTBACK Command Result Parameter During Peripheral Data Acquisition ...... 58 ................ 61 Peripheral Data Configuration................................................................................ 65 Result Parameter Details ........................................................................................ 66 SE SATURN Peripheral ID........................................................................................... 69 SH-2 Direct Mode.................................................................................................. 3.2 SATURN Peripheral 3.1 Purpose of SATURN 3.2 3.4 Support Peripheral Data Section 3 Contents Standard Peripheral SATURN Standard Format Types and Data Format 3.3 Format ..................................................................... Peripheral Control Mode .......................................................... Support Standard SATURN Peripheral Standard Formats .................................... Peripheral 3.3 Support Peripheral Data Format for SMPC Control Mode Peripheral Supportfor SH-2 3.4 Format Format Direct .................................................... Data Data .................................................. 76 Format Format in SH-2 Mode in SMPC Control Mode ......................................... 81 Direct Mode 86 ............................................. 74 76 76 48 76 .........81 ............ 86 SMPC User's Manual 47 3.1 Peripheral Control Mode methods. They are: nti The SH-2 can control peripherals via the SMPC. There are two peripheral control 1) SMPC Control Mode 2) SH-2 Direct Mode SMPC Control Mode al Block Diagram Figure 3.1 shows the SMPC control mode block diagram. The SMPC control mode sets the command parameter in the SH-2 interface register’s IREG and is started up by issuing an INTBACK command. The peripheral data collection results are output to the OREG as a result parameter. SH-2 SH-2 de SMPC PDR1 Data Bus 8 nfi Interface Register PDR2 7 7 Characteristics Co Figure 3.1 SMPC Control Mode Block Diagram Used as an effective method to keep overhead to a minimum when accessing periph- erals from inside an application. Settings for Using SMPC Control Mode Figure 3.2 shows an setting example for using the SMPC control mode for port 1. Mode settings are set independently for each port. GA SE 48 SMPC Control Mode Set DDR1 to "00H" When using EXL1 "0", disable EXL1 to "0". ntial Set IOSEL1 to "0" de Setting End Figure 3.2 SMPC Control Mode Setting Example. Table 3.1. nfi • Parallel I/O Register Default Value During Power On During power-on, the parallel I/O register is set to the default values shown in Table 3.1 Parallel I/O Register Default Values During Power-On Co Register Name Setting Value Description IOSEL1/2 0H SMPC control mode EXL1/2 0H PAD interrupt VDP2 external latch disable DDR1/2 00H Input of all bits SMPC Control Mode Use Method When using the INTBACK command and acquiring peripheral data, the collected peripheral data is output to the OREG as a result parameter. However, it is possible that the collected peripheral data is larger than the OREG capacity. At this time, in GA the SMPC control mode, peripheral data acquisition is stopped when the OREG becomes full. When the OREG becomes full with peripheral data, the SMPC gener- ates an SMPC interrupt and sends a request for peripheral data acquisition to the SH-2. Also, when there is still peripheral data that should be collected, it is displayed that data still remains in the status register. After the SH-2 acquires the peripheral data, a continue request is sent to the SMPC which causes the SMPC to begin acquiring SE peripheral data again. When the remaining peripheral data is not needed, peripheral data acquisition is ended by a break request. The above sequence is illustrated in Figures 3.3 and 3.4. SMPC User's Manual 49 Continue Request A continue request from the SH-2 to the SMPC is done by reversing the IREG bit 7. Break Request nti A break request from the SH-2 to the SMPC is made by writing “1” in the IREG0’s bit 6. Precautions Regarding Continue and Break Requests al When requesting continue or break, be aware of the conditions given in Table 3.2. Table 3.2 Continue and Break Issue Conditions Issue to be requested Continue Break Received Condition SMPC Operation X X O O X O X O Hold Break Continue Prohibited de Request Wait Peripheral data collection is stopped and INTBACK command is terminated. Peripheral data collection is continued. No guarantee Termination Conditions for INTBACK Command that Acquires Peripheral Data ing conditions. nfi The INTBACK command that acquires peripheral data is terminated by the follow- 1) When all peripheral data acquisition is completed. 2) When peripheral data collection could not be completed by V-BLANK-IN (time over). 3) Peripheral data collection was terminated by a break request from the SH-2. Co GA SE 50 SH-2 IREG Set INTBACK Command Issued SMPC ntial Collect Peripheral Data and Create OREG Data Remains de Interrupt Generated OREG Acquisition CONTINUE Request Data Remains nfiInterrupt Generated •• • OREG Acquisition Create OREG CONTINUE Request Co Data Remains Data Remains Interrupt Generated OREG Acquisition CONTINUE Request Create OREG GA Create OREG Interrupt Generated No Data Remains INTBACK Command Ends Figure 3.3 All Peripheral Data Acquisition Sequence SE SMPC User's Manual 51 SH-2 IREG Set INTBACK Command Issued SMPC ntial Collect Peripheral Data and Create OREG Data Remains Interrupt Generated OREG Acquisition CONTINUE Request de Data Remains nfi Interrupt Generated OREG Acquisition •• • Create OREG CONTINUE Request Data Remains Data Remains Co Interrupt Generated OREG Acquisition BREAK Request Create OREG GA INTBACK Command Ends Figure 3.4 Peripheral Data Acquisition Cancel Sequence Due to Break Request SE 52 Methods for Using INTBACK Command in SMPC Control Mode Section 2 explained how to acquire SMPC status using the INTBACK command. As was explained in Section 2, the INTBACK command can be used in three ways. 1) To acquire only the SMPC status. nti 2) To acquire peripheral data after acquiring SMPC status. 3) To acquire only peripheral data. al This section continues on mainly explaining the peripheral control functions by explaining (2) “to acquire peripheral data after acquiring SMPC status” and (3) “to acquire only peripheral data.” How to Acquire Peripheral Data After Acquiring SMPC Status Here the procedure for acquiring peripheral data after acquiring the SMPC status is 3.3 and 3.4) de explained. The procedure for acquiring SMPC status is explained in Section 2, so the following only explains the procedure after status data acquisition. (Refer to Figures 1) Continue request or break request (SH-2) 2) Peripheral data acquisition and result parameter setting (SMPC) 5) INTBACK command end nfi 3) SMPC interrupt generation (SMPC) 4) Peripheral data acquisition (SH-2) If peripheral data still remains, repeat processing from (1). How to Acquire Only Peripheral Data Co The procedure for using the INTBACK command to acquire only peripheral data is explained below. (Refer to Figures 3.3 and 3.4) 1) Command parameter setting (SH-2). 2) INTBACK command issue (SH-2). Examples are given in Table 3.3. 3) Peripheral data collection and result parameter setting (SMPC). 4) SMPC interrupt generation (SMPC). 5) Peripheral data acquisition (SH-2) When no peripheral data remains, the INTBACK command ends (SMPC). GA 6) Continue request or break request (SH-2) 7) When continue is requested the processing in (3) is repeated. 8) INTBACK command end. SE SMPC User's Manual 53 Table 3.3 Example Acquisition Command Parameter Setting When Only Peripheral Data Is Acquired IREG Setting Value Description nti IREG0 00H The data and time, cartridge code, area code, terminal status, SMEM, and reset button mode data are not returned. IREG1 Application specifications Port 2 mode (P2MD1, P2MD0)=from application (except PEN bit) specifications IREG2 F0H specifications al Port 1 mode (P1MD1, P1MD0)=from application Peripheral data enable (PEN)=1B return peripheral data Acquisition time optimization (OPE)=from application specifications Set unconditionally in F0H. de nfi Co GA SE 54 Peripheral Data Collection Time Optimization The application processing cycle for the SMPC was created as follows. 1) Peripheral data is prepared until V-BLANK-IN. output. nti 2) The sprite and control screen parameter in the peripheral are calculated and 3) 3D calculation, etc. 4) Sprite and polygon drawing. 5) Display al The purpose of optimizing the peripheral data collection time is to collect the pe- ripheral data as close to V-BLANK-IN as possible. In other words, the start of pe- ripheral data collection is made as close as possible to V-BLANK-IN to shorten the de time from peripheral data collection to peripheral data acquisition by SH-2. Figure 3.5 shows an operation overview of peripheral data collection time optimization. OREG Acquisition Peripheral V-BLANK nfi INTBACK Issued 1 Peripheral Data Change Information is 1 Peripheral Data Acquisition Response Is Slow Co INTBACK Issued END Peripheral Data Is Changed Optimization Peripheral Data Change OREG Acquisition Peripheral Information is 2 V-BLANK GA Collection Start Timing is Offset 2 1 ms Peripheral Data Collection END SE Figure 3.5 Overview of Peripheral Data Collection Time Optimization SMPC User's Manual 55 Operations when Peripheral Data Collection Time Is Not Optimized Issue the INTBACK command after 300 µs prior to V-BLANK-IN and before V- BLANK-OUT. This makes it possible to accurately start peripheral data collection at V-BLANK-OUT. Peripheral data collection starts when the SMPC detects V-BLANK- OUT. The INTBACK command terminates at the time peripheral data collection is finished. Precautions when Peripheral Data Collection Time Is Not Optimized ntial The peripheral data collection end timing varies depending on the type and number of peripherals that are connected. For example, for a SATURN standard PAD 2 unit configuration, all the peripheral data is put in the OREG much faster than V- BLANK-IN. If an SMPC interrupt is used in this case, peripheral data can be acquired faster than with V-BLANK-IN. Also, as above, when less than 32 OREG are used, peripheral BLANK-OUT. de data can be acquired using V-BLANK-IN timing without using an SMPC interrupt. Operations for Optimizing Peripheral Data Collection Time Issue the INTBACK command after 300 µs after V-BLANK-IN and before V-BLANK- OUT. This makes it possible to accurately start peripheral data collection at V- nfi When optimizing peripheral data collection time, the SMPC first collects peripheral data without optimization and measures the collection time. The peripheral data collection start timing is the timing when the SMPC detects V-BLANK-OUT, as in the case when peripheral data collection time is not optimized. Co From the next frame, a 1 msec margin is added to the measured time, and this time is used as the peripheral data collecting time. The peripheral data is collected using this timing. Refer to Figure 3.5 for more. After that, the peripheral data collection time is constantly monitored and the data collection time is optimized. Also, if a time-over occurs after optimization, the next time optimization is be performed, V-BLANK-OUT will be used as the start timing. GA SE 56 Precautions when Optimizing Peripheral Data Collection Time The peripheral data collection timing varies depending on the type and number of nti peripherals that are connected. When performing peripheral data collection time optimization, verify the types, number, and configuration of connected peripherals and make a sufficient evaluation to prevent time-over from occurring. al In addition, when using continue as well, the continue request wait-time is mea- sured as part of the peripheral data collection time. Therefore, make the time from SMPC interrupt generation to continue request as short as possible, and be sure to execute them at a set time. de nfi Co GA SE SMPC User's Manual 57 INTBACK Command’s Command Parameters During Peripheral Data Acquisition Following is an explanation of command parameters when peripheral data is acquired using the INTBACK command. IREG0 There are two IREG0 settings: when the INTBACK command is issued and when con- tinue or break is requested. • When INTBACK Command Is Issued ntial The IREG0 uses the SMPC status acquisition switch. IREG0 20100001H bit7 de Status Acquisition Switch (00H or 01H) Initial Value: Not Specified Write Only IREG0: SMPC Status Acquisition Switch Setting Value bit0 IREG0 Setting Value 00H 01H nfi Explanation All data for date and time, cartridge code, area code, terminal status, SMEM, and reset button mode are not returned. All data for date and time, cartridge code, area code, terminal status, SMEM, and reset button mode are returned. • During Continue and Break Request Co Figure 3.6 IREG0 (During INTBACK Command Issue) The IREG0 uses the continue and break requests sent to the SMPC. When the SMPC receives a continue request, it begins collecting the remaining peripheral data. When it receives a break request, it stops collecting peripheral data GA and terminates the INTBACK command. bit7 bit0 IREG0 CONT BR --- --- --- --- --- --- CONT: CONTINUE Request Bit CONTINUE is requested by changing the value of this bit. SE Note: BR: ---: BREAK Request Bit A BREAK request is made by changing this bit to "1." Possible for both 0 H and 1H . Figure 3.7 IREG0 (During Continue and Break Requests) When the CONT.BR request value that has reached maximum is also written in IREG0, it cannot be guaranteed which operation the SMPC will execute. Refer to Table 3.2. 58 IREG1 The IREG1 uses the peripheral data collection mode. IREG1 20100003H bit7 bit4 P2MD1 P2MD0 P1MD1 P1MD0 ntial bit3 PEN 0 OPE bit0 0 Unde. Unde. Unde. Unde. Unde. Unde. Unde. Unde. W W W W W --- W --- Bit7, 6: Port 2 Mode Bit7 Bit 6 P2MD1 0 0 1 1 P2MD0 0 1 0 1 de 15-Byte Mode 255-Byte Mode Explanation SEGA RESERVED (Setting Restricted) 0-Byte Mode Bit5, 4: Port 1 Mode Bit7 P1MD1 0 0 1 Bit 6 P1MD0 0 1 0 nfi 15-Byte Mode 255-Byte Mode Explanation SEGA RESERVED (Setting Restricted) PEN 1 Co 1 Bit3: Peripheral Data Enable Bit3 0 1 0-Byte Mode Explanation Peripheral Data Not Returned Peripheral Data Returned Bit1: Acquisition Time Optimization Bit1 Explanation GA OPE 0 1 Peripheral Data Acquisition Time Optimized Peripheral Data Acquisition Time not Optimized Figure 3.8 IREG1 SE Note: When both the SH-2 direct mode and SMPC control mode are both used (example: port 1=SH-2 direct mode, port 2=SMPC control mode), use the 0 byte mode in the port used by SH-2 direct mode when the INTBACK command is issued. SMPC User's Manual 59 IREG2 IREG2 20100005H bit7 Initial Value: Not Specified Write Only F0 H ntial When issuing the INTBACK command, be sure to set F0H in IREG2. bit0 Figure 3.9 IREG2 de nfi Co GA SE 60 INTBACK Command Result Parameter During Peripheral Data Acquisition Following is an explanation of the result parameter when peripheral data is acquired using the INTBACK command. nti Basic Configuration of Result Parameter Acquired Using INTBACK Command al When the INTBACK command is executed, the result parameter shown in Figure 3.10 is configured in the status register and OREG. The peripheral control status shows the statuses used during peripheral control mode. Port 1 status and port 2 status show their respective port peripheral connec- tion states. The connected peripheral’s ID and peripheral data are output in the port 1 data and port 2 data. When the peripheral is directly connected to the peripheral de port, the peripheral data for one unit is output. When a multitap is connected, the peripheral data for several taps is output. nfi Co GA SE SMPC User's Manual 61 SR Peripheral Control Status Port 1 Data = 1 nti PDL NPE RESB P2MD1P2MD0 P1MD1 P1MD0 Port 1 Status Peripheral 1 Data Peripheral 2 Data Num. of = Multitap ID Connectors al SATURN SATURN Peripheral ID = Peripheral Data Size . Extension Data Size Type . Peripheral 1 1st Data OREG Port 2 Data . . Peripheral m Data de Peripheral 1 2nd Data . . . Peripheral 1 nth Data Port 1 data and Port 2 data have the same structure 0