Jump to content
IGNORED

My history teacher ate lemons.


Recommended Posts

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?

mhtal7.asm

Edited by atari2600land
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

mhtal8.asm

mhtal8.bin

Link to comment
Share on other sites

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/tutorials/compare_beyond.html

http://www.6502.org/tutorials/compare_instructions.html

 

It can be tricky sometimes to get it right.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...