2019-05-10 02:58:41 +10:00
|
|
|
# emul
|
|
|
|
|
2019-05-21 02:11:45 +10:00
|
|
|
This folder contains a couple of tools running under the [libz80][libz80]
|
|
|
|
emulator.
|
|
|
|
|
2020-01-01 14:03:48 +11:00
|
|
|
## Not real hardware
|
|
|
|
|
|
|
|
In the few emulated apps described below, we don't try to emulate real hardware
|
|
|
|
because the goal here is to facilitate userspace development.
|
|
|
|
|
|
|
|
These apps run on imaginary hardware and use many cheats to simplify I/Os.
|
|
|
|
|
|
|
|
For real hardware emulation (which helps developing drivers), see the `hw`
|
|
|
|
folder.
|
|
|
|
|
2019-05-21 02:11:45 +10:00
|
|
|
## Build
|
|
|
|
|
|
|
|
First, make sure that the `libz80` git submodule is checked out. If not, run
|
|
|
|
`git submodule init && git submodule update`.
|
|
|
|
|
2020-01-01 05:32:09 +11:00
|
|
|
After that, you can run `make` and it builds all applications.
|
2019-05-21 02:11:45 +10:00
|
|
|
|
2020-03-25 04:46:05 +11:00
|
|
|
## forth
|
|
|
|
|
2020-04-03 14:15:43 +11:00
|
|
|
Collapse OS' Forth interpreter, which is in the process of replacing the
|
|
|
|
zasm-based project.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
2020-04-03 14:15:43 +11:00
|
|
|
The Forth interpreter is entirely self-hosting, that is, it assembles its
|
|
|
|
binary with itself.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
|
|
|
There are 3 build stages.
|
|
|
|
|
2020-04-03 14:15:43 +11:00
|
|
|
**Stage 0**: At this stage, all we have are our bootstrap binaries, `boot.bin`
|
|
|
|
and `z80c.bin`. We concatenate them into `forth0.bin` ans then wrap the
|
|
|
|
emulator around it which is named `stage1` (because it builds the stage 1) to
|
|
|
|
have a barebone forth interpreter.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
|
|
|
**Stage 1**: The `stage1` binary allows us to augment `forth0.bin` with
|
2020-03-25 12:13:02 +11:00
|
|
|
the compiled dictionary of a full Forth interpreter. We feed it with
|
|
|
|
`$(FORTHSRCS)` and then dump the resulting compiled dict.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
From there, we can create `forth1.bin`, which is wrapped by both the `forth`
|
|
|
|
and `stage2` executables. `forth` is the interpreter you'll use.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
2020-03-25 12:13:02 +11:00
|
|
|
**Stage 2**: `stage2` is used to resolve the chicken-and-egg problem and use
|
|
|
|
the power of a full Forth intepreter, including an assembler, to assemble
|
2020-04-03 14:15:43 +11:00
|
|
|
`z80c.bin`. This is a manual step executed through `make updatebootstrap`.
|
|
|
|
|
|
|
|
Normally, running this step should yield the exact same `boot.bin` and
|
|
|
|
`z80c.bin` as before, unless of course you've changed the source.
|
2020-03-25 04:46:05 +11:00
|
|
|
|
2019-11-24 07:22:26 +11:00
|
|
|
## Problems?
|
|
|
|
|
|
|
|
If the libz80-wrapped zasm executable works badly (hangs, spew garbage, etc.),
|
|
|
|
it's probably because you've broken your bootstrap binaries. They're easy to
|
|
|
|
mistakenly break. To verify if you've done that, look at your git status. If
|
2020-04-03 14:15:43 +11:00
|
|
|
`boot.bin` or `z80c.bin` are modified, try resetting them and then run
|
2019-11-24 07:22:26 +11:00
|
|
|
`make clean all`. Things should go better afterwards.
|
|
|
|
|
|
|
|
If that doesn't work, there's also the nuclear option of `git reset --hard`
|
|
|
|
and `git clean -fxd`.
|
|
|
|
|
|
|
|
If that still doesn't work, it might be because the current commit you're on
|
|
|
|
is broken, but that is rather rare: the repo on Github is plugged on Travis
|
|
|
|
and it checks that everything is smooth.
|