Re: A83: Sprite routine problem


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

Re: A83: Sprite routine problem




On Fri, 03 Sep 1999 23:03:56 -0500, Pizza of Hut wrote:

>I am attempting to write my own sprite routine that will display a 8x16
>sprite. However, when I try running the program, all I get is the x & y
>axis for the graph screen and no sprite. The code is as follows.
>
>  call _clrLCDFull
>  ld d,48
>  ld e,32
>  ld ix,big_sprite
>  call _Big_Sprite
>  call _grbufcpy_v
>loop:
>  call _getkey
>  ret nz
>;Input: d-x coord, e-y coord, ix-sprite address
>;Output: 8x16 XOR sprite written to 8e29h
>_Big_Sprite:
>  ld hl,0
>  ld d,0
>;*********Calculate addy in graphbuf********
>  sla e  ;Do y*12
>  sla e
>  add hl,de
>  add hl,de
>  add hl,de
>  ld e,d
>  srl e  ;Do x/8
>  srl e
>  srl e
>  add hl,de
>  ld de,8e29
>  add hl,de
>  ld de,00000111b
>  and d
>  cp 0 ;checks if sprite is aligned
>  jr z,Aligned_Sprite ;If so, goto aligned sprite bit
>;********Non-aligned sprite bit starts here********
>  ld b,a  ;Shift counter
>  ld c,16  ;Line counter
>Line_Loop:
>  ld d,(ix+0)
>  push bc
>Shift_Loop:
>  srl d
>  rr e
>  djnz Shift_Loop
>  pop bc
>  ld a,d  ;Write line to graphbuf
>  xor (hl)
>  ld (hl),a
>  inc hl
>  ld a,e
>  xor (hl)
>  ld (hl),a
>  ld de,11
>  add hl,de
>  inc ix
>  dec c
>  cp 0
>  jr nz,Line_Loop
>  ret
>;********Aligned sprite bit starts here********
>Aligned_Sprite:
>  ld c,16  ;Line counter
>Aligned_Loop:
>  ld d,(ix+0)
>  ld a,d
>  xor (hl)
>  ld (hl),a
>  ld de,12
>  add hl,de
>  inc ix
>  dec c
>  cp 0
>  jr nz,Aligned_Loop
>  ret
>
>big_sprite:
>  .db 11111111b
>  .db 11000011b
>  .db 10100101b
>  .db 10011001b
>  .db 10011001b
>  .db 10100101b
>  .db 11000011b
>  .db 10000001b
>  .db 10000001b
>  .db 11000011b
>  .db 10100101b
>  .db 10011001b
>  .db 10011001b
>  .db 10100101b
>  .db 11000011b
>  .db 11111111b
>.end
>END
>
>If someone could help me out with this, I would really appreciate it.
>Thanx in advance.
>
>P.S. If anyone could tell me how to create a side-scrolling background,
>like the one used in Mega Man 83-ASM, I would be forever grateful.
>--
>Pizza of Hut
>http://www.antishrine.sacone.com/

  I think the Mega Man routine just uses the Movax XOR Sprite routine for 
the whole screen each time the character moves a frame. That's why it 
doesn't run as fast as Sqrxz, Penguins, etc.

James Vernon
jimbob_v@hotmail.com

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Follow-Ups: