FAQProgram in general
Back | ■
FAQ / Program in general

others



When SH2 crashes.

Q)
What should I check when SH2 crashes?

A)
When SH2 crashes, it's best to check the PR to see if the return address from the routine is correct.
This will let you know which routine crashed.
This is also valid for code written in C.


I don't think the SH2 registers are enough.

Q)
One slightly sloppy technique using assembly.

A)

  1. Use MACL, MACH, and GBR as temporary.

  2. Save the pr in the register. (sts.l pr, r14)

This technique should only be used by those who are familiar with library behavior and SH assembly. These operations can cause runaway inside the library if not used properly.


What are the parameter rules (at assembler level) in GCC?

Q)
I want to incorporate a function created in C into an assembler program. How are the arguments and returns of the C function coded?
Also, which register should save the contents?

A)
The details are as follows.

r0:
The value returned by the function.

r0-r3:
temporary. It can be broken by calling a function. --No need to save and list.

r4-r7:
The first four arguments. Broken by callee.

r8-r15:
Temporary available. These must be saved between function calls. Assembly functions handled on gcc must store these registers.

pr:
Processor return Must be saved.

gbr:
The C compiler usually does not write code that uses gbr. Therefore, the gbr register can be used freely. (However, SGL uses gbr in the system. If you want to make the SGL system compatible with the assembler, you need to be careful. Specifically, gbr always uses the start address of the system variable area. It points.)

mac ?:
It will be destroyed. Also, since all the fifth and subsequent arguments are saved on the stack, it is better to keep the number of arguments within 4 for C functions as much as possible to improve performance.

* Before calling the C function, be sure to sign the char and short in r4-r7 or extend them with 0. For gcc, expect the arguments in the register to be signed and extended to int.

Are there any precautions to take when using the SH2 divider?

Q)
Are there any precautions to take when using the SH2 divider?

A)
The SH2 divider has a unit that can perform division in about 39 cycles.
One thing to keep in mind when using the divider is that if an interrupt occurs while using the divider in the main processing and the divider is used in the interrupt processing, the calculated result on the interrupted main processing side will be displayed. It's going to be fraudulent.

As a countermeasure for this

  1. When interrupt processing uses a divider, interrupts are disabled for main processing.

  2. The divider is not used for interrupt processing.

there is.

The SH C compiler has an option switch that uses a divider, so if you don't want to be aware of this, you can either use the unused option (-div = cpu) or disable interrupts when using the divider (-div = cpu). Be sure to specify div = peripheral).

* Gcc does not generate code that uses a divider unless explicitly used in C compile-time code (eg inline assembler).


Please tell me the time required for data transfer of CPU, DMA (CPU / SCU), etc.

Q)
Can you tell me the time required for data transfer for each program transfer, CPU-DMA transfer, and SCU-DMA transfer?

A)
The time (measured value) required to transfer 256 bytes to VDP1, VDP2, and SCSP (Sound RAM) is described. This measurement was performed under the following conditions.

  1. In V Blank. (During the period when VDP2 is always writable)

  2. SCSP is in a state where both 68000 and internal DSP are stopped.

  3. VDP1 is neither drawing nor displaying.

  4. CPU-DMA transfer and SCU-DMA transfer do not include the time to register data in the register.

● WORKRAM-H-> SCSP (256 bytes)
Program transfer 78.14 micro / sec (32.80 clocks per 4 bytes)
CPU-DMA transfer 77.74 micro / sec (32.70 clocks per 4 bytes)
SCU-DMA transfer 63.89 micro / sec (26.80 clocks per 4 bytes)
* Every transfer takes a considerable amount of time. Even for transfers of 256 bytes or less, the speed per 4 bytes does not change much.

● WORKRAM-H-> VDP1 (256 bytes)
Program transfer 36.75 micro / sec (15.40 clocks per 4 bytes)
CPU-DMA transfer 29.56 micro / sec (12.40 clocks per 4 bytes)
SCU-DMA transfer 5.36 micro / sec (2.25 clocks per 4 bytes)
* SCU-DMA transfer speed is quite fast. However, when transferring 256 bytes or less, the number of clocks per 4 bytes becomes worse.
(The number of clocks per 4 bytes required for 16-byte transfer is 5.97)

● WORKRAM-H-> VDP2 (256 bytes)
Program transfer 36.58 micro / sec (15.40 clocks per 4 bytes)
CPU-DMA transfer 17.98 micro / sec (7.76 clocks per 4 bytes)
SCU-DMA transfer 5.20 micro / sec (2.20 clocks per 4 bytes)
* SCU-DMA transfer speed is quite fast. However, when transferring 256 bytes or less, the number of clocks per 4 bytes becomes worse.
(The number of clocks per 4 bytes required for 16-byte transfer is 5.00)

SCU-DMA includes pre-processing (20 clocks or more) and post-processing (12 clocks or more) at run time, which is especially effective when transferring a large amount of data to VDP1 or VDP2. Since SCSP puts weight on external transfers, it is better to use CPU-DMA or program transfers. (Since SCU-DMA is in burst mode, if a cache miss hit or write occurs after execution, processing will stop until the end of SCU-DMA transfer.)

What are the precautions when developing SEGA SATURN software?

Q)
This time, I decided to develop a game software with SEGA SATURN, and I'm looking at the hardware manual to find out what kind of graphic function it has, but there are too many to choose from.
So, please tell me what features SATURN actually has and what restrictions it has.

A)
Certainly SATURN has various functions and I am very confused about how to use it, but when explaining what to do from the viewpoint of graphic design, there are points to be careful in graphic design. ,

palette:
Palettes are shared by scrolls and sprites. Therefore, where and how to allocate limited color data is a very important issue. Saturn uses palette data of 1024 colors or 2048 colors. Before drawing a picture, you should decide where and which palette to use.

VRAM:
VDP1 and VDP2 are used differently, so if you explain them separately,

First, VDP1 puts image data, sprite display commands, color lookup table, and Gouraud shading table in VRAM. All of these must be kept within 512KB. In other words, 512KB cannot be used only with picture data. Of course, if the picture data occupies a lot, the space for commands will decrease, so the number of pictures that can be drawn will decrease, and vice versa. It is better to solidify the specifications with such things in mind.

Next is VDP2, which contains bitmap data, character pattern data, pattern name data, and in some cases rotation coefficient data (this data can also be stored in color RAM). Of course, all of this data fits in VRAM, but there are other access issues as well.

Just be careful, because using bitmaps requires a lot of RAM.

drawing:
VDP1 and VDP2 have different drawing abilities for high resolution and low resolution, respectively. When using high resolution, the drawing ability is half that of low resolution. Therefore, take into account that there are fairly strict restrictions on using high resolution and meeting the requirement to keep it within 1 Int.

VDP1:
VDP1 is responsible for sprite processing. The problem with sprite display is translucency.
Translucency can be done between sprites or for sprites and scrolls, but it is not possible to use translucency for both one sprite and another sprite at the same time, so the first design You must pay close attention to this point at the stage.
If both sprites and scrolls are translucent at the same time, they must be meshed. (It is very good to know at the beginning of development how different the effect is between mesh and translucent. It is also good to know the difference between high resolution and low resolution.)
Another problem is Gouraud shading. Gouraud shading is a convenient function that makes the connection of polygons look smooth, but this is because the image data of the sprite is in RGB format or color lookup mode, and the inside of the lookup table is RGB. This function is valid only when. Gouraud shading is not applied in palette mode, so you need to have some idea of which sprite to use in which mode during the design phase.

VDP2:
VDP2 is mainly responsible for scrolling. One thing to keep in mind when using VDP2 is a parameter called the cycle pattern that sets the order of VRAM access.
Basically, where to display the scroll data depends on this cycle pattern.
]]]]]] <SGL automatically sets this setting in slAutoDisp, but you need to know exactly how to use VRAM when designing. Parameters that affect the cycle pattern include rotating scroll plane, cell, map position on VRAM, VRAM division, number of colors, reduction setting, vertical cell scroll, high resolution / low resolution, CPU to VRAM during screen display period. Access, will be. All of these consume or limit cycle patterns, so be prepared in advance for issues such as what scrolls to use and where to put those data, and whether these specifications can be achieved.

What trap vectors can be used?

Q)
What are the trap exception handling vectors that can be used?

A)
Only user vectors of Vector 20H to 3FH are not used in BOOT-ROM at present and in the future while the application is running, so you can use them freely.
Other vectors cannot be used arbitrarily by the application for purposes other than their intended purpose. 48H to 7FH cannot be used by the user, so please change it if you are using it.
Please note the following points when using the vector.

  1. To access the vector area, you must use the system program built into the BOOT-ROM. SYS_SETSINT ()

  2. NMI vectors are not rewritable. This is due to the processing of the reset button.


Even if I make an IP, it does not boot.

Q)
When I changed the compiler to SH Series C Compiler Ver.3.0B, it did not boot even if I made "IP" as before.
We are using your sample file to create the IP.
(However, the area code links only to Japan)

\ SATURN \ SEGASMP \ SYS \ MK.BAT
                    SMPSYS.C
                    SMPSYS.LNK
                    SYS_ID.SRC

Apparently the versions of ASSEMBLER and LINKAGE EDITOR are irrelevant.
Is there anything that needs to be changed in the compiler?

A)
Line 114 of SMPSYS.C

Sint16 vbIcnt = 0;

from,

volatile Sint16 vbIcnt = 0;

Please rewrite as follows.


Precautions when making a PAL version.

Q)
What kind of changes will be required in terms of program, graphic, and sound data when changing the title created in the Japanese version or USA version to the PAL version?

A)

● Problems with dot aspect ratio
In the PAL version, the aspect ratio of the dots is wider than that of NTSC.
Therefore, the graphic data must also take this into consideration.

● Problems with V-Blank
PAL has a shorter V-blank than NTSC. Therefore, if the processing during blanking is too heavy, processing will be dropped.
Also, since the PAL cycle is 50Hz and NTSC is 60Hz, if you port the NTSC game etc. as it is (because what was processed 60 times per second will be 50 times) as a whole 5 / Since the speed is 6, it is necessary to devise a way to correct it.

● About Cinepak and TrueMotion
There is basically no problem with Cinepak and TrueMotion.
This is because these are compressed in a form that captures time information when creating a movie.
However, please note that the aspect ratio will change and the picture will look shrunk.

Also, in the case of data that puts too much load on VDP, it may not be displayed correctly. (That is, the frame will be dropped.)


What ANSI C libraries can be used for SATURN development?

Q)
Please tell me the ANSI standard compliant C library functions that can be used in the include file.

A)
Basically, file input / output related to fopen, fget, fscanf, etc.
(Of course, please use the CD access related functions that come with the Sega Saturn library.) Also, you cannot use functions that request input / output from the console such as printf and scanf.
(Even if it compiles, the operation cannot be guaranteed. However, if you use libcross.a in the SNASM environment, you can use it without any problem. At that time, the standard output will be the standard output window that appears on snbugsat. increase.)

Also, memory-related functions such as calloc, malloc, and sprintf can be compiled and work, but they are not suitable for game machine programming.
Calloc, malloc, etc. are functions that are deeply dependent on the OS, so when used on Saturn, no error will be returned even when mapping to an illegal address. I think these are natural results given that Saturn is not a machine with an OS.
(This is the same for both SBL and SGL.)


About the default values of VDP, SCU, and SCSP at the time of clock change.

Q)
It is stated in the SMPC User's Manual that VDP1, VDP2, SCU, and SCSP will be the default values when the power is turned on when the clock is changed. What are the default values?

A)
When the clock is changed, SCU, VDP1 and VDP2 are reset, but the initial values of each hardware manual are set as the setting values.
Refer to each hardware manual for the setting values.

For the processing after the clock change, refer to the system program user's manual in the "Programmer's Guide".
To put it simply,

<Reinitialization process after reset>

● SCU
It is necessary to reinitialize the bus, interrupt mask, etc. However, the value of SYS_GETSCUIM is used for the interrupt mask value.

● VDP2
TV mode needs to be set relatively quickly. Since the device itself will be in 320/640 mode after reset, especially when the system clock is changed to 352/704 mode, the sync signal may be out of sync with the TV and the screen may be distorted.

