base:opening_up_the_borders_-_a_further_explanation
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
base:opening_up_the_borders_-_a_further_explanation [2016-03-10 16:47] – created thehighlander | base:opening_up_the_borders_-_a_further_explanation [2016-03-13 22:08] (current) – Standardized headings ftc | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Opening up the borders - a further explanation | + | ====== |
Author: Wouter Bovelander | Author: Wouter Bovelander | ||
Line 5: | Line 5: | ||
Location: http:// | Location: http:// | ||
- | === Introduction === | + | ===== Introduction |
When I read articles by other writers I am always happy that they are willing to share their knowledge. However, at the end of reading some articles I am left with questions. One of those articles is Pasi ‘Albert’ Ojala' | When I read articles by other writers I am always happy that they are willing to share their knowledge. However, at the end of reading some articles I am left with questions. One of those articles is Pasi ‘Albert’ Ojala' | ||
Please note that I shall use assembly language for the MOS 6502/6510 inside a PAL Commodore 64. I am using the Kick Assembler format and I shall explain as many language constructs as I think is necessary. | Please note that I shall use assembly language for the MOS 6502/6510 inside a PAL Commodore 64. I am using the Kick Assembler format and I shall explain as many language constructs as I think is necessary. | ||
- | === The Challenge === | + | ===== The Challenge |
When you boot up the C64 it shows a character screen of 40 columns and 25 lines surrounded by borders. To be more specific, there are border areas directly above and below the text area. There are also borders to the left and the right of the text area. This description leaves the four corners, that is the areas not directly above, below or beside the text area. This article is mostly concerned with the border areas directly below and above the text area. | When you boot up the C64 it shows a character screen of 40 columns and 25 lines surrounded by borders. To be more specific, there are border areas directly above and below the text area. There are also borders to the left and the right of the text area. This description leaves the four corners, that is the areas not directly above, below or beside the text area. This article is mostly concerned with the border areas directly below and above the text area. | ||
Line 17: | Line 17: | ||
We want to be able to utilise the border areas directly above and below the text area. Right off the bat I can tell you that we won't just be able to display any text there, but we could place sprites there. All we can do is to prevent the VIC-2 from drawing the borders but we will need to apply a dirty trick to achieve it. | We want to be able to utilise the border areas directly above and below the text area. Right off the bat I can tell you that we won't just be able to display any text there, but we could place sprites there. All we can do is to prevent the VIC-2 from drawing the borders but we will need to apply a dirty trick to achieve it. | ||
- | === The Theory === | + | ===== The Theory |
Alright, here's how it's supposed to work. After the VIC-2 has finished drawing all the characters on screen it starts drawing the border. Basically this process consists of repeatedly drawing something out of a fixed memory location (I'll come back to this later) and in a set color, namely the border color. Where the VIC-2 normally busies itself with reading information from RAM for every character, it behaves differently while drawing the borders. This border drawing is not an active process; it stops reading bytes from RAM for every location. But rather the VIC-2 draws a single character until it reaches the top of the screen again. Once there it draws more border color (which is the top border) until the text area is to be drawn again. What we want to do is to tell the VIC-2 to not draw border. But there' | Alright, here's how it's supposed to work. After the VIC-2 has finished drawing all the characters on screen it starts drawing the border. Basically this process consists of repeatedly drawing something out of a fixed memory location (I'll come back to this later) and in a set color, namely the border color. Where the VIC-2 normally busies itself with reading information from RAM for every character, it behaves differently while drawing the borders. This border drawing is not an active process; it stops reading bytes from RAM for every location. But rather the VIC-2 draws a single character until it reaches the top of the screen again. Once there it draws more border color (which is the top border) until the text area is to be drawn again. What we want to do is to tell the VIC-2 to not draw border. But there' | ||
Line 26: | Line 26: | ||
Granted, this is a nasty trick and definitely not a feature intended by the C64 designers. Which means we will have to live with whatever the VIC-2 leaves, which isn't much as you will see. | Granted, this is a nasty trick and definitely not a feature intended by the C64 designers. Which means we will have to live with whatever the VIC-2 leaves, which isn't much as you will see. | ||
- | === Garbage === | + | ===== Garbage |
We haven' | We haven' | ||
Line 33: | Line 33: | ||
So whatever is there, the VIC-2 will draw to the screen, using a character color of 0, being black. And that's what we have to deal with. So if we simply cleared $3FFF, the VIC-2 would just draw nothing. But this is where Pasi shows what he can do and introduces us to some more advanced stuff that I'll talk about as well. | So whatever is there, the VIC-2 will draw to the screen, using a character color of 0, being black. And that's what we have to deal with. So if we simply cleared $3FFF, the VIC-2 would just draw nothing. But this is where Pasi shows what he can do and introduces us to some more advanced stuff that I'll talk about as well. | ||
- | === Side note on fancy wobbling === | + | ===== Side note on fancy wobbling |
Naturally dear old Albert wasn't satisfied with just printing garbage or spaces in the borders. He does a little trick. I won't explain it completely here but it comes down to this. He copies character shapes from the character ROM area to RAM and then switches the ROM out of the memory map. Next he copies the values from RAM to $3FFF. All of it? Yes. Naturally the CPU will overwrite whatever is in $3FFF, but remember that the VIC-2 is 8 times faster than the CPU and will draw whatever it finds in $3FFF each time it looks. So when the CPU is ready to change the value of $3FFF, the VIC-2 has already drawn the character that was there completely. | Naturally dear old Albert wasn't satisfied with just printing garbage or spaces in the borders. He does a little trick. I won't explain it completely here but it comes down to this. He copies character shapes from the character ROM area to RAM and then switches the ROM out of the memory map. Next he copies the values from RAM to $3FFF. All of it? Yes. Naturally the CPU will overwrite whatever is in $3FFF, but remember that the VIC-2 is 8 times faster than the CPU and will draw whatever it finds in $3FFF each time it looks. So when the CPU is ready to change the value of $3FFF, the VIC-2 has already drawn the character that was there completely. | ||
Now if that wasn't enough Albert also wants to show off is programming prowess by making the text wobble. He does so by defining the mathematical equivalent of a sinus wave in memory and changing the horizontal scrolling according to those values. This makes the text do its fancy wobble which looks great. But it has nothing to do with opening up the borders so I'll just leave it for what it is. | Now if that wasn't enough Albert also wants to show off is programming prowess by making the text wobble. He does so by defining the mathematical equivalent of a sinus wave in memory and changing the horizontal scrolling according to those values. This makes the text do its fancy wobble which looks great. But it has nothing to do with opening up the borders so I'll just leave it for what it is. | ||
- | === Side note on side borders === | + | ===== Side note on side borders |
In this article I've chosen to write about the areas directly above and below the text area because our trick only affects those areas. There are however other areas we call ' | In this article I've chosen to write about the areas directly above and below the text area because our trick only affects those areas. There are however other areas we call ' | ||
- | === Side note on scrolling lines === | + | ===== Side note on scrolling lines ===== |
At this point in the article I'd like to say a few words about Pasi ‘Albert’ Ojala' | At this point in the article I'd like to say a few words about Pasi ‘Albert’ Ojala' | ||
Line 48: | Line 48: | ||
Please remember that these are just side notes. They have nothing to do with opening up the borders but I am mentioning them because they appear in Pasi's article and I thought they deserved some extra attention. Now let's put all the side notes aside and go back to opening up them borders. | Please remember that these are just side notes. They have nothing to do with opening up the borders but I am mentioning them because they appear in Pasi's article and I thought they deserved some extra attention. Now let's put all the side notes aside and go back to opening up them borders. | ||
- | === The Code === | + | ===== The Code ===== |
Some notes on the code. In Kick Assembler the " | Some notes on the code. In Kick Assembler the " | ||
Using constructs like <irq and >irq resolves into the least significant byte and most significant byte of a 16 bit address respectively. | Using constructs like <irq and >irq resolves into the least significant byte and most significant byte of a 16 bit address respectively. | ||
Line 262: | Line 262: | ||
</ | </ | ||
- | |||
base/opening_up_the_borders_-_a_further_explanation.1457624828.txt.gz · Last modified: 2016-03-10 16:47 by thehighlander