Author Topic: Simple tilemapper  (Read 2269 times)

0 Members and 1 Guest are viewing this topic.

Offline matthias1992

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 408
  • Rating: +33/-5
    • View Profile
Simple tilemapper
« on: June 25, 2011, 01:13:59 pm »
Okay I have a simple OR-sprite display routine (slightly modified version from the 28days one) and the iFastCopy routine in my code. Point is, as a first step towards a simple tilemapper, I want to repeat one simple sprite 12x horizontally (the sprite is 8x8) and 8x vertically. For one reason or the other I can't work it out. I have had several errors now including the feared MEMORY error...so yea...I was runnin on an emulator though. It's probably very easy for the more advanced asm coders out here but here we go:

Sprite: size;8x8 label;SpriteData
Sprite Routine: A-register = x-coord, E-register = y-coord, B-register = #rows (not in bytes) IX-register = label of the sprite (in this case, SpriteData)

My modifications to the Srpite routine are extremely slight and the routine works absolutely fine when just drawing one sprite, my problem lies more in making a proper loop that increments the A and B register respectfully with 8 each pass. Also I read something about drawing in colums being faster than in rows, can anyone confirm? Or should I take a completely different approach towards tilemapping than drawing sprites 1 by 1?

Thanks!
« Last Edit: June 25, 2011, 01:15:08 pm by matthias1992 »
MASM xxxxxxxxxx aborted | SADce ====:::::: 40% -Halted until further notice| XAOS =====::::: 50% -Units done| SKYBOX2D engine ========== 100% -Pre-alpha done. Need to  document it and extend |

~Those who dream by day are cognizant of much more than those who dream by night only. -Sir Edgar Allen Poe-

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Simple tilemapper
« Reply #1 on: June 26, 2011, 09:54:42 pm »
Does your routine preserve all the registers you use after the routine?  For instance, if b is being incremented/decremented, but not preserved by the routine, you need to push its value before calling it and pop it afterwards like this:

Code: [Select]
  ld   b,8
Loop:
  push bc
  call SpriteRoutine
  pop  bc
  djnz Loop

Otherwise b's value will be scrambled after it returns from the call.
___Axe_Parser___
Today the calculator, tomorrow the world!