Hangman (2022) game for the Apple-1

18 posts / 0 new
Last post
Offline
Last seen: 1 year 3 weeks ago
Joined: Dec 10 2021 - 12:26
Posts: 33
Hangman (2022) game for the Apple-1

I've released HANGMAN, the classic pen-and-paper game for the Apple-1 !

Originally meant to be a test for the SD card interface: it's a relatively big file that takes some seconds to load and fills almost all the memory expansion. It's big because it uses a dictionary of 2283 common words (about 16Kbytes).

Get the game here: https://github.com/.../demos/anagram/out/HANGMAN%23060280

(download the file and copy it straight to the SD card)

 

If you don't have a SD card interface, you can still load it from cassette (a 32 K memory expansion is required though). The audio file is here: https://github.com/.../ana.../out/hangman.wav_0280.650CR.zip

(unzip and play it).

The command for loading from the ACI monitor is: 0280.650CR (loading time approx 2:45")

 

The program was written in C with the KickC compiler, you can look at the source code directly from Github: https://github.com/.../blob/main/demos/anagram/hangman.cSD Card interface: https://p-l4b.github.io/sdcard/ 

I hope you like it!

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Good stuff!Working great from

Good stuff!

 

Working great from SD on R1+

 

Is loading from the audio file expected to work with a Replica1? Just curious.

Offline
Last seen: 3 hours 44 min ago
Joined: May 4 2021 - 06:35
Posts: 178
It! Could! Work! :-)

Hi Alex,

I think it would work: R1+ provides 32kB of RAM, so there shouldn't be any problem in loading the game properly!

Let us know! :-)

 

Cheers,

C

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
The load process completes,

The load process completes, but running from 0280R locks up. Is that the correct entry point? 

Offline
Last seen: 3 hours 44 min ago
Joined: May 4 2021 - 06:35
Posts: 178
Hi Alex,I am sure Nino will

Hi Alex,

I am sure Nino will help, here.

In the meantime, you could compare for example the first 32 bytes (i.e. 0280.02B2) and the last 32 bytes (64DA.650C) of the program:

- when you load it from ACI (not working)

- when you load it from microSD card (working)

 

There should be no differences, of course.

 

Replica-1+ has also the possibility to use a USB serial terminal, it should be easy to dump even the whole program and find differences.

To be honest, I don't know if ACI loading have some limitation in memory handling (i.e. 4kB max), I am just speculating here.

Also, I don't think the program use any of the added features of microSD card (VIA/Timer/IRQ...).

 

Let us know your findings...

cheers!

C.

 

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Ah yes, very good point! I

Ah yes, very good point! I should quite easily be able to dump the entire memory region over USB Serial terminal, from either loading method. I shall let you know what I find, thanks for the helpful tips toward troubleshooting. 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
I think/hope a simple fix

I think/hope a simple fix here.

 

Over SD (working:)

HANGMAN#060280

$0280-$650A (25227 BYTES)

OK

 

HANGMAN#060280

$0280-$650A (25227 BYTES)

OK

/PLAB>\

0280.02B2

 

0280: A9 8A 85 02 A9 07 85 03

0288: 20 D4 02 A9 9C 85 02 A9

0290: 07 85 03 20 D4 02 A9 01

0298: 85 0D A9 00 85 0E 20 EB

02A0: 02 C9 00 F0 F9 20 0A 03

02A8: A9 C2 85 02 A9 07 85 03

02B0: 20 D4 02

 

64DA.650C

 

64DA: 4F 57 00 59 45 53

64E0: 54 45 52 44 41 59 00 59

64E8: 49 45 4C 44 00 59 4F 55

64F0: 4E 47 00 59 4F 55 52 53

64F8: 00 59 4F 55 52 53 45 4C

6500: 46 00 59 4F 55 54 48 00

6508: 0D 0D 00 E7 64

 

 

From tape, there are 2 new bytes at the beginning, causing 2 missing bytes at the end it would appear:

From cassette:C100: A9*

0280.650CR

\

0280.02B2

 

0280: 80 02 A9 8A 85 02 A9 07

0288: 85 03 20 D4 02 A9 9C 85

0290: 02 A9 07 85 03 20 D4 02

0298: A9 01 85 0D A9 00 85 0E

02A0: 20 EB 02 C9 00 F0 F9 20

02A8: 0A 03 A9 C2 85 02 A9 07

02B0: 85 03 20

64DA.650C

 

64DA: 4C 4C 4F 57 00 59

64E0: 45 53 54 45 52 44 41 59

64E8: 00 59 49 45 4C 44 00 59

64F0: 4F 55 4E 47 00 59 4F 55

64F8: 52 53 00 59 4F 55 52 53

6500: 45 4C 46 00 59 4F 55 54

6508: 48 00 0D 0D 00

 

 

I tried adding the last 2 bytes at the end, and then starting from 0282 but didn't have any luck. 

 

Offline
Last seen: 3 hours 44 min ago
Joined: May 4 2021 - 06:35
Posts: 178
I think I got it.Nino usually

I think I got it.

Nino usually add two bytes at the beginning, for its FPGA emu.

The two bytes are the start address in little endian format, as usual.

Te real code starts just after, but I am afraid it will miss the two final bytes, E7 and 64.

 

I'll inform Nino about the issue.

Unfortunately starting at $282 does not work 'cause all the jumps are disrupted.

Have faith, I think he'll fix the audio files soon.

 

Thanks for the drill down, read you soon!

Cheers,

Claudio.

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Start address in little

Start address in little endian makes perfect sense.

 

No worries and thank you as well for your replies, it's always fun :)

 

Cheers,

Alex

Offline
Last seen: 3 hours 44 min ago
Joined: May 4 2021 - 06:35
Posts: 178
A temporary work-around

A temporary work-around-solution could be:

- load from tape from 2 address before the real start: $027E (it's the end of the keyboard buffer: won't hurt): 027E.650AR  so the jumps will be preserved.

- add manually the two missing final bytes: with 650B: E7 64

 

I am sure Nino will fix it very soon, but if you wanna try... ;-)

 

Cheers!

C.

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Awesome, great workaround,

Awesome, great workaround, and as usual I learned something :)I knew that the ACI waits for the correct amount of data, and so previously I had appended the last two bytes, but chaning the start location is brilliantly simple.As you could probably have guessed, your proposed solution works perfectly verbatim, so thank you!

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
One more question (because,

One more question (because, of course I have more questions lol)

 

When looking to reformat the bin into text for USB to Serial, I notice the file on the SD card doesn't contain those 2 final bytes. It seems to end on 0D 00. It's trivial because loading over text has no length check like the ACI program, so adding or ommitting them is no issue, but I'm curious now the signficance of those bytes. 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
I tested this over USB to

I tested this over USB to Serial (use case, owner of replica1 with no SD or ACI card)

 

It does take a very long time, but it also works fine :)

 

I used the same "one-liner" I posted in another thread, to convert the bin data to a text file:

 

% xxd -c 8 -g 1 HANGMAN\#060280 |cut -d':' -f 2|cut -d' ' -f 1-9|sed 's/^\ /\:/g' | tr a-z A-Z > Hangman_replica1.txt

 

I added the last 2 bytes as I saw no harm in doing so anyway, but it would be neat to know if they are needed and what for. Anyway, after parsing the binary file with the above command, Prepend line1 with 0280 so it looks like:

 

% head Hangman_replica1.txt 

0280: A9 8A 85 02 A9 07 85 03

:20 D4 02 A9 9C 85 02 A9

:07 85 03 20 D4 02 A9 01

[rest of file]

 

That bash command seems to be a pretty solid way to reformat flattened compiled code back into text in a format where the monitor accepts it over USB to Serial as input. Run the command, add the startpoint to line1, and optionally add a final line of 0280R for example if you want the file to auto-run like most software included with the Briel Replica 1 Plus does. 

Offline
Last seen: 1 year 3 weeks ago
Joined: Dec 10 2021 - 12:26
Posts: 33
sorry

sorry for the mistake, when I converted to WAV I used the ".prg" file as input, which indeed contains the two header bytes, but then treated it as headerless binary. My fault, sorry!

 

I fixed it and now, you can download the correct version here:https://github.com/nippur72/apple1-videocard-lib/raw/main/demos/anagram/out/hangman_0280.650AR.zip

 

By the way, the repo already contains also the text file for serial USB loading, check here: https://github.com/nippur72/apple1-videocard-lib/blob/main/demos/anagram/out/hangman.woz 

 

I do all the conversion stuff with some JavaScript utilities that are also on the repo:

wav to prg: https://github.com/nippur72/apple1-videocard-lib/tree/main/tools/wavconv/wav2prg.js

prg to wav: https://github.com/nippur72/apple1-videocard-lib/tree/main/tools/wavconv/prg2wav.js

prg to woz: https://github.com/nippur72/apple1-videocard-lib/blob/main/tools/prg2woz.js

prg to bin: https://github.com/nippur72/apple1-videocard-lib/blob/main/tools/prg2bin.js

bin to prg: https://github.com/nippur72/apple1-videocard-lib/blob/main/tools/bin2prg.js

they are all meant to be run from the command line promt with node.js

 

 

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Very nice, thanks, will test

Very nice, thanks, will test the woz files later. I see hangman and anagram, if these work, my original pull request was to have the .woz file for tapemon :) . As I believe I mentioned in another thread, I got it working; I see great value in that utility if anyone else builds an ACI for their Replica-1

 

Also much thanks for sharing the conversion utilities :)

 

Cheers,

Alex

retro_bill's picture
Offline
Last seen: 1 year 1 month ago
Joined: Aug 5 2020 - 11:56
Posts: 124
Thanks for the game! I will

Thanks for the game!

 

I will play it as soon as I build my Apple 1 and my SD ACI card gets here :)

Offline
Last seen: 22 hours 24 min ago
Joined: Jun 29 2018 - 16:55
Posts: 590
Tested Hangman successfully

Tested Hangman successfully from the provided .woz file. For those with a Replica 1, it will take quite a long time for the .woz file to be entered from your serial terminal application (with an overly conservative line and character delay, nearly an hour. I doubt it could be done under 30 minutes reliably, even if you stripped the addresses from all but the 1st line to save 4 characters per line).

 

But, it works! Which means, R1+ owners have 3 ways to load this new game:

Serial w/.woz file (takes forever but requires no expansion or accessories)

Cassette w/audio (Tested only with Uncle Bernies gen2 improved ACI, takes less than 3 minutes) 

P-LAB SD Card (Takes only a handful of seconds to load) 

 

I would be curious to see Uncle Bernie make a turbo loader digital audio file for this like he did to load basic insanely fast via his cassette interface ;) 

Offline
Last seen: 1 year 3 weeks ago
Joined: Dec 10 2021 - 12:26
Posts: 33
thanks

thanks for testing "hangman"!

As for the utilities, perhaps I should polish them and make a separate release (they were originally meant for my personal use only). Who knows, maybe an on-line tool that converts files on the fly.

If I have time I would like to experiment with a fast loader as well, indeed I have a lot of unfinished work for the ACI... As Uncle Bernie says, it's a rabbit hole!

Anyway "hangman" could have been made smaller than that, for example at least 2K can be spared by just encoding the word separator in the dictionary with a single bit instead of a whole byte. It's just that I'm lazy :-) 

Log in or register to post comments