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

Commit

Permalink
MENU CODE!
Browse files Browse the repository at this point in the history
  • Loading branch information
cuckydev committed Jun 29, 2021
1 parent 78087af commit 3011704
Show file tree
Hide file tree
Showing 71 changed files with 1,478 additions and 322 deletions.
29 changes: 16 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ SRCS = src/main.c \
src/pad.c \
src/random.c \
src/archive.c \
src/font.c \
src/trans.c \
src/loadscr.c \
src/menu.c \
src/stage.c \
src/stage/dummy.c \
Expand All @@ -32,27 +35,27 @@ LDFLAGS += -L../psyq/lib
LDFLAGS += -Wl,--start-group
# TODO: remove unused libraries
LDFLAGS += -lapi
LDFLAGS += -lc
#LDFLAGS += -lc
LDFLAGS += -lc2
LDFLAGS += -lcard
#LDFLAGS += -lcard
LDFLAGS += -lcd
LDFLAGS += -lcomb
LDFLAGS += -lds
#LDFLAGS += -lcomb
#LDFLAGS += -lds
LDFLAGS += -letc
LDFLAGS += -lgpu
LDFLAGS += -lgs
LDFLAGS += -lgte
LDFLAGS += -lgun
LDFLAGS += -lhmd
#LDFLAGS += -lgs
#LDFLAGS += -lgte
#LDFLAGS += -lgun
#LDFLAGS += -lhmd
#LDFLAGS += -lmath
LDFLAGS += -lmcrd
LDFLAGS += -lmcx
#LDFLAGS += -lmcrd
#LDFLAGS += -lmcx
LDFLAGS += -lpad
LDFLAGS += -lpress
LDFLAGS += -lsio
#LDFLAGS += -lpress
#LDFLAGS += -lsio
LDFLAGS += -lsnd
LDFLAGS += -lspu
LDFLAGS += -ltap
#LDFLAGS += -ltap
LDFLAGS += -flto -Wl,--end-group

include ../common.mk
83 changes: 49 additions & 34 deletions funkin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@

<!-- Menu assets -->
<dir name = "menu">
<file name = "whitefnt.tim" type = "data" source = "iso/menu/whitefnt.tim"/>
<file name = "title0.tim" type = "data" source = "iso/menu/title0.tim"/>
<file name = "title1.tim" type = "data" source = "iso/menu/title1.tim"/>
<file name = "ng.tim" type = "data" source = "iso/menu/ng.tim"/>
<file name = "gf0.tim" type = "data" source = "iso/menu/gf0.tim"/>
<file name = "gf1.tim" type = "data" source = "iso/menu/gf1.tim"/>
<file name = "gf2.tim" type = "data" source = "iso/menu/gf2.tim"/>
<file name = "gf3.tim" type = "data" source = "iso/menu/gf3.tim"/>
<file name = "gf4.tim" type = "data" source = "iso/menu/gf4.tim"/>
<file name = "loading.tim" type = "data" source = "iso/menu/loading.tim"/>
<file name = "menu.arc" type = "data" source = "iso/menu/menu.arc"/>
</dir>

<!-- Fonts -->
<dir name = "font">
<file name = "boldfont.tim" type = "data" source = "iso/font/boldfont.tim"/>
</dir>

<!-- Stage assets -->
Expand Down Expand Up @@ -171,34 +169,47 @@
<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"/>
<!-- Kapi assets -->
<dir name = "kapi">
<!-- Wocky charts -->
<file name = "kapi.1e.cht" type = "data" source = "iso/chart/kapi.1e.cht"/>
<file name = "kapi.1n.cht" type = "data" source = "iso/chart/kapi.1n.cht"/>
<file name = "kapi.1h.cht" type = "data" source = "iso/chart/kapi.1h.cht"/>
<!-- Beathoven charts -->
<file name = "kapi.2e.cht" type = "data" source = "iso/chart/kapi.2e.cht"/>
<file name = "kapi.2n.cht" type = "data" source = "iso/chart/kapi.2n.cht"/>
<file name = "kapi.2h.cht" type = "data" source = "iso/chart/kapi.2h.cht"/>
<!-- Hairball charts -->
<file name = "kapi.3e.cht" type = "data" source = "iso/chart/kapi.3e.cht"/>
<file name = "kapi.3n.cht" type = "data" source = "iso/chart/kapi.3n.cht"/>
<file name = "kapi.3h.cht" type = "data" source = "iso/chart/kapi.3h.cht"/>
<!-- Nyaw charts -->
<file name = "kapi.4e.cht" type = "data" source = "iso/chart/kapi.4e.cht"/>
<file name = "kapi.4n.cht" type = "data" source = "iso/chart/kapi.4n.cht"/>
<file name = "kapi.4h.cht" type = "data" source = "iso/chart/kapi.4h.cht"/>
</dir>

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

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

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

<!-- Mom assets -->
<dir name = "mom">
<file name = "main.arc" type = "data" source = "iso/mom/main.arc"/>
<file name = "hair.tim" type = "data" source = "iso/mom/hair.tim"/>
</dir>

<!-- Tankman Captain assets -->
<dir name = "tank">
<file name = "main.arc" type = "data" source = "iso/tank/main.arc"/>
<file name = "ugh.arc" type = "data" source = "iso/tank/ugh.arc"/>
<file name = "good.arc" type = "data" source = "iso/tank/good.arc"/>

<!-- Dad assets -->
<file name = "dad.arc" type = "data" source = "iso/dad/main.arc"/>

<!-- Mom assets -->
<file name = "mom.arc" type = "data" source = "iso/mom/main.arc"/>
<file name = "momhair.tim" type = "data" source = "iso/mom/hair.tim"/>

<!-- Tankman Captain assets -->
<file name = "tank.arc" type = "data" source = "iso/tank/main.arc"/>
<file name = "tankugh.arc" type = "data" source = "iso/tank/ugh.arc"/>
<file name = "tankgood.arc" type = "data" source = "iso/tank/good.arc"/>
</dir>

<!-- Music -->
Expand Down Expand Up @@ -233,6 +244,10 @@
<dummy sectors="128"/>
<file name = "week7b.xa" type = "xa" source = "iso/music/week7b.xa"/>
<dummy sectors="128"/>
<file name = "kapia.xa" type = "xa" source = "iso/music/kapia.xa"/>
<dummy sectors="128"/>
<file name = "kapib.xa" type = "xa" source = "iso/music/kapib.xa"/>
<dummy sectors="128"/>
</dir>

<!-- Dummy sectors -->
Expand Down
Binary file added iso/chart/kapi.1e.cht
Binary file not shown.
Binary file added iso/chart/kapi.1h.cht
Binary file not shown.
Binary file added iso/chart/kapi.1n.cht
Binary file not shown.
Binary file added iso/chart/kapi.2e.cht
Binary file not shown.
Binary file added iso/chart/kapi.2h.cht
Binary file not shown.
Binary file added iso/chart/kapi.2n.cht
Binary file not shown.
Binary file added iso/chart/kapi.3e.cht
Binary file not shown.
Binary file added iso/chart/kapi.3h.cht
Binary file not shown.
Binary file added iso/chart/kapi.3n.cht
Binary file not shown.
Binary file added iso/chart/kapi.4e.cht
Binary file not shown.
Binary file added iso/chart/kapi.4h.cht
Binary file not shown.
Binary file added iso/chart/kapi.4n.cht
Binary file not shown.
Binary file added iso/font/boldfont.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/font/boldfont.tim
Binary file not shown.
Binary file added iso/menu/back.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/menu/back.tim
Binary file not shown.
Binary file removed iso/menu/gf0.png
Binary file not shown.
Binary file removed iso/menu/gf0.tim
Binary file not shown.
Binary file removed iso/menu/gf1.png
Binary file not shown.
Binary file removed iso/menu/gf1.tim
Binary file not shown.
Binary file removed iso/menu/gf2.png
Binary file not shown.
Binary file removed iso/menu/gf2.tim
Binary file not shown.
Binary file removed iso/menu/gf3.png
Binary file not shown.
Binary file removed iso/menu/gf3.tim
Binary file not shown.
Binary file removed iso/menu/gf4.png
Binary file not shown.
Binary file removed iso/menu/gf4.tim
Binary file not shown.
Binary file added iso/menu/loading.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/menu/loading.tim
Binary file not shown.
Binary file added iso/menu/menu.arc
Binary file not shown.
Binary file modified iso/menu/ng.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 modified iso/menu/ng.tim
Binary file not shown.
Binary file added iso/menu/story.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/menu/story.tim
Binary file not shown.
Binary file added iso/menu/title.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/menu/title.tim
Binary file not shown.
Binary file removed iso/menu/title0.png
Binary file not shown.
Binary file removed iso/menu/title0.tim
Binary file not shown.
Binary file removed iso/menu/title1.png
Binary file not shown.
Binary file removed iso/menu/title1.tim
Binary file not shown.
Binary file removed iso/menu/whitefnt.png
Binary file not shown.
Binary file removed iso/menu/whitefnt.tim
Binary file not shown.
Binary file added iso/music/kapia.xa
Binary file not shown.
Binary file added iso/music/kapib.xa
Binary file not shown.
19 changes: 19 additions & 0 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ static const XA_TrackDef xa_tracks[] = {
{XA_Week7A, XA_LENGTH(13866)}, //XA_Guns
//WEEK7B.XA
{XA_Week7B, XA_LENGTH(12200)}, //XA_Stress
//KAPIA.XA
{XA_KapiA, XA_LENGTH(12138)}, //XA_Wocky
{XA_KapiA, XA_LENGTH(12000)}, //XA_Beathoven
//KAPIB.XA
{XA_KapiB, XA_LENGTH(17159)}, //XA_Hairball
{XA_KapiB, XA_LENGTH(15157)}, //XA_Nyaw
};


