├── README.md ├── bootrom.asm ├── build.bat └── equates.inc /README.md: -------------------------------------------------------------------------------- 1 | # gcbootrom 2 | Disassembly of the game.com boot ROM; builds a 100% matching ROM. 3 | 4 | ### To build: 5 | - Clone this repo into a new folder 6 | - Download [MS-DOS Player](http://takeda-toshiya.my.coocan.jp/msdos/index.html) and copy `msdos.exe` into the folder 7 | - Copy `ASM8521.EXE`, `HEX2BIN.EXE`, `HEX8521.EXE`, `LINK8521.EXE`, `REG8521.CFG`, `SM85.TYP` and `STUFF.EXE` from the game.com SDK into the folder 8 | - Run build.bat 9 | -------------------------------------------------------------------------------- /bootrom.asm: -------------------------------------------------------------------------------- 1 | title Game.com Boot 2 | type 8521 3 | org 1000h 4 | 5 | include equates.inc 6 | 7 | program 8 | 9 | ; interrupt vector table 10 | IVT: 11 | defw DMAINT, TIM0INT, RESERVED, EXTINT 12 | defw UARTINT, RESERVED, RESERVED, LCDCINT 13 | defw RESERVED, TIM1INT, RESERVED, CKINT 14 | defw RESERVED, PIOINT, WDTINT, NMIINT 15 | 16 | ; code entry 17 | entry: 18 | nop 19 | nop 20 | nop 21 | ; disable interrupts 22 | di 23 | ; clear ps0 (and set kernel RP), ie0, ie1 and p0c 24 | mov ps0,#00000000b 25 | clr ie0 26 | clr ie1 27 | clr p0c 28 | ; 16-bit stack, external memory enable 29 | mov sys,#1000110b 30 | ; stack pointer is at 0x3c0 31 | movw sp,#SP_START 32 | ; set up mmu banks 33 | mov mmu1,#k_bank_2 34 | mov mmu2,#k_bank_4 35 | mov mmu4,#k_bank_3 36 | ; security - ensure "Tiger DMG" is in external ROM at correct offset 37 | movw rr2,#sec_str 38 | movw rr4,#ext_sec_str 39 | mov r1,#sec_str_end-sec_str 40 | str_cmp_loop: 41 | ; compare string 42 | mov r0,(rr2)+ 43 | cmp r0,(rr4)+ 44 | br ne,stall 45 | dbnz r1,str_cmp_loop 46 | ; security - ensure these three offsets add up to 0 47 | mov r0,sec_1 48 | add r0,sec_2 49 | add r0,sec_3 50 | br nz,stall 51 | ; jump to external ROM entry point 52 | jmp ext_entry 53 | stall: 54 | ; disable interrupts and stall infinitely 55 | di 56 | inf_loop: 57 | jmp inf_loop 58 | 59 | ; security string 60 | sec_str: 61 | defm "Tiger DMG" 62 | sec_str_end: 63 | 64 | ; jump to "real" ISR in external ROM 65 | TIM0INT: 66 | jmp TIM0INT_ISR 67 | EXTINT: 68 | jmp EXTINT_ISR 69 | UARTINT: 70 | jmp UARTINT_ISR 71 | LCDCINT: 72 | jmp LCDCINT_ISR 73 | TIM1INT: 74 | jmp TIM1INT_ISR 75 | CKINT: 76 | jmp CKINT_ISR 77 | PIOINT: 78 | jmp PIOINT_ISR 79 | WDTINT: 80 | jmp WDTINT_ISR 81 | NMIINT: 82 | jmp NMIINT_ISR 83 | ; DMA interrupt is stubbed 84 | DMAINT: 85 | RESERVED: 86 | iret 87 | 88 | end -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | msdos asm8521 bootrom.asm 3 | msdos link8521 bootrom.obj -o bootrom.pro 4 | msdos hex8521 -p -f bootrom 5 | msdos hex2bin bootrom.hex bootrom.bin 6 | msdos stuff bootrom.bin 4096 255 7 | mkdir out 8 | move /y bootrom.bin out\bootrom.bin -------------------------------------------------------------------------------- /equates.inc: -------------------------------------------------------------------------------- 1 | ; "Tiger DMG" in external ROM 2 | ext_sec_str equ 202fh 3 | 4 | ; security locations 5 | sec_1 equ 20f0h 6 | sec_2 equ 2580h 7 | sec_3 equ 4000h 8 | 9 | ; ISR locations 10 | TIM0INT_ISR equ 2039h 11 | EXTINT_ISR equ 203ch 12 | UARTINT_ISR equ 203fh 13 | LCDCINT_ISR equ 2042h 14 | TIM1INT_ISR equ 2045h 15 | CKINT_ISR equ 2048h 16 | PIOINT_ISR equ 204bh 17 | WDTINT_ISR equ 204eh 18 | NMIINT_ISR equ 2051h 19 | 20 | ; external ROM entry point 21 | ext_entry equ 2054h 22 | 23 | ; start start location 24 | SP_START equ 3c0h 25 | 26 | ; banks 27 | k_bank_1 equ 1 ; 0x2000 28 | k_bank_2 equ 2 ; 0x4000 29 | k_bank_3 equ 3 ; 0x6000 30 | k_bank_4 equ 4 ; 0x8000 31 | k_bank_5 equ 5 ; 0xa000 --------------------------------------------------------------------------------