cleaning up the mess

This commit is contained in:
Bjorn Einar Bjarntes 2021-12-18 21:15:16 +01:00
parent ecedd8fd59
commit 3badd74977

View file

@ -12,7 +12,7 @@
// Should be plenty of stack space between the top of the graphics memory // 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 x; // maybe if the ant does not go tooo far it could be an int..
short y; short y;
short direction; // 0 = right, 64 = up, 128 = left, 192 = down short direction; // 0 = right, 64 = up, 128 = left, 192 = down
@ -54,33 +54,32 @@ void setAndClearHiRes(){
} }
// need to think // need to think
BYTE isPositionWhite(short x, short y) BYTE isPositionWhite(short x, BYTE y)
{ {
short ra = (320 * (short)(y/8)) + (y & 7); short ra = (320 * (BYTE)(y/8)) + (y & 7);
short ba = 8 * (short)(x/8); BYTE ba = 8 * (BYTE)(x/8);
short ma = 1 << ((7-(x & 7))); BYTE ma = 1 << ((7-(x & 7)));
short sa = 0x2000; short sa = 0x2000;
short ad = sa+ra+ba; 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/ // https://archive.org/details/The_Graphics_Book_for_the_Commodore_64/page/n129/
void setPositionWhite(short x, short y) void setPositionWhite(short x, short y)
{ {
short ra = (320 * (short)(y/8)) + (y & 7); short ra = (320 * (short)(y/8)) + (y & 7);
short ba = 8 * (short)(x/8); BYTE ba = 8 * (short)(x/8);
short ma = 1 << ((7-(x & 7))); BYTE ma = 1 << ((7-(x & 7)));
short sa = 0x2000; short sa = 0x2000;
short ad = sa+ra+ba; short ad = sa+ra+ba;
*(short*)(ad) = *(short*)(ad) | ma; *(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 ra = (320 * (short)(y/8)) + (y & 7);
short ba = 8 * (short)(x/8); BYTE ba = 8 * (short)(x/8);
short ma = (1 << ((7-(x & 7)))); BYTE ma = (1 << ((7-(x & 7))));
short sa = 0x2000; short sa = 0x2000;
short ad = sa+ra+ba; short ad = sa+ra+ba;
*(short*)(ad) = (*(short*)(ad)) & ~ma; *(short*)(ad) = (*(short*)(ad)) & ~ma;
@ -128,16 +127,6 @@ unsigned short j;
int main(void) { int main(void) {
setAndClearHiRes(); 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; x = 160;
y = 100; y = 100;
direction = 0; direction = 0;