emerson Posted October 29, 2018 Share Posted October 29, 2018 I have written some code which modifies data in the backtab to change the background color based on time of day. My goal is to edit background colors in software in order to eliminate a massive amount of data tables. The problem I am having is my code is just too slow. You can visibly see the color change as it's happening. Could someone please look at my code and see how I can improve the speed? bg_color_demo.bas bg_color_demo.rom Quote Link to comment Share on other sites More sharing options...
+nanochess Posted October 29, 2018 Share Posted October 29, 2018 I've unrolled loops, avoided comparisons and unloaded code. bg_color_demo.bas Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted October 29, 2018 Share Posted October 29, 2018 Also, if you were to use Color Stack mode, changing the background colour is as simple as updating the stack values. dZ. 1 Quote Link to comment Share on other sites More sharing options...
emerson Posted October 29, 2018 Author Share Posted October 29, 2018 Wow that does work a lot better! Thank you nanochess! So was it the comparisons within nested loops that were slowing me down? When you say "unloaded code" do you mean unloading the cpu? I haven't experimented with color stack mode yet. In my situation there are specific cards that need to keep their background color (player's head, sails, etc). If updating the stack value changes the background color for every card then I don't think it would work for my situation. Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted October 29, 2018 Share Posted October 29, 2018 I haven't experimented with color stack mode yet. In my situation there are specific cards that need to keep their background color (player's head, sails, etc). If updating the stack value changes the background color for every card then I don't think it would work for my situation. Changing a value in the Color Stack only changes the color of those cards using that value. Now, to be clear, assigning Color Stack values to background cards, although straightforward, it's not as simple as in with FG/BG Mode, but it is versatile, and changing one value has the result of updating all cards using it immediately with no additional code or CPU cost. It may not be appropriate for your project to switch modes since you have already started it; but it is definitely worth checking out Color Stack mode in the future. In my opinion, it is really misunderstood and can be very versatile and powerful. It's just weird and takes some effort to get used to it. dZ. Quote Link to comment Share on other sites More sharing options...
+nanochess Posted October 29, 2018 Share Posted October 29, 2018 Wow that does work a lot better! Thank you nanochess! So was it the comparisons within nested loops that were slowing me down? When you say "unloaded code" do you mean unloading the cpu? I haven't experimented with color stack mode yet. In my situation there are specific cards that need to keep their background color (player's head, sails, etc). If updating the stack value changes the background color for every card then I don't think it would work for my situation. Sorry, my bad English, I mean unload the CPU by moving code inside the IF because it's only used there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.