#!/bin/sh
cat>c.c<<E
int i(int,int);int s(char,char,char);int l(char);
main(){
__asm__("ld a,#0\ncall 0xbc0e");
char x,y,o=0;
l(o);
for(y=0;y<200;++y)for(x=0;x<160;++x)s(x,y,x%16);
while(1) l(o=(o-1)%16);
}
s(char x,char y,char c){
char* a=0xc000+(y/8*80)+(2048*(y%8))+x/2;
char p=*a;
if(x%2)p=(c&1?64:0)|(c&4?16:0)|(c&2?4:0)|(c&8?1:0)|(p&0xaa);
else p=(c&1?128:0)|(c&4?32:0)|(c&2?8:0)|(c&8?2:0)|(p&0x55);
*a=p;
}
i(int p,int c){
__asm__("ld a,e\nld b,l\nld c,b\ncall 0xbc32");
}
l(char o){
__asm__("call 0xbd19");
for(char p=0;p<16;++p)i(p,(p+o)%16);
}
E
sdcc -mz80 --code-loc 0x1200 --no-std-crt0 c.c
makebin -p c.ihx|tail -c +4609>c.
iDSK c.dsk -n -i c. -e 1200 -c 1200
mame cpc664 -flop1 c.dsk -skip_gameinfo -ab '\n\nrun"c\n'
