init repo

This commit is contained in:
RomanRom2 committed 2025-01-28 19:17:01 +03:00
commit 90e6151613
3260 files changed
+3745062

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
ROM=dev7
MAP=32k
B=../../build/
CC=${B}glcc
GTSIM=${B}gtsim -rom ../../gigatron/roms/${ROM}.rom
GTPROF=${B}/../gigatron/mapsim/gtprof
PGMS=ascbrot.gt1 ascjulia.gt1 gfxbrotx.gt1 gfxjuliax.gt1
all:${PGMS}
%.gt1: %.c
${CC} -rom=${ROM} -map=${MAP} $< -o $@
%.prof: %.c
${CC} -rom=${ROM} -map=sim,hionly $< -o $*-sim.gt1 --frags > $*-sim.frg
-${GTSIM} -prof $*-sim.prf $*-sim.gt1
${GTPROF} $*-sim.prf $*-sim.frg | sort -nr > $@
clean: FORCE
-rm *.gt1 *.prf *.frg *.prof
FORCE:
+65
View File
@@ -0,0 +1,65 @@
/*----------------------------------------------------------------------+
| |
| ascbrot.c -- demonstrate fractal in text / 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>
#define HEIGHT 15
#define WIDTH 26
#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 = 48;
while (i < 58)
{
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 main(void) {
int x, y, data;
float sx, sy;
for(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
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);
console_state.cx = x;
console_state.cy = y;
console_state.fgbg = (((data-48)*6+1) & 0x3f) << 8;
console_print((char*)&data, 1);
}
}
}
@@ -0,0 +1,67 @@
/*----------------------------------------------------------------------+
| |
| ascjulia.c -- demonstrate fractal in text / 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>
#define HEIGHT 15
#define WIDTH 26
#define SCALE 1.7
#define YSTEP 1
#define XSTEP 1
#define CX -0.8
#define CY 0.156
int julia(float x, float y) {
float zz;
float a;
float b;
float a2;
float b2;
float atemp;
int i;
a = x;
b = y;
i = 48;
while (i < 58)
{
a2 = a * a;
b2 = b * b;
zz = a2 + b2;
if(zz > 4) break;
atemp = a2 - b2 + CX;
b = 2.0 * a * b + CY;
a = atemp;
i++;
}
return i;
}
void main(void) {
int x, y, data;
float sx, sy;
for(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
sx = (SCALE * (WIDTH/2.0 - x) / (WIDTH/2.0))*(-1);
sy = (SCALE * (HEIGHT/2.0 - y) / (HEIGHT/2.0))*(-0.75);
data = julia(sx, sy);
console_state.cx = x;
console_state.cy = y;
console_state.fgbg = (((data-48)*6+1) & 0x3f) << 8;
console_print((char*)&data, 1);
}
}
}
+86
View File
@@ -0,0 +1,86 @@
/*----------------------------------------------------------------------+
| |
| gfxbrot.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;
int col[16];
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(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
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]);
}
}
}
@@ -0,0 +1,70 @@
/*----------------------------------------------------------------------+
| |
| gfxbrotx.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 < 63)
{
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;
int col;
float sx, sy;
for(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
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);
col = 63 - data;
drawPixel(x,y,col);
}
}
}
@@ -0,0 +1,88 @@
/*----------------------------------------------------------------------+
| |
| gfxjulia.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.7
#define YSTEP 1
#define XSTEP 1
#define CX -0.8
#define CY 0.156
int julia(float x, float y) {
float zz;
float a;
float b;
float a2;
float b2;
float atemp;
int i;
a = x;
b = y;
i = 0;
while (i < 15)
{
a2 = a * a;
b2 = b * b;
zz = a2 + b2;
if(zz > 4) break;
atemp = a2 - b2 + CX;
b = 2.0 * a * b + CY;
a = atemp;
i++;
}
return i;
}
void drawPixel(int x, int y, int color)
{
screenMemory[y][x] = color;
}
void main(void) {
int x, y, data;
int col[16];
float sx, sy;
col[14] = 0x01;
col[13] = 0x02;
col[12] = 0x03;
col[11] = 0x07;
col[10] = 0x0b;
col[9] = 0x0f;
col[8] = 0x0e;
col[7] = 0x0d;
col[6] = 0x0c;
col[5] = 0x3c;
col[4] = 0x38;
col[3] = 0x34;
col[2] = 0x30;
col[1] = 0x20;
col[0] = 0x10;
col[15] = 0x00;
for(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
sx = (SCALE * (WIDTH/2.0 - x) / (WIDTH/2.0))*(-1);
sy = (SCALE * (HEIGHT/2.0 - y) / (HEIGHT/2.0))*(-0.75);
data = julia(sx, sy);
drawPixel(x,y,col[data]);
}
}
}
@@ -0,0 +1,72 @@
/*----------------------------------------------------------------------+
| |
| gfxjuliax.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.7
#define YSTEP 1
#define XSTEP 1
#define CX -0.8
#define CY 0.156
int julia(float x, float y) {
float zz;
float a;
float b;
float a2;
float b2;
float atemp;
int i;
a = x;
b = y;
i = 0;
while (i < 63)
{
a2 = a * a;
b2 = b * b;
zz = a2 + b2;
if(zz > 4) break;
atemp = a2 - b2 + CX;
b = 2.0 * a * b + CY;
a = atemp;
i++;
}
return i;
}
void drawPixel(int x, int y, int color)
{
screenMemory[y][x] = color;
}
void main(void) {
int x, y, data;
int col;
float sx, sy;
for(y = 0; y < HEIGHT; y = y + YSTEP ) {
for(x = 0; x < WIDTH; x = x + XSTEP ) {
sx = (SCALE * (WIDTH/2.0 - x) / (WIDTH/2.0))*(-1);
sy = (SCALE * (HEIGHT/2.0 - y) / (HEIGHT/2.0))*(-0.75);
data = julia(sx, sy);
col = 63 - data;
drawPixel(x,y,col);
}
}
}