stack-machine.nv
· 2.0 KiB · Text
Исходник
Playground
|:push: :: $x|
:: push $x
|:push:|
|:set: :: $name :data: $value|
:: set $name $value
|:set: :: $name|
:error: stack underflow
|:get: :: $name|
:: get $name
|:: push $n|
:data: $n
|:: duplicate :data: $n|
:data: $n
:data: $n
|:: duplicate|
:error: stack underflow
|:: drop :data: $n|
|:: drop|
:error: stack underflow
|:: swap :swap: $x :data: $y|
:data: $y
:data: $x
|:: swap :swap: $x|
:error: stack underflow
|:: swap? :data: $x|
:swap: $x
|:compare: :@math: $x|
:data: $x
|:compare: $x :data: $y|
:compare:
:@math: compare $y $x
|:: greater :data: less | :data: false
|:: greater :data: equal | :data: false
|:: greater :data: greater| :data: true
|:: greater? :data: $x|
:compare: $x
|:: abs :@math: less|
::(# -1 *)
|:: abs :@math: $x|
|:: abs? :data: $x?|
:@math: compare $x 0
|:: math $op :@math: $n|
:data: $n
|:: math $op? :@math: $op $x :data: $y|
:@math: $op $y $x
|:: math $op :@math: $op $x|
:error: stack underflow
|:: math $op? :data: $x|
:@math: $op $x
|:: math $op|
:error: stack underflow
|:: print :data: $x|
:@stdio: print $x
|:: print|
:error: stack underflow
|:reset variables:? :checked variables: $x $y|
:variables: $x $y
|:reset variables:|
|:: set $x $y :variables: $x $|
:variables: $x $y
:reset variables:
|:: set $x $y? :variables: $v $|
:checked variables: $v $
:reset variables:
|:: set $x $y|
:variables: $x $y
|:: get $x :variables: $x $y?|
:data: $y
:reset variables:
|:: get $x :variables: $v $|
:checked variables: $v $
:reset variables:
|:: get $x|
:error: $x not found
|:: set | :set:
|:: get | :get:
|:: add | :: math add
|:: subtract| :: math subtract
|:: multiply| :: math multiply
|:: divide | :: math divide
|:: modulo | :: math modulo
|:: and | :: math and
|:: dup | :: duplicate
|:: +| :: add
|:: -| :: subtract
|:: *| :: multiply
|:: /| :: divide
|:: %| :: modulo
|:: &| :: and
|:: >| :: greater
|:: #| :push:
1 | |:push: :: $x| |
2 | :: push $x |
3 | |:push:| |
4 | |
5 | |:set: :: $name :data: $value| |
6 | :: set $name $value |
7 | |:set: :: $name| |
8 | :error: stack underflow |
9 | |
10 | |:get: :: $name| |
11 | :: get $name |
12 | |
13 | |:: push $n| |
14 | :data: $n |
15 | |
16 | |:: duplicate :data: $n| |
17 | :data: $n |
18 | :data: $n |
19 | |:: duplicate| |
20 | :error: stack underflow |
21 | |
22 | |:: drop :data: $n| |
23 | |:: drop| |
24 | :error: stack underflow |
25 | |
26 | |:: swap :swap: $x :data: $y| |
27 | :data: $y |
28 | :data: $x |
29 | |:: swap :swap: $x| |
30 | :error: stack underflow |
31 | |:: swap? :data: $x| |
32 | :swap: $x |
33 | |
34 | |:compare: :@math: $x| |
35 | :data: $x |
36 | |:compare: $x :data: $y| |
37 | :compare: |
38 | :@math: compare $y $x |
39 | |
40 | |:: greater :data: less | :data: false |
41 | |:: greater :data: equal | :data: false |
42 | |:: greater :data: greater| :data: true |
43 | |:: greater? :data: $x| |
44 | :compare: $x |
45 | |
46 | |:: abs :@math: less| |
47 | ::(# -1 *) |
48 | |:: abs :@math: $x| |
49 | |:: abs? :data: $x?| |
50 | :@math: compare $x 0 |
51 | |
52 | |:: math $op :@math: $n| |
53 | :data: $n |
54 | |:: math $op? :@math: $op $x :data: $y| |
55 | :@math: $op $y $x |
56 | |:: math $op :@math: $op $x| |
57 | :error: stack underflow |
58 | |:: math $op? :data: $x| |
59 | :@math: $op $x |
60 | |:: math $op| |
61 | :error: stack underflow |
62 | |
63 | |:: print :data: $x| |
64 | :@stdio: print $x |
65 | |:: print| |
66 | :error: stack underflow |
67 | |
68 | |:reset variables:? :checked variables: $x $y| |
69 | :variables: $x $y |
70 | |:reset variables:| |
71 | |
72 | |:: set $x $y :variables: $x $| |
73 | :variables: $x $y |
74 | :reset variables: |
75 | |:: set $x $y? :variables: $v $| |
76 | :checked variables: $v $ |
77 | :reset variables: |
78 | |:: set $x $y| |
79 | :variables: $x $y |
80 | |
81 | |:: get $x :variables: $x $y?| |
82 | :data: $y |
83 | :reset variables: |
84 | |:: get $x :variables: $v $| |
85 | :checked variables: $v $ |
86 | :reset variables: |
87 | |:: get $x| |
88 | :error: $x not found |
89 | |
90 | |:: set | :set: |
91 | |:: get | :get: |
92 | |:: add | :: math add |
93 | |:: subtract| :: math subtract |
94 | |:: multiply| :: math multiply |
95 | |:: divide | :: math divide |
96 | |:: modulo | :: math modulo |
97 | |:: and | :: math and |
98 | |:: dup | :: duplicate |
99 | |
100 | |:: +| :: add |
101 | |:: -| :: subtract |
102 | |:: *| :: multiply |
103 | |:: /| :: divide |
104 | |:: %| :: modulo |
105 | |:: &| :: and |
106 | |:: >| :: greater |
107 | |
108 | |:: #| :push: |
viznut.nv
· 914 B · Text
Исходник
Playground
|:: next pixel :screen resolution: $x $y? :pixel: $x $y|
:pixel: 0 0
:finished frame:
|:: next pixel :screen resolution: $x $ry? :pixel: $x $py|
:pixel: 0 $py
:: next row
|:: next pixel :pixel: $x $y :@math: $n|
:pixel: $n $y
|:: next pixel? :pixel: $x $y?|
:@math: add $x 1
|:: next row :pixel: $x $y :@math: $n|
:pixel: $x $n
|:: next row? :pixel: $x $y?|
:@math: add $y 1
||:pixel: 0 0
|:: plot :data: true :pixel: $x $y?|
:@graphics: set-pixel $x $y 255 255 255
|:: plot :data: false :pixel: $x $y?|
:@graphics: set-pixel $x $y 0 0 0
|:: plot :pixel: $x $y?|
:: viznut $x $y
:: plot
|:: draw a frame :finished frame:|
|:: draw a frame|
:: plot :: next pixel
:: draw a frame
|:: draw|
:: clear the screen
:: draw a frame
:: draw FPS
|:: viznut $x $y|::(
# $x # $y + # $x # $y - &
# 24 % abs # 9 >
)
|::|
:screen resolution: 64 64
1 | |:: next pixel :screen resolution: $x $y? :pixel: $x $y| |
2 | :pixel: 0 0 |
3 | :finished frame: |
4 | |:: next pixel :screen resolution: $x $ry? :pixel: $x $py| |
5 | :pixel: 0 $py |
6 | :: next row |
7 | |:: next pixel :pixel: $x $y :@math: $n| |
8 | :pixel: $n $y |
9 | |:: next pixel? :pixel: $x $y?| |
10 | :@math: add $x 1 |
11 | |
12 | |:: next row :pixel: $x $y :@math: $n| |
13 | :pixel: $x $n |
14 | |:: next row? :pixel: $x $y?| |
15 | :@math: add $y 1 |
16 | |
17 | ||:pixel: 0 0 |
18 | |:: plot :data: true :pixel: $x $y?| |
19 | :@graphics: set-pixel $x $y 255 255 255 |
20 | |:: plot :data: false :pixel: $x $y?| |
21 | :@graphics: set-pixel $x $y 0 0 0 |
22 | |:: plot :pixel: $x $y?| |
23 | :: viznut $x $y |
24 | :: plot |
25 | |
26 | |:: draw a frame :finished frame:| |
27 | |:: draw a frame| |
28 | :: plot :: next pixel |
29 | :: draw a frame |
30 | |
31 | |:: draw| |
32 | :: clear the screen |
33 | :: draw a frame |
34 | :: draw FPS |
35 | |
36 | |:: viznut $x $y|::( |
37 | # $x # $y + # $x # $y - & |
38 | # 24 % abs # 9 > |
39 | ) |
40 | |
41 | |::| |
42 | :screen resolution: 64 64 |
window-management.nv
· 1.3 KiB · Text
Исходник
Playground
|: Default handlers. :|
|:: update|
|:: handle input|
|:: draw|
|:: draw FPS| :@graphics: draw-fps
|:: clear the screen :screen color: $r $g $b?|
:@graphics: clear-screen $r $g $b
|:: clear the screen|
:@graphics: clear-screen 0 0 0
|:: display| :@graphics: display
|:: poll for input|
:@input: poll-input
:@input: get-mouse-position
:@input: check-mouse-button 0
:@input: check-mouse-button 2
|:@input: mouse-button-pressed 0| :left mouse: pressed
|:@input: mouse-button-pressed 1| :middle mouse: pressed
|:@input: mouse-button-pressed 2| :right mouse: pressed
|:@input: mouse-button-released $x|
|:@input: mouse-position $x $y| :mouse position: $x $y
|:@signal: quit| :quit:
|:left mouse: $x|
|:middle mouse: $x|
|:right mouse: $x|
|:mouse position: $x $y|
|:: check if $key is pressed|
::check if $key was pressed
|:: check if $key was pressed :@input: key-pressed $key|
:key pressed: $key
|:: check if $key was pressed :@input: key-released $key|
:key released: $key
|:: check if $key was pressed?|
:@input: check-key $key
|:key pressed: $key|
|:key released: $key|
|:: start :screen resolution: $x $y?|
:@graphics: set-resolution $x $y
::main loop
|:: main loop :quit:|
|:: main loop|
::poll for input
::handle input
::update
::draw
::display
::main loop
|::|:: start
1 | |: Default handlers. :| |
2 | |:: update| |
3 | |:: handle input| |
4 | |:: draw| |
5 | |
6 | |:: draw FPS| :@graphics: draw-fps |
7 | |
8 | |:: clear the screen :screen color: $r $g $b?| |
9 | :@graphics: clear-screen $r $g $b |
10 | |:: clear the screen| |
11 | :@graphics: clear-screen 0 0 0 |
12 | |
13 | |:: display| :@graphics: display |
14 | |
15 | |:: poll for input| |
16 | :@input: poll-input |
17 | :@input: get-mouse-position |
18 | :@input: check-mouse-button 0 |
19 | :@input: check-mouse-button 2 |
20 | |
21 | |:@input: mouse-button-pressed 0| :left mouse: pressed |
22 | |:@input: mouse-button-pressed 1| :middle mouse: pressed |
23 | |:@input: mouse-button-pressed 2| :right mouse: pressed |
24 | |:@input: mouse-button-released $x| |
25 | |:@input: mouse-position $x $y| :mouse position: $x $y |
26 | |
27 | |:@signal: quit| :quit: |
28 | |
29 | |:left mouse: $x| |
30 | |:middle mouse: $x| |
31 | |:right mouse: $x| |
32 | |:mouse position: $x $y| |
33 | |
34 | |:: check if $key is pressed| |
35 | ::check if $key was pressed |
36 | |:: check if $key was pressed :@input: key-pressed $key| |
37 | :key pressed: $key |
38 | |:: check if $key was pressed :@input: key-released $key| |
39 | :key released: $key |
40 | |:: check if $key was pressed?| |
41 | :@input: check-key $key |
42 | |:key pressed: $key| |
43 | |:key released: $key| |
44 | |
45 | |:: start :screen resolution: $x $y?| |
46 | :@graphics: set-resolution $x $y |
47 | ::main loop |
48 | |
49 | |:: main loop :quit:| |
50 | |:: main loop| |
51 | ::poll for input |
52 | ::handle input |
53 | ::update |
54 | ::draw |
55 | ::display |
56 | ::main loop |
57 | |
58 | |::|:: start |
59 | |
60 |