[stella] Marble Craze control problem

Subject: [stella] Marble Craze control problem
From: Paul Slocum <paul-stella@xxxxxxxxxxxxxx>
Date: Sun, 02 Jun 2002 17:58:31 -0500
I'm working on the paddle control for Marble Craze, and I had a problem come up that I'm not sure how to solve. I hope I haven't just done something really dumb that I'm overlooking! Starting at line 643 of my source you'll see:

ldx padVal3

	; Get paddle value from table (0-15)
	lda paddleDecode,x
	sta DISPLAY

	ldy p2yVel
	ldx p2y
	jsr calcSpeed
	stx p2yVel

As is, you can control the vertical position of the right-side marble with the 3rd paddle (first paddle in port 2). Here's the problem: if you change the first line to:

ldx padVal1

You should be able to control the marble with paddle 1, but it just doesn't work. Paddle 3 and 4 work fine, and Paddle 1 and 2 don't. Now the playfield blocks right under the score show what the variable DISPLAY contains, so you'll see that Paddle 1 is actually being read correctly and shows the exact same values as when Paddle 3 is set, but the marble just doesn't respond. I can't figure out why. Why does it to fail when it's resulting in the same (correct) values?

I've been testing on a Cuttle Cart. If anyone can figure it out, thanks in advance.

-Paul
;---------------------------------------------------------------------------
;
; Marble Craze by Paul Slocum
;
;---------------------------------------------------------------------------

	processor 6502	
	include vcs.h	


	;TODO
	;
	; Generalize acceleration routine
	; Add horizontal ball control
	;
	; Add left player ball routine
	; Horizontal Paddle position indicator
	; Add friction
	;
	; Design level data types
	; Write level loader
	; Write screen to screen handling
	;
	; Write start/finish handling
	


;---------------------------------------------------------------------------
; Constants
;---------------------------------------------------------------------------
SETUPDELAY equ #255

;---------------------------------------------------------------------------
; RAM Variables 
;---------------------------------------------------------------------------

textColor equ $80

playField equ textColor + 1 ; 84 bytes (12 lines * 5) + 24 color bytes
pfBuffer equ playField + 84	; 7 bytes

pMarble equ pfBuffer + 8; 2 bytes
pMarble2 equ pMarble + 2; 2 bytes
pfColor equ pMarble2 + 2

frame equ pfColor + 1

p1x equ frame + 1
p1y equ p1x + 1
p2x equ p1y + 1
p2y equ p2x + 1

DISPLAY equ p2y + 1

p1xVel equ DISPLAY + 1
p1yVel equ p1xVel + 1
p2xVel equ p1yVel + 1
p2yVel equ p2xVel + 1

pwr1x equ p2yVel + 1
pwr1y equ pwr1x + 1
pwr2x equ pwr1y + 1
pwr2y equ pwr2x + 1

padVal1 equ pwr2y + 1
padVal2 equ padVal1 + 1
padVal3 equ padVal2 + 1
padVal4 equ padVal3 + 1

speed equ padVal4 + 1

;---------------------------------------------------------------------------
; Song player variables

temp equ speed + 1

; 16 bit temp
temp16L equ temp + 1
temp16H equ temp16L + 1

;note1 equ temp16H + 1
;note2 equ note1 + 1

;vol1 equ note2 + 1
;vol2 equ vol1 + 1

;sound1 equ vol2 + 1
;sound2 equ sound1 + 1

; Metrenome stuff
;beat equ sound2 + 1
;tempoCount equ beat + 1
;measure equ tempoCount + 1






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

marbleData2
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0

	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0

	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0

	byte #%00111100
	byte #%01111110
	byte #%01111110
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%01111110
	byte #%01111110
	byte #%00111100

	align 256
marbleData3
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0

	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0

	byte #%00111100
	byte #%01111110
	byte #%01111110
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%11111111
	byte #%01111110
	byte #%01111110
	byte #%00111100

	align 256

movement
	byte #%01110001, #%01100001, #%01010001, #%01000001, #%00110001, #%00100001, #%00010001, #%00000001
	byte #%11110001, #%11100001, #%11010001, #%11000001, #%10110001, #%10100001, #%10010001;, #%10000001

	byte #%01110010, #%01100010, #%01010010, #%01000010, #%00110010, #%00100010, #%00010010, #%00000010
	byte #%11110010, #%11100010, #%11010010, #%11000010, #%10110010, #%10100010, #%10010010;, #%10000010

	byte #%01110011, #%01100011, #%01010011, #%01000011, #%00110011, #%00100011, #%00010011, #%00000011
	byte #%11110011, #%11100011, #%11010011, #%11000011, #%10110011, #%10100011, #%10010011;, #%10000011

	byte #%01110100, #%01100100, #%01010100, #%01000100, #%00110100, #%00100100, #%00010100, #%00000100
	byte #%11110100, #%11100100, #%11010100, #%11000100, #%10110100, #%10100100, #%10010100;, #%10000100

	byte #%01110101, #%01100101, #%01010101, #%01000101, #%00110101, #%00100101, #%00010101, #%00000101
	byte #%11110101, #%11100101, #%11010101, #%11000101, #%10110101, #%10100101, #%10010101;, #%10000101

	byte #%01110110, #%01100110, #%01010110, #%01000110, #%00110110, #%00100110, #%00010110, #%00000110
	byte #%11110110, #%11100110, #%11010110, #%11000110, #%10110110, #%10100110, #%10010110;, #%10000110

	byte #%01110111, #%01100111, #%01010111, #%01000111, #%00110111, #%00100111, #%00010111, #%00000111
	byte #%11110111, #%11100111, #%11010111, #%11000111, #%10110111, #%10100111, #%10010111;, #%10000111

	byte #%01111000, #%01101000, #%01011000, #%01001000, #%00111000, #%00101000, #%00011000, #%00001000
	byte #%11111000, #%11101000, #%11011000, #%11001000, #%10111000, #%10101000, #%10011000;, #%10001000

	byte #%01111001, #%01101001, #%01011001, #%01001001, #%00111001, #%00101001, #%00011001, #%00001001
	byte #%11111001, #%11101001, #%11011001, #%11001001, #%10111001, #%10101001, #%10011001;, #%10001001

	byte #%01111010, #%01101010, #%01011010, #%01001010, #%00111010, #%00101010, #%00011010, #%00001010
	byte #%11111010, #%11101010, #%11011010, #%11001010, #%10111010, #%10101010, #%10011010;, #%10001010


paddleDecode
	byte 0,0,0,0,0,0,1,1,1,1,1,1,1
	byte 2,2,2,2,2,2,3,3,3,3,3,3,3
	byte 4,4,4,4,4,4,5,5,5,5,5,5,5
	byte 5,5,5,5,5,5,6,6,6,6,6,6,6
	byte 6,6,6,6,6,6,7,7,7,7,7,7,7
	byte 7,7,7,7,7,7,8,8,8,8,8,8,8
	byte 8,8,8,8,8,8,8,8,8,8,8,8,8
	byte 9,9,9,9,9,9,9,9,9,9,9,9,9
	byte 10,10,10,10,10,10,10,10,10,10,10,10,10
	byte 11,11,11,11,11,11,11,11,11,11,11,11,11
	byte 12,12,12,12,12,12,12,12,12,12,12,12,12
	byte 13,13,13,13,13,13,14,14,14,14,14,14,14
	byte 15,15,15,15,15,15

paddleDecode2
;	byte 0,0,0,0,0,0,1,1,1,1,1,1,1
;	byte 2,2,2,2,2,2,3,3,3,3,3,3,3
;	byte 4,4,4,4,4,4,5,5,5,5,5,5,5
;	byte 6,6,6,6,6,6,7,7,7,7,7,7,7
;	byte 8,8,8,8,8,8,9,9,9,9,9,9,9
;	byte 10,10,10,10,10,10,11,11,11,11,11,11,11
;	byte 12,12,12,12,12,12,13,13,13,13,13,13,13
;	byte 14,14,14,14,14,14,15,15,15,15,15,15,15
;	byte 16,16,16,16,16,16,17,17,17,17,17,17,17
;	byte 18,18,18,18,18,18,19,19,19,19,19,19,19
;	byte 20,20,20,20,20,20,21,21,21,21,21,21,21
;	byte 22,22,22,22,22,22,23,23,23,23,23,23,23
;	byte 24,24,24,24,24,24,25,25,25,25,25,25,25

			
;---------------------------------------------------------------------------
; 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
;---------------------------------------------------------------------------

	; Set initialization flag.
	; This stays set until the first frame is drawn.
	lda #$0f	;set text color to white
	sta COLUP0
	sta COLUP1	

	lda #50
	sta p2y
	sta p1y
	
	lda #10
	sta pwr1y
	
	lda #40
	sta pwr1x
	
	lda #10
	sta p2x
	sta p1x

	lda #7
	sta pwr2y
	
	lda #85
	sta pwr2x

	lda #32
	sta p1xVel



;--------------------------------------------------------------------------
; GameLoop
;--------------------------------------------------------------------------
GameLoop
	inc frame	

	jsr VSync 	;start vertical retrace

	jsr VBlank    	; spare time during screen blank
	jsr drawScreen	; 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

accArray
	
	byte 252,0,252,0,252,0,252,0
	byte 252,0,252,0,252,0,252,0

	byte 252,0,0,252,0,252,0,252
	byte 0,0,252,0,252,0,252,0

	byte 252,0,0,252,0,0,252,0
	byte 252,0,0,252,0,0,252,0

	byte 252,0,0,252,0,0,252,0
	byte 0,252,0,0,252,0,0,0


	byte 252,0,0,0,252,0,0,0
	byte 252,0,0,0,252,0,0,0

	byte 252,0,0,0,0,252,0,0
	byte 0,0,252,0,0,0,0,0

	byte 252,0,0,0,0,0,0,0
	byte 252,0,0,0,0,0,0,0

	byte 252,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0

	
	byte 0,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0

	byte 4,0,0,0,0,0,0,0
	byte 0,0,0,0,0,0,0,0
	
	byte 4,0,0,0,0,0,0,0
	byte 4,0,0,0,0,0,0,0

	byte 4,0,0,0,0,4,0,0
	byte 0,0,4,0,0,0,0,0


	byte 4,0,0,0,4,0,0,0
	byte 4,0,0,0,4,0,0,0

	byte 4,0,0,4,0,0,4,0
	byte 0,4,0,0,4,0,0,0

	byte 4,0,0,4,0,0,4,0
	byte 4,0,0,4,0,0,4,0

	byte 4,0,0,4,0,4,0,4
	byte 0,0,4,0,4,0,4,0



speedArray
	byte 0,0,0,0,0,0,0,0 ;1
	byte 0,0,0,0,0,0,0,0 ;1
	byte 1,0,0,0,0,0,0,0 ;2
	byte 1,0,0,0,1,0,0,0 ;3
	byte 1,0,0,1,0,0,1,0 ;4
	byte 1,0,1,0,1,0,1,0 ;5
	byte 1,1,0,1,0,1,0,1 ;6
	byte 1,1,1,0,1,1,1,0 ;7
	byte 1,1,1,1,1,1,1,0 ;8
	byte 1,1,1,1,1,1,1,1 ;9
	byte 2,1,1,1,1,1,1,1 ;10
	byte 2,1,1,1,2,1,1,1 ;11
	byte 2,1,1,2,1,1,2,1 ;12
	byte 2,1,2,1,2,1,1,2 ;13
	byte 2,1,2,2,1,2,2,1 ;14
	byte 2,2,2,1,2,2,2,1 ;15
	byte 2,2,2,2,2,2,2,1 ;16
	byte 2,2,2,2,2,2,2,2 ;17
	byte 3,2,2,2,2,2,2,2 ;18
	byte 3,2,2,2,3,2,2,2 ;19
	byte 3,2,2,3,2,2,3,2 ;20
	byte 3,2,3,2,3,2,3,2 ;21
	byte 3,3,2,3,3,2,3,2 ;22
	byte 3,3,3,2,3,3,3,2 ;23
	byte 3,3,3,3,3,3,3,2 ;24
	byte 3,3,3,3,3,3,3,3 ;25
	byte 4,3,3,3,3,3,3,3 ;26
	byte 4,3,3,3,4,3,3,3 ;27
	byte 4,3,3,4,3,3,4,3 ;28
	byte 4,3,4,3,4,3,4,3 ;29
	byte 4,4,3,4,4,3,4,3 ;30
	byte 4,4,4,3,4,4,4,3 ;31
	byte 4,4,4,4,4,4,4,3 ;32
	byte 4,4,4,4,4,4,4,4 ;33
	byte 4,4,4,4,4,4,4,4 ;34
	byte 4,4,4,4,4,4,4,4 ;35
	byte 4,4,4,4,4,4,4,4 ;36
	
negConvert
	byte 0,255,254,253,252



;--------------------------------------------------------------------------
; calcSpeed
;--------------------------------------------------------------------------
; Takes a paddle position, position, and speed, and calculates the
; new speed and position.
;
; Preload:
; X: paddle position
; Y: speed
; A: position
;
; Returns:
; X: speed
; A: position
;--------------------------------------------------------------------------
calcSpeed
	stx temp16L
	sty temp16H


	; The acceleration speed is determined by
	; the 4 high bits
	asl
	asl
	asl
	asl
	sta temp

	; Set the current step of acceleration
	lda frame
	and #%00001111
	clc
	adc temp

	; Determine the amount of acceleration
	; for this frame
	tax
	lda accArray,x

	; Add it to the current speed
	clc
	adc temp16H

	; Check for max speeds
	beq noSetVal

	cmp #248
	beq noSetVal

	; Set the speed
	sta temp16H
noSetVal

	; Get the new speed	
	lda temp16H

	; If it's positive speed, go to 
	; the positive speed handler
	bmi posVel

	; Negative speed handler

	; Invert the speed
	asl
	sta temp
	lda #0
	sbc temp
	
	; Set up the current frame
	sta temp
	lda frame
	and #%00000111
	adc temp

	; Get the current speed increment
	tax
	lda speedArray,x

	; Subtract the increment from
	; the current position
	sta temp
	lda temp16L
	sec
	sbc temp

	jmp endVel

posVel
	asl

	; Set up the frame counter
	sta temp
	lda frame
	and #%00000111
	adc temp

	; Get the current speed increment
	tax
	lda speedArray,x

	; Add it to the position
	clc
	adc temp16L

endVel
	ldx temp16H

	rts



;--------------------------------------------------------------------------
; checkYPosition
;--------------------------------------------------------------------------
; Takes current X position and new proposed Y position and checks
; for falling off, edge of screen, or walls.
;
; (Currently just loops)
; 
; Preload:
; A: Y position
;
; Returns:
; A: updated Y position
;
;--------------------------------------------------------------------------
checkYPosition

	cmp #0
	beq topResetY
	cmp #1
	beq topResetY
	cmp #2
	beq topResetY
	cmp #3
	beq topResetY

	cmp #163
	beq resetY
	cmp #162
	beq resetY
	cmp #161
	beq resetY
	cmp #160
	beq resetY
	jmp noResetY

topResetY
	lda #160
	jmp noResetY

resetY
	lda #5

noResetY
	rts


;--------------------------------------------------------------------------
; checkXPosition
;--------------------------------------------------------------------------
; Takes current Y position and new proposed X position and checks
; for falling off, edge of screen, or walls.
;
; (Currently just loops)
; 
; Preload:
; A: X position
;
; Returns:
; A: updated X position
;
;--------------------------------------------------------------------------
checkXPosition

	cmp #0
	beq topResetX
	cmp #1
	beq topResetX
	cmp #2
	beq topResetX
	cmp #3
	beq topResetX

	cmp #69
	beq resetX
	cmp #70
	beq resetX
	cmp #71
	beq resetX
	cmp #72
	beq resetX
	jmp noResetX

topResetX
	lda #68
	jmp noResetX

resetX
	lda #5

noResetX
	rts




;--------------------------------------------------------------------------
; VBlank
;--------------------------------------------------------------------------
; Handle user input and display setup during the VBLANK period
;--------------------------------------------------------------------------
VBlank
;	jsr songPlayer
;	jsr notePlayer

	ldx padVal3

	; Get paddle value from table (0-15)
	lda paddleDecode,x
	sta DISPLAY

	ldy p2yVel
	ldx p2y
	jsr calcSpeed
	stx p2yVel

	jsr checkYPosition
	sta p2y


;	ldx padVal4

	; Get paddle value from table (0-15)
;	lda paddleDecode,x
;	sta DISPLAY

;	ldy p1xVel
;	ldx p1x
;	jsr calcSpeed
;	stx p1xVel

;	jsr checkXPosition
;	sta p1x


;	ldx padVal1
;	ldy p2yVel
;	lda p2y
;	jsr calcSpeed
;	stx p2yVel

;	jsr checkYPosition
;	sta p2y


;	ldx padVal4
;	ldy p2xVel
;	lda p2x
;	jsr calcSpeed
;	stx p2xVel

;	jsr checkXPosition
;	sta p2x



	; Set up temporarly playfield data
	ldy #84
pfCopy
	lda level1-1,y
	sta playField-1,y
	dey
	bne pfCopy

	rts ; VBlank

;--------------------------------------------------------------------------
; Overscan
;--------------------------------------------------------------------------
overscan

	sta WSYNC	
	lda #33		; 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

	rts	; overscan





;--------------------------------------------------------------------------
; Draw Screen
;--------------------------------------------------------------------------
drawScreen

	;******************* Position P0/P1 for Score ***********************

	sta HMCLR
	; Set horizontal player positions for score
	sta WSYNC
	lda (temp),x
	lda (temp),x
	lda (temp),x
	lda (temp),x
	lda temp
	sta RESP0
	lda (temp),x
	lda (temp),x
	lda temp
	sta RESBL
	nop
	lda temp
	sta RESP1	
	
	lda #%00100000
	sta HMP0
	lda #%00010000
	sta HMBL
	sta WSYNC
	sta HMOVE

	; ***************** Wait for Timer ******************

	ldx #$80
	; Wait for timer
timer
    LDA INTIM
    BNE timer ;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.

	lda #%10010010
	sta GRP0
	
	lda #%00000111
	sta NUSIZ0
	sta NUSIZ1

	lda #0
	sta GRP0
	sta GRP1
	sta COLUP0
	sta COLUP1
	sta CTRLPF
	lda #255
	sta ENABL
	sta WSYNC
	lda #$0F
    STA COLUPF
	
	; ************** Score Draw Loop ********************

    LDY #6      ;We're going to use Y to count lines.
