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

Binary file not shown.
Binary file not shown.
+90
View File
@@ -0,0 +1,90 @@
_runtimePath_ "../../../Contrib/at67/gbas/runtime"
_runtimeStart_ &h26FF
_arraysStart_ &h26FF
_codeRomType_ ROMv5a
cls
y=0 : x=y : i=x : j=i : a=j : pitch=a : yy=pitch
color1 = &h3F : color2 = &h03 : horizonY = 32
dim c1(3) = &h3F, &h2A, &h15, &h00
dim c2(3) = &h03, &h02, &h01, &h00
fade=0 : cIndex=fade : decay = 54
' Draw tiles in perspective in screen memory
for y=119 downto horizonY
color1 = c1(cIndex) : color2 = c2(cIndex)
inc fade
if fade &&= decay
inc cIndex
fade = 0
decay = decay LSR 1
endif
yy = y
gosub calcPitch
if((400 / (y-horizonY+40)) AND 1) &&= 0
j = color1 XOR color2
else
j = 0
endif
i = 80 % pitch
a = ((y + 8) LSL 8)
for x=0 to pitch + 159
if i &&= 0
i = pitch - 1
else
i = i - 1
endif
if i+i &>= pitch
p = color1 XOR j
else
p = color2 XOR j
endif
poke a+x,p
next x
set VIDEO_TOP, y+y
next y
set VIDEO_TOP, 0
x=0 : v=8
loop: i = x AND 255
j = 0
q = &h0100 + 240
yy = horizonY
gosub calcPitch
for y=0 &to pitch
j = j + i
next y
i = i + i
p = &h0101 + horizonY + horizonY
wait
repeat
poke p, j LSR 8
j = i + (j AND 255)
p = p + 4 : until p &&>= q
gosub get("BUTTON_STATE")
x = x + v
goto loop
254: v = v + 1 : if v &&> 32 then v = 32
return
253: v = v - 1 : if v &&< -32 then v = -32
return
191: v = 0 : return
127: v = 0 : return
calcPitch: pitch = yy + (96 - 120 + 1)
pitch = (pitch + 1) AND &hfffe
return
+18
View File
@@ -0,0 +1,18 @@
GTBASIC=../../../Contrib/at67/tools/gtbasic/gtbasic
GTASM=../../../Contrib/at67/tools/gtasm/gtasm
TARGET=../Horizon_at67.gt1
$(TARGET): Horizon.gt1
cp Horizon.gt1 $@
%.gt1: %.gasm
$(GTASM) $<
%.gasm: %.gbas
$(GTBASIC) $<
clean:
-rm $(TARGET) Horizon.gt1 Horizon.gasm
+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)