Author Topic: ASM 16x16 tilemap routine  (Read 3507 times)

0 Members and 1 Guest are viewing this topic.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
ASM 16x16 tilemap routine
« on: January 29, 2012, 05:51:56 pm »
Is there a tilemap routine, smooth-scrolling, that works for 16x16 tiles and that avoids simply applying a 16x16 sprite routine?  I normally used JimE's fast tilemapper, but it requires a lot of RAM

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: ASM 16x16 tilemap routine
« Reply #1 on: January 29, 2012, 06:28:30 pm »
I can give you mine, what are you looking for? I've got two versions, based on the same idea, though it also uses a lot of RAM. It's pretty small, though. Basically drawing an aligned tilemap with an extra column/row, then shifting in the fastcopy routine.
Here's some screenshots i posted here today of my tilemap routine:

and another of a more simplified version:


Here's the basic tilemapper source:
http://pastebin.com/hxtH1Vqu
..and here's the code to update the X offset in the fastcopy routine (the y offset is really simple, just inc/dec (hl) until it carries or = 16) and the fastcopy routine itself:
http://pastebin.com/Etv5dX8C

Depending on what you want to use it for, it could potentially be much faster. Currently, it redraws the entire map every cycle and displays the gbuf each cycle to simplify animated tiles. It's been a while since i've touched the code, but in the first program i think i actually run through the routine three times each frame: first to lay the ground/normal tiles, certain tiles (like the roof) don't cover the entire 16x16 box, so they are masked and a default tile is drawn below (grass, in that map). Next, i draw masked tiles drawn above the players coordinates, then i draw the player, and lastly i draw masked tiles drawn below the player (the effect of walking behind the house roof).

I use SafeRAM1 (saveSScreen) and part of SafeRAM2 (statVars) as gbuffer and save the 78 bytes or so in between somewhere else (saferam3/textShadow):
Code: [Select]
    ld hl,$89EC     ;byte after saferam1 (savesscreen) (creando nuestro "saferam")
    ld de,saferam3  ;guardar los valores aqui para no estropear todo
    ld bc,78
    ldir            ;guardarlo
and restore it when quitting.

Consider it public domain, so use it as you want for whatever you want. If you have any questions or want help getting it set up, let me know.

Offline Hot_Dog

  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3006
  • Rating: +445/-10
    • View Profile
Re: ASM 16x16 tilemap routine
« Reply #2 on: January 29, 2012, 10:14:39 pm »
That's actually very kind of you!  Thanks!

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: ASM 16x16 tilemap routine
« Reply #3 on: January 30, 2012, 03:37:09 am »
No problem, if you decide you want to test it out i can help you out implementing it or feel free to look through my source, the Monopoly source is a bit cleaner, but the RPG code (a little dated, what was backed up from before my laptop crashed) is also available. :)