mirror of
https://github.com/KarolS/millfork.git
synced 2024-12-26 12:29:26 +00:00
93 lines
3.6 KiB
Plaintext
93 lines
3.6 KiB
Plaintext
// the emulator supports only 16 sprites:
|
||
const byte SPRITE_COUNT = 16
|
||
array(vera_sprite_data) sprites[SPRITE_COUNT]
|
||
array(sbyte) vx[SPRITE_COUNT]
|
||
array(sbyte) vy[SPRITE_COUNT]
|
||
|
||
import random
|
||
|
||
void main () {
|
||
pointer.vera_sprite_data p
|
||
|
||
byte i,j
|
||
word x,y
|
||
init_rand_seed()
|
||
// make balls striped
|
||
for i,0,parallelto,$1f {
|
||
for j,1,parallelto,$f {
|
||
sprite_bitmap[nonet(j<<5) + i] *= j
|
||
}
|
||
}
|
||
for i,0,paralleluntil,SPRITE_COUNT {
|
||
p = sprites[i].pointer
|
||
// bitmap is at $10000:
|
||
p->address = $800
|
||
p->x.lo = rand()
|
||
p->x.hi = rand() & 1
|
||
p->y = rand()
|
||
// no collision, above all layers, no flipping
|
||
p->ctrl0 = $c
|
||
// 32×32 pixels, different palette offsets
|
||
p->ctrl1 = $a0 | (i & $f)
|
||
vx[i] = 1 - (rand() & 2)
|
||
vy[i] = 1 - (rand() & 2)
|
||
}
|
||
vera_upload_large($10000, sprite_bitmap.addr, sizeof(sprite_bitmap))
|
||
vera_upload_large(VERA_SPRITES, sprites.addr, sizeof(sprites))
|
||
// enable sprites:
|
||
vera_set_sprites_enable(true)
|
||
while true {
|
||
for i,0,paralleluntil,SPRITE_COUNT {
|
||
p = sprites[i].pointer
|
||
x = p->x
|
||
y = p->y
|
||
x += vx[i]
|
||
y += vy[i]
|
||
p->x = x
|
||
p->y = y
|
||
if x == 0 { vx[i] = 1 }
|
||
if x >= 640-32 { vx[i] = 0-1 }
|
||
if y == 0 { vy[i] = 1 }
|
||
if y >= 480-32 { vy[i] = 0-1 }
|
||
}
|
||
vera_upload_large(VERA_SPRITES, sprites.addr, sizeof(sprites))
|
||
}
|
||
}
|
||
|
||
|
||
array sprite_bitmap = [
|
||
$00,$00,$00,$00,$00,$00,$11,$11,$11,$11,$00,$00,$00,$00,$00,$00,
|
||
$00,$00,$00,$00,$01,$11,$11,$11,$11,$11,$11,$10,$00,$00,$00,$00,
|
||
$00,$00,$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,$00,$00,
|
||
$00,$00,$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,$00,$00,
|
||
$00,$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,$00,
|
||
$00,$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,$00,
|
||
$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,
|
||
$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,
|
||
$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,
|
||
$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,
|
||
$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,
|
||
$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,
|
||
$00,$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,$00,
|
||
$00,$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,$00,
|
||
$00,$00,$00,$11,$11,$11,$11,$11,$11,$11,$11,$11,$11,$00,$00,$00,
|
||
$00,$00,$00,$01,$11,$11,$11,$11,$11,$11,$11,$11,$10,$00,$00,$00,
|
||
$00,$00,$00,$00,$01,$11,$11,$11,$11,$11,$11,$10,$00,$00,$00,$00,
|
||
$00,$00,$00,$00,$00,$00,$11,$11,$11,$11,$00,$00,$00,$00,$00,$00
|
||
]
|
||
|