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,3 @@
|
||||
build/
|
||||
*.o
|
||||
*.asm
|
||||
@@ -0,0 +1 @@
|
||||
PASS: 240 frames identical to full redraw; changed cell fraction 8.8%.
|
||||
@@ -0,0 +1,20 @@
|
||||
# Rendering optimization (2026-11-06)
|
||||
|
||||
Preserves the existing palette, dimensions, animation rates and visual design.
|
||||
|
||||
- Boing/Matrix: fuse resized pixel sampling and RGB15 conversion into one pass; duplicate scanlines with memcpy.
|
||||
- Boing: ellipse shadow spans replace repeated per-pixel multiplications with identical coverage.
|
||||
- Boing 3D: cache horizontal sphere sampling coordinates per apparent size.
|
||||
- Matrix: cache sparse glyph pixels, preserving glow and core drawing order.
|
||||
- Chrono: cache horizontal sampling coordinates and date conversion; omit invisible analog/digital calculations.
|
||||
|
||||
Original source and executable retained in versions/before-optimization/. Build with build.ps1. No frame-rate reduction.
|
||||
|
||||
## Cell cache update (2026-11-10)
|
||||
|
||||
- Cache glyph and brightness per stationary grid cell; clear and redraw only changed 8x12 cells, including glow.
|
||||
- Convert/upload/present the bounding rectangle of changed cells; full presentation on resize or refresh. When changes are scattered, the rectangle can still cover most of the frame.
|
||||
- Preserve 50 fps pacing in foreground and background, with event-aware timer waits, process priority -1 and idle pause.
|
||||
- tests/verify-cache.py: 240 deterministic frames identical to full redraw, with 8.8% of cells changed on average in the synthetic workload. This is not a measured CPU saving.
|
||||
- Built from C:/git, installed and observed running alongside RetroIRC and Boing 3D. Interactive resize test was interrupted by user input and is not claimed as verified.
|
||||
- Previous source and installed executable: versions/before-cell-cache/.
|
||||
@@ -0,0 +1,19 @@
|
||||
# Matrix Rain for Amiga
|
||||
|
||||
Standalone native AmigaOS 3.x window demo. Original source, independent of BoingBall and BoingBall3D. No external assets.
|
||||
|
||||
Green digital rain with independent column speeds, changing glyphs, luminous heads and fading trails. Space pauses; Esc or the close gadget exits. Resizable window.
|
||||
|
||||
Requires graphics.library v40 (AmigaOS 3.1). Truecolour screens require Picasso96API.library v2. Current target: 68040 and RTG; real hardware performance untested.
|
||||
|
||||
Build using VBCC m68k-amigaos, VASM and VLINK:
|
||||
|
||||
```powershell
|
||||
./build.ps1 -Toolchain C:/path/to/toolchain
|
||||
```
|
||||
|
||||
Output: build/Matrix. Copy the executable anywhere on the Amiga; launch with Stack 65536.
|
||||
|
||||
The display renders into an offscreen bitmap, with RGB15 conversion for RTG and synchronised presentation. Animation uses timer.device elapsed time.
|
||||
|
||||
Latest optimization preserves the classic visual effect and 50 fps target, while caching unchanged glyph cells, sleeping on events when paused and yielding priority to normal applications. See OPTIMIZATION.md and tests/verify-cache.py.
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
param([string]$Toolchain = $env:AMIGA_TOOLCHAIN)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if (!$Toolchain) { throw 'Specificare -Toolchain con la cartella che contiene bin e targets/m68k-amigaos.' }
|
||||
$Toolchain = (Resolve-Path -LiteralPath $Toolchain).Path
|
||||
$targetPath = Join-Path $Toolchain 'targets/m68k-amigaos'
|
||||
$buildPath = Join-Path $PSScriptRoot 'build'
|
||||
$configPath = Join-Path $buildPath 'vbcc'
|
||||
New-Item -ItemType Directory -Path (Join-Path $configPath 'config') -Force | Out-Null
|
||||
$config = [IO.File]::ReadAllText((Join-Path $PSScriptRoot 'vbcc-config.in')).Replace('@TARGET@', $targetPath.Replace('\','/'))
|
||||
[IO.File]::WriteAllText((Join-Path $configPath 'config/boing'), $config)
|
||||
$previousVBCC = $env:VBCC
|
||||
$previousPath = $env:PATH
|
||||
try {
|
||||
$env:VBCC = $configPath
|
||||
$env:PATH = (Join-Path $Toolchain 'bin') + ';' + $env:PATH
|
||||
Push-Location -LiteralPath $PSScriptRoot
|
||||
try {
|
||||
& (Join-Path $Toolchain 'bin/vc.exe') +boing -O2 -c99 -o build/Matrix matrix.c
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Compilazione fallita.' }
|
||||
Copy-Item -LiteralPath assets/Matrix.info -Destination $buildPath -Force
|
||||
} finally { Pop-Location }
|
||||
} finally {
|
||||
$env:VBCC = $previousVBCC
|
||||
$env:PATH = $previousPath
|
||||
}
|
||||
Write-Output ('Pronto per Amiga: ' + $buildPath)
|
||||
@@ -0,0 +1,28 @@
|
||||
from pathlib import Path
|
||||
from PIL import Image,ImageDraw,ImageFont
|
||||
import struct
|
||||
p=Path(__file__).parent
|
||||
(p/'assets').mkdir(exist_ok=True)
|
||||
h=bytearray(Path('C:/Amiga/HD0/System/Shell.info').read_bytes()[:78])
|
||||
def u16(n):return struct.pack('>H',n)
|
||||
def u32(n):return struct.pack('>I',n&0xffffffff)
|
||||
h[12:16]=u16(48)+u16(40);h[16:18]=u16(6);h[48]=3
|
||||
for off in (22,26):h[off:off+4]=u32(1)
|
||||
for off in (44,50,54,66,70):h[off:off+4]=u32(0)
|
||||
h[58:66]=u32(-1)+u32(-1);h[74:78]=u32(131072)
|
||||
data=bytearray(h)
|
||||
for selected in (False,True):
|
||||
im=Image.new('P',(48,40),0);d=ImageDraw.Draw(im)
|
||||
d.rounded_rectangle((2,1,45,35),radius=3,fill=2,outline=1 if selected else 3,width=2)
|
||||
for col in range(6):
|
||||
for row in range(5):
|
||||
xx=7+col*6; yy=5+row*5
|
||||
if (col+row)%4!=0:
|
||||
d.line((xx,yy,xx+2,yy),fill=1 if row==(col+2)%5 else 3)
|
||||
d.point((xx+1,yy+2),fill=3)
|
||||
d.rectangle((18,36,30,38),fill=3)
|
||||
data+=u16(0)+u16(0)+u16(48)+u16(40)+u16(2)+u32(1)+bytes([3,0])+u32(0)
|
||||
for plane in range(2):
|
||||
for y in range(40):
|
||||
for x in range(0,48,8):data.append(sum((128>>i) if im.getpixel((x+i,y))&(1<<plane) else 0 for i in range(8)))
|
||||
(p/'assets'/'Matrix.info').write_bytes(data)
|
||||
@@ -0,0 +1,222 @@
|
||||
#include <exec/types.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <graphics/gfxbase.h>
|
||||
#include <graphics/view.h>
|
||||
#include <devices/timer.h>
|
||||
#include <proto/exec.h>
|
||||
#include <proto/dos.h>
|
||||
#include <proto/intuition.h>
|
||||
#include <proto/graphics.h>
|
||||
#include <proto/layers.h>
|
||||
#include <proto/timer.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define W 480
|
||||
#define H 320
|
||||
struct IntuitionBase *IntuitionBase;
|
||||
struct GfxBase *GfxBase;
|
||||
struct Library *TimerBase;
|
||||
struct Library *LayersBase;
|
||||
static struct Library *P96Base;
|
||||
/* Picasso96 public ABI: RenderInfo is 12 bytes; RGBFB_R5G5B5 = 11.
|
||||
Only this function is needed, so no complete P96 SDK is required. */
|
||||
struct MatrixRenderInfo {APTR Memory;WORD BytesPerRow,pad;ULONG RGBFormat;};
|
||||
void __matrixP96Write(__reg("a6") void *,__reg("a0") struct MatrixRenderInfo *,
|
||||
__reg("d0") UWORD,__reg("d1") UWORD,__reg("a1") struct RastPort *,
|
||||
__reg("d2") UWORD,__reg("d3") UWORD,__reg("d4") UWORD,__reg("d5") UWORD)="\tjsr\t-102(a6)";
|
||||
static UWORD *rgbFrame,rgbPens[256];
|
||||
static int damageX,damageY,damageW,damageH;
|
||||
static void uploadRGB(struct RastPort *rp,int width,int height){
|
||||
struct MatrixRenderInfo ri;
|
||||
ri.Memory=rgbFrame;ri.BytesPerRow=width*2;ri.pad=0;ri.RGBFormat=11;
|
||||
__matrixP96Write(P96Base,&ri,damageX,damageY,rp,damageX,damageY,damageW,damageH);
|
||||
}
|
||||
static void writeBack(struct RastPort *rp,UBYTE *pixels,int width,int height){
|
||||
if(rgbFrame){
|
||||
int x,y;for(y=damageY;y<damageY+damageH;y++)for(x=damageX;x<damageX+damageW;x++)rgbFrame[(ULONG)y*width+x]=rgbPens[pixels[(ULONG)y*width+x]];
|
||||
uploadRGB(rp,width,height);
|
||||
}else WriteChunkyPixels(rp,0,0,width-1,height-1,pixels,width);
|
||||
}
|
||||
|
||||
/* Original 5x7 glyph patterns, stored as row masks. No external font/assets. */
|
||||
static const UBYTE glyphs[][7]={
|
||||
{14,17,19,21,25,17,14},{4,12,4,4,4,4,14},{14,17,1,2,4,8,31},
|
||||
{30,1,1,14,1,1,30},{2,6,10,18,31,2,2},{31,16,16,30,1,1,30},
|
||||
{14,16,16,30,17,17,14},{31,1,2,4,8,8,8},{14,17,17,14,17,17,14},
|
||||
{14,17,17,15,1,1,14},{14,17,17,31,17,17,17},{30,17,17,30,17,17,30},
|
||||
{14,17,16,16,16,17,14},{30,17,17,17,17,17,30},{31,16,16,30,16,16,31},
|
||||
{31,16,16,30,16,16,16},{14,17,16,23,17,17,15},{17,17,17,31,17,17,17},
|
||||
{14,4,4,4,4,4,14},{7,2,2,2,2,18,12},{17,18,20,24,20,18,17},
|
||||
{16,16,16,16,16,16,31},{17,27,21,21,17,17,17},{17,25,25,21,19,19,17},
|
||||
{14,17,17,17,17,17,14},{30,17,17,30,16,16,16},{14,17,17,17,21,18,13},
|
||||
{30,17,17,30,20,18,17},{15,16,16,14,1,1,30},{31,4,4,4,4,4,4},
|
||||
{17,17,17,17,17,17,14},{17,17,17,17,17,10,4},{17,17,17,21,21,21,10},
|
||||
{17,17,10,4,10,17,17},{17,17,10,4,4,4,4},{31,1,2,4,8,16,31},
|
||||
{4,4,31,4,31,4,4},{0,10,31,31,14,4,0},{31,1,5,4,20,16,31},
|
||||
{4,31,4,14,21,4,4},{0,31,1,9,4,4,8},{4,31,4,4,10,17,0},
|
||||
{0,17,2,4,8,17,0},{0,31,4,31,4,4,0},{31,17,17,31,17,17,31},
|
||||
{0,4,14,31,14,4,0},{31,16,8,4,2,1,31},{4,14,21,4,21,14,4}
|
||||
};
|
||||
#define COLS (W/8)
|
||||
#define ROWS (H/12+1)
|
||||
static UBYTE cells[COLS][ROWS],*frame,*scaled;
|
||||
static UBYTE gx[48][35],gy[48][35],gn[48];
|
||||
static LONG heads[COLS];
|
||||
static signed char oldLevel[COLS][ROWS];static UBYTE oldGlyph[COLS][ROWS];
|
||||
static int dirtyL,dirtyT,dirtyR,dirtyB;
|
||||
static UWORD *xmap;
|
||||
static int speeds[COLS],tails[COLS];
|
||||
static LONG pens[32];
|
||||
static ULONG seed=0x19a49;
|
||||
static ULONG random32(void){seed^=seed<<13;seed^=seed>>17;seed^=seed<<5;return seed;}
|
||||
static void resetColumn(int c,int initial){
|
||||
speeds[c]=70+random32()%101;tails[c]=10+random32()%16;
|
||||
heads[c]=initial?-(LONG)(random32()%(H+200))*1024:-tails[c]*12*1024;
|
||||
}
|
||||
static void drawRain(void){
|
||||
int c,r,x,y,k,head,dist,level,g,px,py;
|
||||
dirtyL=W;dirtyR=-1;dirtyT=H;dirtyB=-1;
|
||||
for(c=0;c<COLS;c++){
|
||||
head=heads[c]/1024;
|
||||
for(r=0;r<ROWS;r++){
|
||||
/* Classic digital rain: stationary glyph grid, travelling light envelope. */
|
||||
y=r*12;dist=head-y;
|
||||
level=29-dist*28/(tails[c]*12);if(level<1)level=1;
|
||||
/* Fade the advancing front instead of switching whole rows abruptly. */
|
||||
if(dist<4)level=8+dist*6;
|
||||
else if(dist<14)level=31;else if(dist<26)level=30;
|
||||
if(dist<0||dist>tails[c]*12)level=0;
|
||||
g=cells[c][r];
|
||||
if(oldLevel[c][r]==level&&(!level||oldGlyph[c][r]==g))continue;
|
||||
oldLevel[c][r]=level;oldGlyph[c][r]=g;
|
||||
if(c*8<dirtyL)dirtyL=c*8;if(c*8+7>dirtyR)dirtyR=c*8+7;
|
||||
if(y<dirtyT)dirtyT=y;if(y+11>dirtyB)dirtyB=y+11<H?y+11:H-1;
|
||||
for(py=y;py<y+12&&py<H;py++)memset(frame+py*W+c*8,(UBYTE)pens[0],8);
|
||||
if(!level)continue;
|
||||
if(level>=29)for(px=0;px<gn[g];px++){
|
||||
int yy=y+gy[g][px]+2;if(yy<0||yy>=H)continue;
|
||||
k=yy*W+c*8+gx[g][px]+1;frame[k-1]=(UBYTE)pens[3];frame[k+1]=(UBYTE)pens[3];
|
||||
}
|
||||
for(px=0;px<gn[g];px++){
|
||||
int yy=y+gy[g][px]+2;if(yy<0||yy>=H)continue;
|
||||
frame[yy*W+c*8+gx[g][px]+1]=(UBYTE)pens[level];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int main(void){
|
||||
struct Screen *screen=0;struct Window *win=0;struct IntuiMessage *msg;
|
||||
struct BitMap *backBitmap=0;struct RastPort backRPort;
|
||||
struct MsgPort *timerport=0;struct timerequest *timerio=0;struct EClockVal clock;
|
||||
int timeropen=0,got=0,done=0,paused=0,i,c,r,x,y,iw,ih,backw=0,backh=0;
|
||||
ULONG frequency=0,last=0,delta,dt,cls,mutation=0,frameStart=0,elapsed,interval;LONG oldPriority=0;int prioritySet=0,force=1;UWORD code;
|
||||
IntuitionBase=(struct IntuitionBase*)OpenLibrary("intuition.library",39);
|
||||
GfxBase=(struct GfxBase*)OpenLibrary("graphics.library",40);LayersBase=OpenLibrary("layers.library",39);
|
||||
if(!IntuitionBase||!GfxBase||!LayersBase)goto end;
|
||||
timerport=CreateMsgPort();if(!timerport)goto end;
|
||||
timerio=(struct timerequest*)CreateIORequest(timerport,sizeof(struct timerequest));if(!timerio)goto end;
|
||||
if(OpenDevice(TIMERNAME,UNIT_MICROHZ,(struct IORequest*)timerio,0))goto end;
|
||||
timeropen=1;TimerBase=(struct Library*)timerio->tr_node.io_Device;
|
||||
frequency=ReadEClock(&clock);last=clock.ev_lo;seed^=last;
|
||||
screen=LockPubScreen(0);if(!screen)goto end;
|
||||
frame=malloc(W*H);scaled=malloc((ULONG)screen->Width*screen->Height);
|
||||
xmap=malloc((ULONG)screen->Width*sizeof(UWORD));
|
||||
if(!frame||!scaled||!xmap)goto end;
|
||||
if(GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH)>8){
|
||||
P96Base=OpenLibrary("Picasso96API.library",2);if(!P96Base)goto end;
|
||||
rgbFrame=malloc((ULONG)screen->Width*screen->Height*2);if(!rgbFrame)goto end;
|
||||
}
|
||||
for(i=0;i<32;i++){
|
||||
int red=i==31?200:(i==30?85:i/3),green=i==0?2:8+i*7,blue=i==31?215:(i==30?130:i/2);
|
||||
if(i>=30)green=255;
|
||||
pens[i]=ObtainBestPen(screen->ViewPort.ColorMap,red*0x01010101UL,green*0x01010101UL,blue*0x01010101UL,TAG_DONE);
|
||||
if(pens[i]<0)goto end;got++;if(pens[i]>255)goto end;
|
||||
rgbPens[pens[i]]=(red>>3)<<10|(green>>3)<<5|(blue>>3);
|
||||
}
|
||||
for(i=0;i<48;i++)for(y=0;y<7;y++)for(x=0;x<5;x++)if(glyphs[i][y]&(16>>x)){
|
||||
int n=gn[i]++;gx[i][n]=x;gy[i][n]=y;
|
||||
}
|
||||
for(c=0;c<COLS;c++){resetColumn(c,1);for(r=0;r<ROWS;r++)cells[c][r]=random32()%(sizeof(glyphs)/7);}
|
||||
win=OpenWindowTags(0,WA_PubScreen,(ULONG)screen,WA_Left,670,WA_Top,350,
|
||||
WA_InnerWidth,W,WA_InnerHeight,H,WA_Title,(ULONG)"Matrix | Space: pausa Esc: esci",
|
||||
WA_CloseGadget,TRUE,WA_DragBar,TRUE,WA_DepthGadget,TRUE,WA_Activate,TRUE,
|
||||
WA_SizeGadget,TRUE,WA_SizeBBottom,TRUE,WA_MinWidth,248,WA_MinHeight,180,
|
||||
WA_MaxWidth,screen->Width,WA_MaxHeight,screen->Height,WA_SimpleRefresh,TRUE,
|
||||
WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_REFRESHWINDOW|IDCMP_NEWSIZE,TAG_DONE);
|
||||
if(!win)goto end;
|
||||
memset(frame,(UBYTE)pens[0],W*H);memset(oldLevel,-1,sizeof(oldLevel));oldPriority=SetTaskPri(FindTask(0),-1);prioritySet=1;
|
||||
while(!done){
|
||||
while((msg=(struct IntuiMessage*)GetMsg(win->UserPort))!=0){
|
||||
cls=msg->Class;code=msg->Code;ReplyMsg((struct Message*)msg);
|
||||
if(cls==IDCMP_CLOSEWINDOW||(cls==IDCMP_RAWKEY&&code==0x45))done=1;
|
||||
if(cls==IDCMP_RAWKEY&&code==0x40){paused=!paused;force=1;}
|
||||
if(cls==IDCMP_NEWSIZE)force=1;
|
||||
if(cls==IDCMP_REFRESHWINDOW){force=1;BeginRefresh(win);EndRefresh(win,TRUE);}
|
||||
}
|
||||
if(done)break;
|
||||
ReadEClock(&clock);interval=frequency/50;elapsed=clock.ev_lo-frameStart;
|
||||
if(frameStart&&elapsed<interval){timerio->tr_node.io_Command=TR_ADDREQUEST;timerio->tr_time.tv_secs=0;timerio->tr_time.tv_micro=(interval-elapsed)*1000UL/(frequency/1000);SendIO((struct IORequest*)timerio);Wait((1UL<<timerport->mp_SigBit)|(1UL<<win->UserPort->mp_SigBit));if(!CheckIO((struct IORequest*)timerio))AbortIO((struct IORequest*)timerio);WaitIO((struct IORequest*)timerio);continue;}
|
||||
frameStart=clock.ev_lo;if(paused&&!force){Wait(1UL<<win->UserPort->mp_SigBit);continue;}
|
||||
ReadEClock(&clock);delta=clock.ev_lo-last;last=clock.ev_lo;
|
||||
if(delta>frequency/20)delta=frequency/20;dt=delta*1024/frequency;
|
||||
if(!paused){
|
||||
for(c=0;c<COLS;c++){
|
||||
heads[c]+=speeds[c]*(LONG)dt;
|
||||
if(heads[c]>(H+tails[c]*12)*1024)resetColumn(c,0);
|
||||
}
|
||||
mutation+=dt;
|
||||
if(mutation>=75){mutation%=75;for(i=0;i<45;i++){
|
||||
c=random32()%COLS;r=random32()%ROWS;cells[c][r]=random32()%(sizeof(glyphs)/7);
|
||||
}}
|
||||
}
|
||||
drawRain();
|
||||
iw=win->Width-win->BorderLeft-win->BorderRight;ih=win->Height-win->BorderTop-win->BorderBottom;
|
||||
if(iw<1||ih<1||iw>screen->Width||ih>screen->Height){WaitTOF();continue;}
|
||||
if(iw!=backw||ih!=backh){
|
||||
force=1;
|
||||
struct BitMap *replacement=AllocBitMap(iw,ih,GetBitMapAttr(screen->RastPort.BitMap,BMA_DEPTH),BMF_CLEAR,screen->RastPort.BitMap);
|
||||
if(!replacement)break;WaitBlit();if(backBitmap)FreeBitMap(backBitmap);
|
||||
for(x=0;x<iw;x++)xmap[x]=(ULONG)x*W/iw;
|
||||
backBitmap=replacement;backw=iw;backh=ih;InitRastPort(&backRPort);backRPort.BitMap=backBitmap;
|
||||
}
|
||||
if(force){damageX=damageY=0;damageW=iw;damageH=ih;}
|
||||
else{if(dirtyR<dirtyL)continue;damageX=dirtyL*iw/W;damageY=dirtyT*ih/H;damageW=(dirtyR+1)*iw/W+2-damageX;damageH=(dirtyB+1)*ih/H+2-damageY;if(damageX+damageW>iw)damageW=iw-damageX;if(damageY+damageH>ih)damageH=ih-damageY;}
|
||||
WaitBlit();
|
||||
if(iw==W&&ih==H)writeBack(&backRPort,frame,W,H);
|
||||
else{
|
||||
int previous=-1,sy;
|
||||
for(y=damageY;y<damageY+damageH;y++){
|
||||
UBYTE *src;sy=(ULONG)y*H/ih;src=frame+sy*W;
|
||||
if(rgbFrame){
|
||||
UWORD *dst=rgbFrame+(ULONG)y*iw;
|
||||
for(x=damageX;x<damageX+damageW;x++)dst[x]=rgbPens[src[xmap[x]]];
|
||||
}else{
|
||||
UBYTE *dst=scaled+(ULONG)y*iw;
|
||||
if(sy==previous)memcpy(dst,dst-iw,iw);
|
||||
else for(x=0;x<iw;x++)dst[x]=src[xmap[x]];
|
||||
}
|
||||
previous=sy;
|
||||
}
|
||||
if(rgbFrame)uploadRGB(&backRPort,iw,ih);
|
||||
else writeBack(&backRPort,scaled,iw,ih);
|
||||
}
|
||||
WaitBlit();LockLayer(0,win->WLayer);
|
||||
if(iw==win->Width-win->BorderLeft-win->BorderRight&&ih==win->Height-win->BorderTop-win->BorderBottom){
|
||||
BltBitMapRastPort(backBitmap,damageX,damageY,win->RPort,win->BorderLeft+damageX,win->BorderTop+damageY,damageW,damageH,0xc0);WaitBlit();force=0;
|
||||
}
|
||||
UnlockLayer(win->WLayer);
|
||||
}
|
||||
end:
|
||||
if(prioritySet)SetTaskPri(FindTask(0),oldPriority);
|
||||
if(GfxBase){WaitBlit();if(backBitmap)FreeBitMap(backBitmap);}
|
||||
if(win)CloseWindow(win);
|
||||
if(screen){for(i=0;i<got;i++)ReleasePen(screen->ViewPort.ColorMap,pens[i]);UnlockPubScreen(0,screen);}
|
||||
free(frame);free(scaled);free(rgbFrame);free(xmap);
|
||||
if(P96Base)CloseLibrary(P96Base);
|
||||
if(timeropen)CloseDevice((struct IORequest*)timerio);
|
||||
if(timerio)DeleteIORequest((struct IORequest*)timerio);if(timerport)DeleteMsgPort(timerport);
|
||||
if(LayersBase)CloseLibrary(LayersBase);if(GfxBase)CloseLibrary((struct Library*)GfxBase);
|
||||
if(IntuitionBase)CloseLibrary((struct Library*)IntuitionBase);return 0;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
from pathlib import Path
|
||||
import re,random
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
s=(root/'matrix.c').read_text();block=s.split('static const UBYTE glyphs[][7]={',1)[1].split('};',1)[0];glyphs=[list(map(int,x.split(','))) for x in re.findall(r'\{([\d,]+)\}',block)]
|
||||
W,H,C,R=480,320,60,27
|
||||
rng=random.Random(458);cached=bytearray(W*H);previous={};updates=0
|
||||
heads=[-rng.randrange(520) for _ in range(C)];tails=[rng.randrange(10,26) for _ in range(C)];cells=[[rng.randrange(48) for _ in range(R)] for _ in range(C)]
|
||||
def draw(buf,c,r,g,level):
|
||||
y=r*12
|
||||
if level>=29:
|
||||
for gy,row in enumerate(glyphs[g]):
|
||||
yy=y+gy+2
|
||||
if yy>=H:continue
|
||||
for gx in range(5):
|
||||
if row&(16>>gx):
|
||||
k=yy*W+c*8+gx+1;buf[k-1]=buf[k+1]=3
|
||||
for gy,row in enumerate(glyphs[g]):
|
||||
yy=y+gy+2
|
||||
if yy>=H:continue
|
||||
for gx in range(5):
|
||||
if row&(16>>gx):buf[yy*W+c*8+gx+1]=level
|
||||
for step in range(240):
|
||||
reference=bytearray(W*H)
|
||||
for c in range(C):
|
||||
heads[c]+=rng.randrange(1,5)
|
||||
if heads[c]>H+tails[c]*12:heads[c]=-tails[c]*12
|
||||
for _ in range(45 if step%4==0 else 0):cells[rng.randrange(C)][rng.randrange(R)]=rng.randrange(48)
|
||||
for c in range(C):
|
||||
for r in range(R):
|
||||
dist=heads[c]-r*12
|
||||
level=max(1,29-dist*28//(tails[c]*12))
|
||||
if dist<4:level=8+dist*6
|
||||
elif dist<14:level=31
|
||||
elif dist<26:level=30
|
||||
if dist<0 or dist>tails[c]*12:level=0
|
||||
g=cells[c][r]
|
||||
if level:draw(reference,c,r,g,level)
|
||||
old=previous.get((c,r))
|
||||
if old and old[0]==level and (not level or old[1]==g):continue
|
||||
previous[c,r]=(level,g);updates+=1
|
||||
for y in range(r*12,min(H,r*12+12)):cached[y*W+c*8:y*W+c*8+8]=bytes(8)
|
||||
if level:draw(cached,c,r,g,level)
|
||||
assert reference==cached,step
|
||||
report=f'PASS: 240 frames identical to full redraw; changed cell fraction {updates/(240*C*R):.1%}.\n'
|
||||
(root/'CACHE-VALIDATION.txt').write_text(report);print(report)
|
||||
@@ -0,0 +1,12 @@
|
||||
-cc=vbccm68k -quiet -hunkdebug %s -o= %s %s -O=%ld -I"@TARGET@/include" -I"@TARGET@/ndk/include_h" -I"@TARGET@/netinclude"
|
||||
-ccv=vbccm68k -hunkdebug %s -o= %s %s -O=%ld -I"@TARGET@/include" -I"@TARGET@/ndk/include_h" -I"@TARGET@/netinclude"
|
||||
-as=vasmm68k_mot -quiet -Fhunk -phxass -opt-fconst -nowarn=62 %s -o %s
|
||||
-asv=vasmm68k_mot -Fhunk -phxass -opt-fconst -nowarn=62 %s -o %s
|
||||
-ld=vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib "@TARGET@/lib/startup.o" %s %s -L"@TARGET@/lib" -lvc -o %s
|
||||
-l2=vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib %s %s -L"@TARGET@/lib" -o %s
|
||||
-ldv=vlink -bamigahunk -t -x -Bstatic -Cvbcc -nostdlib "@TARGET@/lib/startup.o" %s %s -L"@TARGET@/lib" -lvc -o %s
|
||||
-l2v=vlink -bamigahunk -t -x -Bstatic -Cvbcc -nostdlib %s %s -L"@TARGET@/lib" -o %s
|
||||
-ldnodb=-s -Rshort
|
||||
-ul=-l%s
|
||||
-cf=-F%s
|
||||
-ml=500
|
||||
Reference in new issue
Block a user