[stella] "kernel panic!"

Subject: [stella] "kernel panic!"
From: KirkIsrael@xxxxxxxxxxxxx
Date: 2 Jul 2002 23:15:16 -0000
So, I got yesterday's little move-a-missile into a "move a happy
face sprite" (that looks left/right depending on which way it's 
moving)


And man, I'm feeling the pain of how tight a kernel has to be...
Here's what I came up with:
(using Y forthe line counter, starting at 191
YPosFromBot is how far from the bottom it is)

--snip--
ScanLoop 
	STA WSYNC 	

; here the idea is that VisiblePlayerLine
; is zero if the line isn't being drawn now,
; otherwise it's however many lines we have to go

;if scanline counter is at YPosFromBot,
;activate the player
CheckActivatePlayer
	CPY YPosFromBot
	BNE SkipActivatePlayer
	LDA #8
	STA VisiblePlayerLine 

SkipActivatePlayer

;turn player off then see if it should be on
	LDA #00		
	STA GRP0
;
;if the VisiblePlayerLine is non zero,
;we're drawing it
;
	LDX VisiblePlayerLine 
	BEQ FinishPlayer
IsPlayerOn	
	LDA BigHeadGraphic-1,X
	STA GRP0
	DEC VisiblePlayerLine 
FinishPlayer
	DEY		
	BNE ScanLoop	
--snip--
that's it. When it's moving over to the left, the top line
(and only the top line) gets cut off; I think my kernel isn't
fitting in HBLANK in the case where it's having to set
VisiblePlayerLine.

And man, this is for one lonely sprite! Any reccomendations
for cleaning it up?
Full listing follows...
thanks for any advice, I think I'll head to the library and 
see if I can find any 6502 books...the computer books section
looked suitably aged.
-
KirkIsrael@xxxxxxxxxxxxx    http://kisrael.com
"Without music, life would be a mistake. ...I would only believe 
in a God that knew how to dance." --Friedrich Nietzsche 
--snip--
; yet another moving dot by Kirk Israel
	
	processor 6502
	include vcs.h
	org $F000

YPosFromBot = $80;
VisiblePlayerLine = $81;

;generic start up stuff...
Start
	SEI	
	CLD  	
	TXS	
	LDX #$FF	
	LDA #0		
ClearMem 
	STA 0,X		
	DEX		
	BNE ClearMem	
	LDA #$00		
	STA COLUBK	
	LDA #33
	STA COLUP0

	LDA #80
	STA YPosFromBot	;Initial Y Position

;	LDA %00000000
;	STA NUSIZ0	;Quad Width


;VSYNC time
MainLoop
	LDA  #2
	STA  VSYNC	
	STA  WSYNC	
	STA  WSYNC 	
	STA  WSYNC	
	LDA  #43	
	STA  TIM64T	
	LDA #0		
	STA  VSYNC 	


;Main Computations; check down, up, left, right
;general idea is to do a BIT compare to see if 
;a certain direction is pressed, and skip the value
;change if so

	LDA #$10	;Down?
	BIT SWCHA 
	BNE SkipMoveDown
	INC YPosFromBot
SkipMoveDown

	LDA #$20	;Up?
	BIT SWCHA 
	BNE SkipMoveUp
	DEC YPosFromBot
SkipMoveUp


;assum horiz movement will be zero
	LDX #$00	

	LDA #$40	;Left?
	BIT SWCHA 
	BNE SkipMoveLeft
	LDX #$10	
	LDA %00001000
	STA REFP0
SkipMoveLeft
	
	LDA #$80	;Right?
	BIT SWCHA 
	BNE SkipMoveRight
	LDX #$F0	
	LDA %00000000
	STA REFP0
SkipMoveRight

	STX HMP0	;set horiz movement for player 0

WaitForVblankEnd
	LDA INTIM	
	BNE WaitForVblankEnd	
	LDY #191 	

	STA VBLANK  	

	STA WSYNC	
	STA HMOVE 	

;main scanline loop...
ScanLoop 
	STA WSYNC 	

; here the idea is that VisiblePlayerLine
; is zero if the line isn't being drawn now,
; otherwise it's however many lines we have to go

CheckActivatePlayer
	CPY YPosFromBot
	BNE SkipActivatePlayer
	LDA #8
	STA VisiblePlayerLine 

SkipActivatePlayer

;turn player off then see if it should be on
	LDA #00		
	STA GRP0
;
;if the VisiblePlayerLine is non zero,
;we're drawing it
;
	LDX VisiblePlayerLine 
	BEQ FinishPlayer
IsPlayerOn	
	LDA BigHeadGraphic-1,X
	STA GRP0
	DEC VisiblePlayerLine 
FinishPlayer


	DEY		
	BNE ScanLoop	

	LDA #2		
	STA WSYNC  	
	STA VBLANK 	
	LDX #30		
OverScanWait
	STA WSYNC
	DEX
	BNE OverScanWait
	JMP  MainLoop      
 
	org $FF00
BigHeadGraphic
	.byte %00111100
	.byte %01111110
	.byte %11000001
	.byte %10111111
	.byte %11111111
	.byte %11101011
	.byte %01111110
	.byte %00111100

	org $FFFC
	.word Start
	.word Start


--snip--






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


Current Thread