Description
The intro cutscene of M2NES, a ROM hack of M2 that recreates M1.
The main reason I show this is because of the scene at 0:02, which is a pre-rendered FMV running on GB. This pushes the GB to its absolute limit, as I had to save every single CPU cycle that I could to ensure it runs smoothly, especially while blasting VRAM.
It works by having two buffers in VRAM, one being drawn to the BG tilemap, the other to the Window tilemap. When a new frame is completed, a bit of the LCDC register is toggled to switch which tilemap is displayed on the BG layer. The window layer (which has rendering disabled, making it invisible and not affect Hblank usage) is responible for drawing the next frame to be displayed on the screen. Other bits of the LCDC register, such as objects and window rendering are turned off to maximize Hblank time.
Each animation frame is stored at a resolution of 128*56px, with 4 frames per ROM bank (This FMV is 12 frames and is spread across 3 banks. When the end of one bank is reached a WRAM variable used a bank pointer for the FMV is incremented). Midframe interrupts are used to manipulate Yscroll by 1px to effectively stretch to image to 128*112, double its original height (by drawing scanlines twice in succession). Because writing to VRAM can only be done during blanking periods and the GB can't do the "decompression" and write to VRAM within the small window of Hblank, it has to alternate between the two tasks every Hblank. Each new animation frame is uploaded to VRAM in ~5 frames (4 bytes per Hblank, one tile is 16 bytes, each image is 112 tiles, you do the math), meaning the FMV runs at ~12fps (somehow).
The FMV game mode simply switches bank to whatever the FMV bank pointer WRAM variable is set to, then jumps to address $4000, which is the beginning of Bank X, where the FMV code of the relevant bank starts.
tl;dr, LCDC register is a powerful tool.
No copyright intended. I own nothing