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

+72
View File
@@ -0,0 +1,72 @@
/*----------------------------------------------------------------------+
| |
| Horizon.c -- Interactive 3D demo in C |
| |
+----------------------------------------------------------------------*/
// Standard includes
#include <stdio.h>
#include <gigatron/sys.h>
#define screenWidth 160
#define screenHeight 120
#define horizonY 32
#define maxPitch (256 - screenWidth) // Aim for max possible pitch at bottom
#define color1 0x3f
#define color2 0x03
#define maxV 32
int main(void)
{
int y, x, i, j, v = 8;
byte *p, *q = &videoTable[240];
#define makeEven(v) (((v) + 1) & ~1) // Odd pitches give jagged edges?
#define calcPitch(y) makeEven((y) + (maxPitch - screenHeight + 1))
// Draw tiles in perspective in screen memory
for (y=screenHeight-1; y>=horizonY; y--) {
int pitch = calcPitch(y);
int width = screenWidth + pitch;
i = (screenWidth/2) % pitch;
j = (400 / (y-horizonY+40)) & 1 ? 0 : color1^color2; // Swap colors
for (x=0; x<width; x++) {
if (i-- == 0)
i = pitch - 1;
screenMemory[y][x] = (i+i >= pitch) ? color1^j : color2^j;
}
videoTop_v5 = y+y; // Safe no-op on ROMs without videoTop
}
videoTop_v5 = 0; // Show all
// Interactive animation
for (x=0; ; x+=v) {
i = x & 255; // Phase i
// Calculate horizontal shift j at horizon
for (y=0,j=0; y<calcPitch(horizonY); y++)
j += i;
// Quickly update videoTable, in steps of 2 pixel lines for more speed
p = &videoTable[horizonY*2+1];
i += i;
// Synchronize with vertical blank
{ byte nextFrame = frameCount + 1;
while (frameCount != nextFrame) /**/ ; }
for (; p<q; p+=4) {
*p = j >> 8; // LCC nicely emits LD vAC+1 for the shift
j = i + (j & 255); // Faster operand order for LCC...
}
// Change speed by game controller or keys
switch (buttonState) {
case buttonRight: if (++v > maxV) v = maxV; break;
case buttonLeft: if (--v < -maxV) v = -maxV; break;
case buttonA: case buttonB: v = 0; break;
}
}
}
+5
View File
@@ -0,0 +1,5 @@
# horizon.ovl
# ------------size----addr----step----end---- flags (1=nocode, 2=nodata)
segments = [ (0x00fa, 0x0200, 0x0100, 0x0500, 0),
(0x0100, 0x0500, None, None, 0),
(0x0060, 0x08a0, 0x0100, 0x80a0, 0) ]
+20
View File
@@ -0,0 +1,20 @@
# compile c programs with GLCC
CC=glcc
# use 32k map modified by overlay horizon.ovl
CFLAGS=-map=32k,./Horizon.ovl -rom=v6
# avoid runtime bss initialization to save code.
LDFLAGS=--no-runtime-bss-init
# target
TARGET=../Horizon_c.gt1
$(TARGET): Horizon.c Horizon.ovl
${CC} ${CFLAGS} ${LDFLAGS} Horizon.c -o $@
clean:
-rm $(TARGET)