Import Amiga applications and desktop tools

This commit is contained in:
Alberto committed 2026-11-11 16:21:50 +01:00
commit 1c144c9a3c
347 files changed
+423483

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
# Desktop toolkit
Script originali per icone, ordinamento drawer, tema desktop, dock, anteprime e configurazione di avvio. Conservano i percorsi della macchina originale: leggere lo script prima di riutilizzarlo. Nessuna immagine disco o configurazione personale inclusa.
+9
View File
@@ -0,0 +1,9 @@
from pathlib import Path
base=Path('C:/Amiga/HD0/S')
s=Path('work/boot040/Startup-Sequence.before').read_text()
checks=['C:SetPatch QUIET','C:CPU CHECKINSTALL','C:Mount >NIL: DEVS:DOSDrivers/~(#?.info)','C:IPrefs',' Execute S:User-Startup','C:Mount DEVS:DOSDrivers/VNC >NIL:','C:LoadWB']
for n,line in enumerate(checks):
s=s.replace(line,line+'\nEcho "Check '+str(n)+': $RC" >>HD0:Boot-Audit.log')
s=s.replace('C:LoadWB\n','C:CPU >HD0:CPU040.log\nC:Version 68040.library FULL >>HD0:CPU040.log\nC:LoadWB\n')
s='Echo "Boot audit" >HD0:Boot-Audit.log\n'+s
(base/'Startup-Sequence').write_bytes(s.encode('ascii'))
+13
View File
@@ -0,0 +1,13 @@
from pathlib import Path
base=Path('C:/Amiga/HD0/S')
s=Path('work/boot040/User-Startup.before').read_text()
lines=s.splitlines()
out=['Echo "User startup audit" >HD0:User-Audit.log']
for n,line in enumerate(lines):
out.append(line)
if line.strip().lower().startswith(('assign ','path ','amitcp:bin/umask','version ')):
out.append('Echo "Line '+str(n+1)+': $RC" >>HD0:User-Audit.log')
(base/'User-Startup').write_bytes(('\n'.join(out)+'\n').encode('ascii'))
s=(base/'Startup-Sequence').read_text()
s=s.replace('C:Mount >NIL: DEVS:DOSDrivers/~(#?.info)','C:Mount DEVS:DOSDrivers/~(#?.info) >HD0:Mount-error.log')
(base/'Startup-Sequence').write_bytes(s.encode('ascii'))
+14
View File
@@ -0,0 +1,14 @@
from pathlib import Path
base=Path('C:/Amiga/HD0/S')
s=Path('work/boot040/Startup-Sequence.before').read_text()
s=s.replace('DEVS:DOSDrivers/~(#?.info)','DEVS:DOSDrivers/~(#?.info|#?.uaem)')
s=s.replace('DEVS:Monitors/~(#?.info|VGAOnly)','DEVS:Monitors/~(#?.info|#?.uaem|VGAOnly)')
s=s.replace('C:Mount DEVS:DOSDrivers/VNC >NIL:\n','')
Path('work/boot040/Startup-Sequence.fixed').write_bytes(s.encode('ascii'))
for n,line in enumerate(['C:SetPatch QUIET','C:CPU CHECKINSTALL','C:Mount >NIL: DEVS:DOSDrivers/~(#?.info|#?.uaem)',' Execute S:User-Startup','C:LoadWB']):
s=s.replace(line,line+'\nEcho "Check '+str(n)+': $RC" >>HD0:Boot-Fixed.log')
s=s.replace(' Execute S:User-Startup',' Echo "Monitors-result: $RC" >>HD0:Boot-Fixed.log\n Execute S:User-Startup')
s=s.replace('C:LoadWB\n','C:CPU >HD0:CPU040.log\nC:Version 68040.library FULL >>HD0:CPU040.log\nC:LoadWB\n')
s='Echo "Fixed boot audit" >HD0:Boot-Fixed.log\n'+s
(base/'Startup-Sequence').write_bytes(s.encode('ascii'))
(base/'User-Startup').write_bytes(Path('work/boot040/User-Startup.before').read_text().encode('ascii'))
+13
View File
@@ -0,0 +1,13 @@
from pathlib import Path
import zipfile,io
p=Path('C:/Users/Public/Documents/Amiga Files/Titles/Systems/Alberto2 (Commodore-Amiga, 1992, Amiga).rp9')
z=zipfile.ZipFile(io.BytesIO(p.read_bytes()))
out=io.BytesIO()
with zipfile.ZipFile(out,'w') as w:
for i in z.infolist():
data=z.read(i.filename)
if i.filename=='rp9-manifest.xml':
assert b'type="68030"' in data
data=data.replace(b'type="68030"',b'type="68040"')
w.writestr(i,data)
p.write_bytes(out.getvalue())
+16
View File
@@ -0,0 +1,16 @@
Add-Type -AssemblyName System.Drawing
Add-Type -ReferencedAssemblies System.Drawing -TypeDefinition @'
using System;using System.IO;
public class CliIcon {
const int W=64,H=40;
static void R(byte[,]p,int x,int y,int w,int h,byte c){for(int j=y;j<y+h;j++)for(int i=x;i<x+w;i++)p[j,i]=c;}
static byte[,] P(bool sel){var p=new byte[H,W];R(p,3,3,59,35,2);R(p,1,1,60,35,3);R(p,2,2,58,33,0);R(p,3,3,56,6,3);R(p,4,10,54,23,2);R(p,5,4,2,2,2);R(p,8,4,2,2,2);R(p,11,4,2,2,2);R(p,7,14,2,2,1);R(p,9,16,2,2,1);R(p,7,18,2,2,1);R(p,13,19,7,1,3);R(p,7,24,27,1,3);R(p,7,27,18,1,3);R(p,38,24,12,1,0);R(p,38,27,8,1,0);if(sel){R(p,1,1,60,1,1);R(p,1,1,1,35,1);}return p;}
static void U16(BinaryWriter w,int n){w.Write((byte)(n>>8));w.Write((byte)n);}static void U32(BinaryWriter w,int n){w.Write((byte)(n>>24));w.Write((byte)(n>>16));w.Write((byte)(n>>8));w.Write((byte)n);}static void S(BinaryWriter w,string s){var b=System.Text.Encoding.ASCII.GetBytes(s+"\0");U32(w,b.Length);w.Write(b);}
static void Img(BinaryWriter w,byte[,]p){U16(w,0);U16(w,0);U16(w,W);U16(w,H);U16(w,2);w.Write(new byte[]{0,0,0,1,3,0,0,0,0,0});for(int q=0;q<2;q++)for(int y=0;y<H;y++)for(int x=0;x<W;x+=8){byte b=0;for(int i=0;i<8;i++)if((p[y,x+i]&(1<<q))!=0)b|=(byte)(128>>i);w.Write(b);}}
public static void Make(string template,string output){var h=new byte[78];Array.Copy(File.ReadAllBytes(template),h,78);h[12]=0;h[13]=W;h[14]=0;h[15]=H;h[16]=0;h[17]=6;h[48]=4;foreach(int p in new[]{22,26,50,54}){for(int k=0;k<4;k++)h[p+k]=0;h[p+3]=1;}foreach(int p in new[]{44,66,70})for(int k=0;k<4;k++)h[p+k]=0;using(var f=File.Create(output))using(var w=new BinaryWriter(f)){w.Write(h);Img(w,P(false));Img(w,P(true));S(w,"SYS:System/CLI");U32(w,16);S(w,"WINDOW=VNC:80/90/900/580/Amber CLI/SHELL/CLOSE");S(w,"STACK=16384");S(w,"FROM=S:Shell-Startup");}}}
'@
[CliIcon]::Make('C:\Amiga\HD0\System\Shell.info','C:\Amiga\HD0\Utilities\WBDock2\CLI.info')
[IO.File]::WriteAllText('C:\Amiga\HD0\Utilities\WBDock2\CLI','',[Text.Encoding]::ASCII)
$p='C:\Amiga\HD0\Utilities\WBDock2\Amber.config'
$s=[IO.File]::ReadAllText($p).Replace('SYS:System/Shell','SYS:Utilities/WBDock2/CLI')
[IO.File]::WriteAllText($p,$s,[Text.Encoding]::ASCII)
+22
View File
@@ -0,0 +1,22 @@
from pathlib import Path
from PIL import Image
import struct
def chunk(tag,data):
return tag+struct.pack('>I',len(data))+data+(b'\0' if len(data)%2 else b'')
def preview(src,dest):
im=Image.open(src).convert('RGB').resize((320,256),Image.Resampling.LANCZOS).quantize(colors=64)
w,h=im.size
pixels=im.load()
body=bytearray()
for y in range(h):
for plane in range(6):
for x in range(0,w,8):
body.append(sum(((pixels[x+i,y]>>plane)&1)<<(7-i) for i in range(8)))
bmhd=struct.pack('>HHhhBBBBHBBhh',w,h,0,0,6,0,0,0,0,1,1,w,h)
payload=b'ILBM'+chunk(b'BMHD',bmhd)+chunk(b'CMAP',bytes(im.getpalette()[:192]))+chunk(b'BODY',body)
Path(dest).write_bytes(chunk(b'FORM',payload))
preview('work/igame/cannon-shot.png','C:/Amiga/WHDLoad/CannonFodderITA/igame.iff')
preview('work/igame/pinball-shot.png','C:/Amiga/WHDLoad/PinballFantasies_v2.7_0025/PinballFntsies/igame.iff')
+35
View File
@@ -0,0 +1,35 @@
$ErrorActionPreference='Stop'
Add-Type -AssemblyName System.Drawing
Add-Type -ReferencedAssemblies System.Drawing -TypeDefinition @'
using System;using System.IO;using System.Drawing;
public class AmberClockIcon {
const int W=48,H=48;
static void Dot(byte[,]p,int x,int y,byte c){if(x>=0&&x<W&&y>=0&&y<H)p[y,x]=c;}
static void Line(byte[,]p,int x0,int y0,int x1,int y1,byte c){int dx=Math.Abs(x1-x0),sx=x0<x1?1:-1,dy=-Math.Abs(y1-y0),sy=y0<y1?1:-1,e=dx+dy;while(true){Dot(p,x0,y0,c);if(x0==x1&&y0==y1)break;int e2=2*e;if(e2>=dy){e+=dy;x0+=sx;}if(e2<=dx){e+=dx;y0+=sy;}}}
static byte[,] Pixels(bool selected){var p=new byte[H,W];
for(int y=4;y<46;y++)for(int x=5;x<46;x++)if((x-25)*(x-25)+(y-25)*(y-25)<=400)Dot(p,x,y,2);
for(int y=1;y<=43;y++)for(int x=2;x<=44;x++){double d=Math.Sqrt((x-23)*(x-23)+(y-22)*(y-22));if(d<=21){byte c=2;if(d>19)c=(byte)((x+y<45||selected)?1:2);else if(d>16)c=3;Dot(p,x,y,c);}}
for(int t=0;t<12;t++){double a=t*Math.PI/6;int r0=t%3==0?12:14;Line(p,23+(int)Math.Round(Math.Sin(a)*r0),22-(int)Math.Round(Math.Cos(a)*r0),23+(int)Math.Round(Math.Sin(a)*15),22-(int)Math.Round(Math.Cos(a)*15),(byte)(t%3==0?1:3));}
Line(p,23,22,15,15,1);Line(p,23,23,15,16,1);
Line(p,23,22,34,13,1);Line(p,24,22,35,13,1);
Line(p,23,22,26,35,3);Line(p,23,22,22,18,3);
Dot(p,23,22,1);Dot(p,24,22,1);Dot(p,23,23,1);
for(int y=43;y<=45;y++)for(int x=15;x<=31;x++)Dot(p,x,y,(byte)(y==43?3:2));
Line(p,12,46,34,46,3);Line(p,14,45,32,45,1);
return p;}
static int Word(byte[]b,int o){return b[o]*256+b[o+1];}
static uint Long(byte[]b,int o){return ((uint)b[o]<<24)|((uint)b[o+1]<<16)|((uint)b[o+2]<<8)|b[o+3];}
static void U16(BinaryWriter w,int v){w.Write((byte)(v>>8));w.Write((byte)v);}
static void Image(BinaryWriter w,byte[,]p){U16(w,0);U16(w,0);U16(w,W);U16(w,H);U16(w,2);w.Write(new byte[]{0,0,0,1,3,0,0,0,0,0});for(int plane=0;plane<2;plane++)for(int y=0;y<H;y++)for(int b=0;b<6;b++){byte v=0;for(int bit=0;bit<8;bit++)if((p[y,b*8+bit]&(1<<plane))!=0)v|=(byte)(128>>bit);w.Write(v);}}
public static void Make(string source,string output,string preview){var old=File.ReadAllBytes(source);int end=78;if(Long(old,66)!=0)throw new Exception("Clock icon unexpectedly has drawer data");foreach(int ptr in new[]{22,26})if(Long(old,ptr)!=0){bool next;do{int width=Word(old,end+4),height=Word(old,end+6),depth=Word(old,end+8);next=Long(old,end+16)!=0;end+=20+((width+15)/16)*2*height*depth;}while(next);}
var header=new byte[78];Array.Copy(old,header,78);header[12]=0;header[13]=W;header[14]=0;header[15]=H;header[16]=0;header[17]=6;foreach(int ptr in new[]{22,26}){for(int k=0;k<4;k++)header[ptr+k]=0;header[ptr+3]=1;}for(int k=0;k<4;k++)header[44+k]=0;
using(var f=File.Create(output))using(var w=new BinaryWriter(f)){w.Write(header);Image(w,Pixels(false));Image(w,Pixels(true));w.Write(old,end,old.Length-end);}
Color[]colors={Color.FromArgb(53,50,44),Color.FromArgb(228,213,181),Color.FromArgb(25,23,19),Color.FromArgb(169,111,39)};
var pix=Pixels(false);using(var im=new Bitmap(W*6,H*6)){using(var g=Graphics.FromImage(im)){for(int y=0;y<H;y++)for(int x=0;x<W;x++)using(var br=new SolidBrush(colors[pix[y,x]]))g.FillRectangle(br,x*6,y*6,6,6);}im.Save(preview);}
}}
'@
$path='C:\Amiga\HD0\Utilities\Clock.info'
Copy-Item $path 'C:\Amiga\backup-riparazione-20261030\Clock-prima-icona-ambra.info'
[AmberClockIcon]::Make($path,'C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\Clock-Amber.info','C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\Clock-Amber-preview.png')
Copy-Item 'C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\Clock-Amber.info' $path
Copy-Item $path 'C:\Amiga\Snapshots\Alberto2-Amber\HD0\Utilities\Clock.info'
+40
View File
@@ -0,0 +1,40 @@
$ErrorActionPreference='Stop'
Add-Type -AssemblyName System.Drawing
Add-Type -ReferencedAssemblies System.Drawing -TypeDefinition @'
using System;using System.IO;using System.Drawing;
public class RamIcon {
const int W=64,H=32;
static void Rect(byte[,] p,int x,int y,int w,int h,byte c){for(int yy=y;yy<y+h;yy++)for(int xx=x;xx<x+w;xx++)p[yy,xx]=c;}
static byte[,] Pixels(bool selected){var p=new byte[H,W];
// A compact vintage SIMM: stepped PCB silhouette, four ICs, gold contacts.
Rect(p,3,6,58,20,2);Rect(p,5,4,54,24,2);
Rect(p,5,5,54,1,1);Rect(p,4,7,1,16,1);
Rect(p,6,7,52,16,0);Rect(p,6,22,52,2,3);
Rect(p,58,7,2,17,3);
for(int chip=0;chip<4;chip++){int x=9+chip*12;
Rect(p,x,9,10,11,2);Rect(p,x+1,9,8,1,(byte)(selected?3:1));
Rect(p,x+1,10,8,8,2);Rect(p,x+2,12,4,1,0);
for(int pin=0;pin<3;pin++){Rect(p,x-1,11+pin*3,1,1,3);Rect(p,x+10,11+pin*3,1,1,3);}
}
for(int x=9;x<=54;x+=4){if(x>=29&&x<=33)continue;Rect(p,x,25,2,5,3);Rect(p,x,25,1,4,(byte)(selected?1:3));}
Rect(p,29,24,5,6,2);Rect(p,30,25,3,5,0);
Rect(p,6,25,2,2,1);Rect(p,56,25,2,2,1);
return p;}
static void U16(BinaryWriter w,int v){w.Write((byte)(v>>8));w.Write((byte)v);}
static void Image(BinaryWriter w,byte[,] p){U16(w,0);U16(w,0);U16(w,W);U16(w,H);U16(w,2);w.Write(new byte[]{0,0,0,1});w.Write((byte)3);w.Write((byte)0);w.Write(new byte[4]);for(int plane=0;plane<2;plane++)for(int y=0;y<H;y++)for(int b=0;b<8;b++){byte v=0;for(int bit=0;bit<8;bit++)if((p[y,b*8+bit]&(1<<plane))!=0)v|=(byte)(128>>bit);w.Write(v);}}
public static void Make(string original,string output,string preview){var old=File.ReadAllBytes(original);var header=new byte[134];Array.Copy(old,header,134);
header[12]=0;header[13]=W;header[14]=0;header[15]=H;header[16]=0;header[17]=6;
for(int o=22;o<=26;o+=4){for(int k=0;k<4;k++)header[o+k]=0;header[o+3]=1;}
foreach(int o in new[]{44,50,54,70})for(int k=0;k<4;k++)header[o+k]=0;
header[58]=0;header[59]=0;header[60]=0;header[61]=29;
header[62]=0;header[63]=0;header[64]=0;header[65]=18;
var normal=Pixels(false);using(var f=File.Create(output))using(var w=new BinaryWriter(f)){w.Write(header);Image(w,normal);Image(w,Pixels(true));}
Color[] colors={Color.FromArgb(53,50,44),Color.FromArgb(228,213,181),Color.FromArgb(25,23,19),Color.FromArgb(169,111,39)};
using(var im=new Bitmap(W*6,H*6)){using(var g=Graphics.FromImage(im)){for(int y=0;y<H;y++)for(int x=0;x<W;x++)using(var brush=new SolidBrush(colors[normal[y,x]]))g.FillRectangle(brush,x*6,y*6,6,6);}im.Save(preview);}
}}
'@
$old='C:\Amiga\HD0\Prefs\Env-Archive\Sys\def_RAM.info'
Copy-Item $old 'C:\Amiga\backup-riparazione-20261030\RAM-prima-modulo-ambra.info'
[RamIcon]::Make($old,'C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\RamDisk-Amber.info','C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\RamDisk-Amber-preview.png')
Copy-Item 'C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\RamDisk-Amber.info' $old
Copy-Item $old 'C:\Amiga\Snapshots\Alberto2-Amber\HD0\Prefs\Env-Archive\Sys\def_RAM.info'
+48
View File
@@ -0,0 +1,48 @@
$ErrorActionPreference='Stop'
Add-Type -AssemblyName System.IO.Compression.FileSystem
$root='C:\Amiga'
$backup='C:\Amiga\backup-riparazione-20261030\drawer-prima-riordino.zip'
if(Test-Path -LiteralPath $backup){throw 'Backup già presente: non sovrascrivo'}
$files=@(foreach($volume in @('HD0','Share','WHDLoad')){Get-ChildItem -LiteralPath (Join-Path $root $volume) -Recurse -File -Filter '*.info'})
$zip=[IO.Compression.ZipFile]::Open($backup,'Create')
try{foreach($f in $files){[IO.Compression.ZipFileExtensions]::CreateEntryFromFile($zip,$f.FullName,$f.FullName.Substring($root.Length+1).Replace('\','/'))|Out-Null}}finally{$zip.Dispose()}
function Put16($b,$o,$v){$b[$o]=[byte](($v -shr 8)-band 255);$b[$o+1]=[byte]($v-band 255)}
function Put32($b,$o,$v){$b[$o]=[byte](($v-shr 24)-band 255);$b[$o+1]=[byte](($v-shr 16)-band 255);$b[$o+2]=[byte](($v-shr 8)-band 255);$b[$o+3]=[byte]($v-band 255)}
$records=@(foreach($f in $files){
$b=[IO.File]::ReadAllBytes($f.FullName)
if($b.Length-lt 78 -or $b[0]-ne 227 -or $b[1]-ne 16){continue}
$object=$f.FullName.Substring(0,$f.FullName.Length-5)
$isDisk=$f.Name-ieq 'Disk.info'
if(-not $isDisk -and -not(Test-Path -LiteralPath $object)){continue}
$drawerPointer=($b[66]-bor $b[67]-bor $b[68]-bor $b[69])-ne 0
[pscustomobject]@{Path=$f.FullName;Name=[IO.Path]::GetFileName($object);Parent=$f.DirectoryName;IsDisk=$isDisk;IsDirectory=(Test-Path -LiteralPath $object -PathType Container);Bytes=$b;Original=$b.Clone();Drawer=($drawerPointer -and $b.Length-ge 134 -and $b[48]-in @(1,2));W=($b[12]*256+$b[13]);H=($b[14]*256+$b[15]);Changed=$false}
})
$leftOut=@{}
foreach($v in @('HD0','Share','WHDLoad')){
$bp=Join-Path $root "$v\.backdrop"
if(Test-Path -LiteralPath $bp){foreach($line in [IO.File]::ReadAllLines($bp)){if($line.StartsWith(':')){$leftOut[(Join-Path $root ($v+'\'+$line.Substring(1).Replace('/','\')+'.info'))]=$true}}}
}
$groups=0
foreach($group in ($records|Where-Object {-not $_.IsDisk -and -not $leftOut.ContainsKey($_.Path)}|Group-Object Parent)){
$ordered=@($group.Group|Sort-Object @{Expression={-not $_.IsDirectory}},Name)
$cellW=150;$cellH=88
foreach($r in $ordered){$cellW=[Math]::Max($cellW,[Math]::Max($r.Name.Length*8+24,$r.W+24));$cellH=[Math]::Max($cellH,$r.H+30)}
$columns=[Math]::Max(1,[Math]::Floor(940/$cellW));$i=0
foreach($r in $ordered){Put32 $r.Bytes 58 (20+($i%$columns)*$cellW);Put32 $r.Bytes 62 (14+[Math]::Floor($i/$columns)*$cellH);$r.Changed=$true;$i++}
$groups++
}
$windows=0
foreach($r in $records){if($r.Drawer){
Put16 $r.Bytes 78 80;Put16 $r.Bytes 80 55;Put16 $r.Bytes 82 1000;Put16 $r.Bytes 84 720
Put32 $r.Bytes 126 0;Put32 $r.Bytes 130 0
$r.Changed=$true;$windows++
}}
$allowed=@(58..65)+@(78..85)+@(126..133)
$changed=0
foreach($r in $records|Where-Object Changed){
for($i=0;$i-lt $r.Bytes.Length;$i++){if($r.Bytes[$i]-ne $r.Original[$i] -and $i-notin $allowed){throw "Modifica fuori dai campi posizione: $($r.Path), $i"}}
[IO.File]::WriteAllBytes($r.Path,$r.Bytes)
if(-not [Linq.Enumerable]::SequenceEqual([byte[]][IO.File]::ReadAllBytes($r.Path),[byte[]]$r.Bytes)){throw "Verifica scrittura fallita: $($r.Path)"}
$changed++
}
[pscustomobject]@{Backup=$backup;BackupIcons=$files.Count;OrderedDirectories=$groups;SavedWindows=$windows;UpdatedIcons=$changed}|ConvertTo-Json
+62
View File
@@ -0,0 +1,62 @@
$ErrorActionPreference='Stop'
Add-Type -AssemblyName System.Drawing
$src=[Drawing.Image]::FromFile('C:\Users\tilar\.codex\generated_images\01a18c54-cbcf-72e0-985c-3c5d721eb505\exec-8c844b57-8586-4f14-9cd4-3035f1ad4f34.png')
$dst=[Drawing.Bitmap]::new(1280,1024)
$g=[Drawing.Graphics]::FromImage($dst)
$g.InterpolationMode=[Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic
$g.DrawImage($src,0,0,1280,1024)
$png='C:\Amiga\HD0\Prefs\Presets\Amiga-Amber-1280x1024.png'
$dst.Save($png,[Drawing.Imaging.ImageFormat]::Png)
$g.Dispose();$dst.Dispose();$src.Dispose()
Copy-Item $png 'C:\Users\tilar\Documents\Codex\2026-10-30\c\outputs\Amiga-Amber-1280x1024.png'
Add-Type -ReferencedAssemblies System.Drawing -TypeDefinition @'
using System;using System.IO;using System.Drawing;
public class ThemeIFF{
static void U16(BinaryWriter w,int x){w.Write((byte)(x>>8));w.Write((byte)x);}
static void U32(BinaryWriter w,int x){w.Write((byte)(x>>24));w.Write((byte)(x>>16));w.Write((byte)(x>>8));w.Write((byte)x);}
static void Tag(BinaryWriter w,string s){w.Write(System.Text.Encoding.ASCII.GetBytes(s));}
public static void Save(string input,string output){using(var b=new Bitmap(input))using(var f=File.Create(output))using(var w=new BinaryWriter(f)){int row=((b.Width+15)/16)*2,size=row*b.Height*24;Tag(w,"FORM");U32(w,4+28+8+size);Tag(w,"ILBM");Tag(w,"BMHD");U32(w,20);U16(w,b.Width);U16(w,b.Height);U16(w,0);U16(w,0);w.Write(new byte[]{24,0,0,0});U16(w,0);w.Write(new byte[]{1,1});U16(w,b.Width);U16(w,b.Height);Tag(w,"BODY");U32(w,size);for(int y=0;y<b.Height;y++){var colors=new Color[b.Width];for(int x=0;x<b.Width;x++)colors[x]=b.GetPixel(x,y);for(int p=0;p<24;p++){var data=new byte[row];for(int x=0;x<b.Width;x++){int v=p<8?colors[x].R:p<16?colors[x].G:colors[x].B;if((v&(1<<(p%8)))!=0)data[x/8]|=(byte)(128>>(x%8));}w.Write(data);}}}}
}
'@
[ThemeIFF]::Save($png,'C:\Amiga\HD0\Prefs\Presets\Amiga-Amber-1280x1024.iff')
function Put16($b,$o,$v){$b[$o]=[byte](($v-shr 8)-band 255);$b[$o+1]=[byte]($v-band 255)}
function Put32($b,$o,$v){$b[$o]=[byte](($v-shr 24)-band 255);$b[$o+1]=[byte](($v-shr 16)-band 255);$b[$o+2]=[byte](($v-shr 8)-band 255);$b[$o+3]=[byte]($v-band 255)}
function U32($b,$o){return [long]$b[$o]*16777216+[long]$b[$o+1]*65536+[long]$b[$o+2]*256+$b[$o+3]}
# Keep the existing pattern behavior, replace only the pathname and chunk lengths.
$p='C:\Amiga\HD0\Prefs\Env-Archive\Sys\WBPattern.prefs';$old=[IO.File]::ReadAllBytes($p)
$name=[Text.Encoding]::ASCII.GetBytes('HD0:Prefs/Presets/Amiga-Amber-1280x1024.iff'+[char]0)
$len=58+$name.Length;$b=[byte[]]::new($len+($len%2));[Array]::Copy($old,$b,58);[Array]::Copy($name,0,$b,58,$name.Length)
Put32 $b 4 ($b.Length-8);Put32 $b 30 ($len-34);Put16 $b 56 $name.Length
[IO.File]::WriteAllBytes($p,$b)
# PalettePrefs PALT: 16 reserved bytes, 32 four-color pens, 32 eight-color pens, ColorSpec table.
$b=[IO.File]::ReadAllBytes('C:\Users\Public\Documents\Amiga Files\Shared\dir\System\Prefs\Env-Archive\Sys\palette.prefs')
$colors=@('34322C','E4D5B5','8B8170','68431C','151410','FFBC55','B88A49','C0B29A')
for($i=0;$i-lt 8;$i++){for($c=0;$c-lt 3;$c++){$v=[Convert]::ToInt32($colors[$i].Substring($c*2,2),16)*257;Put16 $b (178+$i*8+2+$c*2) $v}}
$pens=@(4,1,1,2,4,3,1,0,5,1,0,4)
for($i=0;$i-lt $pens.Count;$i++){Put16 $b (114+$i*2) $pens[$i]}
[IO.File]::WriteAllBytes('C:\Amiga\HD0\Prefs\Env-Archive\Sys\Palette.prefs',$b)
function Position($path,$x,$y){$b=[IO.File]::ReadAllBytes($path);Put32 $b 58 $x;Put32 $b 62 $y;[IO.File]::WriteAllBytes($path,$b)}
Position 'C:\Amiga\HD0\Disk.info' 20 24
Position 'C:\Amiga\Share\Disk.info' 20 132
Position 'C:\Amiga\WHDLoad\Disk.info' 20 240
Position 'C:\Amiga\HD0\WookieChat_OS3.info' 150 24
Position 'C:\Amiga\HD0\Utilities\Clock.info' 150 132
Position 'C:\Amiga\HD0\Utilities\HippoPlayer\HiP.info' 150 240
# Update Clock's native tooltypes while retaining its icon graphics and extended data.
$p='C:\Amiga\HD0\Utilities\Clock.info';$b=[IO.File]::ReadAllBytes($p);$o=78
if((U32 $b 66)-ne 0){$o+=56}
foreach($ptr in @(22,26)){if((U32 $b $ptr)-ne 0){do{$w=$b[$o+4]*256+$b[$o+5];$h=$b[$o+6]*256+$b[$o+7];$d=$b[$o+8]*256+$b[$o+9];$next=(U32 $b ($o+16))-ne 0;$o+=20+([int][Math]::Ceiling($w/16))*2*$h*$d}while($next)}}
if((U32 $b 50)-ne 0){$o+=4+(U32 $b $o)}
$start=$o;$types=@()
if((U32 $b 54)-ne 0){$count=(U32 $b $o)/4-1;$o+=4;for($i=0;$i-lt $count;$i++){$l=U32 $b $o;$o+=4;$types+=[Text.Encoding]::GetEncoding(28591).GetString($b,$o,$l).TrimEnd([char]0);$o+=$l}}
$types=@($types|Where-Object {$_ -notmatch '^\(?(DIGITAL|ANALOG|24HOUR|SECONDS|DATE|LEFT|TOP|WIDTH|HEIGHT)(=|\)|$)'})+@('DIGITAL','24HOUR','SECONDS','LEFT=1040','TOP=28','WIDTH=220','HEIGHT=56')
$ms=[IO.MemoryStream]::new();$ms.Write($b,0,$start)
$tmp=[byte[]]::new(4);Put32 $tmp 0 (($types.Count+1)*4);$ms.Write($tmp,0,4)
foreach($type in $types){$s=[Text.Encoding]::GetEncoding(28591).GetBytes($type+[char]0);Put32 $tmp 0 $s.Length;$ms.Write($tmp,0,4);$ms.Write($s,0,$s.Length)}
$ms.Write($b,$o,$b.Length-$o);$out=$ms.ToArray();$ms.Dispose();Put32 $out 54 1;[IO.File]::WriteAllBytes($p,$out)
# A single desktop widget, delayed until IPrefs has completed the screen setup.
[IO.File]::WriteAllText('C:\Amiga\HD0\S\Amber-Desktop',"Wait 6 SECS`nRun >NIL: SYS:Utilities/Clock DIGITAL 24HOUR SECONDS LEFT=1040 TOP=28 WIDTH=220 HEIGHT=56`n",[Text.Encoding]::ASCII)
$p='C:\Amiga\HD0\S\Startup-Sequence';$s=[IO.File]::ReadAllText($p)
if($s-notmatch 'Execute S:Amber-Desktop'){$s=$s.Replace('C:LoadWB',"C:LoadWB`nRun >NIL: Execute S:Amber-Desktop")}
[IO.File]::WriteAllText($p,$s,[Text.Encoding]::ASCII)
Write-Output 'Wallpaper IFF/PNG, palette, desktop positions and digital clock configured.'