Expand Down Expand Up @@ -182,6 +188,8 @@ void Audio_Init()
"\\MUSIC\\WEEK6B.XA;1", //XA_Week6B
"\\MUSIC\\WEEK7A.XA;1", //XA_Week7A
"\\MUSIC\\WEEK7B.XA;1", //XA_Week7B
"\\MUSIC\\KAPIA.XA;1", //XA_KapiA
"\\MUSIC\\KAPIB.XA;1", //XA_KapiB
};
CdlFILE *filep = xa_files;
for (u8 i = 0; i < XA_Max; i++)
Expand Down Expand Up @@ -267,6 +275,17 @@ boolean Audio_PlayingXA()
return (xa_state & XA_STATE_PLAYING) != 0;
}

void Audio_WaitPlayXA()
{
while (1)
{
Audio_ProcessXA();
if (Audio_PlayingXA())
return;
VSync(0);
}
}

void Audio_ProcessXA()
{
//Handle playing state
Expand Down
9 changes: 9 additions & 0 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ typedef enum
XA_Week6B, //WEEK6B.XA
XA_Week7A, //WEEK7A.XA
XA_Week7B, //WEEK7B.XA
XA_KapiA, //KAPIA.XA
XA_KapiB, //KAPIB.XA

XA_Max,
} XA_File;
Expand Down Expand Up @@ -67,6 +69,12 @@ typedef enum
XA_Guns, //Guns
//WEEK7B.XA
XA_Stress, //Stress
//KAPIA.XA
XA_Wocky, //Wocky
XA_Beathoven, //Beathoven
//KAPIB.XA
XA_Hairball, //Hairball
XA_Nyaw, //Nyaw
} XA_Track;

//Audio functions
Expand All @@ -81,6 +89,7 @@ void Audio_ChannelXA(u8 channel);
s32 Audio_TellXA_Sector();
s32 Audio_TellXA_Milli();
boolean Audio_PlayingXA();
void Audio_WaitPlayXA();
void Audio_ProcessXA();

#endif
4 changes: 2 additions & 2 deletions src/character/bf.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ Character *Char_BF_New(fixed_t x, fixed_t y)
this->character.focus_zoom = FIXED_DEC(1,1);

//Load art
this->arc_main = IO_Read("\\BF\\MAIN.ARC;1");
this->arc_main = IO_Read("\\CHAR\\BF.ARC;1");
this->arc_dead = NULL;
IO_FindFile(&this->file_dead_arc, "\\BF\\DEAD.ARC;1");
IO_FindFile(&this->file_dead_arc, "\\CHAR\\BFDEAD.ARC;1");

const char **pathp = (const char *[]){
"idle.tim", //BF_ArcMain_Idle
Expand Down
2 changes: 1 addition & 1 deletion src/character/dad.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Character *Char_Dad_New(fixed_t x, fixed_t y)
this->character.focus_zoom = FIXED_DEC(1,1);

//Load art
this->arc_main = IO_Read("\\DAD\\MAIN.ARC;1");
this->arc_main = IO_Read("\\CHAR\\DAD.ARC;1");

const char **pathp = (const char *[]){
"idle0.tim", //Dad_ArcMain_Idle0
Expand Down
2 changes: 1 addition & 1 deletion src/character/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Character *Char_GF_New(fixed_t x, fixed_t y)
this->character.focus_zoom = FIXED_DEC(13,10);

//Load art
this->arc_main = IO_Read("\\GF\\MAIN.ARC;1");
this->arc_main = IO_Read("\\CHAR\\GF.ARC;1");

const char **pathp = (const char *[]){
"bopleft.tim", //GF_ArcMain_BopLeft
Expand Down
4 changes: 2 additions & 2 deletions src/character/mom.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ Character *Char_Mom_New(fixed_t x, fixed_t y)
this->character.focus_zoom = FIXED_DEC(1,1);

//Load hair art
Gfx_LoadTex(&this->tex_hair, IO_Read("\\MOM\\HAIR.TIM;1"), GFX_LOADTEX_FREE);
Gfx_LoadTex(&this->tex_hair, IO_Read("\\CHAR\\MOMHAIR.TIM;1"), GFX_LOADTEX_FREE);
this->hair_i = 0;

//Load art
this->arc_main = IO_Read("\\MOM\\MAIN.ARC;1");
this->arc_main = IO_Read("\\CHAR\\MOM.ARC;1");

const char **pathp = (const char *[]){
"idle0.tim", //Mom_ArcMain_Idle0
Expand Down
2 changes: 1 addition & 1 deletion src/character/speaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void Speaker_Init(Speaker *this)
this->bump = 0;

//Load speaker graphics
Gfx_LoadTex(&this->tex, IO_Read("\\GF\\SPEAKER.TIM;1"), GFX_LOADTEX_FREE);
Gfx_LoadTex(&this->tex, IO_Read("\\CHAR\\SPEAKER.TIM;1"), GFX_LOADTEX_FREE);
}

void Speaker_Bump(Speaker *this)
Expand Down
6 changes: 3 additions & 3 deletions src/character/tank.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Character *Char_Tank_New(fixed_t x, fixed_t y)
this->character.focus_zoom = FIXED_DEC(1,1);

//Load art
this->arc_main = IO_Read("\\TANK\\MAIN.ARC;1");
this->arc_main = IO_Read("\\CHAR\\TANK.ARC;1");

const char **pathp = (const char *[]){
"idle0.tim", //Tank_ArcMain_Idle0
Expand All @@ -221,7 +221,7 @@ Character *Char_Tank_New(fixed_t x, fixed_t y)
case StageId_7_1: //Ugh
{
//Load "Ugh" art
this->arc_scene = IO_Read("\\TANK\\UGH.ARC;1");
this->arc_scene = IO_Read("\\CHAR\\TANKUGH.ARC;1");

const char **pathp = (const char *[]){
"ugh0.tim", //Tank_ArcScene_0
Expand All @@ -236,7 +236,7 @@ Character *Char_Tank_New(fixed_t x, fixed_t y)
case StageId_7_3: //Stress
{
//Load "Heh, pretty good!" art
this->arc_scene = IO_Read("\\TANK\\GOOD.ARC;1");
this->arc_scene = IO_Read("\\CHAR\\TANKGOOD.ARC;1");

const char **pathp = (const char *[]){
"good0.tim", //Tank_ArcScene_0
Expand Down
60 changes: 60 additions & 0 deletions src/font.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "font.h"

#include "main.h"

#include <string.h>

//Font_Bold
s32 Font_Bold_GetWidth(struct FontData *this, const char *text)
{
return strlen(text) * 13;
}

void Font_Bold_Draw(struct FontData *this, const char *text, s32 x, s32 y, FontAlign align)
{
//Offset position based off alignment
switch (align)
{
case FontAlign_Left:
break;
case FontAlign_Center:
x -= Font_Bold_GetWidth(this, text) >> 1;
break;
case FontAlign_Right:
x -= Font_Bold_GetWidth(this, text);
break;
}

//Get animation offsets
u32 v0 = 0;
u8 v1 = (frame_count >> 3) & 1;

//Draw string character by character
u8 c;
while ((c = *text++) != '\0')
{
//Draw character
if ((c -= 'A') <= 'z' - 'A') //Lower-case will show inverted colours
{
RECT src = {((c & 0x7) << 5) + ((((v0 >> c) & 1) ^ v1) << 4), (c & ~0x7) << 1, 16, 16};
Gfx_BlitTex(&this->tex, &src, x, y);
v0 ^= 1 << c;
}
x += 13;
}
}

//Font functions
void FontData_Load(FontData *this, Font font)
{
//Load the given font
switch (font)
{
case Font_Bold:
//Load texture and set functions
Gfx_LoadTex(&this->tex, IO_Read("\\FONT\\BOLDFONT.TIM;1"), GFX_LOADTEX_FREE);
this->get_width = Font_Bold_GetWidth;
this->draw = Font_Bold_Draw;
break;
}
}
Loading

0 comments on commit 3011704

Please sign in to comment.