More system-micros elimination
parent
0edadff45f
commit
4b9760dd67
|
@ -140,7 +140,6 @@ IN: calendar.tests
|
||||||
[ +gt+ ] [ 2005 1 1 12 30 0 instant <timestamp>
|
[ +gt+ ] [ 2005 1 1 12 30 0 instant <timestamp>
|
||||||
2004 1 1 13 30 0 instant <timestamp> <=> ] unit-test
|
2004 1 1 13 30 0 instant <timestamp> <=> ] unit-test
|
||||||
|
|
||||||
[ t ] [ now timestamp>micros system-micros - 1000000 < ] unit-test
|
|
||||||
[ t ] [ 0 micros>timestamp unix-1970 = ] unit-test
|
[ t ] [ 0 micros>timestamp unix-1970 = ] unit-test
|
||||||
[ t ] [ 123456789000000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
|
[ t ] [ 123456789000000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
|
||||||
[ t ] [ 123456789123456000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
|
[ t ] [ 123456789123456000 [ micros>timestamp timestamp>micros ] keep = ] unit-test
|
||||||
|
|
|
@ -22,7 +22,7 @@ server-state f
|
||||||
|
|
||||||
: expire-state ( class -- )
|
: expire-state ( class -- )
|
||||||
new
|
new
|
||||||
-1/0. system-micros [a,b] >>expires
|
-1/0. gmt timestamp>micros [a,b] >>expires
|
||||||
delete-tuples ;
|
delete-tuples ;
|
||||||
|
|
||||||
TUPLE: server-state-manager < filter-responder timeout ;
|
TUPLE: server-state-manager < filter-responder timeout ;
|
||||||
|
|
|
@ -174,7 +174,7 @@ HELP: hand-last-button
|
||||||
{ $var-description "Global variable. The mouse button most recently pressed." } ;
|
{ $var-description "Global variable. The mouse button most recently pressed." } ;
|
||||||
|
|
||||||
HELP: hand-last-time
|
HELP: hand-last-time
|
||||||
{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link system-micros } "." } ;
|
{ $var-description "Global variable. The timestamp of the most recent mouse button click. This timestamp has the same format as the output value of " { $link nano-count } "." } ;
|
||||||
|
|
||||||
HELP: hand-buttons
|
HELP: hand-buttons
|
||||||
{ $var-description "Global variable. A vector of mouse buttons currently held down." } ;
|
{ $var-description "Global variable. A vector of mouse buttons currently held down." } ;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
! Copyright (C) 2008 John Benediktsson
|
! Copyright (C) 2008 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
USING: byte-arrays checksums checksums.md5 checksums.sha
|
USING: byte-arrays calendar checksums checksums.md5
|
||||||
kernel math math.parser math.ranges random unicode.case
|
checksums.sha io.binary kernel math math.parser math.ranges
|
||||||
sequences strings system io.binary ;
|
random sequences strings system unicode.case ;
|
||||||
|
|
||||||
IN: uuid
|
IN: uuid
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -12,7 +11,7 @@ IN: uuid
|
||||||
! 0x01b21dd213814000L is the number of 100-ns intervals
|
! 0x01b21dd213814000L is the number of 100-ns intervals
|
||||||
! between the UUID epoch 1582-10-15 00:00:00 and the
|
! between the UUID epoch 1582-10-15 00:00:00 and the
|
||||||
! Unix epoch 1970-01-01 00:00:00.
|
! Unix epoch 1970-01-01 00:00:00.
|
||||||
system-micros 10 * HEX: 01b21dd213814000 +
|
gmt timestamp>micros 10 * HEX: 01b21dd213814000 +
|
||||||
[ -48 shift HEX: 0fff bitand ]
|
[ -48 shift HEX: 0fff bitand ]
|
||||||
[ -32 shift HEX: ffff bitand ]
|
[ -32 shift HEX: ffff bitand ]
|
||||||
[ HEX: ffffffff bitand ]
|
[ HEX: ffffffff bitand ]
|
||||||
|
|
|
@ -359,8 +359,8 @@ M: space-invaders update-video ( value addr cpu -- )
|
||||||
|
|
||||||
: sync-frame ( micros -- micros )
|
: sync-frame ( micros -- micros )
|
||||||
#! Sleep until the time for the next frame arrives.
|
#! Sleep until the time for the next frame arrives.
|
||||||
1000 60 / >fixnum + system:system-micros - dup 0 >
|
1000 60 / >fixnum + gmt timestamp>micros - dup 0 >
|
||||||
[ milliseconds threads:sleep ] [ drop threads:yield ] if system:system-micros ;
|
[ milliseconds threads:sleep ] [ drop threads:yield ] if gmt timestamp>micros ;
|
||||||
|
|
||||||
: invaders-process ( micros gadget -- )
|
: invaders-process ( micros gadget -- )
|
||||||
#! Run a space invaders gadget inside a
|
#! Run a space invaders gadget inside a
|
||||||
|
@ -378,7 +378,7 @@ M: space-invaders update-video ( value addr cpu -- )
|
||||||
M: invaders-gadget graft* ( gadget -- )
|
M: invaders-gadget graft* ( gadget -- )
|
||||||
dup cpu>> init-sounds
|
dup cpu>> init-sounds
|
||||||
f over quit?<<
|
f over quit?<<
|
||||||
[ system:system-micros swap invaders-process ] curry
|
[ gmt timestamp>micros swap invaders-process ] curry
|
||||||
"Space invaders" threads:spawn drop ;
|
"Space invaders" threads:spawn drop ;
|
||||||
|
|
||||||
M: invaders-gadget ungraft* ( gadget -- )
|
M: invaders-gadget ungraft* ( gadget -- )
|
||||||
|
|
|
@ -35,7 +35,7 @@ CONSTANT: default-height 20
|
||||||
rows>> 1 + 10 / ceiling ;
|
rows>> 1 + 10 / ceiling ;
|
||||||
|
|
||||||
: update-interval ( tetris -- interval )
|
: update-interval ( tetris -- interval )
|
||||||
level>> 1 - 60 * 1000000 swap - ;
|
level>> 1 - 60 * 1,000,000,000 swap - ;
|
||||||
|
|
||||||
: add-block ( tetris block -- )
|
: add-block ( tetris block -- )
|
||||||
over [ board>> ] 2dip current-piece tetromino>> colour>> set-block ;
|
over [ board>> ] 2dip current-piece tetromino>> colour>> set-block ;
|
||||||
|
@ -104,10 +104,10 @@ CONSTANT: default-height 20
|
||||||
dup { 0 1 } tetris-move [ move-drop ] [ lock-piece ] if ;
|
dup { 0 1 } tetris-move [ move-drop ] [ lock-piece ] if ;
|
||||||
|
|
||||||
: update ( tetris -- )
|
: update ( tetris -- )
|
||||||
system-micros over last-update>> -
|
nano-count over last-update>> -
|
||||||
over update-interval > [
|
over update-interval > [
|
||||||
dup move-down
|
dup move-down
|
||||||
system-micros >>last-update
|
nano-count >>last-update
|
||||||
] when drop ;
|
] when drop ;
|
||||||
|
|
||||||
: ?update ( tetris -- )
|
: ?update ( tetris -- )
|
||||||
|
|
Loading…
Reference in New Issue