optimizing

This commit is contained in:
Bjorn Einar Bjarntes 2021-12-19 14:13:43 +01:00
parent 5e9d2fdecc
commit 8bea2e8121

View file

@ -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();
}