Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color *(Launched in 2008)*

You are not logged in.

**ldesilva****New member**- Registered: 2023-01-01
- Posts: 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

Offline

**onHell****New member**- Registered: 2023-01-02
- Posts: 3

I know the GB's computational capabilities are extremely limited, even multiplication and division are not natively supported by the hardware. I'd imagine that there are no available libraries available for these complex mathematical operations, but there's no reason you can't write your own using addition subtraction. Would be an interesting project.

Offline

**bbbbbr****Member**- Registered: 2019-03-04
- Posts: 123

You can see an example of using a sine/cosine lookup table in C with GBStudio's source code:

https://github.com/chrismaltby/gbvm/blo … ore/math.c

https://github.com/chrismaltby/gbvm/blo … math.h#L51

https://github.com/chrismaltby/gbvm/blo … /vm_math.c

Offline

**Robbi_Blechdose****Member**- Registered: 2017-12-10
- Posts: 29

If you *really* need trig functions, e.g. for a calculator program, there's GBDK-3.

It's a fork of GBDK with an updated SDCC and a full math library.

I found it here: http://www.rrsd.com/software_developmen … velopment/

One thing to note: This tool is basically completely unsupported. It works, but don't expect any help from anyone.

Twitter: https://twitter.com/robbi_blechdose

Offline