Jump to content



0

Weapons check


40 replies to this topic

#26 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Wed Jan 28, 2004 7:17 PM

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!

#27 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Wed Jan 28, 2004 7:22 PM

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!

#28 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Wed Jan 28, 2004 7:23 PM

OOPS, sorry for the double post!

#29 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Wed Jan 28, 2004 7:36 PM

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

#30 vb_master OFFLINE  

vb_master

    Stargunner

  • 1,770 posts
  • Location:At my computer, where else?

Posted Wed Jan 28, 2004 7:47 PM

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

#31 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Wed Jan 28, 2004 8:01 PM

4ever2600 said:

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.

Quote

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 :)

#32 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Wed Jan 28, 2004 8:21 PM

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?

#33 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Wed Jan 28, 2004 8:32 PM

4ever2600 said:

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.

#34 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Wed Jan 28, 2004 8:46 PM

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

#35 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Wed Jan 28, 2004 9:33 PM

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?

#36 vb_master OFFLINE  

vb_master

    Stargunner

  • 1,770 posts
  • Location:At my computer, where else?

Posted Wed Jan 28, 2004 9:56 PM

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?

#37 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Thu Jan 29, 2004 12:13 AM

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

#38 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Thu Jan 29, 2004 4:41 AM

vb_master said:

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.

#39 4ever2600 ONLINE  

4ever2600

    Moonsweeper

  • 455 posts

Posted Thu Jan 29, 2004 11:34 AM

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

#40 Robert M OFFLINE  

Robert M

    Stargunner

  • 1,481 posts
  • Rootbeer!
  • Location:Western NY state

Posted Thu Jan 29, 2004 12:59 PM

4ever2600 said:

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!

#41 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Thu Jan 29, 2004 2:43 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users