Wreckages & missiles
The v0.6.1 version enables ships to repair, restock, and defend themselves.
One comfort that was missing from hex-quartet-or-proquint entity identifiers was being able to specify proquints in ship commands. The default ship OS, manatee, is now able to parse shorts in both hexadecimal and proquint form.
$ hexdump proquint-parse.rom
0000000 4020 4100 4200 4443 4521 4746 4948 4a22
0000010 4b00 4d4c 4e23 0000 4f00 0000 00a0 a000
0000020 1a01 2635 39a4 00a0 2805 0020 9414 8006
0000030 0a60 8004 0b7b 201c 0300 0040 2104 ff40
0000040 24e3 a0b9 0500 2028 0500 2222 0040 a83f
0000050 0020 9431 6180 8019 0400 01a0 3800 0614
0000060 0f80 041c f080 061c 0020 2206 2222 0040
0000070 a01d 1a01 0534 053f 0080 3804 01a0 351a
0000080 4021 cbff 2222 01a0 341a 00a0 6c05 00a0
0000090 a000 0000 006c
0000095
Along with this, command argument parsing was reworked in manatee. While the previous way of returning values on the return stack, and jumping from parsers to an error handling label to pop parsed bytes was really clever, it got too clever and unstructured for my taste. Parsers now write their result to a location they receive as an argument, and the returned length of the parsed word can be used to determine if the parser failed, in which case execution can safely skip forward without leaving the stack unbalanced.
In general, this rework taught me that knowing when not to use the stack while writing uxntal is just as important as knowing how to use it. Writing values out to memory takes little overhead, and it seems to me that it’s worth it if it means the contents of the relevant portion of the stack can be kept as shallow as possible, to keep the code understandable.
Wreckages are the remains of destroyed ships. A wreckage repeats the signal of the originating entity, and contains a portion of the materials the originating entity used to grow beyond its minimum set of modules. These materials can be salvaged using a synth module.
HOST_WRITE_SYN_SAL : &entity $2 ->
Salvages raw materials from wreckages. The entity must be no farther than SYNTH_INTERACTION_UNITS.
Synthesis modules are also capable of repairing and restocking entities.
HOST_WRITE_SYN_REP : &entity $2 ->
If the synth module is idle, sets it to repair an entity's hull, and sets the specified entity as its target. If the entity is farther than SYNTH_INTERACTION_UNITS, the synth module will return to idling.
HOST_WRITE_SYN_RES : &entity $2 ->
If the synth module is idle, sets it to restock an entity's bay, and sets the specified entity as its target. If the entity is farther than SYNTH_INTERACTION_UNITS, the synth module will return to idling.
Missiles are projectile weapons launched by ships that damage the targeted entity’s hull upon impact. They expire and self-destruct if they do not reach their target in time. Missiles are stored in and launched from bay modules.
HOST_WRITE_BAY_LAU : &entity $2 ->
If the bay module is idle, sets it to launch a missile towards the specified entity. If no missile is available, the bay module will return to idling.
The host device now provides utility functions to generate random bytes and shorts.
HOST_WRITE_RNG : ->
Generates a random byte, and writes it to the UXN_PORT_HOST_RNG_LO port of the host device. Writes no other ports.
HOST_WRITE_RNG2 : ->
Generates a random short, and writes it to the UXN_PORT_HOST_RNG_HI - UXN_PORT_HOST_RNG_LO ports of the host device. Writes no other ports.
The code that needed a random number to alter control flow was the sustain state in manatee, in which it tries to extract inorganic materials from a barren world, while repairing and restocking any ships in range. To make sure that it both repairs and restocks entities (because the state machine of synth modules would ignore the second request, as it’s not idling), the ship decides which action to take based on a coin flip.
HOST_WRITE_RNG .Host/write DEO
.Host/rnglo DEI #80 LTH [ ?on-screen/sustain-rng-less ]
( write synth restock command to the host )
HOST_WRITE_SYN_RES .Host/write DEO
&sustain-rng-less
( write synth repair command to the host )
HOST_WRITE_SYN_REP .Host/write DEO
Nav modules can query a radius around themselves to see if there is an entity inside it. They can also query the type of an entity.
HOST_WRITE_NAV_ENT_TYP : &entity $2 -> &entity-exists $1 : &type $1
Attempts to query the type of an entity.
HOST_WRITE_NAV_ENT_GET : &radius $2 -> &entity-exists $1 : &entity $2
Attempts to query an entity within a specified radius.
Note that the current configuration values for entities may be unbalanced, so gameplay may end up being too easy or too hard at this point.
Other notes:
- extract modules now operate with cooldowns instead of accumulators, for easier programmability
- the way module capacities are calculated was reworked for consistency and to reward specialization
- some host device event commands were moved to different indices
- fixed module stats not updating after modules were grown or absorbed
- the zeroeth entity is now a star at the origin, to ward off leviathans from the current spawn point
Files
Get doldrusidus
doldrusidus
An open-ended, obscure simulation realized as a multiplayer universe.
Status | In development |
Author | desertslug |
Genre | Simulation |
Tags | Multiplayer, Space, uxn |
More posts
- Porpoise, chibicc & particlesAug 18, 2023
- Quickstart & first argument insertionJul 30, 2023
- RewriteJul 21, 2023
- Hives, wasps & leviathansJun 13, 2023
- Signals & barren worldsJun 02, 2023
- WormholesMay 19, 2023
- Monoliths & module growthMar 31, 2023
- Habitable worldsMar 24, 2023
- Nav module guidanceMar 15, 2023
Leave a comment
Log in with itch.io to leave a comment.