📰 newsreader

twostopbits score 1.21 好み 1.25 en

ESP32-S3にFlying Toastersを詰め込む (taoofmac.com)

原題: Shoehorning Flying Toasters into a ESP32-S3 (taoofmac.com)

esp32-s3emulationafter darkretro computingmicrocontrollermacintosh emulationhardware hackingembedded systems
原文 ↗

日本語訳

# タイトル

ESP32-S3に「Flying Toasters」をねじ込む

# 本文

これは、私が自分流にカスタマイズしたCydintosh、具体的にはESP32-S3ボード上で、65 FPSという驚異的な(そして全く無意味な)速度で「Flying Toasters」を動作させることに成功した、ごく簡略化された物語である。今月これほど満足感を得られたことは、他にそうそうない。

なぜか?

そうしたかったからだ。

### アリ用のMac

Cydintoshの存在を初めて知ったとき、私はすぐに手持ちの「Cheap Yellow Display(CYD)」を引っ張り出し、ソフトウェアを動かそうと試みた。しかし、そこで2つの事実に直面した。

- 私のCYDは(予想通り)仕様が異なっていた(解像度は同じ240×320だが、チップがESP32-D0WDだった)

- 所有していた抵抗膜方式のタッチスクリーンは、画面サイズが比較的小さいことも相まって、実用性に欠けていた

確かに動作はしたのだが……判断は皆さんに委ねることにしよう。

(上の写真は、限界に挑戦しようとしていた時のものだ)

実のところ、たとえ適切な1:1ピクセルスケーリングを行い、ポートレート(縦向き)レンダリングを施し、SPIバス経由でいかに高速に画面更新を行うかという独創的な工夫を凝らしたとしても、動作は苦痛なほど低速だった。たとえMac Plusのエミュレーションや基本的なWi-Fiアクセスが、ESP32のハードウェアをエミュレータに露出させるという天才的なトリックによって非常にうまく機能していたとしてもだ。

### さらなるピクセルを

そこで私は、より強力なチップと、まともな静電容量方式スクリーンを備えた、より大型のディスプレイをいくつか注文するという、当然の選択をした。

その結果は素晴らしいものだった。新しいボードは「ESP32-8048S043S」とラベル付けされており、800×480の静電容量方式パネル、ESP32-S3、そして8MBのPSRAMを搭載している。これは、エミュレータと、より完全なバージョンのMac OSを動作させるのに十分すぎるスペックだ。オリジナルのMusashiベースのumacエミュレータを、かなり良好な速度で(間違いなくオリジナルのMac PlusやClassicよりも速く)、白黒のフル解像度(4erb×800)で実行できる。

### システムの改造

しかし、オリジナルのCydintoshのイメージは古すぎた。エミュレータ自体は問題なく動作したが、自分用のフォーク版では、ファームウェアに多くのアップグレードを施す必要があった。

- 複数のボードプロファイルに対応するため、ディスプレイ・レイヤーを書き換え。S3ターゲットでは、480×800のフレームバッファをランドスケープ(横向き)に回転させて実行。

- エミュレートされたMacのRAMを1MBに増量(オリジナルは128KBで、System 3.2を動かすのが精一杯だった)。

- ポートレート/ランドスケープの向き、タッチのマッピング、およびGT911静電容量式ドライバを修正。

- スマートホーム制御(オリジナルプロジェクトの存在意義)を可能にするため、MQTTレイヤーを追加。

- diskマウントが正しく機能するように、Sonyの取り出し要求を抑制するようumacをパッチ。

- ESP32-S3デバイスへの書き込みはそれ自体が一種の地獄であるため、即席のWebフラッシャーとシリアルログ・キャプチャ・ツールを作成。

これに到達するまでには、数週間にわたる夜の作業と、独創的なハッキングが必要だった。

### レジストレーション? そんなの必要ない……あ。

After DarkをSystemフォルダに注入するまでは、すべてが極めて順調に進んでいたのだが……。

テキストを入力する方法が一切ないため(ちなみにKey Capsもこの用途にはあまり役に立たない)、ResEditを使ってコントロールパネルの一部を削除していくという手段に出るしかなかった。最終的には、ダイアログを削除するという容易ではない作業を、Codex(AI)に依頼してINIT(?)リソースを逆アセンブルさせ、ダイアログをスキップさせることで、なんとか動作するようにした。

ファームウェアにいくつかの細かな調整を加えた結果、After Darkをスクリーンセーバーとして完璧に動作させる「本物の」Macが完成した。

ちなみに、トースターの飛行速度は安定して65〜67 FPSである。

これは、1991年当時のMacintosh SE/30で動いていた速度よりも速い。なぜなら、当時のマシンは68030プロセッサによる1ビットの白黒表示だったのに対し、今回のデバイスは、私の最初の3台のコンピュータを合わせたよりも多くのRAMを持つ、デュアルコア2回240MHzのチップ上で16ビットカラーを実現しているからだ。

白黒表示(オリジナルのMac ROMが対応している範囲内だが)とはいえ、決して悪くない出来栄えだ。

### やりすぎる価値は明らかだ

これこそが、私がさらなる「沼」へと足を踏み入れ、別のESP32ボード(P4)を使って、これをLC ROMへ移植しようとしている理由である。判明したこととして、他のボードではカラーフレームバッファを保持するためのRAMが足りず、オリジナル版で行ったデルタ・リフレッシュのハックを実現するための帯域幅も足りず、必要なエミュレーションやシステム変更を行うためのCPUパワーやストレージも不足している……。

移植可能なサイズまでBasiliskIIを削ぎ落とす作業には、まだ格闘している最中だが、当面の間、このボードはデスクの上で、ただひたすらトースターをレンダリングし続け、ふとした瞬間に「手間をかける価値のあるものもある」ということを私に思い出させてくれている。

原文(英語)を表示

This is the (very) abridged story of how I got After Dark running on my own flavour of the Cydintosh–specifically, Flying Toasters on an ESP32-S3 board, zooming along at 65 FPS, which is both completely pointless and one of the more satisfying things I’ve done this month.

But Why?

Because.

A Mac… For Ants

When I first got wind of the Cydintosh, I immediately dug out one of my Cheap Yellow Displays and tried to get the software running on it, only to find out two things:

- My Cheap Yellow Display was (predictably) different (same 240×320, but an ESP32-D0WD)

- The resistive touch screen mine had, together with the relatively small size, made it unusable in practice

I mean, it ran, but… Here, you be the judge:

The photo above was me trying to push the envelope a bit.

The truth is that even with proper 1:1 pixel scaling, portrait rendering and some creative interpretations of how to push faster screen updates through the SPI bus, and even considering the Mac Plus emulation and basic Wi-Fi access worked really well (because of the genius trick of exposing ESP32 hardware through to the emulator), it was painfully slow.

Moar Pixels

I did the obvious thing and ordered a couple more, larger displays with a slightly more powerful chip and proper capacitive screens:

And the results were glorious: the new boards are labelled ESP32-8048S043C, and they come with an 800×480 capacitive panel, an ESP32-S3, and 8MB PSRAM, which is more than enough to run the emulator and a more complete version of Mac OS, running the original Musashi-based umac

emulator at a fairly good speed (certainly faster than the original Mac Plus or even the Classic) and at full panel screen resolution (480×800) in black and white:

System Shenanigans

However, the original Cydintosh image was ancient. The emulator worked OK, but I needed to do a bunch of upgrades to the firmware on my personal fork:

- Rewrote the display layer to support multiple board profiles, with the S3 target running a 480×800 framebuffer rotated to landscape

- Bumped emulated Mac RAM to 1MB (the original used 128KB, barely enough for System 3.2)

- Fixed portrait/landscape orientation, touch mapping, and the GT911 capacitive driver

- Added an MQTT layer so the thing can actually do smart-home control (the original project’s raison d’être)

- Patched

umac

to suppress Sony eject requests so disk mounting worked properly - Built an impromptu web flasher and a serial log capture tool, because flashing ESP32-S3 devices is its own special kind of hell

Getting there took a few weeks of evenings and a bit of creative hacking.

Registration? We Don’t Need No… Oh

Everything went pretty swimmingly until I actually injected After Dark into the System folder:

Without any way to input text (and no, Key Caps doesn’t really work for this), I had to resort to removing bits from the control panel with ResEdit until it mostly worked (removing the dialog was not trivial, and in the end I asked Codex to just disassemble the INIT(?) resource and skip over the dialog).

A few minor firmware tweaks later, I have a “real” Mac that runs After Dark as a screensaver perfectly:

In case you’re wondering, the toasters fly at a solid 65-67 FPS.

Which is faster than they ran on my actual Macintosh SE/30 back in 1991, because that machine was doing it in 1-bit black and white on a 68030 and this is a $15 display board doing it in 16-bit colour on a dual-core 240MHz chip with more RAM than my first three computers combined.

Not too shabby, even if it’s in black and white (which is what the original Mac ROM can handle).

This is Clearly Worth Overdoing

And that is why I have gone down the rabbit hole of trying to port this to an LC ROM, on yet another ESP32 board (a P4). It turns out there’s not enough RAM on the other boards to hold a colour frame buffer, not enough bandwidth to do the delta refresh hacks I did in the original version, and not enough CPU power and storage for the required emulation and system changes…

I’m still grinding through the mechanics of paring down BasiliskII to fit, but in the meantime this board is sitting on my desk doing nothing but rendering endless toasters and reminding me some things are worth the sheer fun involved every time I glance at it.

← 一覧に戻る