2018-07-05 16:59:37 +00:00
|
|
|
;ACME 0.96.4
|
2013-06-26 23:01:00 +00:00
|
|
|
|
|
|
|
!ifdef lib_cbm_c64_float_a !eof
|
2018-07-05 16:59:37 +00:00
|
|
|
lib_cbm_c64_float_a = 2
|
2013-06-26 23:01:00 +00:00
|
|
|
|
|
|
|
; Here are some definitions to help you call the floating-point functions of the
|
2013-06-27 20:29:08 +00:00
|
|
|
; C64's BASIC ROM. They work on "float registers", which are actually just
|
|
|
|
; structures in zero page:
|
2014-06-02 00:47:46 +00:00
|
|
|
!address {
|
|
|
|
fac1_base = $61 ; base address of floating-point accumulator 1
|
|
|
|
fac2_base = $69 ; base address of floating-point accumulator 2
|
|
|
|
}
|
2013-06-27 20:29:08 +00:00
|
|
|
; There is really no need to use these addresses directly when calling the ROM
|
|
|
|
; functions. You'd only need the addresses when using <cbm/flpt.a>.
|
2013-06-26 23:01:00 +00:00
|
|
|
|
2013-06-27 20:29:08 +00:00
|
|
|
!source <cbm/flpt.a> ; include macro to store floats in six-byte FLPT format
|
|
|
|
!source <cbm/mflpt.a> ; include macro to store floats in five-byte MFLPT format
|
2013-06-26 23:01:00 +00:00
|
|
|
|
|
|
|
; convenience macros:
|
|
|
|
|
2018-07-05 16:59:37 +00:00
|
|
|
; some float functions need a memory address in YYAA
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro movYYAA @addr {
|
|
|
|
lda #<@addr
|
|
|
|
ldy #>@addr
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
2018-07-05 16:59:37 +00:00
|
|
|
; ...or in YYXX
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro movYYXX @addr {
|
|
|
|
ldx #<@addr
|
|
|
|
ldy #>@addr
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
2018-07-05 16:59:37 +00:00
|
|
|
; other float functions expect or output a value in AAYY
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro movAAYY @val {
|
|
|
|
ldy #<@val
|
|
|
|
lda #>@val
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro ldAAYY @addr {
|
|
|
|
ldy @addr
|
|
|
|
lda @addr + 1
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro stAAYY @addr {
|
|
|
|
sty @addr
|
|
|
|
sta @addr + 1
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
2018-07-05 16:59:37 +00:00
|
|
|
; ...or in AAXX
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro ldAAXX @addr {
|
|
|
|
ldx @addr
|
|
|
|
lda @addr + 1
|
2013-06-26 23:01:00 +00:00
|
|
|
}
|
|
|
|
|
2014-06-02 00:47:46 +00:00
|
|
|
!address {
|
|
|
|
; constants in five-byte "mflpt" format
|
|
|
|
mflpt_pi = $aea8 ; 3.1415926...
|
|
|
|
mflpt_minus32768 = $b1a5 ; -32768
|
|
|
|
mflpt_1 = $b9bc ; 1
|
|
|
|
mflpt_half_sqr2 = $b9d6 ; SQR(2) / 2
|
|
|
|
mflpt_sqr2 = $b9db ; SQR(2)
|
|
|
|
mflpt_minus_point5 = $b9e0 ; -.5
|
|
|
|
mflpt_log_2 = $b9e5 ; LOG(2)
|
|
|
|
mflpt_10 = $baf9 ; 10
|
|
|
|
mflpt_99999999 = $bdb3 ; 99 999 999
|
|
|
|
mflpt_999999999 = $bdb8 ; 999 999 999
|
|
|
|
mflpt_1000000000 = $bdbd ; 1 000 000 000
|
|
|
|
mflpt_point5 = $bf11 ; .5, also known as 1 / 2
|
|
|
|
mflpt_log_2_reciprocal = $bfbf ; 1 / LOG(2)
|
|
|
|
mflpt_half_pi = $e2e0 ; PI / 2
|
|
|
|
mflpt_double_pi = $e2e5 ; 2 * PI (also see $e309)
|
|
|
|
mflpt_point25 = $e2ea ; .25, also known as 1 / 4
|
|
|
|
mflpt_2_pi = $e309 ; 2 * PI (also see $e2e5)
|
2013-06-26 23:01:00 +00:00
|
|
|
|
2014-06-02 00:47:46 +00:00
|
|
|
; functions - a few points to note:
|
|
|
|
; fac1/2 might get clobbered even if not mentioned in the function's name,
|
2018-07-05 16:59:37 +00:00
|
|
|
; because stuff like fac1_times_memYYAA will load the value from memory
|
2014-06-02 00:47:46 +00:00
|
|
|
; into fac2 first.
|
|
|
|
; for subtraction and division, the left operand is in fac2, the right operand in fac1.
|
|
|
|
fac1_print = $aabc ; print string representation of contents of fac1
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_to_signedAAYY = $b1aa ; might throw ILLEGAL QUANTITY
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_to_signed16 = $b1bf ; might throw ILLEGAL QUANTITY
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_read_signedAAYY = $b391 ; convert 16 bit signed int to float
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_read_unsignedY = $b3a2 ; convert 8 bit unsigned int to float
|
|
|
|
fac1_read_string = $b7b5 ; $22/23 must point to string, A must be string length
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_to_unsignedAAYY = $b7f7 ; might throw ILLEGAL QUANTITY (result is also in $14/15)
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_add_point5 = $b849 ; for rounding, call this before fac1_int
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_memYYAA_minus_fac1 = $b850 ; subtract fac1 from mflpt value
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_fac2_minus_fac1 = $b853
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_add_memYYAA = $b867 ; add mflpt value
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_add_fac2 = $b86a
|
|
|
|
fac1_log = $b9ea ; LOG()
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_times_memYYAA = $ba28 ; multiply by mflpt value
|
|
|
|
fac2_read_memYYAA = $ba8c ; load mflpt value from memory into fac2
|
2014-06-02 00:47:46 +00:00
|
|
|
fac2_read_mem_via0x22ptr = $ba90 ; load mflpt value from memory into fac2
|
|
|
|
fac1_times_10 = $bae2
|
2015-03-01 15:54:11 +00:00
|
|
|
fac1_divide_by_10 = $bafe ; CAUTION: result is always positive!
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_divide_memYYAA_by_fac1 = $bb0f ; divide mflpt value by fac1 value
|
|
|
|
fac1_read_memYYAA = $bba2 ; load mflpt value from memory into fac1
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_read_mem_via0x22ptr = $bba6 ; load mflpt value from memory into fac1
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_to_memYYXX = $bbd4 ; store fac1 to memory as mflpt
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_read_fac2 = $bbfc ; copy fac2 to fac1
|
|
|
|
fac2_read_fac1 = $bc0c ; copy fac1 to fac2
|
|
|
|
fac1_sign_to_A = $bc2b ; $ff, $0, $1 for negative, zero, positive
|
|
|
|
fac1_sgn = $bc39 ; SGN()
|
|
|
|
fac1_abs = $bc58 ; ABS()
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_compare_to_memYYAA = $bc5b ; compare to mflpt value in memory
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_to_signed32 = $bc9b
|
|
|
|
fac1_int = $bccc ; INT()
|
2015-03-01 15:36:59 +00:00
|
|
|
fac1_read_string0 = $bcf3 ; use b7b5 instead; this only works after calling CHRGET
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_print_unsignedAAXX = $bdcd
|
|
|
|
fac1_to_string = $bddd ; string is stored at $0100 (address returned in YYAA)
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_sqr = $bf71 ; SQR()
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_fac2_to_the_power_of_memYYAA = $bf78
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_negate = $bfb4
|
|
|
|
fac1_exp = $bfed ; EXP()
|
2018-01-29 15:59:20 +00:00
|
|
|
; end of basic rom jumps to start of kernal rom!
|
2014-06-02 00:47:46 +00:00
|
|
|
fac1_rnd = $e097 ; RND()
|
|
|
|
fac1_cos = $e264 ; COS()
|
|
|
|
fac1_sin = $e26b ; SIN()
|
|
|
|
fac1_tan = $e2b4 ; TAN()
|
|
|
|
fac1_atn = $e30e ; ATN()
|
|
|
|
}
|
2018-07-05 16:59:37 +00:00
|
|
|
|
|
|
|
; wrappers for names from older version of this file:
|
2018-08-05 15:33:15 +00:00
|
|
|
!macro movAY @addr { +movYYAA @addr }
|
|
|
|
!macro movXY @addr { +movYYXX @addr }
|
|
|
|
!macro movYA @val { +movAAYY @val }
|
|
|
|
!macro ldYA @addr { +ldAAYY @addr }
|
|
|
|
!macro stYA @addr { +stAAYY @addr }
|
|
|
|
!macro ldXA @addr { +ldAAXX @addr }
|
2018-07-05 16:59:37 +00:00
|
|
|
fac1_to_signedYA = fac1_to_signedAAYY
|
|
|
|
fac1_read_signedYA = fac1_read_signedAAYY
|
|
|
|
fac1_to_unsignedYA = fac1_to_unsignedAAYY
|
|
|
|
fac1_memAY_minus_fac1 = fac1_memYYAA_minus_fac1
|
|
|
|
fac1_add_memAY = fac1_add_memYYAA
|
|
|
|
fac1_times_memAY = fac1_times_memYYAA
|
|
|
|
fac2_read_memAY = fac2_read_memYYAA
|
|
|
|
fac1_divide_memAY_by_fac1 = fac1_divide_memYYAA_by_fac1
|
|
|
|
fac1_read_memAY = fac1_read_memYYAA
|
|
|
|
fac1_to_memXY = fac1_to_memYYXX
|
|
|
|
fac1_compare_to_memAY = fac1_compare_to_memYYAA
|
|
|
|
fac1_print_unsignedXA = fac1_print_unsignedAAXX
|
|
|
|
fac1_fac2_to_the_power_of_memAY = fac1_fac2_to_the_power_of_memYYAA
|