Video problems on hw
Moderator: Stef
Video problems on hw
I have a larger rom, 2.6mb, that works perfectly in several emulators, but when run on hardware, the video is corrupted in many ways (sometimes tiles in wrong parts, sometimes black screen), though the game runs fine - music continues to play and sound effects happen as they should.
I protect VDP accesses by disabling interrupts, and when doing bigger screen setup, also by VDP_setEnable(0). I read I should disable SRAM when the ROM is over 2mb, and indeed the first line in main() is SRAM_disable().
This has me pretty baffled. What could cause it to fail on hw, when several emulators have no issue?
I protect VDP accesses by disabling interrupts, and when doing bigger screen setup, also by VDP_setEnable(0). I read I should disable SRAM when the ROM is over 2mb, and indeed the first line in main() is SRAM_disable().
This has me pretty baffled. What could cause it to fail on hw, when several emulators have no issue?
Re: Video problems on hw
Are you clearing out the 68K's RAM first? Or does SGDK do it for you?
When I was doing homebrew stuff, everything worked fine in every emulator. I eventually got an everdrive, and ran some of my stuff on it. I learned the hard way that you can't expect RAM, registers, or anything else to be cleared beforehand.
When I was doing homebrew stuff, everything worked fine in every emulator. I eventually got an everdrive, and ran some of my stuff on it. I learned the hard way that you can't expect RAM, registers, or anything else to be cleared beforehand.
Visit my web site at http://www.mode5.net/!
Re: Video problems on hw
SGDK does it for me, in boot/sega.s.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Video problems on hw
Interrupts problems would happen on emulator as well but it's true that given your problems i would have think about that in first place.
What kind of flash cart are you using ? possible that some data are corrupted while transferring ?
The SRAM problem would only happen for data above 0x200000 address range.
What kind of flash cart are you using ? possible that some data are corrupted while transferring ?
The SRAM problem would only happen for data above 0x200000 address range.
Re: Video problems on hw
It's not a flashcart, but a programmed chip. Other big roms work.
I'll try to make a small test ROM I can share.
I'll try to make a small test ROM I can share.
-
- Very interested
- Posts: 86
- Joined: Fri Sep 25, 2015 4:16 pm
Re: Video problems on hw
Make sure you are not doing any non-blocking VRAM DMA operations without waiting for a previous DMA completion.
Re: Video problems on hw
My original ROM does not use DMA at all after loading all tiles at startup, so I don't think DMA is the issue.
Okay, I have a redistributable test ROM that shows the issue here:
https://github.com/clbr/gentest/raw/master/game.bin.xz
Sources are in the same repo:
https://github.com/clbr/gentest
I'd appreciate if you could try it on your hw. And maybe build it too, so we can isolate whether it's something in my toolchain (but in that case, it should affect emulators too?).
Okay, I have a redistributable test ROM that shows the issue here:
https://github.com/clbr/gentest/raw/master/game.bin.xz
Sources are in the same repo:
https://github.com/clbr/gentest
I'd appreciate if you could try it on your hw. And maybe build it too, so we can isolate whether it's something in my toolchain (but in that case, it should affect emulators too?).
-
- Very interested
- Posts: 86
- Joined: Fri Sep 25, 2015 4:16 pm
Re: Video problems on hw
These stand out immediately:
Try waiting for DMA completion after each clearPlan. These are non-blocking DMA operations, where you are filling with zero. I remember having a similar problem in a project of mine. I think the palette setting one might also use DMA but I do not remember.
Code: Select all
VDP_clearPlan(VDP_PLAN_A, 1);
VDP_clearPlan(VDP_PLAN_B, 1);
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Video problems on hw
Only DMA fill can be a problem as DMA copy operation locks the main CPU.
Indeed using clearPlan(..) with DMA can be a problem as it *does* use the DMA fill here !
Indeed using clearPlan(..) with DMA can be a problem as it *does* use the DMA fill here !
Re: Video problems on hw
That's extremely surprising, because nowhere in the docs does it say that. I assumed even when using DMA it would block. I would argue it's the job of the SDK to be safe here, doing the blocking internally, or at the very least documenting it with heavy warnings.
I don't have access to hw right now, can you test?
I don't have access to hw right now, can you test?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Video problems on hw
Well the SDK was doing that before but definitely was not a good idea as you might want the method to not block execution.
It can be really interesting to take advantage of background VRAM fill operation while the 68k is doing other stuff
You can use VDP_waitDMACompletion() after each VDP_clearPlan() operation...
Thinking about it, i should eventually replace the 'use_dma' parameter by 'wait' so it always use DMA but also to wait for completion if wanted
It can be really interesting to take advantage of background VRAM fill operation while the 68k is doing other stuff
You can use VDP_waitDMACompletion() after each VDP_clearPlan() operation...
Thinking about it, i should eventually replace the 'use_dma' parameter by 'wait' so it always use DMA but also to wait for completion if wanted
Re: Video problems on hw
Can you confirm the current ROM has issues on hw, and that fixes it?
Also, this really needs to be documented. Every dangerous function needs to have big warnings.
Also, this really needs to be documented. Every dangerous function needs to have big warnings.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Video problems on hw
That will be documented don't worry, i will change the use_dma by wait parameter and explain the difference.
Where is the download to test the rom ?
Where is the download to test the rom ?
Re: Video problems on hw
A couple posts above:
I understood the use_dma parameter as "do it faster if no other DMA is in progress". Am I wrong?cero wrote:Okay, I have a redistributable test ROM that shows the issue here:
https://github.com/clbr/gentest/raw/master/game.bin.xz
Sources are in the same repo:
https://github.com/clbr/gentest
I'd appreciate if you could try it on your hw. And maybe build it too, so we can isolate whether it's something in my toolchain (but in that case, it should affect emulators too?).
Re: Video problems on hw
Hm, would it be too much overhead to add VDP_waitDMACompletion() to the start of every VDP function, thereby making all functions safe to use, and also allowing user code to do non-VDP things when the DMA fill is going on?
If it was made an inline function, that'd be just one or two instructions.
If it was made an inline function, that'd be just one or two instructions.