mirror of
https://github.com/irmen/prog8.git
synced 2025-01-08 22:32:06 +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
|
||||
; 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
|
||||
; 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 {{
|
||||
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
|
||||
jsr prog8_lib.strlen
|
||||
lda $deb6
|
||||
cmp #$d0 ; sanity check for kernal routine correct
|
||||
bne + ;
|
||||
bne +
|
||||
tya
|
||||
jmp $deb6 ; kernal version dependent :(
|
||||
jmp $deb6 ; kernal version dependent...
|
||||
+ ; print error message if routine is borked in kernal, and exit program
|
||||
ldy #0
|
||||
- lda _msg,y
|
||||
|
@ -39,19 +39,19 @@ verafx {
|
||||
|
||||
if (amountof32bits & %1111110000000011) == 0 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
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 {
|
||||
repeat amountof32bits
|
||||
|
@ -441,7 +441,7 @@ _return_minusone
|
||||
|
||||
|
||||
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
|
||||
sty P8ZP_SCRATCH_W1+1
|
||||
ldy #0
|
||||
|
@ -1,24 +1,25 @@
|
||||
%import textio
|
||||
%import bmx
|
||||
%import floats
|
||||
%import string
|
||||
%zeropage basicsafe
|
||||
%option no_sysinit
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
bmx.palette_buffer_ptr = memory("palette", 512, 0)
|
||||
if bmx.open(8, "desertfish.bmx") {
|
||||
if bmx.continue_load(0,0) {
|
||||
uword offset = 10*320 + 100
|
||||
bmx.width = 100
|
||||
bmx.height = 150
|
||||
if bmx.save(8, "@:stamp.bmx", 0, offset, 320) {
|
||||
txt.print("save stamp ok\n")
|
||||
return
|
||||
}
|
||||
}
|
||||
str buffer = "???????????????????????????"
|
||||
repeat {
|
||||
txt.print("enter number: ")
|
||||
void txt.input_chars(buffer)
|
||||
txt.print("\nprog8's parse_f: ")
|
||||
float value = floats.parse_f(buffer)
|
||||
floats.print_f(value)
|
||||
|
||||
; 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))
|
||||
; floats.print_f(value)
|
||||
txt.nl()
|
||||
}
|
||||
txt.print("error: ")
|
||||
txt.print(bmx.error_message)
|
||||
txt.nl()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user