If you are still using the old URL (datacrystal.romhacking.net), please update your bookmarks! The old URL may stop working soon.
The current URL is datacrystal.tcrf.net.
The current URL is datacrystal.tcrf.net.
Crystal Beans from Dungeon Explorer/Cutscene Text Compression: Difference between revisions
Jump to navigation
Jump to search
(Created page) |
m (Hawk moved page Crystal Beans From Dungeon Explorer/Cutscene Text Compression to Crystal Beans from Dungeon Explorer/Cutscene Text Compression) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{subpage}} | |||
==Format== | ==Format== | ||
The cutscene text is slightly compressed in a format a bit similar to LZ. | The cutscene text is slightly compressed in a format a bit similar to LZ. | ||
There is a control byte for every 8 byte sequence, starting from the most significant bit, if the bit is set, 256 is added to the byte to form the character index described in the [[ | There is a control byte for every 8 byte sequence, starting from the most significant bit, if the bit is set, 256 is added to the byte to form the character index described in the [[Crystal Beans From Dungeon Explorer:TBL#Cutscene table|table]]. Another way to think of it is to consider the bits in the control byte as the 8th bit in the character index. | ||
==C Source== | ==C Source== | ||
Line 25: | Line 27: | ||
} | } | ||
</pre> | </pre> | ||
==See also== | |||
* [[Crystal Beans From Dungeon Explorer:Tutorials#Removing the cutscene text compression|Removing the cutscene text compression]] |
Latest revision as of 21:03, 28 January 2024
This is a sub-page of Crystal Beans from Dungeon Explorer.
Format
The cutscene text is slightly compressed in a format a bit similar to LZ.
There is a control byte for every 8 byte sequence, starting from the most significant bit, if the bit is set, 256 is added to the byte to form the character index described in the table. Another way to think of it is to consider the bits in the control byte as the 8th bit in the character index.
C Source
in is the input file pointer and out is the output file pointer. TableGetTextValue is the function to convert a character index to a character string.
int endLoop = 0; int controlByte, curChar, tableIndex; while(!endLoop) { // until the end of the string controlByte = fgetc(in); for (j = 0; j < 8; j++) { // for each bit in controlByte curChar = fgetc(in); tableIndex = curChar + ((controlByte & 0x80) ? 256 : 0); // if bit 7 is set, add 256 fputs(TableGetTextValue(tableIndex), out); if (tableIndex == 0) { // char 0 is end-of-string endLoop = 1; // end-of-string, get out of while loop break; // get out of for loop } controlByte <<= 1; // get next bit } }