1

There is probably a rather elegant solution to this, but for the life of me I am unable to find any form of trig functions in gbdk – with the "math.h" library not included (probably missing something). Any help would be greatly appreciated.

I've tried including the standard "math.h" library (not included) and wasn't able to find any documentation from their website

  • That is old school programming. Gdbk hasn't even a proper floating point number support. Back in the days, if you wanted trigonometry, you had to fill lookup tables yourself, with the precision needed for your application (or implement a CORDIC algorithm). Keep in mind target is Z80 cpu, that even has not integer multiplication – chrslg Jan 01 '23 at 15:22
  • 2
    I think I went too deep into this whole retro programming thing. Your comment has probably saved me countless hours of scanning docs and obscure forums for an answer I’d never find. Happy new years! – Leo De Silva Jan 01 '23 at 16:14
  • I am old enough to have known the time when I would have dreamt to have float in assembly language (I am "only" 50; with 1 or 2 decade to go before retirement. But I was a geek teenager, and even younger, coding in assembly because I had no other choce than BASIC or assembly). But having trig function? That I wouldn't even have dreamt of, because I wasn't missing them: it couldn't imagine that having trig functions directly available was even possible, so how could I miss something that I didn't know could exist? – chrslg Jan 01 '23 at 16:39
  • And yet, even I, when I try to blink a led with a PIC microcontroller am like "what? no floating points division? what I am supposed to do with that?". So, that oldie preamble to say 1. It is quite easy to loose track of how, not that long ago, thinks that we take for granted, such as floats, was not even imaginable. 2. That it should not discourage you. Those things are not that important. For example, if you want do draw a circle, it is not that hard to have a table of 90 values of `sin` of 90 1st degrees (all the other sin and cos can be deduced from them). – chrslg Jan 01 '23 at 16:43
  • For game programming, especially 8bits game programming, it is rare to need more than fixed point arithmetic and some lookup tables. – chrslg Jan 01 '23 at 16:44

0 Answers0