System functions | |
---|---|
sbInit | Initialize Shinobi library |
sbExitSystem | Terminate Shinobi system |
sbHwInit - NEW - | Perform initialization process before initializing Ninja |
sbHwInit2 - NEW - | Perform initialization process after initializing Ninja |
sbHwFinish - NEW - | Terminate the hardware operations |
File access functions | |
gdFsInit | Initialize file system |
gdFsLoadDir | Get directory information |
gdFsChangeDir | Change current directory |
gdFsOpen | Open file |
gdFsGetFileSize | Get file size |
gdFsRead | Read file |
gdFsClose | Close file |
Memory management functions | |
syMallocInit | Reserve Malloc heap area |
syMalloc | Allocate memory |
syFree | Release memory |
Peripheral functions | |
pdGetPeripheral | Get peripheral data |
pdGetPeripheralError | Get peripheral status |
pdExecPeripheralServer | Server function for getting peripheral data |
Function Group for Getting Time Data | |
syTmrGetCount | Get value of the free running timer |
syTmrDiffCount | Get difference of the values of the two timer counts |
syTmrCountToMicro | Convert count value to micro seconds |
syTmrMicroToCount | Convert micro seconds to count value |
Note
In the above functions, gdFsInit, syMallocInit and njInitSystem are executed within the initialization function sbInit. For various reasons, the current release does not include the source code for the sbInit function (it will be made public in a later release). Therefore it is currently not possible to make detailed setting changes. However, because sbInit arguments are passed on unchanged to njInitSystem, you can establish the same Ninja environment by replacing njInitSystem coded for SET2 by sbInit. We apologize for any temporary inconvenience caused by this approach.
The SHINOBI library contains several initialization functions. Calling these functions in a suitable sequence establishes the normal settings. The initialization function source code will be made public in future, allowing it to serve as a sample for library initialization.
* The current release does not include the initialization function source code. It will be made public in a future release. Because this function calls njInitSystem, replace njInitSystem in the SET2 development environment with this function.
Function | Operation |
---|---|
sbInit | Initialize SHINOBI library |
sbExitSystem | Terminate system |
sbHwInit | Perform initialization process before initializing Ninja |
sbHwInit2 | Perform initialization process after initializing Ninja |
sbHwFinish | Terminate the hardware operations |
sbInit Initialize SHINOBI library | Contents |
Frame count is set in 1/60 units.
For example, if "2" is specified, frames are changed every 1/30 seconds.
Frame change is performed with the njWaitVSync function.
The following screen modes are available.
Variable name | Screen mode |
---|---|
NJD_RESOLUTION_VGA | VGA |
NJD_RESOLUTION_320x240_NTSCNI | NTSC non-interlaced 60 Hz |
NJD_RESOLUTION_320x240_NTSCI | NTSC interlaced 30 Hz |
NJD_RESOLUTION_640x240_NTSCNI | NTSC non-interlaced 60 Hz |
NJD_RESOLUTION_640x240_NTSCI | NTSC interlaced 30 Hz |
NJD_RESOLUTION_640x480_NTSCI | NTSC interlaced 30 Hz |
NJD_RESOLUTION_320x240_PALNI | PAL non-interlaced 50 Hz |
NJD_RESOLUTION_320x240_PALI | PAL interlaced 25 Hz |
NJD_RESOLUTION_640x240_PALNI | PAL non-interlaced 50 Hz |
NJD_RESOLUTION_640x240_PALI | PAL interlaced 25 Hz |
NJD_RESOLUTION_640x480_PALI | PAL interlaced 25 Hz |
The following frame buffer modes are available.
NJD_FRAMEBUFFER_MODE_RGB565 |
NJD_FRAMEBUFFER_MODE_RGB555 |
NJD_FRAMEBUFFER_MODE_ARGB4444 |
NJD_FRAMEBUFFER_MODE_ARGB1555 |
NJD_FRAMEBUFFER_MODE_RGB888 |
NJD_FRAMEBUFFER_MODE_ARGB8888 |
File system is used sbinit.obj File system is not used sbinitn.obj
We apologize for any temporary inconvenience caused by this approach.
sbExitSystem Terminate system | Contents |
sbHwInit Perform initialization process before initializing Ninja | Contents |
SH-CPU |
G1-BUS |
Interruption Controller |
Cache |
Timer |
sbHwInit2 Perform initialization process after initializing Ninja | Contents |
sbHwFinish Terminate the hardware operations | Contents |
Function | Operation |
gdFsInit | Initialize and mount file system |
gdFsLoadDir | Get directory information |
gdFsChangeDir | Change current directory |
gdFsOpen | Open file |
gdFsGetFileSize | Get file size |
gdFsRead | Read file |
gdFsClose | Close file |
gdFsInit Initialize and mount file system | Contents |
gdFsInit(8, gdfswork, 64, gdfscurdir);
Number of files that can be opened simultaneously: 8 Work area pointer: global variable "gdfswork" Uint8 gdfswork [ GDFS_WORK_SIZE(8) ]; Number of entries for current directory: 1024 Buffer for current directory: gobal variable "gdfsurdir" Uint8 gdfscurdir[ GDFS_DIRREC_SIZE(1024) ];
gdFsLoadDir Get directory information | Contents |
gdFsLoadDir("MOVIE", g_dir);
/* Sample 2 */
/* Move current directory to DATA directory */
gdFsLoadDir("DATA", NULL);
gdFsChangeDir Change current directory | Contents |
gdFsOpen Open file | Contents |
gf = gdFsOpen("A.BIN", NULL);
/* Sample 2 (accessing a file in the current directory) */
GDFS gf;
Uint8 dirbuf[ GDFS_DIRREC_SIZE(64) ];
GDFS_DIRREC g_dir;
g_dir = gdFsCreateDirhn(dirbuf, 64);
gdFsLoadDir("MOVIE", g_dir);
gf = gdFsOpen("SMP.MOV", g_dir);
gdFsGetFileSize Get file size | Contents |
gf = gdFsOpen("TEST.BIN", NULL);
gdFsGetFileSize(gdfs, &flen);
gdFsRead Read file | Contents |
gf = gdFsOpen("TEST.BIN", NULL);
gdFsRead(gf, 32, buf);
gdFsClose(gf);
gdFsClose Close file | Contents |
gf = gdFsOpen("TEST.BIN", NULL);
gdFsClose(gf);
Function | Operation |
syMallocInit | Get and declare memory area for memory management |
syMalloc | Allocate memory |
syFree | Release memory |
syMallocInit Get and declare memory area for memory management | Contents |
Heap area start address: end of section B Heap size: 0x00400000
syMalloc Allocate memory | Contents |
syFree Release memory | Contents |
PDS_PERIPHERAL Structure
typedef struct { Uint32 id; Uint32 support; Uint32 on; Uint32 off; Uint32 press; Uint32 release; Uint16 r; Uint16 l; Sint16 x1; Sint16 y1; Sint16 x2; Sint16 y2; Sint8* name; void* extend; Uint32 old; } PDS_PERIPHERAL;
id | Device ID |
support | Button/lever support state |
on | Digital button state |
off | Digital button state (reversed) |
press | Digital button down edge state |
release | Digital button up edge state |
r | Analog axis R value (0 - 255) |
l | Analog axis L value (0 - 255) |
x1 | Analog axis X1 value (-128 - 127) |
y1 | Analog axis Y1 value (-128 - 127) |
x2 | Analog axis X2 value (-128 - 127) |
y2 | Analog axis Y2 value (-128 - 127) |
name | Device name |
extend | Extended data address (not used) |
Device | Device ID (id) | Device name string (name) |
Standard control pad | PDD_DEV_CONTROLLER | Product name of the device |
Button or lever | Constants for bit position specification | |||
Cross-key A top | PDD_DEV_SUPPORT_KU | |||
Cross-key A bottom | PDD_DEV_SUPPORT_KD | |||
Cross-key A left | PDD_DEV_SUPPORT_KL | |||
Cross-key A right | PDD_DEV_SUPPORT_KR | |||
Cross-key B top | PDD_DEV_SUPPORT_KUB | |||
Cross-key B bottom | PDD_DEV_SUPPORT_KDB | |||
Cross-key B left | PDD_DEV_SUPPORT_KLB | |||
Cross-key B right | PDD_DEV_SUPPORT_KRB | |||
Start button | PDD_DEV_SUPPORT_ST | |||
A button | PDD_DEV_SUPPORT_TA | |||
B button | PDD_DEV_SUPPORT_TB | |||
C button | PDD_DEV_SUPPORT_TC | |||
X button | PDD_DEV_SUPPORT_TX | |||
Y button | PDD_DEV_SUPPORT_TY | |||
Z button | PDD_DEV_SUPPORT_TZ | |||
D button | PDD_DEV_SUPPORT_TD | |||
Analog axis R | PDD_DEV_SUPPORT_AR | |||
Analog axis L | PDD_DEV_SUPPORT_AL | |||
Analog axis X1 | PDD_DEV_SUPPORT_AX1 | |||
Analog axis Y1 | PDD_DEV_SUPPORT_AY1 | |||
Analog axis X2 | PDD_DEV_SUPPORT_AX2 | |||
Analog axis Y2 | PDD_DEV_SUPPORT_AY2 |
Digital button | Constants for bit position specification |
Cross-key A top | PDD_DGT_KU |
Cross-key A bottom | PDD_DGT_KD |
Cross-key A left | PDD_DGT_KL |
Cross-key A right | PDD_DGT_KR |
A button | PDD_DGT_TA |
B button | PDD_DGT_TB |
C button | PDD_DGT_TC |
D button | PDD_DGT_TD |
X button | PDD_DGT_TX |
Y button | PDD_DGT_TY |
Z button | PDD_DGT_TZ |
L button | PDD_DGT_TL |
R button | PDD_DGT_TR |
Start button | PDD_DGT_ST |
Cross-key B top | PDD_DGT_KUB |
Cross-key B bottom | PDD_DGT_KDB |
Cross-key B left | PDD_DGT_KLB |
Cross-key B right | PDD_DGT_KRB |
Member | Meaning |
Uint32 on | When button is pressed (button down), the corresponding bit is "1". When button is not pressed, the bit is "0". |
Uint32 off | Bits are reversed from "on" member. When button is not pressed (button up), the corresponding bit is "1". |
Uint32 press | When button has changed from not pressed to pressed (button down edge), the corresponding bit becomes "1". Other bits are "0". |
Uint32 release | When button has changed from pressed to not pressed (button up edge), the corresponding bit becomes "1". Other bits are "0". |
* When negative logic was selected, the bit status for button, on, off, press, release will be reversed.
Digital LR button information is simulated by the software based on analog LR information. Note that if a device does not have an analog LR button, the bit status will not change. (There are no devices with digital LR buttons in physical form.)
Member | Sign | Range | Center position | Lever/ button |
Uint16 r | Unsigned | 0 - 255 | 0 | Analog R button |
Uint16 l | Unsigned | 0 - 255 | 0 | Analog L button |
Sint16 x1 | Signed | -128 - 0 - 127 | 0 | Analog lever X1 |
Sint16 y1 | Signed | -128 - 0 - 127 | 0 | Analog lever Y1 |
Sint16 x2 | Signed | -128 - 0 - 127 | 0 | Analog lever X2 |
Sint16 y2 | Signed | -128 - 0 - 127 | 0 | Analog lever Y2 |
Member | Set value |
id,name,extend | Previous value |
Digital button | All buttons not pressed |
Analog axis | Center position |
The function pdGetPeripheralError() can be used to check whether an error has occurred.
Error code | Contents |
PDD_ERR_OK | No error |
PDD_ERR_RETRY | Button data could not be acquired normally |
PDD_ERR_GENERIC | Undefine error |
Function | Operation |
pdGetPeripheral | Get controller button status |
pdGetPeripheralError | Get controller error status |
pdExecPeripheralServer | Get peripheral data from server |
pdGetPeripheral Get controller button status | Contents |
per = pdGetPeripheral(PDD_PORT_A0);
if (per->press & PDD_DGT_ST) {
/* Start button was pressed */
:
:
}
pdGetPeripheralError Get controller error status | Contents |
err = pdGetPeripheralError(PDD_PORT_B0);
pdExecPeripheralServer Get peripheral data from server | Contents |
The KATANA's SH-CPU contains three independent timers as timer units,
and the SHINOBU library uses Timer0 (one of the three timers) as the
free running timer. Timer0's initial value cannot be reset and it is
read-only from user applications. The library user does not need to be
aware that it is a down counter. The counter clock runs at 1.2 micro
seconds per count and can measure between 1.28 micro seconds to 91.6
minutes. It is mainly used for getting time elapsed and for calculating
program processing time.
No(No particular data type is defined for this function group.)
Function | Operation |
---|---|
syTmrGetCount | Get value of the free running timer |
syTmrDiffCount | Get difference of the values of the two timer counts |
syTmrCountToMicro | Convert count value to micro seconds |
syTmrMicroToCount | Convert micro seconds to count value |
syTmrGetCount Get value of the free running timer | Contents |
syTmrDiffCount Get difference of the values of the two timer counts | Contents |
syTmrCountToMicro Convert count value to micro seconds | Contents |
syTmrMicroToCount Convert micro seconds to count value | Contents |
This example measures the execution time of any function, using the free running timer.
#include <sg_sytmr.h> /* Low level timer library header */ main() { Uint32 count1, count2, count, micro; count1 syTmrGetCount(); /* Begin measurement */ TestFunc(); /* Run target function for measurement */ count2 syTmrGetCount(); /* End measurement */ count syTmrDiffCount(count1, count2); /* Get difference of values of counters */ micro syTmrCountToMicro(count); /* Convert counter value to micro seconds */ while (1); }