News for hackers. Stuff that matters.
Re:Cooperative Threading by joppy on Wednesday November 13, 2019 @08:31AM (#21523731)
I think this approach is the "state machine" approach given in the article. The added complexity in moving to a coroutines/co-operative threading model is balanced by the drastic code reduction, pointed out in the article by "Yes, it's really that dramatic of a difference".
Re:Cooperative Threading by fwsgonzo on Wednesday November 13, 2019 @11:55AM (#21526272)
Yes, you inevitably end up implementing a state machine like that.
Re:Cooperative Threading by byuu on Wednesday November 13, 2019 @10:17PM (#21532463)
I consider it something of a trap in fact.

You start writing a new emulator for the first time, dispatching entire instructions in one go, and so you don't even really need a state machine at all.

Then you start trying to get the timing better with opcode-cycle granularity, and in comes a separate state machine for every instruction.

Then you realize you need clock-cycle granularity to fix certain edge-case games (eg emulating the effects that occur during bus accesses), and suddenly the prospect of a state machine for every cycle of every instruction becomes overwhelming.

You would then be realistically stuck with the choice to either stop improving your accuracy, or rewriting things cooperatively.

Since I'm focusing byuu.net articles toward aspiring emulator developers, I thought it would be an important topic to cover.