aboutsummaryrefslogtreecommitdiff
path: root/bignum.h
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-12 07:42:30 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-12 07:42:30 -0500
commit854aaed7643cc2224987738f04384f884d1084d5 (patch)
treef9b4a019a5c859719678bb523ecc1786df665229 /bignum.h
parentf90842d4decc6f9453e53785174c73674dc86a51 (diff)
downloadtaipan-854aaed7643cc2224987738f04384f884d1084d5.tar.gz
some FP wrappers and test code, not very good yet
Diffstat (limited to 'bignum.h')
-rw-r--r--bignum.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/bignum.h b/bignum.h
new file mode 100644
index 0000000..a6306f4
--- /dev/null
+++ b/bignum.h
@@ -0,0 +1,49 @@
+/* big number functions needed by taipan.c.
+
+ The implementation will actually use the Atari ROM floating point
+ routines. To port Taipan to a new cc65 platform, the functions listed
+ here will have to be rewritten, but taipan.c itself shouldn't need
+ changing (at least, not in relation to bignums!) */
+
+#define bignum(x) char x[6]
+#define bignump char *
+
+
+/* zero */
+#define BIG_0 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+
+/* constant initializer for 1.05 goes here */
+#define BIG_1_05 { 0x40, 0x01, 0x05, 0x00, 0x00, 0x00 }
+
+/* bignum 100, used for score calculations in final_stats() */
+#define BIG_10 { 0x41, 0x01, 0x00, 0x00, 0x00, 0x00 }
+
+// void int_to_big(int i, bignum *b);
+// void uint_to_big(unsigned int i, bignum *b);
+
+extern void __fastcall__ ulong_to_big(const unsigned long l, bignump b);
+
+/* returns 0 for success, nonzero for fail (overflow or negative) */
+extern char __fastcall__ big_to_ulong(bignump b, unsigned long *l);
+
+/* this should work like cprintfancy(), but doesn't need centering. */
+// void cprint_big(const bignum *b);
+
+/* basic math functions. conceptually they return a boolean for
+ success, but only division has error checking.
+ all can be read as: dest = arg2 OP arg3;
+ modulus isn't implemented as taipan doesn't use it for the bank.
+ */
+// char big_add(bignum *dest, bignum *addend1, bignum *addend2);
+// char big_sub(bignum *dest, bignum *minuend, bignum *subtrahend);
+// char big_mul(bignum *dest, bignum *multiplicand, bignum *multiplier);
+// char big_div(bignum *dest, bignum *dividend, bignum *divisor);
+
+/* comparison. Perl spaceship operator, <=>
+ returns | if
+ ---------+----------------
+ 0 | a == b
+ 1 | a > b
+ -1 | a < b
+ */
+// signed char big_cmp(const bignum *a, const bignum *b)