Apparently CP only works for the accumulator, but I need to compare IY with 0 without destroying it.
Is there are fast method for this? I was planning on using it for a sprite drawing function, if that helps.
Why not just use the super optimized sprite routines in the C libraries please? (graphx)

This works, but sets bc (or another reg) and hl to iy.


Code:
    lea bc,iy
    sbc hl,hl
    adc hl,bc


Only set hl to iy:


Code:
    lea hl,iy
    add hl,bc
    or a,a
    sbc hl,bc


Both are the same size.
I tried finding a sprite routine but all that I found relied on huge libs I had to import or add to my calculator, or used the graph buffer, something which I can't find documentation on anywhere.

I just want something that pastes into the vRam, which I didn't find.
What are you talking about; the source for the libraries is freely available. Just use the routine you need. You clearly don't understand how libraries work on the CE, but whatever.

https://github.com/CE-Programming/toolchain/blob/master/src/graphx/graphx.asm#L2312
Sometimes, a better way to check if iy is equal to 0 can be to do
Code:
    ld bc/de,-1
    add iy,bc/de
which sets the carry flag if iy is not zero. Of course the main issue with this is that it destroys iy and having to do inc iy to restore it causes it to lose its advantage over the other methods, unless multiple values need to be compared equal to zero at the same time in which case they can share the value already loaded into bc or de.
MateoConLechuga wrote:
What are you talking about; the source for the libraries is freely available. Just use the routine you need. You clearly don't understand how libraries work on the CE, but whatever.

https://github.com/CE-Programming/toolchain/blob/master/src/graphx/graphx.asm#L2312


And I must go through a horde of source files just to find something I need instead of just one simple function being available standalone? That's just horrible.
Mateo did link directly to the sprite routine so you don't have to scour through the entire document, which is handy.

However if you manage to find the time I do suggest you take a look at the various routines in that file, there is a lot of useful code within!

One thing to note is that the C toolchain sprite routines expect the LCD to be at a specific bitdepth (8bpp). I'm not sure what your project will utilise so there may be some minor modification required if it differs from this. The linked routine also has no clipping, though there are clipped versions in the file too!
I'll just copy / paste it here with a few modifications. Hope this helps Smile


Code:
;-------------------------------------------------------------------------------
gfx_Sprite_NoClip:
; Places an sprite on the screen as fast as possible
; Arguments:
;  hl: Pointer to sprite
;  bc : X coordinate
;  e : Y coordinate
; Returns:
;  None
   push   hl
   ld   hl,vRam
   add   hl,bc
   ld   d,LcdWidth/2
   mlt   de
   add   hl,de
   add   hl,de
   ex   de,hl         ; de = start draw location
   pop   hl
   ld   c,(hl)         ; spriteWidth
   inc   hl
   ld   iyh,c
   xor   a,a
   ld   b,a
   srl   c
   sbc   a,.step - .evenw
   ld   (.step - 1),a
   ld   a,LcdWidth/2
   sub   a,c
   ld   iyl,a         ; (LcdWidth/2)-(spriteWidth/2)
   ld   a,(hl)         ; spriteHeight
   inc   hl
   jr   .start
.loop:
   dec   de         ; needed if sprite width is odd
.evenw:
   ld   c,iyl         ; (LcdWidth/2)-(spriteWidth/2)
   ex   de,hl
   add   hl,bc
   add   hl,bc
   ex   de,hl
.start:
   ld   c,iyh         ; spriteWidth
   ldir
   dec   a
   jr   nz,.loop
.step:
   ret
  
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