You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. INCLUDE "hardware.inc"
  2. INCLUDE "util.inc"
  3. INCLUDE "png/map/intro.inc"
  4. SECTION "BG Data", WRAM0
  5. BG_COLLISION_DATA:: dw
  6. BG_MAP_WIDTH:: db
  7. BG_MAP_HEIGHT:: db
  8. BG_SCROLLING:: db
  9. SECTION "BG Code", ROM0
  10. MACRO update_map_info
  11. ld hl, BG_COLLISION_DATA
  12. ld a, HIGH(\1)
  13. ld [hl+], a
  14. ld a, LOW(\1)
  15. ld [hl+], a
  16. ld a, \2
  17. ld [hl+], a
  18. ld a, \3
  19. ld [hl+], a
  20. ENDM
  21. BG_Init::
  22. SET8 BG_SCROLLING, 0
  23. ; copy map
  24. ld e, intro_HEIGHT
  25. ld bc, _SCRN0
  26. ld hl, intro_MAP
  27. .copy_map_row:
  28. ld d, intro_WIDTH
  29. call memcpy
  30. dec e
  31. jr z, .done
  32. ; nothing to skip if map is max width
  33. ld a, 32 - intro_WIDTH
  34. or a
  35. jr z, .copy_map_row
  36. ld d, a
  37. .skip:
  38. ; skip over trailing part in vram
  39. inc c
  40. jr nz, .nocarry
  41. inc b
  42. .nocarry:
  43. dec d
  44. jr nz, .skip
  45. jr .copy_map_row
  46. .done:
  47. ; copy tiles
  48. ld hl, intro_TILES
  49. ld bc, _VRAM
  50. ld d, intro_NUM_TILES
  51. call memcpy
  52. update_map_info intro_COLLISION, intro_WIDTH, intro_HEIGHT
  53. ret
  54. BG_Update::
  55. ret