VIC-20-MEMORY-PARADE-DEFAULT-SETTINGS-&-MORE -------------------------------------------------------------------------------------------------- TOOL: COMMODORE VIC-20 - BASIC 2 Language: BASIC Extra: - Author: Misel Zivanovic Note: (C) 8th JAN 2026 - www.lived.ch, mzretro.ch Updated on 29.05.2026 --------------------------------------------------------------------------------------------------- Well, it's clear i couldn't just pull all this information out of my butt, so several books had to face my brutal judgement. Won't name them here because they are all in VIC-20 Download-Department! And also VIC-20 journey helped a lot here! FEW FACTS: 1. BASIC cannot go beyond 24KB of memory {and memory can be extended up to 48KB} But you can use that memory for all other things {Just not cooking!} 2. VIC-20 is relocating default memory areas as soon as you have more then 8KB of RAM which means, SCREEN AREA, COLOR MAP AREA and BASIC AREA is relocated to different addresses 3. That lead to assumption how it's wise to check what's going on before you start your program! and give a proper warning or start adapted version of your program to run it also with less memory. Bottom conclusion: avoid crashes! 4. If the VIC-20 can relocate everything, then we can too! Sounds GREAT, but will it work!? 5. Custom fonts have a specific start addresses and are also having fix pointers to those locations. It means you cannot have you font beyond 8KB area! It must be within first 8KB area! {Which is paradox because 3KB RAM that can be added to existing 5KB, default VIC-20 RAM, is also an expansion! Well, well, someone was greedy back then!} So 3KB BLOCK 0 doesn't count {it is within 8KB range, total}, However, every other 8KB RAM expansion does! {BLOCK 1 to {4} 5} {And the reason why you cannot do all that: VIC-20 can see just first 8KB!} And actually, if you add 8KB RAM you have had 3KB already added, 3KB will be ignored by BASIC! 3KB RAM will be available to put there what ever you want, just no BASIC lines! That bring us to conclusion how 3KB isn't needed if you'll just do BASIC without the assembler or have no plans to use BASIC-Unused 3KB otherwise! Just extend to BLOCK 1, 8KB RAM directly. 6. There is no area for hardware sprites because VIC-20 has no hardware sprites. It has [can have} however a very flexible bitmap screen where you can move things around, pixel-wise, not just bytewise. It brings smooth scrolling, but it eats so much memory that you probably won't be able to use the full-screen to have fun! Luckily, you can do split-screen and have a portion of the screen pixel-wise and the other part use as a normal text area. 7. I am sure there is more, but let's finish here for now! --------------------------------------------------------------------------------------------------- UPDATE: 28.05.2026 I obviously missed this until today. As it looks, if you add 3KB Memory {RAM BLOCK 0} and then add another 8KB in e.g. RAM BLOCK 5 to be able to load/attach a cartridge in that area, then the RAM actually isn't extended and SCREEN AREA won't change and also the BASIC area WILL NOT change! It will all remain like you would just have default RAM and additional 3KB in BLOCK 0 Basically, if you would wanna have 3KB in BLOCK 3 free for assembly and have BASIC start address @ 4608, then you would need to add additional 8KB RAM of RAM in e.g. RAM BLOCK 1 So your setup would be: 5KB default, 3KB RAM BLOCK 0, 8KB RAM BLOCK 1 and 8KB RAM BLOCK 5 {cartridge} --------------------------------------------------------------------------------------------------- MORE MEMORY AND WHAT IT CHANGES! {29.05.2026, now also with hex values!} ------------------------------------------------------------------------------------------------------------- EXPANSION RAM | TOTAL-RAM | AVAILABLE | COLOR MAP AREA | SCREEN MEMORY | BASIC START | BASIC END | --------------|-----------|---------------|----------------|----------------|---------------|---------------| --------------|-----------|---------------|----------------|----------------|---------------|---------------| NO EXPANSION | 5KB | $0dff | 3583 | $9600 - 38400 | $1e00 - 7680 | $1000 - 4096 | $1dff - 7679 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 3KB | 8KB | $19ff | 6655 | $9600 - 38400 | $1e00 - 7680 | $0400 - 1024 | $1dff - 7679 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 8KB | 13KB | $2dff | 11775 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $3fff - 16383 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 8+3KB | 16KB | $2dff | 11775 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $3fff - 16383 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 16KB | 21KB | $4dff | 19967 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $5fff - 24575 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 16+3KB | 24KB | $4dff | 19967 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $5fff - 24575 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 24KB | 29KB | $6dff | 28159 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $7fff - 32767 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 24+3KB | 32KB | $6dff | 28159 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $7fff - 32767 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 32KB | 37KB | $6dff | 28159 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $7fff - 32767 | --------------|-----------|---------------|----------------|----------------|---------------|---------------| 32+3KB | 40KB | $6dff | 28159 | $9400 - 37888 | $1000 - 4096 | $1200 - 4608 | $7fff - 32767 | ------------------------------------------------------------------------------------------------------------- These lines can tell you how much memory VIC-20 has. {It's showing one byte more than the system startup message} {I guess it's counted from 1 and not from 0} 10 ms=peek(641)+peek(642)*256 20 me=peek(643)+peek(644)*256 30 print me-ms;"bytes free" BOTTOM LINE: As soon as you have more than 3KB Expansion, 3KB remain unused by BASIC source code! {Exception: {If you have attached more 1 RAM BANK more to load a CARTRIDGE software, {it doesn't count as more RAM} {To get the 3KB free for assembly code, you would need to attach 1 additional 8KB RAM BANK} The memory expansion above 24KB remain unused by BASIC source code. Fortunately, you still have the access, even from BASIC, to that memory area. What i could imagine, is to make a data loader program, which will transfer all the needed data to those by BASIC source code unused memory area and then load the actual BASIC program, which is going to access the data. Can't think of anything else but game level data. Maybe text files and graphics for a nice text adventure game... That would give you plenty of space in the actual BASIC area because you wouldn't need to have tons of DATA lines within your main program. More room to make your game great! {Or whatever your plans will be...} --------------------------------------------------------------------------------------------------- POSSIBLE SCREEN-MAP AREAS |POKE 36869,PEEK(36869) AND 15) OR X | |POKE 36866,PEEK(36869) AND 127) OR Y | |POKE 648,SCREEN-AREA/256:CLR | |{instead of CLR also SYS 58648 is OK}| -----------------------------------------------------------|------------------|------------------| SCREEN-AREA | COLOR-MAP | POKE 36869,X |POKE 36866,Y| REPLACE variable | --------------|---------------|---------------|------------|--------|---------| DEC | HEX | DEC | HEX |128|064|032|016|-----128----|...OR X |...OR Y | ------|-------|-------|-------|---|---|---|---|------------|--------|---------| 4096 | $1000 | 37888 | $9400 | 1 | 1 | 0 | 0 | 0 | 192 | 0 | ------------------------------------------------------------------------------| 4608 | $1200 | 38400 | $9600 | 1 | 1 | 0 | 1 | 1 | 192 | 128 | ------------------------------------------------------------------------------| 5120 | $1400 | 37888 | $9400 | 1 | 1 | 0 | 1 | 0 | 208 | 0 | ------------------------------------------------------------------------------| 5632 | $1600 | 38400 | $9600 | 1 | 1 | 0 | 1 | 1 | 208 | 128 | ------------------------------------------------------------------------------| 6144 | $1800 | 37888 | $9400 | 1 | 1 | 1 | 0 | 0 | 224 | 0 | ------------------------------------------------------------------------------| 6656 | $1a00 | 38400 | $9600 | 1 | 1 | 1 | 0 | 1 | 224 | 128 | ------------------------------------------------------------------------------| 7168 | $1c00 | 37888 | $9400 | 1 | 1 | 1 | 1 | 0 | 240 | 0 | ------------------------------------------------------------------------------| 7680 | $1e00 | 38400 | $9600 | 1 | 1 | 1 | 1 | 1 | 240 | 128 | You can have more than one screen, color map and user characters, however you cannot have them outside of the 8KB RAM. VIC-20 is coming with 5KB. You can add 3KB to not jump over the 8KB border. That leaves you 6655 bytes free. However, adding fonts, more screens etc. would exhaust 6.5KB in no time and at the end not much RAM would remain to make something. Ergo, 8KB RAM would be better choice because it would give you a bigger area for the BASIC source code. Now again the 3KB RAM in combination with 8KB RAM. I mentioned that somewhere already... If you have 3KB + 8KB then BASIC will ignore 3KB and use just 8KB. However, you will be able to use 3KB anyway from BASIC! E.g. you could plant there a lot's of small assembly routines. {You can check the Assembler section! I am working on examples there. Short assembly routines with a big impact!} To call those routines, you would just need to call them with SYS command. COMPUTE!'s "Mapping the VIC" is explaining on page 131 how exactly screen, color map etc. I don't see it useful for VIC-20 with 8KB RAM and won't go into furter details here. But you know now where to find the info. --------------------------------------------------------------------------------------------------- NOW A THING ABOUT LINE MEMORY AND LOOPS. VIC-20 can do 88 characters per line. Which is 8 MORE than C64 and 72 LESS than C128. You can say how, if more than 80 character per line were used, that it would be easier to transfer the program to be C128 compatible. I always thought when i got OUT OF MEMORY message, that I actually ran out of memory. And that isn't false thinking! It really is so, however, it can also be connected JUST to BUFFER MEMORY! Meaning, you can still have plenty of memory free, but not the buffer area, which is 512 bytes large {small}. This is something i just learned. Had no idea how NESTED FOR NEXT and GOSUB are eating the BUFFER MEMORY like these guys have nothing else to do! 5 bytes hungry is GOSUB and 18 bytes will cost you any FOR NEXT LOOP! If you have a large program and use tons of GOSUB and FOR NEXT it could happen to stumble on the OUT OF MEMORY error when there is less than 62 bytes free BUFFER MEMORY remaining! While writing my game for C128, The Treasure Hunter, exactly this OUT OF MEMORY stopped me. And I am using there many many many FOR NEXT LOOPS, GOSUBS and RETURNS accordingly. I thought i ran out of the MAIN MEMORY, now i see it also could have been just the BUFFER issues and all i need to do is optimizing the code, eliminate FOR NEXT LOOPS and GOSUB where really isn't necessary and probably i can finished the game! {I went to check the "Mapping the C128" book and there it also says how in addition to FOR NEXT also DO LOOPS are using 5 bytes! I never saw this before in the past and i read that book close to daily, haha} Who knew that VIC-20 would be of such help! Nice! --------------------------------------------------------------------------------------------------- WHERE CAN I SAVE/PUT ASSEMBLER CODING? I think already dinosaurs knew this one! TAPE BUFFER starting @ $33c or dec 828. From this location, you can go up 192 bytes and use for your assembler lines without having to change any pointers. HEX DEC SIZE ------------------------------------------- PAGE 0: ------------------------------------------- $00fb - $00fe 0251 - 0254 0004 bytes ------------------------------------------- OTHER LOCATIONS: {there is more, but not really free} ------------------------------------------- $0295 - $0296 0661 - 0662 0002 bytes $02a1 - $02ff 0673 - 0767 0094 bytes $0310 - $0313 0784 - 0787 0004 bytes $033c - $03fb 0828 - 1019 0192 bytes $03fc - $03ff 1020 - 1023 0004 bytes ---------- 0300 bytes { <- This is a lot! } ----------------------------------------------------------------------------------------------------- AND NOT TO FORGET: {ONLY AVAILABLE** WHEN YOU HAVE 3KB+*8KB MEMORY EXPANSION} {** = Only if in that 8KB RAM no CARTRIDGE is installed! If it ism, then you must add another 8KB RAM} {to get the 3KB RAM BLOCK 0 free for assembly coding!} ----------------------------------------------------------------------------------------------------- $0400 - $0fff 1024 - 4095 3072 bytes { <- This is even more a lot than "this is a lot" } { Now we just need to know how and for what to use it } ---------- 3372 bytes { <- VERY GREAT NUMBERS! } ----------------------------------------------------------------------------------------------------- THE MATRIX I see that VIC-20 also has a possibilities to check the matrix of the keyboard. Address 197,$c5 This is very useful! Not only for the machine language, but also in BASIC. I will not check every key, just those i am planning to use in lessons! PEEK(197) will give you the needed code. Default value is 64, hex #$40 k=peek(197):if k=48 then end In assembler: ask lda $c5 read 197 address cmp #$30 is it 48, Q beq quit then quit jsr main do something else whatever you do bne ask repeat the loop until {one of the button is hit we need} quit rts return to BASIC {or Subroutine} main lda #$08 add 8 to accumulator sta $900f set screen and background to black, not reversed! rts back to subroutine ---------------------------------------------------- KEY MATRIX-CODE PURPOSE ---------------------------------------------------- Q 48 QUIT the program, game, etc. W 9 Move FORWARD A 17 Move LEFT S 41 Move BACK D 18 Move RIGHT R 10 REPEAT N 28 NEW T 50 TRASH I 12 INTRO P 13 PLAYER --------------------------------------------------- That pretty much is it for now in regard to this. If i find something interesting during the VIC-20 journey, I will add it here... ----------------------------------------------------------------------------------------------------- A GENERAL WORD ABOUT RAM EXPANSIONS FOR VIC-20 AND THE VIC-20 BATTLE STRATEGY! And some thoughts about old Commodore Management! ----------------------------------------------------------------------------------------------------- From what i have experienced so far, it can be concluded how Commodore made a GIANT MISTAKE NOT TO GIVE Hardware Sprites and at least 16KB RAM from scratch to VIC-20. I downloaded many books with VIC-20 subject and among them were also VIC-GAMES. And i was really surprised how out of all games just 2 needed +3KB RAM, many games even wouldn't run with inserted RAM Expansion. And most said base VIC-20 is enough, so 5KB or 3.5KB usable. So what's the motivation to buy any RAM Expansions?! COMPUTE! made following statement in one of their books {Creating Arcade Games on the VIC, 1984}: "...and since I want this book to be valuable to the largest number of readers, almost everything we do here can be done in 5K" I mean, really! Was that the Commodore Management top performance? Jesus, they were happy with 1 million sold devices and it could have been 50 million with 2 small additions! Hardware Sprite and more RAM! That were still the pioneer times... People were hungry and got unfinished bread{bin} on the table and mainly lost the appetite {the same happend after the C64 with C series... And then later with C128!} C64 show them how it is done and afterwards they STILL NEVER AGAIN managed to do it properly. That is absolutely and totally NOT understandable and at the same time, also understandable: Old Commodore company JUST GOT LUCKY 1x WITH COMMODORE C64 and then it was a game over! When money was gone, Commodore was gone! What a shame!!! Well, thanks for all the 8-bit Commodore computers anyway! What you were unable to do like God commanded {except C64} back then, the NEW COMMODORE will manage to do it NOW, TODAY, for sure {I assume, hehe...}