From 0ecf3e1c8b566534e0dba42d52b2194287e0af72 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Fri, 4 Oct 2019 19:43:53 -0500 Subject: [PATCH] Test code now exercising ASM line drawing. --- joeylib/src/jIIgs.asm | 2 - joeylib/src/test.c | 87 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 15 deletions(-) diff --git a/joeylib/src/jIIgs.asm b/joeylib/src/jIIgs.asm index 58d49d9..d296d1f 100644 --- a/joeylib/src/jIIgs.asm +++ b/joeylib/src/jIIgs.asm @@ -368,7 +368,6 @@ odd_c equ 19 ; Say surface = $012000... -; lda #surface ; Should be $0120 lda surface+1 ; Should be $0120 pha ; switch to bank we're pointing into plb ; B is now $20 - bad! diff --git a/joeylib/src/test.c b/joeylib/src/test.c index 80a4696..c69a49d 100644 --- a/joeylib/src/test.c +++ b/joeylib/src/test.c @@ -32,6 +32,10 @@ segment "testapp"; #endif +extern jint16 asmTest(jlSurfaceT source); +extern void asmDrawLine(jlSurfaceT target, jint16 color, jint16 x1, jint16 y1, jint16 x2, jint16 y2); + + // Font hacking! __attribute__((__format__ (__printf__, 4, 0))) void printAt(jlStaT *font, jint16 cx, jint16 cy, const char *what, ...) { @@ -58,10 +62,15 @@ int main(void) { jlStaT *kanga = NULL; jlStaT *font = NULL; jint16 y; + jint16 phase = 0; + jint16 x2 = 0; jint16 y2 = 0; - jint16 dy = 1; + jint16 ox = 0; + jint16 oy = 0; + jint16 op = 0; jint16 color = 15; jint16 nextColor = 1; + char what[32]; jlUtilStartup("JoeyLib Test"); @@ -72,26 +81,78 @@ int main(void) { jlDrawColorSet(1); jlDrawBox(0, 0, 319, 199); - jlSoundMusicPlay("music"); + //jlSoundMusicPlay("music"); jlPaletteSet(15, 15, 15, 15); - printAt(font, 1, 16, "X"); + strcpy(what, "Left to Right"); + while (!jlKeyPressed()) { y = 17; - printAt(font, 1, y++, "X = %d ", jlGameGetAxis(0)); - printAt(font, 1, y++, "Y = %d ", jlGameGetAxis(1)); - printAt(font, 1, y++, "T = %d ", jlUtilTimer()); - printAt(font, 1, y++, "R = %d ", asmTest((jlSurfaceT)0x012000)); + //printAt(font, 1, y++, "R = %d ", asmTest((jlSurfaceT)0x012000)); + printAt(font, 1, y++, "Drawing %s ", what); + jlDrawColorSet((byte)color); - jlDrawLine(0, y2, 319, 199-y2); - //asmDrawLine(_jlDrawTargetActual, _jlDrawColor, 0, y2, 319, 199-y2); - y2 += dy; - if (y2 == 199 || y2 == 0) dy = -dy; + if (phase < 2) { + asmDrawLine(_jlDrawTargetActual, _jlDrawColor, x2, y2, 319-x2, 199-y2); + } else { + asmDrawLine(_jlDrawTargetActual, _jlDrawColor, 319-x2, 199-y2, x2, y2); + } + ox = x2; + oy = y2; + op = phase; + + switch (phase) { + // Left, Y incrementing + case 0: + y2++; + if (y2 == 199) { + strcpy(what, "Bottom to Top"); + phase = 1; + } + break; + + // Bottom, X incrementing + case 1: + x2++; + if (x2 == 319) { + strcpy(what, "Right to Left"); + phase = 2; + } + break; + + // Right, Y decrementing + case 2: + y2--; + if (y2 == 0) { + strcpy(what, "Top to Bottom"); + phase = 3; + } + break; + + // Top, X decrementing + case 3: + x2--; + if (x2 == 0) { + strcpy(what, "Left to Right"); + phase = 0; + } + break; + } + jlDisplayPresent(); - //jlUtilNibbleSwap((byte *)font->pixels, 32000, (byte)(color), (byte)(nextColor)); + + jlDrawColorSet((byte)0); + if (op < 2) { + asmDrawLine(_jlDrawTargetActual, _jlDrawColor, ox, oy, 319-ox, 199-oy); + } else { + asmDrawLine(_jlDrawTargetActual, _jlDrawColor, 319-ox, 199-oy, ox, oy); + } + color = nextColor; nextColor++; - if (nextColor > 15) nextColor = 1; + if (nextColor > 15) { + nextColor = 1; + } } jlKeyRead();