Users browsing this thread: 1 Guest(s)
Newbie Still Doesn't Understand Code

#1
Posts: 89
Threads: 11
Thanks Received: 3
Thanks Given: 1
Joined: Dec 2015
Reputation: 3
Status
Debrave
I was looking at the C3 dissassembly and when looking at the code to draw spells for the magic menu, I noticed this.

Code:
C3/4FE4:    20A250      JSR $50A2      (get spells learned amount)
C3/4FE7:    C9FF        CMP #$FF
C3/4FE9:    D02F        BNE $501A      (branch if spell is already learned?)

I'm relying on the comments because I don't understand everything...but is the commentary wrong in this case? The part where it's branching (501A) to is the "blanking out" part. However, there's already a check for not knowing a spell at all prior to this, and this check is for if something is NOT equal to something (what BNE is, essentially). Is 4FE9 just redudnant code or am I terribly misunderstanding what that is checking for?
  Find
Quote  

#2
Posts: 110
Threads: 4
Thanks Received: 4
Thanks Given: 1
Joined: Jan 2012
Reputation: 4
Status
None
That code is part of the code that shows spell+MP cost (enabled by pressing Y), which blanks out partially learned spells as well as unlearned ones. It likely is redundant but wouldn't save much space, as the blanking code is needed regardless. If you'll notice above it, there's a check for whether MP display is enabled or not, and it branches elsewhere if it isn't. That code actually displays learn %.

Code:
Draw text in spell slot of Magic menu
C3/4FC4: A5E6     LDA $E6        ; BG1 write row
C3/4FC6: 1A       INC A          ; Go 1 row down
C3/4FC7: 209F80   JSR $809F      ; Compute map ptr
C3/4FCA: C220     REP #$20       ; 16-bit A
C3/4FCC: 8A       TXA            ; ...
C3/4FCD: 8F899E7E STA $7E9E89    ; Set position
C3/4FD1: E220     SEP #$20       ; 8-bit A
C3/4FD3: A59E     LDA $9E        ; Show MP in list?
C3/4FD5: F067     BEQ $503E      ; Branch if not
C3/4FD7: 20EC50   JSR $50EC      ; Spell
C3/4FDA: 204D51   JSR $514D      ; Handle graying
C3/4FDD: 20EC50   JSR $50EC      ; Spell
C3/4FE0: C9FF     CMP #$FF       ; None?
C3/4FE2: F036     BEQ $501A      ; Blank if so
C3/4FE4: 20A250   JSR $50A2      ; Spell mastery
C3/4FE7: C9FF     CMP #$FF       ; Fully learned?
C3/4FE9: D02F     BNE $501A      ; Blank if not

Fork: Draw spell plus percentage
C3/503E: 20EC50   JSR $50EC      ; Spell
C3/5041: C9FF     CMP #$FF       ; None?
C3/5043: F0D5     BEQ $501A      ; Blank if so
C3/5045: 20A250   JSR $50A2      ; Spell mastery
C3/5048: C900     CMP #$00       ; Zero?
C3/504A: F0CE     BEQ $501A      ; Blank if so
C3/504C: 20EC50   JSR $50EC      ; Spell
C3/504F: 206784   JSR $8467      ; Load name
C3/5052: A2929E   LDX #$9E92     ; 7E/9E92
C3/5055: 8E8121   STX $2181      ; Set WRAM LBs
C3/5058: 20EC50   JSR $50EC      ; Spell
C3/505B: 20A250   JSR $50A2      ; Spell mastery
C3/505E: C9FF     CMP #$FF       ; Fully learned?
C3/5060: F026     BEQ $5088      ; Branch if so
C3/5062: 48       PHA            ; Save mastery
C3/5063: 20B951   JSR $51B9      ; Disable spell
C3/5066: A92C     LDA #$2C       ; Palette 3
C3/5068: 8529     STA $29        ; Color: Bluish
C3/506A: A9C7     LDA #$C7       ; Char: "…"
C3/506C: 8D8021   STA $2180      ; Add to string
C3/506F: 68       PLA            ; Spell mastery
C3/5070: 20E004   JSR $04E0      ; Turn into text
C3/5073: A5F8     LDA $F8        ; Tens digit
C3/5075: 8D8021   STA $2180      ; Add to string
C3/5078: A5F9     LDA $F9        ; Ones digit
C3/507A: 8D8021   STA $2180      ; Add to string
C3/507D: A9CD     LDA #$CD       ; Char: "%"
C3/507F: 8D8021   STA $2180      ; Add to string
C3/5082: 9C8021   STZ $2180      ; End string
C3/5085: 4CD97F   JMP $7FD9      ; Draw string
  Find
Quote  
[-] The following 1 user says Thank You to dn for this post:
  • Turbotastic (09-21-2016)

#3
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
You also might want to check out this. If you are working on understanding the code, this is a much more exhaustive commentary on C3.
  Find
Quote  
[-] The following 1 user says Thank You to B-Run for this post:
  • Turbotastic (09-21-2016)

#4
Posts: 89
Threads: 11
Thanks Received: 3
Thanks Given: 1
Joined: Dec 2015
Reputation: 3
Status
Debrave
Thank you both for the help, resources, and handholding. One of these days I'll either get it or give up.
  Find
Quote  

#5
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
I was in the same boat at one point. Really, the best way to get over the hump is to pick something small you'd like to do and start working on it. Ask for help when you're stuck and let experience show you how the logic works.
  Find
Quote  

#6
Posts: 2,548
Threads: 98
Thanks Received: 147
Thanks Given: 156
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
I've been lost at sea on that boat for years now.


We are born, live, die and then do the same thing over again.
Quote  

#7
Posts: 826
Threads: 11
Thanks Received: 22
Thanks Given: 13
Joined: Nov 2011
Reputation: 16
Status
Double
(09-21-2016, 09:44 PM)Gi Nattak Wrote: I've been lost at sea on that boat for years now.

Oh, so that sea is made out of alcohol then?


Confused Moogles FTW
Quote  

#8
Posts: 2,548
Threads: 98
Thanks Received: 147
Thanks Given: 156
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
Bwahaha!


We are born, live, die and then do the same thing over again.
Quote  

#9
Posts: 89
Threads: 11
Thanks Received: 3
Thanks Given: 1
Joined: Dec 2015
Reputation: 3
Status
Debrave
I'm a slow learner. I'm only now starting to figure out one reason why I was misunderstanding this and other sections of code.

I was assuming "FF" meant "255"  After consulting more documentation, I learned it probably means "-1" instead.

Now it's starting to come together a little.
  Find
Quote  

#10
Posts: 1,633
Threads: 56
Thanks Received: 13
Thanks Given: 84
Joined: Apr 2014
Reputation: 12
Status
Atma
decimals: 0-255
hex: 00-FF
there's the zero, so FF is 256 - 1 = 255


THE GREATEST CHALLENGE OF ALL TIMES AWAITS:
http://www.ff6hacking.com/forums/showthr...p?tid=2593
DO YOU HAVE WHAT IT TAKES TO SLAY A GOD?
------------------------------------------------------------------------
Tenkarider's project #2 is started: FF6 Curse of the Madsiur Joke (CotMJ)
http://www.ff6hacking.com/forums/showthr...p?tid=2755
What happens when Madsiur tweaks your account? This full game hack will show that!
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite