VIC-20 memory areas, help please!
Moderator: Moderators
VIC-20 memory areas, help please!
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.
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.
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.
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
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.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.
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?
Okay.. I've made some progress.. I'm using the ACME assembler, and I've come up with this code:
Which creates a working program that simply turns the screen black and when listing in BASIC shows:
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.
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
Code: Select all
1 SYS 4622
If you use this code you get a nice:
2009 SYS 4622
and whit this code a shorter line with one byte less:
2009 SYS4621
2009 SYS 4622
Code: Select all
!BYTE $0C,$12,$d9,$07,$9E,$20,$34,$36,$32,$32,$00,$00,$00
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.
- Mike
- Herr VC
- Posts: 4845
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
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.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?
Greetings,
Michael
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.nbla000 wrote:and whit this code a shorter line with one byte less:
2009 SYS4621Code: Select all
!BYTE $0B,$12,$d9,$07,$9E,$34,$36,$32,$31,$00,$00,$00
I've used this code in a lot of projects without problems and with both DASM and ACME, personally I prefer DASM.adric22 wrote: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.nbla000 wrote:and whit this code a shorter line with one byte less:
2009 SYS4621Code: Select all
!BYTE $0B,$12,$d9,$07,$9E,$34,$36,$32,$31,$00,$00,$00
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.