TileMap1.z80 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. cp 7
  15. jr nz,+_
  16. ld a,(flags+33)
  17. xor 16
  18. ld (flags+33),a
  19. _:
  20. push bc
  21. push hl
  22. push de
  23. ld bc,(TempWord3)
  24. call HL_Times_BC
  25. ld bc,(TempWord2)
  26. add hl,bc
  27. pop bc \ add hl,bc
  28. ex (sp),hl ;edited in 2.50.0.2
  29. ld de,-12 ;
  30. add hl,de ;
  31. pop de ;
  32. ld (TempWord2),hl
  33. xor a
  34. ld (TempWord1+1),a
  35. pop bc
  36. ;DE points to first Map Element
  37. ;(TempWord2) is the map width thing
  38. ;BC points to the sprite data
  39. ld h,12
  40. TileMap1loop:
  41. ld a,(de) \ inc de
  42. dec h
  43. jr nz,DrawNextTile
  44. ld hl,(TempWord2)
  45. add hl,de
  46. ex de,hl
  47. ld h,12
  48. DrawNextTile:
  49. push hl
  50. ld h,0 \ ld l,a
  51. add hl,hl
  52. add hl,hl
  53. add hl,hl
  54. ld a,(TempWord1)
  55. cp 7
  56. jr nz,+_
  57. add hl,hl
  58. _:
  59. add hl,bc
  60. ld a,(TempWord1+1)
  61. call DrawTile
  62. ld (TempWord1+1),a
  63. pop hl
  64. jr nz,TileMap1Loop
  65. ret
  66. DrawTile:
  67. ;Input:
  68. ; A is the tile number to draw
  69. ; HL points to the sprite data
  70. ;Output:
  71. ; A is incremented by 1
  72. ; BC is not changed
  73. ; DE is not changed
  74. ; HL is not changed
  75. ; z flag set if A is 96
  76. sub 96
  77. ret nc
  78. push af
  79. push hl
  80. push de
  81. push bc
  82. ex de,hl
  83. ;DE points to sprite
  84. ld hl,(gbuf_temp)
  85. inc h
  86. inc h
  87. inc h
  88. ld bc,-96
  89. _:
  90. add hl,bc
  91. add a,12
  92. jr nc,-_
  93. ld c,a
  94. inc b
  95. add hl,bc
  96. ld bc,0108h
  97. ld a,(TempWord1)
  98. call DrawSpriteXxY
  99. pop bc
  100. pop de
  101. pop hl
  102. pop af
  103. add a,97
  104. ret