Simple assembly program issues

Basic and Machine Language

Moderator: Moderators

Post Reply
gmc
Vic 20 Drifter
Posts: 22
Joined: Mon Oct 29, 2018 9:17 am

Simple assembly program issues

Post by gmc »

Trying my hand at some assembly for the Vic 20 and so far I thought it was going ok but have run into a strange issue.

I've got a simple program that prints out TEST on the upper left. This runs from a cartridge at A000 and I've been testing it using VICE. The weird thing is it loads fine in VICE, all the text is in black, on a real VIC20 with a cartridge I get strange colours.

On the picture attached the TEST is printed out with red, green, white , red. So this seems to be related to the values I put in 1E00 to 1E03.
Hopefully something simple I'm missing but I can't figure out why its working on VICE but not the real hardware.

Any assembly gurus out there?

Code: Select all


*	=	$A000           ; set for cartridge

.WORD	START
.WORD	$0000       		
.BYT	"A0",'C'+$80,'B'+$80,'M'+$80    ; Vic-20 looks for A0CBM on startup 

START:

    LDA #$0C    ; 12 for PAL     
    STA $9000
    LDA #$26    ; 38 for PAL 
    STA $9001
    LDA #$96   ; %1001 0110  ; color map=$9600, 22 cols,   
    STA $9002
    LDA #$2E    ; 46 for PAL
    STA $9003
    LDA #$00
    STA $9004
    LDA #$F0    ; %1111 0000; screen map $1E00; char map 
    STA $9005
    LDA #$1B    ; %0001 1011; white/light cyan
    STA $900F

    LDA #0
    TAY

    LDY #0
    LDA #$20

SPACES			; clear screen with spaces
	STA $1E00,Y
	STA $1F00,Y
	INY
	BNE SPACES


    LDA#20  ;T
    STA $1E00
    LDA#5   ;E
    STA $1E01
    LDA#19  ;S
    STA $1E02
    LDA#20  ;T
    STA $1E03

    
Attachments
20200511_152728.jpg
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Simple assembly program issues

Post by Mike »

Your cartridge takes over the VIC-20 at a verly early point, when the colour RAM still isn't initialised.

On real hardware, the SRAM containing the colour RAM data starts up with essentially random values, those are the colours you see. VICE doesn't model this and initialises the colour RAM to all nibbles 0.

Solution: also initialise the colour RAM in $9600..$97FF. :)


P.S. Oh, and you really should derive the values to put into $9000..$9003 from the ROM defaults put at $EDE4. They're different for PAL or NTSC, and otherwise you'll just replicate a design fault found in contempory cartridges that just use a single fixed set of VIC register init values - which then result in a shifted display window on the other TV system. :(
gmc
Vic 20 Drifter
Posts: 22
Joined: Mon Oct 29, 2018 9:17 am

Re: Simple assembly program issues

Post by gmc »

Lovely stuff. That did the trick.

Thanks for the quick reply. Didn't even occur to me to init this space...or that VICE sets it to all 0.

I've got a pal/ntsc routine. First thing I found out how to do. Just excluded it in case it was the cause of the issue. :)
Post Reply