Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
GF and Week 7
Browse files Browse the repository at this point in the history
  • Loading branch information
cuckydev committed Jun 19, 2021
1 parent 1922503 commit 6096b72
Show file tree
Hide file tree
Showing 35 changed files with 437 additions and 65 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ funkin.ps-exe
*.o
*.dep

# Exclude Week 7 files
iso/chart/7.*.cht
iso/music/week7*.xa

# Exclude tool data and executables
tools/funkinchartpak/*.json
tools/funkinchartpak/*.cht
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ SRCS = src/main.c \
src/archive.c \
src/menu.c \
src/stage.c \
src/stage/dummy.c \
src/stage/week4.c \
src/animation.c \
src/character.c \
src/character/bf.c \
src/character/gf.c \
src/character/dad.c \
src/character/mom.c \
src/object.c \
src/object/combo.c \
../common/crt0/crt0.s

CPPFLAGS += -I../psyq/include -Wall -O3
CPPFLAGS += -I../psyq/include -Wall -O2
LDFLAGS += -L../psyq/lib
LDFLAGS += -Wl,--start-group
LDFLAGS += -lapi
Expand Down
25 changes: 25 additions & 0 deletions funkin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,33 @@
<file name = "6.3h.cht" type = "data" source = "iso/chart/6.3h.cht"/>
</dir>

<!-- Week 7 assets -->
<dir name = "week7">
<!-- Ugh charts -->
<file name = "7.1e.cht" type = "data" source = "iso/chart/7.1e.cht"/>
<file name = "7.1n.cht" type = "data" source = "iso/chart/7.1n.cht"/>
<file name = "7.1h.cht" type = "data" source = "iso/chart/7.1h.cht"/>
<!-- Guns charts -->
<file name = "7.2e.cht" type = "data" source = "iso/chart/7.2e.cht"/>
<file name = "7.2n.cht" type = "data" source = "iso/chart/7.2n.cht"/>
<file name = "7.2h.cht" type = "data" source = "iso/chart/7.2h.cht"/>
<!-- Stress charts -->
<file name = "7.3e.cht" type = "data" source = "iso/chart/7.3e.cht"/>
<file name = "7.3n.cht" type = "data" source = "iso/chart/7.3n.cht"/>
<file name = "7.3h.cht" type = "data" source = "iso/chart/7.3h.cht"/>
</dir>

<!-- Boyfriend assets -->
<dir name = "bf">
<file name = "main.arc" type = "data" source = "iso/bf/main.arc"/>
<file name = "dead.arc" type = "data" source = "iso/bf/dead.arc"/>
</dir>

<!-- Girlfriend assets -->
<dir name = "gf">
<file name = "main.arc" type = "data" source = "iso/gf/main.arc"/>
</dir>

<!-- Dad assets -->
<dir name = "dad">
<file name = "main.arc" type = "data" source = "iso/dad/main.arc"/>
Expand Down Expand Up @@ -197,6 +218,10 @@
<dummy sectors="128"/>
<file name = "week6b.xa" type = "xa" source = "iso/music/week6b.xa"/>
<dummy sectors="128"/>
<file name = "week7a.xa" type = "xa" source = "iso/music/week7a.xa"/>
<dummy sectors="128"/>
<file name = "week7b.xa" type = "xa" source = "iso/music/week7b.xa"/>
<dummy sectors="128"/>
</dir>

<!-- Dummy sectors -->
Expand Down
Binary file added iso/chart/7.1e.cht
Binary file not shown.
Binary file added iso/chart/7.1h.cht
Binary file not shown.
Binary file added iso/chart/7.1n.cht
Binary file not shown.
Binary file added iso/chart/7.2e.cht
Binary file not shown.
Binary file added iso/chart/7.2h.cht
Binary file not shown.
Binary file added iso/chart/7.2n.cht
Binary file not shown.
Binary file added iso/chart/7.3e.cht
Binary file not shown.
Binary file added iso/chart/7.3h.cht
Binary file not shown.
Binary file added iso/chart/7.3n.cht
Binary file not shown.
Binary file added iso/gf/bopleft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added iso/gf/bopleft.tim
Binary file not shown.
Binary file added iso/gf/bopright.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added iso/gf/bopright.tim
Binary file not shown.
Binary file added iso/gf/cry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added iso/gf/cry.tim
Binary file not shown.
Binary file added iso/gf/main.arc
Binary file not shown.
Binary file added iso/music/week7a.xa
Binary file not shown.
Binary file added iso/music/week7b.xa
Binary file not shown.
78 changes: 67 additions & 11 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define XA_STATE_PLAYING (1 << 1)
#define XA_STATE_LOOPS (1 << 2)
#define XA_STATE_SEEKING (1 << 3)
static u8 xa_state;
static u8 xa_state, xa_resync, xa_volume, xa_channel;
static u32 xa_pos, xa_start, xa_end;

//XA files and tracks
Expand Down Expand Up @@ -60,10 +60,10 @@ static const XA_TrackDef xa_tracks[] = {
//WEEK6B.XA
{XA_Week6B, XA_LENGTH(10298)}, //XA_Thorns
//WEEK7A.XA
//{XA_Week7A, XA_LENGTH(8493)}, //XA_Ugh
//{XA_Week7A, XA_LENGTH(13866)}, //XA_Guns
{XA_Week7A, XA_LENGTH(8493)}, //XA_Ugh
{XA_Week7A, XA_LENGTH(13866)}, //XA_Guns
//WEEK7B.XA
//{XA_Week7B, XA_LENGTH(12200)}, //XA_Stress
{XA_Week7B, XA_LENGTH(12200)}, //XA_Stress
};


Expand All @@ -84,7 +84,7 @@ static void XA_SetVolume(u8 x)
{
//Set CD mix volume
CdlATV cd_vol;
cd_vol.val0 = cd_vol.val1 = cd_vol.val2 = cd_vol.val3 = x;
xa_volume = cd_vol.val0 = cd_vol.val1 = cd_vol.val2 = cd_vol.val3 = x;
CdMix(&cd_vol);
}

Expand All @@ -96,6 +96,7 @@ static void XA_Init()
if (xa_state & XA_STATE_INIT)
return;
xa_state = XA_STATE_INIT;
xa_resync = 0;

//Set CD mix flag
SpuCommonAttr spu_attr;
Expand Down Expand Up @@ -150,7 +151,7 @@ static void XA_SetFilter(u8 channel)
//Change CD filter
CdlFILTER filter;
filter.file = 1;
filter.chan = channel;
xa_channel = filter.chan = channel;
CdControlF(CdlSetfilter, (u8*)&filter);
}

Expand Down Expand Up @@ -179,8 +180,8 @@ void Audio_Init()
"\\MUSIC\\WEEK5B.XA;1", //XA_Week5B
"\\MUSIC\\WEEK6A.XA;1", //XA_Week6A
"\\MUSIC\\WEEK6B.XA;1", //XA_Week6B
//"\\MUSIC\\WEEK7A.XA;1", //XA_Week7A
//"\\MUSIC\\WEEK7B.XA;1", //XA_Week7B
"\\MUSIC\\WEEK7A.XA;1", //XA_Week7A
"\\MUSIC\\WEEK7B.XA;1", //XA_Week7B
};
CdlFILE *filep = xa_files;
for (u8 i = 0; i < XA_Max; i++)
Expand All @@ -204,6 +205,7 @@ void Audio_PlayXA_File(CdlFILE *file, u8 volume, u8 channel, boolean loop)
xa_start = xa_pos = CdPosToInt(&file->pos);
xa_end = xa_start + (file->size / IO_SECT_SIZE) - 1;
xa_state = XA_STATE_INIT | XA_STATE_PLAYING | XA_STATE_SEEKING;
xa_resync = 0;
if (loop)
xa_state |= XA_STATE_LOOPS;

Expand Down Expand Up @@ -270,15 +272,67 @@ void Audio_ProcessXA()
//Handle playing state
if (xa_state & XA_STATE_PLAYING)
{
//Retrieve CD status
CdControl(CdlNop, NULL, NULL);
u8 cd_status = CdStatus();

//Handle resync timer
if (xa_resync != 0)
{
//Wait for resync timer
if (--xa_resync != 0)
return;

//Check if we're in a proper state
if (cd_status & CdlStatShellOpen)
return;

//Attempt to get CD drive active
while (1)
{
CdControl(CdlNop, NULL, NULL);
cd_status = CdStatus();
if (cd_status & CdlStatStandby)
break;
}

//Re-initialize XA system
u8 prev_state = xa_state;
XA_Init();
xa_state = prev_state;

XA_SetFilter(xa_channel);
XA_SetVolume(xa_volume);

//Get new CD status
CdControl(CdlNop, NULL, NULL);
cd_status = CdStatus();
}

//Check CD status for issues
if (cd_status & CdlStatShellOpen)
{
//Seek just ahead of last reported valid position
if (!(xa_state & XA_STATE_SEEKING))
{
xa_pos++;
xa_state |= XA_STATE_SEEKING;
}

//Wait a moment before attempting the actual resync
xa_resync = 60;
return;
}

//Handle seeking state
if (xa_state & XA_STATE_SEEKING)
{
//Check if CD is still seeking to the XA's beginning
if (!IO_IsSeeking())
if (!(cd_status & CdlStatSeek))
{
//Stopped seeking
xa_state &= ~XA_STATE_SEEKING;
XA_Play(xa_start);
XA_Play(xa_pos);
}
else
{
Expand All @@ -288,7 +342,9 @@ void Audio_ProcessXA()
}

//Get CD position
xa_pos = XA_TellSector();
u32 next_pos = XA_TellSector();
if (next_pos > xa_pos)
xa_pos = next_pos;

//Check position
if (xa_pos >= xa_end)
Expand Down
4 changes: 2 additions & 2 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ typedef enum
XA_Week5B, //WEEK5B.XA
XA_Week6A, //WEEK6A.XA
XA_Week6B, //WEEK6B.XA
//XA_Week7A, //WEEK7A.XA
//XA_Week7B, //WEEK7B.XA
XA_Week7A, //WEEK7A.XA
XA_Week7B, //WEEK7B.XA

XA_Max,
} XA_File;
Expand Down
2 changes: 1 addition & 1 deletion src/character.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ void Character_Draw(Character *this, Gfx_Tex *tex, const CharFrame *cframe)

RECT src = {cframe->src[0], cframe->src[1], cframe->src[2], cframe->src[3]};
RECT_FIXED dst = {x, y, src.w << FIXED_SHIFT, src.h << FIXED_SHIFT};
Stage_DrawTex(tex, &src, &dst, FIXED_MUL(stage.camera.zoom, stage.bump));
Stage_DrawTex(tex, &src, &dst, stage.camera.bzoom);
}
4 changes: 2 additions & 2 deletions src/character/bf.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ void Char_BF_SetAnim(Character *character, u8 anim)
//Begin reading dead.arc and adjust focus
this->arc_dead = IO_AsyncReadFile(&this->file_dead_arc);
character->focus_x = FIXED_DEC(0,1);
character->focus_y = FIXED_DEC(-90,1);
character->focus_zoom = FIXED_DEC(115,100);
character->focus_y = FIXED_DEC(-40,1);
character->focus_zoom = FIXED_DEC(125,100);
break;
case PlayerAnim_Dead2:
//Unload main.arc
Expand Down
Loading

0 comments on commit 6096b72

Please sign in to comment.