Who can assemble for me this C file ?

C and PASCAL (or any other high-level languages) in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Who can assemble for me this C file ?

Postby Maartau » Sat Oct 14, 2006 6:00 am

Well,

I need help for assembling the next C file...

It must be executed in medium resolution.

I'm looking for both files if possible (exec creating MORDOR.CNX & MORDOR.CNX itself 8) ).

Who can done the job for me :oops: ?

Thanks :D
Last edited by Maartau on Wed Oct 18, 2006 12:11 pm, edited 4 times in total.

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Sat Oct 14, 2006 6:01 am

Edit ; corrected & clean present now :wink:
+--------------------------------------+

Code: Select all

#include <osbind>
#include <math>
#define pie 3.14159

int contrl[12],
   intin[128],
   ptsin[128],
   intout[128],
   ptsout[128];
int handle,
   phys_handle;
int gl_hhbox,gl_hwbox,gl_hhchar,gl_hwchar;
int work_out[57],
   work_in[12];
int erreur,
   dummy;
int color_buffer[20000];
int colors[15]={0x000,0x001,0x002,0x003,0x004,0x005,0x006,0x007,0x006,0x005,0x004,0x003,0x002,0x001,0x000};

open_work()
{
int i;
handle=phys_handle;
for(i=0;i<10;work_in[i++]=1);
work_in[10]=2;
v_opnvwk(work_in,&handle,work_out);
}
close_work()
{
v_clsvwk(handle);
appl_exit();
}
main()
{
int a,b,ct=0,x[5],y[5],tab[4],interm[400],
        y_min,y_max,cx[5],cy[5],lang;
long lenght;
float angle;

appl_init();
phys_handle=graf_handle(&gl_hwchar,&gl_hhchar,
                  &gl_hwbox,&gl_hhbox);
open_work();
v_clrwk(handle);
graf_mouse(0,01);
vsl_color(handle,1);

for (angle=0;angle<2*pie-0.0628318; angle=angle+0.0628318)
{

   for(a=0;a<400;a++) interm[a]=0;
   x[0]=cos(angle)*90+320;
   y[0]=sin(angle)*64+66;
   x[1]=cos(angle-pie/16)*90+320;
   y[1]=sin(angle-pie/16)*64+66;
   x[2]=cos(angle-pie/8)*90+320;
   y[2]=sin(angle-pie/8)*64+66;
   x[3]=cos(angle-(3*pie/16))*90+320;
   y[3]=sin(angle-(3*pie/16))*64+66;
   x[4]=cos(angle-pie/4)*90+320;
   y[4]=sin(angle-pie/4)*64+66;
   
   if (y[0]<y>y[2]) y_min=y[2];
   if (y_min>y[3]) y_min=y[3];
   if (y_min>y[4]) y_min=y[4];
   
   if (y[0]>y[1]) y_max=y[0];
   else y_max=y[1];
   if (y_max<y[2]) y_max=y[2];
   if (y_max<y[3]) y_max=y[3];
   if (y_max<y[4]) y_max=y[4];
   
   lang=y_max-y_min+15;
   
   v_hide_c(handle);
   tab[0]=tab[2]=(x[0]+x[1]+x[2]+x[3]+x[4])/4;
   tab[1]=y_min;
   tab[3]=y_max+15;
   v_pline(handle,2,tab);
   v_show_c(handle,0);
   
   b=0;
   do
   {
    for(a=0;a<5>=x[0] && x[a]>=x[1] && x[a]>x[2]
     && x[a]>=x[3] && x[a]>=x[4] && !=5)
     {
      cx[4-b]=x[a]; cy[4-b]=y[a]; x[a]=0; b++;
     };
    };
   } while (b!=5);

  a=cy[4]-y_min; for (b=a;b<a+15;b++) interm[b]=colors[b-a];
  a=cy[3]-y_min; for (b=a;b<a+15;b++) interm[b]=colors[b-a];
  a=cy[2]-y_min; for (b=a;b<a+15;b++) interm[b]=colors[b-a];
  a=cy[1]-y_min; for (b=a;b<a+15;b++) interm[b]=colors[b-a];
  a=cy[0]-y_min; for (b=a;b<a+15;b++) interm[b]=colors[b-a];

   color_buffer[ct++]=y_min;
   color_buffer[ct++]=lang*2;
   for(a=0;a<lang;a++)
   {
    color_buffer[ct++]=interm[a];
   };
};
printf("Press a key to save\n");
gemdos(0x7);

