Skip to content

Commit

Permalink
renderer by spicyjpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
UNSTOP4BLE committed Jul 14, 2024
1 parent 1ad9816 commit e142b9e
Show file tree
Hide file tree
Showing 31 changed files with 1,046 additions and 459 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ set(
set(
sdlLibraries
SDL2
SDL2_image
)
set(
pspLibraries
Expand Down
11 changes: 4 additions & 7 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@
#include "psp/font.h"
#include "psp/assetmanager.h"

//#ifndef PSP
//#endif

class PSPFunkin
{
public:
std::vector<std::string> debugmessages; //debug terminal

//#ifndef PSP
Renderer *renderer;
Gfx::Renderer *renderer;
Gfx::DrawingContext draw_ctx;

Input::Event event;
FontManager *boldFont;
FontManager *normalFont;
//#endif
AssetManager assetmanager;
Timer timer;
Audio::Mixer *audioMixer;
ChartParser parser;
double deltatime;
Color screenCol;
Gfx::Color screenCol;
Screen *currentScreen;
};

Expand Down
4 changes: 2 additions & 2 deletions src/combo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ void Combo::tick(void)
objects[i].falling = true;
if (objects[i].falling) {
objects[objectindex].y.setValue(app->renderer->screenheight, 0.3);
objects[objectindex].y.setValue(app->renderer->height, 0.3);
if (objects[i].timer > 0)
objects[i].alpha -= 4;
}
//destroy object
if (objects[i].y.getValue() >= app->renderer->screenheight)
if (objects[i].y.getValue() >= app->renderer->height)
objects[i].tick = false;
objects[i].disp = {static_cast<int>(objects[i].x), static_cast<int>(objects[i].y.getValue()), 100, 50};
}*/
Expand Down
6 changes: 3 additions & 3 deletions src/combo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include "psp/gfx.h"
#include <string>
#include "psp/gfx_common.h"
#include "psp/tween.h"
#include "psp/assetmanager.h"

Expand All @@ -13,8 +13,8 @@ class ComboObject
float x;
Tween<float, QuadInOutEasing, Chrono> y;
int ymin;
RECT<int> img;
RECT<int> disp;
Gfx::RectWH<int> img;
Gfx::RectWH<int> disp;
int timer;
float alpha;
private:
Expand Down
53 changes: 36 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "psp/gfx.h"
#include <cstdio>
#define SDL_MAIN_HANDLED
#include "psp/gfx_renderer_psp.h"
#include <cstdio>
#include "main.h"
#include "app.h"
#include "screen.h"
Expand All @@ -9,17 +9,12 @@
#include <pspkernel.h>
#include <psputility.h>
#include "psp/callbacks.h"
#else
#include <SDL2/SDL_image.h>
#endif
#include <SDL2/SDL.h>
#include <chrono>
#include "psp/audio_file_readers.h"
#include "psp/audio_streamed_file.h"
#include "psp/font.h"
#include "psp/font.h"
#include "psp/input.h"
#include "psp/tween.h"

#include "menu/title.h"
#ifdef _WIN32
Expand Down Expand Up @@ -76,7 +71,6 @@ void ErrMSG(const char *filename, const char *function, int line, const char *ex
debugmenu(debugy);

app->renderer->swapBuffers();
app->renderer->waitForVSync();
}
}

Expand Down Expand Up @@ -114,11 +108,29 @@ int main()
ASSERTFUNC(SDL_Init(SDL_INIT_EVERYTHING) >= 0, "failed to init sdl");
app->audioMixer = new Audio::Mixer();
app->audioMixer->start();
app->renderer = new PSPRenderer(480, 272, 2);
#ifdef PSP
app->renderer = new Gfx::PSPRenderer(480, 272);
#else
app->renderer = new Gfx::OpenGLRenderer(1280, 720);
#endif
if (!app->renderer)
{
char buffer[512];
snprintf(buffer, sizeof(buffer), "renderer initialization failed");

#ifdef _WIN32
MessageBox(nullptr, buffer, "PSPFunkin error", MB_ICONERROR | MB_OK);
#else
debugLog(buffer);
#endif
exit(1);
}

app->draw_ctx.renderer = app->renderer;
app->normalFont = new FontManager(Font_Font, getPath("assets/font/font.png").c_str());
app->boldFont = new FontManager(Font_Bold, getPath("assets/font/boldfont.png").c_str());

setScreenCol(0xFF00FF00);

#if defined(PSP) || defined(__vita__)
Input::ControllerDevice inputDevice;
#else
Expand All @@ -137,7 +149,7 @@ int main()
{
std::chrono::time_point<std::chrono::system_clock> last = std::chrono::high_resolution_clock::now();

app->renderer->clear(app->screenCol, 0);
app->draw_ctx.beginFrame();
#ifndef PSP
SDL_PumpEvents();

Expand All @@ -154,11 +166,19 @@ int main()
app->currentScreen->update();
app->currentScreen->draw();

Line line = {
{0xff00ff00,10,20, 1}, // 0
{0xffff0000,20,40, 1}, // 1
Gfx::Line line = {
{0xffff0000, 10,20, 1},
{0xffff0000, 20,40, 1}
};
app->renderer->drawLines(&line, 1);
app->draw_ctx.drawLine(line);

Gfx::Triangle triangle = {
{0xffff0000, 10,20, 1},
{0xffff0000, 20,40, 1},
{0xffff0000, 40,50, 1}
};
// app->draw_ctx.drawTriangle(triangle);

#ifdef _WIN32
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));
Expand All @@ -173,8 +193,7 @@ int main()
if (debugshown)
debugmenu(debugy);

app->renderer->waitForVSync();
app->renderer->swapBuffers();
app->draw_ctx.endFrame();

std::chrono::time_point<std::chrono::system_clock> current = std::chrono::high_resolution_clock::now();
app->deltatime = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(current - last).count());
Expand Down
8 changes: 4 additions & 4 deletions src/menu/donate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ void DonateScreen::update(void)

void DonateScreen::draw(void)
{
RECT<int> background_img = {0, 0, 512, 331};
RECT<float> background_disp = {app->renderer->screenwidth/2 - 700/2, app->renderer->screenheight/2 - 397/2, 700, 397};
Gfx::RectWH<int> background_img = {0, 0, 512, 331};
Gfx::RectWH<int> background_disp = {app->renderer->width/2 - 700/2, app->renderer->height/2 - 397/2, 700, 397};
//GFX::drawTex<float>(&background->image, &background_img, &background_disp, 0, 255, 1);

app->normalFont->Print(Center, app->renderer->screenwidth/2, app->renderer->screenheight/2, "DONATE TO ME IF YOU LIKE MY WORKS!!");
app->normalFont->Print(Center, app->renderer->screenwidth/2, app->renderer->screenheight/2+11, "paypal.me/johnathanthepork16th");
app->normalFont->Print(Center, app->renderer->width/2, app->renderer->height/2, "DONATE TO ME IF YOU LIKE MY WORKS!!");
app->normalFont->Print(Center, app->renderer->width/2, app->renderer->height/2+11, "paypal.me/johnathanthepork16th");
}

DonateScreen::~DonateScreen(void)
Expand Down
4 changes: 2 additions & 2 deletions src/menu/freeplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ void FreeplayScreen::update(void)

void FreeplayScreen::draw(void)
{
RECT<int> background_img = {0, 0, 512, 331};
RECT<float> background_disp = {app->renderer->screenwidth/2 - 700/2, app->renderer->screenheight/2 - 397/2, 700, 397};
Gfx::RectWH<int> background_img = {0, 0, 512, 331};
Gfx::RectWH<int> background_disp = {app->renderer->width/2 - 700/2, app->renderer->height/2 - 397/2, 700, 397};
//GFX::drawColTex<float>(&background->image, &background_img, &background_disp, 0, 255, 1,
// 146, 113, 253);
for (int i = 0; i < static_cast<int>(songs.size()); i++)
Expand Down
6 changes: 3 additions & 3 deletions src/menu/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ void MainMenuScreen::update(void)

void MainMenuScreen::draw(void)
{
RECT<int> background_img = {0, 0, 512, 331};
RECT<float> background_disp = {app->renderer->screenwidth/2 - 700/2, backgroundy.getValue(), 700, 397};
Gfx::RectWH<int> background_img = {0, 0, 512, 331};
Gfx::RectWH<int> background_disp = {app->renderer->width/2 - 700/2, backgroundy.getValue(), 700, 397};
//GFX::drawColTex<float>(&background->image, &background_img, &background_disp, 0, 255, 1,
// 253, 232, 113);

int y = 0;
for (int i = 0; i < static_cast<int>(COUNT_OF(menu_selections)); i++)
{
menu_selections[i]->draw(app->renderer->screenwidth/2 - menu_selections[i]->frames[menu_selections[i]->curframe].w/2, y + (25 + menu_selections[i]->frames[menu_selections[i]->curframe].h/2), 0, 255, 1);
menu_selections[i]->draw(app->renderer->width/2 - menu_selections[i]->frames[menu_selections[i]->curframe].w/2, y + (25 + menu_selections[i]->frames[menu_selections[i]->curframe].h/2), 0, 255, 1);
y += MENU_SPACING;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/menu/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void OptionsScreen::update(void)

void OptionsScreen::draw(void)
{
RECT<int> background_img = {0, 0, 512, 331};
RECT<float> background_disp = {app->renderer->screenwidth/2 - 700/2, app->renderer->screenheight/2 - 397/2, 700, 397};
Gfx::RectWH<int> background_img = {0, 0, 512, 331};
Gfx::RectWH<int> background_disp = {app->renderer->width/2 - 700/2, app->renderer->height/2 - 397/2, 700, 397};
//GFX::drawTex<float>(&background->image, &background_img, &background_disp, 0, 255, 1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/menu/storymode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void StoryModeScreen::update(void)

void StoryModeScreen::draw(void)
{
RECT<int> black_background = {0, 0, app->renderer->screenwidth, app->renderer->screenheight};
Gfx::RectWH<int> black_background = {0, 0, app->renderer->width, app->renderer->height};
//GFX::drawrect(&black_background, 1, 0, 0, 0);
RECT<int> middle_strap = {0, 21, app->renderer->screenwidth, 152};
Gfx::RectWH<int> middle_strap = {0, 21, app->renderer->width, 152};
//GFX::drawrect(&middle_strap, 1, 247, 208, 81);

app->normalFont->Print(Left, 5, 6, "WEEK SCORE: ");
Expand Down
35 changes: 17 additions & 18 deletions src/menu/title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

TitleScreen::TitleScreen(int songpos, TitleStates _state)
{
setScreenCol(0xFF000000);
// setScreenCol(0xFF000000);

//load menu jsons
const JsonAsset *titleJson = app->assetmanager.get<JsonAsset>(getPath("assets/menu/title/title.json").c_str());
Expand All @@ -22,7 +22,6 @@ TitleScreen::TitleScreen(int songpos, TitleStates _state)
funnymessage[0] = titleJson->value["messages"][curmsg][0].asString();
funnymessage[1] = titleJson->value["messages"][curmsg][1].asString();


//load and play music
app->parser.chartdata.bpm = titleJson->value["menuSongBPM"].asDouble();
app->parser.calcCrochet();
Expand Down Expand Up @@ -78,52 +77,52 @@ void TitleScreen::update(void)
void TitleScreen::draw(void)
{
//NG logo
RECT<int> NG_img = {0, 0, 90, 88};
RECT<int> NG_disp = {app->renderer->screenwidth / 2 - 90/2, (app->renderer->screenheight / 2 + 88/2) - 20, 90, 88};
Gfx::RectWH<int> NG_img = {0, 0, 90, 88};
Gfx::RectWH<int> NG_disp = {app->renderer->width / 2 - 90/2, (app->renderer->height / 2 + 88/2) - 20, 90, 88};
switch (state)
{
case Intro:
switch (app->parser.curBeat)
{
case 3:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 + 38, "PRESENT");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 + 38, "PRESENT");
[[fallthrough]];
case 2:
[[fallthrough]];
case 1:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 57, "UNSTOPABLE");
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 38, "IGORSOU");
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 19, "MAXDEV");
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2, "SPICYJPEG");
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 + 19, "BILIOUS");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 57, "UNSTOPABLE");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 38, "IGORSOU");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 19, "MAXDEV");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2, "SPICYJPEG");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 + 19, "BILIOUS");
break;
case 7:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 10, "NEWGROUNDS");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 10, "NEWGROUNDS");
//GFX::drawTex<int>(&ng->image, &NG_img, &NG_disp, 0, 255, 1);
[[fallthrough]];
case 6:
[[fallthrough]];
case 5:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 48, "IN ASSOCIATION");
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 29, "WITH");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 48, "IN ASSOCIATION");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 29, "WITH");
break;

case 11:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2, funnymessage[1].c_str());
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2, funnymessage[1].c_str());
[[fallthrough]];
case 10:
[[fallthrough]];
case 9:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 19, funnymessage[0].c_str());
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 19, funnymessage[0].c_str());
break;
case 15:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 + 9, "FUNKIN");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 + 9, "FUNKIN");
[[fallthrough]];
case 14:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 10, "NIGHT");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 10, "NIGHT");
[[fallthrough]];
case 13:
app->boldFont->Print(Center, app->renderer->screenwidth / 2, app->renderer->screenheight / 2 - 29, "FRIDAY");
app->boldFont->Print(Center, app->renderer->width / 2, app->renderer->height / 2 - 29, "FRIDAY");
break;
case 16:
state = Flash;
Expand Down
Loading

0 comments on commit e142b9e

Please sign in to comment.