Advertisement
Guest User

Untitled

a guest
Jan 14th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub drawBackground
  2.     'HELP MY BRAIN IS MELTING
  3.     Dim As Integer Offset
  4.     Dim As Integer tileDrawn 'Offset for the number of tiles drawn already so we don't overwrite shit
  5.     If (cpu.memory(&h2000) Shr 4) = 0 Then Offset = 0 Else Offset = &h1000 'Background pattern Address
  6.     If cpu.memory(&h2002) Shr 7  = 0 Then
  7.     Do
  8.     For i As UByte = 0 To 7 'Draw 8 pixels
  9.     'Ok, so this next line is a bit crazy
  10.     ppu.background(ppu.tilesDrawn * 8 + i,(ppu.tilesDrawn * 8)/256) = (ppu.pattern(ppu.VRAM(offset + ppu.tilesDrawn)) Shr (7-i)And 1) 'Fills n - rows with the low bit of pixels
  11.     ppu.background(ppu.tilesDrawn * 8 + i,(ppu.tilesDrawn * 8)/256) or= (ppu.pattern(ppu.VRAM(offset + ppu.tilesDrawn + 8)) Shr (7-i)And 1) 'Same as above but for high bit
  12.     rowsDrawn += 1
  13.     next
  14.     Loop While ppu.tilesToDraw > 0
  15.     endif
  16. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement