Jump to content

Phantasia (Atari 7800 ARPG)

Recommended Posts

  • Big merge of some feature branches for improved multi-threading (despite that race condition bug that persists) and beginnings of inventory subscreens
  • tidying up player data references
  • fix up UI drawing bits in graphics ROM and made a few changes to take advantage of the new layout
  • added some item art and alternate art for items in different states
  • Game Select button, or similar buttons on some controllers, should toggle opening the subscreen
  • impossible-to-exist items now display as a particular item rather than garbage
  • enhancement to allow Quest Item names to be specified
  • broke the fix from last week for the upper status area without the player — unclear why, re-opened that ticket…
  • macro for fixed-length text, but not using it any more
  • tidy and enumerate items, identifying the graphics drawing needed for the subscreen
  • labels on some anonymous branch targets (+/-) for added clarity
  • general documentation in the code
  • fix for DetectSaveKey
  • .Mul macro now has optimized case for ×20, but not using it any more
  • Tidy up front buffer/back buffer for display lists a bit
  • Palette re-arrangement to make item selections nicer
  • detect SaveKey/MemCard/AtariVox device
  • tidy up label generation in source code generated from scripts
  • remove duplicate WSYNC in NMI/DLI
  • remove some unused/unloved/unwanted junk files
  • ensure that CurrentBank is stable before actually changing the bank
  • warn and correct if we are not in the script bank when we should be
  • signal an error if ScriptYield detects we're in the wrong bank
  • æsthetic improvements when reading aloud to AtariVox (on PC)
  • updates to the map on the Hero Ship

unfortunately, the big bad bug — a race condition in which we try to return from a subroutine and discover that the memory bank selected has been changed from what we wanted — remains in play.

  • Like 2
Link to comment
Share on other sites

Well, this was a weird week's work, including doing a very convincing 6502 implementation of a Dijkstra concurrent locking algorithm before tossing it away for a simple spin lock, but the crazy annoying bug is gone, so is the concept of an “NMI thread,” and the problem turned out to be a race condition in which one thread would try to change its thread context (e.g. yield up control to another thread) while we were in the critical section of that same thread-context-switching on another thread — and putting a semaphore around it was just exactly what the doctor ordered. The NMI thread had to go, though, because it could deadlock, and (as it turns out) we don't want to do too much in the NMI itself, all the fun stuff happens in the other threads (main, script, and stagehand).


So, this week's updates…


In Skyline-Tool …

  • Cleaned up some things in Skyline-Tool, including compiler warnings and missing functions, that sort of thing.
  • Enhanced support for “best fit” or “imperfect” mode for converting full-screen/large bitmaps from PNG to 7800 — the --imperfect option can be passed to allow it to choose the best palette possible from among the 8 palettes you've provided for each 4×16 px cell.
  • Fixed a bug where SpeakJet phrases were not terminated properly
  • When reading from a core dump file, decode the DLL for the screen currently being displayed (front buffer) not composed (back buffer) by default
  • Decode character states (ActorAction) for all defined actions, including “Panic” — this enables you to use the core analysis of the decals in the scene to find a character which is panicking because of e.g. a minor fault STUK signal — that is: When an actor can't navigate the scene, their action changes to “Panic” and they log a minor fault STUK, by watching for minor faults in the debugger, now the designer can find out which actor is in Panic mode and trace what course they weren't able to navigate.

In the game runtime:

  • Shaved a couple of bytes off DebugBreaks sometimes
  • Implemented simple semaphore locking around critical section of thread context switching
  • Added labels for the main service routines at $8000
  • Fixed the (mis)use of the NonTilesetBank value that was causing issues
  • Removed some code that I'd marked as “suspicious” ages ago, and found that it actually did nothing at all
  • Wait only for VBlank to start, not to end, before certain actions
  • Log a minor fault if we ignored an NMI
  • Whenever a minor fault occurs, flash the stats section of the screen's background to red
  • Zero out DLL immediately upon starting to compose a new frame
  • Fixed a few front-buffer/back-buffer confusions in the code
  • Fixed some bad pointer arithmetic in a couple of places
  • Corrected the make ready target, which would fail if your user account did not already have a ~/.local/share/fonts/ folder; and made a “fix-up” routine to detect machines that I'd mucked up and correct them. (The font it was trying to install ended up as ~/.local/share/fonts, as a file, not a folder, confusing everything.)
  • And (and I thought I'd posted this previously, but I guess not?) — ensured that the stack is reset thoroughly when we're drawing the Break screen, as failure to do so could cause the break screen to, itself, crash.

I'm going to cauterize some other references to the NMI thread, tonight, and perhaps work also on a bug that's causing the upper stats area to be ridiculously oversized; then, back to dealing with particle systems and weather.

  • Like 1
Link to comment
Share on other sites

With the race condition sorted, I have finally been able to start cleaning up the NMI procedures themselves, and abolishing the concept of an NMI thread was definitely the right thing to do.



  • Remove old NMI thread references
  • Actually call FadeBrightness for fade in/out to/from black/white
  • Fix for setting weather (missing a # in generated assembly)
  • Set up A7800 watchpoint traps for accesses to garbage memory to ignore harmless accesses caused by using BIT to skip instructions


  • Removed NMI stack and other materials related to the NMI thread
  • Fixed top-of-screen spacing
  • Better way to determine if the player is present in the scene
  • Implemented stack canaries to detect stack overflows
  • Cure “too much” background color bleeding out of speech balloon's top
  • Reduced use of generic/shared variables further
  • Identified some unused vars to reclaim some RAM
  • Improved reading/responsiveness for user controls
  • Initialize all fields for the player on new game
  • Cured a bug where the player's gender was … animated? … I'm sure this was a debug thing, but the number of animation frames was being written to the address currently used for player's gender, which must have been something else in the past — and it's really, really unusual for me to hard-code a specific address into the code like that
  • Fixed a tense-of-verb error in the test script for pronominals (he is vs he was e.g.)
  • SubWordInto macro is basically an impl of x ← a - b to complement SubWord which is a ← a - b (where a, b, and x are 16-bit words)
  • Use a constant for the BIOS address / upper threshold of built-in RAM
  • Started populating animation sequences for some of the NPC characters whose frames were already drawn
  • trimmed the number of rows of the map visible on the screen at a time, such that it doesn't just roll off the bottom of the screen. (There will now be a small black margin at the bottom of the screen.)
  • optimized the code for plotting dialogue lines a bit (We have to word-wrap on the fly, because sentences can contain variables, e.g. the player's name, that can expand to varying lengths)
  • ensured that the Stagehand routine ("OS") does not pass control to a routine in a different memory bank while Maria is drawing from one bank.

At the same time, @Zephyr Salz's working on some maps and script changes


This week-end, or next week, we're expecting to

  • tidy up some background color issues related to the DLI/scheduling fixes
  • finish up a few scripts for opening section cut scenes
  • actually map out the animation sequences for all the NPCs that have been drawn already (assign frames to sequences and sequences to character + action), including “generic humans” and main characters (who have specific, bespoke art frames)
  • implement functions for a few new stage directions
  • fix up the weather system to actually work (for rain, at least)


  • Like 4
Link to comment
Share on other sites

Ah, what a long week-end — ! We did make a good deal of progress, though.

  • fix for centering the camera on the right point in some circumstances
  • ensure that DLIs occur the same before, during, and after stats updates
  • pinhole optimizations
  • wait out last row (of map tiles) better
  • animation sequences for generic humans in robes
  • fixed palette register assignments for speech balloons
  • actually seed random numbers properly
  • rainfall working (part of the effect works, at least, there are some more details to come)
  • made dialogue balloon slightly narrower
  • moved scrolling code to banked ROM to free up wired (last bank) space
  • began support for palettes shifts for fade in/out &c
  • sorted out palettes across most all of the artwork to be in sync with each region
  • fixed stats updates (including place name display for cut scenes)
  • Tidy up display list interrupts around narration text

Also a few bug fixes in Skyline-Tool, mostly related to the palette shuffling details.


We still are working on some scripts and scripting commands even, and a few NPC sequences may not be assigned yet, but we've made great strides in both.

  • Like 2
Link to comment
Share on other sites

Week-end update …


Phantasia runtime improvements:

  • Navigation for characters is now via a Course object, of which there is currently only a very naïve implementation, but we have plans to implement a couple of alternative classes for various character types in future. This was actually a pretty big lift and worked out some parts of the Object-Oriented system that had not been exercised before, so we fixed some edge cases there.
  • New lighting features (partially implemented). We're taking the palette for each tile set, and using relatively high-quality color code running on the PC at compile-time, pre-calculating various tinted versions (dark, light, &c) of each color. These alternate palettes are available immediately for use via scripts; e.g. a script can say “It is night.” and the scene will be dimmed slightly with a small loss of saturation.
  • Work in progress is to take advantage of the CoLu colorspace of the 7800's native palette to enable fades between the normal palette, the tinted (e.g. dark) palette, and the extreme solid colors (e.g. “Fade to black.” will fade from the normal palette, to the dark palette, on its way to fading to black entirely.) There are some weird bugs in this area still being resolved, and I probably won't be working on them today. Bugs include it flickering like candlelight as it argues with itself whether to make the scene 1 unit lighter or darker every few frames, or just plain turning the scene weirdly-mis-colored…



Just a mess


  • Added a scripting command to bring up the title screen
  • Added minimal implementation of Game Over — you lose/you win. (Very minimal)
  • Tidied up some DLI's related to narration
  • Ensure that scripts yield to the main thread when they're not busy
  • Added a bunch of arbitrary words to the SpeakJet dictionary, which now clocks in at 2.434 words in an American accent (For referenece, a fourth-grade vocabulary is around 4,000 words, but we have any number of imaginary or unusual words and names in there, so that isn't quite a fair comparison.)

Skyline-Tool improvements:

  • Fixed some UI type things: clearer output for errors and reporting of successes
  • The UI now decodes Course objects
  • Upgraded to the latest McCLIM toolkit with improved TrueType font support for nicer output, but incidentally all the font sizes are (for now) slightly larger. This also fixed an annoying bug where small gaps appeared in some "fat bits" type pixel displays in the GUI. It did create a bug where some of the table displays look a little “off” from the GUI, but they look fine in a terminal (see the “Instance of Character” section in the screenshots for an example, or the palette explanation below the “Show Decal” example.)
  • image.thumb.png.c756f42fd34237a78699259789792a47.pngimage.thumb.png.75e8d8cff2899f8d7ae1fe36cbb32df7.pngimage.png.42cbd253b8272d8c12e388dd3ff751a3.pngimage.thumb.png.ca58f84e63b997337cf14d17bd8b9e4d.pngimage.thumb.png.f78ed23e76573aab6766b3c9dbda3abb.pngimage.png.15f300f179ff5f7d60cbb26a5719ec61.png
  • Tweaked the YACC grammar for stage directions to avoid some complaints it was presenting.
  • Began to implement a “prepare scene” stanza for scripts to avoid “pop in“ of characters. Essentially, the author will write something like “We open on: … ” in the script, and the system will suppress page flips (between the back buffer and front buffer display lists) until the author has enumerated what the scene looks like, e.g. where any characters might be standing.
  • The names of the 12 “fixed” colors (four upper palettes that are available from any tile set) are now taken from Project.json, so they can be renamed for other projects' use in future. (This is part of the slow walk out of making Skyline Tool more generally useful to others.)
  • Various bug fixes and tweaks.
  • Fixed the make install target (Linux®-only) to add the icon to the Activities Overview applications library — somewhere along the line, the icon got lost, although it is very Phantasia-specific right now and we'll want to improve upon that.





Link to comment
Share on other sites

Another week, a little more progress.



  • Force-apply lighting (palette) changes when needed immediately
  • Commands for waiting for the scene to be ready before the first page flip
  • Support for multiple bodies within a block of NPC graphics, including generic humans


  • Runtime support for lighting changes (fixes)
  • Deferred page flip support in the runtime as well
  • Decoding new animation sequence "body" discriminator — animation sequences are now based on a Kind, a Body number, the Facing direction, and the Action, with fallbacks.
  • Tidied up some unnecessary code
  • Lightning test
  • New text for the "Interworldly" author card
  • Began working on the "real" title card to replace the current placeholder


And, what's this?


  • Like 4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...