17 ms·
Emudore: a C64 emulator written from scratch using C++11 and SDL2
- muterad_murilax 11y agoSpeaking of C64, check out this entry which was submitted yesterday: https://news.ycombinator.com/item?id=11521609 https://news.ycombinator.com/item?id=11521609 ('The 64' – A modern C64 console and handheld project)
- mwfj 11y agoThere is really not a shortage of open source high quality C64 emulators. Does this one bring anything unique to the table?
- cmdrfred 11y agoIf you were asking if you should adopt it as a drop in replacement for your current emulator: "This project is much younger than it's predecessors I would assume it is less developed." If you were asking why it should be displayed on this forum: "This project shows a high level of technical competency and I believe that is why we as a community are showing it support."
- glhaynes 11y agoIf I were learning C++11 and/or SDL2, I'd be really interested. Or if I were versed in C++11 and wanted to learn more about how the C64 worked. Sometimes you're more in the mood to read/experiment with code than to read technical docs.
- PhasmaFelis 11y agoFrom a user's perspective, it sounds like no: "many of the more advanced games written in ML [machine language] do not yet play well due to unimplemented hardware features, writing an emulator is a tough task and after all my goal wasn't to write a full perfect emulator but to learn in the process of making a simple one" The parent is getting downvotes, but I think it's a reasonable question: is this a program I should appreciate as an amibitious project and potential learning tool, or one I would actually want to use on a regular basis?
- dsp1234 11y agofrom the readme: "I don't think anybody would ever dare to use this for an actual useful purpose, but just in case, the project is licensed under the Apache 2.0 license" "Long story short: to learn a bit more about computer architecture, graphics, C++, etc.. while having some fun!" "Due to some of the aforementioned facts, expect things to fail," It seems that the readme pretty much states that this is a WIP for learning, and shouldn't be used for anything.
- boomlinde 11y agoRadare2 support is actually quite neat and useful. The monitor/debugger in vice is great, but reading and writing memory from external applications is something that I have been looking forward to. Even without it, this kind of bare minimum emulation projects are always interesting to me, because the scope and size makes it more approachable.
- jerf 11y ago"This is my [emulator]. There are many like it, but this one is mine."
- spoondan 11y agoThis is a cool project with nice, simple code. However, the submission's title (perhaps counter to the README) makes it seem like a good example of C++11, and I would caution against using it that way. From a cursory examination, and with all due respect to the author, this code is more classical C++ with a few uses of C++11 features than it is representative of how modern C++ (at the time of C++11's publication) should be written. There are a few areas where the code could be updated: adding tests, avoiding manual memory management, making it so objects cannot be created in invalid states that would cause crashes, const correctness, etc. By way of explanation, I'll focus on just the issue of manual memory management. Simplifying a bit, consider this part of the C64 class's implementation: C64::C64() { cpu_ = new Cpu(); mem_ = new Memory(); cia1_ = new Cia1(); ... cpu_->memory(mem_); cpu_->reset(); ... cia1_->cpu(cpu_); ... mem_->cia1(cia1_); ... } C64::~C64() { delete cpu_; delete mem_; delete cia1_; ... } The contract in this code is that a C64 owns the chips, the chips are born when the C64 is instantiated, and when the C64 dies, the chips all die along with it. There are two approaches for making this contract explicit, one is to simply not use pointers and references at all: Cpu cpu_; Memory memory_; Cia1 cia1_; But this does mean we can't use polymorphism within the C64 class, we don't have nullability, and we can't replace the instances. The code doesn't leverage any of these, so that may be an appropriate choice. However, if we need any of those things, we can instead use the appropriate smart pointer: std::unique_ptr<Cpu> cpu_; std::unique_ptr<Memory> memory_; std::unique_ptr<Cia1> cia1_; In either case, C64's destructor is no longer necessary. The other classes still take raw pointers (e.g., `Cpu*`) because they do not own the objects they receive and do not dictate lifetimes. It's worth mentioning that many people would use `std::shared_ptr` here instead, but I think that's abuse that leads you towards circular references (memory leaks): the Cpu doesn't own its Memory, they just have their lifetimes managed exterior to them. This would actually come up with the existing design (if shared ownership were used), since the object dependency graph (which is perhaps another issue) has several circular dependencies.
- nibnib 11y agoSlightly off-topic, but could you recommend any books/articles/talks/resources on modern C++? I learnt the language in the early 2000s and haven't used it in years. If I picked up a C++ project today I would write code exactly like the above.
- greggman 11y agoRun it through emscripten, put it on the Archive for C64 games like they have for dos games?