Re: A86: Sprite XOR
[Prev][Next][Index][Thread]
Re: A86: Sprite XOR
A. El-Helw wrote:
> So, if I wanted to make an XOR routine, just add those three lines
> where I
> call the sprite ? And is there anything else I have to do?
this is an optimizable code to XOR a sprite anywhere:
PutSpriteXOR: ; Puts a sprite stored at (HL) at B,C
push bc ; save BC
push de ; save DE
push hl ; save HL
push hl ; save HL
ld e,b
ld d,c
call FindPixel ; NOTE i did not include the FindPixel Routine..
;its the one found on this list earlier!
ld de,$FC00 ; DE points to VID MEM
ex de,hl ; DE = VID MEM + PIXEL LOC
pop hl ; HL = PIC LOC
ld b,(hl) ; get first byte from PIC LOC (width)
inc hl ; HL = next byte in PIC LOCATION
ld c,(hl) ; get second byte from PIC LOC (height)
inc hl ; HL = START OF PIC
push hl ; save HL
pop ix ; IX = START OF PIC
ex de,hl ; HL = VID MEM + PIXEK LOC DE = START OF
PIC
PS_NewRow:
push bc ; save BC
ld d,(ix) ; D = next byte of PIC
inc ix ; IX points to next byte
push af ; save AF
push hl ; save HL
PS_NewCol:
rl d ; Rotate Left D
ld e,a ; e = a
jr nc,PS_NoPixel ; if No Carry then goto NoPixel
;************ can be OR or XOR or AND or whatever :) *****
xor (hl) ; a = a or (hl)
;***************************************************
ld (hl),a ; hl = hl or a (basically)
jr PS_NextPixel
PS_NoPixel:
cpl
and (hl)
ld (hl),a
PS_NextPixel:
ld a,e ; get A back
rrca ; rotate right circular
jr nc,PS_SameByte ; if no carry then same byte
inc hl ; else HL points to next byte in PIC
PS_SameByte:
djnz PS_NewCol ; go to next column
pop hl
pop af
ld de,16
add hl,de
pop bc
dec c
jr nz,PS_NewRow
pop hl
pop de
pop bc
ret
this is just a modded version that I got from somwhere.. it's not my
code... (sorry to the author, i don't know who you are :( )
--
Trent Lillehaugen
Computer Engineering Major
California Polytechnic University, San Luis Obispo
<tllilleh@polymail.calpoly.edu>
References: