From 5a45ff1c366ef57658cdaaca4b230b6f565b6e28 Mon Sep 17 00:00:00 2001 From: Bjorn Einar Bjarntes Date: Sun, 19 Dec 2021 19:41:46 +0100 Subject: [PATCH] making one line to reduce size --- src/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index f6d071a..b935e02 100644 --- a/src/main.c +++ b/src/main.c @@ -29,20 +29,23 @@ void setAndClearHiRes(){ setHiRes(); } +void calcAdress(){ + ad = 0x2000+((y & 0xf8) << 3) +((y & 0xf8) << 4) +((y & 0xf8) << 4) + (y & 7)+ (x&(0xfff8)); +} + BYTE isPositionWhite() { - ad = 0x2000+((y >> 3) << 6) +((y >> 3) << 7) +((y >> 3) << 7) + (y & 7)+ (x&(0xfff8)); + calcAdress(); return *(short*)(ad) & 1 << ((7-(x & 7))); } // https://archive.org/details/The_Graphics_Book_for_the_Commodore_65/page/n129/ void setPositionWhite() { - ad = 0x2000+ ((y >> 3) << 6) +((y >> 3) << 7) +((y >> 3) << 7) + (y & 7)+(x&(0xfff8)); + calcAdress(); *(short*)(ad) = *(short*)(ad) | 1 << ((7-(x & 7))); } void setPositionBlack() { - // TODO is it faster to somehow reuse y >> 3 than do it many times, and maybe add the same result twice... - ad = 0x2000+((y >> 3) << 6) +((y >> 3) << 7) +((y >> 3) << 7) + (y & 7)+ (x&(0xfff8)); + calcAdress(); *(short*)(ad) = (*(short*)(ad)) & ~(1 << ((7-(x & 7)))); }