DESCRIPTION OF THE DAGGERFALL BOOK FILE FORMAT ============================================================================= Written By Dave Humphrey 20 June 1998 dave@uesp.net This file describes as much as is known about the book files used in the Daggerfall CRPG game created by Bethesda. The book files exist in the directory ARENA2\BOOKS\ in the main DAGGER directory and have names such as 'BOK00100.TXT', 'BOK00002.TXT', etc... All of the information contained in here was found from looking at all the different book files. As such, all known possible values for a field will be stated where appropiate. Overall Format ================================================= The general format of a book file can be split into four different parts, explained as follows. [ ..... 64 Bytes, Title of Book ..... ] [ .... 160 Bytes, Author of Book .... ] [ ..... Variable Length Header ...... ] [ . Variable Start/Length Book Text . ] The first two fields, the title and book author appear to be the only fixed length fields beginning the file. Everything else after this depends on the length of the header. Header Format ================================================= The header isn't that well known at the moment, but I'll attempt to describe what is known. The first portion of the header is always 12 bytes long and has the following format. [ .. Bytes 224..227 .. ] (long) Book Price I believe this has something to do with the relative price of the book (confirmed). 0x03E8: Most files have this value 0x012C, 0x0190, 0x000A, 0x1388, 0x01F4, 0x2710 [ .. Bytes 228..229 .. ] (int) Unknown quantity that is a value from 1 to 4. Probably some sort of book type field? [ .. Bytes 230..231 .. ] (int) Always 0x04D2 except for book #100 where it is 0x04D3. Note that 0x04D2 = 1234 in decimal which is a rather peculiar number. [ .. Bytes 232..233 .. ] (int) Always 0x0929 except for book #100 where it is 0x092A. Note that 0x0929 = 2345 in decimal which again is a rather strange number. [ .. Bytes 234..235 .. ] (int) The number of page offsets which follow. The important bytes to remember are the last two which will be required in order to determine where exactly the book text starts. What follows in the file now are a number of long integer (4 byte) values. The exact number is determined by the value of the last two bytes described above. The offsets each point to the top of a page in the book. This is most likely used for changing pages of a book in the game. The first offset will point to the very start of the book text which also corressponds to the first byte after the offset list ends. So, the header looks essentially like this... ...... Author ....... ] { Start of Header } [ 4 bytes, Book Price ] [ 6 bytes Unknown Header Information ] [ 2 Bytes, Number of Offsets ] [ Offset List, (4 * Number of Offsets) Bytes Long ] { End of Header } [ ...... Book Text ....... Book Text Format ================================================= The text of the book is not in normal ASCII format so it needs some explaining. There are a number of non-printable characters which have a specific task... [ Character 0x00 ] This character is the equivilent of a Carriage Return, indicating that a new line should be started. [ Character 0x01 (ASCII 1) ] Not sure what this is, but it appears to only exist before the 0xFB character described below. It might have something to do with text display but I'm not sure. [ Character 0xF6 (ASCII 246) ] This character indicates the end of a page in the book. [ Character 0xF9 (ASCII 249) ] This selects which font is to be used depending on what the next character afterwards is. 0x02: Display the fancy text (for titles) 0x04: Display the regular text [ Character 0xFB (ASCII 251) ] This character controls the display position of the text given by the following two bytes. The two bytes (a short integer) give the pixel position on the screen to print the next character at (this may be relative or absolute). Typical values used are 0x0800 and 0x1000 (8 and 16 respectively) (almost confirmed). [ Character 0xFD (ASCII 253) ] Indicates that the next line printed should be horizontally centered on the screen. Used mostly for titles, authors, etc... Besides the regular printable characters, these are the only ones to exist in any of the books. The exception is the book BOK10000.TXT which appears to be written in german or something and has all kinds of wierd things happening in it. For this reason I decided to ignore it since it didn't fit the format of all the other book files. For testing purposes I used the above information to create a simple program to output the book files to the screen in text mode. The output appears to be very close, if not identical, to the output produced in Daggerfall itself. The exception occurs for certain lines where the line feed character 0x00 appears to be missing. This causes really long lines (> 80 characters) to be displayed. I would assume that the Daggerfall windowing code can automatically handle and wrap long lines with no line feeds since similar things happen in the quest text files. There actually appears to be evidence that DF cannot properly handle long text lines as someone pointed out to me, since there are cases where text flows past the end of the window. That's about all there is too it. If there's any mistakes, or you find out one of the unknown bytes, just e-mail me to let me know....Enjoy.