Crazy cool programming

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

This is pretty neat.  I have a time-slice system that tries to use all of the available CPU cycles efficiently. That's how the game runs with any speed. To do this efficiently, I need to know that I'm not going to run overtime. Previously I've guessed at the slowest 'object' and made sure there's enough time for that object.

In the latest update, I use the ARM timer to time every object as it's processed. I keep a list of "maximum time for each object" in a set of debug variables. So, basically an array of 128 values (0 if untimed, otherwise the number of clocks the object took maximum). 

Gopher has a really cool feature that lets me (from the debugger) save all the global variables to a CSV file.  So I've setup a scheduled task that parses that CSV file for the object times, and updates a table in the code ("budget") which is used to determine if we have enough time to process a creature.

Screenshot shows it. Essentially, now we can check before any object is processed if there's sufficient time to run THAT object. It appears to be working fine. And every now and then, after playing for a while, I'll save out that CSV file from Gopher... and the scheduled task will automatically update the budget table if any of the creatures are taking longer than previously expected.

I guess it doesn't have to be a scheduled task - for the saving CSV is manaual. But the whole "update the table from the CSV" is something I've been wanting to do for some time. Great to have it working.


Andrew Davie

#1
After a few playthroughs, and updates to the table, things are working really nicely. Time management is probably about 90% there, now.  Very very few overtimes.  Also, I updated from a cron-type task to an automatic check/update as first part of the build.  Now 'budget' array is updated with extra comments, too, showing when a value was last updated... and the previous value. Where shown, the previous value is interesting as it shows the incremental refinement of the times in action.

// Worst-case T1TC ticks per board character, indexed by raw char number
// (0-127, matches debug[]). Throttles processBoardSquares()'s loop.
// _untimed_ = no measurement yet. _B = global margin added to all.
// Auto-updated from DEBUG_TIMES CSV exports -- see tools/update_budget_from_csv.py.

#define _untimed_ 12500
#define _B 100

// Last updated: 2026-07-28 00:45 AEST
static const unsigned short budget[128] = {
    _untimed_,    //   0 CH_BLANK
    _untimed_,    //   1 CH_PLACEHOLDER
    _untimed_,    //   2 CH_DIRT
    _untimed_,    //   3 CH_BRICKWALL
    _B + 342,     //   4 CH_DOORCLOSED -- updated 2026-07-28 00:45 AEST (was 341)
    _untimed_,    //   5 CH_DOOROPEN_0
    _untimed_,    //   6 CH_EXITBLANK
    _untimed_,    //   7 CH_STEELWALL
    _untimed_,    //   8 CH_PEBBLE1
    _untimed_,    //   9 CH_PEBBLE2
    _B + 422,     //  10 CH_ROCK -- updated 2026-07-27 23:24 AEST
    _B + 3384,    //  11 CH_ROCK_FALLING -- updated 2026-07-28 00:45 AEST (was 3360)
    _B + 2023,    //  12 CH_DOGE_00 -- updated 2026-07-27 23:24 AEST
    _B + 2474,    //  13 CH_DOGE_FALLING -- updated 2026-07-28 00:07 AEST
    _B + 276,     //  14 CH_MELLON_HUSK_BIRTH -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  15 CH_LAVA_BLANK
    _untimed_,    //  16 CH_LAVA_SMALL
    _untimed_,    //  17 CH_LAVA_MEDIUM
    _untimed_,    //  18 CH_LAVA_LARGE
    _B + 9587,    //  19 CH_MELLON_HUSK -- updated 2026-07-27 23:48 AEST
    _untimed_,    //  20 CH_DOGE_STATIC
    _untimed_,    //  21 CH_PEBBLE_ROCK
    _untimed_,    //  22 CH_ROCK_PEBBLE
    _untimed_,    //  23 CH_ROCK_PEBBLE_1
    _B + 242,     //  24 CH_DUST_0 -- updated 2026-07-28 00:07 AEST
    _B + 242,     //  25 CH_DUST_1 -- updated 2026-07-28 00:07 AEST
    _B + 234,     //  26 CH_DUST_2 -- updated 2026-07-27 23:24 AEST
    _B + 240,     //  27 CH_GEODOGE -- updated 2026-07-27 23:24 AEST
    _B + 242,     //  28 CH_DUST_ROCK_0 -- updated 2026-07-28 00:07 AEST
    _B + 242,     //  29 CH_DUST_ROCK_1 -- updated 2026-07-28 00:07 AEST
    _B + 234,     //  30 CH_DUST_ROCK_2 -- updated 2026-07-27 23:24 AEST
    _B + 655,     //  31 CH_CONVERT_GEODE_TO_DOGE -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  32 CH_HORIZONTAL_BAR
    _untimed_,    //  33 CH_PUSH_LEFT
    _untimed_,    //  34 CH_PUSH_LEFT_REVERSE
    _untimed_,    //  35 CH_PUSH_RIGHT
    _untimed_,    //  36 CH_PUSH_RIGHT_REVERSE
    _untimed_,    //  37 CH_VERTICAL_BAR
    _untimed_,    //  38 CH_PUSH_UP
    _untimed_,    //  39 CH_PUSH_UP_REVERSE
    _untimed_,    //  40 CH_PUSH_DOWN
    _untimed_,    //  41 CH_PUSH_DOWN_REVERSE
    _untimed_,    //  42 CH_WYRM_BODY
    _untimed_,    //  43 CH_WYRM_VERT_BODY
    _untimed_,    //  44 CH_WYRM_CORNER_LD
    _untimed_,    //  45 CH_WYRM_CORNER_RD
    _untimed_,    //  46 CH_WYRM_CORNER_LU
    _untimed_,    //  47 CH_WYRM_CORNER_RU
    _B + 221,     //  48 CH_WYRM_HEAD_U -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  49 CH_WYRM_HEAD_R
    _untimed_,    //  50 CH_WYRM_HEAD_D
    _untimed_,    //  51 CH_WYRM_HEAD_L
    _B + 3360,    //  52 CH_GEODOGE_FALLING -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  53 CH_FLIP_GRAVITY_0
    _untimed_,    //  54 CH_FLIP_GRAVITY_1
    _untimed_,    //  55 CH_FLIP_GRAVITY_2
    _untimed_,    //  56 CH_BLOCK
    _untimed_,    //  57 CH_GRINDER_0
    _untimed_,    //  58 CH_GRINDER_1
    _untimed_,    //  59 CH_HUB
    _untimed_,    //  60 CH_WATER
    _untimed_,    //  61 CH_WATERFLOW_0
    _untimed_,    //  62 CH_WATERFLOW_1
    _untimed_,    //  63 CH_WATERFLOW_2
    _untimed_,    //  64 CH_WATERFLOW_3
    _untimed_,    //  65 CH_WATERFLOW_4
    _untimed_,    //  66 CH_HUB_1
    _untimed_,    //  67 CH_OUTLET
    _untimed_,    //  68 CH_BELT_0
    _untimed_,    //  69 CH_BELT_1
    _untimed_,    //  70 CH_PUSH_DOWN2
    _untimed_,    //  71 CH_GEODOGE_CONVERT
    _untimed_,    //  72 CH_CONVERT_PIPE
    _untimed_,    //  73 CH_WYRM_TAIL_U
    _untimed_,    //  74 CH_WYRM_TAIL_R
    _untimed_,    //  75 CH_WYRM_TAIL_D
    _untimed_,    //  76 CH_WYRM_TAIL_L
    _B + 240,     //  77 CH_DOGE_FALLING_TOP -- updated 2026-07-28 00:07 AEST
    _B + 234,     //  78 CH_DOGE_FALLING_BOTTOM -- updated 2026-07-27 23:24 AEST
    _B + 234,     //  79 CH_ROCK_FALLING_TOP -- updated 2026-07-27 23:24 AEST
    _B + 240,     //  80 CH_ROCK_FALLING_BOTTOM -- updated 2026-07-28 00:07 AEST
    _B + 1487,    //  81 CH_GEODOGE_FALLING_TOP -- updated 2026-07-28 00:07 AEST
    _B + 234,     //  82 CH_GEODOGE_FALLING_BOTTOM -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  83 CH_DOGE_FALLING_TOP2
    _untimed_,    //  84 CH_DOGE_FALLING_BOTTOM2
    _B + 234,     //  85 CH_DOGE_SIDE_1 -- updated 2026-07-28 00:45 AEST (was 233)
    _B + 251,     //  86 CH_DOGE_SIDE_3 -- updated 2026-07-27 23:24 AEST
    _B + 239,     //  87 CH_DOGE_SIDE_2 -- updated 2026-07-27 23:24 AEST
    _B + 251,     //  88 CH_DOGE_SIDE_4 -- updated 2026-07-27 23:24 AEST
    _B + 467,     //  89 CH_ELECTRIC_0 -- updated 2026-07-27 23:24 AEST
    _B + 382,     //  90 CH_ELECTRIC_1 -- updated 2026-07-27 23:24 AEST
    _B + 382,     //  91 CH_ELECTRIC_2 -- updated 2026-07-27 23:24 AEST
    _B + 384,     //  92 CH_ELECTRIC_3 -- updated 2026-07-27 23:24 AEST
    _untimed_,    //  93 CH_BROKEN_DIRT
    _B + 4047,    //  94 CH_INSULATOR_TOP -- updated 2026-07-28 00:45 AEST (was 3946)
    _B + 221,     //  95 CH_INSULATOR_BOTTOM -- updated 2026-07-27 23:24 AEST
    _B + 1985,    //  96 CH_STAR -- updated 2026-07-28 00:45 AEST (was 1937)
    _B + 234,     //  97 CH_STAR_FALLING_TOP -- updated 2026-07-28 00:45 AEST (was 215)
    _B + 234,     //  98 CH_STAR_FALLING_BOTTOM -- updated 2026-07-28 00:45 AEST (was 215)
    _untimed_,    //  99 CH_ROCK_BONUS
    _untimed_,    // 100 CH_STAR_EXPLODE
    _B + 3755,    // 101 CH_INSULATOR_L -- updated 2026-07-28 00:45 AEST (was 3731)
    _B + 221,     // 102 CH_INSULATOR_R -- updated 2026-07-27 23:24 AEST
    _B + 467,     // 103 CH_ELECTRIC_H0 -- updated 2026-07-27 23:24 AEST
    _B + 382,     // 104 CH_ELECTRIC_H1 -- updated 2026-07-27 23:24 AEST
    _B + 382,     // 105 CH_ELECTRIC_H2 -- updated 2026-07-27 23:24 AEST
    _B + 384,     // 106 CH_ELECTRIC_H3 -- updated 2026-07-27 23:24 AEST
    _B + 190,     // 107 CH_CROSSED_STREAMS -- updated 2026-07-27 23:24 AEST
    _untimed_,    // 108 CH_MOUNT_U
    _untimed_,    // 109 CH_MOUNT_D
    _untimed_,    // 110 CH_MOUNT_L
    _untimed_,    // 111 CH_MOUNT_R
    _untimed_,    // 112 CH_PIT_L0
    _untimed_,    // 113 CH_PIT_R0
    _B + 1336,    // 114 CH_BOMB -- updated 2026-07-28 00:45 AEST (was 1334)
    _B + 5386,    // 115 CH_CRACKED_BRICK
    _untimed_,    // 116 CH_CONCRETE
    _untimed_,    // 117 (unused)
    _untimed_,    // 118 (unused)
    _untimed_,    // 119 (unused)
    _untimed_,    // 120 (unused)
    _untimed_,    // 121 (unused)
    _untimed_,    // 122 (unused)
    _untimed_,    // 123 (unused)
    _untimed_,    // 124 (unused)
    _untimed_,    // 125 (unused)
    _untimed_,    // 126 (unused)
    _untimed_,    // 127 (unused)
};

Andrew Davie

I've realised, of course, that I can now optimise "creatures" where it really matters. For example, the chain reaction of geodoge --- when that happens, it's happening "big time". The original timing of that was 655 ticks/geodoge (31 CH_CONVERT_GEODE_TO_DOGE).  I've got that down to 422 ticks/geodoge.  If I focus on those creatures where it really matters (i.e., super-huge times, or even more importantly creatures that are represented in large numbers and shaving off a tick or two), then the game will speedup.

Andrew Davie

#3
This system has been running for a while. Now I'm seeing real results; the screen rolling/overtime (at least on emulators) is practically gone. And the timings have been optimising for some time now, so they're relatively stable.  Here's a couple of examples of fine adjustments made just now...

    _B + 1846,    //  52 CH_GEODOGE_FALLING -- updated 2026-08-07 13:27 AEST (was 1814)
    _B + 4110,    //  94 CH_INSULATOR_TOP -- updated 2026-08-07 13:27 AEST (was 4109)

Note how the tool/build shows the previous value so I can see how things have changed.
So, timing from 1814 --> 1846 for the CH_GEODOGE_FALLING
and from 4109 --> 4110 for the CH_INSULATOR_TOP

These are maximum time observed for processing those objects. @JetSetIlly has added a keypress to Gopher2600 for me that allows me to hit Ctrl-g to save out a CSV of the globals, and the very next build my code will have updated worst-case times for each creature/object in the budget[] table. It's a brilliant 'self-optimising' step for my timeslice system. Play the game enough, and the timing pretty much sorts itself out. I love it.

It's important to understand - these are not how long each creature takes to process. These are worst-case times.  So if the timeslicer has (say) 4000 cycles of time left, it will NOT start processing CH_INSULATOR_TOP (which has a worst-case of 4110).  Instead, the board processing will exit at that point and continue on at the next block of spare time (i.e, next VB/OS whichever comes next).  On the other hand, if the timeslicer had 4500 cycles spare, then CH_INSULATOR_TOP *would* process immediately, and it might actually only use 300 cycles of time.  So the board processor would then still have 4200 cycles left, and it would continue processing characters/ojbects until it found an object that could not be *guaranteed* to complete in time.  So, again, the times in the budget table are worst-case times -- which are often quite rare occurrences.  They only "slow the system down" when time is already short and we're just being cautious that we can't possibly go over-time.  Another way of thinking of this -- although the average time for processing a rock might be 262 cycles, the maximum time might be 2500 cycles -- and so we can process rocks to our heart's content (costing 262 cycles/rock) but when we're nearly out of time we abandon processing the board (for this OS/VB) just in case we happen to have a worst-case rock at that point.  Optimising code, then, is kind of a mix between the frequency of specific code paths (e.g., rock about to roll) and time for those paths.  I might not bother to optimise code that takes 10000 cycles but happens only when a specific rare even occurs.  Let it take 10000 cycles!  But code that happens for each of the 500 rocks on a level would be a good candidate for trying to shave cycles from -- if I can get 20 cycles improvement from each of those, then I save 500x20 = 10000 cycles per game-frame.  That might allow me to process (say) 10% more rocks in each frame.

Here's the whole table as it currently exists.

// Last updated: 2026-08-07 13:27 AEST
static const unsigned short budget[128] = {
    _nop_,         //   0 CH_BLANK
    _nop_,         //   1 CH_PLACEHOLDER
    _nop_,         //   2 CH_DIRT
    _nop_,         //   3 CH_BRICKWALL
    _B + 336,      //   4 CH_DOORCLOSED -- updated 2026-07-28 18:21 AEST (was 201)
    _untimed_,     //   5 CH_DOOROPEN_0
    _untimed_,     //   6 CH_EXITBLANK
    _nop_,         //   7 CH_STEELWALL
    _B + 346,      //   8 CH_PEBBLE1 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 528,      //   9 CH_PEBBLE2 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 2426,     //  10 CH_ROCK -- updated 2026-08-07 01:41 AEST (was 2325)
    _B + 3088,     //  11 CH_ROCK_FALLING -- updated 2026-08-07 02:11 AEST (was 2488)
    _B + 2064,     //  12 CH_DOGE_00 -- updated 2026-08-07 00:03 AEST (was 2063)
    _B + 2498,     //  13 CH_DOGE_FALLING -- updated 2026-08-07 02:11 AEST (was 2467)
    _B + 292,      //  14 CH_MELLON_HUSK_BIRTH -- updated 2026-08-06 23:32 AEST (was 291)
    _nop_,         //  15 CH_LAVA_BLANK
    _nop_,         //  16 CH_LAVA_SMALL
    _nop_,         //  17 CH_LAVA_MEDIUM
    _nop_,         //  18 CH_LAVA_LARGE
    _B + 10059,    //  19 CH_MELLON_HUSK -- updated 2026-08-07 01:41 AEST (was 5000)
    _B + 195,      //  20 CH_DOGE_STATIC -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 181,      //  21 CH_PEBBLE_ROCK -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 210,      //  22 CH_ROCK_PEBBLE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 210,      //  23 CH_ROCK_PEBBLE_1 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 252,      //  24 CH_DUST_0 -- updated 2026-08-06 23:27 AEST (was 209)
    _B + 252,      //  25 CH_DUST_1 -- updated 2026-08-06 23:57 AEST (was 251)
    _B + 250,      //  26 CH_DUST_2 -- updated 2026-08-06 23:57 AEST (was 249)
    _B + 2366,     //  27 CH_GEODOGE -- updated 2026-08-07 00:03 AEST (was 1608)
    _B + 252,      //  28 CH_DUST_ROCK_0 -- updated 2026-08-06 23:27 AEST (was 242)
    _B + 252,      //  29 CH_DUST_ROCK_1 -- updated 2026-08-06 23:27 AEST (was 242)
    _B + 250,      //  30 CH_DUST_ROCK_2 -- updated 2026-08-06 23:27 AEST (was 207)
    _B + 466,      //  31 CH_CONVERT_GEODE_TO_DOGE -- updated 2026-08-06 23:32 AEST (was 434)
    _B + 165,      //  32 CH_HORIZONTAL_BAR -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 2319,     //  33 CH_PUSH_LEFT -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 235,      //  34 CH_PUSH_LEFT_REVERSE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 2142,     //  35 CH_PUSH_RIGHT -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 236,      //  36 CH_PUSH_RIGHT_REVERSE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 165,      //  37 CH_VERTICAL_BAR -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 2319,     //  38 CH_PUSH_UP -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 235,      //  39 CH_PUSH_UP_REVERSE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 395,      //  40 CH_PUSH_DOWN -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 236,      //  41 CH_PUSH_DOWN_REVERSE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 235,      //  42 CH_WYRM_BODY -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  43 CH_WYRM_VERT_BODY -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  44 CH_WYRM_CORNER_LD -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 234,      //  45 CH_WYRM_CORNER_RD -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  46 CH_WYRM_CORNER_LU -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  47 CH_WYRM_CORNER_RU -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  48 CH_WYRM_HEAD_U -- updated 2026-08-06 23:32 AEST (was 221)
    _B + 235,      //  49 CH_WYRM_HEAD_R -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  50 CH_WYRM_HEAD_D -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  51 CH_WYRM_HEAD_L -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 1846,    //  52 CH_GEODOGE_FALLING -- updated 2026-08-07 13:27 AEST (was 1814)
    _nop_,         //  53 CH_FLIP_GRAVITY_0
    _nop_,         //  54 CH_FLIP_GRAVITY_1
    _nop_,         //  55 CH_FLIP_GRAVITY_2
    _B + 228,      //  56 CH_BLOCK -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 452,      //  57 CH_GRINDER_0 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 436,      //  58 CH_GRINDER_1 -- updated 2026-07-31 13:42 AEST (was untimed)
    _nop_,         //  59 CH_HUB
    _B + 283,      //  60 CH_WATER -- updated 2026-08-06 23:27 AEST (was 232)
    _B + 292,      //  61 CH_WATERFLOW_0 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 296,      //  62 CH_WATERFLOW_1 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 1256,     //  63 CH_WATERFLOW_2 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 1256,     //  64 CH_WATERFLOW_3 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 296,      //  65 CH_WATERFLOW_4 -- updated 2026-07-31 13:42 AEST (was untimed)
    _nop_,         //  66 CH_HUB_1
    _B + 198,      //  67 CH_OUTLET -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 268,      //  68 CH_BELT_0 -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 268,      //  69 CH_BELT_1 -- updated 2026-07-31 13:42 AEST (was untimed)
    _nop_,         //  70 CH_PUSH_DOWN2
    _nop_,         //  71 CH_GEODOGE_CONVERT
    _B + 514,      //  72 CH_CONVERT_PIPE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 235,      //  73 CH_WYRM_TAIL_U -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  74 CH_WYRM_TAIL_R -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  75 CH_WYRM_TAIL_D -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 235,      //  76 CH_WYRM_TAIL_L -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 250,      //  77 CH_DOGE_FALLING_TOP -- updated 2026-08-07 00:00 AEST (was 249)
    _B + 250,      //  78 CH_DOGE_FALLING_BOTTOM -- updated 2026-08-06 23:32 AEST (was 240)
    _B + 250,      //  79 CH_ROCK_FALLING_TOP -- updated 2026-08-06 23:27 AEST (was 240)
    _B + 256,      //  80 CH_ROCK_FALLING_BOTTOM -- updated 2026-08-06 23:27 AEST (was 240)
    _B + 1495,     //  81 CH_GEODOGE_FALLING_TOP -- updated 2026-08-06 23:32 AEST (was 1487)
    _B + 250,      //  82 CH_GEODOGE_FALLING_BOTTOM -- updated 2026-08-06 23:32 AEST (was 240)
    _B + 226,      //  83 CH_DOGE_FALLING_TOP2 -- updated 2026-07-31 13:42 AEST (was untimed)
    _nop_,         //  84 CH_DOGE_FALLING_BOTTOM2
    _B + 250,      //  85 CH_DOGE_SIDE_1 -- updated 2026-08-07 00:03 AEST (was 249)
    _B + 272,      //  86 CH_DOGE_SIDE_3 -- updated 2026-07-28 16:30 AEST (was 263)
    _B + 249,      //  87 CH_DOGE_SIDE_2 -- updated 2026-07-28 16:30 AEST (was 240)
    _B + 272,      //  88 CH_DOGE_SIDE_4 -- updated 2026-07-28 16:30 AEST (was 263)
    _B + 483,      //  89 CH_ELECTRIC_0 -- updated 2026-08-06 23:32 AEST (was 476)
    _B + 398,      //  90 CH_ELECTRIC_1 -- updated 2026-08-06 23:32 AEST (was 391)
    _B + 398,      //  91 CH_ELECTRIC_2 -- updated 2026-08-06 23:32 AEST (was 391)
    _B + 400,      //  92 CH_ELECTRIC_3 -- updated 2026-08-06 23:32 AEST (was 393)
    _nop_,         //  93 CH_BROKEN_DIRT
    _B + 4110,    //  94 CH_INSULATOR_TOP -- updated 2026-08-07 13:27 AEST (was 4109)
    _B + 236,      //  95 CH_INSULATOR_BOTTOM -- updated 2026-07-29 03:45 AEST (was 230)
    _B + 2003,     //  96 CH_STAR -- updated 2026-07-29 00:37 AEST (was 1985)
    _B + 250,      //  97 CH_STAR_FALLING_TOP -- updated 2026-08-07 00:00 AEST (was 249)
    _B + 250,      //  98 CH_STAR_FALLING_BOTTOM -- updated 2026-08-07 00:00 AEST (was 249)
    _untimed_,     //  99 CH_ROCK_BONUS
    _B + 374,      // 100 CH_STAR_EXPLODE -- updated 2026-07-31 13:42 AEST (was untimed)
    _B + 6736,     // 101 CH_INSULATOR_L -- updated 2026-07-29 00:45 AEST (was 3771)
    _B + 236,      // 102 CH_INSULATOR_R -- updated 2026-07-29 03:45 AEST (was 230)
    _B + 483,      // 103 CH_ELECTRIC_H0 -- updated 2026-08-06 23:32 AEST (was 476)
    _B + 398,      // 104 CH_ELECTRIC_H1 -- updated 2026-08-06 23:32 AEST (was 391)
    _B + 398,      // 105 CH_ELECTRIC_H2 -- updated 2026-08-06 23:32 AEST (was 391)
    _B + 400,      // 106 CH_ELECTRIC_H3 -- updated 2026-08-06 23:32 AEST (was 393)
    _B + 235,      // 107 CH_CROSSED_STREAMS -- updated 2026-08-06 23:32 AEST (was 197)
    _B + 1366,     // 108 CH_BOMB -- updated 2026-07-29 03:45 AEST (was 1351)
    _B + 4594,     // 109 CH_CRACKED_BRICK -- updated 2026-07-29 15:01 AEST (was untimed)
    _nop_,         // 110 CH_CONCRETE
    _B + 883,      // 111 CH_TELEPORT (PH4, idle sparkle -- not yet measured) -- updated 2026-08-06 23:27 AEST (was 766)
    _nop_,         // 112 CH_KEY
    _untimed_,     // 113 CH_DOOROPEN_STATIC
    _B + 424,      // 114 CH_IMMOVABLE -- updated 2026-08-06 23:32 AEST (was 261)
    _B + 2348,     // 115 CH_IMMOVABLE_FALLING -- updated 2026-08-07 02:11 AEST (was 2299)
    _B + 213,      // 116 CH_IMMOVABLE_FALLING_TOP -- updated 2026-08-06 23:32 AEST (was 169)
    _B + 213,      // 117 CH_IMMOVABLE_FALLING_BOTTOM -- updated 2026-08-06 23:32 AEST (was 169)
    _B + 213,      // 118 CH_ROCK_SIDE_1 -- updated 2026-08-06 23:27 AEST (was 170)
    _B + 213,      // 119 CH_ROCK_SIDE_2 -- updated 2026-08-06 23:27 AEST (was 170)
    _B + 281,      // 120 CH_ROCK_SIDE_3 -- updated 2026-08-06 23:32 AEST (was 277)
    _B + 281,      // 121 CH_ROCK_SIDE_4 -- updated 2026-08-07 00:03 AEST (was 277)
    _B + 213,      // 122 CH_GEODOGE_SIDE_1 -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 213,      // 123 CH_GEODOGE_SIDE_2 -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 275,      // 124 CH_GEODOGE_SIDE_3 -- updated 2026-08-06 23:32 AEST (was untimed)
    _B + 276,      // 125 CH_GEODOGE_SIDE_4 -- updated 2026-08-06 23:32 AEST (was untimed)
    _untimed_,     // 126 (unused)
    _untimed_,     // 127 (unused)
};



Andrew Davie

Writing that last post I realised it would actually be useful to also have average times -- so I could preferentially optimise those objects that appear in large numbers that have higher averages. So the average is now included in the stats recorded during gameplay, and exported via CSV to the code budget[] table comments.

    _B + 2426,     //  10 CH_ROCK (avg: 389) -- updated 2026-08-07 19:46 AEST (avg was 348)
    _B + 3842,     //  11 CH_ROCK_FALLING (avg: 1547) -- updated 2026-08-07 19:46 AEST (was 3088)

Here we see most rof the time the rock (CH_ROCK) is about 389 cycles, but when "things happen" it can spike to 2426. I'm not worried about that latter figure; the 389 is OK, too.  So it's been a good update in terms of understanding what I need to do to improve things where it matters.