Color High Nibbles

Basic and Machine Language

Moderator: Moderators

Post Reply
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Color High Nibbles

Post by PhilRanger »

Hi,

Do the high nibbles of the color area (38400-... on unexpanded vic) have any use?
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

The colour ram is only 4 bit, so they high bits are seemingly random.
I think their values will be a by-product of last thing on the bus.
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Free memory! A bit complex to get to, but still free memory: 256 bytes + the 6 last ones as the color memory (like the screen memory) uses only 506 of the 512 addresses. Or am I missing something?
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
matsondawson
The Most Noble Order of Denial
Posts: 343
Joined: Fri May 01, 2009 4:44 pm

Post by matsondawson »

Ah I see what your saying. Yes, free memory. You actually get 512+6 nibbles of it.
wimoos
Vic 20 Afficionado
Posts: 352
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Post by wimoos »

These nibbles came out handy in my (WimBasic) version of the Maze (see elsewhere in this forum), because they were easy to map 1-on-1 on screen locations and 4 bits info was wide enough for the purpose.

Regards,

Wim.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PhilRanger wrote:Free memory! A bit complex to get to, but still free memory: [...]
If you need a little more memory there, here's a simple method to expand the colour RAM. :mrgreen:
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Mike wrote:If you need a little more memory there, here's a simple method to expand the colour RAM. :mrgreen:
You are evil, sir. :twisted:

But there's no denying those are very impressive results.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Sorry, siliconed girls and modded computers aren't my cup of tea!
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PhilRanger wrote:Sorry, siliconed girls and modded computers aren't my cup of tea!
Thorough hardware knowledge surely isn't necessary, but at least a bit of it can help to understand why things work as is on the VIC-20:

- The colour RAM is actually 1024 4-bit nibbles in size, and ranges from 37888 ($9400) to 38911 ($97FF). That is, how the 6502 main CPU "sees" the colour RAM.

- During the half-cycle while VIC access the memory, the colour RAM is separated from the normal RAM. Instead there are extra 4 data lines going into the VIC chip, so character data and colour data are read simultaneously over a 12-bit bus. The colour RAM shares the 10 lower address lines with the screen RAM.

- For this reason, the colour RAM also shifts around, when the screen is relocated to 4096 with 8K RAM expansion, or more: 7680 (screen start with unexpanded or +3K) leaves a remainder of 512 when divided by 1024 -> 37888 + 512 = 38400 (=colour RAM start address); 4096 (screen start address with +8K or more) is divisible by 1024 -> colour RAM start address = 37888.

- The VIC chip can change the screen geometry to display more than 506 characters, for example 32 rows with 26 columns. This would need 832 nibbles in the colour RAM, but of course there are still 192 nibbles, amounting to 96 bytes left. :P

- If I have to choose between normal RAM in an expansion cartridge, and colour RAM to store data, I'd nearly always take the former. Unless the data is already 4-bits wide, as Wim already noted: for example in MAXIGRAFIK, the "unused" half of colour RAM is used as mirror copy of the colour RAM data in hires mode.

Yes, your idea is an decidedly old hat.
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Mike wrote:Thorough hardware knowledge surely isn't necessary, but at least a bit of it can help to understand why things work as is on the VIC-20:
I like it. I wish my wife would talk like that to me once in a while!
Mike wrote:- The colour RAM is actually 1024 4-bit nibbles in size, and ranges from 37888 ($9400) to 38911 ($97FF). That is, how the 6502 main CPU "sees" the colour RAM.
Do you mean there is no RAM chip for the high nibble so it's not useable?
Mike wrote:- During the half-cycle while VIC access the memory, the colour RAM is separated from the normal RAM. Instead there are extra 4 data lines going into the VIC chip, so character data and colour data are read simultaneously over a 12-bit bus. The colour RAM shares the 10 lower address lines with the screen RAM.

- For this reason, the colour RAM also shifts around, when the screen is relocated to 4096 with 8K RAM expansion, or more: 7680 (screen start with unexpanded or +3K) leaves a remainder of 512 when divided by 1024 -> 37888 + 512 = 38400 (=colour RAM start address); 4096 (screen start address with +8K or more) is divisible by 1024 -> colour RAM start address = 37888.
Got it.
Mike wrote:- The VIC chip can change the screen geometry to display more than 506 characters, for example 32 rows with 26 columns. This would need 832 nibbles in the colour RAM, but of course there are still 192 nibbles, amounting to 96 bytes left. :P
So half of the color ram is always unused in normal resolution? (unless you use 2 screens and switch between them)
Mike wrote:- If I have to choose between normal RAM in an expansion cartridge, and colour RAM to store data, I'd nearly always take the former. Unless the data is already 4-bits wide, as Wim already noted: for example in MAXIGRAFIK, the "unused" half of colour RAM is used as mirror copy of the colour RAM data in hires mode.
But if you don't have enough memory you could use some (I guess 512 + 6 nibbles, taking for granted this RAM is nibbles, not bytes?) Many variables could fit in 4 bits: level, number of ennemys, etc.
Mike wrote:Yes, your idea is an decidedly old hat.
Meaning other people used it before me? Sorry, my English isn't perfect for idiomatic experssions!
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
User avatar
Mike
Herr VC
Posts: 4901
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

PhilRanger wrote:Do you mean there is no RAM chip for the high nibble so it's not useable?
Exactly.
So half of the color ram is always unused in normal resolution? (unless you use 2 screens and switch between them) [...] But if you don't have enough memory you could use some (I guess 512 + 6 nibbles, taking for granted this RAM is nibbles, not bytes?) Many variables could fit in 4 bits: level, number of enemys, etc.
Yes, you can use the colour RAM this way. Writes proceed as normal, but when read back, the high nibble just reflects random 'bus noise' *), and needs to be masked out with 'AND #%00001111' or the like.
other people used it before me?
Taking the unused colour RAM for storage has indeed been explicitly mentioned before in Denial. Wim's maze example and the mirror copy in MAXIGRAFIK are just two of the more recent uses.

Michael
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Post by PhilRanger »

Thanks Mike! :D
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
Post Reply