# MSX FUSION-C, Talking about bugs, errors, mistakes

Page 18/26
11 | 12 | 13 | 14 | 15 | 16 | 17 | | 19 | 20 | 21 | 22 | 23

Thanks ducasp! --I will look into that example to see how many cycles the basic int-routine spends. For a general purpose library like Fusion-C, things need to be properly handled (as you set out to do), but I'm on the lookout for something like "cpu-cycle-optimal", so I need to research and tailor :-)

Oups ... It seems I missed some questions here !
Sorry ...

I'm currently working on the v1.3. It will be a major update. I 'm testing... thus, I think It will be out soon. ;-)

Hi People,

I need help. This code for plot a Cardiod works, however I think I am doing something wrong because it is too slow, taking 3.51 seconds to complete. I made a version with two sin and cosine integer with two digits and get only 0.38 seconds, almosta ten times faster.

There is a float version using math.h that completed the plot in 2.41 s, then maybe I do not understand how make good integer arithmetic with Fusion-C.

My Regards.

```/*
Curva Cardioide
usando tabela de senos e cossenos

Table[Round[1000*Sin[i]], {i, 0, 2*Pi, 0.05}]
Tempo de execucao 3.51s
*/

#include

int sen_table[126] =
{0, 50, 100, 149, 199, 247, 296, 343, 389, 435, 479, 523, 565, 605,
644, 682, 717, 751, 783, 813, 841, 867, 891, 913, 932, 949, 964, 976,
985, 993, 997, 1000, 1000, 997, 992, 984, 974, 961, 946, 929, 909,
887, 863, 837, 808, 778, 746, 711, 675, 638, 598, 558, 516, 472, 427,
382, 335, 287, 239, 190, 141, 91, 42, -8, -58, -108, -158, -207,
-256, -304, -351, -397, -443, -487, -530, -572, -612, -651, -688,
-723, -757, -789, -818, -846, -872, -895, -916, -935, -952, -966,
-978, -987, -994, -998, -1000, -999, -996, -991, -982, -972, -959,
-944, -926, -906, -883, -859, -832, -804, -773, -740, -706, -669,
-631, -592, -551, -508, -465, -420, -374, -327, -279, -231, -182,
-133, -83, -33};

int cos_table[126] =
{1000, 999, 995, 989, 980, 969, 955, 939, 921, 900, 878, 853, 825,
796, 765, 732, 697, 660, 622, 582, 540, 498, 454, 408, 362, 315, 267,
219, 170, 121, 71, 21, -29, -79, -129, -178, -227, -276, -323, -370,
-416, -461, -505, -547, -589, -628, -666, -703, -737, -770, -801,
-830, -857, -882, -904, -924, -942, -958, -971, -982, -990, -996,
-999, -1000, -998, -994, -987, -978, -967, -953, -936, -918, -897,
-874, -848, -821, -791, -759, -726, -691, -654, -615, -575, -533,
-490, -446, -401, -355, -307, -259, -211, -162, -112, -62, -12, 38,
87, 137, 187, 235, 284, 331, 378, 424, 469, 512, 554, 595, 635, 673,
709, 743, 776, 806, 835, 861, 886, 908, 927, 945, 960, 973, 983, 991,
997, 999};

{1000, 999, 997, 994, 990, 984, 977, 969, 960, 949, 937, 923, 908,
892, 875, 855, 835, 812, 788, 763, 735, 705, 673, 639, 602, 562, 517,
468, 412, 347, 266, 144, 171, 281, 359, 422, 477, 525, 569, 608, 645,
679, 711, 740, 767, 793, 816, 838, 859, 878, 895, 911, 926, 939, 951,
961, 971, 979, 985, 991, 995, 998, 1000, 1000, 999, 997, 994, 989,
983, 976, 968, 958, 947, 935, 921, 906, 889, 871, 852, 831, 808, 784,
758, 730, 700, 668, 633, 595, 554, 509, 459, 402, 335, 250, 111, 194,
296, 370, 432, 485, 533, 576, 615, 651, 684, 716, 745, 772, 797, 820,
842, 862, 881, 898, 914, 928, 941, 953, 963, 972, 980, 986, 992, 996,
998, 1000};

unsigned long int Raio_fun_theta( long signed int valor_sen,unsigned int abs_sqcos) {
int Raio = 28;
unsigned long  int  RaioTheta;
RaioTheta = Raio*( valor_sen *abs_sqcos/(valor_sen + 1400) -2*valor_sen +2000 )/1000 ;
return RaioTheta;
}

void main(void){
char i,x,y,Cor,CentroX,CentroY;
int tempo_ini, tempo_fim, delta_t;
signed long int SinValor,CosValor;
int Raio;
VDP60Hz();
CentroX = 127, CentroY = 70; Cor = 6;
Screen(5);
KeySound(0);
tempo_ini = RealTimer();
SetColors(Cor, 0, 0);
for (i = 0;i < 126;i++) {
SinValor = sen_table[i];
CosValor = cos_table[i];
x = ((Raio * CosValor)/1000 + CentroX);
y = (CentroY - (Raio * SinValor)/1000);
Pset(x, y, Cor, 0);
//Line(x, y, xn, yn, Cor, 0);
//if (Inkey() == 27)
//	break; // Emergencia
}

tempo_fim = RealTimer();
while (Inkey() != 27) {}
Screen(0);
SetColors(15, 0, 0);
KeySound(1);
delta_t = tempo_fim - tempo_ini;
//printf("tempo exec.= %d.%d s",(delta_t)/60,100*(delta_t%60)/60);
Print("tempo exec. = ");
PrintNumber((delta_t) / 60);
Print(",");
PrintNumber(100 * (delta_t % 60) / 60);
Exit(0);

}

```

Hi Eric,

Just to report a bug.

I just found that IntBios and IntDos (IntDosBios.s), as well as dependent routines (like ReadMSXtype) don't work in ROM projects. They rely self-modifying code (they (try to) change ibcladr) and, being unable to set the proper routine address, they end up jumping to 0x0000 and booting the computer.

Github issue opened.

best!

@mpsantos7 : I 'm not able to answer you. Perhaps someone else ?

@DamnedAngel : IntBios, IntDos, ReadMSXType, and others functions that are using interslot call cannot be used in a ROM Project. They are made to work only from MSX-DOS.
If you wish to use FUSION-C To produce ROM file, it's possible, but you must avoid all functions that are using a BIOS Call.

Anyway. By using new version of SDCC (4.0), using the IntBIOS/INTDOS method do not works anymore. So I 've written new functions for the upcoming Fusion-c 1.3. But they are still useless for ROM projects.

ericb59 wrote:

Ok good

I think I will publish Fusion-C 1.3 before the end of the week.
There are many improvements in v1.3...
Before that, to overcome the confinement we endure, I launched myself a little challenge yesterday.
Here in video.

Hello Eric,

Do you have a status update on Fusion-C 1.3?

Hi Eric,

Have you thought about unit-testing your library? So that you could just run a batch of tests (manually or automatically) and they should tell you right away if there are any broken functions or not. I thought about it because it's quite difficult to maintain something the size of Fusion-C with such a small team and it could also improve code quality and avoid recurring problems. I am writing some code to unit test future MSX programs against OpenMSX using its virtual debug-device extension, but it is written in Python and only works on GNU/Linux and MacOS (not tested). This sample code checks if printf works as expected, so you might find it useful.

Hello pizzapower,

this is a good idea. There is some work to do first, but a good idea.

Thank you

Yes I'm in late. It's ready, but I still have some work to do on the documentation.
It will come soon.

ericb59 wrote: