UPDATE: I restructured the the part of the code that makes it compatible with all Commodore machines: It now first checks the keyboard input, which is the same for all of them, and then after that checks the machine type and reads the joystick input accordingly. While this makes the code longer, it definitely improves the performance for the cursor.