From 45e90b55ba7ef10bd99a996fa3e4254f8d7f7a0d Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:06:36 +0100 Subject: [PATCH 1/9] Added SetQuitHandler. --- src/kernel/syscalls.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/kernel/syscalls.S b/src/kernel/syscalls.S index 12b0325..1261859 100644 --- a/src/kernel/syscalls.S +++ b/src/kernel/syscalls.S @@ -42,6 +42,7 @@ .global ___ClearKeyBuffer .global ___GetVRAMAddress .global ___ConfigureStatusArea +.global ___SetQuitHandler #define syscall_(id, syscall_table) \ mov.l syscall_table, r2 ;\ @@ -111,6 +112,8 @@ ___ClearKeyBuffer: syscall(0x241) ___GetVRAMAddress: syscall(0x135) +___SetQuitHandler: + syscall(0x494) syscall_table: .long 0x80010070 @@ -178,6 +181,8 @@ ___GetVRAMAddress: syscall(0x1e6) ___ConfigureStatusArea: syscall(0x2b7) +___SetQuitHandler: + syscall(0x1e6e) .global ___SpecialMatrixCodeProcessing ___SpecialMatrixCodeProcessing: From 93e055cfba3c5f3625115e8648ddd91a4d82d869 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:46:27 +0100 Subject: [PATCH 2/9] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 473f6b8..f5dda44 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The library also offers powerful higher-level features: * An enhanced version of the system's GetKey() and GetKeyWait() * A gray engine that works by rapidly swapping monochrome images on fx-9860G II -* Blazingly fast rendering functions (image rendering is 10 times faster tha +* Blazingly fast rendering functions (image rendering is 10 times faster than MonochromeLib) * Integrated font management From d6e8b096b521c04cde1aa6f82547dbfabb738e42 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:06:36 +0100 Subject: [PATCH 3/9] Added SetQuitHandler. --- src/kernel/syscalls.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/kernel/syscalls.S b/src/kernel/syscalls.S index 12b0325..1261859 100644 --- a/src/kernel/syscalls.S +++ b/src/kernel/syscalls.S @@ -42,6 +42,7 @@ .global ___ClearKeyBuffer .global ___GetVRAMAddress .global ___ConfigureStatusArea +.global ___SetQuitHandler #define syscall_(id, syscall_table) \ mov.l syscall_table, r2 ;\ @@ -111,6 +112,8 @@ ___ClearKeyBuffer: syscall(0x241) ___GetVRAMAddress: syscall(0x135) +___SetQuitHandler: + syscall(0x494) syscall_table: .long 0x80010070 @@ -178,6 +181,8 @@ ___GetVRAMAddress: syscall(0x1e6) ___ConfigureStatusArea: syscall(0x2b7) +___SetQuitHandler: + syscall(0x1e6e) .global ___SpecialMatrixCodeProcessing ___SpecialMatrixCodeProcessing: From 8a6f3bfdce6e5594c1aa200498461c7a2abe1543 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:46:27 +0100 Subject: [PATCH 4/9] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 473f6b8..f5dda44 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The library also offers powerful higher-level features: * An enhanced version of the system's GetKey() and GetKeyWait() * A gray engine that works by rapidly swapping monochrome images on fx-9860G II -* Blazingly fast rendering functions (image rendering is 10 times faster tha +* Blazingly fast rendering functions (image rendering is 10 times faster than MonochromeLib) * Integrated font management From 56e5c2452a4cfc2342293cfb7eb3542bbb11edb4 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 20 Nov 2022 11:36:57 +0100 Subject: [PATCH 5/9] Added gint_set_quit_handler() --- include/gint/gint.h | 10 ++++++++++ src/kernel/osmenu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/gint/gint.h b/include/gint/gint.h index 6925175..d2b5646 100644 --- a/include/gint/gint.h +++ b/include/gint/gint.h @@ -109,6 +109,16 @@ static GINLINE void *gint_inthandler(int code, void const *h, size_t size) { Returns the return value of the callback. */ extern int (*gint_inth_callback)(gint_call_t const *call); +/* gint_set_quit_handler(): Call a GINT_CALL when the user open another add-in + + This function use the SetQuitHandler syscall to call a function when the + user open another add-in. + + @call A GINT_CALL + @do_world_switch 1 to execute @call in a world_switch. */ + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch); + #ifdef __cplusplus } #endif diff --git a/src/kernel/osmenu.c b/src/kernel/osmenu.c index 3c54465..47b0d85 100644 --- a/src/kernel/osmenu.c +++ b/src/kernel/osmenu.c @@ -13,6 +13,7 @@ int __GetKeyWait(int *col,int *row,int type,int time,int menu,uint16_t *key); void __ClearKeyBuffer(void); /* ? */ void *__GetVRAMAddress(void); void __ConfigureStatusArea(int mode); +void __SetQuitHandler(void (*callback)(void)); static int __osmenu_id; @@ -76,3 +77,28 @@ void gint_osmenu(void) { gint_world_switch(GINT_CALL(gint_osmenu_native)); } + +static gint_call_t __gcall; +static bool __do_world_switch; + +static void __handler() +{ + if(__do_world_switch){ + gint_call(__gcall); + }else{ + /* TODO: quit the world switch */ + gint_call(__gcall); + } +} + +static void __sethandler() +{ + __SetQuitHandler((void *)__handler); +} + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch) +{ + __gcall = gcall; + __do_world_switch = do_world_switch; + gint_world_switch(GINT_CALL(__sethandler)); +} From ad0da59de695892611408af97a607c70bb497117 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 20 Nov 2022 11:36:57 +0100 Subject: [PATCH 6/9] Added gint_set_quit_handler() --- include/gint/gint.h | 10 ++++++++++ src/kernel/osmenu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/gint/gint.h b/include/gint/gint.h index 6925175..d2b5646 100644 --- a/include/gint/gint.h +++ b/include/gint/gint.h @@ -109,6 +109,16 @@ static GINLINE void *gint_inthandler(int code, void const *h, size_t size) { Returns the return value of the callback. */ extern int (*gint_inth_callback)(gint_call_t const *call); +/* gint_set_quit_handler(): Call a GINT_CALL when the user open another add-in + + This function use the SetQuitHandler syscall to call a function when the + user open another add-in. + + @call A GINT_CALL + @do_world_switch 1 to execute @call in a world_switch. */ + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch); + #ifdef __cplusplus } #endif diff --git a/src/kernel/osmenu.c b/src/kernel/osmenu.c index 3c54465..47b0d85 100644 --- a/src/kernel/osmenu.c +++ b/src/kernel/osmenu.c @@ -13,6 +13,7 @@ int __GetKeyWait(int *col,int *row,int type,int time,int menu,uint16_t *key); void __ClearKeyBuffer(void); /* ? */ void *__GetVRAMAddress(void); void __ConfigureStatusArea(int mode); +void __SetQuitHandler(void (*callback)(void)); static int __osmenu_id; @@ -76,3 +77,28 @@ void gint_osmenu(void) { gint_world_switch(GINT_CALL(gint_osmenu_native)); } + +static gint_call_t __gcall; +static bool __do_world_switch; + +static void __handler() +{ + if(__do_world_switch){ + gint_call(__gcall); + }else{ + /* TODO: quit the world switch */ + gint_call(__gcall); + } +} + +static void __sethandler() +{ + __SetQuitHandler((void *)__handler); +} + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch) +{ + __gcall = gcall; + __do_world_switch = do_world_switch; + gint_world_switch(GINT_CALL(__sethandler)); +} From 2fe67412cca9a826eed54f9f44639ec32cdebde9 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:06:36 +0100 Subject: [PATCH 7/9] Added SetQuitHandler. --- src/kernel/syscalls.S | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/kernel/syscalls.S b/src/kernel/syscalls.S index 12b0325..1261859 100644 --- a/src/kernel/syscalls.S +++ b/src/kernel/syscalls.S @@ -42,6 +42,7 @@ .global ___ClearKeyBuffer .global ___GetVRAMAddress .global ___ConfigureStatusArea +.global ___SetQuitHandler #define syscall_(id, syscall_table) \ mov.l syscall_table, r2 ;\ @@ -111,6 +112,8 @@ ___ClearKeyBuffer: syscall(0x241) ___GetVRAMAddress: syscall(0x135) +___SetQuitHandler: + syscall(0x494) syscall_table: .long 0x80010070 @@ -178,6 +181,8 @@ ___GetVRAMAddress: syscall(0x1e6) ___ConfigureStatusArea: syscall(0x2b7) +___SetQuitHandler: + syscall(0x1e6e) .global ___SpecialMatrixCodeProcessing ___SpecialMatrixCodeProcessing: From 6426406043bf907fc51e050e22ef0b040b1ac6fe Mon Sep 17 00:00:00 2001 From: mibi88 Date: Fri, 11 Nov 2022 17:46:27 +0100 Subject: [PATCH 8/9] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 473f6b8..f5dda44 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The library also offers powerful higher-level features: * An enhanced version of the system's GetKey() and GetKeyWait() * A gray engine that works by rapidly swapping monochrome images on fx-9860G II -* Blazingly fast rendering functions (image rendering is 10 times faster tha +* Blazingly fast rendering functions (image rendering is 10 times faster than MonochromeLib) * Integrated font management From 984f162cb2bc47d9d8fb8d874245a8fc0f3288b7 Mon Sep 17 00:00:00 2001 From: mibi88 Date: Sun, 20 Nov 2022 11:36:57 +0100 Subject: [PATCH 9/9] Added gint_set_quit_handler() --- include/gint/gint.h | 10 ++++++++++ src/kernel/osmenu.c | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/gint/gint.h b/include/gint/gint.h index 6925175..d2b5646 100644 --- a/include/gint/gint.h +++ b/include/gint/gint.h @@ -109,6 +109,16 @@ static GINLINE void *gint_inthandler(int code, void const *h, size_t size) { Returns the return value of the callback. */ extern int (*gint_inth_callback)(gint_call_t const *call); +/* gint_set_quit_handler(): Call a GINT_CALL when the user open another add-in + + This function use the SetQuitHandler syscall to call a function when the + user open another add-in. + + @call A GINT_CALL + @do_world_switch 1 to execute @call in a world_switch. */ + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch); + #ifdef __cplusplus } #endif diff --git a/src/kernel/osmenu.c b/src/kernel/osmenu.c index 3c54465..47b0d85 100644 --- a/src/kernel/osmenu.c +++ b/src/kernel/osmenu.c @@ -13,6 +13,7 @@ int __GetKeyWait(int *col,int *row,int type,int time,int menu,uint16_t *key); void __ClearKeyBuffer(void); /* ? */ void *__GetVRAMAddress(void); void __ConfigureStatusArea(int mode); +void __SetQuitHandler(void (*callback)(void)); static int __osmenu_id; @@ -76,3 +77,28 @@ void gint_osmenu(void) { gint_world_switch(GINT_CALL(gint_osmenu_native)); } + +static gint_call_t __gcall; +static bool __do_world_switch; + +static void __handler() +{ + if(__do_world_switch){ + gint_call(__gcall); + }else{ + /* TODO: quit the world switch */ + gint_call(__gcall); + } +} + +static void __sethandler() +{ + __SetQuitHandler((void *)__handler); +} + +void gint_set_quit_handler(gint_call_t gcall, bool do_world_switch) +{ + __gcall = gcall; + __do_world_switch = do_world_switch; + gint_world_switch(GINT_CALL(__sethandler)); +}