diff --git a/makefile b/makefile index 55c1bd24..60f338e3 100644 --- a/makefile +++ b/makefile @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.darwin.clang.x86_64 b/makefile.darwin.clang.x86_64 index 2d18232c..1bc7d577 100644 --- a/makefile.darwin.clang.x86_64 +++ b/makefile.darwin.clang.x86_64 @@ -138,6 +138,7 @@ stage6: $(VOCSTATIC) -sP oocIntStr.Mod $(VOCSTATIC) -sP oocSysClock.Mod $(VOCSTATIC) -sP oocTime.Mod + $(VOCSTATIC) -sP oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.freebsd.clang.x86_64 b/makefile.freebsd.clang.x86_64 index 6afce49e..dd829077 100644 --- a/makefile.freebsd.clang.x86_64 +++ b/makefile.freebsd.clang.x86_64 @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.clang.powerpc b/makefile.linux.clang.powerpc index 9c82fac1..235fd695 100644 --- a/makefile.linux.clang.powerpc +++ b/makefile.linux.clang.powerpc @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.clang.x86_64 b/makefile.linux.clang.x86_64 index 8994e028..871900d3 100644 --- a/makefile.linux.clang.x86_64 +++ b/makefile.linux.clang.x86_64 @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sP oocIntStr.Mod $(VOCSTATIC) -sP oocSysClock.Mod $(VOCSTATIC) -sP oocTime.Mod + $(VOCSTATIC) -sP oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.gcc.armv6j_hardfp b/makefile.linux.gcc.armv6j_hardfp index 7fde34c4..c1484669 100644 --- a/makefile.linux.gcc.armv6j_hardfp +++ b/makefile.linux.gcc.armv6j_hardfp @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.gcc.powerpc b/makefile.linux.gcc.powerpc index bb7f3cd6..49c585e3 100644 --- a/makefile.linux.gcc.powerpc +++ b/makefile.linux.gcc.powerpc @@ -136,7 +136,7 @@ stage6: $(VOCSTATIC) -sPF oocIntConv.Mod $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod - $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.gcc.x86 b/makefile.linux.gcc.x86 index 5da96ef7..af0bc83b 100644 --- a/makefile.linux.gcc.x86 +++ b/makefile.linux.gcc.x86 @@ -137,6 +137,7 @@ stage6: $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/makefile.linux.gcc.x86_64 b/makefile.linux.gcc.x86_64 index 55c1bd24..824c6c7d 100644 --- a/makefile.linux.gcc.x86_64 +++ b/makefile.linux.gcc.x86_64 @@ -136,7 +136,7 @@ stage6: $(VOCSTATIC) -sPF oocIntConv.Mod $(VOCSTATIC) -sPF oocIntStr.Mod $(VOCSTATIC) -sPF oocSysClock.Mod - $(VOCSTATIC) -sPF oocTime.Mod + $(VOCSTATIC) -sPF oocRandomNumbers.Mod # $(VOCSTATIC) -s oocLongStrings.Mod # $(CC) oocLongStrings.c # $(VOCSTATIC) -s oocMsg.Mod diff --git a/src/lib/ooc/oocRandomNumbers.Mod b/src/lib/ooc/oocRandomNumbers.Mod new file mode 100644 index 00000000..bc238091 --- /dev/null +++ b/src/lib/ooc/oocRandomNumbers.Mod @@ -0,0 +1,75 @@ +(* $Id: RandomNumbers.Mod,v 1.1 1997/02/07 07:45:32 oberon1 Exp $ *) +MODULE oocRandomNumbers; +(* +For details on this algorithm take a look at + Park S.K. and Miller K.W. (1988). Random number generators, good ones are + hard to find. Communications of the ACM, 31, 1192-1201. +*) + +CONST + modulo* = 2147483647; (* =2^31-1 *) + +VAR + z : LONGINT; + +PROCEDURE GetSeed* (VAR seed : LONGINT); +(* Returns the currently used seed value. *) + BEGIN + seed := z + END GetSeed; + +PROCEDURE PutSeed* (seed : LONGINT); +(* Set 'seed' as the new seed value. Any values for 'seed' are allowed, but + values beyond the intervall [1..2^31-2] will be mapped into this range. *) + BEGIN + seed := seed MOD modulo; + IF (seed = 0) THEN + z := 1 + ELSE + z := seed + END + END PutSeed; + +PROCEDURE NextRND; + CONST + a = 16807; + q = 127773; (* m div a *) + r = 2836; (* m mod a *) + VAR + lo, hi, test : LONGINT; + BEGIN + hi := z DIV q; + lo := z MOD q; + test := a * lo - r * hi; + IF (test > 0) THEN + z := test + ELSE + z := test + modulo + END + END NextRND; + +PROCEDURE RND* (range : LONGINT) : LONGINT; +(* Calculates a new number. 'range' has to be in the intervall + [1..2^31-2]. Result is a number from 0,1,..,range-1. *) + BEGIN + NextRND; + RETURN z MOD range + END RND; + +PROCEDURE Random*() : REAL; +(* Calculates a number x with 0.0 <= x < 1.0. *) + BEGIN + NextRND; + RETURN (z-1)*(1 / (modulo-1)) + END Random; + +(* +PROCEDURE Randomize*; + BEGIN + PutSeed (Unix.time (Unix.NULL)) + END Randomize; +*) + +BEGIN + z := 1 +END oocRandomNumbers. diff --git a/src/test/newt/Makefile b/src/test/newt/Makefile index 0650e8fd..f6eb71af 100644 --- a/src/test/newt/Makefile +++ b/src/test/newt/Makefile @@ -7,6 +7,8 @@ all: $(VOC) -s newt.Mod newttest.Mod -m $(VOC) -s newt.Mod newttest2.Mod -m +tetris: + $(VOC) -s newt.Mod tetris.Mod -m clean: rm *.h rm *.c diff --git a/src/test/newt/newt.Mod b/src/test/newt/newt.Mod index 1a3a10e1..6692366b 100644 --- a/src/test/newt/newt.Mod +++ b/src/test/newt/newt.Mod @@ -98,6 +98,16 @@ BEGIN newtWaitForKey END WaitForKey; +PROCEDURE -newtGetKey(): Int32 + "newtGetKey()"; + +PROCEDURE GetKey*(): CHAR; +VAR i : Int32; +BEGIN + i:= newtGetKey(); + RETURN CHR(SHORT(i)); +END GetKey; + PROCEDURE -newtClearKeyBuffer() "newtClearKeyBuffer()"; diff --git a/src/test/newt/newttest.Mod b/src/test/newt/newttest.Mod index b9597fbe..46d82a8e 100644 --- a/src/test/newt/newttest.Mod +++ b/src/test/newt/newttest.Mod @@ -3,6 +3,7 @@ MODULE newttest; IMPORT newt, oocIntStr, Unix; VAR i, j, k : newt.Int32; str : ARRAY 32 OF CHAR; +ch : CHAR; fo, co : newt.Component; BEGIN i := newt.Init(); @@ -29,10 +30,17 @@ newt.PopHelpLine(); newt.Refresh(); i := Unix.Sleep(1); -fo := newt.Form(NIL, "aaa", 0); -co := newt.Button(15, 15, "OK"); -newt.FormAddComponent(fo, co); +REPEAT +ch := newt.GetKey(); +str[0] := ch; +str[1] := 0X; +newt.DrawRootText(5, 5, str); +newt.PushHelpLine(str); +newt.Refresh; +UNTIL ch = ' '; + +(* newt.WaitForKey(); -newt.Delay(30); +newt.Delay(30);*) i := newt.Finished(); END newttest. diff --git a/voc b/voc index 6ba9f2d7..ad68686a 100755 Binary files a/voc and b/voc differ