CPCWiki forum

General Category => Programming => Topic started by: funkheld on 11:20, 20 July 20

Title: sinus, cosinus table with cpctelera ?
Post by: funkheld on 11:20, 20 July 20


Hi good afternoon.

- I'm looking for a sine, cosine table fed cpctelera.
i want to turn lines.

- how can you pleaseimplement the "tag" command from basic for cptcelera?

thanks
greeting
Title: Re: sinus, cosinus table with cpctelera ?
Post by: ervin on 17:52, 20 July 20
For sine and cosine tables, you can define arrays with 360 elements.
And then you can include math.h, and use the sin() and cos() functions to calculate the tables.
Or you can use a different language to calculate the tables for you and save the data to text files, which you can simply include in your code.

cpctelera lets you print a character at any byte horizontally (so there are 80 possibilities), and on any raster line (200 possibilities).
However for TAG(), you'd need to print at pixel-level horizontally, which cpctelera doesn't have a function for.

Title: Re: sinus, cosinus table with cpctelera ?
Post by: funkheld on 18:05, 20 July 20
hello, thanks for the info

there is a math.h somewhere in cpctelera?
what should the table look like for this sin / cos? how then is math.h used for this.
I'm looking for a small example for cpctelera.


the important sin / cos is part of the graphics.
I am surprised that this was not installed by the developers. the sprites just up / down right / left is little.
you should also be able to set a sprite at a certain angle.


greeting
Title: Re: sinus, cosinus table with cpctelera ?
Post by: teopl on 19:32, 20 July 20
there is only one header file in cpctelera and it misses a lot of features usually for a good reason. (memory and "speed" limitation).

you have very good manual with all the functions listed and explained so if you can't find it there, it is not implemented.

so if you want a function and it's not there, you must create it. (maybe some of those missing will be added later)

when I started with the retro development it was also strange to me how limited I am, but soon it became also something which is very interesting to overcome - I guess that is one of the main reasons why someone develops for Amstrad instead for modern computer)
Title: Re: sinus, cosinus table with cpctelera ?
Post by: funkheld on 21:03, 20 July 20

i wish the young people had as much courage to do cpctelera as i did at 71 years old from germany. I think there would be more programs. 8) 
my english skills are poor.

greeting
Title: Re: sinus, cosinus table with cpctelera ?
Post by: awergh on 11:26, 21 July 20
math.h is a standard C header file and is included with SDCC.

I would suggest trying to avoid needing to use any floating point because it is slower and will require more memory.
Title: Re: sinus, cosinus table with cpctelera ?
Post by: funkheld on 12:56, 21 July 20

math.h is not intended for the CPC from sdcc.

greeting
Title: Re: sinus, cosinus table with cpctelera ?
Post by: andycadley on 13:57, 21 July 20

you should also be able to set a sprite at a certain angle.

Drawing sprites at arbitrary angles is an expensive operation. Even 16-bit consoles like the Megadrive and SNES typically needed extra hardware for effects like that.


Instead most 8-bit (and 16-bit) games handle it by having pre-drawn animation frames that make it look like a sprite has rotated. That typically limits the number of available angles, but on a low res screen that usually isn't much of a problem.


Likewise with sin/cos tables, you can use them to some extent but generally you want to avoid it because there are often better tricks to accomplish similar effects that you might use trig for on a more modern platform.