document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ; @output   Carry: Flag raised if the system in which the game is running is a Super Game Boy
  2. check_sgb:
  3.     di
  4.     ld      hl, MltReqTwoPlayers    ; Two player mode selection
  5.     call    sgbpackettransfer
  6.     ld      a,  P1F_4 | P1F_5
  7.     ld      [rP1], a                ; We disable key and pad reading to read the joypad id
  8.     ld      a, [rP1]
  9.     ld      a, [rP1]
  10.     ld      a, [rP1]
  11.     ld      a, [rP1]                ; Many readings to avoid the "bouncing" of values
  12.     ld      ba                   ; We store the id of the first joypad
  13.     ; Joypad reading simulation
  14.     ld      a,  P1F_5
  15.     ld      [rP1]a               ; Pad reading activated
  16.     ld      a,  P1F_4
  17.     ld      [rP1]a               ; Key reading activated
  18.     ld      a,  P1F_4 | P1F_5
  19.     ld      [rP1], a                ; We disable key and pad reading to read the next joypad id
  20.     ld      a, [rP1]
  21.     ld      a, [rP1]
  22.     ld      a, [rP1]
  23.     ld      a, [rP1]
  24.     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
  25.     jr      nz, check_sgb_0
  26.     and     a                       ; We lower the carry flag
  27.     ret                             ; We are not in a Super Game Boy
  28. check_sgb_0:
  29.     ld      hl, MltReqOnePlayer
  30.     call    sgbpackettransfer       ; We return to one player mode
  31.     scf                             ; We raise the carry flag
  32.     ret                             ; We are in a Super Game Boy
');