cgb.s (508B)
1 .include "global.s" 2 3 .title "CGB support" 4 .module CGB 5 6 .area _CODE 7_cpu_slow:: ; Banked 8 LDH A,(.KEY1) 9 AND #0x80 ; Is GBC in double speed mode? 10 RET Z ; No, already in single speed 11 12.shift_speed: 13 LDH A,(.IE) 14 PUSH AF 15 16 XOR A ; A = 0 17 LDH (.IE),A ; Disable interrupts 18 LDH (.IF),A 19 20 LD A,#0x30 21 LDH (.P1),A 22 23 LD A,#0x01 24 LDH (.KEY1),A 25 26 STOP 27 28 POP AF 29 LDH (.IE),A 30 31 RET 32 33_cpu_fast:: ; Banked 34 LDH A,(.KEY1) 35 AND #0x80 ; Is GBC in double speed mode? 36 RET NZ ; Yes, exit 37 JR .shift_speed