summaryrefslogtreecommitdiff
path: root/arm9/source/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/source/main.c')
-rw-r--r--arm9/source/main.c125
1 files changed, 79 insertions, 46 deletions
diff --git a/arm9/source/main.c b/arm9/source/main.c
index a2b0565..43c8993 100644
--- a/arm9/source/main.c
+++ b/arm9/source/main.c
@@ -26,12 +26,32 @@
#include "framebuffer.h"
#include "gui.h"
+#include "keyboard.h"
+#include "z80.h"
+#include "zx81.h"
#include "splashimg_bin.h"
-#include "zx81_bin.h"
+#include "rom_font_bin.h"
/* ---------------------------------------- STATIC DATA
*/
+static const char *main_menu[]=
+ {
+ "Reset ZX81",
+ "Sticky Keys On",
+ "Sticky Keys Off",
+ "Define Joystick",
+ "Cancel",
+ NULL
+ };
+
+typedef enum
+{
+ MenuReset,
+ MenuStickyOn,
+ MenuStickyOff,
+ MenuDefineJoystick
+} MenuOpt;
/* ---------------------------------------- DISPLAY FUNCS
@@ -87,8 +107,7 @@ static void Splash(void)
*/
int main(int argc, char *argv[])
{
- int ch;
- uint8 *ch_data;
+ Z80 *z80;
powerON(POWER_ALL_2D);
@@ -99,51 +118,14 @@ int main(int argc, char *argv[])
vramSetBankA(VRAM_A_MAIN_BG_0x6000000);
vramSetBankB(VRAM_B_MAIN_BG_0x6020000);
- BG0_CR = BG_COLOR_256|BG_MAP_BASE(31)|BG_TILE_BASE(0);
+ BG0_CR = BG_COLOR_256|BG_MAP_BASE(0)|BG_TILE_BASE(1);
BG0_X0 = 0;
BG0_Y0 = 0;
BG_PALETTE[0] = RGB15(31,31,31);
BG_PALETTE[1] = RGB15(0,0,0);
- ch_data = (uint8*)BG_TILE_RAM(0);
-
- for(ch=0;ch<64;ch++)
- {
- int r;
-
- for(r=0;r<8;r++)
- {
- int b;
- int rd;
-
- rd=zx81_bin[0x1e00+ch*8+r];
- for(b=7;b>=0;b--)
- {
- if (rd&(1<<b))
- {
- *ch_data = 1;
- *(ch_data+4096) = 0;
- }
- else
- {
- *ch_data = 0;
- *(ch_data+4096) = 1;
- }
-
- ch_data++;
- }
- }
- }
-
- {
- uint16 *tiles;
- tiles = (uint16*)BG_MAP_RAM(31);
- for(ch=0;ch<128;ch++)
- {
- *(tiles+(ch%32)+(ch/32)*32)=ch;
- }
- }
+ dmaCopy(rom_font_bin,(void *)BG_TILE_RAM(1),rom_font_bin_size);
/* Set up the sub-screen for rotation (basically for use as a framebuffer)
*/
@@ -167,13 +149,64 @@ int main(int argc, char *argv[])
Splash();
+ z80 = Z80Init(ZX81ReadMem,
+ ZX81WriteMem,
+ ZX81ReadPort,
+ ZX81WritePort,
+ NULL);
+
+ if (!z80)
+ {
+ return EXIT_FAILURE;
+ }
+
+ ZX81Init((uint16*)SCREEN_BASE_BLOCK(0), z80);
+
+ SK_DisplayKeyboard(BG_GFX_SUB);
+
+ SK_SetSticky(SK_SHIFT,1);
+
while(1)
{
- static const char *menu[]={"Option #1","A longer option","Short","Wibble Sticks!",NULL};
- char buff[32];
+ SoftKeyEvent ev;
- sprintf(buff,"sel=%d",GUI_Menu(menu));
- FB_Centre(buff,SCREEN_HEIGHT-10,FB_RGB(31,31,31),FB_RGB(0,0,15));
+ Z80Exec(z80);
+
+ while(SK_GetEvent(&ev))
+ {
+ switch(ev.key)
+ {
+ case SK_ABOUT:
+ case SK_CONFIG:
+ if (ev.pressed)
+ {
+ switch(GUI_Menu(main_menu))
+ {
+ case MenuReset:
+ ZX81Reset(z80);
+ break;
+
+ case MenuStickyOn:
+ SK_SetSticky(SK_SHIFT,1);
+ break;
+
+ case MenuStickyOff:
+ SK_SetSticky(SK_SHIFT,0);
+ break;
+
+ case MenuDefineJoystick:
+ break;
+ }
+
+ SK_DisplayKeyboard(BG_GFX_SUB);
+ }
+ break;
+
+ default:
+ ZX81HandleKey(ev.key,ev.pressed);
+ break;
+ }
+ }
}
return 0;