gigatron/rom/Contrib/at67/gbas/demos/Horizon.gbas
2025-01-28 19:17:01 +03:00

90 lines
1.7 KiB
Plaintext

_runtimePath_ "../runtime"
_runtimeStart_ &h26FF
_arraysStart_ &h26FF
_codeRomType_ ROMv1
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