erreur=gemdos(0x3c,"MORDOR.CNX",0);
lenght=ct*2;
gemdos(0x40,erreur,lenght,color_buffer);
gemdos(0x3e,erreur);
v_hide_c(handle);
v_clrwk();
graf_mouse(0,01);
v_show_c(handle,1);
close_work();
}
Last edited by Maartau on Wed Oct 18, 2006 12:09 pm, edited 6 times in total.

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Mon Oct 16, 2006 7:06 am

Where can I find those C files :?:

#include <osbind>
#include <math>

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Mon Oct 16, 2006 7:07 am

A good soul could help me to translate it into 68k???

User avatar
NiceGuyUK
Atari Super Hero
Atari Super Hero
Posts: 580
Joined: Thu Nov 25, 2004 1:03 pm
Location: Kent, England
Contact:

Postby NiceGuyUK » Mon Oct 16, 2006 10:30 am

osbind and math are both C libraries that should be included with the C compiler (look for file extensions .h)
Also known as Big Boss Man of Demografica

User avatar
christos
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2459
Joined: Tue Apr 13, 2004 8:24 pm
Location: Greece
Contact:

Postby christos » Mon Oct 16, 2006 11:09 am

Yeap just change
osbind to osbind.h
and
math to math.h

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Mon Oct 16, 2006 2:51 pm

Yep, thanks. I found OSbind.h & math.h

I used Lattice C & found bugs in the code. (While the original code was like this one).

I can't made the source running :cry:
Last edited by Maartau on Mon Oct 16, 2006 6:26 pm, edited 1 time in total.

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Mon Oct 16, 2006 2:53 pm

Always multi-errors in line 58 :evil: (See bold line)

Here's LATTICE C v5 in English if it can help.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Tue Oct 17, 2006 10:56 am

Maartau wrote:Always multi-errors in line 58 :evil: (See bold line)

Maybe you should close the comments on line 24 ( /* Color_buffer contient les donn‚es qui seront sauv‚es */ ) and on line 26 ( /* Colors contient le d‚grad‚ bleu formant les 5 rouleaux */
). Otherwise the compiler thinks everything is a comment until the for statement on line 58.

Hans Wessels

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Tue Oct 17, 2006 10:57 pm

Yes, thanks. I hadn't noticed this error & I can say I read many & many times to see what's wrong with no luck :(

I reloaded a correct code and better display :wink:

Help... H...

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Tue Oct 17, 2006 11:07 pm

Ahem, by the way : it's a source code I've typed manually from a french ST Magazine. I can post an excerpt scan.

I don't know at all how to code in C, that's why I really don't understand what's wrong or translating into GFA (as it's said in the mag :evil: ). I'm not also a GFA expert :roll:

The main reason why I choose this code is due to an assembly source included in the article & this source need this file.

1) I can post scans for those who wants to see further :

this code permits to do 5 blue rasters tubes to move around an axe (effect like a revolver gun I should say...)

2) I can (and would like :wink: ) to type the included assembly source

3) As I'm trying to redo some codes, there's explains & clean code so I hope not to be the only one interested :)

See you...

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Wed Oct 18, 2006 12:13 pm

Normally, this is EXACTLY the same code now :cry:

Now, multi errors with caracters like { } (concerning the beginning of the lines).

What the hell...

Soon & next I post the scans. :o

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Wed Oct 18, 2006 1:49 pm

Maartau wrote:Normally, this is EXACTLY the same code now :cry:

Now, multi errors with caracters like { } (concerning the beginning of the lines).

I cleaned up the code with indent and fixed the obvious errors. Included the right include files so the code compiles with Pure C. IMHO this is a horrible pice of C code. Anyhow there is still one typo left. I don't know what it should be. Here is the cleaned up code:

Code: Select all

/* #include <osbind> */
#include <aes>
#include <tos>
#include <vdi>
#include <math>
#include <stdio>

#define pie 3.14159

int contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
int handle, phys_handle;
int gl_hhbox, gl_hwbox, gl_hhchar, gl_hwchar;
int work_out[57], work_in[12];
int erreur, dummy;
int color_buffer[20000];
int colors[15] =
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x006, 0x005, 0x004, 0x003, 0x002, 0x001, 0x000};

void open_work(void)
{
  int i;
  handle = phys_handle;
  for (i = 0; i < 10; work_in[i++] = 1)
  {
    ;
  }
  work_in[10] = 2;
  v_opnvwk (work_in, &handle, work_out);
}

void close_work (void)
{
  v_clsvwk (handle);
  appl_exit ();
}

int main (void)
{
  int a, b, ct = 0, x[5], y[5], tab[4], interm[400], y_min, y_max, cx[5],
    cy[5], lang;
  long lenght;
  float angle;

  appl_init ();
  phys_handle = graf_handle (&gl_hwchar, &gl_hhchar,
              &gl_hwbox, &gl_hhbox);
  open_work ();
  v_clrwk (handle);
  graf_mouse (0, NULL);
  vsl_color (handle, 1);

  for (angle = 0; angle < 2 * pie - 0.0628318; angle = angle + 0.0628318)
  {
    for (a = 0; a < 400; a++)
    {
      interm[a] = 0;
    }
    x[0] = cos (angle) * 90 + 320;
    y[0] = sin (angle) * 64 + 66;
    x[1] = cos (angle - pie / 16) * 90 + 320;
    y[1] = sin (angle - pie / 16) * 64 + 66;
    x[2] = cos (angle - pie / 8) * 90 + 320;
    y[2] = sin (angle - pie / 8) * 64 + 66;
    x[3] = cos (angle - (3 * pie / 16)) * 90 + 320;
    y[3] = sin (angle - (3 * pie / 16)) * 64 + 66;
    x[4] = cos (angle - pie / 4) * 90 + 320;
    y[4] = sin (angle - pie / 4) * 64 + 66;

    if (y[0] <y> y[2])
    {
      y_min = y[2];
    }
    if (y_min > y[3])
    {
      y_min = y[3];
    }
    if (y_min > y[4])
    {
      y_min = y[4];
    }
    if (y[0] > y[1])
    {
      y_max = y[0];
    }
    else
    {
      y_max = y[1];
    }
    if (y_max < y[2])
    {
      y_max = y[2];
    }
    if (y_max < y[3])
    {
      y_max = y[3];
    }
    if (y_max < y[4])
    {
      y_max = y[4];
    }

    lang = y_max - y_min + 15;

    v_hide_c (handle);
    tab[0] = tab[2] = (x[0] + x[1] + x[2] + x[3] + x[4]) / 4;
    tab[1] = y_min;
    tab[3] = y_max + 15;
    v_pline (handle, 2, tab);
    v_show_c (handle, 0);

    b = 0;
    do
    {
      for (a = 0; a <5>= x[0])
       && (x[a] >= x[1])
       && (x[a] >= x[2])
       && (x[a] >= x[3])
       && (x[a] >= x[4])
       && !=5)
/*            ^^^^^^^^^^ Error over here. What variable shouldn't be equal to 5? */
   {
     cx[4 - b] = x[a];
     cy[4 - b] = y[a];
     x[a] = 0;
     b++;
   }
      }
    } while (b != 5);

    a = cy[4] - y_min;
    for (b = a; b < a + 15; b++)
    {
      interm[b] = colors[b - a];
    }
    a = cy[3] - y_min;
    for (b = a; b < a + 15; b++)
    {
      interm[b] = colors[b - a];
    }
    a = cy[2] - y_min;
    for (b = a; b < a + 15; b++)
    {
      interm[b] = colors[b - a];
    }
    a = cy[1] - y_min;
    for (b = a; b < a + 15; b++)
    {
      interm[b] = colors[b - a];
    }
    a = cy[0] - y_min;
    for (b = a; b < a + 15; b++)
    {
      interm[b] = colors[b - a];
    }

    color_buffer[ct++] = y_min;
    color_buffer[ct++] = lang * 2;
    for (a = 0; a < lang; a++)
    {
      color_buffer[ct++] = interm[a];
    }
  }
  printf ("Press a key to save\n");
  gemdos (0x7);

  erreur = (int)gemdos (0x3c, "MORDOR.CNX", 0);
  lenght = ct * 2;
  gemdos (0x40, erreur, lenght, color_buffer);
  gemdos (0x3e, erreur);
  v_hide_c (handle);
  v_clrwk (handle);
  graf_mouse (0, NULL);
  v_show_c (handle, 1);
  close_work ();
  return 0;
}


Hans Wessels

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Wed Oct 18, 2006 3:31 pm

Nyh wrote:
Maartau wrote:Normally, this is EXACTLY the same code now :cry:

Now, multi errors with caracters like { } (concerning the beginning of the lines).

I cleaned up the code with indent and fixed the obvious errors. Included the right include files so the code compiles with Pure C. IMHO this is a horrible pice of C code. Anyhow there is still one typo left. I don't know what it should be. Here is the cleaned up code:


Thanks NYH, but I haven't found Pure C.

Could you fill the *!=5* by *a!=5* & compil the file MORDOR.CNX please :?: :P

Thanks (It's becoming very boring as I spent almost 6 hours on :evil: ).

Lautreamont
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 103
Joined: Fri Jan 27, 2006 9:11 pm
Location: Friceland

Postby Lautreamont » Wed Oct 18, 2006 8:17 pm

I'm not very interested in that code, but I would say the author didn't master it and was even fearful of it at that time.
I would read the test like that:

Code: Select all

    b = 0;
    do   
    {
      for (a = 0;
           
           a < 5
           && (x[a] >= x[0])
           && (x[a] >= x[1])
           && (x[a] >= x[2])
           && (x[a] >= x[3])
           && (x[a] >= x[4])
           && b !=5;
           
           a++)
   ...

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Thu Oct 19, 2006 12:05 pm

Maartau wrote:Thanks NYH, but I haven't found Pure C.

Could you fill the *!=5* by *a!=5* & compil the file MORDOR.CNX please :?: :P

Nope. You will have to compile it yourself. I have cleant the whole file up, removed the tons of poo, unnecessary code and stupid constructs. Made it a bit more readble. It will compile fine on any ANSI C compiliant compiler and as long as integer size is 2 bytes and the system is BIG endian, I think it will give the correct file too!

Code: Select all

#include <stdio.h>
#include <math.h>

#define pie 3.14159

int color_buffer[20000];
int colors[15] =
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x006, 0x005, 0x004, 0x003, 0x002, 0x001, 0x000};

int main (void)
{
  int i, j, ct = 0, x[5], y[5], interm[400], y_min, y_max, cy[5], lang;
  float angle;

  /* one complete revolution is 100 steps */
  for (angle = 0; angle < 2 * pie - 0.0628318; angle = angle + 0.0628318)
  {
    for (i = 0; i < 400; i++)
    {
      interm[i] = 0;
    }
   
    /* calculate (x,y) positions of raster bars */
    for(i=0; i<5; i++)
    {
      x[i] = cos (angle - pie*(float)i/16.0) * 90 + 320;
      y[i] = sin (angle - pie*(float)i/16.0) * 64 + 66;
    }
   
    /* calculate y_min and y_max */
    y_min = y[0];
    y_max = y[0];
   
    for(i=1; i<5; i++)
    {
      if (y[i] < y_min)
      {
        y_min = y[i];
      }
      else if (y[i] > y_max)
      {
        y_max = y[i];
      }
    }

    /* sort on x coordinates, store y */
    for(i = 0; i < 5; i++)
    {
      for (j = 0; j < 5; j++)
      {
        if ((x[j] >= x[0])
            && (x[j] >= x[1])
            && (x[j] >= x[2])
            && (x[j] >= x[3])
            && (x[j] >= x[4]))
        {
          cy[i] = y[j] - y_min;
          x[j] = 0;
        }
      }
    }

    /* first draw hindmost raster bars, overlapping is possible */
    for (i = 4; i >= 0; i--)
    {
      for(j = 0; j< 15; j++)
      {
        interm[j + cy[i]] = colors[j];
      }
    }

    lang = y_max - y_min + 15;
    color_buffer[ct++] = y_min;
    color_buffer[ct++] = lang * 2;
    for (i = 0; i < lang; i++)
    {
      color_buffer[ct++] = interm[i];
    }
  }
  printf ("Saving!\n");
  {
    FILE* f;
    if ((f= fopen("MORDOR.CNX", "wb"))==NULL)
    {
      printf("File open error!\n");
      return -1;
    }
    fwrite(color_buffer, ct*2 , 1, f);
    fclose(f);
  }
  return 0;
}

Hans Wessels
Edit: corrected typo

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Thu Oct 19, 2006 9:15 pm

I've tried the first source using PURE C (I found it finally) : doesn't run (too many errors)

Next, I've tried the second source. There's more errors than the first :!:

As I can't succeed, it will stay dead project.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Postby Nyh » Fri Oct 20, 2006 9:51 am

Maartau wrote:I've tried the first source using PURE C (I found it finally) : doesn't run (too many errors)

Next, I've tried the second source. There's more errors than the first :!:

As I can't succeed, it will stay dead project.

It should compile with any C compiler. For Pure C you have to use the Pure C 'default.prj' to build the file. For gcc I use: "gcc -lm -o st_cnx st_cnx.c"

If you can not get this C-source running maybe you have to write your own program for generating the raster infromation in your favorite programming language. It isn't so hard to understand what is done.

Hans Wessels

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Sun Oct 22, 2006 8:57 pm

Nyh wrote:
Maartau wrote:I've tried the first source using PURE C (I found it finally) : doesn't run (too many errors)

Next, I've tried the second source. There's more errors than the first :!:

As I can't succeed, it will stay dead project.

It should compile with any C compiler. For Pure C you have to use the Pure C 'default.prj' to build the file. For gcc I use: "gcc -lm -o st_cnx st_cnx.c"

If you can not get this C-source running maybe you have to write your own program for generating the raster infromation in your favorite programming language. It isn't so hard to understand what is done.

Hans Wessels


Thanks Nyh... Hope you did not take personally the comments about errors :wink: .

You made a great job. To make it run correctly, I must take more time than typing the code. The main source have errors : the author also says it's very easy to convert it in GFA. (With errors too??? :lol: ).

I used C languages under STeem to try... And well... The original code was printed on two pages divided by two rows (nearly each line of code is broken :x ). So errors/mistakes, bad tools, bad source, really get on my nerves.

The last thing I'll try is to made the code running under MATHLAB (I've got the whole package & docs). Now, I'm more a MIDI expert than C. :wink:

:!: I'm also sure I can't convert the code in MIDI :lol:

Thanks for all

Maartau

User avatar
Zorro 2
Administrator
Administrator
Posts: 2211
Joined: Tue May 21, 2002 12:44 pm
Location: Saint Cloud (France)
Contact:

Postby Zorro 2 » Fri Nov 03, 2006 2:23 pm

After some demands from mister Maartau, I finally created a C project on Pure C to compil the last code from mister Nyh.

We're waiting now for mister Maartau to say : "Ca marche !" :wink:

(Place PRJ folder on C root please to compil...)
You do not have the required permissions to view the files attached to this post.
Member of NoExtra Team

Maartau
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2630
Joined: Thu Dec 15, 2005 2:15 am

Postby Maartau » Sat Nov 04, 2006 9:53 am

Zorro 2 wrote:After some demands from mister Maartau, I finally created a C project on Pure C to compil the last code from mister Nyh.

We're waiting now for mister Maartau to say : "Ca marche !" :wink:

(Place PRJ folder on C root please to compil...)


Yes, ça marche !

Another lack filled :wink:

Many many thanks :D :D :D


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 4 guests