From 3badd74977fa487fd0929ce69c786ccf597a19a1 Mon Sep 17 00:00:00 2001 From: Bjorn Einar Bjarntes Date: Sat, 18 Dec 2021 21:15:16 +0100 Subject: [PATCH] cleaning up the mess --- src/main.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 55f1b57..122c1b5 100644 --- a/src/main.c +++ b/src/main.c @@ -12,7 +12,7 @@ // Should be plenty of stack space between the top of the graphics memory -unsigned short i; +short i; short x; // maybe if the ant does not go tooo far it could be an int.. short y; short direction; // 0 = right, 64 = up, 128 = left, 192 = down @@ -54,33 +54,32 @@ void setAndClearHiRes(){ } // need to think -BYTE isPositionWhite(short x, short y) +BYTE isPositionWhite(short x, BYTE y) { - short ra = (320 * (short)(y/8)) + (y & 7); - short ba = 8 * (short)(x/8); - short ma = 1 << ((7-(x & 7))); + short ra = (320 * (BYTE)(y/8)) + (y & 7); + BYTE ba = 8 * (BYTE)(x/8); + BYTE ma = 1 << ((7-(x & 7))); short sa = 0x2000; short ad = sa+ra+ba; - return *(short*)(ad) & ma; + return *(BYTE*)(ad) & ma; } - // https://archive.org/details/The_Graphics_Book_for_the_Commodore_64/page/n129/ void setPositionWhite(short x, short y) { short ra = (320 * (short)(y/8)) + (y & 7); - short ba = 8 * (short)(x/8); - short ma = 1 << ((7-(x & 7))); + BYTE ba = 8 * (short)(x/8); + BYTE ma = 1 << ((7-(x & 7))); short sa = 0x2000; short ad = sa+ra+ba; *(short*)(ad) = *(short*)(ad) | ma; } -void setPositionBlack(unsigned short x, unsigned short y) +void setPositionBlack(short x, short y) { short ra = (320 * (short)(y/8)) + (y & 7); - short ba = 8 * (short)(x/8); - short ma = (1 << ((7-(x & 7)))); + BYTE ba = 8 * (short)(x/8); + BYTE ma = (1 << ((7-(x & 7)))); short sa = 0x2000; short ad = sa+ra+ba; *(short*)(ad) = (*(short*)(ad)) & ~ma; @@ -128,16 +127,6 @@ unsigned short j; int main(void) { setAndClearHiRes(); - for (i = 0;i<50;i++){ - for (j= 0;j<50;j++){ - setPositionWhite(i,j); - } - } - for (i = 0;i<50;i++){ - for (j= 0;j<50;j++){ - setPositionBlack(i,j); - } - } x = 160; y = 100; direction = 0;