Thomas Jentzsch Posted November 12, 2021 Share Posted November 12, 2021 (edited) Usually tables are used when the code needs to calculate sine or cosine values. But DASM cannot create such tables, so I wondered if some macro magic could change that. That attached include file is what I came up with. It is quite easy to use, e.g. this code creates sine and (mostly overlapping) cosine tables with 120 values per 360° and a maximum of 127 (= range -127..127). include trig.h SIN_COS_TBL 120, 127 Or if you only need the sinus value for 45° in a range of -64..64: include trig.h SINE 45, 64 lda #TRIG_RESULT Currently it only supports sine and cosine functions and only creates tables for these, but it could be extend by other functions. And maybe not only by trigonometric functions, so that it could become a math library. Or does something like that exist somewhere? Edit: Fixed some bugs, new file attached. trig.h Edited November 13, 2021 by Thomas Jentzsch 4 Link to comment Share on other sites More sharing options...
Recommended Posts