1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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)
|