Skip to content

Instantly share code, notes, and snippets.

@andythenorth
Created July 17, 2021 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andythenorth/df51f3b8fa7bce212a87604702fb836c to your computer and use it in GitHub Desktop.
Save andythenorth/df51f3b8fa7bce212a87604702fb836c to your computer and use it in GitHub Desktop.
// Name: LOAD_PERM_TOWN_0
2992 * 28 02 0A F3 8A
1A 20 \dxFFFFFFFF
\2sto 1A 20 \dx00000100
\2r 7C 00 00 \dxFFFFFFFF
\b0
\wx8000 // Return computed value
// Name: LOAD_PERM_TOWN@return
2993 * 13 02 0A F2 89
1C 00 \dxFFFFFFFF
\b0
\wx8000 // Return computed value
// Name: LOAD_PERM_TOWN
// storage_number : register 84
2994 * 24 02 0A F2 89
7D 84 00 \dxFFFFFFFF // storage_number
\b1
\wx00F3 \dx00000000 \dx00000000 // 0 .. 0: LOAD_PERM_TOWN_0;
\wx00F2 // Return computed value
// Name: coal_mine_produce_256_ticks
6342 * 221 02 0A E5 89
7E EA 20 \dxFFFFFFFF // coal_mine_produce_calculate_current_production_level
\2r 7E E2 20 \dxFFFFFFFF // coal_mine_update_supplied_cycles_remaining_per_cargo
\2r 7E DD 20 \dxFFFFFFFF // coal_mine_produce_256_ticks_shift_supplies_delivered
\2r 1A 20 \dx00000000
\2sto 1A 20 \dx00000084
\2r 1A 20 \dx000003E7
\2sto 1A 20 \dx00000085
\2r 7E F6 20 \dxFFFFFFFF // STORE_PERM_TOWN(0, 999)
\2r 1A 20 \dx0000003E
\2sto 1A 20 \dx00000082
\2r 1A 20 \dx00000000
\2sto 1A 20 \dx00000084
\2r 7E F2 20 \dxFFFFFFFF // LOAD_PERM_TOWN(0)
\2sto 1A 20 \dx00000083
\2r 1A 20 \dx00000082
\2sto 1A 20 \dx0000009A
\2r 1A 20 \dx00000083
\2sto 1A 20 \dx0000009B
\2r 7E F5 20 \dxFFFFFFFF // STORE_PERM_ALT(62, LOAD_PERM_TOWN(0)) <- FAILS
\2r 1A 20 \dx00000000
\2sto 1A 20 \dx00000084
\2r 7E F2 20 \dxFFFFFFFF // LOAD_PERM_TOWN(0)
\2sto 1A 20 \dx0000000A
\2r 1A 20 \dx0000003F
\2sto 1A 20 \dx0000009A
\2r 7D 0A 20 \dxFFFFFFFF
\2sto 1A 20 \dx0000009B
\2r 7E F5 00 \dxFFFFFFFF // STORE_PERM_ALT(63, LOAD_TEMP(10)) <- WORKS
\b1
\wx8000 \dx00000001 \dx00000000 // Bogus range to avoid nvar == 0
\wx00E5 // default: coal_mine_produce_256_ticks_switch_economy;
@andythenorth
Copy link
Author

switch (FEAT_INDUSTRIES, PARENT, LOAD_PERM_TOWN_0, LOAD_PERM(0)) {
return;
}
switch (FEAT_INDUSTRIES, SELF, LOAD_PERM_TOWN, storage_number, [storage_number]) {
0: LOAD_PERM_TOWN_0;
return;
}

switch(FEAT_INDUSTRIES, SELF, coal_mine_produce_256_ticks,
[
coal_mine_produce_calculate_current_production_level(),
coal_mine_update_supplied_cycles_remaining_per_cargo(),
coal_mine_produce_256_ticks_shift_supplies_delivered(),
STORE_PERM_TOWN(0, 999),
STORE_PERM_ALT(62, LOAD_PERM_TOWN(0)),
STORE_TEMP(LOAD_PERM_TOWN(0), 10),
STORE_PERM_ALT(63, LOAD_TEMP(10))
]) {
coal_mine_produce_256_ticks_switch_economy;
}

@glx22
Copy link

glx22 commented Jul 17, 2021

\2r 1A 20 \dx00000082 <-- this is wrong
\2sto 1A 20 \dx0000009A
\2r 1A 20 \dx00000083 <-- this is wrong
\2sto 1A 20 \dx0000009B

vs

\2r 1A 20 \dx0000003F
\2sto 1A 20 \dx0000009A 
\2r 7D 0A 20 \dxFFFFFFFF
\2sto 1A 20 \dx0000009B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment