-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1721 from nicolasnoble/kernel-takeover
Allowing psyqo to optionally take over the kernel.
- Loading branch information
Showing
18 changed files
with
525 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
TARGET = hello | ||
TYPE = ps-exe | ||
|
||
SRCS = \ | ||
hello.cpp \ | ||
|
||
LDFLAGS += -Xlinker --defsym=TLOAD_ADDR=0x80001000 | ||
|
||
ifeq ($(TEST),true) | ||
CPPFLAGS = -Werror | ||
endif | ||
CXXFLAGS = -std=c++20 | ||
|
||
include ../../psyqo.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2024 PCSX-Redux authors | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
#include "psyqo/application.hh" | ||
#include "psyqo/font.hh" | ||
#include "psyqo/gpu.hh" | ||
#include "psyqo/kernel.hh" | ||
#include "psyqo/scene.hh" | ||
|
||
// This variant of hello world demonstrates how to let psyqo take over the kernel. | ||
// The only difference is the call to psyqo::Kernel::takeOverKernel() in main. | ||
// Also, this binary is linked so to be loaded at 0x80001000, regaining 60kB of RAM. | ||
namespace { | ||
|
||
class Hello final : public psyqo::Application { | ||
void prepare() override; | ||
void createScene() override; | ||
|
||
public: | ||
psyqo::Font<> m_systemFont; | ||
}; | ||
|
||
class HelloScene final : public psyqo::Scene { | ||
void frame() override; | ||
|
||
uint8_t m_anim = 0; | ||
bool m_direction = true; | ||
}; | ||
|
||
Hello hello; | ||
HelloScene helloScene; | ||
|
||
} // namespace | ||
|
||
void Hello::prepare() { | ||
psyqo::GPU::Configuration config; | ||
config.set(psyqo::GPU::Resolution::W320) | ||
.set(psyqo::GPU::VideoMode::AUTO) | ||
.set(psyqo::GPU::ColorMode::C15BITS) | ||
.set(psyqo::GPU::Interlace::PROGRESSIVE); | ||
gpu().initialize(config); | ||
} | ||
|
||
void Hello::createScene() { | ||
m_systemFont.uploadSystemFont(gpu()); | ||
pushScene(&helloScene); | ||
} | ||
|
||
void HelloScene::frame() { | ||
if (m_anim == 0) { | ||
m_direction = true; | ||
} else if (m_anim == 255) { | ||
m_direction = false; | ||
} | ||
psyqo::Color bg{{.r = 0, .g = 64, .b = 91}}; | ||
bg.r = m_anim; | ||
hello.gpu().clear(bg); | ||
if (m_direction) { | ||
m_anim++; | ||
} else { | ||
m_anim--; | ||
} | ||
|
||
psyqo::Color c = {{.r = 255, .g = 255, .b = uint8_t(255 - m_anim)}}; | ||
hello.m_systemFont.print(hello.gpu(), "Hello World!", {{.x = 16, .y = 32}}, c); | ||
} | ||
|
||
int main() { | ||
psyqo::Kernel::takeOverKernel(); | ||
return hello.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.