game
.L00 ;  rem Generated 1/4/2010 1:48:01 PM by Visual bB Version 1.0.0.548

.L01 ;  rem **********************************

.L02 ;  rem *<Luciano Game>               *

.L03 ;  rem *<Atire no inimigo que vem caindo>*

.L04 ;  rem *<www.lucianovictor.com>             *

.L05 ;  rem **********************************

.
 ; 

.
 ; 

.L06 ;  rem Create the title screen

.opening
 ; opening

.
 ; 

.L07 ;  playfield:

  ifconst pfres
	  ldx #(11>pfres)*(pfres*pfwidth-1)+(11<=pfres)*43
  else
	  ldx #((11*pfwidth-1)*((11*pfwidth-1)<47))+(47*((11*pfwidth-1)>=47))
  endif
	jmp pflabel0
PF_data0
	.byte %10000100, %01011101
	if (pfwidth>2)
	.byte %11101001, %00011110
 endif
	.byte %10000100, %01000101
	if (pfwidth>2)
	.byte %10101001, %00010010
 endif
	.byte %10000100, %01000101
	if (pfwidth>2)
	.byte %11101101, %00010010
 endif
	.byte %10000100, %01000101
	if (pfwidth>2)
	.byte %10101011, %00010010
 endif
	.byte %11110111, %01011101
	if (pfwidth>2)
	.byte %10101001, %00011110
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00011111, %01011110
	if (pfwidth>2)
	.byte %00101111, %00000000
 endif
	.byte %00010000, %11010010
	if (pfwidth>2)
	.byte %01101000, %00000000
 endif
	.byte %00010111, %01011110
	if (pfwidth>2)
	.byte %10101111, %00000000
 endif
	.byte %00010001, %01010010
	if (pfwidth>2)
	.byte %00101000, %00000000
 endif
	.byte %00011111, %01010010
	if (pfwidth>2)
	.byte %00101111, %00000000
 endif
pflabel0
	lda PF_data0,x
	sta playfield,x
	dex
	bpl pflabel0
.
 ; 

.
 ; 

.L08 ;  rem Loop the screen until the spacebar is pressed

.title
 ; title

.L09 ;  COLUBK  =  $0E

	LDA #$0E
	STA COLUBK
.L010 ;  COLUPF  =  212

	LDA #212
	STA COLUPF
.L011 ;  drawscreen

 jsr drawscreen
.L012 ;  if joy0fire  ||  joy1fire then goto skiptitle

 bit INPT4
	BMI .skipL012
.condpart0
 jmp .condpart1
.skipL012
 bit INPT5
	BMI .skip0OR
.condpart1
 jmp .skiptitle

.skip0OR
.L013 ;  goto title

 jmp .title

.
 ; 

.L014 ;  rem This function displays after the title is skipped

.skiptitle
 ; skiptitle

.
 ; 

.L015 ;  rem Colors

.L016 ;  COLUPF  =  212

	LDA #212
	STA COLUPF
.L017 ;  COLUBK  =  $0E

	LDA #$0E
	STA COLUBK
.
 ; 

.L018 ;  rem Player location

.L019 ;  player0x  =  85  :  player0y  =  85

	LDA #85
	STA player0x
	STA player0y
.L020 ;  player1x  =  05 :  player1y  =  05

	LDA #05
	STA player1x
	STA player1y
.
 ; 

.L021 ;  rem Score setting and color

.L022 ;  score  =  0 :  scorecolor  =  $44

	LDA #$00
	STA score+2
	LDA #$00
	STA score+1
	LDA #$00
	STA score
	LDA #$44
	STA scorecolor
.
 ; 

.L023 ;  rem Missle size and location

.L024 ;  missile0height = 4 : missile0y = 255

	LDA #4
	STA missile0height
	LDA #255
	STA missile0y
.L025 ;  NUSIZ0  =  16

	LDA #16
	STA NUSIZ0
.
 ; 

.L026 ;  rem Create a variable to keep up with lives

.L027 ;  a  =  5

	LDA #5
	STA a
.
 ; 

.L028 ;  rem Create the playfield

.L029 ;  playfield:

  ifconst pfres
	  ldx #(11>pfres)*(pfres*pfwidth-1)+(11<=pfres)*43
  else
	  ldx #((11*pfwidth-1)*((11*pfwidth-1)<47))+(47*((11*pfwidth-1)>=47))
  endif
	jmp pflabel1
PF_data1
	.byte %10000100, %01011101
	if (pfwidth>2)
	.byte %11101001, %00001110
 endif
	.byte %10000100, %01000101
	if (pfwidth>2)
	.byte %10101101, %00001010
 endif
	.byte %10000100, %01000101
	if (pfwidth>2)
	.byte %11101011, %00001010
 endif
	.byte %11110111, %01011101
	if (pfwidth>2)
	.byte %10101001, %00001110
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %11111111, %11111111
	if (pfwidth>2)
	.byte %11111111, %11111111
 endif
pflabel1
	lda PF_data1,x
	sta playfield,x
	dex
	bpl pflabel1
.
 ; 

.
 ; 

.
 ; 

.L030 ;  rem This main function is what loops constantly

.main
 ; main

.
 ; 

.L031 ;  rem This is the animation function

.animate
 ; animate

.L032 ;  rem This frame variable slows down the animation

.L033 ;  v  =  v  +  1

	INC v
.
 ; 

.L034 ;  rem This code animates the sprites

.L035 ;  if v  =  7  &&  w  =  0 then ax

	LDA v
	CMP #7
     BNE .skipL035
.condpart2
	LDA w
	CMP #0
	beq .ax
.skipL035
.
 ; 

.L036 ;  goto nextstep

 jmp .nextstep

.
 ; 

.
 ; 

.ax
 ; ax

.L037 ;  v  =  0

	LDA #0
	STA v
.L038 ;  w  =  1

	LDA #1
	STA w
.L039 ;  player1:

	LDX #<playerL039_1
	STX player1pointerlo
	LDA #>playerL039_1
	STA player1pointerhi
	LDA #9
	STA player1height
.L040 ;  goto nextstep

 jmp .nextstep

.
 ; 

.
 ; 

.L041 ;  rem Create acorn sprite

.nextstep
 ; nextstep

.L042 ;  player0:

	LDX #<playerL042_0
	STX player0pointerlo
	LDA #>playerL042_0
	STA player0pointerhi
	LDA #9
	STA player0height
.
 ; 

.L043 ;  rem check to see if a missile has already been fired

.checkfire
 ; checkfire

.L044 ;  if missile0y > 240 then goto skip

	LDA #240
	CMP missile0y
     BCS .skipL044
.condpart3
 jmp .skip

.skipL044
.L045 ;  missile0y  =  missile0y  -  2  :  goto draw

	LDA missile0y
	SEC
	SBC #2
	STA missile0y
 jmp .draw

.
 ; 

.L046 ;  rem if a missile hasn't been fired, then fire missile

.skip
 ; skip

.L047 ;  if joy0fire then missile0y = player0y - 2 : missile0x = player0x + 4

 bit INPT4
	BMI .skipL047
.condpart4
	LDA player0y
	SEC
	SBC #2
	STA missile0y
	LDA player0x
	CLC
	ADC #4
	STA missile0x
.skipL047
.
 ; 

.L048 ;  rem Draw output to screen

.draw
 ; draw

.L049 ;  drawscreen

 jsr drawscreen
.
 ; 

.L050 ;  rem Fix player wraparound bug

.L051 ;  if player0x  <  8 then player0x  =  8

	LDA player0x
	CMP #8
     BCS .skipL051
.condpart5
	LDA #8
	STA player0x
.skipL051
.L052 ;  if player0x  >  150 then player0x  =  150

	LDA #150
	CMP player0x
     BCS .skipL052
.condpart6
	LDA #150
	STA player0x
.skipL052
.L053 ;  if player0y  <  8 then player0y  =  8

	LDA player0y
	CMP #8
     BCS .skipL053
.condpart7
	LDA #8
	STA player0y
.skipL053
.L054 ;  if player0y  >  84 then player0y  =  84

	LDA #84
	CMP player0y
     BCS .skipL054
