mirror of
https://github.com/irmen/prog8.git
synced 2024-07-30 17:29:03 +00:00
refer to ZP scratch constants from asm code via the global P8ZP constants as well
This commit is contained in:
parent
8d8c066447
commit
78bdbde3ae
@ -4,47 +4,47 @@
|
|||||||
ub2float .proc
|
ub2float .proc
|
||||||
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
|
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
|
||||||
; clobbers A, Y
|
; clobbers A, Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
sty c64.SCRATCH_ZPWORD2+1
|
sty P8ZP_SCRATCH_W2+1
|
||||||
ldy c64.SCRATCH_ZPB1
|
ldy P8ZP_SCRATCH_B1
|
||||||
jsr FREADUY
|
jsr FREADUY
|
||||||
_fac_to_mem ldx c64.SCRATCH_ZPWORD2
|
_fac_to_mem ldx P8ZP_SCRATCH_W2
|
||||||
ldy c64.SCRATCH_ZPWORD2+1
|
ldy P8ZP_SCRATCH_W2+1
|
||||||
jsr MOVMF
|
jsr MOVMF
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
b2float .proc
|
b2float .proc
|
||||||
; -- convert byte in SCRATCH_ZPB1 to float at address A/Y
|
; -- convert byte in SCRATCH_ZPB1 to float at address A/Y
|
||||||
; clobbers A, Y
|
; clobbers A, Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
sty c64.SCRATCH_ZPWORD2+1
|
sty P8ZP_SCRATCH_W2+1
|
||||||
lda c64.SCRATCH_ZPB1
|
lda P8ZP_SCRATCH_B1
|
||||||
jsr FREADSA
|
jsr FREADSA
|
||||||
jmp ub2float._fac_to_mem
|
jmp ub2float._fac_to_mem
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
uw2float .proc
|
uw2float .proc
|
||||||
; -- convert uword in SCRATCH_ZPWORD1 to float at address A/Y
|
; -- convert uword in SCRATCH_ZPWORD1 to float at address A/Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
sty c64.SCRATCH_ZPWORD2+1
|
sty P8ZP_SCRATCH_W2+1
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr GIVUAYFAY
|
jsr GIVUAYFAY
|
||||||
jmp ub2float._fac_to_mem
|
jmp ub2float._fac_to_mem
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
w2float .proc
|
w2float .proc
|
||||||
; -- convert word in SCRATCH_ZPWORD1 to float at address A/Y
|
; -- convert word in SCRATCH_ZPWORD1 to float at address A/Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
sty c64.SCRATCH_ZPWORD2+1
|
sty P8ZP_SCRATCH_W2+1
|
||||||
ldy c64.SCRATCH_ZPWORD1
|
ldy P8ZP_SCRATCH_W1
|
||||||
lda c64.SCRATCH_ZPWORD1+1
|
lda P8ZP_SCRATCH_W1+1
|
||||||
jsr GIVAYF
|
jsr GIVAYF
|
||||||
jmp ub2float._fac_to_mem
|
jmp ub2float._fac_to_mem
|
||||||
.pend
|
.pend
|
||||||
@ -52,8 +52,8 @@ w2float .proc
|
|||||||
stack_b2float .proc
|
stack_b2float .proc
|
||||||
; -- b2float operating on the stack
|
; -- b2float operating on the stack
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr FREADSA
|
jsr FREADSA
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -61,9 +61,9 @@ stack_b2float .proc
|
|||||||
stack_w2float .proc
|
stack_w2float .proc
|
||||||
; -- w2float operating on the stack
|
; -- w2float operating on the stack
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
lda c64.ESTACK_HI,x
|
lda P8ESTACK_HI,x
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr GIVAYF
|
jsr GIVAYF
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -71,8 +71,8 @@ stack_w2float .proc
|
|||||||
stack_ub2float .proc
|
stack_ub2float .proc
|
||||||
; -- ub2float operating on the stack
|
; -- ub2float operating on the stack
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
tay
|
tay
|
||||||
jsr FREADUY
|
jsr FREADUY
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
@ -81,34 +81,34 @@ stack_ub2float .proc
|
|||||||
stack_uw2float .proc
|
stack_uw2float .proc
|
||||||
; -- uw2float operating on the stack
|
; -- uw2float operating on the stack
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
ldy c64.ESTACK_HI,x
|
ldy P8ESTACK_HI,x
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr GIVUAYFAY
|
jsr GIVUAYFAY
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
stack_float2w .proc ; also used for float2b
|
stack_float2w .proc ; also used for float2b
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr AYINT
|
jsr AYINT
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
lda $64
|
lda $64
|
||||||
sta c64.ESTACK_HI,x
|
sta P8ESTACK_HI,x
|
||||||
lda $65
|
lda $65
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
dex
|
dex
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
stack_float2uw .proc ; also used for float2ub
|
stack_float2uw .proc ; also used for float2ub
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr GETADR
|
jsr GETADR
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.ESTACK_HI,x
|
sta P8ESTACK_HI,x
|
||||||
tya
|
tya
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
dex
|
dex
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
@ -116,39 +116,39 @@ stack_float2uw .proc ; also used for float2ub
|
|||||||
push_float .proc
|
push_float .proc
|
||||||
; ---- push mflpt5 in A/Y onto stack
|
; ---- push mflpt5 in A/Y onto stack
|
||||||
; (taking 3 stack positions = 6 bytes of which 1 is padding)
|
; (taking 3 stack positions = 6 bytes of which 1 is padding)
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
ldy #0
|
ldy #0
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
iny
|
iny
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
sta c64.ESTACK_HI,x
|
sta P8ESTACK_HI,x
|
||||||
dex
|
dex
|
||||||
iny
|
iny
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
iny
|
iny
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
sta c64.ESTACK_HI,x
|
sta P8ESTACK_HI,x
|
||||||
dex
|
dex
|
||||||
iny
|
iny
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
dex
|
dex
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
func_rndf .proc
|
func_rndf .proc
|
||||||
; -- put a random floating point value on the stack
|
; -- put a random floating point value on the stack
|
||||||
stx c64.SCRATCH_ZPREG
|
stx P8ZP_SCRATCH_REG
|
||||||
lda #1
|
lda #1
|
||||||
jsr FREADSA
|
jsr FREADSA
|
||||||
jsr RND ; rng into fac1
|
jsr RND ; rng into fac1
|
||||||
ldx #<_rndf_rnum5
|
ldx #<_rndf_rnum5
|
||||||
ldy #>_rndf_rnum5
|
ldy #>_rndf_rnum5
|
||||||
jsr MOVMF ; fac1 to mem X/Y
|
jsr MOVMF ; fac1 to mem X/Y
|
||||||
ldx c64.SCRATCH_ZPREG
|
ldx P8ZP_SCRATCH_REG
|
||||||
lda #<_rndf_rnum5
|
lda #<_rndf_rnum5
|
||||||
ldy #>_rndf_rnum5
|
ldy #>_rndf_rnum5
|
||||||
jmp push_float
|
jmp push_float
|
||||||
@ -158,26 +158,26 @@ _rndf_rnum5 .byte 0,0,0,0,0
|
|||||||
pop_float .proc
|
pop_float .proc
|
||||||
; ---- pops mflpt5 from stack to memory A/Y
|
; ---- pops mflpt5 from stack to memory A/Y
|
||||||
; (frees 3 stack positions = 6 bytes of which 1 is padding)
|
; (frees 3 stack positions = 6 bytes of which 1 is padding)
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
ldy #4
|
ldy #4
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_HI,x
|
lda P8ESTACK_HI,x
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_HI,x
|
lda P8ESTACK_HI,x
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -203,12 +203,12 @@ pop_float_fac2 .proc
|
|||||||
|
|
||||||
pop_float_to_indexed_var .proc
|
pop_float_to_indexed_var .proc
|
||||||
; -- pop the float on the stack, to the memory in the array at A/Y indexed by the byte on stack
|
; -- pop the float on the stack, to the memory in the array at A/Y indexed by the byte on stack
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
jsr prog8_lib.pop_index_times_5
|
jsr prog8_lib.pop_index_times_5
|
||||||
jsr prog8_lib.add_a_to_zpword
|
jsr prog8_lib.add_a_to_zpword
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jmp pop_float
|
jmp pop_float
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ copy_float .proc
|
|||||||
sta _target+1
|
sta _target+1
|
||||||
sty _target+2
|
sty _target+2
|
||||||
ldy #4
|
ldy #4
|
||||||
_loop lda (c64.SCRATCH_ZPWORD1),y
|
_loop lda (P8ZP_SCRATCH_W1),y
|
||||||
_target sta $ffff,y ; modified
|
_target sta $ffff,y ; modified
|
||||||
dey
|
dey
|
||||||
bpl _loop
|
bpl _loop
|
||||||
@ -227,35 +227,35 @@ _target sta $ffff,y ; modified
|
|||||||
|
|
||||||
inc_var_f .proc
|
inc_var_f .proc
|
||||||
; -- add 1 to float pointed to by A/Y
|
; -- add 1 to float pointed to by A/Y
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr MOVFM
|
jsr MOVFM
|
||||||
lda #<FL_FONE
|
lda #<FL_FONE
|
||||||
ldy #>FL_FONE
|
ldy #>FL_FONE
|
||||||
jsr FADD
|
jsr FADD
|
||||||
ldx c64.SCRATCH_ZPWORD1
|
ldx P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr MOVMF
|
jsr MOVMF
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
dec_var_f .proc
|
dec_var_f .proc
|
||||||
; -- subtract 1 from float pointed to by A/Y
|
; -- subtract 1 from float pointed to by A/Y
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<FL_FONE
|
lda #<FL_FONE
|
||||||
ldy #>FL_FONE
|
ldy #>FL_FONE
|
||||||
jsr MOVFM
|
jsr MOVFM
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr FSUB
|
jsr FSUB
|
||||||
ldx c64.SCRATCH_ZPWORD1
|
ldx P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr MOVMF
|
jsr MOVMF
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ push_fac1_as_result .proc
|
|||||||
jsr MOVMF
|
jsr MOVMF
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
jmp push_float
|
jmp push_float
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -296,21 +296,21 @@ pow_f .proc
|
|||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr pop_float
|
jsr pop_float
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr CONUPK ; fac2 = float1
|
jsr CONUPK ; fac2 = float1
|
||||||
lda #<fmath_float2
|
lda #<fmath_float2
|
||||||
ldy #>fmath_float2
|
ldy #>fmath_float2
|
||||||
jsr FPWR
|
jsr FPWR
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
div_f .proc
|
div_f .proc
|
||||||
; -- push f1/f2 on stack
|
; -- push f1/f2 on stack
|
||||||
jsr pop_2_floats_f2_in_fac1
|
jsr pop_2_floats_f2_in_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr FDIV
|
jsr FDIV
|
||||||
@ -320,7 +320,7 @@ div_f .proc
|
|||||||
add_f .proc
|
add_f .proc
|
||||||
; -- push f1+f2 on stack
|
; -- push f1+f2 on stack
|
||||||
jsr pop_2_floats_f2_in_fac1
|
jsr pop_2_floats_f2_in_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr FADD
|
jsr FADD
|
||||||
@ -330,7 +330,7 @@ add_f .proc
|
|||||||
sub_f .proc
|
sub_f .proc
|
||||||
; -- push f1-f2 on stack
|
; -- push f1-f2 on stack
|
||||||
jsr pop_2_floats_f2_in_fac1
|
jsr pop_2_floats_f2_in_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr FSUB
|
jsr FSUB
|
||||||
@ -340,7 +340,7 @@ sub_f .proc
|
|||||||
mul_f .proc
|
mul_f .proc
|
||||||
; -- push f1*f2 on stack
|
; -- push f1*f2 on stack
|
||||||
jsr pop_2_floats_f2_in_fac1
|
jsr pop_2_floats_f2_in_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<fmath_float1
|
lda #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr FMULT
|
jsr FMULT
|
||||||
@ -350,7 +350,7 @@ mul_f .proc
|
|||||||
neg_f .proc
|
neg_f .proc
|
||||||
; -- push -flt back on stack
|
; -- push -flt back on stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr NEGOP
|
jsr NEGOP
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -358,7 +358,7 @@ neg_f .proc
|
|||||||
abs_f .proc
|
abs_f .proc
|
||||||
; -- push abs(float) on stack (as float)
|
; -- push abs(float) on stack (as float)
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr ABS
|
jsr ABS
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -369,24 +369,24 @@ equal_f .proc
|
|||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO-3,x
|
lda P8ESTACK_LO-3,x
|
||||||
cmp c64.ESTACK_LO,x
|
cmp P8ESTACK_LO,x
|
||||||
bne _equals_false
|
bne _equals_false
|
||||||
lda c64.ESTACK_LO-2,x
|
lda P8ESTACK_LO-2,x
|
||||||
cmp c64.ESTACK_LO+1,x
|
cmp P8ESTACK_LO+1,x
|
||||||
bne _equals_false
|
bne _equals_false
|
||||||
lda c64.ESTACK_LO-1,x
|
lda P8ESTACK_LO-1,x
|
||||||
cmp c64.ESTACK_LO+2,x
|
cmp P8ESTACK_LO+2,x
|
||||||
bne _equals_false
|
bne _equals_false
|
||||||
lda c64.ESTACK_HI-2,x
|
lda P8ESTACK_HI-2,x
|
||||||
cmp c64.ESTACK_HI+1,x
|
cmp P8ESTACK_HI+1,x
|
||||||
bne _equals_false
|
bne _equals_false
|
||||||
lda c64.ESTACK_HI-1,x
|
lda P8ESTACK_HI-1,x
|
||||||
cmp c64.ESTACK_HI+2,x
|
cmp P8ESTACK_HI+2,x
|
||||||
bne _equals_false
|
bne _equals_false
|
||||||
_equals_true lda #1
|
_equals_true lda #1
|
||||||
_equals_store inx
|
_equals_store inx
|
||||||
sta c64.ESTACK_LO+1,x
|
sta P8ESTACK_LO+1,x
|
||||||
rts
|
rts
|
||||||
_equals_false lda #0
|
_equals_false lda #0
|
||||||
beq _equals_store
|
beq _equals_store
|
||||||
@ -396,7 +396,7 @@ notequal_f .proc
|
|||||||
; -- are the two mflpt5 numbers on the stack different?
|
; -- are the two mflpt5 numbers on the stack different?
|
||||||
jsr equal_f
|
jsr equal_f
|
||||||
eor #1 ; invert the result
|
eor #1 ; invert the result
|
||||||
sta c64.ESTACK_LO+1,x
|
sta P8ESTACK_LO+1,x
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -449,12 +449,12 @@ compare_floats .proc
|
|||||||
jsr MOVFM ; fac1 = flt1
|
jsr MOVFM ; fac1 = flt1
|
||||||
lda #<fmath_float2
|
lda #<fmath_float2
|
||||||
ldy #>fmath_float2
|
ldy #>fmath_float2
|
||||||
stx c64.SCRATCH_ZPREG
|
stx P8ZP_SCRATCH_REG
|
||||||
jsr FCOMP ; A = flt1 compared with flt2 (0=equal, 1=flt1>flt2, 255=flt1<flt2)
|
jsr FCOMP ; A = flt1 compared with flt2 (0=equal, 1=flt1>flt2, 255=flt1<flt2)
|
||||||
ldx c64.SCRATCH_ZPREG
|
ldx P8ZP_SCRATCH_REG
|
||||||
rts
|
rts
|
||||||
_return_false lda #0
|
_return_false lda #0
|
||||||
_return_result sta c64.ESTACK_LO,x
|
_return_result sta P8ESTACK_LO,x
|
||||||
dex
|
dex
|
||||||
rts
|
rts
|
||||||
_return_true lda #1
|
_return_true lda #1
|
||||||
@ -464,7 +464,7 @@ _return_true lda #1
|
|||||||
func_sin .proc
|
func_sin .proc
|
||||||
; -- push sin(f) back onto stack
|
; -- push sin(f) back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr SIN
|
jsr SIN
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -472,7 +472,7 @@ func_sin .proc
|
|||||||
func_cos .proc
|
func_cos .proc
|
||||||
; -- push cos(f) back onto stack
|
; -- push cos(f) back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr COS
|
jsr COS
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -480,7 +480,7 @@ func_cos .proc
|
|||||||
func_tan .proc
|
func_tan .proc
|
||||||
; -- push tan(f) back onto stack
|
; -- push tan(f) back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr TAN
|
jsr TAN
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -488,7 +488,7 @@ func_tan .proc
|
|||||||
func_atan .proc
|
func_atan .proc
|
||||||
; -- push atan(f) back onto stack
|
; -- push atan(f) back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr ATN
|
jsr ATN
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -496,7 +496,7 @@ func_atan .proc
|
|||||||
func_ln .proc
|
func_ln .proc
|
||||||
; -- push ln(f) back onto stack
|
; -- push ln(f) back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr LOG
|
jsr LOG
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -504,7 +504,7 @@ func_ln .proc
|
|||||||
func_log2 .proc
|
func_log2 .proc
|
||||||
; -- push log base 2, ln(f)/ln(2), back onto stack
|
; -- push log base 2, ln(f)/ln(2), back onto stack
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr LOG
|
jsr LOG
|
||||||
jsr MOVEF
|
jsr MOVEF
|
||||||
lda #<c64.FL_LOG2
|
lda #<c64.FL_LOG2
|
||||||
@ -516,7 +516,7 @@ func_log2 .proc
|
|||||||
|
|
||||||
func_sqrt .proc
|
func_sqrt .proc
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr SQR
|
jsr SQR
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -524,7 +524,7 @@ func_sqrt .proc
|
|||||||
func_rad .proc
|
func_rad .proc
|
||||||
; -- convert degrees to radians (d * pi / 180)
|
; -- convert degrees to radians (d * pi / 180)
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<_pi_div_180
|
lda #<_pi_div_180
|
||||||
ldy #>_pi_div_180
|
ldy #>_pi_div_180
|
||||||
jsr FMULT
|
jsr FMULT
|
||||||
@ -535,7 +535,7 @@ _pi_div_180 .byte 123, 14, 250, 53, 18 ; pi / 180
|
|||||||
func_deg .proc
|
func_deg .proc
|
||||||
; -- convert radians to degrees (d * (1/ pi * 180))
|
; -- convert radians to degrees (d * (1/ pi * 180))
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<_one_over_pi_div_180
|
lda #<_one_over_pi_div_180
|
||||||
ldy #>_one_over_pi_div_180
|
ldy #>_one_over_pi_div_180
|
||||||
jsr FMULT
|
jsr FMULT
|
||||||
@ -545,7 +545,7 @@ _one_over_pi_div_180 .byte 134, 101, 46, 224, 211 ; 1 / (pi * 180)
|
|||||||
|
|
||||||
func_round .proc
|
func_round .proc
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr FADDH
|
jsr FADDH
|
||||||
jsr INT
|
jsr INT
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
@ -553,7 +553,7 @@ func_round .proc
|
|||||||
|
|
||||||
func_floor .proc
|
func_floor .proc
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr INT
|
jsr INT
|
||||||
jmp push_fac1_as_result
|
jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -561,7 +561,7 @@ func_floor .proc
|
|||||||
func_ceil .proc
|
func_ceil .proc
|
||||||
; -- ceil: tr = int(f); if tr==f -> return else return tr+1
|
; -- ceil: tr = int(f); if tr==f -> return else return tr+1
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
ldx #<fmath_float1
|
ldx #<fmath_float1
|
||||||
ldy #>fmath_float1
|
ldy #>fmath_float1
|
||||||
jsr MOVMF
|
jsr MOVMF
|
||||||
@ -579,45 +579,45 @@ func_ceil .proc
|
|||||||
|
|
||||||
func_any_f .proc
|
func_any_f .proc
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x ; array size
|
lda P8ESTACK_LO,x ; array size
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPB1 ; times 5 because of float
|
adc P8ZP_SCRATCH_B1 ; times 5 because of float
|
||||||
jmp prog8_lib.func_any_b._entry
|
jmp prog8_lib.func_any_b._entry
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
func_all_f .proc
|
func_all_f .proc
|
||||||
inx
|
inx
|
||||||
jsr prog8_lib.peek_address
|
jsr prog8_lib.peek_address
|
||||||
lda c64.ESTACK_LO,x ; array size
|
lda P8ESTACK_LO,x ; array size
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPB1 ; times 5 because of float
|
adc P8ZP_SCRATCH_B1 ; times 5 because of float
|
||||||
tay
|
tay
|
||||||
dey
|
dey
|
||||||
- lda (c64.SCRATCH_ZPWORD1),y
|
- lda (P8ZP_SCRATCH_W1),y
|
||||||
clc
|
clc
|
||||||
dey
|
dey
|
||||||
adc (c64.SCRATCH_ZPWORD1),y
|
adc (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
adc (c64.SCRATCH_ZPWORD1),y
|
adc (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
adc (c64.SCRATCH_ZPWORD1),y
|
adc (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
adc (c64.SCRATCH_ZPWORD1),y
|
adc (P8ZP_SCRATCH_W1),y
|
||||||
dey
|
dey
|
||||||
cmp #0
|
cmp #0
|
||||||
beq +
|
beq +
|
||||||
cpy #255
|
cpy #255
|
||||||
bne -
|
bne -
|
||||||
lda #1
|
lda #1
|
||||||
sta c64.ESTACK_LO+1,x
|
sta P8ESTACK_LO+1,x
|
||||||
rts
|
rts
|
||||||
+ sta c64.ESTACK_LO+1,x
|
+ sta P8ESTACK_LO+1,x
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -628,23 +628,23 @@ func_max_f .proc
|
|||||||
ldy #>_largest_neg_float
|
ldy #>_largest_neg_float
|
||||||
_minmax_entry jsr MOVFM
|
_minmax_entry jsr MOVFM
|
||||||
jsr prog8_lib.pop_array_and_lengthmin1Y
|
jsr prog8_lib.pop_array_and_lengthmin1Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
- sty c64.SCRATCH_ZPREG
|
- sty P8ZP_SCRATCH_REG
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr FCOMP
|
jsr FCOMP
|
||||||
_minmax_cmp cmp #255 ; modified
|
_minmax_cmp cmp #255 ; modified
|
||||||
bne +
|
bne +
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr MOVFM
|
jsr MOVFM
|
||||||
+ lda c64.SCRATCH_ZPWORD1
|
+ lda P8ZP_SCRATCH_W1
|
||||||
clc
|
clc
|
||||||
adc #5
|
adc #5
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
bcc +
|
bcc +
|
||||||
inc c64.SCRATCH_ZPWORD1+1
|
inc P8ZP_SCRATCH_W1+1
|
||||||
+ ldy c64.SCRATCH_ZPREG
|
+ ldy P8ZP_SCRATCH_REG
|
||||||
dey
|
dey
|
||||||
cpy #255
|
cpy #255
|
||||||
bne -
|
bne -
|
||||||
@ -667,21 +667,21 @@ func_sum_f .proc
|
|||||||
ldy #>FL_ZERO
|
ldy #>FL_ZERO
|
||||||
jsr MOVFM
|
jsr MOVFM
|
||||||
jsr prog8_lib.pop_array_and_lengthmin1Y
|
jsr prog8_lib.pop_array_and_lengthmin1Y
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
- sty c64.SCRATCH_ZPREG
|
- sty P8ZP_SCRATCH_REG
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
ldy c64.SCRATCH_ZPWORD1+1
|
ldy P8ZP_SCRATCH_W1+1
|
||||||
jsr FADD
|
jsr FADD
|
||||||
ldy c64.SCRATCH_ZPREG
|
ldy P8ZP_SCRATCH_REG
|
||||||
dey
|
dey
|
||||||
cpy #255
|
cpy #255
|
||||||
beq +
|
beq +
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
clc
|
clc
|
||||||
adc #5
|
adc #5
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
bcc -
|
bcc -
|
||||||
inc c64.SCRATCH_ZPWORD1+1
|
inc P8ZP_SCRATCH_W1+1
|
||||||
bne -
|
bne -
|
||||||
+ jmp push_fac1_as_result
|
+ jmp push_fac1_as_result
|
||||||
.pend
|
.pend
|
||||||
@ -689,7 +689,7 @@ func_sum_f .proc
|
|||||||
sign_f .proc
|
sign_f .proc
|
||||||
jsr pop_float_fac1
|
jsr pop_float_fac1
|
||||||
jsr SIGN
|
jsr SIGN
|
||||||
sta c64.ESTACK_LO,x
|
sta P8ESTACK_LO,x
|
||||||
dex
|
dex
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
@ -698,22 +698,22 @@ sign_f .proc
|
|||||||
set_0_array_float .proc
|
set_0_array_float .proc
|
||||||
; -- set a float in an array to zero (index on stack, array in SCRATCH_ZPWORD1)
|
; -- set a float in an array to zero (index on stack, array in SCRATCH_ZPWORD1)
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
clc
|
clc
|
||||||
adc c64.ESTACK_LO,x
|
adc P8ESTACK_LO,x
|
||||||
tay
|
tay
|
||||||
lda #0
|
lda #0
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
iny
|
iny
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
iny
|
iny
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
iny
|
iny
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
iny
|
iny
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
rts
|
rts
|
||||||
.pend
|
.pend
|
||||||
|
|
||||||
@ -721,13 +721,13 @@ set_0_array_float .proc
|
|||||||
set_array_float .proc
|
set_array_float .proc
|
||||||
; -- set a float in an array to a value (index on stack, float in SCRATCH_ZPWORD1, array in SCRATCH_ZPWORD2)
|
; -- set a float in an array to a value (index on stack, float in SCRATCH_ZPWORD1, array in SCRATCH_ZPWORD2)
|
||||||
inx
|
inx
|
||||||
lda c64.ESTACK_LO,x
|
lda P8ESTACK_LO,x
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
clc
|
clc
|
||||||
adc c64.ESTACK_LO,x
|
adc P8ESTACK_LO,x
|
||||||
adc c64.SCRATCH_ZPWORD2
|
adc P8ZP_SCRATCH_W2
|
||||||
ldy c64.SCRATCH_ZPWORD2+1
|
ldy P8ZP_SCRATCH_W2+1
|
||||||
bcc +
|
bcc +
|
||||||
iny
|
iny
|
||||||
+ jmp copy_float
|
+ jmp copy_float
|
||||||
@ -739,12 +739,12 @@ set_array_float .proc
|
|||||||
swap_floats .proc
|
swap_floats .proc
|
||||||
; -- swap floats pointed to by SCRATCH_ZPWORD1, SCRATCH_ZPWORD2
|
; -- swap floats pointed to by SCRATCH_ZPWORD1, SCRATCH_ZPWORD2
|
||||||
ldy #4
|
ldy #4
|
||||||
- lda (c64.SCRATCH_ZPWORD1),y
|
- lda (P8ZP_SCRATCH_W1),y
|
||||||
pha
|
pha
|
||||||
lda (c64.SCRATCH_ZPWORD2),y
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
sta (c64.SCRATCH_ZPWORD1),y
|
sta (P8ZP_SCRATCH_W1),y
|
||||||
pla
|
pla
|
||||||
sta (c64.SCRATCH_ZPWORD2),y
|
sta (P8ZP_SCRATCH_W2),y
|
||||||
dey
|
dey
|
||||||
bpl -
|
bpl -
|
||||||
rts
|
rts
|
||||||
|
@ -163,9 +163,9 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
|||||||
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||||
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
|
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
|
||||||
%asm {{
|
%asm {{
|
||||||
sta c64.SCRATCH_ZPREG
|
sta P8ZP_SCRATCH_REG
|
||||||
tya
|
tya
|
||||||
ldy c64.SCRATCH_ZPREG
|
ldy P8ZP_SCRATCH_REG
|
||||||
jmp GIVAYF ; this uses the inverse order, Y/A
|
jmp GIVAYF ; this uses the inverse order, Y/A
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -174,9 +174,9 @@ asmsub FTOSWRDAY () clobbers(X) -> uword @ AY {
|
|||||||
; ---- fac1 to signed word in A/Y
|
; ---- fac1 to signed word in A/Y
|
||||||
%asm {{
|
%asm {{
|
||||||
jsr FTOSWORDYA ; note the inverse Y/A order
|
jsr FTOSWORDYA ; note the inverse Y/A order
|
||||||
sta c64.SCRATCH_ZPREG
|
sta P8ZP_SCRATCH_REG
|
||||||
tya
|
tya
|
||||||
ldy c64.SCRATCH_ZPREG
|
ldy P8ZP_SCRATCH_REG
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -185,9 +185,9 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
|||||||
; ---- fac1 to unsigned word in A/Y
|
; ---- fac1 to unsigned word in A/Y
|
||||||
%asm {{
|
%asm {{
|
||||||
jsr GETADR ; this uses the inverse order, Y/A
|
jsr GETADR ; this uses the inverse order, Y/A
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
tya
|
tya
|
||||||
ldy c64.SCRATCH_ZPB1
|
ldy P8ZP_SCRATCH_B1
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -195,13 +195,13 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
|||||||
sub print_f (float value) {
|
sub print_f (float value) {
|
||||||
; ---- prints the floating point value (without a newline) using basic rom routines.
|
; ---- prints the floating point value (without a newline) using basic rom routines.
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<value
|
lda #<value
|
||||||
ldy #>value
|
ldy #>value
|
||||||
jsr MOVFM ; load float into fac1
|
jsr MOVFM ; load float into fac1
|
||||||
jsr FOUT ; fac1 to string in A/Y
|
jsr FOUT ; fac1 to string in A/Y
|
||||||
jsr c64.STROUT ; print string in A/Y
|
jsr c64.STROUT ; print string in A/Y
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -209,12 +209,12 @@ sub print_f (float value) {
|
|||||||
sub print_fln (float value) {
|
sub print_fln (float value) {
|
||||||
; ---- prints the floating point value (with a newline at the end) using basic rom routines
|
; ---- prints the floating point value (with a newline at the end) using basic rom routines
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda #<value
|
lda #<value
|
||||||
ldy #>value
|
ldy #>value
|
||||||
jsr MOVFM ; load float into fac1
|
jsr MOVFM ; load float into fac1
|
||||||
jsr FPRINTLN ; print fac1 with newline
|
jsr FPRINTLN ; print fac1 with newline
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -7,16 +7,6 @@
|
|||||||
|
|
||||||
|
|
||||||
c64 {
|
c64 {
|
||||||
; TODO get rid of those:
|
|
||||||
const uword ESTACK_LO = $ce00 ; evaluation stack (lsb)
|
|
||||||
const uword ESTACK_HI = $cf00 ; evaluation stack (msb)
|
|
||||||
&ubyte SCRATCH_ZPB1 = $02 ; scratch byte 1 in ZP
|
|
||||||
&ubyte SCRATCH_ZPREG = $03 ; scratch register in ZP
|
|
||||||
&ubyte SCRATCH_ZPREGX = $fa ; temp storage for X register (stack pointer)
|
|
||||||
&uword SCRATCH_ZPWORD1 = $fb ; scratch word in ZP ($fb/$fc)
|
|
||||||
&uword SCRATCH_ZPWORD2 = $fd ; scratch word in ZP ($fd/$fe)
|
|
||||||
|
|
||||||
|
|
||||||
&ubyte TIME_HI = $a0 ; software jiffy clock, hi byte
|
&ubyte TIME_HI = $a0 ; software jiffy clock, hi byte
|
||||||
&ubyte TIME_MID = $a1 ; .. mid byte
|
&ubyte TIME_MID = $a1 ; .. mid byte
|
||||||
&ubyte TIME_LO = $a2 ; .. lo byte. Updated by IRQ every 1/60 sec
|
&ubyte TIME_LO = $a2 ; .. lo byte. Updated by IRQ every 1/60 sec
|
||||||
|
@ -59,9 +59,9 @@ asmsub uword2decimal (uword value @ AY) -> ubyte @Y, ubyte @A, ubyte @X {
|
|||||||
|
|
||||||
|
|
||||||
ASCII_0_OFFSET = $30
|
ASCII_0_OFFSET = $30
|
||||||
temp = c64.SCRATCH_ZPB1 ; byte in zeropage
|
temp = P8ZP_SCRATCH_B1 ; byte in zeropage
|
||||||
hexHigh = c64.SCRATCH_ZPWORD1 ; byte in zeropage
|
hexHigh = P8ZP_SCRATCH_W1 ; byte in zeropage
|
||||||
hexLow = c64.SCRATCH_ZPWORD1+1 ; byte in zeropage
|
hexLow = P8ZP_SCRATCH_W1+1 ; byte in zeropage
|
||||||
|
|
||||||
|
|
||||||
HexToDec65535; SUBROUTINE
|
HexToDec65535; SUBROUTINE
|
||||||
@ -221,7 +221,7 @@ asmsub byte2decimal (byte value @ A) -> ubyte @ Y, ubyte @ A, ubyte @ X {
|
|||||||
asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
|
asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
|
||||||
; ---- A to hex petscii string in AY (first hex char in A, second hex char in Y)
|
; ---- A to hex petscii string in AY (first hex char in A, second hex char in Y)
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
pha
|
pha
|
||||||
and #$0f
|
and #$0f
|
||||||
tax
|
tax
|
||||||
@ -233,7 +233,7 @@ asmsub ubyte2hex (ubyte value @ A) -> ubyte @ A, ubyte @ Y {
|
|||||||
lsr a
|
lsr a
|
||||||
tax
|
tax
|
||||||
lda _hex_digits,x
|
lda _hex_digits,x
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as well
|
_hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as well
|
||||||
@ -243,12 +243,12 @@ _hex_digits .text "0123456789abcdef" ; can probably be reused for other stuff as
|
|||||||
asmsub uword2hex (uword value @ AY) clobbers(A,Y) {
|
asmsub uword2hex (uword value @ AY) clobbers(A,Y) {
|
||||||
; ---- convert 16 bit uword in A/Y into 4-character hexadecimal string 'uword2hex.output' (0-terminated)
|
; ---- convert 16 bit uword in A/Y into 4-character hexadecimal string 'uword2hex.output' (0-terminated)
|
||||||
%asm {{
|
%asm {{
|
||||||
sta c64.SCRATCH_ZPREG
|
sta P8ZP_SCRATCH_REG
|
||||||
tya
|
tya
|
||||||
jsr ubyte2hex
|
jsr ubyte2hex
|
||||||
sta output
|
sta output
|
||||||
sty output+1
|
sty output+1
|
||||||
lda c64.SCRATCH_ZPREG
|
lda P8ZP_SCRATCH_REG
|
||||||
jsr ubyte2hex
|
jsr ubyte2hex
|
||||||
sta output+2
|
sta output+2
|
||||||
sty output+3
|
sty output+3
|
||||||
@ -262,7 +262,7 @@ asmsub str2uword(str string @ AY) -> uword @ AY {
|
|||||||
; the number may NOT be preceded by a + sign and may NOT contain spaces
|
; the number may NOT be preceded by a + sign and may NOT contain spaces
|
||||||
; (any non-digit character will terminate the number string that is parsed)
|
; (any non-digit character will terminate the number string that is parsed)
|
||||||
%asm {{
|
%asm {{
|
||||||
_result = c64.SCRATCH_ZPWORD2
|
_result = P8ZP_SCRATCH_W2
|
||||||
sta _mod+1
|
sta _mod+1
|
||||||
sty _mod+2
|
sty _mod+2
|
||||||
ldy #0
|
ldy #0
|
||||||
@ -293,16 +293,16 @@ _done ; return result
|
|||||||
|
|
||||||
_result_times_10 ; (W*4 + W)*2
|
_result_times_10 ; (W*4 + W)*2
|
||||||
lda _result+1
|
lda _result+1
|
||||||
sta c64.SCRATCH_ZPREG
|
sta P8ZP_SCRATCH_REG
|
||||||
lda _result
|
lda _result
|
||||||
asl a
|
asl a
|
||||||
rol c64.SCRATCH_ZPREG
|
rol P8ZP_SCRATCH_REG
|
||||||
asl a
|
asl a
|
||||||
rol c64.SCRATCH_ZPREG
|
rol P8ZP_SCRATCH_REG
|
||||||
clc
|
clc
|
||||||
adc _result
|
adc _result
|
||||||
sta _result
|
sta _result
|
||||||
lda c64.SCRATCH_ZPREG
|
lda P8ZP_SCRATCH_REG
|
||||||
adc _result+1
|
adc _result+1
|
||||||
asl _result
|
asl _result
|
||||||
rol a
|
rol a
|
||||||
@ -316,14 +316,14 @@ asmsub str2word(str string @ AY) -> word @ AY {
|
|||||||
; the number may be preceded by a + or - sign but may NOT contain spaces
|
; the number may be preceded by a + or - sign but may NOT contain spaces
|
||||||
; (any non-digit character will terminate the number string that is parsed)
|
; (any non-digit character will terminate the number string that is parsed)
|
||||||
%asm {{
|
%asm {{
|
||||||
_result = c64.SCRATCH_ZPWORD2
|
_result = P8ZP_SCRATCH_W2
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
ldy #0
|
ldy #0
|
||||||
sty _result
|
sty _result
|
||||||
sty _result+1
|
sty _result+1
|
||||||
sty _negative
|
sty _negative
|
||||||
lda (c64.SCRATCH_ZPWORD1),y
|
lda (P8ZP_SCRATCH_W1),y
|
||||||
cmp #'+'
|
cmp #'+'
|
||||||
bne +
|
bne +
|
||||||
iny
|
iny
|
||||||
@ -331,7 +331,7 @@ _result = c64.SCRATCH_ZPWORD2
|
|||||||
bne _parse
|
bne _parse
|
||||||
inc _negative
|
inc _negative
|
||||||
iny
|
iny
|
||||||
_parse lda (c64.SCRATCH_ZPWORD1),y
|
_parse lda (P8ZP_SCRATCH_W1),y
|
||||||
sec
|
sec
|
||||||
sbc #48
|
sbc #48
|
||||||
bpl _digit
|
bpl _digit
|
||||||
@ -402,19 +402,19 @@ _irq_handler jsr _irq_handler_init
|
|||||||
_irq_handler_init
|
_irq_handler_init
|
||||||
; save all zp scratch registers and the X register as these might be clobbered by the irq routine
|
; save all zp scratch registers and the X register as these might be clobbered by the irq routine
|
||||||
stx IRQ_X_REG
|
stx IRQ_X_REG
|
||||||
lda c64.SCRATCH_ZPB1
|
lda P8ZP_SCRATCH_B1
|
||||||
sta IRQ_SCRATCH_ZPB1
|
sta IRQ_SCRATCH_ZPB1
|
||||||
lda c64.SCRATCH_ZPREG
|
lda P8ZP_SCRATCH_REG
|
||||||
sta IRQ_SCRATCH_ZPREG
|
sta IRQ_SCRATCH_ZPREG
|
||||||
lda c64.SCRATCH_ZPREGX
|
lda P8ZP_SCRATCH_REG_X
|
||||||
sta IRQ_SCRATCH_ZPREGX
|
sta IRQ_SCRATCH_ZPREGX
|
||||||
lda c64.SCRATCH_ZPWORD1
|
lda P8ZP_SCRATCH_W1
|
||||||
sta IRQ_SCRATCH_ZPWORD1
|
sta IRQ_SCRATCH_ZPWORD1
|
||||||
lda c64.SCRATCH_ZPWORD1+1
|
lda P8ZP_SCRATCH_W1+1
|
||||||
sta IRQ_SCRATCH_ZPWORD1+1
|
sta IRQ_SCRATCH_ZPWORD1+1
|
||||||
lda c64.SCRATCH_ZPWORD2
|
lda P8ZP_SCRATCH_W2
|
||||||
sta IRQ_SCRATCH_ZPWORD2
|
sta IRQ_SCRATCH_ZPWORD2
|
||||||
lda c64.SCRATCH_ZPWORD2+1
|
lda P8ZP_SCRATCH_W2+1
|
||||||
sta IRQ_SCRATCH_ZPWORD2+1
|
sta IRQ_SCRATCH_ZPWORD2+1
|
||||||
; stack protector; make sure we don't clobber the top of the evaluation stack
|
; stack protector; make sure we don't clobber the top of the evaluation stack
|
||||||
dex
|
dex
|
||||||
@ -429,19 +429,19 @@ _irq_handler_init
|
|||||||
_irq_handler_end
|
_irq_handler_end
|
||||||
; restore all zp scratch registers and the X register
|
; restore all zp scratch registers and the X register
|
||||||
lda IRQ_SCRATCH_ZPB1
|
lda IRQ_SCRATCH_ZPB1
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
lda IRQ_SCRATCH_ZPREG
|
lda IRQ_SCRATCH_ZPREG
|
||||||
sta c64.SCRATCH_ZPREG
|
sta P8ZP_SCRATCH_REG
|
||||||
lda IRQ_SCRATCH_ZPREGX
|
lda IRQ_SCRATCH_ZPREGX
|
||||||
sta c64.SCRATCH_ZPREGX
|
sta P8ZP_SCRATCH_REG_X
|
||||||
lda IRQ_SCRATCH_ZPWORD1
|
lda IRQ_SCRATCH_ZPWORD1
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda IRQ_SCRATCH_ZPWORD1+1
|
lda IRQ_SCRATCH_ZPWORD1+1
|
||||||
sta c64.SCRATCH_ZPWORD1+1
|
sta P8ZP_SCRATCH_W1+1
|
||||||
lda IRQ_SCRATCH_ZPWORD2
|
lda IRQ_SCRATCH_ZPWORD2
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
lda IRQ_SCRATCH_ZPWORD2+1
|
lda IRQ_SCRATCH_ZPWORD2+1
|
||||||
sta c64.SCRATCH_ZPWORD2+1
|
sta P8ZP_SCRATCH_W2+1
|
||||||
ldx IRQ_X_REG
|
ldx IRQ_X_REG
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ asmsub scroll_left_full (ubyte alsocolors @ Pc) clobbers(A, Y) {
|
|||||||
; Carry flag determines if screen color data must be scrolled too
|
; Carry flag determines if screen color data must be scrolled too
|
||||||
|
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
bcs +
|
bcs +
|
||||||
jmp _scroll_screen
|
jmp _scroll_screen
|
||||||
|
|
||||||
@ -623,7 +623,7 @@ _scroll_screen ; scroll the screen memory
|
|||||||
dey
|
dey
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -633,7 +633,7 @@ asmsub scroll_right_full (ubyte alsocolors @ Pc) clobbers(A) {
|
|||||||
; contents of the leftmost column are unchanged, you should clear/refill this yourself
|
; contents of the leftmost column are unchanged, you should clear/refill this yourself
|
||||||
; Carry flag determines if screen color data must be scrolled too
|
; Carry flag determines if screen color data must be scrolled too
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
bcs +
|
bcs +
|
||||||
jmp _scroll_screen
|
jmp _scroll_screen
|
||||||
|
|
||||||
@ -657,7 +657,7 @@ _scroll_screen ; scroll the screen memory
|
|||||||
dex
|
dex
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ asmsub scroll_up_full (ubyte alsocolors @ Pc) clobbers(A) {
|
|||||||
; contents of the bottom row are unchanged, you should refill/clear this yourself
|
; contents of the bottom row are unchanged, you should refill/clear this yourself
|
||||||
; Carry flag determines if screen color data must be scrolled too
|
; Carry flag determines if screen color data must be scrolled too
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
bcs +
|
bcs +
|
||||||
jmp _scroll_screen
|
jmp _scroll_screen
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ _scroll_screen ; scroll the screen memory
|
|||||||
dex
|
dex
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -701,7 +701,7 @@ asmsub scroll_down_full (ubyte alsocolors @ Pc) clobbers(A) {
|
|||||||
; contents of the top row are unchanged, you should refill/clear this yourself
|
; contents of the top row are unchanged, you should refill/clear this yourself
|
||||||
; Carry flag determines if screen color data must be scrolled too
|
; Carry flag determines if screen color data must be scrolled too
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
bcs +
|
bcs +
|
||||||
jmp _scroll_screen
|
jmp _scroll_screen
|
||||||
|
|
||||||
@ -725,7 +725,7 @@ _scroll_screen ; scroll the screen memory
|
|||||||
dex
|
dex
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -737,10 +737,10 @@ asmsub print (str text @ AY) clobbers(A,Y) {
|
|||||||
; a call to this subroutine with a string argument of just one char,
|
; a call to this subroutine with a string argument of just one char,
|
||||||
; by just one call to c64.CHROUT of that single char.
|
; by just one call to c64.CHROUT of that single char.
|
||||||
%asm {{
|
%asm {{
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
sty c64.SCRATCH_ZPREG
|
sty P8ZP_SCRATCH_REG
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda (c64.SCRATCH_ZPB1),y
|
- lda (P8ZP_SCRATCH_B1),y
|
||||||
beq +
|
beq +
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
iny
|
iny
|
||||||
@ -752,7 +752,7 @@ asmsub print (str text @ AY) clobbers(A,Y) {
|
|||||||
asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
|
asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
|
||||||
; ---- print the ubyte in A in decimal form, with left padding 0s (3 positions total)
|
; ---- print the ubyte in A in decimal form, with left padding 0s (3 positions total)
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr c64utils.ubyte2decimal
|
jsr c64utils.ubyte2decimal
|
||||||
pha
|
pha
|
||||||
tya
|
tya
|
||||||
@ -761,7 +761,7 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
|
|||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
txa
|
txa
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ asmsub print_ub0 (ubyte value @ A) clobbers(A,Y) {
|
|||||||
asmsub print_ub (ubyte value @ A) clobbers(A,Y) {
|
asmsub print_ub (ubyte value @ A) clobbers(A,Y) {
|
||||||
; ---- print the ubyte in A in decimal form, without left padding 0s
|
; ---- print the ubyte in A in decimal form, without left padding 0s
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr c64utils.ubyte2decimal
|
jsr c64utils.ubyte2decimal
|
||||||
_print_byte_digits
|
_print_byte_digits
|
||||||
pha
|
pha
|
||||||
@ -786,7 +786,7 @@ _print_byte_digits
|
|||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
_ones txa
|
_ones txa
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -794,7 +794,7 @@ _ones txa
|
|||||||
asmsub print_b (byte value @ A) clobbers(A,Y) {
|
asmsub print_b (byte value @ A) clobbers(A,Y) {
|
||||||
; ---- print the byte in A in decimal form, without left padding 0s
|
; ---- print the byte in A in decimal form, without left padding 0s
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
pha
|
pha
|
||||||
cmp #0
|
cmp #0
|
||||||
bpl +
|
bpl +
|
||||||
@ -803,7 +803,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) {
|
|||||||
+ pla
|
+ pla
|
||||||
jsr c64utils.byte2decimal
|
jsr c64utils.byte2decimal
|
||||||
jsr print_ub._print_byte_digits
|
jsr print_ub._print_byte_digits
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -811,7 +811,7 @@ asmsub print_b (byte value @ A) clobbers(A,Y) {
|
|||||||
asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
||||||
; ---- print the ubyte in A in hex form (if Carry is set, a radix prefix '$' is printed as well)
|
; ---- print the ubyte in A in hex form (if Carry is set, a radix prefix '$' is printed as well)
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
bcc +
|
bcc +
|
||||||
pha
|
pha
|
||||||
lda #'$'
|
lda #'$'
|
||||||
@ -821,7 +821,7 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
|||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
tya
|
tya
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -829,20 +829,20 @@ asmsub print_ubhex (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
|||||||
asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
asmsub print_ubbin (ubyte value @ A, ubyte prefix @ Pc) clobbers(A,Y) {
|
||||||
; ---- print the ubyte in A in binary form (if Carry is set, a radix prefix '%' is printed as well)
|
; ---- print the ubyte in A in binary form (if Carry is set, a radix prefix '%' is printed as well)
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
sta c64.SCRATCH_ZPB1
|
sta P8ZP_SCRATCH_B1
|
||||||
bcc +
|
bcc +
|
||||||
lda #'%'
|
lda #'%'
|
||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
+ ldy #8
|
+ ldy #8
|
||||||
- lda #'0'
|
- lda #'0'
|
||||||
asl c64.SCRATCH_ZPB1
|
asl P8ZP_SCRATCH_B1
|
||||||
bcc +
|
bcc +
|
||||||
lda #'1'
|
lda #'1'
|
||||||
+ jsr c64.CHROUT
|
+ jsr c64.CHROUT
|
||||||
dey
|
dey
|
||||||
bne -
|
bne -
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -875,7 +875,7 @@ asmsub print_uwhex (uword value @ AY, ubyte prefix @ Pc) clobbers(A,Y) {
|
|||||||
asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
|
asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
|
||||||
; ---- print the uword in A/Y in decimal form, with left padding 0s (5 positions total)
|
; ---- print the uword in A/Y in decimal form, with left padding 0s (5 positions total)
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr c64utils.uword2decimal
|
jsr c64utils.uword2decimal
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda c64utils.uword2decimal.decTenThousands,y
|
- lda c64utils.uword2decimal.decTenThousands,y
|
||||||
@ -883,7 +883,7 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
|
|||||||
jsr c64.CHROUT
|
jsr c64.CHROUT
|
||||||
iny
|
iny
|
||||||
bne -
|
bne -
|
||||||
+ ldx c64.SCRATCH_ZPREGX
|
+ ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -891,9 +891,9 @@ asmsub print_uw0 (uword value @ AY) clobbers(A,Y) {
|
|||||||
asmsub print_uw (uword value @ AY) clobbers(A,Y) {
|
asmsub print_uw (uword value @ AY) clobbers(A,Y) {
|
||||||
; ---- print the uword in A/Y in decimal form, without left padding 0s
|
; ---- print the uword in A/Y in decimal form, without left padding 0s
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
jsr c64utils.uword2decimal
|
jsr c64utils.uword2decimal
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda c64utils.uword2decimal.decTenThousands,y
|
- lda c64utils.uword2decimal.decTenThousands,y
|
||||||
beq _allzero
|
beq _allzero
|
||||||
@ -940,17 +940,17 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
|
|||||||
; It assumes the keyboard is selected as I/O channel!
|
; It assumes the keyboard is selected as I/O channel!
|
||||||
|
|
||||||
%asm {{
|
%asm {{
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty c64.SCRATCH_ZPWORD1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
ldy #0 ; char counter = 0
|
ldy #0 ; char counter = 0
|
||||||
- jsr c64.CHRIN
|
- jsr c64.CHRIN
|
||||||
cmp #$0d ; return (ascii 13) pressed?
|
cmp #$0d ; return (ascii 13) pressed?
|
||||||
beq + ; yes, end.
|
beq + ; yes, end.
|
||||||
sta (c64.SCRATCH_ZPWORD1),y ; else store char in buffer
|
sta (P8ZP_SCRATCH_W1),y ; else store char in buffer
|
||||||
iny
|
iny
|
||||||
bne -
|
bne -
|
||||||
+ lda #0
|
+ lda #0
|
||||||
sta (c64.SCRATCH_ZPWORD1),y ; finish string with 0 byte
|
sta (P8ZP_SCRATCH_W1),y ; finish string with 0 byte
|
||||||
rts
|
rts
|
||||||
|
|
||||||
}}
|
}}
|
||||||
@ -959,18 +959,18 @@ asmsub input_chars (uword buffer @ AY) clobbers(A) -> ubyte @ Y {
|
|||||||
asmsub setchr (ubyte col @Y, ubyte row @A) clobbers(A) {
|
asmsub setchr (ubyte col @Y, ubyte row @A) clobbers(A) {
|
||||||
; ---- set the character in SCRATCH_ZPB1 on the screen matrix at the given position
|
; ---- set the character in SCRATCH_ZPB1 on the screen matrix at the given position
|
||||||
%asm {{
|
%asm {{
|
||||||
sty c64.SCRATCH_ZPREG
|
sty P8ZP_SCRATCH_REG
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda _screenrows+1,y
|
lda _screenrows+1,y
|
||||||
sta _mod+2
|
sta _mod+2
|
||||||
lda _screenrows,y
|
lda _screenrows,y
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPREG
|
adc P8ZP_SCRATCH_REG
|
||||||
sta _mod+1
|
sta _mod+1
|
||||||
bcc +
|
bcc +
|
||||||
inc _mod+2
|
inc _mod+2
|
||||||
+ lda c64.SCRATCH_ZPB1
|
+ lda P8ZP_SCRATCH_B1
|
||||||
_mod sta $ffff ; modified
|
_mod sta $ffff ; modified
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -981,14 +981,14 @@ _screenrows .word $0400 + range(0, 1000, 40)
|
|||||||
asmsub getchr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
|
asmsub getchr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
|
||||||
; ---- get the character in the screen matrix at the given location
|
; ---- get the character in the screen matrix at the given location
|
||||||
%asm {{
|
%asm {{
|
||||||
sty c64.SCRATCH_ZPB1
|
sty P8ZP_SCRATCH_B1
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda setchr._screenrows+1,y
|
lda setchr._screenrows+1,y
|
||||||
sta _mod+2
|
sta _mod+2
|
||||||
lda setchr._screenrows,y
|
lda setchr._screenrows,y
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPB1
|
adc P8ZP_SCRATCH_B1
|
||||||
sta _mod+1
|
sta _mod+1
|
||||||
bcc _mod
|
bcc _mod
|
||||||
inc _mod+2
|
inc _mod+2
|
||||||
@ -1000,18 +1000,18 @@ _mod lda $ffff ; modified
|
|||||||
asmsub setclr (ubyte col @Y, ubyte row @A) clobbers(A) {
|
asmsub setclr (ubyte col @Y, ubyte row @A) clobbers(A) {
|
||||||
; ---- set the color in SCRATCH_ZPB1 on the screen matrix at the given position
|
; ---- set the color in SCRATCH_ZPB1 on the screen matrix at the given position
|
||||||
%asm {{
|
%asm {{
|
||||||
sty c64.SCRATCH_ZPREG
|
sty P8ZP_SCRATCH_REG
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda _colorrows+1,y
|
lda _colorrows+1,y
|
||||||
sta _mod+2
|
sta _mod+2
|
||||||
lda _colorrows,y
|
lda _colorrows,y
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPREG
|
adc P8ZP_SCRATCH_REG
|
||||||
sta _mod+1
|
sta _mod+1
|
||||||
bcc +
|
bcc +
|
||||||
inc _mod+2
|
inc _mod+2
|
||||||
+ lda c64.SCRATCH_ZPB1
|
+ lda P8ZP_SCRATCH_B1
|
||||||
_mod sta $ffff ; modified
|
_mod sta $ffff ; modified
|
||||||
rts
|
rts
|
||||||
|
|
||||||
@ -1022,14 +1022,14 @@ _colorrows .word $d800 + range(0, 1000, 40)
|
|||||||
asmsub getclr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
|
asmsub getclr (ubyte col @Y, ubyte row @A) clobbers(Y) -> ubyte @ A {
|
||||||
; ---- get the color in the screen color matrix at the given location
|
; ---- get the color in the screen color matrix at the given location
|
||||||
%asm {{
|
%asm {{
|
||||||
sty c64.SCRATCH_ZPB1
|
sty P8ZP_SCRATCH_B1
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
lda setclr._colorrows+1,y
|
lda setclr._colorrows+1,y
|
||||||
sta _mod+2
|
sta _mod+2
|
||||||
lda setclr._colorrows,y
|
lda setclr._colorrows,y
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPB1
|
adc P8ZP_SCRATCH_B1
|
||||||
sta _mod+1
|
sta _mod+1
|
||||||
bcc _mod
|
bcc _mod
|
||||||
inc _mod+2
|
inc _mod+2
|
||||||
@ -1067,11 +1067,11 @@ _colormod sta $ffff ; modified
|
|||||||
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {
|
asmsub plot (ubyte col @ Y, ubyte row @ A) clobbers(A) {
|
||||||
; ---- safe wrapper around PLOT kernel routine, to save the X register.
|
; ---- safe wrapper around PLOT kernel routine, to save the X register.
|
||||||
%asm {{
|
%asm {{
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
tax
|
tax
|
||||||
clc
|
clc
|
||||||
jsr c64.PLOT
|
jsr c64.PLOT
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
|
|||||||
val sub = stmt.target.targetSubroutine(program.namespace) ?: throw AssemblyError("undefined subroutine ${stmt.target}")
|
val sub = stmt.target.targetSubroutine(program.namespace) ?: throw AssemblyError("undefined subroutine ${stmt.target}")
|
||||||
val saveX = CpuRegister.X in sub.asmClobbers || sub.regXasResult()
|
val saveX = CpuRegister.X in sub.asmClobbers || sub.regXasResult()
|
||||||
if(saveX)
|
if(saveX)
|
||||||
asmgen.out(" stx c64.SCRATCH_ZPREGX") // we only save X for now (required! is the eval stack pointer), screw A and Y...
|
asmgen.out(" stx P8ZP_SCRATCH_REG_X") // we only save X for now (required! is the eval stack pointer), screw A and Y...
|
||||||
|
|
||||||
val subName = asmgen.asmIdentifierName(stmt.target)
|
val subName = asmgen.asmIdentifierName(stmt.target)
|
||||||
if(stmt.args.isNotEmpty()) {
|
if(stmt.args.isNotEmpty()) {
|
||||||
@ -57,7 +57,7 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg
|
|||||||
asmgen.out(" jsr $subName")
|
asmgen.out(" jsr $subName")
|
||||||
|
|
||||||
if(saveX)
|
if(saveX)
|
||||||
asmgen.out(" ldx c64.SCRATCH_ZPREGX") // restore X again
|
asmgen.out(" ldx P8ZP_SCRATCH_REG_X") // restore X again
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerArgsViaStackEvaluation(stmt: IFunctionCall, sub: Subroutine) {
|
private fun registerArgsViaStackEvaluation(stmt: IFunctionCall, sub: Subroutine) {
|
||||||
|
@ -617,9 +617,9 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
// TODO what about the optimized routines?
|
// TODO what about the optimized routines?
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
lda $name
|
lda $name
|
||||||
sta c64.SCRATCH_ZPWORD1
|
sta P8ZP_SCRATCH_W1
|
||||||
lda $name+1
|
lda $name+1
|
||||||
sta c64.SCRATCH_ZPWORD1+1
|
sta P8ZP_SCRATCH_W1+1
|
||||||
lda #<$value
|
lda #<$value
|
||||||
ldy #>$value
|
ldy #>$value
|
||||||
jsr math.multiply_words
|
jsr math.multiply_words
|
||||||
@ -801,7 +801,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
asmgen.translateExpression(value)
|
asmgen.translateExpression(value)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- asl $name
|
- asl $name
|
||||||
rol $name+1
|
rol $name+1
|
||||||
@ -814,7 +814,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
if(dt==DataType.UWORD) {
|
if(dt==DataType.UWORD) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- lsr $name+1
|
- lsr $name+1
|
||||||
ror $name
|
ror $name
|
||||||
@ -824,7 +824,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
else {
|
else {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- lda $name+1
|
- lda $name+1
|
||||||
asl a
|
asl a
|
||||||
@ -891,7 +891,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
asmgen.translateExpression(value)
|
asmgen.translateExpression(value)
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- asl $name
|
- asl $name
|
||||||
dey
|
dey
|
||||||
@ -903,7 +903,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
if(dt==DataType.UBYTE) {
|
if(dt==DataType.UBYTE) {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- lsr $name
|
- lsr $name
|
||||||
dey
|
dey
|
||||||
@ -912,7 +912,7 @@ internal class AugmentableAssignmentAsmGen(private val program: Program,
|
|||||||
} else {
|
} else {
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
inx
|
inx
|
||||||
ldy c64.ESTACK_LO,x
|
ldy P8ESTACK_LO,x
|
||||||
beq +
|
beq +
|
||||||
- lda $name
|
- lda $name
|
||||||
asl a
|
asl a
|
||||||
|
@ -186,11 +186,11 @@ graphics {
|
|||||||
asmsub plot(ubyte ploty @A) { ; plotx is 16 bits 0 to 319... doesn't fit in a register
|
asmsub plot(ubyte ploty @A) { ; plotx is 16 bits 0 to 319... doesn't fit in a register
|
||||||
%asm {{
|
%asm {{
|
||||||
tay
|
tay
|
||||||
stx c64.SCRATCH_ZPREGX
|
stx P8ZP_SCRATCH_REG_X
|
||||||
lda plotx+1
|
lda plotx+1
|
||||||
sta c64.SCRATCH_ZPWORD2+1
|
sta P8ZP_SCRATCH_W2+1
|
||||||
lsr a ; 0
|
lsr a ; 0
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
lda plotx
|
lda plotx
|
||||||
pha
|
pha
|
||||||
and #7
|
and #7
|
||||||
@ -198,20 +198,20 @@ graphics {
|
|||||||
|
|
||||||
lda _y_lookup_lo,y
|
lda _y_lookup_lo,y
|
||||||
clc
|
clc
|
||||||
adc c64.SCRATCH_ZPWORD2
|
adc P8ZP_SCRATCH_W2
|
||||||
sta c64.SCRATCH_ZPWORD2
|
sta P8ZP_SCRATCH_W2
|
||||||
lda _y_lookup_hi,y
|
lda _y_lookup_hi,y
|
||||||
adc c64.SCRATCH_ZPWORD2+1
|
adc P8ZP_SCRATCH_W2+1
|
||||||
sta c64.SCRATCH_ZPWORD2+1
|
sta P8ZP_SCRATCH_W2+1
|
||||||
|
|
||||||
pla ; plotx
|
pla ; plotx
|
||||||
and #%11111000
|
and #%11111000
|
||||||
tay
|
tay
|
||||||
lda (c64.SCRATCH_ZPWORD2),y
|
lda (P8ZP_SCRATCH_W2),y
|
||||||
ora _ormask,x
|
ora _ormask,x
|
||||||
sta (c64.SCRATCH_ZPWORD2),y
|
sta (P8ZP_SCRATCH_W2),y
|
||||||
|
|
||||||
ldx c64.SCRATCH_ZPREGX
|
ldx P8ZP_SCRATCH_REG_X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_ormask .byte 128, 64, 32, 16, 8, 4, 2, 1
|
_ormask .byte 128, 64, 32, 16, 8, 4, 2, 1
|
||||||
|
Loading…
Reference in New Issue
Block a user