From 603f3fac82ccb77775d53fd77ae7c32167116ad7 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 3 Nov 2008 17:07:32 +0000 Subject: Initial snapshot code (in progress) --- include/config.h | 5 +++++ include/ds81_debug.h | 15 +++++++++++---- include/gui.h | 1 + include/keyboard.h | 7 +++++++ include/z80.h | 7 +++++++ include/zx81.h | 8 ++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/config.h b/include/config.h index e2d96de..9946356 100644 --- a/include/config.h +++ b/include/config.h @@ -22,11 +22,16 @@ #ifndef DS81_CONFIG_H #define DS81_CONFIG_H +/* Default snapshot dir +*/ +#define DEFAULT_SNAPDIR "/ZX81SNAP/" + typedef enum { DS81_STICKY_SHIFT, DS81_AVERAGE_TOUCHSCREEN, DS81_STATIC_RAM_AT_0x2000, + DS81_LOAD_DEFAULT_SNAPSHOT, DS81_NUM_CONFIG_ITEMS } DS81_ConfigItem; diff --git a/include/ds81_debug.h b/include/ds81_debug.h index 82e8c45..ed7a1eb 100644 --- a/include/ds81_debug.h +++ b/include/ds81_debug.h @@ -22,15 +22,22 @@ #ifndef DS81_DEBUG_H #define DS81_DEBUG_H +#include "gui.h" #include "framebuffer.h" #define DS81_DEBUG(fmt, args...) \ do \ { \ - FB_FillBox(0,184,256,8,FB_RGB(10,0,0)); \ - FB_printf(0,184,FB_RGB(31,31,31),FB_RGB(10,0,0), fmt , ## args);\ - while (keysDownRepeat()!=KEY_A); \ + char tempdebug[512]; \ + sprintf(tempdebug, fmt, ## args); \ + GUI_Alert(FALSE, tempdebug); \ + } while(0) + +#define DS81_DEBUG_STATUS(fmt, args...) \ + do \ + { \ + FB_FillBox(0,184,256,8,COL_DARKGREY); \ + FB_printf(0,184,COL_WHITE,COL_DARKGREY, fmt , ## args); \ } while(0) - #endif /* DS81_DEBUG_H */ diff --git a/include/gui.h b/include/gui.h index 3795481..30989e6 100644 --- a/include/gui.h +++ b/include/gui.h @@ -26,5 +26,6 @@ int GUI_Menu(const char *opts[]); void GUI_Alert(int fatal, const char *text); void GUI_Config(void); int GUI_FileSelect(char pwd[], char selected_file[], const char *filter); +int GUI_InputName(char name[], int maxlen); #endif /* DS81_GUI_H */ diff --git a/include/keyboard.h b/include/keyboard.h index 0827b76..93538ec 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -22,6 +22,8 @@ #ifndef DS81_KEYBOARD_H #define DS81_KEYBOARD_H +#include + /* Note that the first 40 values purposefully are the keyboard matrix keys. Note also that they are in display order, not matrix order. */ @@ -132,4 +134,9 @@ void SK_DefinePad(SoftKey pad, SoftKey key); */ const char *SK_KeyName(SoftKey pad); +/* Allows the keyboard to save/restore its state from a stream +*/ +void SK_SaveSnapshot(FILE *fp); +void SK_LoadSnapshot(FILE *fp); + #endif /* DS81_KEYBOARD_H */ diff --git a/include/z80.h b/include/z80.h index 000b950..1250356 100644 --- a/include/z80.h +++ b/include/z80.h @@ -27,6 +27,8 @@ #ifndef Z80_H #define Z80_H "$Id$" +#include + /* Configuration */ #include "z80_config.h" @@ -245,6 +247,11 @@ void Z80SetLabels(Z80Label labels[]); */ const char *Z80Disassemble(Z80 *cpu, Z80Word *addr); +/* Allows the CPU state to be saved/loaded from a stream +*/ +void Z80SaveSnapshot(Z80 *cpu, FILE *fp); +void Z80LoadSnapshot(Z80 *cpu, FILE *fp); + #endif /* END OF FILE */ diff --git a/include/zx81.h b/include/zx81.h index 2606c98..1f77448 100644 --- a/include/zx81.h +++ b/include/zx81.h @@ -27,6 +27,8 @@ #ifndef DS81_ZX81_H #define DS81_ZX81_H +#include + #include "z80.h" #include "keyboard.h" @@ -79,6 +81,12 @@ void ZX81WritePort(Z80 *z80, Z80Word port, Z80Byte val); #define ZX81ReadDisassem ZX81ReadMem +/* Interfaces to allows the ZX81 to save/load itself as a snapshot to/from + a stream. +*/ +void ZX81SaveSnapshot(FILE *fp); +void ZX81LoadSnapshot(FILE *fp); + #endif -- cgit v1.2.3