.condpart8
	LDA #84
	STA player0y
.skipL054
.
 ; 

.L055 ;  rem Have player 1 chase player 2

.L056 ;  if player1y  <  player0y then player1y  =  player1y  +  1

	LDA player1y
	CMP player0y
     BCS .skipL056
.condpart9
	INC player1y
.skipL056
.L057 ;  if player1y  >  player0y then player1y  =  player1y  -  1

	LDA player0y
	CMP player1y
     BCS .skipL057
.condpart10
	DEC player1y
.skipL057
.L058 ;  if player1x  <  player0x then player1x  =  player1x  +  1

	LDA player1x
	CMP player0x
     BCS .skipL058
.condpart11
	INC player1x
.skipL058
.L059 ;  if player1x  >  player0x then player1x  =  player1x  -  1

	LDA player0x
	CMP player1x
     BCS .skipL059
.condpart12
	DEC player1x
.skipL059
.L060 ;  player1x  =  player1x  :  player1y  =  player1y

	LDA player1x
	STA player1x
	LDA player1y
	STA player1y
.
 ; 

.
 ; 

.L061 ;  rem Detect missile collision with squirrel

.L062 ;  if collision(missile0,player1) then score = score + 1 : player1x = rand / 2 : player1y = 0 : missile0y = 255 : goto pointsound

	bit 	CXM0P
	BPL .skipL062
.condpart13
	SED
	CLC
	LDA score+2
	ADC #$01
	STA score+2
	LDA score+1
	ADC #$00
	STA score+1
	LDA score
	ADC #$00
	STA score
	CLD
 jsr randomize
	lsr
	STA player1x
	LDA #0
	STA player1y
	LDA #255
	STA missile0y
 jmp .pointsound

.skipL062
.L063 ;  rem Detect squirrel collision with the acorn

.L064 ;  if collision(player0,player1) then score = score - 1 : player1x = rand / 2 : player1y = 0 : missile0y = 255 : a = a - 1 : goto deadsound

	bit 	CXPPMM
	BPL .skipL064
.condpart14
	SED
	SEC
	LDA score+2
	SBC #$01
	STA score+2
	LDA score+1
	SBC #$00
	STA score+1
	LDA score
	SBC #$00
	STA score
	CLD
 jsr randomize
	lsr
	STA player1x
	LDA #0
	STA player1y
	LDA #255
	STA missile0y
	DEC a
 jmp .deadsound

.skipL064
.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.L065 ;  rem joystick movements

.L066 ;  if joy0up then player0y  =  player0y - 1  :  goto skipmove

 lda #$10
 bit SWCHA
	BNE .skipL066
.condpart15
	DEC player0y
 jmp .skipmove

.skipL066
.L067 ;  if joy0down then player0y  =  player0y + 1  :  goto skipmove

 lda #$20
 bit SWCHA
	BNE .skipL067
.condpart16
	INC player0y
 jmp .skipmove

.skipL067
.L068 ;  if joy0left then player0x  =  player0x - 1  :  goto skipmove

 bit SWCHA
	BVS .skipL068
.condpart17
	DEC player0x
 jmp .skipmove

.skipL068
.L069 ;  if joy0right then player0x  =  player0x  + 1  :  goto skipmove

 bit SWCHA
	BMI .skipL069
.condpart18
	INC player0x
 jmp .skipmove

.skipL069
.
 ; 

.L070 ;  rem refresh the screen

.skipmove
 ; skipmove

.L071 ;  goto main

 jmp .main

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.L072 ;  rem Play point sound

.pointsound
 ; pointsound

.L073 ;  AUDV0  =  5  :  AUDC0  =  4  :  AUDF0  =  10

	LDA #5
	STA AUDV0
	LDA #4
	STA AUDC0
	LDA #10
	STA AUDF0
.L074 ;  p  =  p  +  1

	INC p
.L075 ;  drawscreen

 jsr drawscreen
.L076 ;  if p  <  2 then pointsound

	LDA p
	CMP #2
	bcc .pointsound
.L077 ;  p  =  0

	LDA #0
	STA p
.L078 ;  AUDV0  =  0  :  AUDC0  =  0  :  AUDF0  =  0

	LDA #0
	STA AUDV0
	STA AUDC0
	STA AUDF0
.L079 ;  goto main

 jmp .main

.
 ; 

.L080 ;  rem Play dead sound

.deadsound
 ; deadsound

.L081 ;  AUDV1  =  8 , 1 , 31

; complex statement detected
	LDA #8
	PHA
	LDA #,
	PHA
	LDA #1
	PHA
	LDA #,
	PHA
	LDA #31
	STA AUDV1
.L082 ;  AUDC1  =  0 , 0 , 0

; complex statement detected
	LDA #0
	PHA
	LDA #,
	PHA
	LDA #0
	PHA
	LDA #,
	PHA
	LDA #0
	STA AUDC1
.L083 ;  AUDF1  =  11

	LDA #11
	STA AUDF1
.L084 ;  p  =  p  +  1

	INC p
.L085 ;  drawscreen

 jsr drawscreen
.L086 ;  if p  <  10 then deadsound

	LDA p
	CMP #10
	bcc .deadsound
.L087 ;  p  =  0

	LDA #0
	STA p
.L088 ;  AUDV1  =  8.1.31  :  AUDC1  =  0.0.0  :  AUDF1  =  11

	STA AUDV1
	STA AUDC1
	LDA #11
	STA AUDF1
.L089 ;  if a  =  0 then goto opening

	LDA a
	CMP #0
     BNE .skipL089
.condpart19
 jmp .opening

.skipL089
.
 ; 

.
 ; 

.L090 ;  playfield:

  ifconst pfres
	  ldx #(11>pfres)*(pfres*pfwidth-1)+(11<=pfres)*43
  else
	  ldx #((11*pfwidth-1)*((11*pfwidth-1)<47))+(47*((11*pfwidth-1)>=47))
  endif
	jmp pflabel2
PF_data2
	.byte %01111110, %10111111
	if (pfwidth>2)
	.byte %11111111, %01111101
 endif
	.byte %01100000, %10110011
	if (pfwidth>2)
	.byte %10011001, %00001101
 endif
	.byte %01101110, %10111111
	if (pfwidth>2)
	.byte %10011001, %00111101
 endif
	.byte %01100110, %10110011
	if (pfwidth>2)
	.byte %10011001, %00001101
 endif
	.byte %01111110, %10110011
	if (pfwidth>2)
	.byte %10011001, %01111101
 endif
	.byte %00000000, %00000000
	if (pfwidth>2)
	.byte %00000000, %00000000
 endif
	.byte %00011111, %11001101
	if (pfwidth>2)
	.byte %01111101, %00011111
 endif
	.byte %00011001, %11001101
	if (pfwidth>2)
	.byte %01100001, %00011001
 endif
	.byte %00011001, %11001101
	if (pfwidth>2)
	.byte %01111001, %00001111
 endif
	.byte %00011001, %11001101
	if (pfwidth>2)
	.byte %01100001, %00011001
 endif
	.byte %00011111, %00110001
	if (pfwidth>2)
	.byte %01111101, %00011001
 endif
pflabel2
	lda PF_data2,x
	sta playfield,x
	dex
	bpl pflabel2
.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.gotomain
 ; gotomain

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

.
 ; 

 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
playerL039_1
	.byte  %01111111
	.byte  %01011101
	.byte  %01000001
	.byte  %01001001
	.byte  %01000001
	.byte  %01010101
	.byte  %01000001
	.byte  %01111111
	.byte 
	.byte  
 if (<*) > (<(*+9))
	repeat ($100-<*)
	.byte 0
	repend
	endif
playerL042_0
	.byte 
	.byte 
	.byte  %01100011
	.byte  %01100011
	.byte  %01100011
	.byte  %01100011
	.byte  %01100011
	.byte  %01111111
	.byte  %01110111
	.byte  %01111111
 if ECHOFIRST
       echo "    ",[(scoretable - *)]d , "bytes of ROM space left")
 endif 
ECHOFIRST = 1
 
 
 
