Browse Source

Sources

master
flo 3 years ago
commit
ea3869585b
62 changed files with 5214 additions and 0 deletions
  1. 48
    0
      Makefile
  2. 198
    0
      Sound4Calc.c
  3. 15
    0
      Sound4Calc.h
  4. 1109
    0
      addresses.h
  5. 51
    0
      autre/OldFunctions.c
  6. BIN
      autre/SCIFTEST.zip
  7. BIN
      autre/sprintf.zip
  8. 12
    0
      autre/syscall.h
  9. 11
    0
      autre/syscall.s
  10. 31
    0
      bin/addin.ld
  11. BIN
      bin/icon.bmp
  12. BIN
      bin/sound.g1a
  13. BIN
      build/Sound4Calc.o
  14. BIN
      build/crt0.o
  15. BIN
      build/sound.bin
  16. BIN
      build/sound.elf
  17. BIN
      build/syscall.o
  18. 172
    0
      crt0.s
  19. 29
    0
      include/_h_c_lib.h
  20. 39
    0
      include/assert.h
  21. 84
    0
      include/builtin.h
  22. 189
    0
      include/complex
  23. 66
    0
      include/ctype.h
  24. 88
    0
      include/dispbios.h
  25. 22
    0
      include/endian.h
  26. 257
    0
      include/ensigdsp.h
  27. 114
    0
      include/errno.h
  28. 74
    0
      include/exception.h
  29. 107
    0
      include/filebios.h
  30. 26
    0
      include/filt_ws.h
  31. 208
    0
      include/float.h
  32. 91
    0
      include/fxlib.h
  33. 60
    0
      include/iomanip
  34. 192
    0
      include/ios
  35. 27
    0
      include/iostream
  36. 112
    0
      include/istream
  37. 149
    0
      include/keybios.h
  38. 35
    0
      include/limits.h
  39. 23
    0
      include/machine.h
  40. 111
    0
      include/math.h
  41. 66
    0
      include/mathf.h
  42. 53
    0
      include/mystrbuf
  43. 31
    0
      include/new
  44. 41
    0
      include/new_ecpp.h
  45. 122
    0
      include/new_edg.h
  46. 87
    0
      include/ostream
  47. 48
    0
      include/setjmp.h
  48. 28
    0
      include/smachine.h
  49. 36
    0
      include/stdarg.h
  50. 46
    0
      include/stddef.h
  51. 47
    0
      include/stdexcept.h
  52. 146
    0
      include/stdio.h
  53. 127
    0
      include/stdlib.h
  54. 97
    0
      include/streambuf
  55. 213
    0
      include/string
  56. 57
    0
      include/string.h
  57. 23
    0
      include/timer.h
  58. 82
    0
      include/typeinfo.h
  59. 55
    0
      include/umachine.h
  60. BIN
      lib/libfx.a
  61. 12
    0
      syscall.h
  62. 47
    0
      syscall.s

+ 48
- 0
Makefile View File

@@ -0,0 +1,48 @@
.PHONY: all mrproper send

PREFIX = sh3eb-elf-
AS = $(PREFIX)as
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
OBJCOPY = $(PREFIX)objcopy
WRAPPER = g1a-wrapper
SEND = UsbConnector

FLAGS = -m3 -mb -Os -nostdlib
CFLAGS = -W -Wall -Wno-main -pedantic -std=c11
INCLUDE = -I. -Iinclude -isystem stdinc
LIBS = -Llib -lgcc -lfx
NAME = sound

OBJ = build/Sound4Calc.o build/crt0.o build/syscall.o
ICON = icon.bmp


all: build/$(NAME).bin
@ $(WRAPPER) build/$(NAME).bin -o bin/$(NAME).g1a
@ echo "Build finished."
@ stat -c "Output size is %s bytes." bin/$(NAME).g1a

build/$(NAME).bin: build/$(NAME).elf
@ $(OBJCOPY) -R .comment -R .bss -O binary build/$(NAME).elf build/$(NAME).bin

build/$(NAME).elf: bin/addin.ld $(OBJ)
@ $(CC) $(FLAGS) $(OBJ) -T"bin/addin.ld" -o build/$(NAME).elf $(LIBS)

build/%.o: %.c
@ $(CC) $(FLAGS) -c $^ -o $@ $(INCLUDE) $(CFLAGS)

build/%.o: %.s
@ $(AS) -c $^ -o $@

send:
@ cp bin/$(NAME).g1a $(NAME).g1a
@ $(SEND) SEND $(NAME).g1a $(NAME).g1a fls0
@ rm -f $(NAME).g1a

mrproper:
rm -f build/*.o
rm -f build/$(NAME).elf
rm -f build/$(NAME).bin



+ 198
- 0
Sound4Calc.c View File

@@ -0,0 +1,198 @@
#include "fxlib.h"

#include <stdlib.h>

#include "addresses.h"
#include "Sound4Calc.h"

#include "syscall.h"

//#define DEBUG

#define PI 3.14159265358

/*#define SH7305_PJDR ((volatile unsigned char*)0xA4050130)
#define SH7305_PJCR ((volatile unsigned short*)0xA4050110)
#define SH7305_PUCR ((volatile unsigned short*)0xA4050142)
#define SH7305_PUDR ((volatile unsigned char*)0xA4050162)
#define SH7305_MSTPCR0 ((volatile unsigned int*)0xA4150030)
#define SH7305_SCSCR ((volatile unsigned short*)0xA4410008)

//SH3 addresses
#define SH7337_STBCR3 ((volatile unsigned int*)0xA40A0000)
#define SH7337_SCSCR2 ((volatile unsigned int*)0xA4410008)
#define SH7337_PGCR ((volatile unsigned int*)0xA400010C)
#define SH7337_PLCR ((volatile unsigned int*)0xA4000114)
#define SH7337_SCPCR ((volatile unsigned int*)0xA4000116)
#define SH7337_PGDR ((volatile unsigned int*)0xA400012C)
#define SH7337_SCPDR ((volatile unsigned int*)0xA4000136)*/

//typedef unsigned volatile;

char *itoa(int n, unsigned char* str, int base)
{
int i=1, j=0, x;
if(n<0) str[j++] = '-', n = -n;
for(x=n;x;x/=base) j++;
for(x=n;x;x/=base) str[j-i++] = x%base + '0' + 39*(x%base>9);
str[j] = 0;
return str;
}

int main(void)
{
unsigned int key;
char buffer[50];
unsigned char str[20];

int sleep = 2000;
int i;
char before = 0, during = 0, after = 0;
setup();
//ResetPin();
while(1)
{
Bdisp_AllClr_VRAM();
PrintMini(1, 1, itoa(sleep, str, 10), 0);

PrintMini(1, 10, itoa(is_SH4, str, 10), 0);

#ifdef DEBUG
PrintMini(1, 20, itoa(before, str, 16), 0);
PrintMini(1, 28, itoa(during, str, 16), 0);
PrintMini(1, 36, itoa(after, str, 16), 0);
#endif

GetKey(&key);

switch(key)
{
case KEY_CTRL_RIGHT : sleep+=50; break;
case KEY_CTRL_LEFT : sleep-=50; break;
case KEY_CTRL_EXE :
while(Keyboard_KeyDown())
{
#ifdef DEBUG

before=*SH7305_PJDR;
ResetPin();
during=*SH7305_PJDR;
for(i=0;i<sleep;i++);
SetPin();
after=*SH7305_PJDR;

#else

ResetPin();
for(i=0;i<sleep;i++);
SetPin();

#endif
}
break;
case KEY_CTRL_EXIT :
return 1;
}
}
return 1; // this point is never reached
}

void setup()
{
is_SH4 = getMPU();

if(is_SH4)
{
// SCIF2 clock on (MSTPCR0.MSTP007)
*(unsigned int*)SH7305_MSTPCR0 &= ~0x00000080;
// switch off SCSMR_2.TE and SCSMR_2.RE
*(unsigned short*)SH7305_SCSCR &= ~0x0030;
// SCIF2 clock off (MSTPCR0.MSTP007)
*(unsigned int*)SH7305_MSTPCR0 |= 0x00000080;

// set bit 3 of port U to output mode
*(unsigned short*)SH7305_PUCR = ( *(unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040;
// set bit 4 and 5 of port U
*(unsigned char*)SH7305_PUDR |= 0x0C;

// set port J bit 2 to output mode
*(unsigned short*)SH7305_PJCR = ( *(unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010;
// set port J bit 3 to output mode
*(unsigned short*)SH7305_PJCR = ( *(unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040;
}
else
{
// SCIF2 clock on (STBCR3.MSTP31)
*(unsigned char*)SH7337_STBCR3 &= ~0x02;
// switch off SCSMR_2.TE and SCSMR_2.RE
*(unsigned short*)SH7337_SCSCR2 &= ~0x0030;
// SCIF2 clock off (STBCR3.MSTP31)
*(unsigned char*)SH7337_STBCR3 |= 0x02;
// set bit 6 of port G to output mode
*(unsigned short*)SH7337_PGCR = ( *(unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000;
// set bit 5 and 6 of port G
*(unsigned char*)SH7337_PGDR |= 0x60;
// set port SC bit 0 to output
*(unsigned short*)SH7337_SCPCR = ( *(unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001;
}
/*
// set port J bit 2 to output
*(unsigned short*)0xA4050110 = ( *(unsigned short*)0xA4050110 & ~0x0030 ) | 0x0010;
// set port J bit 3 to input
*(unsigned short*)0xA4050110 = ( *(unsigned short*)0xA4050110 & ~0x00C0 ) | 0x0080;*/
}

void SetPin()
{
if(is_SH4)
{
*(unsigned char*)SH7305_PJDR |= 0x04;
*(unsigned char*)SH7305_PJDR &= ~0x08;
//set pin to 0x4B
}
else
{
*(unsigned char*)SH7337_SCPDR |= 0x01;
}
}

void ResetPin()
{
if(is_SH4)
{
*(unsigned char*)SH7305_PJDR &= ~0x04;
*(unsigned char*)SH7305_PJDR |= 0x08;
// set the pin to 0x47
}
else
{

*(unsigned char*)SH7337_SCPDR &= ~0x01;
}
}



char getMPU(void)
{
// Port L control register.
volatile unsigned short *plcr = (unsigned short *)0xa4000114;
// Saved value for PLCR.
unsigned short saved_plcr;
unsigned int tested_plcr;

saved_plcr = *plcr;
*plcr = 0xffff;

tested_plcr = *plcr;
*plcr = saved_plcr;

if(tested_plcr == 0x00ff || tested_plcr == 0x0fff)
{
return 0; // MPU_SH3
}

return 1; // MPU_SH4
}

+ 15
- 0
Sound4Calc.h View File

@@ -0,0 +1,15 @@
#ifndef _SOUND4CALC
#define _SOUND4CALC

// SH4 addresses



char is_SH4;

void setup(void); // configure ports to output
void SetPin(void);
void ResetPin(void);
char getMPU(void); //get_MPU to compatibility

#endif

+ 1109
- 0
addresses.h
File diff suppressed because it is too large
View File


+ 51
- 0
autre/OldFunctions.c View File

@@ -0,0 +1,51 @@
void SetPin()
{
if(is_SH4)
{
*(unsigned char*)SH7305_PJDR |= 0x04;
*(unsigned char*)SH7305_PJDR &= ~0x08;
//set pin to 0x4B
}
else
{
*(unsigned char*)SH7337_SCPDR |= 0x01;
}
}

void ResetPin()
{
if(is_SH4)
{
*(unsigned char*)SH7305_PJDR &= ~0x04;
*(unsigned char*)SH7305_PJDR |= 0x08;
// set the pin to 0x47
}
else
{

*(unsigned char*)SH7337_SCPDR &= ~0x01;
}
}


char getMPU(void)
{
// Port L control register.
volatile unsigned short *plcr = (unsigned short *)0xa4000114;
// Saved value for PLCR.
unsigned short saved_plcr;
unsigned int tested_plcr;

saved_plcr = *plcr;
*plcr = 0xffff;

tested_plcr = *plcr;
*plcr = saved_plcr;

if(tested_plcr == 0x00ff || tested_plcr == 0x0fff)
{
return 0; // MPU_SH3
}

return 1; // MPU_SH4
}

BIN
autre/SCIFTEST.zip View File


BIN
autre/sprintf.zip View File


+ 12
- 0
autre/syscall.h View File

@@ -0,0 +1,12 @@
#ifndef _SYSCALL_H
#define _SYSCALL_H
int IsKeyDown(short* matrixcode);
#define KEY_CTRL_EXE 0x0201
#define KEY_CTRL_SHIFT 0x0608
#endif

+ 11
- 0
autre/syscall.s View File

@@ -0,0 +1,11 @@
.global_IsKeyDown

_IsKeyDown:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x24B

sc_addr:
.long 0x80010070

+ 31
- 0
bin/addin.ld View File

@@ -0,0 +1,31 @@
OUTPUT_ARCH(sh3)
ENTRY(initialize)
MEMORY
{
rom : o = 0x00300200, l = 512k
ram : o = 0x08100000, l = 64k /* pretty safe guess */
}
SECTIONS
{
.text : {
*(.pretext) /* init stuff */
*(.text)
} > rom
.rodata : {
*(.rodata)
*(.rodata.str1.4)
_romdata = . ; /* symbol for initialization data */
} > rom
.bss : {
_bbss = . ;
_bssdatasize = . ;
LONG(0); /* bssdatasize */
*(.bss) *(COMMON);
_ebss = . ;
} > ram
.data BLOCK(4) : AT(_romdata) {
_bdata = . ;
*(.data);
_edata = . ;
} > ram
}

BIN
bin/icon.bmp View File


BIN
bin/sound.g1a View File


BIN
build/Sound4Calc.o View File


BIN
build/crt0.o View File


BIN
build/sound.bin View File


BIN
build/sound.elf View File


BIN
build/syscall.o View File


+ 172
- 0
crt0.s View File

@@ -0,0 +1,172 @@
.section .pretext
.global initialize
initialize:
sts.l pr, @-r15
! set up TLB
mov.l Hmem_SetMMU, r3
mov.l address_one, r4 ! 0x8102000
mov.l address_two, r5 ! 0x8801E000
jsr @r3 ! _Hmem_SetMMU
mov #108, r6
! clear the BSS
mov.l bbss, r4 ! start
mov.l ebss, r5 ! end
bra L_check_bss
mov #0, r6
L_zero_bss:
mov.l r6, @r4 ! zero and advance
add #4, r4
L_check_bss:
cmp/hs r5, r4
bf L_zero_bss
! Copy the .data
mov.l bdata, r4 ! dest
mov.l edata, r5 ! dest limit
mov.l romdata, r6 ! source
bra L_check_data
nop
L_copy_data:
mov.l @r6+, r3
mov.l r3, @r4
add #4, r4
L_check_data:
cmp/hs r5, r4
bf L_copy_data
mov.l bbss, r4
mov.l edata, r5
sub r4, r5 ! size of .bss and .data sections
add #4, r5
mov.l bssdatasize, r4
mov.l r5, @r4
mov.l GLibAddinAplExecutionCheck, r2
mov #0, r4
mov #1, r5
jsr @r2 ! _GLibAddinAplExecutionCheck(0,1,1);
mov r5, r6
mov.l CallbackAtQuitMainFunction, r3
mov.l exit_handler, r4
jsr @r3 ! _CallbackAtQuitMainFunction(&exit_handler)
nop
mov.l main, r3
jmp @r3 ! _main()
lds.l @r15+, pr
_exit_handler:
mov.l r14, @-r15
mov.l r13, @-r15
mov.l r12, @-r15
sts.l pr, @-r15
mov.l Bdel_cychdr, r14
jsr @r14 ! _Bdel_cychdr
mov #6, r4
jsr @r14 ! _Bdel_cychdr
mov #7, r4
jsr @r14 ! _Bdel_cychdr
mov #8, r4
jsr @r14 ! _Bdel_cychdr
mov #9, r4
jsr @r14 ! _Bdel_cychdr
mov #10, r4
mov.l BfileFLS_CloseFile, r12
mov #4, r14
mov #0, r13
L_close_files:
jsr @r12 ! _BfileFLS_CloseFile
mov r13, r4
add #1, r13
cmp/ge r14, r13
bf L_close_files
mov.l flsFindClose, r12
mov #0, r13
L_close_finds:
jsr @r12 ! _flsFindClose
mov r13, r4
add #1, r13
cmp/ge r14, r13
bf L_close_finds
lds.l @r15+, pr
mov.l @r15+, r12
mov.l @r15+, r13
mov.l Bkey_Set_RepeatTime_Default, r2
jmp @r2 ! _Bkey_Set_RepeatTime_Default
mov.l @r15+, r14
.align 4
address_two: .long 0x8801E000
address_one: .long 0x8102000
Hmem_SetMMU: .long _Hmem_SetMMU
GLibAddinAplExecutionCheck: .long _GLibAddinAplExecutionCheck
CallbackAtQuitMainFunction: .long _CallbackAtQuitMainFunction
Bdel_cychdr: .long _Bdel_cychdr
BfileFLS_CloseFile: .long _BfileFLS_CloseFile
flsFindClose: .long _flsFindClose
Bkey_Set_RepeatTime_Default: .long _Bkey_Set_RepeatTime_Default
bbss: .long _bbss
ebss: .long _ebss
edata: .long _edata
bdata: .long _bdata
romdata: .long _romdata
bssdatasize: .long _bssdatasize
exit_handler: .long _exit_handler
main: .long _main
_Hmem_SetMMU:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x3FA
_Bdel_cychdr:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x119
_BfileFLS_CloseFile:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x1E7
_Bkey_Set_RepeatTime_Default:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x244
_CallbackAtQuitMainFunction:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x494
_flsFindClose:
mov.l sc_addr, r2
mov.l 1f, r0
jmp @r2
nop
1: .long 0x218
_GLibAddinAplExecutionCheck:
mov.l sc_addr, r2
mov #0x13, r0
jmp @r2
nop
sc_addr: .long 0x80010070
.end

+ 29
- 0
include/_h_c_lib.h View File

@@ -0,0 +1,29 @@
/*------------------------------------------------------*/
/* SH SERIES C/C++ Compiler Ver. 6.0 */
/* Copyright (c) 1992,2000 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/***********************************************************************/
/* SPEC; */
/* NAME = _h_c_lib.h : */
/* */
/* FUNC = Include file for SH SERIES C/C++ Compiler environment */
/* */
/* CLAS = UNIT; */
/* */
/* END; */
/***********************************************************************/
#ifndef _H_C_LIB
#define _H_C_LIB
#ifdef __cplusplus
extern "C"{
#endif
extern void _CALL_INIT(void); /* for global class object initial processing */
extern void _CALL_END(void); /* for global class object post-processing */
#ifdef __cplusplus
}
#endif /* #ifdef __cplusplus */
#endif /* #ifndef _H_C_LIB */

+ 39
- 0
include/assert.h View File

@@ -0,0 +1,39 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 1.0 */
/* Copyright (c) 1992 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/***********************************************************************/
/* SPEC; */
/* NAME = assert.h : debug macro define ; */
/* */
/* FUNC = this module do the following functions; */
/* (1) if NDEBUG defined assert(x) = (void)0; */
/* CLAS = UNIT; */
/* */
/* END; */
/***********************************************************************/
#ifndef _ASSERT
#define _ASSERT
#include <stdio.h>
#ifdef NDEBUG
#ifdef assert
#undef assert
#endif
#define assert(x) ((void)0)
#else
#ifdef assert
#undef assert
#endif
#define assert(x) ( x ? (void) 0 : (fprintf(stderr,\
"ASSERTION FAILED: "#x" FILE %s,LINE %d \n", \
__FILE__,__LINE__),abort(),(void)0))
#endif
#ifdef __cplusplus
extern "C" {
void abort(void);
}
#endif
#endif

+ 84
- 0
include/builtin.h View File

@@ -0,0 +1,84 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 6.0 */
/* Copyright (c) 1992, 2000 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/*****************************************************************/
/* SPEC ; */
/* NAME = builtin : */
/* */
/* FUNC = this header file do the following functions; */
/* (1)builtin function prototype define; */
/* */
/* CLAS = UNIT ; */
/* */
/* END ; */
/*****************************************************************/
#ifndef _BUILTIN
#define _BUILTIN
#ifdef __cplusplus
extern "C" {
/* follow math.h & mathf.h */
extern float _builtin_fabsf(float);
extern double _builtin_fabs(double);
extern float _builtin_sqrtf(float);
extern double _builtin_sqrt(double);
/* follow private.h */
extern void _builtin_fsca(long ,float *,float *);
extern float _builtin_fsrra(float);
/* follow smachine.h */
extern void _builtin_set_imask(int);
extern int _builtin_get_imask(void);
extern void _builtin_set_cr(int);
extern int _builtin_get_cr(void);
extern void _builtin_set_vbr(void *);
extern void *_builtin_get_vbr(void);
extern void _builtin_sleep(void);
/* follow string.h */
extern char *_builtin_strcpy(char *, const char *);
extern int _builtin_strcmp(const char *, const char *);
/* follow umachine.h */
extern void _builtin_set_gbr(void *);
extern void *_builtin_get_gbr(void);
extern unsigned char _builtin_gbr_read_byte(int);
extern unsigned short _builtin_gbr_read_word(int);
extern unsigned long _builtin_gbr_read_long(int);
extern void _builtin_gbr_write_byte(int, unsigned char);
extern void _builtin_gbr_write_word(int, unsigned short);
extern void _builtin_gbr_write_long(int, unsigned long);
extern void _builtin_gbr_and_byte(int, unsigned char);
extern void _builtin_gbr_or_byte(int, unsigned char);
extern void _builtin_gbr_xor_byte(int, unsigned char);
extern int _builtin_gbr_tst_byte(int, unsigned char);
extern int _builtin_tas(char *);
extern int _builtin_trapa(int);
extern int _builtin_macw(short *, short *, unsigned int);
extern int _builtin_macwl(short *, short *, unsigned int, unsigned int);
extern int _builtin_macl(int *, int *, unsigned int);
extern int _builtin_macll(int *, int *, unsigned int, unsigned int);
extern int _builtin_trapa_svc(...);
extern void _builtin_prefetch(void *);
extern void _builtin_set_fpscr(int);
extern int _builtin_get_fpscr(void);
extern float _builtin_fipr(float a1[], float b1[]);
extern void _builtin_ftrv(float a1[], float b1[]);
extern void _builtin_ftrvadd(float a1[], float b1[], float c1[]);
extern void _builtin_ftrvsub(float a1[], float b1[], float c1[]);
extern void _builtin_mtrx4mul(float [][4], float [][4]);
extern void _builtin_mtrx4muladd(float [][4], float [][4], float [][4]);
extern void _builtin_mtrx4mulsub(float [][4], float [][4], float [][4]);
extern void _builtin_ld_ext(float [][4]);
extern void _builtin_st_ext(float [][4]);
extern void _builtin_add4(float a1[], float b1[], float c1[]);
extern void _builtin_sub4(float a1[], float b1[], float c1[]);
extern void _builtin_trace(int);
}
#endif /* #ifdef __cplusplus */
#endif /* #ifndef _BUILTIN */

+ 189
- 0
include/complex View File

@@ -0,0 +1,189 @@
//Embedded C++ Library
//Copyright (c) Hitachi,Ltd. 1997
//Licensed material of Hitachi,Ltd
//====================================================================
// File: complex
// Purpose: Numerics library / Complex numbers
// Header <complex>
// Create: 1997.09.20 Rev. 1.0
//====================================================================
#ifndef _COMPLEX_
#define _COMPLEX_
#include <istream>
#include <ostream>
class float_complex; // based on float
class double_complex; // based on double
// complex specialization
class float_complex {
public:
typedef float value_type;
float_complex(float re = 0.0f, float im = 0.0f){
_re = re; _im = im; return; }
float_complex(const double_complex&);
float real() const{ return (_re);}
float imag() const{ return (_im);}
float_complex& operator= (float rhs){
_re = rhs; _im = 0.0; return *this; }
float_complex& operator+=(float rhs){ _re += rhs; return *this; }
float_complex& operator-=(float rhs){ _re -= rhs; return *this; }
float_complex& operator*=(float rhs){
_re *= rhs; _im *= rhs; return *this; }
float_complex& operator/=(float rhs){
_re /= rhs; _im /= rhs; return *this; }
float_complex& operator=(const float_complex&rhs){
_re = rhs.real(); _im = rhs.imag(); return *this; }
float_complex& operator+=(const float_complex&rhs){
_re += rhs.real(); _im += rhs.imag(); return *this; }
float_complex& operator-=(const float_complex&rhs){
_re -= rhs.real(); _im -= rhs.imag(); return *this; }
float_complex& operator*=(const float_complex&);
float_complex& operator/=(const float_complex&);
private:
float _re, _im;
};
class double_complex {
public:
typedef double value_type;
double_complex(double re = 0.0, double im = 0.0){
_re = re; _im = im; return; }
double_complex(const float_complex&rhs){
_re = (double)rhs.real(); _im = (double)rhs.imag(); return; }
double real() const{ return (_re);}
double imag() const{ return (_im);}
double_complex& operator= (double rhs){
_re = rhs; _im = 0.0; return *this; }
double_complex& operator+=(double rhs){ _re += rhs; return *this; }
double_complex& operator-=(double rhs){ _re -= rhs; return *this; }
double_complex& operator*=(double rhs){
_re *= rhs; _im *= rhs; return *this; }
double_complex& operator/=(double rhs){
_re /= rhs; _im /= rhs; return *this; }
double_complex& operator=(const double_complex&rhs){
_re = rhs.real(); _im = rhs.imag(); return *this; }
double_complex& operator+=(const double_complex&rhs){
_re += rhs.real(); _im += rhs.imag(); return *this; }
double_complex& operator-=(const double_complex&rhs){
_re -= rhs.real(); _im -= rhs.imag(); return *this; }
double_complex& operator*=(const double_complex&);
double_complex& operator/=(const double_complex&);
private:
double _re, _im;
};
// complex non-member functions
float_complex operator+(const float_complex&);
float_complex operator-(const float_complex&);
float_complex operator+(const float_complex&, const float_complex&);
float_complex operator+(const float_complex&, const float&);
float_complex operator+(const float&, const float_complex&);
float_complex operator-(const float_complex&, const float_complex&);
float_complex operator-(const float_complex&, const float&);
float_complex operator-(const float&, const float_complex&);
float_complex operator*(const float_complex&, const float_complex&);
float_complex operator*(const float_complex&, const float&);
float_complex operator*(const float&, const float_complex&);
float_complex operator/(const float_complex&, const float_complex&);
float_complex operator/(const float_complex&, const float&);
float_complex operator/(const float&, const float_complex&);
bool operator==(const float_complex&, const float_complex&);
bool operator==(const float_complex&, const float&);
bool operator==(const float&, const float_complex&);
bool operator!=(const float_complex&, const float_complex&);
bool operator!=(const float_complex&, const float&);
bool operator!=(const float&, const float_complex&);
istream& operator>>(istream&, float_complex&);
ostream& operator<<(ostream&, const float_complex&);
double_complex operator+(const double_complex&);
double_complex operator-(const double_complex&);
double_complex operator+(const double_complex&, const double_complex&);
double_complex operator+(const double_complex&, const double&);
double_complex operator+(const double&, const double_complex&);
double_complex operator-(const double_complex&, const double_complex&);
double_complex operator-(const double_complex&, const double&);
double_complex operator-(const double&, const double_complex&);
double_complex operator*(const double_complex&, const double_complex&);
double_complex operator*(const double_complex&, const double&);
double_complex operator*(const double&, const double_complex&);
double_complex operator/(const double_complex&, const double_complex&);
double_complex operator/(const double_complex&, const double&);
double_complex operator/(const double&, const double_complex&);
bool operator==(const double_complex&, const double_complex&);
bool operator==(const double_complex&, const double&);
bool operator==(const double&, const double_complex&);
bool operator!=(const double_complex&, const double_complex&);
bool operator!=(const double_complex&, const double&);
bool operator!=(const double&, const double_complex&);
istream& operator>>(istream&, double_complex&);
ostream& operator<<(ostream&, const double_complex&);
// complex value operations
float real(const float_complex&);
float imag(const float_complex&);
float abs(const float_complex&);
float arg(const float_complex&);
float norm(const float_complex&);
float_complex conj(const float_complex&);
float_complex polar(const float&, const float&);
double real(const double_complex&);
double imag(const double_complex&);
double abs(const double_complex&);
double arg(const double_complex&);
double norm(const double_complex&);
double_complex conj(const double_complex&);
double_complex polar(const double&, const double&);
// complex transcendentals
#ifdef sqrt
#undef sqrt
extern "C" double sqrt(double);
#endif
float_complex cos (const float_complex&);
float_complex cosh (const float_complex&);
float_complex exp (const float_complex&);
float_complex log (const float_complex&);
float_complex log10(const float_complex&);
float_complex pow(const float_complex&, int);
float_complex pow(const float_complex&, const float&);
float_complex pow(const float_complex&, const float_complex&);
float_complex pow(const float&, const float_complex&);
float_complex sin (const float_complex&);
float_complex sinh (const float_complex&);
float_complex sqrt (const float_complex&);
float_complex tan (const float_complex&);
float_complex tanh (const float_complex&);
double_complex cos (const double_complex&);
double_complex cosh (const double_complex&);
double_complex exp (const double_complex&);
double_complex log (const double_complex&);
double_complex log10(const double_complex&);
double_complex pow(const double_complex&, int);
double_complex pow(const double_complex&, const double&);
double_complex pow(const double_complex&, const double_complex&);
double_complex pow(const double&, const double_complex&);
double_complex sin (const double_complex&);
double_complex sinh (const double_complex&);
double_complex sqrt (const double_complex&);
double_complex tan (const double_complex&);
double_complex tanh (const double_complex&);
#endif

+ 66
- 0
include/ctype.h View File

@@ -0,0 +1,66 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 1.0 */
/* Copyright (c) 1992 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/*****************************************************************/
/* SPEC ; */
/* NAME = ctype : */
/* FUNC = */
/* ; */
/* */
/* */
/* */
/* CLAS = UNIT ; */
/* END ; */
/*****************************************************************/
#ifndef _CTYPE
#define _CTYPE
#ifdef __cplusplus
extern "C" {
#endif
extern unsigned char _ctype[];
extern int isalnum(int);
extern int isalpha(int);
extern int iscntrl(int);
extern int isdigit(int);
extern int isgraph(int);
extern int islower(int);
extern int isprint(int);
extern int ispunct(int);
extern int isspace(int);
extern int isupper(int);
extern int isxdigit(int);
extern int tolower(int);
extern int toupper(int);
#ifdef __cplusplus
}
#endif
#define _UPPER 0x01
#define _LOWER 0x02
#define _DIGIT 0x04
#define _SPACE 0x08
#define _PUNCT 0x10
#define _CNTRL 0x20
#define _WHITE 0x40
#define _HEX 0x80
#define isalnum(c) (_ctype[(c) & 0xff] & (_UPPER | _LOWER | _DIGIT))
#define isalpha(c) (_ctype[(c) & 0xff] & (_UPPER | _LOWER))
#define iscntrl(c) (_ctype[(c) & 0xff] & _CNTRL)
#define isdigit(c) (_ctype[(c) & 0xff] & _DIGIT)
#define isgraph(c) (_ctype[(c) & 0xff] & (_UPPER | _LOWER | _DIGIT | _PUNCT))
#define islower(c) (_ctype[(c) & 0xff] & _LOWER)
#define isprint(c) (_ctype[(c) & 0xff] & (_UPPER|_LOWER|_DIGIT|_PUNCT|_SPACE))
#define ispunct(c) (_ctype[(c) & 0xff] & _PUNCT)
#define isspace(c) (_ctype[(c) & 0xff] & _WHITE)
#define isupper(c) (_ctype[(c) & 0xff] & _UPPER)
#define isxdigit(c) (_ctype[(c) & 0xff] & _HEX)
#define tolower(c) (isupper(c) ? ((c)-'A'+'a') : (c))
#define toupper(c) (islower(c) ? ((c)-'a'+'A') : (c))
#endif

+ 88
- 0
include/dispbios.h View File

@@ -0,0 +1,88 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : dispbios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifndef __DISPBIOS_H__
#define __DISPBIOS_H__
// Defines
#define IM_VRAM_WIDTH 128
#define IM_VRAM_HEIGHT 64
#define IM_VRAM_SIZE 1024
#define IM_CHARACTERS_MAX_LINE 21
#define IM_BYTES_MAX_LINE (IM_CHARACTERS_MAX_LINE*2)
#define SAVEDISP_PAGE1 1
#define SAVEDISP_PAGE2 5
#define SAVEDISP_PAGE3 6
#define MINI_OVER 0x10
#define MINI_OR 0x11
#define MINI_REV 0x12
#define MINI_REVOR 0x13
#define IM_BIOS_DD_WIDTH IM_VRAM_WIDTH
#define IM_BIOS_DD_HEIGHT IM_VRAM_HEIGHT
#define WRITEKIND unsigned char
#define IMB_WRITEKIND_OVER 0x01
#define IMB_WRITEKIND_OR 0x02
#define IMB_WRITEKIND_AND 0x03
#define IMB_WRITEKIND_XOR 0x04
#define WRITEMODIFY unsigned char
#define IMB_WRITEMODIFY_NORMAL 0x01
#define IMB_WRITEMODIFY_REVERCE 0x02
#define IMB_WRITEMODIFY_MESH 0x03
#define AREAKIND unsigned char
#define IMB_AREAKIND_OVER 0x01
#define IMB_AREAKIND_MESH 0x02
#define IMB_AREAKIND_CLR 0x03
#define IMB_AREAKIND_REVERSE 0x04
#define EFFECTWIN unsigned char
#define IMB_EFFECTWIN_OK 0x01
#define IMB_EFFECTWIN_NG 0x02
// Structs
typedef struct tag_DISPBOX{
int left;
int top;
int right;
int bottom;
} DISPBOX;
typedef struct tag_GRAPHDATA{
int width;
int height;
unsigned char *pBitmap;
} GRAPHDATA;
typedef struct tag_RECTANGLE{
DISPBOX LineArea;
AREAKIND AreaKind;
EFFECTWIN EffectWin;
} RECTANGLE;
typedef struct tag_DISPGRAPH{
int x;
int y;
GRAPHDATA GraphData;
WRITEMODIFY WriteModify;
WRITEKIND WriteKind;
} DISPGRAPH;
#endif

+ 22
- 0
include/endian.h View File

@@ -0,0 +1,22 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : endian.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifndef __ENDIAN_H__
#define __ENDIAN_H__
// Macros
#define UtlSwapWord(w) (unsigned short)((((w) & 0x00ff) << 8) | (((w) & 0xff00) >> 8))
#define UtlSwapDword(l) (unsigned long)((((l) & 0x000000ff) << 24) | (((l) & 0x0000ff00) << 8) | (((l) & 0xff000000) >> 24) | (((l) & 0x00ff0000) >> 8))
#define UtlSwapInteger(i) UtlSwapDword(i)
#define UtlSwapPointer(p) (void*)((((unsigned long)(p) & 0x000000ff) << 24) | (((unsigned long)(p) & 0x0000ff00) << 8) | (((unsigned long)(p) & 0xff000000) >> 24) | (((unsigned long)(p) & 0x00ff0000) >> 8))
#endif

+ 257
- 0
include/ensigdsp.h View File

@@ -0,0 +1,257 @@
/*
*SHDSP Library
*Copyright (c) Hitachi,Ltd. 1998
*Licensed material of Hitachi,Ltd
*/
/***********************************************************
* File: ensigdsp.h
* Purpose: Common
* Create: 1998.03.20 Rev. 1.0
***********************************************************/
/*
** Copyright Ensigma Ltd. 1995
**
** Unauthorised copying or distribution of this software is prohibited.
**
** Version 1.0.
**
*/
/*
** ENSIGMA DSP Library
*/
/* Constants */
#ifndef _ENSIGDSP
#define _ENSIGDSP
#define BIQUAD_SIZE 6 /* no. coefficients in an IIR biquad */
#define EDSP_OK 0
#define EDSP_BAD_ARG 1
#define EDSP_NO_HEAP 2
#define EFFTALLSCALE (-1L)
#define EFFTMIDSCALE 0x55555555L
#define EFFTNOSCALE 0x00000000L
#ifdef __cplusplus /*A-10-014-01*/
extern"C"{ /*A-10-014-01*/
#endif /*A-10-014-01*/
/*
** Fourier transforms
*/
int FftComplex(short op_x[],
short op_y[],
const short ip_x[],
const short ip_y[],
long size,
long scale);
int FftInComplex(short data_x[],
short data_y[],
long size,
long scale);
int FftReal(short op_x[],
short op_y[],
const short ip[],
long size,
long scale);
/* int ip_is_x);*/
int FftInReal(short data_x[],
short data_y[],
long size,
long scale,
int not_sure_about_ip_format);
int IfftComplex(short op_x[],
short op_y[],
const short ip_x[],
const short ip_y[],
long size,
long scale);
int IfftInComplex(short data_x[],
short data_y[],
long size,
long scale);
int IfftReal(short op_x[],
short op_y[],
const short ip_x[],
const short ip_y[],
long size,
long scale,
int op_is_x_scratch_is_y);
int IfftInReal(short data_x[],
short data_y[],
long size,
long scale,
int not_sure_about_op_format);
int InitFft(long max_size);
void FreeFft(void); /*A-10-015-01*/
int LogMagnitude(short output[],
const short ip_x[],
const short ip_y[],
long no_elements,
float fscale);
/*
** These three variables are for the internal use of the library FFT
** functions only. They should not be accessed by user programs.
*/
extern long max_fft_size;
extern short *twtble;
/*
** Window functions
*/
int GenBlackman(short data[], long N);
int GenHamming(short data[], long N);
int GenHanning(short data[], long N);
int GenTriangle(short data[], long N);
/*
** Filters. The coefficients must be supplied in X and the workspace in Y.
** If it is straightforward we can support the opposite, ie Xworkspace and
** Ycoeff.
*/
int FreeFir(short **Yworkspace, long order);
int InitFir(short **Yworkspace, long order);
int InitIir(short **Yworkspace, long no_sections);
int FreeIir(short **Yworkspace, long no_sections); /*A-10-015-01*/
int InitDIir(long **Yworkspace, long no_sections);
int FreeDIir(long **Yworkspace, long no_sections); /*A-10-015-01*/
int InitLms(short **Yworkspace, long order);
int FreeLms(short **Yworkspace, long order); /*A-10-015-01*/
int Fir(short op[],
const short ip[],
long no_samples,
const short Xcoeff[],
long order,
int res_shift,
short *Yworkspace);
int Fir1(short *op_ptr,
short input,
const short Xcoeff[],
long order,
int res_shift,
short *Yworkspace);
int Iir(short op[],
const short ip[],
long no_samples,
const short Xcoeff[],
long no_sections,
short *Yworkspace);
int Iir1(short *op_ptr,
short input,
const short Xcoeff[],
long no_sections,
short *Yworkspace);
int DIir(short op[],
const short ip[],
long no_samples,
const long Xcoeff[],
long no_sections,
long *Yworkspace);
int DIir1(short *op_ptr,
const short input, /*98.01.09 C-10-005-01 */
/* short input, 98.01.09 D-10-005-01 */
const long Xcoeff[],
long no_sections,
long *Yworkspace);
int Lms(short op[],
const short ip[],
const short ref[],
long no_samples,
short Xcoeff[],
long order,
int res_shift,
short mu,
short *Yworkspace);
int Lms1(short *op_ptr,
short input,
short ref_op,
short Xcoeff[],
long order,
int res_shift,
short mu,
short *Yworkspace);
/*
** Convolution and Correlation
*/
int ConvComplete(short op[],
const short ix[],
const short iy[],
long ix_size,
long iy_size,
int res_shift);
int ConvCyclic(short op[],
const short ix[],
const short iy[],
long size,
int res_shift);
int ConvPartial(short op[],
const short ix[],
const short iy[],
long ix_size,
long iy_size,
int res_shift);
int Correlate(short op[],
const short ix[],
const short iy[],
long ix_size,
long iy_size,
long no_corr,
int x_is_larger,
int res_shift);
int CorrCyclic(short op[],
const short ix[],
const short iy[],
long size,
int reverse,
int res_shift);
/*
** Miscellaneous
*/
int GenGWnoise(short output[], long no_samples, float variance);
int MinI(short **min_ptr, short buffer[], long buff_len, int src_is_x);
int MaxI(short **max_ptr, short buffer[], long buff_len, int src_is_x);
int PeakI(short **peak_ptr, short buffer[], long buff_len, int src_is_x);
int Mean(short *mean_ptr, const short buffer[], long buff_len, int src_is_x);
int Variance(long *variance_ptr,
short *mean_ptr,
const short buffer[],
long buff_len, int src_is_x);
int VectorMult(short dest[],
const short matrixX[],
const short matrixY[],
long length,
int res_shift);
int MatrixMult(void *matrix3,
const void *matrixX,
const void *matrixY,
long m,
long n,
long p,
int res_shift, int dest_is_x);
int MsPower(long *pow_ptr, const short input[], long buff_size, int src_is_x);
int CopyXtoY(short y[], const short x[], long n);
int CopyYtoX(short x[], const short y[], long n);
int CopyToX(short x[], const short src[], long n);
int CopyToY(short y[], const short src[], long n);
int CopyFromX(short src[], const short x[], long n);
int CopyFromY(short src[], const short y[], long n);
int Limit(short data[], long no_elements, int data_is_x);
#ifdef __cplusplus /*A-10-014-01*/
} /*A-10-014-01*/
#endif /*A-10-014-01*/
#endif

+ 114
- 0
include/errno.h View File

@@ -0,0 +1,114 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 1.0 */
/* Copyright (c) 1992 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/*****************************************************************/
/* SPEC ; */
/* NAME = errno : */
/* FUNC = */
/* ; */
/* */
/* */
/* */
/* CLAS = UNIT ; */
/* END ; */
/*****************************************************************/
#ifndef _ERRNO
#define _ERRNO
#ifndef ERANGE
#define ERANGE 1100
#endif
#ifndef EDOM
#define EDOM 1101
#endif
#ifndef EDIV
#define EDIV 1102
#endif
#ifndef ESTRN
#define ESTRN 1104
#endif
#ifndef PTRERR
#define PTRERR 1106
#endif
#ifndef SEQERR
#define SEQERR 1108
#endif
#ifndef ECBASE
#define ECBASE 1200
#endif
#ifndef ETLN
#define ETLN 1202
#endif
#ifndef EEXP
#define EEXP 1204
#endif
#ifndef EEXPN
#define EEXPN 1206
#endif
#ifndef ENUM
#define ENUM 1208
#endif
#ifndef EFLOATO
#define EFLOATO 1210
#endif
#ifndef EFLOATU
#define EFLOATU 1220
#endif
#ifndef EDBLO
#define EDBLO 1250
#endif
#ifndef EDBLU
#define EDBLU 1260
#endif
#ifndef ELDBLO
#define ELDBLO 1270
#endif
#ifndef ELDBLU
#define ELDBLU 1280
#endif
#ifndef NOTOPN
#define NOTOPN 1300
#endif
#ifndef EBADF
#define EBADF 1302
#endif
#ifndef ECSPEC
#define ECSPEC 1304
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern volatile int _errno;
#ifdef __cplusplus
}
#endif
#ifndef errno
#define errno _errno
#endif
#endif

+ 74
- 0
include/exception.h View File

@@ -0,0 +1,74 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 1.0 */
/* Copyright (c) 1992 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/***********************************************************************/
/* SPEC; */
/* NAME = exception.h : */
/* */
/* FUNC = Include file for exception handling (see 18.6) */
/* */
/* CLAS = UNIT; */
/* */
/* END; */
/***********************************************************************/
#ifndef _EXCEPTION_H
#define _EXCEPTION_H
/* This lets users disable the EDG supplied exception classes. */
#ifndef __NO_EDG_EXCEPTION_CLASSES
#include <stdexcept.h>
#ifdef __EDG_RUNTIME_USES_NAMESPACES
namespace std {
#endif /* ifdef __EDG_RUNTIME_USES_NAMESPACES */
/*
If bool is not supported, use a typedef for bool.
*/
#ifdef _BOOL
typedef bool __bool;
#else /* ifndef _BOOL */
typedef int __bool;
#endif /* ifdef _BOOL */
class bad_exception : public exception {
public:
bad_exception() throw();
bad_exception(const bad_exception&) throw();
bad_exception& operator=(const bad_exception&) throw();
virtual ~bad_exception() throw();
virtual const char* what() const throw();
};
typedef void (*terminate_handler)();
extern terminate_handler set_terminate(terminate_handler);
typedef void (*unexpected_handler)();
extern unexpected_handler set_unexpected(unexpected_handler);
/* unexpected and terminate are in the WP definition of exception.h.
It is not clear why. */
void terminate();
void unexpected();
extern __bool uncaught_exception();
#ifdef __EDG_RUNTIME_USES_NAMESPACES
} /* namespace */
#ifdef __EDG_IMPLICIT_USING_STD
/* Implicitly include a using directive for the STD namespace when this
preprocessing flag is TRUE. */
using namespace std;
#endif /* ifdef __EDG_IMPLICIT_USING_STD */
#endif /* ifdef __EDG_RUNTIME_USES_NAMESPACES */
#endif /* ifndef __NO_EDG_EXCEPTION_CLASSES */
#endif /* _EXCEPTION_H */

+ 107
- 0
include/filebios.h View File

@@ -0,0 +1,107 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : filebios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifndef __FILEBIOS_H__
#define __FILEBIOS_H__
// Defines
#define FONTCHARACTER unsigned short
#define _OPENMODE_READ 0x01
#define _OPENMODE_READ_SHARE 0x80
#define _OPENMODE_WRITE 0x02
#define _OPENMODE_READWRITE 0x03
#define _OPENMODE_READWRITE_SHARE 0x83
#define _CREATEMODE_BINARY 1
#define _CREATEMODE_DIRECTORY 5
enum DEVICE_TYPE{
DEVICE_MAIN_MEMORY,
DEVICE_STORAGE,
DEVICE_SD_CARD, // only fx-9860G SD model
};
// File system standard error code
#define IML_FILEERR_NOERROR 0
#define IML_FILEERR_ENTRYNOTFOUND -1
#define IML_FILEERR_ILLEGALPARAM -2
#define IML_FILEERR_ILLEGALPATH -3
#define IML_FILEERR_DEVICEFULL -4
#define IML_FILEERR_ILLEGALDEVICE -5
#define IML_FILEERR_ILLEGALFILESYS -6
#define IML_FILEERR_ILLEGALSYSTEM -7
#define IML_FILEERR_ACCESSDENYED -8
#define IML_FILEERR_ALREADYLOCKED -9
#define IML_FILEERR_ILLEGALTASKID -10
#define IML_FILEERR_PERMISSIONERROR -11
#define IML_FILEERR_ENTRYFULL -12
#define IML_FILEERR_ALREADYEXISTENTRY -13
#define IML_FILEERR_READONLYFILE -14
#define IML_FILEERR_ILLEGALFILTER -15
#define IML_FILEERR_ENUMRATEEND -16
#define IML_FILEERR_DEVICECHANGED -17
//#define IML_FILEERR_NOTRECORDFILE -18 // Not used
#define IML_FILEERR_ILLEGALSEEKPOS -19
#define IML_FILEERR_ILLEGALBLOCKFILE -20
//#define IML_FILEERR_DEVICENOTEXIST -21 // Not used
//#define IML_FILEERR_ENDOFFILE -22 // Not used
#define IML_FILEERR_NOTMOUNTDEVICE -23
#define IML_FILEERR_NOTUNMOUNTDEVICE -24
#define IML_FILEERR_CANNOTLOCKSYSTEM -25
#define IML_FILEERR_RECORDNOTFOUND -26
//#define IML_FILEERR_NOTDUALRECORDFILE -27 // Not used
#define IML_FILEERR_NOTALARMSUPPORT -28
#define IML_FILEERR_CANNOTADDALARM -29
#define IML_FILEERR_FILEFINDUSED -30
#define IML_FILEERR_DEVICEERROR -31
#define IML_FILEERR_SYSTEMNOTLOCKED -32
#define IML_FILEERR_DEVICENOTFOUND -33
#define IML_FILEERR_FILETYPEMISMATCH -34
#define IML_FILEERR_NOTEMPTY -35
#define IML_FILEERR_BROKENSYSTEMDATA -36
#define IML_FILEERR_MEDIANOTREADY -37
#define IML_FILEERR_TOOMANYALARMITEM -38
#define IML_FILEERR_SAMEALARMEXIST -39
#define IML_FILEERR_ACCESSSWAPAREA -40
#define IML_FILEERR_MULTIMEDIACARD -41
#define IML_FILEERR_COPYPROTECTION -42
#define IML_FILEERR_ILLEGALFILEDATA -43
// FILE_INFO.type
#define DT_DIRECTORY 0x0000 // Directory
#define DT_FILE 0x0001 // File
#define DT_ADDIN_APP 0x0002 // Add-In application
#define DT_EACT 0x0003 // eActivity
#define DT_LANGUAGE 0x0004 // Language
#define DT_BITMAP 0x0005 // Bitmap
#define DT_MAINMEM 0x0006 // Main Memory data
#define DT_TEMP 0x0007 // Temporary data
#define DT_DOT 0x0008 // . (Current directory)
#define DT_DOTDOT 0x0009 // .. (Parent directory)
#define DT_VOLUME 0x000A // Volume label
// Structs
typedef struct tag_FILE_INFO
{
unsigned short id;
unsigned short type;
unsigned long fsize; // File size
unsigned long dsize; // Data size
unsigned int property; // The file has not been completed, except when property is 0.
unsigned long address;
} FILE_INFO;
#endif

+ 26
- 0
include/filt_ws.h View File

@@ -0,0 +1,26 @@
/*
*SHDSP Library
*Copyright (c) Hitachi,Ltd. 1998
*Licensed material of Hitachi,Ltd
*/
/***********************************************************
* File: filt_ws.h
* Purpose: Filter
* Create: 1998.03.20 Rev. 1.0
***********************************************************/
#ifndef FILT_WS
#define FILT_WS
#ifndef WS_SIZE
#define WS_SIZE 1024 /* Set Global workspace buffer size=1024 shorts (2048 bytes) */
#endif
#define MEMSIZE WS_SIZE*sizeof(short)
#pragma section Y /*need to equate DYRAM with link.cmd file*/
short ws_mem[WS_SIZE];
short * ws_ptr=ws_mem;
long ws_left=MEMSIZE;
#pragma section
#endif

+ 208
- 0
include/float.h View File

@@ -0,0 +1,208 @@
/*------------------------------------------------------*/
/* SH SERIES C Compiler Ver. 1.0 */
/* Copyright (c) 1992 Hitachi,Ltd. */
/* Licensed material of Hitachi,Ltd. */
/*------------------------------------------------------*/
/*****************************************************************/
/* SPEC ; */
/* NAME = float : */
/* FUNC = limit about float type and double type ; */
/* */
/* */
/* END ; */
/*****************************************************************/
#ifndef _FLOAT
#define _FLOAT
extern const float _FLT_MAX_VAL;
extern const float _FLT_MIN_VAL;
extern const double _DBL_MAX_VAL;
extern const double _DBL_MIN_VAL;
extern const long double _LDBL_MAX_VAL;
extern const long double _LDBL_MIN_VAL;
#ifndef _FPD
#define FLT_RADIX 2
#if defined(_SH2E)|defined(_SH3E)|(defined(_SH4)&!defined(_RON))
#define FLT_ROUNDS 0
#define FLT_GUARD 0
#else
#define FLT_ROUNDS 1
#define FLT_GUARD 1
#endif
#define FLT_NORMALIZE 1
#define FLT_MAX _FLT_MAX_VAL
#define FLT_MIN _FLT_MIN_VAL
#define FLT_MAX_EXP 127
#if defined(_SH2E)|defined(_SH3E)|(defined(_SH4)&!defined(_DON))
#define FLT_MIN_EXP (-126)
#else
#define FLT_MIN_EXP (-149)
#endif
#define FLT_MAX_10_EXP 38
#if defined(_SH2E)|defined(_SH3E)|(defined(_SH4)&!defined(_DON))
#define FLT_MIN_10_EXP (-38)
#else
#define FLT_MIN_10_EXP (-44)
#endif
#define FLT_DIG 6
#define FLT_MANT_DIG 24
#define FLT_EXP_DIG 8
#if defined(_SH2E)|defined(_SH3E)|(defined(_SH4)&!defined(_RON))
#define FLT_POS_EPS 1.1920928955078125e-7f
#if defined(_DON)
#define FLT_NEG_EPS 1.4012984643248171e-45f
#else
#define FLT_NEG_EPS 1.1754943508222876e-38f
#endif
#else
#define FLT_POS_EPS 5.9604648328104311e-8f
#define FLT_NEG_EPS 2.9802324164052156e-8f
#endif
#define FLT_POS_EPS_EXP (-23)
#if defined(_SH2E)|defined(_SH3E)|defined(_SH4)
#define FLT_NEG_EPS_EXP (-126)
#else
#define FLT_NEG_EPS_EXP (-24)
#endif
#endif
#if defined(_FLT)|defined(_FPS)
#define DBL_RADIX FLT_RADIX
#define DBL_ROUNDS FLT_ROUNDS
#define DBL_GUARD FLT_GUARD
#define DBL_NORMALIZE FLT_NORMALIZE
#define DBL_MAX _FLT_MAX_VAL
#define DBL_MIN _FLT_MIN_VAL
#define DBL_MAX_EXP FLT_MAX_EXP
#define DBL_MIN_EXP FLT_MIN_EXP
#define DBL_MAX_10_EXP FLT_MAX_10_EXP
#define DBL_MIN_10_EXP FLT_MIN_10_EXP
#define DBL_DIG FLT_DIG
#define DBL_MANT_DIG FLT_MANT_DIG
#define DBL_EXP_DIG FLT_EXP_DIG
#define DBL_POS_EPS FLT_POS_EPS
#define DBL_NEG_EPS FLT_NEG_EPS
#define DBL_POS_EPS_EXP FLT_POS_EPS_EXP
#define DBL_NEG_EPS_EXP FLT_NEG_EPS_EXP
#else
#define DBL_RADIX 2
#if defined(_SH4)&!defined(_RON)
#define DBL_ROUNDS 0
#define DBL_GUARD 0
#else
#define DBL_ROUNDS 1
#define DBL_GUARD 1
#endif
#define DBL_NORMALIZE 1
#define DBL_MAX _DBL_MAX_VAL
#define DBL_MIN _DBL_MIN_VAL
#define DBL_MAX_EXP 1023
#if defined(_SH4)&!defined(_DON)
#define DBL_MIN_EXP (-1022)
#else
#define DBL_MIN_EXP (-1074)
#endif
#define DBL_MAX_10_EXP 308
#if defined(_SH4)&!defined(_DON)
#define DBL_MIN_10_EXP (-308)
#else
#define DBL_MIN_10_EXP (-323)
#endif
#define DBL_DIG 15
#define DBL_MANT_DIG 53
#define DBL_EXP_DIG 11
#if defined(_SH4)&!defined(_RON)
#define DBL_POS_EPS 2.2204460492503131e-16
#if defined(_DON)
#define DBL_NEG_EPS 4.9406564584124655e-324
#else
#define DBL_NEG_EPS 2.2250738585072014e-308
#endif
#else
#define DBL_POS_EPS 1.1102230246251567e-16
#define DBL_NEG_EPS 5.5511151231257834e-17
#endif
#define DBL_POS_EPS_EXP (-52)
#ifdef _SH4
#ifdef _RON
#define DBL_NEG_EPS_EXP (-53)
#else
#ifdef _DON
#define DBL_NEG_EPS_EXP (-1023)
#else
#define DBL_NEG_EPS_EXP (-1022)
#endif
#endif
#else
#define DBL_NEG_EPS_EXP (-53)
#endif
#ifdef _FPD
#define FLT_RADIX DBL_RADIX
#define FLT_ROUNDS DBL_ROUNDS
#define FLT_GUARD DBL_GUARD
#define FLT_NORMALIZE DBL_NORMALIZE
#define FLT_MAX _DBL_MAX_VAL
#define FLT_MIN _DBL_MIN_VAL
#define FLT_MAX_EXP DBL_MAX_EXP
#define FLT_MIN_EXP DBL_MIN_EXP
#define FLT_MAX_10_EXP DBL_MAX_10_EXP
#define FLT_MIN_10_EXP DBL_MIN_10_EXP
#define FLT_DIG DBL_DIG
#define FLT_MANT_DIG DBL_MANT_DIG
#define FLT_EXP_DIG DBL_EXP_DIG
#define FLT_POS_EPS DBL_POS_EPS
#define FLT_NEG_EPS DBL_NEG_EPS
#define FLT_POS_EPS_EXP DBL_POS_EPS_EXP
#define FLT_NEG_EPS_EXP DBL_NEG_EPS_EXP
#endif
#endif
#ifdef _FLT
#define LDBL_RADIX 2
#define LDBL_ROUNDS 1
#define LDBL_GUARD 1
#define LDBL_NORMALIZE 1
#define LDBL_MAX _LDBL_MAX_VAL
#define LDBL_MIN _LDBL_MIN_VAL
#define LDBL_MAX_EXP 1023
#define LDBL_MIN_EXP (-1074)
#define LDBL_MAX_10_EXP 308
#define LDBL_MIN_10_EXP (-323)
#define LDBL_DIG 15
#define LDBL_MANT_DIG 53
#define LDBL_EXP_DIG 11
#define LDBL_POS_EPS 1.1102230246251567e-16
#define LDBL_NEG_EPS 5.5511151231257834e-17
#define LDBL_POS_EPS_EXP (-52)
#define LDBL_NEG_EPS_EXP (-53)
#else
#define LDBL_RADIX DBL_RADIX
#define LDBL_ROUNDS DBL_ROUNDS
#define LDBL_GUARD DBL_GUARD
#define LDBL_NORMALIZE DBL_NORMALIZE
#define LDBL_MAX DBL_MAX
#define LDBL_MIN DBL_MIN
#define LDBL_MAX_EXP DBL_MAX_EXP
#define LDBL_MIN_EXP DBL_MIN_EXP
#define LDBL_MAX_10_EXP DBL_MAX_10_EXP
#define LDBL_MIN_10_EXP DBL_MIN_10_EXP
#define LDBL_DIG DBL_DIG
#define LDBL_MANT_DIG DBL_MANT_DIG
#define LDBL_EXP_DIG DBL_EXP_DIG
#define LDBL_POS_EPS DBL_POS_EPS
#define LDBL_NEG_EPS DBL_NEG_EPS
#define LDBL_POS_EPS_EXP DBL_POS_EPS_EXP
#define LDBL_NEG_EPS_EXP DBL_NEG_EPS_EXP
#endif
#endif

+ 91
- 0
include/fxlib.h View File

@@ -0,0 +1,91 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : fxlib.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifndef __FXLIB_H__
#define __FXLIB_H__
#include "dispbios.h"
#include "filebios.h"
#include "keybios.h"
// Prototypes
void Bdisp_AllClr_DD(void);
void Bdisp_AllClr_VRAM(void);
void Bdisp_AllClr_DDVRAM(void);
void Bdisp_AreaClr_DD(const DISPBOX *pArea);
void Bdisp_AreaClr_VRAM(const DISPBOX *pArea);
void Bdisp_AreaClr_DDVRAM(const DISPBOX *pArea);
void Bdisp_AreaReverseVRAM(int x1, int y1, int x2, int y2);
void Bdisp_GetDisp_DD(unsigned char *pData);
void Bdisp_GetDisp_VRAM(unsigned char *pData);
void Bdisp_PutDisp_DD(void);
void Bdisp_PutDispArea_DD(const DISPBOX *PutDispArea);
void Bdisp_SetPoint_DD(int x, int y, unsigned char point);
void Bdisp_SetPoint_VRAM(int x, int y, unsigned char point);
void Bdisp_SetPoint_DDVRAM(int x, int y, unsigned char point);
int Bdisp_GetPoint_VRAM(int x, int y);
void Bdisp_WriteGraph_DD(const DISPGRAPH *WriteGraph);
void Bdisp_WriteGraph_VRAM(const DISPGRAPH *WriteGraph);
void Bdisp_WriteGraph_DDVRAM(const DISPGRAPH *WriteGraph);
void Bdisp_ReadArea_DD(const DISPBOX *ReadArea, unsigned char *ReadData);
void Bdisp_ReadArea_VRAM(const DISPBOX *ReadArea, unsigned char *ReadData);
void Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2);
void Bdisp_ClearLineVRAM(int x1, int y1, int x2, int y2);
void locate(int x, int y);
void Print(const unsigned char *str);
void PrintRev(const unsigned char *str);
void PrintC(const unsigned char *c);
void PrintRevC(const unsigned char *str);
void PrintLine(const unsigned char *str, int max);
void PrintRLine(const unsigned char *str, int max);
void PrintXY(int x, int y, const unsigned char *str, int type);
int PrintMini(int x, int y, const unsigned char *str, int type);
void SaveDisp(unsigned char num);
void RestoreDisp(unsigned char num);
void PopUpWin(int n);
int Bfile_OpenFile(const FONTCHARACTER *filename, int mode);
int Bfile_OpenMainMemory(const unsigned char *name);
int Bfile_ReadFile(int HANDLE, void *buf, int size, int readpos);
int Bfile_WriteFile(int HANDLE, const void *buf, int size);
int Bfile_SeekFile(int HANDLE, int pos);
int Bfile_CloseFile(int HANDLE);
int Bfile_GetMediaFree(enum DEVICE_TYPE devicetype, int *freebytes);
int Bfile_GetFileSize(int HANDLE);
int Bfile_CreateFile(const FONTCHARACTER *filename, int size);
int Bfile_CreateDirectory(const FONTCHARACTER *pathname);
int Bfile_CreateMainMemory(const unsigned char *name);
int Bfile_RenameMainMemory(const unsigned char *oldname, const unsigned char *newname);
int Bfile_DeleteFile(const FONTCHARACTER *filename);
int Bfile_DeleteDirectory(const FONTCHARACTER *pathname);
int Bfile_DeleteMainMemory(const unsigned char *name);
int Bfile_FindFirst(const FONTCHARACTER *pathname, int *FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo);
int Bfile_FindNext(int FindHandle, FONTCHARACTER *foundfile, FILE_INFO *fileinfo);
int Bfile_FindClose(int FindHandle);
void Bkey_Set_RepeatTime(long FirstCount, long NextCount);
void Bkey_Get_RepeatTime(long *FirstCount, long *NextCount);
void Bkey_Set_RepeatTime_Default(void);
int GetKeyWait(int sel, int time, int menu, unsigned int *keycode);
int IsKeyDown(int keycode);
int IsKeyUp(int keycode);
int GetKey(unsigned int *keycode);
int SetTimer(int ID, int elapse, void (*hander)(void));
int KillTimer(int ID);
void Sleep(int millisecond);
void SetQuitHandler(void (*callback)(void));
int INIT_ADDIN_APPLICATION(int isAppli, unsigned short OptionNum);
#endif

+ 60
- 0
include/iomanip View File

@@ -0,0 +1,60 @@
//Embedded C++ Library
//Copyright (c) Hitachi,Ltd. 1997
//Licensed material of Hitachi,Ltd
//
// Embeded C++ Library Header <iomanip>
//
//====================================================================
// File: iomanip
// Purpose: Definition of class iomanip
// Create: 1997.09.20 Rev. 1.0
//====================================================================
#ifndef _IOMANIP_
#define _IOMANIP_
#include <istream>
#include <ostream>
//Class
class smanip{
private:
union{
int val_i;
char val_c;
ios_base::fmtflags val_f;
};
union{
ios_base& (*pfi)(ios_base&,int);
ios_base& (*pfc)(ios_base&,char);
ios_base& (*pff)(ios_base&,ios_base::fmtflags);
};
enum _ec2p_smanip_t{
_ec2p_smanip_i,_ec2p_smanip_c ,_ec2p_smanip_f
}_ec2p_smanip_data;
public:
smanip(ios_base& (*pf)(ios_base&,int),int arg)
:pfi(pf),val_i(arg),_ec2p_smanip_data(_ec2p_smanip_i){}
smanip(ios_base& (*pf)(ios_base&,char),char arg)
:pfc(pf),val_c(arg),_ec2p_smanip_data(_ec2p_smanip_c){}
smanip(ios_base& (*pf)(ios_base&,ios_base::fmtflags),ios_base::fmtflags arg)
:pff(pf),val_f(arg),_ec2p_smanip_data(_ec2p_smanip_f){}
friend ostream& operator << (ostream&,smanip);
friend istream& operator >> (istream&,smanip);
};
//Manipulators
smanip resetiosflags(ios_base::fmtflags);
smanip setiosflags(ios_base::fmtflags);
smanip setbase(int);
smanip setfill(char);
smanip setprecision(int);
smanip setw(int);
#endif

+ 192
- 0
include/ios View File

@@ -0,0 +1,192 @@
//Embedded C++ Library
//Copyright (c) Hitachi,Ltd. 1997
//Licensed material of Hitachi,Ltd
//
// Embeded C++ Class Library Header <ios>
//
//====================================================================
// File: ios
// Purpose: Definition of class ios
// Create: 1997.09.20 Rev. 1.0
//====================================================================
#ifndef _IOS_
#define _IOS_
class streambuf;
class ostream;
typedef long POS_T;
typedef long INT_T;
typedef long SZ_T;
typedef long OFF_T;
typedef OFF_T streamoff;
typedef SZ_T streamsize;
typedef INT_T int_type;
typedef POS_T pos_type;
typedef OFF_T off_type;
class ios_base {
public:
typedef long fmtflags;
static const fmtflags boolalpha;
static const fmtflags dec;
static const fmtflags fixed;
static const fmtflags hex;
static const fmtflags internal;
static const fmtflags left;
static const fmtflags oct;
static const fmtflags right;
static const fmtflags scientific;
static const fmtflags showbase;
static const fmtflags showpoint;
static const fmtflags showpos;
static const fmtflags skipws;
static const fmtflags unitbuf;
static const fmtflags uppercase;
static const fmtflags adjustfield;
static const fmtflags basefield;
static const fmtflags floatfield;
typedef int iostate;
static const iostate badbit;
static const iostate eofbit;
static const iostate failbit;
static const iostate goodbit;
typedef int openmode;
static const openmode app;
static const openmode ate;
static const openmode binary;
static const openmode in;
static const openmode out;
static const openmode trunc;
typedef int seekdir;
static const seekdir beg;
static const seekdir cur;
static const seekdir end;
class Init;
fmtflags flags() const {return (fmtflags)fmtfl;}
fmtflags flags(fmtflags);
fmtflags setf(fmtflags) ;
fmtflags setf(fmtflags, fmtflags);
void unsetf(fmtflags);
char fill() const {
return (char)fillch;
}
char fill(char);
int precision() const {
return prec;
}
streamsize precision(streamsize);