Skip to content

Commit

Permalink
Stub of a new production.
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent 71d7ebc commit 3c942de
Show file tree
Hide file tree
Showing 13 changed files with 504 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TOPDIR = $(realpath .)

SUBDIRS = tools lib system effects
SUBDIRS = tools lib system effects demo
EXTRA-FILES = tags cscope.out
CLEAN-FILES = bootloader.bin a500rom.bin addchip.bootblock.bin vbrmove

Expand Down
1 change: 1 addition & 0 deletions build/effect.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ VBRMOVE = $(TOPDIR)/vbrmove

EXTRA-FILES += $(DATA_GEN) $(EFFECT).adf
CLEAN-FILES += $(DATA_GEN) $(EFFECT).exe $(EFFECT).exe.dbg $(EFFECT).exe.map
CLEAN-FILES += $(EFFECT).img $(EFFECT).rom

ifeq ($(AMIGAOS), 0)
EXTRA-FILES += $(EFFECT).img $(EFFECT).rom
Expand Down
69 changes: 69 additions & 0 deletions demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
TOPDIR := $(realpath ..)

DELTA := 1

DEMONAME = Demo
MODULE := JazzCat-ElectricLifeforms

OBJECTS := data/$(MODULE).trk.o

ifeq ($(DELTA), 1)
OBJECTS += data/$(MODULE)-Delta.smp.o
else
OBJECTS += data/$(MODULE).smp.o
endif

LIBS := libpt

CLEAN-FILES := data/$(MODULE)*.o data/$(MODULE).{smp,trk}* data/loader.c

SOURCES := main.c load.c empty.c
MAIN := #

CPPFLAGS += -DDELTA=$(DELTA) -I.

PNG2C.loader := --bitmap loader,64x64x1 --palette loader,2

include $(TOPDIR)/build/effect.mk

data/%.trk data/%.smp: data/%.mod
$(PYTHON3) $(TOPDIR)/effects/playpt/data/ptsplit.py $^
mv data/$*.mod.trk data/$*.trk
mv data/$*.mod.smp data/$*.smp

OBJCOPY-CHIP := --rename-section .data=.datachip,alloc,load,data,contents

data/%.trk.o: data/%.trk
@echo "[OBJCOPY] $(DIR)$< -> $(DIR)$@"
$(OBJCOPY) -I binary -O amiga \
--redefine-sym _binary_data_$(subst -,_,$*)_trk_start=_Module \
--redefine-sym _binary_data_$(subst -,_,$*)_trk_end=_ModuleEnd \
--redefine-sym _binary_data_$(subst -,_,$*)_trk_size=_ModuleSize \
$^ $@

data/%-Delta.smp: data/%.smp
@echo "[DELTA] $(DIR)$< -> $(DIR)$@"
$(PYTHON3) delta.py $< $@

data/%.smp.o: data/%.smp
@echo "[OBJCOPY] $(DIR)$< -> $(DIR)$@"
$(OBJCOPY) $(OBJCOPY-CHIP) -I binary -O amiga \
--redefine-sym _binary_data_$(subst -,_,$*)_smp_start=_Samples \
--redefine-sym _binary_data_$(subst -,_,$*)_smp_end=_SamplesEnd \
--redefine-sym _binary_data_$(subst -,_,$*)_smp_size=_SamplesSize \
$^ $@

data/%.o: data/%.txt
@echo "[OBJCOPY] $(DIR)$< -> $(DIR)$@"
$(OBJCOPY) -I binary -O amiga \
--redefine-sym _binary_data_$(subst -,_,$*)_txt_start=_Text \
--redefine-sym _binary_data_$(subst -,_,$*)_txt_end=_TextEnd \
--redefine-sym _binary_data_$(subst -,_,$*)_txt_size=_TextSize \
$^ $@

REPOHEAD := $(shell git rev-parse --short HEAD)

%.exe.packed: %.exe
@echo "[PACK] $(DIR)$< -> $(DIR)$@"
Shrinkler -o -f 0xdff180 \
-t "$(DEMONAME) by Ghostown (build: $(REPOHEAD))" $< $@
2 changes: 2 additions & 0 deletions demo/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.c
*.delta
3 changes: 3 additions & 0 deletions demo/data/JazzCat-ElectricLifeforms.mod
Git LFS file not shown
4 changes: 4 additions & 0 deletions demo/data/demo.sync
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@track EffectNumber
$0000 0 !step
$1000 -1
@end
3 changes: 3 additions & 0 deletions demo/data/loader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions demo/delta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import argparse
from array import array

if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Encode 8-bit samples with delta encoding.')
parser.add_argument(
'decoded', metavar='DECODED', type=str, help='Decoded samples file.')
parser.add_argument(
'encoded', metavar='ENCODED', type=str, help='Encoded samples file.')
args = parser.parse_args()

data = array('B')

with open(args.decoded, 'rb') as f:
data.frombytes(f.read())
data.append(0)

out = array('B')
for i in range(len(data) - 1):
out.append((data[i] - data[i - 1]) & 255)

with open(args.encoded, 'wb') as f:
f.write(out)
21 changes: 21 additions & 0 deletions demo/demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __DEMO_H__
#define __DEMO_H__

#include <bitmap.h>
#include <palette.h>
#include <sync.h>
#include <effect.h>

short UpdateFrameCount(void);

static inline short FromCurrKeyFrame(TrackT *track) {
return frameCount - CurrKeyFrame(track);
}

static inline short TillNextKeyFrame(TrackT *track) {
return NextKeyFrame(track) - frameCount;
}

void FadeBlack(const u_short *colors, short count, u_int start, short step);

#endif /* !__DEMO_H__ */
12 changes: 12 additions & 0 deletions demo/empty.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <effect.h>

static void Init(void) {
}

static void Kill(void) {
}

static void Render(void) {
}

EFFECT(Empty, NULL, NULL, Init, Kill, Render, NULL);
77 changes: 77 additions & 0 deletions demo/load.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <demo.h>
#include <debug.h>
#include <copper.h>
#include <blitter.h>
#include <gfx.h>
#include <line.h>

#define _SYSTEM
#include <system/memory.h>
#include <system/interrupt.h>

#include "data/loader.c"

#define X1 96
#define Y1 (120 + 32)
#define X2 224
#define Y2 (136 + 24)

/* from 0 to 256 */
static volatile short LoadProgress = 0;

static int ProgressBarUpdate(void) {
static __code short x = 0;
short newX = LoadProgress >> 1;
for (; x < newX; x++) {
CpuLine(X1 + x, Y1, X1 + x, Y2);
}
return 0;
}

INTSERVER(ProgressBarInterrupt, 0, (IntFuncT)ProgressBarUpdate, NULL);

static void LoadData(void) {
while (LoadProgress < 256) {
LoadProgress++;
WaitVBlank();
}
}

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

void LoadDemo(void) {
BitmapT *screen = NewBitmap(WIDTH, HEIGHT, DEPTH, BM_CLEAR);
CopListT *cp = NewCopList(40);

CpuLineSetup(screen, 0);
CpuLine(X1 - 1, Y1 - 2, X2 + 1, Y1 - 2);
CpuLine(X1 - 1, Y2 + 1, X2 + 1, Y2 + 1);
CpuLine(X1 - 2, Y1 - 1, X1 - 2, Y2 + 1);
CpuLine(X2 + 2, Y1 - 1, X2 + 2, Y2 + 1);

SetupPlayfield(MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT);
LoadColors(loader_colors, 0);

EnableDMA(DMAF_BLITTER);
BitmapCopy(screen, (WIDTH - loader_width) / 2, Y1 - loader_height - 16,
&loader);
WaitBlitter();
DisableDMA(DMAF_BLITTER);

CopSetupBitplanes(cp, screen, DEPTH);
CopListFinish(cp);
CopListActivate(cp);

EnableDMA(DMAF_RASTER);

AddIntServer(INTB_VERTB, ProgressBarInterrupt);
LoadData();
RemIntServer(INTB_VERTB, ProgressBarInterrupt);

DisableDMA(DMAF_RASTER);
DeleteCopList(cp);

DeleteBitmap(screen);
}
Loading

0 comments on commit 3c942de

Please sign in to comment.