From c52294b0667560cf671dc16699a71282c5880c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Sat, 16 Dec 2023 16:50:33 +0100 Subject: [PATCH] Backport miscellaneous changes from ELF --- .clang-format | 94 +++-------------------------------------- .gitattributes | 1 + .gitignore | 1 + build/effect.mk | 5 ++- effects/Config.fs-uae | 1 + effects/Makefile | 1 + include/effect.h | 14 +++++- include/sprite.h | 9 ++-- include/sync.h | 8 ++++ lib/libgfx/MakeSprite.c | 4 +- lib/libpt/pt.asm | 10 +++-- system/amiga.lds | 1 + system/effect.c | 4 +- tools/disass.py | 2 +- tools/png2c/.gitignore | 2 + tools/sync2c/main.go | 14 +++++- 16 files changed, 66 insertions(+), 105 deletions(-) create mode 100644 tools/png2c/.gitignore diff --git a/.clang-format b/.clang-format index e366c931..5c82e9fe 100644 --- a/.clang-format +++ b/.clang-format @@ -1,93 +1,9 @@ --- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Attach -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: false +BasedOnStyle: LLVM +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline ConstructorInitializerIndentWidth: 2 ContinuationIndentWidth: 2 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ TAILQ_FOREACH, SPLAY_FOREACH, RB_FOREACH, WITH_MTX_LOCK, - WITH_SPIN_LOCK, WITH_RW_LOCK, SET_FOREACH, LIST_FOREACH, - TAILQ_FOREACH_REVERSE, TAILQ_FOREACH_SAFE, - LIST_FOREACH_SAFE, WITH_VM_MAP_LOCK ] -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - - Regex: '^(<|"(gtest|isl|json)/)' - Priority: 3 - - Regex: '.*' - Priority: 1 +IndentCaseBlocks: true IndentCaseLabels: true -IndentWidth: 2 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: false -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 8 -UseTab: Never -... - +SortIncludes: Never diff --git a/.gitattributes b/.gitattributes index b60c1d98..a7c5f0a0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ ahxWaves filter=lfs diff=lfs merge=lfs -text +*.akp filter=lfs diff=lfs merge=lfs -text *.bin filter=lfs diff=lfs merge=lfs -text *.BIN filter=lfs diff=lfs merge=lfs -text *.mod filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index d29b868e..b764ea0e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ gdb-dashboard *.exe.map *.rom *.7z +*.dSYM # AmigaOS files *.info diff --git a/build/effect.mk b/build/effect.mk index 0429d797..6e0ef76a 100644 --- a/build/effect.mk +++ b/build/effect.mk @@ -8,7 +8,8 @@ LIBS += libblit libgfx libmisc libc LDEXTRA = $(TOPDIR)/system/system.a LDEXTRA += $(foreach lib,$(LIBS),$(TOPDIR)/lib/$(lib)/$(lib).a) -CRT0 = $(TOPDIR)/system/crt0.o $(TOPDIR)/effects/main.o +CRT0 = $(TOPDIR)/system/crt0.o +MAIN ?= $(TOPDIR)/effects/main.o BOOTLOADER = $(TOPDIR)/bootloader.bin ROMSTARTUP = $(TOPDIR)/a500rom.bin BOOTBLOCK = $(TOPDIR)/addchip.bootblock.bin @@ -44,7 +45,7 @@ $(TOPDIR)/%.bin: FORCE include $(TOPDIR)/build/common.mk -$(EFFECT).exe.dbg $(EFFECT).exe: $(CRT0) $(OBJECTS) $(LDEXTRA) $(LDSCRIPT) +$(EFFECT).exe.dbg $(EFFECT).exe: $(CRT0) $(MAIN) $(OBJECTS) $(LDEXTRA) $(LDSCRIPT) @echo "[LD] $(addprefix $(DIR),$(OBJECTS)) -> $(DIR)$@" $(LD) $(LDFLAGS) -L$(TOPDIR)/system -T$(LDSCRIPT) -Map=$@.map -o $@ \ --start-group $(filter-out %.lds,$^) --end-group diff --git a/effects/Config.fs-uae b/effects/Config.fs-uae index 00e629bf..62038770 100644 --- a/effects/Config.fs-uae +++ b/effects/Config.fs-uae @@ -13,6 +13,7 @@ amiga_model = A500 # uae_cpu_model = 68010 # uae_cpu_multiplier = 16 automatic_input_grab = 0 +stereo_separation = 0 floppy_drive_speed = 800 # floppy_drive_speed = 100 floppy_drive_volume = 10 diff --git a/effects/Makefile b/effects/Makefile index 5c5e0826..ca871c98 100644 --- a/effects/Makefile +++ b/effects/Makefile @@ -16,6 +16,7 @@ SUBDIRS := \ flatshade-convex \ floor \ floor-old \ + game-of-life \ glitch \ growing-tree \ gui \ diff --git a/include/effect.h b/include/effect.h index 51c09a41..3954780b 100644 --- a/include/effect.h +++ b/include/effect.h @@ -26,13 +26,13 @@ /* * Number of frames (50Hz) from time point when Render() was called first. */ -extern int frameCount; +extern short frameCount; /* * The time when Render() was called previously. * Used to calculate how much did it take to render last frame. */ -extern int lastFrameCount; +extern short lastFrameCount; /* * When set to true effect render loop breaks. @@ -40,6 +40,11 @@ extern int lastFrameCount; */ extern bool exitLoop; +#ifdef INTRO +extern short frameFromStart; +extern short frameTillEnd; +#endif + typedef void (*EffectFuncT)(void); typedef struct Effect { @@ -82,6 +87,11 @@ void EffectKill(EffectT *effect); void EffectUnLoad(EffectT *effect); void EffectRun(EffectT *effect); +#ifdef INTRO +#undef ALIAS +#define ALIAS(a, b) +#endif + #define EFFECT(NAME, L, U, I, K, R, V) \ EffectT NAME##Effect = { \ .name = #NAME, \ diff --git a/include/sprite.h b/include/sprite.h index 1674ca65..3e23c1cb 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -90,10 +90,13 @@ static inline int SprDataSize(u_short height, u_short nctrl) { * Information about sprite will be written back to `spr` structure. * Marks sprite as attached if `attached` is set to true. * - * Returns a pointer to next usable sprite data (possibly uninitialized). - * You should call MakeSprite or EndSprite on return value. + * `datp` will point to next usable sprite data (possibly uninitialized). + * You should call MakeSprite or EndSprite on this value. + * + * Returns pointer to first word of sprite data. */ -void MakeSprite(SprDataT **datp, u_int height, bool attached, SpriteT *spr); +SprWordT *MakeSprite(SprDataT **datp, u_int height, bool attached, + SpriteT *spr); /* * Terminate sprite data for DMA channel by writing zero long word after diff --git a/include/sync.h b/include/sync.h index 56990797..8e8989e7 100644 --- a/include/sync.h +++ b/include/sync.h @@ -44,4 +44,12 @@ typedef struct Track { void TrackInit(TrackT *track); short TrackValueGet(TrackT *track, short frame); +static inline short CurrKeyFrame(TrackT *track) { + return track->curr->frame; +} + +static inline short NextKeyFrame(TrackT *track) { + return track->next->frame; +} + #endif diff --git a/lib/libgfx/MakeSprite.c b/lib/libgfx/MakeSprite.c index b0155697..5fe960d2 100644 --- a/lib/libgfx/MakeSprite.c +++ b/lib/libgfx/MakeSprite.c @@ -1,6 +1,7 @@ #include -void MakeSprite(SprDataT **datp, u_int height, bool attached, SpriteT *spr) { +SprWordT *MakeSprite(SprDataT **datp, u_int height, bool attached, SpriteT *spr) +{ SprDataT *dat = *datp; *datp = (SprDataT *)&dat->data[height]; spr->sprdat = dat; @@ -8,4 +9,5 @@ void MakeSprite(SprDataT **datp, u_int height, bool attached, SpriteT *spr) { spr->attached = attached; dat->pos = SPRPOS(0, 0); dat->ctl = SPRCTL(0, 0, attached, height); + return &dat->data[0]; } diff --git a/lib/libpt/pt.asm b/lib/libpt/pt.asm index 49582a64..19d690c2 100644 --- a/lib/libpt/pt.asm +++ b/lib/libpt/pt.asm @@ -17,29 +17,31 @@ _PtInstallCIA: st.b d0 move.l _ExcVecBase,a0 lea $dff000,a6 - bsr _mt_install_cia + jsr _mt_install_cia movem.l (sp)+,d2-d7/a2-a6 rts _PtRemoveCIA: movem.l d2-d7/a2-a6,-(sp) lea $dff000,a6 - bsr _mt_remove_cia + jsr _mt_remove_cia movem.l (sp)+,d2-d7/a2-a6 rts _PtInit: movem.l d2-d7/a2-a6,-(sp) lea $dff000,a6 - bsr _mt_init + jsr _mt_init movem.l (sp)+,d2-d7/a2-a6 rts _PtEnd: movem.l d2-d7/a2-a6,-(sp) lea $dff000,a6 - bsr _mt_end + jsr _mt_end movem.l (sp)+,d2-d7/a2-a6 rts + section '.text.ptplayer',code + include 'ptplayer.asm' diff --git a/system/amiga.lds b/system/amiga.lds index 46eeccfe..6e13b256 100644 --- a/system/amiga.lds +++ b/system/amiga.lds @@ -13,6 +13,7 @@ SECTIONS { __text = .; *(.text) + *(.text.*) } __text_size = SIZEOF(.text); . = ALIGN(0x0); diff --git a/system/effect.c b/system/effect.c index 0cf1dc85..56034f68 100644 --- a/system/effect.c +++ b/system/effect.c @@ -2,8 +2,8 @@ #include #include -int frameCount = 0; -int lastFrameCount = 0; +short frameCount = 0; +short lastFrameCount = 0; bool exitLoop = false; #define SHOW_MEMORY_STATS 0 diff --git a/tools/disass.py b/tools/disass.py index 61a732e7..9451cc2b 100755 --- a/tools/disass.py +++ b/tools/disass.py @@ -391,7 +391,7 @@ def cycles(self, mnemonic, operands): if mnemonic in ['bclr']: dynamic = self.is_dreg(o0) - if self.is_dreg(o1): + if not self.is_dreg(o1): return self.operand_cost(8 if dynamic else 12, 'b', o1) return 10 if dynamic else 14 diff --git a/tools/png2c/.gitignore b/tools/png2c/.gitignore new file mode 100644 index 00000000..1268f15b --- /dev/null +++ b/tools/png2c/.gitignore @@ -0,0 +1,2 @@ +png2c +png2c.exe diff --git a/tools/sync2c/main.go b/tools/sync2c/main.go index b59a4235..0590b29e 100644 --- a/tools/sync2c/main.go +++ b/tools/sync2c/main.go @@ -25,7 +25,7 @@ const ( ) const ( - FramesPerRow = 6 // Assuming constant BPM of 125 + FramesPerRow = 3 // Assuming constant BPM of 125 ) type TrackItem struct { @@ -71,8 +71,20 @@ func parseFrame(token string) (frame int64, err error) { if token[0] == '$' { if len(token) != 5 { err = &parseError{"key must be 4 hex digit protracker song position"} + return } + frame, err = strconv.ParseInt(token[1:], 16, 16) + if err != nil { + return + } + + if frame&0xC0 != 0 { + err = &parseError{"not a valid pattern row"} + return + } + + frame = frame&63 | (frame>>2)&-64 frame *= FramesPerRow } else { var f float64