From 8bea2e8121aa440f0201d42da3444aa36b564643 Mon Sep 17 00:00:00 2001 From: Bjorn Einar Bjarntes Date: Sun, 19 Dec 2021 14:13:43 +0100 Subject: [PATCH] optimizing --- src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 409a636..5fb32c5 100644 --- a/src/main.c +++ b/src/main.c @@ -30,19 +30,19 @@ void setAndClearHiRes(){ } BYTE isPositionWhite() { - ad = 0x2000+(320 * (BYTE)(y >> 3)) + (y & 7)+ (x&(0xfff8)); + ad = 0x2000+(40*(y >> 3)<<3) + (y & 7)+ (x&(0xfff8)); return *(short*)(ad) & 1 << ((7-(x & 7))); } // https://archive.org/details/The_Graphics_Book_for_the_Commodore_64/page/n129/ void setPositionWhite() { // TODO this 8 times something divided must be just masking - ad = 0x2000+(320 * (y >> 3)) + (y & 7)+(x&(0xfff8)); + ad = 0x2000+(40 * (y >> 3) << 3) + (y & 7)+(x&(0xfff8)); *(short*)(ad) = *(short*)(ad) | 1 << ((7-(x & 7))); } void setPositionBlack() { - ad = 0x2000+320 * (y >> 3) + (y & 7)+ (x&(0xfff8)); + ad = 0x2000+ (40* (y >> 3) << 3) + (y & 7)+ (x&(0xfff8)); *(short*)(ad) = (*(short*)(ad)) & ~(1 << ((7-(x & 7)))); } @@ -77,7 +77,8 @@ int main(void) { x = 270; y = 100; direction = 0; - while(x > 0 && x < 320 && y > 0 && y < 200) + //while(x > 0 && x < 320 && y > 0 && y < 200) + while(1) { makeMove(); }