Quote:
Originally Posted by kaminkatze
Pixel based, kindle 3 game of life.
...
(Hope I don't have violated to many of your style constrains.)
|
My style is just so I can "absorb" as much code as possible on an 80x25 display without interrupting my thoughts with vertical scrolling. You did great in that respect.
I especially like how you are caching the framebuffer on ramdisk. I considered storing random access data in a file on /tmp to use as a large array. Shell arrays do not seem to work in my busybox version, so I was planning to fake it with "dd".
Some minor tips:
1) Inside $(( )) expressions, vars do not need $ except when numeric parms $1 $2, etc. You can see in my examples. I see that you left the $ off in some cases, but kept it in others.
2) I originally had a setpixel function, but testing showed that it was quite a bit faster on my 5.0.0 firmware to put the "dd" inline, and wrapping a single line dd call in a function actually consumes more screen space. But it *does* make it more readable though, and in your case it allows you to pipe it to other commands, so it may well be worth the speed trade-off here if simple to understand code is the goal (which is what I aim for in tutorials like this thread).
3) I do not know if you noticed, but when you have multiple inline variable assignments (with no ';'), you cannot use a value earlier in the same line. This is why I sometimes do "; local " in the middle of a line. The "local" statements prevent a function from changing values that belong to its parent.
This does not seem to do anything other than clear the screen on my K3 with firmware 3.3, and I do not have time to study your code in any detail right now. Are there any special requirements to run this?
P.S. "Hope I don't have" should be "Hope I haven't", and I bumped your karma to 2600 for the great hack.