Lower Decks II (WIP): Warp Drive - 1-4 player!

Talk about your programs in progress. Discuss how to implement features, etc.
Forum rules
This section is for testing Commander X16 programs and programs related to the CX16 for other platforms (compilers, data conversion tools, etc.)

Feel free to post works in progress, test builds, prototypes, and tech demos.

Finished works go in the Downloads category. Don't forget to add a hashtag (#) and the version number your program was meant to run on. (ie: #R41).
Post Reply
voidstar
Posts: 503
Joined: Thu Apr 15, 2021 8:05 am

Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by voidstar »

WORK IN PROGRESS

Try It Now!

EDIT: 2024/05/12 VERSION 2 UPDATE
Think have the gamepad-jittery issues resolved, added background audio (randomizes the playback rate between rounds).
Added PAUSE (via pressing START) and SELECT now toggles hard-mode.


Remember to pass -joy1 or -joy2 or -joy3 or -joy4 to enable gamepad in the emulator (or try passing all of those). You can play with "gamepad0" (keyboard) as well.

I'm trying to stick to "regular BASIC" usage as much as possible, not much fancy peek/pokes - as an interesting style and challenge of coding on the X16. Although I do plan to use the ZSMKIT for some audio. But I need to learn a bit more about ZSMs - although if anyone wants to take a stab at making some sound FX, a stock repository of some sound effects would be a nice thing for the community (and maybe toss them onto future SD card updates).



Lower Decks #1 was about PMS... Power Management System!! It's in the BASIC-GAMES folder and is a "requires-mouse" X16 exclusive.

Lower Decks #2 is about the Warp Drive!

How To Play

The job is to match both the WARP and POLARITY settings on the left with the TARGET values on the right. Those TARGET values will change each time the hourglass becomes full (actually there is a bit of delay once the hourglass becomes full, to keep it a little suspenseful on how much time you have left). Basically when the hourglass becomes full, it's an intermission time while the Captain is waiting for new orders and deciding the new warp speed.

What most don't realize about warp drives is that the "density" of space changes across regions. So that's why the polarity changes, and to get a stable warp field the polarity has to match. And it's why even for the same warp speed, you may need a different polarity setting.

WARP speed request can go 1-8, while POLARITY can go 2-64. (cause, you know, 8-bit computer and 64K address space)

Dilithium crystals are the fuel of warp drives, but you can't touch them by hand! So the ship has these special controls to move crystals over to the warp drives. Like all crystals, they grow at varying speed. Larger crystals impact the warp field greater than smaller crystals. You select (using <A>) a crystal from the 16 chambers at the top. Move left/right with the game D-pad, or the L/R buttons at the far edge of the gamepad.

Only one player can select a chamber at a time. Once selected, then you decide what to do with the crystal (after selecting with <A>, your focus then switches to either the Left or Right nacelle - then use up/down on the D-pad to select what action, and <B> to select that action). Actions are: You can toss it into the W+ to increase the warp speed, or P+ to increase the polarity. Alternatively, you can dissolve crystals by tossing them into the W- to decrease the warp speed, or P- to decrease the polarity. How much is increased or decreased just depends on the size of the crystal you used.

Once a crystal reaches the size of its chamber, it can start to rot and go bad. You'll have a few moment, but once it becomes black, it becomes a dead crystal and has to be dissolved before anything else in that chamber can grow. Use button <B> to dissolve dead crystals. This is why you might need other players, to just help dissolving dead crystals. Or, one player can focus on Polarity while another handles Warp. All up to the team!


And that's it! You don't have to match the TARGET warp and polarity exactly. When the graph at the bottom is GREEN, the warp field is stable and you'll earn a point. When yellow, it's a warning, and you neither gain or lose a point. When red, the target parameters aren't reached and you may break the engines! (so you lose a point, for each plot of this status). The accumulated points are applied to the score at the end of each hourglass round.


A couple strategy hints:
- when a chamber is selected, that crystal won't grow. So other players can "hold" a crystal at a certain size, which can help.
- you can dissolve aged crystals early (anytime the edge starts changing color from magenta). Eventually you'll need small crystals to tiny adjustments, so it's good to keep a mixed variety of growth.

- SELECT enables HARD-MODE!! In this mode, rotted crystals start to destabilize your warp field.
- START is used to PAUSE

Pretty silly, but it's a demo of something that can be done with BASLOAD :) Plus I just wanted to see if a 4-player gamepad game could be made in BASIC (what I mean is, at 8MHz is it enough performance to poll and react to that much input). So far it does have a little bit of jitter gameplay issues, I may have to drop down to 2-player only (and the code is setup to be fairly easy to do that). I also wanted up-to-4-players to be able to join the game at any time.


EDIT: Better just get the ZIP since the PRG now depends on a few external files (font and zsm)
Attachments
LOWERDECKS2.BASL.TXT
(25.98 KiB) Downloaded 214 times
LOWERDECKS2-V2.ZIP
(97.56 KiB) Downloaded 224 times
LOWERDECKS2.PRG
(9.92 KiB) Downloaded 177 times
lowerdecks2.jpg
lowerdecks2.jpg (114.83 KiB) Viewed 3267 times
Last edited by voidstar on Sun May 12, 2024 11:01 pm, edited 3 times in total.
__sbrk
Posts: 2
Joined: Tue Apr 02, 2024 9:35 pm

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by __sbrk »

> Dilithium crystals are the fuel of warp drives

Well, according to ST cannon, they moderate the reaction between matter and antimatter. So, not the fuel. :-)

https://memory-alpha.fandom.com/wiki/Dilithium
voidstar
Posts: 503
Joined: Thu Apr 15, 2021 8:05 am

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by voidstar »

But, but... The third paragraph, it says "Housed in a dilithium crystal converter assembly, the crystals were used as a power source as well as a regulator." That chamber is the "dilithium crystal converter assembly" :)
(and "fuel" to me is just generic for any power source, not necessarily liquid or gas- but true, not everyone views it like that)


New version updated!! Should be stable on physical hardware now.
- added some audio
- adjusted some "aging" parameters (sometimes the "Aging" would be darn near zero, so they'd barely ever grow).
- ZSM kit plays background audio, and changes the playback rate between rounds just for some variety.
- Can PAUSE and toggle HARD-MODE at any time (instead of waiting for round 10), and a few cosmetic updates (like now have a background color for the "warp wave function" at the bottom).
- Can also press ESC to end (except then you can't RUN again because I don't unload the ZSMkit, so if you RUN again in stomps on itself - better do "REBOOT").


Had to do some tricks to tame down the "jittery" issue of polling gamepad buttons. Basically once you select a chamber (with [A] now, not [X]), I have to wait till I detect [A] has been released (unpressed) before allowing [A] to be counted as pressed again. Otherwise it was just flipping state too fast (same for the PAUSE button).
TomXP411
Posts: 1788
Joined: Tue May 19, 2020 8:49 pm

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by TomXP411 »

voidstar wrote: Sun May 12, 2024 10:19 pm But, but... The third paragraph, it says "Housed in a dilithium crystal converter assembly, the crystals were used as a power source as well as a regulator." That chamber is the "dilithium crystal converter assembly" :)
(and "fuel" to me is just generic for any power source, not necessarily liquid or gas- but true, not everyone views it like that)
Obviously, that's a wiki, written by fans and amateurs.

The thing is - not even the writers fully understood how a lot of Star Trek's technology was supposed to work, and they were often even less conversant in real-world physics and how that would affect how technology worked on the show.

Simply put: TV writers are kind of dumb, and while they may understand things like dramatic tension, they were NOT physicists, rocket scientists, or computer scientists. (Hence the reason so many computers self-destructed by being fed logical conundrums.)

According to the TNG Technical Manual, which goes into some detail, it works a bit like this:

The ship stores a quantity of deuterium fuel (Hydrogen-1 isotope) and anti-deuterium. The deuterium is actually an isotope of hydrogen with one neutron. (necessary in order to make stable isotopes of larger elements via fusion, for the fusion engines.) The ship stores a lot of deuterium, since it powers the auxiliary fusion reactors and the impulse drive. (These are fusion reactors, similar to the Tokamak reactors actually being built and tested today.)

The other fuel component is anti-deuterium. This is the antimatter part of the matter-antimatter reactor. Anti-deuterium is manufactured from deuterium using a matter collider or linear accelerator. Basically, antimatter is mass produced using giant, solar powered plants in orbit around the sun and other stars. The amount of energy collected is massive, since it takes gigajoules of energy to make even small amounts of antimatter.

So now we have matter and antimatter: the trick is to convert these to energy. This is what the antimatter reactor does. Anti-deuterium and deuterium are injected into the warp core, where they annihilate each other. This releases all of the power of both atoms as pure energy (E=MC²).

So far, this part is all real science. Physicists can actually make microscopic amounts of antimatter today, using colliders, like the Hadron.

