[stella] DD_0003

Subject: [stella] DD_0003
From: Glenn Saunders <cybpunks2@xxxxxxxxxxxxx>
Date: Sun, 23 Sep 2001 19:34:28 -0700
Here is build 0003.

I've got the striping in there, and the kernel is drawing 12 rows of data from RAM instead of ROM, although the ROM is first copied to RAM to show some actual data at first.

I have another strange problem at the top. It doesn't look like it's doing all 8 PF lines.

Advice appreciated.


Glenn Saunders - Producer - Cyberpunks Entertainment Personal homepage: http://www.geocities.com/Hollywood/1698 Cyberpunks Entertainment: http://cyberpunks.uni.cc

Attachment: DD_0003.bin
Description: Binary data

;Death Derby 2001
; By Glenn Saunders

;LINEAGE:

; How to Draw an Asymmetric Reflected Playfield
; by Roger Williams
; Reflected mode modifications by Glenn Saunders

; with a lot of help from Nick Bensema
; (this started out as his "How to Draw a Playfield")

;Roger Williams:

; For comparison, I have tightened up Nick's code
; just a little by eliminating all the subroutine
; calling overhead, which is more like how a real
; game would work, and eliminated the scrolling and
; color effects to isolate them from the pure act of
; displaying a bitmap.
;
	processor 6502
	include vcs.h

; CONSTANTS
RowHeight 	= 15 	; 15+1 = 16 lines
RowsPerScreen 	= 11	; 11+1 = 12 rows
SafeZone	= %10010000

    SEG.U vars
    org $80

Temp       	ds 1
CurrentScanLine ds 1
CurrentRow    	ds 1
PFColorRAM 	ds 1
PF1DataRAM	ds 12
PF2DataRAM	ds 12
PF1bDataRAM	ds 12
PF2bDataRAM	ds 12


    SEG code
    org  $F000

;FrameCounter = $93 was going to try some color cycling


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

	; CLEAR OUT RAM
	LDA #0
B1      STA 0,X
	DEX
	BNE B1


	; I know there is a way to do this cleaner
	LDX #RowsPerScreen
InitializeTombstones; copy from ROM to RAM
	LDA PF1Data,X
	STA PF1DataRAM,X

	LDA PF2Data,X
	STA PF2DataRAM,X

	LDA PF1bData,X
	STA PF1bDataRAM,X

	LDA PF2bData,X
	STA PF2bDataRAM,X
	
	DEX
	BNE InitializeTombstones

	LDA PF1Data
	STA PF1DataRAM

	LDA PF2Data
	STA PF2DataRAM

	LDA PF1bData	
	STA PF1bDataRAM

	LDA PF2bData
	STA PF2bDataRAM


MainLoop
	LDX  #0	   ;vertical blank
	LDA  #2
	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   ;init timer for overscan
	STA  TIM64T

	STA  WSYNC ; Third line of VSYNC.
	STA  VSYNC ; (0)


	LDA #0
	STA COLUBK  ; Background will be black.

VBLOOP	LDA INTIM
	BNE VBLOOP ; Whew!
	

	
	STA WSYNC


	STA VBLANK  ;End the VBLANK period with a zero.
	
	LDA #$34 ; set playfield color to deep red
	STA COLUPF
	
	LDA #PF_Reflect
	STA CTRLPF  ; set playfield to reflect - G.S.



	LDA #0
	;
	STA COLUP0
	STA COLUP1; blacking out player colors

	;STA PFColorRAM
	;
	LDA #200 
	STA CurrentScanLine
	LDA #RowHeight
	STA CurrentRow
	;
	; The height of the screen is not an even multiple of 36
	; (the character height including blank.)  Here we waste
	; the extra lines.
	;
	; NB we may do away with this by adding 2 scans to each
	; char in the blank or fore and aft bigpix lines
	;

	LDA #0
	STA PF0
	STA PF1
	STA PF2; zero out playfield
	
	


	LDX #19	; reserve 15 CurrentScanLines for the score
