Author Topic: sinus, cosinus table with cpctelera ?  (Read 805 times)

0 Members and 1 Guest are viewing this topic.

Offline funkheld

  • 464 Plus
  • *****
  • Posts: 386
  • Liked: 20
  • Likes Given: 0
sinus, cosinus table with cpctelera ?
« 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
« Last Edit: 17:35, 20 July 20 by funkheld »

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.417
  • Country: au
    • index.php?action=treasury
  • Liked: 1110
  • Likes Given: 1323
Re: sinus, cosinus table with cpctelera ?
« Reply #1 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.

My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline funkheld

  • 464 Plus
  • *****
  • Posts: 386
  • Liked: 20
  • Likes Given: 0
Re: sinus, cosinus table with cpctelera ?
« Reply #2 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
« Last Edit: 18:21, 20 July 20 by funkheld »

Offline teopl

  • CPC664
  • ***
  • Posts: 135
  • Country: cs
  • Liked: 59
  • Likes Given: 114
Re: sinus, cosinus table with cpctelera ?
« Reply #3 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)

Offline funkheld

  • 464 Plus
  • *****
  • Posts: 386
  • Liked: 20
  • Likes Given: 0
Re: sinus, cosinus table with cpctelera ?
« Reply #4 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

Offline awergh

  • CPC6128
  • ****
  • Posts: 295
  • Country: au
  • Liked: 177
  • Likes Given: 320
Re: sinus, cosinus table with cpctelera ?
« Reply #5 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.

Offline funkheld

  • 464 Plus
  • *****
  • Posts: 386
  • Liked: 20
  • Likes Given: 0
Re: sinus, cosinus table with cpctelera ?
« Reply #6 on: 12:56, 21 July 20 »

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

greeting

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 930
  • Liked: 458
  • Likes Given: 74
Re: sinus, cosinus table with cpctelera ?
« Reply #7 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.