Compare commits
31 Commits
v0.8.0-pre
...
095-260620
Author | SHA1 | Date | |
---|---|---|---|
c6804dfc03 | |||
a671631dde | |||
566485ccd6 | |||
267f9ce5c3 | |||
5cca34ede4 | |||
5695110739 | |||
476bd93aa7 | |||
9a7078b067 | |||
44ef9f2aad | |||
1ef946570d | |||
ae8181a6e5 | |||
7c190e3cfa | |||
805512fbea | |||
780025bb74 | |||
f6e3c50814 | |||
0399808eb2 | |||
cd677cf3e8 | |||
67edfa4245 | |||
66a35f28e6 | |||
2f7a266dc5 | |||
8a0fd07275 | |||
89299bf91e | |||
af88277680 | |||
dd17a70551 | |||
ec0411373b | |||
222a13387d | |||
c1e471f23a | |||
6b48ba070c | |||
bbbfd60bb7 | |||
62fa5ede9d | |||
20c3a525c8 |
259
.clang-format
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -1
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: true
|
||||||
|
AlignConsecutiveBitFields:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveDeclarations:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignConsecutiveMacros:
|
||||||
|
Enabled: false
|
||||||
|
AcrossEmptyLines: false
|
||||||
|
AcrossComments: false
|
||||||
|
AlignCompound: false
|
||||||
|
PadOperators: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments:
|
||||||
|
Kind: Always
|
||||||
|
OverEmptyLines: 0
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakAfterAttributes: Never
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakArrays: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeConceptDeclarations: Always
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInlineASMColon: OnlyMultiline
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<ext/.*\.h>'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentRequiresClause: true
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertBraces: false
|
||||||
|
InsertNewlineAtEOF: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
IntegerLiteralSeparator:
|
||||||
|
Binary: 0
|
||||||
|
BinaryMinDigits: 0
|
||||||
|
Decimal: 0
|
||||||
|
DecimalMinDigits: 0
|
||||||
|
Hex: 0
|
||||||
|
HexMinDigits: 0
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
LineEnding: DeriveLF
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Never
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PackConstructorInitializers: NextLine
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
PPIndentWidth: -1
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
RawStringFormats:
|
||||||
|
- Language: Cpp
|
||||||
|
Delimiters:
|
||||||
|
- cc
|
||||||
|
- CC
|
||||||
|
- cpp
|
||||||
|
- Cpp
|
||||||
|
- CPP
|
||||||
|
- 'c++'
|
||||||
|
- 'C++'
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
- Language: TextProto
|
||||||
|
Delimiters:
|
||||||
|
- pb
|
||||||
|
- PB
|
||||||
|
- proto
|
||||||
|
- PROTO
|
||||||
|
EnclosingFunctions:
|
||||||
|
- EqualsProto
|
||||||
|
- EquivToProto
|
||||||
|
- PARSE_PARTIAL_TEXT_PROTO
|
||||||
|
- PARSE_TEST_PROTO
|
||||||
|
- PARSE_TEXT_PROTO
|
||||||
|
- ParseTextOrDie
|
||||||
|
- ParseTextProtoOrDie
|
||||||
|
- ParseTestProto
|
||||||
|
- ParsePartialTestProto
|
||||||
|
CanonicalDelimiter: pb
|
||||||
|
BasedOnStyle: google
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
RemoveSemicolon: false
|
||||||
|
RequiresClausePosition: OwnLine
|
||||||
|
RequiresExpressionIndentation: OuterScope
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: LexicographicNumeric
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: true
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterIfMacros: true
|
||||||
|
AfterOverloadedOperator: false
|
||||||
|
AfterRequiresInClause: false
|
||||||
|
AfterRequiresInExpression: false
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: -1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- CF_SWIFT_NAME
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- STRINGIZE
|
||||||
|
...
|
||||||
|
|
100
.github/workflows/Docs.yml
vendored
@ -1,50 +1,50 @@
|
|||||||
name: 📄
|
name: 📄
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "!*" ]
|
branches: [ "!*" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "*" ]
|
branches: [ "*" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# This workflow contains a single job called "build"
|
# This workflow contains a single job called "build"
|
||||||
build:
|
build:
|
||||||
# The type of runner that the job will run on
|
# The type of runner that the job will run on
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Extract branch name
|
- name: Extract branch name
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
||||||
id: branch
|
id: branch
|
||||||
- name: Display branch name
|
- name: Display branch name
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo ${{ steps.branch.outputs.branch }}
|
run: echo ${{ steps.branch.outputs.branch }}
|
||||||
# Runs a single command using the runners shell
|
# Runs a single command using the runners shell
|
||||||
- name: Run a one-line script
|
- name: Run a one-line script
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "tobid7@outlook.de"
|
git config --global user.email "tobid7@outlook.de"
|
||||||
git config --global user.name "Tobi-D7"
|
git config --global user.name "Tobi-D7"
|
||||||
sudo apt-get install doxygen cmake -y
|
sudo apt-get install doxygen cmake -y
|
||||||
doxygen
|
doxygen
|
||||||
echo done
|
echo done
|
||||||
ls -r
|
ls -r
|
||||||
cd ..
|
cd ..
|
||||||
git clone --depth 1 https://${{ secrets.TOKEN }}@github.com/NPI-D7/RenderD7.git RD7 -b gh-pages
|
git clone --depth 1 https://${{ secrets.TOKEN }}@github.com/NPI-D7/RenderD7.git RD7 -b gh-pages
|
||||||
|
|
||||||
mv -v RenderD7/doc/html/* RD7/
|
mv -v RenderD7/doc/html/* RD7/
|
||||||
#rm -r doc
|
#rm -r doc
|
||||||
cd RD7
|
cd RD7
|
||||||
|
|
||||||
echo tobid7
|
echo tobid7
|
||||||
git stage *
|
git stage *
|
||||||
|
|
||||||
echo staged
|
echo staged
|
||||||
git commit -m "Documentation1"
|
git commit -m "Documentation1"
|
||||||
git tag doc
|
git tag doc
|
||||||
echo commited
|
echo commited
|
||||||
git push origin gh-pages
|
git push origin gh-pages
|
||||||
echo pushed
|
echo pushed
|
||||||
|
100
.github/workflows/Update extlibs.yml
vendored
@ -1,50 +1,50 @@
|
|||||||
name: Extlibs
|
name: Extlibs
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ '!*' ]
|
branches: [ '!*' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ '!*' ]
|
branches: [ '!*' ]
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
jobs:
|
jobs:
|
||||||
# This workflow contains a single job called "build"
|
# This workflow contains a single job called "build"
|
||||||
build:
|
build:
|
||||||
# The type of runner that the job will run on
|
# The type of runner that the job will run on
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: update
|
- name: update
|
||||||
run: |
|
run: |
|
||||||
#gl
|
#gl
|
||||||
cd ..
|
cd ..
|
||||||
git clone https://github.com/lua/lua.git
|
git clone https://github.com/lua/lua.git
|
||||||
cd RenderD7
|
cd RenderD7
|
||||||
mkdir -p extlibs/
|
mkdir -p extlibs/
|
||||||
mkdir -p extlibs/lua/
|
mkdir -p extlibs/lua/
|
||||||
cp -r ../lua/*.c extlibs/lua/
|
cp -r ../lua/*.c extlibs/lua/
|
||||||
cp -r ../lua/*.h extlibs/lua/
|
cp -r ../lua/*.h extlibs/lua/
|
||||||
cp -r ../lua/*.md extlibs/lua/
|
cp -r ../lua/*.md extlibs/lua/
|
||||||
#RenderD7
|
#RenderD7
|
||||||
cd ..
|
cd ..
|
||||||
git clone https://github.com/NPI-D7/RenderD7.git
|
git clone https://github.com/NPI-D7/RenderD7.git
|
||||||
cd lp-next-ctr
|
cd lp-next-ctr
|
||||||
mkdir -p extlibs/
|
mkdir -p extlibs/
|
||||||
rm -r extlibs/RenderD7
|
rm -r extlibs/RenderD7
|
||||||
mkdir -p extlibs/RenderD7/
|
mkdir -p extlibs/RenderD7/
|
||||||
cp -r ../RenderD7/*.c* extlibs/RenderD7/
|
cp -r ../RenderD7/*.c* extlibs/RenderD7/
|
||||||
cp -r ../RenderD7/*.h* extlibs/RenderD7/
|
cp -r ../RenderD7/*.h* extlibs/RenderD7/
|
||||||
cp -r ../RenderD7/*.md extlibs/RenderD7/
|
cp -r ../RenderD7/*.md extlibs/RenderD7/
|
||||||
#config
|
#config
|
||||||
git config --global user.email "tobid7@outlook.de"
|
git config --global user.email "tobid7@outlook.de"
|
||||||
git config --global user.name "Tobi-D7"
|
git config --global user.name "Tobi-D7"
|
||||||
#commit
|
#commit
|
||||||
git stage *
|
git stage *
|
||||||
git commit -m "update extlibs"
|
git commit -m "update extlibs"
|
||||||
git push origin main
|
git push origin main
|
||||||
|
10
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
release/
|
release/
|
||||||
debug/
|
debug/
|
||||||
lib/
|
lib/
|
||||||
*.bz2
|
*.bz2
|
||||||
|
rd7le/
|
||||||
|
*.DS_Store*
|
18
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "3DS | Windows",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"C:/devkitpro/libctru/include/**",
|
||||||
|
"C:/devkitpro/devkitARM/include/**",
|
||||||
|
"C:/devkitpro/devkitARM/arm-none-eabi/include/**",
|
||||||
|
"C:/devkitpro/portlibs/3ds/include/**",
|
||||||
|
"/opt/devkitpro/libctru/include/**",
|
||||||
|
"/opt/devkitpro/portlibs/**"
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
115
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "(gdb) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7tf/rd7tf.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||||
|
"miDebuggerServerAddress": "192.168.2.220:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7tf/rd7tf.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb-emu) Launch",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7tf/rd7tf.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/opt/devkitPro/devkitARM/bin/arm-none-eabi-gdb",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7tf/rd7tf.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb-emu) lua",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7le/rd7le.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7le/rd7le.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb) lua",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/rd7le/rd7le.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "192.168.2.220:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/rd7le/rd7le.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "(gdb) testgame",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/testgame/testgame.elf",
|
||||||
|
"targetArchitecture": "arm",
|
||||||
|
"serverLaunchTimeout": 10000,
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "C:\\devkitPro\\devkitARM\\bin\\arm-none-eabi-gdb.exe",
|
||||||
|
"miDebuggerServerAddress": "localhost:4003",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing",
|
||||||
|
"text": "file ${workspaceFolder}/testgame/testgame.elf -enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
181
.vscode/settings.json
vendored
@ -1,65 +1,118 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"array": "cpp",
|
"array": "cpp",
|
||||||
"*.tcc": "cpp",
|
"*.tcc": "cpp",
|
||||||
"cctype": "cpp",
|
"cctype": "cpp",
|
||||||
"clocale": "cpp",
|
"clocale": "cpp",
|
||||||
"cmath": "cpp",
|
"cmath": "cpp",
|
||||||
"cstdarg": "cpp",
|
"cstdarg": "cpp",
|
||||||
"cstddef": "cpp",
|
"cstddef": "cpp",
|
||||||
"cstdint": "cpp",
|
"cstdint": "cpp",
|
||||||
"cstdio": "cpp",
|
"cstdio": "cpp",
|
||||||
"cstdlib": "cpp",
|
"cstdlib": "cpp",
|
||||||
"cwchar": "cpp",
|
"cwchar": "cpp",
|
||||||
"cwctype": "cpp",
|
"cwctype": "cpp",
|
||||||
"unordered_map": "cpp",
|
"unordered_map": "cpp",
|
||||||
"vector": "cpp",
|
"vector": "cpp",
|
||||||
"exception": "cpp",
|
"exception": "cpp",
|
||||||
"algorithm": "cpp",
|
"algorithm": "cpp",
|
||||||
"functional": "cpp",
|
"functional": "cpp",
|
||||||
"iterator": "cpp",
|
"iterator": "cpp",
|
||||||
"memory": "cpp",
|
"memory": "cpp",
|
||||||
"numeric": "cpp",
|
"numeric": "cpp",
|
||||||
"type_traits": "cpp",
|
"type_traits": "cpp",
|
||||||
"fstream": "cpp",
|
"fstream": "cpp",
|
||||||
"initializer_list": "cpp",
|
"initializer_list": "cpp",
|
||||||
"iosfwd": "cpp",
|
"iosfwd": "cpp",
|
||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
"istream": "cpp",
|
"istream": "cpp",
|
||||||
"limits": "cpp",
|
"limits": "cpp",
|
||||||
"new": "cpp",
|
"new": "cpp",
|
||||||
"optional": "cpp",
|
"optional": "cpp",
|
||||||
"ostream": "cpp",
|
"ostream": "cpp",
|
||||||
"sstream": "cpp",
|
"sstream": "cpp",
|
||||||
"stdexcept": "cpp",
|
"stdexcept": "cpp",
|
||||||
"streambuf": "cpp",
|
"streambuf": "cpp",
|
||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"string_view": "cpp",
|
"string_view": "cpp",
|
||||||
"system_error": "cpp",
|
"system_error": "cpp",
|
||||||
"tuple": "cpp",
|
"tuple": "cpp",
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"utility": "cpp",
|
"utility": "cpp",
|
||||||
"atomic": "cpp",
|
"atomic": "cpp",
|
||||||
"bit": "cpp",
|
"bit": "cpp",
|
||||||
"bitset": "cpp",
|
"bitset": "cpp",
|
||||||
"chrono": "cpp",
|
"chrono": "cpp",
|
||||||
"codecvt": "cpp",
|
"codecvt": "cpp",
|
||||||
"condition_variable": "cpp",
|
"condition_variable": "cpp",
|
||||||
"cstring": "cpp",
|
"cstring": "cpp",
|
||||||
"ctime": "cpp",
|
"ctime": "cpp",
|
||||||
"deque": "cpp",
|
"deque": "cpp",
|
||||||
"forward_list": "cpp",
|
"forward_list": "cpp",
|
||||||
"map": "cpp",
|
"map": "cpp",
|
||||||
"iomanip": "cpp",
|
"iomanip": "cpp",
|
||||||
"memory_resource": "cpp",
|
"memory_resource": "cpp",
|
||||||
"ratio": "cpp",
|
"ratio": "cpp",
|
||||||
"regex": "cpp",
|
"regex": "cpp",
|
||||||
"shared_mutex": "cpp",
|
"shared_mutex": "cpp",
|
||||||
"valarray": "cpp",
|
"valarray": "cpp",
|
||||||
"random": "cpp",
|
"random": "cpp",
|
||||||
"cuchar": "cpp",
|
"cuchar": "cpp",
|
||||||
"compare": "cpp",
|
"compare": "cpp",
|
||||||
"concepts": "cpp",
|
"concepts": "cpp",
|
||||||
"numbers": "cpp"
|
"numbers": "cpp",
|
||||||
}
|
"filesystem": "cpp",
|
||||||
|
"xstring": "cpp",
|
||||||
|
"charconv": "cpp",
|
||||||
|
"format": "cpp",
|
||||||
|
"ios": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"locale": "cpp",
|
||||||
|
"mutex": "cpp",
|
||||||
|
"stack": "cpp",
|
||||||
|
"stop_token": "cpp",
|
||||||
|
"thread": "cpp",
|
||||||
|
"xfacet": "cpp",
|
||||||
|
"xhash": "cpp",
|
||||||
|
"xiosbase": "cpp",
|
||||||
|
"xlocale": "cpp",
|
||||||
|
"xlocbuf": "cpp",
|
||||||
|
"xlocinfo": "cpp",
|
||||||
|
"xlocmes": "cpp",
|
||||||
|
"xlocmon": "cpp",
|
||||||
|
"xlocnum": "cpp",
|
||||||
|
"xloctime": "cpp",
|
||||||
|
"xmemory": "cpp",
|
||||||
|
"xstddef": "cpp",
|
||||||
|
"xtr1common": "cpp",
|
||||||
|
"xtree": "cpp",
|
||||||
|
"xutility": "cpp",
|
||||||
|
"queue": "cpp",
|
||||||
|
"semaphore": "cpp",
|
||||||
|
"hash_map": "cpp",
|
||||||
|
"set": "cpp",
|
||||||
|
"unordered_set": "cpp",
|
||||||
|
"source_location": "cpp",
|
||||||
|
"future": "cpp",
|
||||||
|
"cfenv": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeindex": "cpp",
|
||||||
|
"variant": "cpp",
|
||||||
|
"ranges": "cpp",
|
||||||
|
"span": "cpp",
|
||||||
|
"coroutine": "cpp",
|
||||||
|
"__bit_reference": "cpp",
|
||||||
|
"__config": "cpp",
|
||||||
|
"__debug": "cpp",
|
||||||
|
"__errc": "cpp",
|
||||||
|
"__hash_table": "cpp",
|
||||||
|
"__locale": "cpp",
|
||||||
|
"__mutex_base": "cpp",
|
||||||
|
"__node_handle": "cpp",
|
||||||
|
"__split_buffer": "cpp",
|
||||||
|
"__threading_support": "cpp",
|
||||||
|
"__tree": "cpp",
|
||||||
|
"__verbose_abort": "cpp",
|
||||||
|
"complex": "cpp"
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +0,0 @@
|
|||||||
export DEVKITARM=/opt/devkitpro/devkitARM/
|
|
||||||
export DEVKITPRO=/opt/devkitpro/
|
|
||||||
make -j12
|
|
||||||
make install
|
|
98
CHANGELOG.md
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
# RenderD7 Changelog
|
||||||
|
## 0.9.5
|
||||||
|
- Remove Npi Intro and NVID Api
|
||||||
|
- Replace Toasts System with Message
|
||||||
|
- Lots of Optimisations
|
||||||
|
- Added GetTime
|
||||||
|
- Implement Draw2 Api
|
||||||
|
- Implement RD7Color and R7Vec2
|
||||||
|
- Add new Features to Color::RGBA
|
||||||
|
- Cleanup Code
|
||||||
|
- Added RenderD7 Keyboard (Overlay)
|
||||||
|
- Added Ftrace Overlay
|
||||||
|
- Moved MetrikOVL into an Overlay
|
||||||
|
- Removed Old Font/Text Handlers
|
||||||
|
- Added UI7 (New UI Api)
|
||||||
|
- Remove Old UI Api
|
||||||
|
- Added Music Player (MP3, Vorbis)
|
||||||
|
- Rewrite of RenderD7::Image
|
||||||
|
- Internal Debugger/Database (IDB)
|
||||||
|
- Removed BitmapPrinter
|
||||||
|
- Added nimg and nimg_engine
|
||||||
|
- Removed Old Error/Message Handler
|
||||||
|
- GetTextSize (extra buffer) + New TextShorter
|
||||||
|
## 0.9.4
|
||||||
|
- Implement new Security System To prevent from crashes
|
||||||
|
- Implement Functiontrace for better Timing Tests
|
||||||
|
- Implement MemAlloc Tracker (only size)
|
||||||
|
- Add some new Overlays (not functional yet)
|
||||||
|
- Complete Rewrite of Overlay System
|
||||||
|
- Fixed the FrameEnd Crash
|
||||||
|
- New System to get Hardware Info
|
||||||
|
- Removed RenderD7 Super Reselution (800px mode)
|
||||||
|
## 0.9.3
|
||||||
|
- Completly Documented Everything
|
||||||
|
- Fix typo in Sprite::getHeight
|
||||||
|
- Remove Deprecated/Useless Stuff
|
||||||
|
## 0.9.2
|
||||||
|
- Add Nvid Support(v0.0.1)
|
||||||
|
- Add Basic RenderD7 Splash
|
||||||
|
- Faster Graphics Init
|
||||||
|
- Fade Effects
|
||||||
|
- Fix Changelog Screen
|
||||||
|
## 0.9.1
|
||||||
|
- Fix Critical bug in Spritesheet animations
|
||||||
|
- Fix RenderD7::Color::Hex (Major performance tweak)
|
||||||
|
## 0.9.0
|
||||||
|
- Remove Stupid try of Console
|
||||||
|
- Add Services list
|
||||||
|
- Clean up Code
|
||||||
|
- Added Minimal Init for hax2.x
|
||||||
|
## 0.8.5
|
||||||
|
- Fix Deltatime
|
||||||
|
## 0.8.4
|
||||||
|
- A lot of Fixes
|
||||||
|
- New Features for BitmapPrinter
|
||||||
|
## 0.8.3
|
||||||
|
- Added Overlaycount to Info
|
||||||
|
- Addet ResultDecoder for errors
|
||||||
|
## 0.8.2
|
||||||
|
- Fix a lot of Stuff
|
||||||
|
- Use c++17 std::filesystem for RenderD7::Filesystem
|
||||||
|
## 0.8.1
|
||||||
|
- Add abillity to Get Stdout as string to render it to the screen.
|
||||||
|
## 0.8.0
|
||||||
|
- Implement BitmapPrinter
|
||||||
|
## 0.7.3
|
||||||
|
- Implement Over Render Overlay Framework
|
||||||
|
## 0.7.2
|
||||||
|
- Implement MT to csv file saving
|
||||||
|
- Add RGB2HEX
|
||||||
|
## 0.7.1
|
||||||
|
- Add the New Overlay Handler. Its Just in code and does nothing yet
|
||||||
|
## 0.7.0
|
||||||
|
- Made Big Progress In the MT Ovl but it still crashes On a 2nd C3D_FrameEnd \
|
||||||
|
- Implement 800px but doesn't work that good
|
||||||
|
## 0.6.2
|
||||||
|
- Fix Crash when exiting through Home Menu.
|
||||||
|
## 0.6.10
|
||||||
|
- Rewrite Threadsystem
|
||||||
|
- Improve framerate
|
||||||
|
## 0.6.02
|
||||||
|
- Fix Code in lang.hpp
|
||||||
|
- Add Draw Text Left Function (Right since 0.7.0)
|
||||||
|
- Add changelog
|
||||||
|
## 0.6.01
|
||||||
|
- Add Threading system
|
||||||
|
## 0.6.0
|
||||||
|
- Better Scene Management
|
||||||
|
## 0.5.0
|
||||||
|
- Fixed some Bugs!
|
||||||
|
## 0.4.0
|
||||||
|
- Trying to fix Filesystem and Bugs
|
||||||
|
## 0.3.0
|
||||||
|
- Recreate D7-Core into RenderD7
|
||||||
|
## 0.2.0
|
||||||
|
- Trying to create Animations of Images instead of Sheets
|
||||||
|
## 0.1.0
|
||||||
|
- Inital Release of D7-Core sprite animation plugin
|
404
Makefile
@ -1,205 +1,201 @@
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
ifeq ($(strip $(DEVKITARM)),)
|
ifeq ($(strip $(DEVKITARM)),)
|
||||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(DEVKITARM)/3ds_rules
|
include $(DEVKITARM)/3ds_rules
|
||||||
|
|
||||||
export renderd7_MAJOR := 0
|
export renderd7_MAJOR := 0
|
||||||
export renderd7_MINOR := 8
|
export renderd7_MINOR := 9
|
||||||
export renderd7_PATCH := 0
|
export renderd7_PATCH := 4
|
||||||
|
|
||||||
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
|
VERSION := $(renderd7_MAJOR).$(renderd7_MINOR).$(renderd7_PATCH)
|
||||||
|
|
||||||
# If on a tagged commit, use the tag instead of the commit
|
# If on a tagged commit, use the tag instead of the commit
|
||||||
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
|
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
|
||||||
GIT_VER := $(shell git tag -l --points-at HEAD)
|
GIT_VER := $(shell git tag -l --points-at HEAD)
|
||||||
else
|
else
|
||||||
GIT_VER := $(shell git rev-parse --short HEAD)
|
GIT_VER := $(shell git rev-parse --short HEAD)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TIME_TIME := $(shell date --iso=seconds)
|
TIME_TIME := $(shell date --iso=seconds)
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# TARGET is the name of the output
|
# TARGET is the name of the output
|
||||||
# BUILD is the directory where object files & intermediate files will be placed
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
# SOURCES is a list of directories containing source code
|
# SOURCES is a list of directories containing source code
|
||||||
# DATA is a list of directories containing data files
|
# DATA is a list of directories containing data files
|
||||||
# INCLUDES is a list of directories containing header files
|
# INCLUDES is a list of directories containing header files
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
TARGET := renderd7
|
TARGET := renderd7
|
||||||
SOURCES := source external/source external/libnsbmp/source
|
SOURCES := source source/external source/music
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include
|
INCLUDES := include
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||||
|
|
||||||
CFLAGS := -g -Wall -Werror -mword-relocations -save-temps\
|
CFLAGS := -g -Wall -mword-relocations -save-temps\
|
||||||
-DV_STRING=\"$(GIT_VER)\" \
|
-DV_RD7CSTRING=\"$(GIT_VER)\" \
|
||||||
-DV_TIME=\"$(TIME_TIME)\" \
|
-DV_RD7BTIME=\"$(TIME_TIME)\" \
|
||||||
-ffunction-sections -fdata-sections \
|
-ffunction-sections -fdata-sections \
|
||||||
$(ARCH) $(BUILD_CFLAGS)
|
$(ARCH) $(BUILD_CFLAGS)
|
||||||
|
|
||||||
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
||||||
|
|
||||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
||||||
|
|
||||||
ASFLAGS := -g $(ARCH) $(DEFINES)
|
ASFLAGS := -g $(ARCH) $(DEFINES)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
# include and lib
|
# include and lib
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
# rules for different file extensions
|
# rules for different file extensions
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
||||||
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# use CXX for linking C++ projects, CC for standard C
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
ifeq ($(strip $(CPPFILES)),)
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
export LD := $(CC)
|
export LD := $(CC)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
else
|
else
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
export LD := $(CXX)
|
export LD := $(CXX)
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
endif
|
endif
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
|
||||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
||||||
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
|
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
|
||||||
|
|
||||||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
||||||
|
|
||||||
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
-I.
|
-I.
|
||||||
|
|
||||||
.PHONY: clean all doc
|
.PHONY: clean all doc
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
all: lib/librenderd7.a lib/librenderd7d.a
|
all: lib/librenderd7.a lib/librenderd7d.a
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
@doxygen Doxyfile
|
@doxygen Doxyfile
|
||||||
|
|
||||||
dist-bin: all
|
dist-bin: all
|
||||||
@tar --exclude=*~ -cjf $(TARGET)-$(VERSION).tar.bz2 include lib
|
@tar --exclude=*~ -cjf $(TARGET).tar.bz2 include lib
|
||||||
|
|
||||||
dist-src:
|
dist-src:
|
||||||
@tar --exclude=*~ -cjf $(TARGET)-src-$(VERSION).tar.bz2 include $(SOURCES) Makefile
|
@tar --exclude=*~ -cjf $(TARGET)-src.tar.bz2 include $(SOURCES) Makefile
|
||||||
|
|
||||||
dist: dist-src dist-bin
|
dist: dist-src dist-bin
|
||||||
|
|
||||||
install: dist-bin
|
lib:
|
||||||
mkdir -p $(DEPSDIR)$(DEVKITPRO)/libctru
|
@[ -d $@ ] || mkdir -p $@
|
||||||
bzip2 -cd $(TARGET)-$(VERSION).tar.bz2 | tar -xf - -C $(DEPSDIR)$(DEVKITPRO)/libctru
|
|
||||||
|
release:
|
||||||
lib:
|
@[ -d $@ ] || mkdir -p $@
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
debug:
|
||||||
release:
|
@[ -d $@ ] || mkdir -p $@
|
||||||
@[ -d $@ ] || mkdir -p $@
|
|
||||||
|
|
||||||
debug:
|
lib/librenderd7.a : lib release $(SOURCES) $(INCLUDES)
|
||||||
@[ -d $@ ] || mkdir -p $@
|
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
||||||
|
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
|
||||||
|
DEPSDIR=$(CURDIR)/release \
|
||||||
lib/librenderd7.a : lib release $(SOURCES) $(INCLUDES)
|
--no-print-directory -C release \
|
||||||
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
-f $(CURDIR)/Makefile
|
||||||
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
|
|
||||||
DEPSDIR=$(CURDIR)/release \
|
lib/librenderd7d.a : lib debug $(SOURCES) $(INCLUDES)
|
||||||
--no-print-directory -C release \
|
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
|
||||||
-f $(CURDIR)/Makefile
|
BUILD_CFLAGS="-DDEBUG=1 -Og" \
|
||||||
|
DEPSDIR=$(CURDIR)/debug \
|
||||||
lib/librenderd7d.a : lib debug $(SOURCES) $(INCLUDES)
|
--no-print-directory -C debug \
|
||||||
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
|
-f $(CURDIR)/Makefile
|
||||||
BUILD_CFLAGS="-DDEBUG=1 -Og" \
|
|
||||||
DEPSDIR=$(CURDIR)/debug \
|
#---------------------------------------------------------------------------------
|
||||||
--no-print-directory -C debug \
|
clean:
|
||||||
-f $(CURDIR)/Makefile
|
@echo clean ...
|
||||||
|
@rm -fr release debug lib includes
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
clean:
|
#---------------------------------------------------------------------------------
|
||||||
@echo clean ...
|
else
|
||||||
@rm -fr release debug lib includes
|
|
||||||
|
DEPENDS := $(OFILES:.o=.d)
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
else
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
DEPENDS := $(OFILES:.o=.d)
|
#---------------------------------------------------------------------------------
|
||||||
|
$(OUTPUT) : $(OFILES)
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
# main targets
|
$(OFILES_SOURCES) : $(HFILES)
|
||||||
#---------------------------------------------------------------------------------
|
|
||||||
$(OUTPUT) : $(OFILES)
|
#---------------------------------------------------------------------------------
|
||||||
|
# you need a rule like this for each extension you use as binary data
|
||||||
$(OFILES_SOURCES) : $(HFILES)
|
#---------------------------------------------------------------------------------
|
||||||
|
%.bin.o %_bin.h : %.bin
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# you need a rule like this for each extension you use as binary data
|
@echo $(notdir $<)
|
||||||
#---------------------------------------------------------------------------------
|
@$(bin2o)
|
||||||
%.bin.o %_bin.h : %.bin
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
@echo $(notdir $<)
|
# rules for assembling GPU shaders
|
||||||
@$(bin2o)
|
#---------------------------------------------------------------------------------
|
||||||
|
define shader-as
|
||||||
#---------------------------------------------------------------------------------
|
$(eval CURBIN := $*.shbin)
|
||||||
# rules for assembling GPU shaders
|
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
|
||||||
#---------------------------------------------------------------------------------
|
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
|
||||||
define shader-as
|
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
||||||
$(eval CURBIN := $*.shbin)
|
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
||||||
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
|
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
||||||
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
|
picasso -o $(CURBIN) $1
|
||||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
|
||||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
endef
|
||||||
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
|
||||||
picasso -o $(CURBIN) $1
|
%.shbin.o %_shbin.h : %.v.pica %.g.pica
|
||||||
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
|
@echo $(notdir $^)
|
||||||
endef
|
@$(call shader-as,$^)
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.v.pica %.g.pica
|
%.shbin.o %_shbin.h : %.v.pica
|
||||||
@echo $(notdir $^)
|
@echo $(notdir $<)
|
||||||
@$(call shader-as,$^)
|
@$(call shader-as,$<)
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.v.pica
|
%.shbin.o %_shbin.h : %.shlist
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
@$(call shader-as,$<)
|
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
|
||||||
|
|
||||||
%.shbin.o %_shbin.h : %.shlist
|
-include $(DEPENDS)
|
||||||
@echo $(notdir $<)
|
|
||||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
|
#---------------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
-include $(DEPENDS)
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------
|
|
||||||
endif
|
|
||||||
#---------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------
|
74
README.md
@ -1,16 +1,58 @@
|
|||||||
# RenderD7 <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/blob/main/logo.png" height="30">
|
# <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/raw/main/logo.png" height="90">
|
||||||
RenderD7 is now LibRenderD7.
|
RenderD7 is now LibRenderD7.
|
||||||
### Installation (Ubuntu)
|
### Installation
|
||||||
first run this
|
Download a Package From Releses Page
|
||||||
`sudo su`
|
`https://github.com/NPI-D7/RenderD7/releases/download/v0.9.4/renderd7.tar.bz2 -o renderd7.tar.bz2`
|
||||||
then this
|
Then Extract it to your Libraries Path
|
||||||
```
|
`bzip2 -cd renderd7.tar.bz2 | tar -xf - -C path_to_your_libs`
|
||||||
curl -L https://github.com/NPI-D7/RenderD7/releases/download/v0.8.0-pre1/renderd7-0.8.0.tar.bz2 -o renderd7-0.8.0.tar.bz2
|
Finally put `-lrenderd7` to the First Place and add the path_to_your_libs
|
||||||
mkdir -p /opt/devkitpro/libctru
|
```
|
||||||
bzip2 -cd renderd7-0.8.0.tar.bz2 | tar -xf - -C /opt/devkitpro/libctru
|
LIBS := -lrenderd7 -lcurl -lstdc++ -lm -lcitro2d -lcitro3d -lctru
|
||||||
```
|
#---------------------------------------------------------------------------------
|
||||||
Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
# include and lib
|
||||||
# RenderD7 (https://npi-d7.github.io/RenderD7/)
|
#---------------------------------------------------------------------------------
|
||||||
Simple and Easey to use UI and Graphics helper.
|
LIBDIRS := $(PORTLIBS) $(CTRULIB) ../path_to_your_libs
|
||||||
Create DOCS
|
```
|
||||||
|
Make sure that `-lrenderd7` is before `-lcitro2d`, `-lcitro3d`, `-lctru`.
|
||||||
|
Here an example tree
|
||||||
|
```
|
||||||
|
Example-App
|
||||||
|
├── gfx
|
||||||
|
├── libs
|
||||||
|
│ ├── include
|
||||||
|
│ │ ├── rd7.hpp
|
||||||
|
│ │ └── renderd7
|
||||||
|
│ └── lib
|
||||||
|
│ ├── librenderd7.a
|
||||||
|
│ └── librenderd7d.a
|
||||||
|
├── Makefile
|
||||||
|
├── romfs
|
||||||
|
│ └── gfx
|
||||||
|
└── src
|
||||||
|
└── main.cpp
|
||||||
|
```
|
||||||
|
# Back to Old Usage aka Submodule (0.9.5+)
|
||||||
|
If you want to use RenderD7 as Submodule run
|
||||||
|
`git submodule add https://github.com/NPI-D7/RenderD7`
|
||||||
|
|
||||||
|
And to Use Add this to make file
|
||||||
|
```
|
||||||
|
# Make Sure to Change this paths if your Submodule
|
||||||
|
# is located somewhere else
|
||||||
|
RENDERD7_SRC := RenderD7/source RenderD7/external
|
||||||
|
RENDERD7_INC := RenderD7/include
|
||||||
|
```
|
||||||
|
Now you need to add it to your sources and includes
|
||||||
|
```
|
||||||
|
SOURCES := source $(RENDERD7_SRC)
|
||||||
|
INCLUDES := source $(RENDERD7_INC)
|
||||||
|
```
|
||||||
|
Example from rd7tf
|
||||||
|
# Credits
|
||||||
|
- NPI-D7
|
||||||
|
- Tobi-D7 Main Dev
|
||||||
|
|
||||||
|
Some Icons are From
|
||||||
|
https://icons8.de/
|
||||||
|
See Subfolder Readmes
|
||||||
|
31
assets/build_assets.sh
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Create Directorys"
|
||||||
|
mkdir -p build
|
||||||
|
mkdir -p code
|
||||||
|
|
||||||
|
echo "Generating Spritesheets"
|
||||||
|
cd resources
|
||||||
|
|
||||||
|
for file in *.t3s
|
||||||
|
do
|
||||||
|
filename=$(basename "$file" .t3s).t3x
|
||||||
|
tex3ds -o "../build/$filename" -i "${file}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Converting Spritesheets into C++ Code"
|
||||||
|
cd ../code
|
||||||
|
|
||||||
|
for file in ../build/*.t3x
|
||||||
|
do
|
||||||
|
name="${file##*/}"
|
||||||
|
name="${name%.*}"
|
||||||
|
../../tools/bin/file2array "${file}" "${name}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Fix The Output of file2array"
|
||||||
|
for file in ./*.cpp
|
||||||
|
do
|
||||||
|
../../tools/bin/rd7f2afix "${file}" "renderd7"
|
||||||
|
done
|
||||||
|
echo "Finished!"
|
7
assets/clear_assets.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Deleting Directorys"
|
||||||
|
rm -rf build
|
||||||
|
rm -rf code
|
||||||
|
|
||||||
|
echo "Finished!"
|
3
assets/resources/renderd7_logo.t3s
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
--atlas -f rgba -z auto
|
||||||
|
|
||||||
|
renderd7_logo/renderd7_logo.png
|
BIN
assets/resources/renderd7_logo/renderd7_logo.png
Normal file
After Width: | Height: | Size: 17 KiB |
8
cformat.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
find . -type f \( -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.ino' -o -name '*.cpp' -o -name '*.c' -o -name '*.cxx' -o -name '*.inl' \) -and -not -path './build/*' -not -path './base/external/*' -not -path './DPP/*' | while read file; do
|
||||||
|
if [[ "$file" != *"json.hpp" ]]; then
|
||||||
|
echo "Formatting $file..."
|
||||||
|
clang-format -i --style=LLVM $file
|
||||||
|
fi
|
||||||
|
done
|
23
envsetup.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#Build Tools
|
||||||
|
echo "Build Tools..."
|
||||||
|
cd tools
|
||||||
|
./build_tools.sh
|
||||||
|
cd ..
|
||||||
|
#Setup asset-arrays
|
||||||
|
echo "Generate Asset-Arrays..."
|
||||||
|
cd assets
|
||||||
|
./build_assets.sh
|
||||||
|
echo "Update Files in RenderD7..."
|
||||||
|
cp -rf code/*.cpp ../source/
|
||||||
|
cp -rf code/*.hpp ../include/renderd7/
|
||||||
|
echo "Clean Assets..."
|
||||||
|
./clear_assets.sh
|
||||||
|
cd ..
|
||||||
|
#Clear Tools
|
||||||
|
echo "Clean Tools..."
|
||||||
|
cd tools
|
||||||
|
./clear_tools.sh
|
||||||
|
cd ..
|
||||||
|
#Finished
|
||||||
|
echo "Done!"
|
20
external/libnsbmp/COPYING
vendored
@ -1,20 +0,0 @@
|
|||||||
Copyright (C) 2006 Richard Wilson
|
|
||||||
Copyright (C) 2008 Sean Fox
|
|
||||||
|
|
||||||
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.
|
|
1388
external/libnsbmp/source/libnsbmp.c
vendored
386
external/source/fs.c
vendored
@ -1,386 +0,0 @@
|
|||||||
#include <renderd7/external/fs.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/statvfs.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define WORKING_DIR "/"
|
|
||||||
|
|
||||||
void Utils_U8_To_U16(u16 *buf, const u8 *input, size_t bufsize) {
|
|
||||||
ssize_t units = utf8_to_utf16(buf, input, bufsize);
|
|
||||||
|
|
||||||
if (units < 0)
|
|
||||||
units = 0;
|
|
||||||
|
|
||||||
buf[units] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_Archive archive, sdmc_archive, nand_archive;
|
|
||||||
|
|
||||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenArchive(archive, archiveID, fsMakePath(PATH_EMPTY, ""))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_CloseArchive(FS_Archive archive) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CloseArchive(archive)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_OpenDir(Handle *handle, FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenDirectory(handle, archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_OpenFile(Handle *handle, FS_Archive archive, const char *path, u32 flags, u32 attributes) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(handle, archive, fsMakePath(PATH_UTF16, path_u16), flags, attributes)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_MakeDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateDirectory(archive, fsMakePath(PATH_UTF16, path_u16), 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_CreateFile(FS_Archive archive, const char *path, u64 size) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateFile(archive, fsMakePath(PATH_UTF16, path_u16), 0, size)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RecursiveMakeDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
char buf[256];
|
|
||||||
char *p = NULL;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s", path);
|
|
||||||
len = strlen(buf);
|
|
||||||
|
|
||||||
if (buf[len - 1] == '/')
|
|
||||||
buf[len - 1] = 0;
|
|
||||||
|
|
||||||
for (p = buf + 1; *p; p++) {
|
|
||||||
if (*p == '/') {
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
if (!FS_DirExists(archive, buf))
|
|
||||||
ret = FS_MakeDir(archive, buf);
|
|
||||||
|
|
||||||
*p = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FS_DirExists(archive, buf))
|
|
||||||
ret = FS_MakeDir(archive, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FS_FileExists(FS_Archive archive, const char *path) {
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (R_FAILED(FSFILE_Close(handle)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FS_DirExists(FS_Archive archive, const char *path) {
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (R_FAILED(FSDIR_Close(handle)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_GetFileSize(FS_Archive archive, const char *path, u64 *size) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_GetSize(handle, size))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetFreeStorage(FS_SystemMediaType media_type) {
|
|
||||||
FS_ArchiveResource resource = {0};
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, media_type)))
|
|
||||||
return (((u64)resource.freeClusters * (u64)resource.clusterSize));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetTotalStorage(FS_SystemMediaType media_type) {
|
|
||||||
FS_ArchiveResource resource = {0};
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(FSUSER_GetArchiveResource(&resource, media_type)))
|
|
||||||
return (((u64)resource.totalClusters * (u64)resource.clusterSize));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
u64 FS_GetUsedStorage(FS_SystemMediaType media_type) {
|
|
||||||
return 0;//(FS_GetTotalStorage(media_type) - FS_GetUsedStorage(media_type));
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveFile(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteFile(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveDir(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteDirectory(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RemoveDirRecursive(FS_Archive archive, const char *path) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_DeleteDirectoryRecursively(archive, fsMakePath(PATH_UTF16, path_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RenameFile(FS_Archive archive, const char *old_filename, const char *new_filename) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 old_filename_u16[strlen(old_filename) + 1];
|
|
||||||
Utils_U8_To_U16(old_filename_u16, (const u8 *)old_filename, strlen(old_filename) + 1);
|
|
||||||
|
|
||||||
u16 new_filename_u16[strlen(new_filename) + 1];
|
|
||||||
Utils_U8_To_U16(new_filename_u16, (const u8 *)new_filename, strlen(new_filename) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_RenameFile(archive, fsMakePath(PATH_UTF16, old_filename_u16), archive, fsMakePath(PATH_UTF16, new_filename_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new_dirname) {
|
|
||||||
Result ret = 0;
|
|
||||||
|
|
||||||
u16 old_dirname_u16[strlen(old_dirname) + 1];
|
|
||||||
Utils_U8_To_U16(old_dirname_u16, (const u8 *)old_dirname, strlen(old_dirname) + 1);
|
|
||||||
|
|
||||||
u16 new_dirname_u16[strlen(new_dirname) + 1];
|
|
||||||
Utils_U8_To_U16(new_dirname_u16, (const u8 *)new_dirname, strlen(new_dirname) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_RenameDirectory(archive, fsMakePath(PATH_UTF16, old_dirname_u16), archive, fsMakePath(PATH_UTF16, new_dirname_u16))))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
|
|
||||||
u32 bytes_read = 0;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FS_OpenFile(&handle, archive, path, FS_OPEN_READ, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Read(handle, &bytes_read, 0, buf, size))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size) {
|
|
||||||
Result ret = 0;
|
|
||||||
Handle handle;
|
|
||||||
u32 bytes_written = 0;
|
|
||||||
|
|
||||||
if (FS_FileExists(archive, path))
|
|
||||||
FS_RemoveFile(archive, path);
|
|
||||||
|
|
||||||
u16 path_u16[strlen(path) + 1];
|
|
||||||
Utils_U8_To_U16(path_u16, (const u8 *)path, strlen(path) + 1);
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_CreateFile(archive, fsMakePath(PATH_UTF16, path_u16), 0, size)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_WRITE, 0)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Write(handle, &bytes_written, 0, buf, size, FS_WRITE_FLUSH))) {
|
|
||||||
FSFILE_Close(handle);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_FAILED(ret = FSFILE_Close(handle)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *FS_GetFileTimestamp(const char *path) {
|
|
||||||
static char timeStr[60];
|
|
||||||
u64 mtime = 0;
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(archive_getmtime(path, &mtime))) {
|
|
||||||
time_t mt = mtime;
|
|
||||||
struct tm *timeStruct = gmtime(&mt);
|
|
||||||
|
|
||||||
int hours = timeStruct->tm_hour;
|
|
||||||
int minutes = timeStruct->tm_min;
|
|
||||||
|
|
||||||
int day = timeStruct->tm_mday;
|
|
||||||
int month = timeStruct->tm_mon + 1; // January being 0
|
|
||||||
int year = timeStruct->tm_year + 1900;
|
|
||||||
|
|
||||||
snprintf(timeStr, 60, "%d/%d/%d %2i:%02i", year, month, day, hours, minutes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return timeStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
FS_Path getPathInfo(const char * path, FS_ArchiveID * archive) {
|
|
||||||
*archive = ARCHIVE_SDMC;
|
|
||||||
FS_Path filePath = {0};
|
|
||||||
unsigned int prefixlen = 0;
|
|
||||||
|
|
||||||
if (!strncmp(path, "sdmc:/", 6)) {
|
|
||||||
prefixlen = 5;
|
|
||||||
} else if (*path != '/') {
|
|
||||||
//if the path is local (doesnt start with a slash), it needs to be appended to the working dir to be valid
|
|
||||||
char * actualPath = NULL;
|
|
||||||
asprintf(&actualPath, "%s%s", WORKING_DIR, path);
|
|
||||||
filePath = fsMakePath(PATH_ASCII, actualPath);
|
|
||||||
free(actualPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if the filePath wasnt set above, set it
|
|
||||||
if (filePath.size == 0) {
|
|
||||||
filePath = fsMakePath(PATH_ASCII, path+prefixlen);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
Result makeDirs(const char * path) {
|
|
||||||
Result ret = 0;
|
|
||||||
FS_ArchiveID archiveID;
|
|
||||||
FS_Path filePath = getPathInfo(path, &archiveID);
|
|
||||||
FS_Archive archive;
|
|
||||||
|
|
||||||
ret = FSUSER_OpenArchive(&archive, archiveID, fsMakePath(PATH_EMPTY, ""));
|
|
||||||
|
|
||||||
for (char * slashpos = strchr(path+1, '/'); slashpos != NULL; slashpos = strchr(slashpos+1, '/')) {
|
|
||||||
char bak = *(slashpos);
|
|
||||||
*(slashpos) = '\0';
|
|
||||||
Handle dirHandle;
|
|
||||||
|
|
||||||
ret = FSUSER_OpenDirectory(&dirHandle, archive, filePath);
|
|
||||||
if (R_SUCCEEDED(ret)) FSDIR_Close(dirHandle);
|
|
||||||
else ret = FSUSER_CreateDirectory(archive, filePath, FS_ATTRIBUTE_DIRECTORY);
|
|
||||||
|
|
||||||
*(slashpos) = bak;
|
|
||||||
}
|
|
||||||
|
|
||||||
FSUSER_CloseArchive(archive);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result openFile(Handle* fileHandle, const char * path, bool write) {
|
|
||||||
FS_ArchiveID archive;
|
|
||||||
FS_Path filePath = getPathInfo(path, &archive);
|
|
||||||
u32 flags = (write ? (FS_OPEN_CREATE | FS_OPEN_WRITE) : FS_OPEN_READ);
|
|
||||||
|
|
||||||
Result ret = 0;
|
|
||||||
ret = makeDirs(strdup(path));
|
|
||||||
ret = FSUSER_OpenFileDirectly(fileHandle, archive, fsMakePath(PATH_EMPTY, ""), filePath, flags, 0);
|
|
||||||
if (write) ret = FSFILE_SetSize(*fileHandle, 0); //truncate the file to remove previous contents before writing
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
6464
external/source/lodepng.cpp
vendored
@ -1 +0,0 @@
|
|||||||
External Librarys
|
|
@ -1,4 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <renderd7/bmp.hpp>
|
#include <renderd7/StealConsole.hpp>
|
||||||
#include <renderd7/renderd7.hpp>
|
#include <renderd7/renderd7.hpp>
|
||||||
|
#include <renderd7/sound.hpp>
|
||||||
|
#include <renderd7/Message.hpp>
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <renderd7/Hid.hpp>
|
||||||
|
#include <renderd7/UI7.hpp>
|
||||||
|
#include <renderd7/FileSystem.hpp>
|
||||||
|
#include <renderd7/Image.hpp>
|
||||||
|
#include <renderd7/Timer.hpp>
|
||||||
|
#include <renderd7/music/Music.hpp>
|
||||||
|
#include <renderd7/nimg_engine.hpp>
|
||||||
|
#include <renderd7/global_db.hpp>
|
||||||
|
#include <renderd7/Error.hpp>
|
@ -1,111 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <renderd7/bmp.hpp>
|
|
||||||
#include <renderd7/bmpconverter.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Image.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Screen.hpp>
|
|
||||||
#include <renderd7/Time.hpp>
|
|
||||||
|
|
||||||
#include <renderd7/Fonts/NFontApi.hpp>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
enum Encoder {
|
|
||||||
BITMAP, ///< Encode Data to Bitmap
|
|
||||||
DIRECT, ///< Encode Direct to Framebuffer(No Decoder Required)
|
|
||||||
C3D ///< Encode Directly to C3D_Tex (Just an Idea)
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Decoder {
|
|
||||||
BITMAP2C3D, ///< Decode and Encode to C3D_Tex (Currently Fastest) (47,4ms)
|
|
||||||
BITMAP2PNG2C3D ///< Decode Bitmap end Convert to Png, then C3D (Very Slow)
|
|
||||||
///< (201,4ms)
|
|
||||||
};
|
|
||||||
|
|
||||||
class BitmapPrinter {
|
|
||||||
public:
|
|
||||||
BitmapPrinter(int w, int h);
|
|
||||||
~BitmapPrinter();
|
|
||||||
bool DecodeFile(std::string file);
|
|
||||||
|
|
||||||
void SetDecoder(Decoder deccc) { decc = deccc; }
|
|
||||||
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
|
|
||||||
void UsePreMap(BMP map);
|
|
||||||
void UsePrePrintMap(BitmapPrinter printmap);
|
|
||||||
BMP GetBitmap() { return bitmap; }
|
|
||||||
void SaveBmp(std::string name);
|
|
||||||
void SavePng(std::string name);
|
|
||||||
|
|
||||||
void CreateScreen(C3D_RenderTarget *target);
|
|
||||||
bool DrawScreenDirectF(int framerate);
|
|
||||||
bool DrawScreenDirect();
|
|
||||||
void DrawScreenF(int framerate);
|
|
||||||
void DrawScreen();
|
|
||||||
bool UpdateScreenF(int framerate);
|
|
||||||
bool UpdateScreen();
|
|
||||||
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
|
|
||||||
void ClearBlank();
|
|
||||||
RenderD7::Image GetImage();
|
|
||||||
/// Test to Find out The Best Settings for BitmapPrinter
|
|
||||||
void Benchmark();
|
|
||||||
/// Setup the Benchmark
|
|
||||||
/// \param framerate The Fps of the ScreenUpdates
|
|
||||||
void SetupBenchmark(int framerate);
|
|
||||||
bool IsBenchmarkRunning() { return this->benchmark; }
|
|
||||||
|
|
||||||
void DrawDebugText(int x, int y, int t_size, u32 color, std::string text);
|
|
||||||
void DrawText(int x, int y, float t_size, u32 color, std::string text,
|
|
||||||
RenderD7::NFontApi font);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// funcs
|
|
||||||
bool Decode(Decoder deccc);
|
|
||||||
void DrawDebugChar(u32 posX, u32 posY, int t_size, u32 color, char character);
|
|
||||||
void DrawChar(int posX, int posY, float t_size, u32 color, char character,
|
|
||||||
RenderD7::NFontApi font);
|
|
||||||
// parameter
|
|
||||||
int frame = 0;
|
|
||||||
RenderD7::Image renderframe;
|
|
||||||
bool isscreen = false;
|
|
||||||
C3D_RenderTarget *targetr;
|
|
||||||
BMP bitmap = BMP(
|
|
||||||
20, 20,
|
|
||||||
true); // Need to Set e Predefined Bitmap. If not the System will Crash.
|
|
||||||
BMP blank = BMP(
|
|
||||||
20, 20,
|
|
||||||
true); // Need to Set e Predefined Bitmap. If not the System will Crash.
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Benchmark Stuff;
|
|
||||||
int testfpsd;
|
|
||||||
bool benchmark = false;
|
|
||||||
bool setupbenchmark;
|
|
||||||
float frametime = 0;
|
|
||||||
uint64_t lastTime = 0;
|
|
||||||
float dtt = 0.f;
|
|
||||||
float dtt2 = 0.f;
|
|
||||||
float dtt3 = 0.f;
|
|
||||||
float timer = 0;
|
|
||||||
float mhdtt = 0;
|
|
||||||
float mdtt2;
|
|
||||||
float mdtt3;
|
|
||||||
|
|
||||||
float fpsClock = 0.f;
|
|
||||||
int frameCounter = 0, fps = 0;
|
|
||||||
|
|
||||||
std::vector<float> hdttt;
|
|
||||||
std::vector<float> hdttt2;
|
|
||||||
std::vector<float> hdttt3;
|
|
||||||
std::vector<int> fpscountc;
|
|
||||||
int renderedframes = 0;
|
|
||||||
int testfps = 60;
|
|
||||||
Encoder encc = Encoder::BITMAP;
|
|
||||||
Decoder decc = Decoder::BITMAP2C3D;
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
@ -1,31 +1,169 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <cstring>
|
#include <unistd.h>
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
#include <cstring>
|
||||||
#include <regex>
|
#include <functional>
|
||||||
#include <sstream>
|
#include <memory>
|
||||||
#include <string>
|
#include <regex>
|
||||||
#include <unistd.h>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#define UNPACK_RGBA(col) (uint8_t)(col >> 24), (col >> 16), (col >> 8), (col)
|
|
||||||
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
|
#define UNPACK_RGBA(col) (uint8_t)(col >> 24), (col >> 16), (col >> 8), (col)
|
||||||
|
#define UNPACK_BGRA(col) (uint8_t)(col >> 8), (col >> 16), (col >> 24), (col)
|
||||||
namespace RenderD7 {
|
// it is actually not RGBA lol
|
||||||
namespace Color {
|
inline uint32_t RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) {
|
||||||
struct rgba {
|
#define ISIMPLEPAK(x, y) (((x) & 0xff) << y)
|
||||||
uint8_t r, g, b, a;
|
return (ISIMPLEPAK(r, 0) | ISIMPLEPAK(g, 8) | ISIMPLEPAK(b, 16) |
|
||||||
};
|
ISIMPLEPAK(a, 24));
|
||||||
class RGBA {
|
}
|
||||||
public:
|
|
||||||
RGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
/*#define RGBA8(r, g, b, a) \
|
||||||
: m_r(r), m_g(g), m_b(b), m_a(a) {}
|
((((r)&0xFF) << 0) | (((g)&0xFF) << 8) | (((b)&0xFF) << 16) | \
|
||||||
uint32_t toRGBA() const {
|
(((a)&0xFF) << 24))*/
|
||||||
return (m_r << 24) | (m_g << 16) | (m_b << 8) | m_a;
|
|
||||||
}
|
typedef int RD7Color;
|
||||||
|
|
||||||
uint8_t m_r, m_g, m_b, m_a;
|
// MultiColor (Less FunctionNameLen)
|
||||||
};
|
|
||||||
std::string RGB2Hex(int r, int g, int b);
|
struct Color2 {
|
||||||
uint32_t Hex(const std::string color, uint8_t a = 255);
|
unsigned int color0;
|
||||||
} // namespace Color
|
unsigned int color1;
|
||||||
} // namespace RenderD7
|
};
|
||||||
|
|
||||||
|
struct Color3 {
|
||||||
|
unsigned int color0;
|
||||||
|
unsigned int color1;
|
||||||
|
unsigned int color2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Color4 {
|
||||||
|
unsigned int color0;
|
||||||
|
unsigned int color1;
|
||||||
|
unsigned int color2;
|
||||||
|
unsigned int color3;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum RD7Color_ {
|
||||||
|
RD7Color_Text, ///< This Color Should always be used for Light Backgrounds
|
||||||
|
RD7Color_TextDisabled, /// Text Disabled Color
|
||||||
|
RD7Color_Text2, ///< And This want for Texts on Dark Backgrounds
|
||||||
|
RD7Color_Background, ///< Your Bg Color
|
||||||
|
RD7Color_Header, ///< Header Color (if the header is dark text2 is used)
|
||||||
|
RD7Color_Selector,
|
||||||
|
RD7Color_SelectorFade,
|
||||||
|
RD7Color_List0,
|
||||||
|
RD7Color_List1,
|
||||||
|
RD7Color_MessageBackground,
|
||||||
|
RD7Color_Button,
|
||||||
|
RD7Color_ButtonHovered,
|
||||||
|
RD7Color_ButtonDisabled,
|
||||||
|
RD7Color_ButtonActive,
|
||||||
|
RD7Color_Checkmark,
|
||||||
|
RD7Color_FrameBg,
|
||||||
|
RD7Color_FrameBgHovered,
|
||||||
|
RD7Color_Progressbar,
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
unsigned int StyleColor(RD7Color color);
|
||||||
|
void RedirectColor(RD7Color to, RD7Color from);
|
||||||
|
void TextColorByBg(RD7Color background);
|
||||||
|
/// @brief Customices a color until undone
|
||||||
|
/// For example with RebderD7::Color::Hex
|
||||||
|
void CustomizeColor(RD7Color color, unsigned int custom);
|
||||||
|
/// @brief Completly changes a theme color
|
||||||
|
void ColorNew(RD7Color color, unsigned int new_color);
|
||||||
|
void UndoColorEdit(RD7Color color);
|
||||||
|
void UndoAllColorEdits();
|
||||||
|
namespace Color {
|
||||||
|
/// @brief RGBA Class
|
||||||
|
class RGBA {
|
||||||
|
public:
|
||||||
|
/// @brief Construct
|
||||||
|
/// @param r
|
||||||
|
/// @param g
|
||||||
|
/// @param b
|
||||||
|
/// @param a
|
||||||
|
RGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
|
||||||
|
: m_r(r), m_g(g), m_b(b), m_a(a) {}
|
||||||
|
/// @brief Construct
|
||||||
|
/// @param r
|
||||||
|
/// @param g
|
||||||
|
/// @param b
|
||||||
|
/// @param a
|
||||||
|
RGBA(float r, float g, float b, float a = 1.f)
|
||||||
|
: m_r(r * 255.f), m_g(g * 255.f), m_b(b * 255.f), m_a(a * 255.f) {}
|
||||||
|
RGBA(unsigned int in) {
|
||||||
|
#define ISIMPLEUNPAK(x, y) (((x) >> y) & 0xFF)
|
||||||
|
m_r = ISIMPLEUNPAK(in, 0);
|
||||||
|
m_g = ISIMPLEUNPAK(in, 8);
|
||||||
|
m_b = ISIMPLEUNPAK(in, 16);
|
||||||
|
m_a = ISIMPLEUNPAK(in, 24);
|
||||||
|
}
|
||||||
|
RGBA(RD7Color in) {
|
||||||
|
unsigned int col = RenderD7::StyleColor(in);
|
||||||
|
m_r = ISIMPLEUNPAK(col, 0);
|
||||||
|
m_g = ISIMPLEUNPAK(col, 8);
|
||||||
|
m_b = ISIMPLEUNPAK(col, 16);
|
||||||
|
m_a = ISIMPLEUNPAK(col, 24);
|
||||||
|
}
|
||||||
|
RGBA &changeR(unsigned char r) {
|
||||||
|
m_r = r;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeG(unsigned char g) {
|
||||||
|
m_g = g;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeB(unsigned char b) {
|
||||||
|
m_b = b;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
RGBA &changeA(unsigned char a) {
|
||||||
|
m_a = a;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBA &fade_to(const RGBA &color, float p) {
|
||||||
|
m_a =
|
||||||
|
m_a + static_cast<unsigned char>((color.m_a - m_a) * ((p + 1.0f) / 2));
|
||||||
|
m_b =
|
||||||
|
m_b + static_cast<unsigned char>((color.m_b - m_b) * ((p + 1.0f) / 2));
|
||||||
|
m_g =
|
||||||
|
m_g + static_cast<unsigned char>((color.m_g - m_g) * ((p + 1.0f) / 2));
|
||||||
|
m_r =
|
||||||
|
m_r + static_cast<unsigned char>((color.m_r - m_r) * ((p + 1.0f) / 2));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Get as Uint32
|
||||||
|
/// @return color
|
||||||
|
uint32_t toRGBA() const { return RGBA8(m_r, m_g, m_b, m_a); }
|
||||||
|
|
||||||
|
// Just calculate the "lightness" f.e. to use Text or Text2
|
||||||
|
float luminance() const {
|
||||||
|
// For Reference https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness
|
||||||
|
return (0.3 * (m_r / 255.f) + 0.59 * (m_g / 255.f) + 0.11 * (m_b / 255.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_light() {
|
||||||
|
// Gives us the light or dark to not
|
||||||
|
// always use the below "if" statement
|
||||||
|
return (luminance() >= 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t m_r, m_g, m_b, m_a;
|
||||||
|
};
|
||||||
|
/// @brief Convert RGB to Hex
|
||||||
|
/// @param r
|
||||||
|
/// @param g
|
||||||
|
/// @param b
|
||||||
|
/// @return Hex-String
|
||||||
|
std::string RGB2Hex(int r, int g, int b);
|
||||||
|
/// @brief Hex to U32
|
||||||
|
/// @param color
|
||||||
|
/// @param a
|
||||||
|
/// @return Color32
|
||||||
|
uint32_t Hex(const std::string &color, uint8_t a = 255);
|
||||||
|
} // namespace Color
|
||||||
|
} // namespace RenderD7
|
@ -1,28 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <3ds.h>
|
|
||||||
#include <citro2d.h>
|
|
||||||
#include <citro3d.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
namespace Draw {
|
|
||||||
bool Rect(float x, float y, float w, float h, u32 color);
|
|
||||||
bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
|
||||||
bool Px(float x, float y, u32 color);
|
|
||||||
void TextCentered(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
void Text(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
void TextRight(float x, float y, float size, u32 color, std::string Text,
|
|
||||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
|
||||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
|
||||||
void GetTextSize(float size, float *width, float *height, std::string Text,
|
|
||||||
C2D_Font fnt = nullptr);
|
|
||||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
|
||||||
Result LoadFont(C2D_Font &fnt, const char *Path = "");
|
|
||||||
Result UnloadFont(C2D_Font &fnt);
|
|
||||||
bool Circle(float x, float y, float radius, u32 color);
|
|
||||||
bool Image(C2D_Image img, float x, float y, float scaleX = 1.0f,
|
|
||||||
float scaleY = 1.0f);
|
|
||||||
} // namespace Draw
|
|
||||||
} // namespace RenderD7
|
|
51
include/renderd7/DrawV2.hpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <citro2d.h>
|
||||||
|
|
||||||
|
#include <renderd7/Color.hpp>
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <renderd7/Image.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#define MAKEFLAG(x) (1 << x)
|
||||||
|
|
||||||
|
typedef unsigned int RD7TextFlags;
|
||||||
|
|
||||||
|
enum RD7TextFlags_ {
|
||||||
|
RD7TextFlags_None = 0, //< Align is Left and Other things are disabled
|
||||||
|
RD7TextFlags_AlignRight = MAKEFLAG(0),
|
||||||
|
RD7TextFlags_AlignMid = MAKEFLAG(1),
|
||||||
|
RD7TextFlags_Shaddow = MAKEFLAG(2), // TextBuf Killer lol (doubled Text)
|
||||||
|
RD7TextFlags_Wrap = MAKEFLAG(3),
|
||||||
|
RD7TextFlags_Short = MAKEFLAG(4),
|
||||||
|
RD7TextFlags_Scroll = MAKEFLAG(5),
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
R7Vec2 GetTextDimensions(const std::string &text);
|
||||||
|
void CustomTextSize(float size);
|
||||||
|
void TextDefaultSize();
|
||||||
|
std::string TextShort(const std::string& in, int max_len);
|
||||||
|
// Overrite TextBox Size (by default Screenwidth x Text.h)
|
||||||
|
void TextMaxBox(R7Vec2 size);
|
||||||
|
void TextDefaultBox();
|
||||||
|
void TextFont(C2D_Font fnt);
|
||||||
|
void TextDefaultFont();
|
||||||
|
namespace Draw2 {
|
||||||
|
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t = 1);
|
||||||
|
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors);
|
||||||
|
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color);
|
||||||
|
// Wrapper of RectFilledSolid
|
||||||
|
inline void RFS(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||||
|
RectFilledSolid(pos, size, color);
|
||||||
|
}
|
||||||
|
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t = 1);
|
||||||
|
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors);
|
||||||
|
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color);
|
||||||
|
// Beta and Very unstable
|
||||||
|
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||||
|
int t = 1);
|
||||||
|
void Text(R7Vec2 pos, const std::string& text, RD7TextFlags flags = 0);
|
||||||
|
void Image(RenderD7::Image* img, const R7Vec2& pos = R7Vec2(0, 0), const R7Vec2& scale = R7Vec2(1, 1));
|
||||||
|
} // namespace Draw2
|
||||||
|
} // namespace RenderD7
|
16
include/renderd7/Error.hpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
void Error(const std::string& msg);
|
||||||
|
inline void InlineError(const std::string& msg) {
|
||||||
|
std::string location = __FILE__ + std::string(":") + std::to_string(__LINE__);
|
||||||
|
Error("Error: \n" + location + "\n" + msg);
|
||||||
|
}
|
||||||
|
inline void InlineAssert(bool v, const std::string& msg) {
|
||||||
|
std::string location = __FILE__ + std::string(":") + std::to_string(__LINE__);
|
||||||
|
if(v == false)
|
||||||
|
Error("Assert Failed:\n" + location + "\n" + msg);
|
||||||
|
}
|
||||||
|
}
|
@ -1,105 +1,25 @@
|
|||||||
// FileSystem based on libphyfs based on
|
#pragma once
|
||||||
// https://github.com/TurtleP/3ds-examples/blob/fs/physfs/fs/physfs/include/filesystem.h
|
#include <string>
|
||||||
#pragma once
|
#include <vector>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
namespace RenderD7 {
|
||||||
|
namespace FileSystem {
|
||||||
#include <physfs.h>
|
/// @brief A Directory Entry
|
||||||
|
struct Entry {
|
||||||
#define RD7_FSYS_GETINFO(path) \
|
/// @brief Patf of The Entry
|
||||||
({ \
|
std::string path;
|
||||||
RenderD7::FileSystem::Info inf; \
|
/// @brief Name of The Entry
|
||||||
RenderD7::FileSystem::GetInfo(path, inf); \
|
std::string name;
|
||||||
inf; \
|
/// @brief Directory or File
|
||||||
})
|
bool dir = false;
|
||||||
|
};
|
||||||
namespace RenderD7 {
|
/// @brief Gets All Entrys of A Directory into a Vector
|
||||||
namespace FileSystem {
|
/// @param path The Path of the Directory
|
||||||
static constexpr auto MAX_STAMP = 0x20000000000000LL;
|
/// @return The Vector of found Entrys
|
||||||
|
std::vector<RenderD7::FileSystem::Entry> GetDirContent(std::string path);
|
||||||
enum FileMode { FileMode_Open, FileMode_Read, FileMode_Write, FileMode_Closed };
|
std::string GetParentPath(std::string path, std::string mount_point);
|
||||||
|
std::vector<Entry>
|
||||||
enum FileType {
|
GetDirContentsExt(std::string &path,
|
||||||
FileType_File,
|
const std::vector<std::string> &extensions);
|
||||||
FileType_Directory,
|
} // namespace FileSystem
|
||||||
FileType_SymLink,
|
|
||||||
FileType_Other
|
|
||||||
};
|
|
||||||
|
|
||||||
struct File {
|
|
||||||
PHYSFS_file *handle;
|
|
||||||
FileMode mode;
|
|
||||||
|
|
||||||
File() {
|
|
||||||
this->handle = nullptr;
|
|
||||||
this->mode = FileMode_Closed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t GetSize() {
|
|
||||||
if (this->handle == nullptr)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return (int64_t)PHYSFS_fileLength(this->handle);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Info {
|
|
||||||
int64_t size;
|
|
||||||
int64_t mod_time;
|
|
||||||
FileType type;
|
|
||||||
};
|
|
||||||
|
|
||||||
int Init(const char *argv);
|
|
||||||
|
|
||||||
void Initialize();
|
|
||||||
|
|
||||||
/*
|
|
||||||
** mounts a specific directory for physfs to search in
|
|
||||||
** this is typically a main directory
|
|
||||||
*/
|
|
||||||
bool SetSource(const char *source);
|
|
||||||
|
|
||||||
/*
|
|
||||||
** mounts a specific directory as a "save" directory
|
|
||||||
** if appended, it will be added to the search path
|
|
||||||
*/
|
|
||||||
bool SetIdentity(const char *name, bool append);
|
|
||||||
|
|
||||||
static std::string savePath;
|
|
||||||
|
|
||||||
/* gets the last physfs error */
|
|
||||||
const char *GetPhysfsError();
|
|
||||||
|
|
||||||
/* strips any duplicate slashes */
|
|
||||||
std::string Normalize(const std::string &input);
|
|
||||||
|
|
||||||
/* gets the user directory from physfs */
|
|
||||||
std::string GetUserDirectory();
|
|
||||||
|
|
||||||
/* gets the save directory */
|
|
||||||
std::string GetSaveDirectory();
|
|
||||||
|
|
||||||
/* sets up the writing directory for physfs */
|
|
||||||
bool SetupWriteDirectory();
|
|
||||||
|
|
||||||
/* gets a list of files in a directory */
|
|
||||||
void GetDirectoryItems(const char *directory, std::vector<std::string> &items);
|
|
||||||
|
|
||||||
/* gets the size, mod_time, and type of a file */
|
|
||||||
bool GetInfo(const char *filename, Info &info);
|
|
||||||
|
|
||||||
/* creates a new directory */
|
|
||||||
bool CreateDirectory(const char *name);
|
|
||||||
|
|
||||||
bool CloseFile(File &file);
|
|
||||||
|
|
||||||
/* creates a new file */
|
|
||||||
bool OpenFile(File &file, const char *name, FileMode mode);
|
|
||||||
|
|
||||||
/* writes to a file */
|
|
||||||
bool WriteFile(File &file, const void *data, int64_t size);
|
|
||||||
|
|
||||||
/* reads a file's content */
|
|
||||||
int64_t ReadFile(File &file, void *destination, int64_t size);
|
|
||||||
} // namespace FileSystem
|
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,142 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <bitset>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <renderd7/external/stb_truetype.h>
|
|
||||||
|
|
||||||
#define MAXUNICODE 0x10FFFF
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
inline int utf8_decode(const char *o) {
|
|
||||||
static const unsigned int limits[] = {0xFF, 0x7F, 0x7FF, 0xFFFF};
|
|
||||||
const unsigned char *s = (const unsigned char *)o;
|
|
||||||
unsigned int c = s[0];
|
|
||||||
unsigned int res = 0; /* final result */
|
|
||||||
if (c < 0x80) /* ascii? */
|
|
||||||
res = c;
|
|
||||||
else {
|
|
||||||
int count = 0; /* to count number of continuation bytes */
|
|
||||||
while (c & 0x40) { /* still have continuation bytes? */
|
|
||||||
int cc = s[++count]; /* read next byte */
|
|
||||||
if ((cc & 0xC0) != 0x80) /* not a continuation byte? */
|
|
||||||
return -1; /* invalid byte sequence */
|
|
||||||
res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */
|
|
||||||
c <<= 1; /* to test next bit */
|
|
||||||
}
|
|
||||||
res |= ((c & 0x7F) << (count * 5)); /* add first byte */
|
|
||||||
if (count > 3 || res > MAXUNICODE || res <= limits[count])
|
|
||||||
return -1; /* invalid byte sequence */
|
|
||||||
s += count; /* skip continuation bytes read */
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::string IntToUtf8(int convertval) {
|
|
||||||
|
|
||||||
// We only care about plane 1 right now,
|
|
||||||
// but know that we have other options (0x10FFFF)
|
|
||||||
// Technically UTF-8 is "limited" to 4 bytes, so it's not
|
|
||||||
// Like it matters much anyways these days
|
|
||||||
|
|
||||||
if (convertval == 0)
|
|
||||||
return " ";
|
|
||||||
if ((convertval <= 0x7F) && (convertval > 0x00)) {
|
|
||||||
|
|
||||||
std::string out(".");
|
|
||||||
|
|
||||||
std::bitset<8> x(convertval);
|
|
||||||
|
|
||||||
unsigned long l = x.to_ulong();
|
|
||||||
unsigned char c = static_cast<unsigned char>(l);
|
|
||||||
out[0] = c;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else if ((convertval >= 0x80) && (convertval <= 0x07FF)) {
|
|
||||||
|
|
||||||
std::string out("..");
|
|
||||||
|
|
||||||
int firstShift = (convertval >> 0x06) ^ 0xC0;
|
|
||||||
int secondShift = ((convertval ^ 0xFFC0) | 0x80) & ~0x40;
|
|
||||||
|
|
||||||
std::bitset<8> first(firstShift);
|
|
||||||
std::bitset<8> last(secondShift);
|
|
||||||
|
|
||||||
unsigned long l = first.to_ulong();
|
|
||||||
unsigned char c = static_cast<unsigned char>(l);
|
|
||||||
out[0] = c;
|
|
||||||
|
|
||||||
unsigned long ltwo = last.to_ulong();
|
|
||||||
unsigned char ctwo = static_cast<unsigned char>(ltwo);
|
|
||||||
out[1] = ctwo;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else if ((convertval >= 0x0800) && (convertval <= 0xFFFF)) {
|
|
||||||
|
|
||||||
std::string out("...");
|
|
||||||
|
|
||||||
int firstShift = ((convertval ^ 0xFC0FFF) >> 0x0C) | 0xE0;
|
|
||||||
int secondShift = (((convertval ^ 0xFFF03F) >> 0x06) | 0x80) & ~0x40;
|
|
||||||
int thirdShift = ((convertval ^ 0xFFFC0) | 0x80) & ~0x40;
|
|
||||||
|
|
||||||
std::bitset<8> first(firstShift);
|
|
||||||
std::bitset<8> second(secondShift);
|
|
||||||
std::bitset<8> third(thirdShift);
|
|
||||||
|
|
||||||
unsigned long lone = first.to_ulong();
|
|
||||||
unsigned char cone = static_cast<unsigned char>(lone);
|
|
||||||
out[0] = cone;
|
|
||||||
|
|
||||||
unsigned long ltwo = second.to_ulong();
|
|
||||||
unsigned char ctwo = static_cast<unsigned char>(ltwo);
|
|
||||||
out[1] = ctwo;
|
|
||||||
|
|
||||||
unsigned long lthree = third.to_ulong();
|
|
||||||
unsigned char cthree = static_cast<unsigned char>(lthree);
|
|
||||||
out[2] = cthree;
|
|
||||||
|
|
||||||
return out;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#define I2U82I(val) RenderD7::utf8_decode(RenderD7::IntToUtf8(val).c_str())
|
|
||||||
|
|
||||||
class NFontApi {
|
|
||||||
public:
|
|
||||||
NFontApi();
|
|
||||||
~NFontApi();
|
|
||||||
void LoadTTF(std::string path);
|
|
||||||
unsigned char *GetGlyphBitmap(char glyph);
|
|
||||||
std::string GetStatus() { return status; }
|
|
||||||
float GetScale() { return scale; }
|
|
||||||
int GetGlyphWidth(char glyph);
|
|
||||||
int GetGlyphHeight(char glyph);
|
|
||||||
int GetLineHeight() { return l_h; }
|
|
||||||
int GetBaseHeight() { return height; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string status;
|
|
||||||
|
|
||||||
int height;
|
|
||||||
|
|
||||||
float scale;
|
|
||||||
int b_w;
|
|
||||||
int b_h;
|
|
||||||
int l_h;
|
|
||||||
|
|
||||||
int w;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
int x0, y0, x1, y1;
|
|
||||||
int ascent, baseline, decent, linegap;
|
|
||||||
|
|
||||||
int linespace;
|
|
||||||
|
|
||||||
stbtt_fontinfo font;
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
53
include/renderd7/FunctionTrace.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
// Base includes
|
||||||
|
#include <functional>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
// 3ds does not support std::chrono
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
/// @brief 3ds System Ticks per milli second
|
||||||
|
#define TICKS_PER_MSEC 268111.856
|
||||||
|
|
||||||
|
#define f2s(x_) #x_
|
||||||
|
#define scomb(x1, x2) std::string(x1 + x2)
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Ftrace {
|
||||||
|
/// @brief Result of FTrace
|
||||||
|
struct FTRes {
|
||||||
|
std::string group; ///< Group of the Trace
|
||||||
|
std::string func_name; ///< Function Name
|
||||||
|
|
||||||
|
uint64_t time_start; ///< when started
|
||||||
|
uint64_t time_end; ///< when stopped
|
||||||
|
float time_of; ///< stop - start (how long)
|
||||||
|
bool is_ovl; ///< is displayed in overlay?
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief Map of Traces
|
||||||
|
extern std::map<std::string, RenderD7::Ftrace::FTRes> rd7_traces;
|
||||||
|
|
||||||
|
/// @brief Set a Start TracePoint
|
||||||
|
/// @param group Set a Group Name
|
||||||
|
/// @param func_name Set a Function Name
|
||||||
|
inline void Beg(std::string group, std::string func_name) {
|
||||||
|
std::string trace_id = scomb(group, func_name);
|
||||||
|
rd7_traces[trace_id].group = group;
|
||||||
|
rd7_traces[trace_id].func_name = func_name;
|
||||||
|
rd7_traces[trace_id].time_start = svcGetSystemTick();
|
||||||
|
}
|
||||||
|
/// @brief Set an End TracePoint
|
||||||
|
/// @param group Set a Group Name
|
||||||
|
/// @param func_name Set a Function Name
|
||||||
|
inline void End(std::string group, std::string func_name) {
|
||||||
|
std::string trace_id = scomb(group, func_name);
|
||||||
|
rd7_traces[trace_id].time_end = svcGetSystemTick();
|
||||||
|
rd7_traces[trace_id].time_of = static_cast<float>(
|
||||||
|
rd7_traces[trace_id].time_end / (float)TICKS_PER_MSEC -
|
||||||
|
rd7_traces[trace_id].time_start / (float)TICKS_PER_MSEC);
|
||||||
|
}
|
||||||
|
} // namespace Ftrace
|
||||||
|
} // namespace RenderD7
|
23
include/renderd7/Hardware.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Hardware {
|
||||||
|
/// @brief Initialisize required Services
|
||||||
|
void Initialisize();
|
||||||
|
/// @brief Check if Headphones are Plugged in
|
||||||
|
/// @return true if headphones plugged in
|
||||||
|
bool IsHeadphones();
|
||||||
|
/// @brief Check if the 3ds Is Charging
|
||||||
|
/// @return true if System gets Charged
|
||||||
|
bool IsCharging();
|
||||||
|
/// @brief Check the Battery Percentage
|
||||||
|
/// @return Persentage as float
|
||||||
|
float GetBatteryPercentage();
|
||||||
|
/// @brief Get current State of 3d Slider
|
||||||
|
/// @return current 3dslider poition
|
||||||
|
float Get3dSliderLevel();
|
||||||
|
/// @brief Get Current state of Sound Slider
|
||||||
|
/// @return current SoundSlider state
|
||||||
|
float GetSoundSliderLevel();
|
||||||
|
} // namespace Hardware
|
||||||
|
} // namespace RenderD7
|
41
include/renderd7/Hid.hpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/// WARNING
|
||||||
|
/// THIS IS BETA STUFF
|
||||||
|
/// ITS MAKE LIKE EXTERNAL BUT
|
||||||
|
/// FOR RENDERD7 ITS INTEGRATED
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Hid {
|
||||||
|
enum Actions {
|
||||||
|
Down = 0,
|
||||||
|
Held = 1,
|
||||||
|
Up = 2,
|
||||||
|
DownRepeat = 3,
|
||||||
|
};
|
||||||
|
// Register Functions
|
||||||
|
// Register Current state values
|
||||||
|
void RegKeyDown(uint32_t &key_down);
|
||||||
|
void RegKeyHeld(uint32_t &key_held);
|
||||||
|
void RegKeyUp(uint32_t &key_up);
|
||||||
|
void RegKeyRepeat(uint32_t &repeat);
|
||||||
|
void RegTouchCoords(R7Vec2 &touch_pos);
|
||||||
|
// Not Corectly Implemented Yet
|
||||||
|
void RegAnalog1Movement(R7Vec2 &movement);
|
||||||
|
void RegAnalog2Movement(R7Vec2 &movement);
|
||||||
|
// Register Keys
|
||||||
|
void RegKeyEvent(const std::string &event, uint32_t key);
|
||||||
|
// KeyEvents
|
||||||
|
bool IsEvent(const std::string &event, Actions action);
|
||||||
|
R7Vec2 GetTouchPosition();
|
||||||
|
R7Vec2 GetLastTouchPosition();
|
||||||
|
void Update();
|
||||||
|
// Lock/Unlock Input api for example for Keyboard
|
||||||
|
void Lock();
|
||||||
|
void Unlock();
|
||||||
|
void Clear();
|
||||||
|
} // namespace Hid
|
||||||
|
} // namespace RenderD7
|
@ -1,46 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <citro2d.h>
|
|
||||||
#include <citro3d.h>
|
#include <citro2d.h>
|
||||||
#include <memory>
|
#include <3ds.h>
|
||||||
|
|
||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/R7Vec.hpp>
|
||||||
#include <renderd7/bmp.hpp>
|
#include <renderd7/nimg.hpp>
|
||||||
#include <renderd7/bmpconverter.hpp>
|
|
||||||
|
#include <string>
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
namespace RenderD7 {
|
||||||
#include <renderd7/Color.hpp>
|
class Image {
|
||||||
#include <renderd7/external/lodepng.h>
|
public:
|
||||||
|
Image();
|
||||||
namespace RenderD7 {
|
~Image();
|
||||||
/// Image Class
|
void load(const std::string& path);
|
||||||
class Image {
|
void from_nimg(const nimg& image);
|
||||||
public:
|
|
||||||
Image() {}
|
C2D_Image get();
|
||||||
~Image();
|
C2D_Image& get_ref();
|
||||||
|
void set(const C2D_Image& i);
|
||||||
void Unload();
|
R7Vec2 get_size();
|
||||||
/// Load Image from Png
|
bool loaded();
|
||||||
/// \param path path to png file
|
|
||||||
void LoadPng(const std::string path);
|
private:
|
||||||
/// Load the Image from buffer
|
void safe_del();
|
||||||
/// \param buffer the frame buffer
|
bool ld = false;
|
||||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
C2D_Image img;
|
||||||
void LoadFromBitmap(BMP bitmap);
|
};
|
||||||
/// Draw the Image directly
|
}
|
||||||
/// \param x The x position
|
|
||||||
/// \param y the y position
|
|
||||||
/// \param scaleX x scale from 0.0 to 1.0
|
|
||||||
/// \param scaleY y scale from 0.0 to 1.0
|
|
||||||
bool Draw(float x, float y, float scaleX = 1.0f, float scaleY = 1.0f);
|
|
||||||
/// \brief Get The Image
|
|
||||||
/// \return C2D_Image
|
|
||||||
C2D_Image Get() { return this->img; }
|
|
||||||
|
|
||||||
void FromSheet(RenderD7::Sheet sheet, size_t index);
|
|
||||||
/// \param img this is the C2D_Image
|
|
||||||
C2D_Image img;
|
|
||||||
/// \param loadet whether the image is loadet or not
|
|
||||||
bool loadet = false;
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
25
include/renderd7/Memory.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Memory {
|
||||||
|
/// @brief Metriks struct For the Internal Tracker
|
||||||
|
struct memory_metrics {
|
||||||
|
uint32_t t_TotalAllocated = 0; ///< Total Allocated Memory
|
||||||
|
uint32_t t_TotalFreed = 0; ///< Total Deleted Memory
|
||||||
|
/// @brief Gets the Currently Allocated Memory
|
||||||
|
uint32_t t_CurrentlyAllocated() { return t_TotalAllocated - t_TotalFreed; }
|
||||||
|
};
|
||||||
|
/// @brief Get Total Allocated Memory
|
||||||
|
/// @return Total Allocated Memory
|
||||||
|
size_t GetTotalAllocated();
|
||||||
|
/// @brief Get Total Deleted Memory
|
||||||
|
/// @return Total Deleted Memory
|
||||||
|
size_t GetTotalFreed();
|
||||||
|
/// @brief Get Current Allocated Memory
|
||||||
|
/// @return Current Allocated Memory
|
||||||
|
size_t GetCurrent();
|
||||||
|
} // namespace Memory
|
||||||
|
} // namespace RenderD7
|
24
include/renderd7/Message.hpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
struct Message {
|
||||||
|
Message(std::string t, std::string m) {
|
||||||
|
title = t;
|
||||||
|
message = m;
|
||||||
|
animationframe = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string title;
|
||||||
|
std::string message;
|
||||||
|
int animationframe;
|
||||||
|
};
|
||||||
|
|
||||||
|
void ProcessMessages();
|
||||||
|
void PushMessage(const Message& msg);
|
||||||
|
// Config
|
||||||
|
void SetMessageIdleStartFrame(int frame);
|
||||||
|
void SetMessageTotalAnimationFrames(int total_frames);
|
||||||
|
void SetMessageFadeOutStartFrame(int frame);
|
||||||
|
}
|
74
include/renderd7/Overlays.hpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/Ovl.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Ovl_Ftrace : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
Ovl_Ftrace(bool* is_enabled);
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool* i_is_enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Ovl_Metrik : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
Ovl_Metrik(bool* is_enabled, bool* screen, uint32_t* mt_color, uint32_t* txt_color, float* txt_size);
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Mutable internal values
|
||||||
|
mutable std::string mt_fps;
|
||||||
|
mutable std::string mt_cpu;
|
||||||
|
mutable std::string mt_gpu;
|
||||||
|
mutable std::string mt_cmd;
|
||||||
|
mutable std::string mt_lfr;
|
||||||
|
mutable std::string mt_tbs;
|
||||||
|
|
||||||
|
// Importand Adresses
|
||||||
|
bool* i_is_enabled;
|
||||||
|
bool* i_screen;
|
||||||
|
uint32_t* i_mt_color;
|
||||||
|
uint32_t* i_txt_color;
|
||||||
|
float* i_txt_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int RD7Keyboard;
|
||||||
|
|
||||||
|
enum RD7Keyboard_ {
|
||||||
|
RD7Keyboard_Default,
|
||||||
|
RD7Keyboard_Numpad,
|
||||||
|
RD7Keyboard_Password,
|
||||||
|
};
|
||||||
|
|
||||||
|
class Ovl_Keyboard : public RenderD7::Ovl {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
/// Keyboard Type not Supported for now
|
||||||
|
Ovl_Keyboard(std::string& ref, const std::string& hint = "", RD7Keyboard type = 0);
|
||||||
|
/// @brief Deconstructor
|
||||||
|
~Ovl_Keyboard();
|
||||||
|
/// @brief Override for Draw
|
||||||
|
void Draw(void) const override;
|
||||||
|
/// @brief Override for Logic
|
||||||
|
void Logic() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable std::map<unsigned char, char> shared_data;
|
||||||
|
// Pointer to useres String
|
||||||
|
std::string *typed_text = nullptr;
|
||||||
|
std::string str_bak;
|
||||||
|
int mode = 0;
|
||||||
|
int ft3 = 0;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
@ -1,17 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class Ovl {
|
/// @brief The Overlay Class (Used for Toasts for example)
|
||||||
public:
|
class Ovl {
|
||||||
virtual ~Ovl() {}
|
public:
|
||||||
virtual void Draw() const = 0;
|
/// @brief Deconstructor
|
||||||
virtual void Logic() = 0;
|
virtual ~Ovl() {}
|
||||||
inline bool IsKilled() { return this->iskilled; }
|
/// @brief Function Called to Draw this
|
||||||
inline void Kill() { iskilled = true; }
|
virtual void Draw() const = 0;
|
||||||
|
/// @brief Logic of the Overlay
|
||||||
private:
|
virtual void Logic() = 0;
|
||||||
bool iskilled = false;
|
/// @brief Should the overlay be killed
|
||||||
};
|
/// @return Killed or Not
|
||||||
void AddOvl(std::unique_ptr<RenderD7::Ovl> scene);
|
inline bool IsKilled() { return this->iskilled; }
|
||||||
|
/// @brief Kill The Overlay
|
||||||
|
inline void Kill() { iskilled = true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @param iskilled For IsKilled();
|
||||||
|
bool iskilled = false;
|
||||||
|
};
|
||||||
|
/// @brief Add an Overlay to the Screen
|
||||||
|
/// @param scene Overlay to push to Screen
|
||||||
|
void AddOvl(std::unique_ptr<RenderD7::Ovl> scene);
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
42
include/renderd7/R7Vec.hpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct R7Vec2 {
|
||||||
|
// Init Funcs
|
||||||
|
R7Vec2() : x(0), y(0) {}
|
||||||
|
R7Vec2(float i0, float i1) : x(i0), y(i1) {}
|
||||||
|
R7Vec2(const R7Vec2 &i) {
|
||||||
|
x = i.x;
|
||||||
|
y = i.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Operators
|
||||||
|
// Add
|
||||||
|
R7Vec2 &operator+=(const R7Vec2 &i) {
|
||||||
|
x += i.x;
|
||||||
|
y += i.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 operator+(const R7Vec2 &i) const { return R7Vec2(x + i.x, y + i.y); }
|
||||||
|
|
||||||
|
// Sub
|
||||||
|
R7Vec2 &operator-=(const R7Vec2 &i) {
|
||||||
|
x -= i.x;
|
||||||
|
y -= i.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
R7Vec2 operator-(const R7Vec2 &i) const { return R7Vec2(x - i.x, y - i.y); }
|
||||||
|
|
||||||
|
// Compare
|
||||||
|
bool operator==(const R7Vec2 &in) const { return x == in.x && y == in.y; }
|
||||||
|
|
||||||
|
bool operator!=(const R7Vec2 &in) const {
|
||||||
|
// use the first comparefuncs result
|
||||||
|
// and swap it lol
|
||||||
|
return !(*this == in);
|
||||||
|
}
|
||||||
|
// Internal Values
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
};
|
53
include/renderd7/ResultDecoder.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <3ds.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
/// @brief Decoder for 3ds Result Codes
|
||||||
|
class ResultDecoder {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
ResultDecoder() {}
|
||||||
|
/// @brief Deconstructor
|
||||||
|
~ResultDecoder() {}
|
||||||
|
/// @brief Load a Result into Decoder
|
||||||
|
/// @param rescode Result Code
|
||||||
|
void Load(Result rescode);
|
||||||
|
/// @brief Load A Hex Converted Code into Decoder
|
||||||
|
/// @param rescode Result-Hex Code
|
||||||
|
void Load(std::string rescode);
|
||||||
|
/// @brief Get Hex Code
|
||||||
|
/// @return Hex-Code
|
||||||
|
std::string GetCode();
|
||||||
|
/// @brief Get Level Name
|
||||||
|
/// @return Level Name
|
||||||
|
std::string GetLevel();
|
||||||
|
/// @brief Get Level Value
|
||||||
|
/// @return Level Value
|
||||||
|
int GetLevelInt();
|
||||||
|
/// @brief Get The Mosule Name
|
||||||
|
/// @return Module Name
|
||||||
|
std::string GetModule();
|
||||||
|
/// @brief Get The Module Value
|
||||||
|
/// @return Module Value
|
||||||
|
int GetModuleInt();
|
||||||
|
/// @brief Get The Description
|
||||||
|
/// @return Description
|
||||||
|
std::string GetDescription();
|
||||||
|
/// @brief Get The Description Valur
|
||||||
|
/// @return Description Value
|
||||||
|
int GetDescriptionInt();
|
||||||
|
/// @brief Get the Summary
|
||||||
|
/// @return Summary
|
||||||
|
std::string GetSummary();
|
||||||
|
/// @brief Get the Summary Value
|
||||||
|
/// @return Summary Value
|
||||||
|
int GetSummaryInt();
|
||||||
|
/// @brief Write a Result log file to sd
|
||||||
|
void WriteLog(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @param m_rescode Result code
|
||||||
|
Result m_rescode;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
@ -1,13 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
extern C3D_RenderTarget *Top;
|
/// \param Top Tob-Screen Target
|
||||||
extern C3D_RenderTarget *TopRight;
|
extern C3D_RenderTarget *Top;
|
||||||
extern C3D_RenderTarget *Bottom;
|
/// \param TopRight Top-Right-Screen Target (Never atually used)
|
||||||
|
extern C3D_RenderTarget *TopRight;
|
||||||
namespace RenderD7 {
|
/// \param Bottom Bottom-Screen Target
|
||||||
/// Set current RenderScreen
|
extern C3D_RenderTarget *Bottom;
|
||||||
/// \param target The RenderTarget Top, Bottom
|
|
||||||
void OnScreen(C3D_RenderTarget *target);
|
namespace RenderD7 {
|
||||||
} // namespace RenderD7
|
/// @brief Begin Drawing On Specific Screen
|
||||||
|
/// @param target The Screen Target (Top, Bottom or TopTight)
|
||||||
|
void OnScreen(C3D_RenderTarget *target);
|
||||||
|
} // namespace RenderD7
|
||||||
|
60
include/renderd7/Security.hpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <functional>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Init {
|
||||||
|
void Security();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Security {
|
||||||
|
public:
|
||||||
|
/// @brief Security Levels
|
||||||
|
enum Level {
|
||||||
|
NONE, ///< Do Completly Nothing (excludes FrameEnd Security)
|
||||||
|
FULL, ///< Display Every Reports even Success
|
||||||
|
ERRORS, ///< Display Only Errors
|
||||||
|
WARNINGS, ///< Display Errors and Warnings
|
||||||
|
LOG, ///< Log Every Error with Detailed Information
|
||||||
|
};
|
||||||
|
|
||||||
|
Security();
|
||||||
|
~Security();
|
||||||
|
/// @brief Report an Output (For SafeTraceInit)
|
||||||
|
/// @param addr Adress of Pointer
|
||||||
|
/// @param result_ptr Pointer to the result
|
||||||
|
void Report(uint32_t addr, void *result_ptr);
|
||||||
|
/// @brief Set the Security Level
|
||||||
|
/// @param level Level to use
|
||||||
|
void SetLevel(Level level);
|
||||||
|
/// @brief Get Current Security Level
|
||||||
|
/// @return Security Level
|
||||||
|
Level GetLevel();
|
||||||
|
/// @brief Call a Function at Program Crash/Exit
|
||||||
|
/// @param exit_func Function to Call
|
||||||
|
void SafeExit(void (*exit_func)());
|
||||||
|
/// @brief SaveInit a Function and define a Exit Func
|
||||||
|
/// @param init_func Init Function
|
||||||
|
/// @param exit_func Exit Function
|
||||||
|
void SafeInit(void (*init_func)(), void (*exit_func)());
|
||||||
|
/// @brief SaveInit a Function and define a Exit Func
|
||||||
|
/// @param init_func Init Function
|
||||||
|
/// @param exit_func Exit Function
|
||||||
|
void SafeInit(Result (*init_func)(), void (*exit_func)());
|
||||||
|
/// @brief SaveInit a Function and define a Exit Func
|
||||||
|
/// @param init_func Init Function
|
||||||
|
/// @param exit_func Exit Function
|
||||||
|
void SafeInit(void (*init_func)(), Result (*exit_func)());
|
||||||
|
/// @brief SaveInit a Function and define a Exit Func
|
||||||
|
/// @param init_func Init Function
|
||||||
|
/// @param exit_func Exit Function
|
||||||
|
void SafeInit(Result (*init_func)(), Result (*exit_func)());
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
||||||
|
|
||||||
|
/// @brief RenderD7 Security Object
|
||||||
|
extern RenderD7::Security *rd7_security;
|
@ -1,21 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
#include <3ds.h> // Result
|
||||||
namespace RenderD7 {
|
#include <string>
|
||||||
/** The Spritesheet Class */
|
|
||||||
class Sheet {
|
namespace RenderD7 {
|
||||||
public:
|
/// @brief SpriteSheet Class
|
||||||
/// Construct sheet
|
class Sheet {
|
||||||
Sheet();
|
public:
|
||||||
// Deconstruct sheet
|
/// @brief Constructor
|
||||||
~Sheet();
|
Sheet();
|
||||||
/// Load a Sritesheet
|
/// @brief Deconstructor
|
||||||
/// \param path Path to the Spritesheet (.t3x)
|
~Sheet();
|
||||||
Result Load(const char *path);
|
/// @brief Load A Spritesheet File
|
||||||
/// Unload the Spritesheet
|
/// @param path Path to the t3x
|
||||||
void Free();
|
/// @return Result Code
|
||||||
/// The Spritesheet
|
Result Load(const std::string& path);
|
||||||
C2D_SpriteSheet spritesheet;
|
/// @brief Unload the Sheet
|
||||||
};
|
void Free();
|
||||||
|
/// \param spritesheet The Sheet
|
||||||
|
C2D_SpriteSheet spritesheet;
|
||||||
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,39 +1,64 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
#include <renderd7/Image.hpp>
|
#include <renderd7/Image.hpp>
|
||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/Sheet.hpp>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
/// Sprite Class
|
/// @brief Sprite Class
|
||||||
class Sprite {
|
class Sprite {
|
||||||
public:
|
public:
|
||||||
/// \brief Construct Sprite
|
/// \brief Construct Sprite
|
||||||
Sprite();
|
Sprite();
|
||||||
/// \brief Deconstruct Sprite
|
/// \brief Deconstruct Sprite
|
||||||
~Sprite();
|
~Sprite();
|
||||||
/// \brief Load a Sprite From SpriteSheet
|
/// \brief Load a Sprite From SpriteSheet
|
||||||
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
/// \param sheet the Sheet to load from.(RenderD7::Sheet)
|
||||||
/// \param index the number of the Sprite in the Sheet
|
/// \param index the number of the Sprite in the Sheet
|
||||||
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
void FromSheet(RenderD7::Sheet *sheet, size_t index);
|
||||||
/// \brief Load a Sprite From SpriteSheet
|
/// \brief Load a Sprite From SpriteSheet
|
||||||
/// \param img the Image to load from.(RenderD7::Image)
|
/// \param img the Image to load from.(RenderD7::Image)
|
||||||
void FromImage(RenderD7::Image *img);
|
void FromImage(RenderD7::Image *img);
|
||||||
bool Draw();
|
/// @brief Draw the Sprite
|
||||||
void SetCenter(float x, float y);
|
/// @return success ?
|
||||||
void SetPos(float x, float y);
|
bool Draw();
|
||||||
void SetScale(float x, float y);
|
/// @brief Set the Center Position
|
||||||
void SetRotation(float rotation);
|
/// @param x X Pos
|
||||||
void Rotate(float speed);
|
/// @param y Y Pos
|
||||||
float getWidth();
|
void SetCenter(float x, float y);
|
||||||
float getHeigh();
|
/// @brief Set the Sprite's Position
|
||||||
float getPosX();
|
/// @param x X Pos
|
||||||
float getPosY();
|
/// @param y Y Pos
|
||||||
|
void SetPos(float x, float y);
|
||||||
private:
|
/// @brief Set The Sprite's Scale
|
||||||
C2D_ImageTint tint;
|
/// @param x Scale on X-Axis
|
||||||
C2D_Sprite sprite;
|
/// @param y Scale on Y-Axis
|
||||||
};
|
void SetScale(float x, float y);
|
||||||
|
/// @brief Set the Sprite's Rotation
|
||||||
|
/// @param rotation ratation
|
||||||
|
void SetRotation(float rotation);
|
||||||
|
/// @brief Rotate the Sprite
|
||||||
|
/// @param speed Speed to Rotate
|
||||||
|
void Rotate(float speed);
|
||||||
|
/// @brief Get Tje Sprite's Width
|
||||||
|
/// @return Width
|
||||||
|
float getWidth();
|
||||||
|
/// @brief Get the Sprite's Height
|
||||||
|
/// @return Height
|
||||||
|
float getHeight();
|
||||||
|
/// @brief Get The Sprite's X Position
|
||||||
|
/// @return X Position
|
||||||
|
float getPosX();
|
||||||
|
/// @brief Get the Sprite's Y Position
|
||||||
|
/// @return Y Position
|
||||||
|
float getPosY();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @param tint ImageTint (unused)
|
||||||
|
C2D_ImageTint tint;
|
||||||
|
/// @param sprite The Sprite
|
||||||
|
C2D_Sprite sprite;
|
||||||
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
@ -1,25 +1,41 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/Sheet.hpp>
|
||||||
#include <renderd7/Sprite.hpp>
|
#include <renderd7/Sprite.hpp>
|
||||||
|
|
||||||
#include <citro2d.h>
|
#include <citro2d.h>
|
||||||
#include <citro3d.h>
|
#include <citro3d.h>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class SpriteSheetAnimation : public RenderD7::Sprite {
|
/// @brief SpriteSheetAnimation Class
|
||||||
public:
|
class SpriteSheetAnimation : public RenderD7::Sprite {
|
||||||
SpriteSheetAnimation();
|
public:
|
||||||
~SpriteSheetAnimation();
|
/// @brief Constructor
|
||||||
void Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage,
|
SpriteSheetAnimation();
|
||||||
float frame_begin, float frame_finish);
|
/// @brief Deconstructor
|
||||||
void Play(float timespeed);
|
~SpriteSheetAnimation();
|
||||||
|
/// @brief Setup an Animation
|
||||||
private:
|
/// @param sheet Input Spritesheet
|
||||||
size_t images;
|
/// @param imagecount Count of Images
|
||||||
size_t imgs = 0;
|
/// @param startimage Where to Start the Loop
|
||||||
float D_totaltime;
|
/// @param frame_begin Current Time (Should be 0)
|
||||||
RenderD7::Sheet *sheet;
|
/// @param frame_finish Time Length
|
||||||
float time;
|
void Setup(RenderD7::Sheet *sheet, size_t imagecount, size_t startimage,
|
||||||
};
|
float frame_begin, float frame_finish);
|
||||||
|
/// @brief Play the Animation
|
||||||
|
/// @param timespeed Speed of the animation
|
||||||
|
void Play(float timespeed);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @param images Count of Images
|
||||||
|
size_t images;
|
||||||
|
/// @param imgs Another Count of images ???
|
||||||
|
size_t imgs = 0;
|
||||||
|
/// @param D_totaltime Current Time
|
||||||
|
float D_totaltime;
|
||||||
|
/// @param sheet The Sheet of Images
|
||||||
|
RenderD7::Sheet *sheet;
|
||||||
|
/// @param time Total Time from frame_finish
|
||||||
|
float time;
|
||||||
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
21
include/renderd7/StealConsole.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
/// @brief StealConsole Class
|
||||||
|
class StealConsole {
|
||||||
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
|
StealConsole();
|
||||||
|
/// @brief Deconstructor
|
||||||
|
~StealConsole();
|
||||||
|
/// @brief The Stolen Stdout
|
||||||
|
/// @return Stdout as string
|
||||||
|
std::string GetStdout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// @param stolen_stdout Stolen Stdout
|
||||||
|
std::stringstream stolen_stdout;
|
||||||
|
};
|
||||||
|
} // namespace RenderD7
|
13
include/renderd7/Tasks.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <3ds.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
namespace Tasks {
|
||||||
|
/// @brief Push A Task
|
||||||
|
/// @param entrypoint Function of Your Task
|
||||||
|
void create(ThreadFunc entrypoint);
|
||||||
|
/// @brief Destroy all Tasks
|
||||||
|
void destroy(void);
|
||||||
|
} // namespace Tasks
|
||||||
|
} // namespace RenderD7
|
@ -1,7 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
std::string FormatString(std::string fmt_str, ...);
|
/// @brief Format a String
|
||||||
std::string GetTimeStr(void);
|
/// @param fmt_str Format To
|
||||||
|
/// @param ... Additional Args
|
||||||
|
/// @return Formatted String
|
||||||
|
std::string FormatString(std::string fmt_str, ...);
|
||||||
|
/// @brief Get Current Time as String
|
||||||
|
/// @return Time-String
|
||||||
|
std::string GetTimeStr(void);
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
22
include/renderd7/Timer.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <3ds.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Timer {
|
||||||
|
public:
|
||||||
|
Timer(bool autostart = true);
|
||||||
|
~Timer() {}
|
||||||
|
void reset();
|
||||||
|
void tick();
|
||||||
|
void pause();
|
||||||
|
void resume();
|
||||||
|
float get();
|
||||||
|
float get_live();
|
||||||
|
bool running();
|
||||||
|
private:
|
||||||
|
uint64_t last = 0;
|
||||||
|
uint64_t current = 0;
|
||||||
|
bool is_running = false;
|
||||||
|
};
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <renderd7/BitmapPrinter.hpp>
|
|
||||||
#include <renderd7/Color.hpp>
|
|
||||||
#include <renderd7/Image.hpp>
|
|
||||||
#include <renderd7/Ovl.hpp>
|
|
||||||
#include <renderd7/Screen.hpp>
|
|
||||||
|
|
||||||
namespace RenderD7 {
|
|
||||||
class Toast : public RenderD7::Ovl {
|
|
||||||
public:
|
|
||||||
Toast(std::string head, std::string msg);
|
|
||||||
void Draw(void) const override;
|
|
||||||
void Logic() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
RenderD7::BitmapPrinter toast = RenderD7::BitmapPrinter(400, 70);
|
|
||||||
RenderD7::Image *toastrendered;
|
|
||||||
std::string head, msg;
|
|
||||||
int msgposy = 240;
|
|
||||||
int delay = 0;
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
49
include/renderd7/UI7.hpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <renderd7/R7Vec.hpp>
|
||||||
|
#include <renderd7/DrawV2.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// UI7: The new RenderD7 UI Standart based on
|
||||||
|
// Draw2 (based on Citro2D)
|
||||||
|
|
||||||
|
#define UI7MAKEFLAG(x) (1 << x)
|
||||||
|
|
||||||
|
typedef int UI7MenuFlags;
|
||||||
|
|
||||||
|
enum UI7MenuFlags_ {
|
||||||
|
UI7MenuFlags_None = 0,
|
||||||
|
UI7MenuFlags_NoTitlebar = UI7MAKEFLAG(0),
|
||||||
|
UI7MenuFlags_TitleMid = UI7MAKEFLAG(1),
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace UI7 {
|
||||||
|
// Key functions
|
||||||
|
void Init();
|
||||||
|
void Deinit();
|
||||||
|
void Update();
|
||||||
|
float GetTime();
|
||||||
|
float GetDeltaTime();
|
||||||
|
|
||||||
|
bool Button(const std::string &label, R7Vec2 size = R7Vec2(0, 0));
|
||||||
|
void Checkbox(const std::string &label, bool &c);
|
||||||
|
void Label(const std::string &label, RD7TextFlags flags = 0);
|
||||||
|
void Progressbar(float value);
|
||||||
|
/// @brief Draw Image in Menu
|
||||||
|
/// @param img Pointer f.e to RenderD7::Image2
|
||||||
|
void Image(RenderD7::Image* img);
|
||||||
|
void BrowserList(const std::vector<std::string> &entrys, int &selection, RD7TextFlags txtflags = 0,
|
||||||
|
R7Vec2 size = R7Vec2(0, 0), int max_entrys = 13);
|
||||||
|
void InputText(const std::string &label, std::string &text,
|
||||||
|
const std::string &hint = "");
|
||||||
|
bool BeginMenu(const std::string &title, R7Vec2 size = R7Vec2(0, 0),
|
||||||
|
UI7MenuFlags flags = 0);
|
||||||
|
void EndMenu();
|
||||||
|
void Grid(const std::string& name, const R7Vec2 &size, R7Vec2(*display_func)(void*, R7Vec2), void**data_array, size_t num_entrys);
|
||||||
|
R7Vec2 GetCursorPos();
|
||||||
|
void SetCursorPos(R7Vec2 cp);
|
||||||
|
void RestoreCursor();
|
||||||
|
void SameLine();
|
||||||
|
} // namespace UI7
|
@ -1,749 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <vector>
|
|
||||||
using namespace std;
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
|
|
||||||
struct BMPFileHeader {
|
|
||||||
uint16_t file_type{0x4D42}; // File type always BM which is 0x4D42 (stored as
|
|
||||||
// hex uint16_t in little endian)
|
|
||||||
uint32_t file_size{0}; // Size of the file (in bytes)
|
|
||||||
uint16_t reserved1{0}; // Reserved, always 0
|
|
||||||
uint16_t reserved2{0}; // Reserved, always 0
|
|
||||||
uint32_t offset_data{
|
|
||||||
0}; // Start position of pixel data (bytes from the beginning of the file)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BMPInfoHeader {
|
|
||||||
uint32_t size{0}; // Size of this header (in bytes)
|
|
||||||
int32_t width{0}; // width of bitmap in pixels
|
|
||||||
int32_t height{
|
|
||||||
0}; // height of bitmap in pixels
|
|
||||||
// (if positive, bottom-up, with origin in lower left corner)
|
|
||||||
// (if negative, top-down, with origin in upper left corner)
|
|
||||||
uint16_t planes{1}; // No. of planes for the target device, this is always 1
|
|
||||||
uint16_t bit_count{0}; // No. of bits per pixel
|
|
||||||
uint32_t compression{0}; // 0 or 3 - uncompressed. THIS PROGRAM CONSIDERS ONLY
|
|
||||||
// UNCOMPRESSED BMP images
|
|
||||||
uint32_t size_image{0}; // 0 - for uncompressed images
|
|
||||||
int32_t x_pixels_per_meter{0};
|
|
||||||
int32_t y_pixels_per_meter{0};
|
|
||||||
uint32_t colors_used{0}; // No. color indexes in the color table. Use 0 for
|
|
||||||
// the max number of colors allowed by bit_count
|
|
||||||
uint32_t colors_important{0}; // No. of colors used for displaying the bitmap.
|
|
||||||
// If 0 all colors are required
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BMPColorHeader {
|
|
||||||
uint32_t red_mask{0x00ff0000}; // Bit mask for the red channel
|
|
||||||
uint32_t green_mask{0x0000ff00}; // Bit mask for the green channel
|
|
||||||
uint32_t blue_mask{0x000000ff}; // Bit mask for the blue channel
|
|
||||||
uint32_t alpha_mask{0xff000000}; // Bit mask for the alpha channel
|
|
||||||
uint32_t color_space_type{0x73524742}; // Default "sRGB" (0x73524742)
|
|
||||||
uint32_t unused[16]{0}; // Unused data for sRGB color space
|
|
||||||
};
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
struct BMP {
|
|
||||||
BMPFileHeader file_header;
|
|
||||||
BMPInfoHeader bmp_info_header;
|
|
||||||
BMPColorHeader bmp_color_header;
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
|
|
||||||
BMP(const char *fname) { read(fname); }
|
|
||||||
|
|
||||||
int read(const char *fname) {
|
|
||||||
std::ifstream inp{fname, std::ios_base::binary};
|
|
||||||
if (inp) {
|
|
||||||
inp.read((char *)&file_header, sizeof(file_header));
|
|
||||||
if (file_header.file_type != 0x4D42) {
|
|
||||||
|
|
||||||
return 50; // throw std::runtime_error("Error! Unrecognized file
|
|
||||||
// format.");
|
|
||||||
}
|
|
||||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
|
|
||||||
// The BMPColorHeader is used only for transparent images
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
// Check if the file has bit mask color information
|
|
||||||
if (bmp_info_header.size >=
|
|
||||||
(sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
|
||||||
inp.read((char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space
|
|
||||||
// type is sRGB
|
|
||||||
check_color_header(bmp_color_header);
|
|
||||||
} else {
|
|
||||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
|
||||||
// contain bit mask information\n";
|
|
||||||
return 51; // throw std::runtime_error("Error! Unrecognized file
|
|
||||||
// format.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jump to the pixel data location
|
|
||||||
inp.seekg(file_header.offset_data, inp.beg);
|
|
||||||
|
|
||||||
// Adjust the header fields for output.
|
|
||||||
// Some editors will put extra info in the image file, we only save the
|
|
||||||
// headers and the data.
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) +
|
|
||||||
sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
}
|
|
||||||
file_header.file_size = file_header.offset_data;
|
|
||||||
|
|
||||||
if (bmp_info_header.height < 0) {
|
|
||||||
return 52; // throw std::runtime_error("The program can treat only BMP
|
|
||||||
// images with the origin in the bottom left corner!");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.resize(bmp_info_header.width * bmp_info_header.height *
|
|
||||||
bmp_info_header.bit_count / 8);
|
|
||||||
|
|
||||||
// Here we check if we need to take into account row padding
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
inp.read((char *)data.data(), data.size());
|
|
||||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
|
||||||
} else {
|
|
||||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
inp.read((char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
inp.read((char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
file_header.file_size +=
|
|
||||||
static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 53; // throw std::runtime_error("Unable to open the input image
|
|
||||||
// file "+std::string(fname));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int read_mem(std::vector<unsigned char> buffer) {
|
|
||||||
std::stringstream inp;
|
|
||||||
std::copy(buffer.begin(), buffer.end(),
|
|
||||||
std::ostream_iterator<unsigned char>(inp, "\n"));
|
|
||||||
if (inp) {
|
|
||||||
inp.read((char *)&file_header, sizeof(file_header));
|
|
||||||
if (file_header.file_type != 0x4D42) {
|
|
||||||
|
|
||||||
return 50; // throw std::runtime_error("Error! Unrecognized file
|
|
||||||
// format.");
|
|
||||||
}
|
|
||||||
inp.read((char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
|
|
||||||
// The BMPColorHeader is used only for transparent images
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
// Check if the file has bit mask color information
|
|
||||||
if (bmp_info_header.size >=
|
|
||||||
(sizeof(BMPInfoHeader) + sizeof(BMPColorHeader))) {
|
|
||||||
inp.read((char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space
|
|
||||||
// type is sRGB
|
|
||||||
check_color_header(bmp_color_header);
|
|
||||||
} else {
|
|
||||||
// std::cerr << "Error! The file \"" << fname << "\" does not seem to
|
|
||||||
// contain bit mask information\n";
|
|
||||||
return 51; // throw std::runtime_error("Error! Unrecognized file
|
|
||||||
// format.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Jump to the pixel data location
|
|
||||||
inp.seekg(file_header.offset_data, inp.beg);
|
|
||||||
|
|
||||||
// Adjust the header fields for output.
|
|
||||||
// Some editors will put extra info in the image file, we only save the
|
|
||||||
// headers and the data.
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) +
|
|
||||||
sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
}
|
|
||||||
file_header.file_size = file_header.offset_data;
|
|
||||||
|
|
||||||
if (bmp_info_header.height < 0) {
|
|
||||||
return 52; // throw std::runtime_error("The program can treat only BMP
|
|
||||||
// images with the origin in the bottom left corner!");
|
|
||||||
}
|
|
||||||
|
|
||||||
data.resize(bmp_info_header.width * bmp_info_header.height *
|
|
||||||
bmp_info_header.bit_count / 8);
|
|
||||||
|
|
||||||
// Here we check if we need to take into account row padding
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
inp.read((char *)data.data(), data.size());
|
|
||||||
file_header.file_size += static_cast<uint32_t>(data.size());
|
|
||||||
} else {
|
|
||||||
row_stride = bmp_info_header.width * bmp_info_header.bit_count / 8;
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
inp.read((char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
inp.read((char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
file_header.file_size +=
|
|
||||||
static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * static_cast<uint32_t>(padding_row.size());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 53; // throw std::runtime_error("Unable to open the input image
|
|
||||||
// file "+std::string(fname));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BMP(int32_t width, int32_t height, bool has_alpha = true) {
|
|
||||||
if (width <= 0 || height <= 0) {
|
|
||||||
width = 1;
|
|
||||||
height = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bmp_info_header.width = width;
|
|
||||||
bmp_info_header.height = height;
|
|
||||||
if (has_alpha) {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader) + sizeof(BMPColorHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader) +
|
|
||||||
sizeof(BMPColorHeader);
|
|
||||||
|
|
||||||
bmp_info_header.bit_count = 32;
|
|
||||||
bmp_info_header.compression = 3;
|
|
||||||
row_stride = width * 4;
|
|
||||||
data.resize(row_stride * height);
|
|
||||||
file_header.file_size = file_header.offset_data + data.size();
|
|
||||||
} else {
|
|
||||||
bmp_info_header.size = sizeof(BMPInfoHeader);
|
|
||||||
file_header.offset_data = sizeof(BMPFileHeader) + sizeof(BMPInfoHeader);
|
|
||||||
|
|
||||||
bmp_info_header.bit_count = 24;
|
|
||||||
bmp_info_header.compression = 0;
|
|
||||||
row_stride = width * 3;
|
|
||||||
data.resize(row_stride * height);
|
|
||||||
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
file_header.file_size =
|
|
||||||
file_header.offset_data + static_cast<uint32_t>(data.size()) +
|
|
||||||
bmp_info_header.height * (new_stride - row_stride);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned write(const char *fname) {
|
|
||||||
std::ofstream of{fname, std::ios_base::binary};
|
|
||||||
if (of) {
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
write_headers_and_data(of);
|
|
||||||
} else if (bmp_info_header.bit_count == 24) {
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
write_headers_and_data(of);
|
|
||||||
} else {
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
write_headers(of);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
of.write((const char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
of.write((const char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 54; // throw std::runtime_error("The program can treat only 24 or
|
|
||||||
// 32 bits per pixel BMP files");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 55; // throw std::runtime_error("Unable to open the output image
|
|
||||||
// file.");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<unsigned char> DATA() {
|
|
||||||
std::stringstream ss;
|
|
||||||
if (ss) {
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
write_headers_and_datass(ss);
|
|
||||||
} else if (bmp_info_header.bit_count == 24) {
|
|
||||||
if (bmp_info_header.width % 4 == 0) {
|
|
||||||
write_headers_and_datass(ss);
|
|
||||||
} else {
|
|
||||||
uint32_t new_stride = make_stride_aligned(4);
|
|
||||||
std::vector<uint8_t> padding_row(new_stride - row_stride);
|
|
||||||
|
|
||||||
write_headersss(ss);
|
|
||||||
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
ss.write((const char *)(data.data() + row_stride * y), row_stride);
|
|
||||||
ss.write((const char *)padding_row.data(), padding_row.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
std::string test11 = ss.str();
|
|
||||||
std::vector<unsigned char> test12(test11.begin(), test11.end());
|
|
||||||
return test12;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned fill_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
/*if (x + w > (uint32_t)bmp_info_header.width || y + h >
|
|
||||||
(uint32_t)bmp_info_header.height) {
|
|
||||||
//
|
|
||||||
}*/
|
|
||||||
// else{
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fill_region_df(uint32_t x1, uint32_t y1, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A) {
|
|
||||||
|
|
||||||
int x0 = x1;
|
|
||||||
int y0 = this->bmp_info_header.height - y1 - h;
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
if ((x + w < (uint32_t)bmp_info_header.width) ||
|
|
||||||
this->bmp_info_header.height - y - h > 0) {
|
|
||||||
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void manipulate_region(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t A) {
|
|
||||||
int choice, choice2, intensity;
|
|
||||||
cout << "What color do you want to change? " << endl;
|
|
||||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
|
||||||
cin >> choice;
|
|
||||||
cout << "To what color do you want to change it too?" << endl;
|
|
||||||
cout << "Enter 1 for Blue, 2 for Green, 3 for Red " << endl;
|
|
||||||
cin >> choice2;
|
|
||||||
cout << "Enter the intensity of the color. (From 0 to 255) " << endl;
|
|
||||||
cin >> intensity;
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return; // throw std::runtime_error("The region does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
if (choice == 1 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 0] = B;
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 1] = G;
|
|
||||||
// data[channels * (y * bmp_info_header.width + x) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 1 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 1 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make blue thing red
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 0] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 2 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make green thing red
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 1] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 1) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 2) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing green
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = intensity;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = 0;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (choice == 3 && choice2 == 3) {
|
|
||||||
for (uint32_t y = y0; y < y0 + h; ++y) {
|
|
||||||
for (uint32_t x = x0; x < x0 + w; ++x) {
|
|
||||||
cout << channels * (y * bmp_info_header.width + x) << endl;
|
|
||||||
// Make red thing blue
|
|
||||||
if (data[channels * (y * bmp_info_header.width + x) + 2] > 80 &&
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] < 255) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 0] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 1] = 0;
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 2] = intensity;
|
|
||||||
}
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y * bmp_info_header.width + x) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int OrganizeAverageRed() {
|
|
||||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
;
|
|
||||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
|
||||||
float intensity = 0;
|
|
||||||
float sum = 0;
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
|
||||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
|
||||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
|
||||||
// Read red
|
|
||||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
|
||||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
|
||||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
|
||||||
sum = ColorRed[y][x] + sum -
|
|
||||||
((ColorBlue[y][x]) / 2 + (ColorGreen[y][x]) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
intensity = sum / pixels;
|
|
||||||
cout << intensity << endl;
|
|
||||||
return intensity;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OrganizeAverageGreen() {
|
|
||||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
;
|
|
||||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
|
||||||
float intensity = 0;
|
|
||||||
float sum = 0;
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
|
||||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
|
||||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
|
||||||
// Read Green
|
|
||||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
|
||||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
|
||||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
|
||||||
sum = ColorGreen[y][x] + sum -
|
|
||||||
((ColorBlue[y][x]) / 2 + (ColorRed[y][x]) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
intensity = sum / pixels;
|
|
||||||
cout << intensity << endl;
|
|
||||||
return intensity;
|
|
||||||
}
|
|
||||||
|
|
||||||
int OrganizeAverageBlue() {
|
|
||||||
int ColorRed[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
int ColorGreen[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
;
|
|
||||||
int ColorBlue[bmp_info_header.height][bmp_info_header.width];
|
|
||||||
float pixels = bmp_info_header.height * bmp_info_header.width;
|
|
||||||
float intensity = 0;
|
|
||||||
float sum = 0;
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
cout << "The Width of the image is " << bmp_info_header.width << endl;
|
|
||||||
cout << "The height of the image is " << bmp_info_header.height << endl;
|
|
||||||
for (int y = 0; y < bmp_info_header.height; ++y) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; ++x) {
|
|
||||||
// cout << channels*(y*bmp_info_header.width+x) << endl;
|
|
||||||
// Read Blue
|
|
||||||
ColorBlue[y][x] = data[channels * (y * bmp_info_header.width + x) + 0];
|
|
||||||
ColorGreen[y][x] = data[channels * (y * bmp_info_header.width + x) + 1];
|
|
||||||
ColorRed[y][x] = data[channels * (y * bmp_info_header.width + x) + 2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = 0; y < bmp_info_header.height; y++) {
|
|
||||||
for (int x = 0; x < bmp_info_header.width; x++) {
|
|
||||||
sum = ColorBlue[y][x] + sum -
|
|
||||||
((ColorGreen[y][x]) / 2 + (ColorRed[y][x]) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
intensity = sum / pixels;
|
|
||||||
cout << intensity << endl;
|
|
||||||
return intensity;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned set_pixel(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R,
|
|
||||||
uint8_t A) {
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 >= (uint32_t)bmp_info_header.height || x0 < 0 || y0 < 0) {
|
|
||||||
return 59; // throw std::runtime_error("The point is outside the image
|
|
||||||
// boundaries!");
|
|
||||||
}
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_pixel_df(uint32_t x0, uint32_t y0, uint8_t B, uint8_t G, uint8_t R,
|
|
||||||
uint8_t A) {
|
|
||||||
uint32_t y1 = this->bmp_info_header.height - y0;
|
|
||||||
if (x0 >= (uint32_t)bmp_info_header.width ||
|
|
||||||
y1 <= (uint32_t)bmp_info_header.width || x0 < 0 || y0 > 0) {
|
|
||||||
return; // throw std::runtime_error("The point is outside the image
|
|
||||||
// boundaries!");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 0] = B;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 1] = G;
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 2] = R;
|
|
||||||
if (channels == 4) {
|
|
||||||
data[channels * (y0 * bmp_info_header.width + x0) + 3] = A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned draw_rectangle(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A,
|
|
||||||
uint8_t line_w) {
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return 59; // throw std::runtime_error("The rectangle does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_region(x0, y0, w, line_w, B, G, R, A); // top line
|
|
||||||
fill_region(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
|
||||||
fill_region((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)), B,
|
|
||||||
G, R, A); // right line
|
|
||||||
fill_region(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R,
|
|
||||||
A); // left line
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw_rectangle_df(uint32_t x0, uint32_t y0, uint32_t w, uint32_t h,
|
|
||||||
uint8_t B, uint8_t G, uint8_t R, uint8_t A,
|
|
||||||
uint8_t line_w) {
|
|
||||||
if (x0 + w > (uint32_t)bmp_info_header.width ||
|
|
||||||
y0 + h > (uint32_t)bmp_info_header.height) {
|
|
||||||
return; // throw std::runtime_error("The rectangle does not fit in the
|
|
||||||
// image!");
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_region_df(x0, y0, w, line_w, B, G, R, A); // top line
|
|
||||||
fill_region_df(x0, (y0 + h - line_w), w, line_w, B, G, R, A); // bottom line
|
|
||||||
fill_region_df((x0 + w - line_w), (y0 + line_w), line_w, (h - (2 * line_w)),
|
|
||||||
B, G, R, A); // right line
|
|
||||||
fill_region_df(x0, (y0 + line_w), line_w, (h - (2 * line_w)), B, G, R,
|
|
||||||
A); // left line
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint32_t row_stride{0};
|
|
||||||
|
|
||||||
void write_headers(std::ofstream &of) {
|
|
||||||
of.write((const char *)&file_header, sizeof(file_header));
|
|
||||||
of.write((const char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
of.write((const char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headers_and_data(std::ofstream &of) {
|
|
||||||
write_headers(of);
|
|
||||||
of.write((const char *)data.data(), data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headersss(std::stringstream &of) {
|
|
||||||
of.write((const char *)&file_header, sizeof(file_header));
|
|
||||||
of.write((const char *)&bmp_info_header, sizeof(bmp_info_header));
|
|
||||||
if (bmp_info_header.bit_count == 32) {
|
|
||||||
of.write((const char *)&bmp_color_header, sizeof(bmp_color_header));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_headers_and_datass(std::stringstream &of) {
|
|
||||||
write_headersss(of);
|
|
||||||
of.write((const char *)data.data(), data.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add 1 to the row_stride until it is divisible with align_stride
|
|
||||||
uint32_t make_stride_aligned(uint32_t align_stride) {
|
|
||||||
uint32_t new_stride = row_stride;
|
|
||||||
while (new_stride % align_stride != 0) {
|
|
||||||
new_stride++;
|
|
||||||
}
|
|
||||||
return new_stride;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the pixel data is stored as BGRA and if the color space type is
|
|
||||||
// sRGB
|
|
||||||
void check_color_header(BMPColorHeader &bmp_color_header) {
|
|
||||||
BMPColorHeader expected_color_header;
|
|
||||||
if (expected_color_header.red_mask != bmp_color_header.red_mask ||
|
|
||||||
expected_color_header.blue_mask != bmp_color_header.blue_mask ||
|
|
||||||
expected_color_header.green_mask != bmp_color_header.green_mask ||
|
|
||||||
expected_color_header.alpha_mask != bmp_color_header.alpha_mask) {
|
|
||||||
return; // throw std::runtime_error("Unexpected color mask format! The
|
|
||||||
// program expects the pixel data to be in the BGRA format");
|
|
||||||
}
|
|
||||||
if (expected_color_header.color_space_type !=
|
|
||||||
bmp_color_header.color_space_type) {
|
|
||||||
return; // throw std::runtime_error("Unexpected color space type! The
|
|
||||||
// program expects sRGB values");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <renderd7/external/lodepng.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace BitmapConverter {
|
|
||||||
// returns 0 if all went ok, non-0 if error
|
|
||||||
// output image is always given in RGBA (with alpha channel), even if it's a BMP
|
|
||||||
// without alpha channel
|
|
||||||
unsigned decodeBMP(std::vector<unsigned char> &image, unsigned &w, unsigned &h,
|
|
||||||
const std::vector<unsigned char> &bmp);
|
|
||||||
|
|
||||||
std::vector<unsigned char> ConvertFile(std::string filename);
|
|
||||||
|
|
||||||
std::vector<unsigned char> ConvertData(std::vector<unsigned char> data);
|
|
||||||
} // namespace BitmapConverter
|
|
@ -1,187 +0,0 @@
|
|||||||
/*
|
|
||||||
This file was autogenerated by raw2c.
|
|
||||||
Visit http://www.devkitpro.org
|
|
||||||
*/
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
#ifndef _debugfont_h_
|
|
||||||
#define _debugfont_h_
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
static const unsigned char debugfont[] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81,
|
|
||||||
0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e,
|
|
||||||
0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, 0x10, 0x38, 0x7c, 0xfe,
|
|
||||||
0x7c, 0x38, 0x10, 0x00, 0x3c, 0x3c, 0x18, 0xff, 0xe7, 0x18, 0x3c, 0x00,
|
|
||||||
0x10, 0x38, 0x7c, 0xfe, 0xee, 0x10, 0x38, 0x00, 0x00, 0x00, 0x18, 0x3c,
|
|
||||||
0x3c, 0x18, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
|
|
||||||
0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3, 0x99, 0xbd,
|
|
||||||
0xbd, 0x99, 0xc3, 0xff, 0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78,
|
|
||||||
0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0x08, 0x0c, 0x0a, 0x0a,
|
|
||||||
0x08, 0x78, 0xf0, 0x00, 0x18, 0x14, 0x1a, 0x16, 0x72, 0xe2, 0x0e, 0x1c,
|
|
||||||
0x10, 0x54, 0x38, 0xee, 0x38, 0x54, 0x10, 0x00, 0x80, 0xe0, 0xf8, 0xfe,
|
|
||||||
0xf8, 0xe0, 0x80, 0x00, 0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00,
|
|
||||||
0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66,
|
|
||||||
0x66, 0x00, 0x66, 0x00, 0x7f, 0xdb, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x00,
|
|
||||||
0x1c, 0x22, 0x38, 0x44, 0x44, 0x38, 0x88, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x5a, 0x18, 0x5a, 0x3c, 0x18, 0x7e,
|
|
||||||
0x18, 0x3c, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0x5a, 0x3c, 0x18, 0x00, 0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00,
|
|
||||||
0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0,
|
|
||||||
0xc0, 0xfe, 0x00, 0x00, 0x00, 0x24, 0x42, 0xff, 0x42, 0x24, 0x00, 0x00,
|
|
||||||
0x00, 0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x7c,
|
|
||||||
0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, 0x6c, 0x24, 0x24, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
|
|
||||||
0x10, 0x7c, 0xd0, 0x7c, 0x16, 0xfc, 0x10, 0x00, 0x00, 0x66, 0xac, 0xd8,
|
|
||||||
0x36, 0x6a, 0xcc, 0x00, 0x38, 0x4c, 0x38, 0x78, 0xce, 0xcc, 0x7a, 0x00,
|
|
||||||
0x30, 0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, 0x60,
|
|
||||||
0x60, 0x30, 0x18, 0x00, 0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00,
|
|
||||||
0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x30, 0x30, 0xfc,
|
|
||||||
0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20,
|
|
||||||
0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x30, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x00,
|
|
||||||
0x7c, 0xce, 0xde, 0xf6, 0xe6, 0xe6, 0x7c, 0x00, 0x18, 0x38, 0x78, 0x18,
|
|
||||||
0x18, 0x18, 0x7e, 0x00, 0x7c, 0xc6, 0x06, 0x1c, 0x70, 0xc6, 0xfe, 0x00,
|
|
||||||
0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00, 0x1c, 0x3c, 0x6c, 0xcc,
|
|
||||||
0xfe, 0x0c, 0x1e, 0x00, 0xfe, 0xc0, 0xfc, 0x06, 0x06, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00, 0xfe, 0xc6, 0x0c, 0x18,
|
|
||||||
0x30, 0x30, 0x30, 0x00, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x30, 0x00, 0x00,
|
|
||||||
0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x10, 0x20,
|
|
||||||
0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00,
|
|
||||||
0x00, 0x7e, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00,
|
|
||||||
0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00, 0x7c, 0x82, 0x9e, 0xa6,
|
|
||||||
0x9e, 0x80, 0x7c, 0x00, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00,
|
|
||||||
0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00, 0x7c, 0xc6, 0xc0, 0xc0,
|
|
||||||
0xc0, 0xc6, 0x7c, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00,
|
|
||||||
0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00, 0xfe, 0x62, 0x68, 0x78,
|
|
||||||
0x68, 0x60, 0xf0, 0x00, 0x7c, 0xc6, 0xc6, 0xc0, 0xce, 0xc6, 0x7e, 0x00,
|
|
||||||
0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x3c, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x3c, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00,
|
|
||||||
0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00, 0xf0, 0x60, 0x60, 0x60,
|
|
||||||
0x62, 0x66, 0xfe, 0x00, 0x82, 0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
|
|
||||||
0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00, 0x7c, 0xc6, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x06, 0xfc, 0x66, 0x66, 0x7c,
|
|
||||||
0x66, 0x66, 0xe6, 0x00, 0x7c, 0xc6, 0xc0, 0x7c, 0x06, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7e, 0x5a, 0x5a, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x10, 0x00,
|
|
||||||
0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x82, 0x00, 0xc6, 0x6c, 0x38, 0x38,
|
|
||||||
0x38, 0x6c, 0xc6, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00, 0x78, 0x60, 0x60, 0x60,
|
|
||||||
0x60, 0x60, 0x78, 0x00, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00,
|
|
||||||
0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00, 0x10, 0x38, 0x6c, 0xc6,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
|
||||||
0x30, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc6, 0x7c, 0x00, 0x1c, 0x0c, 0x0c, 0x7c,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
|
||||||
0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x76, 0xcc,
|
|
||||||
0xcc, 0x7c, 0x0c, 0x78, 0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00,
|
|
||||||
0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x0c, 0x00, 0x1c,
|
|
||||||
0x0c, 0x0c, 0xcc, 0x78, 0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00,
|
|
||||||
0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0xcc, 0xfe,
|
|
||||||
0xd6, 0xd6, 0xd6, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0xdc, 0x66,
|
|
||||||
0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x7c, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e,
|
|
||||||
0x00, 0x00, 0xde, 0x76, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0xc0,
|
|
||||||
0x7c, 0x06, 0x7c, 0x00, 0x10, 0x30, 0xfc, 0x30, 0x30, 0x34, 0x18, 0x00,
|
|
||||||
0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0xc6, 0xc6,
|
|
||||||
0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0xc6, 0xd6, 0xd6, 0xfe, 0x6c, 0x00,
|
|
||||||
0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0xcc, 0xcc,
|
|
||||||
0xcc, 0x7c, 0x0c, 0xf8, 0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00,
|
|
||||||
0x0e, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0e, 0x00, 0x18, 0x18, 0x18, 0x00,
|
|
||||||
0x18, 0x18, 0x18, 0x00, 0xe0, 0x30, 0x30, 0x18, 0x30, 0x30, 0xe0, 0x00,
|
|
||||||
0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c,
|
|
||||||
0xc6, 0xc6, 0xfe, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x70,
|
|
||||||
0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x0e, 0x10, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc0, 0x7c, 0x00, 0x7c, 0x82, 0x38, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
|
||||||
0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00,
|
|
||||||
0x00, 0x00, 0x7c, 0xc0, 0xc0, 0x7c, 0x18, 0x70, 0x7c, 0x82, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc0, 0x7c, 0x00, 0xc6, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00,
|
|
||||||
0xe0, 0x10, 0x7c, 0xc6, 0xfe, 0xc0, 0x7c, 0x00, 0x66, 0x00, 0x38, 0x18,
|
|
||||||
0x18, 0x18, 0x3c, 0x00, 0x7c, 0x82, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0xe0, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00, 0xc6, 0x00, 0x7c, 0xc6,
|
|
||||||
0xfe, 0xc6, 0xc6, 0x00, 0x38, 0x38, 0x7c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00,
|
|
||||||
0x0e, 0x10, 0xfe, 0x60, 0x78, 0x60, 0xfe, 0x00, 0x00, 0x00, 0x7c, 0x12,
|
|
||||||
0x7e, 0xd0, 0x7e, 0x00, 0x7e, 0xc8, 0xc8, 0xfe, 0xc8, 0xc8, 0xce, 0x00,
|
|
||||||
0x7c, 0x82, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0x00, 0x7c, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0xe0, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0x82, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0xe0, 0x10, 0xcc, 0xcc,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8,
|
|
||||||
0xc6, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0xc6, 0x00, 0xc6, 0xc6,
|
|
||||||
0xc6, 0xc6, 0x7c, 0x00, 0x18, 0x7c, 0xd6, 0xd0, 0xd6, 0x7c, 0x18, 0x00,
|
|
||||||
0x38, 0x6c, 0x60, 0xf0, 0x60, 0xf2, 0xdc, 0x00, 0x66, 0x3c, 0x18, 0x7e,
|
|
||||||
0x18, 0x7e, 0x18, 0x00, 0xf8, 0xcc, 0xf8, 0xc4, 0xcc, 0xde, 0xcc, 0x06,
|
|
||||||
0x0e, 0x1b, 0x18, 0x3c, 0x18, 0x18, 0xd8, 0x70, 0x0e, 0x10, 0x78, 0x0c,
|
|
||||||
0x7c, 0xcc, 0x76, 0x00, 0x0e, 0x10, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
|
|
||||||
0x0e, 0x10, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x0e, 0x10, 0xcc, 0xcc,
|
|
||||||
0xcc, 0xcc, 0x76, 0x00, 0x66, 0x98, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x00,
|
|
||||||
0x66, 0x98, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0x00, 0x38, 0x0c, 0x3c, 0x34,
|
|
||||||
0x00, 0x7e, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00,
|
|
||||||
0x30, 0x00, 0x30, 0x60, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0xfc,
|
|
||||||
0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00,
|
|
||||||
0xc0, 0xc8, 0xd0, 0xfe, 0x46, 0x8c, 0x1e, 0x00, 0xc0, 0xc8, 0xd0, 0xec,
|
|
||||||
0x5c, 0xbe, 0x0c, 0x00, 0x18, 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x18, 0x00,
|
|
||||||
0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36,
|
|
||||||
0x6c, 0xd8, 0x00, 0x00, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
|
|
||||||
0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xdb, 0x77, 0xdb, 0xee,
|
|
||||||
0xdb, 0x77, 0xdb, 0xee, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18,
|
|
||||||
0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x36, 0x36, 0x36,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xfe, 0x36, 0x36, 0x36, 0x00, 0x00, 0xf8, 0x18,
|
|
||||||
0xf8, 0x18, 0x18, 0x18, 0x36, 0x36, 0xf6, 0x06, 0xf6, 0x36, 0x36, 0x36,
|
|
||||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0xfe, 0x06,
|
|
||||||
0xf6, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf6, 0x06, 0xfe, 0x00, 0x00, 0x00,
|
|
||||||
0x36, 0x36, 0x36, 0x36, 0xfe, 0x00, 0x00, 0x00, 0x18, 0x18, 0xf8, 0x18,
|
|
||||||
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x18, 0x18, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3f, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x3f, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0xf7, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
|
||||||
0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x00, 0x00, 0xff, 0x00,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0xf7, 0x00, 0xf7, 0x36, 0x36, 0x36,
|
|
||||||
0x18, 0x18, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x18, 0x18, 0x18,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0xff, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
|
||||||
0x3f, 0x00, 0x00, 0x00, 0x18, 0x18, 0x1f, 0x18, 0x1f, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x1f, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x3f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xff, 0x36, 0x36, 0x36,
|
|
||||||
0x18, 0x18, 0xff, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
|
||||||
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
|
|
||||||
0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0xcc, 0xc8, 0xdc, 0x76, 0x00,
|
|
||||||
0x78, 0xcc, 0xd8, 0xcc, 0xc6, 0xc6, 0xdc, 0x40, 0xfe, 0x62, 0x60, 0x60,
|
|
||||||
0x60, 0x60, 0xf0, 0x00, 0x00, 0x02, 0x7e, 0xec, 0x6c, 0x6c, 0x48, 0x00,
|
|
||||||
0xfe, 0x62, 0x30, 0x18, 0x30, 0x62, 0xfe, 0x00, 0x00, 0x00, 0x7e, 0xd0,
|
|
||||||
0xc8, 0xc8, 0x70, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xf8, 0x80,
|
|
||||||
0x00, 0x00, 0x7e, 0xd8, 0x18, 0x18, 0x10, 0x00, 0x38, 0x10, 0x7c, 0xd6,
|
|
||||||
0xd6, 0x7c, 0x10, 0x38, 0x7c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x7c, 0x00,
|
|
||||||
0x7c, 0xc6, 0xc6, 0xc6, 0x6c, 0x28, 0xee, 0x00, 0x3c, 0x22, 0x18, 0x7c,
|
|
||||||
0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x66, 0x99, 0x99, 0x66, 0x00, 0x00,
|
|
||||||
0x00, 0x06, 0x7c, 0x9e, 0xf2, 0x7c, 0xc0, 0x00, 0x00, 0x00, 0x7c, 0xc0,
|
|
||||||
0xf8, 0xc0, 0x7c, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00,
|
|
||||||
0x00, 0xfe, 0x00, 0xfe, 0x00, 0xfe, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18,
|
|
||||||
0x18, 0x00, 0x7e, 0x00, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0x00,
|
|
||||||
0x18, 0x30, 0x60, 0x30, 0x18, 0x00, 0x7c, 0x00, 0x0e, 0x1b, 0x1b, 0x18,
|
|
||||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xd8, 0xd8, 0x70,
|
|
||||||
0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00,
|
|
||||||
0x76, 0xdc, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x18, 0x00, 0x00, 0x00, 0x0f, 0x0c, 0x0c, 0x0c, 0xec, 0x6c, 0x3c, 0x00,
|
|
||||||
0xd8, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30, 0xc0, 0xf0,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
|
|
||||||
};
|
|
||||||
const int debugfont_size = sizeof(debugfont);
|
|
||||||
//---------------------------------------------------------------------------------
|
|
||||||
#endif //_font_h_
|
|
||||||
//---------------------------------------------------------------------------------
|
|
12532
include/renderd7/external/dr_flac.h
vendored
Normal file
8668
include/renderd7/external/dr_wav.h
vendored
Normal file
29
include/renderd7/external/fs.h
vendored
@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <3ds.h>
|
|
||||||
|
|
||||||
extern FS_Archive archive, sdmc_archive, nand_archive;
|
|
||||||
|
|
||||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID id);
|
|
||||||
Result FS_CloseArchive(FS_Archive archive);
|
|
||||||
Result FS_OpenDir(Handle *handle, FS_Archive archive, const char *path);
|
|
||||||
Result FS_OpenFile(Handle *handle, FS_Archive archive, const char *path, u32 flags, u32 attributes);
|
|
||||||
Result FS_MakeDir(FS_Archive archive, const char *path);
|
|
||||||
Result FS_CreateFile(FS_Archive archive, const char *path, u64 size);
|
|
||||||
Result FS_RecursiveMakeDir(FS_Archive archive, const char *path);
|
|
||||||
bool FS_FileExists(FS_Archive archive, const char *path);
|
|
||||||
bool FS_DirExists(FS_Archive archive, const char *path);
|
|
||||||
Result FS_GetFileSize(FS_Archive archive, const char *path, u64 *size);
|
|
||||||
u64 FS_GetFreeStorage(FS_SystemMediaType media_type);
|
|
||||||
u64 FS_GetTotalStorage(FS_SystemMediaType media_type);
|
|
||||||
u64 FS_GetUsedStorage(FS_SystemMediaType media_type);
|
|
||||||
Result FS_RemoveFile(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RemoveDir(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RemoveDirRecursive(FS_Archive archive, const char *path);
|
|
||||||
Result FS_RenameFile(FS_Archive archive, const char *old_filename, const char *new_filename);
|
|
||||||
Result FS_RenameDir(FS_Archive archive, const char *old_dirname, const char *new_dirname);
|
|
||||||
Result FS_Read(FS_Archive archive, const char *path, u64 size, void *buf);
|
|
||||||
Result FS_Write(FS_Archive archive, const char *path, const void *buf, u32 size);
|
|
||||||
char *FS_GetFileTimestamp(const char *path);
|
|
||||||
Result makeDirs(const char * path);
|
|
||||||
Result openFile(Handle* fileHandle, const char * path, bool write);
|
|
50894
include/renderd7/external/json.hpp
vendored
250
include/renderd7/external/libnsbmp/libnsbmp.h
vendored
@ -1,250 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2006 Richard Wilson <richard.wilson@netsurf-browser.org>
|
|
||||||
* Copyright 2008 Sean Fox <dyntryx@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of NetSurf's libnsbmp, http://www.netsurf-browser.org/
|
|
||||||
* Licenced under the MIT License,
|
|
||||||
* http://www.opensource.org/licenses/mit-license.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file
|
|
||||||
* Bitmap file decoding interface.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef libnsbmp_h_
|
|
||||||
#define libnsbmp_h_
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* bmp flags */
|
|
||||||
#define BMP_NEW 0
|
|
||||||
/** image is opaque (as opposed to having an alpha mask) */
|
|
||||||
#define BMP_OPAQUE (1 << 0)
|
|
||||||
/** memory should be wiped */
|
|
||||||
#define BMP_CLEAR_MEMORY (1 << 1)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* error return values
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
BMP_OK = 0,
|
|
||||||
BMP_INSUFFICIENT_MEMORY = 1,
|
|
||||||
BMP_INSUFFICIENT_DATA = 2,
|
|
||||||
BMP_DATA_ERROR = 3
|
|
||||||
} bmp_result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* encoding types
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
BMP_ENCODING_RGB = 0,
|
|
||||||
BMP_ENCODING_RLE8 = 1,
|
|
||||||
BMP_ENCODING_RLE4 = 2,
|
|
||||||
BMP_ENCODING_BITFIELDS = 3
|
|
||||||
} bmp_encoding;
|
|
||||||
|
|
||||||
/* API for Bitmap callbacks */
|
|
||||||
typedef void* (*bmp_bitmap_cb_create)(int width, int height, unsigned int state);
|
|
||||||
typedef void (*bmp_bitmap_cb_destroy)(void *bitmap);
|
|
||||||
typedef unsigned char* (*bmp_bitmap_cb_get_buffer)(void *bitmap);
|
|
||||||
typedef size_t (*bmp_bitmap_cb_get_bpp)(void *bitmap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Bitmap callbacks function table
|
|
||||||
*/
|
|
||||||
typedef struct bmp_bitmap_callback_vt_s {
|
|
||||||
/** Callback to allocate bitmap storage. */
|
|
||||||
bmp_bitmap_cb_create bitmap_create;
|
|
||||||
/** Called to free bitmap storage. */
|
|
||||||
bmp_bitmap_cb_destroy bitmap_destroy;
|
|
||||||
/** Return a pointer to the pixel data in a bitmap. */
|
|
||||||
bmp_bitmap_cb_get_buffer bitmap_get_buffer;
|
|
||||||
/** Find the width of a pixel row in bytes. */
|
|
||||||
bmp_bitmap_cb_get_bpp bitmap_get_bpp;
|
|
||||||
} bmp_bitmap_callback_vt;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bitmap image
|
|
||||||
*/
|
|
||||||
typedef struct bmp_image {
|
|
||||||
/** callbacks for bitmap functions */
|
|
||||||
bmp_bitmap_callback_vt bitmap_callbacks;
|
|
||||||
/** pointer to BMP data */
|
|
||||||
uint8_t *bmp_data;
|
|
||||||
/** width of BMP (valid after _analyse) */
|
|
||||||
uint32_t width;
|
|
||||||
/** heigth of BMP (valid after _analyse) */
|
|
||||||
uint32_t height;
|
|
||||||
/** whether the image has been decoded */
|
|
||||||
bool decoded;
|
|
||||||
/** decoded image */
|
|
||||||
void *bitmap;
|
|
||||||
|
|
||||||
/* Internal members are listed below */
|
|
||||||
/** total number of bytes of BMP data available */
|
|
||||||
uint32_t buffer_size;
|
|
||||||
/** pixel encoding type */
|
|
||||||
bmp_encoding encoding;
|
|
||||||
/** offset of bitmap data */
|
|
||||||
uint32_t bitmap_offset;
|
|
||||||
/** bits per pixel */
|
|
||||||
uint16_t bpp;
|
|
||||||
/** number of colours */
|
|
||||||
uint32_t colours;
|
|
||||||
/** colour table */
|
|
||||||
uint32_t *colour_table;
|
|
||||||
/** whether to use bmp's limited transparency */
|
|
||||||
bool limited_trans;
|
|
||||||
/** colour to display for "transparent" pixels when using limited
|
|
||||||
* transparency
|
|
||||||
*/
|
|
||||||
uint32_t trans_colour;
|
|
||||||
/** scanlines are top to bottom */
|
|
||||||
bool reversed;
|
|
||||||
/** image is part of an ICO, mask follows */
|
|
||||||
bool ico;
|
|
||||||
/** true if the bitmap does not contain an alpha channel */
|
|
||||||
bool opaque;
|
|
||||||
/** four bitwise mask */
|
|
||||||
uint32_t mask[4];
|
|
||||||
/** four bitwise shifts */
|
|
||||||
int32_t shift[4];
|
|
||||||
/** colour representing "transparency" in the bitmap */
|
|
||||||
uint32_t transparent_index;
|
|
||||||
} bmp_image;
|
|
||||||
|
|
||||||
typedef struct ico_image {
|
|
||||||
bmp_image bmp;
|
|
||||||
struct ico_image *next;
|
|
||||||
} ico_image;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* icon image collection
|
|
||||||
*/
|
|
||||||
typedef struct ico_collection {
|
|
||||||
/** callbacks for bitmap functions */
|
|
||||||
bmp_bitmap_callback_vt bitmap_callbacks;
|
|
||||||
/** width of largest BMP */
|
|
||||||
uint16_t width;
|
|
||||||
/** heigth of largest BMP */
|
|
||||||
uint16_t height;
|
|
||||||
|
|
||||||
/* Internal members are listed below */
|
|
||||||
/** pointer to ICO data */
|
|
||||||
uint8_t *ico_data;
|
|
||||||
/** total number of bytes of ICO data available */
|
|
||||||
uint32_t buffer_size;
|
|
||||||
/** root of linked list of images */
|
|
||||||
ico_image *first;
|
|
||||||
} ico_collection;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialises bitmap ready for analysing the bitmap.
|
|
||||||
*
|
|
||||||
* \param bmp The Bitmap to initialise
|
|
||||||
* \param callbacks The callbacks the library will call on operations.
|
|
||||||
* \return BMP_OK on success or appropriate error code.
|
|
||||||
*/
|
|
||||||
bmp_result bmp_create(bmp_image *bmp, bmp_bitmap_callback_vt *callbacks);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialises icon ready for analysing the icon
|
|
||||||
*
|
|
||||||
* \param bmp The Bitmap to initialise
|
|
||||||
* \param callbacks The callbacks the library will call on operations.
|
|
||||||
* \return BMP_OK on success or appropriate error code.
|
|
||||||
*/
|
|
||||||
bmp_result ico_collection_create(ico_collection *ico,
|
|
||||||
bmp_bitmap_callback_vt *callbacks);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Analyse a BMP prior to decoding.
|
|
||||||
*
|
|
||||||
* This will scan the data provided and perform checks to ensure the data is a
|
|
||||||
* valid BMP and prepare the bitmap image structure ready for decode.
|
|
||||||
*
|
|
||||||
* This function must be called and resturn BMP_OK before bmp_decode() as it
|
|
||||||
* prepares the bmp internal state for the decode process.
|
|
||||||
*
|
|
||||||
* \param bmp the BMP image to analyse.
|
|
||||||
* \param size The size of data in cdata.
|
|
||||||
* \param data The bitmap source data.
|
|
||||||
* \return BMP_OK on success or error code on faliure.
|
|
||||||
*/
|
|
||||||
bmp_result bmp_analyse(bmp_image *bmp, size_t size, uint8_t *data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Analyse an ICO prior to decoding.
|
|
||||||
*
|
|
||||||
* This function will scan the data provided and perform checks to ensure the
|
|
||||||
* data is a valid ICO.
|
|
||||||
*
|
|
||||||
* This function must be called before ico_find().
|
|
||||||
*
|
|
||||||
* \param ico the ICO image to analyse
|
|
||||||
* \param size The size of data in cdata.
|
|
||||||
* \param data The bitmap source data.
|
|
||||||
* \return BMP_OK on success
|
|
||||||
*/
|
|
||||||
bmp_result ico_analyse(ico_collection *ico, size_t size, uint8_t *data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode a BMP
|
|
||||||
*
|
|
||||||
* This function decodes the BMP data such that bmp->bitmap is a valid
|
|
||||||
* image. The state of bmp->decoded is set to TRUE on exit such that it
|
|
||||||
* can easily be identified which BMPs are in a fully decoded state.
|
|
||||||
*
|
|
||||||
* \param bmp the BMP image to decode
|
|
||||||
* \return BMP_OK on success
|
|
||||||
*/
|
|
||||||
bmp_result bmp_decode(bmp_image *bmp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode a BMP using "limited transparency"
|
|
||||||
*
|
|
||||||
* Bitmaps do not have native transparency support. However, there is a
|
|
||||||
* "trick" that is used in some instances in which the first pixel of the
|
|
||||||
* bitmap becomes the "transparency index". The decoding application can
|
|
||||||
* replace this index with whatever background colour it chooses to
|
|
||||||
* create the illusion of transparency.
|
|
||||||
*
|
|
||||||
* When to use transparency is at the discretion of the decoding
|
|
||||||
* application.
|
|
||||||
*
|
|
||||||
* \param bmp the BMP image to decode
|
|
||||||
* \param colour the colour to use as "transparent"
|
|
||||||
* \return BMP_OK on success
|
|
||||||
*/
|
|
||||||
bmp_result bmp_decode_trans(bmp_image *bmp, uint32_t transparent_colour);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the closest BMP within an ICO collection
|
|
||||||
*
|
|
||||||
* This function finds the BMP with dimensions as close to a specified set
|
|
||||||
* as possible from the images in the collection.
|
|
||||||
*
|
|
||||||
* \param ico the ICO collection to examine
|
|
||||||
* \param width the preferred width (0 to use ICO header width)
|
|
||||||
* \param height the preferred height (0 to use ICO header height)
|
|
||||||
*/
|
|
||||||
bmp_image *ico_find(ico_collection *ico, uint16_t width, uint16_t height);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalise a BMP prior to destruction.
|
|
||||||
*
|
|
||||||
* \param bmp the BMP image to finalise.
|
|
||||||
*/
|
|
||||||
void bmp_finalise(bmp_image *bmp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalise an ICO prior to destruction.
|
|
||||||
*
|
|
||||||
* \param ico the ICO image to finalise,
|
|
||||||
*/
|
|
||||||
void ico_finalise(ico_collection *ico);
|
|
||||||
|
|
||||||
#endif
|
|
27
include/renderd7/external/libnsbmp/log.h
vendored
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
||||||
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
|
|
||||||
*
|
|
||||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
||||||
* Licenced under the MIT License,
|
|
||||||
* http://www.opensource.org/licenses/mit-license.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef _LIBNSBMP_LOG_H_
|
|
||||||
#define _LIBNSBMP_LOG_H_
|
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
# define LOG(x) ((void) 0)
|
|
||||||
#else
|
|
||||||
# ifdef __GNUC__
|
|
||||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
|
||||||
# elif defined(__CC_NORCROFT)
|
|
||||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
|
||||||
# else
|
|
||||||
# define LOG(x) do { printf x, fputc('\n', stdout)); } while (0)
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
4091
include/renderd7/external/lodepng.h
vendored
16578
include/renderd7/external/stb_image.h
vendored
3778
include/renderd7/external/stb_image_write.h
vendored
10713
include/renderd7/external/stb_truetype.h
vendored
28
include/renderd7/global_db.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
|
|
||||||
|
// Outdated HidApi (HidV2Patched)
|
||||||
|
extern u32 d7_hDown;
|
||||||
|
extern u32 d7_hHeld;
|
||||||
|
extern u32 d7_hUp;
|
||||||
|
extern u32 d7_hRepeat; // Inofficial lol
|
||||||
|
extern touchPosition d7_touch;
|
||||||
|
|
||||||
|
// Outdated Screens
|
||||||
|
extern C3D_RenderTarget *Top;
|
||||||
|
extern C3D_RenderTarget *TopRight;
|
||||||
|
extern C3D_RenderTarget *Bottom;
|
||||||
|
|
||||||
|
// Modern Global Api
|
||||||
|
extern int rd7_max_objects;
|
||||||
|
extern bool rd7_do_splash;
|
||||||
|
extern bool rd7_enable_scene_system;
|
||||||
|
extern bool rd7_debugging;
|
||||||
|
extern C3D_RenderTarget *rd7_top;
|
||||||
|
extern C3D_RenderTarget *rd7_top_right;
|
||||||
|
extern C3D_RenderTarget *rd7_bottom;
|
||||||
|
|
||||||
|
// Draw2
|
||||||
|
extern float rd7_draw2_tsm;
|
55
include/renderd7/internal_db.hpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <renderd7/renderd7.hpp>
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
|
#include <renderd7/global_db.hpp>
|
||||||
|
|
||||||
|
#define CFGVER "0"
|
||||||
|
|
||||||
|
#ifndef V_RD7BTIME
|
||||||
|
#define V_RD7BTIME "SUBMODULE"
|
||||||
|
#endif
|
||||||
|
#ifndef V_RD7CSTRING
|
||||||
|
#define V_RD7CSTRING "SUBMODULE"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// Base ///
|
||||||
|
extern std::string rd7i_app_name;
|
||||||
|
extern std::string rd7i_config_path;
|
||||||
|
extern nlohmann::json rd7i_config;
|
||||||
|
extern u8 rd7i_console_model;
|
||||||
|
extern u8 rd7i_system_region;
|
||||||
|
extern bool rd7i_is_citra;
|
||||||
|
extern bool rd7i_settings;
|
||||||
|
extern R7Vec2 rd7i_hid_touch_pos;
|
||||||
|
extern C2D_TextBuf rd7i_text_buffer;
|
||||||
|
extern C2D_TextBuf rd7i_d2_dimbuf;
|
||||||
|
extern C2D_Font rd7i_base_font;
|
||||||
|
extern bool rd7i_is_ndsp;
|
||||||
|
extern bool rd7i_running;
|
||||||
|
extern std::unique_ptr<RenderD7::Scene> rd7i_fade_scene;
|
||||||
|
extern std::vector<std::unique_ptr<RenderD7::Ovl>> rd7i_overlays;
|
||||||
|
extern unsigned int rd7i_frames;
|
||||||
|
extern u64 rd7i_last_time;
|
||||||
|
extern float rd7i_framerate;
|
||||||
|
extern u32 rd7i_mt_color;
|
||||||
|
extern u32 rd7i_mt_txtcolor;
|
||||||
|
extern bool rd7i_mt_screen;
|
||||||
|
extern float rd7i_mt_txtSize;
|
||||||
|
extern bool rd7i_metrikd;
|
||||||
|
extern bool rd7i_ftraced;
|
||||||
|
extern bool rd7i_current_screen;
|
||||||
|
extern u64 rd7i_delta_time;
|
||||||
|
extern u64 rd7i_last_tm;
|
||||||
|
extern float rd7i_dtm;
|
||||||
|
extern float rd7i_time;
|
||||||
|
extern bool rd7i_fadeout;
|
||||||
|
extern bool rd7i_fadein;
|
||||||
|
extern bool rd7i_fadeout2;
|
||||||
|
extern bool rd7i_fadein2;
|
||||||
|
extern int rd7i_fadealpha;
|
||||||
|
extern int rd7i_fadecolor;
|
||||||
|
extern bool rd7i_wait_fade;
|
||||||
|
extern bool rd7i_fade_exit;
|
||||||
|
extern bool rd7i_fade_scene_wait;
|
||||||
|
extern bool rd7i_idb_running;
|
||||||
|
extern bool rd7i_graphics_on;
|
@ -1,15 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <renderd7/external/json.hpp>
|
// clang-format off
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <renderd7/external/json.hpp>
|
||||||
/// RenderD7::Lang
|
// clang-format on
|
||||||
namespace RenderD7::Lang {
|
|
||||||
/// Get the 3ds System Language
|
namespace RenderD7 {
|
||||||
std::string getSys();
|
namespace Lang {
|
||||||
/// Get a translated string
|
/// @brief Get 3ds System lang! [en] by default
|
||||||
/// \param key The Key so the code can find your string
|
/// @return Sytemlang as string
|
||||||
std::string get(const std::string &key);
|
std::string getSys();
|
||||||
/// Load the lang file from dir structure en/app.json for sample
|
/// @brief Get The Translation String
|
||||||
/// \param lang the folder name en, fr, de ... . I prefer geSys()
|
/// @param key Key of Translation
|
||||||
void load(const std::string &lang);
|
/// @return The Translated String
|
||||||
} // namespace RenderD7::Lang
|
std::string get(const std::string &key);
|
||||||
|
/// @brief Load A Language json
|
||||||
|
/// @param lang The Language Key [en], [de], etc, or getSys()
|
||||||
|
void load(const std::string &lang);
|
||||||
|
} // namespace Lang
|
||||||
|
} // namespace RenderD7
|
||||||
|
@ -5,23 +5,26 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
/** Log Class */
|
/// @brief Log Class
|
||||||
class Log {
|
class Log {
|
||||||
public:
|
public:
|
||||||
/** Construct */
|
/// @brief Constructor
|
||||||
Log();
|
Log();
|
||||||
/** Deconstruct */
|
/// @brief Deconstructor
|
||||||
~Log();
|
~Log();
|
||||||
/// Init the log file
|
/// @brief Init the Logger
|
||||||
/// \param filename name for the file
|
/// @param filename Filename[_data_time.log]
|
||||||
void Init(const char *filename);
|
void Init(const char *filename);
|
||||||
/// Write Text to logfile
|
/// @brief Write a String to the File
|
||||||
/// \param debug_text your text
|
/// @param debug_text string
|
||||||
void Write(std::string debug_text);
|
void Write(std::string debug_text);
|
||||||
/// Get the date
|
/// @brief Get the Date
|
||||||
|
/// @return Date as string fmt[data_time]
|
||||||
std::string logDate(void);
|
std::string logDate(void);
|
||||||
/// Format to logstyle
|
/// @brief Format a string like sprintf
|
||||||
/// \param fmt_str the formatted style
|
/// @param fmt_str the string wich defines the fmt
|
||||||
|
/// @param ... Additional Data
|
||||||
|
/// @return Formatted String
|
||||||
std::string format(const std::string &fmt_str, ...);
|
std::string format(const std::string &fmt_str, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
28
include/renderd7/music/Mp3.hpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/music/Music.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <mpg123.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class Mp3Decoder : public MusicDecoder {
|
||||||
|
public:
|
||||||
|
Mp3Decoder() {}
|
||||||
|
~Mp3Decoder() {}
|
||||||
|
|
||||||
|
int _init(const std::string& path, MusicMeta& meta) override;
|
||||||
|
unsigned int _getSampleRate() override;
|
||||||
|
unsigned char _getChannels() override;
|
||||||
|
size_t _getBufSize() override;
|
||||||
|
unsigned long long _decode(signed short* buf_addr) override;
|
||||||
|
void _deinit() override;
|
||||||
|
size_t _getFileSamples() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mpg123_handle *hnd = nullptr;
|
||||||
|
size_t buf_size = 0;
|
||||||
|
long rate = 0;
|
||||||
|
int channels = 0;
|
||||||
|
};
|
||||||
|
}
|
90
include/renderd7/music/Music.hpp
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// RenderD7 Music Backend
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class MusicMeta {
|
||||||
|
public:
|
||||||
|
MusicMeta() {
|
||||||
|
ititle = "Unknown";
|
||||||
|
ialbum = "Unknown";
|
||||||
|
iyear = "Unknown";
|
||||||
|
iname = "Unknown";
|
||||||
|
ipath = "Unknown";
|
||||||
|
iartist = "Unknown";
|
||||||
|
imdt = "Unknown";
|
||||||
|
}
|
||||||
|
~MusicMeta() {}
|
||||||
|
std::string name() { return iname; }
|
||||||
|
std::string album() { return ialbum; }
|
||||||
|
std::string year() { return iyear; }
|
||||||
|
std::string title() { return ititle; }
|
||||||
|
std::string path() { return ipath; }
|
||||||
|
std::string artist() { return iartist; }
|
||||||
|
std::string mdt() { return imdt; }
|
||||||
|
|
||||||
|
void name(std::string name) { iname = name; }
|
||||||
|
void album(std::string album) { ialbum = album; }
|
||||||
|
void year(std::string year) { iyear = year; }
|
||||||
|
void title(std::string title) { ititle = title; }
|
||||||
|
void path(std::string path) { ipath = path; }
|
||||||
|
void artist(std::string artist) { iartist = artist; }
|
||||||
|
void mdt(std::string mdt) { imdt = mdt; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string ititle = "";
|
||||||
|
std::string ialbum = "";
|
||||||
|
std::string iyear = "";
|
||||||
|
std::string iname = "";
|
||||||
|
std::string ipath = "";
|
||||||
|
std::string iartist = "";
|
||||||
|
std::string imdt = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
// Template Class for Decoders
|
||||||
|
class MusicDecoder {
|
||||||
|
public:
|
||||||
|
MusicDecoder() = default;
|
||||||
|
virtual ~MusicDecoder() {}
|
||||||
|
|
||||||
|
static void LoadFile(const std::string &path);
|
||||||
|
static void CleanUp();
|
||||||
|
|
||||||
|
static int init(const std::string &path, MusicMeta &meta) {
|
||||||
|
return decoder->_init(path, meta);
|
||||||
|
}
|
||||||
|
static unsigned int getSampleRate() { return decoder->_getSampleRate(); }
|
||||||
|
static unsigned char getChannels() { return decoder->_getChannels(); }
|
||||||
|
static size_t getBufSize() { return decoder->_getBufSize(); }
|
||||||
|
static unsigned long long decode(signed short *buf_addr) {
|
||||||
|
return decoder->_decode(buf_addr);
|
||||||
|
}
|
||||||
|
static void deinit() { decoder->_deinit(); }
|
||||||
|
static size_t getFileSamples() { return decoder->_getFileSamples(); }
|
||||||
|
|
||||||
|
static MusicDecoder *decoder;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int _init(const std::string &path, MusicMeta &meta) = 0;
|
||||||
|
virtual unsigned int _getSampleRate() = 0;
|
||||||
|
virtual unsigned char _getChannels() = 0;
|
||||||
|
virtual size_t _getBufSize() = 0;
|
||||||
|
virtual unsigned long long _decode(signed short *buf_addr) = 0;
|
||||||
|
virtual void _deinit() = 0;
|
||||||
|
virtual size_t _getFileSamples() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace MusicPlayer {
|
||||||
|
void PlayFile(const std::string &path);
|
||||||
|
void Play();
|
||||||
|
void Pause();
|
||||||
|
void Stop();
|
||||||
|
bool IsPlaying();
|
||||||
|
bool IsRunning();
|
||||||
|
int PosCurrent();
|
||||||
|
int Total();
|
||||||
|
int SampleRate();
|
||||||
|
MusicMeta GetMeta();
|
||||||
|
} // namespace MusicPlayer
|
||||||
|
} // namespace RenderD7
|
29
include/renderd7/music/Vorbis.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/music/Music.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <tremor/ivorbiscodec.h>
|
||||||
|
#include <tremor/ivorbisfile.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class VorbisDecoder : public MusicDecoder {
|
||||||
|
public:
|
||||||
|
VorbisDecoder() {}
|
||||||
|
~VorbisDecoder() {}
|
||||||
|
|
||||||
|
int _init(const std::string& path, MusicMeta& meta) override;
|
||||||
|
unsigned int _getSampleRate() override;
|
||||||
|
unsigned char _getChannels() override;
|
||||||
|
size_t _getBufSize() override;
|
||||||
|
unsigned long long _decode(signed short* buf_addr) override;
|
||||||
|
void _deinit() override;
|
||||||
|
size_t _getFileSamples() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
OggVorbis_File vorbis_file;
|
||||||
|
vorbis_info *vi;
|
||||||
|
FILE* f; // Only used cause required by lib
|
||||||
|
const size_t buf_size = 8 * 4096;
|
||||||
|
};
|
||||||
|
}
|
47
include/renderd7/nimg.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#define NPI_NIMG_ (uint32_t)0x4e494d47 // Magic: NIMG
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NIMG Format Value Description
|
||||||
|
* int format
|
||||||
|
* 0 = rgba32
|
||||||
|
* 1 = rgb24 (3x8bit)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NIMG Compression Value Description
|
||||||
|
* int compression
|
||||||
|
* 0 = no compression
|
||||||
|
* 1 = npi_simple_compress (RLE Style)
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace RenderD7
|
||||||
|
{
|
||||||
|
struct nimg
|
||||||
|
{
|
||||||
|
unsigned int magic; // Magic number defaults do NPI_NIMG_
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int format;
|
||||||
|
int compression;
|
||||||
|
std::vector<unsigned char> pixel_buffer;
|
||||||
|
|
||||||
|
nimg(int w = 0, int h = 0, int fmt = 0, int cmp = 0)
|
||||||
|
{
|
||||||
|
magic = NPI_NIMG_;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
format = fmt;
|
||||||
|
compression = cmp;
|
||||||
|
pixel_buffer.resize((w*h)*(format ? 3 : 4));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
nimg NIMG_Load(std::string path);
|
||||||
|
nimg NIMG_LoadFromMem(unsigned char* buffer, size_t bf_size);
|
||||||
|
void NIMG_Save(nimg image, std::string path);
|
||||||
|
}
|
26
include/renderd7/nimg_engine.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/nimg.hpp>
|
||||||
|
|
||||||
|
namespace RenderD7
|
||||||
|
{
|
||||||
|
class NIMG_Engine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NIMG_Engine(int w, int h);
|
||||||
|
NIMG_Engine();
|
||||||
|
~NIMG_Engine();
|
||||||
|
nimg& GetImage() { return image; }
|
||||||
|
void load_file(const std::string& path);
|
||||||
|
void load_nimg(const std::string& path);
|
||||||
|
|
||||||
|
// Rendering
|
||||||
|
void draw_pixel(int x, int y, unsigned int color);
|
||||||
|
void draw_rect(int x, int y, int w, int h, unsigned int color, int t = 1);
|
||||||
|
void draw_rect_solid(int x, int y, int w, int h, unsigned int color);
|
||||||
|
void flip(bool h, bool v);
|
||||||
|
|
||||||
|
private:
|
||||||
|
nimg image;
|
||||||
|
};
|
||||||
|
}
|
@ -1,118 +1,118 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
class Parameter {
|
class Parameter {
|
||||||
private:
|
private:
|
||||||
using id = size_t;
|
using id = size_t;
|
||||||
|
|
||||||
template <typename T> struct type {
|
template <typename T> struct type {
|
||||||
static void id() {}
|
static void id() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> static id type_id() {
|
template <typename T> static id type_id() {
|
||||||
return reinterpret_cast<id>(&type<T>::id);
|
return reinterpret_cast<id>(&type<T>::id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> using decay = typename std::decay<T>::type;
|
template <typename T> using decay = typename std::decay<T>::type;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using none =
|
using none =
|
||||||
typename std::enable_if<!std::is_same<Parameter, T>::value>::type;
|
typename std::enable_if<!std::is_same<Parameter, T>::value>::type;
|
||||||
|
|
||||||
struct base {
|
struct base {
|
||||||
virtual ~base() {}
|
virtual ~base() {}
|
||||||
virtual bool is(id) const = 0;
|
virtual bool is(id) const = 0;
|
||||||
virtual base *copy() const = 0;
|
virtual base *copy() const = 0;
|
||||||
} *p = nullptr;
|
} *p = nullptr;
|
||||||
|
|
||||||
template <typename T> struct data : base, std::tuple<T> {
|
template <typename T> struct data : base, std::tuple<T> {
|
||||||
using std::tuple<T>::tuple;
|
using std::tuple<T>::tuple;
|
||||||
|
|
||||||
T &get() & { return std::get<0>(*this); }
|
T &get() & { return std::get<0>(*this); }
|
||||||
T const &get() const & { return std::get<0>(*this); }
|
T const &get() const & { return std::get<0>(*this); }
|
||||||
|
|
||||||
bool is(id i) const override { return i == type_id<T>(); }
|
bool is(id i) const override { return i == type_id<T>(); }
|
||||||
base *copy() const override { return new data{get()}; }
|
base *copy() const override { return new data{get()}; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> T &stat() { return static_cast<data<T> &>(*p).get(); }
|
template <typename T> T &stat() { return static_cast<data<T> &>(*p).get(); }
|
||||||
|
|
||||||
template <typename T> T const &stat() const {
|
template <typename T> T const &stat() const {
|
||||||
return static_cast<data<T> const &>(*p).get();
|
return static_cast<data<T> const &>(*p).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> T &dyn() { return dynamic_cast<data<T> &>(*p).get(); }
|
template <typename T> T &dyn() { return dynamic_cast<data<T> &>(*p).get(); }
|
||||||
|
|
||||||
template <typename T> T const &dyn() const {
|
template <typename T> T const &dyn() const {
|
||||||
return dynamic_cast<data<T> const &>(*p).get();
|
return dynamic_cast<data<T> const &>(*p).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor
|
* @brief Default constructor
|
||||||
*/
|
*/
|
||||||
Parameter() {}
|
Parameter() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destructs the Parameter
|
* @brief Destructs the Parameter
|
||||||
*/
|
*/
|
||||||
~Parameter() { delete p; }
|
~Parameter() { delete p; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copy constructor
|
* @brief Copy constructor
|
||||||
* @param s The Parameter to copy
|
* @param s The Parameter to copy
|
||||||
*/
|
*/
|
||||||
Parameter(Parameter &&s) : p{s.p} { s.p = nullptr; }
|
Parameter(Parameter &&s) : p{s.p} { s.p = nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Const copy constructor
|
* @brief Const copy constructor
|
||||||
* @param s The Parameter to copy
|
* @param s The Parameter to copy
|
||||||
*/
|
*/
|
||||||
Parameter(Parameter const &s) : p{s.p->copy()} {}
|
Parameter(Parameter const &s) : p{s.p->copy()} {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the Parameter with the given value
|
* @brief Initializes the Parameter with the given value
|
||||||
* @param x The value to initialize the Parameter with
|
* @param x The value to initialize the Parameter with
|
||||||
*/
|
*/
|
||||||
template <typename T, typename U = decay<T>, typename = none<U>>
|
template <typename T, typename U = decay<T>, typename = none<U>>
|
||||||
Parameter(T &&x) : p{new data<U>{std::forward<T>(x)}} {}
|
Parameter(T &&x) : p{new data<U>{std::forward<T>(x)}} {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Overloads the assignment operator
|
* @brief Overloads the assignment operator
|
||||||
* @param s The value to set the Parameter to
|
* @param s The value to set the Parameter to
|
||||||
*/
|
*/
|
||||||
Parameter &operator=(Parameter s) {
|
Parameter &operator=(Parameter s) {
|
||||||
swap(*this, s);
|
swap(*this, s);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend void swap(Parameter &s, Parameter &r) { std::swap(s.p, r.p); }
|
friend void swap(Parameter &s, Parameter &r) { std::swap(s.p, r.p); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clears the Parameter
|
* @brief Clears the Parameter
|
||||||
*/
|
*/
|
||||||
void clear() {
|
void clear() {
|
||||||
delete p;
|
delete p;
|
||||||
p = nullptr;
|
p = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks whether the Parameter is the given type
|
* @brief Checks whether the Parameter is the given type
|
||||||
* @tparam T The type to check
|
* @tparam T The type to check
|
||||||
* @return Whether the Parameter has the given type or not
|
* @return Whether the Parameter has the given type or not
|
||||||
*/
|
*/
|
||||||
template <typename T> bool is() const {
|
template <typename T> bool is() const {
|
||||||
return p ? p->is(type_id<T>()) : false;
|
return p ? p->is(type_id<T>()) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the value of the Parameter
|
* @brief Returns the value of the Parameter
|
||||||
* @tparam T The type of the Parameter
|
* @tparam T The type of the Parameter
|
||||||
* @return The value of the Parameter
|
* @return The value of the Parameter
|
||||||
* @warning If the type of the Parameter doesn't match the type of it's stored
|
* @warning If the type of the Parameter doesn't match the type of it's stored
|
||||||
* value, it will result in undefined behaviour.
|
* value, it will result in undefined behaviour.
|
||||||
*/
|
*/
|
||||||
template <typename T> T &get() & { return stat<T>(); }
|
template <typename T> T &get() & { return stat<T>(); }
|
||||||
};
|
};
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <3ds.h>
|
/// c++ Includes
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <citro2d.h>
|
#include <codecvt>
|
||||||
#include <citro3d.h>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <dirent.h>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -13,29 +11,32 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
/// c includes
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
/// 3ds Includes
|
||||||
|
#include <3ds.h>
|
||||||
|
#include <citro2d.h>
|
||||||
#include <codecvt>
|
#include <citro3d.h>
|
||||||
|
/// RenderD7 Includes
|
||||||
#include <renderd7/BitmapPrinter.hpp>
|
|
||||||
#include <renderd7/Color.hpp>
|
#include <renderd7/Color.hpp>
|
||||||
#include <renderd7/Draw.hpp>
|
#include <renderd7/FunctionTrace.hpp>
|
||||||
#include <renderd7/Image.hpp>
|
#include <renderd7/Hardware.hpp>
|
||||||
|
#include <renderd7/Memory.hpp>
|
||||||
#include <renderd7/Ovl.hpp>
|
#include <renderd7/Ovl.hpp>
|
||||||
|
#include <renderd7/ResultDecoder.hpp>
|
||||||
#include <renderd7/Screen.hpp>
|
#include <renderd7/Screen.hpp>
|
||||||
|
#include <renderd7/Security.hpp>
|
||||||
#include <renderd7/Sheet.hpp>
|
#include <renderd7/Sheet.hpp>
|
||||||
#include <renderd7/Sprite.hpp>
|
#include <renderd7/Sprite.hpp>
|
||||||
#include <renderd7/SpriteAnimation.hpp>
|
#include <renderd7/SpriteAnimation.hpp>
|
||||||
|
#include <renderd7/Tasks.hpp>
|
||||||
#include <renderd7/Time.hpp>
|
#include <renderd7/Time.hpp>
|
||||||
#include <renderd7/Toast.hpp>
|
|
||||||
#include <renderd7/bmp.hpp>
|
|
||||||
#include <renderd7/bmpconverter.hpp>
|
|
||||||
#include <renderd7/external/lodepng.h>
|
#include <renderd7/external/lodepng.h>
|
||||||
#include <renderd7/ini.hpp>
|
#include <renderd7/ini.hpp>
|
||||||
#include <renderd7/lang.hpp>
|
#include <renderd7/lang.hpp>
|
||||||
@ -43,240 +44,200 @@
|
|||||||
#include <renderd7/stringtool.hpp>
|
#include <renderd7/stringtool.hpp>
|
||||||
#include <renderd7/thread.hpp>
|
#include <renderd7/thread.hpp>
|
||||||
|
|
||||||
|
#define RENDERD7VSTRING "0.9.5"
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <renderd7/external/fs.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RENDERD7VSTRING "0.8.0"
|
|
||||||
#define CHANGELOG \
|
|
||||||
"0.8.0: Implement BitmapPrinter\n0.7.3: Implement Over Render Overlay " \
|
|
||||||
"Framework\n0.7.2: Implement MT to csv file saving. Add RGB2HEX. \n0.7.1: " \
|
|
||||||
"Add the New Overlay Handler. Its Just in code and does nothing yet. " \
|
|
||||||
"\n0.7.0: Made Big Progress In the MT Ovl but it still crashes On a Scnd " \
|
|
||||||
"C3D_FrameEnd(). Implement 800px but doesn't work that good. \n0.6.2: Fix " \
|
|
||||||
"Crash when exiting trouth Home Menu. \n0.6.10: rewrite Threadsystem, " \
|
|
||||||
"Improve framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left " \
|
|
||||||
"Function.\nadd changelog\n0.6.01: add Threading system."
|
|
||||||
#define DEFAULT_CENTER 0.5f
|
#define DEFAULT_CENTER 0.5f
|
||||||
|
|
||||||
/*extern C3D_RenderTarget* Top;
|
/// @param rd7_do_splash Config Value To Enable RenderD7 Splash
|
||||||
extern C3D_RenderTarget* TopRight;
|
extern bool rd7_do_splash;
|
||||||
extern C3D_RenderTarget* Bottom;*/
|
/// @param rd7_enable_memtrack Config Value to Track Mem Allocations
|
||||||
|
extern bool rd7_enable_memtrack;
|
||||||
extern u32 d7_hDown;
|
/// @param rd7_max_objects Config Param for C2D Mac objects
|
||||||
extern u32 d7_hHeld;
|
extern int rd7_max_objects;
|
||||||
extern u32 d7_hUp;
|
/// @param rd7_enable_scene_system Enable/Disable Scene System (for example for your own implementations)
|
||||||
extern touchPosition d7_touch;
|
extern bool rd7_enable_scene_system;
|
||||||
|
|
||||||
extern std::string dspststus;
|
|
||||||
|
|
||||||
/// RenderD7
|
/// RenderD7
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
|
/// @brief Get Deltatime
|
||||||
|
/// @return Deltatime
|
||||||
float GetDeltaTime();
|
float GetDeltaTime();
|
||||||
enum kbd { SWKBD, BKBD };
|
|
||||||
enum kbd_type { NUMPAD, STANDARD };
|
|
||||||
struct TObject {
|
|
||||||
int x; // Position X
|
|
||||||
int y; // Position Y
|
|
||||||
int w; // Button Width
|
|
||||||
int h; // Button Height
|
|
||||||
std::string text = ""; // Text
|
|
||||||
float correctx = 0; // Correct X Position
|
|
||||||
float correcty = 0; // Correct Y Position
|
|
||||||
float txtsize = 0.7f; // Set Text Size
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/// @brief A Button
|
||||||
|
struct TObject {
|
||||||
|
int x; ///< Position X
|
||||||
|
int y; ///< Position Y
|
||||||
|
int w; ///< Button Width
|
||||||
|
int h; ///< Button Height
|
||||||
|
std::string text = ""; ///< Text
|
||||||
|
float txtsize = 0.7f; ///< Set Text Size
|
||||||
|
};
|
||||||
|
/// @brief Scene Class
|
||||||
class Scene {
|
class Scene {
|
||||||
public:
|
public:
|
||||||
|
/// @brief Stack of the Scenes
|
||||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||||
|
/// @brief Deconstructor
|
||||||
virtual ~Scene() {}
|
virtual ~Scene() {}
|
||||||
virtual void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) = 0;
|
virtual void Logic() = 0;
|
||||||
|
/// @brief Draw Func to Override
|
||||||
virtual void Draw() const = 0;
|
virtual void Draw() const = 0;
|
||||||
// virtual void Ovl() const = 0;
|
/// @brief Push a Scene to Stack
|
||||||
|
/// @param scene Scene to Push
|
||||||
|
/// @param fade FadeEffect (Not Correctly Implementet yet)
|
||||||
static void Load(std::unique_ptr<Scene> scene, bool fade = false);
|
static void Load(std::unique_ptr<Scene> scene, bool fade = false);
|
||||||
|
/// @brief Go Back a Scene
|
||||||
static void Back();
|
static void Back();
|
||||||
|
/// @brief do the Draw (Called in RenderD7::MainLoop())
|
||||||
static void doDraw();
|
static void doDraw();
|
||||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
static void doLogic();
|
||||||
// static void HandleOvl();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Integrated Setting Menu of RenderD7
|
||||||
class RSettings : public RenderD7::Scene {
|
class RSettings : public RenderD7::Scene {
|
||||||
private:
|
private:
|
||||||
enum RState { RSETTINGS, RINFO };
|
/// @brief State (Define for Menus)
|
||||||
|
enum RState {
|
||||||
|
RSETTINGS,
|
||||||
|
RINFO,
|
||||||
|
RSERVICES,
|
||||||
|
RMCONFIG,
|
||||||
|
RFTRACE,
|
||||||
|
RUI7,
|
||||||
|
RCREDITS
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @param shared_request Defines requests from Draw to Logic
|
||||||
|
/// As it is not planned to make Draw non const you'll need
|
||||||
|
/// A map of data or bool values that are mutable ake
|
||||||
|
/// editable by const functions
|
||||||
|
mutable std::map<unsigned int, unsigned int> shared_request;
|
||||||
|
/// @param m_state Current menu State (Default=MainMenu aka RSETTINGS)
|
||||||
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
RenderD7::RSettings::RState m_state = RenderD7::RSettings::RState::RSETTINGS;
|
||||||
|
|
||||||
std::string rd7srstate = "false";
|
/// @brief Position in FTrace Menu
|
||||||
std::string csvstate = "false";
|
int ftrace_index = 0;
|
||||||
|
|
||||||
|
/// @param mtovlstate State of Metricks Overlay
|
||||||
std::string mtovlstate = "false";
|
std::string mtovlstate = "false";
|
||||||
std::string fpsstate = "60";
|
/// @param mtscreenstate Screen the Overlay is Set to
|
||||||
std::string mtscreenstate = "Top";
|
std::string mtscreenstate = "Top";
|
||||||
std::string mttxtcolstate = "#ffffff";
|
std::string kbd_test;
|
||||||
std::string mtcola = "255";
|
bool statemtold = false;
|
||||||
std::string mttxtcola = "255";
|
bool stateftold = false;
|
||||||
|
|
||||||
std::vector<RenderD7::TObject> buttons = {
|
|
||||||
{20, 35, 120, 35, "RD7SR", -11, 10},
|
|
||||||
{20, 85, 120, 35, "MT_CSV", -15, 9},
|
|
||||||
{20, 135, 120, 35, "MT_OVL", -19, 10},
|
|
||||||
{20, 185, 120, 35, "FPS", 6, 10},
|
|
||||||
{180, 35, 120, 35, "MTSCREEN", -29, 10},
|
|
||||||
{180, 85, 120, 35, "DSPERR", -13, 10},
|
|
||||||
{180, 135, 120, 35, "INFO", 2, 10},
|
|
||||||
{180, 185, 120, 35, "", -13, 10}};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// @brief Constructor
|
||||||
RSettings();
|
RSettings();
|
||||||
|
/// @brief Override for Draw
|
||||||
|
/// @param
|
||||||
void Draw(void) const override;
|
void Draw(void) const override;
|
||||||
|
/// @brief Deconstructor
|
||||||
~RSettings();
|
~RSettings();
|
||||||
void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
void LoadSettings();
|
|
||||||
|
|
||||||
class DSP_NF : public RenderD7::Ovl {
|
|
||||||
public:
|
|
||||||
DSP_NF();
|
|
||||||
void Draw(void) const override;
|
|
||||||
void Logic() override;
|
void Logic() override;
|
||||||
|
|
||||||
private:
|
|
||||||
int msgposy = 240;
|
|
||||||
int delay = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Show Up the RenderD7-Settings Menu
|
||||||
|
void LoadSettings();
|
||||||
|
/// @brief Get's The Programs Time running
|
||||||
|
/// @return Time Running
|
||||||
|
float GetTime();
|
||||||
|
/// @brief Get Framerate as Number
|
||||||
|
/// @return FPS
|
||||||
|
int GetFps();
|
||||||
|
|
||||||
|
/// @brief Get A Rendom Int
|
||||||
|
/// @param b From
|
||||||
|
/// @param e To
|
||||||
|
/// @return Random Int
|
||||||
int GetRandomInt(int b, int e);
|
int GetRandomInt(int b, int e);
|
||||||
|
/// @brief DrawMetrikOvl (YOUR OWN RISK)
|
||||||
void DrawMetrikOvl();
|
void DrawMetrikOvl();
|
||||||
|
/// @brief Draw Image from RenderD7 Sheet
|
||||||
|
/// @param sheet Spritesheet
|
||||||
|
/// @param index Image index Value
|
||||||
|
/// @param x Pos X
|
||||||
|
/// @param y Pos Y
|
||||||
|
/// @param scaleX Scale on X-Axis
|
||||||
|
/// @param scaleY Scale on Y-Axis
|
||||||
|
/// @return success ?
|
||||||
bool DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x, float y,
|
bool DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x, float y,
|
||||||
float scaleX = 1.0, float scaleY = 1.0);
|
float scaleX = 1.0, float scaleY = 1.0);
|
||||||
namespace Error {
|
/// @brief Fade In
|
||||||
void DisplayError(std::string toptext, std::string errortext, int timesec = 3);
|
/// @param duration Duration in Frames
|
||||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
void FadeIn();
|
||||||
} // namespace Error
|
/// @brief Fade Out
|
||||||
|
/// @param duration Duration in Frames
|
||||||
|
void FadeOut();
|
||||||
|
/// @brief Display Fade Effects
|
||||||
|
void FadeDisplay();
|
||||||
|
|
||||||
|
/// @brief Loads a font
|
||||||
|
/// @param path path to font (bcfnt)
|
||||||
|
/// @return link to C2D_Font Object
|
||||||
|
C2D_Font LoadFont(const std::string& path);
|
||||||
|
|
||||||
namespace Init {
|
namespace Init {
|
||||||
|
/// @brief Init Default RenderD7
|
||||||
|
/// @param app_name Name of Your App
|
||||||
|
/// @return ResCode
|
||||||
Result Main(std::string app_name = "RD7Game");
|
Result Main(std::string app_name = "RD7Game");
|
||||||
|
/// @brief Init Minimal RenderD7 (For better Hax2.x support)
|
||||||
|
/// @param app_name Name of Your App
|
||||||
|
/// @return ResCode
|
||||||
|
Result Minimal(std::string app_name = "RD7Game");
|
||||||
|
/// @brief Reload the Graphics Engine
|
||||||
|
/// @return ResCode
|
||||||
Result Reload();
|
Result Reload();
|
||||||
|
/// @brief Init Graphics Only (NOT SUPPORTET use Reload)
|
||||||
void Graphics();
|
void Graphics();
|
||||||
void NdspFirm(bool useit = false);
|
/// @brief Init Ndsp for Sounds
|
||||||
} // namespace Init
|
|
||||||
namespace Exit {
|
|
||||||
void Main();
|
|
||||||
void NdspFirm();
|
void NdspFirm();
|
||||||
void Graphics();
|
} // namespace Init
|
||||||
} // namespace Exit
|
|
||||||
namespace Msg {
|
|
||||||
void Display(std::string titletxt, std::string subtext,
|
|
||||||
C3D_RenderTarget *target);
|
|
||||||
void DisplayWithProgress(std::string titletext, std::string subtext,
|
|
||||||
float current, float total, u32 prgbarcolor);
|
|
||||||
} // namespace Msg
|
|
||||||
|
|
||||||
namespace Convert {
|
namespace Convert {
|
||||||
|
/// @brief Convert a String to Flaot
|
||||||
|
/// @param inp Input String
|
||||||
|
/// @return Float
|
||||||
inline float StringtoFloat(std::string inp) { return std::atof(inp.c_str()); }
|
inline float StringtoFloat(std::string inp) { return std::atof(inp.c_str()); }
|
||||||
|
/// @brief Convert String to Int
|
||||||
|
/// @param inp Input String
|
||||||
|
/// @return Int
|
||||||
inline int StringtoInt(std::string inp) { return std::atoi(inp.c_str()); }
|
inline int StringtoInt(std::string inp) { return std::atoi(inp.c_str()); }
|
||||||
inline bool FloatToBool(float inp) {
|
/// @brief Convert a Float to Bool
|
||||||
if (inp == 1)
|
/// @param inp Input Float
|
||||||
return true;
|
/// @return Bool
|
||||||
else
|
inline bool FloatToBool(float inp) { return (inp == 1 ? true : false); }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} // namespace Convert
|
} // namespace Convert
|
||||||
|
|
||||||
struct DirContent {
|
|
||||||
std::string name;
|
|
||||||
std::string path;
|
|
||||||
bool isDir;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace FS {
|
namespace FS {
|
||||||
|
/// @brief Check if File exists
|
||||||
|
/// @param path Path to the File
|
||||||
|
/// @return exists or not
|
||||||
bool FileExist(const std::string &path);
|
bool FileExist(const std::string &path);
|
||||||
}
|
} // namespace FS
|
||||||
|
|
||||||
|
/// @brief Check if Ndsp is Init
|
||||||
|
/// @return is or not
|
||||||
bool IsNdspInit();
|
bool IsNdspInit();
|
||||||
void SetupLog(void);
|
/// @brief Get Current Framerate as String
|
||||||
|
/// @return Framerate String
|
||||||
std::string GetFramerate();
|
std::string GetFramerate();
|
||||||
|
/// @brief MainLoop of RenderD7s
|
||||||
|
/// @return Is Still Running or not
|
||||||
bool MainLoop();
|
bool MainLoop();
|
||||||
|
/// @brief Exit App (brak the MainLoop)
|
||||||
void ExitApp();
|
void ExitApp();
|
||||||
|
|
||||||
|
/// @brief Clear the Citro2D TextBuffers
|
||||||
|
/// @param
|
||||||
void ClearTextBufs(void);
|
void ClearTextBufs(void);
|
||||||
|
|
||||||
std::string Kbd(int lenght, SwkbdType tp);
|
/// @brief Draw Overlays And end the Frame. DO NEVER USE C3D_FRAMEEND cause it
|
||||||
|
/// breaks Overlay crash Security
|
||||||
void FrameEnd();
|
void FrameEnd();
|
||||||
void ToggleRD7SR();
|
|
||||||
bool IsRD7SR();
|
|
||||||
|
|
||||||
struct TLBtn {
|
|
||||||
int x; // Position X
|
|
||||||
int y; // Position Y
|
|
||||||
int w; // Button Width
|
|
||||||
int h; // Button Height
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScrollList1 {
|
|
||||||
std::string Text = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ScrollList2 {
|
|
||||||
float x;
|
|
||||||
float y;
|
|
||||||
float w;
|
|
||||||
float h;
|
|
||||||
std::string Text = "";
|
|
||||||
};
|
|
||||||
/*enum ListType
|
|
||||||
{
|
|
||||||
ONE,
|
|
||||||
TWO
|
|
||||||
};*/
|
|
||||||
void DrawList1(RenderD7::ScrollList1 &l, float txtsize, C3D_RenderTarget *t);
|
|
||||||
void DrawTObjects(std::vector<RenderD7::TObject> tobjects, u32 color,
|
|
||||||
u32 txtcolor, int selection = -1,
|
|
||||||
u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"),
|
|
||||||
u32 selcolor = RenderD7::Color::Hex("#000000"));
|
|
||||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex,
|
|
||||||
u32 color, u32 txtcolor);
|
|
||||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
|
||||||
bool touchTLBtn(touchPosition touch, RenderD7::TLBtn button);
|
|
||||||
void DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color,
|
|
||||||
int selection = -1,
|
|
||||||
u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"),
|
|
||||||
u32 selcolor = RenderD7::Color::Hex("#000000"));
|
|
||||||
|
|
||||||
struct Checkbox {
|
|
||||||
float x, y, s;
|
|
||||||
bool is_chexked = false;
|
|
||||||
u32 outcol, incol, chcol;
|
|
||||||
};
|
|
||||||
void DrawCheckbox(Checkbox box);
|
|
||||||
|
|
||||||
class Console {
|
|
||||||
public:
|
|
||||||
Console();
|
|
||||||
Console(int x, int y, int w, int h, u8 a = 255);
|
|
||||||
Console(int x, int y, int w, int h, RenderD7::Color::rgba col);
|
|
||||||
Console(int x, int y, int w, int h, std::string name,
|
|
||||||
RenderD7::Color::rgba col = {255, 255, 255, 255},
|
|
||||||
RenderD7::Color::rgba barcol = {0, 0, 0, 255},
|
|
||||||
RenderD7::Color::rgba outlinecol = {222, 222, 222, 255});
|
|
||||||
void On(C3D_RenderTarget *t_cscreen);
|
|
||||||
bool Update();
|
|
||||||
~Console();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<std::string> m_lines;
|
|
||||||
int x, y, w, h;
|
|
||||||
std::string m_name = "";
|
|
||||||
C3D_RenderTarget *cscreen;
|
|
||||||
bool m_nconsole = false;
|
|
||||||
bool m_mconsole = false;
|
|
||||||
RenderD7::Color::rgba color = {255, 255, 255, 255};
|
|
||||||
RenderD7::Color::rgba outlinecol = {222, 222, 222, 255};
|
|
||||||
RenderD7::Color::rgba barcolor = {0, 0, 0, 255};
|
|
||||||
};
|
|
||||||
|
|
||||||
void GetDirContentsExt(std::vector<RenderD7::DirContent> &dircontent,
|
|
||||||
const std::vector<std::string> &extensions);
|
|
||||||
void GetDirContents(std::vector<RenderD7::DirContent> &dircontent);
|
|
||||||
|
|
||||||
|
/// @brief Returns App Working Directory path
|
||||||
|
/// @return AppDir Path
|
||||||
|
std::string GetAppDirectory();
|
||||||
} // namespace RenderD7
|
} // namespace RenderD7
|
||||||
|
5
include/renderd7/renderd7_logo.hpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
extern unsigned char renderd7_logo[];
|
||||||
|
extern size_t renderd7_logo_size;
|
@ -11,17 +11,20 @@ public:
|
|||||||
/// \param channel the channel 1-23
|
/// \param channel the channel 1-23
|
||||||
/// \param toloop true:loop the sound, false: don't loop
|
/// \param toloop true:loop the sound, false: don't loop
|
||||||
sound(const std::string &path, int channel = 1, bool toloop = false);
|
sound(const std::string &path, int channel = 1, bool toloop = false);
|
||||||
/** deconstruct the sound */
|
/// @brief Deconstructor
|
||||||
~sound();
|
~sound();
|
||||||
/** play the sound */
|
/// @brief Play the sound
|
||||||
void play();
|
void play();
|
||||||
/** stop the sound */
|
/// @brief Stop the sound
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// \param dataSize the Size of the filedata
|
/// \param dataSize Size of the filedata
|
||||||
u32 dataSize;
|
u32 dataSize;
|
||||||
|
/// \param waveBuf For ndsp
|
||||||
ndspWaveBuf waveBuf;
|
ndspWaveBuf waveBuf;
|
||||||
u8 *data = NULL;
|
/// \param data Memmory data of the sound
|
||||||
|
uint8_t *data = NULL;
|
||||||
|
/// \param chnl Channel of the sound
|
||||||
int chnl;
|
int chnl;
|
||||||
};
|
};
|
||||||
|
@ -1,40 +1,103 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
namespace RenderD7 {
|
|
||||||
inline bool NameIsEndingWith(const std::string &name,
|
namespace RenderD7 {
|
||||||
const std::vector<std::string> &extensions) {
|
/// @brief Check if A String ends with
|
||||||
if (name.substr(0, 2) == "._")
|
/// @param name Input String
|
||||||
return false;
|
/// @param extensions Extensions to Check for
|
||||||
|
/// @return Ends with or not
|
||||||
if (name.size() == 0)
|
inline bool NameIsEndingWith(const std::string &name,
|
||||||
return false;
|
const std::vector<std::string> &extensions) {
|
||||||
|
if (name.substr(0, 2) == "._") return false;
|
||||||
if (extensions.size() == 0)
|
|
||||||
return true;
|
if (name.size() == 0) return false;
|
||||||
|
|
||||||
for (int i = 0; i < (int)extensions.size(); i++) {
|
if (extensions.size() == 0) return true;
|
||||||
const std::string ext = extensions.at(i);
|
|
||||||
if (strcasecmp(name.c_str() + name.size() - ext.size(), ext.c_str()) == 0)
|
for (int i = 0; i < (int)extensions.size(); i++) {
|
||||||
return true;
|
const std::string ext = extensions.at(i);
|
||||||
}
|
if (strcasecmp(name.c_str() + name.size() - ext.size(), ext.c_str()) == 0)
|
||||||
|
return true;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
} // namespace RenderD7
|
return false;
|
||||||
template <class T> T GetFileName(T const &path, T const &delims = "/\\") {
|
}
|
||||||
return path.substr(path.find_last_of(delims) + 1);
|
/// @brief Format Milliseconds to clean string (Stolen from one of my Mc
|
||||||
}
|
/// Plugins)
|
||||||
template <class T> T remove_ext(T const &filename) {
|
/// @param t_time Time in ms
|
||||||
typename T::size_type const p(filename.find_last_of('.'));
|
/// @return String
|
||||||
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
inline std::string MsTimeFmt(float t_time, bool dems = false) {
|
||||||
}
|
std::ostringstream oss;
|
||||||
|
|
||||||
template <typename T> std::string Int_To_Hex(T i) {
|
if (t_time < 0.001f) {
|
||||||
std::stringstream stream;
|
oss << std::fixed << std::setprecision(2) << t_time * 1000.0f << "ns";
|
||||||
stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex
|
} else if (t_time < 1.0f) {
|
||||||
<< i;
|
oss << std::fixed << std::setprecision(2) << t_time << "ms";
|
||||||
return stream.str();
|
} else if (t_time < 60000.0f) {
|
||||||
|
int seconds = static_cast<int>(t_time / 1000.0f);
|
||||||
|
float milliseconds = t_time - (seconds * 1000.0f);
|
||||||
|
|
||||||
|
if (seconds > 0) {
|
||||||
|
oss << seconds << "s ";
|
||||||
|
}
|
||||||
|
if (!dems)
|
||||||
|
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||||
|
} else {
|
||||||
|
int minutes = static_cast<int>(t_time / 60000.0f);
|
||||||
|
int seconds = static_cast<int>((t_time - (minutes * 60000.0f)) / 1000.0f);
|
||||||
|
float milliseconds = t_time - (minutes * 60000.0f) - (seconds * 1000.0f);
|
||||||
|
|
||||||
|
oss << minutes << "m ";
|
||||||
|
if (seconds > 0 || milliseconds > 0.0f) {
|
||||||
|
oss << seconds << "s ";
|
||||||
|
}
|
||||||
|
if (milliseconds > 0.0f && !dems) {
|
||||||
|
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::string FormatBytes(int bytes) {
|
||||||
|
char out[32];
|
||||||
|
|
||||||
|
if (bytes == 1)
|
||||||
|
snprintf(out, sizeof(out), "%d Byte", bytes);
|
||||||
|
|
||||||
|
else if (bytes < 1024)
|
||||||
|
snprintf(out, sizeof(out), "%d Bytes", bytes);
|
||||||
|
|
||||||
|
else if (bytes < 1024 * 1024)
|
||||||
|
snprintf(out, sizeof(out), "%.1f KB", (float)bytes / 1024);
|
||||||
|
|
||||||
|
else if (bytes < 1024 * 1024 * 1024)
|
||||||
|
snprintf(out, sizeof(out), "%.1f MB", (float)bytes / 1024 / 1024);
|
||||||
|
|
||||||
|
else
|
||||||
|
snprintf(out, sizeof(out), "%.1f GB", (float)bytes / 1024 / 1024 / 1024);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
} // namespace RenderD7
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
T GetFileName(T const &path, T const &delims = "/\\") {
|
||||||
|
return path.substr(path.find_last_of(delims) + 1);
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
T remove_ext(T const &filename) {
|
||||||
|
typename T::size_type const p(filename.find_last_of('.'));
|
||||||
|
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
std::string Int_To_Hex(T i) {
|
||||||
|
std::stringstream stream;
|
||||||
|
stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex
|
||||||
|
<< i;
|
||||||
|
return stream.str();
|
||||||
}
|
}
|
@ -1,136 +1,122 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <renderd7/parameter.hpp>
|
#include <renderd7/parameter.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using CTRU_Thread = Thread;
|
using CTRU_Thread = Thread;
|
||||||
|
|
||||||
#define THREAD_STACK_SIZE 0x1000
|
#define THREAD_STACK_SIZE 0x1000
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
namespace Threads {
|
class Thread {
|
||||||
inline bool threadrunning = false;
|
public:
|
||||||
|
/**
|
||||||
struct Thread {
|
* @brief Default constructor
|
||||||
Handle handle;
|
* @note This should only be called when calling m3d::Thread::initialize()
|
||||||
void (*ep)(void);
|
* before calling m3d::Thread::start()
|
||||||
bool finished;
|
*/
|
||||||
void *stacktop;
|
Thread();
|
||||||
};
|
|
||||||
|
/**
|
||||||
bool Create();
|
* @brief Constructs the thread
|
||||||
bool Join();
|
* @param t_function The thread function
|
||||||
void Exit();
|
* @param t_parameter The parameter to pass to the function
|
||||||
} // namespace Threads
|
* @param t_autostart Whether the thread should start instantly
|
||||||
class Thread {
|
* @param t_detached Whether the thread starts detached or not
|
||||||
public:
|
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
||||||
/**
|
* to multiples of 8 bytes)
|
||||||
* @brief Default constructor
|
* @note t_function needs to be of type `void` and take one (and only one)
|
||||||
* @note This should only be called when calling m3d::Thread::initialize()
|
* parameter of type m3d::Parameter
|
||||||
* before calling m3d::Thread::start()
|
* @warning If the thread priority is lower than the priority of the calling
|
||||||
*/
|
* thread, the thread will never get executed. Use
|
||||||
Thread();
|
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
||||||
|
*/
|
||||||
/**
|
Thread(std::function<void(RenderD7::Parameter)> t_function,
|
||||||
* @brief Constructs the thread
|
RenderD7::Parameter t_parameter = nullptr, bool t_autostart = false,
|
||||||
* @param t_function The thread function
|
bool t_detached = false,
|
||||||
* @param t_parameter The parameter to pass to the function
|
unsigned long long int t_stackSize = 4 * 1024);
|
||||||
* @param t_autostart Whether the thread should start instantly
|
|
||||||
* @param t_detached Whether the thread starts detached or not
|
/**
|
||||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
* @brief Destructs the thread
|
||||||
* to multiples of 8 bytes)
|
*/
|
||||||
* @note t_function needs to be of type `void` and take one (and only one)
|
virtual ~Thread();
|
||||||
* parameter of type m3d::Parameter
|
|
||||||
* @warning If the thread priority is lower than the priority of the calling
|
/**
|
||||||
* thread, the thread will never get executed. Use
|
* @brief Initializes the thread
|
||||||
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
* @param t_function The thread function
|
||||||
*/
|
* @param t_parameter The parameter to pass to the function
|
||||||
Thread(std::function<void(RenderD7::Parameter)> t_function,
|
* @param t_autostart Whether the thread should start instantly
|
||||||
RenderD7::Parameter t_parameter = nullptr, bool t_autostart = false,
|
* @param t_detached Whether the thread starts detached or not
|
||||||
bool t_detached = false,
|
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
||||||
unsigned long long int t_stackSize = 4 * 1024);
|
* to multiples of 8 bytes)
|
||||||
|
* @note t_function needs to be of type `void` and take one (and only one)
|
||||||
/**
|
* parameter of type m3d::Parameter
|
||||||
* @brief Destructs the thread
|
* @warning If the thread priority is lower than the priority of the calling
|
||||||
*/
|
* thread, the thread will never get executed. Use
|
||||||
virtual ~Thread();
|
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
||||||
|
*/
|
||||||
/**
|
void initialize(std::function<void(RenderD7::Parameter)> t_function,
|
||||||
* @brief Initializes the thread
|
RenderD7::Parameter t_parameter = nullptr,
|
||||||
* @param t_function The thread function
|
bool t_autostart = false, bool t_detached = false,
|
||||||
* @param t_parameter The parameter to pass to the function
|
unsigned long long int t_stackSize = 4 * 1024);
|
||||||
* @param t_autostart Whether the thread should start instantly
|
|
||||||
* @param t_detached Whether the thread starts detached or not
|
/**
|
||||||
* @param t_stackSize The stacksize allocated for the thread in bytes (rounded
|
* @brief Sets the size of the stack that gets allocated for the next thread
|
||||||
* to multiples of 8 bytes)
|
* that get's started
|
||||||
* @note t_function needs to be of type `void` and take one (and only one)
|
* @param t_stackSize The allocated space in bytes (rounded to multiples of 8
|
||||||
* parameter of type m3d::Parameter
|
* bytes)
|
||||||
* @warning If the thread priority is lower than the priority of the calling
|
*/
|
||||||
* thread, the thread will never get executed. Use
|
void setStackSize(unsigned long long int t_stackSize);
|
||||||
* m3d::Thread::getCurrentPriority() to get the priority of the current thread
|
|
||||||
*/
|
/**
|
||||||
void initialize(std::function<void(RenderD7::Parameter)> t_function,
|
* @brief Starts the thread. To restart it, call Thread::join() before
|
||||||
RenderD7::Parameter t_parameter = nullptr,
|
* @param t_detached Whether the thread should start detached or not
|
||||||
bool t_autostart = false, bool t_detached = false,
|
*/
|
||||||
unsigned long long int t_stackSize = 4 * 1024);
|
void start(bool t_detached = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the size of the stack that gets allocated for the next thread
|
* @brief Detaches the thread
|
||||||
* that get's started
|
*/
|
||||||
* @param t_stackSize The allocated space in bytes (rounded to multiples of 8
|
void kill();
|
||||||
* bytes)
|
|
||||||
*/
|
/**
|
||||||
void setStackSize(unsigned long long int t_stackSize);
|
* @brief Waits for the thread to finish
|
||||||
|
* @param t_timeout The timeout in nanoseconds. Leave it for no timeout
|
||||||
/**
|
*/
|
||||||
* @brief Starts the thread. To restart it, call Thread::join() before
|
void join(long long unsigned int t_timeout = U64_MAX);
|
||||||
* @param t_detached Whether the thread should start detached or not
|
|
||||||
*/
|
bool isRunning();
|
||||||
void start(bool t_detached = false);
|
|
||||||
|
/**
|
||||||
/**
|
* @brief Puts the thread to sleep
|
||||||
* @brief Detaches the thread
|
*
|
||||||
*/
|
* This is needed if you have multiple threads running at the same time. It
|
||||||
void kill();
|
* doesn't affect the execution-time of the thread, it just makes it possible
|
||||||
|
* for the other threads to get their chance to shine.
|
||||||
/**
|
*/
|
||||||
* @brief Waits for the thread to finish
|
static void sleep();
|
||||||
* @param t_timeout The timeout in nanoseconds. Leave it for no timeout
|
|
||||||
*/
|
/**
|
||||||
void join(long long unsigned int t_timeout = U64_MAX);
|
* @brief Sleeps for the given time
|
||||||
|
* @param t_milliseconds The time to sleep in milliseconds
|
||||||
bool isRunning();
|
*/
|
||||||
|
static void sleep(int t_milliseconds);
|
||||||
/**
|
|
||||||
* @brief Puts the thread to sleep
|
private:
|
||||||
*
|
struct ThreadData {
|
||||||
* This is needed if you have multiple threads running at the same time. It
|
RenderD7::Parameter m_parameter;
|
||||||
* doesn't affect the execution-time of the thread, it just makes it possible
|
std::function<void(RenderD7::Parameter)> m_function;
|
||||||
* for the other threads to get their chance to shine.
|
std::atomic<bool> *m_running;
|
||||||
*/
|
};
|
||||||
static void sleep();
|
|
||||||
|
static void threadFunction(void *t_arg);
|
||||||
/**
|
/* data */
|
||||||
* @brief Sleeps for the given time
|
int m_priority, m_stackSize;
|
||||||
* @param t_milliseconds The time to sleep in milliseconds
|
bool m_started;
|
||||||
*/
|
std::atomic<bool> m_running;
|
||||||
static void sleep(int t_milliseconds);
|
RenderD7::Thread::ThreadData m_data;
|
||||||
|
CTRU_Thread m_thread;
|
||||||
private:
|
};
|
||||||
struct ThreadData {
|
} // namespace RenderD7
|
||||||
RenderD7::Parameter m_parameter;
|
|
||||||
std::function<void(RenderD7::Parameter)> m_function;
|
|
||||||
std::atomic<bool> *m_running;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void threadFunction(void *t_arg);
|
|
||||||
/* data */
|
|
||||||
int m_priority, m_stackSize;
|
|
||||||
bool m_started;
|
|
||||||
std::atomic<bool> m_running;
|
|
||||||
RenderD7::Thread::ThreadData m_data;
|
|
||||||
CTRU_Thread m_thread;
|
|
||||||
};
|
|
||||||
} // namespace RenderD7
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
#include <renderd7/Clock.hpp>
|
|
||||||
|
|
||||||
namespace rnd7 {
|
|
||||||
enum class TweenType : int { Position = 1, Color, Alpha };
|
|
||||||
|
|
||||||
enum class TweenLoop : int {
|
|
||||||
None = 1,
|
|
||||||
Loop = 2,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class TweenDirection : int { Current, Forward, Backward };
|
|
||||||
|
|
||||||
enum class TweenState : int { Playing = 1, Stopped };
|
|
||||||
class Tween {
|
|
||||||
public:
|
|
||||||
Tween(float from, float to, float duration, TweenLoop loop, TweenState state);
|
|
||||||
};
|
|
||||||
} // namespace rnd7
|
|
BIN
logo.png
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 17 KiB |
52
not_functional/Flac.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include <renderd7/music/Flac.hpp>
|
||||||
|
#ifdef RENDERD7_MUSICDEC
|
||||||
|
#define DR_FLAC_IMPLEMENTATION
|
||||||
|
#include <renderd7/external/dr_flac.h>
|
||||||
|
|
||||||
|
int rd7i_check_flac(const std::string &path) {
|
||||||
|
int err = -1;
|
||||||
|
drflac* flac = drflac_open_file(path.c_str(), NULL);
|
||||||
|
|
||||||
|
if(flac != NULL)
|
||||||
|
err = 0;
|
||||||
|
|
||||||
|
drflac_close(flac);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
int FlacDecoder::_init(const std::string &path, MusicMeta& meta) {
|
||||||
|
meta.path(path);
|
||||||
|
if(path.find_last_of('/') != path.npos)
|
||||||
|
meta.name(path.substr(path.find_last_of('/')));
|
||||||
|
else
|
||||||
|
meta.name(path);
|
||||||
|
flac = drflac_open_file(path.c_str(), NULL);
|
||||||
|
return flac == NULL ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int FlacDecoder::_getSampleRate() { return flac->sampleRate; }
|
||||||
|
|
||||||
|
unsigned char FlacDecoder::_getChannels() { return flac->channels; }
|
||||||
|
|
||||||
|
size_t FlacDecoder::_getBufSize() { return buf_size; }
|
||||||
|
|
||||||
|
unsigned long long FlacDecoder::_decode(signed short*buf_addr) {
|
||||||
|
unsigned long long bsf = (unsigned long long)buf_size/(unsigned long long)flac->channels;
|
||||||
|
|
||||||
|
unsigned long long samples_read = drflac_read_pcm_frames_s16(flac, bsf, buf_addr);
|
||||||
|
samples_read *= (unsigned long long)flac->channels;
|
||||||
|
|
||||||
|
return samples_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FlacDecoder::_deinit() {
|
||||||
|
drflac_close(flac);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t FlacDecoder::_getFileSamples() {
|
||||||
|
return flac->totalPCMFrameCount * (size_t)flac->channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace RenderD7
|
||||||
|
#endif
|
26
not_functional/Flac.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/music/Music.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <renderd7/external/dr_flac.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class FlacDecoder : public MusicDecoder {
|
||||||
|
public:
|
||||||
|
FlacDecoder() {}
|
||||||
|
~FlacDecoder() {}
|
||||||
|
|
||||||
|
int _init(const std::string& pat, MusicMeta& meta) override;
|
||||||
|
unsigned int _getSampleRate() override;
|
||||||
|
unsigned char _getChannels() override;
|
||||||
|
size_t _getBufSize() override;
|
||||||
|
unsigned long long _decode(signed short* buf_addr) override;
|
||||||
|
void _deinit() override;
|
||||||
|
size_t _getFileSamples() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
drflac* flac;
|
||||||
|
const size_t buf_size = 16 * 1024;
|
||||||
|
};
|
||||||
|
}
|
40
not_functional/MUSIC.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# Copy of removed Music.cpp file loaders
|
||||||
|
```
|
||||||
|
#include <renderd7/music/Flac.hpp>
|
||||||
|
#include <renderd7/music/Wav.hpp>
|
||||||
|
// "RIFF"
|
||||||
|
/*case 0x46464952:
|
||||||
|
// "riff"
|
||||||
|
case 0x66666972:
|
||||||
|
// "RIFX"
|
||||||
|
case 0x58464952:
|
||||||
|
// "RF64"
|
||||||
|
case 0x34364652:
|
||||||
|
// "FORM"
|
||||||
|
case 0x4D524F46:
|
||||||
|
decoder = new WavDecoder();
|
||||||
|
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||||
|
MusicDecoder::CleanUp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;*/
|
||||||
|
// Flac
|
||||||
|
/*case 0x43614c66:
|
||||||
|
decoder = new FlacDecoder();
|
||||||
|
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||||
|
RenderD7::PushMessage(
|
||||||
|
RenderD7::Message("Music Player", "Failed to load FLAC"));
|
||||||
|
MusicDecoder::CleanUp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;*/
|
||||||
|
|
||||||
|
// The other one
|
||||||
|
/*else if (rd7i_check_flac(path) == 0) {
|
||||||
|
decoder = new FlacDecoder();
|
||||||
|
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||||
|
MusicDecoder::CleanUp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
```
|
41
not_functional/Wav.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#include <renderd7/music/Wav.hpp>
|
||||||
|
|
||||||
|
#ifdef RENDERD7_MUSICDEC
|
||||||
|
#define DR_WAV_IMPLEMENTATION
|
||||||
|
#include <renderd7/external/dr_wav.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
int WavDecoder::_init(const std::string &path, MusicMeta& meta) {
|
||||||
|
meta.path(path);
|
||||||
|
if(path.find_last_of('/') != path.npos)
|
||||||
|
meta.name(path.substr(path.find_last_of('/')));
|
||||||
|
else
|
||||||
|
meta.name(path);
|
||||||
|
return !drwav_init_file(&wav, path.c_str(), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int WavDecoder::_getSampleRate() { return wav.sampleRate; }
|
||||||
|
|
||||||
|
unsigned char WavDecoder::_getChannels() { return wav.channels; }
|
||||||
|
|
||||||
|
size_t WavDecoder::_getBufSize() { return buf_size; }
|
||||||
|
|
||||||
|
unsigned long long WavDecoder::_decode(signed short*buf_addr) {
|
||||||
|
unsigned long long bsf = (unsigned long long)buf_size/(unsigned long long)wav.channels;
|
||||||
|
|
||||||
|
unsigned long long samples_read = drwav_read_pcm_frames(&wav, bsf, buf_addr);
|
||||||
|
samples_read *= (unsigned long long)wav.channels;
|
||||||
|
|
||||||
|
return samples_read;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WavDecoder::_deinit() {
|
||||||
|
drwav_uninit(&wav);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t WavDecoder::_getFileSamples() {
|
||||||
|
return wav.totalPCMFrameCount * (size_t)wav.channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace RenderD7
|
||||||
|
#endif
|
26
not_functional/Wav.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <renderd7/music/Music.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <renderd7/external/dr_wav.h>
|
||||||
|
|
||||||
|
namespace RenderD7 {
|
||||||
|
class WavDecoder : public MusicDecoder {
|
||||||
|
public:
|
||||||
|
WavDecoder() {}
|
||||||
|
~WavDecoder() {}
|
||||||
|
|
||||||
|
int _init(const std::string& path, MusicMeta& meta) override;
|
||||||
|
unsigned int _getSampleRate() override;
|
||||||
|
unsigned char _getChannels() override;
|
||||||
|
size_t _getBufSize() override;
|
||||||
|
unsigned long long _decode(signed short* buf_addr) override;
|
||||||
|
void _deinit() override;
|
||||||
|
size_t _getFileSamples() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
drwav wav;
|
||||||
|
const size_t buf_size = 16 * 1024;
|
||||||
|
};
|
||||||
|
}
|
278
rd7tf/Makefile
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
.SUFFIXES:
|
||||||
|
#nicetest
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
ifeq ($(strip $(DEVKITARM)),)
|
||||||
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||||
|
endif
|
||||||
|
|
||||||
|
TOPDIR ?= $(CURDIR)
|
||||||
|
include $(DEVKITARM)/3ds_rules
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# TARGET is the name of the output
|
||||||
|
# BUILD is the directory where object files & intermediate files will be placed
|
||||||
|
# SOURCES is a list of directories containing source code
|
||||||
|
# DATA is a list of directories containing data files
|
||||||
|
# INCLUDES is a list of directories containing header files
|
||||||
|
# GRAPHICS is a list of directories containing graphics files
|
||||||
|
# GFXBUILD is the directory where converted graphics files will be placed
|
||||||
|
# If set to $(BUILD), it will statically link in the converted
|
||||||
|
# files as if they were data files.
|
||||||
|
#
|
||||||
|
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||||
|
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
|
||||||
|
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||||
|
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||||
|
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||||
|
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||||
|
# If not set, it attempts to use one of the following (in this order):
|
||||||
|
# - <Project name>.png
|
||||||
|
# - icon.png
|
||||||
|
# - <libctru folder>/default_icon.png
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# External tools
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
MAKEROM ?= C:/devkitpro/tools/bin/makerom.exe
|
||||||
|
BANNERTOOL ?= C:/devkitpro/tools/bin/bannertool.exe
|
||||||
|
|
||||||
|
else
|
||||||
|
MAKEROM ?= makerom
|
||||||
|
BANNERTOOL ?= bannertool
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# If on a tagged commit, use the tag instead of the commit
|
||||||
|
ifneq ($(shell echo $(shell git tag -l --points-at HEAD) | head -c 1),)
|
||||||
|
GIT_VER := $(shell git tag -l --points-at HEAD)
|
||||||
|
else
|
||||||
|
GIT_VER := $(shell git rev-parse --short HEAD)
|
||||||
|
endif
|
||||||
|
|
||||||
|
TIME_TIME := unk
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# Version number
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
VERSION_MAJOR := 1
|
||||||
|
|
||||||
|
VERSION_MINOR := 0
|
||||||
|
|
||||||
|
VERSION_MICRO := 0
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# Make Sure to Change this paths if your Submodule
|
||||||
|
# is located somewhere else
|
||||||
|
# Using ../ cause rd7tf is shipped with the RenderD7
|
||||||
|
# Repository!
|
||||||
|
RENDERD7_SRC := ../source ../external ../source/music
|
||||||
|
RENDERD7_INC := ../include
|
||||||
|
# Libraries used for RenderD7
|
||||||
|
# if you already use -lm, -lctru etc place a # before -lm
|
||||||
|
RENDERD7_LIBS := -lcurl -lm -lcitro2dd -lcitro3d -lctru
|
||||||
|
TARGET := rd7tf
|
||||||
|
BUILD := build
|
||||||
|
SOURCES := source $(RENDERD7_SRC)
|
||||||
|
DATA := data
|
||||||
|
INCLUDES := source $(RENDERD7_INC)
|
||||||
|
GRAPHICS := gfx
|
||||||
|
#GFXBUILD := $(BUILD)
|
||||||
|
ROMFS := romfs
|
||||||
|
GFXBUILD := $(ROMFS)/gfx
|
||||||
|
APP_AUTHOR := NPI-D7
|
||||||
|
APP_DESCRIPTION := RenderD7 Test Framework
|
||||||
|
ICON := app/icon.png
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# options for code generation
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||||
|
|
||||||
|
CFLAGS := -g -Wall -Wno-psabi -O2 -mword-relocations \
|
||||||
|
-DV_STRING=\"$(GIT_VER)\" \
|
||||||
|
-DV_TIME=\"$(TIME_TIME)\" \
|
||||||
|
-ffunction-sections \
|
||||||
|
$(ARCH)
|
||||||
|
|
||||||
|
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
||||||
|
|
||||||
|
ASFLAGS := -g $(ARCH)
|
||||||
|
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
|
LIBS := -lstdc++ $(RENDERD7_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
# include and lib
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
# rules for different file extensions
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||||
|
export TOPDIR := $(CURDIR)
|
||||||
|
|
||||||
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||||
|
|
||||||
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||||
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
|
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
|
||||||
|
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
|
||||||
|
GFXFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.t3s)))
|
||||||
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# use CXX for linking C++ projects, CC for standard C
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(strip $(CPPFILES)),)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CC)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export LD := $(CXX)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
ifeq ($(GFXBUILD),$(BUILD))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export T3XFILES := $(GFXFILES:.t3s=.t3x)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
export ROMFS_T3XFILES := $(patsubst %.t3s, $(GFXBUILD)/%.t3x, $(GFXFILES))
|
||||||
|
export T3XHFILES := $(patsubst %.t3s, $(BUILD)/%.h, $(GFXFILES))
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||||
|
|
||||||
|
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \
|
||||||
|
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.o)
|
||||||
|
|
||||||
|
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES)
|
||||||
|
|
||||||
|
export HFILES := $(PICAFILES:.v.pica=_shbin.h) $(SHLISTFILES:.shlist=_shbin.h) \
|
||||||
|
$(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||||
|
|
||||||
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||||
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||||
|
-I$(CURDIR)/$(BUILD)
|
||||||
|
|
||||||
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||||
|
|
||||||
|
export _3DSXDEPS := $(if $(NO_SMDH),,$(OUTPUT).smdh)
|
||||||
|
|
||||||
|
ifeq ($(strip $(ICON)),)
|
||||||
|
icons := $(wildcard *.png)
|
||||||
|
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||||
|
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||||
|
else
|
||||||
|
ifneq (,$(findstring icon.png,$(icons)))
|
||||||
|
export APP_ICON := $(TOPDIR)/icon.png
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(strip $(NO_SMDH)),)
|
||||||
|
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(ROMFS),)
|
||||||
|
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: $(BUILD) $(GFXBUILD) $(DEPSDIR) $(ROMFS_T3XFILES) $(T3XHFILES)
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
clean:
|
||||||
|
@echo clean ...
|
||||||
|
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).3dsx $(TARGET).cia $(TARGET).smdh app/*.bin
|
||||||
|
@rm -fr $(OUTDIR)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
send:
|
||||||
|
@3dslink -a $(IP) $(TARGET).3dsx
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
run:
|
||||||
|
@flatpak run org.citra_emu.citra $(TARGET).3dsx
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
3dsx: $(BUILD)
|
||||||
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 3dsx
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(GFXBUILD)/%.t3x $(BUILD)/%.h : %.t3s
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
$(DEVKITPRO)/tools/bin/tex3ds -i $< -H $(BUILD)/$*.h -d $(DEPSDIR)/$*.d -o $(GFXBUILD)/$*.t3x
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(BUILD):
|
||||||
|
@[ -d $@ ] || mkdir -p $@
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
else
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# main targets
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
all: $(OUTPUT).elf $(OUTPUT).3dsx
|
||||||
|
|
||||||
|
$(OUTPUT).elf : $(OFILES)
|
||||||
|
$(OUTPUT).3dsx : $(_3DSXDEPS)
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
# you need a rule like this for each extension you use as binary data
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.bin.o %_bin.h : %.bin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
@echo $(notdir $<)
|
||||||
|
@$(bin2o)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
.PRECIOUS : %.t3x %.shbin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.t3x.o %_t3x.h : %.t3x
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(SILENTMSG) $(notdir $<)
|
||||||
|
$(bin2o)
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
%.shbin.o %_shbin.h : %.shbin
|
||||||
|
#---------------------------------------------------------------------------------
|
||||||
|
$(SILENTMSG) $(notdir $<)
|
||||||
|
$(bin2o)
|
||||||
|
|
||||||
|
-include $(DEPSDIR)/*.d
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------------------
|
||||||
|
endif
|
||||||
|
#---------------------------------------------------------------------------------------
|
BIN
rd7tf/app/icon.png
Executable file
After Width: | Height: | Size: 844 B |
9
rd7tf/clean.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#Clean old build
|
||||||
|
echo "Cleaning..."
|
||||||
|
make clean
|
||||||
|
rm -rf libs/*
|
||||||
|
cd ..
|
||||||
|
make clean
|
||||||
|
echo "Done!"
|
BIN
rd7tf/gfx/default_icon.png
Executable file
After Width: | Height: | Size: 949 B |
BIN
rd7tf/gfx/folder.png
Executable file
After Width: | Height: | Size: 5.6 KiB |
BIN
rd7tf/gfx/renderd7.png
Executable file
After Width: | Height: | Size: 13 KiB |
6
rd7tf/gfx/sprites.t3s
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
--atlas -f rgba -z auto
|
||||||
|
|
||||||
|
renderd7.png
|
||||||
|
folder.png
|
||||||
|
default_icon.png
|
||||||
|
unk_icon.png
|
BIN
rd7tf/gfx/unk_icon.png
Executable file
After Width: | Height: | Size: 1.3 KiB |
1
rd7tf/romfs/gfx/Leere Datei
Executable file
@ -0,0 +1 @@
|
|||||||
|
vcx
|
BIN
rd7tf/romfs/gfx/bg.png
Executable file
After Width: | Height: | Size: 149 KiB |