Code: Select all
t%() = a%() DIV &8000
t%() -= t%() DIV 2
t%() *= &7FFF
a%() AND= t%() - 1
a%() OR= t%()
Code: Select all
t%() = a%() DIV &8000
t%() -= t%() DIV 2
t%() *= &7FFF
a%() AND= t%() - 1
a%() OR= t%()
Code: Select all
a%() AND= t%() - 1
Code: Select all
a%() AND= t%()
No. If you omit the - 1 you end up ANDing and ORing a%() with the same value, which can't work! That's easily seen in the t%() = 0 case (i.e. no saturation/clipping is required) when what you want to do is to AND a%() with &FFFFFFFF and OR it with &00000000 because that's the 'no change' condition.TobyLobster wrote: ↑Mon Mar 15, 2021 12:23 pm Shouldn't this linebeCode: Select all
a%() AND= t%() - 1
Code: Select all
a%() AND= t%()
The order of the AND and OR matters! In the specific example you gave, the input is &8000, it is first ANDed with &7FFE (giving zero) and then ORed with &7FFF (giving &7FFF) which is the correct answer.
Code: Select all
DIM a%(9), t%(9)
FOR I% = -98300 TO +98300
a%() = I%
t%() = a%() DIV &8000
t%() -= t%() DIV 2
t%() *= &7FFF
a%() AND= t%() - 1
a%() OR= t%()
CASE TRUE OF
WHEN I% < -32767: IF a%(0) <> -32767 STOP
WHEN I% > +32767: IF a%(0) <> +32767 STOP
OTHERWISE: IF a%(0) <> I% STOP
ENDCASE
NEXT
PRINT "Tests completed successfully"
Code: Select all
RMS = MOD(array()) / SQR(DIM(array(),1) + 1)
Indeed. If you've seen my adaptation of David Williams' prizewinning Tyoob game the particles making up the 'tube' do use BBC BASIC's whole-array operations - without them I could never have animated it in BASIC. The in-browser version is here, but with the overhead of Web Assembly it needs a fast PC for good results. If you have a Mac you can't run the browser version in Safari (although you can in Vivaldi) in which case use the native version instead.cardboardguru wrote: ↑Tue Mar 16, 2021 6:02 pm Seems like they'd be useful for implementing a particle system.