more optimization

This commit is contained in:
Bjorn Einar Bjarntes 2021-12-19 13:29:54 +01:00
parent 985a228bac
commit f913d0ff65
3 changed files with 6 additions and 5 deletions

1
.gitignore vendored
View file

@ -10,6 +10,7 @@ disk/
*.o *.o
*.pet *.pet
*.avi
*.prg *.prg
*.d81 *.d81
*.c64 *.c64

4
.vscode/tasks.json vendored
View file

@ -17,9 +17,9 @@
"command": " x64sc.exe out/program.c64" "command": " x64sc.exe out/program.c64"
}, },
{ {
"label": "Build & run program", "label": "Build & run program with optimization",
"type": "shell", "type": "shell",
"command": "cl65 src/main.c -o out/program.c64 && x64sc.exe out/program.c64", "command": "cl65 src/main.c -o out/program.c64 -Oi && x64sc.exe out/program.c64",
"problemMatcher": [] "problemMatcher": []
} }
] ]

View file

@ -30,18 +30,18 @@ void setAndClearHiRes(){
} }
BYTE isPositionWhite() { BYTE isPositionWhite() {
ad = 0x2000+(320 * (BYTE)(y >> 3)) + (y & 7)+8 * (BYTE)(x/8); ad = 0x2000+(320 * (BYTE)(y >> 3)) + (y & 7)+8 * (BYTE)(x>>3);
return *(short*)(ad) & 1 << ((7-(x & 7))); return *(short*)(ad) & 1 << ((7-(x & 7)));
} }
// 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() { void setPositionWhite() {
ad = 0x2000+(320 * (y >> 3)) + (y & 7)+8 * (x/8); ad = 0x2000+(320 * (y >> 3)) + (y & 7)+8 * (x>>3);
*(short*)(ad) = *(short*)(ad) | 1 << ((7-(x & 7))); *(short*)(ad) = *(short*)(ad) | 1 << ((7-(x & 7)));
} }
void setPositionBlack() { void setPositionBlack() {
ad = 0x2000+320 * (y >> 3) + (y & 7)+8 * (x/8); ad = 0x2000+320 * (y >> 3) + (y & 7)+8 * (x>>3);
*(short*)(ad) = (*(short*)(ad)) & ~(1 << ((7-(x & 7)))); *(short*)(ad) = (*(short*)(ad)) & ~(1 << ((7-(x & 7))));
} }