mirror of
https://github.com/irmen/prog8.git
synced 2025-02-19 11:31:07 +00:00
tweak mandelbrots and c64 graphics plot() doesnt work with XY parameter
This commit is contained in:
parent
364ef3e55c
commit
5eae7a2b93
@ -38,15 +38,15 @@ graphics {
|
|||||||
}
|
}
|
||||||
dx *= 2
|
dx *= 2
|
||||||
dy *= 2
|
dy *= 2
|
||||||
plotx = x1
|
internal_plotx = x1
|
||||||
|
|
||||||
if dx >= dy {
|
if dx >= dy {
|
||||||
if positive_ix {
|
if positive_ix {
|
||||||
repeat {
|
repeat {
|
||||||
plot(y1)
|
internal_plot(y1)
|
||||||
if plotx==x2
|
if internal_plotx==x2
|
||||||
return
|
return
|
||||||
plotx++
|
internal_plotx++
|
||||||
d += dy
|
d += dy
|
||||||
if d > dx {
|
if d > dx {
|
||||||
y1++
|
y1++
|
||||||
@ -55,10 +55,10 @@ graphics {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repeat {
|
repeat {
|
||||||
plot(y1)
|
internal_plot(y1)
|
||||||
if plotx==x2
|
if internal_plotx==x2
|
||||||
return
|
return
|
||||||
plotx--
|
internal_plotx--
|
||||||
d += dy
|
d += dy
|
||||||
if d > dx {
|
if d > dx {
|
||||||
y1++
|
y1++
|
||||||
@ -70,25 +70,25 @@ graphics {
|
|||||||
else {
|
else {
|
||||||
if positive_ix {
|
if positive_ix {
|
||||||
repeat {
|
repeat {
|
||||||
plot(y1)
|
internal_plot(y1)
|
||||||
if y1 == y2
|
if y1 == y2
|
||||||
return
|
return
|
||||||
y1++
|
y1++
|
||||||
d += dx
|
d += dx
|
||||||
if d > dy {
|
if d > dy {
|
||||||
plotx++
|
internal_plotx++
|
||||||
d -= dy
|
d -= dy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
repeat {
|
repeat {
|
||||||
plot(y1)
|
internal_plot(y1)
|
||||||
if y1 == y2
|
if y1 == y2
|
||||||
return
|
return
|
||||||
y1++
|
y1++
|
||||||
d += dx
|
d += dx
|
||||||
if d > dy {
|
if d > dy {
|
||||||
plotx--
|
internal_plotx--
|
||||||
d -= dy
|
d -= dy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,26 +104,26 @@ graphics {
|
|||||||
byte @zp decisionOver2 = 1-xx as byte
|
byte @zp decisionOver2 = 1-xx as byte
|
||||||
|
|
||||||
while xx>=yy {
|
while xx>=yy {
|
||||||
plotx = xcenter + xx
|
internal_plotx = xcenter + xx
|
||||||
ploty = ycenter + yy
|
ploty = ycenter + yy
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter - xx
|
internal_plotx = xcenter - xx
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter + xx
|
internal_plotx = xcenter + xx
|
||||||
ploty = ycenter - yy
|
ploty = ycenter - yy
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter - xx
|
internal_plotx = xcenter - xx
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter + yy
|
internal_plotx = xcenter + yy
|
||||||
ploty = ycenter + xx
|
ploty = ycenter + xx
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter - yy
|
internal_plotx = xcenter - yy
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter + yy
|
internal_plotx = xcenter + yy
|
||||||
ploty = ycenter - xx
|
ploty = ycenter - xx
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
plotx = xcenter - yy
|
internal_plotx = xcenter - yy
|
||||||
plot(ploty)
|
internal_plot(ploty)
|
||||||
yy++
|
yy++
|
||||||
if decisionOver2<=0
|
if decisionOver2<=0
|
||||||
decisionOver2 += 2*yy+1
|
decisionOver2 += 2*yy+1
|
||||||
@ -146,21 +146,21 @@ graphics {
|
|||||||
ubyte cy_plus_xx = cy + xx
|
ubyte cy_plus_xx = cy + xx
|
||||||
ubyte cy_min_xx = cy - xx
|
ubyte cy_min_xx = cy - xx
|
||||||
|
|
||||||
for plotx in cx to cx+xx {
|
for internal_plotx in cx to cx+xx {
|
||||||
plot(cy_plus_yy)
|
internal_plot(cy_plus_yy)
|
||||||
plot(cy_min_yy)
|
internal_plot(cy_min_yy)
|
||||||
}
|
}
|
||||||
for plotx in cx-xx to cx-1 {
|
for internal_plotx in cx-xx to cx-1 {
|
||||||
plot(cy_plus_yy)
|
internal_plot(cy_plus_yy)
|
||||||
plot(cy_min_yy)
|
internal_plot(cy_min_yy)
|
||||||
}
|
}
|
||||||
for plotx in cx to cx+yy {
|
for internal_plotx in cx to cx+yy {
|
||||||
plot(cy_plus_xx)
|
internal_plot(cy_plus_xx)
|
||||||
plot(cy_min_xx)
|
internal_plot(cy_min_xx)
|
||||||
}
|
}
|
||||||
for plotx in cx-yy to cx {
|
for internal_plotx in cx-yy to cx {
|
||||||
plot(cy_plus_xx)
|
internal_plot(cy_plus_xx)
|
||||||
plot(cy_min_xx)
|
internal_plot(cy_min_xx)
|
||||||
}
|
}
|
||||||
yy++
|
yy++
|
||||||
if decisionOver2<=0
|
if decisionOver2<=0
|
||||||
@ -180,17 +180,27 @@ graphics {
|
|||||||
; @(addr) |= ormask[lsb(px) & 7]
|
; @(addr) |= ormask[lsb(px) & 7]
|
||||||
; }
|
; }
|
||||||
|
|
||||||
uword plotx ; 0..319 ; separate 'parameter' for plot()
|
; TODO fix the use of X (or XY) as parameter so we can actually use this plot() routine
|
||||||
|
; calling it with a byte results in a compiler crash, calling it with word results in clobbering X register I think
|
||||||
|
asmsub plotXXX(uword plotx @XY, ubyte ploty @A) {
|
||||||
|
%asm {{
|
||||||
|
stx internal_plotx
|
||||||
|
sty internal_plotx+1
|
||||||
|
jmp internal_plot
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
asmsub plot(ubyte ploty @A) { ; plotx is 16 bits 0 to 319... doesn't fit in a register
|
uword internal_plotx ; 0..319 ; separate 'parameter' for internal_plot()
|
||||||
|
|
||||||
|
asmsub internal_plot(ubyte ploty @A) { ; internal_plotx is 16 bits 0 to 319... doesn't fit in a register
|
||||||
%asm {{
|
%asm {{
|
||||||
tay
|
tay
|
||||||
stx P8ZP_SCRATCH_REG_X
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda plotx+1
|
lda internal_plotx+1
|
||||||
sta P8ZP_SCRATCH_W2+1
|
sta P8ZP_SCRATCH_W2+1
|
||||||
lsr a ; 0
|
lsr a ; 0
|
||||||
sta P8ZP_SCRATCH_W2
|
sta P8ZP_SCRATCH_W2
|
||||||
lda plotx
|
lda internal_plotx
|
||||||
pha
|
pha
|
||||||
and #7
|
and #7
|
||||||
tax
|
tax
|
||||||
@ -203,7 +213,7 @@ graphics {
|
|||||||
adc P8ZP_SCRATCH_W2+1
|
adc P8ZP_SCRATCH_W2+1
|
||||||
sta P8ZP_SCRATCH_W2+1
|
sta P8ZP_SCRATCH_W2+1
|
||||||
|
|
||||||
pla ; plotx
|
pla ; internal_plotx
|
||||||
and #%11111000
|
and #%11111000
|
||||||
tay
|
tay
|
||||||
lda (P8ZP_SCRATCH_W2),y
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
|
@ -26,14 +26,14 @@ main {
|
|||||||
ubyte pixely
|
ubyte pixely
|
||||||
|
|
||||||
for pixely in 0 to height-1 {
|
for pixely in 0 to height-1 {
|
||||||
float yy = YL+dy*pixely
|
float yy = YL+dy*(pixely as float)
|
||||||
|
|
||||||
cx16.r0 = 0
|
cx16.r0 = 0
|
||||||
cx16.r1 = pixely
|
cx16.r1 = pixely
|
||||||
cx16.FB_cursor_position()
|
cx16.FB_cursor_position()
|
||||||
|
|
||||||
for pixelx in 0 to width-1 {
|
for pixelx in 0 to width-1 {
|
||||||
float xx = XL+dx*pixelx
|
float xx = XL+dx*(pixelx as float)
|
||||||
|
|
||||||
float xsquared = 0.0
|
float xsquared = 0.0
|
||||||
float ysquared = 0.0
|
float ysquared = 0.0
|
||||||
|
@ -37,10 +37,10 @@ main {
|
|||||||
iter++
|
iter++
|
||||||
}
|
}
|
||||||
|
|
||||||
if iter & 1 {
|
if iter & 1
|
||||||
graphics.plotx = pixelx
|
; TODO fix plot() so we don't have to use separate internal variable
|
||||||
graphics.plot(pixely)
|
graphics.internal_plotx = pixelx
|
||||||
}
|
graphics.internal_plot(pixely)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user