LCC for the Gigatron. Take two.

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
denjhang
Posts: 54
Joined: 02 May 2021, 01:25
Location: yuenan
Contact:

Re: LCC for the Gigatron. Take two.

Post by denjhang »

I wrote a simple music engine, but found a lot of weirdness. In my program, it seems to be difficult to get music from four channels at the same time, which usually gets stuck. This phenomenon made me have to use each channel staggered.
Currently I'm happy with step11.c, but also confused with the other files.
Attachments
step11.c
(2.37 KiB) Downloaded 149 times
step10.c
(2.27 KiB) Downloaded 134 times
step7.c
(1.99 KiB) Downloaded 147 times
step6.c
(2.51 KiB) Downloaded 140 times
step5.c
(1.97 KiB) Downloaded 141 times
step4.c
(1.96 KiB) Downloaded 142 times
denjhang
Posts: 54
Joined: 02 May 2021, 01:25
Location: yuenan
Contact:

Re: LCC for the Gigatron. Take two.

Post by denjhang »

I'm trying to compile GLCC using cygwin, and while it compiles without any errors, the GLCC I compile doesn't have the correct functionality at all. It looks problematic in every way.
Attachments
glcc cygwin.zip
(3.76 MiB) Downloaded 132 times
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: LCC for the Gigatron. Take two.

Post by lb3361 »

Please explain what you mean by "doesn't have the correct functionality" and "problematic in every way".

Also try the precompiled version from https://forum.gigatron.io/viewtopic.php ... t=20#p2484
Make sure to read the instructions.
denjhang
Posts: 54
Joined: 02 May 2021, 01:25
Location: yuenan
Contact:

Re: LCC for the Gigatron. Take two.

Post by denjhang »

lb3361 wrote: 19 Mar 2022, 19:08 Please explain what you mean by "doesn't have the correct functionality" and "problematic in every way".

Also try the precompiled version from https://forum.gigatron.io/viewtopic.php ... t=20#p2484
Make sure to read the instructions.
The precompiled version is fine, but I wish I could compile one myself.
There are a few exceptions I'm talking about.
1.glcc -V gives me back unknown version
2. When I compile a header file that includes gigatron/sys.h, the glcc I compile directly reports an error, just like ordinary lcc, which cannot use gigatron's unique inclusion.
However I use the precompiled version of glcc without any problems.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: LCC for the Gigatron. Take two.

Post by lb3361 »

  • The lack of glcc -V probably means that you did not have the git command in the path when you compiled glcc.
  • I noticed that one of the c files you posted had non-ascii blank characters. Maybe your sys.h has the same problem?
For compiling under Windows. see the section "Windows notes" of the README (https://github.com/lb3361/gigatron-lcc/ ... /README.md). To compile under cygwin. You should also install git under cygwin to get the -V command. The precompiled version was created with the GitForWindowsSDK method.
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: LCC for the Gigatron. Take two.

Post by lb3361 »

Release 1.5 of GLCC.

Just because this has been a long time and because a lot of internal things have changed.
  • he page zero usage has been changed to increase compatibility with at67's' forthcoming work. The runtime support for longs and floats now works entirely in area 0xc0-0xcf using either the vCPU emulation or using new instructions present in AT67's forthcoming ROM. The register file now lives in 0x50-0x7f by default but can be relocated elsewhere with option --register-base=xxxx.
  • The code generator supports a newer version of AT67's ROM in which native support for long integers is also used to speed up floating point emulation. As long as AT67's ROM is not finalized, things are not final there.
  • There is a new map, --map=512k, for the two or three 512k Gigatron in existence (doc with option --info). Long integers are now aligned on 4 byte boundaries instead of 2 bytes boundaries.
  • There is support to constrain the placement in memory of a piece of code (PLACE directive in glink).
  • And a number of library functions have been improved.
As usual, the source code can be obtained with

Code: Select all

git clone https://github.com/lb3361/gigatron-lcc.git  
For convenience, a precompiled Windows version is attached to this message.
Attachments
glcc-1.5.zip
(1.47 MiB) Downloaded 118 times
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: LCC for the Gigatron. Take two.

Post by veekoo »

Great contribution to Gigatron TTL society to make this GLCC available! Floating point mentioned. MIght my fractals with floating point calculation get any faster?
lb3361
Posts: 360
Joined: 17 Feb 2021, 23:07

Re: LCC for the Gigatron. Take two.

Post by lb3361 »

veekoo wrote: 21 May 2022, 12:07 Great contribution to Gigatron TTL society to make this GLCC available! Floating point mentioned. MIght my fractals with floating point calculation get any faster?

Not until we get at67's rom.
Maybe twice faster but not more.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: LCC for the Gigatron. Take two.

Post by veekoo »

Am I running out of memory? No warnings here when compiling. I am using two dimensional array size of 38kb. I have 64k machine.
My simpler versions of this randomizes drawing the dots, but might draw same dot multiple times.
There might be another way to use video memory for this?

Edit. Drawing only 1/4 of screen (array of 9kb) and change reserved code to 555. Then I observe wheter dot is 555 or something else. Now it seems to draw image of random dots.

Code: Select all

/*----------------------------------------------------------------------+
 |                                                                      |
 |     rndbrot.c -- demonstrate fractal in gfx / quick and dirty        |
 |                                                                      |
 +----------------------------------------------------------------------*/
 
// Standard includes
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <math.h>
#include <gigatron/console.h>
#include <gigatron/sys.h>

#define HEIGHT 120
#define WIDTH 160
#define SCALE 1.6
#define YSTEP 1
#define XSTEP 1

int mandelbrot(float x, float y) {
 float zz;
 float a;
 float b;
 float a2;
 float b2;
 float atemp;
 int i;
  
  a = 0;
  b = 0;  
  i = 0;
  while (i < 15)
  {
    a2 = a * a;
    b2 = b * b;
    zz = a2 + b2;
    if(zz > 4) break;
    
    atemp = a2 - b2 + x;
    b = 2.0 * a * b + y;
    a = atemp;
    i++;
  }
  return i;
}

void drawPixel(int x, int y, int color)
{
  screenMemory[y][x] = color;
}

void main(void) {
  int x, y, data, n;
  int col[16];
  int sm[HEIGHT][WIDTH];
  float sx, sy;
  
  col[0] = 0x01;
  col[1] = 0x02;
  col[2] = 0x03;
  col[3] = 0x07;
  col[4] = 0x0b;
  col[5] = 0x0f;
  col[6] = 0x0e;
  col[7] = 0x0d;
  col[8] = 0x0c;
  col[9] = 0x3c;
  col[10] = 0x38;
  col[11] = 0x34;
  col[12] = 0x30;
  col[13] = 0x20;
  col[14] = 0x10;
  col[15] = 0x00;
   
  for(n = 0; n < 19201; n = n + 1 ) {
    y = rand() % HEIGHT;
    x = rand() % WIDTH;
    
    if(sm[y][x] == 1) n--;
    
    if(sm[y][x] == 0) {    
      sx = -0.7 + (SCALE * (WIDTH/2.0 - x) / (WIDTH/2.0))*(-1);
      sy = (SCALE * (HEIGHT/2.0 - y) / (HEIGHT/2.0))*(-0.75);
      data = mandelbrot(sx, sy);
      drawPixel(x,y,col[data]);
      sm[y][x] = 1;
    }
  }
}
Last edited by veekoo on 11 Oct 2022, 06:21, edited 1 time in total.
veekoo
Posts: 121
Joined: 07 Jun 2021, 07:07

Re: LCC for the Gigatron. Take two.

Post by veekoo »

Still testing this, but seems to be drawing randomly dots of mandelbrot. Now full screen.

Array size is 38kb...

Edit. Last part of picture is little bit wrong. Probably array size of 30kb is closer to fit and function. I will make array of [96][160].

Code: Select all

/*----------------------------------------------------------------------+
 |                                                                      |
 |     rndbrot.c -- demonstrate fractal in gfx / quick and dirty        |
 |                                                                      |
 +----------------------------------------------------------------------*/
 
// Standard includes
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <math.h>
#include <gigatron/console.h>
#include <gigatron/sys.h>

#define HEIGHT 120
#define WIDTH 160
#define SCALE 1.6
#define YSTEP 1
#define XSTEP 1

int mandelbrot(float x, float y) {
 float zz;
 float a;
 float b;
 float a2;
 float b2;
 float atemp;
 int i;
  
  a = 0;
  b = 0;  
  i = 0;
  while (i < 15)
  {
    a2 = a * a;
    b2 = b * b;
    zz = a2 + b2;
    if(zz > 4) break;
    
    atemp = a2 - b2 + x;
    b = 2.0 * a * b + y;
    a = atemp;
    i++;
  }
  return i;
}

void drawPixel(int x, int y, int color)
{
  screenMemory[y][x] = color;
}

void main(void) {
  int x, y, data, n;
  int col[16];
  int sm[HEIGHT][WIDTH];
  float sx, sy;
  
  col[0] = 0x01;
  col[1] = 0x02;
  col[2] = 0x03;
  col[3] = 0x07;
  col[4] = 0x0b;
  col[5] = 0x0f;
  col[6] = 0x0e;
  col[7] = 0x0d;
  col[8] = 0x0c;
  col[9] = 0x3c;
  col[10] = 0x38;
  col[11] = 0x34;
  col[12] = 0x30;
  col[13] = 0x20;
  col[14] = 0x10;
  col[15] = 0x00;
   
  for(n = 0; n < 19201; n = n + 1 ) {
    y = rand() % HEIGHT;
    x = rand() % WIDTH;
    
    if(sm[y][x] == 555) n--;
    
    if(sm[y][x] != 555) {    
      sx = -0.7 + (SCALE * (WIDTH/2.0 - x) / (WIDTH/2.0))*(-1);
      sy = (SCALE * (HEIGHT/2.0 - y) / (HEIGHT/2.0))*(-0.75);
      data = mandelbrot(sx, sy);
      drawPixel(x,y,col[data]);
      sm[y][x] = 555;
    }
  }
}
Post Reply