| Age | Commit message (Collapse) | Author |
|
I forgot to commit the makefile configuration, and also added some
other small improvements to help with the poor performance (still
only around 20 FPS).
|
|
Compile PICO-w for the PS Vita :tada:.
Fixes some minor compiler warnings that only showed up because
of the different compilation target, and makes the Makefile port
system a little more opinionated.
|
|
|
|
|
|
|
|
|
|
|
|
It looks like the `SHUTDOWN` menu option shows up when the `-run`
CLI argument is passed, so pass it. There is a catch though, in
that PICO-8 does not properly report shutdown requests in those
cases, so read Wasm memory directly to detect the shutdown request.
|
|
Relax loading errors when we are unable to decode an embedded PNG
cart and just log a warning instead, continuing with the load.
Some other minor fixes included as well.
|
|
|
|
We do some fixes, namely fixing relative mouse motion which worked
very differently compared to mouse motion outside of pointer lock.
This appears to be something built in to PICO-8 itself (as evident by
keeping track of `STAT(32-33,38-39)` under pointer lock: PICO-8 scales
relative mouse motion by a factor of `.25` before adding to the
absolute mouse position.
Additionally, we support running PICO-w on systems with no audio
playback.
|
|
|
|
|
|
|
|
We abstract over SDL's audio subsystem and implement an audio
device that fits into PICO-8's model. We fixed the implementation
for the PICO-8 window focus and key buffer and can now actually
boot into PICO-8 games with working sounds and controls!
There are a few issues that remain:
1. There is no "exit" option in the pause menu, I think it thinks
that we are on the BBS, and maybe there is someway to fix this?
2. The clipboard textarea is not implemented at all; we should
keep a text buffer in `pw_input` and interact with SDL's
clipboard system
3. Multicart's don't always work; in particular Undune II tries
to download from the BBS, I would like to shim this somehow
to support both `LOAD("FOO.P8")` and `LOAD("#FOO")` forms
transparently.
|
|
Actually... come to think about it, the strict-aliasing change it
not necessary, as `image` is the result of a `malloc` which is
guaranteed to alias to any type (otherwise `(T *)malloc(...)`
would be undefined behaviour). Go back to the old code, as that
was (IMO) nicer.
|
|
I think I was doing an aliasing violation when I was casting the
`char *` to the union type, so instead reaturn bytes and provide
a method for reading a pixel from an image.
These are only called when loading images during cart selection
and setup (for the debug info font) and so I would prefer to be
safe rather than sorry (since performance isn't that critical -
it is not in the tight PICO-8 game loop).
|
|
After some playing around with devkit mode, I noticed two things:
1. The mouse pointer can be outside of the range [0. 128) in case
the window is larger than the PICO-8 screen, but it does not
move to positions that would be outside of the window
2. Under pointer lock, relative positions continue to be reported
even when the mouse is stuck to the edge of the window
This means our implementation was slightly wrong, as it it did
not properly handle the second case in a few ways:
- We would always round to integer relative mouse mouse motions,
meaning we would incorrectly approximate in case we collected
multiple frames of relative mouse motion
- We would compute the relative motion based on the mouse position,
which is incorrect under pointer lock (as the position doesn't
change but PICO-8 still needs relative mouse motion)
- We would reset relative mouse motion every frame, meaning that
we would not correctly accumulate relative motion in case the
host's refresh rate was faster than PICO-8's (which seems to
only run its frame logic at 30 FPS).
We fix that here.
|
|
There were a few cases where we would have stale input information
becaues the `pw_input` only receives events while the game is
running. This fixes that by:
- Reseting the player count on game start
- Clearing button states for disconnected players
- Improve handling of the POOM player 2 support in case a second
player connects
|
|
|
|
We use a linked list of frames and unwind to the latest. The
code turned out to be very simple, just following what the
Emscripten export does.
|
|
Now that we implemented our file-system, we can implement IO-related
syscalls and ASM constants and get further into the boot.
For now, we just use an in-memory userdat storage, but eventually,
I want to persist this to disk.
We can now boot to the point where we try to `invoke_vii`, which,
AFAIU, is the whole setjmp/longjmp machinery that I have to figure
out.
|
|
We added logic to read from a Tar archive, and write to Tar archive,
including seeding our virtual file-system with files from said
archive, but we forgot to add the writing of the Tar file when
syncing. Resolve that.
Additionally, normalize paths and strip leading `/`. Don't allow
empty paths. Paths that end in `/` are allowed - we don't have
special directory semantics (maybe can be reconsidered?)
|
|
We implement a reduced version of UStar as a storage mechanism for
our virtual FS to persist to disk.
We don't implement all UStar features, but it should be good enough.
|
|
PICO-8 carts write to a file-system when running carts, even ones
that don't do anything. From what I can tell, it records cart
changes to an `IndexDB` file-system in the Emscripten bundle, so
things like `CSTORE(...)` persist for a given cart.
It uses the same system calls for also:
- Reading the `data.pod` file, which contains some data for boot
- Writing logs to `stdout`, which we mimic by producing `SDL_Log`s
Persistance will be handled later, by reading and writing to a
UStar file (since they are simple, and allow us to keep all
cart-specific save data in one file).
None of this is hooked up to the `env.c` Emscripten glue code port.
|
|
We also implement some additional mouse functionality for pointer
locking and for reading the mouse wheel (although, that is currently
not hooked up over the ASM constants quite yet).
|
|
|
|
When starting to implement the ASM constants, I noticed that the
multicart support would be _WAYYYYY_ easier if all the multicarts
are just passed in as embedded cart data.
Here, we modify the cart module to introduce a new "cartdat" type
that represents a cart export (either a single cart, for the regular
case, or multiple carts for the multicart case). This simplifies
lots of code, and allows us to use the ASM constants for passing in
cart data without additional glue logic.
It mimics how the PICO-8 export works for multi-cart code as well.
Lastly, cart names now include the `.p8` extension in the name,
to match how they work with the multicart export. I'm not sure how
this will interact with splore multi-cart loading (i.e.
`LOAD("#SOMECART")`).
|
|
Implemented many of the missing host functions, but some things are
still unimplemented:
1. Audio, because I have _no_ idea how that works.
2. Syscalls, they look hairy and will look into them separately.
3. ASM constants, we need to go over the array in the the exported
JS module and understand how each one maps to our host.
The other functions are _mostly_ straightforward to implement, and
I did so with some caveats (for example, only supporting the single
format the PICO-8 uses for `strftime`) which is good enough for us.
Next, I need to refactor how we load carts: in particular, all
carts need to come from the `_cartdat` mechanism, so the "embedded"
carts instead of loading them ad-hoc. This requires us to refactor
how we do the multicart loading to pre-load the entire `.p8.dir`
when a cart is selected (instead of just keeping their names and
lazy-loading them in).
|
|
|
|
Now the cart fails to boot (we trap on unimplemented stubs), but
a lot of small functionv have been setup.
Now the marathon begins for trying to understand what each of the
stubs do...
|
|
Note that we fail to build on linking errors - we have a lot of
missing `env` functions to implement since moving away from the
stub.
Now the real fun begins...
|
|
We implemented trap handing with setjmp/longjmp. This _should_ be
very widely supported, but it was _one_ nicety of WAMR: it did
not rely on this mechanism and would instead return errors on
runtime calls in case of a trap.
The implementation is fairly straightforward: we set a global
`jmp_buf` when installing a handler and longjmp in case of a
trap. Note that the handler also keeps the trap code, because
the C standard only requires `if (setjmp(buf))` to be supported,
i.e. "the entire controlling expression of `if`", meaning even
if it does return the code passed to `longjmp`, we can't really
do anything with it.
Added a `Esc` key handler in the PICO-8 stub to check traps
work, and they do :).
|
|
Instead of interpreting Wasm, compile it ahead of time to C and
run that instead:
- it is much faster (no interpreter overhead)
- it is easier to implement host functions, they are just C calls
This works well for us since we only ever load a single Wasm blob
(the PICO-8 runtime that `picow` is built with).
There was some fun figuring out how big-endian stuff works (WRT
memory layout), but otherwise it was pretty straight forward.
Note that traps are still not working, I need to figure that out
still...
|
|
|
|
We now print debug stats (ATM, just FPS) overlaying the actual game.
We use the PICO-8 font to keep things consistent; I probable should
choose a better color though...
|
|
I went down a deep rabbithole to understand the pixel order, and
it turns out that the Emscripten library code is setting the wrong
`format` value for what it actually uses, which threw me off.
We now set the correct pixel format tag, and handle pixel byte
ordering correctly on the host.
Some other minor fixes.
|
|
Start implementing the surface-specific SDL API so that we can get
our stub PICO-8 engine to draw a mouse crosshairs to screen.
The Emscripten runtime still needs its own file, and we need to
convert everything over to `wasm2c`.
|
|
|
|
We now read a `config.ini` from the SDL preference path for
options and parse CLI.
We now also disable `getopt` parsing on platforms that do not
support it, falling back to the `config.ini` system in those cases.
Additionally, carts are read from that directory as well -
allowing us to simplify the build system (as we no longer build
any `.p8.png` files in the `carts` directory).
|
|
We now support pixel perfect scaling (what existed before) as well
as new scaling modes:
- `fill`: Fill fit to output, but keep aspect ratio
- `stretch`: Fill every pixel in the output, may look OK on certain
displays that are close to 1:1 aspect ratio
We also fixed a small mouse position computation bug (we would jump
to the next pixel too early).
|
|
|
|
|
|
We now have two separate "scenes":
- cart selection
- game
In their own modules. Instead of implementing some scene management
logic, we just hardcode the scene logic directly in the `picow`
main module - I don't forsee more scenes and there is no need to
over-engineer at this point.
|
|
We now handle player controller connection/disconnection in a
separate component (since, for scene selection we actually don't
want 1:1 PICO-8 input semantics).
We also added a new `pw_framebuffer` type for managing the
framebuffer that can be written to by PICO-8. The target rect is
updated every frame, and we provide utilities for mapping window
coordinates to clamped framebuffer coordinates (used for the mouse).
Next up is actually implementing the scenes in their separate file,
at which point we can move the FB logic into our stub PICO-8 WAT
implementation and wireup the events correctly!
|
|
Start factoring out controller logic, note that we need to manage
controllers at the app-level and not the scene level, as the
different scenes need gamepad events (for controlling cart selection
and passing to the game respectively).
There are some hacks to work around how the new abstraction does
not exactly fit the previous model, we will fix that up once we
wire up the rest of input handling: PICO-8 needs keyboard and mouse
events only from the host, and they need to be in SDL 1.3 format
(the Emscripten SDL builtin that PICO-8 uses).
|
|
Move path utilities (basename, joining, etc.) to a separate module.
`-h` now prints the basename of arg0 instead of arg0. Avoid some
macros and replace with a small helper function.
|
|
Getting the full PICO-8 bindings working right off the bat is way
too daunting: instead create a small stub so that we can wire up
the WASM code to do the main PICO-8 WASM setup:
1. Build the environment (stubbed out for now, but in theory this
would allocate space to store environment variable strings).
2. Call the `_main` function which sets a "main loop" callback;
making sure to allocate memory for `argv`.
And then the main loop: call the main loop callback function with
the Emscripten `dynCall` builtin and then the PICO-8 specific
audio mixing function; this was determined experimentally by
attaching a debugger to a running exported PICO-8 cartridge.
|
|
We now build STB image library directly in the `cart` module, so
we no longer need to build it as a static library.
|
|
In an effort to split up `picow.c` into smaller modules, add a `cart`
module that includes logic for listing and loading cart files. We
also added multi-cart support (by creating special `.p8.dir`
directories for each individual parent cart that specifies which
carts can be loaded in-game).
Small fixes to the Makefile.
|