Skip to content

Commit

Permalink
Backport miscellaneous changes from ELF
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent f3d5a5c commit c52294b
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 105 deletions.
94 changes: 5 additions & 89 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gdb-dashboard
*.exe.map
*.rom
*.7z
*.dSYM

# AmigaOS files
*.info
Expand Down
5 changes: 3 additions & 2 deletions build/effect.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions effects/Config.fs-uae
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions effects/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SUBDIRS := \
flatshade-convex \
floor \
floor-old \
game-of-life \
glitch \
growing-tree \
gui \
Expand Down
14 changes: 12 additions & 2 deletions include/effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@
/*
* 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.
* Normally set by LeftMouseButton routine, but can be overwritten.
*/
extern bool exitLoop;

#ifdef INTRO
extern short frameFromStart;
extern short frameTillEnd;
#endif

typedef void (*EffectFuncT)(void);

typedef struct Effect {
Expand Down Expand Up @@ -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, \
Expand Down
9 changes: 6 additions & 3 deletions include/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions include/sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion lib/libgfx/MakeSprite.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include <sprite.h>

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;
spr->height = height;
spr->attached = attached;
dat->pos = SPRPOS(0, 0);
dat->ctl = SPRCTL(0, 0, attached, height);
return &dat->data[0];
}
10 changes: 6 additions & 4 deletions lib/libpt/pt.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions system/amiga.lds
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SECTIONS
{
__text = .;
*(.text)
*(.text.*)
}
__text_size = SIZEOF(.text);
. = ALIGN(0x0);
Expand Down
4 changes: 2 additions & 2 deletions system/effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <effect.h>
#include <system/cia.h>

int frameCount = 0;
int lastFrameCount = 0;
short frameCount = 0;
short lastFrameCount = 0;
bool exitLoop = false;

#define SHOW_MEMORY_STATS 0
Expand Down
2 changes: 1 addition & 1 deletion tools/disass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions tools/png2c/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
png2c
png2c.exe
14 changes: 13 additions & 1 deletion tools/sync2c/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
)

const (
FramesPerRow = 6 // Assuming constant BPM of 125
FramesPerRow = 3 // Assuming constant BPM of 125
)

type TrackItem struct {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c52294b

Please sign in to comment.