From 08fa96d243cf17ab561753bb66263170796b9be3 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sat, 14 Jan 2023 12:14:19 +0100 Subject: [PATCH 1/8] First version. --- README.md | 12 ++- microfx_src/Makefile | 27 ++++++ microfx_src/include/microfx/config.h.in | 6 ++ microfx_src/include/microfx/keycodes.h | 6 ++ microfx_src/include/microfx/microfx.h | 105 +++++++++++++++++++++++ microfx_src/src/fx98xx.ld | 33 +++++++ microfx_src/src/microfx.c | 89 +++++++++++++++++++ microfx_src/src/start.c | 21 +++++ microfx_src/src/syscall.S | 76 ++++++++++++++++ template/Makefile | 40 +++++++++ template/icon.png | Bin 0 -> 166 bytes template/lib/fx98xx.ld | 33 +++++++ template/lib/include/microfx/config.h.in | 6 ++ template/lib/include/microfx/keycodes.h | 6 ++ template/lib/include/microfx/microfx.h | 68 +++++++++++++++ template/lib/libMicrofx.a | Bin 0 -> 4744 bytes template/src/main.c | 6 ++ 17 files changed, 533 insertions(+), 1 deletion(-) create mode 100644 microfx_src/Makefile create mode 100644 microfx_src/include/microfx/config.h.in create mode 100644 microfx_src/include/microfx/keycodes.h create mode 100644 microfx_src/include/microfx/microfx.h create mode 100644 microfx_src/src/fx98xx.ld create mode 100644 microfx_src/src/microfx.c create mode 100644 microfx_src/src/start.c create mode 100644 microfx_src/src/syscall.S create mode 100644 template/Makefile create mode 100644 template/icon.png create mode 100644 template/lib/fx98xx.ld create mode 100644 template/lib/include/microfx/config.h.in create mode 100644 template/lib/include/microfx/keycodes.h create mode 100644 template/lib/include/microfx/microfx.h create mode 100644 template/lib/libMicrofx.a create mode 100644 template/src/main.c diff --git a/README.md b/README.md index 65e6796..da2df92 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # libMicrofx -Make very small add-ins. \ No newline at end of file +Make very small add-ins. + +With this library you can easly make very small add-ins, but they are not as fast as add-ins made using gint, so you should use gint to write more complex add-ins. This library only provides support of the fx98xx series of CASIO monochrome calculators that support add-ins. + +## Getting started + +An example add-in is in template. Start your project with this folder. Requires sh-elf-* of the fxsdk. + +The library is in microfx_src. If the library was updated, update you project by replacing lib with a new version compiled by typing `make` in microfx_src. + +You can read the header files in lib/include/microfx to see the available functions. \ No newline at end of file diff --git a/microfx_src/Makefile b/microfx_src/Makefile new file mode 100644 index 0000000..94387ab --- /dev/null +++ b/microfx_src/Makefile @@ -0,0 +1,27 @@ +CC = sh-elf-gcc +AR = sh-elf-ar + +OUT = libMicrofx.a +OUT_DIR = lib + +SRC = src/start.c src/syscall.S src/microfx.c +OBJ = $(SRC:src/%=build/%.o) + +BUILD = build + +all: $(OBJ) | $(OUT_DIR)/ + $(AR) rsv $(OUT_DIR)/$(OUT) $(OBJ) + cp --recursive include $(OUT_DIR)/ + cp src/fx98xx.ld $(OUT_DIR)/ + +$(BUILD)/%.o: src/% | $(BUILD)/ + $(CC) -c $< -o $@ -Os + +.PRECIOUS: %/ + +%/: + @ mkdir -p $@ + +clean: $(BUILD)/ | $(OUT_DIR)/ + rm $(OUT_DIR) --recursive + rm $(BUILD) --recursive diff --git a/microfx_src/include/microfx/config.h.in b/microfx_src/include/microfx/config.h.in new file mode 100644 index 0000000..a660533 --- /dev/null +++ b/microfx_src/include/microfx/config.h.in @@ -0,0 +1,6 @@ +#ifndef MICROFX_CONFIG_H +#define MICROFX_CONFIG_H + +#define EX_VERSION "@libMicrofx_VERSION@" + +#endif diff --git a/microfx_src/include/microfx/keycodes.h b/microfx_src/include/microfx/keycodes.h new file mode 100644 index 0000000..b7182cd --- /dev/null +++ b/microfx_src/include/microfx/keycodes.h @@ -0,0 +1,6 @@ +#ifndef KEYCODES_H +#define KEYCODES_H + +#define KCEXIT 47 + +#endif diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h new file mode 100644 index 0000000..87b0a4e --- /dev/null +++ b/microfx_src/include/microfx/microfx.h @@ -0,0 +1,105 @@ +#ifndef MICROFX_H +#define MICROFX_H + +#include "keycodes.h" + +/******* DISPLAY *******/ + +enum {SWHITE = 0, SBLACK}; + +/* void sclear(void); + +Clears the VRAM in white. +*/ + +void sclear(void); + +/* void supdate(void); + +Put the VRAM on the screen. +*/ + +void supdate(void); + +/* void srect(int x1, int y1, int x2, int y2); + +Draws a white rectangle with a black border of one pixel from (x1, y1) to (x2, y2) +in the VRAM. +*/ + +void srect(int x1, int y1, int x2, int y2); + +/* void spixel(int x, int y, int color); + +Set the pixel at (x, y) in the color color in the VRAM. +The available colors are SWHITE or SBLACK. +*/ + +void spixel(int x, int y, int color); + +/* void stext(int x, int y, char *text); + +Puts the text text at (x, y) on the screen using casio default font. +*/ + +void stext(int x, int y, char *text); + +/* void slocate(int x, int y, char *text); + +Works like the Locate function of CASIO Basic. +*/ + +void slocate(int x, int y, char *text); + +/******* KEYBOARD *******/ + +enum {KFAST = 0, KLONG}; + +/* int kisdown(void); + +Returns a positive int if a key is down. +Returns 0 if there is no key down. +*/ +int kisdown(void); + +/* int kcheck(int key, int type); + +/!\ Not working /!\ + +Checks if the key key is down. + +int key if 0x(1 byte for the column)(1 byte for the row). +Based on the syscalls 0x24B/0x24C. + +Type is KFAST or KLONG. +KFAST : Syscall 0x24B is used. +KLONG : Syscall 0x24C is used. +*/ +int kcheck(int key, int type); + +/* int kgetkey(void); + +Works like the Getkey function of CASIO Basic. +Returns the pressed key. +*/ +int kgetkey(void); + +/******* TOOLS *******/ + +/* void itoa(int n, char *buffer); + +Put a string of the int n in buffer. +*/ + +void itoa(int n, char *buffer); + +/******* TIME *******/ + +/* void tsleep_ms(int ms); + +Wait ms miliseconds. +*/ +void tsleep_ms(int ms); + +#endif + diff --git a/microfx_src/src/fx98xx.ld b/microfx_src/src/fx98xx.ld new file mode 100644 index 0000000..8a5279b --- /dev/null +++ b/microfx_src/src/fx98xx.ld @@ -0,0 +1,33 @@ +ENTRY(_start) + +MEMORY +{ + rom (rx) : ORIGIN = 0x00300200, LENGTH = 512K + ram (rw) : ORIGIN = 0x08100200, LENGTH = 20K +} + +SECTIONS +{ + .text : { + *(.pretext) + *(.text) + } > rom + .rodata : { + *(.rodata) + *(.rodata.str1.4) + _romdata_start = . ; + } > rom + .bss : { + _start_bss = . ; + _bssdatasize = . ; + LONG(0); + *(.bss) + *(COMMON) + _end_bss = . ; + } > ram + .data : AT(_romdata_start) { + _start_data = . ; + *(.data) + _end_data = . ; + } > ram +} diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c new file mode 100644 index 0000000..4297c3e --- /dev/null +++ b/microfx_src/src/microfx.c @@ -0,0 +1,89 @@ +#include "../include/microfx/microfx.h" + +/******* DISPLAY *******/ + +/* Syscalls */ + +void _Bdisp_PutDisp_DD(void); +void _Bdisp_DrawRectangle(int x1, int y1, int x2, int y2); +void _Bdisp_AllClr_VRAM(void); +void _Bdisp_SetPoint_VRAM(int x, int y, int color); +void _PrintXY(int x, int y, unsigned char *text, int type); +void _locate(int x, int y); +void _Print(unsigned char *text); + +/* Microfx */ + +void sclear() { + _Bdisp_AllClr_VRAM(); +} + +void supdate() { + _Bdisp_PutDisp_DD(); +} + +void spixel(int x, int y, int color) { + _Bdisp_SetPoint_VRAM(x, y, color); +} + +void srect(int x1, int y1, int x2, int y2) { + _Bdisp_DrawRectangle(x1, y1, x2, y2); +} + +void stext(int x, int y, char *text) { + _PrintXY(x, y, (unsigned char*)text, 0); +} + +void slocate(int x, int y, char *text) { + _locate(x, y); + _Print((unsigned char*)text); +} + +/******* KEYBOARD *******/ + +/* Syscalls */ + +short _Keyboard_GetPressedTime(void); +int _Keyboard_IsKeyPressed_fast(short *matrixcode); +int _Keyboard_IsKeyPressed(short *matrixcode); +int _Keyboard_KeyDown(void); +int _Keyboard_PRGM_GetKey(unsigned char* buffer); + +/* Microfx */ + +int kisdown(void) { + return _Keyboard_KeyDown(); +} + +int kcheck(int key, int type) { + short skey = (short)key; + switch(type){ + case KFAST: + return _Keyboard_IsKeyPressed_fast(&skey); + break; + default: + return _Keyboard_IsKeyPressed(&skey); + break; + } +} + +int kgetkey(void){ + unsigned char buffer[12]; + _Keyboard_PRGM_GetKey(buffer); + return (buffer[1] & 0x0F) * 10 + ((buffer[2] & 0xF0 ) >> 4); +} + +/******* Time *******/ + +/* Syscalls */ + +void _Sleep(int delay_ms); +int _RTC_GetTicks(void); +int _RTC_Elapsed_ms(int start_value, int duration_in_ms); + +/* Microfx */ + +void tsleep_ms(int ms) { + _Sleep(ms); +} + diff --git a/microfx_src/src/start.c b/microfx_src/src/start.c new file mode 100644 index 0000000..665955d --- /dev/null +++ b/microfx_src/src/start.c @@ -0,0 +1,21 @@ +extern char start_bss, end_bss; +extern char start_data, end_data; +extern char romdata_start; +extern int main(void); + +__attribute__((section(".pretext"))) + +int start(int isappli, int optnum) { + int i; + char *bss_startptr = &start_bss; + for(i=0;i<&end_bss - &start_bss;i++){ + bss_startptr[i] = 0; + } + char *data_startptr = &start_data; + char *romdataptr = &romdata_start; + for(i=0;i<&end_data - &start_data;i++){ + data_startptr[i] = romdataptr[i]; + } + return main(); +} + diff --git a/microfx_src/src/syscall.S b/microfx_src/src/syscall.S new file mode 100644 index 0000000..703c5a0 --- /dev/null +++ b/microfx_src/src/syscall.S @@ -0,0 +1,76 @@ +.text + +.global __Bdisp_PutDisp_DD +.global __Bdisp_DrawRectangle +.global __Bdisp_AllClr_VRAM +.global __Bdisp_SetPoint_VRAM +.global __Bdisp_GetPoint_VRAM +.global __PrintXY +.global __locate +.global __Print +/* Keyboard */ +.global __Keyboard_GetPressedTime +.global __Keyboard_IsKeyPressed +.global __Keyboard_IsKeyPressed_fast +.global __Keyboard_KeyDown +.global __Keyboard_PRGM_GetKey +/* Time */ +.global __Sleep +.global __RTC_GetTicks +.global __RTC_Elapsed_ms +/* Files */ +/* Tools */ +.global _itoa + +#define syscall(syscall_number) \ + mov.l 1f, r0 ;\ + mov.l do_syscall, r2 ;\ + jmp @r2 ;\ + nop ;\ +.align 4 ;\ +1: .long syscall_number + +/* Display */ +__Bdisp_PutDisp_DD: + syscall(0x028) +__Bdisp_DrawRectangle: + syscall(0x0763) +__Bdisp_AllClr_VRAM: + syscall(0x143) +__Bdisp_SetPoint_VRAM: + syscall(0x146) +__Bdisp_GetPoint_VRAM: + syscall(0x149) +__PrintXY: + syscall(0x150) +__locate: + syscall(0x807) +__Print: + syscall(0x808) +/* Keyboard */ +__Keyboard_GetPressedTime: + syscall(0x249) +__Keyboard_IsKeyPressed: + syscall(0x24C) +__Keyboard_IsKeyPressed_fast: + syscall(0x24B) +__Keyboard_KeyDown: + syscall(0x24D) +__Keyboard_PRGM_GetKey: + syscall(0x6C4) +/* Time */ +__Sleep: + syscall(0x0420) +__RTC_GetTicks: + syscall(0x03B) +__RTC_Elapsed_ms: + syscall(0x03C) +/* Files */ +/* Nothing here ... */ +/* Tools */ +_itoa: + syscall(0x541) +/* Menu */ +/* Nothing here ... */ + +do_syscall: .long 0x80010070 diff --git a/template/Makefile b/template/Makefile new file mode 100644 index 0000000..a6698b8 --- /dev/null +++ b/template/Makefile @@ -0,0 +1,40 @@ +NAME = Template + +ELF = $(NAME).elf +BIN = $(NAME).bin + +CC = sh-elf-gcc + +SRC = src/main.c +OBJ = $(SRC:src/%=build/%.o) + +ICON = icon.png + +LIB = lib + +BUILD = build + +VERSION = v.1.0 + +all: $(BIN) + fxgxa --g1a -n $(NAME) -i $(ICON) --version="$(VERSION)" -o $(NAME).g1a build/$(BIN) + sh-elf-objdump -h $(BUILD)/$(ELF) + +$(BIN): $(ELF) + sh-elf-objcopy -O binary build/$(ELF) build/$(BIN) -R .bss + +$(ELF): $(OBJ) | $(LIB)/ + $(CC) $< lib/libMicrofx.a -o $(BUILD)/$@ -nostdlib -T lib/fx98xx.ld -ffreestanding -mb -m3 -Os -Wa,--dsp + +$(BUILD)/%.o: src/% | $(BUILD)/ + $(CC) -c $< -o $@ -Os -Ilib/include/ + +.PRECIOUS: %/ + +%/: + @ mkdir -p $@ + +clean: $(BUILD) + rm $(BUILD) --recursive + rm $(NAME).g1a + diff --git a/template/icon.png b/template/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d15353bb85beba720e11955b3d23573faeb50c94 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^azHH1!2%?8mzRDAQn{Wkjv*GkPlKZQ4k&Oe?*6{N z=zF5NV7ggheKylaM^`Qd-Ckw?qkNGw6^r|yt&QeQkw^{KSj**Td#J42qmDmf{kjw1 zCmm1F7dSuD@`~5oBDXYw74QD?ujBvZ{K<9xW{vEJ(zSg*ly|zYh8HlkdyAP)42hQo PTFl_->gTe~DWM4f*=RZU literal 0 HcmV?d00001 diff --git a/template/lib/fx98xx.ld b/template/lib/fx98xx.ld new file mode 100644 index 0000000..8a5279b --- /dev/null +++ b/template/lib/fx98xx.ld @@ -0,0 +1,33 @@ +ENTRY(_start) + +MEMORY +{ + rom (rx) : ORIGIN = 0x00300200, LENGTH = 512K + ram (rw) : ORIGIN = 0x08100200, LENGTH = 20K +} + +SECTIONS +{ + .text : { + *(.pretext) + *(.text) + } > rom + .rodata : { + *(.rodata) + *(.rodata.str1.4) + _romdata_start = . ; + } > rom + .bss : { + _start_bss = . ; + _bssdatasize = . ; + LONG(0); + *(.bss) + *(COMMON) + _end_bss = . ; + } > ram + .data : AT(_romdata_start) { + _start_data = . ; + *(.data) + _end_data = . ; + } > ram +} diff --git a/template/lib/include/microfx/config.h.in b/template/lib/include/microfx/config.h.in new file mode 100644 index 0000000..a660533 --- /dev/null +++ b/template/lib/include/microfx/config.h.in @@ -0,0 +1,6 @@ +#ifndef MICROFX_CONFIG_H +#define MICROFX_CONFIG_H + +#define EX_VERSION "@libMicrofx_VERSION@" + +#endif diff --git a/template/lib/include/microfx/keycodes.h b/template/lib/include/microfx/keycodes.h new file mode 100644 index 0000000..b7182cd --- /dev/null +++ b/template/lib/include/microfx/keycodes.h @@ -0,0 +1,6 @@ +#ifndef KEYCODES_H +#define KEYCODES_H + +#define KCEXIT 47 + +#endif diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h new file mode 100644 index 0000000..7186084 --- /dev/null +++ b/template/lib/include/microfx/microfx.h @@ -0,0 +1,68 @@ +#ifndef MICROFX_H +#define MICROFX_H + +#include "keycodes.h" + +/******* DISPLAY *******/ + +enum {SWHITE = 0, SBLACK}; + +/* void sclear(void); + +Clears the screen in white. +*/ + +void sclear(void); + +/* + +*/ + +void supdate(void); + +/* + +*/ + +void srect(int x1, int y1, int x2, int y2); + +/* + +*/ + +void spixel(int x, int y, int color); + +/* + +*/ + +void stext(int x, int y, char *text); + +/* + +*/ + +void slocate(int x, int y, char *text); + +/******* KEYBOARD *******/ + +enum {KFAST = 0, KLONG}; + +int kisdown(void); +int kcheck(int key, int type); +int kgetkey(void); + +/******* TOOLS *******/ + +/* + +*/ + +void itoa(int n, char *buffer); + +/******* TIME *******/ + +void tsleep_ms(int ms); + +#endif + diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a new file mode 100644 index 0000000000000000000000000000000000000000..18dfd8ba618cc2cc20b453851ef668426ce301d9 GIT binary patch literal 4744 zcmeHKPiz!r6o0eb(r#OADUGP0EES;&ZntbH2t;?;LM4E0N;R06><+V2cGKPNIx_^g zSWqM+YT&?ugBKGI>V?F3^gs+InrKoAQEy5@g7Ky$dNI-8`{w&*zD~h5>e1J}{oe1r zH{YN6-uLEv>vx-uRer9mKe>kPj5wh-fWQEK9WF z(!b}94x**G;CiOxQK7J>RB;=HvE$w_x5LAMYS=MPjN6uHP9Lko#_E-6Z=rT1q8)SKa^w{}Rjpg5$6X2)+5`5fqjl3M75Ev)c3rzPQK_*FkC+|t*geyM-K5YFhPB|YTFI8;}dySPE@QZSHitjvw?XOYEV?X zx=97ss@kT5_IRTt=I=HtC+#W}4qg))&pyeGTHaK}Es4>mtg>xQQDN$s?M?Bxp3CEM z*Ce(fWu@vefb_T-NT(4r!SB$}AfrJUIK{S^y$AOhF$3Wv$)KkpX^Pl+;1~@Gdmpt? z;zrLMn(LX&4E34TzLgi^uNmKVXNnhMxvpDAuIugY8=Z4qlbP?jH2Z^^y?M4hyO|Qb zjVnJnhUN99uiSNl@lK0j!k++-`E>aL)ILf4SOjm1;7kPXS%BrnQo)`s6^^=yBBAj` z)**&CsQ4I4*{Ro9sg7pNtW0y46GW}*-5eoGDEU=QE)umVeTk@D$z|jMC08|lgXjTY zpK?#tJo6}}T+i{_vXVqRr^Gx{yn>WtSItzzv3-M8uhr~nPpx`c?HYLTxV#@seq{PG z|EjsJm$KT|`}y&nw1SuN8<73!DOhChe=frfv8{Hcb2 zg?uf<2A_qS8s?b4t>Gl(yBfyXHsS#;)eAEI@ge{JaJ8AZ{AKWt-)b?=e_-mrGFVbtC6zS{Rlq-|^Q>*W>-? zMtgJZW$SuV>CMrNxy|L@)M920zT=5^L!-UL{LCNb{F#-d`6rLeHot3lvDtXGof0$g z(T#-G_v2^#&&{@t_Ricb&u809^JmZ8YWu3Q*pYnv>>I|T#g1$un@F#n>ENgQvGh69 ze}6}mvE;7`K;#IuMqrMEc8NQ1`QtqdzTq-3Io>$GDtlV`i{OEr2S2RY4@B%H@CMCZ zj@VxZ<~~*bZ$<1EfOmt}%K2T6*x!%fkAQJU4Ep;dV*diT1l}V1`zB)lc_B9V3|$1L zeSbr}FS&lB7q+WlIe+6B$b!WC3l0SCxw3eYDS1H|85C6a$k(dIlBP(hDJw5&j8v?$ z9`mbAEw>eurqal5szMM9E(gt?}i*`8bG@ zU{Rs)Pf7#A+Qb>u@91Acr%0V&{-&^;^$l@8pB$t79M6|+tlKED%mZp!(E6klTLAIC zgKv*C2aWQ>Jwx=L_ANpk + +int main(void) { + stext(1, 1, "A Microfx Add-in !"); + return 1; +} From beb17387046f3ed339bbcb018d35d7ae788bb5f9 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sat, 14 Jan 2023 12:15:39 +0100 Subject: [PATCH 2/8] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da2df92..7ed7723 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,9 @@ An example add-in is in template. Start your project with this folder. Requires The library is in microfx_src. If the library was updated, update you project by replacing lib with a new version compiled by typing `make` in microfx_src. -You can read the header files in lib/include/microfx to see the available functions. \ No newline at end of file +You can read the header files in lib/include/microfx to see the available functions. + + + + +Big thanks to Lephenixnoir for his help ! \ No newline at end of file From 2fe7d3e6a2a1baf780359b01eeb16d7137908d92 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sat, 14 Jan 2023 17:40:01 +0100 Subject: [PATCH 3/8] Updated lib in template/ --- template/lib/include/microfx/microfx.h | 51 +++++++++++++++++++++---- template/lib/libMicrofx.a | Bin 4744 -> 4744 bytes 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index 7186084..87b0a4e 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -9,37 +9,44 @@ enum {SWHITE = 0, SBLACK}; /* void sclear(void); -Clears the screen in white. +Clears the VRAM in white. */ void sclear(void); -/* +/* void supdate(void); +Put the VRAM on the screen. */ void supdate(void); -/* +/* void srect(int x1, int y1, int x2, int y2); +Draws a white rectangle with a black border of one pixel from (x1, y1) to (x2, y2) +in the VRAM. */ void srect(int x1, int y1, int x2, int y2); -/* +/* void spixel(int x, int y, int color); +Set the pixel at (x, y) in the color color in the VRAM. +The available colors are SWHITE or SBLACK. */ void spixel(int x, int y, int color); -/* +/* void stext(int x, int y, char *text); +Puts the text text at (x, y) on the screen using casio default font. */ void stext(int x, int y, char *text); -/* +/* void slocate(int x, int y, char *text); +Works like the Locate function of CASIO Basic. */ void slocate(int x, int y, char *text); @@ -48,20 +55,50 @@ void slocate(int x, int y, char *text); enum {KFAST = 0, KLONG}; +/* int kisdown(void); + +Returns a positive int if a key is down. +Returns 0 if there is no key down. +*/ int kisdown(void); + +/* int kcheck(int key, int type); + +/!\ Not working /!\ + +Checks if the key key is down. + +int key if 0x(1 byte for the column)(1 byte for the row). +Based on the syscalls 0x24B/0x24C. + +Type is KFAST or KLONG. +KFAST : Syscall 0x24B is used. +KLONG : Syscall 0x24C is used. +*/ int kcheck(int key, int type); + +/* int kgetkey(void); + +Works like the Getkey function of CASIO Basic. +Returns the pressed key. +*/ int kgetkey(void); /******* TOOLS *******/ -/* +/* void itoa(int n, char *buffer); +Put a string of the int n in buffer. */ void itoa(int n, char *buffer); /******* TIME *******/ +/* void tsleep_ms(int ms); + +Wait ms miliseconds. +*/ void tsleep_ms(int ms); #endif diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 18dfd8ba618cc2cc20b453851ef668426ce301d9..b8bdc351c578a3583ebbb90df480a6897aae125d 100644 GIT binary patch delta 61 wcmeBB?NFT{!)9)1Vq|W-QOSr2%ACB8O?-19lQ|2Nzj+;75i7EsEsr-F0Ng4MP5=M^ delta 61 wcmeBB?NFT{!)9h_Y-DP*QOSr2%ACB8O?-19lQ|2Nzj+;75i7EsEsr-F0Nv*gS^xk5 From f8e00a91d4b0eb82f95c7c58aa72fc69617ae51b Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 15 Jan 2023 17:03:10 +0100 Subject: [PATCH 4/8] Working kcheck --- README.md | 5 +- microfx_src/include/microfx/keycodes.h | 59 +++++++++++++++++++++++- microfx_src/include/microfx/microfx.h | 17 ++----- microfx_src/src/microfx.c | 31 ++++++++----- template/lib/include/microfx/keycodes.h | 59 +++++++++++++++++++++++- template/lib/include/microfx/microfx.h | 17 ++----- template/lib/libMicrofx.a | Bin 4744 -> 4672 bytes 7 files changed, 146 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 7ed7723..1ba40a4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,4 @@ The library is in microfx_src. If the library was updated, update you project by You can read the header files in lib/include/microfx to see the available functions. - - - -Big thanks to Lephenixnoir for his help ! \ No newline at end of file +Thanks to Lephenixnoir and Yatis for their help ! \ No newline at end of file diff --git a/microfx_src/include/microfx/keycodes.h b/microfx_src/include/microfx/keycodes.h index b7182cd..80fc942 100644 --- a/microfx_src/include/microfx/keycodes.h +++ b/microfx_src/include/microfx/keycodes.h @@ -1,6 +1,63 @@ #ifndef KEYCODES_H #define KEYCODES_H -#define KCEXIT 47 +#define KCF1 79 +#define KCF2 69 +#define KCF3 59 +#define KCF4 49 +#define KCF5 39 +#define KCF6 29 + +#define KCSHIFT 78 +#define KCOPTN 68 +#define KCVARS 58 +#define KCMENU 48 +#define KCLEFT 38 +#define KCUP 28 + +#define KCALPHA 77 +#define KCX2 67 +#define KCPOW 57 +#define KCEXIT 47 +#define KCDOWN 37 +#define KCRIGHT 27 + +#define KCXOT 76 +#define KCLOG 66 +#define KCLN 56 +#define KCSIN 46 +#define KCCOS 36 +#define KCTAN 26 + +#define KCFRAC 75 +#define KCSD 65 +#define KCLPAR 55 +#define KCRPAR 45 +#define KCCOMMA 35 +#define KCARROW 25 + +#define KC7 74 +#define KC8 64 +#define KC9 54 +#define KCDEL 44 +#define KCAC 10 + +#define KC4 73 +#define KC5 63 +#define KC6 53 +#define KCMULTI 43 +#define KCDIV 33 + +#define KC1 72 +#define KC2 62 +#define KC3 52 +#define KCPLUS 42 +#define KCMIN 32 + +#define KC0 71 +#define KCDOT 61 +#define KCEXP 51 +#define KCNEGA 41 +#define KCEXE 31 #endif diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index 87b0a4e..82cf266 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -39,7 +39,8 @@ void spixel(int x, int y, int color); /* void stext(int x, int y, char *text); -Puts the text text at (x, y) on the screen using casio default font. +Puts the text text at (x, y) on the screen using casio +default font. */ void stext(int x, int y, char *text); @@ -53,8 +54,6 @@ void slocate(int x, int y, char *text); /******* KEYBOARD *******/ -enum {KFAST = 0, KLONG}; - /* int kisdown(void); Returns a positive int if a key is down. @@ -66,16 +65,10 @@ int kisdown(void); /!\ Not working /!\ -Checks if the key key is down. - -int key if 0x(1 byte for the column)(1 byte for the row). -Based on the syscalls 0x24B/0x24C. - -Type is KFAST or KLONG. -KFAST : Syscall 0x24B is used. -KLONG : Syscall 0x24C is used. +Checks if the key key is down or not : returns a positive +int if the key is down, or 0 if he's not down. */ -int kcheck(int key, int type); +int kcheck(int key); /* int kgetkey(void); diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c index 4297c3e..6f2c8b3 100644 --- a/microfx_src/src/microfx.c +++ b/microfx_src/src/microfx.c @@ -44,8 +44,6 @@ void slocate(int x, int y, char *text) { /* Syscalls */ short _Keyboard_GetPressedTime(void); -int _Keyboard_IsKeyPressed_fast(short *matrixcode); -int _Keyboard_IsKeyPressed(short *matrixcode); int _Keyboard_KeyDown(void); int _Keyboard_PRGM_GetKey(unsigned char* buffer); @@ -55,16 +53,25 @@ int kisdown(void) { return _Keyboard_KeyDown(); } -int kcheck(int key, int type) { - short skey = (short)key; - switch(type){ - case KFAST: - return _Keyboard_IsKeyPressed_fast(&skey); - break; - default: - return _Keyboard_IsKeyPressed(&skey); - break; - } +int kcheck(int key) { + /* TODO : Compatibility with older calcs. */ + /* Get the column and the row of the key. */ + int row = key%10; + int column = key/10 - 1; + /* The bit that I will read in the KIUDATA + register. */ + int column_pos = column + 8 * (row & 1); + /* row_data will contain the data of the + KIUDATA register that we need. + keyboard_register contains the address of + KIUDATA0. */ + unsigned short *keyboard_register = (unsigned short*)0xA44B0000; + unsigned short row_data; + /* Get KIUDATAx where x is row / 2 because two rows + are stored in each KIUDATA register. */ + row_data = keyboard_register[row/2]; + /* Get the bit located at column. */ + return (row_data >> column_pos) & 1; } int kgetkey(void){ diff --git a/template/lib/include/microfx/keycodes.h b/template/lib/include/microfx/keycodes.h index b7182cd..80fc942 100644 --- a/template/lib/include/microfx/keycodes.h +++ b/template/lib/include/microfx/keycodes.h @@ -1,6 +1,63 @@ #ifndef KEYCODES_H #define KEYCODES_H -#define KCEXIT 47 +#define KCF1 79 +#define KCF2 69 +#define KCF3 59 +#define KCF4 49 +#define KCF5 39 +#define KCF6 29 + +#define KCSHIFT 78 +#define KCOPTN 68 +#define KCVARS 58 +#define KCMENU 48 +#define KCLEFT 38 +#define KCUP 28 + +#define KCALPHA 77 +#define KCX2 67 +#define KCPOW 57 +#define KCEXIT 47 +#define KCDOWN 37 +#define KCRIGHT 27 + +#define KCXOT 76 +#define KCLOG 66 +#define KCLN 56 +#define KCSIN 46 +#define KCCOS 36 +#define KCTAN 26 + +#define KCFRAC 75 +#define KCSD 65 +#define KCLPAR 55 +#define KCRPAR 45 +#define KCCOMMA 35 +#define KCARROW 25 + +#define KC7 74 +#define KC8 64 +#define KC9 54 +#define KCDEL 44 +#define KCAC 10 + +#define KC4 73 +#define KC5 63 +#define KC6 53 +#define KCMULTI 43 +#define KCDIV 33 + +#define KC1 72 +#define KC2 62 +#define KC3 52 +#define KCPLUS 42 +#define KCMIN 32 + +#define KC0 71 +#define KCDOT 61 +#define KCEXP 51 +#define KCNEGA 41 +#define KCEXE 31 #endif diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index 87b0a4e..82cf266 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -39,7 +39,8 @@ void spixel(int x, int y, int color); /* void stext(int x, int y, char *text); -Puts the text text at (x, y) on the screen using casio default font. +Puts the text text at (x, y) on the screen using casio +default font. */ void stext(int x, int y, char *text); @@ -53,8 +54,6 @@ void slocate(int x, int y, char *text); /******* KEYBOARD *******/ -enum {KFAST = 0, KLONG}; - /* int kisdown(void); Returns a positive int if a key is down. @@ -66,16 +65,10 @@ int kisdown(void); /!\ Not working /!\ -Checks if the key key is down. - -int key if 0x(1 byte for the column)(1 byte for the row). -Based on the syscalls 0x24B/0x24C. - -Type is KFAST or KLONG. -KFAST : Syscall 0x24B is used. -KLONG : Syscall 0x24C is used. +Checks if the key key is down or not : returns a positive +int if the key is down, or 0 if he's not down. */ -int kcheck(int key, int type); +int kcheck(int key); /* int kgetkey(void); diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index b8bdc351c578a3583ebbb90df480a6897aae125d..6004ab9cf232a69efcaf29f9a0a91344c267bc5a 100644 GIT binary patch delta 352 zcmeBBJ)kl{mc`P-$Y`UY2@@-jVQ4gY9h>;(LM96q2zT>3wqjPWlF4h?B$!Q&EG9ef zXtPdWU|LdxCWMt%WRCM5QR5ai*b}#sEAeW?@$ep0k!1rh|FFaTWx zQOxjxfkATeeSrqXFOw4lmDrf?0L3dNcL*voYD{)u6&KV2@;QK*8KNF2I)PQ5(*Vx< kBdE@519aGe$r?h+tU%q243h(dltn{;Dy$%?z$Dl{0ADXe8vp7VpfCP6IkUr4Zvmry)c=BO^uCF1n8RslOG5wvt9wROee>%DT%Sn N0jjZrr~{K=n*jDXJTd?P From fef708ab6ce4be937074eabd543e28db57feaa2b Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 15 Jan 2023 20:49:48 +0100 Subject: [PATCH 5/8] Added some functions. You can now make REAL games with this lib ! --- microfx_src/include/microfx/microfx.h | 25 +++++++++++++++++++++++++ microfx_src/src/microfx.c | 18 ++++++++++++++++++ microfx_src/src/syscall.S | 6 ++++++ template/lib/include/microfx/microfx.h | 25 +++++++++++++++++++++++++ template/lib/libMicrofx.a | Bin 4672 -> 5188 bytes 5 files changed, 74 insertions(+) diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index 82cf266..ccb4ffb 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -29,6 +29,15 @@ in the VRAM. void srect(int x1, int y1, int x2, int y2); +/* void sline(int x1, int y1, int x2, int y2, int color); + +Draws a line with a width of one pixel from (x1, y1) to (x2, y2) in the VRAM of +color color. +The available colors are SWHITE or SBLACK. +*/ + +void sline(int x1, int y1, int x2, int y2, int color); + /* void spixel(int x, int y, int color); Set the pixel at (x, y) in the color color in the VRAM. @@ -94,5 +103,21 @@ Wait ms miliseconds. */ void tsleep_ms(int ms); +/* void tgetticks(void); + +Get 1/128 seconds ticks since midnight. +*/ + +void tgetticks(void); + +/* int tiselapsed(int start, int ms); + +Check if ms where elapsed since start (ticks that you can +get with tgetticks). +Returns 1 if ms is elapsed and 0 if it is not. +*/ + +int tiselapsed(int start, int ms); + #endif diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c index 6f2c8b3..4c3bb6e 100644 --- a/microfx_src/src/microfx.c +++ b/microfx_src/src/microfx.c @@ -11,6 +11,8 @@ void _Bdisp_SetPoint_VRAM(int x, int y, int color); void _PrintXY(int x, int y, unsigned char *text, int type); void _locate(int x, int y); void _Print(unsigned char *text); +void _Bdisp_DrawLineVRAM(int x1, int y1, int x2, int y2); +void _Bdisp_ClearLineVRAM(int x1, int y1, int x2, int y2); /* Microfx */ @@ -30,6 +32,14 @@ void srect(int x1, int y1, int x2, int y2) { _Bdisp_DrawRectangle(x1, y1, x2, y2); } +void sline(int x1, int y1, int x2, int y2, int color) { + if(color){ + _Bdisp_DrawLineVRAM(x1, y1, x2, y2); + }else{ + _Bdisp_ClearLineVRAM(x1, y1, x2, y2); + } +} + void stext(int x, int y, char *text) { _PrintXY(x, y, (unsigned char*)text, 0); } @@ -94,3 +104,11 @@ void tsleep_ms(int ms) { _Sleep(ms); } +void tgetticks(void) { + _RTC_GetTicks(); +} + +int tiselapsed(int start, int ms) { + return _RTC_Elapsed_ms(start, ms); +} + diff --git a/microfx_src/src/syscall.S b/microfx_src/src/syscall.S index 703c5a0..cd620d4 100644 --- a/microfx_src/src/syscall.S +++ b/microfx_src/src/syscall.S @@ -8,6 +8,8 @@ .global __PrintXY .global __locate .global __Print +.global __Bdisp_DrawLineVRAM +.global __Bdisp_ClearLineVRAM /* Keyboard */ .global __Keyboard_GetPressedTime .global __Keyboard_IsKeyPressed @@ -47,6 +49,10 @@ __locate: syscall(0x807) __Print: syscall(0x808) +__Bdisp_DrawLineVRAM: + syscall(0x030) +__Bdisp_ClearLineVRAM: + syscall(0x031) /* Keyboard */ __Keyboard_GetPressedTime: syscall(0x249) diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index 82cf266..ccb4ffb 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -29,6 +29,15 @@ in the VRAM. void srect(int x1, int y1, int x2, int y2); +/* void sline(int x1, int y1, int x2, int y2, int color); + +Draws a line with a width of one pixel from (x1, y1) to (x2, y2) in the VRAM of +color color. +The available colors are SWHITE or SBLACK. +*/ + +void sline(int x1, int y1, int x2, int y2, int color); + /* void spixel(int x, int y, int color); Set the pixel at (x, y) in the color color in the VRAM. @@ -94,5 +103,21 @@ Wait ms miliseconds. */ void tsleep_ms(int ms); +/* void tgetticks(void); + +Get 1/128 seconds ticks since midnight. +*/ + +void tgetticks(void); + +/* int tiselapsed(int start, int ms); + +Check if ms where elapsed since start (ticks that you can +get with tgetticks). +Returns 1 if ms is elapsed and 0 if it is not. +*/ + +int tiselapsed(int start, int ms); + #endif diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 6004ab9cf232a69efcaf29f9a0a91344c267bc5a..48126ab4704f646e628baaa9913afbe2f38d129e 100644 GIT binary patch delta 1458 zcmb`GUr1AN6vxl+ZoAvuEvHO3!rXOA4h6m1o!Vcgvn(uPVYq>#2!3I4P zWMCYhte2?3hlrpcp_c+5LVB21PrU^85J3g5y+zJj(C(r_fWcWzNJinZ(q&G-#PbI-ZQB z((!5R7wSZw301+zqW9@Vq1S3+K~=F|QnCzGN&`R;>>w6YvCCUFMh4r#S^CkKys$A` z@_~JdI8tU7A?`QvVd8xzK1$qc;?cZtaASAb;jq(yP7^zb+sh0JajS{DaM8ZWRGf3% z$v&iWFY>dy0T_K=kUcQ*d(zKL{FU@-nHj$gR5W8g+ez}1iFulSn0P;JV=Z$%J4Oyq z*}*1=TkwW+Y0IU(@2_Im=&EC3R9($1hhdu+FSy*Ka;{cejuy<}BUeDQ&^BxmC&YkY zoy1?RV4<*~5HGZ)k189M+63DhOiE!-?0b`MUAPJB!hl{)nv2WQYfqkqOAbS$Y&nV7 zEi!Iyn`b^uZTDuE_+R3U^2*y2vLj?tEuDeB&&dj{7=J|&C2J_g*Ys#<{@V)vK%62o z)+^+kkI~o5!cWpy$)d#t|B%j;DLOL;=|a;dFu#5-V?owd5$~qBM84vN>_A0)gyOzZ z+yZPIebw`w{JE80DEZpw`f50X&9I0@N9L4!~>Z-vB#`nkTEl&~#ZF4J`x6y6#9{p2@@}p##^f zwYcIwCD1MQ)dWQAXFA6+hHIKBBm8Dwsd1B9u=$+|KO&`V93A2=kzu-#whQ2jXo delta 937 zcmbu5L1@!Z7{|Z7wrRGdnl^=^Rt)W+WrZ$HHd9fw=n%XW>0vh`+risl_TWLt4tjEG z!!QlM;-g{Ao6TU=Fx*KZDiVnnk$m_6rK&`M4u|HS^PM+0`I_{a&kOqyUG837 z?bes-E3>zXP;u11=P&v->Ob72F+Tw>Lg9JO_VizYm!Zz+ye;@mq8Tzr3m^7u z_y+z8g$M5Nnzqg-vunJQwOdW1{r**DYn|dXK9Ha+$Ck@GbRXr#RY>@~-m!%Gy`TSoq$B!cb From 33fb421d2a0386862828b3d5f02c63e0f7b37813 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Mon, 16 Jan 2023 18:24:47 +0100 Subject: [PATCH 6/8] Fixed the makefile of template --- template/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/Makefile b/template/Makefile index a6698b8..5aaecbf 100644 --- a/template/Makefile +++ b/template/Makefile @@ -24,7 +24,7 @@ $(BIN): $(ELF) sh-elf-objcopy -O binary build/$(ELF) build/$(BIN) -R .bss $(ELF): $(OBJ) | $(LIB)/ - $(CC) $< lib/libMicrofx.a -o $(BUILD)/$@ -nostdlib -T lib/fx98xx.ld -ffreestanding -mb -m3 -Os -Wa,--dsp + $(CC) $(OBJ) $(LIB)/libMicrofx.a -o $(BUILD)/$@ -nostdlib -T lib/fx98xx.ld -ffreestanding -mb -m3 -Os -Wa,--dsp $(BUILD)/%.o: src/% | $(BUILD)/ $(CC) -c $< -o $@ -Os -Ilib/include/ From 2458478835911303d641c85683f7d079c003de09 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Mon, 16 Jan 2023 18:55:59 +0100 Subject: [PATCH 7/8] Some fixes. Added void csleep(void); --- microfx_src/include/microfx/microfx.h | 13 +++++++++++-- microfx_src/src/microfx.c | 9 +++++++-- template/lib/include/microfx/microfx.h | 13 +++++++++++-- template/lib/libMicrofx.a | Bin 5188 -> 5232 bytes 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index ccb4ffb..7dbb9bf 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -108,7 +108,7 @@ void tsleep_ms(int ms); Get 1/128 seconds ticks since midnight. */ -void tgetticks(void); +int tgetticks(void); /* int tiselapsed(int start, int ms); @@ -119,5 +119,14 @@ Returns 1 if ms is elapsed and 0 if it is not. int tiselapsed(int start, int ms); -#endif +/******* CPU *******/ +/* void csleep(void); + +Uses asm sleep instruction. +Can be used to reduce battery usage of some loops. +*/ + +void csleep(void); + +#endif diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c index 4c3bb6e..ab21aa4 100644 --- a/microfx_src/src/microfx.c +++ b/microfx_src/src/microfx.c @@ -104,11 +104,16 @@ void tsleep_ms(int ms) { _Sleep(ms); } -void tgetticks(void) { - _RTC_GetTicks(); +int tgetticks(void) { + return _RTC_GetTicks(); } int tiselapsed(int start, int ms) { return _RTC_Elapsed_ms(start, ms); } +/******* CPU *******/ + +void csleep(void) { + __asm__("sleep"); +} diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index ccb4ffb..7dbb9bf 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -108,7 +108,7 @@ void tsleep_ms(int ms); Get 1/128 seconds ticks since midnight. */ -void tgetticks(void); +int tgetticks(void); /* int tiselapsed(int start, int ms); @@ -119,5 +119,14 @@ Returns 1 if ms is elapsed and 0 if it is not. int tiselapsed(int start, int ms); -#endif +/******* CPU *******/ +/* void csleep(void); + +Uses asm sleep instruction. +Can be used to reduce battery usage of some loops. +*/ + +void csleep(void); + +#endif diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 48126ab4704f646e628baaa9913afbe2f38d129e..0bea3d70d1e5a023d9a52ade767e1a37c436d350 100644 GIT binary patch delta 395 zcmX@2@j+vPY`vv{rG=4#f`I}EAd?CTW`;lsFi7BHU|>*UU|?Foz`*v0dYI>d2?GPq z15)wEGZz?@;**PWQd0{Uic1oUO7xQT^7SEZH8e9fwgCHT@;e^!&1ab`SXdEUMfMY{ zaIOTCx!L3kOj=B=Z#J9onliFWGjKC-GH_0AU=H5Ao9_}MKLcYX0|TQ9(D!UYK*r`C zflNkrsLh+d2&ywO>P(gqR$^l1nCu{|&X_P+fk%9Dy|4g~H37`uA*{|@0t`3>pb_jK ZVnpHTNM?{%%!(;;y5daV0T_OMg delta 379 zcmeyMaYSQ+Y`vk8fvKs2f`I}EAd?CTW(E+xf1_rhd)WbYi3>X-A zu8@K^Ubw(0Ra}x-RHB!xm#+_Ywt}IVxv>S%Cng4)4>9?(utJz(?Dtvaq5d;80C@&Z znwgmZc@`!nlMUFlm{`wjcHlK-++542!nAp#KnCMxMIkjtMwQ7P!b(gmFDB;*t20JS zzQ8Izd9| Date: Mon, 16 Jan 2023 19:41:49 +0100 Subject: [PATCH 8/8] Added ext/img.h --- microfx_src/Makefile | 2 +- microfx_src/include/microfx/ext/img.h | 20 +++++++++++++++++ microfx_src/src/img.c | 29 +++++++++++++++++++++++++ template/lib/include/microfx/ext/img.h | 20 +++++++++++++++++ template/lib/libMicrofx.a | Bin 5232 -> 6140 bytes 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 microfx_src/include/microfx/ext/img.h create mode 100644 microfx_src/src/img.c create mode 100644 template/lib/include/microfx/ext/img.h diff --git a/microfx_src/Makefile b/microfx_src/Makefile index 94387ab..482b46c 100644 --- a/microfx_src/Makefile +++ b/microfx_src/Makefile @@ -4,7 +4,7 @@ AR = sh-elf-ar OUT = libMicrofx.a OUT_DIR = lib -SRC = src/start.c src/syscall.S src/microfx.c +SRC = src/start.c src/syscall.S src/microfx.c src/img.c OBJ = $(SRC:src/%=build/%.o) BUILD = build diff --git a/microfx_src/include/microfx/ext/img.h b/microfx_src/include/microfx/ext/img.h new file mode 100644 index 0000000..32be80d --- /dev/null +++ b/microfx_src/include/microfx/ext/img.h @@ -0,0 +1,20 @@ +#ifndef IMG_H +#define IMG_H + +enum {SNORMAL = 0, SINVERTED, STRANSP, SNOWHITE, SNOBLACK}; + +/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); + +Draws an image from a Sprite Coder string that is in img, +where the top left corner is at (sx, sy). +w is the width and h the height of the image. +mode can be : +SNORMAL : Draws the image normally. +SINVERTED : Draws the image with inverted colors. +STRANSP : Black is white and white is not drawn. Useful for +transparency in sprites. +*/ + +void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); + +#endif diff --git a/microfx_src/src/img.c b/microfx_src/src/img.c new file mode 100644 index 0000000..befb6f2 --- /dev/null +++ b/microfx_src/src/img.c @@ -0,0 +1,29 @@ +#include "../include/microfx/ext/img.h" +#include + +void simage(int sx, int sy, int w, int h, unsigned char *img, int mode) { + /* Draws an image from a sprite coder string */ + int x, y, rpos, gpos, bpos, color; + for(y=0;yiA5!P$$I(v5CJ!EzA#N w^0RSp8i2Ji03{39)LH)kc@2{VM1UG=fK2hpD|nQ|7#9GURzM5`AO|r307EvTaR2}S delta 261 zcmeyP|3PDdT)ly%g^_}SfdU91lL`uEhCm50NZ?{%U{GRUU|PYz!1jlFnCAh5B?FKk z5yuyoBo>uy_U8&`oNUNcEd}Q4CF|wuL!4`9W^Qa@3G&$Hb4&p&EFjk8b4=o!E!j`9 KB6zaA@$3MKaX(W4