● VDP1, VDP2, SCSP
All previous settings will be invalid and will need to be reconfigured.
If you are using a library, you need to do the same as initializing the application.


About the recording range of the program area of the CD.

Q)
I have a question about the recording range of the program area.
Currently, the maximum is 63 minutes and 04 seconds, but is it okay to create data beyond this?
If you like, how many minutes can you do?

A)
This limitation is to secure a security area on the CD-ROM, and data that exceeds the maximum time will erode the security area and cannot be made into a product.

For the above reasons, it is not possible to create data longer than 63 minutes 04 seconds.
If the created software is 63 minutes 04 seconds or more, it cannot be commercialized as a matter of course.


About data cartridges.

Q)
I have a question about data cartridges.

  1. When emulating the cartridge part, is it possible to specify the address of the ROM image for the address setting on CartDev and Programming Box?

  2. Does Cart Dev use SIMM memory for emulation?

  3. In that case, is it possible to coexist with the file system?

  4. Is it possible to access the ROM cartridge in bytes?

  5. Are SCU restrictions the same as normal A-Bus access?

  6. I set the weight of the SCU, but how slow is the access compared to LOW-RAM?

  7. Is there a sample program that uses a data cartridge?

  8. In the case of a CD, I will submit the one created with a write-once writer, but how should I submit the data of the data cartridge part?
    (Compress with floppy disk and submit, create ROM with ROM writer, etc.)

A)
I will answer.

  1. Since the ROM space to be used is fixed, it is not possible to specify the address of the ROM image.

  2. SIMM will be set in the dedicated cartridge (sold by Ado Electronics) used in the SIMM system for emulation.

  3. SIMM system (GFS debug mode) and cartridge emulation may be possible if the GFMC_Base configuration address does not match the cartridge usage address.

  4. It can also be done in bytes.

  5. There is no change. However, unlike the CD buffer, there is a read address update (that is, there is a read address update like a normal memory copy), so be careful with the DMA settings.

  6. I set it to 3 clock weights (as described in the manual), but it takes about 25 clocks to get 16-bit data in actual measurement.
    It is about 4 times slower than WORKRAM-L.

  7. No sample program is available. Be careful when programming so that reading from the CD and reading the cartridge do not overlap.

  8. Like the old cartridge software such as MegaDrive, it is basically delivered in ROM. This form may change at the time of delivery.


I want to create a self-booting CD.

Q)
I want to make a self-booting CD, how do I make it?

A)
The procedure for creating a self-booting CD is as follows.

  1. Create an executable file in BIN format.

  2. Create an IP.

  3. Create a virtual CD script file and create a disk image.

  4. Check the operation on the virtual CD.

  5. Create a TOC file using VCDMKTOC.EXE.

  6. Create a write-once CD using SEGACDW.EXE.

For an explanation of the IP itself and how to write a script file for a self-booting CD,

reference
"Programmer's Guide" DISC format standard specifications / boot system

Please refer to.

The execution procedure for each item is as follows.

  1. Creating a BIN file
  2. ○ In the case of GNU environment First, create a coff file as usual, and then use the objcopy (sh-objcopy for IRIX) command as follows.

     objcopy -O binary input output

    Or with GCC's link options

     -Xlinker -oformat -Xlinker binary

  3. Creating an IP
  4. In the sample version of IP, the address of the 1stREAD FILE is set to 0x06010000, and the sample initialization program jumps to the first address of the 1stREAD FILE.

    If you change the read address of the 1st READ FILE, you need to recompile the IP.
    The IP sources and security objects currently provided are for SH-C, so it is necessary to create an IP with Hitachi SH-C.
    Alternatively, we can provide you with the files needed to create an IP for GNU by email, so please contact us if you need them.

  5. Create script file
  6. Please refer to "Appendix A / List of various samples " in the DISC format standard specifications of the Programmer's Guide.

    The file (1ST READ FILE) that is automatically loaded after the IP is loaded is the first file on the CD-ROM with the file name in ASCII order (synonymous with the file with the file identifier 2).
    The file name on the CD-ROM is specified by the File command, and the source on DOS is specified by the FileSource command. At this time, the file name on the CD and the file name of the source do not need to match.
    For the meaning of the text file registered in the system area, refer to the attached document. (These text files can be dummy during development, but be sure to include the rights-related text files by the time of master-up.) In addition, the SNASM debugger is used for the self-starting execution method. Please note that it cannot be done.


