OmegaGB is an emulator for the Nintendo Game Boy, written in pure haskell.
It's in a very early state, and only barely shows the title screen of a few games. It uses gtk2hs for the user interface, but there is also a version that doesn't require gtk2hs and uses ascii art. The main problem I am having is getting decent performance. I have set up a darcs repository in the hopes of receiving advice or patches to improve performance. You can find more information about the program at the website: http://www.mutantlemon.com/omegagb/ The program works by maintaining a state of all of the gameboy hardware: cpu registers, memory, and internal timers for various interrupts and other things. A function is used to update the state: updateMachineDisplayFrame :: JoypadKeyStates -> ((RegisterStates, Memory), IrqStates) -> (Display, ((RegisterStates, Memory), IrqStates)) This approach does not give enough performance, and the emulator is not able to run in real time. I have experimented with replacing most of the state with mutable IORefs and an IOUArray for the memory. This gave approximately double the performance, but that is still only 10% of real time speed on my computer. And all this is still without emulating most of the GB graphics hardware, which will require quite a bit more computations. I originally started this project to explore whether haskell is really a capable language in the domain of performance critical applications. I think that with the right optimizations, OmegaGB will be able to do real time emulation. Unfortunately, I am not experienced enough to know what kind of optimizations to use. This is why I am calling out for help. Thanks, Bit Connor PS: Here is some of the profiling output from a typical run: total time = 174.10 secs (3482 ticks @ 50 ms) total alloc = 31,338,925,440 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc renderScanLine Machine 28.6 17.9 machineCpuExecute' Machine 12.6 11.4 tickHBlank Machine 9.1 21.1 tickHBlankMode0 Machine 6.3 13.7 executeInstruction Cpu 5.6 1.6 test02 GuiTest02 5.0 1.4 tickDIV Machine 4.7 13.1 irqUpdate Machine 3.4 0.8 transformIrq Machine 3.3 3.2 tickHBlankMode3 Machine 3.1 6.9 mcti Cpu 2.2 0.5 setRegState Machine 1.9 1.7 setReg2State Machine 1.7 1.8 doFromTo GuiDrawUtil 1.6 1.5 updateMachine Machine 1.4 0.5 updateMachineDisplayFrame Machine 1.3 0.5 writeFlags CpuExecution 1.2 0.3 fetchInstruction Machine 1.1 0.5 _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell