Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Math and triggers
Math and triggers
Oct 26 2008, 5:13 am
By: Morphling  

Oct 26 2008, 5:13 am Morphling Post #1



How can I simplify a fraction via triggers. I have DC1 as my denominator and DC2 as my numerator.



None.

Oct 26 2008, 1:03 pm y10k Post #2



This should work
how it works:

You have, A/B

You decrease B to 0 with a binary countdown, simultaneously decreasing it from A too.
You need to store B's value to a C one during the countoff. You might need to store your original numerator as well (A->D).
With this you can count, how many times (E) this can be executed (till A reaches 0).
You restore C's value to B and start again.

S2 is set, S1 is cleared, DC1 & DC2 >= 32 => DC1 & DC2 : -32 , DC3 & DC4 : +32
S2 is set, S1 is cleared, DC1 & DC2 >= 16 => DC1 & DC2 : -16 , DC3 & DC4 : +16
more required: 8,4,2,1, and additionally you can go up to 64,128,256,512.....etc.
but in decreasing order.
S2 is set, S1 is cleared, DC2 = 0 => DC5++ , set S1
S2 is set, S1 is set, DC3 >= 32 => DC2 : +32 , DC3 : -32
S2 is set, S1 is set, DC3 >= 16 => DC2 : +16 , DC3 : -16
more required: 8,4,2,1, and additionally you can go up to 64,128,256,512.....etc.
S2 is set, S1 is set, DC3 = 0 => clear S1.
S2 is set, S1 is cleared, DC1 = 0, DC2 >= 0 => clear S2

S2 is cleared : DC5 = quotient, DC4 = original numerator, DC2 = should stay whatever it is.

S1 is set when you count the denominator and check if it is lower than the numerator, if yes you increase quotient by 1 and reset denominator (S1 is cleared)
S2 is cleared when operation has finished. Set S2 to start the operation.
Required amount of trigger cycles is the quotient (these must be run as many times as that is)

17123 / 3 will take a long time, while 400/31 takes only 13 cycles.



None.

Oct 26 2008, 2:13 pm Falkoner Post #3



You could also increase the speed by having conditions that if they have, say 300, then you add 100 to the quotient, and subract 300, and that can speed it up so it can be done in a single trigger loop.

Of course, the best method would be to use Binary Count-Offs instead, check out this tutorial on how to use them for division.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[01:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
[2024-4-30. : 7:43 am]
NudeRaider -- Vrael
Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
[2024-4-29. : 6:36 pm]
RIVE -- Nah, I'm still on Orange Box.
[2024-4-29. : 4:36 pm]
Oh_Man -- anyone play Outside the Box yet? it was a fun time
[2024-4-29. : 12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[2024-4-29. : 11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
Please log in to shout.


Members Online: Zycorax, Roy