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

#15
Posts: 200
Threads: 1
Thanks Received: 10
Thanks Given: 0
Joined: Oct 2015
Reputation: 18
Status
None
(09-17-2017, 04:58 AM)GrayShadows Wrote: 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

untested, hasn't been assembled:

Code:
phx

ldy #$04      ; full list index.  start at 1st Magic slot.
tyx           ; index of next spot to write in shortened list.  start at 1st
              ;  Magic slot.

mainLoop:
LDA ($F2),Y
CMP #$FF
BEQ checkNextSpell   ; branch if current entry null

stx $f0
cpy $f0       ; does full list index == output index?  yes, i use
              ;  this variable in a single place, because no other
              ;  easy way to compare X and Y. :/
beq noCopy    ; skip copying if so, but still advance

clc
rep #$20

copyLoop:
lda ($F2),Y   ; read two spell menu bytes from original position
phy
txy
sta ($F2),Y   ; save to new position
ply
iny
iny
inx
inx
bcs done      ; exit loop if we've iterated twice.  this
              ;  way lets us avoid using decrementor.
sec
bra copyLoop  ; otherwise, iterate that second time
done:

sep #$20

bra alreadyInced

noCopy:
inx
inx
inx
inx           ; advance index of next place to write in shortened list

checkNextSpell:
iny
iny
iny
iny           ; advance full list index
alreadyInced:

cpy #$D8      ; have we processed end of Magic list?
bcc mainLoop  ; loop if not

; now blank out unused remainder of shortened list

txy
blankLoop:
cpy #$D8         ; have we reached Lore Land yet?
bcs nothingLeft  ; branch if so

LDA #$FF
STA ($F2),Y   ; this blanks out a spell
LDA #$00
STA ($F4),Y   ; and zeroes out the MP cost
iny
iny
iny
iny

bra blankLoop
nothingLeft:

plx


one strong point is i'm able to mostly keep the second index in a register.  but i do resort to using $F0 briefly to avoid stack jackassery.  that could pose problems if i wanted to use the variable for bounds or other parameters in a unified version.

for the zeroing+FF'ing of spell data, it'd be a little smaller (and maybe faster) to have a "TDC ... DEC", with the ($F4) write first.
Quote  



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 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