Re: [stella] Brainstorming: 3D-Corridor

Subject: Re: [stella] Brainstorming: 3D-Corridor
From: Paul Slocum <paul-stella@xxxxxxxxxxxxxx>
Date: Sat, 29 Mar 2003 21:47:36 -0600
I started messing around with making a warp portal and I came up with this one. I later got carried away with crazy graphics and adding music to make it a sort of demo. :o)

-Paul

Attachment: cor2.bin
Description: Binary data

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

	processor 6502	
	include vcs.h	


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

;---------------------------------------------------------------------------
; RAM Variables 
;---------------------------------------------------------------------------
frame equ $80
temp equ $81
pointerL equ $82
pointerH equ $83


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


Lines
   byte %00011000, %00000000, %00000000, %00000011, %00000000, %00000000
   byte %00001100, %00000000, %00001000, %00000001, %10000001, %00001011

   byte %01000000, %00000000, %00000000, %00011000, %00000000, %00000000
   byte %01100000, %00000000, %00110000, %00000011, %00000011, %00011011

   byte %00000000, %00000000, %00000000, %11000000, %00000000, %00000001
   byte %10000000, %00000000, %11000000, %00000100, %00000010, %00010011

   byte %00000000, %00000000, %00000110, %00000000, %00000000, %00001100
   byte %00000000, %00000011, %00000000, %00001000, %00000100, %00110011

   byte %00000000, %00000000, %01010000, %00000000, %00000000, %00110000
   byte %00000000, %00001100, %00000000, %00110000, %00001000, %00100111

   byte %00000000, %00000011, %00000000, %00000000, %00000001, %10000000
   byte %00000000, %00110000, %00000000, %01000000, %00010000, %01100101

   byte %00000000, %00101000, %00000000, %00000000, %00001100, %00000000
   byte %00000000, %11000000, %00000001, %10000000, %00100000, %01000101

   byte %00000001, %10000000, %00000000, %00000000, %01100000, %00000000
   byte %00000011, %00000000, %00000110, %00000000, %01000000, %10001101
				
;---------------------------------------------------------------------------
; 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 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 #$00
	sta COLUBK

	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



pfData
	byte %10000000, %10000000, %11000000, %00000000

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


	; Set background blue
	lda #0
	sta COLUBK
	
	lda #$FF

	sta PF1
	sta PF2
	
	lda #1
	sta CTRLPF



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

	; Set up line data pointer
	lda #$F0
	sta pointerH

	lda frame
	;asl
	asl
	sta temp

	lda frame
	lsr
	and #%111
	tax
	lda Offsets,x
	sta pointerL


	; top half
	ldy #0
ScanLoop2	
;---------------------------------------------------------------------------
	ldx #128
InnerLoop2
	sta WSYNC
	txa
	and (pointerL),y
	beq NoLine2
	tya
	eor #$0F
	ora temp
NoLine2
	sta COLUPF
	txa
	lsr
	tax
	bcc InnerLoop2
	iny
	cpy #12
	bne ScanLoop2


	; bottom half
	ldy #11
ScanLoop	
;---------------------------------------------------------------------------
	ldx #1
InnerLoop
	sta WSYNC
	txa
	and (pointerL),y
	beq NoLine
	tya
	eor #$6F
	ora temp
NoLine
	sta COLUPF
	txa
	asl
	tax
	bcc InnerLoop
	dey
	cpy #255
	bne ScanLoop

;	stx PF1
;	stx PF2

	rts	; Picture

Offsets
	byte 0,12,24,36, 48,60,72,84


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

Attachment: demo.bin
Description: Binary data

Current Thread