DrawScore
	STA WSYNC
	DEC CurrentScanLine
	DEX
	BNE DrawScore


	LDX #RowsPerScreen
	
TopBorder ; 2 lines
	LDA #$FF 
	
	STA PF0 ; draw a solid line
	STA PF1
	STA PF2
	DEC CurrentScanLine
	STA WSYNC

	LDY #SafeZone
	STY PF0 ; now PF0 is in the proper shape for the rest of the screen
	
	;A is still $FF
	STA PF1
	STA PF2
	;NO WSYNC necessary here because ScanGo will finish the line off

ScanLoop
	DEC CurrentRow		;next screen pixel line
	BNE ScanGo

	LDA #RowHeight; if counter reaches zero, reset to 15
	STA CurrentRow
	DEX			;next big pixel line
	BNE ScanGo
	;LDX #10
ScanGo
	STA WSYNC
	; Time to begin cycle counting

				;	0
	;STA.W HMOVE		;+4	4
	
	NOP 			;+2	2
	NOP			;+2	4
	
	;will probably have to do an HMOVE on every line to 
	;simplify logic.  HMOVE is only necessary for the missiles

	LDA <PF1DataRAM,X       ;+4	8
	STA PF1               	;+3  = *11*  < 29	;PF1 visible
	
	LDA <PF2DataRAM,X       ;+4	15
	STA PF2                 ;+3  = *19*  < 40	;PF2 visible

	nop			;+2	20
	nop			;+2	22
	nop			;+2	24
	nop			;+2	26
	nop			;+2	28
	nop			;+2 	30
	nop			;+2	32
	nop			;+2	34
	
	LDA <PF1bDataRAM,X	;+4	38

	;PF1 no longer visible, safe to rewrite
	STA PF1			;+3 = *41*


	LDA <PF2bDataRAM,X	;+3     44
	
	;PF2 rewrite must begin at exactly cycle 45!!, no more, no less
	STA PF2			;+3  = *47*  ; > 46 PF2 no longer visible



	DEC CurrentScanLine
	BNE ScanLoop2
	;
	LDA #2
	STA WSYNC  ;Finish CurrentScanLine 189.
	JMP DoBorder

ScanLoop2
	DEC CurrentRow		;next screen pixel line
	BNE ScanGo2

	LDA #RowHeight; if counter reaches zero, reset to 15
	STA CurrentRow
	DEX			;next big pixel line
	BNE ScanGo2
	;LDX #10

ScanGo2; do all the sprite routines here
	STA WSYNC
	LDA #0
	STA PF1
	STA PF2
	DEC CurrentScanLine
	BNE ScanLoop

	



DoBorder
	LDA #$FF
	STA PF0
	STA PF1
	STA PF2
	STA WSYNC
	;STA WSYNC
	
	
	STA VBLANK ; Make TIA output invisible,
	;
	LDA #0
	STA PF0
	STA PF1
	STA PF2
	STA GRP0
	STA GRP1
	STA ENAM0
	STA ENAM1
	STA ENABL

OverScan
	LDX #22
KillLines
	STA WSYNC
	DEX
	BNE KillLines

	JMP  MainLoop      ;Continue forever.


	org $FF00 ; *********************** GRAPHICS DATA


;               REFLECTED  PLAYFIELD            
;                                               
; PF0|   PF1  |  PF2   ||   PF2b |   PF1b |PF0b|
;4567|76543210|01234567||76543210|01234567|7654|


;SafeZone ;     7654----
;	.byte %10011001

PF1Data  ;     76543210

	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	
PF2Data  ;     01234567

	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	
PF2bData ;     76543210;<--- scanning order
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010


	
PF1bData;      01234567;<--- scanning order

	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101
	.byte %10101010
	.byte %01010101


	
	org $FFFC
        .word Start
        .word Start

Current Thread