Import Amiga applications and desktop tools
This commit is contained in:
commit
1c144c9a3c
347 files changed
+423483
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
p=Path(__file__).parent/'player.c'
|
||||
s=p.read_text()
|
||||
s=s.replace('static UBYTE *frame,*scaled,*font;','static UBYTE *frame,*scaled,*font,*panel;')
|
||||
s=s.replace('static int bars[24],peak[24],vu[4]','static int bars[24],peak[24],target[24],vu[4]')
|
||||
old='if(t>bars[i])bars[i]=(bars[i]+t*4)/5;else{bars[i]=(bars[i]*2+t)/3;if(bars[i]>t)bars[i]--;}if(bars[i]>peak[i])peak[i]=bars[i];else if(peak[i]>2)peak[i]-=3;else peak[i]=0;'
|
||||
assert old in s
|
||||
s=s.replace(old,'target[i]=t;')
|
||||
helper='''
|
||||
static void drawAudio(void){int i,h,b;for(i=0;i<24;i++){
|
||||
int d=target[i]-bars[i];if(d){int delta=d/(d>0?2:4);if(!delta)delta=d>0?1:-1;bars[i]+=delta;}
|
||||
if(bars[i]>peak[i])peak[i]=bars[i];else if(peak[i]>1)peak[i]-=2;else peak[i]=0;
|
||||
h=bars[i];b=h<70?h:70;if(b)rect(398+i*13,303-b,9,b,6);
|
||||
b=h>112?42:h-70;if(b>0)rect(398+i*13,233-b,9,b,2);
|
||||
if(h>112)rect(398+i*13,303-h,9,h-112,8);
|
||||
if(h)rect(398+i*13,303-h,9,1,9);
|
||||
if(peak[i])rect(398+i*13,302-peak[i],9,1,9);
|
||||
}
|
||||
for(i=0;i<4;i++){rect(382+i*90,504,80,5,4);rect(382+i*90,504,vu[i]*70/64,5,5);}
|
||||
}
|
||||
'''
|
||||
s=s.replace('int main(void)',helper+'\nint main(void)')
|
||||
s=s.replace('frames=0,active=0,dragging=0','frames=0,active=0,dragging=0,dirty=1,lastState=-1')
|
||||
s=s.replace('ULONG cls,lasts=0','ULONG lastSecond=0xffffffff,cls,lasts=0')
|
||||
s=s.replace('frame=malloc(W*H);font=','frame=malloc(W*H);panel=malloc(W*H);font=')
|
||||
s=s.replace('if(!frame||!font||!scaled)','if(!frame||!panel||!font||!scaled)')
|
||||
s=s.replace('ReplyMsg((struct Message*)m);if(cls==IDCMP_CLOSEWINDOW)','ReplyMsg((struct Message*)m);if(cls!=IDCMP_MOUSEMOVE||dragging)dirty=1;if(cls==IDCMP_CLOSEWINDOW)')
|
||||
s=s.replace('frames++;spectrum();','frames++;if(frames%2==0)spectrum();\n if(dirty||seconds!=lastSecond||(hip?hip->play:0)!=lastState){')
|
||||
bar=' for(i=0;i<24;i++){int h=bars[i],px=398+i*13;for(y=0;y<h;y+=3)rect(px,302-y,9,2,y>112?8:y>70?2:6);if(peak[i])rect(px,302-peak[i],9,1,9);}'
|
||||
assert bar in s
|
||||
s=s.replace(bar,'')
|
||||
vu=' for(i=0;i<4;i++){int vv=vu[i]*70/64;rect(382+i*90,504,80,5,4);rect(382+i*90,504,vv,5,5);}'
|
||||
assert vu in s
|
||||
s=s.replace(vu,'')
|
||||
mark=' iw=w->Width-w->BorderLeft-w->BorderRight;'
|
||||
assert mark in s
|
||||
s=s.replace(mark,' memcpy(panel,frame,W*H);dirty=0;lastSecond=seconds;lastState=hip?hip->play:0;}\n memcpy(frame,panel,W*H);drawAudio();\n'+mark)
|
||||
s=s.replace(' Delay(2);',' Delay(1);')
|
||||
s=s.replace('free(frame);free(font);','free(frame);free(panel);free(font);')
|
||||
p.write_text(s)
|
||||
Reference in new issue
Block a user