Loading...
Searching...
No Matches
main.c File Reference

SA-1 Murmuration Demo — 128 dots in Lissajous sine patterns. More...

#include <snes.h>
#include <snes/sa1.h>

Macros

#define NBIRDS   128
 
#define SA1_STAR_BUF   ((volatile u8*)0x3010)
 
#define SA1_SYNC   (*(volatile u8*)0x3001)
 

Functions

int main (void)
 

Variables

static const u8 dot_tile []
 
static const u16 pal []
 

Detailed Description

SA-1 Murmuration Demo — 128 dots in Lissajous sine patterns.

The SA-1 computes 128 "bird" positions using overlapping Lissajous sine patterns at 10.74 MHz. The main CPU reads positions from I-RAM and displays them as pixel sprites. No assets — generated in code.

Each bird's position is the sum of two sine harmonics per axis, with prime-number phase multipliers creating organic flock spread: X = sin[bird*3 + frame]/2 + sin[bird*7 + frame*2]/4 + 32 Y = sin[bird*5 + frame+64]/2 + sin[bird*11 + frame*3]/4 + 16

What to Observe
  • 128 dots moving in smooth, coordinated flock-like patterns
  • The pattern resembles a murmuration (starling flock)
  • All math computed by SA-1 coprocessor at 10.74 MHz
Modules Used
console, sprite, dma, background, input, sa1

Macro Definition Documentation

◆ NBIRDS

#define NBIRDS   128

◆ SA1_STAR_BUF

#define SA1_STAR_BUF   ((volatile u8*)0x3010)

◆ SA1_SYNC

#define SA1_SYNC   (*(volatile u8*)0x3001)

Function Documentation

◆ main()

int main ( void  )

Variable Documentation

◆ dot_tile

const u8 dot_tile[]
static
Initial value:
= {
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x18, 0x18,
0x18, 0x18,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x18, 0x18,
0x18, 0x18,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
}

2x2 pixel dot tile (4bpp, 8x8, pixels 3-4 on rows 3-4)

◆ pal

const u16 pal[]
static
Initial value:
= {
0x0000, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
0x0000, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318,
0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318, 0x6318,
0x0000, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210,
0x4210, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210, 0x4210,
0x0000, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108,
0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108,
}

Sprite palettes: 4 brightness levels for depth illusion