From c0f5dc8500cb3d33ca69fe6a875efe9f1e9f4cc1 Mon Sep 17 00:00:00 2001 From: Aleksandra Date: Wed, 5 Apr 2023 19:45:13 +0200 Subject: [PATCH 1/8] Fix sync bugs (#69) --- intro/data/intro.sync | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/intro/data/intro.sync b/intro/data/intro.sync index 878009cd..d1dd5843 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -32,7 +32,7 @@ $2D00 1 # logo $3000 0 # end -$3300 -1 +$3200 -1 @end @track GhostownLogoPal @@ -389,7 +389,6 @@ $0200 15 @track TurmiteFadeOut $003E 15 !trigger $013E 15 -$023E 15 @end @track TurmitePal @@ -410,23 +409,23 @@ $012E 10 @track UvmapTransition $0000 128 !trigger -$0020 128 $0100 128 -$0120 128 +$0200 128 +$0300 128 @end @track UvmapSrcTexture $0000 1 !step -$0020 0 $0100 0 -$0120 1 +$0200 0 +$0300 1 @end @track UvmapDstTexture $0000 1 !step -$0020 0 -$0100 1 -$0120 0 +$0100 0 +$0200 1 +$0300 0 @end @track WeaveBarPulse From ab32b7cad3f13cf1c4d4b5caa86c283375947f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ob=C5=82onczek?= Date: Wed, 5 Apr 2023 20:17:21 +0200 Subject: [PATCH 2/8] GOL color transitions (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add color transitions between game of life rules; fix palette on vitruvian * Add missing palettes * Slightly better but still meh * Attempt at some better sync * Fix formatting using clang-format. Co-authored-by: Krystian Bacławski --- .clang-format | 94 +++------------------------------------- intro/Makefile | 6 +++ intro/data/gol-pal-1.png | 3 ++ intro/data/gol-pal-2.png | 3 ++ intro/data/gol-pal-3.png | 3 ++ intro/data/gol-pal-4.png | 3 ++ intro/data/intro.sync | 30 ++++++++++--- intro/game-of-life.c | 63 +++++++++++++++------------ intro/gol-palette.c | 82 +++++++++++++++++------------------ intro/gol-transparency.c | 45 ++++++++++--------- 10 files changed, 143 insertions(+), 189 deletions(-) create mode 100644 intro/data/gol-pal-1.png create mode 100644 intro/data/gol-pal-2.png create mode 100644 intro/data/gol-pal-3.png create mode 100644 intro/data/gol-pal-4.png 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/intro/Makefile b/intro/Makefile index 80f62e29..7ead8c73 100644 --- a/intro/Makefile +++ b/intro/Makefile @@ -147,6 +147,7 @@ PNG2C.tilemover-bg-pal := --palette tilemover_bg_pal,6 PNG2C.texture-inside := --pixmap texture_in,64x64x8,+onlydata --palette texture_pal,16 PNG2C.texture-outside := --pixmap texture_out,64x64x8,+onlydata PNG2C.gradient := --pixmap gradient,16x16x12,+onlydata +PNG2C.gol-transitions := --pixmap gol_transitions,3x46x12,+onlydata CPPFLAGS += -DINTRO -DVQ=$(VQ) -DDELTA=$(DELTA) -DKLANG=$(KLANG) -I. @@ -207,6 +208,11 @@ data/gradient.png: $(GRADIENT) data/texture-inside.png @echo "[GEN] $@" $(PYTHON3) $(GRADIENT) load $(word 2,$^) copy hue 0.4 save $@ +data/gol-transitions.png: $(GRADIENT) + @echo "[GEN] $@" + $(PYTHON3) $(GRADIENT) load data/gol-pal-1.png load data/gol-pal-2.png \ + load data/gol-pal-3.png load data/gol-pal-4.png save $@ + audiovq: audiovq.c @echo "[HOSTCC] $(DIR)$< -> $(DIR)$@" cc -O2 -march=native -Wall -o $@ $^ -lm diff --git a/intro/data/gol-pal-1.png b/intro/data/gol-pal-1.png new file mode 100644 index 00000000..9c565c1a --- /dev/null +++ b/intro/data/gol-pal-1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:480a37e320e0a817750b40661ded361af55ed5e0f53281dd500ae04b61c8f596 +size 532 diff --git a/intro/data/gol-pal-2.png b/intro/data/gol-pal-2.png new file mode 100644 index 00000000..b7bd6997 --- /dev/null +++ b/intro/data/gol-pal-2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be5688a44b730b37baaaecb34e883e4162febc2b2abb98920ab7390f186e30d0 +size 532 diff --git a/intro/data/gol-pal-3.png b/intro/data/gol-pal-3.png new file mode 100644 index 00000000..9fe7f7a9 --- /dev/null +++ b/intro/data/gol-pal-3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae730ed593f92a6279a5995ddf3613cc89ac68ff0e6986e9bfbf6e60a4ce53bd +size 4196 diff --git a/intro/data/gol-pal-4.png b/intro/data/gol-pal-4.png new file mode 100644 index 00000000..33b4df0f --- /dev/null +++ b/intro/data/gol-pal-4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdd0e1538d377cd7416490749354c186eed00019220639a81d6deac39fcb5771 +size 4195 diff --git a/intro/data/intro.sync b/intro/data/intro.sync index d1dd5843..5d09c7e2 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -253,10 +253,14 @@ $0A30 2 # Diamoeba $0B20 3 #---second time---# -# maze -$2000 2 # classic -$2100 0 +$2000 0 +# stains +$2020 4 +# day and night +$2100 5 +# Diamoeba +$2130 3 @end @track GOLCellColor @@ -266,7 +270,7 @@ $2020 2 @track GOLLogoColor $2000 0 !step -$2020 1 +$211a 1 @end @track GOLLogoFade @@ -274,8 +278,8 @@ $2000 0 !smooth $2010 0 $2020 15 $2030 0 -$2100 0 -$2110 15 +$211a 0 +$212a 15 @end # logo bitmap: @@ -283,7 +287,19 @@ $2110 15 # 1 - LIFEFORMS @track GOLLogoType $2000 0 !step -$2100 1 +@end + +# encoding: 0x[steps][start] +# e.g. 0x0f01 - start at gradient row 1 and do 15 transition steps +@track GOLGradientTrans +# load +$0A00 0x0100 !event +$0A20 0x0f01 +$0A30 0x0f10 +$0B20 0x0f1f +# load +$2000 0x011f +$2020 0x0f1f @end @track WireworldDisplayBg diff --git a/intro/game-of-life.c b/intro/game-of-life.c index 95329feb..d804797c 100644 --- a/intro/game-of-life.c +++ b/intro/game-of-life.c @@ -229,8 +229,7 @@ static void MakeCopperList(CopListT *cp) { CopSetupSprites(cp, sprptr); for (i = 0; i < 8; i++) { SpriteT *spr = &wireworld_chip[i]; - SpriteUpdatePos(spr, - X(DISP_WIDTH / 2 + (i / 2) * 16 - 33), + SpriteUpdatePos(spr, X(DISP_WIDTH / 2 + (i / 2) * 16 - 33), Y(DISP_HEIGHT / 2 - spr->height / 2)); if (wireworld && TrackValueGet(&WireworldBg, frameCount) == 1) { CopInsSetSprite(sprptr[i], spr); @@ -255,7 +254,7 @@ static void MakeCopperList(CopListT *cp) { CopSetColor(cp, 13, *color); CopSetColor(cp, 14, *color); CopSetColor(cp, 15, *color++); - } + } CopMove16(cp, bpl1mod, -prev_states[0]->bytesPerRow); CopMove16(cp, bpl2mod, -prev_states[0]->bytesPerRow); CopWaitSafe(cp, Y(i), 0); @@ -306,12 +305,13 @@ static void GameOfLife(void *boards) { static short scene_count = 0; static void LoadBackground(const BitmapT *bg, u_short x, u_short y, short idx) { - BitmapT *tmp = NewBitmapCustom(EXT_BOARD_WIDTH, EXT_BOARD_HEIGHT, BOARD_DEPTH, BM_DISPLAYABLE); - BitmapClear(tmp); // comment for cool effects! - BitmapCopy(tmp, x, y, bg); - WaitBlitter(); - PixelDouble(tmp->planes[0], background[idx]->planes[0], double_pixels); - DeleteBitmap(tmp); + BitmapT *tmp = NewBitmapCustom(EXT_BOARD_WIDTH, EXT_BOARD_HEIGHT, BOARD_DEPTH, + BM_DISPLAYABLE); + BitmapClear(tmp); // comment for cool effects! + BitmapCopy(tmp, x, y, bg); + WaitBlitter(); + PixelDouble(tmp->planes[0], background[idx]->planes[0], double_pixels); + DeleteBitmap(tmp); } static void SharedPreInit(void) { @@ -329,16 +329,19 @@ static void SharedPreInit(void) { } for (i = 0; i < BOARD_COUNT; i++) - boards[i] = NewBitmapCustom(EXT_BOARD_WIDTH, EXT_BOARD_HEIGHT, BOARD_DEPTH, BM_DISPLAYABLE); + boards[i] = NewBitmapCustom(EXT_BOARD_WIDTH, EXT_BOARD_HEIGHT, BOARD_DEPTH, + BM_DISPLAYABLE); for (i = 0; i < PREV_STATES_DEPTH; i++) { // only needs half the vertical resolution, other half // achieved via copper line doubling - prev_states[i] = NewBitmapCustom(DISP_WIDTH, DISP_HEIGHT / 2, BOARD_DEPTH, BM_DISPLAYABLE); + prev_states[i] = + NewBitmapCustom(DISP_WIDTH, DISP_HEIGHT / 2, BOARD_DEPTH, BM_DISPLAYABLE); } for (i = 0; i < 2; i++) - background[i] = NewBitmapCustom(DISP_WIDTH, DISP_HEIGHT / 2, BOARD_DEPTH, BM_DISPLAYABLE); + background[i] = + NewBitmapCustom(DISP_WIDTH, DISP_HEIGHT / 2, BOARD_DEPTH, BM_DISPLAYABLE); SetupPlayfield(MODE_LORES, DISP_DEPTH, X(0), Y(0), DISP_WIDTH, DISP_HEIGHT); @@ -387,7 +390,6 @@ static void SharedPostInit(void) { static void InitWireworld(void) { short i; const BitmapT *desired_bg; - const PaletteT *pal; short display_bg = TrackValueGet(&WireworldDisplayBg, frameCount); short bg_idx = TrackValueGet(&WireworldBg, frameCount); @@ -396,12 +398,12 @@ static void InitWireworld(void) { prev_states_depth = display_bg ? 4 : 5; desired_bg = bg_idx ? &wireworld_pcb : &wireworld_vitruvian; cur_electrons = bg_idx ? &pcb_electrons : &vitruvian_electrons; - pal = bg_idx ? &palette_pcb : &palette_vitruvian; SharedPreInit(); - for (i = 0; i < pal->count; i++) - CopInsSet16(&palptr[i], pal->colors[i]); - InitSpawnFrames(cur_electrons, TrackValueGet(&WireworldSpawnMask, frameCount)); + for (i = 0; i < 16; i++) + CopInsSet16(&palptr[i], palette_vitruvian[i]); + InitSpawnFrames(cur_electrons, + TrackValueGet(&WireworldSpawnMask, frameCount)); if (display_bg) { LoadBackground(desired_bg, 0, 0, 0); @@ -419,12 +421,17 @@ static void InitWireworld(void) { } static void InitGameOfLife(void) { + short i; current_game = &games[0]; wireworld = false; prev_states_depth = 4; SharedPreInit(); + TransitionPal(palette_gol + 1); + for (i = 0; i < 16; i++) + CopInsSet16(&palptr[i], palette_gol[i]); + LoadBackground(&electric_logo, 0, 32, 0); LoadBackground(&lifeforms_logo, 0, 32, 1); @@ -473,10 +480,10 @@ static void GolStep(void) { if (!wireworld) current_game = &games[TrackValueGet(&GOLGame, frameCount)]; if (wireworld) { - // For technical reasons wireworld implementation requires 2 separate games to - // be ran in alternating fashion, and the switch between them must be done - // precisely when the board for a game finishes being calculated or things will - // break in ways undebuggable by single-stepping the game state + // For technical reasons wireworld implementation requires 2 separate games + // to be ran in alternating fashion, and the switch between them must be + // done precisely when the board for a game finishes being calculated or + // things will break in ways undebuggable by single-stepping the game state // which wireworld game (0-1) phase are we on static __code short wireworld_step = 0; @@ -486,10 +493,10 @@ static void GolStep(void) { wireworld_step ^= 1; // set pixels on correct board - SpawnElectrons(cur_electrons, - boards[wireworld_step ^ 1], boards[wireworld_step]); + SpawnElectrons(cur_electrons, boards[wireworld_step ^ 1], + boards[wireworld_step]); } - + // ----- PIXELDOUBLE-BLITTER SYNCHRONIZATION ----- // run all blits except the last GameOfLife(boards); @@ -510,12 +517,14 @@ static void GolStep(void) { UpdateBitplanePointers(); if (wireworld) { const short cycling_len = - sizeof(wireworld_chip_cycling)/sizeof(wireworld_chip_cycling[0]); - ColorCyclingStep(&palptr[16], wireworld_chip_cycling, cycling_len, &wireworld_chip_pal); + sizeof(wireworld_chip_cycling) / sizeof(wireworld_chip_cycling[0]); + ColorCyclingStep(&palptr[16], wireworld_chip_cycling, cycling_len, + &wireworld_chip_pal); } else { short logo_idx = TrackValueGet(&GOLLogoType, frameCount); CopInsSet32(bplptr[3], background[logo_idx]->planes[0]); - ColorFadingStep(); + TransitionPal(palette_gol + 1); + ColorFadingStep(palette_gol); } stepCount++; diff --git a/intro/gol-palette.c b/intro/gol-palette.c index a51cb940..5bf278aa 100644 --- a/intro/gol-palette.c +++ b/intro/gol-palette.c @@ -1,45 +1,41 @@ -static PaletteT palette_vitruvian = { - .count = 16, - .colors = - { - 0x000, // 0000 - 0x006, // 0001 - 0x026, // 0010 - 0x026, // 0011 - 0x05B, // 0100 - 0x05B, // 0101 - 0x05B, // 0110 - 0x05B, // 0111 - 0x09F, // 1000 - 0x09F, // 1001 - 0x09F, // 1010 - 0x09F, // 1011 - 0x09F, // 1100 - 0x09F, // 1101 - 0x09F, // 1110 - 0x09F, // 1111 - }, -}; +#include "data/gol-transitions.c" + +extern TrackT GOLGradientTrans; +extern TrackT GOLLogoType; -static PaletteT palette_pcb = { - .count = 16, - .colors = - { - 0x000, // 0000 - 0x000, // 0001 - 0x000, // 0010 - 0x000, // 0011 - 0x000, // 0100 - 0x000, // 0101 - 0x000, // 0110 - 0x000, // 0111 - 0x006, // 1000 - 0x009, // 1001 - 0x01c, // 1010 - 0x01c, // 1011 - 0x03f, // 1100 - 0x03f, // 1101 - 0x03f, // 1110 - 0x03f, // 1111 - }, +// taken from the wireworld palette +static short palette_vitruvian[16] = { + 0x000, 0x3bf, 0x9ee, 0x9ee, 0xdff, 0xdff, 0xdff, 0xdff, + 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, }; + +static short palette_gol[16] = {0}; + +static short *LoadCompressedPal(short *from, short *to) { + *to++ = *from++; + *to++ = *from; + *to++ = *from++; + *to++ = *from; + *to++ = *from; + *to++ = *from; + *to++ = *from++; + return from; +} + +static void TransitionPal(short *target_pal) { + u_short val, start, steps; + static u_short *pal; + static short phase = 0; + + val = TrackValueGet(&GOLGradientTrans, frameCount); + start = (val & 0xff) * gol_transitions_width; + steps = (val & 0xff00) >> 8; + if (steps > 0) { + phase = steps; + pal = gol_transitions_pixels + start; + } + if (phase) { + pal = LoadCompressedPal(pal, target_pal); + phase--; + } +} \ No newline at end of file diff --git a/intro/gol-transparency.c b/intro/gol-transparency.c index 61f16ce0..7f9f8446 100644 --- a/intro/gol-transparency.c +++ b/intro/gol-transparency.c @@ -1,30 +1,29 @@ extern TrackT GOLCellColor; extern TrackT GOLLogoColor; extern TrackT GOLLogoFade; -extern TrackT GOLLogoType; -static void ColorFadingStep(void) { - short i; - short s = TrackValueGet(&GOLLogoFade, frameCount); - short cell_col = 0; - short logo_col = 0; +static void ColorFadingStep(short *pal) { + short i; + short s = TrackValueGet(&GOLLogoFade, frameCount); + short cell_col = 0; + short logo_col = 0; - switch(TrackValueGet(&GOLCellColor, frameCount)) { - case 0: cell_col = 0; break; - case 1: cell_col = s; break; - case 2: cell_col = 15-s; break; - case 3: cell_col = 15; break; - } + switch (TrackValueGet(&GOLCellColor, frameCount)) { + case 0: cell_col = 0; break; + case 1: cell_col = s; break; + case 2: cell_col = 15 - s; break; + case 3: cell_col = 15; break; + } - switch(TrackValueGet(&GOLLogoColor, frameCount)) { - case 0: logo_col = 0; break; - case 1: logo_col = s; break; - case 2: logo_col = 15-s; break; - case 3: logo_col = 15; break; - } + switch (TrackValueGet(&GOLLogoColor, frameCount)) { + case 0: logo_col = 0; break; + case 1: logo_col = s; break; + case 2: logo_col = 15 - s; break; + case 3: logo_col = 15; break; + } - for (i = 0; i < 8; i++) { - CopInsSet16(palptr + i, ColorTransition(palette_vitruvian.colors[i], 0x000, cell_col)); - CopInsSet16(palptr + i + 8, ColorTransition(palette_vitruvian.colors[i], 0xfff, logo_col)); - } -} \ No newline at end of file + for (i = 0; i < 8; i++) { + CopInsSet16(palptr + i, ColorTransition(pal[i], 0x000, cell_col)); + CopInsSet16(palptr + i + 8, ColorTransition(pal[i], 0xfff, logo_col)); + } +} From 94e1de5957ca9433f4dc616af916cbabae3e5db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Wed, 5 Apr 2023 21:18:36 +0200 Subject: [PATCH 3/8] Fix uvmap based effects. * clear texture when about to stop effect * fix copying missing row of texture * added sync for uvtit --- intro/data/intro.sync | 48 ++++++++++++++++++++++-------- intro/uvmap.c | 69 ++++++++++++++++++++++++++++--------------- 2 files changed, 81 insertions(+), 36 deletions(-) diff --git a/intro/data/intro.sync b/intro/data/intro.sync index 5d09c7e2..e31f5412 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -424,24 +424,48 @@ $012E 10 @end @track UvmapTransition -$0000 128 !trigger -$0100 128 -$0200 128 -$0300 128 +# uvgut +$1400 64 !trigger +$1500 64 +$1600 64 +$1700 64 +$1730 16 +$1738 16 +# uvtit +$2200 64 +$2220 64 +$2300 64 +$2330 16 +$2338 16 @end @track UvmapSrcTexture -$0000 1 !step -$0100 0 -$0200 0 -$0300 1 +# uvgut +$1400 1 !step +$1500 0 +$1600 0 +$1700 1 +$1730 -1 +# uvtit +$2200 1 +$2220 0 +$2300 0 +$2330 -1 @end @track UvmapDstTexture -$0000 1 !step -$0100 0 -$0200 1 -$0300 0 +# uvgut +$1400 1 !step +$1500 0 +$1600 1 +$1700 0 +$1738 1 +# uvtit +$2200 1 +$2220 0 +$2300 1 +$2330 0 +$2338 1 @end @track WeaveBarPulse diff --git a/intro/uvmap.c b/intro/uvmap.c index 3de9a203..5c06be8c 100644 --- a/intro/uvmap.c +++ b/intro/uvmap.c @@ -67,7 +67,8 @@ static void CopyTexture(const u_char *data, u_short *hi0, u_short *lo0, { int start = step * TW; - data += start; + if (data) + data += start; hi0 += start; lo0 += start; hi1 = hi0 + TW * TH; @@ -76,14 +77,23 @@ static void CopyTexture(const u_char *data, u_short *hi0, u_short *lo0, n = (lastStep - step) * TW; - while (--n >= 0) { - int c = *data++; - short hi = PixelHi[c]; - short lo = PixelLo[c]; - *hi0++ = hi; - *hi1++ = hi; - *lo0++ = lo; - *lo1++ = lo; + if (data) { + while (--n >= 0) { + int c = *data++; + short hi = PixelHi[c]; + short lo = PixelLo[c]; + *hi0++ = hi; + *hi1++ = hi; + *lo0++ = lo; + *lo1++ = lo; + } + } else { + while (--n >= 0) { + *hi0++ = 0; + *hi1++ = 0; + *lo0++ = 0; + *lo1++ = 0; + } } } @@ -409,6 +419,31 @@ static void Kill(void) { DeleteBitmap(screen[1]); } +static void ControlTexture(void) { + short step; + + if ((step = TrackValueGet(&UvmapTransition, frameCount)) || lastStep) { + short texSrcIdx = TrackValueGet(&UvmapSrcTexture, frameCount); + short texDstIdx = TrackValueGet(&UvmapDstTexture, frameCount); + + u_short *dstHi = texDstIdx ? texSndHi : texFstHi; + u_short *dstLo = texDstIdx ? texSndLo : texFstLo; + const u_char *src = NULL; + + if (texSrcIdx >= 0) + src = texSrcIdx ? texture_in_pixels : texture_out_pixels; + else + step *= 4; + + CopyTexture(src, dstHi, dstLo, step); + + if (lastStep == 0) + step = 64; + + lastStep = step; + } +} + PROFILE(UVMap); static void Render(void) { @@ -419,21 +454,7 @@ static void Render(void) { /* screen's bitplane #0 is used as a chunky buffer */ ProfilerStart(UVMap); - { - short val; - - if ((val = TrackValueGet(&UvmapTransition, frameFromStart)) || lastStep) { - short texSrcIdx = TrackValueGet(&UvmapSrcTexture, frameFromStart); - short texDstIdx = TrackValueGet(&UvmapDstTexture, frameFromStart); - short step = val / 2; - - CopyTexture(texSrcIdx ? texture_in_pixels : texture_out_pixels, - texDstIdx ? texSndHi : texFstHi, - texDstIdx ? texSndLo : texFstLo, step); - - lastStep = step; - } - } + ControlTexture(); { u_short *chunky = screen[active]->planes[0] + WIDTH * HEIGHT / 2; From a7af3619ab58b9e9b5ca8daddb125e7b1a6733a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Wed, 5 Apr 2023 21:48:13 +0200 Subject: [PATCH 4/8] Separate LogoIn/LogoOut effects. --- intro/data/intro.sync | 2 +- intro/logo.c | 24 +++++++++++++++++------- intro/main.c | 6 ++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/intro/data/intro.sync b/intro/data/intro.sync index e31f5412..fc8c384a 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -30,7 +30,7 @@ $2900 5 # scrolling text $2D00 1 # logo -$3000 0 +$3000 12 # end $3200 -1 @end diff --git a/intro/logo.c b/intro/logo.c index 50e2c5b9..bc9f3d57 100644 --- a/intro/logo.c +++ b/intro/logo.c @@ -30,8 +30,13 @@ static const PaletteT *ghostown_logo_pal[] = { extern TrackT GhostownLogoPal; static void Load(void) { - PixmapToBitmap(&ghostown_logo, ghostown_logo_width, ghostown_logo_height, 3, - ghostown_logo_pixels); + static __code short done = false; + + if (!done) { + PixmapToBitmap(&ghostown_logo, ghostown_logo_width, ghostown_logo_height, 3, + ghostown_logo_pixels); + done = true; + } } static void Init(void) { @@ -62,14 +67,18 @@ static void Init(void) { EnableDMA(DMAF_RASTER); } +static void Kill(void) { + DisableDMA(DMAF_RASTER); + DeleteCopList(cp); + + DeleteBitmap(screen); +} + void KillLogo(void) { static __code bool enabled = false; if (enabled) { - DisableDMA(DMAF_RASTER); - DeleteCopList(cp); - - DeleteBitmap(screen); + Kill(); } else { enabled = true; } @@ -97,4 +106,5 @@ static void Render(void) { TaskWaitVBlank(); } -EFFECT(Logo, Load, NULL, Init, NULL, Render, NULL); +EFFECT(LogoIn, Load, NULL, Init, NULL, Render, NULL); +EFFECT(LogoOut, Load, NULL, Init, Kill, Render, NULL); diff --git a/intro/main.c b/intro/main.c index a48daa1a..31fba4fc 100644 --- a/intro/main.c +++ b/intro/main.c @@ -18,7 +18,7 @@ extern u_char Module[]; extern u_char Samples[]; -extern EffectT LogoEffect; +extern EffectT LogoInEffect; extern EffectT WeaveEffect; extern EffectT TextScrollEffect; extern EffectT TurmiteEffect; @@ -30,6 +30,7 @@ extern EffectT GameOfLifeEffect; extern EffectT VitruvianEffect; extern EffectT UVGutEffect; extern EffectT UVTitEffect; +extern EffectT LogoOutEffect; short frameFromStart; short frameTillEnd; @@ -37,7 +38,7 @@ short frameTillEnd; #include "data/intro.c" static EffectT *AllEffects[] = { - &LogoEffect, + &LogoInEffect, &TextScrollEffect, &WeaveEffect, &TurmiteEffect, @@ -49,6 +50,7 @@ static EffectT *AllEffects[] = { &VitruvianEffect, &UVGutEffect, &UVTitEffect, + &LogoOutEffect, NULL, }; From a061d3fd26a752dc587262f6a62afb272577f5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Wed, 5 Apr 2023 23:09:48 +0200 Subject: [PATCH 5/8] Fix reverse logo appearance at the end of intro. --- intro/logo.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/intro/logo.c b/intro/logo.c index bc9f3d57..5c8de483 100644 --- a/intro/logo.c +++ b/intro/logo.c @@ -39,18 +39,14 @@ static void Load(void) { } } -static void Init(void) { +static void SharedInit(bool out) { + short i; + cleanup = true; + screen = NewBitmap(WIDTH, HEIGHT, DEPTH); SetupPlayfield(MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT); - { - short i = 0; - - for (i = 0; i < (1 << DEPTH); i++) - SetColor(i, ghostown_logo_1_pal.colors[0]); - } - EnableDMA(DMAF_BLITTER); BitmapCopy(screen, (WIDTH - ghostown_logo_width) / 2, (HEIGHT - ghostown_logo_height) / 2, &ghostown_logo); @@ -64,9 +60,21 @@ static void Init(void) { CopListActivate(cp); + for (i = 0; i < (1 << DEPTH); i++) + SetColor(i, out ? ghostown_logo_3_pal.colors[i] + : ghostown_logo_1_pal.colors[0]); + EnableDMA(DMAF_RASTER); } +static void InitIn(void) { + SharedInit(0); +} + +static void InitOut(void) { + SharedInit(1); +} + static void Kill(void) { DisableDMA(DMAF_RASTER); DeleteCopList(cp); @@ -84,17 +92,18 @@ void KillLogo(void) { } } -static void Render(void) { +static void Render(bool out) { short num = TrackValueGet(&GhostownLogoPal, frameCount); - short frame = FromCurrKeyFrame(&GhostownLogoPal); + short frame = out ? TillNextKeyFrame(&GhostownLogoPal) + : FromCurrKeyFrame(&GhostownLogoPal); - if (num > 0) { + if (num) { if (frame < 16) { short i; for (i = 0; i < (1 << DEPTH); i++) { short prev = (num == 1) ? ghostown_logo_1_pal.colors[0] - : ghostown_logo_pal[num - 1]->colors[i]; + : ghostown_logo_pal[num - 1]->colors[i]; short curr = ghostown_logo_pal[num]->colors[i]; SetColor(i, ColorTransition(prev, curr, frame)); } @@ -106,5 +115,13 @@ static void Render(void) { TaskWaitVBlank(); } -EFFECT(LogoIn, Load, NULL, Init, NULL, Render, NULL); -EFFECT(LogoOut, Load, NULL, Init, Kill, Render, NULL); +static void RenderIn(void) { + Render(0); +} + +static void RenderOut(void) { + Render(1); +} + +EFFECT(LogoIn, Load, NULL, InitIn, NULL, RenderIn, NULL); +EFFECT(LogoOut, Load, NULL, InitOut, Kill, RenderOut, NULL); From f3d048e4864d0e16632e26d72278ca1d67abbb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Thu, 6 Apr 2023 17:01:29 +0200 Subject: [PATCH 6/8] New artwork and various fixes to uvgut / sea-anemone / turmite (#70) * Attach new whirl artwork. Fix anemone timing. * [sea-anemone] simplify fade-in/fade-out. * Simplify whirl palette. * Fade-in/fade-out whirl sprite as well. * Different gradients for uvtit & uvgut. * [sea-anemone] add gradient pulses * Show turmite board for a second. * Add electic sprite to uvtit. * [png2c] add definition for number of generated sprites * [ResetSprites] Reset sprite priorities as well. --- intro/Makefile | 14 ++++-- intro/data/electric-small.png | 3 ++ intro/data/intro.sync | 84 ++++++++++++++++++++--------------- intro/data/whirl.png | 4 +- intro/logo.c | 12 +++-- intro/sea-anemone.c | 27 ++++++----- intro/turmite.c | 23 +++++----- intro/uvmap.c | 33 ++++++++++---- lib/libgfx/ResetSprites.c | 3 ++ tools/png2c.py | 7 +-- 10 files changed, 129 insertions(+), 81 deletions(-) create mode 100644 intro/data/electric-small.png diff --git a/intro/Makefile b/intro/Makefile index 7ead8c73..73bbfd71 100644 --- a/intro/Makefile +++ b/intro/Makefile @@ -41,7 +41,7 @@ CLEAN-FILES := main.o \ data/electric.c data/lifeforms.c \ data/circles.c data/squares.c data/whirl.c \ data/grass.c data/loader.c \ - data/texture-{in,out}side.c data/gradient.c data/gradient.png \ + data/texture-{in,out}side.c data/uv*-gradient.c data/uv*-gradient.png \ data/tilemover-*.c data/chip.c data/wireworld-pcb-pal.c \ data/pal-gold*.c data/pal-green*.c data/pal-red*.c data/pal-blue*.c \ data/tree-pal-*.c @@ -68,6 +68,7 @@ PNG2C.tree-pal-electric := --palette tree_pal_electric,32 PNG2C.fruit-1 := --bitmap fruit_1,16x16x2,+onlydata PNG2C.fruit-2 := --bitmap fruit_2,16x16x2,+onlydata PNG2C.grass := --sprite grass,32,8 +PNG2C.electric-small := --sprite electric,32,5 --palette electric_pal,16,+store_unused PNG2C.tilemover-pal := --palette tilemover_pal,16 PNG2C.ghostown-logo-crop := --pixmap ghostown_logo,192x131x4,+onlydata,+displayable PNG2C.ghostown-logo-01 := --palette ghostown_logo_1_pal,8 @@ -83,7 +84,7 @@ PNG2C.loader := --bitmap loader,64x64x1 --palette loader_pal,2 PNG2C.electric := --bitmap electric_logo,160x64x1,+shared PNG2C.lifeforms := --bitmap lifeforms_logo,160x64x1,+shared PNG2C.anemone-gradient := --palette anemone_gradient_pal,16 -PNG2C.whirl := --sprite whirl,64,4 --palette whirl_pal,4 +PNG2C.whirl := --sprite whirl,64,4 --palette whirl_pal,16,+store_unused PNG2C.circles := \ --bitmap circle1,3x3x1,extract_at=0x0 \ @@ -146,7 +147,8 @@ PNG2C.tilemover-bg-pal := --palette tilemover_bg_pal,6 PNG2C.texture-inside := --pixmap texture_in,64x64x8,+onlydata --palette texture_pal,16 PNG2C.texture-outside := --pixmap texture_out,64x64x8,+onlydata -PNG2C.gradient := --pixmap gradient,16x16x12,+onlydata +PNG2C.uvgut-gradient := --pixmap uvgut_gradient,16x16x12,+onlydata +PNG2C.uvtit-gradient := --pixmap uvtit_gradient,16x16x12,+onlydata PNG2C.gol-transitions := --pixmap gol_transitions,3x46x12,+onlydata CPPFLAGS += -DINTRO -DVQ=$(VQ) -DDELTA=$(DELTA) -DKLANG=$(KLANG) -I. @@ -204,7 +206,11 @@ data/%.png: data/%.rle @echo "[RLE] $(DIR)$< -> $(DIR)$@" $(PYTHON3) $(RLE2PNG) $< $@ || (rm -f $@ && exit 1) -data/gradient.png: $(GRADIENT) data/texture-inside.png +data/uvgut-gradient.png: $(GRADIENT) data/texture-inside.png + @echo "[GEN] $@" + $(PYTHON3) $(GRADIENT) load $(word 2,$^) copy hue 0.495 save $@ + +data/uvtit-gradient.png: $(GRADIENT) data/texture-inside.png @echo "[GEN] $@" $(PYTHON3) $(GRADIENT) load $(word 2,$^) copy hue 0.4 save $@ diff --git a/intro/data/electric-small.png b/intro/data/electric-small.png new file mode 100644 index 00000000..f07852bf --- /dev/null +++ b/intro/data/electric-small.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e60385ab6ed6e52b172e61c9fc030e7e001b03f7c54a8e0ff557b9f68e7862f0 +size 974 diff --git a/intro/data/intro.sync b/intro/data/intro.sync index fc8c384a..1c5dd352 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -343,7 +343,7 @@ $0100 2 $0120 1 $0200 2 $0220 3 -$0310 4 +$0300 4 @end # available palettes @@ -358,53 +358,54 @@ $0100 3 $0120 2 $0200 3 $0220 1 -$0310 4 +$0300 4 @end -@track SeaAnemoneFadeOut -$001E 15 !trigger -$003E 15 -$011E 15 -$013E 15 -$021E 15 -#$033E 15 -@end - -@track SeaAnemoneFadeIn -$0020 15 !trigger -$0100 15 -$0120 15 -$0200 15 -$0220 15 -$0310 15 +@track SeaAnemoneFade +$0c00 0 +$0c20 0 +$0d00 0 +$0d20 0 +$0e00 0 +$0e20 0 +$0f00 0 +$1000 0 @end @track SeaAnemoneGradient -$0023 31 !trigger -$0039 31 -$0122 31 -$0137 31 +# takes 30 frames (10 protracker rows); pos $28 & $38 +$0025 31 !trigger +$0035 31 +$0125 31 +$0135 31 @end @track SeaAnemonePalPulse -$0005 30 !trigger +$0007 15 !trigger +$0017 15 !trigger +$0107 15 !trigger +$0117 15 !trigger +$0207 15 !trigger +$0217 15 !trigger +$0227 15 !trigger +$0237 15 !trigger +$0307 15 !trigger +$0317 15 !trigger +$0327 15 !trigger +$0337 15 !trigger @end @track TurmiteBoard -$0000 1 !event -$0100 2 -$0200 3 +$2400 1 !event +$2500 2 +$2600 3 @end -@track TurmiteFadeIn -$0000 15 !trigger -$0100 15 -$0200 15 -@end - -@track TurmiteFadeOut -$003E 15 !trigger -$013E 15 +@track TurmiteFade +$2400 0 !step +$2500 0 +$2600 0 +$2900 0 @end @track TurmitePal @@ -421,6 +422,19 @@ $0120 10 $0125 10 $012A 10 $012E 10 +$020A 10 +$0215 10 +$022A 10 +$022E 10 +$030E 10 +$0310 10 +$0315 10 +$031A 10 +$031E 10 +$0320 10 +$0325 10 +$032A 10 +$032E 10 @end @track UvmapTransition diff --git a/intro/data/whirl.png b/intro/data/whirl.png index 2f562b4f..600b899e 100644 --- a/intro/data/whirl.png +++ b/intro/data/whirl.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c7cafb4f17903cf5217e21a0cfd3f428a71bba662bec2eff2aa6f44a7e01434 -size 850 +oid sha256:61fae088e5deeffce8018d3fd3cfc51c71aa95ea758b9e145255883f09fbde65 +size 1462 diff --git a/intro/logo.c b/intro/logo.c index 5c8de483..91a9a30b 100644 --- a/intro/logo.c +++ b/intro/logo.c @@ -92,12 +92,10 @@ void KillLogo(void) { } } -static void Render(bool out) { - short num = TrackValueGet(&GhostownLogoPal, frameCount); - short frame = out ? TillNextKeyFrame(&GhostownLogoPal) - : FromCurrKeyFrame(&GhostownLogoPal); +static void Render(short frame) { + short num; - if (num) { + if ((num = TrackValueGet(&GhostownLogoPal, frameCount))) { if (frame < 16) { short i; @@ -116,11 +114,11 @@ static void Render(bool out) { } static void RenderIn(void) { - Render(0); + Render(FromCurrKeyFrame(&GhostownLogoPal)); } static void RenderOut(void) { - Render(1); + Render(TillNextKeyFrame(&GhostownLogoPal)); } EFFECT(LogoIn, Load, NULL, InitIn, NULL, RenderIn, NULL); diff --git a/intro/sea-anemone.c b/intro/sea-anemone.c index 056bbfa5..08a5b570 100644 --- a/intro/sea-anemone.c +++ b/intro/sea-anemone.c @@ -87,8 +87,7 @@ extern TrackT SeaAnemoneVariant; extern TrackT SeaAnemonePal; extern TrackT SeaAnemonePalPulse; extern TrackT SeaAnemoneGradient; -extern TrackT SeaAnemoneFadeOut; -extern TrackT SeaAnemoneFadeIn; +extern TrackT SeaAnemoneFade; typedef const PaletteT *SeaAnemonePalT[5]; @@ -138,10 +137,9 @@ static const SeaAnemonePalT *sea_anemone_pal[5] = { static const SeaAnemonePalT *active_pal = &anemone1_pal; static const short blip_sequence[] = { - 0, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 0, 2, + 1, 1, 1, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, }; static const short gradient_envelope[] = { @@ -318,12 +316,18 @@ static void VBlank(void) { if ((val = TrackValueGet(&SeaAnemonePalPulse, frameFromStart))) LoadPalette((*active_pal)[blip_sequence[val]], 0); + + (void)TrackValueGet(&SeaAnemoneFade, frameCount); + + if ((val = FromCurrKeyFrame(&SeaAnemoneFade)) < 16) { + FadeBlack(sea_anemone_palettes[activePalIndex], 0, val); + FadeBlack(&whirl_pal, 16, val); + } - if ((val = TrackValueGet(&SeaAnemoneFadeOut, frameFromStart))) + if ((val = TillNextKeyFrame(&SeaAnemoneFade)) < 16) { FadeBlack(sea_anemone_palettes[activePalIndex], 0, val); - - if ((val = TrackValueGet(&SeaAnemoneFadeIn, frameFromStart))) - FadeBlack(sea_anemone_palettes[activePalIndex], 0, 16 - val); + FadeBlack(&whirl_pal, 16, val); + } } static void MakeCopperList(CopListT *cp, CopInsT **bplptr, CopInsT **sprptr, @@ -371,8 +375,7 @@ static void Init(void) { SetupPlayfield(MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT); LoadPalette(sea_anemone_palettes[activePalIndex], 0); - for (i = 16; i < 32; i += 4) - LoadPalette(&whirl_pal, i); + LoadPalette(&whirl_pal, 16); cp[0] = NewCopList(50 + 2 * anemone_gradient_length); cp[1] = NewCopList(50 + 2 * anemone_gradient_length); diff --git a/intro/turmite.c b/intro/turmite.c index a1179e0f..e5d78f62 100644 --- a/intro/turmite.c +++ b/intro/turmite.c @@ -31,8 +31,7 @@ static u_int lookup[256][2]; extern TrackT TurmiteBoard; extern TrackT TurmitePal; -extern TrackT TurmiteFadeIn; -extern TrackT TurmiteFadeOut; +extern TrackT TurmiteFade; #include "palettes.h" @@ -582,11 +581,13 @@ static void ForEachFrame(void) { if ((val = TrackValueGet(&TurmitePal, frameFromStart))) LoadPalette((*active_pal)[blip_sequence[val]], 0); - if ((val = TrackValueGet(&TurmiteFadeOut, frameFromStart))) + (void)TrackValueGet(&TurmiteFade, frameCount); + + if ((val = FromCurrKeyFrame(&TurmiteFade)) < 16) FadeBlack(turmite_palettes[active_pal_index], 0, val); - if ((val = TrackValueGet(&TurmiteFadeIn, frameFromStart))) - FadeBlack(turmite_palettes[active_pal_index], 0, 16 - val); + if ((val = TillNextKeyFrame(&TurmiteFade)) < 16) + FadeBlack(turmite_palettes[active_pal_index], 0, val); } static void Init(void) { @@ -623,13 +624,15 @@ PROFILE(SimulateTurmite); static void Render(void) { short val; - if ((val = TrackValueGet(&TurmiteBoard, frameFromStart))) + if ((val = TrackValueGet(&TurmiteBoard, frameCount))) ChooseTurmiteBoard(val); - ProfilerStart(SimulateTurmite); - SimulateTurmite(TheTurmite[0], board, screen->planes[0]); - SimulateTurmite(TheTurmite[1], board, screen->planes[0]); - ProfilerStop(SimulateTurmite); + if (FromCurrKeyFrame(&TurmiteBoard) >= 50) { + ProfilerStart(SimulateTurmite); + SimulateTurmite(TheTurmite[0], board, screen->planes[0]); + SimulateTurmite(TheTurmite[1], board, screen->planes[0]); + ProfilerStop(SimulateTurmite); + } TaskWaitVBlank(); } diff --git a/intro/uvmap.c b/intro/uvmap.c index 5c06be8c..2a6cce81 100644 --- a/intro/uvmap.c +++ b/intro/uvmap.c @@ -6,6 +6,7 @@ #include #include #include +#include #define WIDTH 160 #define HEIGHT 100 @@ -24,10 +25,13 @@ static __code short c2p_phase; static __code void **c2p_bpl; static CopListT *cp; static CopInsT *bplptr[DEPTH]; +static CopInsT *sprptr[8]; +#include "data/electric-small.c" #include "data/texture-inside.c" #include "data/texture-outside.c" -#include "data/gradient.c" +#include "data/uvgut-gradient.c" +#include "data/uvtit-gradient.c" #include "data/uvmap/gut-uv.c" #include "data/uvmap/tit-uv.c" @@ -331,12 +335,12 @@ static void ChunkyToPlanar(void) { c2p_phase++; } -static void MakeCopperList(CopListT *cp) { - short *pixels = gradient_pixels; +static void MakeCopperList(CopListT *cp, short *pixels) { short i, j; CopInit(cp); CopSetupBitplanes(cp, bplptr, screen[active], DEPTH); + CopSetupSprites(cp, sprptr); for (j = 0; j < 16; j++) CopSetColor(cp, j, *pixels++); for (i = 0; i < HEIGHT * 2; i++) { @@ -355,7 +359,9 @@ static void MakeCopperList(CopListT *cp) { CopEnd(cp); } -static void Init(void) { +static void Init(short var) { + short i; + screen[0] = NewBitmap(WIDTH * 2, HEIGHT * 2, DEPTH); screen[1] = NewBitmap(WIDTH * 2, HEIGHT * 2, DEPTH); @@ -376,10 +382,20 @@ static void Init(void) { SetupPlayfield(MODE_LORES, DEPTH, X(0), Y(28), WIDTH * 2, HEIGHT * 2); cp = NewCopList(900 + 256); - MakeCopperList(cp); + MakeCopperList(cp, var ? uvtit_gradient_pixels : uvgut_gradient_pixels); CopListActivate(cp); - EnableDMA(DMAF_RASTER); + if (var) { + for (i = 0; i < electric_sprites; i++) { + short hp = X(i * 16 + (320 - electric_sprites * 16) / 2); + SpriteUpdatePos(&electric[i], hp, Y((256 - electric_height) / 2)); + CopInsSetSprite(sprptr[i], &electric[i]); + } + + LoadPalette(&electric_pal, 16); + } + + EnableDMA(DMAF_RASTER | DMAF_SPRITE); active = 0; c2p_bpl = NULL; @@ -393,16 +409,17 @@ static void Init(void) { static void InitGut(void) { UVMapRender = MemAlloc(UVMapRenderSize, MEMF_PUBLIC); MakeUVMapRenderCode((u_short *)gut); - Init(); + Init(0); } static void InitTit(void) { UVMapRender = MemAlloc(UVMapRenderSize, MEMF_PUBLIC); MakeUVMapRenderCode((u_short *)tit); - Init(); + Init(1); } static void Kill(void) { + ResetSprites(); DisableDMA(DMAF_COPPER | DMAF_RASTER | DMAF_BLITTER); DisableINT(INTF_BLIT); diff --git a/lib/libgfx/ResetSprites.c b/lib/libgfx/ResetSprites.c index 037c3368..0c05a1cf 100644 --- a/lib/libgfx/ResetSprites.c +++ b/lib/libgfx/ResetSprites.c @@ -6,6 +6,9 @@ void ResetSprites(void) { DisableDMA(DMAF_SPRITE); + /* Move sprites into foreground. */ + custom->bplcon2 = BPLCON2_PF1P2|BPLCON2_PF2P2; + for (i = 0; i < 8; i++) { custom->sprpt[i] = NullSprData; custom->spr[i].datab = 0; diff --git a/tools/png2c.py b/tools/png2c.py index b37b3a11..fd3f3a3a 100755 --- a/tools/png2c.py +++ b/tools/png2c.py @@ -259,13 +259,14 @@ def do_sprite(im, desc): stride = ((width + 15) & ~15) // 16 bpl = planar(pix, width, height, depth) - print(f'#define {name}_height {height}') - print('') - n = width // 16 if attached: n *= 2 + print(f'#define {name}_height {height}') + print(f'#define {name}_sprites {n}') + print('') + sprites = [] for i in range(n): From 0727f4fd8b2286a611f74cbc5d934183d32bfbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ob=C5=82onczek?= Date: Thu, 6 Apr 2023 17:05:11 +0200 Subject: [PATCH 7/8] Sync 2nd showing of game of life (#71) --- intro/data/intro.sync | 4 ++-- intro/game-of-life.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/intro/data/intro.sync b/intro/data/intro.sync index 1c5dd352..5908979f 100644 --- a/intro/data/intro.sync +++ b/intro/data/intro.sync @@ -256,11 +256,11 @@ $0B20 3 # classic $2000 0 # stains -$2020 4 +$2030 4 # day and night $2100 5 # Diamoeba -$2130 3 +$2120 6 @end @track GOLCellColor diff --git a/intro/game-of-life.c b/intro/game-of-life.c index d804797c..6c84d7f4 100644 --- a/intro/game-of-life.c +++ b/intro/game-of-life.c @@ -422,6 +422,7 @@ static void InitWireworld(void) { static void InitGameOfLife(void) { short i; + short display_bg = TrackValueGet(&WireworldDisplayBg, frameCount); current_game = &games[0]; wireworld = false; prev_states_depth = 4; @@ -436,7 +437,8 @@ static void InitGameOfLife(void) { LoadBackground(&lifeforms_logo, 0, 32, 1); BitmapClear(boards[0]); - BitmapCopy(boards[0], EXT_WIDTH_LEFT, EXT_HEIGHT_TOP, &wireworld_vitruvian); + BitmapCopy(boards[0], EXT_WIDTH_LEFT, EXT_HEIGHT_TOP, + display_bg ? &wireworld_pcb : &wireworld_vitruvian); SharedPostInit(); } From 7b143b78d1d104b8160ef8f38a4d3d4678078a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ob=C5=82onczek?= Date: Thu, 6 Apr 2023 17:16:16 +0200 Subject: [PATCH 8/8] Fix vitruvian palette (#73) --- intro/game-of-life.c | 39 ++++++++++++++++++++++++++------------- intro/gol-palette.c | 6 ------ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/intro/game-of-life.c b/intro/game-of-life.c index 6c84d7f4..076120b8 100644 --- a/intro/game-of-life.c +++ b/intro/game-of-life.c @@ -215,9 +215,11 @@ static void BlitFunc(const BitmapT *sourceA, const BitmapT *sourceB, custom->bltsize = BLTSIZE; } -static void MakeCopperList(CopListT *cp) { +void MakeCopperList(CopListT *cp) { short i; short *color = wireworld_pcb_pal_pixels; + short display_bg = TrackValueGet(&WireworldDisplayBg, frameCount); + short pal_start = display_bg ? 8 : 0; CopInit(cp); // initially previous states are empty @@ -246,14 +248,28 @@ static void MakeCopperList(CopListT *cp) { for (i = 1; i <= DISP_HEIGHT; i += 2) { // vertical pixel doubling if (wireworld && (i - 1) % 8 == 0) { - CopSetColor(cp, 8, *color++); - CopSetColor(cp, 9, *color++); - CopSetColor(cp, 10, *color); - CopSetColor(cp, 11, *color++); - CopSetColor(cp, 12, *color); - CopSetColor(cp, 13, *color); - CopSetColor(cp, 14, *color); - CopSetColor(cp, 15, *color++); + // if we're displaying background set its colors without any electrons + if (display_bg) + CopSetColor(cp, pal_start, *color++); + // else background should be black + + // if we're displaying background set its colors with electrons + // if we're not displaying background set first half of the color palette + CopSetColor(cp, pal_start+1, *color++); + CopSetColor(cp, pal_start+2, *color); + CopSetColor(cp, pal_start+3, *color++); + CopSetColor(cp, pal_start+4, *color); + CopSetColor(cp, pal_start+5, *color); + CopSetColor(cp, pal_start+6, *color); + CopSetColor(cp, pal_start+7, *color++); + + // if we're not displaying background set second half of the color palette + if (!display_bg) { + short j; + for (j = pal_start + 8; j < 16; j++) + CopSetColor(cp, j, *color); + color++; + } } CopMove16(cp, bpl1mod, -prev_states[0]->bytesPerRow); CopMove16(cp, bpl2mod, -prev_states[0]->bytesPerRow); @@ -345,7 +361,7 @@ static void SharedPreInit(void) { SetupPlayfield(MODE_LORES, DISP_DEPTH, X(0), Y(0), DISP_WIDTH, DISP_HEIGHT); - cp = NewCopList(1820); + cp = NewCopList(1310); MakeCopperList(cp); CopListActivate(cp); @@ -388,7 +404,6 @@ static void SharedPostInit(void) { } static void InitWireworld(void) { - short i; const BitmapT *desired_bg; short display_bg = TrackValueGet(&WireworldDisplayBg, frameCount); short bg_idx = TrackValueGet(&WireworldBg, frameCount); @@ -400,8 +415,6 @@ static void InitWireworld(void) { cur_electrons = bg_idx ? &pcb_electrons : &vitruvian_electrons; SharedPreInit(); - for (i = 0; i < 16; i++) - CopInsSet16(&palptr[i], palette_vitruvian[i]); InitSpawnFrames(cur_electrons, TrackValueGet(&WireworldSpawnMask, frameCount)); diff --git a/intro/gol-palette.c b/intro/gol-palette.c index 5bf278aa..21dd58cf 100644 --- a/intro/gol-palette.c +++ b/intro/gol-palette.c @@ -3,12 +3,6 @@ extern TrackT GOLGradientTrans; extern TrackT GOLLogoType; -// taken from the wireworld palette -static short palette_vitruvian[16] = { - 0x000, 0x3bf, 0x9ee, 0x9ee, 0xdff, 0xdff, 0xdff, 0xdff, - 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, -}; - static short palette_gol[16] = {0}; static short *LoadCompressedPal(short *from, short *to) {