crz1spriteroutine: ;+--------------------------------------------------------------------+ ;| "And Or Xor Spriteroutine" | ;| (only 217 bytes) | ;| | ;| (programmed by Pelle Kersaan a.k.a. Cerzus, ©2003) | ;| (cerzus69@hotmail.com) | ;| | ;| Description: This routine puts an 8x8 sprite at a given location | ;| in the graphbuffer. If the location is chosen so, that the sprite | ;| cannot fully be put on the screen, then the edges are cut off | ;| instead of wrapped to another line. Also, it has the option to | ;| 'and', 'or' or 'xor' it to the buffer. This routine is used right | ;| when the x-position isn't lower than -7 or higher than 95 and the | ;| y-position isn't lower than -7 or higher than 63. | ;| Input: c is operator (1=and, 2=or, 3=xor) | ;| d is x-position (min. -7, max. 95) | ;| e is y-position (min. -7, max. 63) | ;| ix is sprite-address | ;| Destroys: a, bc, de, hl, ix, (currow), (curcol) | ;+--------------------------------------------------------------------+ ld b,8 push bc ld hl,0 ld (currow),hl ld a,e ld b,7 crz1topoffcheck: inc a jr z,crz1topoff djnz crz1topoffcheck ld c,e add hl,bc add hl,bc add hl,bc add hl,hl add hl,hl ld a,e sub 56 ld b,7 crz1bottomoffcheck: dec a jr z,crz1bottomoff djnz crz1bottomoffcheck jr crz1checkxpos crz1topoff: push bc ld a,8 sub b ld c,a ld b,0 add ix,bc pop bc crz1bottomoff: ld a,b pop bc ld b,a push bc crz1checkxpos: ld a,d ld b,7 crz1leftoffcheck: inc a jr z,crz1leftoff djnz crz1leftoffcheck ld c,d srl c srl c srl c add hl,bc ld a,d sub 88 ld b,7 crz1rightoffcheck: dec a jr z,crz1rightoff djnz crz1rightoffcheck jr crz1finishscreenpos crz1leftoff: ld a,10b ld (currow),a dec hl jr crz1finishscreenpos crz1rightoff: ld a,01b ld (currow),a crz1finishscreenpos: ld bc,plotsscreen add hl,bc ld a,d pop de and 00000111b jr z,crz1aligned ld (curcol),a crz1nonaligned: ld b,(ix+0) ld a,e cp 1 jr nz,crz1orxorshift ld c,11111111b ld a,(curcol) crz1andshiftloop: srl b rr c ex af,af' ld a,b add a,10000000b ld b,a ex af,af' dec a jr nz,crz1andshiftloop jr crz1endshiftloop crz1orxorshift: ld c,00000000b ld a,(curcol) crz1orxorshiftloop: srl b rr c dec a jr nz,crz1orxorshiftloop crz1endshiftloop: ld a,(currow) and 10b call z,crz1putsprite ld b,c inc hl ld a,(currow) and 01b call z,crz1putsprite inc ix ld bc,11 add hl,bc dec d jr nz,crz1nonaligned ret crz1aligned: ld b,(ix+0) call crz1putsprite inc ix ld bc,12 add hl,bc dec d jr nz,crz1aligned ret crz1putsprite: ld a,e dec a call z,crz1putand ld a,e cp 2 call z,crz1putor ld a,e cp 3 call z,crz1putxor ret crz1putand: ld a,(hl) and b ld (hl),a ret crz1putor: ld a,(hl) or b ld (hl),a ret crz1putxor: ld a,(hl) xor b ld (hl),a ret