document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ; Super Game Boy initialization
  2. init_sgb:
  3.     xor     a
  4.     ld      [_SGB_F],   a           ; Indicates if the game is running on a Super Game Boy
  5.     ld      a,  SGB_BNK
  6.     ld      [_CUR_BNK], a
  7.     ld      [$2000],    a           ; Bank with the Super Game Boy related graphics and routines
  8.     call    check_sgb
  9.     ret     nc                      ; We return if the game is not running on a Super Game Boy
  10.     di
  11.     ld      a1
  12.     ld      [_SGB_F],   a
  13.     ld      hl, MaskEnFreeze
  14.     call    sgbpackettransfer       ; Freezes the visualization of the Super Game Boy screen to hide the graphic garbage during the VRAM transfers
  15.     call    init_sgb_default        ; 8 initialization data packet sending, according to the official documentation
  16.     xor     a
  17.     ld      [_AUXVAR]a
  18.     ld      de, ChrTrn1
  19.     ld      hl, SGBBorderTiles
  20.     call    copysnes                ; Copies to SNES RAM the first 128 tiles of the frame (256 Game Boy tiles)
  21.     xor     a
  22.     ld      [_AUXVAR]a
  23.     ld      de, ChrTrn2
  24.     ld      hl, SGBBorderTiles + 4096
  25.     call    copysnes                ; Copies to SNES RAM the second 128 tiles of the frame (256 Game Boy tiles)
  26.     xor     a
  27.     ld      [_AUXVAR]a
  28.     ld      de, PctTrn
  29.     ld      hl, SGBBorder
  30.     call    copysnes                ; Copies to SNES RAM the frame map
  31.     xor     a
  32.     ld      [_AUXVAR]a
  33.     ld      de, PalTrn
  34.     ld      hl, SGBSuperPalettes
  35.     call    copysnes                ; Copies to SNES RAM the custom game palettes
  36.     ; VRAM reset
  37.     ld      de, _VRAM
  38.     ld      bc, $2000
  39.     ld      l$0
  40.     call    fillmem
  41.     ; Default game palette set
  42.     ld      hl, PalSet
  43.     call    sgbpackettransfer
  44.     ld      hl, MaskEnCancel
  45.     call    sgbpackettransfer       ; Super Game Boy screen visualization unfreezing
  46.     ret
');