From e007fe3daeff4bcd64bd41894d5606fe43948672 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 13 Sep 2006 23:49:18 +0000 Subject: Initail version with Spectrum booting --- source/main.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 7 deletions(-) (limited to 'source/main.c') diff --git a/source/main.c b/source/main.c index 2cf5579..0cab2ab 100644 --- a/source/main.c +++ b/source/main.c @@ -26,11 +26,34 @@ #include "framebuffer.h" #include "gui.h" +#include "z80.h" +#include "spec.h" +#include "keyboard.h" +#include "error.h" #include "splashimg_bin.h" /* ---------------------------------------- STATIC DATA */ +static const char *main_menu[]= + { + "Reset Spectrum", + "Select Tape", + "Sticky Keys On", + "Sticky Keys Off", + "Define Joystick", + "Cancel", + NULL + }; + +typedef enum +{ + MenuReset, + MenuSelectTape, + MenuStickyOn, + MenuStickyOff, + MenuDefineJoystick +} MenuOpt; /* ---------------------------------------- DISPLAY FUNCS @@ -100,6 +123,8 @@ static void Splash(void) */ int main(int argc, char *argv[]) { + Z80 *z80; + powerON(POWER_ALL_2D); videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE); @@ -133,14 +158,62 @@ int main(int argc, char *argv[]) Splash(); - while(1) - { - static const char *menu[]={"Option #1","A longer option","Short","Wibble Sticks!",NULL}; - char buff[32]; + /* Initialise processor and the Spectrum + */ + z80=Z80Init(SPECPeek,SPECPoke,SPECReadPort,SPECWritePort,SPECDisPeek); - sprintf(buff,"sel=%d",GUI_Menu(menu)); - FB_Centre(buff,SCREEN_HEIGHT-10,FB_RGB(31,31,31),FB_RGB(0,0,15)); + if (!z80) + { + DSSPEC_Error("Failed to create\na Z80 processor"); } - return 0; + SPECInit(BG_GFX,z80); + SK_DisplayKeyboard(BG_GFX_SUB); + + while(1) + { + SoftKeyEvent ev; + + Z80Exec(z80); + + while(SK_GetEvent(&ev)) + { + switch(ev.key) + { + case SK_ABOUT: + case SK_CONFIG: + switch(GUI_Menu(main_menu)) + { + case MenuReset: + SPECReset(z80); + break; + + case MenuSelectTape: + break; + + case MenuStickyOn: + break; + + case MenuStickyOff: + break; + + case MenuDefineJoystick: + break; + } + + SK_DisplayKeyboard(BG_GFX_SUB); + break; + + default: + SPECHandleKey(ev.key,ev.pressed); + break; + } + } + + { + static int pressed=0; + SPECHandleKey(SK_P,pressed); + pressed=!pressed; + } + } } -- cgit v1.2.3