Compare commits
43 Commits
Author | SHA1 | Date |
---|---|---|
flo | 22bbc81c4a | |
flo | 8de686f0d2 | |
flo | 5649753dfc | |
flo | 523ea45acd | |
flo | 0044669e5d | |
flo | a95779e318 | |
flo | 4b84b3853e | |
flo | cf189355a9 | |
flo | 62dacc7f0d | |
flo | 3de8e28307 | |
flo | 6f37e29f4d | |
flo | 93d8443d6a | |
flo | c61b0f3393 | |
flo | b7d80d83d7 | |
flo | 637dea4a3a | |
flo | 25eb828a72 | |
flo | df07aa65b0 | |
flo | 75824c67e5 | |
flo | 2b569efdcd | |
flo | 53096a9a42 | |
flo | 08438dd6b6 | |
flo | d27b18f8d3 | |
flo | c47158af0c | |
flo | 40d0217883 | |
flo | a9f14bc15f | |
flo | cc930929cd | |
flo66 | 6b0835af67 | |
flo66 | 16cda07a7e | |
flo66 | 0b260c78ab | |
flo66 | a81f124774 | |
flo66 | 254ae1aab2 | |
flo66 | b1ecce7212 | |
flo66 | d8e725275a | |
flo66 | 01b7c62b8b | |
flo66 | c940d5ad9d | |
flo66 | cfb3fb08b0 | |
flo66 | 8ec6d4b8af | |
flo | 2beee17123 | |
flo66 | ea5b8682b6 | |
flo66 | 5315bc1a83 | |
flo66 | e84dadb5f3 | |
flo66 | df9c703659 | |
flo66 | 0f60e60428 |
|
@ -3,3 +3,4 @@
|
|||
/*.bin
|
||||
/*.elf
|
||||
/*.g1a
|
||||
/*.txt
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/make -f
|
||||
# INCLUDE CONFIGURATION
|
||||
include $(CURDIR)/Makefile.cfg
|
||||
include $(CURDIR)/Makefile.config
|
||||
|
||||
# DEDUCED VARS
|
||||
ALLOBJ = $(SRC:%=$(OBJDIR)/%.o)
|
||||
ALLINC = $(INC:%=$(INCDIR)/%.h)
|
||||
ALLOBJ = $(patsubst %,$(OBJDIR)/%.o,$(SRC))
|
||||
ALLINC = $(INC:%=$(INCDIR)/%)
|
||||
|
||||
# RULES
|
||||
## Make it all (default rule)
|
||||
|
@ -15,11 +15,11 @@ $(OBJDIR):
|
|||
mkdir -p $(OBJDIR)
|
||||
|
||||
## Make an object file out of an ASM source file
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.s
|
||||
$(OBJDIR)/%.s.o: $(SRCDIR)/%.s
|
||||
$(AS) -c -o $@ $<
|
||||
|
||||
## Make an object file out of a C source file
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(ALLINC)
|
||||
$(OBJDIR)/%.c.o: $(SRCDIR)/%.c $(ALLINC)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
## Make the ELF file
|
||||
|
@ -32,29 +32,31 @@ $(NAME).bin: $(NAME).elf
|
|||
|
||||
## Make the G1A file
|
||||
$(NAME).g1a: $(NAME).bin
|
||||
$(WRAPR) $< -o $(NAME).g1a
|
||||
$(WRAPR) $< -o $(NAME).g1a -i $(ICON)
|
||||
@stat -c "Build finished -- output size is %s bytes." $(NAME).g1a
|
||||
|
||||
## Clean up your mess
|
||||
clean:
|
||||
$(RM) $(ALLOBJ)
|
||||
$(RM) $(OBJDIR)
|
||||
$(RM) $(NAME).elf
|
||||
$(RM) $(NAME).bin
|
||||
|
||||
## Clean up everything
|
||||
mrproper: clean
|
||||
fclean: clean
|
||||
$(RM) $(NAME).g1a
|
||||
fclean: mrproper
|
||||
$(RM) $(NAME).txt
|
||||
|
||||
dump:
|
||||
$(OBJDUMP) -d $(NAME).elf > $(NAME).txt
|
||||
@stat -c "Dump file -- dump file put in %n ." $(NAME).txt
|
||||
|
||||
## Remake
|
||||
re: fclean all
|
||||
|
||||
## Send to calc
|
||||
send:
|
||||
@if [ ! -f $(NAME).g1a ]; then \
|
||||
echo "Please make before sending."; \
|
||||
else $(SENDR) SEND $(NAME).g1a $(NAME).g1a fls0; \
|
||||
fi
|
||||
$(SENDR) send $(NAME).g1a -f
|
||||
|
||||
## Phuneral phuture ?
|
||||
.PHONY: all clean fclean mrproper re send
|
||||
.PHONY: all clean fclean dump re send
|
||||
# END OF FILE
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/make -f
|
||||
# PROJECT INFORMATION
|
||||
NAME = sound
|
||||
ICON = ./icon.bmp
|
||||
LIB = gcc fx
|
||||
ICON = misc/icon.bmp
|
||||
LIB = gcc
|
||||
|
||||
## DIRECTORIES
|
||||
SRCDIR = ./src
|
||||
|
@ -15,28 +15,28 @@ SCPTDIR = ./scripts
|
|||
## Directory maker
|
||||
MD = mkdir -p
|
||||
## File remover
|
||||
RM = rm -f
|
||||
RM = rm -f -r
|
||||
## Assembler
|
||||
AS = sh3eb-elf-as
|
||||
## C compiler
|
||||
CC = sh3eb-elf-gcc
|
||||
CFLAGS = -m3 -mb -O0 -nostdlib -Wall -Wextra -Wno-main -pedantic -std=c11 -I $(INCDIR)
|
||||
CFLAGS = -m3 -mb -ffreestanding -O2 -nostdlib -Wall -Wextra -Wno-main -pedantic -std=c11 -I $(INCDIR) `fxsdk --cflags`
|
||||
## Linker
|
||||
LD = sh3eb-elf-gcc
|
||||
LFLAGS = -nostdlib -T $(SCPTDIR)/addin.ld -L $(LIBDIR) $(addprefix -l,$(LIB))
|
||||
LFLAGS = `fxsdk --cflags` `fxsdk --libs`
|
||||
## Object copier
|
||||
OBJCPY = sh3eb-elf-objcopy
|
||||
## Object dump
|
||||
OBJDUMP = sh3eb-elf-objdump
|
||||
## G1A Wrapper
|
||||
WRAPR = g1a-wrapper
|
||||
## Sender
|
||||
SENDR = UsbConnector
|
||||
SENDR = p7
|
||||
|
||||
# SOURCES
|
||||
SRC = crt0 Sound4Calc syscall
|
||||
SRC = $(notdir $(wildcard $(SRCDIR)/*.[cs]))
|
||||
|
||||
# INCLUDES
|
||||
INC = dispbios endian filebios fxlib keybios timer \
|
||||
stdlib syscall \
|
||||
Sound4Calc
|
||||
INC = $(notdir $(wildcard $(INCDIR)/*.h))
|
||||
|
||||
# END OF FILE
|
|
@ -6,4 +6,10 @@ Building the library is achieved by the Makefile :
|
|||
- `make`: make the library ;
|
||||
- `make clean`: clean the object files ;
|
||||
- `make fclean`: clean the object files and the final library ;
|
||||
- `make re`: cleans the object files and the final library, then makes the project.
|
||||
- `make re`: cleans the object files and the final library, then makes the project.
|
||||
|
||||
These sources can be compiled with __GCC__ and use __Gint__ (Lephenixnoir's library)
|
||||
|
||||
## Final project
|
||||
|
||||
A sound library to make sound in games.
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
#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
|
||||
|
||||
unsigned char *itoa(int n, unsigned char* str, int base);
|
||||
|
||||
#endif
|
|
@ -1,88 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* 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
|
|
@ -1,22 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* 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
|
|
@ -1,107 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* 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
|
|
@ -1,91 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* 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
|
|
@ -1,149 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* CASIO fx-9860G SDK Library */
|
||||
/* */
|
||||
/* File name : keybios.h */
|
||||
/* */
|
||||
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
|
||||
/* */
|
||||
/*****************************************************************/
|
||||
#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
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _MAIN_H
|
||||
#define _MAIN_H
|
||||
|
||||
void DrawKeyF(char* str, unsigned char keyF);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,49 @@
|
|||
#ifndef _SOUND4CALC_H
|
||||
#define _SOUND4CALC_H
|
||||
|
||||
#include <timer.h>
|
||||
#include <clock.h>
|
||||
#include <mpu.h>
|
||||
|
||||
struct Wave
|
||||
{
|
||||
unsigned int signal;
|
||||
unsigned short length;
|
||||
};
|
||||
|
||||
extern struct Note
|
||||
{
|
||||
struct Wave wave;
|
||||
unsigned short duration;
|
||||
unsigned int freq;
|
||||
} note;
|
||||
|
||||
extern int frequency;
|
||||
|
||||
void CallSequence(timer_t **timer);
|
||||
void Sequence();
|
||||
//void CallNote(timer_t **timer);
|
||||
void Note();
|
||||
void PutPinState(char level);
|
||||
void PlayNote();
|
||||
void InitPorts();
|
||||
void StopTimer();
|
||||
|
||||
//SH4 addresses
|
||||
#define SH7305_PJCR 0xA4050110
|
||||
#define SH7305_PUCR 0xA4050142
|
||||
#define SH7305_PJDR 0xA4050130
|
||||
#define SH7305_PUDR 0xA4050162
|
||||
#define SH7305_MSTPCR0 0xA4150030
|
||||
#define SH7305_SCSCR 0xA4410008
|
||||
|
||||
//SH3 addresses
|
||||
#define SH7337_STBCR3 0xA40A0000
|
||||
#define SH7337_SCSCR2 0xA4410008
|
||||
#define SH7337_PGCR 0xA400010C
|
||||
#define SH7337_PLCR 0xA4000114
|
||||
#define SH7337_SCPCR 0xA4000116
|
||||
#define SH7337_PGDR 0xA400012C
|
||||
#define SH7337_SCPDR 0xA4000136
|
||||
|
||||
#endif
|
127
include/stdlib.h
127
include/stdlib.h
|
@ -1,127 +0,0 @@
|
|||
/*------------------------------------------------------*/
|
||||
/* SH SERIES C Compiler Ver. 1.0 */
|
||||
/* Copyright (c) 1992 Hitachi,Ltd. */
|
||||
/* Licensed material of Hitachi,Ltd. */
|
||||
/*------------------------------------------------------*/
|
||||
/*****************************************************************/
|
||||
/* SPEC ; */
|
||||
/* NAME = stdlib : */
|
||||
/* FUNC = */
|
||||
/* ; */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* CLAS = UNIT ; */
|
||||
/* END ; */
|
||||
/*****************************************************************/
|
||||
#ifndef _STDLIB
|
||||
#define _STDLIB
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct _DIV_T_TAG { /* tag define for div_t */
|
||||
int quot; /* quotient */
|
||||
int rem; /* remainder */
|
||||
}; /* */
|
||||
struct _LDIV_T_TAG { /* tag define for ldiv_t */
|
||||
long quot; /* quotient */
|
||||
long rem; /* remainder */
|
||||
}; /* */
|
||||
|
||||
typedef struct _DIV_T_TAG div_t ;
|
||||
/* int quot; int rem */
|
||||
typedef struct _LDIV_T_TAG ldiv_t ;
|
||||
/* long quot; long rem; */
|
||||
|
||||
#ifndef RAND_MAX
|
||||
#define RAND_MAX 32767
|
||||
#endif
|
||||
|
||||
#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 ECBASE
|
||||
#define ECBASE 1200
|
||||
#endif
|
||||
|
||||
#ifndef ETLN
|
||||
#define ETLN 1202
|
||||
#endif
|
||||
|
||||
#ifndef EEXP
|
||||
#define EEXP 1204
|
||||
#endif
|
||||
|
||||
#ifndef EEXPN
|
||||
#define EEXPN 1206
|
||||
#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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern volatile int _errno;
|
||||
extern const double _HUGE_VAL;
|
||||
#define HUGE_VAL _HUGE_VAL
|
||||
|
||||
extern double atof(const char *) ;
|
||||
extern int atoi(const char *) ;
|
||||
extern long int atol(const char *) ;
|
||||
extern double strtod(const char *, char **) ;
|
||||
extern long int strtol(const char *, char **, int);
|
||||
extern int rand(void) ;
|
||||
extern void srand(unsigned int);
|
||||
extern void *calloc(size_t, size_t);
|
||||
extern void free(void *) ;
|
||||
extern void *malloc(size_t);
|
||||
extern void *realloc(void *, size_t) ;
|
||||
extern void *bsearch(const void *, const void *, size_t, size_t,
|
||||
int(*)(const void*,const void*) ) ;
|
||||
extern void qsort(void *, size_t, size_t,
|
||||
int(*)(const void*,const void*) );
|
||||
|
||||
extern int abs(int);
|
||||
extern div_t div(int, int);
|
||||
extern long int labs(long int);
|
||||
extern ldiv_t ldiv(long int, long int);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef _SYSCALL_H
|
||||
#define _SYSCALL_H
|
||||
|
||||
int Keyboard_GetKey(int*column, int*row, int type_of_waiting, int timeout_period, int menu, unsigned short*keycode);
|
||||
|
||||
int Keyboard_GetPressedKey(short *matrixcode);
|
||||
int Keyboard_IsKeyPressed(short *matrixcode);
|
||||
int Keyboard_KeyDown(void);
|
||||
int Keyboard_ClrBuffer(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/*****************************************************************/
|
||||
/* */
|
||||
/* CASIO fx-9860G SDK Library */
|
||||
/* */
|
||||
/* File name : timer.h */
|
||||
/* */
|
||||
/* Copyright (c) 2006 CASIO COMPUTER CO., LTD. */
|
||||
/* */
|
||||
/*****************************************************************/
|
||||
#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
|
BIN
lib/libfx.a
BIN
lib/libfx.a
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 326 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
@ -1,31 +0,0 @@
|
|||
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
|
||||
}
|
180
src/Sound4Calc.c
180
src/Sound4Calc.c
|
@ -1,180 +0,0 @@
|
|||
#include <fxlib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <addresses.h>
|
||||
#include <Sound4Calc.h>
|
||||
|
||||
#include <syscall.h>
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
//#define PI 3.14159265358
|
||||
|
||||
unsigned 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;
|
||||
#ifdef DEBUG
|
||||
char before = 0, during = 0, after = 0;
|
||||
#endif
|
||||
|
||||
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=*(volatile unsigned char*)SH7305_PJDR;
|
||||
ResetPin();
|
||||
during=*(volatile unsigned char*)SH7305_PJDR;
|
||||
for(i=0;i<sleep;i++);
|
||||
SetPin();
|
||||
after=*(volatile unsigned char*)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)
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(volatile unsigned short*)SH7305_SCSCR &= ~0x0030;
|
||||
// SCIF2 clock off (MSTPCR0.MSTP007)
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 |= 0x00000080;
|
||||
|
||||
// set bit 3 of port U to output mode
|
||||
*(volatile unsigned short*)SH7305_PUCR = ( *(volatile unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040;
|
||||
// set bit 4 and 5 of port U
|
||||
*(volatile unsigned char*)SH7305_PUDR |= 0x0C;
|
||||
|
||||
// set port J bit 2 to output mode
|
||||
*(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010;
|
||||
// set port J bit 3 to output mode
|
||||
*(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SCIF2 clock on (STBCR3.MSTP31)
|
||||
*(volatile unsigned char*)SH7337_STBCR3 &= ~0x02;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(volatile unsigned short*)SH7337_SCSCR2 &= ~0x0030;
|
||||
// SCIF2 clock off (STBCR3.MSTP31)
|
||||
*(volatile unsigned char*)SH7337_STBCR3 |= 0x02;
|
||||
// set bit 6 of port G to output mode
|
||||
*(volatile unsigned short*)SH7337_PGCR = ( *(volatile unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000;
|
||||
// set bit 5 and 6 of port G
|
||||
*(volatile unsigned char*)SH7337_PGDR |= 0x60;
|
||||
// set port SC bit 0 to output
|
||||
*(volatile unsigned short*)SH7337_SCPCR = ( *(volatile 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)
|
||||
{
|
||||
*(volatile unsigned char*)SH7305_PJDR |= 0x04;
|
||||
*(volatile unsigned char*)SH7305_PJDR &= ~0x08;
|
||||
//set pin to 0x4B
|
||||
}
|
||||
else
|
||||
{
|
||||
*(volatile unsigned char*)SH7337_SCPDR |= 0x01;
|
||||
}
|
||||
}
|
||||
|
||||
void ResetPin()
|
||||
{
|
||||
if(is_SH4)
|
||||
{
|
||||
*(volatile unsigned char*)SH7305_PJDR &= ~0x04;
|
||||
*(volatile unsigned char*)SH7305_PJDR |= 0x08;
|
||||
// set the pin to 0x47
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
*(volatile 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
|
||||
}
|
172
src/crt0.s
172
src/crt0.s
|
@ -1,172 +0,0 @@
|
|||
.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
|
|
@ -0,0 +1,83 @@
|
|||
#include "main.h"
|
||||
#include "sound4calc.h"
|
||||
|
||||
#include <display.h>
|
||||
#include <keyboard.h>
|
||||
#include "string.h"
|
||||
//#define PI 3.141592653584
|
||||
|
||||
unsigned 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 = 0;
|
||||
unsigned short place = 0;
|
||||
unsigned char str[33];
|
||||
|
||||
// initialisation to play
|
||||
note.freq = 440;
|
||||
note.wave.signal = 0;
|
||||
note.duration = 2000;
|
||||
|
||||
note.wave.length = 32; // 4 bytes long
|
||||
|
||||
InitPorts();
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
dclear();
|
||||
|
||||
dprint(1, 1, "frq = %d", note.freq);
|
||||
dprint(1, 10, "%s", itoa(note.wave.signal, str, 16));
|
||||
dprint(1, 20, "%d", note.wave.signal);
|
||||
dprint(1, 30, "%d", place);
|
||||
dprint(1, 40, "length %d", note.wave.length);
|
||||
// dprint(50, 50, "clk : %d", clock_setting(note.freq * note.wave.length, clock_Hz));
|
||||
|
||||
DrawKeyF("not", 1);
|
||||
DrawKeyF("seq", 2);
|
||||
|
||||
dupdate();
|
||||
|
||||
key = getkey();
|
||||
|
||||
switch(key)
|
||||
{
|
||||
case KEY_RIGHT : note.freq += 1; break;
|
||||
case KEY_LEFT : note.freq -= 1; break;
|
||||
case KEY_UP : note.freq += 10; break;
|
||||
case KEY_DOWN : note.freq -= 10; break;
|
||||
|
||||
case KEY_1 : note.wave.signal = note.wave.signal | (0x01 << place); place = (place < note.wave.length - 1 ? place + 1 : place); break;
|
||||
case KEY_0 : note.wave.signal = (note.wave.signal & ~(0x0 << place)); place = (place < note.wave.length - 1 ? place + 1 : place); break;
|
||||
|
||||
case KEY_DEL : place = 0; note.wave.signal = 0; break;
|
||||
|
||||
//case KEY_F5 : *(note.wave.signal+place++) = 255; *(note.wave.signal+place) = 0; break;
|
||||
//case KEY_F6 : *(note.wave.signal+place++) = 240; *(note.wave.signal+place) = 0; break;
|
||||
//case KEY_DEL : place=(place>0 ? place - 1 : 0); *(note.wave.signal+place) = 0; break;
|
||||
|
||||
case KEY_F1 : frequency = 0; Note(); break;
|
||||
case KEY_F2 : Sequence(); break;
|
||||
|
||||
case KEY_EXIT : StopTimer(); return 1;
|
||||
}
|
||||
note.wave.signal &= 0x7FFFFFFF;
|
||||
}
|
||||
return 1; // this point is never reached
|
||||
}
|
||||
|
||||
void DrawKeyF(char* str, unsigned char keyF)
|
||||
{
|
||||
dprint((keyF-1)*21 + 11 - 3*strlen(str), 55, "%s", str);
|
||||
//dreverse_area((keyF-1)*21 + 1 , 54, keyF * 21 - 1, 64);
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
#include "sound4calc.h"
|
||||
|
||||
static struct {
|
||||
int freq;
|
||||
int length_ms;
|
||||
} seq[] = {
|
||||
{ 440, 500 },
|
||||
{ 392, 500 },
|
||||
{ 349, 1000 },
|
||||
{ 262, 500 },
|
||||
{ 294, 500 },
|
||||
{ 262, 1000 },
|
||||
{ -1, -1 },
|
||||
};
|
||||
|
||||
struct Note note;
|
||||
|
||||
int frequency;
|
||||
|
||||
timer_t *timer = NULL;
|
||||
|
||||
/*
|
||||
CallSequence()
|
||||
make a little sound sequence
|
||||
*/
|
||||
/*void CallSequence(timer_t **timer)
|
||||
{
|
||||
static int seq_length = 0;
|
||||
static int seq_note = -1;
|
||||
|
||||
if(seq_length<=0)
|
||||
{
|
||||
seq_note++;
|
||||
|
||||
//Stop the timer
|
||||
if(seq[seq_note].freq < 0)
|
||||
{
|
||||
seq_length = 0;
|
||||
seq_note = -1;
|
||||
timer_stop(timer);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t constant = clock_setting(note.wave.length * seq[seq_note].freq, clock_Hz);
|
||||
*timer = htimer_setup(timer_user, constant, timer_Po_4, 0);
|
||||
timer_attach(*timer, CallSequence, timer);
|
||||
timer_start(*timer);
|
||||
|
||||
// update of the number of turn
|
||||
seq_length = note.wave.length * seq[seq_note].freq * seq[seq_note].length_ms / 1000;
|
||||
}
|
||||
|
||||
PlayNote();
|
||||
seq_length--;
|
||||
}*/
|
||||
|
||||
void Sequence()
|
||||
{
|
||||
static int seq_length = 0;
|
||||
static int seq_note = -1;
|
||||
|
||||
if(seq_length<=0)
|
||||
{
|
||||
seq_note++;
|
||||
|
||||
//Stop the timer
|
||||
if(seq[seq_note].freq < 0)
|
||||
{
|
||||
seq_length = 0;
|
||||
seq_note = -1;
|
||||
timer_stop(timer);
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t constant = clock_setting(note.wave.length * seq[seq_note].freq, clock_Hz);
|
||||
|
||||
timer = htimer_setup(timer_user, constant, timer_Po_4, 0);
|
||||
timer_attach(timer, Sequence, NULL);
|
||||
timer_start(timer);
|
||||
|
||||
// update of the number of turn
|
||||
seq_length = note.wave.length * seq[seq_note].freq * seq[seq_note].length_ms / 1000;
|
||||
}
|
||||
|
||||
PlayNote();
|
||||
seq_length--;
|
||||
}
|
||||
|
||||
/*
|
||||
CallNote();
|
||||
Create a single sound
|
||||
*/
|
||||
/*void CallNote()
|
||||
{
|
||||
//timer_t *timer = NULL;
|
||||
uint32_t duration = note.freq * note.wave.length;
|
||||
uint32_t constante = clock_setting(duration, clock_Hz);
|
||||
|
||||
timer = htimer_setup(timer_user, constante, timer_Po_4, 2 * duration);
|
||||
|
||||
timer_attach(timer, PlayNote, NULL);
|
||||
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
void Note()
|
||||
{
|
||||
|
||||
uint32_t duration = note.freq * note.wave.length;
|
||||
uint32_t constante = clock_setting(duration, clock_Hz);
|
||||
|
||||
timer = htimer_setup(timer_user, constante, timer_Po_4, 2 * duration);
|
||||
|
||||
timer_attach(timer, PlayNote, NULL);
|
||||
|
||||
timer_start(timer);
|
||||
}
|
||||
|
||||
/*
|
||||
StopTimer()
|
||||
Allow to stop the timer, it's to be independant with the main programm
|
||||
*/
|
||||
void StopTimer()
|
||||
{
|
||||
timer_stop(timer);
|
||||
}
|
||||
|
||||
/*
|
||||
PlayNote()
|
||||
allow to make different waveforms with bits
|
||||
*/
|
||||
void PlayNote()
|
||||
{
|
||||
static int x = 0;
|
||||
|
||||
PutPinState((note.wave.signal >> x) & 0x01);
|
||||
x = x + 1;
|
||||
if(x >= note.wave.length)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
PutPinState()
|
||||
put the pin at the level wanted
|
||||
|
||||
SH4 :
|
||||
state 0 : xxxx.x0xx
|
||||
state 1 : xxxx.x1xx
|
||||
|
||||
We can put 2 other state (on bit 3) but the sound volume is too high
|
||||
We could reduce the sound volume but we have to send
|
||||
a lot of bits to the port in order to reduce the volume. (Poupe solution)
|
||||
|
||||
SH3 :
|
||||
state 0 : xxxx.xxx0
|
||||
state 1 : xxxx.xxx1
|
||||
*/
|
||||
void PutPinState(char level)
|
||||
{
|
||||
level = !!level;
|
||||
|
||||
if(isSH3())
|
||||
{
|
||||
*(volatile unsigned char*)SH7337_SCPDR = (*(volatile unsigned char*)SH7337_SCPDR & 0xFE) | level ;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(volatile unsigned char*)SH7305_PJDR = (*(volatile unsigned char*)SH7305_PJDR & 0xFB) | (level << 0x2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
InitPorts();
|
||||
Ports initialisation
|
||||
Open all need ports to use SwitchPinState()
|
||||
*/
|
||||
void InitPorts()
|
||||
{
|
||||
if(isSH3())
|
||||
{
|
||||
// SCIF2 clock on (STBCR3.MSTP31)
|
||||
*(volatile unsigned char*)SH7337_STBCR3 &= ~0x02;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(volatile unsigned short*)SH7337_SCSCR2 &= ~0x0030;
|
||||
// SCIF2 clock off (STBCR3.MSTP31)
|
||||
*(volatile unsigned char*)SH7337_STBCR3 |= 0x02;
|
||||
// set bit 6 of port G to output mode
|
||||
*(volatile unsigned short*)SH7337_PGCR = ( *(volatile unsigned short*)SH7337_PGCR & ~0x3000 ) | 0x1000;
|
||||
// set bit 5 and 6 of port G
|
||||
*(volatile unsigned char*)SH7337_PGDR |= 0x60;
|
||||
// set port SC bit 0 to output
|
||||
*(volatile unsigned short*)SH7337_SCPCR = ( *(volatile unsigned short*)SH7337_SCPCR & ~0x0003 ) | 0x0001;
|
||||
}
|
||||
else
|
||||
{
|
||||
// SCIF2 clock on (MSTPCR0.MSTP007)
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080;
|
||||
// switch off SCSMR_2.TE and SCSMR_2.RE
|
||||
*(volatile unsigned short*)SH7305_SCSCR &= ~0x0030;
|
||||
// SCIF2 clock off (MSTPCR0.MSTP007)
|
||||
*(volatile unsigned int*)SH7305_MSTPCR0 |= 0x00000080;
|
||||
// set bit 3 of port U to output mode
|
||||
*(volatile unsigned short*)SH7305_PUCR = ( *(volatile unsigned short*)SH7305_PUCR & ~0x00C0 ) | 0x0040;
|
||||
// set bit 4 and 5 of port U
|
||||
*(volatile unsigned char*)SH7305_PUDR |= 0x0C;
|
||||
// set port J bit 2 to output
|
||||
*(unsigned short*)SH7305_PJCR = ( *(unsigned short*)SH7305_PJCR & ~0x0030 ) | 0x0010;
|
||||
|
||||
// set port J bit 3 to input
|
||||
*(unsigned short*)SH7305_PJCR= ( *(unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0080;
|
||||
|
||||
// set port J bit 3 to output mode
|
||||
//*(volatile unsigned short*)SH7305_PJCR = ( *(volatile unsigned short*)SH7305_PJCR & ~0x00C0 ) | 0x0040;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
.global _Keyboard_GetKey
|
||||
.type _Keyboard_GetKey, @function
|
||||
_Keyboard_GetKey:
|
||||
mov.l sc_addr, r2
|
||||
mov.l 1f, r0
|
||||
jmp @r2
|
||||
nop
|
||||
1: .long 0x247
|
||||
|
||||
.global _Keyboard_GetPressedKey
|
||||
.type _Keyboard_GetPressedKey, @function
|
||||
_Keyboard_GetPressedKey:
|
||||
mov.l sc_addr, r2
|
||||
mov.l 2f, r0
|
||||
jmp @r2
|
||||
nop
|
||||
2: .long 0x24A
|
||||
|
||||
.global _Keyboard_IsKeyPressed
|
||||
.type _Keyboard_IsKeyPressed, @function
|
||||
_Keyboard_IsKeyPressed:
|
||||
mov.l sc_addr, r2
|
||||
mov.l 3f, r0
|
||||
jmp @r2
|
||||
nop
|
||||
3: .long 0x24B
|
||||
|
||||
.global _Keyboard_KeyDown
|
||||
.type _Keyboard_KeyDown, @function
|
||||
_Keyboard_KeyDown:
|
||||
mov.l sc_addr, r2
|
||||
mov.l 4f, r0
|
||||
jmp @r2
|
||||
nop
|
||||
4: .long 0x24D
|
||||
|
||||
.global _Keyboard_ClrBuffer
|
||||
.type _Keyboard_ClrBuffer, @function
|
||||
_Keyboard_ClrBuffer:
|
||||
mov.l sc_addr, r2
|
||||
mov.l 5f, r0
|
||||
jmp @r2
|
||||
nop
|
||||
5: .long 0x241
|
||||
|
||||
sc_addr:
|
||||
.long 0x80010070
|
Loading…
Reference in New Issue