; global variables at the start of hram
DEF vCurrentSpread EQU GLOBAL_VARS_START ; 16bit address of current spread, ff90
DEF vSelectedSpreadIndex equ vCurrentSpread + 2 ; ff92
def vSelectedSpreadCard equ vSelectedSpreadIndex + 1 ; ff93
def vSelectedCardIndex equ vSelectedSpreadCard+1 ; ff94
DEF vFrameCountSquares EQU vSelectedCardIndex+1 ; ff95
DEF vTime EQU vFrameCountSquares+1 ; 16bit ; ff96
def vBlocked EQU vTime+2
println "vBlocked is ", vBlocked ;


; screen-specific variables 
DEF vFrameCount1 EQU SCREEN_VARS_START
DEF vFrameCount2 equ vFrameCount1+1
DEF vFrameCount3 EQU vFrameCount2+1
DEF vMenuIndex equ vFrameCount3+1
DEF vMenuIndexPrevious equ vMenuIndex + 1

ScreenMainMenu:
  dw MainMenuSetup
  dw MainMenuUpdate
  dw MainMenuDraw
  dw MainMenuTeardown

MainMenuSetup:
; Turn the LCD off
  ld hl, rLCDC
  bit 7, [hl]
  jp z, .screenOff
.busyWait
  ld a, [rLY]
  cp a, 143
  ;jp c, .busyWait

.screenOff:
  ld a, 0 
  ldh [rLCDC], a
  
  ld hl, SquaresTileset8
  ld de, $8010 + $80*16
  ld bc, 16
;println "the diff is ", SquaresTilesetEnd - SquaresTileset8
  call CopyRange
  
  def spacing equ $12
  
  ld hl, CardBackSprites24 ; source
  def TileStartCardBackSprites24 equ 0
  ld de, $8000 + TileStartCardBackSprites24*$10; destination of copy
  ld bc, CardBackSprites24End - CardBackSprites24 ; length to copy
  call CopyRange
  
  ld hl, CardBackSprites23
  def TileStartCardBackSprites23 equ TileStartCardBackSprites24 + spacing
  ld de, $8000 + TileStartCardBackSprites23*$10; destination of copy
  ld bc, CardBackSprites23End - CardBackSprites23
  call CopyRangeUnsafe
  
  ld hl, CardBackSprites22
  def TileStartCardBackSprites22 equ TileStartCardBackSprites23 + spacing
  ld de, $8000 + TileStartCardBackSprites22*$10; destination of copy
  ld bc, CardBackSprites22End - CardBackSprites22
  call CopyRange
  
  ld hl, CardBackSprites21
  def TileStartCardBackSprites21 equ TileStartCardBackSprites22 + spacing
  ld de, $8000 + TileStartCardBackSprites21*$10; destination of copy
  ld bc, CardBackSprites21End - CardBackSprites21
  call CopyRange
  
  ld hl, CardBackSprites20
  def TileStartCardBackSprites20 equ TileStartCardBackSprites21 + spacing
  ld de, $8000 + TileStartCardBackSprites20*$10
  ld bc, CardBackSprites20End - CardBackSprites20
  call CopyRange
  
  ld hl, CardBackSprites19
  def TileStartCardBackSprites19 equ TileStartCardBackSprites20 + spacing
  ld de, $8000 + TileStartCardBackSprites19*$10
  ld bc, CardBackSprites19End - CardBackSprites19
  call CopyRange
  
  ld hl, CardBackSprites18
  def TileStartCardBackSprites18 equ TileStartCardBackSprites19 + spacing
  ld de, $8000 + TileStartCardBackSprites18*$10
  ld bc, CardBackSprites18End - CardBackSprites18
  call CopyRange
  
  ld hl, CardBackSprites17
  def TileStartCardBackSprites17 equ TileStartCardBackSprites18 + spacing
  ld de, $8000 + TileStartCardBackSprites17*$10
  ld bc, CardBackSprites17End - CardBackSprites17
  call CopyRange
  
  def TileStartCardBackSprites16 equ TileStartCardBackSprites17 + spacing
  
  ld hl, MainUITilemap
  ld de, $9800
  ld b, 18
  ld c, 20
  call CopyTilesToMap
  
  ld hl, StringRead
  ld de, $9800 + 32*11 + 4
  call PrintString
  ld hl, StringShuffle
  ld de, $9800 + 32*13 + 4
  call PrintString
  ld hl, StringBrowse
  ld de, $9800 + 32*15 + 4
  call PrintString
  
  
  ; clear out the dma source
  ld hl, MY_OAM
  ld a, 0 
:
  ld [hl+], a 
  cp a, l 
  jp nz, :- ; this was clever. as long as a (0) doesn't equal l (low bit of address) we loop
  ; so this goes until l loops around to 0
  
  ld de, SAFE_DMA_LOCATION
  ld a, HIGH(MY_OAM)
  call RunDMA
  
  ; set LCD and display registers
  ld a, %11100100
  ldh [rBGP], a
  ldh [rOBP0], a

  ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON | LCDCF_OBJ16
  ldh [rLCDC], a

  ld a, 0 
  ld [vFrameCount1], a ; first starts at 0
  ld [vTime], a 
  ld [vTime+1], a 
  ld [vMenuIndex], a
  ld [vMenuIndexPrevious], a 
  
  ld [vSelectedSpreadCard], a
  
  
  ; second starts at 1/3 length which is approximately L/2 - L/4 - L/8 + L/16 ?
  ld hl, Coords
  ld a, [hl]
  ld b, a 
  srl b 
  sub a, b ; L - L/2
  srl b
  sub a, b ; L - L/2 - L/4
  srl b
  add a, b ; L - L/2 - L/4 + L/8
  srl b
  sub a, b ; L - L/2 - L/4 + L/8 - L/16
  srl b
  add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32
  srl b
  sub a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64
  srl b
  add a, b ; L - L/2 - L/4 + L/8 - L/16 + L/32 - L/64 + L/128
  ; that should be approx 1/3 of L !
  ld [vFrameCount2], a 
  
  ; third starts at 2/3 length which is approximately L/2 - L/4 + L/8 - L/16 ?
  ld hl, Coords
  ld a, [hl]
  ld b, a 
  srl b 
  sub a, b ; L - L/2
  srl b
  add a, b ; L - L/2 + L/4
  srl b
  sub a, b ; L - L/2 + L/4 - L/8
  srl b
  add a, b ; L - L/2 + L/4 - L/8 + L/16
  srl b
  sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32
  srl b
  add a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64
  srl b
  sub a, b ; L - L/2 + L/4 - L/8 + L/16 - L/32 + L/64 - L/128
  ; that should be just about 2/3 of L !
  ld [vFrameCount3], a 
  
  ;ld hl, Coords
  ;ld a, [hl] 
  ;srl a 
  ;ldh [vFrameCount4], a 
  
  ld a, 0
  ld [vFrameCountSquares], a 


  ; load graphics into vram for deck face
  ; set up variables: LFSR stuff
  ret ; return from cardreadsetup

MainMenuUpdate:
  ; if pressing a key and unblocked:
  ; signal an animation to start
  ; turn on block
  ; if in animation state:
  ; increment timer
  ; if timer is max, turn off animation state and unblock?
  ld hl, rMYBTNP

  ld a, [vMenuIndex]
  bit 3, [hl]  ; select the down key
  jp z, .doneWithDownInput ; skip the following code if down is not pressed
  inc a 
.doneWithDownInput
  bit 2, [hl] ; select up key %0000_0100
  jp z, .doneWithUpInput ; skip the following code if up is not pressed
  dec a 
.doneWithUpInput
  ld hl, MenuCount
  call ArrayClampLooping
  ld [vMenuIndex], a 
  
  
  ld hl, rMYBTNP
  
  bit 5, [hl] ; button a pressed?
  jp z, .doneWithMenuSelect 
  ld a, [vMenuIndex]
  cp a, 0
  jp z, .option1
  cp a, 1
  jp z, .option2
  cp a, 2
  jp z, .option3
  jp .doneWithMenuSelect
.option1
  ld a, 0 
  ld [vSelectedSpreadIndex], a
  ld hl, ScreenSpreadSelect
  call ChangeScene
  ret
.option2
  ld hl, ScreenShuffle
  call ChangeScene
  ret
.option3
  ld a, 0 
  ld [vSelectedCardIndex], a 
  ld hl, ScreenCardBrowse
  call ChangeScene
  ret
.doneWithMenuSelect
  
  ld a, [rDELTAT]
  ld b, a 
  ld a, [vTime]
  add a, b
  ld [vTime], a 
  ld a, [vTime+1]
  adc a, 0 
  ld [vTime+1], a ; increment time. when the 16bit time register is greater 
  ; than 4096 ($10_00) then one second has passed. so that's satisfied when
  ; vTime+1 is equal to or greater than $10
  
  ld a, [vTime+1]
  cp a, $01
  jp c, .allDone ; if the timer is less than $0100, skip to end
  
  ;otherwise reset the timer
  ld a, 0 
  ld [vTime], a 
  ld [vTime+1], a 
  
  
  ld hl, Coords
  
  ; and advance the frame counts
  ld a, [vFrameCount1]
  inc a
  call ArrayClampLooping
  ld [vFrameCount1], a 
  
  ld a, [vFrameCount2]
  inc a
  call ArrayClampLooping
  ld [vFrameCount2], a 
  
  ld a, [vFrameCount3]
  inc a
  call ArrayClampLooping
  ld [vFrameCount3], a 
  
  ld hl, SquaresTiles
  ld a, [vFrameCountSquares]
  inc a
  call ArrayClampLooping
  ld [vFrameCountSquares], a 
  
  
  
  ld hl, Coords
  inc hl
  ld b, 0 
  ld a, [vFrameCount1]
  ld c, a 
  add hl, bc
  add hl, bc
  add hl, bc
  ld a, [hl+] 
  ld b, a ; y coordinate
  ld a, [hl+]
  ld c, a ; x coordinate
  ld a, [hl+]
  ld e, a ; width
  ld hl, MY_OAM
  call DrawWholeCard
  
  ld hl, Coords
  inc hl
  ld b, 0 
  ld a, [vFrameCount2]
  ld c, a 
  add hl, bc
  add hl, bc
  add hl, bc
  ld a, [hl+] 
  ld b, a ; y coordinate
  ld a, [hl+]
  ld c, a ; x coordinate
  ld a, [hl+]
  ld e, a ; width
  ld hl, MY_OAM + 9*4
  call DrawWholeCard
  
  ld hl, Coords
  inc hl
  ld b, 0 
  ld a, [vFrameCount3]
  ld c, a 
  add hl, bc
  add hl, bc
  add hl, bc
  ld a, [hl+] 
  ld b, a ; y coordinate
  ld a, [hl+]
  ld c, a ; x coordinate
  ld a, [hl+]
  ld e, a ; width
  ld hl, MY_OAM + 18*4
  call DrawWholeCard
  
.allDone
  ret

MainMenuDraw:
  ld de, SAFE_DMA_LOCATION
  ld a, HIGH(MY_OAM) 
  call RunDMA
  
  di
  ld hl, SquaresTiles
  inc hl 
  ld b, 0
  ld a, [vFrameCountSquares]
  ld c, a 
  add hl, bc 
  add hl, bc
  ld c, [hl]
  inc hl
  ld b, [hl]
  ld h, b
  ld l, c
  ld de, $8000+$100*16 + 1*16
  ld bc, (SquaresTileset8 - SquaresTileset7) / 8
  call CopyRangeUnsafeBy8s
  
  ld b, 0
  ld c, 32
  
  ; find the location of the last selected caret and make it blank
  ld hl, $9800 + 32*11 + 3 - 64
  ld a, [vMenuIndexPrevious]
  inc a
.findLastCaret
  add hl, bc
  add hl, bc
  dec a
  jp nz, .findLastCaret
  ld [hl], $0

  ;find the location of the new selected caret and make it a caret
  ; bc contains 32 (row stride of bgmap)
  ld hl, $9800 + 32*11 + 3 - 64
  ld a, [vMenuIndex]
  inc a
.findNewCaret
  add hl, bc
  add hl, bc
  dec a
  jp nz, .findNewCaret
  ld [hl], $80 + $10 + $9
  
  ld a, [vMenuIndex]
  ld [vMenuIndexPrevious], a 
  ei
  ret
  
MainMenuTeardown:
  ret

DrawWholeCard: ; hl memory location, b y, c x, e width, d wiggle
  ld a, e 
  cp a, 32
  ld e, TileStartCardBackSprites24
  jp z, Draw4x4Card
  cp a, 24
  ld e, TileStartCardBackSprites24
  jp z, Draw3x3Card
  cp a, 23
  ld e, TileStartCardBackSprites23
  jp z, Draw3x3Card
  cp a, 22
  ld e, TileStartCardBackSprites22
  jp z, Draw3x3Card
  cp a, 21
  ld e, TileStartCardBackSprites21
  jp z, Draw3x3Card
  cp a, 20
  ld e, TileStartCardBackSprites20
  jp z, Draw3x3Card
  cp a, 19
  ld e, TileStartCardBackSprites19
  jp z, Draw3x3Card
  cp a, 18
  ld e, TileStartCardBackSprites18
  jp z, Draw3x3Card
  cp a, 17
  ld e, TileStartCardBackSprites17
  jp z, Draw3x3Card

  ; else fall through into 2x2card
  ld e, TileStartCardBackSprites16
  jp Draw2x2Card
  
