libc/newlib/libc/sys/sh3eb/sys/casio_syscalls.h

64 lines
2.3 KiB
C

#ifdef _CASIO_SYSCALLS_H
#define _CASIO_SYSCALLS_H
#else
// the following definitions are only needed once
#define _CASIO_SYSCALLS_SCA 0xD201D002
#define _CASIO_SYSCALLS_SCB 0x422B0009
#define _CASIO_SYSCALLS_SCE 0x80010070
// 0x80010070 is the fx-9860-syscall-entry point
// 0x80020070 is the fx-CG-syscall-entry point (but remember: the syscall numbers are different!)
// for reference:
// this are the assembler instructions, which represent the int arrays of the type
// "const unsigned int scSyscallNo[] = { SCA, SCB, SCE, SyscallNo };"
// mov.l #h'80010070, r2
// mov.l #SyscallNo, r0
// jmp @r2
// nop
/*
* Macro for defining function pointers to some Casio syscalls
* see for addesses: http://media.taricorp.net/prizm/simon_chm/fx_legacy_syscalls.htm
*/
#define DEFINE_CASIO_SYSCALL_FN_PTR(func_name, ret, args, addr) \
typedef ret (* _ ## func_name ## _type) args; \
const unsigned int _ ## func_name ## _ ## address[] = {_CASIO_SYSCALLS_SCA, _CASIO_SYSCALLS_SCB, _CASIO_SYSCALLS_SCE, addr}; \
const _ ## func_name ## _type _ ## func_name ## _ptr = (_ ## func_name ## _type) _ ## func_name ## _ ## address;
/* example for the code generated by DEFINE_SYSCALL_FN_PTR(malloc, void*, (size_t), 0xACD) */
// typedef void* (*_malloc_type)(size_t size);
// const unsigned int _malloc_address[] = { SCA, SCB, SCE, 0xACD };
// const _malloc_type _malloc_ptr = (_malloc_type) _malloc_address;
/*
* Original Casio key positions
*/
#define _CASIO_ROW_AC 1
#define _CASIO_ROW_MIN 2 // bottom
#define _CASIO_ROW_SHIFT 9
#define _CASIO_ROW_ALPHA 8
#define _CASIO_ROW_MAX 10 // top
#define _CASIO_COL_AC 1
#define _CASIO_COL_MIN 2 // right
#define _CASIO_COL_SHIFT 7
#define _CASIO_COL_ALPHA 7
#define _CASIO_COL_MAX 7 // left
/*
* Casio syscalls (non-stdlib)
*/
int GetKey(unsigned int* keycode);
int PutKey(int keycode, int mode);
int GetKeyWait(int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short *keycode);
void Bdisp_AllClr_DDVRAM(void);
void Bdisp_PutDisp_DD(void);
void Print(const unsigned char* str);
void locate(int x, int y);
void wait_ms(unsigned int ms); // TODO signature assumed
#endif /* _CASIO_SYSCALLS_H */