Re: A86: Some help with gamming


[Prev][Next][Index][Thread]

Re: A86: Some help with gamming




In a message dated 4/23/00 9:09:08 AM Eastern Daylight Time, 
erroneus404@usa.net writes:

> Does anyone know how to take a column of 8x8 sprites from a map then place
>  them onto the screen?

It's simply a matter of looping through a call to a putsprite routine.  If 
you know your tiles will be aligned (on a byte offset), then you can use an 
aligned putsprite routine, which makes things a lot easier.  However, if they 
aren't, then you need to use a regular putsprite in something like this:

  ld hl,firsttile
  ld bc,x*256   ;x=column
drawcolumn:
  ld a,(hl)
  add a,a
  add a,a
  add a,a    ;*8, to get sprite size
  ld e,a
  ld d,0
  push hl
  ld hl,tilesprites
  add hl,de   ;get pointer to sprite
  push bc  ;save x,y coordinates
  call putsprite  ;display sprite
  pop bc
  pop hl
  ld de,16    ;number of tiles between one row and the next
  add hl,de
  ld a,c
  add a,8   ;move down a row
  ld c,a
  cp 64
  jr c,drawcolumn
  ret

However, it's generally more efficient to draw the whole map at once, rather 
than each column at a time.  You would essentially use the above routine, yet 
you'd move the column first, and if it was >=128, then you'd set it to 0 and 
move the row down.  And once the row was >=64, you'd quit.  And of course 
you'd only increment the tile pointer rather than adding a whole row's offset 
to it.


----
Jonah Cohen
<ComAsYuAre@aol.com>
http://jonah.ticalc.org