+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  SNES ROM Expansion and Moving Pointer Tables.
Pages: 1 2 3 [4] 5
Author Topic: SNES ROM Expansion and Moving Pointer Tables.  (Read 2 times)
DarknessSavior
Guest
« Reply #45 on: August 22, 2007, 03:49:45 pm »

Yeah, thats the same way I treat hex math. I learned about it, and I can do it, but when I'm lazy I use a calculator. But uh, HyperHacker. I don't want to be rude, but please don't assume I don't know how to use the Windows Calculator. Just telling me that the calculator had those functions would've been nicer. =P

And yeah, it was confusing at first, Kaio, but methinks I got it now.

~DS
Disch
Guest
« Reply #46 on: August 22, 2007, 03:51:09 pm »

simply:

AND masks out bits.  The value being ANDed is the bits you want to keep.

Therefore  "AND #$00FF"  is saying "I'm only interested in the low 8 bits, throw away the other bits".

And yes... you shouldn't need a calculator.  With enough time and practice you should be able to look at two numbers and AND/OR them in your head just as easily (or more easily) as you would be able to add them together.
creaothceann
Guest
« Reply #47 on: August 22, 2007, 03:59:45 pm »

There are other useful things to learn as well, for example using XOR to invert specific bits of a value.


Disch:
OK, what's 682 OR 5779? Wink
DarknessSavior
Guest
« Reply #48 on: August 23, 2007, 10:59:08 am »

Okay, here's the next step. I'm pretty sure I understand it, but I'd rather ask to make sure before I wind up a few steps ahead and wrong.

Code:
$00/9E6E C9 4B 00    CMP #$004B              A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizcHC:0972 VC:088 00 FL:48268
- Compares $004B with $0088.

Jay's ASM tutorial states that the carry flag is set "...when borrow is required".

Does that mean that when the CMP number is smaller than the number in the accumulator (as in, to "borrow" from one column, as if one were doing old-school subtraction)? If so, that makes sense, I guess.p

~DS
RedComet
Guest
« Reply #49 on: August 23, 2007, 11:23:17 am »

Quote from: DarknessSavior on August 23, 2007, 10:59:08 am
Okay, here's the next step. I'm pretty sure I understand it, but I'd rather ask to make sure before I wind up a few steps ahead and wrong.

Code:
$00/9E6E C9 4B 00    CMP #$004B              A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizcHC:0972 VC:088 00 FL:48268
- Compares $004B with $0088.

Jay's ASM tutorial states that the carry flag is set "...when borrow is required".

Does that mean that when the CMP number is smaller than the number in the accumulator (as in, to "borrow" from one column, as if one were doing old-school subtraction)? If so, that makes sense, I guess.p

~DS

Code:
if (A >= #number) carry = set;
else carry = clear;

Now, what does that instruction do?
DarknessSavior
Guest
« Reply #50 on: August 23, 2007, 11:28:03 am »

Uh...the exact same thing, right?

Also, just for clarification, in Geiger, when a flag is set, it's upper-case, right? Not lower-case? Yeah, I know, I ask stupid questions. >.<

~DS
Disch
Guest
« Reply #51 on: August 23, 2007, 11:48:45 am »

Actually... the carry flag is set when borrow isn't required (it's a little backwards with subtraction).

CMP essentially does the same thing as SBC -- in that it subtracts the given value from A.  Only CMP does not change the contents of A in the process... only C,Z,N flags.

C is set when:  A - v >= 0  (A >= v)
C is clear when:  A - v < 0  (A < v)

(where 'v' is the value being compared)

And yes... Capital means flag set in geiger's debugger.

Also, please refrain from putting text in code tags... or at least, if you do, insert linebreaks.  You're mucking up the thread layout.
DarknessSavior
Guest
« Reply #52 on: August 23, 2007, 11:53:04 am »

Okay. Here's the quote from the guide.

Quote from: Jay
If the result is negative, the n flag is set. If the result is zero (or
equal), the z flag is set. Carry is set usually when borrow is required.

So that's wrong? >.<

And I'll keep text out of my codes from now on. ^_^

~DS

Disch
Guest
« Reply #53 on: August 23, 2007, 11:57:06 am »

He just has carry backwards, that's all.  The rest of it is right.

Z is set when A - v == 0  (A == v)

N is set when A - v is negative (has high bit set).  Note that N can be set without C being clear ($C000 - $0005, for example, sets both N and C)... so N can't really be used to do greater than or less than checks
KaioShin
Guest
« Reply #54 on: August 23, 2007, 11:59:28 am »

I always knew the use of carry with CMP instructions the same as Disch. But before I said anything wrong I decided to check back since I never touched Snes ASM (although it shouldn't be different on such a fundamental level I wanted to make sure) and saw that document too. Confused the hell out of me. That shows how dangerous false information in such documents can be. If you'd learn this crap without knowing it's wrong you'll screw up your code over and over again without noticing Sad
DarknessSavior
Guest
« Reply #55 on: August 23, 2007, 12:11:14 pm »

And hence why I ask so many questions. You never know when something you've learned could be horribly wrong. >.<

Hopefully I'll figure this pointer thing out. Unfortunately, both RedComet and I think the system is built into the control codes for the game (I think I posted part of it before to show an example), but maybe I'm lucky and it isn't, or I can find a way to modify it and have it fit my needs. ^_^

~DS
KaioShin
Guest
« Reply #56 on: August 23, 2007, 12:15:35 pm »

There is nothing wrong with asking question if you did your homework before (as in checking the docs as you did). To me it's even fun to test my basic ASM skills a bit Smiley
DarknessSavior
Guest
« Reply #57 on: August 27, 2007, 12:18:16 pm »

Okay, here comes the fun. More instructions.

Code:
$00/9E71 90 34       BCC $34    [$9EA7]      A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizCHC:1004 VC:088 00 FL:48268

This is "Branch if carry clear". The carry IS set, so it does nothing, right?

Code:
$00/9E73 C9 7E 00    CMP #$007E              A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizCHC:1070 VC:088 00 FL:48268

Another CMP. Compares $007E to $0088. This would set the carry flag, if it wasn't already set, I think. The outcome is the same as the one from before.

Code:
$00/9E76 B0 26       BCS $26    [$9E9E]      A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizCHC:1102 VC:088 00 FL:48268

Now I'm confused. This one is "Branch if carry set". It is set. But where are we branching to? $000026? If so, where did the [$9E9E] come from?

That is all, for now.

~DS
mit_mis
Guest
« Reply #58 on: August 27, 2007, 12:34:09 pm »

$9E78 + $26 = $9E9E  Wink

it jumps $26 bytes from the next instruction i guess
DarknessSavior
Guest
« Reply #59 on: August 27, 2007, 12:39:25 pm »

Doh. That makes sense, that's where we're branching to. Continuing on:

Code:
$00/9E9E 45 1D       EOR $1D    [$00:001D]   A:0088 X:0000 Y:001C D:0000 DB:00 S:1FE4 P:envmxdizCHC:1132 VC:088 00 FL:48268

I'm not too sure about this command. Jay's guide says that means "Exclusive OR Accumulator", performing an XOR to the accumulator. I did that and came up with $95. Is that correct?

If that's correct, what exactly does that mean? It's supposed to be doing something to the accumulator, and the next value the accumulator has is $AC88. Huh?

~DS
Pages: 1 2 3 [4] 5  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC