home *** CD-ROM | disk | FTP | other *** search
- ; Sprite AND XOR Routine
- ; by Frank Schoep. Revision: 33
-
- ; Routine input: D is the x coordinate
- ; E is the y coordinate
- ; BC as pointer to bit mask (8 bits) + sprite data (8 bits)
- ; Routine output: N/A
-
- GrBufBackup: ;main identifier of grbufbak
- ld hl,plotsscreen ;hl->screen
- ld de,saferam1 ;de->safe bak memory
- ld bc,768 ;bc=786 bytes to copy
- ldir ;LoaD Increment Repeat (bc=0)
- ret ;return
-
- GrBufResBackup: ;main identifier of grresbak
- ld hl,saferam1 ;hl->safe bak memory
- ld de,plotsscreen ;de->screen
- ld bc,768 ;bc=786 bytes to copy
- ldir ;copy backup to screen
- ret ;return
-
- SPRANDXOR: ;display sprite AND XOR way
- push de ;store memory address (XOR)
- ld a,d ;a=x coord
- call sprand ;draw bit mask
- pop de ;restore memory address (XOR)
- ld a,d ;a=x coord
- call sprxor ;draw xor sprite
- ret ;return
-
- SPRAND:
-
- push bc ;for Baldur's Gate only!
-
- push bc ; Save sprite address
- ld hl,0 ; Do y*12
- ld d,0
- add hl,de
- add hl,de
- add hl,de
- add hl,hl
- add hl,hl
- ld e,a
- srl e
- srl e
- srl e
- add hl,de
- ld de,8e29h
- add hl,de ; Add address to graphbuf
- ld b,00000111b ; Get the remainder of x/8
- and b
- or a
- jp z,AALIGN
- pop ix ; ix->sprite
- ld d,a ; d=how many bits to shift each line
- ld e,8 ; Line loop
- ALILOP: ld b,(ix+0) ; Get sprite data
- ld c,$ff ; Changed into $FF because of AND bit mask!!!
- scf
- push de
- ASHLOP: rr b ;srl
- rr c
- dec d
- jp nz,ASHLOP
- pop de
- ld a,b ; Write line to graphbuf
- and (hl)
- ld (hl),a
- inc hl
- ld a,c
- and (hl)
- ld (hl),a
- ld bc,11 ; Calculate next line address
- add hl,bc
- inc ix ; Inc spritepointer
- dec e
- jp nz,ALILOP ; Next line
- jp ADONE1
- AALIGN: ; Blit an aligned sprite to graphbuf
- pop de ; de->sprite
- ld b,8
- AALOP1: ld a,(de)
- and (hl)
- ld (hl),a
- inc de
- push bc
- ld bc,12
- add hl,bc
- pop bc
- djnz AALOP1
- ADONE1:
- pop bc ;this code is for the memory increment after
- inc bc ;displaying.
- inc bc ;added by Frank Schoep
- inc bc ;MOVAX has nothing to do with it
- inc bc
- inc bc
- inc bc
- inc bc
- inc bc
- ret
-
- ; Sprite XOR Routine
- ; originally written by MOVAX
- ; edited for SPRANDXOR by Frank Schoep
- ; Revision: 3
-
- ; Routine input: A is the x coordinate
- ; E is the y coordinate
- ; BC as pointer to sprite data
- ; Routine output: N/A
-
- SPRXOR:
-
- push bc ;for needed for SPRANDXOR
-
- push bc ; Save sprite address
- ld hl,0 ; Do y*12
- ld d,0
- add hl,de
- add hl,de
- add hl,de
- add hl,hl
- add hl,hl
- ld e,a
- srl e
- srl e
- srl e
- add hl,de
- ld de,8e29h
- add hl,de ; Add address to graphbuf
- ld b,00000111b ; Get the remainder of x/8
- and b
- or a
- jp z,ALIGN
- pop ix ; ix->sprite
- ld d,a ; d=how many bits to shift each line
- ld e,8 ; Line loop
- LILOP: ld b,(ix+0) ; Get sprite data
- ld c,0 ; Shift loop
- push de
- SHLOP: srl b
- rr c
- dec d
- jp nz,SHLOP
- pop de
- ld a,b ; Write line to graphbuf
- xor (hl)
- ld (hl),a
- inc hl
- ld a,c
- xor (hl)
- ld (hl),a
- ld bc,11 ; Calculate next line address
- add hl,bc
- inc ix ; Inc spritepointer
- dec e
- jp nz,LILOP ; Next line
- jp DONE1
- ALIGN: ; Blit an aligned sprite to graphbuf
- pop de ; de->sprite
- ld b,8
- ALOP1: ld a,(de)
- xor (hl)
- ld (hl),a
- inc de
- push bc
- ld bc,12
- add hl,bc
- pop bc
- djnz ALOP1
- DONE1:
- pop bc ;this code is for the memory increment after
- inc bc ;displaying.
- inc bc ;added by Frank Schoep
- inc bc ;MOVAX has nothing to do with it
- inc bc
- inc bc
- inc bc
- inc bc
- inc bc
- ret
-