Compare commits
7 Commits
v0.9.4
...
095-260620
Author | SHA1 | Date | |
---|---|---|---|
c6804dfc03 | |||
a671631dde | |||
566485ccd6 | |||
267f9ce5c3 | |||
5cca34ede4 | |||
5695110739 | |||
476bd93aa7 |
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
|
||||
...
|
||||
|
2
.gitignore
vendored
@ -2,3 +2,5 @@ release/
|
||||
debug/
|
||||
lib/
|
||||
*.bz2
|
||||
rd7le/
|
||||
*.DS_Store*
|
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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
18
.vscode/settings.json
vendored
@ -97,6 +97,22 @@
|
||||
"cfenv": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"variant": "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"
|
||||
}
|
||||
}
|
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
|
8
Makefile
@ -32,7 +32,7 @@ TIME_TIME := $(shell date --iso=seconds)
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := renderd7
|
||||
SOURCES := source external/source
|
||||
SOURCES := source source/external source/music
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
@ -41,9 +41,9 @@ INCLUDES := include
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
|
||||
CFLAGS := -g -Wall -Werror -mword-relocations -save-temps\
|
||||
-DV_STRING=\"$(GIT_VER)\" \
|
||||
-DV_TIME=\"$(TIME_TIME)\" \
|
||||
CFLAGS := -g -Wall -mword-relocations -save-temps\
|
||||
-DV_RD7CSTRING=\"$(GIT_VER)\" \
|
||||
-DV_RD7BTIME=\"$(TIME_TIME)\" \
|
||||
-ffunction-sections -fdata-sections \
|
||||
$(ARCH) $(BUILD_CFLAGS)
|
||||
|
||||
|
21
README.md
@ -1,8 +1,8 @@
|
||||
# <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/blob/main/logo.png" height="90">
|
||||
# <img alt="LOGO" src="https://github.com/NPI-D7/RenderD7/raw/main/logo.png" height="90">
|
||||
RenderD7 is now LibRenderD7.
|
||||
### Installation
|
||||
Download a Package From Releses Page
|
||||
`https://github.com/NPI-D7/RenderD7/releases/download/v0.9.3/renderd7.tar.bz2 -o renderd7.tar.bz2`
|
||||
`https://github.com/NPI-D7/RenderD7/releases/download/v0.9.4/renderd7.tar.bz2 -o renderd7.tar.bz2`
|
||||
Then Extract it to your Libraries Path
|
||||
`bzip2 -cd renderd7.tar.bz2 | tar -xf - -C path_to_your_libs`
|
||||
Finally put `-lrenderd7` to the First Place and add the path_to_your_libs
|
||||
@ -32,6 +32,23 @@ Example-App
|
||||
└── 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
|
||||
|
@ -23,9 +23,6 @@ do
|
||||
../../tools/bin/file2array "${file}" "${name}"
|
||||
done
|
||||
|
||||
echo "Convert Npi-Intro to C++ Code"
|
||||
../../tools/bin/file2array ../splash/npi_intro.nvid npi_intro
|
||||
|
||||
echo "Fix The Output of file2array"
|
||||
for file in ./*.cpp
|
||||
do
|
||||
|
@ -1,2 +0,0 @@
|
||||
# Source
|
||||
https://icons8.de/
|
Before Width: | Height: | Size: 900 B |
Before Width: | Height: | Size: 739 B |
Before Width: | Height: | Size: 388 B |
Before Width: | Height: | Size: 394 B |
Before Width: | Height: | Size: 437 B |
Before Width: | Height: | Size: 445 B |
Before Width: | Height: | Size: 440 B |
Before Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 638 B |
@ -1,11 +0,0 @@
|
||||
--atlas -f rgba -z auto
|
||||
|
||||
battery/battery_full.png
|
||||
battery/battery_nearfull.png
|
||||
battery/battery_half.png
|
||||
battery/battery_low.png
|
||||
battery/battery_verylow.png
|
||||
battery/battery_warning.png
|
||||
battery/battery_charging.png
|
||||
battery/battery_empty.png
|
||||
battery/battery_dead.png
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 17 KiB |
@ -1,19 +0,0 @@
|
||||
--atlas -f rgba -z auto
|
||||
|
||||
ui_elements/high_volume.png
|
||||
ui_elements/mid_volume.png
|
||||
ui_elements/low_volume.png
|
||||
ui_elements/speaker_v1.png
|
||||
ui_elements/no_sound.png
|
||||
ui_elements/speaker.png
|
||||
|
||||
ui_elements/wifi_connected.png
|
||||
ui_elements/wifi_disconnected.png
|
||||
ui_elements/wifi_off.png
|
||||
|
||||
ui_elements/good_connection.png
|
||||
ui_elements/mid_connection.png
|
||||
ui_elements/bad_connection.png
|
||||
ui_elements/no_connection.png
|
||||
|
||||
ui_elements/headphones.png
|
@ -1,2 +0,0 @@
|
||||
# Source
|
||||
https://icons8.de/
|
Before Width: | Height: | Size: 392 B |
Before Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 964 B |
Before Width: | Height: | Size: 400 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 681 B |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.3 KiB |
3185
external/source/jpgd.cpp
vendored
1246
external/source/jpge.cpp
vendored
@ -1,5 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/StealConsole.hpp>
|
||||
#include <renderd7/bmp.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,219 +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 {
|
||||
/// @brief Encoder
|
||||
enum Encoder {
|
||||
BITMAP, ///< Encode Data to Bitmap
|
||||
DIRECT, ///< Encode Direct to Framebuffer(No Decoder Required)
|
||||
C3D ///< Encode Directly to C3D_Tex (Just an Idea)
|
||||
};
|
||||
|
||||
/// @brief Decoder
|
||||
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)
|
||||
};
|
||||
|
||||
/// @brief BitmapPrinetr Class
|
||||
class BitmapPrinter {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
/// @param w Widrth
|
||||
/// @param h Height
|
||||
BitmapPrinter(int w, int h);
|
||||
/// @brief Deconstructor
|
||||
~BitmapPrinter();
|
||||
/// @brief Dexode Bitmap File
|
||||
/// @param file path to File
|
||||
/// @return success ?
|
||||
bool DecodeFile(std::string file);
|
||||
|
||||
/// @brief Set the Decoder
|
||||
/// @param deccc Decoder
|
||||
void SetDecoder(Decoder deccc) { decc = deccc; }
|
||||
/// @brief Draw a Pixel
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param b color blue
|
||||
/// @param g color green
|
||||
/// @param r color red
|
||||
/// @param a color alpha
|
||||
void DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a);
|
||||
/// @brief Draw Rectangle
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param w width
|
||||
/// @param h height
|
||||
/// @param line_w line width
|
||||
/// @param b color blue
|
||||
/// @param g color green
|
||||
/// @param r color red
|
||||
/// @param a colr alpha
|
||||
void DrawRect(int x, int y, int w, int h, u8 line_w, u8 b, u8 g, u8 r, u8 a);
|
||||
/// @brief Draw a Fillif Rectangle
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param w width
|
||||
/// @param h height
|
||||
/// @param b color blue
|
||||
/// @param g color green
|
||||
/// @param r color red
|
||||
/// @param a color alpha
|
||||
void DrawRectFilled(int x, int y, int w, int h, u8 b, u8 g, u8 r, u8 a);
|
||||
/// @brief Draw Bitmap
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param map Bitmap to Print
|
||||
void DrawBitmap(int x, int y, BMP map);
|
||||
/// @brief Use Prebuild Bitmap
|
||||
/// @param map bitmap
|
||||
void UsePreMap(BMP map);
|
||||
/// @brief Use Prebuild Printer Setup
|
||||
/// @param printmap Printer
|
||||
void UsePrePrintMap(BitmapPrinter printmap);
|
||||
/// @brief Get Bitmap
|
||||
/// @return Bitmap
|
||||
BMP GetBitmap() { return bitmap; }
|
||||
/// @brief Save to File
|
||||
/// @param name Name/Path
|
||||
void SaveBmp(std::string name);
|
||||
/// @brief Save as Png
|
||||
/// @param name Name/Path
|
||||
void SavePng(std::string name);
|
||||
|
||||
/// @brief Setup Screen
|
||||
/// @param target Screen
|
||||
void CreateScreen(C3D_RenderTarget *target);
|
||||
/// @brief Draw Directly to Screen With Framerate
|
||||
/// @param framerate Framerate
|
||||
/// @return
|
||||
bool DrawScreenDirectF(int framerate);
|
||||
/// @brief Draw Directly to Screen
|
||||
/// @return
|
||||
bool DrawScreenDirect();
|
||||
/// @brief Render on Screen by Framerate
|
||||
/// @param framerate Framerate
|
||||
void DrawScreenF(int framerate);
|
||||
/// @brief Draw to Screen
|
||||
void DrawScreen();
|
||||
/// @brief Update Image by Framerate
|
||||
/// @param framerate Framerate
|
||||
/// @return
|
||||
bool UpdateScreenF(int framerate);
|
||||
/// @brief Update Image
|
||||
/// @return
|
||||
bool UpdateScreen();
|
||||
/// @brief Clear by Color
|
||||
/// @param b color blue
|
||||
/// @param g color green
|
||||
/// @param r color red
|
||||
/// @param a color alpha
|
||||
void Clear(u8 b = 0, u8 g = 0, u8 r = 0, u8 a = 255);
|
||||
/// @brief Clear Completly Blank
|
||||
void ClearBlank();
|
||||
/// @brief Get Rendered Image
|
||||
/// @return Image
|
||||
RenderD7::Image GetImage();
|
||||
/// Test to Find out The Best Settings for BitmapPrinter
|
||||
void Benchmark();
|
||||
/// @brief Setup the Benchmark
|
||||
/// \param framerate The Fps of the ScreenUpdates
|
||||
void SetupBenchmark(int framerate);
|
||||
/// @brief Check if Benchmark is Running
|
||||
/// @return is running or not
|
||||
bool IsBenchmarkRunning() { return this->benchmark; }
|
||||
|
||||
/// @brief Draw a Dubug Text
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param t_size Size of the Text
|
||||
/// @param color Color of the Text
|
||||
/// @param text String of the Text
|
||||
void DrawDebugText(int x, int y, int t_size, u32 color, std::string text);
|
||||
/// @brief Draw a Text width NFontApi (TTF)
|
||||
/// @param x pos x
|
||||
/// @param y pos y
|
||||
/// @param t_size size of the Text
|
||||
/// @param color Color of The Text
|
||||
/// @param text String of The Text
|
||||
/// @param font TTF Font
|
||||
void DrawText(int x, int y, float t_size, u32 color, std::string text,
|
||||
RenderD7::NFontApi font);
|
||||
|
||||
private:
|
||||
// funcs
|
||||
|
||||
/// @brief Decode 2 RenderD7::Image
|
||||
/// @param deccc Decoder
|
||||
/// @return
|
||||
bool Decode(Decoder deccc);
|
||||
/// @brief Draw Char Func
|
||||
/// @param posX pos x
|
||||
/// @param posY pos y
|
||||
/// @param t_size size
|
||||
/// @param color color
|
||||
/// @param character char
|
||||
void DrawDebugChar(u32 posX, u32 posY, int t_size, u32 color, char character);
|
||||
/// @brief NFont Draw Char
|
||||
/// @param posX pos x
|
||||
/// @param posY pos y
|
||||
/// @param t_size size
|
||||
/// @param color color
|
||||
/// @param character char
|
||||
/// @param font ttf
|
||||
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,36 +1,155 @@
|
||||
#pragma once
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
#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)
|
||||
// it is actually not RGBA lol
|
||||
inline uint32_t RGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) {
|
||||
#define ISIMPLEPAK(x, y) (((x) & 0xff) << y)
|
||||
return (ISIMPLEPAK(r, 0) | ISIMPLEPAK(g, 8) | ISIMPLEPAK(b, 16) |
|
||||
ISIMPLEPAK(a, 24));
|
||||
}
|
||||
|
||||
/*#define RGBA8(r, g, b, a) \
|
||||
((((r)&0xFF) << 0) | (((g)&0xFF) << 8) | (((b)&0xFF) << 16) | \
|
||||
(((a)&0xFF) << 24))*/
|
||||
|
||||
typedef int RD7Color;
|
||||
|
||||
// MultiColor (Less FunctionNameLen)
|
||||
|
||||
struct Color2 {
|
||||
unsigned int color0;
|
||||
unsigned int color1;
|
||||
};
|
||||
|
||||
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 Struct
|
||||
struct rgba {
|
||||
/// @brief rgba Colors
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
/// @brief RGBA Class
|
||||
class RGBA {
|
||||
public:
|
||||
public:
|
||||
/// @brief Construct
|
||||
/// @param r
|
||||
/// @param g
|
||||
/// @param b
|
||||
/// @param a
|
||||
RGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t 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 (m_r << 24) | (m_g << 16) | (m_b << 8) | m_a;
|
||||
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;
|
||||
@ -46,5 +165,5 @@ std::string RGB2Hex(int r, int g, int b);
|
||||
/// @param a
|
||||
/// @return Color32
|
||||
uint32_t Hex(const std::string &color, uint8_t a = 255);
|
||||
} // namespace Color
|
||||
} // namespace RenderD7
|
||||
} // namespace Color
|
||||
} // namespace RenderD7
|
@ -1,111 +0,0 @@
|
||||
#pragma once
|
||||
#include <3ds.h>
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Draw {
|
||||
/// @brief Draw Rectangle
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param w Width
|
||||
/// @param h Height
|
||||
/// @param color Color
|
||||
/// @return success ?
|
||||
bool Rect(float x, float y, float w, float h, u32 color);
|
||||
/// @brief Draw a not filled Rectangle
|
||||
/// @param p1x Pos X
|
||||
/// @param p1y Pos Y
|
||||
/// @param w Width
|
||||
/// @param h Height
|
||||
/// @param color Color
|
||||
/// @param scale Scale
|
||||
/// @return success ?
|
||||
bool NFRect(float p1x, float p1y, float w, float h, u32 color, float scale = 1);
|
||||
/// @brief Draw A Pixel
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param color Color
|
||||
/// @return success ?
|
||||
bool Px(float x, float y, u32 color);
|
||||
/// @brief Draw a Centered Text
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param size Scale of the Text
|
||||
/// @param color Color of The Text
|
||||
/// @param Text Striing to Display
|
||||
/// @param maxWidth Width to Calculate Centered Pos
|
||||
/// @param maxHeight Height to Calculate Centered Pos
|
||||
/// @param fnt Custom Font
|
||||
void TextCentered(float x, float y, float size, u32 color, std::string Text,
|
||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
/// @brief Draw a Text
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param size Scale of the Text
|
||||
/// @param color Color of The Text
|
||||
/// @param Text Striing to Display
|
||||
/// @param maxWidth Width to Calculate Centered Pos
|
||||
/// @param maxHeight Height to Calculate Centered Pos
|
||||
/// @param fnt Custom Font
|
||||
void Text(float x, float y, float size, u32 color, std::string Text,
|
||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
/// @brief Draw a Text Set to the Right
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param size Scale of the Text
|
||||
/// @param color Color of The Text
|
||||
/// @param Text Striing to Display
|
||||
/// @param maxWidth Width to Calculate Centered Pos
|
||||
/// @param maxHeight Height to Calculate Centered Pos
|
||||
/// @param fnt Custom Font
|
||||
void TextRight(float x, float y, float size, u32 color, std::string Text,
|
||||
int maxWidth = 0, int maxHeight = 0, C2D_Font fnt = nullptr);
|
||||
/// @brief Get Width of Text
|
||||
/// @param size Size of the Text
|
||||
/// @param Text String of The text
|
||||
/// @param fnt Custom Font
|
||||
/// @return The Size
|
||||
float GetTextWidth(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
/// @brief Get Text Size
|
||||
/// @param size Size of The Text
|
||||
/// @param width Width of the Text
|
||||
/// @param height Height of The Text
|
||||
/// @param Text String of Text
|
||||
/// @param fnt Custom Font
|
||||
void GetTextSize(float size, float *width, float *height, std::string Text,
|
||||
C2D_Font fnt = nullptr);
|
||||
/// @brief Get Height of the Text
|
||||
/// @param size Size of the Text
|
||||
/// @param Text String of the Text
|
||||
/// @param fnt Custom Font
|
||||
/// @return The Height
|
||||
float GetTextHeight(float size, std::string Text, C2D_Font fnt = nullptr);
|
||||
/// @brief Load A .bcfnt
|
||||
/// @param fnt Output Font
|
||||
/// @param Path path of The File
|
||||
/// @return Result Code
|
||||
Result LoadFont(C2D_Font &fnt, const char *Path = "");
|
||||
/// @brief Unload a Font
|
||||
/// @param fnt Font to Unload
|
||||
/// @return Result Code
|
||||
Result UnloadFont(C2D_Font &fnt);
|
||||
/// @brief Draw a Circle
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param radius Radius of the Circle
|
||||
/// @param color Color of the circle
|
||||
/// @return success ?
|
||||
bool Circle(float x, float y, float radius, u32 color);
|
||||
/// @brief Draw A Citro2D Image
|
||||
/// @param img Image to Draw
|
||||
/// @param x Pos X
|
||||
/// @param y Pos Y
|
||||
/// @param scaleX Scale of X-Axis
|
||||
/// @param scaleY Scale of Y-Axis
|
||||
/// @return success ?
|
||||
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,5 +1,3 @@
|
||||
// FileSystem based on libphyfs based on
|
||||
// https://github.com/TurtleP/3ds-examples/blob/fs/physfs/fs/physfs/include/filesystem.h
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -19,5 +17,9 @@ struct Entry {
|
||||
/// @param path The Path of the Directory
|
||||
/// @return The Vector of found Entrys
|
||||
std::vector<RenderD7::FileSystem::Entry> GetDirContent(std::string path);
|
||||
std::string GetParentPath(std::string path, std::string mount_point);
|
||||
std::vector<Entry>
|
||||
GetDirContentsExt(std::string &path,
|
||||
const std::vector<std::string> &extensions);
|
||||
} // namespace FileSystem
|
||||
} // 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
|
@ -24,6 +24,7 @@ struct FTRes {
|
||||
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
|
||||
|
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,50 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
#include <memory>
|
||||
#include <3ds.h>
|
||||
|
||||
#include <renderd7/Sheet.hpp>
|
||||
#include <renderd7/bmp.hpp>
|
||||
#include <renderd7/bmpconverter.hpp>
|
||||
#include <renderd7/R7Vec.hpp>
|
||||
#include <renderd7/nimg.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/external/lodepng.h>
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// Image Class
|
||||
class Image {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
Image() {}
|
||||
/// @brief Deconstructor
|
||||
~Image();
|
||||
/// @brief Unload The Image
|
||||
void Unload();
|
||||
/// Load Image from Png
|
||||
/// \param path path to png file
|
||||
void LoadPng(const std::string path);
|
||||
/// Load the Image from buffer
|
||||
/// \param buffer the frame buffer
|
||||
void LoadPFromBuffer(const std::vector<u8> &buffer);
|
||||
void LoadFromBitmap(BMP bitmap);
|
||||
void LoadJpg(std::string path);
|
||||
void LoadPixels(int w, int h, int bpp, void *buffer);
|
||||
/// 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; }
|
||||
class Image {
|
||||
public:
|
||||
Image();
|
||||
~Image();
|
||||
void load(const std::string& path);
|
||||
void from_nimg(const nimg& image);
|
||||
|
||||
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
|
||||
C2D_Image get();
|
||||
C2D_Image& get_ref();
|
||||
void set(const C2D_Image& i);
|
||||
R7Vec2 get_size();
|
||||
bool loaded();
|
||||
|
||||
private:
|
||||
void safe_del();
|
||||
bool ld = false;
|
||||
C2D_Image img;
|
||||
};
|
||||
}
|
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);
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/Ovl.hpp>
|
||||
|
||||
namespace RenderD7 {
|
||||
class Ovl_Ftrace : public RenderD7::Ovl {
|
||||
/// @brief Constructor
|
||||
Ovl_Ftrace();
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
};
|
||||
class Ovl_UiBattery : public RenderD7::Ovl {
|
||||
/// @brief Constructor
|
||||
/// @param percentage Percentage
|
||||
Ovl_UiBattery(float *percentage);
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
float *_pct_addr = 0;
|
||||
};
|
||||
class Ovl_UiSound : public RenderD7::Ovl {
|
||||
/// @brief Constructor
|
||||
/// @param percentage Percentage
|
||||
Ovl_UiSound(float *percentage);
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
float *_pct_addr = 0;
|
||||
};
|
||||
class Ovl_Ui3d : public RenderD7::Ovl {
|
||||
/// @brief Constructor
|
||||
/// @param percentage Percentage
|
||||
Ovl_Ui3d(float *percentage);
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
float *_pct_addr = 0;
|
||||
};
|
||||
class Ovl_UiWifi : public RenderD7::Ovl {
|
||||
/// @brief Constructor
|
||||
/// @param level strengh level
|
||||
Ovl_UiWifi(uint8_t *level);
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
uint8_t *_pct_addr = 0;
|
||||
};
|
||||
} // namespace RenderD7
|
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
|
@ -24,7 +24,4 @@ private:
|
||||
/// @brief Add an Overlay to the Screen
|
||||
/// @param scene Overlay to push to Screen
|
||||
void AddOvl(std::unique_ptr<RenderD7::Ovl> scene);
|
||||
/// @brief Add an Overlay to the Toast Stack
|
||||
/// @param scene Overlay to push to Toast Stack
|
||||
void AddToast(std::unique_ptr<RenderD7::Ovl> scene);
|
||||
} // 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;
|
||||
};
|
@ -43,6 +43,8 @@ public:
|
||||
/// @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
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
#include <3ds.h> // Result
|
||||
#include <string>
|
||||
|
||||
namespace RenderD7 {
|
||||
/// @brief SpriteSheet Class
|
||||
@ -13,7 +15,7 @@ public:
|
||||
/// @brief Load A Spritesheet File
|
||||
/// @param path Path to the t3x
|
||||
/// @return Result Code
|
||||
Result Load(const char *path);
|
||||
Result Load(const std::string& path);
|
||||
/// @brief Unload the Sheet
|
||||
void Free();
|
||||
/// \param spritesheet The Sheet
|
||||
|
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,30 +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 {
|
||||
/// @brief Toast Class
|
||||
class Toast : public RenderD7::Ovl {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
/// @param head Displayed String in Head
|
||||
/// @param msg Displayed String in Message Box
|
||||
Toast(std::string head, std::string msg);
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
/// @param head The Header Text
|
||||
/// @param nsg The Message-Box Text
|
||||
std::string head, msg;
|
||||
/// @param msgposy Position Y of The Toast
|
||||
int msgposy = 240;
|
||||
/// @param delay Delay of the Toast
|
||||
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,5 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
extern unsigned char battery_icons[];
|
||||
extern size_t battery_icons_size;
|
@ -1,707 +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)
|
||||
|
||||
class BMP {
|
||||
public:
|
||||
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"));
|
||||
std::cout << buffer.size() << std::endl;
|
||||
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. Header " +
|
||||
// std::to_string(file_header.file_type));
|
||||
}
|
||||
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. Size");
|
||||
}
|
||||
}
|
||||
|
||||
// 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 buffer");
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
// std::string errr = "The point is outside the image boundaries! -> " +
|
||||
// std::to_string(x0) + "," + std::to_string(y0); throw
|
||||
// std::runtime_error(errr);
|
||||
}
|
||||
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! ->
|
||||
// " + std::to_string(x0) + "," + std::to_string(y1));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t get_pixel(uint32_t x0, uint32_t y0) {
|
||||
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;
|
||||
uint32_t outcol = 0;
|
||||
uint8_t red = 0;
|
||||
uint8_t green = 0;
|
||||
uint8_t blue = 0;
|
||||
uint8_t alpha = 255;
|
||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
||||
if (channels == 4) {
|
||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
||||
}
|
||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
||||
return outcol;
|
||||
}
|
||||
|
||||
uint32_t get_pixel_df(uint32_t x0, uint32_t y0) {
|
||||
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 0; // throw std::runtime_error("The point is outside the image
|
||||
// boundaries!");
|
||||
}
|
||||
|
||||
uint32_t channels = bmp_info_header.bit_count / 8;
|
||||
uint32_t outcol = 0;
|
||||
uint8_t red = 0;
|
||||
uint8_t green = 0;
|
||||
uint8_t blue = 0;
|
||||
uint8_t alpha = 255;
|
||||
blue = data[channels * (y0 * bmp_info_header.width + x0) + 0];
|
||||
green = data[channels * (y0 * bmp_info_header.width + x0) + 1];
|
||||
red = data[channels * (y0 * bmp_info_header.width + x0) + 2];
|
||||
if (channels == 4) {
|
||||
alpha = data[channels * (y0 * bmp_info_header.width + x0) + 3];
|
||||
}
|
||||
outcol = ((red << 24) | (green << 16) | (blue << 8) | alpha);
|
||||
return outcol;
|
||||
}
|
||||
|
||||
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,21 +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);
|
||||
|
||||
/// @brief Convert A File
|
||||
/// @param filename
|
||||
/// @return data
|
||||
std::vector<unsigned char> ConvertFile(std::string filename);
|
||||
/// @brief Convert data
|
||||
/// @param data
|
||||
/// @return data
|
||||
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
422
include/renderd7/external/jpgd.h
vendored
@ -1,422 +0,0 @@
|
||||
// jpgd.h - C++ class for JPEG decompression.
|
||||
// Richard Geldreich <richgel99@gmail.com>
|
||||
// See jpgd.cpp for license (Public Domain or Apache 2.0).
|
||||
#ifndef JPEG_DECODER_H
|
||||
#define JPEG_DECODER_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <cinttypes>
|
||||
#include <setjmp.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define JPGD_NORETURN __declspec(noreturn)
|
||||
#elif defined(__GNUC__)
|
||||
#define JPGD_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
#define JPGD_NORETURN
|
||||
#endif
|
||||
|
||||
#define JPGD_HUFF_TREE_MAX_LENGTH 512
|
||||
#define JPGD_HUFF_CODE_SIZE_MAX_LENGTH 256
|
||||
|
||||
namespace jpgd {
|
||||
typedef unsigned char uint8;
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint;
|
||||
typedef signed int int32;
|
||||
|
||||
// Loads a JPEG image from a memory buffer or a file.
|
||||
// req_comps can be 1 (grayscale), 3 (RGB), or 4 (RGBA).
|
||||
// On return, width/height will be set to the image's dimensions, and
|
||||
// actual_comps will be set to the either 1 (grayscale) or 3 (RGB). Notes: For
|
||||
// more control over where and how the source data is read, see the
|
||||
// decompress_jpeg_image_from_stream() function below, or call the jpeg_decoder
|
||||
// class directly. Requesting a 8 or 32bpp image is currently a little faster
|
||||
// than 24bpp because the jpeg_decoder class itself currently always unpacks to
|
||||
// either 8 or 32bpp.
|
||||
unsigned char *decompress_jpeg_image_from_memory(const unsigned char *pSrc_data,
|
||||
int src_data_size, int *width,
|
||||
int *height, int *actual_comps,
|
||||
int req_comps,
|
||||
uint32_t flags = 0);
|
||||
unsigned char *decompress_jpeg_image_from_file(const char *pSrc_filename,
|
||||
int *width, int *height,
|
||||
int *actual_comps, int req_comps,
|
||||
uint32_t flags = 0);
|
||||
|
||||
// Success/failure error codes.
|
||||
enum jpgd_status {
|
||||
JPGD_SUCCESS = 0,
|
||||
JPGD_FAILED = -1,
|
||||
JPGD_DONE = 1,
|
||||
JPGD_BAD_DHT_COUNTS = -256,
|
||||
JPGD_BAD_DHT_INDEX,
|
||||
JPGD_BAD_DHT_MARKER,
|
||||
JPGD_BAD_DQT_MARKER,
|
||||
JPGD_BAD_DQT_TABLE,
|
||||
JPGD_BAD_PRECISION,
|
||||
JPGD_BAD_HEIGHT,
|
||||
JPGD_BAD_WIDTH,
|
||||
JPGD_TOO_MANY_COMPONENTS,
|
||||
JPGD_BAD_SOF_LENGTH,
|
||||
JPGD_BAD_VARIABLE_MARKER,
|
||||
JPGD_BAD_DRI_LENGTH,
|
||||
JPGD_BAD_SOS_LENGTH,
|
||||
JPGD_BAD_SOS_COMP_ID,
|
||||
JPGD_W_EXTRA_BYTES_BEFORE_MARKER,
|
||||
JPGD_NO_ARITHMITIC_SUPPORT,
|
||||
JPGD_UNEXPECTED_MARKER,
|
||||
JPGD_NOT_JPEG,
|
||||
JPGD_UNSUPPORTED_MARKER,
|
||||
JPGD_BAD_DQT_LENGTH,
|
||||
JPGD_TOO_MANY_BLOCKS,
|
||||
JPGD_UNDEFINED_QUANT_TABLE,
|
||||
JPGD_UNDEFINED_HUFF_TABLE,
|
||||
JPGD_NOT_SINGLE_SCAN,
|
||||
JPGD_UNSUPPORTED_COLORSPACE,
|
||||
JPGD_UNSUPPORTED_SAMP_FACTORS,
|
||||
JPGD_DECODE_ERROR,
|
||||
JPGD_BAD_RESTART_MARKER,
|
||||
JPGD_BAD_SOS_SPECTRAL,
|
||||
JPGD_BAD_SOS_SUCCESSIVE,
|
||||
JPGD_STREAM_READ,
|
||||
JPGD_NOTENOUGHMEM,
|
||||
JPGD_TOO_MANY_SCANS
|
||||
};
|
||||
|
||||
// Input stream interface.
|
||||
// Derive from this class to read input data from sources other than files or
|
||||
// memory. Set m_eof_flag to true when no more data is available. The decoder is
|
||||
// rather greedy: it will keep on calling this method until its internal input
|
||||
// buffer is full, or until the EOF flag is set. It the input stream contains
|
||||
// data after the JPEG stream's EOI (end of image) marker it will probably be
|
||||
// pulled into the internal buffer. Call the get_total_bytes_read() method to
|
||||
// determine the actual size of the JPEG stream after successful decoding.
|
||||
class jpeg_decoder_stream {
|
||||
public:
|
||||
jpeg_decoder_stream() {}
|
||||
virtual ~jpeg_decoder_stream() {}
|
||||
|
||||
// The read() method is called when the internal input buffer is empty.
|
||||
// Parameters:
|
||||
// pBuf - input buffer
|
||||
// max_bytes_to_read - maximum bytes that can be written to pBuf
|
||||
// pEOF_flag - set this to true if at end of stream (no more bytes remaining)
|
||||
// Returns -1 on error, otherwise return the number of bytes actually written
|
||||
// to the buffer (which may be 0). Notes: This method will be called in a loop
|
||||
// until you set *pEOF_flag to true or the internal buffer is full.
|
||||
virtual int read(uint8 *pBuf, int max_bytes_to_read, bool *pEOF_flag) = 0;
|
||||
};
|
||||
|
||||
// stdio FILE stream class.
|
||||
class jpeg_decoder_file_stream : public jpeg_decoder_stream {
|
||||
jpeg_decoder_file_stream(const jpeg_decoder_file_stream &);
|
||||
jpeg_decoder_file_stream &operator=(const jpeg_decoder_file_stream &);
|
||||
|
||||
FILE *m_pFile;
|
||||
bool m_eof_flag, m_error_flag;
|
||||
|
||||
public:
|
||||
jpeg_decoder_file_stream();
|
||||
virtual ~jpeg_decoder_file_stream();
|
||||
|
||||
bool open(const char *Pfilename);
|
||||
void close();
|
||||
|
||||
virtual int read(uint8 *pBuf, int max_bytes_to_read, bool *pEOF_flag);
|
||||
};
|
||||
|
||||
// Memory stream class.
|
||||
class jpeg_decoder_mem_stream : public jpeg_decoder_stream {
|
||||
const uint8 *m_pSrc_data;
|
||||
uint m_ofs, m_size;
|
||||
|
||||
public:
|
||||
jpeg_decoder_mem_stream() : m_pSrc_data(NULL), m_ofs(0), m_size(0) {}
|
||||
jpeg_decoder_mem_stream(const uint8 *pSrc_data, uint size)
|
||||
: m_pSrc_data(pSrc_data), m_ofs(0), m_size(size) {}
|
||||
|
||||
virtual ~jpeg_decoder_mem_stream() {}
|
||||
|
||||
bool open(const uint8 *pSrc_data, uint size);
|
||||
void close() {
|
||||
m_pSrc_data = NULL;
|
||||
m_ofs = 0;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
virtual int read(uint8 *pBuf, int max_bytes_to_read, bool *pEOF_flag);
|
||||
};
|
||||
|
||||
// Loads JPEG file from a jpeg_decoder_stream.
|
||||
unsigned char *decompress_jpeg_image_from_stream(jpeg_decoder_stream *pStream,
|
||||
int *width, int *height,
|
||||
int *actual_comps,
|
||||
int req_comps,
|
||||
uint32_t flags = 0);
|
||||
|
||||
enum {
|
||||
JPGD_IN_BUF_SIZE = 8192,
|
||||
JPGD_MAX_BLOCKS_PER_MCU = 10,
|
||||
JPGD_MAX_HUFF_TABLES = 8,
|
||||
JPGD_MAX_QUANT_TABLES = 4,
|
||||
JPGD_MAX_COMPONENTS = 4,
|
||||
JPGD_MAX_COMPS_IN_SCAN = 4,
|
||||
JPGD_MAX_BLOCKS_PER_ROW = 16384,
|
||||
JPGD_MAX_HEIGHT = 32768,
|
||||
JPGD_MAX_WIDTH = 32768
|
||||
};
|
||||
|
||||
typedef int16 jpgd_quant_t;
|
||||
typedef int16 jpgd_block_coeff_t;
|
||||
|
||||
class jpeg_decoder {
|
||||
public:
|
||||
enum { cFlagBoxChromaFiltering = 1, cFlagDisableSIMD = 2 };
|
||||
|
||||
// Call get_error_code() after constructing to determine if the stream is
|
||||
// valid or not. You may call the get_width(), get_height(), etc. methods
|
||||
// after the constructor is called. You may then either destruct the object,
|
||||
// or begin decoding the image by calling begin_decoding(), then decode() on
|
||||
// each scanline.
|
||||
jpeg_decoder(jpeg_decoder_stream *pStream, uint32_t flags = 0);
|
||||
|
||||
~jpeg_decoder();
|
||||
|
||||
// Call this method after constructing the object to begin decompression.
|
||||
// If JPGD_SUCCESS is returned you may then call decode() on each scanline.
|
||||
|
||||
int begin_decoding();
|
||||
|
||||
// Returns the next scan line.
|
||||
// For grayscale images, pScan_line will point to a buffer containing 8-bit
|
||||
// pixels (get_bytes_per_pixel() will return 1). Otherwise, it will always
|
||||
// point to a buffer containing 32-bit RGBA pixels (A will always be 255, and
|
||||
// get_bytes_per_pixel() will return 4). Returns JPGD_SUCCESS if a scan line
|
||||
// has been returned. Returns JPGD_DONE if all scan lines have been returned.
|
||||
// Returns JPGD_FAILED if an error occurred. Call get_error_code() for a more
|
||||
// info.
|
||||
int decode(const void **pScan_line, uint *pScan_line_len);
|
||||
|
||||
inline jpgd_status get_error_code() const { return m_error_code; }
|
||||
|
||||
inline int get_width() const { return m_image_x_size; }
|
||||
inline int get_height() const { return m_image_y_size; }
|
||||
|
||||
inline int get_num_components() const { return m_comps_in_frame; }
|
||||
|
||||
inline int get_bytes_per_pixel() const { return m_dest_bytes_per_pixel; }
|
||||
inline int get_bytes_per_scan_line() const {
|
||||
return m_image_x_size * get_bytes_per_pixel();
|
||||
}
|
||||
|
||||
// Returns the total number of bytes actually consumed by the decoder (which
|
||||
// should equal the actual size of the JPEG file).
|
||||
inline int get_total_bytes_read() const { return m_total_bytes_read; }
|
||||
|
||||
private:
|
||||
jpeg_decoder(const jpeg_decoder &);
|
||||
jpeg_decoder &operator=(const jpeg_decoder &);
|
||||
|
||||
typedef void (*pDecode_block_func)(jpeg_decoder *, int, int, int);
|
||||
|
||||
struct huff_tables {
|
||||
bool ac_table;
|
||||
uint look_up[256];
|
||||
uint look_up2[256];
|
||||
uint8 code_size[JPGD_HUFF_CODE_SIZE_MAX_LENGTH];
|
||||
uint tree[JPGD_HUFF_TREE_MAX_LENGTH];
|
||||
};
|
||||
|
||||
struct coeff_buf {
|
||||
uint8 *pData;
|
||||
int block_num_x, block_num_y;
|
||||
int block_len_x, block_len_y;
|
||||
int block_size;
|
||||
};
|
||||
|
||||
struct mem_block {
|
||||
mem_block *m_pNext;
|
||||
size_t m_used_count;
|
||||
size_t m_size;
|
||||
char m_data[1];
|
||||
};
|
||||
|
||||
jmp_buf m_jmp_state;
|
||||
uint32_t m_flags;
|
||||
mem_block *m_pMem_blocks;
|
||||
int m_image_x_size;
|
||||
int m_image_y_size;
|
||||
jpeg_decoder_stream *m_pStream;
|
||||
|
||||
int m_progressive_flag;
|
||||
|
||||
uint8 m_huff_ac[JPGD_MAX_HUFF_TABLES];
|
||||
uint8 *m_huff_num[JPGD_MAX_HUFF_TABLES]; // pointer to number of Huffman codes
|
||||
// per bit size
|
||||
uint8 *
|
||||
m_huff_val[JPGD_MAX_HUFF_TABLES]; // pointer to Huffman codes per bit size
|
||||
jpgd_quant_t
|
||||
*m_quant[JPGD_MAX_QUANT_TABLES]; // pointer to quantization tables
|
||||
int m_scan_type; // Gray, Yh1v1, Yh1v2, Yh2v1, Yh2v2 (CMYK111, CMYK4114 no
|
||||
// longer supported)
|
||||
int m_comps_in_frame; // # of components in frame
|
||||
int m_comp_h_samp[JPGD_MAX_COMPONENTS]; // component's horizontal sampling
|
||||
// factor
|
||||
int m_comp_v_samp[JPGD_MAX_COMPONENTS]; // component's vertical sampling
|
||||
// factor
|
||||
int m_comp_quant[JPGD_MAX_COMPONENTS]; // component's quantization table
|
||||
// selector
|
||||
int m_comp_ident[JPGD_MAX_COMPONENTS]; // component's ID
|
||||
int m_comp_h_blocks[JPGD_MAX_COMPONENTS];
|
||||
int m_comp_v_blocks[JPGD_MAX_COMPONENTS];
|
||||
int m_comps_in_scan; // # of components in scan
|
||||
int m_comp_list[JPGD_MAX_COMPS_IN_SCAN]; // components in this scan
|
||||
int m_comp_dc_tab[JPGD_MAX_COMPONENTS]; // component's DC Huffman coding table
|
||||
// selector
|
||||
int m_comp_ac_tab[JPGD_MAX_COMPONENTS]; // component's AC Huffman coding table
|
||||
// selector
|
||||
int m_spectral_start; // spectral selection start
|
||||
int m_spectral_end; // spectral selection end
|
||||
int m_successive_low; // successive approximation low
|
||||
int m_successive_high; // successive approximation high
|
||||
int m_max_mcu_x_size; // MCU's max. X size in pixels
|
||||
int m_max_mcu_y_size; // MCU's max. Y size in pixels
|
||||
int m_blocks_per_mcu;
|
||||
int m_max_blocks_per_row;
|
||||
int m_mcus_per_row, m_mcus_per_col;
|
||||
int m_mcu_org[JPGD_MAX_BLOCKS_PER_MCU];
|
||||
int m_total_lines_left; // total # lines left in image
|
||||
int m_mcu_lines_left; // total # lines left in this MCU
|
||||
int m_num_buffered_scanlines;
|
||||
int m_real_dest_bytes_per_scan_line;
|
||||
int m_dest_bytes_per_scan_line; // rounded up
|
||||
int m_dest_bytes_per_pixel; // 4 (RGB) or 1 (Y)
|
||||
huff_tables *m_pHuff_tabs[JPGD_MAX_HUFF_TABLES];
|
||||
coeff_buf *m_dc_coeffs[JPGD_MAX_COMPONENTS];
|
||||
coeff_buf *m_ac_coeffs[JPGD_MAX_COMPONENTS];
|
||||
int m_eob_run;
|
||||
int m_block_y_mcu[JPGD_MAX_COMPONENTS];
|
||||
uint8 *m_pIn_buf_ofs;
|
||||
int m_in_buf_left;
|
||||
int m_tem_flag;
|
||||
|
||||
uint8 m_in_buf_pad_start[64];
|
||||
uint8 m_in_buf[JPGD_IN_BUF_SIZE + 128];
|
||||
uint8 m_in_buf_pad_end[64];
|
||||
|
||||
int m_bits_left;
|
||||
uint m_bit_buf;
|
||||
int m_restart_interval;
|
||||
int m_restarts_left;
|
||||
int m_next_restart_num;
|
||||
int m_max_mcus_per_row;
|
||||
int m_max_blocks_per_mcu;
|
||||
|
||||
int m_max_mcus_per_col;
|
||||
uint m_last_dc_val[JPGD_MAX_COMPONENTS];
|
||||
jpgd_block_coeff_t *m_pMCU_coefficients;
|
||||
int m_mcu_block_max_zag[JPGD_MAX_BLOCKS_PER_MCU];
|
||||
uint8 *m_pSample_buf;
|
||||
uint8 *m_pSample_buf_prev;
|
||||
int m_crr[256];
|
||||
int m_cbb[256];
|
||||
int m_crg[256];
|
||||
int m_cbg[256];
|
||||
uint8 *m_pScan_line_0;
|
||||
uint8 *m_pScan_line_1;
|
||||
jpgd_status m_error_code;
|
||||
int m_total_bytes_read;
|
||||
|
||||
bool m_ready_flag;
|
||||
bool m_eof_flag;
|
||||
bool m_sample_buf_prev_valid;
|
||||
bool m_has_sse2;
|
||||
|
||||
inline int check_sample_buf_ofs(int ofs) const {
|
||||
assert(ofs >= 0);
|
||||
assert(ofs < m_max_blocks_per_row * 64);
|
||||
return ofs;
|
||||
}
|
||||
void free_all_blocks();
|
||||
JPGD_NORETURN void stop_decoding(jpgd_status status);
|
||||
void *alloc(size_t n, bool zero = false);
|
||||
void *alloc_aligned(size_t nSize, uint32_t align = 16, bool zero = false);
|
||||
void word_clear(void *p, uint16 c, uint n);
|
||||
void prep_in_buffer();
|
||||
void read_dht_marker();
|
||||
void read_dqt_marker();
|
||||
void read_sof_marker();
|
||||
void skip_variable_marker();
|
||||
void read_dri_marker();
|
||||
void read_sos_marker();
|
||||
int next_marker();
|
||||
int process_markers();
|
||||
void locate_soi_marker();
|
||||
void locate_sof_marker();
|
||||
int locate_sos_marker();
|
||||
void init(jpeg_decoder_stream *pStream, uint32_t flags);
|
||||
void create_look_ups();
|
||||
void fix_in_buffer();
|
||||
void transform_mcu(int mcu_row);
|
||||
coeff_buf *coeff_buf_open(int block_num_x, int block_num_y, int block_len_x,
|
||||
int block_len_y);
|
||||
inline jpgd_block_coeff_t *coeff_buf_getp(coeff_buf *cb, int block_x,
|
||||
int block_y);
|
||||
void load_next_row();
|
||||
void decode_next_row();
|
||||
void make_huff_table(int index, huff_tables *pH);
|
||||
void check_quant_tables();
|
||||
void check_huff_tables();
|
||||
bool calc_mcu_block_order();
|
||||
int init_scan();
|
||||
void init_frame();
|
||||
void process_restart();
|
||||
void decode_scan(pDecode_block_func decode_block_func);
|
||||
void init_progressive();
|
||||
void init_sequential();
|
||||
void decode_start();
|
||||
void decode_init(jpeg_decoder_stream *pStream, uint32_t flags);
|
||||
void H2V2Convert();
|
||||
uint32_t H2V2ConvertFiltered();
|
||||
void H2V1Convert();
|
||||
void H2V1ConvertFiltered();
|
||||
void H1V2Convert();
|
||||
void H1V2ConvertFiltered();
|
||||
void H1V1Convert();
|
||||
void gray_convert();
|
||||
void find_eoi();
|
||||
inline uint get_char();
|
||||
inline uint get_char(bool *pPadding_flag);
|
||||
inline void stuff_char(uint8 q);
|
||||
inline uint8 get_octet();
|
||||
inline uint get_bits(int num_bits);
|
||||
inline uint get_bits_no_markers(int numbits);
|
||||
inline int huff_decode(huff_tables *pH);
|
||||
inline int huff_decode(huff_tables *pH, int &extrabits);
|
||||
|
||||
// Clamps a value between 0-255.
|
||||
static inline uint8 clamp(int i) {
|
||||
if (static_cast<uint>(i) > 255)
|
||||
i = (((~i) >> 31) & 0xFF);
|
||||
return static_cast<uint8>(i);
|
||||
}
|
||||
int decode_next_mcu_row();
|
||||
|
||||
static void decode_block_dc_first(jpeg_decoder *pD, int component_id,
|
||||
int block_x, int block_y);
|
||||
static void decode_block_dc_refine(jpeg_decoder *pD, int component_id,
|
||||
int block_x, int block_y);
|
||||
static void decode_block_ac_first(jpeg_decoder *pD, int component_id,
|
||||
int block_x, int block_y);
|
||||
static void decode_block_ac_refine(jpeg_decoder *pD, int component_id,
|
||||
int block_x, int block_y);
|
||||
};
|
||||
|
||||
} // namespace jpgd
|
||||
|
||||
#endif // JPEG_DECODER_H
|
478
include/renderd7/external/jpgd_idct.h
vendored
@ -1,478 +0,0 @@
|
||||
// Copyright 2009 Intel Corporation
|
||||
// All Rights Reserved
|
||||
//
|
||||
// Permission is granted to use, copy, distribute and prepare derivative works
|
||||
// of this software for any purpose and without fee, provided, that the above
|
||||
// copyright notice and this statement appear in all copies. Intel makes no
|
||||
// representations about the suitability of this software for any purpose. THIS
|
||||
// SOFTWARE IS PROVIDED "AS IS." INTEL SPECIFICALLY DISCLAIMS ALL WARRANTIES,
|
||||
// EXPRESS OR IMPLIED, AND ALL LIABILITY, INCLUDING CONSEQUENTIAL AND OTHER
|
||||
// INDIRECT DAMAGES, FOR THE USE OF THIS SOFTWARE, INCLUDING LIABILITY FOR
|
||||
// INFRINGEMENT OF ANY PROPRIETARY RIGHTS, AND INCLUDING THE WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Intel does not assume
|
||||
// any responsibility for any errors which may appear in this software nor any
|
||||
// responsibility to update it.
|
||||
//
|
||||
// From:
|
||||
// https://software.intel.com/sites/default/files/m/d/4/1/d/8/UsingIntelAVXToImplementIDCT-r1_5.pdf
|
||||
// https://software.intel.com/file/29048
|
||||
//
|
||||
// Requires SSE
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#include <immintrin.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define JPGD_SIMD_ALIGN(type, name) __declspec(align(16)) type name
|
||||
#else
|
||||
#define JPGD_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
|
||||
#endif
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
#define BITS_INV_ACC 4
|
||||
#define SHIFT_INV_ROW 16 - BITS_INV_ACC
|
||||
#define SHIFT_INV_COL 1 + BITS_INV_ACC
|
||||
const short IRND_INV_ROW = 1024 * (6 - BITS_INV_ACC); // 1 << (SHIFT_INV_ROW-1)
|
||||
const short IRND_INV_COL = 16 * (BITS_INV_ACC - 3); // 1 << (SHIFT_INV_COL-1)
|
||||
const short IRND_INV_CORR = IRND_INV_COL - 1; // correction -1.0 and round
|
||||
|
||||
JPGD_SIMD_ALIGN(short, shortM128_one_corr[8]) = {1, 1, 1, 1, 1, 1, 1, 1};
|
||||
JPGD_SIMD_ALIGN(short, shortM128_round_inv_row[8]) = {
|
||||
IRND_INV_ROW, 0, IRND_INV_ROW, 0, IRND_INV_ROW, 0, IRND_INV_ROW, 0};
|
||||
JPGD_SIMD_ALIGN(short, shortM128_round_inv_col[8]) = {
|
||||
IRND_INV_COL, IRND_INV_COL, IRND_INV_COL, IRND_INV_COL,
|
||||
IRND_INV_COL, IRND_INV_COL, IRND_INV_COL, IRND_INV_COL};
|
||||
JPGD_SIMD_ALIGN(short, shortM128_round_inv_corr[8]) = {
|
||||
IRND_INV_CORR, IRND_INV_CORR, IRND_INV_CORR, IRND_INV_CORR,
|
||||
IRND_INV_CORR, IRND_INV_CORR, IRND_INV_CORR, IRND_INV_CORR};
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tg_1_16[8]) = {
|
||||
13036, 13036, 13036, 13036,
|
||||
13036, 13036, 13036, 13036}; // tg * (2<<16) + 0.5
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tg_2_16[8]) = {
|
||||
27146, 27146, 27146, 27146,
|
||||
27146, 27146, 27146, 27146}; // tg * (2<<16) + 0.5
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tg_3_16[8]) = {
|
||||
-21746, -21746, -21746, -21746,
|
||||
-21746, -21746, -21746, -21746}; // tg * (2<<16) + 0.5
|
||||
JPGD_SIMD_ALIGN(short, shortM128_cos_4_16[8]) = {
|
||||
-19195, -19195, -19195, -19195,
|
||||
-19195, -19195, -19195, -19195}; // cos * (2<<16) + 0.5
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Table for rows 0,4 - constants are multiplied on cos_4_16
|
||||
// w15 w14 w11 w10 w07 w06 w03 w02
|
||||
// w29 w28 w25 w24 w21 w20 w17 w16
|
||||
// w31 w30 w27 w26 w23 w22 w19 w18
|
||||
// movq -> w05 w04 w01 w00
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tab_i_04[]) = {
|
||||
16384, 21407, 16384, 8867,
|
||||
16384, -8867, 16384, -21407, // w13 w12 w09 w08
|
||||
16384, 8867, -16384, -21407, // w07 w06 w03 w02
|
||||
-16384, 21407, 16384, -8867, // w15 w14 w11 w10
|
||||
22725, 19266, 19266, -4520, // w21 w20 w17 w16
|
||||
12873, -22725, 4520, -12873, // w29 w28 w25 w24
|
||||
12873, 4520, -22725, -12873, // w23 w22 w19 w18
|
||||
4520, 19266, 19266, -22725}; // w31 w30 w27 w26
|
||||
|
||||
// Table for rows 1,7 - constants are multiplied on cos_1_16
|
||||
// movq -> w05 w04 w01 w00
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tab_i_17[]) = {
|
||||
22725, 29692, 22725, 12299,
|
||||
22725, -12299, 22725, -29692, // w13 w12 w09 w08
|
||||
22725, 12299, -22725, -29692, // w07 w06 w03 w02
|
||||
-22725, 29692, 22725, -12299, // w15 w14 w11 w10
|
||||
31521, 26722, 26722, -6270, // w21 w20 w17 w16
|
||||
17855, -31521, 6270, -17855, // w29 w28 w25 w24
|
||||
17855, 6270, -31521, -17855, // w23 w22 w19 w18
|
||||
6270, 26722, 26722, -31521}; // w31 w30 w27 w26
|
||||
|
||||
// Table for rows 2,6 - constants are multiplied on cos_2_16
|
||||
// movq -> w05 w04 w01 w00
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tab_i_26[]) = {
|
||||
21407, 27969, 21407, 11585,
|
||||
21407, -11585, 21407, -27969, // w13 w12 w09 w08
|
||||
21407, 11585, -21407, -27969, // w07 w06 w03 w02
|
||||
-21407, 27969, 21407, -11585, // w15 w14 w11 w10
|
||||
29692, 25172, 25172, -5906, // w21 w20 w17 w16
|
||||
16819, -29692, 5906, -16819, // w29 w28 w25 w24
|
||||
16819, 5906, -29692, -16819, // w23 w22 w19 w18
|
||||
5906, 25172, 25172, -29692}; // w31 w30 w27 w26
|
||||
// Table for rows 3,5 - constants are multiplied on cos_3_16
|
||||
// movq -> w05 w04 w01 w00
|
||||
JPGD_SIMD_ALIGN(short, shortM128_tab_i_35[]) = {
|
||||
19266, 25172, 19266, 10426,
|
||||
19266, -10426, 19266, -25172, // w13 w12 w09 w08
|
||||
19266, 10426, -19266, -25172, // w07 w06 w03 w02
|
||||
-19266, 25172, 19266, -10426, // w15 w14 w11 w10
|
||||
26722, 22654, 22654, -5315, // w21 w20 w17 w16
|
||||
15137, -26722, 5315, -15137, // w29 w28 w25 w24
|
||||
15137, 5315, -26722, -15137, // w23 w22 w19 w18
|
||||
5315, 22654, 22654, -26722}; // w31 w30 w27 w26
|
||||
|
||||
JPGD_SIMD_ALIGN(short, shortM128_128[8]) = {128, 128, 128, 128,
|
||||
128, 128, 128, 128};
|
||||
|
||||
void idctSSEShortU8(const short *pInput, uint8_t *pOutputUB) {
|
||||
__m128i r_xmm0, r_xmm4;
|
||||
__m128i r_xmm1, r_xmm2, r_xmm3, r_xmm5, r_xmm6, r_xmm7;
|
||||
__m128i row0, row1, row2, row3, row4, row5, row6, row7;
|
||||
short *pTab_i_04 = shortM128_tab_i_04;
|
||||
short *pTab_i_26 = shortM128_tab_i_26;
|
||||
|
||||
// Get pointers for this input and output
|
||||
pTab_i_04 = shortM128_tab_i_04;
|
||||
pTab_i_26 = shortM128_tab_i_26;
|
||||
|
||||
// Row 1 and Row 3
|
||||
r_xmm0 = _mm_load_si128((__m128i *)pInput);
|
||||
r_xmm4 = _mm_load_si128((__m128i *)(&pInput[2 * 8]));
|
||||
|
||||
// *** Work on the data in xmm0
|
||||
// low shuffle mask = 0xd8 = 11 01 10 00
|
||||
// get short 2 and short 0 into ls 32-bits
|
||||
r_xmm0 = _mm_shufflelo_epi16(r_xmm0, 0xd8);
|
||||
|
||||
// copy short 2 and short 0 to all locations
|
||||
r_xmm1 = _mm_shuffle_epi32(r_xmm0, 0);
|
||||
|
||||
// add to those copies
|
||||
r_xmm1 = _mm_madd_epi16(r_xmm1, *((__m128i *)pTab_i_04));
|
||||
|
||||
// shuffle mask = 0x55 = 01 01 01 01
|
||||
// copy short 3 and short 1 to all locations
|
||||
r_xmm3 = _mm_shuffle_epi32(r_xmm0, 0x55);
|
||||
|
||||
// high shuffle mask = 0xd8 = 11 01 10 00
|
||||
// get short 6 and short 4 into bit positions 64-95
|
||||
// get short 7 and short 5 into bit positions 96-127
|
||||
r_xmm0 = _mm_shufflehi_epi16(r_xmm0, 0xd8);
|
||||
|
||||
// add to short 3 and short 1
|
||||
r_xmm3 = _mm_madd_epi16(r_xmm3, *((__m128i *)&pTab_i_04[16]));
|
||||
|
||||
// shuffle mask = 0xaa = 10 10 10 10
|
||||
// copy short 6 and short 4 to all locations
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm0, 0xaa);
|
||||
|
||||
// shuffle mask = 0xaa = 11 11 11 11
|
||||
// copy short 7 and short 5 to all locations
|
||||
r_xmm0 = _mm_shuffle_epi32(r_xmm0, 0xff);
|
||||
|
||||
// add to short 6 and short 4
|
||||
r_xmm2 = _mm_madd_epi16(r_xmm2, *((__m128i *)&pTab_i_04[8]));
|
||||
|
||||
// *** Work on the data in xmm4
|
||||
// high shuffle mask = 0xd8 11 01 10 00
|
||||
// get short 6 and short 4 into bit positions 64-95
|
||||
// get short 7 and short 5 into bit positions 96-127
|
||||
r_xmm4 = _mm_shufflehi_epi16(r_xmm4, 0xd8);
|
||||
|
||||
// (xmm0 short 2 and short 0 plus pSi) + some constants
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_shufflelo_epi16(r_xmm4, 0xd8);
|
||||
r_xmm0 = _mm_madd_epi16(r_xmm0, *((__m128i *)&pTab_i_04[24]));
|
||||
r_xmm5 = _mm_shuffle_epi32(r_xmm4, 0);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm4, 0xaa);
|
||||
r_xmm5 = _mm_madd_epi16(r_xmm5, *((__m128i *)&shortM128_tab_i_26[0]));
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, r_xmm2);
|
||||
r_xmm2 = r_xmm1;
|
||||
r_xmm7 = _mm_shuffle_epi32(r_xmm4, 0x55);
|
||||
r_xmm6 = _mm_madd_epi16(r_xmm6, *((__m128i *)&shortM128_tab_i_26[8]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm3);
|
||||
r_xmm4 = _mm_shuffle_epi32(r_xmm4, 0xff);
|
||||
r_xmm2 = _mm_sub_epi32(r_xmm2, r_xmm0);
|
||||
r_xmm7 = _mm_madd_epi16(r_xmm7, *((__m128i *)&shortM128_tab_i_26[16]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm1);
|
||||
r_xmm2 = _mm_srai_epi32(r_xmm2, 12);
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_madd_epi16(r_xmm4, *((__m128i *)&shortM128_tab_i_26[24]));
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, r_xmm6);
|
||||
r_xmm6 = r_xmm5;
|
||||
r_xmm0 = _mm_srai_epi32(r_xmm0, 12);
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm2, 0x1b);
|
||||
row0 = _mm_packs_epi32(r_xmm0, r_xmm2);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm7);
|
||||
r_xmm6 = _mm_sub_epi32(r_xmm6, r_xmm4);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm5);
|
||||
r_xmm6 = _mm_srai_epi32(r_xmm6, 12);
|
||||
r_xmm4 = _mm_srai_epi32(r_xmm4, 12);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm6, 0x1b);
|
||||
row2 = _mm_packs_epi32(r_xmm4, r_xmm6);
|
||||
|
||||
// Row 5 and row 7
|
||||
r_xmm0 = _mm_load_si128((__m128i *)(&pInput[4 * 8]));
|
||||
r_xmm4 = _mm_load_si128((__m128i *)(&pInput[6 * 8]));
|
||||
|
||||
r_xmm0 = _mm_shufflelo_epi16(r_xmm0, 0xd8);
|
||||
r_xmm1 = _mm_shuffle_epi32(r_xmm0, 0);
|
||||
r_xmm1 = _mm_madd_epi16(r_xmm1, *((__m128i *)pTab_i_04));
|
||||
r_xmm3 = _mm_shuffle_epi32(r_xmm0, 0x55);
|
||||
r_xmm0 = _mm_shufflehi_epi16(r_xmm0, 0xd8);
|
||||
r_xmm3 = _mm_madd_epi16(r_xmm3, *((__m128i *)&pTab_i_04[16]));
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm0, 0xaa);
|
||||
r_xmm0 = _mm_shuffle_epi32(r_xmm0, 0xff);
|
||||
r_xmm2 = _mm_madd_epi16(r_xmm2, *((__m128i *)&pTab_i_04[8]));
|
||||
r_xmm4 = _mm_shufflehi_epi16(r_xmm4, 0xd8);
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_shufflelo_epi16(r_xmm4, 0xd8);
|
||||
r_xmm0 = _mm_madd_epi16(r_xmm0, *((__m128i *)&pTab_i_04[24]));
|
||||
r_xmm5 = _mm_shuffle_epi32(r_xmm4, 0);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm4, 0xaa);
|
||||
r_xmm5 = _mm_madd_epi16(r_xmm5, *((__m128i *)&shortM128_tab_i_26[0]));
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, r_xmm2);
|
||||
r_xmm2 = r_xmm1;
|
||||
r_xmm7 = _mm_shuffle_epi32(r_xmm4, 0x55);
|
||||
r_xmm6 = _mm_madd_epi16(r_xmm6, *((__m128i *)&shortM128_tab_i_26[8]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm3);
|
||||
r_xmm4 = _mm_shuffle_epi32(r_xmm4, 0xff);
|
||||
r_xmm2 = _mm_sub_epi32(r_xmm2, r_xmm0);
|
||||
r_xmm7 = _mm_madd_epi16(r_xmm7, *((__m128i *)&shortM128_tab_i_26[16]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm1);
|
||||
r_xmm2 = _mm_srai_epi32(r_xmm2, 12);
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_madd_epi16(r_xmm4, *((__m128i *)&shortM128_tab_i_26[24]));
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, r_xmm6);
|
||||
r_xmm6 = r_xmm5;
|
||||
r_xmm0 = _mm_srai_epi32(r_xmm0, 12);
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm2, 0x1b);
|
||||
row4 = _mm_packs_epi32(r_xmm0, r_xmm2);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm7);
|
||||
r_xmm6 = _mm_sub_epi32(r_xmm6, r_xmm4);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm5);
|
||||
r_xmm6 = _mm_srai_epi32(r_xmm6, 12);
|
||||
r_xmm4 = _mm_srai_epi32(r_xmm4, 12);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm6, 0x1b);
|
||||
row6 = _mm_packs_epi32(r_xmm4, r_xmm6);
|
||||
|
||||
// Row 4 and row 2
|
||||
pTab_i_04 = shortM128_tab_i_35;
|
||||
pTab_i_26 = shortM128_tab_i_17;
|
||||
r_xmm0 = _mm_load_si128((__m128i *)(&pInput[3 * 8]));
|
||||
r_xmm4 = _mm_load_si128((__m128i *)(&pInput[1 * 8]));
|
||||
|
||||
r_xmm0 = _mm_shufflelo_epi16(r_xmm0, 0xd8);
|
||||
r_xmm1 = _mm_shuffle_epi32(r_xmm0, 0);
|
||||
r_xmm1 = _mm_madd_epi16(r_xmm1, *((__m128i *)pTab_i_04));
|
||||
r_xmm3 = _mm_shuffle_epi32(r_xmm0, 0x55);
|
||||
r_xmm0 = _mm_shufflehi_epi16(r_xmm0, 0xd8);
|
||||
r_xmm3 = _mm_madd_epi16(r_xmm3, *((__m128i *)&pTab_i_04[16]));
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm0, 0xaa);
|
||||
r_xmm0 = _mm_shuffle_epi32(r_xmm0, 0xff);
|
||||
r_xmm2 = _mm_madd_epi16(r_xmm2, *((__m128i *)&pTab_i_04[8]));
|
||||
r_xmm4 = _mm_shufflehi_epi16(r_xmm4, 0xd8);
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_shufflelo_epi16(r_xmm4, 0xd8);
|
||||
r_xmm0 = _mm_madd_epi16(r_xmm0, *((__m128i *)&pTab_i_04[24]));
|
||||
r_xmm5 = _mm_shuffle_epi32(r_xmm4, 0);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm4, 0xaa);
|
||||
r_xmm5 = _mm_madd_epi16(r_xmm5, *((__m128i *)&pTab_i_26[0]));
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, r_xmm2);
|
||||
r_xmm2 = r_xmm1;
|
||||
r_xmm7 = _mm_shuffle_epi32(r_xmm4, 0x55);
|
||||
r_xmm6 = _mm_madd_epi16(r_xmm6, *((__m128i *)&pTab_i_26[8]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm3);
|
||||
r_xmm4 = _mm_shuffle_epi32(r_xmm4, 0xff);
|
||||
r_xmm2 = _mm_sub_epi32(r_xmm2, r_xmm0);
|
||||
r_xmm7 = _mm_madd_epi16(r_xmm7, *((__m128i *)&pTab_i_26[16]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm1);
|
||||
r_xmm2 = _mm_srai_epi32(r_xmm2, 12);
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_madd_epi16(r_xmm4, *((__m128i *)&pTab_i_26[24]));
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, r_xmm6);
|
||||
r_xmm6 = r_xmm5;
|
||||
r_xmm0 = _mm_srai_epi32(r_xmm0, 12);
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm2, 0x1b);
|
||||
row3 = _mm_packs_epi32(r_xmm0, r_xmm2);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm7);
|
||||
r_xmm6 = _mm_sub_epi32(r_xmm6, r_xmm4);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm5);
|
||||
r_xmm6 = _mm_srai_epi32(r_xmm6, 12);
|
||||
r_xmm4 = _mm_srai_epi32(r_xmm4, 12);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm6, 0x1b);
|
||||
row1 = _mm_packs_epi32(r_xmm4, r_xmm6);
|
||||
|
||||
// Row 6 and row 8
|
||||
r_xmm0 = _mm_load_si128((__m128i *)(&pInput[5 * 8]));
|
||||
r_xmm4 = _mm_load_si128((__m128i *)(&pInput[7 * 8]));
|
||||
|
||||
r_xmm0 = _mm_shufflelo_epi16(r_xmm0, 0xd8);
|
||||
r_xmm1 = _mm_shuffle_epi32(r_xmm0, 0);
|
||||
r_xmm1 = _mm_madd_epi16(r_xmm1, *((__m128i *)pTab_i_04));
|
||||
r_xmm3 = _mm_shuffle_epi32(r_xmm0, 0x55);
|
||||
r_xmm0 = _mm_shufflehi_epi16(r_xmm0, 0xd8);
|
||||
r_xmm3 = _mm_madd_epi16(r_xmm3, *((__m128i *)&pTab_i_04[16]));
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm0, 0xaa);
|
||||
r_xmm0 = _mm_shuffle_epi32(r_xmm0, 0xff);
|
||||
r_xmm2 = _mm_madd_epi16(r_xmm2, *((__m128i *)&pTab_i_04[8]));
|
||||
r_xmm4 = _mm_shufflehi_epi16(r_xmm4, 0xd8);
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_shufflelo_epi16(r_xmm4, 0xd8);
|
||||
r_xmm0 = _mm_madd_epi16(r_xmm0, *((__m128i *)&pTab_i_04[24]));
|
||||
r_xmm5 = _mm_shuffle_epi32(r_xmm4, 0);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm4, 0xaa);
|
||||
r_xmm5 = _mm_madd_epi16(r_xmm5, *((__m128i *)&pTab_i_26[0]));
|
||||
r_xmm1 = _mm_add_epi32(r_xmm1, r_xmm2);
|
||||
r_xmm2 = r_xmm1;
|
||||
r_xmm7 = _mm_shuffle_epi32(r_xmm4, 0x55);
|
||||
r_xmm6 = _mm_madd_epi16(r_xmm6, *((__m128i *)&pTab_i_26[8]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm3);
|
||||
r_xmm4 = _mm_shuffle_epi32(r_xmm4, 0xff);
|
||||
r_xmm2 = _mm_sub_epi32(r_xmm2, r_xmm0);
|
||||
r_xmm7 = _mm_madd_epi16(r_xmm7, *((__m128i *)&pTab_i_26[16]));
|
||||
r_xmm0 = _mm_add_epi32(r_xmm0, r_xmm1);
|
||||
r_xmm2 = _mm_srai_epi32(r_xmm2, 12);
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, *((__m128i *)shortM128_round_inv_row));
|
||||
r_xmm4 = _mm_madd_epi16(r_xmm4, *((__m128i *)&pTab_i_26[24]));
|
||||
r_xmm5 = _mm_add_epi32(r_xmm5, r_xmm6);
|
||||
r_xmm6 = r_xmm5;
|
||||
r_xmm0 = _mm_srai_epi32(r_xmm0, 12);
|
||||
r_xmm2 = _mm_shuffle_epi32(r_xmm2, 0x1b);
|
||||
row5 = _mm_packs_epi32(r_xmm0, r_xmm2);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm7);
|
||||
r_xmm6 = _mm_sub_epi32(r_xmm6, r_xmm4);
|
||||
r_xmm4 = _mm_add_epi32(r_xmm4, r_xmm5);
|
||||
r_xmm6 = _mm_srai_epi32(r_xmm6, 12);
|
||||
r_xmm4 = _mm_srai_epi32(r_xmm4, 12);
|
||||
r_xmm6 = _mm_shuffle_epi32(r_xmm6, 0x1b);
|
||||
row7 = _mm_packs_epi32(r_xmm4, r_xmm6);
|
||||
|
||||
r_xmm1 = _mm_load_si128((__m128i *)shortM128_tg_3_16);
|
||||
r_xmm2 = row5;
|
||||
r_xmm3 = row3;
|
||||
r_xmm0 = _mm_mulhi_epi16(row5, r_xmm1);
|
||||
|
||||
r_xmm1 = _mm_mulhi_epi16(r_xmm1, r_xmm3);
|
||||
r_xmm5 = _mm_load_si128((__m128i *)shortM128_tg_1_16);
|
||||
r_xmm6 = row7;
|
||||
r_xmm4 = _mm_mulhi_epi16(row7, r_xmm5);
|
||||
|
||||
r_xmm0 = _mm_adds_epi16(r_xmm0, r_xmm2);
|
||||
r_xmm5 = _mm_mulhi_epi16(r_xmm5, row1);
|
||||
r_xmm1 = _mm_adds_epi16(r_xmm1, r_xmm3);
|
||||
r_xmm7 = row6;
|
||||
|
||||
r_xmm0 = _mm_adds_epi16(r_xmm0, r_xmm3);
|
||||
r_xmm3 = _mm_load_si128((__m128i *)shortM128_tg_2_16);
|
||||
r_xmm2 = _mm_subs_epi16(r_xmm2, r_xmm1);
|
||||
r_xmm7 = _mm_mulhi_epi16(r_xmm7, r_xmm3);
|
||||
r_xmm1 = r_xmm0;
|
||||
r_xmm3 = _mm_mulhi_epi16(r_xmm3, row2);
|
||||
r_xmm5 = _mm_subs_epi16(r_xmm5, r_xmm6);
|
||||
r_xmm4 = _mm_adds_epi16(r_xmm4, row1);
|
||||
r_xmm0 = _mm_adds_epi16(r_xmm0, r_xmm4);
|
||||
r_xmm0 = _mm_adds_epi16(r_xmm0, *((__m128i *)shortM128_one_corr));
|
||||
r_xmm4 = _mm_subs_epi16(r_xmm4, r_xmm1);
|
||||
r_xmm6 = r_xmm5;
|
||||
r_xmm5 = _mm_subs_epi16(r_xmm5, r_xmm2);
|
||||
r_xmm5 = _mm_adds_epi16(r_xmm5, *((__m128i *)shortM128_one_corr));
|
||||
r_xmm6 = _mm_adds_epi16(r_xmm6, r_xmm2);
|
||||
|
||||
// Intermediate results, needed later
|
||||
__m128i temp3, temp7;
|
||||
temp7 = r_xmm0;
|
||||
|
||||
r_xmm1 = r_xmm4;
|
||||
r_xmm0 = _mm_load_si128((__m128i *)shortM128_cos_4_16);
|
||||
r_xmm4 = _mm_adds_epi16(r_xmm4, r_xmm5);
|
||||
r_xmm2 = _mm_load_si128((__m128i *)shortM128_cos_4_16);
|
||||
r_xmm2 = _mm_mulhi_epi16(r_xmm2, r_xmm4);
|
||||
|
||||
// Intermediate results, needed later
|
||||
temp3 = r_xmm6;
|
||||
|
||||
r_xmm1 = _mm_subs_epi16(r_xmm1, r_xmm5);
|
||||
r_xmm7 = _mm_adds_epi16(r_xmm7, row2);
|
||||
r_xmm3 = _mm_subs_epi16(r_xmm3, row6);
|
||||
r_xmm6 = row0;
|
||||
r_xmm0 = _mm_mulhi_epi16(r_xmm0, r_xmm1);
|
||||
r_xmm5 = row4;
|
||||
r_xmm5 = _mm_adds_epi16(r_xmm5, r_xmm6);
|
||||
r_xmm6 = _mm_subs_epi16(r_xmm6, row4);
|
||||
r_xmm4 = _mm_adds_epi16(r_xmm4, r_xmm2);
|
||||
|
||||
r_xmm4 = _mm_or_si128(r_xmm4, *((__m128i *)shortM128_one_corr));
|
||||
r_xmm0 = _mm_adds_epi16(r_xmm0, r_xmm1);
|
||||
r_xmm0 = _mm_or_si128(r_xmm0, *((__m128i *)shortM128_one_corr));
|
||||
|
||||
r_xmm2 = r_xmm5;
|
||||
r_xmm5 = _mm_adds_epi16(r_xmm5, r_xmm7);
|
||||
r_xmm1 = r_xmm6;
|
||||
r_xmm5 = _mm_adds_epi16(r_xmm5, *((__m128i *)shortM128_round_inv_col));
|
||||
r_xmm2 = _mm_subs_epi16(r_xmm2, r_xmm7);
|
||||
r_xmm7 = temp7;
|
||||
r_xmm6 = _mm_adds_epi16(r_xmm6, r_xmm3);
|
||||
r_xmm6 = _mm_adds_epi16(r_xmm6, *((__m128i *)shortM128_round_inv_col));
|
||||
r_xmm7 = _mm_adds_epi16(r_xmm7, r_xmm5);
|
||||
r_xmm7 = _mm_srai_epi16(r_xmm7, SHIFT_INV_COL);
|
||||
r_xmm1 = _mm_subs_epi16(r_xmm1, r_xmm3);
|
||||
r_xmm1 = _mm_adds_epi16(r_xmm1, *((__m128i *)shortM128_round_inv_corr));
|
||||
r_xmm3 = r_xmm6;
|
||||
r_xmm2 = _mm_adds_epi16(r_xmm2, *((__m128i *)shortM128_round_inv_corr));
|
||||
r_xmm6 = _mm_adds_epi16(r_xmm6, r_xmm4);
|
||||
|
||||
// Store results for row 0
|
||||
//_mm_store_si128((__m128i *) pOutput, r_xmm7);
|
||||
__m128i r0 = r_xmm7;
|
||||
|
||||
r_xmm6 = _mm_srai_epi16(r_xmm6, SHIFT_INV_COL);
|
||||
r_xmm7 = r_xmm1;
|
||||
r_xmm1 = _mm_adds_epi16(r_xmm1, r_xmm0);
|
||||
|
||||
// Store results for row 1
|
||||
//_mm_store_si128((__m128i *) (&pOutput[1*8]), r_xmm6);
|
||||
__m128i r1 = r_xmm6;
|
||||
|
||||
r_xmm1 = _mm_srai_epi16(r_xmm1, SHIFT_INV_COL);
|
||||
r_xmm6 = temp3;
|
||||
r_xmm7 = _mm_subs_epi16(r_xmm7, r_xmm0);
|
||||
r_xmm7 = _mm_srai_epi16(r_xmm7, SHIFT_INV_COL);
|
||||
|
||||
// Store results for row 2
|
||||
//_mm_store_si128((__m128i *) (&pOutput[2*8]), r_xmm1);
|
||||
__m128i r2 = r_xmm1;
|
||||
|
||||
r_xmm5 = _mm_subs_epi16(r_xmm5, temp7);
|
||||
r_xmm5 = _mm_srai_epi16(r_xmm5, SHIFT_INV_COL);
|
||||
|
||||
// Store results for row 7
|
||||
//_mm_store_si128((__m128i *) (&pOutput[7*8]), r_xmm5);
|
||||
__m128i r7 = r_xmm5;
|
||||
|
||||
r_xmm3 = _mm_subs_epi16(r_xmm3, r_xmm4);
|
||||
r_xmm6 = _mm_adds_epi16(r_xmm6, r_xmm2);
|
||||
r_xmm2 = _mm_subs_epi16(r_xmm2, temp3);
|
||||
r_xmm6 = _mm_srai_epi16(r_xmm6, SHIFT_INV_COL);
|
||||
r_xmm2 = _mm_srai_epi16(r_xmm2, SHIFT_INV_COL);
|
||||
|
||||
// Store results for row 3
|
||||
//_mm_store_si128((__m128i *) (&pOutput[3*8]), r_xmm6);
|
||||
__m128i r3 = r_xmm6;
|
||||
|
||||
r_xmm3 = _mm_srai_epi16(r_xmm3, SHIFT_INV_COL);
|
||||
|
||||
// Store results for rows 4, 5, and 6
|
||||
//_mm_store_si128((__m128i *) (&pOutput[4*8]), r_xmm2);
|
||||
//_mm_store_si128((__m128i *) (&pOutput[5*8]), r_xmm7);
|
||||
//_mm_store_si128((__m128i *) (&pOutput[6*8]), r_xmm3);
|
||||
|
||||
__m128i r4 = r_xmm2;
|
||||
__m128i r5 = r_xmm7;
|
||||
__m128i r6 = r_xmm3;
|
||||
|
||||
r0 = _mm_add_epi16(*(const __m128i *)shortM128_128, r0);
|
||||
r1 = _mm_add_epi16(*(const __m128i *)shortM128_128, r1);
|
||||
r2 = _mm_add_epi16(*(const __m128i *)shortM128_128, r2);
|
||||
r3 = _mm_add_epi16(*(const __m128i *)shortM128_128, r3);
|
||||
r4 = _mm_add_epi16(*(const __m128i *)shortM128_128, r4);
|
||||
r5 = _mm_add_epi16(*(const __m128i *)shortM128_128, r5);
|
||||
r6 = _mm_add_epi16(*(const __m128i *)shortM128_128, r6);
|
||||
r7 = _mm_add_epi16(*(const __m128i *)shortM128_128, r7);
|
||||
|
||||
((__m128i *)pOutputUB)[0] = _mm_packus_epi16(r0, r1);
|
||||
((__m128i *)pOutputUB)[1] = _mm_packus_epi16(r2, r3);
|
||||
((__m128i *)pOutputUB)[2] = _mm_packus_epi16(r4, r5);
|
||||
((__m128i *)pOutputUB)[3] = _mm_packus_epi16(r6, r7);
|
||||
}
|
186
include/renderd7/external/jpge.h
vendored
@ -1,186 +0,0 @@
|
||||
// jpge.h - C++ class for JPEG compression.
|
||||
// Public Domain or Apache 2.0, Richard Geldreich <richgel99@gmail.com>
|
||||
// Alex Evans: Added RGBA support, linear memory allocator.
|
||||
#ifndef JPEG_ENCODER_H
|
||||
#define JPEG_ENCODER_H
|
||||
|
||||
namespace jpge {
|
||||
typedef unsigned char uint8;
|
||||
typedef signed short int16;
|
||||
typedef signed int int32;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned int uint;
|
||||
|
||||
// JPEG chroma subsampling factors. Y_ONLY (grayscale images) and H2V2 (color
|
||||
// images) are the most common.
|
||||
enum subsampling_t { Y_ONLY = 0, H1V1 = 1, H2V1 = 2, H2V2 = 3 };
|
||||
|
||||
// JPEG compression parameters structure.
|
||||
struct params {
|
||||
inline params()
|
||||
: m_quality(85), m_subsampling(H2V2), m_no_chroma_discrim_flag(false),
|
||||
m_two_pass_flag(false), m_use_std_tables(false) {}
|
||||
|
||||
inline bool check() const {
|
||||
if ((m_quality < 1) || (m_quality > 100))
|
||||
return false;
|
||||
if ((uint)m_subsampling > (uint)H2V2)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Quality: 1-100, higher is better. Typical values are around 50-95.
|
||||
int m_quality;
|
||||
|
||||
// m_subsampling:
|
||||
// 0 = Y (grayscale) only
|
||||
// 1 = YCbCr, no subsampling (H1V1, YCbCr 1x1x1, 3 blocks per MCU)
|
||||
// 2 = YCbCr, H2V1 subsampling (YCbCr 2x1x1, 4 blocks per MCU)
|
||||
// 3 = YCbCr, H2V2 subsampling (YCbCr 4x1x1, 6 blocks per MCU-- very common)
|
||||
subsampling_t m_subsampling;
|
||||
|
||||
// Disables CbCr discrimination - only intended for testing.
|
||||
// If true, the Y quantization table is also used for the CbCr channels.
|
||||
bool m_no_chroma_discrim_flag;
|
||||
|
||||
bool m_two_pass_flag;
|
||||
|
||||
// By default we use the same quantization tables as mozjpeg's default.
|
||||
// Set to true to use the traditional tables from JPEG Annex K.
|
||||
bool m_use_std_tables;
|
||||
};
|
||||
|
||||
// Writes JPEG image to a file.
|
||||
// num_channels must be 1 (Y) or 3 (RGB), image pitch must be
|
||||
// width*num_channels.
|
||||
bool compress_image_to_jpeg_file(const char *pFilename, int width, int height,
|
||||
int num_channels, const uint8 *pImage_data,
|
||||
const params &comp_params = params());
|
||||
|
||||
// Writes JPEG image to memory buffer.
|
||||
// On entry, buf_size is the size of the output buffer pointed at by pBuf, which
|
||||
// should be at least ~1024 bytes. If return value is true, buf_size will be set
|
||||
// to the size of the compressed data.
|
||||
bool compress_image_to_jpeg_file_in_memory(
|
||||
void *pBuf, int &buf_size, int width, int height, int num_channels,
|
||||
const uint8 *pImage_data, const params &comp_params = params());
|
||||
|
||||
// Output stream abstract class - used by the jpeg_encoder class to write to the
|
||||
// output stream. put_buf() is generally called with len==JPGE_OUT_BUF_SIZE
|
||||
// bytes, but for headers it'll be called with smaller amounts.
|
||||
class output_stream {
|
||||
public:
|
||||
virtual ~output_stream(){};
|
||||
virtual bool put_buf(const void *Pbuf, int len) = 0;
|
||||
template <class T> inline bool put_obj(const T &obj) {
|
||||
return put_buf(&obj, sizeof(T));
|
||||
}
|
||||
};
|
||||
|
||||
// Lower level jpeg_encoder class - useful if more control is needed than the
|
||||
// above helper functions.
|
||||
class jpeg_encoder {
|
||||
public:
|
||||
jpeg_encoder();
|
||||
~jpeg_encoder();
|
||||
|
||||
// Initializes the compressor.
|
||||
// pStream: The stream object to use for writing compressed data.
|
||||
// params - Compression parameters structure, defined above.
|
||||
// width, height - Image dimensions.
|
||||
// channels - May be 1, or 3. 1 indicates grayscale, 3 indicates RGB source
|
||||
// data. Returns false on out of memory or if a stream write fails.
|
||||
bool init(output_stream *pStream, int width, int height, int src_channels,
|
||||
const params &comp_params = params());
|
||||
|
||||
const params &get_params() const { return m_params; }
|
||||
|
||||
// Deinitializes the compressor, freeing any allocated memory. May be called
|
||||
// at any time.
|
||||
void deinit();
|
||||
|
||||
uint get_total_passes() const { return m_params.m_two_pass_flag ? 2 : 1; }
|
||||
inline uint get_cur_pass() { return m_pass_num; }
|
||||
|
||||
// Call this method with each source scanline.
|
||||
// width * src_channels bytes per scanline is expected (RGB or Y format).
|
||||
// You must call with NULL after all scanlines are processed to finish
|
||||
// compression. Returns false on out of memory or if a stream write fails.
|
||||
bool process_scanline(const void *pScanline);
|
||||
|
||||
private:
|
||||
jpeg_encoder(const jpeg_encoder &);
|
||||
jpeg_encoder &operator=(const jpeg_encoder &);
|
||||
|
||||
typedef int32 sample_array_t;
|
||||
|
||||
output_stream *m_pStream;
|
||||
params m_params;
|
||||
uint8 m_num_components;
|
||||
uint8 m_comp_h_samp[3], m_comp_v_samp[3];
|
||||
int m_image_x, m_image_y, m_image_bpp, m_image_bpl;
|
||||
int m_image_x_mcu, m_image_y_mcu;
|
||||
int m_image_bpl_xlt, m_image_bpl_mcu;
|
||||
int m_mcus_per_row;
|
||||
int m_mcu_x, m_mcu_y;
|
||||
uint8 *m_mcu_lines[16];
|
||||
uint8 m_mcu_y_ofs;
|
||||
sample_array_t m_sample_array[64];
|
||||
int16 m_coefficient_array[64];
|
||||
int32 m_quantization_tables[2][64];
|
||||
uint m_huff_codes[4][256];
|
||||
uint8 m_huff_code_sizes[4][256];
|
||||
uint8 m_huff_bits[4][17];
|
||||
uint8 m_huff_val[4][256];
|
||||
uint32 m_huff_count[4][256];
|
||||
int m_last_dc_val[3];
|
||||
enum { JPGE_OUT_BUF_SIZE = 2048 };
|
||||
uint8 m_out_buf[JPGE_OUT_BUF_SIZE];
|
||||
uint8 *m_pOut_buf;
|
||||
uint m_out_buf_left;
|
||||
uint32 m_bit_buffer;
|
||||
uint m_bits_in;
|
||||
uint8 m_pass_num;
|
||||
bool m_all_stream_writes_succeeded;
|
||||
|
||||
void optimize_huffman_table(int table_num, int table_len);
|
||||
void emit_byte(uint8 i);
|
||||
void emit_word(uint i);
|
||||
void emit_marker(int marker);
|
||||
void emit_jfif_app0();
|
||||
void emit_dqt();
|
||||
void emit_sof();
|
||||
void emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag);
|
||||
void emit_dhts();
|
||||
void emit_sos();
|
||||
void emit_markers();
|
||||
void compute_huffman_table(uint *codes, uint8 *code_sizes, uint8 *bits,
|
||||
uint8 *val);
|
||||
void compute_quant_table(int32 *dst, int16 *src);
|
||||
void adjust_quant_table(int32 *dst, int32 *src);
|
||||
void first_pass_init();
|
||||
bool second_pass_init();
|
||||
bool jpg_open(int p_x_res, int p_y_res, int src_channels);
|
||||
void load_block_8_8_grey(int x);
|
||||
void load_block_8_8(int x, int y, int c);
|
||||
void load_block_16_8(int x, int c);
|
||||
void load_block_16_8_8(int x, int c);
|
||||
void load_quantized_coefficients(int component_num);
|
||||
void flush_output_buffer();
|
||||
void put_bits(uint bits, uint len);
|
||||
void code_coefficients_pass_one(int component_num);
|
||||
void code_coefficients_pass_two(int component_num);
|
||||
void code_block(int component_num);
|
||||
void process_mcu_row();
|
||||
bool terminate_pass_one();
|
||||
bool terminate_pass_two();
|
||||
bool process_end_of_image();
|
||||
void load_mcu(const void *src);
|
||||
void clear();
|
||||
void init();
|
||||
};
|
||||
|
||||
} // namespace jpge
|
||||
|
||||
#endif // JPEG_ENCODER
|
222
include/renderd7/external/nvid.hpp
vendored
@ -1,222 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory.h>
|
||||
#include <memory>
|
||||
#include <renderd7/external/jpgd.h>
|
||||
#include <renderd7/external/jpge.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
struct NVID_Header {
|
||||
char magic[4]; // Magic
|
||||
int framerate; // Only Up to 60
|
||||
int width; // Width
|
||||
int height; // Height
|
||||
uint32_t framecount; // Count of Frames
|
||||
};
|
||||
|
||||
struct NVID_Frame {
|
||||
char magic[4]; // Magic
|
||||
uint32_t framesize; // Size of Frame
|
||||
};
|
||||
|
||||
struct NVID_Image {
|
||||
int framenum; // Register of Frame
|
||||
int w; // Width of Frame
|
||||
int h; // Height of Frame
|
||||
int bpp; // bpp of Frame
|
||||
void *pBuf; // Buffer
|
||||
};
|
||||
|
||||
inline void CreateHeader(NVID_Header &header) {
|
||||
header.magic[0] = 'N';
|
||||
header.magic[1] = 'V';
|
||||
header.magic[2] = 'I';
|
||||
header.magic[3] = 'D';
|
||||
}
|
||||
|
||||
inline void CreateFrame(NVID_Frame &frame) {
|
||||
frame.magic[0] = 'N';
|
||||
frame.magic[1] = 'F';
|
||||
frame.magic[2] = 'R';
|
||||
frame.magic[3] = 'M';
|
||||
}
|
||||
|
||||
inline bool CheckHeader(NVID_Header &header) {
|
||||
if (header.magic[0] == 'N' && header.magic[1] == 'V' &&
|
||||
header.magic[2] == 'I' && header.magic[3] == 'D')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool CheckFrame(NVID_Frame &frame) {
|
||||
if (frame.magic[0] == 'N' && frame.magic[1] == 'F' && frame.magic[2] == 'R' &&
|
||||
frame.magic[3] == 'M')
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline std::vector<std::unique_ptr<NVID_Image>>
|
||||
LoadNVID(const std::string &path) {
|
||||
std::vector<std::unique_ptr<NVID_Image>> res;
|
||||
std::ifstream nvid_file(path, std::ios::binary | std::ios::in);
|
||||
if (!nvid_file) {
|
||||
std::cerr << "Failed to open NVID file: " << path << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
NVID_Header header;
|
||||
nvid_file.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||
if (!CheckHeader(header)) {
|
||||
std::cerr << "Invalid NVID header" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
for (int i = 0; i < (int)header.framecount; i++) {
|
||||
NVID_Frame frame;
|
||||
nvid_file.read(reinterpret_cast<char *>(&frame), sizeof(frame));
|
||||
if (!CheckFrame(frame)) {
|
||||
std::cerr << "Invalid NVID frame" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compressed_data(frame.framesize);
|
||||
nvid_file.read(reinterpret_cast<char *>(compressed_data.data()),
|
||||
compressed_data.size());
|
||||
|
||||
int width, height, components;
|
||||
unsigned char *decompressed_data = jpgd::decompress_jpeg_image_from_memory(
|
||||
compressed_data.data(), compressed_data.size(), &width, &height,
|
||||
&components, 3);
|
||||
if (!decompressed_data) {
|
||||
std::cerr << "Failed to decompress JPEG data" << std::endl;
|
||||
return res;
|
||||
}
|
||||
|
||||
auto image = std::make_unique<NVID_Image>();
|
||||
image->bpp = components;
|
||||
image->w = width;
|
||||
image->h = height;
|
||||
image->framenum = i;
|
||||
image->pBuf = decompressed_data;
|
||||
|
||||
res.push_back(std::move(image));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
inline std::vector<std::unique_ptr<NVID_Image>> LoadMemNVID(const void *data,
|
||||
size_t size) {
|
||||
std::vector<std::unique_ptr<NVID_Image>> res;
|
||||
std::istringstream nvid_stream(
|
||||
std::string(reinterpret_cast<const char *>(data), size));
|
||||
NVID_Header header;
|
||||
nvid_stream.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||
if (!CheckHeader(header)) {
|
||||
std::cerr << "Invalid NVID header" << std::endl;
|
||||
return res;
|
||||
}
|
||||
for (int i = 0; i < (int)header.framecount; i++) {
|
||||
NVID_Frame frame;
|
||||
nvid_stream.read(reinterpret_cast<char *>(&frame), sizeof(frame));
|
||||
if (!CheckFrame(frame)) {
|
||||
std::cerr << "Invalid NVID frame" << std::endl;
|
||||
return res;
|
||||
}
|
||||
std::vector<uint8_t> compressed_data(frame.framesize);
|
||||
nvid_stream.read(reinterpret_cast<char *>(compressed_data.data()),
|
||||
compressed_data.size());
|
||||
int width, height, components;
|
||||
unsigned char *decompressed_data = jpgd::decompress_jpeg_image_from_memory(
|
||||
compressed_data.data(), compressed_data.size(), &width, &height,
|
||||
&components, 3);
|
||||
if (!decompressed_data) {
|
||||
std::cerr << "Failed to decompress JPEG data" << std::endl;
|
||||
return res;
|
||||
}
|
||||
auto image = std::make_unique<NVID_Image>();
|
||||
image->bpp = components;
|
||||
image->w = width;
|
||||
image->h = height;
|
||||
image->framenum = i;
|
||||
image->pBuf = decompressed_data;
|
||||
res.push_back(std::move(image));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
class NVID_Stream {
|
||||
public:
|
||||
NVID_Stream(const std::string &path)
|
||||
: file_(path, std::ios::binary | std::ios::in) {
|
||||
if (!file_) {
|
||||
std::cout << "Failed to open NVID file: " << path << std::endl;
|
||||
return;
|
||||
} else {
|
||||
file_.read(reinterpret_cast<char *>(&header_), sizeof(header_));
|
||||
if (!CheckHeader(header_)) {
|
||||
std::cout << "Invalid NVID header" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NVID_Stream(const void *data, std::size_t size) {
|
||||
if (!data || size < sizeof(header_)) {
|
||||
std::cout << "Invalid NVID data" << std::endl;
|
||||
return;
|
||||
} else {
|
||||
memcpy(&header_, data, sizeof(header_));
|
||||
if (!CheckHeader(header_)) {
|
||||
std::cout << "Invalid NVID header" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~NVID_Stream() { file_.close(); }
|
||||
|
||||
bool ReadNext(NVID_Image &image) {
|
||||
if (!file_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NVID_Frame frame;
|
||||
file_.read(reinterpret_cast<char *>(&frame), sizeof(frame));
|
||||
if (!CheckFrame(frame)) {
|
||||
std::cout << "Invalid NVID frame" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compressed_data(frame.framesize);
|
||||
file_.read(reinterpret_cast<char *>(compressed_data.data()),
|
||||
compressed_data.size());
|
||||
|
||||
int width, height, components;
|
||||
unsigned char *decompressed_data = jpgd::decompress_jpeg_image_from_memory(
|
||||
compressed_data.data(), compressed_data.size(), &width, &height,
|
||||
&components, 3);
|
||||
if (!decompressed_data) {
|
||||
std::cout << "Failed to decompress JPEG data" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
image.bpp = components;
|
||||
image.w = width;
|
||||
image.h = height;
|
||||
image.framenum = current_frame_++;
|
||||
image.pBuf = decompressed_data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::ifstream file_;
|
||||
NVID_Header header_;
|
||||
int current_frame_ = 0;
|
||||
};
|
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,6 +1,8 @@
|
||||
#pragma once
|
||||
#include <renderd7/external/json.hpp>
|
||||
// clang-format off
|
||||
#include <string>
|
||||
#include <renderd7/external/json.hpp>
|
||||
// clang-format on
|
||||
|
||||
namespace RenderD7 {
|
||||
namespace Lang {
|
||||
|
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,5 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
extern unsigned char npi_intro[];
|
||||
extern size_t npi_intro_size;
|
@ -24,12 +24,9 @@
|
||||
#include <citro2d.h>
|
||||
#include <citro3d.h>
|
||||
/// RenderD7 Includes
|
||||
#include <renderd7/BitmapPrinter.hpp>
|
||||
#include <renderd7/Color.hpp>
|
||||
#include <renderd7/Draw.hpp>
|
||||
#include <renderd7/FunctionTrace.hpp>
|
||||
#include <renderd7/Hardware.hpp>
|
||||
#include <renderd7/Image.hpp>
|
||||
#include <renderd7/Memory.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/ResultDecoder.hpp>
|
||||
@ -40,9 +37,6 @@
|
||||
#include <renderd7/SpriteAnimation.hpp>
|
||||
#include <renderd7/Tasks.hpp>
|
||||
#include <renderd7/Time.hpp>
|
||||
#include <renderd7/Toast.hpp>
|
||||
#include <renderd7/bmp.hpp>
|
||||
#include <renderd7/bmpconverter.hpp>
|
||||
#include <renderd7/external/lodepng.h>
|
||||
#include <renderd7/ini.hpp>
|
||||
#include <renderd7/lang.hpp>
|
||||
@ -50,77 +44,25 @@
|
||||
#include <renderd7/stringtool.hpp>
|
||||
#include <renderd7/thread.hpp>
|
||||
|
||||
#define RENDERD7VSTRING "0.9.4"
|
||||
#define CHANGELOG \
|
||||
"0.9.4: Implement new Security System\n To prevent from crashes\nImplement " \
|
||||
"Functiontrace for better\nTiming Tests\nImplement MemAlloc Tracker (only " \
|
||||
"size)\nAdd some new Overlays (not functional yet)\nComplete Rewrite of " \
|
||||
"Overlay System\nFixed the FrameEnd Crash\nNew System to get Hardware " \
|
||||
"Info\nRemoved RD7SR\n0.9.3: Completly Documanted Everything\nFix typo " \
|
||||
"in " \
|
||||
"Sprite::getHeight()\nRemove Deprecated/Useless Stuff\n0.9.2: Add " \
|
||||
"NpiSplashVideo\nNvid Support(v0.0.1)\nAdd " \
|
||||
"Basic RenderD7 " \
|
||||
"Splash\nFaster Graphics Init\nFade Effects\nFix Screen for this " \
|
||||
"Changelog\n0.9.1: Fix Critical bug in\nSpritesheet animations\nFix " \
|
||||
"Color " \
|
||||
"Conver(Hex)\n0.9.0: Remove Stupid try of Console\nAdd Services list and " \
|
||||
"Clean up " \
|
||||
"Code.\nAlso added Minimal Init for hax2.x\n0.8.5: Fix Deltatime \n0.8.4: " \
|
||||
"A lot of Fixes and new\nFeatures for BitmapPrinter! \n0.8.3: Addet " \
|
||||
"Overlaycount to Info\nand Addet ResultDecoder for errors.\n0.8.2: Fix a " \
|
||||
"lot of Stuff and\nadd c++17 based filesystem class.\n0.8.1: Add abillity " \
|
||||
"to Get Stdout as string\nto render it to the screen.\n0.8.0: Implement " \
|
||||
"BitmapPrinter\n0.7.3: Implement Over\nRender Overlay Framework\n0.7.2: " \
|
||||
"Implement MT to csv file\nsaving.(removed) Add RGB2HEX.\n0.7.1: Add the " \
|
||||
"New Overlay Handler. Its\nJust in code and does nothing yet.\n0.7.0: Made " \
|
||||
"Big Progress In the MT\nOvl but it still crashes On\na Scnd " \
|
||||
"C3D_FrameEnd()." \
|
||||
"\nImplement 800px but\ndoesn't work that good. \n0.6.2: Fix Crash when " \
|
||||
"exiting\ntrouth Home Menu.\n0.6.10: rewrite Threadsystem,\nImprove " \
|
||||
"framerate\n0.6.02: Fix Code in lang.hpp\nadd Draw Text Left " \
|
||||
"Function\n(Right since 0.7.0).\nadd changelog\n0.6.01: add Threading " \
|
||||
"system.\n0.6.0: Better " \
|
||||
"Scene Management\n0.5.0: Fixed some Bugs!\n0.4.0: Trying to fix " \
|
||||
"Filesystem and Bugs!\n0.3.0: Recreate D7-Core into RenderD7!\n0.2.0: " \
|
||||
"Trying to create Animations of\nImages instead of Sheets!\n0.1.0: Initial " \
|
||||
"Release of\nD7-Core sprite animation plugin!"
|
||||
#define RENDERD7VSTRING "0.9.5"
|
||||
|
||||
#define DEFAULT_CENTER 0.5f
|
||||
|
||||
#define RD7_DEPRECATED // __attribute__ ((deprecated))
|
||||
|
||||
/// @param d7_hDown Current Key Down
|
||||
extern u32 d7_hDown;
|
||||
/// @param d7_hHeld Current Key Held
|
||||
extern u32 d7_hHeld;
|
||||
/// @param d7_hUp Current Key Up
|
||||
extern u32 d7_hUp;
|
||||
/// @param d7_touch Current Touch Position
|
||||
extern touchPosition d7_touch;
|
||||
|
||||
/// @param dspststus Dsp Status String
|
||||
extern std::string dspststus;
|
||||
|
||||
/// @param rd7_do_splash Config Value To Enable RenderD7 Splash
|
||||
extern bool rd7_do_splash;
|
||||
/// @param rd7_enable_memtrack Config Value to Track Mem Allocations
|
||||
extern bool rd7_enable_memtrack;
|
||||
/// @param rd7_max_objects Config Param for C2D Mac objects
|
||||
extern int rd7_max_objects;
|
||||
/// @param rd7_enable_scene_system Enable/Disable Scene System (for example for your own implementations)
|
||||
extern bool rd7_enable_scene_system;
|
||||
|
||||
/// RenderD7
|
||||
namespace RenderD7 {
|
||||
/// @brief Get Deltatime
|
||||
/// @return Deltatime
|
||||
float GetDeltaTime();
|
||||
/// @brief Keyboard
|
||||
enum kbd {
|
||||
/// @brief libctru Keyboard
|
||||
SWKBD,
|
||||
/// @brief Unk (Not Usable)
|
||||
BKBD
|
||||
};
|
||||
/// @brief Keyboar Type
|
||||
enum kbd_type { NUMPAD, STANDARD };
|
||||
|
||||
/// @brief A Button
|
||||
struct TObject {
|
||||
int x; ///< Position X
|
||||
@ -137,12 +79,7 @@ public:
|
||||
static std::stack<std::unique_ptr<Scene>> scenes;
|
||||
/// @brief Deconstructor
|
||||
virtual ~Scene() {}
|
||||
/// @brief Logic To Overide
|
||||
/// @param hDown Key Down
|
||||
/// @param hHeld Key Held
|
||||
/// @param hUp Key Up
|
||||
/// @param touch Touch Position
|
||||
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;
|
||||
/// @brief Push a Scene to Stack
|
||||
@ -153,43 +90,31 @@ public:
|
||||
static void Back();
|
||||
/// @brief do the Draw (Called in RenderD7::MainLoop())
|
||||
static void doDraw();
|
||||
/// @brief do the Logic (Called in RenderD7::MainLoop())
|
||||
/// @param hDown Key Down
|
||||
/// @param hHeld Key Held
|
||||
/// @param hUp Key Up
|
||||
/// @param touch Touch Positon
|
||||
static void doLogic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch);
|
||||
static void doLogic();
|
||||
};
|
||||
|
||||
/// @brief Integrated Setting Menu of RenderD7
|
||||
class RSettings : public RenderD7::Scene {
|
||||
private:
|
||||
/// @brief Calculate the Changelog Screen Stuff
|
||||
/// @param lines vector of Lines
|
||||
/// @param screen_index Current Screen
|
||||
/// @param screens Count of Possible Screens
|
||||
void calculate_screens(const std::vector<std::string> &lines,
|
||||
int &screen_index, int &screens);
|
||||
/// @brief State (Define for Menus)
|
||||
enum RState {
|
||||
RSETTINGS,
|
||||
RINFO,
|
||||
RSERVICES,
|
||||
RCLOG,
|
||||
RMCONFIG,
|
||||
RFTRACE,
|
||||
RSECM,
|
||||
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;
|
||||
|
||||
/// @param screens Count of Changelog Screens
|
||||
int screens = 0;
|
||||
/// @param screen_index Current Changelog Screen
|
||||
int screen_index = 0;
|
||||
/// @param lines Vector of Changelog-Lines
|
||||
std::vector<std::string> lines;
|
||||
/// @brief Position in FTrace Menu
|
||||
int ftrace_index = 0;
|
||||
|
||||
@ -197,13 +122,9 @@ private:
|
||||
std::string mtovlstate = "false";
|
||||
/// @param mtscreenstate Screen the Overlay is Set to
|
||||
std::string mtscreenstate = "Top";
|
||||
|
||||
/// @param buttons Vector of Buttons
|
||||
std::vector<RenderD7::TObject> buttons = {
|
||||
{20, 35, 120, 35, "NotYET"}, {20, 85, 120, 35, "Changelog"},
|
||||
{20, 135, 120, 35, "Metrik-Ovl"}, {20, 185, 120, 35, "Tasks"},
|
||||
{180, 35, 120, 35, "FTrace"}, {180, 85, 120, 35, "Credits"},
|
||||
{180, 135, 120, 35, "Info"}, {180, 185, 120, 35, "Security"}};
|
||||
std::string kbd_test;
|
||||
bool statemtold = false;
|
||||
bool stateftold = false;
|
||||
|
||||
public:
|
||||
/// @brief Constructor
|
||||
@ -213,47 +134,23 @@ public:
|
||||
void Draw(void) const override;
|
||||
/// @brief Deconstructor
|
||||
~RSettings();
|
||||
/// @brief Override for Logic
|
||||
/// @param hDown Key Down
|
||||
/// @param hHeld Key Held
|
||||
/// @param hUp Key Up
|
||||
/// @param touch Touch Position
|
||||
void Logic(u32 hDown, u32 hHeld, u32 hUp, touchPosition touch) override;
|
||||
void Logic() override;
|
||||
};
|
||||
|
||||
/// @brief Show Up the RenderD7-Settings Menu
|
||||
void LoadSettings();
|
||||
|
||||
/// @brief DspNotFound Error Toast (Deprectated)
|
||||
class DSP_NF : public RenderD7::Ovl {
|
||||
public:
|
||||
/// @brief Constructor
|
||||
DSP_NF();
|
||||
/// @brief Override for Draw
|
||||
void Draw(void) const override;
|
||||
/// @brief Override for Logic
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
/// @param msgposy Y Position of Toast
|
||||
int msgposy = 240;
|
||||
/// @param delay Delay of Toast
|
||||
int delay = 0;
|
||||
};
|
||||
/// @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);
|
||||
/// @brief Short a String with (..,)
|
||||
/// @param in Input string
|
||||
/// @param size Size of Input Text
|
||||
/// @param maxlen Max length of texr
|
||||
/// @param font Custom Font for Correct Size Calculation
|
||||
/// @return Shorted String
|
||||
std::string ShortString(std::string in, float size, int maxlen,
|
||||
C2D_Font font = nullptr);
|
||||
/// @brief DrawMetrikOvl (YOUR OWN RISK)
|
||||
void DrawMetrikOvl();
|
||||
/// @brief Draw Image from RenderD7 Sheet
|
||||
@ -266,8 +163,6 @@ void DrawMetrikOvl();
|
||||
/// @return success ?
|
||||
bool DrawImageFromSheet(RenderD7::Sheet *sheet, size_t index, float x, float y,
|
||||
float scaleX = 1.0, float scaleY = 1.0);
|
||||
/// @brief Display the Npi-D7 Video Intro (NVID)
|
||||
void DoNpiIntro();
|
||||
/// @brief Fade In
|
||||
/// @param duration Duration in Frames
|
||||
void FadeIn();
|
||||
@ -277,17 +172,10 @@ void FadeOut();
|
||||
/// @brief Display Fade Effects
|
||||
void FadeDisplay();
|
||||
|
||||
namespace Error {
|
||||
/// @brief DEPRECATED Display Error for n Seconds
|
||||
/// @param toptext Head Text
|
||||
/// @param errortext Error Text
|
||||
/// @param timesec Time n to Display in Seconds
|
||||
void DisplayError(std::string toptext, std::string errortext, int timesec = 3);
|
||||
/// @brief Display A Fatal Error
|
||||
/// @param toptext Head Text
|
||||
/// @param errortext Error Text
|
||||
void DisplayFatalError(std::string toptext, std::string errortext);
|
||||
} // namespace Error
|
||||
/// @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 {
|
||||
/// @brief Init Default RenderD7
|
||||
@ -307,23 +195,6 @@ void Graphics();
|
||||
void NdspFirm();
|
||||
} // namespace Init
|
||||
|
||||
namespace Msg {
|
||||
/// @brief Display A Message
|
||||
/// @param titletxt Header Text
|
||||
/// @param subtext Message Text
|
||||
/// @param target Screen
|
||||
void Display(std::string titletxt, std::string subtext,
|
||||
C3D_RenderTarget *target);
|
||||
/// @brief Display A Message Wit Progress
|
||||
/// @param titletext Header Text
|
||||
/// @param subtext Message Text
|
||||
/// @param current Current Progress
|
||||
/// @param total Total Progress
|
||||
/// @param prgbarcolor Color of Progressbar
|
||||
void DisplayWithProgress(std::string titletext, std::string subtext,
|
||||
float current, float total, u32 prgbarcolor);
|
||||
} // namespace Msg
|
||||
|
||||
namespace Convert {
|
||||
/// @brief Convert a String to Flaot
|
||||
/// @param inp Input String
|
||||
@ -362,59 +233,11 @@ void ExitApp();
|
||||
/// @param
|
||||
void ClearTextBufs(void);
|
||||
|
||||
/// @brief Open A Keyboard (SWKBD)
|
||||
/// @param lenght Length of the string
|
||||
/// @param tp Type of The Keyboard
|
||||
/// @return the string if pressed Ok
|
||||
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();
|
||||
|
||||
/// @brief Textless Button
|
||||
struct TLBtn {
|
||||
int x; ///< Position X
|
||||
int y; ///< Position Y
|
||||
int w; ///< Button Width
|
||||
int h; ///< Button Height
|
||||
};
|
||||
/// @brief Draw Buttons
|
||||
/// @param tobjects Vector of Buttons
|
||||
/// @param color Color of the Buttons
|
||||
/// @param txtcolor Color of The Text
|
||||
/// @param selection Positon of Selection
|
||||
/// @param selbgcolor Selection BackgroundColor
|
||||
/// @param selcolor Selection Color
|
||||
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"));
|
||||
/// @brief Draw A Single Button
|
||||
/// @param tobject Button
|
||||
/// @param tobjectindex Button Index
|
||||
/// @param color Color of the Button
|
||||
/// @param txtcolor Color of The Text
|
||||
void DrawSTObject(std::vector<RenderD7::TObject> tobject, int tobjectindex,
|
||||
u32 color, u32 txtcolor);
|
||||
/// @brief Touched A Button
|
||||
/// @param touch Touch Position
|
||||
/// @param button Button
|
||||
/// @return is touched or not
|
||||
bool touchTObj(touchPosition touch, RenderD7::TObject button);
|
||||
/// @brief Touched A Textless Button
|
||||
/// @param touch Touch Position
|
||||
/// @param button Button
|
||||
/// @return is touched or not
|
||||
bool touchTLBtn(touchPosition touch, RenderD7::TLBtn button);
|
||||
/// @brief Draw Textless Buttons
|
||||
/// @param tobjects Vector of Buttons
|
||||
/// @param color Color of the Buttons
|
||||
/// @param selection Positon of Selection
|
||||
/// @param selbgcolor Selection BackgroundColor
|
||||
/// @param selcolor Selection Color
|
||||
void DrawTLBtns(std::vector<RenderD7::TLBtn> btns, u32 color,
|
||||
int selection = -1,
|
||||
u32 selbgcolor = RenderD7::Color::Hex("#2D98AF"),
|
||||
u32 selcolor = RenderD7::Color::Hex("#000000"));
|
||||
/// @brief Returns App Working Directory path
|
||||
/// @return AppDir Path
|
||||
std::string GetAppDirectory();
|
||||
} // namespace RenderD7
|
||||
|
@ -11,14 +11,11 @@ namespace RenderD7 {
|
||||
/// @return Ends with or not
|
||||
inline bool NameIsEndingWith(const std::string &name,
|
||||
const std::vector<std::string> &extensions) {
|
||||
if (name.substr(0, 2) == "._")
|
||||
return false;
|
||||
if (name.substr(0, 2) == "._") return false;
|
||||
|
||||
if (name.size() == 0)
|
||||
return false;
|
||||
if (name.size() == 0) return false;
|
||||
|
||||
if (extensions.size() == 0)
|
||||
return true;
|
||||
if (extensions.size() == 0) return true;
|
||||
|
||||
for (int i = 0; i < (int)extensions.size(); i++) {
|
||||
const std::string ext = extensions.at(i);
|
||||
@ -32,7 +29,7 @@ inline bool NameIsEndingWith(const std::string &name,
|
||||
/// Plugins)
|
||||
/// @param t_time Time in ms
|
||||
/// @return String
|
||||
inline std::string MsTimeFmt(float t_time) {
|
||||
inline std::string MsTimeFmt(float t_time, bool dems = false) {
|
||||
std::ostringstream oss;
|
||||
|
||||
if (t_time < 0.001f) {
|
||||
@ -46,7 +43,8 @@ inline std::string MsTimeFmt(float t_time) {
|
||||
if (seconds > 0) {
|
||||
oss << seconds << "s ";
|
||||
}
|
||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||
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);
|
||||
@ -56,24 +54,48 @@ inline std::string MsTimeFmt(float t_time) {
|
||||
if (seconds > 0 || milliseconds > 0.0f) {
|
||||
oss << seconds << "s ";
|
||||
}
|
||||
if (milliseconds > 0.0f) {
|
||||
if (milliseconds > 0.0f && !dems) {
|
||||
oss << std::fixed << std::setprecision(2) << milliseconds << "ms";
|
||||
}
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
} // namespace RenderD7
|
||||
|
||||
template <class T> T GetFileName(T const &path, T const &delims = "/\\") {
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
|
@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
|
||||
extern unsigned char ui_elements[];
|
||||
extern size_t ui_elements_size;
|
BIN
logo.png
Before Width: | Height: | Size: 13 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;
|
||||
};
|
||||
}
|
@ -52,7 +52,7 @@ else
|
||||
GIT_VER := $(shell git rev-parse --short HEAD)
|
||||
endif
|
||||
|
||||
TIME_TIME := $(shell date --iso=seconds)
|
||||
TIME_TIME := unk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Version number
|
||||
@ -66,11 +66,20 @@ 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
|
||||
SOURCES := source $(RENDERD7_SRC)
|
||||
DATA := data
|
||||
INCLUDES := source
|
||||
INCLUDES := source $(RENDERD7_INC)
|
||||
GRAPHICS := gfx
|
||||
#GFXBUILD := $(BUILD)
|
||||
ROMFS := romfs
|
||||
@ -87,7 +96,7 @@ 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)\" \
|
||||
-fomit-frame-pointer -ffunction-sections \
|
||||
-ffunction-sections \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -D__3DS__ -D_GNU_SOURCE=1
|
||||
@ -97,14 +106,14 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++20
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lrenderd7d -lcurl -lstdc++ -lm -lz -lcitro2d -lcitro3d -lctru -ljpeg
|
||||
LIBS := -lstdc++ $(RENDERD7_LIBS)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(CTRULIB) ../libs
|
||||
LIBDIRS := $(PORTLIBS) $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
@ -249,44 +258,18 @@ $(OUTPUT).3dsx : $(_3DSXDEPS)
|
||||
@$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.PRECIOUS : %.t3x
|
||||
.PRECIOUS : %.t3x %.shbin
|
||||
#---------------------------------------------------------------------------------
|
||||
%.t3x.o %_t3x.h : %.t3x
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# rules for assembling GPU shaders
|
||||
%.shbin.o %_shbin.h : %.shbin
|
||||
#---------------------------------------------------------------------------------
|
||||
define shader-as
|
||||
$(eval CURBIN := $*.shbin)
|
||||
$(eval DEPSFILE := $(DEPSDIR)/$*.shbin.d)
|
||||
echo "$(CURBIN).o: $< $1" > $(DEPSFILE)
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
|
||||
picasso -o $(CURBIN) $1
|
||||
bin2s $(CURBIN) | $(AS) -o $*.shbin.o
|
||||
endef
|
||||
|
||||
%.shbin.o %_shbin.h : %.v.pica %.g.pica
|
||||
@echo $(notdir $^)
|
||||
@$(call shader-as,$^)
|
||||
|
||||
%.shbin.o %_shbin.h : %.v.pica
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$<)
|
||||
|
||||
%.shbin.o %_shbin.h : %.shlist
|
||||
@echo $(notdir $<)
|
||||
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)$(file)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.t3x %.h : %.t3s
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@tex3ds -i $< -H $*.h -d $*.d -o $*.t3x
|
||||
$(SILENTMSG) $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPSDIR)/*.d
|
||||
|
||||
|
BIN
rd7tf/romfs/icons/icon.png
Normal file
After Width: | Height: | Size: 844 B |
BIN
rd7tf/romfs/roboto_bold.bcfnt
Normal file
BIN
rd7tf/romfs/thesound.wav
Normal file
@ -1,18 +1,49 @@
|
||||
#include <rd7.hpp>
|
||||
#include "scene.hpp"
|
||||
#include "renderd7/music/Music.hpp"
|
||||
|
||||
void ColorThemeSample() {
|
||||
RenderD7::ColorNew(RD7Color_Text, RenderD7::Color::Hex("#000000", 255));
|
||||
RenderD7::ColorNew(RD7Color_TextDisabled, RenderD7::Color::Hex("#212121", 200));
|
||||
RenderD7::ColorNew(RD7Color_Text2, RenderD7::Color::Hex("#ffffff", 255));
|
||||
RenderD7::ColorNew(RD7Color_Background, RenderD7::Color::Hex("#eeeeee", 170));
|
||||
RenderD7::ColorNew(RD7Color_Header, RenderD7::Color::Hex("#222222", 190));
|
||||
RenderD7::ColorNew(RD7Color_Selector, RenderD7::Color::Hex("#4444dd", 200));
|
||||
RenderD7::ColorNew(RD7Color_SelectorFade, RenderD7::Color::Hex("#7777dd", 200));
|
||||
RenderD7::ColorNew(RD7Color_List0, RenderD7::Color::Hex("#555555", 130));
|
||||
RenderD7::ColorNew(RD7Color_List1, RenderD7::Color::Hex("#777777", 130));
|
||||
RenderD7::ColorNew(RD7Color_MessageBackground, RenderD7::Color::Hex("#222222", 180));
|
||||
RenderD7::ColorNew(RD7Color_Button, RenderD7::Color::Hex("#4444dd", 150));
|
||||
RenderD7::ColorNew(RD7Color_ButtonHovered, RenderD7::Color::Hex("#6666dd", 150));
|
||||
RenderD7::ColorNew(RD7Color_ButtonDisabled, RenderD7::Color::Hex("#2222dd", 150));
|
||||
RenderD7::ColorNew(RD7Color_ButtonActive, RenderD7::Color::Hex("#7777dd", 150));
|
||||
RenderD7::ColorNew(RD7Color_Checkmark, RenderD7::Color::Hex("#4444dd", 130));
|
||||
RenderD7::ColorNew(RD7Color_FrameBg, RenderD7::Color::Hex("#555555", 160));
|
||||
RenderD7::ColorNew(RD7Color_FrameBgHovered, RenderD7::Color::Hex("#777777", 160));
|
||||
RenderD7::ColorNew(RD7Color_Progressbar, RenderD7::Color::Hex("#4444dd", 200));
|
||||
}
|
||||
|
||||
extern void IdbServer();
|
||||
|
||||
int main() {
|
||||
rd7_enable_memtrack = true;
|
||||
rd7_do_splash = true;
|
||||
RenderD7::Ftrace::Beg("app", "app_init");
|
||||
RenderD7::Init::Main("rd7tf");
|
||||
RenderD7::FadeIn();
|
||||
//RenderD7::InlineAssert(1 == 2, "1 is not 2!");
|
||||
//IdbServer();
|
||||
ColorThemeSample();
|
||||
RenderD7::Init::NdspFirm();
|
||||
RenderD7::Ftrace::Beg("app", f2s(RenderD7::LoadSettings));
|
||||
RenderD7::LoadSettings();
|
||||
RenderD7::Ftrace::End("app", f2s(RenderD7::LoadSettings));
|
||||
RenderD7::Scene::Load(std::make_unique<Sample>());
|
||||
RenderD7::Ftrace::End("app", "app_init");
|
||||
while (RenderD7::MainLoop()) {
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::Ftrace::Beg("app", "app_mainloop");
|
||||
if (d7_hDown & KEY_START)
|
||||
if (d7_hDown & KEY_START) {
|
||||
RenderD7::FadeOut();
|
||||
RenderD7::ExitApp();
|
||||
}
|
||||
RenderD7::OnScreen(Top);
|
||||
RenderD7::FrameEnd();
|
||||
RenderD7::Ftrace::End("app", "app_mainloop");
|
||||
}
|
||||
|
132
rd7tf/source/scene.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
#include "scene.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
static float MakeOffset(float x) {
|
||||
float y = cos(x) * 42;
|
||||
return y - floor(y);
|
||||
}
|
||||
|
||||
static void Wave(int index, R7Vec2 position, R7Vec2 size, float time,
|
||||
bool dbg) {
|
||||
float offset = MakeOffset(index) * 62;
|
||||
float x_position =
|
||||
position.x + size.x / 8 * ((index % 11) - 1) + cos(offset + time) * 10;
|
||||
float y_position = position.y + size.y / 8 * (index / 11) + 40 +
|
||||
sin(offset + time) * 10 + 30;
|
||||
float color_effect = 1 - exp(-(index / 11) / 3.0f);
|
||||
|
||||
// As this is 3ds dont go out of the box
|
||||
int shrink = 0;
|
||||
if (y_position >= position.y + size.y - 90) {
|
||||
shrink = y_position - (position.y + size.y - 90);
|
||||
}
|
||||
// Just to make sure...
|
||||
y_position = std::min(y_position, position.y + size.y - (90 - shrink));
|
||||
|
||||
if (dbg)
|
||||
RenderD7::Draw2::TriangleLined(
|
||||
R7Vec2(x_position, y_position),
|
||||
R7Vec2(x_position + 300, y_position + (90 - shrink)),
|
||||
R7Vec2(x_position - 300, y_position + (90 - shrink)),
|
||||
RenderD7::Color::RGBA(.94f - .17f * color_effect,
|
||||
.61f - .25f * color_effect,
|
||||
.36f + .38f * color_effect)
|
||||
.toRGBA());
|
||||
else
|
||||
RenderD7::Draw2::TriangleSolid(
|
||||
R7Vec2(x_position, y_position),
|
||||
R7Vec2(x_position + 300, y_position + (90 - shrink)),
|
||||
R7Vec2(x_position - 300, y_position + (90 - shrink)),
|
||||
RenderD7::Color::RGBA(.94f - .17f * color_effect,
|
||||
.61f - .25f * color_effect,
|
||||
.36f + .38f * color_effect)
|
||||
.toRGBA());
|
||||
}
|
||||
|
||||
void DrawWave(R7Vec2 position, R7Vec2 size, float time, bool dbg) {
|
||||
RenderD7::Draw2::RectFilledSolid(position, size, 0xff64c9fd);
|
||||
int i = 0;
|
||||
for (; i < 44; i++) Wave(i, position, size, time, dbg);
|
||||
}
|
||||
|
||||
R7Vec2 testv2 = R7Vec2(48, 48);
|
||||
|
||||
R7Vec2 grid_display_entry(void* data, R7Vec2 pos) {
|
||||
auto img = reinterpret_cast<RenderD7::Image*>(data);
|
||||
RenderD7::Draw2::Image(img, pos);
|
||||
RenderD7::Draw2::RFS(pos, testv2, RenderD7::Color::Hex("#0000ff", 140));
|
||||
return testv2;
|
||||
}
|
||||
|
||||
std::vector<RenderD7::Image*> imgdb;
|
||||
|
||||
Sample::Sample() {
|
||||
/*RenderD7::Image* im = new RenderD7::Image();
|
||||
im->load("romfs:/icons/icon.png");
|
||||
for(int i = 0; i < 64; i++)
|
||||
imgdb.push_back(im);*/
|
||||
auto t = RenderD7::FileSystem::GetDirContent("sdmc:/music/");
|
||||
for(const auto& it : t)
|
||||
names.push_back(it.path);
|
||||
}
|
||||
|
||||
Sample::~Sample() {
|
||||
// Here you can clear your data
|
||||
}
|
||||
|
||||
void Sample::Draw() const {
|
||||
// Draw Things to Screen:
|
||||
// Step 1 -> Select Screen
|
||||
RenderD7::OnScreen(Top);
|
||||
// Step 2 -> Draw Things
|
||||
// The hbloader Triangle Wave
|
||||
DrawWave(R7Vec2(0, 0), R7Vec2(400, 240), RenderD7::GetTime(),
|
||||
debug_background);
|
||||
// For Example A Rect with Draw2 and StyleColorApi
|
||||
// And the RFS Wrapper for RectFilledSolid lol
|
||||
/*RenderD7::Draw2::RFS(R7Vec2(0, 0), R7Vec2(400, 20),
|
||||
RenderD7::StyleColor(RD7Color_Header));
|
||||
// As the Top bar is Dark you need TextColor2
|
||||
RenderD7::RedirectColor(RD7Color_Text, RD7Color_Text2);
|
||||
RenderD7::Draw2::Text(R7Vec2(5, 2), "RenderD7 - Test Framework");
|
||||
RenderD7::Draw2::Text(R7Vec2(395, 2), RENDERD7VSTRING,
|
||||
RD7TextFlags_AlignRight);
|
||||
RenderD7::UndoColorEdit(RD7Color_Text);*/
|
||||
if (UI7::BeginMenu("RenderD7 Test Framework")) {
|
||||
UI7::SetCursorPos(R7Vec2(395, 2));
|
||||
UI7::Label(RenderD7::FormatBytes(RenderD7::Memory::GetCurrent()), RD7TextFlags_AlignRight);
|
||||
UI7::RestoreCursor();
|
||||
//UI7::Grid("Files", R7Vec2(390, 210), grid_display_entry, reinterpret_cast<void**>(imgdb.data()), imgdb.size());
|
||||
UI7::BrowserList(names, sel);
|
||||
UI7::EndMenu();
|
||||
}
|
||||
RenderD7::OnScreen(Bottom);
|
||||
if (UI7::BeginMenu("Control Center")) {
|
||||
if (UI7::Button("RenderD7 Settings"))
|
||||
shared_requests[1U] = 1U; // Request a Toggle
|
||||
UI7::SameLine();
|
||||
if (UI7::Button("Test Message"))
|
||||
shared_requests[2U] = 1U; // Request Test Msg
|
||||
UI7::Checkbox("Debug BG", debug_background);
|
||||
UI7::SameLine();
|
||||
UI7::Checkbox("RD7-Debug", rd7_debugging);
|
||||
UI7::InputText("Search", search__, "Tap Here");
|
||||
UI7::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void Sample::Logic() {
|
||||
for (const auto& it : shared_requests) {
|
||||
if (it.first == 1U) {
|
||||
if (it.second) RenderD7::LoadSettings();
|
||||
} else if (it.first == 2U) {
|
||||
if (it.second)
|
||||
RenderD7::PushMessage(RenderD7::Message(
|
||||
"Test Message", "Button Bressed\nBest Msg Handler..."));
|
||||
}
|
||||
}
|
||||
// Make sure to clear after processing!!!;
|
||||
shared_requests.clear();
|
||||
if (d7_hDown & KEY_B) debug_background = !debug_background;
|
||||
}
|
27
rd7tf/source/scene.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <rd7.hpp>
|
||||
|
||||
class Sample : public RenderD7::Scene {
|
||||
public:
|
||||
Sample();
|
||||
~Sample();
|
||||
|
||||
void Draw() const override;
|
||||
void Logic() override;
|
||||
|
||||
private:
|
||||
// Just as the RD7 Settings Shows here as example
|
||||
// by using a mutale map you're able to process
|
||||
// requests from the const Draw function in the
|
||||
// Logic Function! you could also create lots of
|
||||
// mutable bool or make all Variables mutable but
|
||||
// i think seperating draw and logic is better
|
||||
// editable map request_id data/operation
|
||||
mutable std::map<unsigned int, unsigned int> shared_requests;
|
||||
// For Checkbox its best to use mutable
|
||||
mutable bool debug_background = false;
|
||||
mutable std::string search__ = "";
|
||||
mutable std::vector<std::string> names;
|
||||
mutable int sel;
|
||||
};
|
@ -1,475 +0,0 @@
|
||||
#include <renderd7/BitmapPrinter.hpp>
|
||||
#include <renderd7/Ovl.hpp>
|
||||
#include <renderd7/Toast.hpp>
|
||||
#include <renderd7/stringtool.hpp>
|
||||
|
||||
extern bool shouldbe_disabled;
|
||||
extern std::string csvpc;
|
||||
|
||||
RenderD7::BitmapPrinter::BitmapPrinter(int w, int h) {
|
||||
BMP newmap(w, h, true);
|
||||
bitmap = newmap;
|
||||
// renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
|
||||
blank = newmap;
|
||||
}
|
||||
|
||||
RenderD7::BitmapPrinter::~BitmapPrinter() {
|
||||
if (this->renderframe.loadet)
|
||||
this->renderframe.Unload();
|
||||
}
|
||||
|
||||
bool RenderD7::BitmapPrinter::DecodeFile(std::string file) {
|
||||
unsigned error = bitmap.read(file.c_str());
|
||||
|
||||
if (error) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"BitmapPrinter", "Error Code: " + std::to_string(error)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawPixel(int x, int y, u8 b, u8 g, u8 r, u8 a) {
|
||||
unsigned error =
|
||||
bitmap.set_pixel(x, bitmap.bmp_info_header.height - y, b, g, r, a);
|
||||
if (error) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"BitmapPrinter->Pixel", "Error Code: " + std::to_string(error)));
|
||||
}
|
||||
}
|
||||
void RenderD7::BitmapPrinter::DrawRect(int x, int y, int w, int h, u8 line_w,
|
||||
u8 b, u8 g, u8 r, u8 a) {
|
||||
unsigned error = bitmap.draw_rectangle(
|
||||
x, bitmap.bmp_info_header.height - y - h, w, h, b, g, r, a, line_w);
|
||||
if (error) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"BitmapPrinter->Rect", "Error Code: " + std::to_string(error)));
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawRectFilled(int x, int y, int w, int h, u8 b,
|
||||
u8 g, u8 r, u8 a) {
|
||||
unsigned error = bitmap.fill_region(x, bitmap.bmp_info_header.height - h - y,
|
||||
w, h, b, g, r, a);
|
||||
if (error) {
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"BitmapPrinter->RectF", "Error Code: " + std::to_string(error)));
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::SaveBmp(std::string name) {
|
||||
if (!RenderD7::NameIsEndingWith(name, {"bmp"})) {
|
||||
name += ".bmp";
|
||||
}
|
||||
bitmap.write(name.c_str());
|
||||
}
|
||||
void RenderD7::BitmapPrinter::SavePng(std::string name) {
|
||||
if (!RenderD7::NameIsEndingWith(name, {"png"})) {
|
||||
name += ".png";
|
||||
}
|
||||
std::vector<unsigned char> ImageBuffer;
|
||||
ImageBuffer = BitmapConverter::ConvertData(bitmap.DATA());
|
||||
lodepng::save_file(ImageBuffer, name);
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::CreateScreen(C3D_RenderTarget *target) {
|
||||
isscreen = true;
|
||||
targetr = target;
|
||||
if (target == Top) {
|
||||
bitmap = BMP(400, 240, true);
|
||||
blank = BMP(400, 240, true);
|
||||
}
|
||||
if (target == TopRight) {
|
||||
bitmap = BMP(400, 240, true);
|
||||
blank = BMP(400, 240, true);
|
||||
}
|
||||
if (target == Bottom) {
|
||||
bitmap = BMP(320, 240, true);
|
||||
blank = BMP(320, 240, true);
|
||||
}
|
||||
renderframe.LoadPFromBuffer(BitmapConverter::ConvertData(bitmap.DATA()));
|
||||
}
|
||||
bool RenderD7::BitmapPrinter::DrawScreenDirectF(int framerate) {
|
||||
bool updtt = false;
|
||||
if (isscreen) {
|
||||
if (frame == (60 / framerate)) {
|
||||
RenderD7::OnScreen(targetr);
|
||||
if (renderframe.loadet)
|
||||
renderframe.Unload();
|
||||
this->Decode(decc);
|
||||
frame = 0;
|
||||
updtt = true;
|
||||
}
|
||||
|
||||
if (renderframe.loadet)
|
||||
renderframe.Draw(0, 0);
|
||||
frame++;
|
||||
}
|
||||
return updtt;
|
||||
}
|
||||
|
||||
bool RenderD7::BitmapPrinter::DrawScreenDirect() {
|
||||
bool updtt = false;
|
||||
if (isscreen) {
|
||||
RenderD7::OnScreen(targetr);
|
||||
if (renderframe.loadet)
|
||||
renderframe.Unload();
|
||||
this->Decode(decc);
|
||||
updtt = true;
|
||||
if (renderframe.loadet)
|
||||
renderframe.Draw(0, 0);
|
||||
}
|
||||
return updtt;
|
||||
}
|
||||
|
||||
RenderD7::Image RenderD7::BitmapPrinter::GetImage() {
|
||||
RenderD7::Image img;
|
||||
img.LoadFromBitmap(bitmap);
|
||||
return img;
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::UsePreMap(BMP map) { bitmap = map; }
|
||||
void RenderD7::BitmapPrinter::UsePrePrintMap(BitmapPrinter printmap) {
|
||||
bitmap = printmap.GetBitmap();
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::Clear(u8 b, u8 g, u8 r, u8 a) {
|
||||
bitmap.fill_region(0, 0, bitmap.bmp_info_header.width,
|
||||
bitmap.bmp_info_header.height, b, g, r, a);
|
||||
}
|
||||
void RenderD7::BitmapPrinter::ClearBlank() { bitmap = blank; }
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawScreenF(int framerate) {
|
||||
if (isscreen) {
|
||||
if (frame == (60 / framerate)) {
|
||||
RenderD7::OnScreen(targetr);
|
||||
frame = 0;
|
||||
}
|
||||
|
||||
if (renderframe.loadet)
|
||||
renderframe.Draw(0, 0);
|
||||
frame++;
|
||||
}
|
||||
}
|
||||
void RenderD7::BitmapPrinter::DrawScreen() {
|
||||
if (isscreen) {
|
||||
RenderD7::OnScreen(targetr);
|
||||
if (renderframe.loadet)
|
||||
renderframe.Draw(0, 0);
|
||||
}
|
||||
}
|
||||
bool RenderD7::BitmapPrinter::UpdateScreenF(int framerate) {
|
||||
bool updtt = false;
|
||||
if (isscreen) {
|
||||
if (frame == (60 / framerate)) {
|
||||
if (renderframe.loadet)
|
||||
renderframe.Unload();
|
||||
// renderframe.LoadFromBitmap(bitmap);
|
||||
this->Decode(decc);
|
||||
frame = 0;
|
||||
updtt = true;
|
||||
}
|
||||
frame++;
|
||||
}
|
||||
return updtt;
|
||||
}
|
||||
bool RenderD7::BitmapPrinter::UpdateScreen() {
|
||||
bool updtt = false;
|
||||
if (isscreen) {
|
||||
if (renderframe.loadet)
|
||||
renderframe.Unload();
|
||||
this->Decode(decc);
|
||||
updtt = true;
|
||||
}
|
||||
return updtt;
|
||||
}
|
||||
|
||||
#define TICKS_PER_MSEC 268111.856
|
||||
|
||||
void RenderD7::BitmapPrinter::Benchmark() {
|
||||
if (setupbenchmark) {
|
||||
frametime = 0;
|
||||
renderedframes = 0;
|
||||
timer = 0;
|
||||
setupbenchmark = false;
|
||||
lastTime = svcGetSystemTick();
|
||||
}
|
||||
if (benchmark) {
|
||||
if (timer >= 60) {
|
||||
std::string renderedf = std::to_string(renderedframes);
|
||||
std::string avgdtt = std::to_string(mhdtt);
|
||||
float alldtt = 0;
|
||||
for (size_t i = 1; i < hdttt.size(); i++) {
|
||||
alldtt += hdttt[i];
|
||||
}
|
||||
float alldtt2 = 0;
|
||||
for (size_t i = 0; i < hdttt2.size(); i++) {
|
||||
alldtt2 += hdttt2[i];
|
||||
}
|
||||
float alldtt3 = 0;
|
||||
for (size_t i = 0; i < hdttt3.size(); i++) {
|
||||
alldtt3 += hdttt3[i];
|
||||
}
|
||||
int allfps = 0;
|
||||
for (size_t f = 1; f < fpscountc.size(); f++) {
|
||||
allfps += fpscountc[f];
|
||||
}
|
||||
|
||||
std::string avgcpu = std::to_string((alldtt / (float)hdttt.size() - 1));
|
||||
std::string avgcpu2 =
|
||||
std::to_string(((alldtt2 / (float)hdttt2.size()) * 1000));
|
||||
std::string avgcpu3 =
|
||||
std::to_string(((alldtt3 / (float)hdttt3.size()) * 1000));
|
||||
std::string avgfps = std::to_string((allfps / (int)fpscountc.size() - 1));
|
||||
|
||||
std::string resultt =
|
||||
"TestMode: " + std::to_string(testfpsd) + "fps" +
|
||||
"\nRendered Frames: " + renderedf + "\nMax Cpu Time: " + avgdtt +
|
||||
"\nAvg Cpu Time: " + avgcpu + "\nAvg Fps: " + avgfps +
|
||||
"\nAvg EncodeTime: " + avgcpu2 + "ms/f\nAvg DecodeTime: " + avgcpu3 +
|
||||
"ms\n";
|
||||
this->ClearBlank();
|
||||
this->DrawRectFilled(0, 0, this->bitmap.bmp_info_header.width,
|
||||
this->bitmap.bmp_info_header.height, 0, 0, 0, 255);
|
||||
this->DrawDebugText(0, 0, 0, RenderD7::Color::Hex("#ffffff"), resultt);
|
||||
std::string outname =
|
||||
csvpc + "/benchmark_" + RenderD7::GetTimeStr() + ".png";
|
||||
this->SavePng(outname);
|
||||
RenderD7::AddOvl(std::make_unique<RenderD7::Toast>(
|
||||
"Benchmark", "Saved to: \n" + outname));
|
||||
benchmark = false;
|
||||
}
|
||||
uint64_t currentTime = svcGetSystemTick();
|
||||
dtt = ((float)(currentTime / (float)TICKS_PER_MSEC) -
|
||||
(float)(lastTime / (float)TICKS_PER_MSEC)) /
|
||||
1000.f;
|
||||
lastTime = currentTime;
|
||||
lastTime = currentTime;
|
||||
frameCounter++;
|
||||
fpsClock += dtt;
|
||||
if (fpsClock >= 1.f) {
|
||||
fps = frameCounter;
|
||||
frameCounter = 0;
|
||||
fpsClock = 0.f;
|
||||
}
|
||||
uint64_t lastTime2 = svcGetSystemTick();
|
||||
this->ClearBlank();
|
||||
this->DrawRectFilled(0, 0, this->bitmap.bmp_info_header.width,
|
||||
this->bitmap.bmp_info_header.width, 255, 255, 255,
|
||||
255);
|
||||
this->DrawRect(5, 5, this->bitmap.bmp_info_header.width - 10,
|
||||
this->bitmap.bmp_info_header.height - 10, 5, 0, 0, 0, 0);
|
||||
// this->DrawDebugText(20, 20, 0, RenderD7::Color::Hex("#ffffff"), "Fps: " +
|
||||
// std::to_string(fps));
|
||||
this->DrawDebugText(0, 0, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"Time: " + std::to_string(timer));
|
||||
this->DrawDebugText(0, 10, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"Fps: " + std::to_string(fps));
|
||||
this->DrawDebugText(0, 20, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"dt: " + std::to_string(dtt));
|
||||
this->DrawDebugText(0, 30, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"MaxEncodeTime: " + std::to_string(mdtt2 * 1000) +
|
||||
"ms/f");
|
||||
this->DrawDebugText(0, 40, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"MaxDecodeTime: " + std::to_string(mdtt3 * 1000) +
|
||||
"ms");
|
||||
uint64_t currentTime2 = svcGetSystemTick();
|
||||
dtt2 = ((float)(currentTime2 / (float)TICKS_PER_MSEC) -
|
||||
(float)(lastTime2 / (float)TICKS_PER_MSEC)) /
|
||||
1000.f;
|
||||
hdttt2.push_back(dtt2);
|
||||
lastTime2 = svcGetSystemTick();
|
||||
bool updgg = this->UpdateScreenF(testfps);
|
||||
currentTime2 = svcGetSystemTick();
|
||||
dtt3 = ((float)(currentTime2 / (float)TICKS_PER_MSEC) -
|
||||
(float)(lastTime2 / (float)TICKS_PER_MSEC)) /
|
||||
1000.f;
|
||||
if (updgg)
|
||||
hdttt3.push_back(dtt3);
|
||||
if (!shouldbe_disabled)
|
||||
this->DrawScreen();
|
||||
renderedframes++;
|
||||
if (mdtt2 < dtt2) {
|
||||
mdtt2 = dtt2;
|
||||
}
|
||||
if (mdtt3 < dtt3 && updgg) {
|
||||
mdtt3 = dtt3;
|
||||
}
|
||||
timer += 1 * dtt;
|
||||
float hdtt = C3D_GetProcessingTime();
|
||||
hdttt.push_back(hdtt);
|
||||
fpscountc.push_back(fps);
|
||||
if (mhdtt < hdtt) {
|
||||
mhdtt = C3D_GetProcessingTime();
|
||||
}
|
||||
/*if (!shouldbe_disabled)
|
||||
{
|
||||
RenderD7::OnScreen(Bottom);
|
||||
RenderD7::DrawText(0, 0, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"Time: " + std::to_string(timer)); RenderD7::DrawText(0, 20, 0.5f,
|
||||
RenderD7::Color::Hex("#ff0000"), "Fps: " + std::to_string(fps));
|
||||
RenderD7::DrawText(0, 40, 0.5f, RenderD7::Color::Hex("#ff0000"),
|
||||
"dt: " + std::to_string(dtt)); RenderD7::DrawText(0, 60, 0.5f,
|
||||
RenderD7::Color::Hex("#ff0000"), "MaxRenderTime: " +
|
||||
std::to_string(mdtt2*1000) + "ms/f"); RenderD7::DrawText(0, 80, 0.5f,
|
||||
RenderD7::Color::Hex("#ff0000"), "MaxConvertTime: " +
|
||||
std::to_string(mdtt3*1000) + "ms");
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::SetupBenchmark(int framerate) {
|
||||
benchmark = true;
|
||||
setupbenchmark = true;
|
||||
this->testfps = framerate;
|
||||
this->testfpsd = framerate;
|
||||
}
|
||||
|
||||
#include <renderd7/debugfont.h>
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawDebugChar(u32 posX, u32 posY, int t_size,
|
||||
u32 color, char character) {
|
||||
bool isscale = (t_size > 1) ? true : false;
|
||||
for (u32 y = 0; y < 8; y++) {
|
||||
char charPos = debugfont[character * 8 + y];
|
||||
|
||||
for (u32 x = 0; x < 8; x++)
|
||||
if (((charPos >> (7 - x)) & 1) == 1) {
|
||||
if (!isscale)
|
||||
DrawPixel((int)posX + x + 1, (int)posY + y + 1, UNPACK_BGRA(color));
|
||||
if (isscale)
|
||||
DrawRectFilled(((int)posX) + (x * t_size) + 1,
|
||||
((int)posY) + (y * t_size) + 1, t_size, t_size,
|
||||
UNPACK_BGRA(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawChar(int posX, int posY, float t_size,
|
||||
u32 color, char character,
|
||||
RenderD7::NFontApi font) {
|
||||
for (int y = 0; y < font.GetGlyphHeight(character); y++) {
|
||||
for (int x = 0; x < font.GetGlyphWidth(character); x++) {
|
||||
DrawPixel(posX + x + 1, posY + y + 1, 255, 255, 255,
|
||||
font.GetGlyphBitmap(
|
||||
character)[((y * font.GetGlyphWidth(character) + x) * 1)]);
|
||||
if (((font.GetGlyphBitmap(
|
||||
character)[font.GetGlyphHeight(character) + y] >>
|
||||
(font.GetGlyphWidth(character - 1) - x)) &
|
||||
1) == 1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// for(int y = 0; y < font.GetGlyphHeight(character) *
|
||||
// font.GetGlyphWidth(character); y++)
|
||||
//{
|
||||
// DrawPixel(posX + x + 1, posY + y + 1, UNPACK_BGRA(color));
|
||||
//}
|
||||
}
|
||||
|
||||
#define SPACING_Y 10
|
||||
#define SPACING_X 8
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawDebugText(int x, int y, int t_size, u32 color,
|
||||
std::string text) {
|
||||
if (t_size < 1) {
|
||||
t_size = 1;
|
||||
}
|
||||
|
||||
for (u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
||||
switch (text[i]) {
|
||||
case '\n':
|
||||
y += (SPACING_Y * t_size);
|
||||
line_i = 0;
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
line_i += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Make sure we never get out of the screen
|
||||
if (line_i >= (((u32)this->bitmap.bmp_info_header.width) - (u32)x) /
|
||||
(SPACING_X * t_size)) {
|
||||
y += (SPACING_Y * t_size);
|
||||
line_i = 1; // Little offset so we know the same text continues
|
||||
if (text[i] == ' ')
|
||||
break; // Spaces at the start look weird
|
||||
}
|
||||
|
||||
this->DrawDebugChar((u32)x + line_i * (SPACING_X * t_size), (u32)y,
|
||||
t_size, color, text[i]);
|
||||
|
||||
line_i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawText(int x, int y, float t_size, u32 color,
|
||||
std::string text,
|
||||
RenderD7::NFontApi font) {
|
||||
if (t_size < 1) {
|
||||
t_size = 1;
|
||||
}
|
||||
|
||||
for (u32 i = 0, line_i = 0; i < strlen(text.c_str()); i++)
|
||||
switch (text[i]) {
|
||||
case '\n':
|
||||
y += (font.GetLineHeight());
|
||||
line_i = 0;
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
line_i += 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Make sure we never get out of the screen
|
||||
if (line_i >= (((u32)this->bitmap.bmp_info_header.width) - (u32)x) /
|
||||
(u32)(font.GetGlyphWidth(text[i]))) {
|
||||
y += (SPACING_Y * t_size);
|
||||
line_i = 1; // Little offset so we know the same text continues
|
||||
if (text[i] == ' ')
|
||||
break; // Spaces at the start look weird
|
||||
}
|
||||
|
||||
this->DrawChar(x + line_i * (font.GetGlyphWidth(text[i])), y, t_size,
|
||||
color, text[i], font);
|
||||
|
||||
line_i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderD7::BitmapPrinter::Decode(Decoder deccc) {
|
||||
bool res = false;
|
||||
|
||||
switch (deccc) {
|
||||
case Decoder::BITMAP2PNG2C3D:
|
||||
renderframe.LoadPFromBuffer(
|
||||
BitmapConverter::ConvertData(this->bitmap.DATA()));
|
||||
res = true;
|
||||
break;
|
||||
case Decoder::BITMAP2C3D:
|
||||
renderframe.LoadFromBitmap(this->bitmap);
|
||||
res = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void RenderD7::BitmapPrinter::DrawBitmap(int x, int y, BMP map) {
|
||||
for (int i = 0; i < map.bmp_info_header.width; i++) {
|
||||
for (int j = 0; j < map.bmp_info_header.height; j++) {
|
||||
bitmap.set_pixel(
|
||||
x + i, (bitmap.bmp_info_header.height - 1) - (y + j),
|
||||
UNPACK_BGRA(map.get_pixel(i, (map.bmp_info_header.height - 1) - j)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +1,71 @@
|
||||
#include <map>
|
||||
#include <renderd7/Color.hpp>
|
||||
|
||||
#define RGBA8(r, g, b, a) \
|
||||
((((r)&0xFF) << 0) | (((g)&0xFF) << 8) | (((b)&0xFF) << 16) | \
|
||||
(((a)&0xFF) << 24))
|
||||
// This is btw the default theme setup
|
||||
// RenderD7 StyleColor Api
|
||||
// not const cause const = error lol
|
||||
std::map<RD7Color, unsigned int> rd7i_color_map = {
|
||||
{RD7Color_Text, RGBA8(0, 0, 0, 255)},
|
||||
{RD7Color_Text2, RGBA8(255, 255, 255, 255)}, // For Background change or so
|
||||
{RD7Color_TextDisabled, RGBA8(170, 170, 170, 255)},
|
||||
{RD7Color_Background, RGBA8(238, 238, 238, 255)},
|
||||
{RD7Color_Header, RGBA8(17, 17, 17, 255)},
|
||||
{RD7Color_Selector, RGBA8(34, 34, 34, 255)},
|
||||
{RD7Color_SelectorFade, RGBA8(90, 90, 90, 255)},
|
||||
{RD7Color_List0, RGBA8(204, 204, 204, 255)}, // List0 = % 2
|
||||
{RD7Color_List1, RGBA8(187, 187, 187, 255)},
|
||||
{RD7Color_MessageBackground, RGBA8(51, 51, 51, 255)},
|
||||
{RD7Color_Button, RGBA8(17, 17, 17, 255)},
|
||||
{RD7Color_ButtonHovered, RGBA8(34, 34, 34, 255)},
|
||||
{RD7Color_ButtonDisabled, RGBA8(8, 8, 8, 255)},
|
||||
{RD7Color_ButtonActive, RGBA8(42, 42, 42, 255)},
|
||||
{RD7Color_Checkmark, RGBA8(42, 42, 42, 255)},
|
||||
{RD7Color_FrameBg, RGBA8(85, 85, 85, 255)},
|
||||
{RD7Color_FrameBgHovered, RGBA8(119, 119, 119, 255)},
|
||||
{RD7Color_Progressbar, RGBA8(0, 255, 0, 255)},
|
||||
};
|
||||
|
||||
// uint32_t RenderD7::Color::Hex(const std::string &color, uint8_t a) {
|
||||
// if (color.length() < 7 ||
|
||||
// std::regex_search(color.substr(1),
|
||||
// std::regex("[^0-9A-Fa-f]"))) { // invalid color.
|
||||
// return RenderD7::Color::Hex("#000000", 0);
|
||||
// }
|
||||
// int r = std::stoi(color.substr(1, 2), nullptr, 16);
|
||||
// int g = std::stoi(color.substr(3, 2), nullptr, 16);
|
||||
// int b = std::stoi(color.substr(5, 2), nullptr, 16);
|
||||
// return RGBA8(r, g, b, a);
|
||||
// }
|
||||
std::map<RD7Color, unsigned int> rd7i_color_swap_map;
|
||||
|
||||
// Lookup-Table für Hex-to-Dez-Konvertierung
|
||||
unsigned int RenderD7::StyleColor(RD7Color color) {
|
||||
if (rd7i_color_swap_map.find(color) != rd7i_color_swap_map.end())
|
||||
return rd7i_color_swap_map[color];
|
||||
else if (rd7i_color_map.find(color) != rd7i_color_map.end())
|
||||
return rd7i_color_map[color];
|
||||
return RGBA8(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void RenderD7::ColorNew(RD7Color color, unsigned int new_color) {
|
||||
rd7i_color_map[color] = new_color;
|
||||
}
|
||||
|
||||
void RenderD7::RedirectColor(RD7Color to, RD7Color from) {
|
||||
// As you see at the code Redirect doesnt redirect xd
|
||||
// Just named cause it feels like redirecting
|
||||
// Oh and if the color is edit you redirect to it is
|
||||
// grabs that redirected lol
|
||||
rd7i_color_swap_map[to] = StyleColor(from);
|
||||
}
|
||||
|
||||
void RenderD7::CustomizeColor(RD7Color color, unsigned int custom) {
|
||||
rd7i_color_swap_map[color] = custom;
|
||||
}
|
||||
|
||||
void RenderD7::TextColorByBg(RD7Color background) {
|
||||
UndoColorEdit(RD7Color_Text); // To be sure
|
||||
rd7i_color_swap_map[RD7Color_Text] = StyleColor(
|
||||
Color::RGBA(background).is_light() ? RD7Color_Text : RD7Color_Text2);
|
||||
}
|
||||
|
||||
void RenderD7::UndoColorEdit(RD7Color color) {
|
||||
if (rd7i_color_swap_map.find(color) == rd7i_color_swap_map.end())
|
||||
return;
|
||||
rd7i_color_swap_map.erase(color);
|
||||
}
|
||||
|
||||
void RenderD7::UndoAllColorEdits() { rd7i_color_swap_map.clear(); }
|
||||
|
||||
// Standart Color Converter
|
||||
static const std::map<char, int> HEX_TO_DEC = {
|
||||
{'0', 0}, {'1', 1}, {'2', 2}, {'3', 3}, {'4', 4}, {'5', 5},
|
||||
{'6', 6}, {'7', 7}, {'8', 8}, {'9', 9}, {'a', 10}, {'b', 11},
|
||||
|
216
source/Draw.cpp
@ -1,216 +0,0 @@
|
||||
#include <renderd7/Draw.hpp>
|
||||
|
||||
extern C2D_TextBuf TextBuf;
|
||||
extern C2D_Font Font;
|
||||
extern bool currentScreen;
|
||||
|
||||
bool RenderD7::Draw::Rect(float x, float y, float w, float h, u32 color) {
|
||||
return C2D_DrawRectSolid(x, y, 0.5f, w, h, color);
|
||||
}
|
||||
|
||||
bool RenderD7::Draw::Px(float x, float y, u32 color) {
|
||||
return C2D_DrawRectSolid(x, y, 0.5f, 1, 1, color);
|
||||
}
|
||||
|
||||
void RenderD7::Draw::TextCentered(float x, float y, float size, u32 color,
|
||||
std::string Text, int maxWidth, int maxHeight,
|
||||
C2D_Font fnt) {
|
||||
float lineHeight, widthScale;
|
||||
|
||||
// Check for the lineHeight.
|
||||
if (fnt != nullptr) {
|
||||
lineHeight = RenderD7::Draw::GetTextHeight(size, " ", fnt);
|
||||
} else {
|
||||
lineHeight = RenderD7::Draw::GetTextHeight(size, " ");
|
||||
}
|
||||
|
||||
int line = 0;
|
||||
while (Text.find('\n') != Text.npos) {
|
||||
if (maxWidth == 0) {
|
||||
// Do the widthScale.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = RenderD7::Draw::GetTextWidth(
|
||||
size, Text.substr(0, Text.find('\n')), fnt);
|
||||
} else {
|
||||
widthScale =
|
||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||
}
|
||||
} else {
|
||||
// Do the widthScale 2.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = std::min((float)maxWidth,
|
||||
RenderD7::Draw::GetTextWidth(
|
||||
size, Text.substr(0, Text.find('\n')), fnt));
|
||||
} else {
|
||||
widthScale = std::min((float)maxWidth,
|
||||
RenderD7::Draw::GetTextWidth(
|
||||
size, Text.substr(0, Text.find('\n'))));
|
||||
}
|
||||
}
|
||||
if (fnt != nullptr) {
|
||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
||||
y + (lineHeight * line), size, color,
|
||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight,
|
||||
fnt);
|
||||
} else {
|
||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
||||
y + (lineHeight * line), size, color,
|
||||
Text.substr(0, Text.find('\n')), maxWidth,
|
||||
maxHeight);
|
||||
}
|
||||
|
||||
Text = Text.substr(Text.find('\n') + 1);
|
||||
line++;
|
||||
}
|
||||
|
||||
if (maxWidth == 0) {
|
||||
// Do the next WidthScale.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = RenderD7::Draw::GetTextWidth(
|
||||
size, Text.substr(0, Text.find('\n')), fnt);
|
||||
} else {
|
||||
widthScale =
|
||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n')));
|
||||
}
|
||||
} else {
|
||||
// And again.
|
||||
if (fnt != nullptr) {
|
||||
widthScale = std::min((float)maxWidth,
|
||||
RenderD7::Draw::GetTextWidth(
|
||||
size, Text.substr(0, Text.find('\n')), fnt));
|
||||
} else {
|
||||
widthScale = std::min(
|
||||
(float)maxWidth,
|
||||
RenderD7::Draw::GetTextWidth(size, Text.substr(0, Text.find('\n'))));
|
||||
}
|
||||
}
|
||||
if (fnt != nullptr) {
|
||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
||||
y + (lineHeight * line), size, color,
|
||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight,
|
||||
fnt);
|
||||
} else {
|
||||
RenderD7::Draw::Text((currentScreen ? 200 : 160) + x - (widthScale / 2),
|
||||
y + (lineHeight * line), size, color,
|
||||
Text.substr(0, Text.find('\n')), maxWidth, maxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw String or Text.
|
||||
void RenderD7::Draw::Text(float x, float y, float size, u32 color,
|
||||
std::string Text, int maxWidth, int maxHeight,
|
||||
C2D_Font fnt) {
|
||||
C2D_Text c2d_text;
|
||||
|
||||
if (fnt != nullptr) {
|
||||
C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str());
|
||||
} else {
|
||||
C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str());
|
||||
}
|
||||
|
||||
C2D_TextOptimize(&c2d_text);
|
||||
|
||||
float heightScale;
|
||||
if (maxHeight == 0) {
|
||||
heightScale = size;
|
||||
} else {
|
||||
if (fnt != nullptr) {
|
||||
heightScale = std::min(
|
||||
size,
|
||||
size * (maxHeight / RenderD7::Draw::GetTextHeight(size, Text, fnt)));
|
||||
} else {
|
||||
heightScale = std::min(
|
||||
size, size * (maxHeight / RenderD7::Draw::GetTextHeight(size, Text)));
|
||||
}
|
||||
}
|
||||
|
||||
if (maxWidth == 0) {
|
||||
C2D_DrawText(&c2d_text, C2D_WithColor, x, y, 0.5f, size, heightScale,
|
||||
color);
|
||||
} else {
|
||||
if (fnt != nullptr) {
|
||||
C2D_DrawText(
|
||||
&c2d_text, C2D_WithColor, x, y, 0.5f,
|
||||
std::min(size, size * (maxWidth / RenderD7::Draw::GetTextWidth(
|
||||
size, Text, fnt))),
|
||||
heightScale, color);
|
||||
} else {
|
||||
C2D_DrawText(
|
||||
&c2d_text, C2D_WithColor, x, y, 0.5f,
|
||||
std::min(size, size * (maxWidth /
|
||||
RenderD7::Draw::GetTextWidth(size, Text))),
|
||||
heightScale, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
void RenderD7::Draw::TextRight(float x, float y, float size, u32 color,
|
||||
std::string Text, int maxWidth, int maxHeight,
|
||||
C2D_Font fnt) {
|
||||
RenderD7::Draw::Text(x - RenderD7::Draw::GetTextWidth(size, Text, fnt), y,
|
||||
size, color, Text, maxWidth, maxHeight, fnt);
|
||||
}
|
||||
// Get String or Text Width.
|
||||
float RenderD7::Draw::GetTextWidth(float size, std::string Text, C2D_Font fnt) {
|
||||
float width = 0;
|
||||
if (fnt != nullptr) {
|
||||
GetTextSize(size, &width, NULL, Text, fnt);
|
||||
} else {
|
||||
GetTextSize(size, &width, NULL, Text);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
// Get String or Text Size.
|
||||
void RenderD7::Draw::GetTextSize(float size, float *width, float *height,
|
||||
std::string Text, C2D_Font fnt) {
|
||||
C2D_Text c2d_text;
|
||||
if (fnt != nullptr) {
|
||||
C2D_TextFontParse(&c2d_text, fnt, TextBuf, Text.c_str());
|
||||
} else {
|
||||
C2D_TextFontParse(&c2d_text, Font, TextBuf, Text.c_str());
|
||||
}
|
||||
C2D_TextGetDimensions(&c2d_text, size, size, width, height);
|
||||
}
|
||||
|
||||
// Get String or Text Height.
|
||||
float RenderD7::Draw::GetTextHeight(float size, std::string Text,
|
||||
C2D_Font fnt) {
|
||||
float height = 0;
|
||||
if (fnt != nullptr) {
|
||||
GetTextSize(size, NULL, &height, Text.c_str(), fnt);
|
||||
} else {
|
||||
GetTextSize(size, NULL, &height, Text.c_str());
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
Result RenderD7::Draw::LoadFont(C2D_Font &fnt, const char *Path) {
|
||||
fnt = C2D_FontLoad(Path); // Only load if found.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Unload a Font.
|
||||
Result RenderD7::Draw::UnloadFont(C2D_Font &fnt) {
|
||||
if (fnt != nullptr) {
|
||||
C2D_FontFree(fnt); // Make sure to only unload if not nullptr.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RenderD7::Draw::Circle(float x, float y, float radius, u32 color) {
|
||||
return C2D_DrawCircleSolid(x, y, 0.5f, radius, color);
|
||||
}
|
||||
|
||||
bool RenderD7::Draw::Image(C2D_Image img, float x, float y, float scaleX,
|
||||
float scaleY) {
|
||||
return C2D_DrawImageAt(img, x, y, 0.5f, nullptr, scaleX, scaleY);
|
||||
}
|
||||
|
||||
bool RenderD7::Draw::NFRect(float p1x, float p1y, float w, float h, u32 color,
|
||||
float scale) {
|
||||
C2D_DrawLine(p1x, p1y, color, w, p1y, color, scale, 1);
|
||||
C2D_DrawLine(w, p1y, color, w, h, color, scale, 1);
|
||||
C2D_DrawLine(w, h, color, p1x, h, color, scale, 1);
|
||||
C2D_DrawLine(p1x, h, color, p1x, p1y, color, scale, 1);
|
||||
return true;
|
||||
}
|
237
source/DrawV2.cpp
Normal file
@ -0,0 +1,237 @@
|
||||
#include <citro2d.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <renderd7/DrawV2.hpp>
|
||||
#include <renderd7/global_db.hpp>
|
||||
#include <renderd7/internal_db.hpp>
|
||||
|
||||
const float rd7i_d7_dts = 0.5f;
|
||||
float rd7i_d2_txt_size = rd7i_d7_dts;
|
||||
C2D_Font rd7i_d2_fnt = nullptr;
|
||||
R7Vec2 rd7i_d7_mwh = R7Vec2(0, 0);
|
||||
std::map<std::string, float> rd7i_d2_ts;
|
||||
std::map<std::string, int> rd7i_d2_mln;
|
||||
|
||||
bool rd7i_txt_init = false;
|
||||
|
||||
std::string GetShortedText(const std::string &in, int maxlen) {
|
||||
auto textdim = RenderD7::GetTextDimensions(in);
|
||||
if (textdim.x < (float)maxlen) return in;
|
||||
std::string ft = "";
|
||||
std::string worker = in;
|
||||
if (in.find_last_of('.') != in.npos) {
|
||||
ft = in.substr(in.find_last_of('.'));
|
||||
worker = in.substr(0, in.find_last_of('.'));
|
||||
}
|
||||
|
||||
maxlen -= RenderD7::GetTextDimensions(ft).x -
|
||||
RenderD7::GetTextDimensions("(...)").x;
|
||||
float len_mod = (float)maxlen / textdim.x;
|
||||
int pos = (in.length() * len_mod) / rd7_draw2_tsm;
|
||||
std::string out;
|
||||
|
||||
out = in.substr(0, pos);
|
||||
|
||||
for (size_t i = pos; i < worker.length(); i++) {
|
||||
out += worker[i];
|
||||
if (RenderD7::GetTextDimensions(out + "(...)" + ft).x > (float)maxlen) {
|
||||
out += "(...)";
|
||||
out += ft;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return ""; // Impossible to reach
|
||||
}
|
||||
|
||||
std::string WrapText(const std ::string &in, int maxlen) {
|
||||
std::string out;
|
||||
std::string line;
|
||||
int line_x = 0;
|
||||
std::istringstream istream(in);
|
||||
std::string temp;
|
||||
|
||||
while (istream >> temp) {
|
||||
R7Vec2 dim = RenderD7::GetTextDimensions(line + temp);
|
||||
if (line_x + dim.x <= maxlen) {
|
||||
line += temp + ' ';
|
||||
line_x += dim.x;
|
||||
} else {
|
||||
out += line + '\n';
|
||||
line = temp + ' ';
|
||||
line_x = dim.x;
|
||||
}
|
||||
}
|
||||
out += line;
|
||||
return out;
|
||||
}
|
||||
|
||||
bool RD7I_FNT_VALID() {
|
||||
if (rd7i_d2_fnt != nullptr && !rd7i_txt_init) {
|
||||
rd7i_txt_init = true;
|
||||
}
|
||||
if (!rd7i_txt_init) {
|
||||
if (rd7i_base_font != nullptr) {
|
||||
rd7i_d2_fnt = rd7i_base_font;
|
||||
rd7i_txt_init = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (rd7i_d2_fnt != nullptr) {
|
||||
return true;
|
||||
} else {
|
||||
rd7i_d2_fnt = rd7i_base_font;
|
||||
return true;
|
||||
}
|
||||
// Schould never be reached
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
R7Vec2 GetTextDimensions(const std::string &text) {
|
||||
C2D_TextBufClear(rd7i_d2_dimbuf);
|
||||
float w = 0, h = 0;
|
||||
if (!RD7I_FNT_VALID()) return R7Vec2(w, h);
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_d2_dimbuf, text.c_str());
|
||||
C2D_TextGetDimensions(&c2dtext, rd7i_d2_txt_size, rd7i_d2_txt_size, &w, &h);
|
||||
return R7Vec2(w, h);
|
||||
}
|
||||
|
||||
void CustomTextSize(float size) { rd7i_d2_txt_size = size; }
|
||||
|
||||
void TextDefaultSize() { rd7i_d2_txt_size = rd7i_d7_dts; }
|
||||
|
||||
void TextMaxBox(R7Vec2 size) { rd7i_d7_mwh = size; }
|
||||
|
||||
void TextDefaultBox() { rd7i_d7_mwh = R7Vec2(0, 0); }
|
||||
|
||||
void TextFont(C2D_Font fnt) { rd7i_d2_fnt = fnt; }
|
||||
|
||||
void TextDefaultFont() { rd7i_d2_fnt = rd7i_base_font; }
|
||||
|
||||
std::string TextShort(const std::string &in, int max_len) {
|
||||
return GetShortedText(in, max_len);
|
||||
}
|
||||
|
||||
namespace Draw2 {
|
||||
void Rect(R7Vec2 pos, R7Vec2 size, unsigned int color, int t) {
|
||||
// 4 DrawLine Calls Lol
|
||||
C2D_DrawLine(pos.x, pos.y, color, pos.x + size.x, pos.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos.x, pos.y, color, pos.x, pos.y + size.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos.x + size.x, pos.y, color, pos.x + size.x, pos.y + size.y,
|
||||
color, t, 1.f);
|
||||
C2D_DrawLine(pos.x, pos.y + size.y, color, pos.x + size.x, pos.y + size.y,
|
||||
color, t, 1.f);
|
||||
}
|
||||
|
||||
void RectFilled(R7Vec2 pos, R7Vec2 size, Color4 colors) {
|
||||
C2D_DrawRectangle(pos.x, pos.y, 0.5f, size.x, size.y, colors.color0,
|
||||
colors.color1, colors.color2, colors.color3);
|
||||
}
|
||||
|
||||
void RectFilledSolid(R7Vec2 pos, R7Vec2 size, unsigned int color) {
|
||||
C2D_DrawRectSolid(pos.x, pos.y, 0.5f, size.x, size.y, color);
|
||||
}
|
||||
|
||||
void Line(R7Vec2 pos0, R7Vec2 pos1, unsigned int color, int t) {
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||
}
|
||||
|
||||
void Triangle(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, Color3 colors) {
|
||||
C2D_DrawTriangle(pos0.x, pos0.y, colors.color0, pos1.x, pos1.y, colors.color1,
|
||||
pos2.x, pos2.y, colors.color2, 0.5f);
|
||||
}
|
||||
|
||||
void TriangleSolid(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color) {
|
||||
C2D_DrawTriangle(pos0.x, pos0.y, color, pos1.x, pos1.y, color, pos2.x, pos2.y,
|
||||
color, 0.5f);
|
||||
}
|
||||
|
||||
void TriangleLined(R7Vec2 pos0, R7Vec2 pos1, R7Vec2 pos2, unsigned int color,
|
||||
int t) {
|
||||
// 3 Line Cqalls lol more efficient than Rect
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos1.x, pos1.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos0.x, pos0.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||
C2D_DrawLine(pos1.x, pos1.y, color, pos2.x, pos2.y, color, t, 1.f);
|
||||
}
|
||||
|
||||
void Text(R7Vec2 pos, const std::string &text, RD7TextFlags flags) {
|
||||
// The Start of the C2D Text Hell
|
||||
if (!RD7I_FNT_VALID()) return;
|
||||
// Variables
|
||||
bool updated_mwh = false;
|
||||
if (rd7i_d7_mwh.x == 0.0f) {
|
||||
rd7i_d7_mwh.x = rd7i_current_screen ? 400 : 320;
|
||||
updated_mwh = true;
|
||||
}
|
||||
if (rd7i_d7_mwh.y == 0.0f) {
|
||||
rd7i_d7_mwh.y = 240;
|
||||
updated_mwh = true;
|
||||
}
|
||||
std::string edit_text = text;
|
||||
if (edit_text.substr(text.length() - 1) != "\n")
|
||||
edit_text.append("\n"); // Add \n to end if not exist
|
||||
int line = 0;
|
||||
|
||||
if(flags & RD7TextFlags_Wrap)
|
||||
edit_text = WrapText(text, rd7i_d7_mwh.x - pos.x);
|
||||
|
||||
while (edit_text.find('\n') != edit_text.npos) {
|
||||
std::string current_line = edit_text.substr(0, edit_text.find('\n'));
|
||||
if (flags & RD7TextFlags_Short)
|
||||
current_line = GetShortedText(current_line, rd7i_d7_mwh.x - pos.x);
|
||||
R7Vec2 newpos = pos;
|
||||
// Check Flags
|
||||
R7Vec2 dim = GetTextDimensions(current_line);
|
||||
if (flags & RD7TextFlags_AlignRight)
|
||||
newpos.x = newpos.x - GetTextDimensions(current_line).x;
|
||||
if (flags & RD7TextFlags_AlignMid) // Offset by inpos
|
||||
newpos.x = (rd7i_d7_mwh.x * 0.5) - (dim.x * 0.5) + pos.x;
|
||||
if (flags & RD7TextFlags_Scroll) { // Scroll Text
|
||||
if (newpos.x + dim.x > rd7i_d7_mwh.x - newpos.x - 10) {
|
||||
if (rd7i_d2_ts.find(current_line) == rd7i_d2_ts.end())
|
||||
rd7i_d2_ts[current_line] = 0;
|
||||
if (rd7i_d2_mln.find(current_line) == rd7i_d2_mln.end())
|
||||
rd7i_d2_mln[current_line] =
|
||||
GetShortedText(current_line, rd7i_d7_mwh.x - newpos.x).length();
|
||||
rd7i_d2_ts[current_line] += rd7i_dtm * 6;
|
||||
if ((int)rd7i_d2_ts[current_line] >= (int)current_line.length()) {
|
||||
rd7i_d2_ts[current_line] = 0.0f;
|
||||
}
|
||||
std::string bcl = current_line;
|
||||
current_line = current_line.substr((int)rd7i_d2_ts[current_line],
|
||||
rd7i_d2_mln[current_line]);
|
||||
if (newpos.x + GetTextDimensions(current_line).x <
|
||||
rd7i_d7_mwh.x - newpos.x)
|
||||
current_line +=
|
||||
"|" + bcl.substr(0, rd7i_d2_ts[bcl] - (int)current_line.length());
|
||||
}
|
||||
}
|
||||
if (rd7_debugging) {
|
||||
RenderD7::Draw2::Rect(newpos, dim, RenderD7::Color::Hex("#ff0000"));
|
||||
}
|
||||
C2D_Text c2dtext;
|
||||
C2D_TextFontParse(&c2dtext, rd7i_d2_fnt, rd7i_text_buffer,
|
||||
current_line.c_str());
|
||||
C2D_TextOptimize(&c2dtext);
|
||||
|
||||
if (flags & RD7TextFlags_Shaddow) // performance Killer xd
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x + 1 + (dim.y * line),
|
||||
newpos.y + 1, 0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||
RenderD7::StyleColor(RD7Color_TextDisabled));
|
||||
|
||||
C2D_DrawText(&c2dtext, C2D_WithColor, newpos.x, newpos.y + (dim.y * line),
|
||||
0.5, rd7i_d2_txt_size, rd7i_d2_txt_size,
|
||||
RenderD7::StyleColor(RD7Color_Text));
|
||||
edit_text = edit_text.substr(edit_text.find('\n') + 1);
|
||||
line++;
|
||||
}
|
||||
|
||||
if (updated_mwh) rd7i_d7_mwh = R7Vec2(0, 0);
|
||||
}
|
||||
void Image(RenderD7::Image *img, const R7Vec2 &pos, const R7Vec2 &scale) {
|
||||
if (img->loaded())
|
||||
C2D_DrawImageAt(img->get(), pos.x, pos.y, 0.5f, nullptr, scale.x, scale.y);
|
||||
}
|
||||
} // namespace Draw2
|
||||
} // namespace RenderD7
|