Skip to content

Commit 4f52a76

Browse files
committed
readme
1 parent dbf3759 commit 4f52a76

File tree

2 files changed

+46
-9
lines changed

2 files changed

+46
-9
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ This repository, however, will contain more than the final code. It will tell yo
66

77
So behold, here is a program that uses virtually all concepts in Wend:
88
```cpp
9-
fun main() {
9+
main() {
1010
// square root of a fixed-point number
1111
// stored in a 32 bit integer variable, shift is the precision
1212

13-
fun sqrt(n:int, shift:int) : int {
14-
var x:int;
15-
var x_old:int;
16-
var n_one:int;
13+
int sqrt(int n, int shift) {
14+
int x;
15+
int x_old;
16+
int n_one;
1717

18-
if n > 65535 { // pay attention to potential overflows
18+
if n > 2147483647/shift { // pay attention to potential overflows
1919
return 2 * sqrt(n / 4, shift);
2020
}
2121
x = shift; // initial guess 1.0, can do better, but oh well
@@ -29,7 +29,7 @@ fun main() {
2929
}
3030
}
3131

32-
fun abs(x:int) : int {
32+
int abs(int x) {
3333
if x < 0 {
3434
return -x;
3535
} else {
@@ -50,11 +50,11 @@ And as usual, there will be a program with a raytracer :)
5050

5151
## run tests
5252
```sh
53-
make run
53+
make test
5454
```
5555

5656
## Graphics!
57-
It is so dull to compute Fibonacci numbers, so here are more eyecandy examples for our compiler, check gfx/*.wend files.
57+
It is so dull to compute Fibonacci numbers, so here are more eyecandy examples for our compiler, check test-programs/gfx/*.wend files.
5858
```sh
5959
make gfx
6060
```

test-programs/gfx/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Graphics!
2+
It is so dull to compute Fibonacci numbers, so here are more eyecandy examples for tinycompiler.
3+
4+
### build wend version:
5+
```sh
6+
git clone https://github.com/ssloy/tinycompiler.git &&
7+
cd tinycompiler &&
8+
make gfx
9+
```
10+
11+
### build C version:
12+
```sh
13+
git clone https://github.com/ssloy/tinycompiler.git &&
14+
cd tinycompiler/test-programs/gfx/ &&
15+
gcc breakout.c -o breakout &&
16+
gcc fire.c -o fire &&
17+
gcc mandelbrot.c -o mandelbrot &&
18+
gcc metaballs.c -o metaballs -lm &&
19+
gcc race.c -o race -lm
20+
```
21+
22+
23+
### Mandelbrot set
24+
<img src="https://raw.githubusercontent.com/ssloy/ssloy.github.io/main/docs/tinycompiler/gfx/mandelbrot.png" width="336">
25+
26+
### Zero-player breakout game
27+
![](https://raw.githubusercontent.com/ssloy/ssloy.github.io/main/docs/tinycompiler/gfx/breakout.gif)
28+
29+
### Fire
30+
![](https://raw.githubusercontent.com/ssloy/ssloy.github.io/main/docs/tinycompiler/gfx/fire6.gif)
31+
32+
### Sunset race
33+
![](https://raw.githubusercontent.com/ssloy/ssloy.github.io/main/docs/tinycompiler/gfx/sunset-race.gif)
34+
35+
### Metaballs
36+
![](https://raw.githubusercontent.com/ssloy/ssloy.github.io/main/docs/tinycompiler/gfx/metaballs.gif)
37+

0 commit comments

Comments
 (0)