KermMartian wrote:
Hey, all you did was use my code slightly permuted. Nice job, calc84.
I was going to post something like that anyway, then you ninja'd me unsigned char b = 0x55;
b = (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
unsigned char b = 0x55;
b = (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
Init:
ld hl,0
ld b,a
ld c,3
lstart:
bit 0,b
jr z,skadd
ld a,l
add a,c
ld l,a
skadd:
sla c
sla c
jr nz, hax
ld c,h
ld h,l
ld l,c
ld c,3
hax:
ld a,(lstart+1)
add a,00001000b
ld (lstart+1),a
cp %10000000
jp nz,lstart
;; optional in case you want to run the code again.....
ld a,%01000000
ld (lstart+1),a
rrca; HABCDEFG H 4 4
rra; HHABCDEF G 4 8
rra; GHHABCDE F 4 12
rr l; GHHABCDE ? F 8 20
sra a;GGHHABCD E F 8 28
rl l; GGHHABCD F E 8 36
ld h,a; F E 4 40
rra; FGGHHABC D E 4 44
rr h; DGGHHABC* D E 8 52
rr h; DDGGHHAB* C E 8 60
rr h; CDDGGHHA* B E 8 68
sra a;FFGGHHAB C E 8 76
rr h; CCDDGGHH* A E 8 82
rr l; FFGGHHAB E 8 90
rra; EFFGGHHA B 4 94
rr h; BCCDDFFG* G 8 102
sra h;BBCCDDFF* G 8 108
sra a;EEFFGGHH A 8 116
rr h; ABBCCDDF* F 8 124
sra h;AABBCCDD 8 132
ld l,a;EEFFGGHH A 4 136
rrca
rra
rra
ld l,a
rra
sra l
rla
rr l
sra l
rra
rr l
sra l
rrca
rra
rra
ld h,a
rra
sra h
rla
rr h
sra h
rra
rr h
sra h
ClearHorizLine:
;A = x pos
;L = y pos
;C = width
ld h,0
ld d,h
ld e,l
add hl,hl
add hl,de
add hl,hl
add hl,hl
ld b,a
rra
scf
rra
srl a
ld d,$93
ld e,a
add hl,de
ld a,b
or $f8
ld b,a
add a,c
ld c,a
ld a,$ff
jr nc,CHZloop4
CHZloop1:
add a,a
inc b
jr nz,CHZloop1
and (hl)
ld (hl),a
inc hl
ld a,c
sub 8
jr c,CHZskip
CHZloop2:
ld (hl),b
inc hl
sub 8
jr nc,CHZloop2
CHZskip:
ld b,a
xor a
CHZloop3:
scf
rla
inc b
jr nz,CHZloop3
and (hl)
ld (hl),a
ret
CHZloop4:
add a,a
inc b
jr nz,CHZloop4
ld b,a
CHZloop5:
scf
rla
inc c
jr nz,CHZloop5
or b
and (hl)
ld (hl),a
ret
;l = y
;a = x
;b = length
line:
ld e,l
ld h,00h
ld d,h
add hl,de
add hl,de
add hl,hl
add hl,hl;y offset * 12
ld e,a
and 07h; bit offset within byte
ld c,a
srl e
srl e
srl e
add hl,de; byte number in which to start
ld de,gbuf
add hl,de; address of first byte of line
ld a,b
cp 8
jp c,SmallLine
lineleftcap:
ld d,0FFh
ld a,c
sub b
neg
ld b,a;length-offset=number of pixels left to draw
ld a,c
or a;if it's right on the byte, no need for cap
jp z,lineloopprep
lineleftcaploop:
srl d
dec a
jp nz,lineleftcaploop
lineleftcapskip1:
ld a,(hl)
xor d
ld (hl),a
inc hl
lineloopprep:
ld a,b
and 07h
ld c,a
srl b
srl b
srl b;b is number of bytes now
ld a,b
or a
jp z,linerightcap
lineloop:
ld a,(hl)
xor 0FFh
ld (hl),a
inc hl
djnz lineloop
linerightcap:
ld a,c
or a
ret z
ld d,80h
dec a
jp z,linerightcaploopskip
linerightcaploop:
sra d
dec a
jp nz,linerightcaploop
linerightcaploopskip:
ld a,(hl)
xor d
ld (hl),a
ret
SmallLine:
ld d,80h
dec b
jp z,SmallLineNext
SmallLineLoop:
sra d
djnz SmallLineLoop
ld e,00h
ld a,c
or a
jp z,SmallLineSkip1
SmallLineLoop2:
srl d
rr e
dec a
jp nz,SmallLineLoop2
SmallLineSkip1:
ld a,(hl)
xor d
ld (hl),a
inc hl
ld a,(hl)
xor e
ld (hl),a
ret
Advertisement