Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.
Zero Tolerance for Disrespect

Higurashi Daybreak DX/Kai .DAT

Featured Replies

Solved by Hazza12555

  • Localization
  • Solution

The daybreakNN.dat files are simple: an encrypted file table, then the files back to back, each XORed with a one-byte key taken from its offset. Most assets inside use the engine's own .cnv container (raw BGRA images or raw PCM sounds), and the models are DirectX .x files, some of them MSZIP compressed. The attached script (daybreak_extract.py) extracts:

  • images (.cnv) as PNG, keeping alpha

  • voices and sound effects (.cnv) as WAV

  • skinned, animated DirectX models (.X), unpacked, with their texture names pointed at the PNGs

  • scripts and settings (.txt, .ini), converted from Shift-JIS to UTF-8

  • movies (.mpg) and everything else, decrypted

Usage

  • Needs Python 3 and Pillow. Without Pillow the images are left as decrypted .cnv files.

  • Put daybreak_extract.py next to the .dat files and run it from that folder.

python daybreak_extract.py daybreak*.dat                    every archive
python daybreak_extract.py daybreak04.dat                   one archive
python daybreak_extract.py --list daybreak04.dat            list the files without extracting
python daybreak_extract.py --raw daybreak04.dat             decrypt only, keep the game's own formats
python daybreak_extract.py -o D:\rips daybreak04.dat        different output folder

File layout

Everything is little endian, with no alignment or padding. The first file starts right after the table and the last one ends at the end of the .dat.

u16                  file_count
entry[file_count]    file table, 0x10C bytes per entry, encrypted
file data            the files back to back in table order, each XORed with its own key

File table

0x000  char[260]  name, Shift-JIS, zero padded (e.g. data/win/15a.cnv)
0x104  u32        size
0x108  u32        offset from the start of the .dat

The whole table (file_count entries of 0x10C bytes, starting at offset 2) is one XOR stream:

k = 0x64
t = 0x64
for each byte:
    byte ^= k
    k = (k + t) & 0xFF
    t = (t + 0x4D) & 0xFF

The keystream repeats every 512 bytes, so it can be built once and tiled.

File data

Each file is XORed with one byte worked out from its offset in the table:

key = ((offset >> 1) | 0x08) & 0xFF

.cnv images

A .cnv is an image when the first byte is 24 or 32 and the file is exactly the 17-byte header plus 4 bytes per pixel.

0x00  u8    bpp, 24 or 32
0x01  u32   width
0x05  u32   height
0x09  u32   width again (pitch in pixels)
0x0D  u32   0
0x11  u8[]  pixels, width * height * 4 bytes, BGRA, top row first

.cnv sounds

A WAVEFORMATEX, the data length, then raw PCM. Wrapping it in a RIFF/WAVE header gives a normal .wav.

0x00  u16   format (1 = PCM)
0x02  u16   channels
0x04  u32   sample rate
0x08  u32   bytes per second
0x0C  u16   block align
0x0E  u16   bits per sample
0x10  u16   cbSize (0)
0x12  u32   data length
0x16  u8[]  PCM data

Compressed .X models

0x00  char[16]  "xof 0303bzip0032"
0x10  u32       unpacked size + 16
then blocks until the end of the file:
      u16       unpacked block size
      u16       packed block size, including the "CK"
      char[2]   "CK"
      u8[]      raw deflate data

daybreak_extract.py

  • Author
  • Localization
1 hour ago, Hazza12555 said:

The daybreakNN.dat files are simple: an encrypted file table, then the files back to back, each XORed with a one-byte key taken from its offset. Most assets inside use the engine's own .cnv container (raw BGRA images or raw PCM sounds), and the models are DirectX .x files, some of them MSZIP compressed. The attached script (daybreak_extract.py) extracts:

  • images (.cnv) as PNG, keeping alpha

  • voices and sound effects (.cnv) as WAV

  • skinned, animated DirectX models (.X), unpacked, with their texture names pointed at the PNGs

  • scripts and settings (.txt, .ini), converted from Shift-JIS to UTF-8

  • movies (.mpg) and everything else, decrypted

Usage

  • Needs Python 3 and Pillow. Without Pillow the images are left as decrypted .cnv files.

  • Put daybreak_extract.py next to the .dat files and run it from that folder.

python daybreak_extract.py daybreak*.dat                    every archive
python daybreak_extract.py daybreak04.dat                   one archive
python daybreak_extract.py --list daybreak04.dat            list the files without extracting
python daybreak_extract.py --raw daybreak04.dat             decrypt only, keep the game's own formats
python daybreak_extract.py -o D:\rips daybreak04.dat        different output folder

File layout

Everything is little endian, with no alignment or padding. The first file starts right after the table and the last one ends at the end of the .dat.

u16                  file_count
entry[file_count]    file table, 0x10C bytes per entry, encrypted
file data            the files back to back in table order, each XORed with its own key

File table

0x000  char[260]  name, Shift-JIS, zero padded (e.g. data/win/15a.cnv)
0x104  u32        size
0x108  u32        offset from the start of the .dat

The whole table (file_count entries of 0x10C bytes, starting at offset 2) is one XOR stream:

k = 0x64
t = 0x64
for each byte:
    byte ^= k
    k = (k + t) & 0xFF
    t = (t + 0x4D) & 0xFF

The keystream repeats every 512 bytes, so it can be built once and tiled.

File data

Each file is XORed with one byte worked out from its offset in the table:

key = ((offset >> 1) | 0x08) & 0xFF

.cnv images

A .cnv is an image when the first byte is 24 or 32 and the file is exactly the 17-byte header plus 4 bytes per pixel.

0x00  u8    bpp, 24 or 32
0x01  u32   width
0x05  u32   height
0x09  u32   width again (pitch in pixels)
0x0D  u32   0
0x11  u8[]  pixels, width * height * 4 bytes, BGRA, top row first

.cnv sounds

A WAVEFORMATEX, the data length, then raw PCM. Wrapping it in a RIFF/WAVE header gives a normal .wav.

0x00  u16   format (1 = PCM)
0x02  u16   channels
0x04  u32   sample rate
0x08  u32   bytes per second
0x0C  u16   block align
0x0E  u16   bits per sample
0x10  u16   cbSize (0)
0x12  u32   data length
0x16  u8[]  PCM data

Compressed .X models

0x00  char[16]  "xof 0303bzip0032"
0x10  u32       unpacked size + 16
then blocks until the end of the file:
      u16       unpacked block size
      u16       packed block size, including the "CK"
      char[2]   "CK"
      u8[]      raw deflate data

daybreak_extract.py

Thanks!!ひぐらし目.png it worked!!

Edited by Sirduckdude

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.