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

0 Members and 1 Guest are viewing this topic.

#### Hot_Dog

• CoT Emeritus
• LV12 Extreme Poster (Next: 5000)
• Posts: 3005
• Rating: +445/-10
##### 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

#### chickendude

• Posts: 816
• Rating: +90/-1
##### 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            ;guardarloand 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.

#### Hot_Dog

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