From f913d0ff656046e996890ec9ef8c8ea5157abe92 Mon Sep 17 00:00:00 2001 From: Bjorn Einar Bjarntes Date: Sun, 19 Dec 2021 13:29:54 +0100 Subject: [PATCH] more optimization --- .gitignore | 1 + .vscode/tasks.json | 4 ++-- src/main.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index bd4a4be..cc21340 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ disk/ *.o *.pet +*.avi *.prg *.d81 *.c64 diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 25d4098..042f4e8 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -17,9 +17,9 @@ "command": " x64sc.exe out/program.c64" }, { - "label": "Build & run program", + "label": "Build & run program with optimization", "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": [] } ] diff --git a/src/main.c b/src/main.c index ca88569..198afe5 100644 --- a/src/main.c +++ b/src/main.c @@ -30,18 +30,18 @@ void setAndClearHiRes(){ } 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))); } // https://archive.org/details/The_Graphics_Book_for_the_Commodore_64/page/n129/ 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))); } 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)))); }