I bought a WikiReader recently, which apart from being a 4GB text only offline version of Wikipedia, comes with a fun feature where it can run any Forth programs which are placed on its internal mini SD card. I wrote this program so I could test my small Forth programs without having to swap the mini SD card in and out repeatedly. The current version can run most of the test programs exactly as they appear on the SD card very faithfully. This app uses a Forth interpreter provided by the open source embeddable Forth implementation FICL (http://ficl.sourceforge.net/), and it works by providing device specific words as callbacks to a simulated WikiReader. It implements enough now to be useful, including the framebuffer functions, GDI functions (including text rendering using the device's font) and input functions, so I'm releasing it.
Usage:
See simlib.4th for the list of device specific words supported by this simulator, as well as simtest.4th for some simple examples. The other Forth programs included are the ones which come with the device and which I've tested on this simulator. Please refer to them for more reference material when writing your own programs.
The console supports multi-line commands. To enter a multi-line command, press ctrl-enter for a new line. The console also keeps a history of all commands entered. To navigate the history, press ctrl-up or ctrl-down. Pressing up or down without ctrl will move the cursor around the console.
To simulate moving your finger over the screen during the execution of your Forth command or program, move your mouse over the screen while holding down the left mouse button. To simulate hardware key presses, the hardware keys are mapped as follows:
Search | Q |
History | W |
Random | E |
A note about the calculator progam, calc.4th:
The calculator program is not completely identical to the original version on the retail device, because the version on the device has a bug. I found the bug while writing this simulator, and submitted a bug report. Here is a link to the bug report. To see the bug for yourself, on your device, try the following calculation: -75 + 5 =. The result it gives is gibberish, and when trying it on the simulator with the original calc.4th, a stack underflow occurs. Fortunately, I believe I have fixed the bug, and have included the fixed version of calc.4th in the simulator. You can transfer this fixed version to your device as well.
Here are the downloads for the fixed calculator:
- calc.4th
- calc.patch (so you can see what I changed more clearly)
Screenshots:
Where is the download link
ReplyDeleteOn the downloads page
DeleteCodewitch, thanks for making this available. These units are under $20 now so I am getting one, or two, or three... Depends on how useful the first one turns out to be.
ReplyDeleteI'm trying to put my digital dictionary into wikireader, but don't understand what compression they used on wikireader. You have any idea?
ReplyDeleteI haven't looked into that myself. Reading through the source code for the wikireader browser might help you. Its available here:
Deletehttps://github.com/wikireader/wikireader