+  RHDN Forum Archive
|-+  Romhacking
| |-+  ROM Hacking Discussion
| | |-+  SNES ROM Expansion and Moving Pointer Tables.
Pages: 1 ... 3 4 [5]
Author Topic: SNES ROM Expansion and Moving Pointer Tables.  (Read 2 times)
Disch
Guest
« Reply #60 on: August 27, 2007, 01:04:58 pm »

the 3 basic bitwise logics:

Inclusive OR  (aka ORA) :
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1

Exclusive OR (aka EOR, aka XOR) :
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0

AND
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1


'ORA' is used to set bits.  ORA #$0001 will ensure that bit 0 of A is set

'EOR' is used to toggle bits.  EOR #$8000 will toggle the high bit of A (set it if it is clear, clear it if it is set), while leaving other bits unaffected.

'AND' is used to mask bits.  AND #$000F will clear the high bits so that only bits 0-3 remain




note... that it's doing EOR $1D... not EOR #$1D.  no # symbol indicates direct page mode... not immediate mode.  If A is $AC88, then that means $00001D=AC00
« Last Edit: August 29, 2007, 02:25:24 pm by Disch »
RedComet
Guest
« Reply #61 on: August 27, 2007, 06:04:10 pm »

Quote from: DarknessSavior 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

That's what the instructions do, but why do they do that? This is the same thing I spent hours earlier this year (unsuccessfully) pounding into your brain. :banghead:

Also, for the love of god next time you post a snippet of code, add a few line breaks. They don't bite.
DarknessSavior
Guest
« Reply #62 on: August 28, 2007, 01:09:32 pm »

I know. I've been trying to learn the instructions first, and then I'll go back and interpret them. Though, I know what the first bit does: it's loading the bytes for "It" (of Item) into the Accumulator. But that's about as far as I got in that endeavor. I'd imagine that the branching is probably for when it reaches the end of a menu option, branching to make the next one, but I could be wrong. ;_;

~DS
Disch
Guest
« Reply #63 on: August 28, 2007, 01:30:38 pm »

Instead of making the generic observations of "branch if carry set" -- which isn't really an observation so much as stating what the instruction does -- try to look at what purpose that serves.

That is... when you come across BCS... look at what last changed the C flag, and use that in your comments instead

given the following:

Code:
CMP #$007E
BCS $26

Right now you're looking at that and saying  "Compare A to #$007E", "Branch if Carry Set".  Which isn't really that useful, since the instructions are already plainly saying that.

To know what purpose that BCS serves, you need to know what the C flag is doing.  So look at what set the C flag -- in this case, the CMP.  C will be set when A >= #$7E.  Therefore instead of saying "Branch when carry set", say "Branch when A >= #$7E".   Or "if A >= #$7E, jump to $xxxx".

That's the first step in understanding it... the next step would be to figure out what A is doing.  Is A a character in the string?  Then revise your comment:
"If the character is >= #$7E, jump to $xxxx"

Now you might start to get a clearer picture.  Perhaps characters over $7E are DTE characters, and that is jumping to a DTE routine or something.  Or perhaps they're control codes.  Or whatever.  But just using register names and dictating the bare-bones function of the instruction doesn't help you understand.

The next step would be to figure out what the code at $xxxx is doing, then adjust your comment yet again.  "If character >= #$7E, jump to DTE routine" or somesuch.
DarknessSavior
Guest
« Reply #64 on: August 28, 2007, 01:36:12 pm »

Yeah, I know. That's what RedComet was saying. I just want to make sure I have the basic information down before I try to get all complex. Though, the way you put it made it seem easier than I had once thought, thanks! =D

~DS
DarknessSavior
Guest
« Reply #65 on: August 29, 2007, 01:07:05 pm »

One small question:

Since a previous CMP (CMP #$004B) set the Carry flag, would that mean "if A >= #$4B, jump to $9E9E"? Because really, the second CMP does nothing, since the Carry flag was already set, right?

~DS
KaioShin
Guest
« Reply #66 on: August 29, 2007, 01:39:46 pm »

STOP double posting all over the place. You've been told this before, several times even if I'm not mistaken. EDIT your posts instead. One more double post and it'll result in an official warning.
Disch
Guest
« Reply #67 on: August 29, 2007, 02:23:54 pm »

No.

CMP updates the carry flag.  That means it will change its state according to the new value -- meaning it will set or clear the carry flag according to the instruction result.  If you do two CMP instructions in a row, it's the first one that will be overwritten by the second one (so the first would be the one doing nothing)
DarknessSavior
Guest
« Reply #68 on: August 30, 2007, 11:58:57 am »

Gotcha. So now I need to find out what the instruction at $9E9E is doing, so I can complete the statement. More on that later. =D

Edit: Well, now I've got a different problem. I wanted to use some extra space I had in the
Crest Dialogue section of Demon's Blazon, so I wanted to mess with the pointers.

The location of the text I wanted to edit the pointers for is at 1F250A. Demon's Blazon
is a LoROM game and has a header (for now, I'll probably wind up taking it out eventually).

The outcome should be 0AA3 (this is after taking away $200 for the header.
You wind up with 230A, but since it is under $8000 you add $8000 to it, right?

That gives you $A30A, and then you switch it. $0AA3.

I searched for all of the instances of that above the text I wanted pointers for.
I found a few entries that looked like a pointer table, so I changed the $0A to $0B. Nothing.

Then, I decided to take Disch's advice and use a corrupter. So I used Corrupster. I took a
bunch of different ranges ($00200000 to the end, $00100000 to $00200000, gradually getting smaller and going upwards). No results either, aside from screwing the game up so that it wouldn't even start on a few occasions.

Is there a non-ASM way for me to try and figure out the pointer system for this?

~DS
« Last Edit: August 31, 2007, 11:52:37 am by DarknessSavior »
creaothceann
Guest
« Reply #69 on: August 31, 2007, 03:59:00 pm »

Quote from: DarknessSavior on August 30, 2007, 11:58:57 am
Demon's Blazon is a LoROM game and has a header (for now, I'll probably wind up taking it out eventually).
The outcome should be 0AA3 (this is after taking away $200 for the header.
You wind up with 230A, but since it is under $8000 you add $8000 to it, right?

That gives you $A30A, and then you switch it. $0AA3.

Why would you switch it?

And you can access the ROM with several CPU addresses, depending what bank is selected...
Disch
Guest
« Reply #70 on: August 31, 2007, 04:18:59 pm »

I think he means reversing it to cope with little endian.  IE:  $A30A == "0A A3".  Though the way he prints it is confusing because he keeps it a single 4-digit value  Tongue

Also:  don't use Corrupster.  I wrote that hella long ago and it only really sorta works for NES really.  You might want to try something like NoChaos.
DarknessSavior
Guest
« Reply #71 on: September 03, 2007, 02:53:25 pm »

Yeah, I was switching it to deal with the way SNES and NES deals with pointers.

And thanks, I'll try a different corruptor.

Edit: I took a better look at the EOR instruction (quoted above). So it's taking the value from $7E001D ($002C) and doing what? I'm confused, all it seems like it's doing is throwing that value, reversed, into the accumulator (taking A from $0088 to $2C88). Also, I'm not sure if it matters or not, but $2C is probably a control code (I have an entry in my table for $2B as a code to open a new window, and there's a thousand of them, so $2C is probably one that I haven't encountered yet).

I also took a better look at the two CMPs. The first CMP compares A to $004B. Anything that is $4A or below in the table is the DTE/Dictionary values. The second CMP is $7E, and directly after that is the normal kana ($4B-7D is the dakuten/handakuten section). So is it checking to see if the value is DTE/Dictionary in the first CMP, and seeing if it needs dakuten/handakuten in the second CMP?

~DS
« Last Edit: September 08, 2007, 12:16:44 pm by DarknessSavior »
Neil
Guest
« Reply #72 on: January 01, 2009, 08:34:30 pm »

-necrobump to save a thread from the great board prune of 2009-
some arguably useful teaching type stuff in here.
Pages: 1 ... 3 4 [5]  


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