Skip to content

Commit

Permalink
Backported changes from f4f7128
Browse files Browse the repository at this point in the history
* Add VBlank hook to effects
* Make effects use the VBlank handler
* Remove ptplayer.asm features on demand
* Fix mt_data symbol address
* Fix anim-polygons Makefile
* EffectRun: do not render same frame multiple times.
  • Loading branch information
spookbench authored and cahirwpz committed Dec 16, 2023
1 parent 6432b78 commit e679bcd
Show file tree
Hide file tree
Showing 60 changed files with 116 additions and 113 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TOPDIR = $(realpath .)

SUBDIRS = tools lib effects
SUBDIRS = tools lib system effects
EXTRA-FILES = tags cscope.out
CLEAN-FILES = bootloader.bin a500rom.bin addchip.bootblock.bin vbrmove
Expand Down
2 changes: 1 addition & 1 deletion effects/anim-polygons/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ PNG2C.dancing-pal := --pixmap gradient,16x22x12

include $(TOPDIR)/build/effect.mk

%.c: %.svg
data/%.c: data/%.svg
@echo "[ANIM] $(DIR)$< -> $(DIR)$@"
$(PYTHON3) encode.py $< > $@
2 changes: 1 addition & 1 deletion effects/anim-polygons/anim-polygons.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ static void Render(void) {
maybeSkipFrame = 1;
}

EFFECT(AnimPolygons, NULL, NULL, Init, Kill, Render);
EFFECT(AnimPolygons, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/anim/anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ static void Render(void) {
active = (active + 1) % (DEPTH + 1);
}

EFFECT(Anim, Load, UnLoad, Init, Kill, Render);
EFFECT(Anim, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/ball/ball.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Ball, NULL, NULL, Init, Kill, Render);
EFFECT(Ball, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/blurred/blurred.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Blurred, Load, UnLoad, Init, Kill, Render);
EFFECT(Blurred, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/blurred3d/blurred3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,4 @@ static void Render(void) {
swapr(screen0, screen1);
}

EFFECT(Blurred3D, Load, UnLoad, Init, Kill, Render);
EFFECT(Blurred3D, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/bobs3d/bobs3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,4 @@ static void Render(void) {
swapr(screen0, screen1);
}

EFFECT(Bobs3D, NULL, NULL, Init, Kill, Render);
EFFECT(Bobs3D, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/bumpmap-rgb/bumpmap-rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(BumpMapRGB, Load, UnLoad, Init, Kill, Render);
EFFECT(BumpMapRGB, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/butterfly-gears/butterfly-gears.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ static void Render(void) {
TaskWaitVBlank();
}

EFFECT(ButterflyGears, NULL, NULL, Init, Kill, Render);
EFFECT(ButterflyGears, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/circles/circles.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ static void Render(void) {
TaskWaitVBlank();
}

EFFECT(Circles, NULL, NULL, Init, Kill, Render);
EFFECT(Circles, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/credits/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,4 @@ static void Render(void) {
swapr(cp0, cp1);
}

EFFECT(Credits, NULL, NULL, Init, Kill, Render);
EFFECT(Credits, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/empty/empty.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ static void Render(void) {
TaskWaitVBlank();
}

EFFECT(Empty, NULL, NULL, Init, Kill, Render);
EFFECT(Empty, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/flatshade-convex/flatshade-convex.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(FlatShadeConvex, Load, UnLoad, Init, Kill, Render);
EFFECT(FlatShadeConvex, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/flatshade/flatshade.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,4 @@ static void Render(void) {
swapr(screen0, screen1);
}

EFFECT(FlatShade, Load, UnLoad, Init, Kill, Render);
EFFECT(FlatShade, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/floor-old/floor-old.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(FloorOld, Load, UnLoad, Init, Kill, Render);
EFFECT(FloorOld, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/floor/floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Floor, NULL, NULL, Init, Kill, Render);
EFFECT(Floor, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/game-of-life/game-of-life.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,4 +522,4 @@ static void Render(void) {
#endif
}

EFFECT(GameOfLife, NULL, NULL, Init, Kill, Render);
EFFECT(GameOfLife, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/glitch/glitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Glitch, NULL, NULL, Init, Kill, Render);
EFFECT(Glitch, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/growing-tree/growing-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ static void Render(void) {
TaskWaitVBlank();
}

EFFECT(GrowingTree, NULL, NULL, Init, Kill, Render);
EFFECT(GrowingTree, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ static void Render(void) {
exitLoop = !HandleEvent();
}

EFFECT(GUI, Load, NULL, Init, Kill, Render);
EFFECT(GUI, Load, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/highway/highway.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(HighWay, NULL, NULL, Init, Kill, Render);
EFFECT(HighWay, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/kbtest/kbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ static void Render(void) {
exitLoop = !HandleEvent();
}

EFFECT(KbdTest, NULL, NULL, Init, Kill, Render);
EFFECT(KbdTest, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/layers/layers.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,4 @@ static void Render(void) {
swapr(cp0, cp1);
}

EFFECT(Credits, NULL, NULL, Init, Kill, Render);
EFFECT(Credits, NULL, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/lines/lines.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ static void Render(void) {
ProfilerStop(Lines);
}

EFFECT(Lines, Load, UnLoad, Init, NULL, Render);
EFFECT(Lines, Load, UnLoad, Init, NULL, Render, NULL);
14 changes: 13 additions & 1 deletion effects/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ static void StartBgTask(void) {
}
#endif

static int VBlankISR(void) {
if (Effect.VBlank)
Effect.VBlank();
return 0;
}

INTSERVER(VBlankInterrupt, 0, (IntFuncT)VBlankISR, NULL);

int main(void) {
/* NOP that triggers fs-uae debugger to stop and inform GDB that it should
* fetch segments locations to relocate symbol information read from file. */
asm volatile("exg %d7,%d7");

AddIntServer(INTB_VERTB, VBlankInterrupt);

#if BGTASK
StartBgTask();
#endif
Expand All @@ -39,5 +49,7 @@ int main(void) {
EffectKill(&Effect);
EffectUnLoad(&Effect);

return 0;
RemIntServer(INTB_VERTB, VBlankInterrupt);

return 0;
}
2 changes: 1 addition & 1 deletion effects/metaballs/metaballs.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(MetaBalls, Load, UnLoad, Init, Kill, Render);
EFFECT(MetaBalls, Load, UnLoad, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/multipipe/multipipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(MultiPipe, Load, UnLoad, Init, Kill, Render);
EFFECT(MultiPipe, Load, UnLoad, Init, Kill, Render, NULL);
13 changes: 3 additions & 10 deletions effects/neons/neons.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "2d.h"
#include "fx.h"
#include <stdlib.h>
#include <system/interrupt.h>

#define WIDTH 320
#define HEIGHT 256
Expand Down Expand Up @@ -108,7 +107,7 @@ static void UnLoad(void) {
DeleteBitmap(screen[1]);
}

static int CustomRotatePalette(void) {
static void CustomRotatePalette(void) {
u_short *src = palette[0]->colors;
CopInsT *ins = pal + 1;
int i = frameCount;
Expand All @@ -117,11 +116,9 @@ static int CustomRotatePalette(void) {
while (--n >= 0)
CopInsSet16(ins++, src[i++ & 15]);

return 0;
return;
}

INTSERVER(RotatePaletteInterrupt, 0, (IntFuncT)CustomRotatePalette, NULL);

static void Init(void) {
EnableDMA(DMAF_BLITTER);

Expand All @@ -143,15 +140,11 @@ static void Init(void) {

CopListActivate(cp);
EnableDMA(DMAF_RASTER);

AddIntServer(INTB_VERTB, RotatePaletteInterrupt);
}

static void Kill(void) {
DisableDMA(DMAF_COPPER | DMAF_RASTER | DMAF_BLITTER);

RemIntServer(INTB_VERTB, RotatePaletteInterrupt);

DeleteCopList(cp);
}

Expand Down Expand Up @@ -228,4 +221,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Neons, Load, UnLoad, Init, Kill, Render);
EFFECT(Neons, Load, UnLoad, Init, Kill, Render, CustomRotatePalette);
2 changes: 1 addition & 1 deletion effects/plasma/plasma.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Plasma, Load, NULL, Init, Kill, Render);
EFFECT(Plasma, Load, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/playahx/playahx.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ static bool HandleEvent(void) {
return true;
}

EFFECT(PlayAHX, NULL, NULL, Init, Kill, Render);
EFFECT(PlayAHX, NULL, NULL, Init, Kill, Render, NULL);
15 changes: 4 additions & 11 deletions effects/playctr/playctr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <console.h>
#include <copper.h>
#include <system/event.h>
#include <system/interrupt.h>
#include <system/keyboard.h>
#include <system/memory.h>

Expand Down Expand Up @@ -49,16 +48,14 @@ static void UnLoad(void) {
MemFree(module);
}

static int CinterMusic(void) {
static void CinterMusic(void) {
if (stopped)
return 0;
return;
CinterPlay1(player);
CinterPlay2(player);
return 0;
return;
}

INTSERVER(CinterMusicServer, 10, (IntFuncT)CinterMusic, NULL);

static void Init(void) {
KeyboardInit();

Expand All @@ -83,8 +80,6 @@ static void Init(void) {
CinterInit(module, instruments, player);
musicStart = player->c_MusicPointer;

AddIntServer(INTB_VERTB, CinterMusicServer);

ConsoleSetCursor(&console, 0, 0);
ConsolePutStr(&console,
"Pause (SPACE) -10s (LEFT) +10s (RIGHT)\n"
Expand All @@ -94,8 +89,6 @@ static void Init(void) {
}

static void Kill(void) {
RemIntServer(INTB_VERTB, CinterMusicServer);

DisableDMA(DMAF_COPPER | DMAF_RASTER | DMAF_AUDIO);

DeleteCopList(cp);
Expand Down Expand Up @@ -173,4 +166,4 @@ static bool HandleEvent(void) {
return true;
}

EFFECT(PlayCinter, Load, UnLoad, Init, Kill, Render);
EFFECT(PlayCinter, Load, UnLoad, Init, Kill, Render, CinterMusic);
8 changes: 1 addition & 7 deletions effects/playp61/playp61.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <copper.h>
#include <p61.h>
#include <system/event.h>
#include <system/interrupt.h>
#include <system/keyboard.h>
#include <system/memory.h>
#include <system/timer.h>
Expand All @@ -24,8 +23,6 @@ static CopListT *cp;
static ConsoleT console;
static CIATimerT *p61tmr;

INTSERVER(P61PlayerServer, 10, (IntFuncT)P61_Music, NULL);

static inline void putpixel(u_char *line, short x) {
bset(line + (x >> 3), ~x);
}
Expand Down Expand Up @@ -118,8 +115,6 @@ static void Init(void) {
P61_Init(module, NULL, NULL);
P61_ControlBlock.Play = 1;

AddIntServer(INTB_VERTB, P61PlayerServer);

ConsolePutStr(&console,
"Pause (SPACE) Prev (LEFT) Next (RIGHT)\n"
"Exit (ESC)\n");
Expand All @@ -129,7 +124,6 @@ static void Kill(void) {
P61_ControlBlock.Play = 0;
P61_End();

RemIntServer(INTB_VERTB, P61PlayerServer);
ReleaseTimer(p61tmr);

DisableDMA(DMAF_COPPER | DMAF_RASTER | DMAF_BLITTER);
Expand Down Expand Up @@ -222,4 +216,4 @@ static bool HandleEvent(void) {
return true;
}

EFFECT(PlayP61, NULL, NULL, Init, Kill, Render);
EFFECT(PlayP61, NULL, NULL, Init, Kill, Render, P61_Music);
13 changes: 7 additions & 6 deletions effects/playpt/playpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
#include <console.h>
#include <copper.h>
#include <system/event.h>
#include <system/interrupt.h>
#include <system/keyboard.h>
#include <system/memory.h>

#define WIDTH 320
#define HEIGHT 256
#define DEPTH 1

/* XXX: Always consult this value with AmigaKlang output,
* otherwise you'll experience a really nasty debugging session. */
#define AKLANG_BUFLEN 36864

#include "data/lat2-08.c"

extern u_char Module[];
Expand All @@ -28,14 +31,12 @@ extern u_int AK_Progress;
void AK_Generate(void *TmpBuf asm("a1"));

static void Load(void) {
void *TmpBuf = MemAlloc(32768, MEMF_PUBLIC);
void *TmpBuf = MemAlloc(AKLANG_BUFLEN, MEMF_PUBLIC);
Log("Generating samples, please wait...\n");
AK_Generate(TmpBuf);
MemFree(TmpBuf);
}

static void UnLoad(void) {
}

static void Init(void) {
KeyboardInit();

Expand Down Expand Up @@ -181,4 +182,4 @@ static bool HandleEvent(void) {
return true;
}

EFFECT(PlayProtracker, Load, UnLoad, Init, Kill, Render);
EFFECT(PlayProtracker, Load, NULL, Init, Kill, Render, NULL);
2 changes: 1 addition & 1 deletion effects/plotter/plotter.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ static void Render(void) {
active ^= 1;
}

EFFECT(Plotter, NULL, NULL, Init, Kill, Render);
EFFECT(Plotter, NULL, NULL, Init, Kill, Render, NULL);
Loading

0 comments on commit e679bcd

Please sign in to comment.