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 ; --- 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 ub2float .proc
; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y ; -- convert ubyte in SCRATCH_ZPB1 to float at address A/Y
@ -233,8 +236,8 @@ inc_var_f .proc
sty P8ZP_SCRATCH_W1+1 sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X stx P8ZP_SCRATCH_REG_X
jsr MOVFM jsr MOVFM
lda #<ONE lda #<FL_ONE_const
ldy #>ONE ldy #>FL_ONE_const
jsr FADD jsr FADD
ldx P8ZP_SCRATCH_W1 ldx P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1 ldy P8ZP_SCRATCH_W1+1
@ -248,8 +251,8 @@ dec_var_f .proc
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1 sty P8ZP_SCRATCH_W1+1
stx P8ZP_SCRATCH_REG_X stx P8ZP_SCRATCH_REG_X
lda #<ONE lda #<FL_ONE_const
ldy #>ONE ldy #>FL_ONE_const
jsr MOVFM jsr MOVFM
lda P8ZP_SCRATCH_W1 lda P8ZP_SCRATCH_W1
ldy P8ZP_SCRATCH_W1+1 ldy P8ZP_SCRATCH_W1+1
@ -573,8 +576,8 @@ func_ceil .proc
jsr FCOMP jsr FCOMP
cmp #0 cmp #0
beq + beq +
lda #<ONE lda #<FL_ONE_const
ldy #>ONE ldy #>FL_ONE_const
jsr FADD jsr FADD
+ jmp push_fac1_as_result + jmp push_fac1_as_result
.pend .pend
@ -665,8 +668,8 @@ _largest_pos_float .byte 255,127,255,255,255 ; largest positive float
.pend .pend
func_sum_f .proc func_sum_f .proc
lda #<ZERO lda #<FL_ZERO_const
ldy #>ZERO ldy #>FL_ZERO_const
jsr MOVFM jsr MOVFM
jsr prog8_lib.pop_array_and_lengthmin1Y jsr prog8_lib.pop_array_and_lengthmin1Y
stx P8ZP_SCRATCH_REG_X stx P8ZP_SCRATCH_REG_X

View File

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

View File

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

View File

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

View File

@ -1,7 +1,13 @@
%import cx16textio %import c64textio
%import c64flt
%option enable_floats
%zeropage basicsafe %zeropage basicsafe
; TODO fix compilation when zeropage is not basicsafe on cx16
main { main {
sub start() { sub start() {
;asmsub clear_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { ...} ;asmsub clear_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { ...}
@ -10,15 +16,6 @@ main {
; sub color(...) {} ; sub color(...) {}
; sub other(ubyte color) {} ; TODO don't cause name conflict ; 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?
} }