The fiction part is "dilithium": the dilithium crystals channel the energy released from the antimatter explosion, creating something called "electro-plasma." The electro-plasma is used to directly power the warp coils, and it can also be run through "plasma inverters" to create AC and DC electricity, for running ship's equipment.

So in this fictional anti-matter reactor, the dilithium acts as a catalyst, absorbing and converting the raw energy from the antimatter reaction into electricity.

Early on, Star Trek's writers had not firmly established this theory, yet, and so they though that dilithium acted as fuel, which would be depleted, much like the uranium or plutonium in modern-day fission reactors. It wasn't until later that Trek writers researched some of the actual science behind antimatter and fusion power and better developed the theories behind the warp and impulse drives in the show.
mortarm
Posts: 302
Joined: Tue May 16, 2023 6:21 pm

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by mortarm »

Wow, this takes me back to the golden days of ST fandom ('70s-'80s) when I was a hard-core ST fan of everything technical. I miss those days.

LL&P! \\//
voidstar
Posts: 503
Joined: Thu Apr 15, 2021 8:05 am

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by voidstar »

I'm thinking Lower Decks #3 will be the Transporters - it'll be my excuse to exercise the user port, to "teleport" bytes from one X16 to another (trying to resist buying yet-another-ESP32, or throwing more hardware onto an already expensive kit). But I'll have to PEEK/POKE it. Annoying since even the OG VIC-20 had serial IO from BASIC. Hoping Michael Steil can re-engage to resurrect those aspects of the ROM. The CCGMS source seemed pretty close to what was needed.

And thinking #4 will be manually operating the deflector - and my excuse to actually use some sprites. Of course, just deflecting things willy-nilly out of the way will probably eventually push those things into crashing into other planets. It's sort of why I worry about asteroid mining, and it inadvertently altering our orbit. Who knew the orbit of Vesta was actually important at holding us steady :) But there is a pretty wide margin on the distance from the sun we can handle.

Actually #4 might just be a docking sim, that might be an easier starter on using sprites.
TomXP411
Posts: 1788
Joined: Tue May 19, 2020 8:49 pm

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by TomXP411 »

voidstar wrote: Mon May 13, 2024 6:50 am I'm thinking Lower Decks #3 will be the Transporters - it'll be my excuse to exercise the user port, to "teleport" bytes from one X16 to another (trying to resist buying yet-another-ESP32, or throwing more hardware onto an already expensive kit). But I'll have to PEEK/POKE it. Annoying since even the OG VIC-20 had serial IO from BASIC. Hoping Michael Steil can re-engage to resurrect those aspects of the ROM. The CCGMS source seemed pretty close to what was needed.
This seems like a good use for the new Serial/Network card (or the Calypso.)

We probably should consider a serial API, but the problem at this point is that there are already 3 different serial/network devices, and each requires different code:
  • The Serial/Network card uses the TI UART at up to (almost) 1Mbps.
  • The MIDI card can also be used as an X16-to-X16 or X16-to-PC device, but has a different baud generator with different speeds
  • Calypso and VERA ESPecial use VERA's SPI pins to talk to an ESP32
Having said that... it seems reasonable to provide a default driver for 16550 compatible UARTs with maybe a vector that can point to a jump table in RAM for custom port drivers.

At the very least, I'm hoping we can build a standard serial API that everyone implementing serial and network drivers can follow.
voidstar
Posts: 503
Joined: Thu Apr 15, 2021 8:05 am

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by voidstar »

I just want to use the VIA2 that the system already has (including the Otter16). No need to spend another $30+ on something the system can already do (granted, at only somewhere between 2400 and 9600 baud). The premium price of PR boards is fine, as long as there is software value there.

Other than streaming pure-data (files) for updating versions of stuff straight to the SD, the speed doesn't mean much since BASIC itself will be extremely throttled down on how much data it could process and do anything meaningful with (like drawing game-state updates in response to that data, or interpreting terminal codes). (I suppose the VERA SPI maybe it can write direct to VRAM, so there might be some effects there to take advantage of)

I still think actually using the UserPort would just give the system more value, than tacking on more hardware that drains even more power.
TomXP411
Posts: 1788
Joined: Tue May 19, 2020 8:49 pm

Re: Lower Decks II (WIP): Warp Drive - 1-4 player!

Post by TomXP411 »

Well, I guess if you're writing this in BASIC, people can modify your netcode for whatever device they choose.
Post Reply