RE: [stella] JoustPong: more exciting than ever!

Subject: RE: [stella] JoustPong: more exciting than ever!
From: "Paul Slocum" <paul-stella@xxxxxxxxxxxxxx>
Date: Mon, 23 Feb 2004 13:14:33 -0600
You can have a flicker free kernal just by putting P0 in copy mode and positioning it at the right side of the screen so it wraps around. Use P1 for ptery and the ball for the ball. Then you don't ever have to reposition P0 (just use the same setup for the score.) Example attached. Only drawback is that you may not be able to color the two players differently.

BTW: The link to your source is not working.

-paul

Attachment: pongtest.bin
Description: Binary data

;---------------------------------------------------------------------------
;
; Generic 2600 Game
;
;---------------------------------------------------------------------------

	processor 6502	
	include vcs.h	


;---------------------------------------------------------------------------
; Constants
;---------------------------------------------------------------------------

;---------------------------------------------------------------------------
; RAM Variables 
;---------------------------------------------------------------------------
frame equ $80
temp equ $81
temp16L equ $82
temp16H equ $83



;---------------------------------------------------------------------------
;---------------------------------------------------------------------------
	org $F000
;---------------------------------------------------------------------------
;---------------------------------------------------------------------------


				
;---------------------------------------------------------------------------
; Start of Program
;---------------------------------------------------------------------------
; Clear memory, locate character graphics positions and such,
; initialize key memory values, start GameLoop.
;-------------------------------------------------------------
Start
	sei  	
	cld  		
	ldx #$FF
	txs  		
	lda #0
clear   
	sta 0,x
	dex
	bne clear	

;---------------------------------------------------------------------------
; Initialize variables / registers
;---------------------------------------------------------------------------
	stx GRP0
	stx GRP1
	stx PF0
	stx PF1
	stx PF2
	
	; Set background black
	lda #0
	sta COLUBK

	; Set playfield to white
	LDA #$0F
	STA COLUPF



;--------------------------------------------------------------------------
; GameLoop
;--------------------------------------------------------------------------
GameLoop
	jsr VSync 	;start vertical retrace

	inc frame	;count frame

	jsr VBlank    	; spare time during screen blank
	jsr Picture		; draw one screen
	jsr overscan	; do overscan

	jmp GameLoop    ;back to top



;--------------------------------------------------------------------------
; VSync
;--------------------------------------------------------------------------
VSync
	lda #2		;bit 1 needs to be 1 to start retrace
	sta VSYNC	;start retrace
	sta WSYNC 	;wait a few lines
	sta WSYNC 
	lda #44		;prepare timer to exit blank period (44)
	sta TIM64T	;turn it on
	sta WSYNC 	;wait one more
	sta VSYNC 	;done with retrace, write 0 to bit 1

	rts ; VSync



;--------------------------------------------------------------------------
; VBlank
;--------------------------------------------------------------------------
; Game Logic
;--------------------------------------------------------------------------
VBlank

	rts ; VBlank



;--------------------------------------------------------------------------
; Overscan
;--------------------------------------------------------------------------
; More Game Logic
;--------------------------------------------------------------------------
overscan

	sta WSYNC	

	lda #36		; Use the timer to make sure overscan takes (34)
	sta TIM64T	; 30 scan lines.  29 scan lines * 76 = 2204 / 64 = 34.4

endOS	
	lda INTIM	; We finished, but wait for timer
	bne endOS	; by looping till zero
	
	sta WSYNC	; End last scanline

	lda #$82
	sta VBLANK
	lda #$02
	sta VBLANK

	rts	; overscan



;--------------------------------------------------------------------------
; Draw TV Pictures
;--------------------------------------------------------------------------
;
;--------------------------------------------------------------------------
Picture

	; position and setup players
	sta WSYNC
	ldx #8
posDelay
	dex
	bne posDelay
	sta RESP1
	ldx #4
posDelay2
	dex
	bne posDelay2
	sta RESP0
	lda #%00010000
	sta HMP0
	sta WSYNC
	sta HMOVE
	lda #$84
	sta COLUP0
	lda #$24
	sta COLUP1
	lda #2
	sta NUSIZ0
	lda #5
	sta NUSIZ1


pictureLoop
	lda INTIM	;check timer for end of VBLANK period
	bne pictureLoop	;loop until it reaches 0

	sta WSYNC
	lda #$80
	sta VBLANK  	;end screen blank

;---------------------------------------------------------------------------
	ldx #192
ScanLoop:
	sta WSYNC
	txa
	and #%00001111
	tay
	lda data1,y
	sta GRP0		; left player
	lda data2,y 
	sta GRP1		; ptery
	dec $2d		; wait 5 cycles
	dec $2d		; and another
	lda data3,y
	sta GRP0		; right player
	dex 
	bne ScanLoop
	stx GRP0
	stx GRP1

	rts	; Picture

data1
	byte %00111000
	byte %00010000
	byte %00010000
	byte %00010000
	byte %00010000
	byte %00010000
	byte %00110000
	byte %00010000
	byte 0,0,0,0,0,0,0,0

data2
	byte %01111100
	byte %01000000
	byte %00100000
	byte %00010000
	byte %00001000
	byte %00000100
	byte %01000100
	byte %00111000
	byte 0,0,0,0,0,0,0,0

data3
	byte %00111000
	byte %01000100
	byte %00000100
	byte %00011000
	byte %00000100
	byte %00000100
	byte %01000100
	byte %00111000
	byte 0,0,0,0,0,0,0,0


;---------------------------------------------------------------------------
; Program Startup
;---------------------------------------------------------------------------
	org $FFFC
	.word Start
	.word Start

Current Thread