Users browsing this thread: 1 Guest(s)
Expanded palette hack

#17
Posts: 200
Threads: 1
Thanks Received: 10
Thanks Given: 0
Joined: Oct 2015
Reputation: 18
Status
None
(11-26-2019, 02:44 AM)assassin Wrote: what i'm focused on going forward are two things in the section from "lbg_replace_done" to "lbg_done_replacement_colors":

1. as you can see, i'm mulling optimizations from "EOR / STA" to TSB and to TRB.  it looks like i put each of those in the right spot based off his comments, but based on his actual code (there and at "lbg_find_unused_color" and "lbg_find_expanded_color"), i think i've got the instructions switched.  thoughts?

did so.  my TSB and TRB were in the right place, because Eggers' comments were correct.  (weird how i'd been reasonably confident otherwise.  and i'm not talking about those coding sessions where i've been up too long and the brain is running on fumes; it's a given that those produce failure often.  i mean where i'm plenty alert, looking right at the code, and somehow conclude the wrong thing.  [see also: two drafts of my bit reversal optimization, where i stored results to the wrong bytes.])

Quote:2.
Code:
JMP lbg_find_unused_color_pre        ; Return to the beginning of the loop

i half-think he wanted to do "JMP lbg_find_unused_color" there, based on:
a. the nature of most loops (e.g. not re-initializing an index to its starting value)
b. the way he preserves X right before looping
c. how he never branches to "[label_name]_pre*" -titled labels from below.  they're for loop setups as opposed to loop contents, apparently.

if i'm right, changing this one line could save as much time as my other dozens of optimizations put together!

thus, more scrutiny on "lbg_calculate_replacement_colors" through "lbg_done_replacement_colors" would be much appreciated.

yeah, i've since gotten confident enough to incorporate this one.  though instead of a jump to "lbg_find_unused_color" , i added a new label shortly after that to avoid a pointless read.

note that this 2nd optimization switches the order of the blocks discussed in #1, for space/speed reasons -- not because anything was wrong with them.

i'm considering further optimizing this section by also picking up where we left off in the inner, "lbg_find_expanded_color_pre" loop.  probably by writing X to Variable $10, which is temporarily free.  admittedly, there's less urgency to this tweak, because expanded palettes have at most 4 slots that are pointlessly repeated currently, versus up to 12 for the non-expanded ones.

both the existing optimization and the considered one work on the knowledge that:
- unused main palette entries and used expanded ones are each claimed first-come, first-serve, in ascending order.
- code can mark main entries as used and expanded as unused, but never the reverse.  so lower-numbered entries won't suddenly become candidates for a switch midway through.

the two combined mean that if we're replacing Expanded Palette M with Main Palette N, we'll never need to go back and look at Expanded < M or Main < N.

Quote:if i'm right, changing this one line could save as much time as my other dozens of optimizations put together!

probably an overstatement, in retrospect, but it should still be a significant help.
Quote  



Messages In This Thread
Expanded palette hack - by Eggers - 09-12-2014, 11:10 PM
RE: Expanded palette hack - by SSJ Rick - 09-15-2014, 09:55 PM
RE: Expanded palette hack - by Gi Nattak - 11-19-2019, 07:18 PM
RE: Expanded palette hack - by Odbarc - 11-24-2019, 11:45 PM
RE: Expanded palette hack - by ScarabEnigma - 11-24-2019, 11:48 PM
RE: Expanded palette hack - by Odbarc - 11-26-2019, 03:17 PM
RE: Expanded palette hack - by assassin - 11-26-2019, 12:01 AM
RE: Expanded palette hack - by Gi Nattak - 11-26-2019, 02:22 AM
RE: Expanded palette hack - by assassin - 11-26-2019, 02:44 AM
RE: Expanded palette hack - by assassin - 12-05-2019, 04:52 PM
RE: Expanded palette hack - by Gi Nattak - 11-26-2019, 11:33 AM
RE: Expanded palette hack - by assassin - 11-28-2019, 12:26 AM
RE: Expanded palette hack - by C-Dude - 11-29-2019, 12:53 PM
RE: Expanded palette hack - by assassin - 11-29-2019, 11:01 PM
RE: Expanded palette hack - by C-Dude - 11-30-2019, 12:23 AM
RE: Expanded palette hack - by Gi Nattak - 12-01-2019, 09:57 PM
RE: Expanded palette hack - by assassin - 12-02-2019, 02:55 AM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite