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

#18
Posts: 89
Threads: 11
Thanks Received: 3
Thanks Given: 1
Joined: Dec 2015
Reputation: 3
Status
Debrave
I hate to double post, but the content of this post is completely different from that of the previous ones.

I gave up on C3 for now and moseyed over to C2.  I'm finally starting to understand how the code works here instead of just reading commentary. However, there is still something that nags at me.

As many of you know already, the magic menu in  battle is literally built twice.  At first, the spells in the Magic menu are populated to those known by ALL the characters, and then the spells are restricted to individual character menus.  In both cases, there are are branches to deal with unknown spells, but in each loop these branches are handled differently.

For instance in the first pass, we get....


Code:
C2/55A3: C9 FF        CMP #$FF       (does this character know the current spell?)
C2/55A5: D0 04        BNE $55AB      (branch if not)

BNE (D0) is "branch if not equal" or if the zero flag is not set, and most often, this is the branch used to compare if something is not equal.

The second pass is different.


Code:
C2/56EC: C9 FF        CMP #$FF
C2/56EE: F0 1E        BEQ $570E


This uses BEQ (F0) operator, the branch if equal or zero. In this case, though, it does branch if not equal. Apparently because the zero flag has been set, it works that way.

I have two questions.

1. Where is the zero flag set prior to this?
2. If the zero flag is not set prior to this, why is BEQ behaving identically to BNE?
  Find
Quote  



Messages In This Thread
RE: Newbie Still Doesn't Understand Code - by dn - 09-21-2016, 12:06 PM
RE: Newbie Still Doesn't Understand Code - by Turbotastic - 10-18-2016, 09:37 AM

Forum Jump:

Users browsing this thread: 2 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite