# SPDX-License-Identifier: MIT """Rung 7's host pieces: the skip-BIOS start (U-SYS-2) and the window's picture format.""" from __future__ import annotations from programs import board_for from gba_python.window import ppm_bytes def test_skip_bios_leaves_the_documented_stacks_and_system_mode(): b = board_for(b"\x00" * 0x100) b.skip_bios() cpu = b.cpu assert cpu.cpsr & 0xFF == 0x1F # System mode, ARM, IRQ and FIQ enabled assert cpu.r[13] == 0x03007F00 and cpu.r[14] == 0x08000000 banks = cpu.capture_state().banks assert banks[2][5] == 0x03007FE0 # SP_svc (GBATEK §BIOS RAM Usage) assert banks[4][5] == 0x03007FA0 # SP_irq assert b.ppu.read16(0x00) == 0x0080 # forced blank, as the boot leaves it assert [b.ppu.regs[o >> 1] for o in (0x20, 0x26, 0x30, 0x36)] == [0x100] * 4 # unscaled assert b.sound.read16(0x88) == 0x0200 assert b.irq.postflg == 1 def test_ppm_is_a_whole_frame(): picture = [[0x7FFF] * 240 for _ in range(160)] data = ppm_bytes(picture) header = b"P6 240 160 255\n" assert data.startswith(header) assert len(data) == len(header) + 240 * 160 * 3