1 line
36 KiB
Plaintext
1 line
36 KiB
Plaintext
|
' This cog takes care of the smooth scrolling and animates animated objects.
' Also:
' - flashes the screen when the game target is reached
' - signals about new life with random background pattern
var
long x, y, nx, ny
long scroll_addr
long tile_addr
long palette_addr
long stack[12]
long rockford_dir
long random_addr
long vsync_addr
byte flash_cnt
byte new_life_cnt
byte tapping
byte blinking
byte wall_milling
pub start(video_params, rnd_addr)
x := 0
y := 0
vsync_addr := long[video_params + constant(6 * 4)]
random_addr := rnd_addr
palette_addr := long[video_params + constant(5 * 4)] + constant(40 * 28)
scroll_addr := palette_addr + 4
tile_addr := scroll_addr + constant(4 + 4 + 20 * 2)
rockford_dir := 0
flash_cnt := 0
new_life_cnt := 0
blinking := 0
tapping := 0
wall_milling := 0
cognew(process, @stack)
pub scroll_to(sx, sy)
nx := sx
ny := sy
pub rockford_reset
blinking := 0
tapping := 0
pub rockford_go(dir)
rockford_dir := dir
if rockford_dir <> 0
blinking := 0
tapping := 0
pub flash
flash_cnt := 6
pub new_life
new_life_cnt := 400
pub milling_on
wall_milling := 1
pub milling_off
wall_milling := 0
pub process | i, n, cp, temp
n := 0
i := 0
repeat
'wait for vsync
repeat while byte[vsync_addr] == 0
repeat while byte[vsync_addr] <> 0
if x <> nx or y <> ny
if x > nx
x := x - 1
elseif x < nx
x := x + 1
if y > ny
y := y - 2
elseif y < ny
y := y + 2
long[scroll_addr] := (x << 16) + y
if i == 0
'rockford
if rockford_dir > 0
cp := @rockford_right + n
elseif rockford_dir < 0
cp := @rockford_left + n
else
cp := @rockford
if n == 0
if (byte[random_addr] & $03) == 0
blinking := 1
else
blinking := 0
if (byte[random_addr] & $0F) == 0
tapping ^= 1
ifnot blinking or tapping
wordmove(tile_addr + constant(32 * $38), cp, 16)
wordmove(tile_addr + constant(32 * $39), cp, 16)
else
if blinking
cp := @rockford_bored + n
wordmove(tile_addr + constant(32 * $38), cp, 8) ' top part only
wordmove(tile_addr + constant(32 * $39), cp, 8)
if tapping
cp := @rockford_bored + 16 + n
wordmove(tile_addr + constant(32 * $38 + 16), cp, 8) ' bottom part only
wordmove(tile_addr + constant(32 * $39 + 16), cp, 8)
' diamonds
cp := @diamonds + n
wordmove(tile_addr + constant(32 * $14), cp, 16) ' update all 4 variants
wordmove(tile_addr + constant(32 * $15), cp, 16)
wordmove(tile_addr + constant(32 * $16), cp, 16)
wordmove(tile_addr + constant(32 * $17), cp, 16)
' fireflies
cp := @firefly + n
wordmove(tile_addr + constant(32 * $08), cp, 16) ' update all 8 variants
wordmove(tile_addr + constant(32 * $09), cp, 16)
wordmove(tile_addr + constant(32 * $0A), cp, 16)
wordmove(tile_addr + constant(32 * $0B), cp, 16)
wordmove(tile_addr + constant(32 * $0C), cp, 16)
wordmove(tile_addr + constant(32 * $0D), cp, 16)
wordmove(tile_addr + constant(32 * $0E), cp, 16)
wordmove(tile_addr + constant(32 * $0F), cp, 16)
' butterflies
cp := @butterfly + n
wordmove(tile_addr + constant(32 * $30), cp, 16) ' update all 8 variants
wordmove(tile_addr + constant(32 * $31), cp, 16)
wordmove(tile_addr + constant(32 * $32), cp, 16)
wordmove(tile_addr + constant(32 * $33), cp, 16)
wordmove(tile_addr + constant(32 * $34), cp, 16)
wordmove(tile_addr + constant(32 * $35), cp, 16)
wordmove(tile_addr + constant(32 * $36), cp, 16)
wordmove(tile_addr + constant(32 * $37), cp, 16)
' amoeba
cp := @amoeba + n
wordmove(tile_addr + constant(32 * $3A), cp, 16)
wordmove(tile_addr + constant(32 * $3B), cp, 16)
' magic wall
|