Advertisement
Kitomas

kit-8 std/math.h v0

Apr 13th, 2023 (edited)
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | Source Code | 0 0
  1. #ifndef _STD_MATH_H
  2. #define _STD_MATH_H
  3. ;std/math.h
  4. ;(include "math.asm" somewhere if you want to actually use this)
  5.  
  6. ;available defines of MATH_USE_x:
  7. ;MATH_USE_ALL (auto-defines everything else)
  8. ;MATH_USE_ADD
  9. ;MATH_USE_SIN
  10.  
  11. #include "pseudoOps.h"
  12.  
  13. #ifdef MATH_USE_ALL
  14.  #ifndef MATH_USE_ADD
  15.   #define MATH_USE_ADD
  16.  #endif
  17.  #ifndef MATH_USE_SIN
  18.   #define MATH_USE_SIN
  19.  #endif
  20. #endif
  21.  
  22. ;used to actually call the math subroutines
  23. #ifdef MATH_USE_ADD
  24. #define add8s_16(_d,_val, _ptrA) \
  25.     lda _d,(_val) && ldc_imm(_ptrA) &&\
  26.     stc_abs(math_ptrA)              &&\
  27.     l1call_abs_s(_add8s_16)
  28. #define add16_16(_ptrA,_ptrB) \
  29.     ldc_imm(_ptrA) && stc_abs(math_ptrA)    &&\
  30.     ldc_imm(_ptrB)                          &&\
  31.     stc_abs(math_ptrB)                      &&\
  32.     l1call_abs_s(_add16_16)
  33. #endif
  34.  
  35. #ifdef MATH_USE_SIN
  36. ;this computes sin by grabbing from sin_table
  37. ;(requires sin256_8.bin)
  38. #define sin8_i_shift(_shft) \
  39.     lda @,sin_table                     &&\
  40.     shr(#,_shft) && sta $,_SCRATCH_C    &&\
  41.     and #,0x80>>_shft && bnz @+2+3      &&\
  42.     lda #,0 && jmp @+3+2                &&\
  43.     lda #,_l(0xff00>>_shft)             &&\
  44.     ora_abs(_SCRATCH_C)
  45. #endif
  46.  
  47. #endif
Tags: kit-8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement