Skip to content

Commit a55105c

Browse files
authored
Merge pull request #217 from boriel/feature/fastplot
Add fastplot library
2 parents 6dfb9ad + e831fdf commit a55105c

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

library/fastplot.bas

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
' ----------------------------------------------------------------
2+
' This file is released under the MIT License
3+
'
4+
' Copyleft (k) 2019
5+
' Contributed by Britlion and rearranged by John Mcgibbitts
6+
' ----------------------------------------------------------------
7+
8+
9+
#ifndef __LIBRARY_FASTPLOT__
10+
REM Avoid recursive / multiple inclusion
11+
#define __LIBRARY_FASTPLOT__
12+
13+
#pragma push(case_insensitive)
14+
#pragma case_insensitive = True
15+
16+
17+
' ----------------------------------------------------------------
18+
' Plots a point at (x, y) in OVER 1 mode (XOR) with color as ATTR
19+
' This routine is slightly faster than PLOT XOR 1 with ATTRs
20+
' ----------------------------------------------------------------
21+
SUB fastcall fastPlotXORAttr (x AS UBYTE, y AS UBYTE, color AS UBYTE)
22+
ASM
23+
pop hl
24+
pop de
25+
ex (sp), hl
26+
ld c, h
27+
28+
ld e, a
29+
ld a, 191
30+
sub d
31+
ld d, a
32+
ret c
33+
34+
AND a
35+
rra
36+
scf
37+
rra
38+
AND a
39+
rra
40+
XOR d
41+
AND 248
42+
XOR d
43+
ld h, a
44+
ld a, e
45+
rlca
46+
rlca
47+
rlca
48+
XOR d
49+
AND 199
50+
XOR d
51+
rlca
52+
rlca
53+
ld l, a
54+
55+
ld a, e
56+
AND 7
57+
ld b, a
58+
inc b
59+
ld a, 254
60+
61+
plotPointXORAttr_loop:
62+
rrca
63+
djnz plotPointXORAttr_loop
64+
65+
cpl
66+
xor (hl)
67+
ld (hl), a
68+
69+
plotPointXORAttr_end: ; ' Point plotted.
70+
ld a, h ; ' HL = addr of attr
71+
rrca
72+
rrca
73+
rrca
74+
and $03
75+
or $58
76+
ld h, a ; ' HL = addr of attr
77+
78+
ld (hl),c
79+
END ASM
80+
END SUB
81+
82+
83+
' ----------------------------------------------------------------
84+
' Plots a point at (x, y) in OVER 1 mode (XOR) with color as ATTR
85+
' This routine is slightly faster than PLOT XOR 1
86+
' ----------------------------------------------------------------
87+
SUB fastcall fastPlotXOR(x AS UBYTE, y AS UBYTE)
88+
ASM
89+
pop hl
90+
ex (sp), hl
91+
92+
ld e, a
93+
ld a, 191
94+
sub h
95+
ld d, a
96+
ret c
97+
98+
AND a
99+
rra
100+
scf
101+
rra
102+
AND a
103+
rra
104+
XOR d
105+
AND 248
106+
XOR d
107+
ld h, a
108+
ld a, e
109+
rlca
110+
rlca
111+
rlca
112+
XOR d
113+
AND 199
114+
XOR d
115+
rlca
116+
rlca
117+
ld l, a
118+
119+
ld a, e
120+
AND 7
121+
ld b, a
122+
inc b
123+
ld a, 254
124+
125+
plotPointXORAttr_loop:
126+
rrca
127+
djnz plotPointXORAttr_loop
128+
129+
cpl
130+
xor (hl)
131+
ld (hl), a
132+
133+
END ASM
134+
END SUB
135+
136+
137+
#pragma pop(case_insensitive)
138+
139+
#endif

0 commit comments

Comments
 (0)