Draw2x2Card:
; hl memory location, b y coord, c x coord, e tile start
  ; top-left
  ld a, $0 
  call DrawTile
  
  xor a, a
  ld [hl+], a
  ld [hl+], a 
  ld [hl+], a 
  ld [hl+], a 
  
  ld a, c 
  add a, 8
  ld c, a
  ld e, TileStartCardBackSprites16
  ld a, $4
  call DrawTile

  ld a, c 
  sub a, 8
  ld c, a ; step back to the left
  
  xor a, a 
  ld [hl+], a
  ld [hl+], a 
  ld [hl+], a 
  ld [hl+], a 
  
  ld [hl+], a
  ld [hl+], a 
  ld [hl+], a 
  ld [hl+], a 
  
  ld [hl+], a
  ld [hl+], a 
  ld [hl+], a 
  ld [hl+], a 
  
  ld a, b
  add a, 16
  ld b, a 
  ld e, TileStartCardBackSprites16
  ld a, $c ; TileStartCardBackSprites8 + $12
  call DrawTile
  
  ld a, 0
  ld [hl+], a
  ld [hl+], a 
  ld [hl+], a 
  ld [hl+], a 
  
  ld a, c 
  add a, 8
  ld c, a
  ld e, TileStartCardBackSprites16
  ld a, $10
  call DrawTile
  ret

Draw3x3Card:
; hl memory location, b y coord, c x coord, e base for tiles, d wiggle

  ;first row
  ; top-left
  ld a, 0
  call DrawTile
  
  ld a, c 
  add a, 8 ; add stride to x
  ld c, a
  ld a, $2
  call DrawTile

  ld a, c 
  add a, 8
  ld c, a
  ld a, $4
  call DrawTile
 
  ;second row 
  ld a, b
  add a, 16
  ld b, a ; add 16 to y coord
  ld a, c 
  sub a, 16
  ld c, a ; restore the state to before we drew the first row
  ld a, $6
  call DrawTile
  
 
  ld a, c 
  add a, 8
  ld c, a 
  ld a, $8
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $a
  call DrawTile
  
  ; third row
  ld a, b
  add a, 16
  ld b, a ; add stridex2 to y coord
  ld a, c 
  sub a, 16
  ld c, a ; subtract stridex2 from x
  ld a, $c
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $e
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $10
  call DrawTile
  ret
  
Draw4x4Card:
; hl memory location, b y coord, c x coord, e base for tiles, d wiggle

  ;first row
  ; top-left
  ld a, 0
  call DrawTile
  
  ld a, c 
  add a, 8 ; add stride to x
  ld c, a
  ld a, $2
  call DrawTile

  ld a, c 
  add a, 8
  ld c, a
  ld a, $2
  call DrawTile

  ld a, c 
  add a, 8
  ld c, a
  ld a, $4
  call DrawTile
 
  ;second row 
  ld a, b
  add a, 16
  ld b, a ; add 16 to y coord
  ld a, c 
  sub a, 24
  ld c, a ; restore the state to before we drew the first row
  ld a, $6
  call DrawTile
 
  ld a, c 
  add a, 8
  ld c, a 
  ld a, $8
  call DrawTile
 
  ld a, c 
  add a, 8
  ld c, a 
  ld a, $8
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $a
  call DrawTile
  
  
  ;second row 
  ld a, b
  add a, 16
  ld b, a ; add 16 to y coord
  ld a, c 
  sub a, 24
  ld c, a ; restore the state to before we drew the first row
  ld a, $6
  call DrawTile
 
  ld a, c 
  add a, 8
  ld c, a 
  ld a, $8
  call DrawTile
 
  ld a, c 
  add a, 8
  ld c, a 
  ld a, $8
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $a
  call DrawTile
  
  ; third row
  ld a, b
  add a, 16
  ld b, a ; add stridex2 to y coord
  ld a, c 
  sub a, 24
  ld c, a ; subtract stridex2 from x
  ld a, $c
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $e
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $e
  call DrawTile
  
  ld a, c 
  add a, 8
  ld c, a
  ld a, $10
  call DrawTile
  ret
  
DrawTile: ; b: y. c: x. a: part id. hl: location of sprite in OAM
  ; e: sprite bank
  ld d, a ; immediateely put the card part id into d
  ld a, e 
.testFor16
  cp a, TileStartCardBackSprites16
  jp nz, .testFor17
  
  ; we're in a 16-width card sprite
  ld a, d 
  cp a, $0
  jp z, .leftSideThreshholds16
  cp a, $6
  jp z, .leftSideThreshholds16
  cp a, $c
  jp z, .leftSideThreshholds16
  cp a, $4
  jp z, .rightSideThreshholds16
  cp a, $a
  jp z, .rightSideThreshholds16
  cp a, $10
  jp z, .rightSideThreshholds16
  jp .skipThisTile
  
  
  
.leftSideThreshholds16
  ld a, c 
  ;cp a, 8+16
  ;jp c, .dontSkip ; we don't have to worry about activating it when it's far to
  ; the left because it'll never be drawn far to the left
  cp a, 8+52
  jp c, .skipThisTile ; left edge < 48 => dont draw
  cp a, 8-8+105 ; right edge < 120 => do draw
  jp c, .dontSkip
  jp .skipThisTile
  
.rightSideThreshholds16
  ld a, c 
  ;cp a, 8+16
  ;jp c, .dontSkip ; we don't have to worry about activating it when it's far to
  ; the left because it'll never be drawn far to the left
  cp a, 8+54
  jp c, .skipThisTile ; left edge < 48 => dont draw
  cp a, 8-8+109 ; right edge < 120 => do draw
  jp c, .dontSkip
  jp .skipThisTile
  

.testFor17
  cp a, TileStartCardBackSprites17
  jp nz, .dontSkip ; if it's not 16 or 17, draw it
  
  ld a, d 
  cp a, $0
  jp z, .leftSideThreshholds17
  cp a, $6
  jp z, .leftSideThreshholds17
  cp a, $c
  jp z, .leftSideThreshholds17
  cp a, $2
  jp z, .middleThreshholds17
  cp a, $8
  jp z, .middleThreshholds17
  cp a, $e
  jp z, .middleThreshholds17
  cp a, $4
  jp z, .rightSideThreshholds17
  cp a, $a
  jp z, .rightSideThreshholds17
  cp a, $10
  jp z, .rightSideThreshholds17
  jp .skipThisTile
  
  
.leftSideThreshholds17
  ld a, c 
  cp a, 8+37 
  jp c, .dontSkip
  cp a, 8+80 
  jp c, .skipThisTile
  ;cp a, 8-17 + 100 ; right edge < 100 => draw
  ;jp c, .dontSkip ; we can comment this one out because wee dont atm need to 
  ; worry about drawing 17-wides in the middle
  cp a, 8-8 + 118 
  jp c, .skipThisTile
  jp .dontSkip ; right edge edge < 168 => draw
  
.middleThreshholds17

  ld a, c 
  cp a, 8+42 ; left edge < 10 => draw 
  jp c, .dontSkip
  cp a, 8+80 ; left edge < 80 => skip
  jp c, .skipThisTile
  ;cp a, 8-17 + 100 ; right edge < 100 => draw
  ;jp c, .dontSkip ; we can comment this one out because wee dont atm need to 
  ; worry about drawing 17-wides in the middle
  cp a, 8-8 + 121 ; right edge < 120 => skip
  jp c, .skipThisTile
  jp .dontSkip ; right edge edge < 168 => draw
  
.rightSideThreshholds17
  ld a, c 
  cp a, 8+80 ; left edge < 10 => draw 
  jp c, .dontSkip
  cp a, 8+80 ; left edge < 80 => skip
  jp c, .skipThisTile
  ;cp a, 8-17 + 100 ; right edge < 100 => draw
  ;jp c, .dontSkip ; we can comment this one out because wee dont atm need to 
  ; worry about drawing 17-wides in the middle
  cp a, 8-8 + 121 ; right edge < 120 => skip
  jp c, .skipThisTile
  jp .dontSkip ; right edge edge < 168 => draw
  
  
.dontSkip
  ld a, e 
  cp a, TileStartCardBackSprites16
  jp nz, .goAheadAndDraw
  ld e, TileStartCardBackSprites24
.goAheadAndDraw
  ld a, b
  ld [hl+], a 
  ld a, c 
  ld [hl+], a 
  ld a, d
  add a, e
  ld [hl+], a 
  ld a, 0 
  ld [hl+], a 
  ret 
  
.skipThisTile
  ld a, 0 
  ld [hl+], a 
  ld [hl+], a 
  inc hl
  inc hl 
  ret

MenuCount:
  db 3
StringRead:
  db 11, "Read Spread"
StringShuffle:
  db 7, "Shuffle"
StringBrowse:
  db 11, "Browse Deck"
Coords: ; y, x, spread
 db 255, $24, $12, $14, $24, $12, $14, $24, $12, $14, $24, $12, $14, $24, $12, $14, $24, $12, $14, $23, $12, $15, $23, $13, $15, $23, $13, $15, $23, $13, $15, $23, $13, $15, $23, $14, $15, $23, $14, $15, $23, $14, $15, $23, $15, $15, $23, $15, $15, $22, $16, $16, $22, $16, $16, $22, $17, $16, $22, $18, $16, $22, $18, $16, $22, $19, $16, $22, $1a, $16, $22, $1a, $16, $22, $1b, $16, $22, $1c, $16, $22, $1d, $16, $22, $1e, $16, $21, $1e, $17, $21, $1f, $17, $21, $20, $17, $21, $21, $17, $21, $22, $17, $21, $23, $17, $21, $24, $17, $21, $25, $17, $21, $27, $17, $21, $28, $17, $21, $29, $17, $21, $2a, $17, $21, $2b, $17, $21, $2c, $17, $21, $2e, $17, $21, $2f, $17, $20, $30, $18, $20, $31, $18, $20, $33, $18, $20, $34, $18, $20, $35, $18, $20, $37, $18, $20, $38, $18, $20, $3a, $18, $20, $3b, $18, $20, $3c, $18, $20, $3e, $18, $20, $3f, $18, $20, $41, $18, $20, $42, $18, $20, $44, $18, $20, $45, $18, $20, $46, $18, $20, $48, $18, $20, $49, $18, $20, $4b, $18, $20, $4c, $18, $20, $4e, $18, $20, $4f, $18, $20, $51, $18, $20, $52, $18, $20, $54, $18, $20, $55, $18, $20, $57, $18, $20, $58, $18, $20, $5a, $18, $20, $5b, $18, $20, $5c, $18, $20, $5e, $18, $20, $5f, $18, $20, $61, $18, $20, $62, $18, $20, $64, $18, $20, $65, $18, $20, $66, $18, $20, $68, $18, $20, $69, $18, $21, $6a, $17, $21, $6c, $17, $21, $6d, $17, $21, $6e, $17, $21, $6f, $17, $21, $71, $17, $21, $72, $17, $21, $73, $17, $21, $74, $17, $21, $75, $17, $21, $76, $17, $21, $77, $17, $21, $78, $17, $21, $7a, $17, $21, $7b, $17, $21, $7b, $17, $22, $7c, $16, $22, $7d, $16, $22, $7e, $16, $22, $7f, $16, $22, $80, $16, $22, $81, $16, $22, $82, $16, $22, $82, $16, $22, $83, $16, $22, $84, $16, $22, $84, $16, $23, $85, $15, $23, $86, $15, $23, $86, $15, $23, $87, $15, $23, $87, $15, $23, $87, $15, $23, $88, $15, $23, $88, $15, $23, $89, $15, $23, $89, $15, $23, $89, $15, $24, $89, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $24, $8a, $14, $25, $8a, $13, $25, $8a, $13, $25, $89, $13, $25, $89, $13, $25, $89, $13, $25, $89, $13, $25, $88, $13, $25, $88, $13, $25, $87, $13, $25, $87, $13, $25, $86, $13, $26, $86, $12, $26, $85, $12, $26, $85, $12, $26, $84, $12, $26, $83, $12, $26, $83, $12, $26, $82, $12, $26, $81, $12, $26, $81, $12, $26, $80, $12, $26, $7f, $12, $27, $7e, $11, $27, $7d, $11, $27, $7c, $11, $27, $7b, $11, $27, $7a, $11, $27, $79, $11, $27, $78, $11, $27, $77, $11, $27, $76, $11, $27, $75, $11, $27, $74, $11, $27, $73, $11, $27, $71, $11, $27, $70, $11, $27, $6f, $11, $27, $6e, $11, $28, $6c, $10, $28, $6b, $10, $28, $6a, $10, $28, $69, $10, $28, $67, $10, $28, $66, $10, $28, $65, $10, $28, $63, $10, $28, $62, $10, $28, $60, $10, $28, $5f, $10, $28, $5e, $10, $28, $5c, $10, $28, $5b, $10, $28, $59, $10, $28, $58, $10, $28, $56, $10, $28, $55, $10, $28, $53, $10, $28, $52, $10, $28, $50, $10, $28, $4f, $10, $28, $4d, $10, $28, $4c, $10, $28, $4a, $10, $28, $49, $10, $28, $48, $10, $28, $46, $10, $28, $45, $10, $28, $43, $10, $28, $42, $10, $28, $40, $10, $28, $3f, $10, $28, $3d, $10, $28, $3c, $10, $28, $3b, $10, $28, $39, $10, $28, $38, $10, $28, $36, $10, $28, $35, $10, $28, $34, $10, $27, $32, $11, $27, $31, $11, $27, $30, $11, $27, $2f, $11, $27, $2d, $11, $27, $2c, $11, $27, $2b, $11, $27, $2a, $11, $27, $28, $11, $27, $27, $11, $27, $26, $11, $27, $25, $11, $27, $24, $11, $27, $23, $11, $27, $22, $11, $27, $21, $11, $26, $20, $12, $26, $1f, $12, $26, $1e, $12, $26, $1d, $12, $26, $1c, $12, $26, $1c, $12, $26, $1b, $12, $26, $1a, $12, $26, $19, $12, $26, $19, $12, $26, $18, $12, $26, $17, $12, $25, $17, $13, $25, $16, $13, $25, $16, $13, $25, $15, $13, $25, $15, $13, $25, $14, $13, $25, $14, $13, $25, $14, $13, $25, $13, $13, $25, $13, $13, $24, $13, $14, $24, $12, $14, $24, $12, $14, $24, $12, $14, $24, $12, $14


CardBackSprites16:
CardBackSprites24:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa ; top-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	
	db $00,$ff,$fe,$ff,$fe,$ff,$06,$ff,$f6,$ff,$56,$bf,$b6,$5f,$56,$bf ; top-right
	db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; middle-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left

	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle

	db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; middle-right
	db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; middle-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff ; bottom-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	db $aa,$55,$55,$aa,$aa,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff ; bottom-middle
	
	db $b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf,$b6,$5f,$56,$bf ; middle-right
	db $b6,$5f,$56,$bf,$b6,$5f,$f6,$ff,$06,$ff,$fe,$ff,$fe,$ff,$00,$ff ; bottom-right
CardBackSprites16End:
CardBackSprites24End:
CardBackSprites23:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa ; top-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	
	db $00,$fe,$fc,$fe,$fc,$fe,$0c,$fe,$ec,$fe,$6c,$be,$ac,$7e,$6c,$be ; top-right
	db $ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be ; middle-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	
	db $ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be ; middle-right
	db $ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be ; middle-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff,$00,$00,$00,$00 ; bottom-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; middle-middle
	db $aa,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$00,$00 ; bottom-middle
	
	db $ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be,$ac,$7e,$6c,$be ; middle-right
	db $ac,$7e,$ec,$fe,$0c,$fe,$fc,$fe,$fc,$fe,$00,$fe,$00,$00,$00,$00 ; bottom-right
CardBackSprites23End:
CardBackSprites22:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa ; top-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle

	db $00,$fc,$f8,$fc,$f8,$fc,$18,$fc,$d8,$fc,$58,$fc,$d8,$7c,$58,$fc ; top-right
	db $d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc ; upper-right

	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left

	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle

	db $d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc ; upper-right
	db $d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc ; upper-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff ; lower-left
	db $60,$ff,$7f,$ff,$7f,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$ff,$ff ; lower-middle
	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-middle
	
	db $d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$58,$fc,$d8,$7c,$d8,$fc ; lower-right
	db $18,$fc,$f8,$fc,$f8,$fc,$00,$fc,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-right
CardBackSprites22End:

CardBackSprites21:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left

	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$aa,$aa,$55,$55,$aa ; top-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle
	
	db $00,$f8,$f0,$f8,$f0,$f8,$30,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8 ; top-right
	db $b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8 ; upper-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$55,$aa ; upper-middle
	
	db $b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8 ; upper-right
	db $b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8 ; upper-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff ; lowere-left
	db $7f,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-left
	
	db $aa,$55,$55,$aa,$aa,$55,$55,$aa,$aa,$55,$ff,$ff,$00,$ff,$ff,$ff ; lower-middle
	db $ff,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottmo-middle
	
	db $b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$b0,$f8,$30,$f8,$f0,$f8 ; lower-right
	db $f0,$f8,$00,$f8,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-right
CardBackSprites21End:
CardBackSprites20:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middel-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$ff,$ff,$55,$ab,$ab,$55,$55,$ab ; top-middle
	db $ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab ; middle-middle
	
	db $00,$f0,$e0,$f0,$e0,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0 ; top-right
	db $60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0 ; middle-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middel-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middel-left
	
	db $ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab ; middle-middle
	db $ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab,$ab,$55,$55,$ab ; middle-middle
	
	db $60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0 ; middle-right
	db $60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0 ; middle-right

	db $6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff ; bottom-left
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty

	db $ab,$55,$55,$ab,$ab,$55,$ff,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff ; bottom-middle
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
	
	db $60,$f0,$60,$f0,$60,$f0,$60,$f0,$60,$f0,$e0,$f0,$e0,$f0,$00,$f0 ; bottom-right
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
CardBackSprites20End:
CardBackSprites19:
db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left

	db $00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$fe,$ff,$56,$ab,$aa,$57,$56,$ab ; top-middle
	db $aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab ; middle-middle

	db $00,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0 ; top-rihgt
	db $c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0 ; middle-right

	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left

	db $aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab ; middle-middle
	db $aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab,$aa,$57,$56,$ab ; middle-middle

	db $c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0 ; middle-right
	db $c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0 ; middle-right

	db $6a,$fd,$6f,$ff,$60,$ff,$7f,$ff,$7f,$ff,$00,$ff,$00,$00,$00,$00 ; lower-left
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty

	db $aa,$57,$fe,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$00,$00 ; lower-middle
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty

	db $c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$c0,$e0,$00,$e0,$00,$00,$00,$00 ; lower-right
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
CardBackSprites19End:
CardBackSprites18:
	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa; top-left 
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$01,$ff,$fd,$ff,$55,$af,$ad,$57,$55,$af ; top-middle
	db $ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$55,$af ; upper-m,iddle
	
	db $00,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0 ; top-right
	db $80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0 ; upper-right
	
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; upper-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff ; lower-left
	
	db $ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$55,$af ; upper-m,iddle
	db $ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$55,$af,$ad,$57,$fd,$ff ; lower-middle
	
	db $80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0 ; lower-right
	db $80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0,$80,$c0 ; upper-right
	
	db $60,$ff,$7f,$ff,$7f,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-left
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; under-left
	
	db $01,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-middle
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; under-middle
	
	db $80,$c0,$80,$c0,$80,$c0,$00,$c0,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-right
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; under-right
	

	
CardBackSprites18End:
CardBackSprites17:

	db $00,$ff,$7f,$ff,$7f,$ff,$60,$ff,$6f,$ff,$6d,$fa,$6a,$fd,$6d,$fa ; top-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	
	db $00,$ff,$ff,$ff,$ff,$ff,$03,$ff,$fb,$ff,$5b,$af,$ab,$5f,$5b,$af ; top-middle
	db $ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af ; middle-middle
	
	db $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 ; top-rihgt
	db $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 ; middle-rihgt

	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa ; middle-left
	db $6a,$fd,$6d,$fa,$6a,$fd,$6d,$fa,$6a,$fd,$6f,$ff,$60,$ff,$7f,$ff ; lower-left
	
	db $ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$5b,$af ; middle-middle
	db $ab,$5f,$5b,$af,$ab,$5f,$5b,$af,$ab,$5f,$fb,$ff,$03,$ff,$ff,$ff ; lower-middle
	
	db $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 ; middle-rihgt
  db $00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80,$00,$80 ; lower-rihgt

	db $7f,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-left 
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
	
	db $ff,$ff,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-middle
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
	
	db $00,$80,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; bottom-right
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 ; empty
CardBackSprites17End:
SquaresTiles:
  db 8
  dw SquaresTileset1
  dw SquaresTileset2
  dw SquaresTileset3
  dw SquaresTileset4
  dw SquaresTileset5
  dw SquaresTileset6
  dw SquaresTileset7
  dw SquaresTileset8

SquaresTileset1:
	db $fe,$00,$82,$00,$82,$00,$82,$00,$82,$00,$82,$00,$fe,$00,$00,$00

SquaresTileset2:
	db $00,$00,$7f,$00,$41,$00,$41,$00,$41,$00,$41,$00,$41,$00,$7f,$00

SquaresTileset3:
	db $bf,$00,$00,$00,$bf,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00,$a0,$00
	
SquaresTileset4:
	db $50,$00,$df,$00,$00,$00,$df,$00,$50,$00,$50,$00,$50,$00,$50,$00
	
SquaresTileset5:
	db $28,$00,$28,$00,$ef,$00,$00,$00,$ef,$00,$28,$00,$28,$00,$28,$00

SquaresTileset6:
	db $14,$00,$14,$00,$14,$00,$f7,$00,$00,$00,$f7,$00,$14,$00,$14,$00

SquaresTileset7:
	db $0a,$00,$0a,$00,$0a,$00,$0a,$00,$fb,$00,$00,$00,$fb,$00,$0a,$00

SquaresTileset8:
	db $05,$00,$05,$00,$05,$00,$05,$00,$05,$00,$fd,$00,$00,$00,$fd,$00

SquaresTilesetEnd:


MainUITilemap:
  db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	db $01, $01, $09, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $02, $08, $01, $01
	db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
	db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
	db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
	db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
	db $01, $01, $03, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $04, $01, $01
	db $01, $01, $06, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $05, $07, $01, $01
	db $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01
	
MainUITilemapEnd: