Closed jc-SpaceXp closed 1 year ago
Goal is to simplify the decoders (currently in progress, see: #7 and #8) and then the execute functions should be more consistent.
A lot of the issues stem from this decoder
https://github.com/jc-SpaceXp/cNES/blob/dd8098cce783804012a1bef9c545c66e5838c915/src/cpu.c#L798-L809
All other decoders let the execution function perform the read, however immediate address mode performs the read hence the weird check against the immediate address mode in the execute functions.
Other awkward issue is due to the accumulator, since the accumulator isn't a memory address there has to be a branch to either load the accumulator or the value from memory (whilst also writing back to that region). So far no suitable function can handle this behaviour hence the "awkwardness" in the execute functions.
This (18f1c52033a18af951aaabf7a4eb5dbd94b2fa90) was created to solve the accumulator issue, does require further changes for it to work properly. The idea is that if the address mode is the accumulator we read from there, otherwise read from memory (or X/Y registers).
https://github.com/jc-SpaceXp/cNES/blob/450c2d25ff7bafba3c4a09a56615db06cc92fc74/src/cpu.c#L282-L293
A similar function would be needed for writing back to the accumulator or memory (or X/Y).
Simplified instructions which support the immediate address
5b3cb3ccb7d3ce613bac63667f06f1fe086d9d28
Simplified instructions which support the accumulator address mode
8323a503a475e2f8f006323f2c46b53a830bfba5
Currently, the execute functions are a bit all over the place in terms of clarity. See: the accumulator versions of instructions. Since most execute functions are just the final cycle they should be a short/simple as possible.