RE: [stella] Little Help Here

Subject: RE: [stella] Little Help Here
From: "Tempest" <reicher6@xxxxxxxxxxxxx>
Date: Fri, 2 Mar 2001 23:14:47 -0500
Ok here's my code.  It's pieced together from several other code snippets
I've found in the archives.  It use to display some multi-colored stripes on
the screen but I disabled those for the time being by clearing the Playfield
registers.

What it should do is display my stupid ship graphic on scanline 92 and
recognize the joystick input (that part works), but I'm getting nothing but
a blank screen.  Maybe I shouldn't write zero's to the Playfield registers?
If someone can fill me in on what stupid mistake I'm making I'd appreciate
it.

Tempest


;***************************************
;*	Galactic Tactic		         *
;*	Ver. 0.01		     		   *
;***************************************


        processor 6502
        include vcs.h


    org $F000


;*****************************************************
;*	Equates					   	     *
;*****************************************************

Scanctrl equ $91


;*****************************************************
;*	Clear Memory				   	     *
;*****************************************************

Start

	SEI  		; Disable interrupts, if there are any.
	CLD  		; Clear BCD math bit.
	LDX  #$FF
	TXS 		; Set stack to top of RAM.

	LDA #0  	;Zero everything except VSYNC.
B1	STA 0,X
    	DEX
    	BNE B1


	JSR  GameInit


;******************************************************
;	Main Loop						      *
;******************************************************

MainLoop
    	JSR  VerticalBlank ;Execute the vertical blank.
    	JSR  CheckSwitches ;Check console switches.
    	JSR  GameCalc      ;Do calculations during Vblank
    	JSR  DrawScreen    ;Draw the screen
    	JSR  OverScan      ;Do more calculations during overscan
    	JMP  MainLoop      ;Continue forever.


;******************************************************
;	Verticle Blanking					      *
;******************************************************

VerticalBlank

	LDA  #2	;VBLANK was set at the beginning of overscan.
    	STA  WSYNC
    	STA  WSYNC
    	STA  WSYNC
    	STA  VSYNC	;Begin vertical sync.
    	STA  WSYNC	;First line of VSYNC
    	STA  WSYNC 	;Second line of VSYNC.

    	LDA #44     ;Set timer to activate during the last line of VBLANK.
    	STA TIM64T

    	LDA #0   	;Now we can end the VSYNC period.
    	STA  WSYNC 	;Third line of VSYNC.
    	STA  VSYNC 	;Writing zero to VSYNC ends vertical sync period.
    	RTS


;******************************************************
;	Check Switches					      *
;******************************************************

CheckSwitches

    	LDA #0          ;Clear collision latches
    	STA CXCLR       ;In a real game, we'd probably check the collision
                      ;registers before clearing them.
    	RTS


;******************************************************
;	Game Calculations					      *
;******************************************************

GameCalc

    	LDA #0
    	STA COLUBK	;Background will be black.

    	LDA #$80
    	BIT SWCHA
    	BEQ Right
    	LSR
    	BIT SWCHA
    	BEQ Left
    	LSR
    	BIT SWCHA
    	BEQ Down
    	LSR
    	BIT SWCHA
    	BEQ Up
    	JMP NoStick


Right
    	JMP NoStick

Left
    	JMP NoStick

Down
    	JMP NoStick

Up
    	JMP NoStick

NoStick

    	LDA #$00    ;Pixels: 00000000
    	STA PF0
    	STA PF2     ;Store alternating bit pattern to the playfield registers
    	ASL        ;Because PF1 displays in the opposite bit order from PF0
    	STA PF1
    	LDA #1
    	STA CTRLPF  ;Let's reflect the playfield just cause we feel like it =)
	STA RESP0
    	RTS


;******************************************************
;	Draw Screen						      *
;******************************************************

DrawScreen

    	LDA INTIM
    	BNE DrawScreen ;Loops until the timer is done - that means we're
                     ;somewhere in the last line of vertical blank.
    	STA WSYNC      ;End the current scanline - the last line of VBLANK.
    	STA VBLANK     ;End the VBLANK period.  The TIA will display stuff
        	         ;starting with the next scanline.  We do have 23 cycles
                     ;of horizontal blank before it displays anything.

    	LDY #192       ;We're going to use Y to count scanlines.


ScanLoop

    	STY COLUPF     ;Keep changing the playfield color every line
    	STA WSYNC      ;Wait for end of scanline
    	DEY
    	TYA
    	CMP #$91
    	BEQ DrawSprite
    	BNE ScanLoop   ;Count scanlines.
    	RTS


DrawSprite

	LDX #07
cont	STA WSYNC
	LDA Sprite,X
	STA GRP0
	DEX
	BNE cont
	RTS


;******************************************************
;	Overscan						      *
;******************************************************

OverScan          ;We've got 30 scanlines to kill.
    	LDX #30     ;In a real game, we'd probably be doing calculations here,

KillLines         ;possibly using the timer again to tell us when overscan
    	STA WSYNC   ;is done instead of counting the scanlines.
    	DEX
    	BNE KillLines
    	RTS

GameInit	      ;Usually called to start a new game.. we're not using it yet.
    	RTS

Sprite
	.byte	%00000000
	.byte	%00011000
	.byte	%00011000
	.byte	%10011001
	.byte	%10100101
	.byte	%11000011
	.byte	%00000000


	org $FFFC
	.word Start
	.word Start



-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread