Re: A86: New Asm programmer Needs Help


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

Re: A86: New Asm programmer Needs Help




James Tyra wrote:
> 
> Helo my name is JT. I am new to this mailing list and to asm
> programming in
> general.
> Below is a program I made i was trying to put a 24X24 sprite on the
> screen can
> someone please tell me where I went wrong? It doesn't work very well at
> all :)
> 
> > .org _asm_exec_ram
> >         call _clrLCD
> >         ld hl, PIC1
> >     call Sprite
> >
> > Sprite:
> >         ld b,(hl) ;
> >         inc hl
> >         ld c, (hl)
> >         push hl
> >         pop ix           <= you must increase hl by 2 before,
> >         ld hl,$fc00         or the first 2 bytes of data will
> >         ld de,$18           be the size of the sprite
> 
> > Pixel_Put:
> >         ld a,(ix)
> >         ld (hl),a
> >         inc ix             <= you forgot to increment hl too. you're
> >         djnz Pixel_Put        writing always in the same screen
location

    what you are doing here is not puting a 24x24 sprite on screen, you're
    puting a 8*24x8*24 sprite. A byte holds 8 pixels.
    You have to loop only 24/8 = 3 times to put 24 pixels on screen (on
    width; on height is 24 times, 'cause a byte is a 8x1 sprite.

> >         jp Next_Row       <=? not needed
> > Next_Row:
> >         add hl,de         <= to go to next screenlocation you have to
add
                                16-3. 16 is bytes/line, 3 is
bytes/sprite_line.
                                
> >         ld b,24
> >         jp Pixel_Put <= this routine never ends. you wanted to
> >         ret            decrement c, test for 0, and if not 0 then
                           jp Pixel_put
> >
> > PIC1:
> >
> >    .db 24, 24
> >
> >  .db (the sprite data in here)
> >

 NSJ aka Viriato