Forum Replies Created
-
AuthorPosts
-
Nice work!
Some compiler fixes for the numeric errors above have been pushe to the develop branch.
Also, I had to do some tweaking to the code above, the main issue being that ‘Shr’ in mx2 is signed/unsigned depending on whether LHS is signed/unsigned (like C/C++) whereas in BMX Shr is signed and Sar is unsigned. So I rolled a little unsigned Shr (UShr) function which I may end up adding to the language as an operator…?
New code below, will add it to std soon (in std.digest?):
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241#Import "<std>"Using std..'====================================== TEST ======================================Function Main()Print ""Print "==== MD5 ===="Print MD5("The quick brown fox jumps over the lazy dog")Print "9e107d9d372bb6826bd81d3542a419d6 <- Should be this"Print ""Print "===== SHA-1 ====="Print SHA1("The quick brown fox jumps over the lazy dog")Print "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12 <- Should be this"Print ""Print "===== SHA-256 ====="Print SHA256("The quick brown fox jumps over the lazy dog")Print "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592 <- Should be this"End Function''====================================== TEST ======================================Function MD5:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476Local r:Int[] = New Int[](7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21)Local k:Int[] = New Int[]($D76AA478, $E8C7B756, $242070DB, $C1BDCEEE, $F57C0FAF, $4787C62A,$A8304613, $FD469501, $698098D8, $8B44F7AF, $FFFF5BB1, $895CD7BE,$6B901122, $FD987193, $A679438E, $49B40821, $F61E2562, $C040B340,$265E5A51, $E9B6C7AA, $D62F105D, $02441453, $D8A1E681, $E7D3FBC8,$21E1CDE6, $C33707D6, $F4D50D87, $455A14ED, $A9E3E905, $FCEFA3F8,$676F02D9, $8D2A4C8A, $FFFA3942, $8771F681, $6D9D6122, $FDE5380C,$A4BEEA44, $4BDECFA9, $F6BB4B60, $BEBFBC70, $289B7EC6, $EAA127FA,$D4EF3085, $04881D05, $D9D4D039, $E6DB99E5, $1FA27CF8, $C4AC5665,$F4292244, $432AFF97, $AB9423A7, $FC93A039, $655B59C3, $8F0CCC92,$FFEFF47D, $85845DD1, $6FA87E4F, $FE2CE6E0, $A3014314, $4E0811A1,$F7537E82, $BD3AF235, $2AD7D2BB, $EB86D391)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = data[c Shr 2] | ((in[c] & $FF) Shl ((c & 3) Shl 3))Nextdata[in.Length Shr 2] = data[in.Length Shr 2] | ($80 Shl ((in.Length & 3) Shl 3))data[data.Length - 2] = (Long(in.Length) * 8) & $FFFFFFFFdata[data.Length - 1] = (Long(in.Length) * 8) Shr 32For Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3For Local i:Int=0 To 15Local f:Int = d ~ (b & (c ~ d))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + i]), r[i]) + ba = tNextFor Local i:Int=16 To 31Local f:Int = c ~ (d & (b ~ c))Local t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((5 * i) + 1) & 15)]), r[i]) + ba = tNextFor Local i:Int=32 To 47Local f:Int = b ~ c ~ dLocal t:Int = dd = c ; c = bb = Rol((a + f + k[i] + data[chunkStart + (((3 * i) + 5) & 15)]), r[i]) + ba = tNextFor Local i:Int=48 To 63Local f:Int = c ~ (b | ~d)Local t:Int = dd = cc = bb = Rol((a + f + k[i] + data[chunkStart + ((7 * i) & 15)]), r[i]) + ba = tNexth0 += ah1 += bh2 += ch3 += dNextReturn (LEHex(h0) + LEHex(h1) + LEHex(h2) + LEHex(h3)).ToLower()End FunctionFunction SHA1:String(in:String)Local h0:Int = $67452301, h1:Int = $EFCDAB89, h2:Int = $98BADCFE, h3:Int = $10325476, h4:Int = $C3D2E1F0Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4Local w := data.Slice(chunkStart,chunkStart+16).Resize(80)For Local i:Int=16 To 79w[i] = Rol(w[i - 3] ~ w[i - 8] ~ w[i - 14] ~ w[i - 16], 1)NextFor Local i:Int=0 To 19Local t:Int = Rol(a, 5) + (d ~ (b & (c ~ d))) + e + $5A827999 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=20 To 39Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $6ED9EBA1 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=40 To 59Local t:Int = Rol(a, 5) + ((b & c) | (d & (b | c))) + e + $8F1BBCDC + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNextFor Local i:Int=60 To 79Local t:Int = Rol(a, 5) + (b ~ c ~ d) + e + $CA62C1D6 + w[i]e = d ; d = cc = Rol(b, 30)b = a ; a = tNexth0 += ah1 += bh2 += ch3 += dh4 += eNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4)).ToLower()End FunctionFunction SHA256:String(in:String)Local h0:Int = $6A09E667, h1:Int = $BB67AE85, h2:Int = $3C6EF372, h3:Int = $A54FF53ALocal h4:Int = $510E527F, h5:Int = $9B05688C, h6:Int = $1F83D9AB, h7:Int = $5BE0CD19Local k:Int[] = New Int[]($428A2F98, $71374491, $B5C0FBCF, $E9B5DBA5, $3956C25B, $59F111F1,$923F82A4, $AB1C5ED5, $D807AA98, $12835B01, $243185BE, $550C7DC3,$72BE5D74, $80DEB1FE, $9BDC06A7, $C19BF174, $E49B69C1, $EFBE4786,$0FC19DC6, $240CA1CC, $2DE92C6F, $4A7484AA, $5CB0A9DC, $76F988DA,$983E5152, $A831C66D, $B00327C8, $BF597FC7, $C6E00BF3, $D5A79147,$06CA6351, $14292967, $27B70A85, $2E1B2138, $4D2C6DFC, $53380D13,$650A7354, $766A0ABB, $81C2C92E, $92722C85, $A2BFE8A1, $A81A664B,$C24B8B70, $C76C51A3, $D192E819, $D6990624, $F40E3585, $106AA070,$19A4C116, $1E376C08, $2748774C, $34B0BCB5, $391C0CB3, $4ED8AA4A,$5B9CCA4F, $682E6FF3, $748F82EE, $78A5636F, $84C87814, $8CC70208,$90BEFFFA, $A4506CEB, $BEF9A3F7, $C67178F2)Local intCount:Int = (((in.Length + 8) Shr 6) + 1) Shl 4Local data:Int[] = New Int[intCount]For Local c:Int=0 Until in.Lengthdata[c Shr 2] = (data[c Shr 2] Shl 8) | (in[c] & $FF)Nextdata[in.Length Shr 2] = ((data[in.Length Shr 2] Shl 8) | $80) Shl ((3 - (in.Length & 3)) Shl 3)data[data.Length - 2] = (Long(in.Length) * 8) Shr 32data[data.Length - 1] = (Long(in.Length) * 8) & $FFFFFFFFFor Local chunkStart:Int=0 Until intCount Step 16Local a:Int = h0, b:Int = h1, c:Int = h2, d:Int = h3, e:Int = h4, f:Int = h5, g:Int = h6, h:Int = h7Local w:=data.Slice(chunkStart,chunkStart+16).Resize(64)For Local i:Int=16 To 63w[i] = w[i - 16] + (Ror(w[i - 15], 7) ~ Ror(w[i - 15], 18) ~ ( UShr(w[i - 15],3) ))+w[i - 7] + (Ror(w[i - 2], 17) ~ Ror(w[i - 2], 19) ~ ( UShr(w[i - 2],10) ))' w[i] = w[i - 16] + (Ror(w[i - 15], 7) ~ Ror(w[i - 15], 18) ~ (w[i - 15] Shr 3))+' w[i - 7] + (Ror(w[i - 2], 17) ~ Ror(w[i - 2], 19) ~ (w[i - 2] Shr 10))NextFor Local i:Int=0 To 63Local t0:Int = (Ror(a, 2) ~ Ror(a, 13) ~ Ror(a, 22)) + ((a & b) | (b & c) | (c & a))Local t1:Int = h + (Ror(e, 6) ~ Ror(e, 11) ~ Ror(e, 25)) + ((e & f) | (~e & g)) + k[i] + w[i]h = g ; g = f ; f = e ; e = d + t1d = c ; c = b ; b = a ; a = t0 + t1Nexth0 += a ; h1 += b ; h2 += c ; h3 += dh4 += e ; h5 += f ; h6 += g ; h7 += hNextReturn (Hex(h0) + Hex(h1) + Hex(h2) + Hex(h3) + Hex(h4) + Hex(h5) + Hex(h6) + Hex(h7)).ToLower()End FunctionFunction Hex:String(val:UInt)Local hex:=("00000000"+ULongToString(val,16)).Right(8)Return hexEnd FunctionFunction Rol:UInt(val:UInt, shift:Int)Return (val Shl shift) | (val Shr (32 - shift))End FunctionFunction Ror:UInt(val:UInt, shift:Int)Return (val Shr shift) | (val Shl (32 - shift))End FunctionFunction UShr:UInt(val:UInt, shift:Int)Return val Shr shiftEndFunction LEHex:String(val:UInt)Local out:String = Hex(val)Return out.Slice(6,8) + out.Slice(4,6) + out.Slice(2,4) + out.Slice(0,2)End FunctionNumlock problem is happening here too, but NumLock doesn’t work for me here with ANY apps – it always just emits numbers. This is easy enough to hack into TextView and is the best I can do for now without a keyboard with functional NumLock, perhaps I need a ‘real’ Mac keyboard? I only have an el cheapo Windows keyboard.
Copy from console may or may not be a Ted2go thing – I’ll have a look.
As for app icons, it’ll have to wait until I next mess with the build system. There are a number of things to be done here anyway so it’ll probably be soonish.
Slice (2,2) will return a 0 length string, which will cause an array index error if you try and index it.
Will have a hack tomorrow/soon.
I have just pushed a fix for the opengl build error to the develop branch, although weirdly I’m not getting this error myself! It is a valid error though…
Initial gltf2 animation/skin support added and pushed to develop branch. Also added models and tests if that’s OK?
It’s an early attempt so there will probably be issues, but the above models seem to work OK (although walker looks quite different in mojo3d which I’ll look into).
Welcome Pengwin!
Try again now…
Oops, broke non-android builds a bit…fixed now.
Excellent, thank you.
[edit]Nice find too: https://pissang.github.io/qtek-model-viewer/editor/
…also, I should probably mention that I updated the default android studio project for android products to android studio 3.0.1, so android users should probably do the same. Ditto upgrade all installed tools/sdks/ndks etc to the latest versions.
Some fixes for this are now up in the develop branch.
It was mostly working already except there was an issue with sdl that meant the app wasn’t initally being given focus properly so key events weren’t getting sent to it. If you hit ‘home’ and refocus app, key events started working. I’ve hacked around this a bit and it should work now.
The other issue is that the back key wasn’t even include in the Key enum. This has been fixed too, so you can now go:
If Keyboard.KeyHit( Key.ACBack) App.Terminate()
(Anyone know what the ‘AC’ in ‘ACBack’ stands for?)
Here’s a little runnable demo which is working fine on my API15 emulator and nvidia shield.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnKeyEvent( event:KeyEvent ) OverrideIf event.Type=EventType.KeyDown Print "KeyDown: "+Keyboard.KeyName( event.Key )If event.Type=EventType.KeyUp Print "KeyUp: "+Keyboard.KeyName( event.Key )EndMethod OnRender( canvas:Canvas ) OverrideRequestRender()' If Keyboard.KeyHit( Key.ACBack ) App.Terminate()canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )EndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndMonkey2 only currently supports a single window. Multiple windows may or may not work to varying degrees depending on target – they are totally untested. By all means feel free to get in there and try to get them working – the basic framework is there – but I wont be able to address this myself for a while yet.
I believe it saves in GLTF 2.0 (with an additional .bin file, if that makes any difference)
Cool, this is standard gltf format – have you got any actual animations for me to play with?
I will eventually update the gltf2 loader to load skinned animations, probably soon if anyone actually has a need for it!
Can you export or gltf2, or just gltf1? Needs to be gltf2…
-
AuthorPosts