; @output Carry: Flag raised if the system in which the game is running is a Super Game Boy
check_sgb:
di
ld hl, MltReqTwoPlayers ; Two player mode selection
call sgbpackettransfer
ld a, P1F_4 | P1F_5
ld [rP1], a ; We disable key and pad reading to read the joypad id
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1] ; Many readings to avoid the "bouncing" of values
ld b, a ; We store the id of the first joypad
; Joypad reading simulation
ld a, P1F_5
ld [rP1], a ; Pad reading activated
ld a, P1F_4
ld [rP1], a ; Key reading activated
ld a, P1F_4 | P1F_5
ld [rP1], a ; We disable key and pad reading to read the next joypad id
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
ld a, [rP1]
cp b ; If the id is the same then there has not been reply to the two player mode request, and therefore we are not in a Super Game Boy
jr nz, check_sgb_0
and a ; We lower the carry flag
ret ; We are not in a Super Game Boy
check_sgb_0:
ld hl, MltReqOnePlayer
call sgbpackettransfer ; We return to one player mode
scf ; We raise the carry flag
ret ; We are in a Super Game Boy