POKE 7424,0 - What is this memory for?

Basic and Machine Language

Moderator: Moderators

Post Reply
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

POKE 7424,0 - What is this memory for?

Post by allenhuffman »

Can anyone tell me what is going on with memory 7424 to 7432? All I can find online is that it is just "User BASIC RAM". I find examples of storing assembly language programs there, too. For some reason, in one of my old games, I did this:

FOR A=7424 TO 7432:POKE A,0:NEXT A

I am not sure what this is for. What is in that memory range that is significant? I can't find anything.

I had some other POKEs at the start, which appear to be ones to disable LIST, RESTORE and STOP. I also am loading data in to 7168-7303 which I believe is my custom character set for the game. Another POKE seems to be setting screen border colors and such (36879,26).

It's amazing that there was a time when I knew all this :) I think most of my information came from Compute's Gazette since, at the time, I didn't know anyone with a VIC-20 yet. There was only one store that we could find in all of Houston that sold anything for the VIC-20 (beyond stores that sold it and Commodore cartridges).

Fun times!

Thanks for helping me remember.

Image
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: POKE 7424,0 - What is this memory for?

Post by Mike »

Hint: (7424-7168)/8 = 32, which is the screen code for SPACE.
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

Re: POKE 7424,0 - What is this memory for?

Post by allenhuffman »

Mike wrote:Hint: (7424-7168)/8 = 32, which is the screen code for SPACE.
Ah, of course. So 7168 is the start of programable character set memory, and I am customizing the first range of characters, then leaving some alone, and wanting to set the "space" character slot so I have that available. There is a method to the madness! Thanks.

I am doing an blog post dissecting my old programs, and need to look at the second part of this one next to see how it enables the custom characters.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: POKE 7424,0 - What is this memory for?

Post by Mike »

7168 (=$1C00) is just one of several possible starts for user defined character sets.

There is one good reason to set the UDG of SPACE (7424..7431) to all bytes zero: otherwise you'll get 'crap' characters in parts of the screen normally supposed to be blank, as soon as the foreground colour there is different from the background colour. This is normally not directly visible, as both background and foreground are normally set to white. But a freshly powered on VIC-20 doesn't clear its memory, there's always some (most of alternating) pattern of 255 and 0 stored in uninitialized memory - and also in 7424..7431.

My bet is you actually saw those crap characters at that time, and then went to clear the definition of UDG SPACE, which was the Right Thing™ to do. :)
I [...] need to look at the second part of this one next to see how it enables the custom characters.
This is done with POKE36869,255, which sets the base of the character set to $1C00, and leaves the screen at $1E00.

You'll get UDGs from 0..63, the definitions of screen codes 64..127 overlap with the text screen and are thus unusable[1], and you can access the non-inverted ROM character set by PRINTing/POKEing those on screen in reverse - thanks to an address wraparound in the VIC chip.

Cheers,

Michael

[1]: it is possible to put the screen at $1A00, which will make all characters 0..127 available. It is also possible to redefine the entire character set, by putting it at $1800 and the text screen at $1600. Other combinations are also possible, but more useful when a bigger RAM expansion (+8K or more) is used.
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

Re: POKE 7424,0 - What is this memory for?

Post by allenhuffman »

Mike wrote:7168 (=$1C00) is just one of several possible starts for user defined character sets.

...
You'll get UDGs from 0..63, the definitions of screen codes 64..127 overlap with the text screen and are thus unusable[1], and you can access the non-inverted ROM character set by PRINTing/POKEing those on screen in reverse - thanks to an address wraparound in the VIC chip.
I think, back when I was 12 and learning my first computer, all of this was "magic" and I just knew the POKEs to do. Today, it makes sense.

The VIC chip has no true graphics mode, correct? How did something like the Super Expander manage to make one? 22x23 would be 506 characters. How would it be able to map more characters on the screen to use them like bitmap data?
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

Re: POKE 7424,0 - What is this memory for?

Post by allenhuffman »

Mike wrote:[1]: it is possible to put the screen at $1A00, which will make all characters 0..127 available. It is also possible to redefine the entire character set, by putting it at $1800 and the text screen at $1600. Other combinations are also possible, but more useful when a bigger RAM expansion (+8K or more) is used.
Ah, I see that some things move around. That may explain why some of my programs are not working as intended right now (I added memory to the emulator). I never had any extra RAM on my VIC, except when using the Super Expander.

The 4K RAM seems to be:

1000-1DFF - User BASIC area (3583 bytes)
1E00-1FFF - Screen memory (511 bytes)

That should be 4K, but then there is the cassette buffer, keyboard buffer, etc. Where does that memory come from? Is there actually more RAM in the machine, but 4K is what BASIC gets to use?
User avatar
tokra
Vic 20 Scientist
Posts: 1120
Joined: Tue Apr 27, 2010 5:32 pm
Location: Scheessel, Germany

Re: POKE 7424,0 - What is this memory for?

Post by tokra »

There are 5K of RAM in an unexpanded VIC-20

1K at $000-$03ff
4K at $1000-$1fff

Regarding graphics you can put the VIC into an 8x16 character mode which makes it possible to map all 512 chars to the screen and redefine them. However since 512 chars x 8 bytes = 4096 bytes this leaves no room for the video-RAM itself. The best mode to use without loosing Commodore BASIC is using 240 chars of 8x16 resolutions set up in a 20x12 grid for a resolution of 160x192. This mode takes (480x8+240)=4080 bytes and neatly fits into the 4K-area the VIC-chip can see.

This is the mode used by Mike's MINIGRAFIK basic-extension and MINIPAINT. If you want to familiarze yourself with the VIC-20 again I would highly recommend "Programming the VIC", which can be found here:

http://www.bombjack.org/commodore/books-vic.htm
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: POKE 7424,0 - What is this memory for?

Post by Mike »

tokra wrote:It is possible to map all 512 chars to the screen and redefine them. However since 512 chars x 8 bytes = 4096 bytes this leaves no room for the video-RAM itself. [...]
Of course those are still 256 characters, even if double-height. But then, 256 chars x 16 bytes also equals 4096. :wink: So, the double-height character feature allows a character set to span a full 4K.

@allenhuffman: Four other things to consider, when the screen is set up as bitmap:

- the VIC chip can only(!) access the internal RAM, and the character ROM for text screen/character data (colour RAM goes extra),

- any (VIC accessible) memory, which isn't used for the text screen, is always available for the character definitions of the bitmap,

- when the text screen is laid out with unique characters to address the bitmap, it doesn't need to 'start' with character #0,

- sensible arrangements of the characters are row-wise (similar to C64) or column-wise (used by MINIGRAFIK).


MINIGRAFIK puts both text screen and character set base at $1000. The text screen uses 240 bytes, but the first used character is 'P' (value 16), so the bitmap actually starts at $1100. There are 240 characters with the numbers between (and including both) 16 and 255, so the bitmap extends from $1100 to $1FFF. The small gap left at $10F0 .. $10FF also finds good use within the BASIC extension. :)
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

Re: POKE 7424,0 - What is this memory for?

Post by allenhuffman »

Mike wrote: Of course those are still 256 characters, even if double-height. But then, 256 chars x 16 bytes also equals 4096. :wink: So, the double-height character feature allows a character set to span a full 4K.
Aha! That makes much more sense to me now.
Mike wrote: - the VIC chip can only(!) access the internal RAM, and the character ROM for text screen/character data (colour RAM goes extra),
By this, do you mean the VIC chip only has access to the main 5K range?
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: POKE 7424,0 - What is this memory for?

Post by Mike »

allenhuffman wrote:By this, do you mean the VIC chip only has access to the main 5K range?
Exactly this. Only the built-in RAM ($0000..$03FF and $1000..$1FFF) and the character ROM is 'visible' to the VIC chip.

Even though it appears that the VIC registers allow for a text screen address and character set base in the range $0400..$0FFF: the +3K RAM expansion (regardless what kind: 'raw' or Super Expander) cannot be used by VIC. Neither can any of the bigger RAM expansions.
allenhuffman
Vic 20 Amateur
Posts: 46
Joined: Fri May 21, 2010 11:50 pm
Website: http://www.subethasoftware.com
Location: Des Moines, Iowa, US
Occupation: Embedded programmer.

Re: POKE 7424,0 - What is this memory for?

Post by allenhuffman »

tokra wrote:If you want to familiarze yourself with the VIC-20 again I would highly recommend "Programming the VIC", which can be found here:

http://www.bombjack.org/commodore/books-vic.htm
Wow. This is great. Thank you for the reference. I had zero books on the VIC when it first came out (I'm not sure there were any yet) so my only source of information was a few magazines. I think I want to, at the very least, update my original batch of games (and finish the ones that don't seem to be fully baked).
Post Reply