Users browsing this thread: 1 Guest(s)
Condensing Spell List in Battle

#13
Posts: 175
Threads: 11
Thanks Received: 10
Thanks Given: 8
Joined: May 2013
Reputation: 13
Status
Well-Fed
(09-17-2017, 04:01 AM)assassin Wrote: re optimization: haha; they are a bit opposite.  two paths to the same goal.  i went ahead and coded my method, borrowing from your code, out of curiosity and boredom.  can post if wanted, but don't think there's any (measurable) advantage to it.

from what i can tell, yours should work.  it'll definitely be faster than the first version.

I'd be curious to see yours, just to compare -- I learn more from seeing everyone else's coding than I do just by coding myself, half the time. Wink

Quote:your assumption regarding Summons seems fairly sound.
Realistically, I probably don't even need to include a check for #$FF/end of spells in the MP deduction function, because there shouldn't be a way to get to it with a spell the character doesn't know. XD But it's in the original function, so I figured it'd be better to be on the safe side with it.

Quote:have you tried unifying the list condensing for Magic and Lore?  if you can find somewhere to store parameters/bounds, it shouldn't be too hard to make a more flexible function.  now, it'll be a little slower (e.g. the index always being in 16-bit mode), but it'll save a lot of space.

... I hadn't, but now I'm thinking about it. I'll take a look at it tomorrow, after I get some sleep. (... Later today. Oops, it's 6AM.)


BTB said:
Quote:I'm keeping my eye on this one. It's a request I've made and have had every hacker I know throw up their arms at.


It's completely functional now, if you've got space for it! I still kinda can't believe I finally figured it out. XD Like I said above, though, I am going to take assassin's suggestion and try unifying the condensing code.


ETA:
Ooooor I could not sleep, and code the unified version instead. 

Code:
org !freespace_C2_0
condenseSpellLists:
PHX                ; This is our character ID coming in
PHP
REP #$10
LDY #$0004            ; this is the index of the first Spell slot in the character's spell list
STY $F0    
LDX #$004A            ; this is our main loop index; we're checking 53 spells and 23 lores, since we
                ; don't need to actually check the last slot of either list
    .checkLoreLoop    
    LDA ($F2),Y
    CMP #$FF
    BNE .checkNextLore

        .findNextLore
        INY #4
        CPY #$00DC        ; if we've hit the first Lore slot, there are no more spells to copy back
        BEQ .noMoreSpells    ; so jump out, reset $F0 to start our lores
        CPY #$013C        ; this is after the last Lore slot, so if we've gone that far, there are no more spells to copy back
        BEQ .noMoreLores
        LDA ($F2),Y
        CMP #$FF
        BEQ .findNextLore

    PHX            ; set aside the starting byte for the spell we found
    PHY            ; we'll be pushing and pulling within the loop, but we need to know
    LDX #$0003        ; where it started so we can blank out the slot we copied from
    
        .copyNextLore
        LDA ($F2),Y        ; Yes, we just did this, but we need to do it within this loop, too
        PHY            ; this stores our Y location, i.e. the next slot with a spell learned
        LDY $F0            ; and loads our index for slot to write to
        STA ($F2),Y
        PLY            ; back to our 'write from' location
        INY            ; and gets the next byte
        REP #$20
        INC $F0            ; while getting our next write-to byte, too.
        SEP #$20
        DEX            
        BPL .copyNextLore    ; if we haven't done four bytes, loop back and grab the next

    PLY            ; this is the first byte of the slot we copied from
    LDA #$FF
    STA ($F2),Y        ; this blanks out the spell we copied from
    LDA #$00
    STA ($F4),Y        ; and zeroes out the MP cost
        
    PLX            ; this gets our index for the loop -- how many spell slots we've checked
    BRA .weCopiedALore
    .checkNextLore
    REP #$20
    INC $F0            ; if we DIDN'T copy a spell, we need to increment our 'current slot' index
    INC $F0            ; but if we did, the loop already has it pointing to the next slot
    INC $F0
    INC $F0
    SEP #$20
    .weCopiedALore
    LDY $F0            ; and then copy it over to Y for our next loop through
    CPY #$00D8        ; if this is the last spell slot
    BEQ .checkNextLore    ; loop back up and INC again so we skip over it and point at our first Lore slot
    
    DEX
    BPL .checkLoreLoop
    .noMoreLores
    
PLP    
PLX
JMP $532C

.noMoreSpells
LDX #$0016            ; reset our index to cover just the Lores
STY $F0                ; and reset our working index for the first Lore slot
BRA .checkLoreLoop

Found a couple of other little places I could tidy up the code, too, including the placements of a PHX and such.


Current Project: FF6: Tensei | Discord ID: TristanGrayse
  Find
Quote  
[-] The following 3 users say Thank You to GrayShadows for this post:
  • Gi Nattak (09-17-2017), SSJ Rick (09-18-2017), Warrax (09-17-2017)



