Complete makeover: simplify test repo

This commit is contained in:
Memallox 2018-09-07 11:59:06 +02:00
parent 0c9ee5f4f8
commit ff2a727d24
19 changed files with 50 additions and 1023 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
# Build files
build/**
.vscode/**
.astyle

197
Makefile
View File

@ -1,192 +1,13 @@
# TODO use := where it is possible
TOOLCHAIN_PREFIX = sh3eb-elf-
CC = $(TOOLCHAIN_PREFIX)gcc
CXX = $(TOOLCHAIN_PREFIX)g++
LD = $(TOOLCHAIN_PREFIX)ld
AS = $(TOOLCHAIN_PREFIX)as
AR = $(TOOLCHAIN_PREFIX)ar
OBJCOPY = $(TOOLCHAIN_PREFIX)objcopy
FXCONV = fxconv
G1AWRAPPER = g1a-wrapper
CASIOUPLOADER ?= CasioUsbUploader -w
all: main.c main.ld crt0.s icon.bmp
mkdir -p build/
sh3eb-elf-gcc -c crt0.s -o build/crt0.o -m3 -mb -ffreestanding -Iinclude -O2 -std=c11 -nostdlib
sh3eb-elf-gcc -c main.c -o build/main.o -m3 -mb -ffreestanding -Iinclude -O2 -std=c11 -nostdlib
sh3eb-elf-gcc -o build/main.elf build/crt0.o build/main.o -m3 -mb -ffreestanding -Iinclude -O2 -std=c11 -nostdlib -Tmain.ld -Llib -lm -lc -lgcc
sh3eb-elf-objcopy -R .comment -R .bss -O binary build/main.elf build/main.bin
g1a-wrapper build/main.bin -o build/main.g1a -i icon.bmp
SRCDIR = src
BASEINCDIR = include
INCDIRS = $(shell find $(BASEINCDIR) -type d)
OBJDIR = build
LDDIR = ld
LIBDIR = lib
LIBSRCDIR = $(LIBDIR)/$(SRCDIR)
LIBOBJDIR = $(OBJDIR)/$(LIBDIR)
# OUTPUTNAME must not exceed 12 chars!
OUTPUTNAME = cryptfx
LDFILE = $(LDDIR)/$(OUTPUTNAME).ld
VERSIONFILE = version
THUMBNAIL = $(SRCDIR)/icon.bmp
LIBGCCCFGFILE = gcc.cfg
CFLAGS = -m3 -mb -ffreestanding $(foreach d,$(INCDIRS),-I$d) -O2 -std=c11 -nostdlib
CXXFLAGS = -m3 -mb -ffreestanding $(foreach d,$(INCDIRS),-I$d) -O2 -std=c++11 -nostdlib
CPPFLAGS = TODO
LDFLAGS = -T $(LDFILE) -L$(LIBDIR) $(subst lib,-l,$(LIBS)) $(subst lib,-l,$(PREBUILTLIBS))
# static libraries (.a) only!
# libgcc is added in LDFLAGS
# TODO what about -lfx?
#LIBS = libgint libc libfx
LIBS =
PREBUILTLIBS = libc libgcc libfx
INCFILES = $(foreach d,$(INCDIRS),$(wildcard $d/*.h))
SRCFILES = $(shell find $(SRCDIR) -name *.c -o -name *.cpp)
OBJFILES = $(patsubst $(SRCDIR)/%.s, $(OBJDIR)/%.s.o, $(shell find $(SRCDIR)/ -name *.s)) \
$(patsubst $(SRCDIR)/%.cpp, $(OBJDIR)/%.cpp.o, $(shell find $(SRCDIR)/ -name *.cpp)) \
$(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.c.o, $(shell find $(SRCDIR)/ -name *.c))
LIBFILES = $(foreach d,$(LIBS),$d.a)
#--------------------------
# Version management
#--------------------------
# Retrieve version information.
version_string = $(shell cat $(VERSIONFILE) | sed 's/[-.]/ /g')
version_type = $(word 1,$(version_string))
version_major = $(word 2,$(version_string))
version_minor = $(word 3,$(version_string))
version_build = $(word 4,$(version_string))
# Make up the new version integer.
version_build_n = $(shell echo $$(($(version_build) + 1)))
version_letter = $(shell echo -n $(version_type) | sed -r 's/^(.).*/\1/')
version_symbol = $(shell printf '0x%02x%01x%01x%04x' "'$(version_letter)'" \
$(version_major) $(version_minor) $(version_build))
#--------------------------
# Targets
#--------------------------
# make everything: .o, linking (.elf), .bin, .g1a
:PHONY:
all: $(OBJFILES) $(OBJDIR)/$(OUTPUTNAME).elf $(OBJDIR)/$(OUTPUTNAME).bin $(OBJDIR)/$(OUTPUTNAME).g1a
# upload .g1a to the calculator
.PHONY:
upload: all
# upload the addin to the CASIO 9860GII
# note: to be able to upload withou root privilege, create a file /etc/udev/rules.d/60-user-usb.rules containing
# SUBSYSTEM=="usb", ATTRS{idVendor}=="07cf", ATTRS{idProduct}=="6101", MODE="0666
# note: the uploaded file name (including the path!) must not exceed 12 chars!
cd $(OBJDIR); $(CASIOUPLOADER) -f $(OUTPUTNAME).g1a; cd ..
.PHONY:
lib: $(LIBS) #$(foreach d, $(LIBS), $(LIBDIR)/$d.a)
#--------------------------
# Component Targets
#--------------------------
# TODO compile resources (bmps) (only if necessary?), but print warning that this is incompatible with WinSDK
# create directory
%:
#mkdir -p $@
##################### Library ###############################################################
# TODO DOESNT WORK
# link static library
# only consider files in lib/src and its subdirectories!
.SECONDEXPANSION:
$(LIBDIR)/%.a: $$(patsubst $(LIBSRCDIR)/%.c, $(LIBOBJDIR)/%.o, $$(shell find $(LIBSRCDIR)/$$(notdir $$(basename $$@)) -name *.c))
echo $^
echo $(patsubst $(LIBSRCDIR)/%.c, $(LIBOBJDIR)/%.o, $^)
echo.
# TODO this works, but the upper one would be better
.PHONY:
.SECONDEXPANSION:
$(LIBS): $$(patsubst $(LIBSRCDIR)/%.s, $(LIBOBJDIR)/%.s.o, $$(shell find $(LIBSRCDIR)/'$$@' -name *.s)) \
$$(patsubst $(LIBSRCDIR)/%.c, $(LIBOBJDIR)/%.c.o, $$(shell find $(LIBSRCDIR)/'$$@' -name *.c)) \
$$(patsubst $(LIBSRCDIR)/%.cpp, $(LIBOBJDIR)/%.cpp.o, $$(shell find $(LIBSRCDIR)/'$$@' -name *.cpp)) \
$$(patsubst $(LIBSRCDIR)/%.bmp, $(LIBOBJDIR)/%.bmp.o, $$(shell find $(LIBSRCDIR)/'$$@' -name *.bmp))
# TODO include version
$(AR) rcs $(LIBDIR)/$@.a $^
# compile .c files to .o
$(LIBOBJDIR)/%.c.o: $(LIBSRCDIR)/%.c
mkdir -p $(dir $@)
# TODO create dedicated LIBCFLAGS
$(CC) -c $< -o $@ $(CFLAGS) @$(LIBGCCCFGFILE) -g0
# compile .cpp files to .o
$(LIBOBJDIR)/%.cpp.o: $(LIBSRCDIR)/%.cpp
mkdir -p $(dir $@)
# TODO create dedicated LIBCFLAGS
$(CXX) -c $< -o $@ $(CXXFLAGS) @$(LIBGCCCFGFILE) -g0
# compile .s files to .s.o
$(LIBOBJDIR)/%.s.o: $(LIBSRCDIR)/%.s
mkdir -p $(dir $@)
$(AS) -c $< -o $@
# convert bmps to binary (font for the library)
$(LIBOBJDIR)/%.bmp.o: $(LIBSRCDIR)/%.bmp
mkdir -p $(dir $@)
# e.g. if it is build/lib/libgint/display/font_system.bmp.o, use -n gint_font_system
$(FXCONV) -font $< -o $@ -font -n gint_font_system $(firstword $(subst /, ,$(patsubst $(LIBSRCDIR)/lib%,%,$<)))_$(basename $(notdir $<))
###############################################################################################
# compile .c files to .o
$(OBJDIR)/%.c.o: $(SRCDIR)/%.c $(INCFILES)
mkdir -p $(dir $@)
$(CC) -c $< -o $@ $(CFLAGS)
# compile .cpp files to .o
$(OBJDIR)/%.cpp.o: $(SRCDIR)/%.cpp $(INCFILES)
mkdir -p $(dir $@)
$(CXX) -c $< -o $@ $(CXXFLAGS)
cd build; CasioUsbUploader -w -f main.g1a; cd ..
# crt0.s is a special case [TODO obsolete]
$(OBJDIR)/%.s.o: $(SRCDIR)/%.s $(INCFILES)
mkdir -p $(dir $@)
$(CC) -c $< -o $@ $(CFLAGS)
# TODO below here, directory dependency is sloppy. fix this!
# define the version symbol in a specific object file. ld generates a .stack
# section on sh3eb-elf, which it didn't on x86_64. I don't understand the
# details of why, so I just fall back to removing it afterwards.
$(OBJDIR)/$(VERSIONFILE).o:
@ echo "_GINT_VERSION = $(version_symbol);" > $(OBJDIR)/$(VERSIONFILE).tmp.c
$(if $(VERBOSE),,@) $(LD) -r -R $(OBJDIR)/$(VERSIONFILE).tmp.c -o $@
# link object files to .elf file
%.elf: $(OBJFILES)
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
# convert to .elf to .bin
%.bin: %.elf
$(OBJCOPY) -R .comment -R .bss -O binary $< $@
# convert to .bin (and addin thumbnail) to .g1a
%.g1a: %.bin
$(G1AWRAPPER) $< -o $@ -i $(THUMBNAIL)
.PHONY: clean
clean:
rm -rfv $(OBJDIR)
rm -rfv $(patsubst %.a, $(LIBDIR)/%.a, $(LIBFILES))
rm -rfv build/

View File

View File

@ -1,3 +0,0 @@
-D ATEXIT_MAX=16
-D TIMER_SLOTS=16
-D EVENTS_QUEUE_SIZE=64

BIN
icon.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,97 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : dispbios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#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
#ifdef __cplusplus
}
#endif

View File

@ -1,31 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : endian.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#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
#ifdef __cplusplus
}
#endif

View File

@ -1,116 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : filebios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#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
#ifdef __cplusplus
}
#endif

View File

@ -1,122 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : fxlib.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#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);
// Standard declarations
#ifndef _SIZE_T
#define _SIZE_T
typedef int size_t;
#endif // _SIZE_T
void *malloc(size_t size);
void *calloc(size_t num, size_t size);
void *realloc(void *ptr, size_t size);
void free(const void *pointer);
int sprintf(char *str, const char *format, ...);
int vsprintf(char *str, const char *format, __builtin_va_list args);
void *memcpy(void *dest, const void *src, size_t len);
void *memset(void *pointer, int value, size_t len);
#ifndef NULL
#define NULL ((void *)0)
#endif
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,158 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : keybios.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __KEYBIOS_H__
#define __KEYBIOS_H__
// Defines
// Character codes
#define KEY_CHAR_0 0x30
#define KEY_CHAR_1 0x31
#define KEY_CHAR_2 0x32
#define KEY_CHAR_3 0x33
#define KEY_CHAR_4 0x34
#define KEY_CHAR_5 0x35
#define KEY_CHAR_6 0x36
#define KEY_CHAR_7 0x37
#define KEY_CHAR_8 0x38
#define KEY_CHAR_9 0x39
#define KEY_CHAR_DP 0x2e
#define KEY_CHAR_EXP 0x0f
#define KEY_CHAR_PMINUS 0x87
#define KEY_CHAR_PLUS 0x89
#define KEY_CHAR_MINUS 0x99
#define KEY_CHAR_MULT 0xa9
#define KEY_CHAR_DIV 0xb9
#define KEY_CHAR_FRAC 0xbb
#define KEY_CHAR_LPAR 0x28
#define KEY_CHAR_RPAR 0x29
#define KEY_CHAR_COMMA 0x2c
#define KEY_CHAR_STORE 0x0e
#define KEY_CHAR_LOG 0x95
#define KEY_CHAR_LN 0x85
#define KEY_CHAR_SIN 0x81
#define KEY_CHAR_COS 0x82
#define KEY_CHAR_TAN 0x83
#define KEY_CHAR_SQUARE 0x8b
#define KEY_CHAR_POW 0xa8
#define KEY_CHAR_IMGNRY 0x7f50
#define KEY_CHAR_LIST 0x7f51
#define KEY_CHAR_MAT 0x7f40
#define KEY_CHAR_EQUAL 0x3d
#define KEY_CHAR_PI 0xd0
#define KEY_CHAR_ANS 0xc0
#define KEY_CHAR_LBRCKT 0x5b
#define KEY_CHAR_RBRCKT 0x5d
#define KEY_CHAR_LBRACE 0x7b
#define KEY_CHAR_RBRACE 0x7d
#define KEY_CHAR_CR 0x0d
#define KEY_CHAR_CUBEROOT 0x96
#define KEY_CHAR_RECIP 0x9b
#define KEY_CHAR_ANGLE 0x7f54
#define KEY_CHAR_EXPN10 0xb5
#define KEY_CHAR_EXPN 0xa5
#define KEY_CHAR_ASIN 0x91
#define KEY_CHAR_ACOS 0x92
#define KEY_CHAR_ATAN 0x93
#define KEY_CHAR_ROOT 0x86
#define KEY_CHAR_POWROOT 0xb8
#define KEY_CHAR_SPACE 0x20
#define KEY_CHAR_DQUATE 0x22
#define KEY_CHAR_VALR 0xcd
#define KEY_CHAR_THETA 0xce
#define KEY_CHAR_A 0x41
#define KEY_CHAR_B 0x42
#define KEY_CHAR_C 0x43
#define KEY_CHAR_D 0x44
#define KEY_CHAR_E 0x45
#define KEY_CHAR_F 0x46
#define KEY_CHAR_G 0x47
#define KEY_CHAR_H 0x48
#define KEY_CHAR_I 0x49
#define KEY_CHAR_J 0x4a
#define KEY_CHAR_K 0x4b
#define KEY_CHAR_L 0x4c
#define KEY_CHAR_M 0x4d
#define KEY_CHAR_N 0x4e
#define KEY_CHAR_O 0x4f
#define KEY_CHAR_P 0x50
#define KEY_CHAR_Q 0x51
#define KEY_CHAR_R 0x52
#define KEY_CHAR_S 0x53
#define KEY_CHAR_T 0x54
#define KEY_CHAR_U 0x55
#define KEY_CHAR_V 0x56
#define KEY_CHAR_W 0x57
#define KEY_CHAR_X 0x58
#define KEY_CHAR_Y 0x59
#define KEY_CHAR_Z 0x5a
// Control codes
#define KEY_CTRL_NOP 0
#define KEY_CTRL_EXE 30004
#define KEY_CTRL_DEL 30025
#define KEY_CTRL_AC 30015
#define KEY_CTRL_FD 30046
#define KEY_CTRL_XTT 30001
#define KEY_CTRL_EXIT 30002
#define KEY_CTRL_SHIFT 30006
#define KEY_CTRL_ALPHA 30007
#define KEY_CTRL_OPTN 30008
#define KEY_CTRL_VARS 30016
#define KEY_CTRL_UP 30018
#define KEY_CTRL_DOWN 30023
#define KEY_CTRL_LEFT 30020
#define KEY_CTRL_RIGHT 30021
#define KEY_CTRL_F1 30009
#define KEY_CTRL_F2 30010
#define KEY_CTRL_F3 30011
#define KEY_CTRL_F4 30012
#define KEY_CTRL_F5 30013
#define KEY_CTRL_F6 30014
#define KEY_CTRL_CATALOG 30100
#define KEY_CTRL_CAPTURE 30055
#define KEY_CTRL_CLIP 30050
#define KEY_CTRL_PASTE 30036
#define KEY_CTRL_INS 30033
#define KEY_CTRL_MIXEDFRAC 30054
#define KEY_CTRL_FRACCNVRT 30026
#define KEY_CTRL_QUIT 30029
#define KEY_CTRL_PRGM 30028
#define KEY_CTRL_SETUP 30037
#define KEY_CTRL_PAGEUP 30052
#define KEY_CTRL_PAGEDOWN 30053
#define KEY_CTRL_MENU 30003
#define KEY_CTRL_RESERVE1 30060
#define KEY_CTRL_RESERVE2 30061
#define KEY_CTRL_RESERVE3 30062
// in Bkey_GetKeyWait function
#define KEYWAIT_HALTON_TIMEROFF 0
#define KEYWAIT_HALTOFF_TIMEROFF 1
#define KEYWAIT_HALTON_TIMERON 2
#define KEYREP_NOEVENT 0
#define KEYREP_KEYEVENT 1
#define KEYREP_TIMEREVENT 2
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,31 +0,0 @@
/*****************************************************************/
/* */
/* CASIO fx-9860G SDK Library */
/* */
/* File name : timer.h */
/* */
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
/* */
/*****************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __TIMER_H__
#define __TIMER_H__
// Defines
#define ID_USER_TIMER1 1
#define ID_USER_TIMER2 2
#define ID_USER_TIMER3 3
#define ID_USER_TIMER4 4
#define ID_USER_TIMER5 5
#endif
#ifdef __cplusplus
}
#endif

Binary file not shown.

23
main.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(void) {
unsigned int key = 0;
char out[20] = "Test";
while (1) {
Bdisp_AllClr_DDVRAM();
locate(1, 4);
Print("Out: ");
Bdisp_PutDisp_DD();
GetKey(&key);
_read(0, out, 5);
}
return 0;
}

View File

@ -15,8 +15,15 @@ SECTIONS
*(.rodata)
*(.rodata.str1.4)
_romdata = . ; /* symbol for initialization data */
initialize = .;
/*initialize = .;*/
} > rom
/*
.eh_frame : AT(0x00310000) {
*(.eh_frame)
} > rom
*/
.bss : {
_bbss = . ;
_bssdatasize = . ;
@ -33,7 +40,12 @@ SECTIONS
_end = . ;
} > ram
/DISCARD/ : {
*(.eh_frame)
}
/*
PROVIDE(_stack = .);
PROVIDE(_end = .);
*/
/DISCARD/ : {
*(.eh_frame)
}
}

View File

@ -1,61 +0,0 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "string.h"
#include "fxlib.h"
#ifdef __cplusplus
}
#endif
#include "memfunctest.h"
// unused
void conv_to_hex(char x, char* a, char* b) {
*a = (x >> 4) & 0xf;
if (*a < 10) {
*a += '0';
} else {
*a += 'a'-10;
}
*b = x & 0xf;
if (*b < 10) {
*b += '0';
} else {
*b += 'a'-10;
}
}
int main(void) {
unsigned int key;
int i=1;
char in[20] = "Hello World!";
//char* out;
char out[20] = {0};
Bdisp_AllClr_DD();
locate(1, 1);
Print((unsigned char*) in);
//out = (char*) malloc(strlen(in) + 1);
strcpy(out, in);
locate(1, 2);
Print((unsigned char*) out);
//free(out);
locate(1, 3);
memfunctest();
Bdisp_PutDisp_DD();
while(1) GetKey(&key);
return 0;
}
void initialize(void) {
main();
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -1,194 +0,0 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
/* 4-abyte buffer alignement */
#define ALIGN(n) __attribute__((aligned(n)))
/* Unused parameters */
#define UNUSED __attribute__((unused))
//---
// Basic setup
//---
/* Source buffer, used as a data source when copying */
ALIGN(4) static uint8_t src[256];
/* Destination buffer, used as destination when copying or clearing */
ALIGN(4) static uint8_t dst[256];
/* System buffer, used to reproduce the behavior on the system and compare */
ALIGN(4) static uint8_t sys[256];
/* Temporary buffer, used by the naive memmove() */
ALIGN(4) static uint8_t tmp[256];
/* fill() - fill a buffer with non-zero data */
static void fill(uint8_t *buf)
{
for(int i = 0; i < 256; i++) buf[i] = i;
}
/* clear() - clear a buffer with zeros */
static void clear(uint8_t *buf)
{
for(int i = 0; i < 256; i++) buf[i] = 0;
}
/* cmp() - check that some two buffers are equal
Returns non-zero if the buffers differ. */
static int cmp(uint8_t *lft, uint8_t *rgt)
{
for(int i = 0; i < 256; i++) if(lft[i] != rgt[i]) return 1;
return 0;
}
//---
// Naive functions (reference behaviour)
//---
/* naive_memcpy() - bytewise copy */
static void *naive_memcpy(void *_dst, const void *_src, size_t len)
{
uint8_t *dst = _dst;
uint8_t const *src = _src;
while(len--) *dst++ = *src++;
return _dst;
}
/* naive_memset() - bytewise set */
static void *naive_memset(void *_dst, int byte, size_t len)
{
uint8_t *dst = _dst;
while(len--) *dst++ = byte;
return _dst;
}
/* naive_memmove() - bytewise copy with buffer */
static void *naive_memmove(void *_dst, const void *_src, size_t len)
{
naive_memcpy(tmp, _src, len);
naive_memcpy(_dst, tmp, len);
return _dst;
}
//---
// Testing functions
//---
static int test_memcpy(int off_dst, int off_src, size_t len)
{
clear(dst);
clear(sys);
memcpy(dst + off_dst, src + off_src, len);
naive_memcpy(sys + off_dst, src + off_src, len);
return cmp(dst, sys);
}
static int test_memset(int off_dst, UNUSED int off_src, size_t len)
{
fill(dst);
fill(sys);
memset(dst + off_dst, 0, len);
naive_memset(sys + off_dst, 0, len);
return cmp(dst, sys);
}
static int test_memmove(int off_dst, int off_src, size_t len)
{
fill(dst);
fill(sys);
memmove(dst + off_dst, dst + off_src, len);
naive_memmove(sys + off_dst, sys + off_src, len);
return cmp(dst, sys);
}
//---
// Automated tests
//
// These tests are meant to check all size/alignment scenarios for the
// core memory functions. Two intervals of sizes are tested:
// - 12..15 bytes, expected to be handled naively
// - 192..195 bytes, expected to trigger alignment-related optimizations
// For each of these intervals, all alignments possibilities are tested:
// - 4n + { 0,1,2,3 } for the source address
// - 4n + { 0,1,2,3 } for destination address
// Also, the source and destination regions are made to overlap to allow
// non-trivial memmove() cases to be checked.
//
// The testing function non-zero if one or more tests fail.
//---
/* test() - check core memory functions in various size/alignment scenarios
The function to test takes three arguments: two buffer offsets and the size
of the operation. Bounds need no be checked. It must return 0 in case of
success and non-zero in case of failure.
@func Function to test, will be called with various sizes and alignments
@count If non-null, set to number of tests performed
Returns the number of failed tests; thus, non-zero indicates failure. */
static int test(int (*func)(int off_dst, int off_src, size_t size), int *count)
{
/* Number of failed tests */
int failed = 0;
/* Number of tests */
int tests = 0;
/* For each source and destination alignment... */
for(int dst_al = 0; dst_al < 4; dst_al++)
for(int src_al = 0; src_al < 4; src_al++)
/* For each "alignment" of operation size... */
for(int len_al = 0; len_al < 4; len_al++)
{
/* Try a small size first */
failed += !!func(96 + dst_al, 96 + src_al, 12 + len_al);
/* Then a medium region without overlapping */
failed += !!func(4 + dst_al, 128 + src_al, 92 + len_al);
/* A large region with left-right overlapping */
failed += !!func(64 + dst_al, 96 + src_al, 128 + len_al);
/* A large region with right-left overlapping */
failed += !!func(96 + dst_al, 64 + src_al, 128 + len_al);
tests += 4;
}
if(count) *count = tests;
return failed;
}
//---
// Main function
//---
/* memfunctest() - check the bejavior of the core memory functions
Returns non-zero if any test fails. */
int memfunctest(void)
{
int count = 0, failed = 0, count_one, failed_one;
fill(src);
failed_one = test(test_memcpy, &count_one);
failed += failed_one;
count += count_one;
failed_one = test(test_memset, &count_one);
failed += failed_one;
count += count_one;
failed_one = test(test_memmove, &count_one);
failed += failed_one;
count += count_one;
char str[21];
sprintf(str, "Score: %d/%d.", count - failed, count);
Print(str);
return (failed != 0);
}

View File

@ -1,17 +0,0 @@
//---
// memfunctest - Check the behaviour of the core memory functions
//
// This small program checks that memcpy(), memset() and memmove() work
// properly in all source/destination alignment, size, overlap scenarios.
// It also checks both small and large areas to trigger usual optimizations.
//---
#ifndef __MEMFUNCTEST_H__
#define __MEMFUNCTEST_H__
/* memfunctest() - check the bejavior of the core memory functions
Displays the test result on the screen.
Returns non-zero if any test fails. */
int memfunctest(void);
#endif /* __MEMFUNCTEST_H__ */

View File

@ -1 +0,0 @@
beta-0.9-586