IGNORED

# Weapons check

## Recommended Posts

Here is another important plot point I'm missing...

If I have:

BEQ &FF93 ; Touching sword

I know that BEQ = F0

But how do you translate FF93 into a two digit code?

Accoring to the original code:

F850 F0,4C BEQ &F89E ;Branch if so (Return)

4C=F89E How does that happen? HELP!

##### Share on other sites

I'm missing this important plot point...

If I have this:

BEQ &FF93 ; Touching sword

I understand that BEQ=F0... But what does FF93 change into a 2 digit code?

In the original...

F850 F0,4C BEQ &F89E ;Branch if so (Return)

4C = F89E How the heck is this translated? HELP!

##### Share on other sites

OOPS, sorry for the double post!

##### Share on other sites

Branching instructions work by having the argument jump relative to where in memory you currently are. An argument of zero is straight ahead...just as if the branch never existed. An argument of \$FE causes the branch instruction to jump to itself for eternity (similar to Basic's 10 GOTO 10). Huh? How come a higher value causes it to jump backward? This is because the computer divides the 256 possible combinations of a byte to be half positive (values \$00 to \$7F) and half negative (values \$80 to \$FF). The positive values are easy to figure out...simply jump ahead by the number of bytes shown. The negative values work in reverse...you jump backward by [\$FF minus the byte value shown]. For example, our endless loop of BEQ \$FE is jumping \$FF-\$FE bytes...or 1 byte in reverse. (the value \$FF points to the memory address of the argument itself). So in computing, you should never use a branch value of \$FF (which will probably crash the computer when it lands on the argument rather than an instruction), and you should never need a branch value of \$00 (which is right straight ahead to the next instruction in memory).

##### Share on other sites

4ever2600, do you have a BIN file? I'd like to see this.

##### Share on other sites

I KNEW THAT WAS COMING!

But is that what an NOP is?  A hole filler?

In effect...yes. NOP literally means no operation. You are instructing the computer to do nothing for 2 cycles of machine time. This instruction is often used when debugging code (because you can just NOP over parts of the program that you think might be causing problems, or use them for a placeholder that will go to a subroutine that is not completed yet)...and it will keep the rest of memory from shifting downward to fill that space when you compile the program. In 2600 coding, NOP's are actually REQUIRED to use in areas of the display kernal...since you need the computer to do nothing until the sprites can be placed at the proper positions on the screen.

How does that translate into binary or hex?

\$EA is the value of a NOP instruction. Let's say that a game that you want to cheat in uses an instruction DEC \$88 to kill off one of your lives...you can NOP twice to cover this instruction (1 NOP to cover the DEC instruction, and 1 NOP to cover the \$88 argument). Now instead of executing the instruction DEC \$88 (which means to lower ram location \$88 by 1)...the computer will see NOP...NOP. Tada...infinite lives

##### Share on other sites

Well, here is how I configured your equasion...

;Object #4 : State FF : Graphic

;Software patch

FD88 CMP #&51

FD8A BEQ &FD93 ; Touching sword

FD8C CMP #&87

FD8E BEQ &FD93 ; Touching dot

FD90 JMP &F84B ; nothing happens

FD93 JMP &F83F ; dragon dies

OK, after BEQ &FD93, I want to jump ahead 7 spaces right? So I count from 00 to 06? Or 07? I'm assuming 06...

Did I do this right? Which means I make the value at FD8B 06?

##### Share on other sites

Well, here is how I configured your equasion...

;Object #4 : State FF : Graphic

;Software patch

FD88       CMP #&51    ;2 bytes

FD8A       BEQ  &FD93  ;2 bytes  <-start here    ; Touching sword

FD8C       CMP  #&87   ;2 bytes...branch value \$00

FD8E        BEQ  &FD93  ;2 bytes...branch value \$02     ; Touching dot

FD90        JMP   &F84B  ;3 bytes...branch value \$04     ; nothing happens

FD93       JMP   &F83F    ;3 bytes...branch value \$07    ; dragon dies

OK, after BEQ &FD93, I want to jump ahead 7 spaces right?  So I count from 00 to 06? Or 07?  I'm assuming 06...

Did I do this right? Which means I make the value at FD8B 06?

Aha...you've got to watch out for those JMP instructions...they use 3 bytes (one byte for the JMP, and 2 bytes for the argument). Your first guess of 7 was correct...trust your instincts :wink:

I suggest you get a reference manual so you can see how many bytes the instructions you use take up. In the 65xx computer, they use from 1 to 3 bytes. I've indicated the number of bytes your snippet uses above.

##### Share on other sites

I suppose another way of saying it is that you are skipping the 7 bytes between where you are to where you want to end up...BEQ \$07

##### Share on other sites

Alright, here is what's wierd...

I've triple checked my code... Basically, the solution that Robert gave me DID in fact work... Kinda...

Now the game plays fine... The name is cut off 14 lines, which it should be... But is still there...

The sword kills the dragons once again...

BUT THE DOT DOESN'T!

His solution makes perfect sense... Am I missing something?

##### Share on other sites

Perhaps this should help?

```LF832: STX \$9A

LDX \$A0

JSR LF6FE

LDX \$9A

CMP #\$87;I added this line to make the dot (#\$87) kill the drag

NOP

CMP #\$51;If the sword (#\$51) hits dragon, jump to 'kill' routine

BNE LF84B

LDA #\$01

STA NUSIZ0,X

LDA #\$03

STA \$E0

LDA #\$10

STA \$DF

```

Maybe this works?

##### Share on other sites

Nevermind everybody, IT WORKED! Thanks ROBERT M and NUKEY... I haven't tried VB_Masters quick fix yet, but I am going to really soon here... HAPPY CODING!!!!!!!!! - D

##### Share on other sites

Perhaps this should help?

```LF832: STX \$9A

LDX \$A0

JSR LF6FE

LDX \$9A

CMP #\$87;I added this line to make the dot (#\$87) kill the drag

NOP

CMP #\$51;If the sword (#\$51) hits dragon, jump to 'kill' routine

BNE LF84B

LDA #\$01

STA NUSIZ0,X

LDA #\$03

STA \$E0

LDA #\$10

STA \$DF

```

Maybe this works?

Nope...the two CMP instructions are back-to-back. In the above example, the result of line CMP #\$87 is not even being used...because the program immediately does a CMP #\$51 - tossing out the previous result. Whenever you are doing a CMP, CPX, or CPY...the results of that test are stored in a "status register"...and the computer only has one of those. So you need to do the comparison, and then branch based off the result of that comparison, before doing another.

##### Share on other sites

Guess I won't try it then... Very happy with the results of Robert M.'s patch! And as always thanks to the Nukey.

##### Share on other sites

Nevermind everybody, IT WORKED!  Thanks ROBERT M and NUKEY...   I haven't tried VB_Masters quick fix yet, but I am going to really soon here...  HAPPY CODING!!!!!!!!! - D

Oh good! Sorry about the whole branching address thing. I didn't have my handing dandy chart for calcuating branch offsets so I just put the target address. I thought that would be okay since that's how it was for original branch instructions in the listing.

Cheers!

##### Share on other sites

You know...in the old days, the programmer would need to flip 8 toggle-switches (the bits) and enter a program in byte-by-byte

## 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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.