; ZGFXL v1.0 ; Graphics Library for SOS ; v0.1: 06-24-1998 ; v0.2: 07-01-1998 ; v1.0: 08-08-1998 .nolist #include "joeti83.inc" .list .dw getVersion ; get version .dw largeSprite ; put large sprite .dw fastCopy ; fast buffer copy ;---------= Version =--------- ; Gets the version of ZGFXL ; Input: nothing ; Output: hl=verion (h=major, l=minor) getVersion: ld hl,1*256+0 error: ret ;---------= Large Sprite =--------- ; Draws a Large sprite. ;Input: ix->sprite ; a=x ; l=y ; b=height (in pixels) ; c=width (in bytes, e.g. 2 would be 16) ;Output: nothing ; All registers are destroyed except bc', de', hl' largeSprite: di ex af,af' ld a,c push af ex af,af' ld e,l ld h,$00 ld d,h add hl,de add hl,de add hl,hl add hl,hl ld e,a and $07 ld c,a srl e srl e srl e add hl,de ld de,gbuf add hl,de sl0: push hl sl1: ld d,(ix) ld e,$00 ld a,c or a jr z,sl3 sl2: srl d rr e dec a jr nz,sl2 sl3: ld a,(hl) xor d ld (hl),a inc hl ld a,(hl) xor e ld (hl),a inc ix ex af,af' dec a push af ex af,af' pop af jr nz,sl1 pop hl pop af push af ex af,af' ld de,$0C add hl,de djnz sl0 pop af ret ;---------= Fast Copy =--------- ;Input: nothing ;Output:graph buffer is copied to the screen fastCopy: di ; 4 ld a,$80 ; 7 out ($10),a ; 11 ld hl,gbuf-12-(-(12*64)+1) ; 10 ld a,$20 ; 7 ld c,a ; 4 ; 43 fastCopyAgain: ld b,64 ; 7 inc c ; 4 ld de,-(12*64)+1 ; 10 out ($10),a ; 11 add hl,de ; 11 ld de,11 ; 10 fastCopyLoop: add hl,de ; 11 inc hl ; 6 ret c ; 5 ; do nothing instruction (was nop (4 clocks)) ld a,(hl) ; 7 out ($11),a ; 11 djnz fastCopyLoop ; 13/8 ; 3392 ld a,c ; 4 cp $2B+1 ; 7 jr nz,fastCopyAgain; 12/7 ; 52 ; 41773 (used to be 41136) ret ; 11 ; 18 ; 41773 clocks total ; 37 bytes total .end END