Messages In This Thread
Condensing Spell List in Battle - by GrayShadows - 09-14-2017, 06:27 PM
RE: Condensing Spell List in Battle - by madsiur - 09-14-2017, 07:22 PM
RE: Condensing Spell List in Battle - by Warrax - 09-14-2017, 08:09 PM
RE: Condensing Spell List in Battle - by assassin - 09-14-2017, 08:42 PM
RE: Condensing Spell List in Battle - by Warrax - 09-15-2017, 12:33 AM
RE: Condensing Spell List in Battle - by assassin - 09-15-2017, 04:33 AM
RE: Condensing Spell List in Battle - by assassin - 09-17-2017, 04:01 AM
RE: Condensing Spell List in Battle - by GrayShadows - 09-17-2017, 04:58 AM
RE: Condensing Spell List in Battle - by assassin - 09-17-2017, 05:34 PM
RE: Condensing Spell List in Battle - by BTB - 09-17-2017, 04:05 AM
RE: Condensing Spell List in Battle - by assassin - 09-18-2017, 04:28 AM
RE: Condensing Spell List in Battle - by assassin - 09-18-2017, 12:45 PM
RE: Condensing Spell List in Battle - by assassin - 09-18-2017, 10:15 PM
RE: Condensing Spell List in Battle - by BTB - 09-19-2017, 08:32 PM
RE: Condensing Spell List in Battle - by Warrax - 09-20-2017, 11:16 AM
RE: Condensing Spell List in Battle - by Warrax - 09-21-2017, 01:06 AM
RE: Condensing Spell List in Battle - by seibaby - 09-20-2017, 06:00 PM
RE: Condensing Spell List in Battle - by assassin - 09-20-2017, 10:39 PM
RE: Condensing Spell List in Battle - by assassin - 09-21-2017, 12:59 PM
RE: Condensing Spell List in Battle - by Warrax - 09-21-2017, 04:35 PM
RE: Condensing Spell List in Battle - by Warrax - 09-23-2017, 12:12 AM
RE: Condensing Spell List in Battle - by assassin - 09-23-2017, 01:21 AM
RE: Condensing Spell List in Battle - by Warrax - 09-23-2017, 07:45 AM
RE: Condensing Spell List in Battle - by Warrax - 09-23-2017, 03:04 PM
RE: Condensing Spell List in Battle - by seibaby - 09-23-2017, 05:38 PM
RE: Condensing Spell List in Battle - by assassin - 09-23-2017, 05:50 PM
RE: Condensing Spell List in Battle - by Warrax - 09-23-2017, 06:04 PM
RE: Condensing Spell List in Battle - by Warrax - 09-24-2017, 01:47 PM
RE: Condensing Spell List in Battle - by Warrax - 10-04-2017, 05:29 PM
RE: Condensing Spell List in Battle - by assassin - 10-04-2017, 06:43 PM
RE: Condensing Spell List in Battle - by assassin - 10-04-2017, 08:44 PM
RE: Condensing Spell List in Battle - by Warrax - 10-04-2017, 10:01 PM
RE: Condensing Spell List in Battle - by Warrax - 10-04-2017, 11:11 PM
RE: Condensing Spell List in Battle - by assassin - 10-04-2017, 11:46 PM
RE: Condensing Spell List in Battle - by assassin - 10-05-2017, 03:51 AM
RE: Condensing Spell List in Battle - by assassin - 10-05-2017, 09:27 PM
RE: Condensing Spell List in Battle - by assassin - 10-05-2017, 09:51 PM
RE: Condensing Spell List in Battle - by assassin - 10-06-2017, 08:20 PM
RE: Condensing Spell List in Battle - by assassin - 10-07-2017, 01:08 AM
RE: Condensing Spell List in Battle - by seibaby - 10-24-2017, 03:36 PM
RE: Condensing Spell List in Battle - by assassin - 10-30-2017, 07:38 PM
RE: Condensing Spell List in Battle - by assassin - 10-31-2017, 01:23 AM
RE: Condensing Spell List in Battle - by assassin - 10-31-2017, 02:42 PM
RE: Condensing Spell List in Battle - by BTB - 11-23-2017, 11:42 PM
RE: Condensing Spell List in Battle - by Warrax - 11-24-2017, 12:15 AM
RE: Condensing Spell List in Battle - by fw4210 - 07-23-2021, 03:48 AM
RE: Condensing Spell List in Battle - by fw4210 - 07-24-2021, 02:05 PM
RE: Condensing Spell List in Battle - by fw4210 - 07-25-2021, 06:32 PM
RE: Condensing Spell List in Battle - by fw4210 - 07-25-2021, 08:58 PM
RE: Condensing Spell List in Battle - by Warrax - 07-25-2021, 08:43 PM
RE: Condensing Spell List in Battle - by fw4210 - 08-02-2021, 08:13 PM
RE: Condensing Spell List in Battle - by fw4210 - 08-10-2021, 02:51 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite