Users browsing this thread: 1 Guest(s)
Direct Page and Stack at C2 Bank, and Other Fundamental Info

#1
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
I've found some fundamental information about the Direct Page, which can be changed by assembly opcodes, and thought I'd make a page for critical reference info like this:

Quote:Hatzen08
11-30-2015, 02:44 PM
RE: ASM coding - Checking battle command in use

Perhaps, can it be the direct page value? In the C2 bank, it is always zero and TDC is almost used to clear the two bytes of the A register. When the direct page is changed, it always is set back to zero afterwards.

The direct page can be different in the code in the C1 bank. You can try a TDC and check if the value returned to A is zero (two bytes). If it is not, it is the wrong value for the direct page and all opcodes related to the direct page will load the wrong value.

The user Synchisi also had a quote about the direct page changing in C2 based on code, so it's actually changed at times, apparently.



The stack address can also be defined as well--It's not just $100 - $1FF like in previous chipsets.  Does anyone know what the stack address boundaries are?
  Find
Quote  

#2
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
(03-06-2016, 01:24 AM)ReturnerScum Wrote: The user Synchisi also had a quote about the direct page changing in C2 based on code, so it's actually changed at times, apparently.

For the record, this is done in the function that starts at C2/286D.


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  

#3
Posts: 2,549
Threads: 98
Thanks Received: 147
Thanks Given: 159
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
(03-06-2016, 01:24 AM)ReturnerScum Wrote: The user Synchisi

Good try lol.
Quote  

#4
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
I should have put Graveyard Duck instead? I'm not sure what you're suggesting, but I don't like it!
  Find
Quote  

#5
Posts: 2,549
Threads: 98
Thanks Received: 147
Thanks Given: 159
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
I meant you misspelled his incredibly tricky name. Wink
Quote  

#6
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(03-06-2016, 04:06 PM)ReturnerScum Wrote: I should have put Graveyard Duck instead?  

It's not a duck but a guitar with a hoodie.
  Find
Quote  

#7
Posts: 61
Threads: 18
Thanks Received: 1
Thanks Given: 47
Joined: May 2014
Status
None
I don't feel like we've offended enough people yet with this thread.
  Find
Quote  

#8
Posts: 149
Threads: 21
Thanks Received: 40
Thanks Given: 3
Joined: Dec 2013
Reputation: 9
Status
Auto-life
For the Final Fantasy 3 game, with a few exceptions, the developers didn't program with the direct page methodology. They set the direct page as zero and generally use it to clear the B register. (top byte of the A register in 8-bit mode).

If you need a example of direct page, you can check the following code in the assembly:
Code:
C2/286E: F4 00 11     PEA $1100         (Set direct page register 11 $1100)
C2/2871: 2B           PLD 
C2/2872: A5 C9        LDA $C9 ($11C9)
C2/2874: C9 9F        CMP #$9F          (Moogle Suit in character's Armor slot?)
C2/2876: D0 0B        BNE $2883         (if not, branch)

For this example, PEA will put the address in the stack (two bytes) and PLD will remove it from the stack and set it as the direct page address. Note that the direct page is a special register and there are other opcodes which can copy or setup it as well. Common opcodes related with the setting/copy of the direct page are TCD, TDC, PHD and PLD.

Opcodes related with the direct page has only one byte in the range [0, 255]. However, they are incremented with the direct page when they are executed. In this example, LDA $C9 is actually equivalent to LDA $11C9. The effective address is the direct page value ($1100) plus the operand ($C9), which is $11C9.

I never found any opcode in the game related with the relocation of the stack pointer. However, specific opcodes exist for the stack relocation. They are TCS, TSC, TXS and TSX.
  Find
Quote  
[-] The following 1 user says Thank You to HatZen08 for this post:
  • ReturnerScum (03-06-2016)

#9
Posts: 826
Threads: 11
Thanks Received: 22
Thanks Given: 13
Joined: Nov 2011
Reputation: 16
Status
Double
(03-06-2016, 04:50 PM)Madsiur Wrote:
(03-06-2016, 04:06 PM)ReturnerScum Wrote: I should have put Graveyard Duck instead?  

It's not a duck but a guitar with a hoodie.

Thank you.  Everybody at ID said I was crazy for seeing that.  Hello


Confused Moogles FTW
Quote  

#10
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
That just means you're both crazy.


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite