autc04 / Retro68

a gcc-based cross-compiler for classic 68K and PPC Macintoshes
GNU General Public License v3.0
537 stars 51 forks source link

Rez gets stuck compiling FONT #250

Open briankendall opened 1 month ago

briankendall commented 1 month ago

I've attached a rez file containing the definition of a FONT resource, as decompiled by MPW's DeRez. If I try to compile it with Retro68's version of Rez and give it the correct header search paths so that it can find SysTypes.r from Apple Universal Interfaces 3.4, then it'll get stuck and run indefinitely.

(Luckily it's not hard to work around since if I don't include SysTypes.r when running DeRez it'll export the FONT as just binary data, which compiles fine.)

test.r.txt

autc04 commented 1 month ago

Diagnosis: Rez miscalculates an array size and starts meditating about a gigabyte-sized FONT resource. Some unoptimized code that was never intended to deal with more than a few megabytes follows, so it seems stuck.

The reason for miscalculating it is that the array size is calculated from reading back parts of the already-written output, which the architecture I came up with for my Rez 10 years ago doesn't really support. At the very least, I'll have to rearrange some things in the code, so this will not be a quick fix.

Currently, Rez runs as in two passes; the first pass is supposed to lay things out and generate an intial version of the resource; the second pass then fills in things that depend on the first pass, such as $$CountOf, $$Word, $$Bitfield. This works nicely for the more common pattern where some integer in the resource is defined to be an array count or an offset, but it fails horribly for the FONT resource, where an array size is calculated in a non-trivial way.

That will have to be changed...