Skip to content

Latest commit

 

History

History
118 lines (95 loc) · 5.72 KB

m64.md

File metadata and controls

118 lines (95 loc) · 5.72 KB

m64 format specification

The m64 movie format has been designed to be very simple to replay on the C64, but requires a lot of memory bandwidth. This makes it suitable for use with the super-reu.

An m64 movie consists of a simple sequence of data frames concatenated after each other, where one frame is processed every physical video frame (1/50s on PAL, 1/60s on NTSC). A data frame consists of a header and optionally audio and video data. If no audio data is present then no audio playback is done for that frame. If no video data is present then the picture from the previous frame is retained. This allows for video to have a lower update rate than 50 fps, saving file size.

A data frame is always an integral number of 256 byte blocks. First there is a variable length part which contains the header and optional audio data. This part can be 1 to 4 blocks in length. It is allowed to add padding blocks after the audio data as long as the total number of blocks is at most 4.

After the variable length part comes two optional fixed length parts for the video. The first contains the dot and matrix memory contents, and has a length of 36 blocks (first 32 blocks of dot data, then 4 blocks of matrix data). The second contains the color memory contents, and has a length of 4 blocks. The color memory part is used only in multicolor mode.

Header

The header is 16 bytes in length and is located first in the first block of each data frame.

Offset Value range Function
0 $AA Header magic byte 1, indicates start of header
1 $4D Header magic byte 2, indicates start of header
2 1-44 Total size of data frame, in 256 byte blocks
3 1-4 Size of header and audio part, in 256 byte blocks
4 0-7 Bitmask indicating presence of optional parts
Bit 2 - Audio data is present
Bit 1 - Color video data data is present
Bit 0 - Dot and matrix video data is present
5 0-255 Number of audio samples, low byte
6 0-3 Number of audio samples, high byte
7 50 / 60 Intended playback FPS
8 0-255 Audio frequency, low byte
9 0 / 19-187 Audio frequency, high byte
10 4-240 Audio playback timing for PAL, PHI2 cycles
11 0-255 Audio playback timing for PAL, 1/256 PHI2 cycles
12 4-240 Audio playback timing for NTSC, PHI2 cycles
13 0-255 Audio playback timing for NTSC, 1/256 PHI2 cycles
14 $08 / $18 Value to write into $D018 for this frame
15 0-15 Value to write into $D021 for this frame

The total size must be the sum of the header size and the sizes of those optional video section that are present. Any padding blocks must be placed before the video data and included in the header size.

The intended playback FPS indicates if the movie was generated for a PAL or NTSC C64. If it does not match the actual video frame rate, the recommended course of action is simply to ignore this field and playback the movie at the wrong speed, using the appropriate audio timing values to keep audio and video in sync.

The audio frequency value is purely informational, the actual playback timing is gived by the cycle values. The frequency value should be in the range 5000-48000 Hz. If no audio data is present, the frequency should be set to 0.

The values for $D018 and $D021 control multicolor mode on/off, and the common background color for multicolor mode, respectively.

Audio data

If the audio samples present bit is set, audio data starts immediately after the header, at offset 16 in the first block of the data frame. Each sample is stored as a byte with a value of 0-15, suitable for storing directly into $D418.

The number of samples (bytes) is stored in the header, and should be in the range 80-960. If the audio samples present bit is not set, the number of samples should be set to 0 in the header.

The appropriate delay between each sample in (fractional) PHI2 cycles is indicated in the header. The first byte gives the number of integral PHI2 cycles, and the second byte the number of additional 1/256:th PHI2 cycles for fine-tuning the delay. The fractional part should be accumulated over multiple samples to find when an extra full cycles delay should be inserted to keep the correct rate over time. For playback on a PAL C64 (processing 50 data frames per second), the PAL delay value should be used. For playback on an NTSC C64 (processing 60 data frames per second), the NTSC delay value should be used.

Video data

If either of the video present bits is set, video data appears after the header and audio data, at the block offset indicated by the header size field of the header. The contents can be 36 blocks of dot and matrix data, 4 blocks of color data, or both, for a total of 40 blocks. If both dot and matrix data and color data are present, the color data appears last.

The video data is preformatted to be accessed directly by VIC. At the vblank, $D018 and $D021 should be set up as indicated by the header, $DD00 and $D016 should be set to point to the place in memory where VIC can find the dot and matrix video data, and $D011 should be set to bitmap mode. If color data is present, it must be copied to $D800-$DBFF starting at the vblank and keeping ahead of the raster sweep.