summaryrefslogtreecommitdiff
path: root/source/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/main.c')
-rw-r--r--source/main.c105
1 files changed, 80 insertions, 25 deletions
diff --git a/source/main.c b/source/main.c
index cfdf231..9d25ee0 100644
--- a/source/main.c
+++ b/source/main.c
@@ -33,6 +33,8 @@
#include "zx81.h"
#include "tapes.h"
#include "config.h"
+#include "textmode.h"
+#include "monitor.h"
#include "splashimg_bin.h"
#include "rom_font_bin.h"
@@ -45,6 +47,7 @@ static const char *main_menu[]=
"Select Tape",
"Configure",
"Map Joypad to Keys",
+ "Machine Code Monitor",
"Cancel",
NULL
};
@@ -55,6 +58,7 @@ typedef enum
MenuSelectTape,
MenuConfigure,
MenuMapJoypad,
+ MenuMonitor,
} MenuOpt;
/* ---------------------------------------- IRQ FUNCS
@@ -69,6 +73,15 @@ static void VBlankFunc(void)
static void Splash(void)
{
+ static char scroller[]=
+ {
+ " "
+ "Welcome to DS81, a ZX81 emulator for the Ninetendo DS. "
+ "You can safely ignore this message. I was just bored for half an "
+ "hour. "
+ "Thanks to Slay Radio for coding fuel."
+ };
+
static const char *text[]=
{
"DS81 \177 2006 Ian C",
@@ -91,22 +104,24 @@ static void Splash(void)
int f;
int y;
int res=FALSE;
+ int scr_x=0;
ZX81SuspendDisplay();
ZX81DisplayString("10 print '%the zx81 is ace%'\n20 goto 10");
+ TM_printf(0,23,"%-34.34s",scroller);
+
FB_Clear();
loadPCX(splashimg_bin,&img);
- image8to16(&img);
- FB_Blit(&img,0,0);
+ FB_Blit(&img,0,0,1);
y = 10;
for(f=0;text[f];f++)
{
- FB_Centre(text[f],y,FB_RGB(31,31,31),-1);
+ FB_Centre(text[f],y,COL_WHITE,COL_TRANSPARENT);
y += 8;
}
@@ -120,46 +135,65 @@ static void Splash(void)
{
ZX81EnableFileSystem(TRUE);
- FB_Centre("Found a FAT device.",y,FB_RGB(31,31,31),-1);
+ FB_Centre("Found a FAT device.",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("If you place .P tape files in",y,FB_RGB(31,31,31),-1);
+ FB_Centre("If you place .P tape files in",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("the top directory or ZX81SNAP",y,FB_RGB(31,31,31),-1);
+ FB_Centre("the top directory or ZX81SNAP",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("then you should be able to load",y,FB_RGB(31,31,31),-1);
+ FB_Centre("then you should be able to load",y,
+ COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("GAME.P with the command",y,FB_RGB(31,31,31),-1);
+ FB_Centre("GAME.P with the command",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("LOAD \"GAME\"",y,FB_RGB(31,31,31),-1);
+ FB_Centre("LOAD \"GAME\"",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
}
else
{
ZX81EnableFileSystem(FALSE);
- FB_Centre("Sorry, but you don't have a",y,FB_RGB(31,31,31),-1);
+ FB_Centre("Sorry, but you don't have a",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("supported FAT device.",y,FB_RGB(31,31,31),-1);
+ FB_Centre("supported FAT device.",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("Only the internal tape",y,FB_RGB(31,31,31),-1);
+ FB_Centre("Only the internal tape",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
- FB_Centre("files can be used.",y,FB_RGB(31,31,31),-1);
+ FB_Centre("files can be used.",y,COL_WHITE,COL_TRANSPARENT);
y += 8;
}
while(!(keysDown() & KEY_A))
{
swiWaitForVBlank();
+
+ if (++scr_x == 8)
+ {
+ size_t l = sizeof scroller;
+ char c;
+
+ scr_x = 0;
+
+ c = scroller[0];
+ memmove(scroller,scroller+1,l-2);
+ scroller[l-2] = c;
+
+ TM_printf(0,23,"%-34.34s",scroller);
+ }
+
+ SUB_BG0_X0 = scr_x;
}
+ SUB_BG0_X0 = 0;
+
ZX81ResumeDisplay();
}
@@ -241,7 +275,8 @@ int main(int argc, char *argv[])
vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
vramSetBankB(VRAM_B_MAIN_BG_0x06020000);
- BG0_CR = BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(0);
+ BG0_CR = BG_COLOR_256 | BG_32x32 | BG_MAP_BASE(0) |
+ BG_TILE_BASE(1) | BG_PRIORITY(0);
BG0_X0 = 0;
BG0_Y0 = 0;
@@ -258,22 +293,35 @@ int main(int argc, char *argv[])
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)
+ /* Set up the sub-screen for rotation (basically for use as a framebuffer).
+ Now overlaid with a text screen for the monitor (I thought a bitmapped
+ printing routine would needlessly slow down the monitor when watching
+ the ZX81 run).
*/
- videoSetModeSub(MODE_5_2D | DISPLAY_BG2_ACTIVE);
+ videoSetModeSub(MODE_3_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
- SUB_BG2_CR = BG_BMP16_256x256;
- SUB_BG2_XDX = 0x100;
- SUB_BG2_XDY = 0;
- SUB_BG2_YDX = 0;
- SUB_BG2_YDY = 0x100;
- SUB_BG2_CX = 0;
- SUB_BG2_CY = 0;
+ SUB_BG0_CR = BG_COLOR_256 | BG_64x32 | BG_MAP_BASE(4) |
+ BG_TILE_BASE(0) | BG_PRIORITY(0);
+ SUB_BG0_X0 = 0;
+ SUB_BG0_Y0 = 0;
+
+ SUB_BG3_CR = BG_BMP8_256x256 | BG_BMP_BASE(1) | BG_PRIORITY(1);
+ SUB_BG3_XDX = 0x100;
+ SUB_BG3_XDY = 0;
+ SUB_BG3_YDX = 0;
+ SUB_BG3_YDY = 0x100;
+ SUB_BG3_CX = 0;
+ SUB_BG3_CY = 0;
/* Tell 'framebuffer' routines to use this
*/
- FB_Init(BG_GFX_SUB);
+ FB_Init((uint16*)BG_BMP_RAM_SUB(1), BG_PALETTE_SUB);
+
+ /* Set up lower screen text overlay
+ */
+ FB_LoadASCIITiles((uint16*)BG_TILE_RAM_SUB(0));
+ TM_Init((uint16*)BG_MAP_RAM_SUB(4),64,32,FALSE);
/* Set up interrupts and timers
*/
@@ -289,7 +337,7 @@ int main(int argc, char *argv[])
ZX81WriteMem,
ZX81ReadPort,
ZX81WritePort,
- NULL);
+ ZX81ReadDisassem);
if (!z80)
{
@@ -311,6 +359,9 @@ 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))
@@ -341,6 +392,10 @@ int main(int argc, char *argv[])
case MenuMapJoypad:
MapJoypad();
break;
+
+ case MenuMonitor:
+ MachineCodeMonitor();
+ break;
}
SK_DisplayKeyboard(BG_GFX_SUB);