-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emulator reset is broken #28
Comments
it's problem with low part of rom
|
Wait, that would mean the emulator starts at PC=0 when reset, instead of PC=$100? That's a problem. |
it's seems to be problem with binjgb - what i belive it happens that emulator "hides" lower addresses to long (if I understand it correctly on real hardware program starts from address 0 but not from rom but som internal bootrom) |
Yes, the console starts at 0 and runs a boot ROM that yields back control at $100, but that can be mostly papered over as if the console started at $100 in a post-boot ROM state directly. The bug would be that the emulator starts at $100 the first time, but then at 0 when reset? |
hmm it is not bootrom ... this emulator doesn't even have bootrom .... wrapper.c: then when you call emulator_delete it calls and if messing with input buffer which should not be freed but binjgb library I did comment this line and now this is fixed .. but do not know if |
eventually patching this file (common.c in binjgb library) to delete offensive line could help |
hehe, before I posted this I was testing something and put in OP's example |
hmmm second option is to remove |
Er, that sounds like a much deeper issue. What I find puzzling is that binjgb makes a copy of the ROM on load, so there should only be a single pointer to that ROM. (Put differently, we should always be |
this is not a copy but pointer assigment |
No: static Result set_rom_file_data(Emulator* e, const FileData* file_data) {
CHECK_MSG(file_data->size > 0, "File is empty.\n");
CHECK_MSG((file_data->size & (MINIMUM_ROM_SIZE - 1)) == 0,
"File size (%ld) should be a multiple of minimum rom size (%ld).\n",
(long)file_data->size, (long)MINIMUM_ROM_SIZE);
e->file_data = *file_data;
return OK;
ON_ERROR_RETURN;
}
|
sure ... but structure holds pointer typedef struct FileData {
u8* data;
size_t size;
} FileData; so |
Oh, you were talking about Yes, indeed, it does take ownership of the ROM... at least on success. Good catch! We were double-freeing this. |
edit: frack this #28 (comment) |
Yes, that would be correct. (I would add a comment right above |
yeah, one year from now someone would add free again :D |
I cannot reproduce the error in the OP anymore. Why was the issue reopened? |
Looks fixed for this specific case, didn't check if is luck or if the timing is 100% the same now for both runs. |
Not sure what all was changed around this, but emulator reset no longer works properly.
If you run this example:
https://raw.githubusercontent.com/daid/gameboy-assembly-by-example/master/graphics/sprites.asm
The first run is fine, and the 2nd run after a reset has corrupted sprites. Indicating that something went wrong with VRAM access, which is odd that it only happens the 2nd time.
The text was updated successfully, but these errors were encountered: