Banking VIC Color RAM

Started by airship, October 13, 2007, 01:26 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

airship

Here's a quote from Christian Johansson's incredible C128 assembly language programming page at http://folkvagn.commodore64.org/c128assembly.htm :

QuoteFor both the Commodore 64 and the Commodore 128, the colour RAM occupies the area from address $D800 to $DBE7. However, the Commodore 128 has as mentioned earlier two 64 kB RAM banks and it is possible to select which of these two banks that contains the colour RAM seen by the CPU or by the VIC chip. Bit 0 in the register at address $0001 defines which colour RAM bank that is seen by the CPU while bit 1 in the register at address $0001 defines which colour RAM bank that is seen by the VIC chip. This makes it possible to quickly change the colours of a whole screen. The CPU can define the colours in a colour RAM bank that is not seen by the VIC chip and when it wants the colours to appear on the screen, it just switches in the colour RAM bank it has written to so that the VIC chip can see it. (Bits 0 and 1 in the register at address $0001 are on the Commodore 64 used for switching in or out BASIC or Kernal ROM, which on the Commodore 128 is taken care of by the MMU.) The switching of colour RAM bank seen by the VIC chip can be used to slightly improve some of the advanced VIC graphics modes. For example, in FLI mode, the colour RAM bank can be switched every fourth raster line and in IFLI mode it can be switched every frame. I have come up with this idea for improvement myself. I don't know if anyone else has had the same idea before and if it in that case has been tested in practise. Note that this feature is only possible in C128 mode.
Does anyone know if any graphics demos or editors use this color RAM banking scheme on the C128?

I'm particularly intrigued by his assertion that you can change the color RAM bank every four raster lines in FLI mode. It seems to me that you should be able to update a character row of color RAM in that amount of time, right? So you should be able to get two sets of colors in every character row, one for the upper half of a character and one for the lower half. Or am I missing something?

Changing it every frame in IFLI is also interesting, since phosphor persistence, smear, and persistence of vision should blend to create some nice blended colors.

It would also mean that doing the internal C128 RAM expansion to create 4 banks would give you lots more versatility with both screens AND colors in VIC displays.
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine

wte

QuoteDoes anyone know if any graphics demos or editors use this color RAM banking scheme on the C128?
:D The normal splitscreen (multi color / text) of the C128 usees both Color-RAM banks :D
GRAPHIC 4,1,10
Color-RAM bank 0 is for text (the same RAM is visible in the c64)
Color-RAM bank 1 is for multi color graphic (never visible in C64 mode!)

But this two (half byte) RAM banks are completely independent/separated from the "normal" RAM banks 0/1!

I think in the VIC interlaced Mode [ http://landover.no-ip.com/128/viewtopic.php?id=821 ] the interlace for multi color should also use this feature to expand the colormap for color #3 (not possible in c64 mode). I think (hope) it will do so, but I don't know.

WTE

airship

Just goes to show how dangerous it is for the ignorant (me) to discover even a small nugget of knowledge. :)
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine

wte

Quote from: airshipJust goes to show how dangerous it is for the ignorant (me) to discover even a small nugget of knowledge. :)
But it really IS a nugget! And yes it should be possible to enhance color modes with the second color ram.
Maybe "Risen from Oblivion" is dealing with ist (I don't know). And for C64 user it is a nugget that they never can see :P

By the way, checking Christian Johansson's quote, i didn't found a correct and comprehensive description of the use/functionality of the CPU port bits in the 8502 in the www. Always: ... bla, bla, 8502 is compatible to the 6510 bla, bla but 7 instead of 6 bit port (used for ASC/DIN), bla, bla - end. A real lack of documentation. :förvånad:

hydrophilic

It is very useful and probably the best thing the C128 VIC has over the C64.  This makes scrolling a color screen sooo much easier.  The VIC Interlace demo uses it for FLI text mode so you get 50 rows of different colors.  This could also be done in bitmap mode but I'm not aware of any program that does.

You could, in theory, update 4 rows of color in the time of 4 rasters, BUT it would have to be very simple.  For example,
LDA #4 ;new color of cyan
STA $D800
STA $D801
STA $D802
...
STA $D827

would take 2+4*40 = 162 cycles.  PAL has 63 cycles and NTSC has 65 cycles / raster, or an average of 64 cycles/raster.  So that means 256 cycles available, or 94 cycles to spare.

Different colors are also possible like this
LDA #c0 ;color for column 0
STA $D800
LDA #c1 ;color column 1
STA $D801
...
LDA #c39 ;color column 39
STA $D827

would take 6*40 = 240 cycles which leaves 16 cycles to spare.  I don't think you could do any fancy tricks with those 16 cycles but I could be wrong... Oh no!  I just remembered that VIC will steal 40 cycles every bad line so this probably wouldn't work :(

Of course this is not practical for anything useful except a picture viewer / title screen.  Note that a more useful routine like
LDX #39
loop:
LDA color,X
STA $D800,X
DEX
BPL loop

would take 2+40*(4+5+2+3)-1 = 561 cycles which is far too long for 4 rasters, or even 8 rasters.

Which is the reason swappable color RAM is awesome :cool:

airship

So... is there a single bit that controls which bank of color RAM is used, or could you get two more banks if you added another 128k of internal memory to your C128?  :o
Serving up content-free posts on the Interwebs since 1983.
History of INFO Magazine

hydrophilic

The Color RAM is completely seperate from system RAM, like VDC RAM except easy to access.  It's in a 2K static RAM and you have 1 bit to select which 1K you want.  There is another 1 bit which selects which 1K the VIC actually uses (so you can update RAM without affecting the display).

You know, the Color RAM is actually an 8-bit static RAM (U19, a 2016), even though the Color RAM Buss is only 4-bits wide (the other 4 bits, pins 14~17, are tied to +5V through 3.3K resistors).  If someone really wanted to, they could figure out how to access the other half.  Then you'd have 4 color RAM banks.  Since the C128 lets you use /GAME and /XROM as outputs, you could use those to select the extra RAM: one line for CPU access and the other for VIC.