Newbie Still Doesn't Understand Code
09-21-2016, 11:04 AM
(This post was last modified: 09-21-2016, 11:05 AM by Turbotastic.)
I was looking at the C3 dissassembly and when looking at the code to draw spells for the magic menu, I noticed this.
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?
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?
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
09-21-2016, 01:25 PM
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.
Let's Hack FF6 Stream: https://www.twitch.tv/b_run_
FFVI - Children of Vector: http://www.ff6hacking.com/forums/showthr...p?tid=2386
Monster AI Upgrade Patch: http://www.ff6hacking.com/forums/showthr...p?tid=2673
MMMMMagic 2.0: http://www.ff6hacking.com/forums/showthr...p?tid=3330
09-21-2016, 05:39 PM
Thank you both for the help, resources, and handholding. One of these days I'll either get it or give up.
09-21-2016, 08:58 PM
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.
Let's Hack FF6 Stream: https://www.twitch.tv/b_run_
FFVI - Children of Vector: http://www.ff6hacking.com/forums/showthr...p?tid=2386
Monster AI Upgrade Patch: http://www.ff6hacking.com/forums/showthr...p?tid=2673
MMMMMagic 2.0: http://www.ff6hacking.com/forums/showthr...p?tid=3330
09-21-2016, 09:44 PM
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.
09-21-2016, 10:05 PM
09-21-2016, 10:35 PM
Bwahaha!
We are born, live, die and then do the same thing over again.
10-06-2016, 05:44 AM
(This post was last modified: 10-06-2016, 05:47 AM by Turbotastic.)
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.
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.
10-06-2016, 11:47 AM
(This post was last modified: 10-06-2016, 11:48 AM by Tenkarider.)
decimals: 0-255
hex: 00-FF
there's the zero, so FF is 256 - 1 = 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!
« Next Oldest | Next Newest »
Users browsing this thread: 1 Guest(s)