Re: A83: Sprite routine problem
[Prev][Next][Index][Thread]
Re: A83: Sprite routine problem
On Mon, 06 Sep 1999 17:52:08 -0500, Pizza of Hut wrote:
>James Vernon wrote:
>
> > 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
>
>I've never really understood how you could use Movax's XOR sprite routing
>as
>a scrolling routine. Could someone please explain it?
>
>--
>Pizza of Hut
>http://www.antishrine.sacone.com/
I don't really know where to start.. say you have a variable (x). This is
the x coord of the player, and it starts on 0 at the start of every level.
Each time the player moves right we increment (x).
When we want to update display on the graph buffer, we first check the
value of (x). If it is divisible by 8, we can fit 12 8*8 tiles on the
screen, otherwise we will only put 11 (as in MegaMan). Use:
and %00000111
to check if (x) is divisible by 8. The value that is then left in A is the x
value to start with for the Movax routine. Start the Movax y value at 0, and
then display 11(or 12)*8 tiles on the screen. After each tile is finished,
add 8 to the Movax x value, and once 11 (or 12) tiles have been displayed
across, add 8 to the y value and put the x value to what you started at for
the previous row. Do all 8 rows and there is your refresh.
Have I explained that ok? If I have time I might write a full example
routine and mail it to the list for anyone that might want it.
It just occured to me, doesn't MegaMan have the source included? I'm
pretty sure that I have a copy of the source, so if you don't, I can send it
to you. cya later.
James Vernon
jimbob_v@hotmail.com
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com