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,7 @@
|
||||
/build/
|
||||
/toolchain/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.o
|
||||
*.asm
|
||||
/assets/preview.png
|
||||
@@ -0,0 +1 @@
|
||||
PASS: 476 comparisons of partial vs full redraw at 4 sizes; no missing changed pixels. Mean updated area in synthetic motion: 13.3%.
|
||||
@@ -0,0 +1,27 @@
|
||||
# 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.
|
||||
|
||||
## Multitasking update (2026-11-10)
|
||||
|
||||
- Convert, upload and present only the union of the old/new sphere and shadow bounds. Full redraw on resize/refresh.
|
||||
- Animation task priority -1: normal desktop applications take precedence.
|
||||
- Event-aware timer pacing: up to 30 fps active / 15 fps inactive; paused windows wait for input.
|
||||
- Position and rotation use elapsed time; scene, palette, projection and sprites retained.
|
||||
- Removed the unconditional WaitTOF, keeping the layer locked only during partial presentation.
|
||||
- 476 synthetic comparisons at 240x180, 400x300, 800x600 and 1280x960 passed against full redraw. Synthetic mean damage area 13.3%; this is not a measured CPU percentage.
|
||||
- Emulator smoke check: animation, resize and unsent RetroIRC typing with the demo running. Perceived latency still needs the user's judgement.
|
||||
|
||||
Previous source and installed executable: versions/before-damage-rendering/.
|
||||
|
||||
|
||||
### Fluidity correction
|
||||
The user found 30/15 fps pacing visibly less fluid. Pacing is now 50 fps in both foreground and background; damage rendering, priority -1 and event-aware waits remain. This supersedes the initial 30/15 fps cap.
|
||||
@@ -0,0 +1,27 @@
|
||||
# Boing Ball 3D - variante separata
|
||||
|
||||
Progetto indipendente da BoingBall, che resta invariato.
|
||||
Rimbalzi fisici lungo X, altezza Y e profondita Z dentro una stanza.
|
||||
Proiezione prospettica della posizione, del diametro e dell'ombra al suolo.
|
||||
La sfera conserva i 64 sprite di rotazione precalcolati: non e' una mesh 3D.
|
||||
Il moto, la profondita e la prospettiva sono calcolati in tempo reale in C.
|
||||
Buffer fuori schermo e ridimensionamento dell'area interna sempre 4:3.
|
||||
|
||||
## Compilazione
|
||||
|
||||
```powershell
|
||||
.\build.ps1 -Toolchain "C:\percorso\amiga-dev"
|
||||
```
|
||||
|
||||
Il risultato e' in `build/Boing3D` con i due file .bin e l'icona.
|
||||
Copiare insieme in `SYS:Utilities/Boing3D`.
|
||||
Per rigenerare gli asset: `python generate.py` (Python + Pillow).
|
||||
Toolchain esterna: VBCC, VASM, VLINK, target m68k-amigaos e NDK,
|
||||
come https://github.com/kusma/amiga-dev.
|
||||
AmigaOS 3.x, graphics.library v40; per RTG >8 bit Picasso96API.library v2.
|
||||
|
||||
Spazio: pausa/riprendi. Esc: esci. Mouse: sposta o ridimensiona la finestra.
|
||||
I limiti del mondo e la camera si trovano nel ciclo principale di `boing.c`
|
||||
e nella funzione `project` di `generate.py`; devono rimanere coerenti.
|
||||
|
||||
Latest version uses damage-based partial rendering, low task priority and 50 fps pacing to protect Workbench responsiveness. See OPTIMIZATION.md. The executable was built from this C:/git project and installed under SYS:Utilities/Boing3D/.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,273 @@
|
||||
#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>
|
||||
#include "palette.h"
|
||||
#define W 400
|
||||
#define H 300
|
||||
#define D 114
|
||||
#define N 64
|
||||
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 BoingRenderInfo {APTR Memory;WORD BytesPerRow,pad;ULONG RGBFormat;};
|
||||
void __boingP96Write(__reg("a6") void *,__reg("a0") struct BoingRenderInfo *,
|
||||
__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 BoingRenderInfo ri;
|
||||
ri.Memory=rgbFrame;ri.BytesPerRow=width*2;ri.pad=0;ri.RGBFormat=11;
|
||||
__boingP96Write(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);
|
||||
}
|
||||
static UBYTE *background,*sprites,*frame,*scaled;
|
||||
static UWORD *xmap;
|
||||
static UBYTE sphereX[D*2];
|
||||
static int lastSphereSize;
|
||||
static LONG pens[21];
|
||||
static int load(char *path,UBYTE *p,long size) {
|
||||
FILE *f=fopen(path,"rb"); int ok; if(!f)return 0;
|
||||
ok=fread(p,1,size,f)==size; fclose(f);return ok;
|
||||
}
|
||||
/* Intuition completes the native resize first; snap its inner area to 4:3.
|
||||
Use the axis moved most, then clamp both axes together in 4x3 pixel steps. */
|
||||
static void keepAspect(struct Window *w,struct Screen *sc,int *oldw,int *oldh){
|
||||
int bw=w->BorderLeft+w->BorderRight,bh=w->BorderTop+w->BorderBottom;
|
||||
int iw=w->Width-bw,ih=w->Height-bh,k,kmin,kmax,t;
|
||||
if(iw*3==ih*4){*oldw=iw;*oldh=ih;return;}
|
||||
if(abs(iw-*oldw)*3>=abs(ih-*oldh)*4)k=(iw+2)/4;
|
||||
else k=(ih+1)/3;
|
||||
kmin=(w->MinWidth-bw+3)/4;
|
||||
t=(w->MinHeight-bh+2)/3;if(t>kmin)kmin=t;
|
||||
if(kmin<1)kmin=1;
|
||||
kmax=(sc->Width-w->LeftEdge-bw)/4;
|
||||
t=(sc->Height-w->TopEdge-bh)/3;if(t<kmax)kmax=t;
|
||||
if(kmax<kmin)kmax=kmin;
|
||||
if(k<kmin)k=kmin;if(k>kmax)k=kmax;
|
||||
*oldw=k*4;*oldh=k*3;
|
||||
ChangeWindowBox(w,w->LeftEdge,w->TopEdge,*oldw+bw,*oldh+bh);
|
||||
}
|
||||
int main(void) {
|
||||
struct BitMap *backBitmap=0;struct RastPort backRPort;
|
||||
int backw=0,backh=0,aspectw=W,aspecth=H;
|
||||
struct Screen *screen=0; struct Window *win=0; struct IntuiMessage *msg;
|
||||
int i,j,x,y,bx,by,size,den,wx,wy,wz,phase=0,done=0,paused=0,got=0;
|
||||
ULONG cls; UWORD code; UBYTE *sp; int sx,sy,dx,dy;
|
||||
int iw,ih,rw,rh,ox,oy,lastw=0,lasth=0,srcy,prevy;
|
||||
UBYTE *row;
|
||||
struct MsgPort *timerport=0;
|
||||
struct timerequest *timerio=0;
|
||||
struct EClockVal clock;
|
||||
ULONG frequency=0,last=0,delta,dt,rotation=0;
|
||||
LONG xpos=-95*1024,ypos=150*1024,zpos=180*1024;
|
||||
LONG xspeed=95,yspeed=0,zspeed=110;
|
||||
int timeropen=0,force=1,oldL=0,oldT=0,oldR=W-1,oldB=H-1;
|
||||
int dl,dr,dtp,db,nl,nr,nt,nb,renderX,renderY,renderR,renderB;
|
||||
ULONG frameStart=0,interval,elapsed,signals;LONG oldPriority=0;int prioritySet=0;
|
||||
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;
|
||||
screen=LockPubScreen(0); if(!screen)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*sizeof(UWORD));
|
||||
if(!rgbFrame)goto end;
|
||||
}
|
||||
scaled=malloc((ULONG)screen->Width*screen->Height);
|
||||
xmap=malloc((ULONG)screen->Width*sizeof(UWORD));
|
||||
background=malloc(W*H); frame=malloc(W*H); sprites=malloc(N*D*D);
|
||||
if(!background||!frame||!sprites||!scaled||!xmap)goto end;
|
||||
if(!load("PROGDIR:background.bin",background,W*H)||!load("PROGDIR:sprites.bin",sprites,N*D*D))goto end;
|
||||
for(i=0;i<21;i++) {
|
||||
pens[i]=ObtainBestPen(screen->ViewPort.ColorMap,colors[i][0]*0x01010101UL,colors[i][1]*0x01010101UL,colors[i][2]*0x01010101UL,TAG_DONE);
|
||||
if(pens[i]<0||pens[i]>255)goto end; got++;
|
||||
rgbPens[pens[i]]=(colors[i][0]>>3)<<10|(colors[i][1]>>3)<<5|(colors[i][2]>>3);
|
||||
}
|
||||
for(i=0;i<W*H;i++)background[i]=(UBYTE)pens[background[i]];
|
||||
for(i=0;i<N*D*D;i++)if(sprites[i]!=255)sprites[i]=(UBYTE)pens[sprites[i]];
|
||||
win=OpenWindowTags(0,WA_PubScreen,(ULONG)screen,WA_Left,740,WA_Top,400,
|
||||
WA_InnerWidth,W,WA_InnerHeight,H,WA_Title,(ULONG)"Boing 3D | Space: pausa Esc: esci",
|
||||
WA_CloseGadget,TRUE,WA_DragBar,TRUE,WA_DepthGadget,TRUE,WA_Activate,TRUE,
|
||||
WA_SizeGadget,TRUE,WA_SizeBBottom,TRUE,
|
||||
WA_MinWidth,240,WA_MinHeight,195,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;
|
||||
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_NEWSIZE)keepAspect(win,screen,&aspectw,&aspecth);
|
||||
if(cls==IDCMP_REFRESHWINDOW){force=1;BeginRefresh(win);EndRefresh(win,TRUE);}
|
||||
}
|
||||
if(done)break;
|
||||
/* Sleep on timer OR window input; never busy-wait or delay keyboard events. */
|
||||
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);signals=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/10)delta=frequency/10;
|
||||
dt=delta*1024/frequency;
|
||||
if(!paused){
|
||||
/* World space in fixed point. Sphere radius 50; room 380x250x400. */
|
||||
xpos+=xspeed*(LONG)dt;
|
||||
if(xpos<-140*1024){xpos=-140*1024;xspeed=95;}
|
||||
if(xpos>140*1024){xpos=140*1024;xspeed=-95;}
|
||||
zpos+=zspeed*(LONG)dt;
|
||||
if(zpos<50*1024){zpos=50*1024;zspeed=110;}
|
||||
if(zpos>350*1024){zpos=350*1024;zspeed=-110;}
|
||||
ypos+=yspeed*(LONG)dt/1024-625*(LONG)dt*(LONG)dt/2048;
|
||||
yspeed-=625*(LONG)dt;
|
||||
if(ypos<50*1024){ypos=50*1024;yspeed=400*1024;}
|
||||
if(ypos>200*1024){ypos=200*1024;yspeed=-abs(yspeed);}
|
||||
rotation=(rotation+dt*50)%(N*1024);
|
||||
}
|
||||
wx=xpos/1024;wy=ypos/1024;wz=zpos/1024;
|
||||
den=260+wz;
|
||||
size=100*340/den;
|
||||
bx=200+wx*340/den-size/2;
|
||||
by=100+(150-wy)*340/den-size/2;
|
||||
phase=rotation/1024;
|
||||
memcpy(frame,background,W*H);
|
||||
/* Project the shadow separately on the floor at the sphere's world depth. */
|
||||
{int shadowz=wz+(wy-50)/7,shadowden=260+shadowz;
|
||||
sx=200+(wx+(wy-50)/6)*340/shadowden;
|
||||
sy=100+150*340/shadowden;
|
||||
dx=(40+(wy-50)/10)*340/shadowden;
|
||||
dy=(11+(wy-50)/30)*340/shadowden;
|
||||
if(dy<2)dy=2;
|
||||
}
|
||||
nl=bx<sx-dx?bx:sx-dx;nr=bx+size>sx+dx?bx+size:sx+dx;
|
||||
nt=by<sy-dy?by:sy-dy;nb=by+size>sy+dy?by+size:sy+dy;
|
||||
dl=nl<oldL?nl:oldL;dr=nr>oldR?nr:oldR;dtp=nt<oldT?nt:oldT;db=nb>oldB?nb:oldB;
|
||||
oldL=nl;oldR=nr;oldT=nt;oldB=nb;
|
||||
if(dl<0)dl=0;if(dtp<0)dtp=0;if(dr>=W)dr=W-1;if(db>=H)db=H-1;
|
||||
for(y=-dy;y<=dy;y++){
|
||||
int span=dx,left,right,yy=sy+y;
|
||||
LONG limit=(LONG)dx*dx*((LONG)dy*dy-(LONG)y*y);
|
||||
if(yy<0||yy>=H)continue;
|
||||
while(span>0&&(LONG)span*span*dy*dy>limit)span--;
|
||||
left=sx-span;right=sx+span;if(left<0)left=0;if(right>=W)right=W-1;
|
||||
if(left<=right)memset(frame+yy*W+left,(UBYTE)pens[2],right-left+1);
|
||||
}
|
||||
sp=sprites+phase*D*D;
|
||||
/* The checker sphere uses the original prerendered rotation frames;
|
||||
position and apparent diameter come from a real perspective projection. */
|
||||
if(size!=lastSphereSize){for(i=0;i<size;i++)sphereX[i]=i*D/size;lastSphereSize=size;}
|
||||
for(j=0;j<size;j++){
|
||||
int yy=by+j,srcrow=j*D/size*D;
|
||||
if(yy<0||yy>=H)continue;
|
||||
for(i=0;i<size;i++){
|
||||
UBYTE c=sp[srcrow+sphereX[i]];int xx=bx+i;
|
||||
if(c!=255&&xx>=0&&xx<W)frame[yy*W+xx]=c;
|
||||
}
|
||||
}
|
||||
iw=win->Width-win->BorderLeft-win->BorderRight;
|
||||
ih=win->Height-win->BorderTop-win->BorderBottom;
|
||||
if(done)break;
|
||||
if(iw<=0||ih<=0||iw>screen->Width||ih>screen->Height){WaitTOF();continue;}
|
||||
/* Build a complete frame off screen. Never expose the scanline conversion. */
|
||||
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);
|
||||
backBitmap=replacement;backw=iw;backh=ih;
|
||||
InitRastPort(&backRPort);backRPort.BitMap=backBitmap;
|
||||
}
|
||||
if(force){damageX=damageY=0;damageW=iw;damageH=ih;}
|
||||
else{damageX=dl*iw/W;damageY=dtp*ih/H;damageW=(dr+1)*iw/W+2-damageX;damageH=(db+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
|
||||
if(iw>0&&ih>0&&iw<=screen->Width&&ih<=screen->Height) {
|
||||
/* Fit a 4:3 scene inside any window shape; keep the sphere round. */
|
||||
rw=iw;rh=iw*H/W;
|
||||
if(rh>ih){rh=ih;rw=ih*W/H;}
|
||||
ox=(iw-rw)/2;oy=(ih-rh)/2;
|
||||
if(iw!=lastw||ih!=lasth){
|
||||
for(i=0;i<rw;i++)xmap[i]=(ULONG)i*W/rw;
|
||||
lastw=iw;lasth=ih;
|
||||
}
|
||||
if(rgbFrame&&force){ULONG k,n=(ULONG)iw*ih;UWORD bg=rgbPens[pens[0]];for(k=0;k<n;k++)rgbFrame[k]=bg;}
|
||||
else if(!rgbFrame)memset(scaled,(UBYTE)pens[0],(ULONG)iw*ih);
|
||||
prevy=-1;
|
||||
for(y=damageY>oy?damageY-oy:0;y<rh&&y+oy<damageY+damageH;y++){
|
||||
srcy=(ULONG)y*H/rh;row=scaled+(ULONG)(oy+y)*iw+ox;
|
||||
if(rgbFrame){
|
||||
UWORD *dst=rgbFrame+(ULONG)(oy+y)*iw+ox;
|
||||
for(x=damageX>ox?damageX-ox:0;x<rw&&x+ox<damageX+damageW;x++)dst[x]=rgbPens[frame[srcy*W+xmap[x]]];
|
||||
}else{
|
||||
if(srcy==prevy)memcpy(row,row-iw,rw);
|
||||
else for(x=0;x<rw;x++)row[x]=frame[srcy*W+xmap[x]];
|
||||
}
|
||||
prevy=srcy;
|
||||
}
|
||||
if(rgbFrame)uploadRGB(&backRPort,iw,ih);
|
||||
else writeBack(&backRPort,scaled,iw,ih);
|
||||
}
|
||||
/* Finish conversion, then present once per refresh. A resize between
|
||||
rendering and presentation invalidates the old geometry: skip that frame. */
|
||||
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);
|
||||
force=0;
|
||||
WaitBlit();
|
||||
}
|
||||
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(background);free(frame);free(sprites);
|
||||
free(scaled);free(xmap);free(rgbFrame);
|
||||
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,26 @@
|
||||
param([string]$Toolchain = $env:BOING_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/Boing3D boing.c
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Compilazione fallita.' }
|
||||
Copy-Item -LiteralPath assets/background.bin,assets/sprites.bin,assets/Boing3D.info -Destination $buildPath -Force
|
||||
} finally { Pop-Location }
|
||||
} finally {
|
||||
$env:VBCC = $previousVBCC
|
||||
$env:PATH = $previousPath
|
||||
}
|
||||
Write-Output ('Pronto per Amiga: ' + $buildPath)
|
||||
@@ -0,0 +1,57 @@
|
||||
from pathlib import Path
|
||||
import math
|
||||
from PIL import Image, ImageDraw
|
||||
root=Path(__file__).parent
|
||||
out=root/'assets'
|
||||
out.mkdir(exist_ok=True)
|
||||
W,H,R,N=400,300,57,64
|
||||
palette=[(170,170,170),(145,0,145),(75,75,75),(110,110,110),(215,215,215)]
|
||||
palette += [(int(160+i*95/7),int(8+i*12/7),int(8+i*12/7)) for i in range(8)]
|
||||
palette += [(int(160+i*95/7),)*3 for i in range(8)]
|
||||
bg=Image.new('P',(W,H),0)
|
||||
bg.putpalette(sum((list(c) for c in palette),[])+[0]*(768-len(palette)*3))
|
||||
d=ImageDraw.Draw(bg)
|
||||
# Perspective room: same camera and dimensions used by the C animation.
|
||||
def project(x,y,z):
|
||||
return (200+x*340/(260+z),100+(150-y)*340/(260+z))
|
||||
def line(a,b): d.line((project(*a),project(*b)),fill=1)
|
||||
def plane(points,color):d.polygon([project(*v) for v in points],fill=color)
|
||||
plane([(-190,0,400),(190,0,400),(190,250,400),(-190,250,400)],4)
|
||||
plane([(-190,0,0),(-190,0,400),(-190,250,400),(-190,250,0)],3)
|
||||
plane([(190,0,0),(190,0,400),(190,250,400),(190,250,0)],3)
|
||||
for x in range(-190,191,38):
|
||||
line((x,0,0),(x,0,400))
|
||||
line((x,0,400),(x,250,400))
|
||||
for z in range(0,401,40):
|
||||
line((-190,0,z),(190,0,z))
|
||||
line((-190,0,z),(-190,250,z))
|
||||
line((190,0,z),(190,250,z))
|
||||
for y in range(0,251,50):
|
||||
line((-190,y,400),(190,y,400))
|
||||
line((-190,y,0),(-190,y,400))
|
||||
line((190,y,0),(190,y,400))
|
||||
(out/'background.bin').write_bytes(bg.tobytes())
|
||||
sprites=bytearray()
|
||||
for phase in range(N):
|
||||
im=Image.new('P',(R*2,R*2),255); im.putpalette(bg.getpalette())
|
||||
for y in range(R*2):
|
||||
for x in range(R*2):
|
||||
nx=(x+.5-R)/R; ny=(y+.5-R)/R; rr=nx*nx+ny*ny
|
||||
if rr>=1: continue
|
||||
nz=math.sqrt(1-rr)
|
||||
# Tilt the rotation axis, as in the original red/white ball.
|
||||
a=.24; xx=nx*math.cos(a)-ny*math.sin(a); yy=nx*math.sin(a)+ny*math.cos(a)
|
||||
# The checker pattern repeats after two columns (45 degrees).
|
||||
# Sample that period densely instead of aliasing a full turn.
|
||||
lon=math.atan2(xx,nz)+phase*(math.pi/4)/N
|
||||
lat=math.acos(max(-1,min(1,yy)))
|
||||
red=(math.floor((lon+math.pi)*8/math.pi)+math.floor(lat*8/math.pi))%2
|
||||
light=max(0,min(1,.45+.55*(nz*.8-nx*.35-ny*.35)))
|
||||
shade=min(7,int(light*7))
|
||||
im.putpixel((x,y),(5 if red else 13)+shade)
|
||||
sprites.extend(im.tobytes())
|
||||
if phase==3:
|
||||
preview=bg.copy(); preview.paste(im,(120,65),im.point(lambda p:0 if p==255 else 255).convert('1'))
|
||||
preview.convert('RGB').save(out/'preview.png')
|
||||
(out/'sprites.bin').write_bytes(sprites)
|
||||
(root/'palette.h').write_text('static unsigned char colors[][3] = {'+','.join('{%d,%d,%d}'%c for c in palette)+'};\n')
|
||||
@@ -0,0 +1 @@
|
||||
static unsigned char colors[][3] = {{170,170,170},{145,0,145},{75,75,75},{110,110,110},{215,215,215},{160,8,8},{173,9,9},{187,11,11},{200,13,13},{214,14,14},{227,16,16},{241,18,18},{255,20,20},{160,160,160},{173,173,173},{187,187,187},{200,200,200},{214,214,214},{227,227,227},{241,241,241},{255,255,255}};
|
||||
@@ -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