Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Samples/ASCII - Fonts/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"configurations": [
{
"name": "Saturn",
"includePath": [
"${workspaceFolder}/../../saturnringlib",
"${workspaceFolder}/../../modules/sgl/INC",
"${workspaceFolder}/../../modules/tlsf",
"${workspaceFolder}/../../modules/SaturnMathPP",
"${workspaceFolder}/../../Compiler/sh2eb-elf/sh-elf/include",
"${workspaceFolder}/../../Compiler/sh2eb-elf/sh-elf/include/c++/14.2.0",
"${workspaceFolder}/../../saturnringlib/**"
],
"compilerPath": "${workspaceFolder}/../../Compiler/sh2eb-elf/bin/sh-elf-gcc-14.2.0.exe",
"cStandard": "c23",
"cppStandard": "c++23",
"intelliSenseMode": "gcc-x86",
"defines": [
"__STDC_HOSTED__=0",
"SRL_CUSTOM_SGL_WORK_AREA=0",
"SRL_MALLOC_MEMORY=131072",
"SRL_MAX_TEXTURES=100",
"SRL_MODE_PAL",
"SRL_FRAMERATE=0",
"SRL_MAX_CD_BACKGROUND_JOBS=1",
"SRL_MAX_CD_FILES=255",
"SRL_MAX_CD_RETRIES=5",
"SRL_DEBUG_MAX_PRINT_LENGTH=45",
"SRL_USE_SGL_SOUND_DRIVER=1",
"SRL_ENABLE_FREQ_ANALYSIS=1",
"DEBUG"
]
}
],
"version": 4
}
5 changes: 5 additions & 0 deletions Samples/ASCII - Fonts/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode.cpptools"
]
}
42 changes: 42 additions & 0 deletions Samples/ASCII - Fonts/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"files.exclude": {
"**/*.o": true,
"**/*.bat": true,
"[Cc][Dd]/[Bb]uild[Dd]rop**" : true,
},
"files.watcherExclude": {
"**/*.o": true,
"**/*.bat": true,
"[Cc][Dd]/[Bb]uild[Dd]rop**" : true,
},
"C_Cpp.loggingLevel": "Debug",
"files.associations": {
"*.embeddedhtml": "html",
"*.H": "c",
"*.C": "c",
"*.def": "c",
"*.h": "c",
"*.c": "c",
"*.HPP": "cpp",
"*.CXX": "cpp",
"*.hpp": "cpp",
"*.cxx": "cpp",
"functional": "cpp",
"vector": "cpp"
},
"cmake.configureOnOpen": false,
"makefile.makefilePath": "./makefile",
"C_Cpp.default.cppStandard": "c++23",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.formatting": "vcFormat",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "newLine",
"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": "newLine",
"C_Cpp.vcFormat.indent.lambdaBracesWhenParameter": false,
"C_Cpp.inlayHints.autoDeclarationTypes.enabled": true,
"C_Cpp.inlayHints.autoDeclarationTypes.showOnLeft": true,
"C_Cpp.inlayHints.referenceOperator.enabled": true,
"C_Cpp.inlayHints.referenceOperator.showSpace": true
}
63 changes: 63 additions & 0 deletions Samples/ASCII - Fonts/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Run with Mednafen",
"type": "shell",
"command": "./run_with_mednafen.bat",
"problemMatcher": [],
"presentation": {
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Compile [DEBUG]",
"type": "shell",
"command": "./compile.bat debug",
"problemMatcher": [],
"presentation": {
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Compile [RELEASE]",
"type": "shell",
"command": "./compile.bat release",
"problemMatcher": [],
"presentation": {
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Clean",
"type": "shell",
"command": "./clean.bat",
"problemMatcher": [],
"presentation": {
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
]
}
Binary file added Samples/ASCII - Fonts/cd/data/FONT1.tga
Binary file not shown.
3 changes: 3 additions & 0 deletions Samples/ASCII - Fonts/clean.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:; "../../tools/scripts/make.sh" clean; exit;
@ECHO Off
"../../tools/scripts/make.bat" clean
3 changes: 3 additions & 0 deletions Samples/ASCII - Fonts/compile.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:; "../../tools/scripts/make.sh" $1; exit;
@ECHO Off
"../../tools/scripts/make.bat" %1
35 changes: 35 additions & 0 deletions Samples/ASCII - Fonts/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Configuration
SRL_MAX_TEXTURES = 100 # Number of VDP1 texture slots
SRL_MODE = NTSC # Valid options are PAL or NTSC
SRL_HIGH_RES = 0 # 480i mode
SRL_FRAMERATE = 1 # Framerate control (0=dynamic, 1=< 60/value)
SRL_MAX_CD_BACKGROUND_JOBS = 1 # Maximum number of files GFS can open at once
SRL_MAX_CD_FILES = 256 # Maximum number of files on a CD
SRL_MAX_CD_RETRIES = 5 # Number of times to retry on unsuccessful read

# Sound driver specific configuration
SRL_USE_SGL_SOUND_DRIVER = 0 # Set to 1 if you want to use SGL sound driver, this will copy necessary files into the CD folder
SRL_ENABLE_FREQ_ANALYSIS = 0 # Set to 1 if you want to enable frequency analysis for CD audio, this will load a DSP program into effect slot 1, SGL sound driver must be enabled

# SGL configuration
SGL_MAX_VERTICES = 2500 # Number of vertices that can be used
SGL_MAX_POLYGONS = 1500 # Number of polygons that can be used
SGL_MAX_EVENTS = 1 # Number of events that can be used
SGL_MAX_WORKS = 1 # Number of works that can be used

# Disk name
CD_NAME = VDP2_ScrollScreen

# Directory build will be placed into
BUILD_DROP = ./BuildDrop

# SRL installation directory
SRL_INSTALL_ROOT ?= ../..

# Find all .c and .cxx files
SOURCES = $(patsubst ./%,%,$(shell find src/ -name '*.c'))
SOURCES += $(patsubst ./%,%,$(shell find src/ -name '*.cxx'))

# Include shared makefile
SDK_ROOT = $(SRL_INSTALL_ROOT)/saturnringlib
include $(SDK_ROOT)/shared.mk
3 changes: 3 additions & 0 deletions Samples/ASCII - Fonts/run_with_mednafen.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:; "../../tools/scripts/run.sh" mednafen; exit;
@ECHO Off
"../../tools/scripts/run.bat" mednafen
93 changes: 93 additions & 0 deletions Samples/ASCII - Fonts/src/main.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*VDP2 Scroll Layer Demo:
This Demo provides a sample of using the SRL::ASCII module to load custom fonts
and swap between multiple fonts and color palettes. The system is largely meant
to display debug messages to developers, but can be used for simple dialog
systems as well.
However because The characters printed are fixed to a tilemap grid, font
formatting features such as variable width characters and kerning are not
possible with this system. Fonts are limited to 16 color 8x8 characters.
*/
#include <srl.hpp>

using namespace SRL::Types;
using namespace SRL::Input;
using namespace SRL::Math;

//A custom 16 color palette to load for a font:
HighColor CustomPalette[16] =
{
HighColor::Colors::Black,//note: index 0 color in a palette will be transparent
HighColor::Colors::Red,
HighColor::Colors::Green,
HighColor::Colors::Blue,
HighColor::Colors::White,
HighColor::Colors::Magenta,
HighColor::Colors::Yellow,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
HighColor::Colors::Black,
};

int main()
{

SRL::Core::Initialize(HighColor(20,10,50));

/* During initialization, SRL loads the SGL font to font index 0.
By default print statements will display using font index 0, palette index 0:*/

SRL::Debug::Print(1,2,"SRL Ascii Font Demo");
SRL::Debug::Print(1,7,"This is the Default SGL Font");

/*The font system can use the first 8 16 color palettes in CRAM (0-7).
So we can load additional palettes to use with fonts: */

//reserve CRAM palette 1 for a font palette:
SRL::CRAM::SetBankUsedState(1, SRL::CRAM::TextureColorMode::Paletted16, true);
SRL::CRAM::Palette MyPalette(SRL::CRAM::TextureColorMode::Paletted16, 1);

//load custom colors to CRAM palette 1
MyPalette.Load(CustomPalette,16);

//Switch the current font palette:
SRL::ASCII::SetPalette(1);

//Now subsequent print statments will use palette 1:
SRL::Debug::Print(1,10, "This is a custom font palette-");
SRL::Debug::Print(1,11, "8 palettes can display simultaneously!");

//Switch back to palette 0
SRL::ASCII::SetPalette(0);

/*Custom fonts can also be used. Up to 6 can be loaded and displayed at once (0-5).
The system loads 8x8 character ASCII tables from a bitmap source.
-Ensure the source is 4bpp (16 color) and the table begins with
one whitespace character followed by the standard Ascii characters. See the
included image in the CD::Data folder for an example of the proper table format.
-Only 7bit ascii tables (first 128 characters) are supported.*/

//load bitmap of the custom font to work ram
SRL::Bitmap::TGA* CustomFont = new SRL::Bitmap::TGA("FONT1.TGA");

//load custom font to Ascii index 1:
SRL::ASCII::LoadFont(CustomFont, 1);

//Now we can switch to the new font like we switched palettes:
SRL::ASCII::SetFont(1);
SRL::Debug::Print(1,14,"This is a custom font-");
SRL::Debug::Print(1,15,"6 fonts can display simultaneously!");

//Main Game Loop
while(1)
{
//Print statments will remain on screen until SRL::ASCII::Clear() is Called
SRL::Core::Synchronize();
}
return 0;
}
2 changes: 1 addition & 1 deletion Samples/VDP1 - 3D - Smooth teapot/src/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main()

// Initializes gouraud table work area
SRL::Scene3D::LightInitGouraudTable(0, vertWork, workTable, polygons);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless change, plese revert

// Sets current light shading table
SRL::Scene3D::LightSetGouraudTable(shadingTable);

Expand Down
3 changes: 1 addition & 2 deletions Samples/VDP2 - ColorCalc/src/main.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*VDP2 Color Calculation Demo:
This Demo Shows The use of VDP2 Color Calculation and Priority through SRL and demonstrates
its effect by creating an interactive version of color calculation diagrams found in the
VDP2 Users Manual.
VDP2 Users Manual.

A Blue Triangle, Green Square, and Red Circle are displayed on 3 separate VDP2 ScrollScreens.
Priorities are set such that the Triangle draws on top, Square draws in middle, and Circle draws
Expand Down Expand Up @@ -161,7 +161,6 @@ class UiManager
SRL::Debug::Print(0,CursorLine+5,"->");

}

};

