WP-2 Native File Format Notes

01/08/06, John R. Hogerhuis



Offset

Size

Purpose

Min

Max

Default

0x00

8

Unknown

N/A

N/A

\0\0sekine

or,

00 00 73 65 6b 69 6e 65

0x08

1

Justification, 0=ON, 1=OFF

0

1

1 (OFF)

0x09

1

Starting Page Number

0

255

1

0x0A

1

Header Alignment 0=Center, 1=Right, 2=Left, 3=None

0

3

3

0x0B

1

Footer Alignment 0=Center, 1=Right, 2=Left, 3=None

0

3

3

0x0C

1

Top Margin

0

page_length - 1

6

0x0D

1

Left Margin

0

99

10

0x0E

1

Characters Per Line

8

120

65

0x0F

1

Page Length in lines

1

255

66

0x10

1

Line Spacing

1

3

1

0x11

2

Unknown; seems file-length dependent

?

?

?

0x13

1

Bottom Margin

0

Page Len - Top Margin

6

0x14

13

Unknown, possibly unused

N/A

N/A

All Null

0x21

32

Header string, null terminated if < 32

N/A

N/A

All Null

0x41

32

Footer string, null terminated if < 32

N/A

N/A

All Null

0x61

15

Tab positions (bit string)

N/A

N/A

Every 4 characters

0x70

16

Unknown, possibly unused

N/A

N/A

All Null

0x80

?

Body Text

N/A

N/A

0x1A (EOF)



Files are always a multiple of 256 (0x100) bytes.

``Pause between pages'' is not saved in the file... must be a global variable

Offset 0x13 is the bottom margin; maximum is based on page len, bottom margin and top margin, BUT page length of 255 fools it.

Bytes 0x21..0x40 is the page header string. The UI lets you enter 48 characters, but only 32 appear in the file header. Whatever is in the upper 16 bytes will remain there across loads & saves. I don't know if these upper 16 characters would actually print.

Bytes 0x41..0x60 is the page footer string. The UI lets you enter 48 characters, but only 32 appear in the file header. Whatever is in the upper 16 bytes will remain there across loads & saves. I don't know if these upper 16 characters would actually print.


To generate/interpret tab bit string:

Default 16 bytes at offset 0x61 is

00 10 42 08 21 84 10 42 08 01 00 00 00 00 00 00

Starting at 0x61, bit #1 (bit #0 appears unused) is a set of bitflags representing tab positions.

Suppose we want to set a tab at position p (where p = 0..117),

The byte offset where the tab flag will be stored is 0x61 + (p + 1) / 8, or

0x61 + ((p + 1) >> 3)

The byte to OR to set flag at position p can be calculated:

2 ^ ((p + 1) % 8), or alternatively,

1 << ((p + 1) & 7)

High bit of byte at 0x6f is always set. So, if bit 117 is set, the byte at 0x6f is not 0x40, but 0xc0.


Text starts at offset 0x80, ends with character 0x1A (EOF).

If a file has no characters, it will just have the 0x1A character at 0x80 offset.


Everything after the EOF marker is garbage. Usually this includes a header for the next file, including the file name but it is probably all irrelevant as a saved file.


Special Characters/Style Codes:

Newline character is the single character 0x0d

Page break is form feed character 0x0c

Boldface is started with character 0x00 and stopped with 0x00

Underline is started with character 0x01 and stopped with 0x01

Other-Font is started with character 0x02 and stopped with 0x02

Centered paragraphs begin with character 0x04

Set-line-width with character 0x05 followed by ASCII number string and 0x0d

Set-left-margin with character 0x06 followed by ASCII number string and 0x0d