|
| void | doval (void) |
| void | doint (void) |
| | Int(Expression) - the integer part as a long.
|
| void | dosgn (void) |
| | Sgn(Expression) - the sign: -1, 0 or 1.
|
| void | doffrac (void) |
| | Frac(Expression) - the fractional part, as a float.
|
| void | doqfrac (void) |
| | QFrac(Quick) - the fraction of |q| (inline).
|
| void | doqwrap (void) |
| | QWrap(Quick,Low,High) - wrap q into low..high (inline).
|
| void | dornd1 (void) |
| | Rnd - a random fraction.
|
| void | dornd2 (void) |
| | Rnd(Range) - a random value 0..range.
|
| void | doqabs (void) |
| | QAbs(Quick) - the absolute value (inline).
|
| void | dofabs (void) |
| | Abs(Expression) - the absolute value, as a float.
|
| void | doqlimit (void) |
| | QLimit(Quick,Low,High) - limit q to low..high.
|
| void | dontsc (void) |
| void | dodispheight (void) |
| void | dobeamy (void) |
| | VPos - the vertical beam position (inline).
|
| void | dotrue (void) |
| | True - the constant -1 (inline: MOVEQ #-1,d0).
|
| void | dofalse (void) |
| | False - the constant 0 (inline: MOVEQ #0,d0).
|
| void | doqangle (void) |
| void | intchk (void) |
| static ULONG | divu (ULONG dividend, UWORD y) |
| static ULONG | doqangle_c (UWORD sx, UWORD sy, UWORD dx, UWORD dy) |
| | QAngle(Src X,Src Y,Dest X,Dest Y) - the angle of the line dest -> src.
|
| | BLITZ_ALIAS (doqangle, doqangle_c) |
| static ULONG | dodispheight_c (ULONG hiword, const struct GfxBase *gfx) |
| | DispHeight - the display height: 200 for NTSC or 256 for PAL.
|
| | BLITZ_ALIAS (dodispheight, dodispheight_c) |
| static ULONG | dontsc_c (ULONG hiword, const struct GfxBase *gfx) |
| | NTSC - whether the display is NTSC.
|
| | BLITZ_ALIAS (dontsc, dontsc_c) |
| static void | intchk_c (const UBYTE *args) |
| | intchk - error check of Int, Sgn and Frac (debugger only).
|
| BL_ALWAYS_INLINE UWORD | getdec (const UBYTE **pp, LONG *np, ULONG *num, ULONG *scale, int frac) |
| BL_ALWAYS_INLINE ULONG | notneg (const void *ffp, const UBYTE *p, LONG n) |
| BL_ALWAYS_INLINE ULONG | gethex (const void *ffp, const UBYTE *p, LONG n) |
| BL_ALWAYS_INLINE ULONG | getbin (const void *ffp, const UBYTE *p, LONG n) |
| static BLITZ_ENTRYPOINT ULONG | doval_c (UBYTE *str, const void *ffp, const UBYTE *args) |
| | Val(String$) - the numeric value of a string, as a float.
|
| | BLITZ_ALIAS_EP (doval, doval_c) |
Abs(Expression) - the absolute value, as a float.
The value as Float with the sign bit (bit 7) cleared: float as is, quick via floatquicklib ($D300), byte/word sign extended, everything else (long, and types >= 6) with SPFlt. The original clears the bit with BCHG #7,d0:BNE 'skip:BCHG #7,d0; here BCLR #7,d0, the same bits.
In: d0 the value, a6 the mathffp base, a2 the argument stack (-2 = the type word: 1 byte, 2 word, 3 long, 4 quick, 5 float) Out: d0 |v| (FFP)
Frac(Expression) - the fractional part, as a float.
Any numeric type (!args{8}, unknown, as Int, Sgn and Abs; the type word at -2(a2)):
- Float: f - Floor(f) for positive, f - Ceil(f) for negative f (FFP sign = bit 7): SPSub with d0 = f, d1 = Floor/Ceil, the original's code with the original's tail jump into SPSub.
- Quick: the FFP built from the fraction word of |q| directly: shifted left until its top bit is set (the mantissa), exponent 64 minus the shifts, the sign of q; 0 for no fraction. No mathffp call. Fixed (#1064): the original takes a Float argument, so the compiler converted a Quick with qutofl first, whose 24-bit mantissa rounds away the low fraction bits of an integer part of 256 or more (Frac of the Quick 300.75 was right, of 30000 + 10/65536 it was 0); here the result is the exact fraction of the Quick (16 bits, which an FFP mantissa always holds).
- Byte, Word, Long: 0 (the original's SPFlt gave an integral float, whose fraction is 0). The original's argument was float: a string was a compile error; now it is refused by intchk in the error check area (runtime error "Illegal Type", as for Int and Sgn).
Changes d0, d1 and what mathffp changes (a0, a1); keeps a2 and a6.
Errors (debugger only, intchk): a string -> "Illegal Type".
In: d0 the value, a6 the mathffp base, a2 the argument stack (-2 = the type word: 1 byte, 2 word, 3 long, 4 quick, 5 float) Out: d0 the fraction (FFP)
Int(Expression) - the integer part as a long.
Float with SPFix (truncates, JMP -30(a6)), quick truncated towards 0 (negative: NEG.l, integer part, NEG), byte/word sign extended, long as is.
Errors (debugger only, intchk): a string -> "Illegal Type".
In: d0 the value, a6 the mathffp base, a2 the argument stack (-2 = the type word) Out: d0 the long
| ULONG doqangle_c |
( |
UWORD | sx, |
|
|
UWORD | sy, |
|
|
UWORD | dx, |
|
|
UWORD | dy ) |
|
static |
QAngle(Src X,Src Y,Dest X,Dest Y) - the angle of the line dest -> src.
Octant from the signs and the steepness, arctan from the table arc (arc.bin of the original), mirrored and offset per octant (oct). Fixed (intended deviation, #1003): the differences are longs, their absolute values (0..65535) are compared unsigned. The original subtracted words: a difference of 32768 or more in magnitude wrapped (NEG of -32768 stays negative, CMP/BMI is the sign of the 16 bit difference) and gave the angle of another quadrant. The DIVU of the smaller value << 16 by the larger cannot overflow; for differences in -32767..32767 the result is the original's.
- Parameters
-
| sx | d0: source x |
| sy | d1: source y |
| dx | d2: destination x |
| dy | d3: destination y |
- Returns
- d0: Quick, the fraction of a full turn (0..$FFFF in the low word)
QLimit(Quick,Low,High) - limit q to low..high.
Signed: below low -> low, at or above high -> high (CMP.l d2,d0:BLT - q = high also gives high, low wins if low > high only below low). The original's code, an assembler entry: it changes only d0, whatever GCC would make of a C function.
In: d0 the Quick value, d1 the lower limit, d2 the upper limit Out: d0 the limited value
Rnd - a random fraction.
MOVEQ #0,d0 + genrnd (hardware noise, see GENRND). Rnd and Rnd(Range) keep a0 and a1, which the CD programs SQUIRT2_TO and SQUIRT3_TO hold across them (inline assembler): the assembler changes only d0-d2 (KEEPS a0|a1 in libs/tests/systest_cmdlibs.c).
Out: d0 Quick 0..$FFFF/$10000 (16 random bits in the low word)
Rnd(Range) - a random value 0..range.
MULU range.w,genrnd (range as unsigned word: Rnd(-1) = Rnd(65535)). The original keeps the range in d7 (MOVE d0,d7); here it waits in the upper word of d1, which GENRND does not touch, so Rnd(Range) changes only d0-d2, as Rnd.
In: d0.w the range (unsigned word) Out: d0 Quick 0..range (exclusive)
Sgn(Expression) - the sign: -1, 0 or 1.
Float through SPTst, long and quick tested as long, byte (type 1) and word (types 0, 2) sign extended.
Errors (debugger only, intchk): a string -> "Illegal Type".
Fixed (#301): mathffp SPTst tests D1, not D0; the original passes d1 as it has it, the type (MOVE -(a2),d1: 5 in the low word, the caller's upper word), so Sgn of a float was 1 whatever the value (Sgn(-1.0) = Sgn(0.0) = 1). Now SPTst gets the float in d1 (MOVE.l d0,d1).
In: d0 the value, a6 the mathffp base, a2 the argument stack (-2 = the type word) Out: d0 Quick -1, 0 or 1 ($FFFF0000, 0, $00010000)
| BLITZ_ENTRYPOINT ULONG doval_c |
( |
UBYTE * | str, |
|
|
const void * | ffp, |
|
|
const UBYTE * | args ) |
|
static |
Val(String$) - the numeric value of a string, as a float.
doval2: leading spaces skipped, then "$" hex, "%" binary, "-" negative (SPNeg), else decimal with an optional fraction. MOVE.l d0,a3: a3 = the string afterwards (frees the work area).
Fixed (#302): after "$", "%" and "-" the count is decremented with the character skipped. The original did not, so hex, binary and negative numbers read one byte behind the string as a further digit (normally its terminating 0: Val(Left$("-12",2)) = -1; a digit there was taken too). Fixed (#303): the length is used as a long (the original counted its low word (SUBQ #1,d2:BMI): lengths 32769..65536 gave 0, longer ones counted mod 65536). Fixed (#304): only the first 9 fraction digits count (the original took them all modulo 2^32: wrong from 10 decimal places on, dropped from 32 on).
- Parameters
-
| str | d0: the string |
| ffp | a6: the mathffp base |
| args | a2: the argument stack, -4 = the string length (long) |
- Returns
- d0: the value (FFP), 0 for an empty string
| void intchk_c |
( |
const UBYTE * | args | ) |
|
|
static |
intchk - error check of Int, Sgn and Frac (debugger only).
CMP #6,-2(a2):BCC err1:RTS - the type word on the a2 stack (not popped) must be numeric; keeps all registers.
Errors: type >= 6 (a string) -> runtime error "Illegal Type".
- Parameters
-
| args | a2: the argument stack, -2 = the type word |