Hi
Where to place user-defined graphics/characters on a Vic20+3k while possibly having all or most of the ram for the code in a
contiguous block?
Fabrizio
UDG on a Vic20 + 3K?
Moderator: Moderators
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
- Mike
- Herr VC
- Posts: 5134
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: UDG on a Vic20 + 3K?
Regardless the +3K RAM expansion, the UDGs can still only be placed in the internal RAM ($1000..$1FFF, if we disregard $0000..$03FF), three main options (I suppose you stick with the standard screen size of 22x23 chars and single-height 8x8 pixel character definitions):
1. screen at $1E00, charset at $1C00: gives 64 UDGs, another 64 UDGs overlap with the screen, the upper 128 chars access the non-inverted ROM character set - RAM available for code and data: $0400..$1BFF ^= 6 KB,
2. screen at $1A00, charset at $1C00: gives 128 UDGs, the upper 128 chars again access the non-inverted ROM character set - RAM available for code and data: $0400..$19FF ^= 5.5 KB, and
3. screen at $1600, charset at $1800: gives a full set of 256 UDGs. RAM available for code and data: $0400..$15FF ^= 4.5 KB.
Take your pick.
1. screen at $1E00, charset at $1C00: gives 64 UDGs, another 64 UDGs overlap with the screen, the upper 128 chars access the non-inverted ROM character set - RAM available for code and data: $0400..$1BFF ^= 6 KB,
2. screen at $1A00, charset at $1C00: gives 128 UDGs, the upper 128 chars again access the non-inverted ROM character set - RAM available for code and data: $0400..$19FF ^= 5.5 KB, and
3. screen at $1600, charset at $1800: gives a full set of 256 UDGs. RAM available for code and data: $0400..$15FF ^= 4.5 KB.
Take your pick.

-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
Thanks!
I will need slightly more than 6k. My game currently takes 6430 bytes.
Maybe I could optimize it a little bit more and make it fit in about 6000.
The game is CROSS CHASE in its Vic20 + 3k version, which I write in C for any 8 bit computer/console/handheld.
How do I fix the char memory and screen memory at the right places for the 6k solution?
Which VIC registers do I need to set? Which bits?
I will need slightly more than 6k. My game currently takes 6430 bytes.
Maybe I could optimize it a little bit more and make it fit in about 6000.
The game is CROSS CHASE in its Vic20 + 3k version, which I write in C for any 8 bit computer/console/handheld.
How do I fix the char memory and screen memory at the right places for the 6k solution?
Which VIC registers do I need to set? Which bits?
- Mike
- Herr VC
- Posts: 5134
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: UDG on a Vic20 + 3K?
You'll have to assign the UDGs a dedicated static area in the *.cfg file, and link a prepared 512 byte file with the character definitions. Alternatively, just assign the program/data the restricted range $0400[1]..$1BFF and append the UDGs at $1C00 manually. In each case, the resulting binary (including the BASIC stub) then spans $0401..$1DFF.Linzino wrote:How do I fix the char memory and screen memory at the right places for the 6k solution?
Just set VIC register $9005 to $FF.Which VIC registers do I need to set? Which bits?
If you *really* want to be sure, that the screen memory is accessed by VIC at $1E00 and not $1C00, additionally set bit 7 (value: 128) of VIC register $9002; but it is already correct when the VIC-20 is started up with a +3K RAM expansion.
The colour RAM is located at $9600.
[1]: Actually, "$0400" with the necessary corrections to honor the BASIC start of $0401.
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
Thanks Mike!
CROSS CHASE already supports UDG in +8k and +16k Vic20 versions (CROSS CHASE is a game for *all* 8 bit computer/consoles/handhelds).
The VERY SAME C CODE is used for all computers/consoles except for the hardware-specific code in some cases.
The game has 3 versions (generated also by the same meta-code): TINY (6k-8k), LIGHT (about 10-14k), FULL (about 16k-18k).
For the +8k and +16k Vic20 configs I use an external .s file .byte pseudo-opcodes and the memory areas in the cfg look like this:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
SCREEN: start = $1000, size = $0200;
LOADADDR: file = %O, start = $11FF, size = $0002;
HEADER: file = %O, start = $1201, size = $000C;
MAIN: file = %O, define = yes, start = $120D, fill = yes, size = $1C00 - $120D - __STACKSIZE__;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, fill = yes, size = __STACKSIZE__;
CHARMEM: file = %O, start = $1C00, size = $0400, type = rw, define = yes, fill = yes;
RAM1: file = %O, start = $2000, size = $2000, type = rw;
}
...
I now need to figure out if I can squeeze fit my game with UDGs in the +3k (which works now with no UDG).
The current +3k config with no UDG looks like:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $03FF, size = $0002;
HEADER: file = %O, start = $0401, size = $000C;
MAIN: file = %O, define = yes, start = $040D, size = $1E00 - __MAIN_START__ - __STACKSIZE__;
}
...
I need to understand how to modify the 3k in a way that almost all previously available code ram is kept. Otherwise no UDGs for the +3k version.
Fabrizio
CROSS CHASE already supports UDG in +8k and +16k Vic20 versions (CROSS CHASE is a game for *all* 8 bit computer/consoles/handhelds).
The VERY SAME C CODE is used for all computers/consoles except for the hardware-specific code in some cases.
The game has 3 versions (generated also by the same meta-code): TINY (6k-8k), LIGHT (about 10-14k), FULL (about 16k-18k).
For the +8k and +16k Vic20 configs I use an external .s file .byte pseudo-opcodes and the memory areas in the cfg look like this:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
SCREEN: start = $1000, size = $0200;
LOADADDR: file = %O, start = $11FF, size = $0002;
HEADER: file = %O, start = $1201, size = $000C;
MAIN: file = %O, define = yes, start = $120D, fill = yes, size = $1C00 - $120D - __STACKSIZE__;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, fill = yes, size = __STACKSIZE__;
CHARMEM: file = %O, start = $1C00, size = $0400, type = rw, define = yes, fill = yes;
RAM1: file = %O, start = $2000, size = $2000, type = rw;
}
...
I now need to figure out if I can squeeze fit my game with UDGs in the +3k (which works now with no UDG).
The current +3k config with no UDG looks like:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $03FF, size = $0002;
HEADER: file = %O, start = $0401, size = $000C;
MAIN: file = %O, define = yes, start = $040D, size = $1E00 - __MAIN_START__ - __STACKSIZE__;
}
...
I need to understand how to modify the 3k in a way that almost all previously available code ram is kept. Otherwise no UDGs for the +3k version.
Fabrizio
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
I think I am close to get UDG into my game for the Vic20+3k but I do not see the UDG on the srceen.
I am trying to get 64 UDG and 6k of available ram for code and data.
The screen starts at $1E00 (7680). If I write into $1E00, I do see the characters but not the user-defined characters.
I am not sure I am correctly setting the VIC chip:
POKE(0x9005,0xFF);
POKE(0x9002,PEEK(0x9002) | 0x80);
But if I do:
for(tmp=0;tmp<254;++tmp)
{
POKE(7680+tmp,tmp);
}
I don't see the UDG.
The cfg may be correct:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $03FF, size = $0002;
HEADER: file = %O, start = $0401, size = $000C;
MAIN: file = %O, define = yes, start = $040D, size = $1800 - __MAIN_START__ - __STACKSIZE__;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, size = __STACKSIZE__, fill = yes;
CHARMEM: file = %O, start = $1C00, size = $0400, type = rw, define = yes, fill = yes;
}
SEGMENTS {
...
UDCCHAR: load = CHARMEM, type = ro, define = yes, optional = no;
...
I am trying to get 64 UDG and 6k of available ram for code and data.
The screen starts at $1E00 (7680). If I write into $1E00, I do see the characters but not the user-defined characters.
I am not sure I am correctly setting the VIC chip:
POKE(0x9005,0xFF);
POKE(0x9002,PEEK(0x9002) | 0x80);
But if I do:
for(tmp=0;tmp<254;++tmp)
{
POKE(7680+tmp,tmp);
}
I don't see the UDG.
The cfg may be correct:
...
MEMORY {
ZP: file = "", define = yes, start = $0002, size = $001A;
LOADADDR: file = %O, start = $03FF, size = $0002;
HEADER: file = %O, start = $0401, size = $000C;
MAIN: file = %O, define = yes, start = $040D, size = $1800 - __MAIN_START__ - __STACKSIZE__;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, size = __STACKSIZE__, fill = yes;
CHARMEM: file = %O, start = $1C00, size = $0400, type = rw, define = yes, fill = yes;
}
SEGMENTS {
...
UDCCHAR: load = CHARMEM, type = ro, define = yes, optional = no;
...
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
If I use Vice monitor and look at $1C00, I only find $00, which means that the linker did not do what I was expecting.
A similar cfg file works fine with the 8k and 16k configuration... No idea what is wrong.
A similar cfg file works fine with the 8k and 16k configuration... No idea what is wrong.
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
Hi!
I have managed to get UDG with +3k. I can only redefine the first 20 characters, though.
I wonder whether this is the expected behavior.
Fabrizio
I have managed to get UDG with +3k. I can only redefine the first 20 characters, though.
I wonder whether this is the expected behavior.
Fabrizio
-
- Vic 20 Dabbler
- Posts: 83
- Joined: Fri Nov 06, 2015 4:13 pm
- Website: http://retrocomputingarchive.blogspot.fr/
- Location: France
Re: UDG on a Vic20 + 3K?
I may have figure it out! 
CROSS CHASE with user-defined characers, some sound and joystick support now works on a Vic 20 + 3k!
The following config seems to be OK.
...
MEMORY {
...
MAIN: file = %O, define = yes, start = $040D, size = $1C00 - $40D - __STACKSIZE__, fill=yes;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, size = __STACKSIZE__, fill = yes;
CHARMEM: file = %O, define = yes, start = $1C00, size = $0200, type = rw, fill = yes;
}
SEGMENTS {
...
UDCCHAR: load = CHARMEM, type = ro, define = yes, optional = no;
}
...

CROSS CHASE with user-defined characers, some sound and joystick support now works on a Vic 20 + 3k!
The following config seems to be OK.
...
MEMORY {
...
MAIN: file = %O, define = yes, start = $040D, size = $1C00 - $40D - __STACKSIZE__, fill=yes;
DUMMY: file = %O, start = $1C00 - __STACKSIZE__ - 1, size = __STACKSIZE__, fill = yes;
CHARMEM: file = %O, define = yes, start = $1C00, size = $0200, type = rw, fill = yes;
}
SEGMENTS {
...
UDCCHAR: load = CHARMEM, type = ro, define = yes, optional = no;
}
...