Japanese
SGL User's ManualPROGRAMMER'S TUTORIAL
■ | Go forward
PROGRAMMER'S TUTORIAL

1.About Sega Saturn 3D game library


The Sega 3D Game Library (abbreviation: SGL) is a group of functions that can control three-dimensional graphics, provided for Sega Saturn software developers. Each function in the library (especially each function in the calculation library) is an algorithm designed by a programmer who is familiar with Saturn's processing capabilities, so it can be processed at high speed.

This chapter explains the steps for developing software using the Sega 3D Game Library and precautions when using the library.

1-1. Flow of programming work

The flow of programming Sega Saturn software using SGL is shown in the diagram below.

Figure 1-1 Programming work flow

●Host machine
Perform programming work, compilation, debugging, etc.

●Make
Generates an executable file including compilation work.

●ICE
Emulates the operation of SH2 of Sega Saturn's main CPU. By loading the executable program into ICE, you can check the operation of the created program.

●Debugger
You can load, run, and debug programs at the source level.

●Target box
It can be connected to ICE and works similar to Sega Saturn.

For detailed instructions on how to use ICE and debugger, please refer to their respective manuals.
  • HITACHI E7000 SH7604 emulator
  • SEGA SH7604 E7000 Graphical User Interface Software
  •  

    Host machine settings

    The following two items are required to configure the host machine environment. These settings are
    “.cshrc” or “.tcshrc”
    You need to set it in a script such as , or register it in your own script.

    1. Add the path for the debugger to the path environment variable.

      example

      Set△path=($path/usr/local/lib/sh2/GUI)
      △=space

    2. Set the following three environment variables: SHC library path, debugger help path, and ICE address.

    Figure 1-2 Setting environment variables
    ●Environment variables●
    setenv SHC_LIB< library path>
    setenv SH76GIHOST< IP address>
    setenv HELPPATH< help path>

     

    ICE settings

    To connect ICE and a host machine, some initial settings such as setting a network ID and registering the host machine are required. This is explained below.

    ●Connection of ICE and terminal
    1. Remove the floppy disk from the ICE.
    2. Turn off S8 of the ICE rear dip switch.
      Connect your laptop, etc. and ICE via RS-232C.
      (Connect to CRT on E7000 side)
    3. Start the terminal software on your computer.

    Notes on using Wterm
    Once you have made all the settings, press the [Control] + [GRAPH] + [S] keys at the same time to complete the connection. If you have not configured various settings, you will need to match the settings of ICE and Wterm. For ICE settings, please refer to page 29 of "ICE Emulator User's Manual"

    ●IP address (ID on the network) settings
    1. If the connection is successful, a message like the one below will be displayed.

      START ICE
      S:START ICE
      R:RELOAD&START ICE
      B:BACKUP FD
      F:FORMAT FD
      L:SET LAN PATAMETER
      T:START DIAGNOSTIC TEST
      (S/R/B/F/L/T)?

    2. When the message is output, enter “ L ” and the message below will be displayed.

      IP ADDRESS=XXXX

    3. Please enter the address you want to set here. for example,

      IP ADDRESS=XXXX123.456.78.987

    4. When you have finished inputting, turn off the power.

    This completes the address setting.

    ●Registering the host machine
    1. Connect your network.
    2. Turn on S8 of the ICE rear dip switch.
      (Turns it on when you tilt it to the right when facing the rear)
    3. Turn on the ICE.

    4. Run the “telnet” command on your workstation. for example,

      telnet 157.109.50.120 or telnet[hostname|IP address]

    5. When “ (file name / return) ? ” is displayed, please return.

    6. When the prompt “:” appears, enter the following:
      A list of registered workstations will be displayed.

      LAN_HOST;S
      (You can also enter "lh;s". "llhh;;ss" will be displayed on the screen.)

    7. When “ PLEASE SELECT NO? ” is displayed, select the number (01 to 09) you wish to register or change.

    8. Enter the host name (workstation controlling the ICE).

      example)
      01 HOST NAME SUN214 ? SUNXXX

      SUNXXX=Host name of the host machine to use

    9. Enter the host's IP address.

      01 IP ADDRESS ?157.109.50.47

      157.109.50.47=Hostname of your host machine

    10. When all entries are complete, you will see the following message:

      PLEASE SELECT NO? . [RET]

    11. Press “ctrl” + “]” keys to terminate the “telnet” command.
    12. The prompt is “telnet”> ”, type “quit” to exit.
    13. Turn off the ICE.
    14. Insert the floppy disk into the ICE and start the ICE again.

    The ICE settings are now complete.

     

    Makefile settings/execution

    Make generates a sequence of commands that the UNIX shell executes according to a file called a “Makefile,” which is a set of steps and rules. Make can efficiently control the relationships between files that are related to each other, so if you change only one of multiple source files, you can avoid having to recompile all the source files. It has several functions.

    SGL provides a special make file. By executing the Make command, the source programs specified in this file are compiled and an executable file is automatically generated.

    This makefile must be placed at the same level as the source file.

    When a user creates a new application, the Makefile must be recreated accordingly. Please refer to commercially available books regarding Make's functions and format.

    Reference book example: make (Keigaku Publishing/written by Andrew Oram and Steve Talbot)

     

    Debugger startup/initial settings

    HITACHI E7000 ICE is controlled by software with a dedicated graphical user interface (GUI). This software is called the "debugger" in this manual. The following explains how to start and initialize this debugger.

    1. Power on the ICE first, then the target (power off in the reverse order).

    2. Creating files for automation
      Create two files “ gish ” and “ PRESET ” in the current directory.

      gish
      gish76△PRESET

      PRESET
      HOST△Host machine△Login name△Password
      R.S.
      G

      △=space

    The settings in these files allow you to automate the following tasks:

    1. Starting the debugger
      Type “gish” on the host machine and return to start the debugger.
      If the following message appears during startup and the program is waiting for input, click inside the window to enable key input and return.

      (file name/return)?

      When the target is reset and the initial screen is displayed, click “STOP”.

    2. Loading the initial program
      Type “g 400” and when the screen disappears, click “STOP”.

    3. Development settings (disabling interrupts)
      Select “REGISTER” from the [VIEW] menu to display the “Register Dialog Box”.
      Enter “000000f0” in the status register (SR) and click “ENTER”.

    This development setting is for using ICE. There is no need to set this in the software that will actually be released.

     

    Loading and running the program

    This section explains how to use a debugger to load and execute an executable program on the ICE.

    If you do not use an initialization file such as “PRESET” explained in the previous section, select “HOST” from the [FILE] menu to open the “HOST dialog” and enter the HOST NAME, USER NAME, and PASSWORD. Also, enter "rs [return] g [return]" in the command area of the debugger to reset the target.

    1. Select [LOAD] → “PROGRAM FILE” from the [FILE] menu and enter the file name with the full path.

    2. Click “LOAD”.
      The executable program is now loaded.

    If tcsh is used for the USER's LOGIN SHELL, FTP will not work unless tcsh is registered in the host machine's /etc/shells file, and the executable program will not be loaded.
    For more information, please see reference books on FTP.

    1. Select “GO” from the [EXECUTION] menu.

    2. In the "GO Dialog Box", click the "START ADDRESS" input area, move the text cursor, and enter "6004000" in the same area. Next, select “order” from the pull-down menu of the “START MODE” button and click “Done”.

    The executable program will now start running.

    debug

    ●Displaying the source program
    1. Select “SOURCE DISPLAY” from the [VIEW] menu to display the “SOURCE DISPLAY dialog box”.

    2. Click on the name of the program you want to display to highlight it.

    The highlighted area expands each time you click the mouse button. It is OK if you can reverse specific lines, including the path name.

    1. Click “DISPLAY”.
      If you click “DISPLAY” while the lease program is loading or running, an error will occur. Please wait for the ICE command to finish loading or STOP before clicking.

    Click “CANCEL” if you want to clear the dialog box.

    ●Trace
    The trace function allows you to trace the source program step by step.

    1. After running the program, with “STOP” clicked or with the above source program displayed, double-click the area surrounded by the frame in the list section shown below. The beginning of the line will be reversed.

      Figure 1-3 Tracing from source program

    2. Click “SET” here.
      Breakpoint [P] is set. However, it cannot be set on a line without a B.

    3. Select “GO” from the [EXECUTION] menu.
      The program counter [PC>] stops at the breakpoint [P].

    There are two ways to trace step by step from here:


    ■ | Go forward
    SGL User's ManualPROGRAMMER'S TUTORIAL
    Copyright SEGA ENTERPRISES, LTD., 1997