jgilchrist / gbemu Goto Github PK
View Code? Open in Web Editor NEWA Gameboy emulator in modern C++
License: BSD 3-Clause "New" or "Revised" License
A Gameboy emulator in modern C++
License: BSD 3-Clause "New" or "Revised" License
In the debugger the command parser is looking for strings of mem or memcell in order to view a location or range in the virtual memory:
if (cmd == "mem") return CommandType::Memory;
if (cmd == "memcell") return CommandType::MemoryCell;
However, the help menu says to type "memory" or "memory cell":
printf("memory $start $lines Print a dump of memory from $start to $end\n");
printf("memorycell $addr Print the value of the memory at $addr\n");
One or the other should be changed so that they matched. Selfishly, mem and memcell are faster to type.
When calling help within the debugger, we get the following output.
> help
...
= Debug Information
registers Print a dump of the CPU registers
flags Print a dump of the CPU flags
....
But the command to print a dump of the registers seems to be just regs
.
Hi! Great emulator, I got a custom Gameboy
instance working very quickly in my environment. However, I think I am struggling with state restore/save data. I'm saving the get_cartridge_ram()
to disk and pass it as save_data
in the ctor, but the game I'm trying out is always starting from the beginning. I've tried saving both during the run
-loop and afterwards, and data seem to be written (there is binary data in the file). Am I misunderstanding something, or is it maybe the ROM I'm using that is to blame?
delete me
Hi @jgilchrist , I also want to make a Gameboy emulator on C/C++ and I have no idea how to approach the problem. I know I must read Gameboy manual and understand how it works but what do I do after that? I see that you have solved this problem, so will you please explain me how to get started with coding something for this project? Thanks in advance!
PS: I am going to code in Visual Studio 2017, on Windows 10.
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Attempting to read from cartridge RAM
| Boot rom was disabled
| Wrote to sound on/off address 0xff26 - 0x0
| Wrote to sound on/off address 0xff26 - 0x80
| Wrote to selection of sound output terminal address 0xff25 - 0xff
| Wrote to channel control address 0xff24 - 0x77
cpu_instrs
| Attempting to write to cartridge ROM: 2000 - 0x1
01| Wrote to sound on/off address 0xff26 - 0x0
| Wrote to sound on/off address 0xff26 - 0x80
| Wrote to selection of sound output terminal address 0xff25 - 0xff
| Wrote to channel control address 0xff24 - 0x77
:ok | Attempting to write to cartridge ROM: 2000 - 0x1
02| Wrote to sound on/off address 0xff26 - 0x0
| Wrote to sound on/off address 0xff26 - 0x80
| Wrote to selection of sound output terminal address 0xff25 - 0xff
| Wrote to channel control address 0xff24 - 0x77
| Wrote to unknown address 0xff05 - 0x0
:04 | Attempting to write to cartridge ROM: 2000 - 0x1
03| Wrote to sound on/off address 0xff26 - 0x0
| Wrote to sound on/off address 0xff26 - 0x80
| Wrote to selection of sound output terminal address 0xff25 - 0xff
| Wrote to channel control address 0xff24 - 0x77
| Attempted to read from 'Prepare Speed Switch' register
| Attempted to write to 'Prepare Speed Switch' register
| Fatal error @ [opcode_stop:822]
| Stopped
Is it possible to change the clock speed of the emulator? I'd like to make it runs at X2 speed.
I do also wonder why AND
touches the F
register.
| 0xC321: LD A,C (0x79)
> regs
AF: 0100
BC: 1301
DE: 1300
HL: C304
SP: DFFD
PC: C322
> step
| 0xC322: AND n (0xe6)
> regs
AF: 00A0
BC: 1301
DE: 1300
HL: C304
SP: DFFD
PC: C324
Any documentation I found only talks about A
fuwangqin@fuwangqin-pc:~/code/emulator$ make
-- Found SFML 2.3.2 in /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fuwangqin/code/emulator/build
make[1]: Entering directory '/home/fuwangqin/code/emulator/build'
make[2]: Entering directory '/home/fuwangqin/code/emulator/build'
make[3]: Entering directory '/home/fuwangqin/code/emulator/build'
Scanning dependencies of target emulator
make[3]: Leaving directory '/home/fuwangqin/code/emulator/build'
make[3]: Entering directory '/home/fuwangqin/code/emulator/build'
[ 4%] Building CXX object CMakeFiles/emulator.dir/src/address.cc.o
c++: error: unrecognized command line option ‘-Weverything’
CMakeFiles/emulator.dir/build.make:62: recipe for target 'CMakeFiles/emulator.dir/src/address.cc.o' failed
make[3]: *** [CMakeFiles/emulator.dir/src/address.cc.o] Error 1
make[3]: Leaving directory '/home/fuwangqin/code/emulator/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/emulator.dir/all' failed
make[2]: *** [CMakeFiles/emulator.dir/all] Error 2
make[2]: Leaving directory '/home/fuwangqin/code/emulator/build'
Makefile:83: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/fuwangqin/code/emulator/build'
Makefile:16: recipe for target 'compile' failed
make: *** [compile] Error 2
fuwangqin@fuwangqin-pc:~/code/emulator$
When i tried running make command, I am getting the following error.
CMake Error at CMakeLists.txt:25 (find_package):
By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2", but
CMake did not find one.
Could not find a package configuration file provided by "SDL2" with any of
the following names:
SDL2Config.cmake
sdl2-config.cmake
Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.
I was digging into the cpu_instr rom since the 01 special push af test case does not work on my emulator (very early development). After inspecting the test case code and debugging for hours, I am thinking that the test case should never work at all.
Then I saw that your emulator is able to get the test to pass so I used your debugger (thank you for that) to figure out why.
As far as I understand, if a PUSH
is followed by a POP
directly (no other interactions with the SP
register), the POP
should write the value, which was previously pushed, to the given register.
> step
| 0xC31D: PUSH BC (0xc5)
> regs
AF: 0000
BC: 1301
DE: 1200
HL: C304
SP: DFFB
PC: C31E
> step
| 0xC31E: POP AF (0xf1)
> regs
AF: 1300
BC: 1301
DE: 1200
HL: C304
SP: DFFD
PC: C31F
Why is AF 0x1300
and not 0x1301
?
Hi :-)
i was able to build the emulator following the instructions of the readme file. Just a question, the audio is available at the moment or it has to be add?
I ask you that because at the moment i have no audio output and I don't know if I am missing some dependencies or I need to put some specific option on the cli when I run the emulator. I tested it with super mario land
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.