Commit Graph

39 Commits

Author SHA1 Message Date
SonoSooS
ad57534181 Move memory dispatch code separate from the microcode 2025-02-22 05:49:22 +01:00
SonoSooS
38160087f6 Clean up unused code 2025-02-22 04:47:31 +01:00
SonoSooS
c701fa064e Absolutely destroy microcode dispatch code
ISTG, gcc spills registers to stack more often than a glass without a bottom.
Like seriously, is it really necessary to push and use r4, when r2 and r3 are not used? Or to push r4 and pop it back without ever getting used?

Bleh.
2025-02-22 04:37:39 +01:00
SonoSooS
cf87d798f6 Replace even more instances of logic ops with arithmetic ops 2025-02-21 22:24:16 +01:00
SonoSooS
23a02847a1 Reduce and restructure some logic on JR space heater detection 2025-02-21 22:22:59 +01:00
SonoSooS
6461c8d63e Try replacing more binary ops with ALU ops 2025-02-21 21:52:02 +01:00
SonoSooS
f1af3630ee Optimize WRAM accesses too 2025-02-21 21:51:33 +01:00
SonoSooS
487cd28dfa Change some binary ops to ALU ops to make Thumb targets faster
Thumb has no imm8 version encoding for AND and ORR opcodes, so this change should bring some speedup, as no register trashing (and thus extra register PUSHed to and POPped from stack is saved), and no LDR from constant pool necessary.
This also speeds up x86 target by a great margin for some reason.
2025-02-21 21:21:11 +01:00
SonoSooS
b9ccc3fe26 Update cycle timing comments, and fix POP r16 timing 2025-02-21 21:00:07 +01:00
SonoSooS
36d6417678 Remove the Cache Destroyed instruction decoder
It was an unmaintainable broken mess anyway, it serves no purpose
2025-02-21 19:51:05 +01:00
SonoSooS
cc3890856c Add CGB mode switching support 2024-11-23 02:12:03 +01:00
SonoSooS
136f4c1cfe Hack back flat ROM pointer support
It was present in prerelease alpha version, but when porting to the RP2040, it was converted to double indirection, as it worked with the shitty LRU algo that I used at the time.
However, double indirection is not only slower just by requiring an extra load instruction, it's also slower by trashing the cache. On Windows, I get a 10% performance decrease with double indirection, which is pretty wild.
2024-06-03 06:05:03 +02:00
SonoSooS
93f95219fb Optimize 2-byte operand fetch
Although gcc makes me pull my hair out with its aggressive nonsense spilling to the stack, and me having to resort to these nonsensical attribute spam just to get it to stop spilling my registers :(
2024-06-03 04:43:43 +02:00
SonoSooS
0a471d4764 More funny tail call optimization 2024-06-03 03:43:49 +02:00
SonoSooS
225cd8f3f9 Take a shot every time gcc unnecessarily spills regs to stack
(impossible challenge)
2024-06-03 02:51:32 +02:00
SonoSooS
3276940d88 Experimental shortcut for often-used functions
Thanks @nstbayless for the instruction count data!
2024-06-02 05:13:20 +02:00
SonoSooS
d1090f16fe Hard-to-read code doesn't run any faster 2024-06-02 04:03:20 +02:00
SonoSooS
dc2690be69 Bunch of core microoptimizations and refactors
- Added extra comments for spicy code (to be refactored)
- Made code more risky (due to assumptions, this is perfectly fine, edge cases are accounted for)
- Made code more Thumb-friendly (replaced binary (AND/OR) ops with constant with ALU (ADD/SUB) ops with constant, saving on register pressure and constant loads)
- Tuned code for gcc without inline ASM for better register allocation, and thus faster code due to less PUSHes/POPs
- Introduced an off-by-one error intentionally (normally not a problem, and makes a lot of sense for such application-specific emulator core like this)
- Refactored code for readability (duplicated same code with different function name)
- Gated unused functions to save code space (where --gc-sections is not used)
2024-06-02 02:00:46 +02:00
SonoSooS
f8c41261a0 Reduce HRAM size requirement (RP2 port is really tight on free RAM) 2023-08-04 19:19:10 +02:00
SonoSooS
c58cce6df2 Revert "Make HALT bug work at no extra cost"
This reverts commit e4f26a8b8b.
2023-04-29 10:59:16 +02:00
SonoSooS
e4f26a8b8b Make HALT bug work at no extra cost 2023-03-23 10:33:01 +01:00
SonoSooS
2853e13dcf Eliminate double shift accidentally introduced in an earlier commit
I didn't notice the bank resolver code already did the shift
2023-03-14 08:56:13 +01:00
SonoSooS
7b0e12e820 Force better optimization for Playdate build 2023-03-10 11:49:42 +01:00
SonoSooS
91f9cf2d2c Move attribute definition to a more proper place 2023-03-10 11:48:07 +01:00
SonoSooS
2af9a6a61d Make cc checking faster, also use correct return value type 2023-03-10 10:53:47 +01:00
SonoSooS
d726b850c5 Allow gating the cache subsystem for debug purposes 2023-03-10 10:52:23 +01:00
SonoSooS
4378d0583c Oops, fix LRU cache callback 2023-03-10 10:50:49 +01:00
SonoSooS
977bf0bdf0 Refactor microcode, futile attempt at trying to make the big jump table work again 2023-03-09 15:34:41 +01:00
SonoSooS
e993cd95ec Slight microcode interface refactor + add comments 2023-03-08 18:35:11 +01:00
SonoSooS
f1e84a285d More refactor 2023-03-08 18:11:36 +01:00
SonoSooS
c95dde2271 Pending work on refactor 2023-03-08 17:38:57 +01:00
SonoSooS
2d5ced8d1f Add some defines, and gatekeep a few functions behind compile flag 2023-03-02 02:21:09 +01:00
SonoSooS
3bc87efb74 Added LRU support (mostly for low-RAM devices) 2023-02-22 19:38:35 +01:00
SonoSooS
342814fab4 Slight refactor 2023-02-22 19:37:42 +01:00
SonoSooS
d7531bc55a Slightly clean up microcode variable names and usages 2023-02-22 06:14:24 +01:00
SonoSooS
84d4c993e7 Optimization attempt 2023-02-21 06:48:47 +01:00
SonoSooS
1a2223ebea Add more direct jumps (broken) 2023-02-21 05:12:22 +01:00
SonoSooS
03bdb69a3e Make the CPU core fully compliant 2023-02-21 04:36:22 +01:00
SonoSooS
7d445e406d Initial commit 2023-02-20 16:48:41 +01:00