Skip to content

6502: Added Apple II support - #89

Merged
dstelzer merged 21 commits into
Dialog-IF:mainfrom
sehugg:apple2
Aug 25, 2026
Merged

6502: Added Apple II support#89
dstelzer merged 21 commits into
Dialog-IF:mainfrom
sehugg:apple2

Conversation

@sehugg

@sehugg sehugg commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Here's the Apple II port:

  • Supports Apple II+ and later models
  • 64 or 128 kB
  • 40 or 80 columns
  • Aambundle builds 140 kB and 800 kB ProDOS-format disk images
  • No actual ProDOS system image is needed
  • Save/restore is supported with only one slot at the moment
  • The bundler generates a readme.txt explaining things
  • Run "make -C test apple2" for unit tests

It needs the ACME assembler to build and the izapple2 emulator to run (optional) tests, but the makefiles will prompt for those if not found.

There are a couple of updates to engine.s but those should not affect anything in the C64 port. Part of the engine is split into the $d000+ language card area so there's no elegant way to do that.

I started this port against full ProDOS, but it was low on memory, so moved to the ProRWTS2 sector loader. You can still define PRODOS=1 and PRORWTS=0 to enable the full ProDOS port but it should be considered unsupported (but might be handy to compare against if bugs come up.)

Have tested on a few emulators (izapple2, Virtual ][, 8bitworkshop) but my real Apple ][+ is in storage :(

(Also a minor fix in aambundle: Stories without a title in their metadata are given the base name of the story file.)

@sehugg
sehugg force-pushed the apple2 branch 2 times, most recently from 90fadee to c7c9787 Compare August 24, 2026 12:24
@dstelzer

Copy link
Copy Markdown
Contributor

This looks absolutely fantastic! I'm going to give it a once-over and try to test it as best I can, but I'm mostly just going to assume this works, since I don't know much about the Apple II environment.

@dstelzer

dstelzer commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

A couple minor things:

The licenses for things like the trackloader should be added to license.txt in the root of the repo. That's where fake6502 and jquery are, for example.

I love how the Makefile suggests install commands if tools aren't found on the PATH. We should start doing that for the rest of the Makefiles!

I also appreciate your extensive comments. I wish Linus had done the same!

Building via Makefile produces this:

Warning - File a2_prorwts2.acme, line 3766 (Zone <untitled>): !warn: floppy code: 53248 (0xd000)-54237 (0xd3dd)
Warning - File a2_prorwts2.acme, line 3767 (Zone <untitled>): !warn: floppy data: 54272 (0xd400)-54527 (0xd4ff)
Warning - File a2_prorwts2.acme, line 3768 (Zone <untitled>): !warn: floppy dirbuf: 54528 (0xd500)-55039 (0xd6ff)
Warning - File a2_prorwts2.acme, line 3770 (Zone <untitled>): !warn: floppy encbuf: 55040 (0xd700)-55551 (0xd8ff)
Warning - File a2_prorwts2.acme, line 3773 (Zone <untitled>): !warn: floppy treebuf: 55552 (0xd900)-56063 (0xdaff)
Warning - File a2_prorwts2.acme, line 3775 (Zone <untitled>): !warn: floppy driver start: 625 (0x271)
Warning - File a2_prorwts2.acme, line 3908 (Zone <untitled>): !warn: hdd code: 53248 (0xd000)-53723 (0xd1db)
Warning - File a2_prorwts2.acme, line 3912 (Zone <untitled>): !warn: hdd dirbuf: 53760 (0xd200)-54271 (0xd3ff)
Warning - File a2_prorwts2.acme, line 3914 (Zone <untitled>): !warn: hdd encbuf: 54272 (0xd400)-54783 (0xd5ff)
Warning - File a2_prorwts2.acme, line 3917 (Zone <untitled>): !warn: hdd treebuf: 54784 (0xd600)-55295 (0xd7ff)
Warning - File a2_prorwts2.acme, line 3919 (Zone <untitled>): !warn: hdd driver start: 1617 (0x651)

Is it anything to worry about? Or is that just info?

CLAUDE.md is inaccurate in a few respects. test/familiar is not currently used (and should probably be removed). Updating the version numbers can be done with bin/bump_version.sh which keeps all the version numbers in sync. The Asciidoc version of the spec is authoritative if the two get out of sync.

@dstelzer

Copy link
Copy Markdown
Contributor

A few more serious issues:

  • Only the top line of the screen is drawn in reverse-video, even when the status bar is more than one line tall
  • A [more] prompt is not printed when the screen is overfull, which means if the game prints too much text at once, the start of it is lost

Also, another minor thing: Dialog's Z-machine runtime includes fallbacks for a number of non-ZSCII Unicode characters: NBSPs (00A0, 202F) display as a space, en-dash (2013) displays as -, em-dash (2014) displays as --, curly-quotes (201C, 201D, 201E) display as ", bullet (2022) displays as *, curly-apostrophes (2018, 2019) display as '. It would be nice for the Apple II backend to include all of these as well. Currently, 202F, 201E, and 2022 are missing.

I see in the comments you've thought about using MouseText for a pretty progress bar. That would be a great enhancement, but I don't really see how MouseText would be useful for that—a long arrow, I guess? It's so limited compared to the box-drawing character sets I'm used to…

@dstelzer

Copy link
Copy Markdown
Contributor

Sometimes the progress bar doesn't seem to work:

image

That should be a 19/25 progress bar at the bottom, same as at the top.

@sehugg

sehugg commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Good feedback, I'll make a story to reproduce these issues and fix. The Apple 2 version uses ROM routines for printing but I think it can do everything as long as we have a rectangular window. I left styling out (b/c we only have inverse and flash) and just assumed inverse is used for status areas if that's reasonable.

I think I considered MouseText before I looked at the full character set (the little running guy is cool but maybe not appropriate!) Maybe there's still something useful there, or maybe it can be used for of a few of the Unicode characters. If we relax the no-self-modification rule we can patch at init time and it won't take much extra RAM.

@dstelzer

dstelzer commented Aug 24, 2026 via email

Copy link
Copy Markdown
Contributor

@sehugg

sehugg commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Good luck on your entry!

BTW is that drawn with (inline status bar)? If so I think neither interpreter supports that feature right now.

@dstelzer

Copy link
Copy Markdown
Contributor

Thanks!

This one's not an inline status bar, just a normal (progress bar $ of $); it seems like inline status bars (correctly) don't show up at all.

Unfortunately due to IFComp rules I can't actually post a link to the .aastory file here; send an email to dsdraco7@gmail.com and I'll send it over.

@sehugg

sehugg commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

I'll also add all the other codepoints that the C64 version supports with a glyph, there's about 23 of them. Makes sense to have parity between the two ports. I can commit a test story for codepoints if that's useful.

There's also a thing with non-breaking spaces I have to chase down, I think on the 6502 they were getting dropped.

sehugg added 19 commits August 25, 2026 13:43
- Supports Apple II+ and later models
- 64 or 128 kB
- 40 or 80 columns
- Aambundle builds 140 kB and 800 kB ProDOS-format disk images
- No actual ProDOS system image is needed
- Save/restore is supported with only one slot at the moment
- Run "make -C test apple2" for unit tests

Aambundle: Stories without a title in their metadata are
named after the base name of the story file.
@dstelzer

Copy link
Copy Markdown
Contributor

Wow, that's a lot of commits! You mention in a few places that there may also be problems with the C64 version—where are those in particular?

@sehugg

sehugg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

So the new "codepoints" test runs through a bunch of transliteration and word wrap edge cases, and a few problems are specific to Apple II but a few are in C-64 and even aambox. Things like counting dual-character translits, not adding spurious new lines, not flushing the buffer properly, handling non-breaking spaces properly. The C-64 also has a lot of missing glyphs and translits. And I'm not sure about a lot of stuff like status bar heights (they always seem to be 1)

There was a problem with all frontends where the NBSP opcode was being ignored, so I changed it to a breaking space. The "proper" fix might impact savefiles so a little more complex. But that's the only non-Apple II fix in this new batch.

The C-64 can be brought up to par but I thought that would overcomplicate this PR. I made a lot of little commits here so it'll be easier to trace back the changes later. I didn't want the Apple II port to get too far ahead.

I also added an izapple2 test on Github which doesn't block anything, just informative.

@dstelzer

Copy link
Copy Markdown
Contributor

Hmm, I think something is wrong. I cloned your repository into an entirely new directory, switched to the apple2 branch, built aambundle via make, and used that to build a new version of my disk image, but I'm seeing the same problems as before—inline progress bars are always empty, there's no [more] prompt, and the second row of the status bar is not reverse-video.

It also says "Aa-machine 1.0.2" when I load the disk, so I suspect I have an old version somehow. How do I get the latest version to test?

@dstelzer

Copy link
Copy Markdown
Contributor

Ah, had to make clean before make. I don't know what files were lingering around that shouldn't be, but it's better now. Yes, this is looking good!

@sehugg

sehugg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Weird ... maybe you have another copy of aambundle in your path? I guess the first thing would be to check timestamps on everything.

@dstelzer

Copy link
Copy Markdown
Contributor

Yeah, I'm honestly not sure what was going wrong. I was calling aambundle with an absolute path, and git status doesn't show that any tracked files changed. Something must have been left around from an earlier build.

But this all looks good now! If you're ready to merge, I'll merge it.

@sehugg

sehugg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Another thing: The Apple II has a hardcoded transliteration table (codepoint -> 0, 1 or 2 chars) which is to compensate for not being able to define its own fonts. Here's the current table, which includes (I think) the C-64 extended glyphs:

a2_translit.txt

Is there an offical list of supported codepoints besides the Z-machine list? I guess dedicated story authors could hack it to add their own custom glyphs/translit table.

@dstelzer

Copy link
Copy Markdown
Contributor

The most official list is fontdef.txt, which is used to build the C64 interpreter (with its custom font). But that list is deliberately easy to add to, so it may change in the future.

@sehugg

sehugg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Okay, makes sense. Yeah, I'm ready to merge. Good luck with your game and I hope you consider an Apple II release :)

@dstelzer

Copy link
Copy Markdown
Contributor

Oh, I absolutely will!

@dstelzer
dstelzer merged commit 42ef8a5 into Dialog-IF:main Aug 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants