Okay, so I've put together this basic 16*16 sprite drawing routine for 8bpp mode. I'm new to ez80 assembly so this is not the most efficient, but this is for testing right now and will later be optimized. You can see my entire code below, but my question specifically is why do I have to have this twice:

Code:

 ld a,(de)
 ld (hl),a
 inc de
 inc hl
 ld a,(de)
 ld (hl),a
 inc de
 inc hl

Why do I have to repeat that section? I loop through 16 times, so that should work with it being in the code only once. The only reason I added it twice was because half the square was being drawn and that seemed to fix it.

Full code:

Code:

;gets x and y coords
 ld de,spritedata
 ld hl,vram
 ld a,(de)
 ld b,a
 inc de
 ld a,(de)
 ld c,a
 add hl,bc
 inc de
 ld a,(de)
 ld c,a
 ld b,160
 mlt bc
 add hl,bc
 add hl,bc
 inc de

;draws sprite
 ld c,16
spriteloop1:
 ld b,16
spriteloop2:
 ld a,(de)
 ld (hl),a
 inc de
 inc hl
 ld a,(de)
 ld (hl),a
 inc de
 inc hl
 dec b
 djnz spriteloop2
 dec c
 push de
 ld de,304
 add hl,de
 pop de
 jr nz,spriteloop1
It's pretty obvious but:


Code:
 dec b
 djnz spriteloop2


Hope this helps Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement