VIC-20 memory areas, help please!

You need an actual VIC.

Moderator: Moderators

Post Reply
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

VIC-20 memory areas, help please!

Post by adric22 »

Okay, so I'm trying to write my first ML program on the VIC using CC65. Obviously, I'm familiar with doing this on the C64 but I've run into a few obvious problems that I can't find any quick answers to.

First of all, assume the VIC-20 has 24K memory. I've noticed the memory map seems to change a bit depending on how much memory it has.

When loading a BASIC program from disk, where does it go? Essentially, I want my program to have the usual like something like this:

10 SYS 4096

Obviously, 4096 is screen memory area, but you get the idea.. I am having trouble figuring out where the program is going to go, and what SYS prefix to give it, plus the obvious issue I have to tell the compiler where in RAM the code goes.
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

When you add 8K or more, start of Basic is moved from 4096 to 4608. In your case, it is likely you need SYS 4621 or greater.

The screen matrix will also be moved from 7680 to 4096, as you already found out. The colour memory gets moved from 38400 to 37888, which is a by-effect of having the screen matrix at an even 1K.
Anders Carlsson

Image Image Image Image Image
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

carlsson wrote:When you add 8K or more, start of Basic is moved from 4096 to 4608. In your case, it is likely you need SYS 4621 or greater.

The screen matrix will also be moved from 7680 to 4096, as you already found out. The colour memory gets moved from 38400 to 37888, which is a by-effect of having the screen matrix at an even 1K.
Okay.. thanks.. I was sort of starting to figure that out by writing a line of BASIC and searching through with the VICE monitor trying to find where it ended up.

However, I just discovered that CC65 is a C compiler.. and I was thinking it was an assembler. So what cross-assember do you guys typically use for VIC-20 coding?
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

Okay.. I've made some progress.. I'm using the ACME assembler, and I've come up with this code:

Code: Select all

!to "game.o", cbm	; set output file and format		
*= $1201		; set program counter

BASIC	!BYTE $0C,$12,$01,$00,$9E,$20,$34,$36,$32,$32,$00,$00,$00
	;Adds BASIC line:  1 SYS 4622

	LDX	#$08
	STX	$900F
	RTS
Which creates a working program that simply turns the screen black and when listing in BASIC shows:

Code: Select all

1 SYS 4622
yeah.. Maybe not so impressive, but it took me 2 hours to figure this out. Anyway, now I think I can actually get started writing the game. :-)
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

If you use this code you get a nice:
2009 SYS 4622

Code: Select all

!BYTE $0C,$12,$d9,$07,$9E,$20,$34,$36,$32,$32,$00,$00,$00
and whit this code a shorter line with one byte less:
2009 SYS4621

Code: Select all

!BYTE $0B,$12,$d9,$07,$9E,$34,$36,$32,$31,$00,$00,$00
Mega-Cart: the cartridge you plug in once and for all.
User avatar
Mike
Herr VC
Posts: 4845
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

adric22 wrote:However, I just discovered that CC65 is a C compiler.. and I was thinking it was an assembler. So what cross-assember do you guys typically use for VIC-20 coding?
The accompanying ca65 *is* an assembler, so you might use that instead of ACME. Also DASM often is used. Both are discussed in more detail in the Emulators & Cross developing section, as are suitable stub macros to include into a ML source to make it RUNable.

Greetings,

Michael
User avatar
Kweepa
Vic 20 Scientist
Posts: 1315
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

Not that there's anything wrong with ACME.
I've used it for a couple of games.
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

nbla000 wrote:and whit this code a shorter line with one byte less:
2009 SYS4621

Code: Select all

!BYTE $0B,$12,$d9,$07,$9E,$34,$36,$32,$31,$00,$00,$00
Actually, that is how I tried first and couldn't get it to work. The BASIC listing would always have garbage after the first line. So I added the extra zero and moved it to SYS4622 and it seemed to clear up.
User avatar
nbla000
Salmon Run
Posts: 2582
Joined: Thu Oct 13, 2005 8:58 am
Location: Italy

Post by nbla000 »

adric22 wrote:
nbla000 wrote:and whit this code a shorter line with one byte less:
2009 SYS4621

Code: Select all

!BYTE $0B,$12,$d9,$07,$9E,$34,$36,$32,$31,$00,$00,$00
Actually, that is how I tried first and couldn't get it to work. The BASIC listing would always have garbage after the first line. So I added the extra zero and moved it to SYS4622 and it seemed to clear up.
I've used this code in a lot of projects without problems and with both DASM and ACME, personally I prefer DASM.

The first 2 bytes are pointers for next row ($120b) and correspond to the last 2 bytes ($00,00) that means Basic program finished.
Mega-Cart: the cartridge you plug in once and for all.
Post Reply