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.
[06:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[05:41 am]
Ultraviolet -- 🤔 so inf is in you?
[04:57 am]
O)FaRTy1billion[MM] -- my name is mud
[04:35 am]
Ultraviolet -- mud, meet my friend, the stick
[10:07 pm]
lil-Inferno -- nah
[2024-5-16. : 8:36 pm]
Ultraviolet -- Inf, we've got a job for you. ASUS has been very naughty and we need our lil guy to go do their mom's to teach them if they fuck around, they gon' find out
[2024-5-16. : 5:25 pm]
NudeRaider -- there he is, right on time! Go UV! :D
[2024-5-16. : 5:24 pm]
lil-Inferno -- poopoo
[2024-5-16. : 5:14 pm]
UndeadStar -- I wonder if that's what happened to me. A returned product (screen) was "officially lost" for a while before being found and refunded. Maybe it would have remained "lost" if I didn't communicate?
[2024-5-16. : 3:36 pm]
NudeRaider -- :lol:
Please log in to shout.


Members Online: 1avac86100ho3, Roy, 9charlottec233rN2, NudeRaider, Sylph-Of-Space, 2jordanc7385eg3, 8evanc5422yr0