Advertisement
Zeda

TileMap1

Jan 4th, 2012
448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;=====================================================
  2. TileMap1:
  3. ;=====================================================
  4. ;Inputs:
  5. ;     DE=MapLoc
  6. ;     BC=TileLoc
  7. ;     HL=MapWidth
  8. ;     A=TileLogic
  9. ;     (TempWord2)=Map X
  10. ;     (TempWord3)=Map Y
  11. ;=====================================================
  12.      and 7
  13.      ld (TempWord1),a
  14.      push bc
  15.      push hl
  16.      push de
  17.      ld bc,(TempWord3)
  18.      call HL_Times_BC
  19.      ld bc,(TempWord2)
  20.      add hl,bc
  21.      pop bc \ add hl,bc
  22.      pop de \ push hl
  23.      ld hl,-12 \ add hl,de
  24.      pop de
  25.      ld (TempWord2),hl
  26.      xor a \ ld (TempWord1+1),a
  27.      pop bc
  28. ;DE points to first Map Element
  29. ;(TempWord2) is the map width thing
  30. ;BC points to the sprite data    
  31. TileMap1loop:
  32.    ld h,12
  33.      ld a,(de) \ inc de
  34.      dec h
  35.      jr nz,$+9
  36.        ld hl,(TempWord2)
  37.        add hl,de
  38.        ex de,hl
  39.        ld h,12
  40.      push hl
  41.      ld h,0 \ ld l,a
  42.      add hl,hl
  43.      add hl,hl
  44.      add hl,hl
  45.      add hl,bc
  46.      ld a,(TempWord1+1)
  47.      call DrawTile
  48.      ld (TempWord1+1),a
  49.      pop hl
  50.      jr nz,TileMap1Loop+2
  51.      ret
  52. DrawTile:
  53. ;Input:
  54. ;     A is the tile number to draw plus
  55. ;     HL points to the sprite data
  56. ;Output:
  57. ;     A is incremented by 1
  58. ;     BC is not changed
  59. ;     DE is not changed
  60. ;     HL is not changed
  61. ;     z flag set if A is 96
  62.      cp 96 \ ret z
  63.      push af
  64.      push hl
  65.      push de
  66.      push bc
  67.      ex de,hl
  68. ;DE points to sprite
  69.      ld c,a \ ld l,12
  70.      call C_Div_L
  71. ;a+bc*96
  72.      ld h,b \ ld l,c
  73.      add hl,hl \ add hl,bc
  74.      add hl,hl \ add hl,hl
  75.      add hl,hl \ add hl,hl
  76.      add hl,hl
  77.      ld c,a \ add hl,bc
  78.      ld bc,(BufPtr)
  79.      add hl,bc
  80.      ld bc,0108h
  81.      ld a,(TempWord1)
  82.      call DrawSpriteXxY
  83.      pop bc
  84.      pop de
  85.      pop hl
  86.      pop af
  87.      inc a
  88.      ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement