fix some issues with float const 0.0 and 1.0

This commit is contained in:
Irmen de Jong 2020-09-05 02:05:28 +02:00
parent 37f6c2858f
commit 8f9f947c42
5 changed files with 24 additions and 30 deletions

View File

@ -1,5 +1,8 @@
; --- low level floating point assembly routines for the C64
FL_ONE_const .byte 129 ; 1.0
FL_ZERO_const .byte 0,0,0,0,0 ; 0.0
ub2float .proc
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
@ -233,8 +236,8 @@ inc_var_f .proc
sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X
jsr MOVFM
lda #<ONE
ldy #>ONE
lda #<FL_ONE_const
ldy #>FL_ONE_const
jsr FADD
ldx P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
@ -248,8 +251,8 @@ dec_var_f .proc
sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X
lda #<ONE
ldy #>ONE
lda #<FL_ONE_const
ldy #>FL_ONE_const
jsr MOVFM
lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1
@ -573,8 +576,8 @@ func_ceil .proc
jsr FCOMP
cmp #0
beq +
lda #<ONE
ldy #>ONE
lda #<FL_ONE_const
ldy #>FL_ONE_const
jsr FADD
+ jmp push_fac1_as_result
.pend
@ -665,8 +668,8 @@ _largest_pos_float .byte 255,127,255,255,255 ; largest positive float
.pend
func_sum_f .proc
lda #<ZERO
ldy #>ZERO
lda #<FL_ZERO_const
ldy #>FL_ZERO_const
jsr MOVFM
jsr prog8_lib.pop_array_and_lengthmin1Y
stx P8ZP_SCRATCH_REG_X

View File

@ -9,11 +9,8 @@
c64flt {
; ---- this block contains C-64 floating point related functions ----
; TODO fix var storage in ASM when declared const:
float PI = 3.141592653589793
float TWOPI = 6.283185307179586
float ZERO = 0.0
float ONE = 1.0
const float PI = 3.141592653589793
const float TWOPI = 6.283185307179586
; ---- C64 basic and kernal ROM float constants and functions ----

View File

@ -9,11 +9,8 @@
c64flt {
; ---- this block contains C-64 floating point related functions ----
; TODO fix var storage in ASM when declared const:
float PI = 3.141592653589793
float TWOPI = 6.283185307179586
float ZERO = 0.0
float ONE = 1.0
const float PI = 3.141592653589793
const float TWOPI = 6.283185307179586
; ---- ROM float functions ----

View File

@ -70,8 +70,8 @@ main {
; plot the points of the 3d cube
; first the points on the back, then the points on the front (painter algorithm)
ubyte @zp i
float @zp rz ; TODO compiler warning that float can't be in ZP?
float @zp persp
float rz
float persp
ubyte sx
ubyte sy

View File

@ -1,7 +1,13 @@
%import cx16textio
%import c64textio
%import c64flt
%option enable_floats
%zeropage basicsafe
; TODO fix compilation when zeropage is not basicsafe on cx16
main {
sub start() {
;asmsub clear_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { ...}
@ -10,15 +16,6 @@ main {
; sub color(...) {}
; sub other(ubyte color) {} ; TODO don't cause name conflict
; TODO fix var storage in ASM when declared const:
float PI = 3.141592653589793
float TWOPI = 6.283185307179586
float ZERO = 0.0
float ONE = 1.0
float @zp rz ; TODO compiler warning that float can't be in ZP?
}