26 Commits

Author SHA1 Message Date
Myles Busig
b7776ef379 Optimize and expand fixed point number implementation
Before this commit, fixed point multiplication was implemented using an
assembly routine in a separate translation unit. This commit implements
this routine directly using inline assembly. By doing so, these
operations can be inlined when called from ARM code. Fixed point
division is implemented as well, along with various documentation and
style improvements.
2024-07-28 19:24:47 -06:00
Myles Busig
b53bedbcb7 Add ability to disable logging
If MTL_LOGGING_DISABLED is defined, logging is disabled. Otherwise, it
is enabled.
2024-06-19 19:36:26 -06:00
Myles Busig
1738dd9f63 Change log level to use an enum instead of uint 2024-06-19 19:29:45 -06:00
Myles Busig
dff9316987 Refactor string_stream and string_streamx, and provide ENDL selection
option

This commit refactors string_stream and string_streamx into a common
basic_string_stream template class. When the EXT template == true, the
string_streamx formatting options are enabled, they default to disabled.
These options are enabled at compile time, and do not affect performance
when they are disabled. By implementing the two streams in this manner,
duplicated code is removed.

This commit also adds the ENDL template paramter. When ENDL is set to
zero, no endline character is printed when piping mtl::endl. Otherwise,
the character is printed. Defaults to '\n'. This allows logging on the
GBA to handle mtl::endl correctly and not print two newlines on the MGBA
emulator.
2024-04-10 08:39:30 -06:00
Myles Busig
1d41674dc1 Fix udiv100000 and udiv1000000000 ASM macros changing the source
register
2024-04-04 04:18:36 -06:00
Myles Busig
002bd5a17a Fix type stdin instead of stdout 2024-03-27 00:59:10 -06:00
Myles Busig
81a44afbb4 Add log 2024-03-27 00:32:54 -06:00
Myles Busig
f1275bfcc5 Fix incorrect usage of platform specific function 2024-03-27 00:30:45 -06:00
Myles Busig
dbdf8b6e3c Change armv4t integer to string conversion to use an unrolled loop
This implementation also writes the digits from left to right instead of
right to left. Using this method we can write the string to the
beginning of the buffer and still avoid reversing the string. It also
has the benefit of being slightly slower than the previous
implementation. The function's signature changed as well because there
is no longer a reason to pass the buffer size or a pointer to output the
start of the string.
2024-03-25 17:13:29 -06:00
Myles Busig
0a84391c39 Add armv4t assembly optimized integer to string conversion functions 2024-03-24 01:07:24 -06:00
Myles Busig
998e3adf4d Add armv4t assembly optimized division and modulo by 10 2024-03-24 00:30:56 -06:00
Myles Busig
6d5c083616 Optimize string single character append
Now uses a specialized implementation instead of the append multiple
characters implementation. Useful for appending single characters to
string streams (ex. newline).
2024-03-21 20:35:22 -06:00
Myles Busig
c7918a2b8b Update CMakeLists.txt to use globbing, and support arch. dependent files
CONFIGURE_DEPENDS option was added in CMake v3.12. This option allows the
build system to automatically re-run CMake if the glob changes, solving the
major issue with globbing. May have a performance impact, but it should be
negligible compared to the time spent building.
2024-03-10 21:55:50 -06:00
Myles Busig
a8c30df08e Implement istring replace, append, erase 2024-03-10 20:50:09 -06:00
Myles Busig
cf90307a1f Implement istring comparison operators
Not thoroughly tested.
2024-03-07 21:29:44 -07:00
Myles Busig
b6746d7ac0 Remove iterators from string and string_view
Iterators could probably be implemented efficiently, but it is not a
priority at the moment. They are removed for the time being.
2024-03-07 19:38:00 -07:00
Myles Busig
ca8aae6c66 Change istring to use string_view for the majority of its operations
The istring and string_view operators have identical implementations. By
changing the istring operators to cast to string_view and use that
implementation instead, the number of redundant implementations is
reduced. This does incurr a small performance penalty, around 15 cycles
when tested on the MGBA Gameboy Advance emulator (uses an armv7tdmi).
When compared to the time operations take, the performance difference is
negligible. Ex. An insertion with two 8 character strings takes around
450 cycles.
2024-03-07 16:28:18 -07:00
Myles Busig
18246e131f Implement istring::insert with given index and count 2024-03-07 16:07:21 -07:00
Myles Busig
cb4f9d2861 Implement string::copy and string_view::copy 2024-03-07 15:57:29 -07:00
Myles Busig
6f98434a18 Fix mtl_rmemcpy32 incorrectly calculating the number of bytes and words 2024-03-07 15:53:10 -07:00
Myles Busig
e8601d7807 Change strings to use mtl::memmove instead of memcpy ot std::memmove 2024-03-07 14:32:46 -07:00
Myles Busig
7bfc38d978 Change strings to use string_view instead of const char*
Because the length of a string_view is computed at compile time, it is
faster for simple copies.
2024-03-07 14:25:39 -07:00
Myles Busig
99bb7d4b6e Add initial string_view implementation 2024-03-07 14:24:10 -07:00
Myles Busig
6f74f94aee Add initial fixed point number implementation 2024-03-06 23:42:48 -07:00
Myles Busig
d89ae1fbe5 Fix rmemcpy32 not copying chunks correctly 2024-03-06 23:00:38 -07:00
Myles Busig
29aa5bdc5b Add cmake files and initial memcpy/string implementation 2024-03-04 20:44:58 -07:00