lifepillar / homebrew-appleii

Homebrew formulae for anything related to Apple I, Apple II, Apple ///, and Apple IIGS emulators.
54 stars 6 forks source link

ARM c2t Formula does not work #37

Closed Garrett-Bodley closed 7 months ago

Garrett-Bodley commented 7 months ago

Hello!

The binary that is installed via brew install c2t does not seem to work.

When I download c2t-master and build from source the generated .wav file works. I have access to a physical Apple //e and am calling LOAD to transfer the program.

When building from source all three of the following generate a working .wav file that loads a working program onto the Apple //e.

c2t-master/bin/c2t
c2t-master/bin/c2t_arm
c2t-master/bin/c2t_x86

The cassette load routine seems to work with the homebrew .wav file (I get two beeps from the machine), but the program I'm loading does not run.

Comparing outputs

Homebrew output:

c2t -bc8 out/main,2000 out/main.wav

Reading out/main, type binary, segment 1, start: 0x2000, length: 3013

Writing out/main.wav as Apple II formatted wave.

WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1000
start: 0xB134, length:  2251, deflated: 25.29%, data time:2.25, inflate time:0.00

To load up and run on your Apple II, type:

        LOAD

Built-from-source output:

../c2t-master/bin/c2t -bc8 out/main,2000 out/main.wav

Reading out/main, type binary, segment 1, start: 0x2000, length: 3013

Writing out/main.wav as Apple II formatted wave.

start: 0xB134, length:  2251, deflated: 25.29%, data time:2.73, inflate time:0.97
WARNING: compression disabled: no significant gain (2.74)

To load up and run on your Apple II, type:

        LOAD

SHA-1 of the homebrew binary:

07dac10a8f7ebb01f3f62639af3d373342128d16  /opt/homebrew/bin/c2t

SHA-1 of the binaries built from source:

19b2154e5fa0e10b2f68f4067944728f71f674f4  ../c2t-master/bin/c2t_x86

73ce5223d6c01d0c2a6c360439984959fc3a6288  ../c2t-master/bin/c2t_arm

8a8c890605134088a198bd21acb19288c6a65c04  ../c2t-master/bin/c2t

Fat Binary

Both the fat binary of c2t and the ARM targeted c2t_arm work on my machine.

The homebrew version seems to be an ARM binary.

 % file ../c2t-master/bin/c2t
../c2t-master/bin/c2t: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
../c2t-master/bin/c2t (for architecture x86_64):        Mach-O 64-bit executable x86_64
../c2t-master/bin/c2t (for architecture arm64): Mach-O 64-bit executable arm64

% file ../c2t-master/bin/c2t_arm 
../c2t-master/bin/c2t_arm: Mach-O 64-bit executable arm64

% which c2t | xargs file
/opt/homebrew/bin/c2t: Mach-O 64-bit executable arm64
lifepillar commented 7 months ago

Thanks for reporting! I can reproduce the issue.

If I try to generate an audio file using c2t-master/bin/c2t-96h (the pre-compiled binary), it works, and I can load the audio file in my emulator. The Homebrew version generates some warnings, and the resulting audio file cannot be loaded. This is the output I get with Homebrew:

$ c2t-96h -n UtilityCity.dsk UtilityCity.aif

Reading UtilityCity.dsk, type disk, segment 1, start: 0x1000, length: 28672
Reading UtilityCity.dsk, type disk, segment 2, start: 0x1000, length: 28672
Reading UtilityCity.dsk, type disk, segment 3, start: 0x1000, length: 28672
Reading UtilityCity.dsk, type disk, segment 4, start: 0x1000, length: 28672
Reading UtilityCity.dsk, type disk, segment 5, start: 0x1000, length: 28672

Writing UtilityCity.aif as Apple II formatted aiff.

WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1000
Segment: 0, start: 0x6117, length: 12008, deflated: 58.12%, data time: 10.27, inflate time:  0.00
WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1000
Segment: 1, start: 0x5C2A, length: 13269, deflated: 53.72%, data time: 11.27, inflate time:  0.00
WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1000
Segment: 2, start: 0x62E5, length: 11546, deflated: 59.73%, data time:  9.86, inflate time:  0.00
WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1000
Segment: 3, start: 0x6C2A, length:  9173, deflated: 68.01%, data time:  7.90, inflate time:  0.00
WARNING: simulated checksum failed: FF
WARNING: simulated inflate failed at 1004
Segment: 4, start: 0x6601, length: 10750, deflated: 62.51%, data time:  9.19, inflate time:  0.00

Times: Data: 48.495417, Inflate: 0.000029, Audio: 93.898689, File: UtilityCity.dsk

Play List:

000.00  770Hz Preamble + Sync Bit
004.02  BASIC Header + 770Hz Preamble
008.02  BASIC Stub/Assembly 9600 BPS Code @ 1333 BPS
008.09  INSTA-DISK Code + DOS Load @ 9600 BPS
016.58  Load Segment @ 9600 BPS
026.62  Inflate + Write Delay (2000 Hz)
035.62  Load Segment @ 9600 BPS
046.65  Inflate + Write Delay (2000 Hz)
053.65  Load Segment @ 9600 BPS
063.27  Inflate + Write Delay (2000 Hz)
070.27  Load Segment @ 9600 BPS
077.94  Inflate + Write Delay (2000 Hz)
084.94  Load Segment @ 9600 BPS
093.90  Inflate + Exit

To load up and run on your Apple II, type:

        LOAD

Those warnings shouldn't be there.

As the Homebrew formula for c2t does nothing more than make clean and make, I suspect that the problem is the cc65 dependency: the c2t Readme says that cl65 v2.13.3 is needed, and Homebrew installs v2.18. Which version of cc65 have you installed?

Garrett-Bodley commented 7 months ago

Thanks for responding!

I'm on v.2.18 for cl65

% cl65 --version
cl65 V2.18 - N/A
% which cl65
/opt/homebrew/bin/cl65

FWIW the built-from-source c2t is being fed the same binary file as the homebrew c2t (a C program compiled with cl65 v2.18)

lifepillar commented 7 months ago

Yeah, I've tried building v0.997 with cc65 2.13.3, but without success. It seems that building the released v0.997 does not result in a good executable, but building from c2t master works. I've updated the formula accordingly. Please try brew update and brew install c2t.

lifepillar commented 7 months ago

I'm closing this as fixed. Please reopen if you still have issues with the c2t formula.

Garrett-Bodley commented 7 months ago

Tested the new formula an a //e today and it works! Thanks for the quick resolution