| Vectors, header, and the first instructions, which log the machine before touching it. .equ VDATA, 0xC00000 .equ VCTRL, 0xC00004 .equ VHV, 0xC00008 .equ BOOT, 0xFF3F40 .equ MARK, 0xFFFFF0 .equ MARKV, 0x4D44504D .equ RSAMP, 0xFFFFB0 .globl _start, trap, font, font_end, predict, build_id .text .org 0 .long 0x00FFFE00, _start .rept 26 .long trap .endr .long hint_isr, trap | 28: level 4, HINT .long vint, trap .rept 32 .long trap .endr .org 0x100 .ascii "SEGA MEGA DRIVE " .ascii "(C)ALEW 2026.NOV" .ascii "ALEWMAN PROBE " .ascii "ALEWMAN PROBE " .ascii "GM 00000000-01" .word 0 .ascii "J " .long 0, __rom_end-1 .long 0xFF0000, 0xFFFFFF .ascii "RA" .byte 0xF8, 0x20 .long 0x200001, 0x200000+(SAVE_BYTES*2)-1 .ascii " " .ascii " " .ascii "JUE " .org 0x200 trap: 1: bra.s 1b _start: move #0x2700,sr | Only registers until the log is written: nothing else may touch memory yet. | A TMSS console locks up at any VDP access before the unlock, so that comes first. moveq #0,d4 move.b 0xA10001,d4 move.b d4,d0 andi.b #0x0F,d0 beq.s 1f move.l #0x53454741,0xA14000 1: move.w VHV,d7 | 17 more HV reads, 28 clocks apart, from ROM alone: a refresh is 14 MCLK more between two of | them. One reset cannot show that; the mean of many can, which is what the reset log is for. nop nop nop .irp r,d0,d1,d2,d3,d5 move.w VHV,\r swap \r nop nop move.w VHV,\r nop nop nop .endr .irp r,a0,a1,a2,a3,a4,a5,a6 movea.w VHV,\r nop nop nop .endr movem.l d0-d3/d5/a0-a6,RSAMP move.w VCTRL,d6 moveq #0,d5 cmpi.l #MARKV,MARK bne.s 1f moveq #1,d5 1: lea 0xFF0000,a0 move.w #0x7FD7,d0 | up to RSAMP moveq #0,d1 moveq #0,d2 moveq #0,d3 2: move.w (a0)+,d3 beq.s 3f addq.l #1,d1 add.l d3,d2 3: dbf d0,2b movea.l d1,a2 movea.l d2,a3 | Work RAM below the save's copy is ours to clear; the copy survives a reset. lea 0xFF0000,a0 move.w #0x1FFF,d0 1: clr.w (a0)+ dbf d0,1b lea BOOT,a0 move.w d7,(a0)+ move.w d6,(a0)+ move.w d5,(a0)+ move.w d4,(a0)+ move.l a3,(a0)+ move.l a2,(a0)+ move.l #MARKV,MARK lea 0xFFFE00,sp lea __data_load,a0 lea __data_start,a1 move.l #__data_end,d0 sub.l a1,d0 beq.s 2f subq.w #1,d0 1: move.b (a0)+,(a1)+ dbf d0,1b 2: lea __bss_start,a0 move.l #__bss_end,d0 sub.l a0,d0 beq.s 2f subq.w #1,d0 1: clr.b (a0)+ dbf d0,1b 2: jsr main jmp trap .org DSRC .incbin "gen/data.bin" font: .include "gen/font.inc" font_end: .align 2 | Patched by build.py after linking, so filling it moves no code. build_id: .ascii "BUILDID0" predict: .ascii "PRED" .rept 255 .long 0xFFFFFFFF .endr