I've seen cool C64 demos showing sprites in the border area of the screen. It shouldn't be possible; I think they managed to fool the graphics chip somehow. How exactly did they do it?
|
|
Yes you need assembler. It's an interrupt timing trick. The VIC is able to show sprites in the border, but the frame is just hiding them, so the sprites can slide begind it. It's connected to scan lines displayed by the VIC. For lower/upper border it's quite simple:
For sprites in the left/right border it's more complicated because the process has to be repeated for every scan line:
The problem is that all these NOPs are busy waits and steal the cycles you have for your stuff. Update: I was able to find some code for you, from an sprite scroller in the lower border. Here is the code. (It was ripped from some demo.)
|
|||||||||
|
|
it all relied on timing. The c64 had a method to query the exact vertical location of the electron beam while it was drawing the screen. When a new line started, you had to wait a few cycles (you could time this using the NOP instruction) and then you had to set a hardware register of the videochip which was responsible for setting the screenmode (and the border width). By timing it exactly right, and doing it every scanline again, the whole sideborder disappeared. The bottom border went away with a similar trick. On the exact scanline where the vertical border started you too had to set the videomode which disabled the bottom border for that frame. indeed this whole thing had to be done in assembly. otherwise you could never get the timing exactly right as a side note. I think the sideborder trick was credited to the 1001 crew (a dutch group). I'm not sure who pulled off the first bottom border trick |
|||||||||||||
|
|
For a good tutorial on the topic of opening the borders on the C64, check out Pasi Ojala's excellent article in C=Hacking Issue 6. Without getting too technical, the trick uses a feature of the VIC chip to let you switch between 25/24 rows and 40/38 columns of text/graphics, and involves making this switch at the exact right moment to fool the VIC into thinking it has already switched the borders on when in fact it hasn't. Check out the above article for a more thorough explanation with code examples. |
||||
|
|
|
That is a long time ago. I know there was a solution that relied on the frequency of the monitor. With a CRT, the current pixel is known even if it was outside of the normal screen. So you could manipulate the ray. Somewhere in my junkpile there must be some C64 books. Offtopic, but graphics with the VIC20 (the predecessor of the C64) was fun. There was no way to manipulate each pixel, but you could change the existing characters. So you filled the screen with all characters from 0 to ... and changed the characters to set pixels to the screen. ;-). |
|||
|
|
|
Timing was the key. The image was created in the border by changing the overscan (border) colour as the CRT's beam moved from left to right. There are two timing signals required to produce an image - vertical refresh and horizontal refresh. By detecting when the horizontal and vertical refresh occurs you can start a sequence of assembler instructions to change the border colour to produce an image. You need to work out the number of CPU clock ticks per border pixel and use that to create code that changes the border colour at the right point. It doesn't work very well when it comes to writing games as the CPU overhead is too great for there to be any time lift to process user input and game state. |
|||||||||||||||||
|