int main()
Expand Down
Binary file removed Samples/VDP2 - Layers/cd/data/FOGRGB.bin
Binary file not shown.
12 changes: 7 additions & 5 deletions Samples/VDP2 - Layers/src/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ using namespace SRL::Math;

int main()
{



SRL::Core::Initialize(HighColor(20,10,50));
Digital port0(0); // Initialize gamepad on port 0

SRL::Tilemap::Interfaces::CubeTile* TestTilebin = new SRL::Tilemap::Interfaces::CubeTile("SPACE.BIN");//Load tilemap from cd to work RAM

SRL::Tilemap::TilemapInfo TestInfo = TestTilebin->GetInfo();

SRL::VDP2::NBG0::LoadTilemap(*TestTilebin);//Transfer tilemap from work RAM to VDP2 VRAM and register with NBG0
delete TestTilebin;//free work RAM

delete TestTilebin;//free work RAM

TestTilebin = new SRL::Tilemap::Interfaces::CubeTile("FOG256.BIN");//Load fog tilemap from cd to work RAM
SRL::VDP2::NBG1::LoadTilemap(*TestTilebin);//Transfer tilemap from work RAM to VDP2 VRAM and register with NBG1
delete TestTilebin;//free work RAM
Expand Down Expand Up @@ -60,14 +62,14 @@ int main()
SRL::VDP2::NBG2::SetPosition(Nbg2Position);//Set the static screen position for SRL Logo
SRL::VDP2::NBG2::ScrollEnable();//enable display of NBG2

SRL::Debug::Print(1,3,"VDP2 ScrollScreen Sample");
SRL::Debug::Print(1,3,"VDP2 ScrollScreen Layers Sample");

//Main Game Loop
while(1)
{
//move positions of NBG0 and NBG1 scrolls:
Nbg0Position += Vector2D(1.0, 1.0);
Nbg1Position += Vector2D(-2.0, 1.0);
Nbg1Position += Vector2D(1.0, 0.0);
SRL::VDP2::NBG0::SetPosition(Nbg0Position);
SRL::VDP2::NBG1::SetPosition(Nbg1Position);

Expand Down
Loading
Loading