scoreLoop
	lda scoreData1,y
	sta PF1
	lda scoreP0,y
	sta GRP0
	lda scoreData2,y
	sta PF2
	lda scoreP1,y
	sta GRP1
    STA WSYNC      ;Wait for end of scanline
    DEY
    BNE scoreLoop   ;Count scanlines.

	lda #0
	sta PF1
	sta PF2

	; ************** Future Status and Timer (22 lines) ****************

	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	lda #%00001111
	sta PF2
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	lda DISPLAY
	sta PF2
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC
	sta WSYNC


	; ***************** Position Game Objects *********************

	lda #$54
	sta pfColor
	
	; Set sizes
	lda #32		;2
	sta NUSIZ1	;3
	lda #0
	sta NUSIZ0	;3
	sta PF1		;3
	sta PF2		;3

	; Load playfield color buffer
	lda playField+71,x	;4 66 
	sta pfBuffer+7

	; ***************** Position M0 (Divider Line) *********************
	
	nop
	nop
	nop
	nop
	nop
	nop
	nop

	sta HMCLR
	sta RESM0
	lda #%00010000
	sta HMM0

	sta WSYNC

	; ***************** Set Up Marble Shape Pointers *******************

	; Set up P0 (Left Player)
	
	lda #>marbleData2
	sta pMarble+1

	lda p1y
	sta pMarble

	; For vertical values >100 a different page of image data is used
	cmp #100
	bmi noOffset

	sbc #64
	sta pMarble			;3

	lda #>marbleData3
	sta pMarble+1

noOffset

	; Set up P1 (Right Player)
	
	lda #>marbleData2
	sta pMarble2+1

	lda p2y
	sta pMarble2

	; For vertical values >100 a different page of image data is used
	cmp #100
	bmi noOffset2
	sbc #64
	sta pMarble2			;3

	lda #>marbleData3
	sta pMarble2+1

noOffset2
	
	; Set player colors to white
	lda #$0F		;2
	sta COLUP0		;3
	sta COLUP1		;3


	;**************** Position P0 (Left Marble) ***************

	ldx p1x
	STA WSYNC
	; Uses a lookup table to get the fine and course movement
	lda movement,x
	STA HMP0
	AND #$0F
	TAY

pPos1
	DEY
	BPL pPos1
	STA RESP0


	STA WSYNC
	STA HMOVE

	;**************** Position P1 (Right Marble) ***************

	nop
	nop	
	nop
	nop
	nop
	nop

	ldx p2x
	; Uses a lookup table to get the fine and course movement
	lda movement,x
	STA HMP1

	ldx #0
	stx HMP0
	stx HMM0

	AND #$0F
	TAY

pPos2
	DEY
	BPL pPos2

	STA RESP1

	; **************** Position M1 (Power Ups) *********************

	STA WSYNC
	STA HMOVE
	

	; Power up flickers between player 1 and 2
	; power up.
	ldx pwr1x
	lda frame
	and #%00000001
	beq powerUp1
	ldx pwr2x	
powerUp1

	; Uses a lookup table to get the fine and course movement
	lda movement,x
	ldy #$0F


	sta WSYNC
	sta HMCLR

	STA HMM1

	AND #$0F
	TAY
pPos3
	DEY
	BPL pPos3
	STA RESM1


	sta WSYNC
	sta HMOVE

	; The Ball is used to show the center divider in the score
	; area, but M0 is used in the game area.  Turn on M0 here.
	lda #$FF
	sta ENAM0

	;******* Calculate line position of Vertical Paddle bar (Ball) *******

	; temp16L stores the position
	; of the vertical paddle indicator
	ldx padVal1

	lda frame
	and #1
	bne vertPad1

	ldx padVal3
vertPad1

	lda paddleDecode,x

	sta temp
	lda #14
	sec
	sbc temp
	bcc padZero

	clc
	adc #1
	jmp notPadZero

padZero 
	lda #1
notPadZero

	sta temp16L

	ldx #$0

	cmp #13
	bmi ballOff

	ldx #$FF

ballOff

	stx ENABL

	lda #%00010000
	sta CTRLPF

	sta WSYNC

	; Draw top white line
	lda #$0F
	sta COLUBK
	sta COLUBK
	

	;*********** Position Ball (shows vertical Paddle position) ***********

	; The ball graphics flickers between the left side and right side
	; to indicate both player's vertical paddle positions

	lda frame
	and #1
	beq right

	ldx #4
ballL
	dex
	bne ballL

	lda #%11010000
	sta HMBL	

	nop
	sta RESBL

	jmp endBallPos

right
	ldx #9
ballR
	dex
	bne ballR

	lda #%11000000
	sta HMBL	

	nop
	sta RESBL

endBallPos
	sta WSYNC
	sta HMOVE


	lda #0
	sta COLUBK
	
	lda #$FF
	sta ENAM0

	nop
	nop
	nop
	nop
	nop
	nop
	nop	
	nop
	nop	
	nop

	;***************** General Setup for Screen Drawing *******************


	; Use Y to track the actual line
	ldy #156		;2 20

	; number of blocks
	ldx #12			;2 = 18


	; Alternate the two kernals every frame
	lda frame
	and #%00000001
	beq gotoScanLoop2

	jmp gotoScanLoop3	

gotoScanLoop2
	
	; Set starting Paddle counter values
	lda #161
	sta padVal1
	sta padVal2


	; Playfield Reference
	;
	; pfBuffer
	; 0 = PF0.1
	; 1 = PF1.1
	; 2 = PF2.1
	; 3 = PF0.2
	; 4 = PF1.2
	; 5 = PF2.2
	; 6 = PFCOLOR1
	; 7 = PFCOLOR2
	;
	;  0  Hblank  22 PF0 28   PF1   38   PF2   48 PF0 56   PF1   66   PF2   76
	;  |----22----||--6--||---10----||---10----||--6--||---10----||---10----||
	;               4---7  7-------0  0-------7  4---7  7-------0  0-------7


	;****************** Start of Kernal A **********************

scanLoop2

	lda pfColor
	sta COLUPF

	lda playField-1,x	;4 76

	; 1A) setup
	;---------------------------------------

	sta PF0				;3
	sta pfBuffer		;3
	lda (pMarble),y		;5*
	sta GRP0			;3
	lda playField+11,x	;4
	sta PF1				;3
	lda playField+23,x	;4
	sta PF2				;3

	lda (pMarble2),y		;5*
	sta GRP1			;3

	lda pfBuffer		;3
	asl					;2
	asl					;2
	asl					;2
	asl					;2
	sta PF0				;3 48
	sta pfBuffer+3		;3

	lda playField+35,x	;4
	sta PF1				;3 55
	lda playField+47,x	;4
	sta PF2				;3
	sta pfBuffer+5		;3
	dey				;2
	lda (pMarble),y		;5*
	
	; 2A) colors
	;---------------------------------------
	sta GRP0			;3

	lda playField+59,x	;4 66 
	sta COLUPF			;3
	sta pfBuffer+6		;3 

	lda pfBuffer		;3
	sta PF0				;3
	lda playField+11,x	;4
	sta PF1				;3
	lda playField+23,x	;4
	sta PF2				;3 34

	lda (pMarble2),y		;4
	sta GRP1			;3
	
	
	lda pfBuffer+3		;3
	sta PF0				;3 52
	lda playField+35,x	;4
	sta PF1				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3

	; 3A) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3
	lda pfColor			;3
	sta COLUPF			;3

	lda playField+11,x	;4
	sta PF1				;3
	sta pfBuffer+1		;3

	lda playField+23,x	;4
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3 39
	
	nop

	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda playField+35,x	;4
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3 68

	lda INPT0			;3
	bmi paddles1		;2 or 3
	sty padVal1			;3
paddles1

;	lda (temp),x		; 6 simulate max paddle read cycles
;	nop					; 2

	lda pfBuffer		;3
	sta PF0				;3

	sta WSYNC

	; 4A) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	lda pfBuffer+1		;4
	sta PF1				;3

	lda playField+23,x	;4
	sta PF2				;3 29
	sta pfBuffer+2		;3

	lda (pMarble2),y		;4
	sta GRP1			;3
	

	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda playField+35,x	;4
	sta PF1				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3

	; 5A) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	lda pfBuffer+1		;3
	sta PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3 29

	lda (pMarble2),y		;4
	sta GRP1			;3
	
	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda playField+35,x	;4
	sta PF1				;3
	sta pfBuffer+4

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3
	
	lda INPT1			;3
	bmi paddles2		;2 or 3
	sty padVal2			;3
paddles2

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC

	; 6A) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	txs
	ldx pfBuffer+1		;3
	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	dey					;2
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3


	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3

	; 7A) more setup
	;---------------------------------------

;	lda pfBuffer		;3
;	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3


	; Draw the power up (using missile 1)
	tsx					;2
	txa					;2
	ldx #ENABL			;2
	txs					;2
	cmp temp16L
	php
	cmp pwr1y			;2
	php					;3
	tax

	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	
	txs
	nop

	lda pfBuffer		;3
	sta WSYNC

	sta PF0				;3
	ldx pfBuffer+1		;3

	; 8A) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	dey					;2
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3


	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3

	; 9A) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	nop					;8
	nop
	nop
	nop
;	lda #0
;	sta ENABL
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3
	
	lda INPT0			;3
	bmi paddles3		;2 or 3
	sty padVal1			;3
paddles3

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC


	; 10A) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	lda #0
	sta ENAM1
	;nop
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	dey					;2

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3

	; 11A) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	nop
	nop
	nop
	nop

	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3

	lda INPT1			;3
	bmi paddles4		;2 or 3
	sty padVal2			;3
paddles4

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC

	; 12A) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	nop
	nop
	nop
	dey					;2
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3

	; 13A) setup for loop
	;---------------------------------------

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3
	tsx					;2
	;nop

	; Load the next right-playfield color
	lda playField+71-1,x	;4 66 
	sta pfBuffer+7			;3 

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y
	sta GRP1

	nop
	dey

	lda pfBuffer+3		;3
	sta PF0				;3
	lda pfBuffer+4		;4
	sta PF1				;3
	lda pfBuffer+5		;3
	sta PF2				;3


    dex					;2
    beq quitScanLoop2   ;2
	jmp scanLoop2		;3 must be 70

	;******************* End Of Kernal A ***********************

	;******************* Kernal Clean Up **********************

quitScanLoop2
	sta WSYNC

	; Draw the white line at the bottom
	lda #$0F
	sta COLUPF
	lda #255
	sta PF0
	sta PF1
	sta PF2

endOfScreen
	
	; One more scanline
	sta WSYNC
	lda #0
	sta PF0
	sta ENABL
	sta ENAM0
	sta PF1
	sta PF2
	sta COLUP0
	sta COLUP1

	; restore stack
	ldx #253
	txs

    RTS


	; ***************** Start of Kernal B ******************

gotoScanLoop3
	; Set starting paddle counter values
	lda #161
	sta padVal3
	sta padVal4

scanLoop3
	lda pfColor
	sta COLUPF

	lda playField-1,x	;4 76

	; 1B) setup
	;---------------------------------------

	sta PF0				;3
	sta pfBuffer		;3
	lda (pMarble),y		;5*
	sta GRP0			;3
	lda playField+11,x	;4
	sta PF1				;3
	lda playField+23,x	;4
	sta PF2				;3

	lda (pMarble2),y		;5*
	sta GRP1			;3

	lda pfBuffer		;3
	asl					;2
	asl					;2
	asl					;2
	asl					;2
	sta PF0				;3 48
	sta pfBuffer+3		;3

	lda playField+35,x	;4
	sta PF1				;3 55
	lda playField+47,x	;4
	sta PF2				;3
	sta pfBuffer+5		;3
	dey				;2


	; 2B) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3
;	lda pfColor			;3
;	sta COLUPF			;3

	lda playField+11,x	;4
	sta PF1				;3
	sta pfBuffer+1		;3

	lda playField+23,x	;4
	sta PF2				;3
	sta pfBuffer+2		;3

	lda (pMarble2),y		;4
	sta GRP1			;3 39
	
	nop
	nop
	nop
	dey					;2

	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda playField+35,x	;4
	sta PF1				;3
	sta pfBuffer+4		;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3 68

	lda INPT2			;3
	bmi paddles5		;2 or 3
	sty padVal3			;3
paddles5

;	lda (temp),x		; 6 simulate max paddle read cycles
;	nop					; 2

	lda pfBuffer		;3
	sta PF0				;3



;	lda (pMarble),y		;5*
;	sta GRP0			;3
	sta WSYNC


	
	; 3B) colors
	;---------------------------------------

	lda playField+59,x	;4 66 
	sta COLUPF			;3
	sta pfBuffer+6		;3 

	lda pfBuffer+1		;3
	sta PF1				;3
	lda pfBuffer+2		;3
	sta PF2				;3 34

	lda (pMarble2),y		;4
	sta GRP1			;3
	
	nop
	nop
	nop
	
	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+4		;3
	sta PF1				;3



	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3

	; 4B) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	lda pfBuffer+1		;3
	sta PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3 29

	lda (pMarble2),y		;4
	sta GRP1			;3

	dey					;2
	nop
	nop
	
	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3
	
	lda INPT3			;3
	bmi paddles6		;2 or 3
	sty padVal4			;3
paddles6

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC

	; 5B) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	lda pfBuffer+1		;4
	sta PF1				;3

	lda playField+23,x	;4
	sta PF2				;3 29
	sta pfBuffer+2		;3

	lda (pMarble2),y		;4
	sta GRP1			;3
	
	lda pfBuffer+3		;3
	sta PF0				;3 52

	lda playField+35,x	;4
	sta PF1				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3


	; 6B) more setup
	;---------------------------------------

	lda pfColor			;3
	sta COLUPF			;3

	lda pfBuffer+1		;3
	sta PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	; Draw the power up (using missile 1)
	txa					;2
	ldx #ENABL			;2
	txs					;2
	cmp temp16L
	php
	cmp pwr2y			;2
	php					;3
	tax


	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	

	lda pfBuffer		;3
	sta PF0				;3
;	sta WSYNC
;	nop
	nop


	; 7B) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	txs
	ldx pfBuffer+1		;3
	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	dey					;2

