mirror of
https://github.com/irmen/prog8.git
synced 2025-02-21 10:29:03 +00:00
fix array assignment stack error
This commit is contained in:
parent
c2c1b43714
commit
214b100f96
@ -21,9 +21,13 @@
|
|||||||
while(true) {
|
while(true) {
|
||||||
rotate_vertices(time)
|
rotate_vertices(time)
|
||||||
c64scr.clear_screenchars(32)
|
c64scr.clear_screenchars(32)
|
||||||
c64scr.print("\uf1203d cube! (using floating point)")
|
|
||||||
draw_edges()
|
draw_edges()
|
||||||
time+=0.2
|
time+=0.2
|
||||||
|
c64.PLOT(0,0,0)
|
||||||
|
c64scr.print("3d cube! (float) ")
|
||||||
|
c64scr.print_ub(c64.TIME_LO)
|
||||||
|
c64scr.print(" jiffies/frame")
|
||||||
|
c64.TIME_LO=0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,12 +55,9 @@
|
|||||||
float Azz = cosb*cosc
|
float Azz = cosb*cosc
|
||||||
|
|
||||||
for ubyte i in 0 to len(xcoor)-1 {
|
for ubyte i in 0 to len(xcoor)-1 {
|
||||||
float xc = xcoor[i]
|
rotatedx[i] = Axx*xcoor[i] + Axy*ycoor[i] + Axz*zcoor[i]
|
||||||
float yc = ycoor[i]
|
rotatedy[i] = Ayx*xcoor[i] + Ayy*ycoor[i] + Ayz*zcoor[i]
|
||||||
float zc = zcoor[i]
|
rotatedz[i] = Azx*xcoor[i] + Azy*ycoor[i] + Azz*zcoor[i]
|
||||||
rotatedx[i] = Axx*xc + Axy*yc + Axz*zc
|
|
||||||
rotatedy[i] = Ayx*xc + Ayy*yc + Ayz*zc
|
|
||||||
rotatedz[i] = Azx*xc + Azy*yc + Azz*zc
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
const uword width = 40
|
const uword width = 40
|
||||||
const uword height = 25
|
const uword height = 25
|
||||||
const float height_f = height
|
|
||||||
|
|
||||||
; vertices
|
; vertices
|
||||||
byte[8] xcoor = [ -40, -40, -40, -40, 40, 40, 40, 40 ]
|
byte[8] xcoor = [ -40, -40, -40, -40, 40, 40, 40, 40 ]
|
||||||
@ -24,11 +23,15 @@
|
|||||||
while(true) {
|
while(true) {
|
||||||
rotate_vertices(msb(anglex), msb(angley), msb(anglez))
|
rotate_vertices(msb(anglex), msb(angley), msb(anglez))
|
||||||
c64scr.clear_screenchars(32)
|
c64scr.clear_screenchars(32)
|
||||||
c64scr.print("\uf1203d cube!")
|
|
||||||
draw_edges()
|
draw_edges()
|
||||||
anglex+=1000
|
anglex+=1000
|
||||||
angley+=433
|
angley+=433
|
||||||
anglez+=907
|
anglez+=907
|
||||||
|
c64.PLOT(0,0,0)
|
||||||
|
c64scr.print("3d cube! (integer) ")
|
||||||
|
c64scr.print_ub(c64.TIME_LO)
|
||||||
|
c64scr.print(" jiffies/frame")
|
||||||
|
c64.TIME_LO=0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,26 +49,20 @@
|
|||||||
word wcosa_sinb = wcosa*wsinb // 128
|
word wcosa_sinb = wcosa*wsinb // 128
|
||||||
word wsina_sinb = wsina*wsinb // 128
|
word wsina_sinb = wsina*wsinb // 128
|
||||||
|
|
||||||
word Axx = (wcosa*wcosb as float / 128.0) as word
|
word Axx = wcosa*wcosb // 128
|
||||||
word Axy = ((wcosa_sinb*wsinc - wsina*wcosc) as float / 128.0) as word
|
word Axy = (wcosa_sinb*wsinc - wsina*wcosc) // 128
|
||||||
word Axz = ((wcosa_sinb*wcosc + wsina*wsinc) as float / 128.0) as word
|
word Axz = (wcosa_sinb*wcosc + wsina*wsinc) // 128
|
||||||
word Ayx = (wsina*wcosb as float / 128.0) as word
|
word Ayx = wsina*wcosb // 128
|
||||||
word Ayy = ((wsina_sinb*wsinc + wcosa*wcosc) as float / 128.0) as word
|
word Ayy = (wsina_sinb*wsinc + wcosa*wcosc) // 128
|
||||||
word Ayz = ((wsina_sinb*wcosc - wcosa*wsinc) as float / 128.0) as word
|
word Ayz = (wsina_sinb*wcosc - wcosa*wsinc) // 128
|
||||||
word Azx = -wsinb
|
word Azx = -wsinb
|
||||||
word Azy = (wcosb*wsinc as float / 128.0) as word
|
word Azy = wcosb*wsinc // 128
|
||||||
word Azz = (wcosb*wcosc as float / 128.0) as word
|
word Azz = wcosb*wcosc // 128
|
||||||
|
|
||||||
for ubyte i in 0 to len(xcoor)-1 {
|
for ubyte i in 0 to len(xcoor)-1 {
|
||||||
word xc = xcoor[i] as word
|
rotatedx[i] = (Axx*xcoor[i] + Axy*ycoor[i] + Axz*zcoor[i]) // 128
|
||||||
word yc = ycoor[i] as word
|
rotatedy[i] =(Ayx*xcoor[i] + Ayy*ycoor[i] + Ayz*zcoor[i]) // 128
|
||||||
word zc = zcoor[i] as word
|
rotatedz[i] = (Azx*xcoor[i] + Azy*ycoor[i] + Azz*zcoor[i]) // 128
|
||||||
word zz = (Axx*xc + Axy*yc + Axz*zc) // 128 ; @todo bugs when not using 'zz' temporary var!?
|
|
||||||
rotatedx[i] = zz
|
|
||||||
zz=(Ayx*xc + Ayy*yc + Ayz*zc) // 128
|
|
||||||
rotatedy[i] = zz
|
|
||||||
zz = (Azx*xc + Azy*yc + Azz*zc) // 128
|
|
||||||
rotatedz[i] = zz
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +74,14 @@
|
|||||||
for ubyte i in 0 to len(xcoor)-1 {
|
for ubyte i in 0 to len(xcoor)-1 {
|
||||||
word rz = rotatedz[i]
|
word rz = rotatedz[i]
|
||||||
if rz >= 10 {
|
if rz >= 10 {
|
||||||
|
const float height_f = height
|
||||||
float persp = (rz as float + 180.0)/height_f
|
float persp = (rz as float + 180.0)/height_f
|
||||||
byte sx = rotatedx[i] as float / persp as byte + width//2
|
byte sx = rotatedx[i] as float / persp as byte + width//2
|
||||||
byte sy = rotatedy[i] as float / persp as byte + height//2
|
byte sy = rotatedy[i] as float / persp as byte + height//2
|
||||||
|
; @todo switch to this once idiv_w is implemented: (and remove c64flt import)
|
||||||
|
;word persp = (rz+180) // height
|
||||||
|
;byte sx = rotatedx[i] // persp as byte + width//2
|
||||||
|
;byte sy = rotatedy[i] // persp as byte + height//2
|
||||||
c64scr.setchrclr(sx as ubyte, sy as ubyte, 46, i+2)
|
c64scr.setchrclr(sx as ubyte, sy as ubyte, 46, i+2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,9 +89,14 @@
|
|||||||
for ubyte i in 0 to len(xcoor)-1 {
|
for ubyte i in 0 to len(xcoor)-1 {
|
||||||
word rz = rotatedz[i]
|
word rz = rotatedz[i]
|
||||||
if rz < 10 {
|
if rz < 10 {
|
||||||
|
const float height_f = height
|
||||||
float persp = (rz as float + 180.0)/height_f
|
float persp = (rz as float + 180.0)/height_f
|
||||||
byte sx = rotatedx[i] as float / persp as byte + width//2
|
byte sx = rotatedx[i] as float / persp as byte + width//2
|
||||||
byte sy = rotatedy[i] as float / persp as byte + height//2
|
byte sy = rotatedy[i] as float / persp as byte + height//2
|
||||||
|
; @todo switch to this once idiv_w is implemented: (and remove c64flt import)
|
||||||
|
;word persp = (rz+180) // height
|
||||||
|
;byte sx = rotatedx[i] // persp as byte + width//2
|
||||||
|
;byte sy = rotatedy[i] // persp as byte + height//2
|
||||||
c64scr.setchrclr(sx as ubyte, sy as ubyte, 81, i+2)
|
c64scr.setchrclr(sx as ubyte, sy as ubyte, 81, i+2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,9 +582,10 @@ class AsmGen(val options: CompilationOptions, val program: IntermediateProgram,
|
|||||||
lda ${ESTACK_LO.toHex()},x
|
lda ${ESTACK_LO.toHex()},x
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda ${(ESTACK_LO-1).toHex()},x
|
inx
|
||||||
|
lda ${ESTACK_LO.toHex()},x
|
||||||
sta ${ins.callLabel},y
|
sta ${ins.callLabel},y
|
||||||
lda ${(ESTACK_HI-1).toHex()},x
|
lda ${ESTACK_HI.toHex()},x
|
||||||
sta ${ins.callLabel}+1,y
|
sta ${ins.callLabel}+1,y
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
@ -560,9 +560,14 @@ asmsub clear_screenchars (ubyte char @ A) -> clobbers(Y) -> () {
|
|||||||
%asm {{
|
%asm {{
|
||||||
ldy #0
|
ldy #0
|
||||||
_loop sta c64.Screen,y
|
_loop sta c64.Screen,y
|
||||||
|
sta c64.Screen+1,y
|
||||||
sta c64.Screen+$0100,y
|
sta c64.Screen+$0100,y
|
||||||
|
sta c64.Screen+$0101,y
|
||||||
sta c64.Screen+$0200,y
|
sta c64.Screen+$0200,y
|
||||||
|
sta c64.Screen+$0201,y
|
||||||
sta c64.Screen+$02e8,y
|
sta c64.Screen+$02e8,y
|
||||||
|
sta c64.Screen+$02e9,y
|
||||||
|
iny
|
||||||
iny
|
iny
|
||||||
bne _loop
|
bne _loop
|
||||||
rts
|
rts
|
||||||
@ -575,9 +580,14 @@ asmsub clear_screencolors (ubyte color @ A) -> clobbers(Y) -> () {
|
|||||||
%asm {{
|
%asm {{
|
||||||
ldy #0
|
ldy #0
|
||||||
_loop sta c64.Colors,y
|
_loop sta c64.Colors,y
|
||||||
|
sta c64.Colors+1,y
|
||||||
sta c64.Colors+$0100,y
|
sta c64.Colors+$0100,y
|
||||||
|
sta c64.Colors+$0101,y
|
||||||
sta c64.Colors+$0200,y
|
sta c64.Colors+$0200,y
|
||||||
|
sta c64.Colors+$0201,y
|
||||||
sta c64.Colors+$02e8,y
|
sta c64.Colors+$02e8,y
|
||||||
|
sta c64.Colors+$02e9,y
|
||||||
|
iny
|
||||||
iny
|
iny
|
||||||
bne _loop
|
bne _loop
|
||||||
rts
|
rts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user