summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2007-03-02 23:18:38 +0000
committerIan C <ianc@noddybox.co.uk>2007-03-02 23:18:38 +0000
commiteeef0966f0448d71e79ad43d53769afebd47b459 (patch)
tree542dcd6a3e8112a81ec550c819ced78fb42552f4
parent6be2806499299bb13edde3481803f28416429902 (diff)
Added support for text rotation modes to textmode interface
-rw-r--r--source/main.c32
-rw-r--r--source/textmode.c27
2 files changed, 40 insertions, 19 deletions
diff --git a/source/main.c b/source/main.c
index 9d25ee0..2fc613c 100644
--- a/source/main.c
+++ b/source/main.c
@@ -75,7 +75,7 @@ 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. "
@@ -109,7 +109,10 @@ static void Splash(void)
ZX81SuspendDisplay();
ZX81DisplayString("10 print '%the zx81 is ace%'\n20 goto 10");
- TM_printf(0,23,"%-34.34s",scroller);
+ SUB_BG2_XDX = 0x080;
+ SUB_BG2_YDY = 0x080;
+
+ TM_printf(0,11,"%-18.18s",scroller);
FB_Clear();
@@ -186,13 +189,15 @@ static void Splash(void)
memmove(scroller,scroller+1,l-2);
scroller[l-2] = c;
- TM_printf(0,23,"%-34.34s",scroller);
+ TM_printf(0,11,"%-18.18s",scroller);
}
- SUB_BG0_X0 = scr_x;
+ SUB_BG2_CX = scr_x << 8;
}
- SUB_BG0_X0 = 0;
+ SUB_BG2_XDX = 0x100;
+ SUB_BG2_YDY = 0x100;
+ SUB_BG2_CX = 0;
ZX81ResumeDisplay();
}
@@ -296,15 +301,20 @@ int main(int argc, char *argv[])
/* 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).
+ the ZX81 run). Having said the overlay is currently a rotation map
+ for some pointless frippery! Still be quicker though.
*/
- videoSetModeSub(MODE_3_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE);
+ videoSetModeSub(MODE_4_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE);
vramSetBankC(VRAM_C_SUB_BG_0x06200000);
- SUB_BG0_CR = BG_COLOR_256 | BG_64x32 | BG_MAP_BASE(4) |
+ SUB_BG2_CR = BG_COLOR_256 | BG_RS_64x64 | BG_MAP_BASE(4) |
BG_TILE_BASE(0) | BG_PRIORITY(0);
- SUB_BG0_X0 = 0;
- SUB_BG0_Y0 = 0;
+ 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_BG3_CR = BG_BMP8_256x256 | BG_BMP_BASE(1) | BG_PRIORITY(1);
SUB_BG3_XDX = 0x100;
@@ -321,7 +331,7 @@ int main(int argc, char *argv[])
/* 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);
+ TM_Init((uint16*)BG_MAP_RAM_SUB(4),64,64,TRUE);
/* Set up interrupts and timers
*/
diff --git a/source/textmode.c b/source/textmode.c
index aa6de44..0de43f6 100644
--- a/source/textmode.c
+++ b/source/textmode.c
@@ -54,15 +54,26 @@ static inline void Plot_Text(int x, int y, int c)
static inline void Plot_RS(int x, int y, int c)
{
- int xw;
- int yw;
+ uint16 ch;
+ int odd;
+ uint16 *off;
- xw = x/32;
- yw = y/32;
- x %= 32;
- y %= 32;
+ odd = x&1;
- *(text + x + y*32 + (xw+yw) * 1024) = c;
+ off = text + x/2 + y*mapw/2;
+
+ ch = *off;
+
+ if (odd)
+ {
+ ch = (c<<8) | (ch&0xff);
+ }
+ else
+ {
+ ch = c | (ch&0xff00);
+ }
+
+ *off = ch;
}
@@ -97,7 +108,7 @@ void TM_Init(uint16 *vram, int map_width, int map_height, int map_is_rotation)
is_rot = map_is_rotation;
- draw_string = map_is_rotation ? Text_Put : RS_Put;
+ draw_string = map_is_rotation ? RS_Put : Text_Put;
TM_Cls();
}