Jump to content



0

Having problems with programming (asm)


3 replies to this topic

#1 phider OFFLINE  

phider

    Space Invader

  • 13 posts

Posted Tue Dec 2, 2008 6:01 PM

I've just started with this asm tutorial, and decided to start modifying the first program. I successfully changed the colors, and enabled the 2nd missile and made 2 lines going in opposite directions. Then I decided to try cycling the background color by decrementing it every frame, and wrapping to $FF when it hits zero. I also took out the moving line. I added the following code near the beginning of the main loop, where the tutorial said you could put game logic.
	ldx COLUBK
	dex
	bne SkipReset
	ldx #$FF

SkipReset
	txa
	sta COLUBK
The background color starts at $FF, and *should* decrement by one every frame. However, instead it changes immediately to a light gray, and stays there. I slowed down the color changing by making it do 50 frames before it changed, and it seemed to change to gray on the first change. Here's the full code:
	processor 6502
	include vcs.h
	org $F000
Start
	sei
	cld
	ldx #$FF
	tsx
	lda #0
ClearMem
	sta 0,X
	dex
	bne ClearMem
	lda #255
	sta COLUBK
MainLoop
	lda #2
	sta VSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	lda #43
	sta TIM64T
	lda #0
	sta VSYNC

	ldx COLUBK	;Here's the code I added
	dex
	bne SkipReset
	ldx #$FF

SkipReset
	txa
	sta COLUBK	;End of added code

WaitForVblankEnd
	lda INTIM
	bne WaitForVblankEnd
	ldy #191

	sta WSYNC
	sta VBLANK
ScanLoop
	sta WSYNC
	dey
	bne ScanLoop

	lda #2
	sta WSYNC
	sta VBLANK
	ldx #30
OverScanWait
	sta WSYNC
	dex
	bne OverScanWait
	jmp MainLoop

	org $FFFC
	.word Start
	.word Start


#2 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Dec 2, 2008 6:26 PM

Hardware ram (like COLUBK... zero page address $09) performs different functions depending on read or write. When storing a value, this register updates the background color. However...when reading the register, $09 is checking the status of INPT1 (the second paddle).

In your case, you'd need to store the value to user ram so that it's properly read and written.

This same limitation affects other registers as well. You can't (for example) load PF0 and expect it to hold the on/off state of the playfield pixels.

#3 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Dec 2, 2008 6:35 PM

BTW the 2600 color palette ignores the low bit. Color value #$00 produces the same effect as color value #$01.

#4 phider OFFLINE  

phider

    Space Invader

  • 13 posts

Posted Tue Dec 2, 2008 6:54 PM

Thanks, it works now :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users