From 40e4d7dd31e232ca84204d836e137afd683de750 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 20 Jan 2023 18:19:42 +0100 Subject: [PATCH] Added some tools, some drawing functions and some GUI functions. --- README.md | 2 + microfx_src/include/microfx/microfx.h | 52 +++++++++++++++++++++++-- microfx_src/src/microfx.c | 39 ++++++++++++++++++- microfx_src/src/syscall.S | 12 ++++++ template/lib/include/microfx/microfx.h | 52 +++++++++++++++++++++++-- template/lib/libMicrofx.a | Bin 6654 -> 7450 bytes 6 files changed, 149 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1ba40a4..e9c3c7a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Make very small add-ins. +You can also write this name "libµfx" or "ufx". + 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 diff --git a/microfx_src/include/microfx/microfx.h b/microfx_src/include/microfx/microfx.h index 5e22a00..4371e95 100644 --- a/microfx_src/include/microfx/microfx.h +++ b/microfx_src/include/microfx/microfx.h @@ -48,13 +48,13 @@ The available colors are SWHITE or SBLACK. void spixel(int x, int y, int color); -/* void stext(int x, int y, char *text); +/* void stext(int x, int y, char *text, int color); Puts the text text at (x, y) on the screen using casio -default font. +default font with color color. */ -void stext(int x, int y, char *text); +void stext(int x, int y, char *text, int color); /* void slocate(int x, int y, char *text); @@ -63,6 +63,29 @@ Works like the Locate function of CASIO Basic. void slocate(int x, int y, char *text); +/* void saddlocate(char *text); + +Continues the text displayed with slocate, can be used +multiple times after a locate. +*/ + +void saddlocate(char *text); + +/* void sgoto(int x, int y); + +Moves the position where you can add text with saddlocate. +*/ + +void sgoto(int x, int y); + +/* void stextmini(int x, int y, char *text); + +Works like stext, but here the font is PrintMini and you cannot +set the color. +*/ + +void stextmini(int x, int y, char *text); + /******* KEYBOARD *******/ /* int kisdown(void); @@ -123,6 +146,14 @@ Free __ptr. void free(void *__ptr); +/* void itohex(char *buffer, int value, int len); + +Puts the hex representation of value into buffer. The hex number +will have the size len. +*/ + +void itohex(char *buffer, int value, int len); + /******* TIME *******/ /* void tsleep_ms(int ms); @@ -182,4 +213,19 @@ string and maxlen is the maximal length of the input. void gstrask(char *buffer, char *message, int maxlen); +/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); + +Draws an fkey from a Sprite Coder string that is in img, +at fkey position pos. +*/ + +void gfkeyset(int pos, unsigned char *img); + +/* void gmessagebox(int height, char *message); + +Draws a message box of height height with that contains message. +*/ + +void gmessagebox(int height, char *message); + #endif diff --git a/microfx_src/src/microfx.c b/microfx_src/src/microfx.c index 1d901b0..b62ed51 100644 --- a/microfx_src/src/microfx.c +++ b/microfx_src/src/microfx.c @@ -13,6 +13,8 @@ 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); +void _PrintMiniSd(int x, int y, unsigned char *text, int color); +void _DisplayMessageBox(int height, unsigned char *message); /* Microfx */ @@ -40,8 +42,8 @@ void sline(int x1, int y1, int x2, int y2, int color) { } } -void stext(int x, int y, char *text) { - _PrintXY(x, y, (unsigned char*)text, 0); +void stext(int x, int y, char *text, int color) { + _PrintXY(x, y, (unsigned char*)text, !color); } void slocate(int x, int y, char *text) { @@ -49,6 +51,22 @@ void slocate(int x, int y, char *text) { _Print((unsigned char*)text); } +void saddlocate(char *text) { + _Print((unsigned char*)text); +} + +void sgoto(int x, int y) { + _locate(x, y); +} + +void stextmini(int x, int y, char *text) { + _PrintMiniSd(x, y, (unsigned char*)text, 0); +} + +void gmessagebox(int height, char *message) { + _DisplayMessageBox(height, (unsigned char*)message); +} + /******* KEYBOARD *******/ /* Syscalls */ @@ -90,6 +108,18 @@ int kgetkey(void){ return (buffer[1] & 0x0F) * 10 + ((buffer[2] & 0xF0 ) >> 4); } +/******* Tools *******/ + +/* Syscalls */ + +int _LongToAscHex(int value, char *dest, int digits); + +/* Microfx */ + +void itohex(char *buffer, int value, int len) { + _LongToAscHex(value, buffer, len); +} + /******* Time *******/ /* Syscalls */ @@ -126,6 +156,7 @@ void csleep(void) { int _InputNumber(unsigned char *heading, int maxlen, int mode); int _InputString(unsigned char *buffer, unsigned char *heading, int maxlen); +void _DisplayFKeyIcon(int FKeyPos, unsigned char *pBitmap); /* Microfx */ @@ -135,4 +166,8 @@ int gnumask(char *message, int maxlen, int type) { void gstrask(char *buffer, char *message, int maxlen) { _InputString((unsigned char *)buffer, (unsigned char *)message, maxlen); +} + +void gfkeyset(int pos, unsigned char *img) { + _DisplayFKeyIcon(pos, img); } \ No newline at end of file diff --git a/microfx_src/src/syscall.S b/microfx_src/src/syscall.S index 2749b0f..4564bfc 100644 --- a/microfx_src/src/syscall.S +++ b/microfx_src/src/syscall.S @@ -10,6 +10,8 @@ .global __Print .global __Bdisp_DrawLineVRAM .global __Bdisp_ClearLineVRAM +.global __PrintMiniSd +.global __DisplayMessageBox /* Keyboard */ .global __Keyboard_GetPressedTime .global __Keyboard_IsKeyPressed @@ -27,9 +29,11 @@ .global _calloc .global _realloc .global _free +.global __LongToAscHex /* GUI */ .global __InputNumber .global __InputString +.global __DisplayFKeyIcon #define syscall(syscall_number) \ mov.l 1f, r0 ;\ @@ -60,6 +64,10 @@ __Bdisp_DrawLineVRAM: syscall(0x030) __Bdisp_ClearLineVRAM: syscall(0x031) +__PrintMiniSd: + syscall(0xC4F) +__DisplayMessageBox: + syscall(0x0901) /* Keyboard */ __Keyboard_GetPressedTime: syscall(0x249) @@ -91,11 +99,15 @@ _realloc: syscall(0xE6D) _free: syscall(0xACC) +__LongToAscHex: + syscall(0x467) /* GUI */ __InputNumber: syscall(0x0CC4) __InputString: syscall(0x0CC5) +__DisplayFKeyIcon: + syscall(0x04D1) /* Menu */ /* Nothing here ... */ diff --git a/template/lib/include/microfx/microfx.h b/template/lib/include/microfx/microfx.h index 5e22a00..4371e95 100644 --- a/template/lib/include/microfx/microfx.h +++ b/template/lib/include/microfx/microfx.h @@ -48,13 +48,13 @@ The available colors are SWHITE or SBLACK. void spixel(int x, int y, int color); -/* void stext(int x, int y, char *text); +/* void stext(int x, int y, char *text, int color); Puts the text text at (x, y) on the screen using casio -default font. +default font with color color. */ -void stext(int x, int y, char *text); +void stext(int x, int y, char *text, int color); /* void slocate(int x, int y, char *text); @@ -63,6 +63,29 @@ Works like the Locate function of CASIO Basic. void slocate(int x, int y, char *text); +/* void saddlocate(char *text); + +Continues the text displayed with slocate, can be used +multiple times after a locate. +*/ + +void saddlocate(char *text); + +/* void sgoto(int x, int y); + +Moves the position where you can add text with saddlocate. +*/ + +void sgoto(int x, int y); + +/* void stextmini(int x, int y, char *text); + +Works like stext, but here the font is PrintMini and you cannot +set the color. +*/ + +void stextmini(int x, int y, char *text); + /******* KEYBOARD *******/ /* int kisdown(void); @@ -123,6 +146,14 @@ Free __ptr. void free(void *__ptr); +/* void itohex(char *buffer, int value, int len); + +Puts the hex representation of value into buffer. The hex number +will have the size len. +*/ + +void itohex(char *buffer, int value, int len); + /******* TIME *******/ /* void tsleep_ms(int ms); @@ -182,4 +213,19 @@ string and maxlen is the maximal length of the input. void gstrask(char *buffer, char *message, int maxlen); +/* void simage(int sx, int sy, int w, int h, unsigned char *img, int mode); + +Draws an fkey from a Sprite Coder string that is in img, +at fkey position pos. +*/ + +void gfkeyset(int pos, unsigned char *img); + +/* void gmessagebox(int height, char *message); + +Draws a message box of height height with that contains message. +*/ + +void gmessagebox(int height, char *message); + #endif diff --git a/template/lib/libMicrofx.a b/template/lib/libMicrofx.a index 18b93d2f94bfcd30ff59773ee2169903a27be1aa..d065d96c6e9c30b9515575eb3afb2fac22e58191 100644 GIT binary patch delta 2278 zcmcJRU1%It6vxk<-OOx~&F-4d*3`|ImNvR6-E3k$Olk8)Y)L``yH-(fy6%qK&BspY z4w!&u6pM-$3EU#3Sg`1Wh=?>r5Jifl4;3qIi9U!*9|Wa{PgM~_{LjwL%#AP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