Jump to content



0

I want to keep learning A2600 programming but I'm stuck!


1 reply to this topic

#1 Nico OFFLINE  

Nico

    Combat Commando

  • 6 posts
  • Location:Argentina

Posted Today, 3:55 PM

Hi all! I'm a bit new at this forum and I noticed a lot of great A2600 programmers here, so perhaps some of them might help me. I've started reading about the A2600 arquitecture (6507, TIA and RIOT) and I've understood most of them, I also made some simple examples using the playfield and player objects. My first goal at A2600 programming is to make a simple PONG like game but so far I havent been able to make any advances. I thought about dividing the game into 3 simple parts:

1- The score
2- The paddles
3- The ball

I managed to create the 2 moving paddles but making the ball move both vertical and horizontal seems to be way more difficult than I thought. Can anyone give me some ideas how I can solve this? Thanks!

#2 Joe Musashi OFFLINE  

Joe Musashi

    Space Invader

  • 31 posts

Posted Today, 5:41 PM

Moving the ball horizontally is done the same way as with all other objects. I.e., by setting a coarse postion with the RES registers and doing refinement with HMOVE. For this you can, e.g., use the routine from Battlezone:

	        ...
		ldx	 #4
		lda	 BallHPos
		jsr	 HPosNoHMOVE
		sta	 WSYNC
		sta	 HMOVE
	        ...

HPosNoHMOVE:	SUBROUTINE
	        sec
		sta	 WSYNC
.loop		sbc	 #15
		bcs	 .loop
		eor	 #7
		asl
		asl
		asl
		asl
		sta.wx   HMP0,x
		sta	 RESP0,x
		rts

Moving an object vertically is a bit more tricky. Basically, this is done by enabling the object on the lines where it is visible:

		ldy	 #NUMBER_OF_LINES
.loop		sta	 WSYNC
		ldx	 #%00000010	  ; set ball enable bit
		tya		          ; move line number to A
		sec	                  ; set carry before subtracting
		sbc	 BallVPos         ; subtract ball start line
		cmp	 #BALL_HEIGHT     ; test if line is in [0, BALL_HEIGHT-1]
		bcc	 .write		  ; yes -> enable ball
		ldx	 #%00000000	  ; no -> clear ball enable bit
.write		stx	 ENABL
		dey
		bne	 .loop

To make it bit clearer I made a small demo that shows how this works. This is simply a moving ball object, which bounces back from the screen borders.

BallDemo.png

Attached Files


Edited by Joe Musashi, Today, 6:12 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users