Re: A83: inverse sprite


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

Re: A83: inverse sprite




Actually, the other method suggested earlier is better (smaller and faster).
Since you forgot the "inc hl", that might have messed up your counting:

 ld a,(hl)    ; 7 / 1
 xor $ff      ; 7 / 2
 ld (hl),a    ; 7 / 1
 inc hl       ; 6 / 1
              ; = 27 t-states, 5 bytes

 ld a,(hl)    ; 7 / 1
 cpl          ; 4 / 1
 ld (hl),a    ; 7 / 1
 inc hl       ; 6 / 1
              ; = 24 t-states, 4 bytes

I know it's not much, but sometimes every byte counts.  Normally, the XOR
instruction would be faster and the way to invert something, but the CPL
(complement) instruction only works the the accumulator and doesn't require
a second immediate byte, so it's faster.  The Z80 is much slower with
immediates unlike an x86.  This is due to it not having an instruction
cache, thus it takes more time to load the extra byte(s) from the
bus/memory.

-----Original Message-----
From: Master M <benjamin99@juno.com>
To: assembly-83@lists.ticalc.org <assembly-83@lists.ticalc.org>
Date: Wednesday, November 04, 1998 9:25 PM
Subject: Re: A83: inverse sprite


>
>Use this:
>
>;Input:
>; HL->sprite
>; (SprLegnth)=Legnth of sprite in bytes
>
>
> ld a,(SprLength)
> ld b,a
>Inverse:
> ld a,(hl)
> xor $FF
> ld (hl),a
> djnz Inverse
>
>
><<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>
>       See ya,
>       Mastermind
>
>       http://www.bigfoot.com/~mastermind5
>
>
>On Tue, 3 Nov 1998 16:51:20 -0800 "Chris Hiszpanski" <mecad@scv.net>
>writes:
>>
>>How can I inverse a sprite? That mean if I have:
>>00000000
>>00011000
>>00011000
>>00011000
>>00011000
>>00011000
>>00011000
>>00000000
>>
>>how simple get:
>>
>>11111111
>>11100111
>>11100111
>>11100111
>>11100111
>>11100111
>>11100111
>>11111111
>>
>>James, maybe you could add this to your sprites section of your
>>tutorial?
>>
>>From: Chris
>>mecad@scv.net
>>
>
>
>___________________________________________________________________
>You don't need to buy Internet access to use free Internet e-mail.
>Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
>or call Juno at (800) 654-JUNO [654-5866]