mrdudz / cc65-floatlib Goto Github PK
View Code? Open in Web Editor NEWa naive approach for using kernal floating point numbers on C64, while using IEEE float values at application level
License: zlib License
a naive approach for using kernal floating point numbers on C64, while using IEEE float values at application level
License: zlib License
Hi! First I wanted to say, I am so grateful and delighted that you've undertaken this effort! Thank you!
I just started with cc65 a few days ago and discovered there was no floating point then found your project. So I tried it out and I got the errors below. I commented out the lines with those functions and it builds and runs, although I haven't verified them. Is this an error in how I'm using this, or an error with the library? Is there anything I can do to help fix this? Thank you.
Noah@DESKTOP-VL0THH1 /cygdrive/c/Users/Noah/fun/c64/cc65-floatlib
$ make
ca65 float.s -o float.o
cc65 floatc.c -o floatc.s
ca65 floatc.s -o floatc.o
ar65 a runtime.lib float.o floatc.o
cl65 floattest.c runtime.lib -o floattest.prg
floattest.c(162): Warning: Constant is long
gcc -O2 -W -Wall -Wextra -o floattest -lm floattest.c
In file included from floattest.c:10:0:
floattest.c: In function ‘calcsin’:
floattest.c:61:37: warning: implicit declaration of function ‘fsin’; did you mean ‘fmin’? [-Wimplicit-function-declaration]
csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
^
float.h:149:28: note: in definition of macro ‘ftoi’
#define ftoi(a) ((int)(a))
^
floattest.c:61:32: note: in expansion of macro ‘fmul’
csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
^~~~
floattest.c:61:42: warning: implicit declaration of function ‘deg2rad’ [-Wimplicit-function-declaration]
csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
^
float.h:149:28: note: in definition of macro ‘ftoi’
#define ftoi(a) ((int)(a))
^
floattest.c:61:32: note: in expansion of macro ‘fmul’
csetpoint8(XNUM2+(ftoi(fmul(fsin(deg2rad(itof(i),itof(YNUM))),itof(YNUM2)))/(YNUM/XNUM)));
^~~~
floattest.c: In function ‘calccos’:
floattest.c:70:17: warning: implicit declaration of function ‘fcos’; did you mean ‘acos’? [-Wimplicit-function-declaration]
fd=fmul(fcos(fs),itof(YNUM2));
^
float.h:121:23: note: in definition of macro ‘fmul’
#define fmul(a,b) ((a)*(b))
^
/tmp/ccAMzp5l.o:floattest.c:(.text+0x106): undefined reference to `deg2rad'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x10e): undefined reference to `fsin'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x1a6): undefined reference to `deg2rad'
/tmp/ccAMzp5l.o:floattest.c:(.text+0x1bc): undefined reference to `fcos'
collect2: error: ld returned 1 exit status
make: *** [makefile:19: floattest] Error 1
Would love to see a 128 port of this. Any pointers on how to develop a port?
Hello There!
Thank you very much for making this very useful library.
I can build the library and testcode (using latest cc65), though I get the following message:
float.s(169): Warning: Didn't use zeropage addressing for 'sreg'
When running the testcode, the floats do not seem to work properly.
The function f1() crashes the application, and the following code shows a:0:
a=itof(2); printf("a:%x\n",a);
Any help would be most appreciated!!!
Anthony
There's no licence for the code so I'm afraid to use it.
Would PET support be possible? BASIC would have all the same IEEE routines, but they're at different locations.
If it were possible, I have an MTU graphics board and could do a kiiller analog clock for the PET! But I need floating point :-)
Random trivia: Bill and Paul thought the floating point was going to be really hard, and they were talking about it at lunch in their dorm cafeteria. One of their friends scoffed that it'd be easy, he'd done it before!
His name was Monte Davidoff, and Bill and Paul called his bluff and hired him to write the floating point routines for BASIC (8080 originally). I got to chat with him a while back when I was researching the history of the floating point code. Long story short, it mostly comes from what he learned looking at a FOCAL interpreter.
As far as I know, Ric Weiland did the 6502 port.
I am trying to get a decimal number into a float. So I did this
Y=fdiv(itof((int)14278),itof((int)10000));
Which should result in 1.4278.
Instead I get 1.42779994.
I know there is some rounding error when dealing with floats but I didn't think it was this bad. Am I doing something wrong?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.