mirror of
https://github.com/irmen/prog8.git
synced 2024-10-25 00:24:16 +00:00
floats.parse_f uses kernal VAL if it's present
This commit is contained in:
parent
992732f2cb
commit
e40ebd75a2
@ -140,16 +140,26 @@ asmsub parse_f(str value @AY) -> float @FAC1 {
|
|||||||
; -- parse a string value of a number to float in FAC1
|
; -- parse a string value of a number to float in FAC1
|
||||||
; warning: on older <R47 kernals it uses an internal BASIC routine that is ROM version dependent,
|
; warning: on older <R47 kernals it uses an internal BASIC routine that is ROM version dependent,
|
||||||
; ($deb6 is inside the routine for VAL at $deb3) See basic.sym from x16-rom
|
; ($deb6 is inside the routine for VAL at $deb3) See basic.sym from x16-rom
|
||||||
; TODO add a check to see if the VAL_1 kernal jump entry is valid if so, then use that instead
|
; TODO once VAL_1 is merged into the kernal properly, remove all the workarounds here
|
||||||
%asm {{
|
%asm {{
|
||||||
sta $a9
|
ldx VAL_1
|
||||||
|
cpx #$4c ; is there an implementation in VAL_1? (test for JMP)
|
||||||
|
bne + ; no, do it ourselves
|
||||||
|
pha ; yes, count the length and call rom VAL_1.
|
||||||
|
phy
|
||||||
|
jsr prog8_lib.strlen
|
||||||
|
tya
|
||||||
|
ply
|
||||||
|
plx
|
||||||
|
jmp VAL_1
|
||||||
|
+ sta $a9 ; 'index' variable
|
||||||
sty $aa
|
sty $aa
|
||||||
jsr prog8_lib.strlen
|
jsr prog8_lib.strlen
|
||||||
lda $deb6
|
lda $deb6
|
||||||
cmp #$d0 ; sanity check for kernal routine correct
|
cmp #$d0 ; sanity check for kernal routine correct
|
||||||
bne + ;
|
bne +
|
||||||
tya
|
tya
|
||||||
jmp $deb6 ; kernal version dependent :(
|
jmp $deb6 ; kernal version dependent...
|
||||||
+ ; print error message if routine is borked in kernal, and exit program
|
+ ; print error message if routine is borked in kernal, and exit program
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda _msg,y
|
- lda _msg,y
|
||||||
|
@ -39,19 +39,19 @@ verafx {
|
|||||||
|
|
||||||
if (amountof32bits & %1111110000000011) == 0 {
|
if (amountof32bits & %1111110000000011) == 0 {
|
||||||
repeat lsb(amountof32bits >> 2)
|
repeat lsb(amountof32bits >> 2)
|
||||||
unroll 4 cx16.VERA_DATA0=0 ; write 4 bytes at a time, unrolled
|
unroll 4 cx16.VERA_DATA0=0 ; write 4*4 bytes at a time, unrolled
|
||||||
}
|
}
|
||||||
else if (amountof32bits & %1111111000000001) == 0 {
|
else if (amountof32bits & %1111111000000001) == 0 {
|
||||||
repeat lsb(amountof32bits >> 1)
|
repeat lsb(amountof32bits >> 1)
|
||||||
unroll 2 cx16.VERA_DATA0=0 ; write 4 bytes at a time, unrolled
|
unroll 2 cx16.VERA_DATA0=0 ; write 2*4 bytes at a time, unrolled
|
||||||
}
|
}
|
||||||
else if (lsb(amountof32bits) & 3) == 0 {
|
else if (lsb(amountof32bits) & 3) == 0 {
|
||||||
repeat amountof32bits >> 2
|
repeat amountof32bits >> 2
|
||||||
unroll 4 cx16.VERA_DATA0=0 ; write 4 bytes at a time, unrolled
|
unroll 4 cx16.VERA_DATA0=0 ; write 4*4 bytes at a time, unrolled
|
||||||
}
|
}
|
||||||
else if (lsb(amountof32bits) & 1) == 0 {
|
else if (lsb(amountof32bits) & 1) == 0 {
|
||||||
repeat amountof32bits >> 1
|
repeat amountof32bits >> 1
|
||||||
unroll 2 cx16.VERA_DATA0=0 ; write 4 bytes at a time, unrolled
|
unroll 2 cx16.VERA_DATA0=0 ; write 2*4 bytes at a time, unrolled
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
repeat amountof32bits
|
repeat amountof32bits
|
||||||
|
@ -441,7 +441,7 @@ _return_minusone
|
|||||||
|
|
||||||
|
|
||||||
strlen .proc
|
strlen .proc
|
||||||
; -- returns the number of bytes in the string in AY, in Y.
|
; -- returns the number of bytes in the string in AY, in Y. Clobbers A.
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
||||||
sty P8ZP_SCRATCH_W1+1
|
sty P8ZP_SCRATCH_W1+1
|
||||||
ldy #0
|
ldy #0
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import bmx
|
%import floats
|
||||||
|
%import string
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
bmx.palette_buffer_ptr = memory("palette", 512, 0)
|
str buffer = "???????????????????????????"
|
||||||
if bmx.open(8, "desertfish.bmx") {
|
repeat {
|
||||||
if bmx.continue_load(0,0) {
|
txt.print("enter number: ")
|
||||||
uword offset = 10*320 + 100
|
void txt.input_chars(buffer)
|
||||||
bmx.width = 100
|
txt.print("\nprog8's parse_f: ")
|
||||||
bmx.height = 150
|
float value = floats.parse_f(buffer)
|
||||||
if bmx.save(8, "@:stamp.bmx", 0, offset, 320) {
|
floats.print_f(value)
|
||||||
txt.print("save stamp ok\n")
|
|
||||||
return
|
; floats.VAL_1 is defined as:
|
||||||
}
|
; romsub $fe09 = VAL_1(uword string @XY, ubyte length @A) clobbers(A,X,Y) -> float @FAC1
|
||||||
}
|
; txt.print("\nrom val_1: ")
|
||||||
}
|
; value = floats.VAL_1(buffer, string.length(buffer))
|
||||||
txt.print("error: ")
|
; floats.print_f(value)
|
||||||
txt.print(bmx.error_message)
|
|
||||||
txt.nl()
|
txt.nl()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user