diff --git a/src/core/setup.c b/src/core/setup.c index 452c0f3..b46b5f0 100644 --- a/src/core/setup.c +++ b/src/core/setup.c @@ -207,17 +207,17 @@ int __Timer_Install(int id, void (*handler)(void), int delay); int __Timer_Start(int id); int __Timer_Stop(int id); int __Timer_Deinstall(int id); -int __PutKeyCode(short *matrixcode); +int __PutKeyCode(int row, int column, int keycode); 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); static int __osmenu_id; static void __osmenu_handler(void) { - short matrixcode = 0x0308; - __PutKeyCode(&matrixcode); + __PutKeyCode(0x04, 0x09, 0); __Timer_Stop(__osmenu_id); __Timer_Deinstall(__osmenu_id); @@ -226,23 +226,49 @@ static void __osmenu_handler(void) static void __osmenu(void) { __ClearKeyBuffer(); + + #ifdef FX9860G memcpy(__GetVRAMAddress(), gint_vram, 1024); + #endif + + #ifdef FXCG50 + /* Unfortunately ineffective (main menu probably reenables it) + __ConfigureStatusArea(3); */ + + /* TODO: Improve copied VRAM behavior in gint_osmenu() on fxcg50 */ + uint16_t *vram1, *vram2; + dgetvram(&vram1, &vram2); + + uint16_t *dst = __GetVRAMAddress(); + uint16_t *src = (gint_vram == vram1) ? vram2 + 6 : vram1 + 6; + + for(int y = 0; y < 216; y++, dst+=384, src+=396) + for(int x = 0; x < 384; x++) + { + dst[x] = src[x]; + } + #endif + + /* Mysteriously crashes when coming back; might be useful another time + instead of GetKeyWait() + int C=0x04, R=0x09; + __SpecialMatrixCodeProcessing(&C, &R); */ __osmenu_id = __Timer_Install(0, __osmenu_handler, 0 /* ms */); if(__osmenu_id <= 0) return; - __Timer_Start(__osmenu_id); int column, row; unsigned short keycode; - __GetKeyWait(&column, &row, 0, 0 /* s */, 0, &keycode); + __GetKeyWait(&column, &row, + 0 /* KEYWAIT_HALTON_TIMEROFF */, + 1 /* Delay in seconds */, + 0 /* Enable return to main menu */, + &keycode); } /* gint_osmenu() - switch out of gint and call the calculator's main menu */ void gint_osmenu(void) { - /* TODO: return to menu on fxcg50 */ - #ifdef FX9860G gint_switch(__osmenu); - #endif } diff --git a/src/core/syscalls.S b/src/core/syscalls.S index 405fa8b..e3a5c49 100644 --- a/src/core/syscalls.S +++ b/src/core/syscalls.S @@ -36,6 +36,7 @@ .global ___GetKeyWait .global ___ClearKeyBuffer .global ___GetVRAMAddress +.global ___ConfigureStatusArea .section ".pretext" @@ -114,7 +115,7 @@ ___Timer_Stop: ___Timer_Deinstall: syscall(0x119) ___PutKeyCode: - syscall(0x24f) + syscall(0x248) ___GetKeyWait: syscall(0x247) ___ClearKeyBuffer: @@ -140,6 +141,29 @@ _calloc: _realloc: syscall(0x1f46) +___Timer_Install: + syscall(0x8d9) +___Timer_Start: + syscall(0x8db) +___Timer_Stop: + syscall(0x8dc) +___Timer_Deinstall: + syscall(0x8da) +___PutKeyCode: + syscall(0x12c6) +___GetKeyWait: + syscall(0x12bf) +___ClearKeyBuffer: + syscall(0x12c7) +___GetVRAMAddress: + syscall(0x1e6) +___ConfigureStatusArea: + syscall(0x2b7) + +.global ___SpecialMatrixCodeProcessing +___SpecialMatrixCodeProcessing: + syscall(0x1e60) + syscall_table: .long 0x80020070