How to store data as big endian on byte boundaries?

Q)
How do I reserve relative values as big endian data on a byte boundary?

A)
Let me introduce an example of using ASMSH in the Hitachi compiler environment as an example.
In the Hitachi assembler environment, you can use the divider shift for absolute values. Using this function,

.DATA.B \ data >> 24
.DATA.B \ data << 8 >> 24
.DATA.B \ data << 16 >> 24
.DATA.B \ data << 24 >> 24

Please define a macro such as.


Where should the load address of the 1st Read File be set?

Q)
Where should I set the load address of the 1st read file?

A)
The 1st read file is the file that is first loaded as an application after IP.BIN. The loadable area is as follows.

6002000H + IP size ┏━━━━━━━━━━━━┓
             ┃ 1st lead file ┃
             ┃ Loadable area ┃
             ┃ ┃
             ┃ ┃
60FF000H ┣━━━━━━━━━━━━┫
             ┃ System usage area ┃
60FFFFFH ┗━━━━━━━━━━━━┛

60FF000H to 60FFFFFH are used by the system, so never load the 1st read file.

After loading the 1st read file, it will be released to the application.
Also, 6000000H to 6001FFFH are used by the system and should not be used in applications.
However, you can use the stack of 600E00H to 6001FFFH.
After the IP processing is completed and the application is started,

If you prepare another stack of master SH, up to 6001000H,
If you prepare another stack of slave SH, up to 6000E00H,

Each can be used.

6000000H ┏━━━━━━━━━━━━┓
             ┃Vector, resident routine ┃
6000E00H ┣━━━━━━━━━━━━┫
             ┃Slave SH stack ┃
6001000H ┣━━━━━━━━━━━━┫
             ┃Master SH stack ┃
6002000H ┣━━━━━━━━━━━━┫
             ┃ ┃


If you open the tray the moment you black out from the SEGA logo, you will run out of control.

Q)
After reading the 1st Read File, the SEGA logo appears, but if you open the CD tray immediately after this Black Out and the screen turns black, the program will run out of control.
During normal games, even if I open the CD tray, it jumps to the multiplayer screen without any problem, but if I open the CD tray only at this time, it runs out of control. Why?

A)
The most likely cause of these symptoms is neglecting the CD tray open check.
To explain in detail, when the screen blacks out, control is transferred to the application program.
After this, if a new program is loaded, the program will be called with the program data incompletely loaded if the tray open check is not performed.
The results after that are self-explanatory, but the application goes wild.
In other words, the application must always open the tray.
Also, it has been confirmed that such a symptom occurs very rarely (although it is a fairly severe timing) as a bug in the GFS library.
If the same symptom occurs despite the above measures, there may be a GFS bug, so replace it with the latest GFS library (lincd.a file in the case of SGL). ..


Please tell me about the hierarchical structure of the 3D model.

Q)
I'm thinking of making a 3D articulated game next time, but I'm not sure about manipulating data that has a 3D indirect structure.
Please tell me about creating 3D games.

A)
Generally, when creating a 3D game that has a hierarchical structure, the child data is calculated from the parent-child structure of the model.
In other words, the child has only the relative component from the parent, and when the parent's calculation is completed, the parent's data is used to calculate the child's coordinates.
If you have the parent's position information in a matrix, to calculate the child's coordinates, generate the child's relative components by performing a 3D affine transformation on the child's parent's matrix. If this is SGL, it can be easily done with the function of the system.
Of course, it's not that you can't do it with SBL, but it's easier with SGL. * SGL has a sample using Virtua Fighter's AKIRA model, but the hierarchical structure of this sample program uses a very special method and is not suitable for reference as it is.
If you want a hierarchical sample, see s_8_12 (sample_8_12 for IRIX). This idea itself can be used in both SGL and SBL as well.


Back | ■
FAQProgram in general
Copyright SEGA ENTERPRISES, LTD ,. 1997