Sprites, SYS, And Storage On The 64
I have several questions about the Commodore 64:
First of all, I know you can check if a sprite has hit a background character by PEEKing (V + 31) when V = 53248. Is there any way to find out what kind of character it hit?
Second, I have seen many programs which read: 10 SYS(X). How do they do this? Using Commodore's assembler package, you must load in the machine language program off the disk.
Last, where is there room to insert machine language programs in memory other than C000 - CFFF (49152 - 53247)?
The sprite-to-background collision detection byte (53279) is set up to be a "toggle" switch; in other words, it registers an off/on condition (collision or no collision). It does not offer the option of telling you what character the sprite collided with. However, you can program this option for yourself. For instance, after a collision has been detected you could branch to a subroutine that would convert the affected sprite's position to its screen position, and then perform a simple PEEK to see what character it hit.
The SYS command is used to start a machine language program running. When, in a BASIC program, you see a statement such as 10 SYS XXXX, the program is simply branching to a machine language routine much the same way that a pure BASIC program would branch to a BASIC subroutine via the GOTO or GOSUB command.
Commodore's machine language assembler is stored on disk. Like BASIC, machine language programs may be stored on either tape or disk and, once LOADed (by the LOAD command, or via a BASIC loader), it may be called or branched to at anytime by the SYS command.
There are many places for you to safely place your machine language programs. Besides the obvious BASIC programming area (2048 to 40959), there are other good locations available: $02A7 to $02FF (decimal 679 to 767, 89 bytes), $033C to $03FB (decimal 828 to 1019 – the tape cassette buffer – 192 bytes), and, as you mentioned, $C000 to $CFFF (decimal 49152 to 53247, 4096 bytes).