diff options
-rw-r--r-- | include/framebuffer.h | 5 | ||||
-rw-r--r-- | include/gui.h | 2 | ||||
-rw-r--r-- | include/keyboard.h | 13 | ||||
-rw-r--r-- | source/framebuffer.c | 12 | ||||
-rw-r--r-- | source/gui.c | 58 | ||||
-rw-r--r-- | source/keyboard.c | 58 | ||||
-rw-r--r-- | source/main.c | 11 | ||||
-rw-r--r-- | source/monitor.c | 66 | ||||
-rw-r--r-- | source/zx81.c | 6 |
9 files changed, 185 insertions, 46 deletions
diff --git a/include/framebuffer.h b/include/framebuffer.h index 3055e51..afe5972 100644 --- a/include/framebuffer.h +++ b/include/framebuffer.h @@ -45,6 +45,11 @@ typedef enum */ void FB_Init(uint16 *vram, uint16 *palette); +/* Gives access to the parameters of the frame buffer. +*/ +uint16 *FB_VRAM(void); +uint16 *FB_PALETTE(void); + /* Load the internal framebuffer font as a set of ASCII tiles (starting with space) at tiles. The tiles will use colour COL_WHITE. */ diff --git a/include/gui.h b/include/gui.h index 388c200..3795481 100644 --- a/include/gui.h +++ b/include/gui.h @@ -25,6 +25,6 @@ int GUI_Menu(const char *opts[]); void GUI_Alert(int fatal, const char *text); void GUI_Config(void); -bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter); +int GUI_FileSelect(char pwd[], char selected_file[], const char *filter); #endif /* DS81_GUI_H */ diff --git a/include/keyboard.h b/include/keyboard.h index 2afb5df..0827b76 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -100,9 +100,15 @@ typedef struct } SoftKeyEvent; -/* Display the soft keyboard +/* Display the soft keyboard. */ -void SK_DisplayKeyboard(uint16 *vram); +void SK_DisplayKeyboard(void); + +/* If dim is TRUE, then the keyboard is displayed with reduced brightness along + with the selection box. This routine simply adjusts the palette, and + assumes that the keyboard is already on display. +*/ +void SK_SetDisplayBrightness(int dim); /* Returns TRUE while there are still key events for this cycle */ @@ -113,8 +119,7 @@ int SK_GetEvent(SoftKeyEvent *ev); */ int SK_GetBareEvent(SoftKeyEvent *ev); -/* Sets a key to be 'sticky' (it will be released automatically on the next - non-sticky press). +/* Sets a key to be 'sticky'. */ void SK_SetSticky(SoftKey key, int is_sticky); diff --git a/source/framebuffer.c b/source/framebuffer.c index 6d16529..7507a52 100644 --- a/source/framebuffer.c +++ b/source/framebuffer.c @@ -187,6 +187,18 @@ void FB_Init(uint16 *vram, uint16 *palette) } +uint16 *FB_VRAM(void) +{ + return buff; +} + + +uint16 *FB_PALETTE(void) +{ + return pal; +} + + void FB_LoadASCIITiles(uint16 *tiles) { uint8 *src; diff --git a/source/gui.c b/source/gui.c index 2027a37..886c103 100644 --- a/source/gui.c +++ b/source/gui.c @@ -191,14 +191,14 @@ int GUI_Menu(const char *opts[]) int no; int sel; int f; - bool done; - bool defer; + int done; + int defer; w=0; h=0; sel=0; - done=false; - defer=false; + done=FALSE; + defer=FALSE; for(no=0;opts[no];no++) { @@ -239,13 +239,13 @@ int GUI_Menu(const char *opts[]) { swiWaitForVBlank(); } while (keysHeld()&KEY_TOUCH); - done=true; + done=TRUE; } else { if (key & (KEY_A|KEY_B|KEY_X|KEY_Y)) { - done=true; + done=TRUE; } else if ((key & KEY_UP) && sel) { @@ -261,7 +261,7 @@ int GUI_Menu(const char *opts[]) if (tp.px>=x && tp.px<(w+w) && tp.py>=y && tp.py<(y+h)) { - defer=true; + defer=TRUE; sel=(tp.py-y)/16; } } @@ -350,12 +350,12 @@ void GUI_Config(void) { int sel; DS81_ConfigItem f; - bool done; - bool save; + int done; + int save; sel = 0; - done = false; - save = false; + done = FALSE; + save = FALSE; FB_Clear(); @@ -396,13 +396,13 @@ void GUI_Config(void) if (key & KEY_START) { - done=true; + done=TRUE; } #ifndef DS81_DISABLE_FAT else if (key & KEY_SELECT) { - done=true; - save=true; + done=TRUE; + save=TRUE; } #endif else if (key & KEY_A) @@ -439,19 +439,19 @@ void GUI_Config(void) } -bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) +int GUI_FileSelect(char pwd[], char selected_file[], const char *filter) { int no; int sel; int top; int bar_size; double bar_step; - bool done; - bool ret; + int done; + int ret; FB_Colour paper; int off; int f; - bool drag; + int drag; int drag_start; CheckPath(pwd); @@ -469,9 +469,9 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) sel = 0; top = 0; - done = false; - ret = false; - drag = false; + done = FALSE; + ret = FALSE; + drag = FALSE; drag_start = 0; if (no<=FSEL_LINES) @@ -560,13 +560,13 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) } else { - drag = false; + drag = FALSE; } } if (!drag) { - bool activate = false; + int activate = FALSE; do { @@ -583,7 +583,7 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) { if (tp.px > 239) { - drag = true; + drag = TRUE; drag_start = tp.py; } else @@ -596,7 +596,7 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) { if (new_sel == sel) { - activate = true; + activate = TRUE; } else { @@ -665,11 +665,11 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) } else if (key & KEY_A) { - activate = true; + activate = TRUE; } else if (key & KEY_B) { - done = true; + done = TRUE; } if (activate) @@ -698,8 +698,8 @@ bool GUI_FileSelect(char pwd[], char selected_file[], const char *filter) } else { - done = true; - ret = true; + done = TRUE; + ret = TRUE; strcpy(selected_file,pwd); strcat(selected_file,fsel[sel].name); diff --git a/source/keyboard.c b/source/keyboard.c index 8853dd1..d2e7aa7 100644 --- a/source/keyboard.c +++ b/source/keyboard.c @@ -30,6 +30,12 @@ /* ---------------------------------------- STATIC DATA */ +#define PAL_OFFSET 110 + +static int is_dim = FALSE; +static int selection_on = COL_WHITE; +static int selection_off = COL_BLACK; + static struct { int state; @@ -237,7 +243,7 @@ static int GetEvent(SoftKeyEvent *ev, int map) y = 37 + (f / 10) * 30; FB_Box(x, y, 25, 18, key_state[f].new_state ? - COL_WHITE : COL_BLACK); + selection_on : selection_off); } } } @@ -267,7 +273,7 @@ static int GetEvent(SoftKeyEvent *ev, int map) /* ---------------------------------------- PUBLIC INTERFACES */ -void SK_DisplayKeyboard(uint16 *vram) +void SK_DisplayKeyboard(void) { static sImage img; static int loaded; @@ -278,7 +284,53 @@ void SK_DisplayKeyboard(uint16 *vram) loaded = true; } - FB_Blit(&img,0,0,110); + FB_Blit(&img,0,0,PAL_OFFSET); +} + + +void SK_SetDisplayBrightness(int dim) +{ + static uint16 saved_pal[16]; + int f; + uint16 *pal; + + pal = FB_PALETTE(); + + if (dim != is_dim) + { + is_dim = dim; + + if (is_dim) + { + selection_on = COL_DARKGREY; + + for(f=0;f<16;f++) + { + int r,g,b; + + saved_pal[f] = pal[PAL_OFFSET + f]; + + r = saved_pal[f] & 0x1f; + g = (saved_pal[f]>>5) & 0x1f; + b = (saved_pal[f]>>10) & 0x1f; + + r/=3; + g/=3; + b/=3; + + pal[PAL_OFFSET + f] = RGB15(r,g,b); + } + } + else + { + selection_on = COL_WHITE; + + for(f=0;f<16;f++) + { + pal[PAL_OFFSET + f] = saved_pal[f]; + } + } + } } diff --git a/source/main.c b/source/main.c index 2fc613c..33ca01e 100644 --- a/source/main.c +++ b/source/main.c @@ -199,6 +199,8 @@ static void Splash(void) SUB_BG2_YDY = 0x100; SUB_BG2_CX = 0; + TM_Cls(); + ZX81ResumeDisplay(); } @@ -212,7 +214,7 @@ static void MapJoypad(void) int done = FALSE; char text[256]; - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); ZX81SuspendDisplay(); @@ -361,7 +363,7 @@ int main(int argc, char *argv[]) LoadConfig(); ZX81Reconfigure(); - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); SK_SetSticky(SK_SHIFT,DS81_Config[DS81_STICKY_SHIFT]); @@ -369,9 +371,6 @@ int main(int argc, char *argv[]) { SoftKeyEvent ev; - TM_printf(0,0,"HL = %4.4x",z80->HL.w); - TM_printf(0,23,"PC = %4.4x",z80->PC); - Z80Exec(z80); while(SK_GetEvent(&ev)) @@ -408,7 +407,7 @@ int main(int argc, char *argv[]) break; } - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); } break; diff --git a/source/monitor.c b/source/monitor.c index 62d5f3b..ad81b28 100644 --- a/source/monitor.c +++ b/source/monitor.c @@ -24,9 +24,75 @@ #include <stdlib.h> #include "monitor.h" +#include "keyboard.h" +#include "textmode.h" +#include "framebuffer.h" + +/* ---------------------------------------- STATIC INTERFACES +*/ +static void DisplayHelp() +{ + static const char *help[]= + { + /* 12345678901234567890123456789012 */ + "MONITOR HELP", + "", + "Click on the config bar to exit.", + "", + "Press START to toggle between", + "single step mode and running.", + "", + "Press SELECT to toggle between", + "CPU info and memory display.", + "", + "In single step mode press A", + "to execute next instruction.", + "", + "Use L/R to alter memory shown", + "on the memory display.", + "", + "Note that all numbers are in hex", + "and the all keyboard keys are", + "sticky until the monitor exits.", + "", + "Press A to continue", + NULL + }; + + int f; + + TM_Cls(); + + for(f=0; help[f]; f++) + { + TM_Put(0,f,help[f]); + } + + while(!(keysUp() & KEY_A)) + { + swiWaitForVBlank(); + } +} + /* ---------------------------------------- PUBLIC INTERFACES */ void MachineCodeMonitor(void) { + int done = FALSE; + + SK_DisplayKeyboard(); + SK_SetDisplayBrightness(TRUE); + + DisplayHelp(); + + /* + while(!done) + { + swiWaitForVBlank(); + } + */ + + SK_SetDisplayBrightness(FALSE); + TM_Cls(); } diff --git a/source/zx81.c b/source/zx81.c index 4d1da51..c0af981 100644 --- a/source/zx81.c +++ b/source/zx81.c @@ -303,7 +303,7 @@ static FILE *OpenTapeFile(Z80Word addr, int *cancelled) *cancelled = TRUE; } - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); } else { @@ -773,7 +773,7 @@ static int EDCallback(Z80 *z80, Z80Val data) if (!cancel) { GUI_Alert(FALSE,"Couldn't open tape"); - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); } } } @@ -786,7 +786,7 @@ static int EDCallback(Z80 *z80, Z80Val data) else { GUI_Alert(FALSE,"No tape image selected"); - SK_DisplayKeyboard(BG_GFX_SUB); + SK_DisplayKeyboard(); } } |