[stella] Colour Display Programme

Subject: [stella] Colour Display Programme
From: crackers@xxxxxxxx
Date: Tue, 16 Sep 1997 19:27:01 -0400 (EDT)
Well gang. I'm starting work on my Virtual Pet for the 2600 now. But
the colours of the 2600 just seem kind of abstract to me. I mean just
how does 11011010 look? So here's a simple, very simple, damn simple
programme that let's you cycle through the colour pallet, one at a time
and gives you a binary representation of what colour you are on with the
PF2 register.

Maybe someone can use this programme to actually assign some RGB values
to the 2600's pallet.

I've only tested it out on an emulator so far. Here's the programme.

----------------------------------------------------------------------------
	processor 6502

VSYNC	=	$00
VBLANK	=	$01
WSYNC	=	$02
COLUPF 	=	$08
COLUBK	=	$09
PF0	=	$0D
PF1	=	$0E
PF2	=	$0F
CXCLR	=	$2C
SWCHA	=	$280
INTIM	=	$284
TIM64T	=	$296
COLOUR	=	$80	;the value for the colour
DELAY	=	$81	;the value for the joystick delay

	org  $F000

start	SEI            
	CLD
	LDX  #$FF
	TXS
	LDA  #$00

zero	STA  $00,X	;looks familiar, right?     
	DEX		;typical zeroing routine
	BNE  zero
	sta  COLUBK
	sta  PF0
	sta  PF1
	sta  PF2
	sta  COLUPF

main	JSR  vertb	;main loop
	JSR  draw       
	JSR  oscan      
	JMP  main       

vertb	LDX  #$00	;vertical blank, We all know what this is about         
	LDA  #$02           
	STA  WSYNC         
	STA  WSYNC        
	STA  WSYNC
	STA  VSYNC        
	STA  WSYNC         
	STA  WSYNC        
	LDA  #$2C
	STA  TIM64T        
	LDA  #$00
	STA  CXCLR        
	STA  WSYNC        
	STA  VSYNC
	RTS

draw	LDA  INTIM         
	BNE  draw
	sta  WSYNC
	sta  VBLANK
        ldx  #$C0	;192 scanlines
	lda  COLOUR	;loads the colour
	sta  COLUBK	;into the playfield background
	sta  PF1	;also displays a binary representation to PF1
	lda  #$0F
	sta  PF2	;just to help the binary number look clear.

doit	STA  WSYNC	;not much going on here, just repeat the
	dex		;same scanline 192 times
	beq  done
	jmp  doit

done	rts
 
oscan   jsr  joy	;go check the joystick
	LDX  #$1E          
                  
waste	STA  WSYNC      ;no game logic so let's blow the overscan   
	DEX                
	BNE  waste            
	RTS                

joy	lda  SWCHA	;check the joystick ports
	cmp  #$7F	;see if it's moved right (joystick 1)
        beq  right
        cmp  #$BF	;see if it's moved left  (joystick 1)
        beq  left
        rts

right   inc  DELAY	;our joystick delay timer is increased
	lda  DELAY
        cmp  #$1E	;check to see if we've had enough delay (30 frames)
	bpl  clrup	;yep. Let's increase the colour
        rts

left    inc  DELAY	;joystick timer increased
	lda  DELAY	
        cmp  #$1E	;30 frames yet?
	bpl  clrdwn	;yep, decrease colour
        rts
 
clrup	lda  COLOUR	
	cmp  #$FE	;check to see if we've hit the maximum colour
	bne  upit	;nope, then let's increase it
	lda  #$00	
	sta  DELAY	;reset joystick delay timer
	rts

upit	inc  COLOUR	;okay... this is sloppy, but it works
	inc  COLOUR     ;increases the colour value to next setting
	lda  #$00
	sta  DELAY	;reset joystick delay
	rts

clrdwn	lda  COLOUR	
	cmp  #$00	;see if we've hit minimum colour
	bne  dwnit	;nope, then let's decrease it
	lda  #$00
	sta  DELAY	;reset the joystick delay
	rts

dwnit	dec  COLOUR	;yeah, I know, not exactly eligant, but
	dec  COLOUR	;it increases the colour value to next setting
        lda  #$00
        sta  DELAY	;reset joystick delay
	rts

	org $FFFC
	.word start
	.word start

----------------------------------------------------------------------------

I'm sorry I have to post my work as source code, but you see I'm a freenet
user. So while I get the advantage of very inexpensive internet access, some
of the frills like being able to attach a binary to a text message are
unavailable to me.

Incidently, colour appearance varies greatly between an emulator and a
real 2600. So you'll want to check your colours on both systems to
make sure they're okay.


Now that I know what the colours look like for each value it will be
easier to assign specific colours for different elements in my future
projects.


I know I could have made this programme more useful by drawing a hex
representation of the colour with sprites, but I just wanted to
whip this off quickly so I could get to work on my real programme.
If someone else wants to fix this up then be my guest.

                                 CRACKERS
                   (A fine capitalist tool from hell!!!!!)



-- 

Accordionist - Wethifl Musician - Atari 2600 Collector | /\/\
*NEW CrAB URL* http://www.hwcn.org/~ad329/crab.html ***| \^^/
Bira Bira Devotee - FES Member - Samurai Pizza Cats Fan| =\/=




--
Archives updated once/day at http://www.biglist.com/lists/stella/archives/
Unsubscribing and other info at http://www.biglist.com/lists/stella/stella.html

Current Thread