PHC to BASIC


PHC binary decoder

This function enables the conversion of a PHC file into a BASIC file. Refer to the binary decoding below.


How to

Click the 'Load PHC' button. The file will be decoded in the area below. You can copy or save it via the 'Save .bas' button.



PHC filename:
Lignes detected: 0

PHC (hex view)
Basic

TO DO

Improve comments and indent in files.

The decrypted PHC binary

Description of the PHC file structure.

Sync header

10 bytes of value A5h

a5 a5 a5 a5 a5 a5 a5 a5 a5 a5

Program name:

6 ASCII characters (padded with 00h if shorter).

nn nn nn nn nn nn

Program body

Repeated blocks of BASIC code encoded in tokens/ASCII.
Each line ends with 00h.
Continue until no more lines.

nn nn nn nn nn 00

End of program marker

This includ the end of the last line.

00 00 00

Line index table (stored in reverse order)

Each entry is 4 bytes:

  • AL, AH : memory address of the line (little endian)
  • NL, NH : line number (little endian)
Repeat until no more entries.
The first four bytes are the last line, the last four bytes are the first line.

 al ah nl nh ...

Trailer

00h FFh FFh FFh FFh

followed by padding with 00h bytes (18).

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Fixed tail section to mark the end of the file.