# A tiny own Game Boy program for the link test (no game data): 256 bytes over the serial port. # Starts with the A button. role m: clocks (SC=0x81) and sends 0,1,2..; role s: answers (SC=0x80) with 0x80,0x81,..; both keep what they get at C000. # python3 mklinkrom.py m|s out.gb import sys m = sys.argv[1] == 'm' r = bytearray(32768) r[0x100:0x104] = bytes([0x00, 0xC3, 0x50, 0x01]) r[0x134:0x13C] = b'LINKTEST' code = [0xF3, 0x3E, 0x10, 0xE0, 0x00, 0xF0, 0x00, 0xCB, 0x47, 0x20, 0xF6, # wait for A (both sides know each other by then) 0x21, 0x00, 0xC0, 0x06, 0x00, 0x78, 0xEE, 0x00 if m else 0x80, 0xE0, 0x01, 0x3E, 0x81 if m else 0x80, 0xE0, 0x02, 0xF0, 0x02, 0xCB, 0x7F, 0x20, 0xFA, 0xF0, 0x01, 0x22, 0x04, 0x0E, 0x00, 0x0D, 0x20, 0xFD, 0x7C, 0xFE, 0xC1, 0x20, 0xE3, 0x18, 0xFE] r[0x150:0x150 + len(code)] = bytes(code) x = 0 for i in range(0x134, 0x14D): x = (x - r[i] - 1) & 0xFF r[0x14D] = x open(sys.argv[2], 'wb').write(r)