;	nop
;	nop
	nop
	lda temp
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3


	lda (pMarble),y		;4*
	sta GRP0			;3


	; 8B) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	nop					;8
	nop
;	lda #0
;	sta ENABL
	nop
	nop
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	dey					;2
	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3
	
	lda INPT2			;3
	bmi paddles7		;2 or 3
	sty padVal3			;3
paddles7

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC



	; 9B) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	dey					;2
	nop
	nop
	nop
	lda #0				;2
	sta ENAM1			;3
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+4		;3
	sta PF1				;3


	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3


	; 10B) paddles
	;---------------------------------------

	lda pfBuffer		;3
	sta PF0				;3

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	lda temp
	nop
	nop
	nop
	dey					;2

	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3
	lda pfBuffer		;3
	sta PF0				;3
	
	lda INPT3			;3
	bmi paddles8		;2 or 3
	sty padVal4			;3
paddles8

;	lda (temp),x		; 6 simulate max paddle-read cycles
;	nop					; 2

	sta WSYNC


	; 11B) colors
	;---------------------------------------

	lda pfBuffer+6		;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	lda temp
	nop
	nop
	nop
	nop
	dey					;2
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+7		;3
	sta COLUPF			;3

	lda pfBuffer+4		;3
	sta PF1				;3


	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3

	lda pfBuffer		;3
	sta PF0				;3


	; 12B) nothing
	;---------------------------------------

	lda pfColor			;3
	sta COLUPF			;3

	stx PF1				;3

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y		;4
	sta GRP1			;3

	nop
	nop
	nop
	nop
	nop
	nop	
	nop
	nop
	dey					;2
	
	lda pfBuffer+3		;3
	sta PF0				;3

	lda pfBuffer+4		;3
	sta PF1				;3

	lda pfBuffer+5		;4
	sta PF2				;3

	lda (pMarble),y		;4*
	sta GRP0			;3

	nop
	nop

	lda pfBuffer		;3
	sta PF0				;3

	; 13B) setup for loop
	;---------------------------------------


	stx PF1				;3
	tsx					;2
	;nop

	; Load the next right-playfield color
	lda playField+71-1,x	;4 66 
	sta pfBuffer+7			;3 

	lda pfBuffer+2		;3
	sta PF2				;3

	lda (pMarble2),y
	sta GRP1

	nop
	dey

	lda pfBuffer+3		;3
	sta PF0				;3
	lda pfBuffer+4		;4
	sta PF1				;3
	lda pfBuffer+5		;3
	sta PF2				;3


    dex					;2
    beq quitScanLoop3   ;2
	jmp scanLoop3		;3 must be 70

quitScanLoop3
	sta WSYNC

	lda #$0F
	sta COLUPF
	lda #255
	sta PF0
	sta PF1
	sta PF2
	
	jmp endOfScreen

	; ******************* End of Kernal B ******************









timeData1
scoreP1
scoreP0
	byte #%00000000
	byte #%00000000
	byte #%10000010
	byte #%00000000
	byte #%00000000
	byte #%10010000
	byte #%00000000
	byte #%00000000

scoreData1
	byte #%00000000
	byte #%10110010
	byte #%10110010
	byte #%10110010
	byte #%10110110
	byte #%10110110
	byte #%10110110
	byte #%10110110

scoreData2
	byte #%00000000
	byte #%00010011
	byte #%00010011
	byte #%00010011
	byte #%00010011
	byte #%00010001
	byte #%00011011
	byte #%00011011

	
level1
	;PF1/2
	byte %01100000
	byte %11100000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00001111
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000

	;PF1.1
	byte %00000000
	byte %11111111
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00111111
	byte %00110000
	byte %00110000

	;PF1.2
	byte %00000000
	byte %00111111
	byte %00110000
	byte %00110000
	byte %00110000
	byte %00111111
	byte %00000011
	byte %01111111
	byte %01100000
	byte %01111111
	byte %00000000
	byte %00000000
	
	;PF2.1
	byte %01100000
	byte %01100000
	byte %01111000
	byte %00011000
	byte %00011110
	byte %00000110
	byte %11111111
	byte %00000001
	byte %00000001
	byte %00000000
	byte %00000000
	byte %00000000

	;PF2.2
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000000
	byte %00000001
	byte %00000001
	byte %00000111
	byte %00000110
	byte %00011110
	byte %00011000

	; colors
	byte $52
	byte $54
	byte $52
	byte $52
	byte $52
	byte $54
	byte $56
	byte $54
	byte $52
	byte $54
	byte $54
	byte $54

	; colors
	byte $52
	byte $52
	byte $54
	byte $52
	byte $54
	byte $52
	byte $54
	byte $52
	byte $54
	byte $52
	byte $54
	byte $54


;	include mtitle.h

;	include songplay.h


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

Current Thread