Page 1 of 1

Reading Colour RAM

Posted: Mon May 05, 2025 2:46 pm
by SparkyNZ
I've noticed that if I try to do a PEEK(38400), I don't always get the actual colour value back - and I see the same thing in VICE (unexpanded Vic).

When the kernel scrolls the screen up (as it would during a LIST for example), I assume that the the kernel must read the colour RAM in order to move the colour codes up the screen.

What is needed in order to read the colour RAM correctly - and what causes the changing values that I see at 38400?

Re: Reading Colour RAM

Posted: Mon May 05, 2025 4:39 pm
by Wilson
The color RAM is only 4-bit. What you read on the upper 4 bits will just be garbage on the bus.
You need to AND your read value with $0f to get the actual contents of the memory between $9400-$9800.

Re: Reading Colour RAM

Posted: Mon May 05, 2025 4:45 pm
by SparkyNZ
Wilson wrote: Mon May 05, 2025 4:39 pm The color RAM is only 4-bit. What you read on the upper 4 bits will just be garbage on the bus.
You need to AND your read value with $0f to get the actual contents of the memory between $9400-$9800.
Oh, is it that simple? Hehe. Of course - that makes perfect sense now. Thanks for that :-)

Re: Reading Colour RAM

Posted: Wed May 07, 2025 9:45 am
by Orangeman96
Wilson wrote: Mon May 05, 2025 4:39 pm The color RAM is only 4-bit. What you read on the upper 4 bits will just be garbage on the bus.
You need to AND your read value with $0f to get the actual contents of the memory between $9400-$9800.
So is the high nybble is always garbage on the bus between $9400-$9800 / 37888-38912? -OGM

Re: Reading Colour RAM

Posted: Wed May 07, 2025 4:54 pm
by AndyH
Yes, those bits are just not available.

It can be used for storing data within these limitations for the range that's spare. On Emu's Massive Hunt I use it to store 4 flags per screen to determine what objects you've collected on that screen.

Re: Reading Colour RAM

Posted: Wed May 07, 2025 5:30 pm
by SparkyNZ
AndyH wrote: Wed May 07, 2025 4:54 pm Yes, those bits are just not available.

It can be used for storing data within these limitations for the range that's spare. On Emu's Massive Hunt I use it to store 4 flags per screen to determine what objects you've collected on that screen.
So whereabouts do your 4 bits actually get written to? The colour RAM chips are only 4bits wide I believe - so where do the other 4bits go if you're writing to $9600 for example?

Re: Reading Colour RAM

Posted: Wed May 07, 2025 5:40 pm
by AndyH
Depending where your screen is set, either $9400 or $9600 will be free to use (the lower 4 bits).

Re: Reading Colour RAM

Posted: Wed May 07, 2025 5:46 pm
by SparkyNZ
AndyH wrote: Wed May 07, 2025 5:40 pm Depending where your screen is set, either $9400 or $9600 will be free to use (the lower 4 bits).
Oh sorry, I thought you were meaning that the upper 4 bits could be used to store additional 4 bits of data.

Re: Reading Colour RAM

Posted: Wed May 07, 2025 6:46 pm
by Orangeman96
AndyH wrote: Wed May 07, 2025 5:40 pm Depending where your screen is set, either $9400 or $9600 will be free to use (the lower 4 bits).
So its only two low nybbles then, AndyH: the low nybble of $9400 (four bits) and the low nybble of $9600 (four bits)? -OGM

Re: Reading Colour RAM

Posted: Wed May 07, 2025 7:15 pm
by SparkyNZ
Orangeman96 wrote: Wed May 07, 2025 6:46 pm So its only two low nybbles then, AndyH: the low nybble of $9400 (four bits) and the low nybble of $9600 (four bits)? -OGM
I'm pretty sure the read of $9600 on an unexpanded Vic reads the same physical chip and location as $9400 does with 8K RAM expansion. In other words the address mapping changes when the 8K RAM is present, but the Vic chip is always accessing the same colour RAM chip locations in both cases.

If we had a screen that was smaller than the full colour RAM that is available, then we could use the unused colour RAM 4-bit locations that are at the end of the screen space. Maybe that's the bit I didn't get.

Re: Reading Colour RAM

Posted: Wed May 07, 2025 8:37 pm
by Orangeman96
SparkyNZ wrote: Wed May 07, 2025 7:15 pm
I'm pretty sure the read of $9600 on an unexpanded Vic reads the same physical chip and location as $9400 does with 8K RAM expansion. In other words the address mapping changes when the 8K RAM is present, but the Vic chip is always accessing the same colour RAM chip locations in both cases.

If we had a screen that was smaller than the full colour RAM that is available, then we could use the unused colour RAM 4-bit locations that are at the end of the screen space. Maybe that's the bit I didn't get.
Gotcha, Sparky, I was just trying to ascertain how many half-byte locations were acutally in-play/meaningfully-usable. -OGM

Re: Reading Colour RAM

Posted: Wed May 07, 2025 9:43 pm
by SparkyNZ
Orangeman96 wrote: Wed May 07, 2025 8:37 pm Gotcha, Sparky, I was just trying to ascertain how many half-byte locations were acutally in-play/meaningfully-usable. -OGM
If its 4-bit x 1K.. For a default screen size of 22x23, that would be 506 nybbles.. so I guess 1024 - 506 nybbles free?

Hehe. This is all quite fun and hacky - I would never have thought about using the colour RAM for additional memory :-)

Re: Reading Colour RAM

Posted: Thu May 08, 2025 12:16 am
by AndyH
Colour memory, with only lower 4 bits wired up are between $9400 and $97ff.

Mapping the Vic describes the memory range as bits 7-4 = not there, bit 3 = multicolour, bits 0-2 = foreground colour.

Bit 7 of $9002 affects the location of screen memory (along with $9005) but more importantly it also defines if colour memory starts at $9400 or $9600.

So for Emu I use the unused colour space for my screen item flags. Only lower nybble is usable.

In another game, Bluevolution, I use the spare colour ram for my meteor bits, like a double buffer. Again only the lower 4 bits used.

Re: Reading Colour RAM

Posted: Thu May 08, 2025 1:17 am
by Mike
So much for the rumours, here are the facts: https://sleepingelephant.com/ipw-web/bu ... 1&start=22

Re: Reading Colour RAM

Posted: Thu May 08, 2025 7:50 pm
by Orangeman96
Mike wrote: Thu May 08, 2025 1:17 am So much for the rumours, here are the facts: https://sleepingelephant.com/ipw-web/bu ... 1&start=22
Vielen Dank, Herr VC! :mrgreen: -OGM

(mod: unnecessary full quote of linked-to posting removed)