Swords of Glass fortune format

From ModdingWiki
Jump to navigation Jump to search
Swords of Glass fortune format
Format typeText
Text purposeControl
Line endingsNone
Character setCode Page 437
Games

Statues in Swords of Glass can give you a fortune, which is little more than what you would read on a fortune cookie, and just as useless. The fortunes are stored in the Fortunes.dat file. Each fortune is two lines long even if only one if shown. In the data file, a line is 21 bytes long, even if not all of the bytes are used. The first byte of each line is the length of bytes to read from the line. The file is fixed-width and stores 20 two-lined fortunes.

Data type Description
UINT8 Message length The number of characters to read from the message line.
char[20] Name The message line.
2 lines per fortune.
20 fortunes in the file.

Source Code

Exporter

This FreeBASIC program will export each of the game's fortunes into a text file.

Dim As Integer FortuneNo, LineNo
Dim As String FortuneLines(0 To 1)
Dim As UByte LineLength(0 To 17)

Open "Fortunes.dat" For Binary As #1
Open "Fortunes.txt" For Binary As #2

For FortuneNo = 0 To 19
	' Read the lines.
	For LineNo = 0 To 1
		Get #1, , LineLength(LineNo)
		FortuneLines(LineNo) = Space(20)
		Get #1, , FortuneLines(LineNo)
		FortuneLines(LineNo) = Left(FortuneLines(LineNo), LineLength(LineNo))
	Next LineNo
	
	' Export the fortune.
	Put #2, , "Fortune: " + Str(FortuneNo) + Chr(13) + Chr(10)
	Put #2, , Chr(13) + Chr(10)

	' Export the lines.
	For LineNo = 0 To 1
		Put #2, , FortuneLines(LineNo) + Chr(13) + Chr(10)
	Next LineNo
	Put #2, , Chr(13) + Chr(10)
	Put #2, , Chr(13) + Chr(10)
	Put #2, , Chr(13) + Chr(10)
Next FortuneNo

Credits

This format was reverse engineered by TheAlmightyGuru. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)