Jump to content

Photo

My history teacher ate lemons.


4 replies to this topic

#1 atari2600land ONLINE  

atari2600land

    Channel F Viewer

  • 11,215 posts
  • Location:Salem, Oregon

Posted Wed Nov 8, 2017 8:23 PM

So I've got the beginnings of a game here. I want to know how much space I have left but when I go to compile it, it compiles fine but it won't tell me how many bytes I have left. Any ideas why?

 

Attached Files



#2 atari2600land ONLINE  

atari2600land

    Channel F Viewer

  • Topic Starter
  • 11,215 posts
  • Location:Salem, Oregon

Posted Thu Nov 9, 2017 9:25 PM

I am so angry I want to kill myself. Why won't this work?!?!?!?!??! :mad:

Collisions
        ldx PlayerX
        cpx #42      ; test for edge of screen
        bcs TestOnLips     ; save value as is if we're not at edge
        
        lda CXP0FB
        and #$80                   
        beq NoCollisions        
        
        ldx PlayerX
        cpx #18       ; test for edge of screen
        bcs TestSwallowing      ; save value as is if we're not at edge        

        ldx FoodType
        cpx #1
        bcs    Wrong    
    
        jmp    ResetPPPPP


TestSwallowing
        ldx FoodType
        cpx #1        ; used to be 2
        bcs    Wrong    
    
        jmp     ResetPPPPP

TestOnLips
        lda CXP0FB
        and #$80                   
        beq NoCollisions

        ldx FoodType
        cpx #2
        bcs Wrong        
    
        jmp ResetPPPPP        
    
Wrong
        lda #1
        sta AUDC0

        jmp ResetPPPPP2

ResetPPPPP
        sed             ; turn on decimal mode
        clc
        lda Score+1     ; Score+1 holds the Tens and Ones digits
        adc #1          ; add 1 to score
        sta Score+1
        lda Score       ; Score holds the Thousands and Hundreds digits
        adc #0          ; add 0 to this digit, carry will inc by 1 if needed
        sta Score       ;
        cld             ; turn off decimal mode    

        lda #4    
        sta AUDC0

ResetPPPPP2
        lda #4    
        sta AUDV0
        lda #22
        sta AUDF0    

        lda #8
        sta OverscanValue
    
        lda #1
        sta SFXTimer
    
        ldy #140
        sty PlayerX        

        jsr Random
        and #$01
        sta FoodType    

NoCollisions
        sta CXCLR
        rts

 Lemon is 2 and French Fry is 1. I want it to do the following:

 

If Lemon hits lips then AUDC0=1. Otherwise AUDC0=4

if French Fry hits lips then AUDC0=4, otherwise AUDC0=1

 

I've tried every single possible combination and they're all wrong. WHY?

Attached Files


Edited by atari2600land, Thu Nov 9, 2017 9:25 PM.


#3 Kiwi ONLINE  

Kiwi

    Stargunner

  • 1,534 posts

Posted Fri Nov 10, 2017 12:24 AM

I think this is what you want.

 

Collisions


		ldx PlayerX
		cpx #40      ; test for edge of screen
	        bpl TestOnLips     ; changed to a plus, it works as a greater than symbol in basic
		
		lda CXP0FB 
		and #$80           		
		beq NoCollisions		
		
		ldx PlayerX
		cpx #18       ; test for edge of screen
	        beq TestSwallowing      ; Changed to an equal, branch on carry requires the carry flag to be raised.		

		ldx FoodType
		cpx #1
		beq	 Wrong	;changed to equal
	
		jmp	ResetPPPPP 


TestSwallowing
		ldx FoodType
		cpx #2		; Now a 2.
		beq	Wrong	; branch on equal to 2
	
		jmp	 ResetPPPPP 

TestOnLips
		lda CXP0FB 
		and #$80           		
		beq NoCollisions

		ldx FoodType ;I assuming you want points to increase if a fry hit the lip.
		cpx #2       ;if not, you can comment these 3 out
		beq Wrong    ;	and replace jmp ResetPPPPP below with jmp Wrong
	
		jmp ResetPPPPP		
	
Wrong
		lda #1
		sta AUDC0

		jmp ResetPPPPP2


#4 atari2600land ONLINE  

atari2600land

    Channel F Viewer

  • Topic Starter
  • 11,215 posts
  • Location:Salem, Oregon

Posted Fri Nov 10, 2017 4:48 PM

Thank you so much! That worked. I must remember to use beq instead of bcs, though. I thought bcs did what beq did. This is so confusing. Here is the latest version. I tested it to make sure the scanline doesn't go above 262, even when resetting it. The part in bold was the hardest part. It kept going to 263 for 2 frames before going back down to 262.

Attached Files



#5 carlsson OFFLINE  

carlsson

    Metagalactic Mule

  • 6,803 posts
  • Location:Västerås, Sweden

Posted Fri Nov 17, 2017 5:24 AM

Some text copied from a tutorial. Notice the differences between unsigned and signed, and between < and <=.

* If the Z flag is 0, then A <> NUM and BNE will branch
* If the Z flag is 1, then A = NUM and BEQ will branch
* If the C flag is 0, then A (unsigned) < NUM (unsigned) and BCC will branch
* If the C flag is 1, then A (unsigned) >= NUM (unsigned) and BCS will branch
* If the N flag is 1, then A (signed) <= NUM (signed) and BMI will branch
* If the N flag is 0, then A (signed) > NUM (signed) and BPL will branch

http://www.6502.org/...are_beyond.html
http://www.6502.org/...structions.html

It can be tricky sometimes to get it right.




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users