; my magnum opus... my greatest work. gaze upon it and despair
; this is such a tangled (not really) mess of lookup tables and case switches
; which is impressive given thta i don't hvae those in assembly.
; there's a matrix of speesd that determines how fast sprites move across 
; the globe to make it look like it's really rotating andd not just madde of 
; sliding segments. i'm very proud of this not because it's good code but
; because it works.

TheWorld:
  db 10, "THE WORLD "
  db 10, "          "
  db 9, "success  "
  db 9, "wholeness"
  db 9, "travel   "
  dw .BackgroundCopyEnd - .BackgroundCopy
  dw .BackgroundCopy
  dw .KeyArtTilesEnd - .KeyArtTiles
  dw .KeyArtTiles
  dw .SpriteTilesEnd - .SpriteTiles
  dw .SpriteTiles
  dw .fInit
  dw .fUpdate
  dw .fDraw
  
.fInit: 
  ld hl, CVS
  ld a, 0
  ld [hl+], a ; CVS timer 
  ld [hl+], a ; 
  ld [hl+], a ; CVS + 2 frame index for rotating earth
  ld [hl+], a ; CVS + 3 flag for whether we've run out of OAM
  
  
  
  ld hl, MY_OAM
.priorityLoop
  inc hl
  inc hl
  inc hl
  set OAMB_PRI, [hl]
  inc hl 
  ld a, l 
  cp a, $9F
  jp c, .priorityLoop

  ret
.fUpdate: 
  ld hl, CVS
  call IncrementTimer
  
  ld a, [CVS+1] ; checking the high byte of the timer
  cp a, $01 ; $10 = 1 second, $02 = 1/8 of a second
  ret c
  
  ld a, 0 
  ld [CVS], a 
  ld [CVS+1], a 
  
  ld b, 80
  ld a, [CVS+2]
  dec a 
  call ArrayClampLoopingB
  ld [CVS+2], a 


  call .rotate
  
  call .cleanNonVisibleTiles
  
  call .spawnNewTiles
 
  ret  

.spawnNewTiles:
  ; spawn whatever new stripe of tiles is indicated in the map structure
  ld a, [CVS+2]
  ld b, a 
  ld hl, .map
.loopFindCurrentStripes
  ld a, [CVS+2]
  ld b, a 
  ld a, [hl] ; hl points at a timing index
  cp a, 255
  jp z, .doneSpawningStripe ; if it's 255 then we've reached the end of the list
  cp a, b
  jp z, .foundOne ; if it's =[CVS+2] then we've found a stripe that should be spawned now
  inc hl ; now hl points at LOW(stripe address)
  inc hl ; now hl points at HIGH(stripe address)
  inc hl ; now hl points at a timing index
  jp .loopFindCurrentStripes ; look at the next one
.foundOne
  inc hl ; now hl points at LOW(stripe address)
  ld c, [hl]
  inc hl ; now hl points at HIGH(strpie address)
  ld b, [hl]
  push hl ; save our location from the map list...
  ld h, b 
  ld l, c
  
  ; hl holdds the addrerss of a map stripe in memory, linearly packed
  call .BuildMapStripe
  pop hl ; rerstore the map list memory location
  inc hl ; now hl points at a timing index
  jp .loopFindCurrentStripes ; look at the next one
.doneSpawningStripe
  ret
  
.BuildMapStripe:
  ; go through MY_OAM aand fiind six unused sprites, and draw our candidate
  ; sprites in those slots.
  ; each time we need to check if our counter (b) is six 
  ; and also if we're outsidde the dedicated OAM space (not as important maybe)

  ; hl points to a list of six tile ids
  ld b, 0
  ld d, h
  ld e, l 
  ld hl, MY_OAM
  
.spriteLoop
  ld a, [hl]
  cp a, 0 
  jp nz, .skipToNextSlot ; if the y value of the slot we're in is not zero, 
  ; we have to skip this OAM slot
  ld a, 6 ; STRPES ARE SIX TILIES TALLL
  cp a, b 
  ret z ; if we'rer trying to draw sprite 6 in our stripe, we're done
  
  ld a, [de] 
  cp a, 0
  jp z, .doneDrawingSprite ; if the tile we're trying to draw is id 0, we're done
  ; else, fill this slot with the correct sprite.
  ; six way branch based on what position in the stripe we're at
  ld a, b
: cp a, 0
  jp nz, :+
  
  ld [hl], (2+1+5)*8 ; y
  inc hl 
  ld [hl], (1+1+1)*8 + 2; x
  inc hl 
  ld a, [de]
  ld [hl], a
  ld a, 255
: cp a, 1
  jp nz, :+
  
  ld [hl], (2+1+6)*8 ; y
  inc hl 
  ld [hl], (1+1+0)*8+4; x
  inc hl 
  ld a, [de]
  ld [hl], a
  
  ld a, 255
: cp a, 2
  jp nz, :+
  
  ld [hl], (2+1+7)*8 ; y
  inc hl 
  ld [hl], (1+1+0)*8+1; x
  inc hl 
  ld a, [de]
  ld [hl], a
  
  ld a, 255
: cp a, 3
  jp nz, :+
  
  ld [hl], (2+1+8)*8 ; y
  inc hl 
  ld [hl], (1+1+0)*8+1; x
  inc hl 
  ld a, [de]
  ld [hl], a
  
  ld a, 255
: cp a, 4
  jp nz, :+
  
  ld [hl], (2+1+9)*8 ; y
  inc hl 
  ld [hl], (1+1+0)*8+4; x
  inc hl 
  ld a, [de]
  ld [hl], a
  
  ld a, 255
: cp a, 5
  jp nz, :+
  
  ld [hl], (2+1+10)*8 ; y
  inc hl 
  ld [hl], (1+1+1)*8 + 2; x
  inc hl 
  ld a, [de]
  ld [hl], a
  
  ld a, 255
: 
  inc hl ; now it's pointing at the attributes
  ;set OAMB_PRI, [hl]
  inc hl ; now it's pointing at the next OAM slot
.doneDrawingSprite
  inc de ; move to the next sprite in the strip
  inc b ; increment our sprite-in-strip counter
  jp .checkIfOutOfOAM
  
.skipToNextSlot
  inc hl
  inc hl
  inc hl 
  inc hl
  jp .checkIfOutOfOAM
  
.checkIfOutOfOAM
  ld a, l 
  cp a, $9F
  jp c, .spriteLoop
  
  ret ; if we're out of oam we're done!


.rotate:
  ; move all currently visible sprites according to the rotation behavior.
  ld hl, MY_OAM
.loop
  ld a, [hl] ; y value
  cp a, 0
  jp nz, :+
  inc hl ; x
  inc hl ; tile id 
  inc hl ; attrs
  inc hl ; next oam value
  
  ld a, l 
  cp a, $9F
  ret nc
  jp .loop
:
  ld b, [hl] ; y value
  inc hl 
  ld c, [hl] ; x value
  
  push hl
  ld hl, .speedMatrix
  call .GetOffsetForMatrix
  pop hl
  ld b, a ; b now holds the speed matrrix value
  
  ld a, [CVS+2]
  and a, $01
  ld d, a ; every-other-frame bit
  ld a, [CVS+2]
  and a, $03
  inc a 
  sra a
  sra a
  ld e, a ; every-fourth-frame bit
  
  ld a, [hl] ; x value to modify
  bit 0, b 
  jp z, :+
  add a, 1
: bit 1, b
  jp z, :+
  add a, d
: bit 2, b 
  jp z, :+
  add a, e
:
  ld [hl], a 
 
.done
  inc hl ; now ponting at tile id
  inc hl ; now pointing at attrs
  inc hl
  ld a, l 
  cp a, $A0
  jp nz, .loop
  
  ret
  
.cleanNonVisibleTiles:
  ld hl, MY_OAM
  ; go through MY_OAM and, for any which aren't still visible, set their
  ; y value to zero.
  ; this could probably be rewritten as a simpler lookup table if we rewrote it 
  ; using jp hl and pointer math rather than explicitly listing all the possibilities
.cleanUpLoop
  ld a, [hl] ; a is the y value and hl points to y
: cp a, (2+1+5)*8
  jp nz, :+ ; if the y value doesn't match our target, try the next check 
  inc hl
  ld a, [hl-] ; a is the x value and hl points to x
  cp a, (1+1+5)*8+6
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: cp a, (2+1+6)*8
  jp nz, :+
  inc hl
  ld a, [hl-] ; a is the x value and hl points to x
  cp a, (1+1+6)*8+4
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: cp a, (2+1+7)*8
  jp nz, :+
  inc hl
  ld a, [hl-] ; a is the x value and hl points to x
  cp a, (1+1+7)*8+4
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: cp a, (2+1+8)*8
  jp nz, :+
  inc hl
  ld a, [hl-] ; a is the x value and hl points to x
  cp a, (1+1+7)*8+4
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: cp a, (2+1+9)*8
  jp nz, :+
  inc hl
  ld a, [hl-] ; a is the x value and hl points to x
  cp a, (1+1+6)*8+4
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: cp a, (2+1+10)*8
  jp nz, :+
  inc hl
  ld a, [hl-] ; a is the x value and hl points to y
  cp a, (1+1+5)*8+6
  jp c, .nextTile ; if x value is not less than the threshold, 
  ; skip this tile and look at the next tile
  
  ; else, the x value is <= the threshhold, so we put it in baby jail
  ld [hl], 0 ; set y to zero
  jp .nextTile
: 
.nextTile
  inc hl 
  inc hl 
  inc hl 
  inc hl 
  ld a, $A0 
  cp a, l 
  jp nz, .cleanUpLoop
  ret
  


.GetOffsetForMatrix:
  ; b has y, c has x, hl has a 6x6 matrix of bytes.
  ; when this is done hl will point to the individual byte we want
  ; subtract (2+1+5)*8 from b, then divide by 8
  ; subtract (1+1+1)*8 from c, then divide by 8.
  ld a, b
  sub a, (2+1+5)*8
  sra a 
  sra a 
  sra a 
  cp a, 5
  jp c, :+
  ld a, 5  
: ld b, a 
  
  ld a, c 
  sub a, (1+1+0)*8
  sra a 
  sra a 
  sra a 
  cp a, 6
  jp c, :+
  ld a, 6  
: ld c, a
  
  ld d, 0 
  ld a, 0
  add a, b
  add a, b
  add a, b
  add a, b
  add a, b
  add a, b ; a = 6*b
  add a, b
  ld e, a 
  
  add hl, de 
  
  ld d, 0
  ld e, c 
  
  add hl, de
  
  ld a, [hl]
  
  ret
  
.speedMatrix 
  ; bits are  
  ; 1s: normal speed, 
  ; 2s: 50% boost
  ; 4s: 25% boost
  db %0000_0111, %0000_0110, %0000_0110, %0000_0001, %0000_0110, %0000_0110, %0000_0111
  db %0000_0001, %0000_0101, %0000_0101, %0000_0101, %0000_0101, %0000_0101, %0000_0001
  db %0000_0101, %0000_0101, %0000_0011, %0000_0011, %0000_0011, %0000_0101, %0000_0101
  db %0000_0101, %0000_0101, %0000_0011, %0000_0011, %0000_0011, %0000_0101, %0000_0101
  db %0000_0001, %0000_0101, %0000_0101, %0000_0101, %0000_0101, %0000_0101, %0000_0001
  db %0000_0111, %0000_0110, %0000_0110, %0000_0001, %0000_0110, %0000_0110, %0000_0111


.map
  db 0
  dw .stripes
  db 5
  dw .stripes + 6
  db 10
  dw .stripes + 12
  db 15
  dw .stripes + 18
  db 20
  dw .stripes + 24
  db 25
  dw .stripes + 30
  db 30
  dw .stripes + 36
  db 35
  dw .stripes + 42
  db 40
  dw .stripes + 48
  db 45
  dw .stripes + 54
  db 50
  dw .stripes + 60
  db 55
  dw .stripes + 66
  db 60
  dw .stripes + 72
  db 65
  dw .stripes + 78
  db 70
  dw .stripes + 84
  db 75
  dw .stripes + 90
  db 255
  
.stripes
db $02, $05, $00, $00, $00, $00
db $03, $06, $07, $00, $00, $33
db $04, $0a, $08, $0c, $00, $2c
db $09, $0b, $0d, $0e, $10, $00
db $12, $00, $00, $0f, $11, $00
db $00, $13, $17, $00, $00, $2d
db $1c, $14, $18, $1a, $00, $2e
db $1d, $15, $19, $1b, $00, $2f
db $24, $16, $00, $00, $00, $00
db $25, $1e, $1f, $00, $00, $00
db $26, $20, $21, $00, $00, $32
db $22, $23, $2b, $27, $29, $30
db $34, $37, $00, $28, $2a, $31
db $35, $38, $00, $00, $39, $00
db $36, $00, $00, $00, $00, $00
.fDraw: ret
.SpriteTiles:
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff
	db $00,$00,$03,$03,$0f,$0f,$ff,$ff,$ff,$ff,$ff,$ff,$7f,$7f,$1f,$1f
	db $00,$00,$f0,$f0,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $00,$00,$3e,$3e,$ff,$ff,$f7,$ff,$d5,$ff,$ea,$ff,$d1,$ff,$ff,$ff
	db $03,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $cf,$ff,$e7,$ff,$73,$7f,$19,$1f,$0f,$0f,$0e,$0f,$06,$07,$06,$05
	db $06,$05,$06,$05,$07,$04,$07,$04,$03,$03,$01,$01,$00,$00,$00,$00
	db $f2,$7e,$fe,$fe,$ee,$ee,$c6,$c6,$e0,$e0,$f0,$f0,$ff,$ff,$01,$01
	db $00,$00,$00,$00,$fc,$fc,$58,$f8,$b0,$f0,$60,$e0,$80,$80,$00,$00
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fa,$fa,$fd,$3d,$fd,$1f,$fb,$1f
	db $80,$80,$e0,$e0,$e0,$e0,$e0,$e0,$c0,$c0,$80,$80,$00,$00,$00,$00
	db $01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$80,$80,$f8,$f8
	db $fe,$fe,$e3,$ff,$61,$ff,$60,$ff,$30,$ff,$b3,$ff,$bf,$ff,$bf,$ff
	db $00,$00,$80,$80,$c0,$c0,$40,$c0,$e0,$e0,$e0,$e0,$c0,$c0,$c0,$c0
	db $5f,$7f,$5f,$7f,$5f,$73,$bc,$e4,$f0,$c0,$e0,$c0,$c0,$80,$80,$80
	db $80,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $7f,$41,$7f,$41,$7f,$40,$3f,$00,$3f,$31,$1f,$13,$1e,$12,$00,$00
	db $01,$01,$03,$03,$0f,$0f,$0e,$0e,$00,$00,$03,$03,$0f,$0e,$1f,$10
	db $ff,$ff,$f2,$f2,$02,$02,$00,$00,$00,$00,$ff,$ff,$ff,$06,$ff,$00
	db $ff,$ff,$bb,$ba,$3b,$3a,$1f,$1f,$3c,$34,$7f,$61,$df,$d0,$ef,$68
	db $ff,$e0,$ff,$00,$ff,$00,$ff,$c0,$3f,$3e,$07,$07,$81,$81,$01,$01
	db $1f,$10,$1f,$10,$1f,$18,$0f,$0f,$03,$03,$00,$00,$00,$00,$00,$00
	db $ff,$00,$ff,$00,$ff,$30,$ff,$fc,$cf,$cd,$0f,$0f,$07,$07,$0f,$0f
	db $f2,$32,$f0,$00,$fa,$0a,$fe,$3e,$fe,$3e,$fe,$fe,$fe,$fe,$fc,$fc
	db $07,$07,$0f,$0f,$07,$07,$07,$07,$0f,$0f,$0f,$0d,$07,$04,$03,$02
	db $fc,$fc,$fc,$fc,$fc,$fc,$fc,$fc,$fd,$fd,$f9,$99,$f1,$11,$e0,$00
	db $00,$00,$01,$01,$01,$01,$03,$03,$46,$46,$c0,$c0,$87,$87,$1f,$1f
	db $00,$00,$80,$80,$df,$df,$fb,$ff,$73,$7f,$e7,$ff,$cf,$ff,$df,$ff
	db $ff,$02,$ff,$04,$f3,$0c,$f9,$0f,$fc,$3f,$fe,$ff,$ff,$ff,$f8,$f8
	db $f0,$f0,$e0,$e0,$c0,$c0,$00,$00,$20,$20,$60,$60,$00,$00,$00,$00
	db $ff,$63,$ff,$03,$ff,$07,$ff,$0f,$fb,$8f,$76,$fe,$fc,$fc,$f8,$f8
	db $78,$78,$38,$38,$38,$38,$20,$20,$20,$20,$30,$30,$18,$18,$08,$08
	db $0c,$0c,$ff,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$ff,$fc,$fc,$e0,$e0,$c0,$c0,$70,$70,$18,$18,$00,$00,$00,$00
	db $00,$00,$0f,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $3f,$00,$ff,$00,$ff,$f0,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $fc,$00,$ff,$00,$ff,$01,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$f1
	db $03,$03,$00,$00,$e0,$e0,$07,$07,$1f,$1f,$3f,$31,$7f,$60,$ff,$e0
	db $fe,$fe,$00,$00,$00,$00,$08,$08,$08,$08,$9c,$9c,$fe,$fe,$ff,$07
	db $ff,$e4,$7f,$7f,$38,$38,$10,$10,$00,$00,$00,$00,$00,$00,$00,$00
	db $ff,$03,$ff,$c3,$fe,$fe,$3c,$3c,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$10,$10,$c0,$c0,$8f,$8f
	db $00,$00,$00,$00,$03,$03,$0e,$0e,$fc,$fc,$f8,$f8,$fe,$fe,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$ff,$ff,$ff,$ff,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$e0,$e0,$ff,$ff,$ff,$ff,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f3,$f3,$ff,$ff,$00,$00
	db $00,$00,$00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00
	db $00,$00,$00,$00,$00,$00,$f0,$f0,$f8,$f8,$d8,$d8,$c0,$c0,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$ff,$ff,$00,$00
	db $00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$07,$07,$07,$07,$00,$00
	db $00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$e0,$e0
	db $00,$00,$e0,$e0,$fc,$fc,$fc,$fc,$f8,$f8,$e0,$e0,$00,$00,$00,$00
	db $f8,$f8,$00,$00,$00,$00,$00,$00,$20,$20,$20,$20,$60,$60,$c0,$c0
	db $60,$60,$60,$60,$60,$60,$c0,$c0,$00,$00,$00,$00,$00,$00,$00,$00
	db $00,$00,$00,$00,$06,$06,$02,$02,$06,$06,$0c,$0c,$18,$18,$00,$00
.SpriteTilesEnd:
; original export script by gabriel reis, modified by shoofle
 
.KeyArtTiles:
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00
	db $ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$07,$ff,$07,$ff,$07,$ff,$07
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$00,$ff,$00,$ff,$80,$ff,$80,$ff,$c0,$ff,$f8,$ff,$ff,$ff,$ff
	db $ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$04
	db $ff,$00,$ff,$00,$ff,$07,$ff,$07,$ff,$07,$ff,$07,$ff,$07,$ff,$0f
	db $ff,$0f,$ff,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$80,$ff,$80,$ff,$c0,$ff,$f0,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$c0,$ff,$f0,$ff,$f8
	db $ff,$06,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$07,$ff,$0f,$ff,$3f
	db $ff,$3f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fe,$fe
	db $ff,$ff,$fe,$fe,$fd,$fd,$ea,$ea,$d4,$d4,$a0,$a0,$50,$50,$a0,$a0
	db $e0,$e0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $07,$07,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $ff,$ff,$7f,$7f,$1f,$1f,$07,$07,$03,$03,$00,$00,$00,$00,$00,$00
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$7f,$7f,$3f,$3f
	db $fe,$fe,$fd,$fd,$fa,$fa,$fd,$fd,$fa,$fa,$d5,$d5,$fa,$fa,$f5,$f5
	db $a0,$a0,$00,$00,$80,$80,$00,$00,$80,$80,$00,$00,$00,$00,$00,$00
	db $1f,$1f,$1f,$1f,$0f,$0f,$07,$07,$07,$07,$03,$03,$03,$03,$01,$01
	db $fc,$fc,$aa,$aa,$f4,$f4,$aa,$aa,$f4,$f4,$ea,$ea,$74,$74,$aa,$aa
	db $01,$01,$01,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $fc,$fc,$aa,$aa,$74,$74,$aa,$aa,$f4,$f4,$ea,$ea,$f4,$f4,$aa,$aa
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$01,$01,$01,$01,$01
	db $ee,$ee,$f5,$f5,$fa,$fa,$f5,$f5,$fa,$fa,$fd,$fd,$fa,$fa,$fd,$fd
	db $00,$00,$00,$00,$00,$00,$00,$00,$80,$80,$00,$00,$80,$80,$40,$40
	db $01,$01,$03,$03,$03,$03,$07,$07,$07,$07,$0f,$0f,$1f,$1f,$1f,$1f
	db $ff,$ff,$fe,$fe,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $40,$40,$80,$80,$50,$50,$e8,$e8,$f4,$f4,$f8,$f8,$ff,$ff,$ff,$ff
	db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff
	db $00,$00,$00,$00,$00,$00,$03,$03,$07,$07,$1f,$1f,$7f,$7f,$ff,$ff
	db $3f,$3f,$7f,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$0f
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fe,$ff,$f8,$ff,$f0,$ff,$f0
	db $ff,$ff,$ff,$ff,$ff,$ff,$ff,$e7,$ff,$00,$ff,$00,$ff,$00,$ff,$00
	db $ff,$07,$ff,$03,$ff,$03,$ff,$02,$ff,$00,$ff,$00,$ff,$00,$ff,$00
	db $ff,$ff,$ff,$ff,$ff,$cf,$ff,$07,$ff,$03,$ff,$01,$ff,$00,$ff,$00
	db $ff,$ff,$f8,$f8,$fd,$fd,$fc,$fc,$fe,$fe,$fe,$fe,$ff,$1f,$ff,$0f
	db $ff,$ff,$00,$00,$f6,$f6,$e6,$e6,$ef,$ef,$4f,$4f,$5f,$5f,$1f,$1f
	db $ff,$ff,$00,$00,$fb,$fb,$73,$73,$77,$77,$27,$27,$af,$af,$8f,$8f
	db $ff,$ff,$1f,$1f,$3f,$3f,$3f,$3f,$3f,$3f,$3f,$3e,$3f,$38,$3f,$38
	db $ff,$e0,$ff,$e0,$ff,$e0,$ff,$e0,$ff,$80,$ff,$00,$ff,$00,$ff,$00
	db $ff,$0f,$ff,$0f,$ff,$0f,$fe,$0e,$fe,$0e,$fc,$0c,$f8,$08,$ff,$0f
	db $bf,$bf,$1f,$1f,$5f,$5f,$4f,$4f,$ef,$ef,$e6,$e6,$00,$00,$ff,$ff
	db $df,$df,$8f,$8f,$af,$af,$27,$27,$77,$77,$73,$73,$00,$00,$ff,$ff
	db $3f,$38,$3f,$38,$3f,$30,$3f,$30,$3f,$30,$3f,$30,$1f,$10,$ff,$f0
	db $1f,$1f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $ff,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $fd,$fd,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $dd,$dd,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $55,$55,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
	db $11,$11,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
.KeyArtTilesEnd:

.BackgroundCopy: ; tiles start at 26
	db $1b, $1b, $1c, $1d, $1d, $1e, $1b, $1b
	db $1f, $20, $21, $1d, $1d, $1d, $22, $23
	db $24, $25, $1d, $1d, $1d, $1d, $1d, $1d
	db $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d
	db $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d
	db $1d, $26, $27, $28, $29, $2a, $2b, $1d
	db $1d, $2c, $2d, $1a, $1a, $1a, $2e, $1d
	db $1d, $2f, $1a, $1a, $1a, $1a, $30, $1d
	db $1d, $31, $1a, $1a, $1a, $1a, $32, $1d
	db $1d, $33, $34, $1a, $1a, $1a, $35, $1d
	db $1d, $36, $37, $38, $38, $39, $3a, $1d
	db $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d
	db $1d, $1d, $1d, $1d, $1d, $1d, $1d, $1d
	db $3b, $1d, $1d, $1d, $1d, $1d, $3c, $3d
	db $3e, $3f, $40, $41, $42, $43, $44, $1b
	db $1b, $1b, $45, $46, $47, $48, $1b, $1b

.BackgroundCopyEnd: