Test code now exercising ASM line drawing.
This commit is contained in:
parent
ec08f48556
commit
0ecf3e1c8b
2 changed files with 74 additions and 15 deletions
|
@ -368,7 +368,6 @@ odd_c equ 19
|
|||
|
||||
; Say surface = $012000...
|
||||
|
||||
; lda #<surface ; Should be $2000
|
||||
lda surface ; Should be $2000
|
||||
sta __e0 ; set "even" addresses
|
||||
sta __e1
|
||||
|
@ -402,7 +401,6 @@ odd_c equ 19
|
|||
sta __o13
|
||||
|
||||
phb ; keep original bank
|
||||
; 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!
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue