irixxxx / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
47 stars 24 forks source link

[Mega Drive] Corrupted graphics on Alien Soldier weapon select screen #103

Closed freq-mod closed 5 months ago

freq-mod commented 6 months ago

Glad I made in in time for 2.0 final;p Screencast_20231226_194225.webm - this is how it looks in picodrive and this is how it should look like: https://youtu.be/aJNEfPimU40?si=InvA_RUhWBMBu3Ud&t=287

irixxxx commented 6 months ago

I'm not seeing this under osx and linux. What platform are you using? What's your exact procedure to get to this?

freq-mod commented 6 months ago

Also linux x86_64, compiled with --platform=generic, fresh master terminal output:


plat_sdl: overlay: fmt 59565955, planes: 1, pitch: 1280, hw: 1
input: new device #0 "sdl:keys"
input: async-only devices detected..
# drv probed binds name
0   0      y     y sdl:keys
platform/libpicofe/readpng.c: unexpected font image size 256x320, needed 128x160
platform/libpicofe/readpng.c: unexpected selector image size 16x20, needed 8x10
found skin.txt
using sdl audio output driver
libpng warning: iCCP: known incorrect sRGB profile
menu_loop_romsel failed, dir: 
selected file: /home/anon/Pobrane/Alien Soldier (Japan).md
emu_ReloadRom(/home/anon/Pobrane/Alien Soldier (Japan).md)
warning: failed to do hugetlb mmap (0x2000000, 2097156): 12
00000:000: sram: 200000 - 203fff; eeprom: 0
starting audio: 44100 len: 882 stereo: 1, pal: 1
starting audio: 44100 len: 735 stereo: 1, pal: 0```

happens also on libretro (armv7a)
irixxxx commented 6 months ago

Hmm. What renderer are you using? It should work fine with both accurate renderers, but has problems with the fast renderer.

irixxxx commented 6 months ago

Is your linux distro using sdl 1.2, or sdl 2 with the compat library?

freq-mod commented 6 months ago

First and foremost, game despite being a japanese rom, starts in PAL speed (50 fps). When its left as is, it's far less glitchy, only the letters have a palette bug. renderer is 16bit accurate, but strange;y when cycled through the renderer options, letter palette is back to normal. Oh and it seems changing the console region to NTSC-J triggers the bug.

SDL2

edit: the more I play with it, the less sense it makes. Turns out changing the display mode fixed the text palette

freq-mod commented 6 months ago

Ok, there is also some weird region option in picodrivecalled "Japan PAL"... what is this

irixxxx commented 6 months ago

Japan PAL should probably be called Asian PAL. AFAIK it was e.g. used in Korea.

freq-mod commented 6 months ago

Korea is NTSC too, China and India is PAL. But thing is, Alien Soldier shouldnt boot in PAL mode, but rather NTSC :thinking:

irixxxx commented 6 months ago

Then it's maybe India. Both the Japan and EU variant of the ROM has the info that it can be used anywhere but in the US. The standard auto setting prefers EU over Japan, and that's why it's setting the hardware to EU. You could change the auto search order to "US JP EU" to change that behaviour.

Nonetheless, I cannot reproduce the bug. What's the name and md5sum of your image?

freq-mod commented 6 months ago

Alien Soldier (Japan).md fd04c4616bb559e646937effdd343a09

irixxxx commented 6 months ago

None of my own dumps of Alien Soldier (EU and Japan) has this checksum :-/

irixxxx commented 6 months ago

I now have a version with a matching checksum, but still can't see the problem. Attach me your config2 file please.

freq-mod commented 6 months ago

config2.cfg.zip

irixxxx commented 6 months ago

Still no dice. Neither in EU nor in JP mode with your or my config I can see this behaviour. Difference is I'm using it on an aarch64 Mac. I hit Start to get to the weapon select screen and everything looks as it should.

freq-mod commented 6 months ago

@irixxxx STEPS TO REPLICATE:

  1. delete config2.cfg. i didint have it created until I manually saved config via "save global options"
  2. load alien soldier. it will start in 50 hz
  3. you already should have a palette problem with letters in weapon menu
  4. GO INTO THE OPTIONS, and change the region to Japan NTSC. Restart the game.
  5. you now have a broken letter palette and a broken weapon menu visual
  6. To fix, you must exit, save a global settings with japan ntsc region and perform some video renderer shenanigans before you load the game
irixxxx commented 6 months ago

I assume with "restart" you refer to reset the game? Just as a remark, that's similar to pressing reset on the console. It doesn't modify the memory, so this may be caused by remnants. As an experiment, please change the auto region order to "US JP EU" and save a game specific config. It should start in JP mode in that case. Do you observe the behaviour with that setup as well?

irixxxx commented 6 months ago

With your instructions I can reproduce the problem, but it goes away if I save game specific options which select a JP configuration (both auto US JP EU or Japan NTSC) and start the game with that. I think that strongly points to stuff surviving the reset. It would really be interesting to see how this behaves on a real MD (start Alien soldier in 50 Hz, go to weapon select screen, switch to 60 Hz, then reset and check weapon select screen).

The real question here is IMO whether the auto region select should prefer games running in English (or another European language if a select is available) or if it should prefer games running in NTSC mode (i.e. 60 Hz frame rate).

irixxxx commented 6 months ago

Re letters palette bug: The game switches the color of the letters once a frame, between the cram values 0xeee (B=7, G=7, R=7) and 0xeea (B=7, G=7, R=5). This would probably blend on a real tube TV. The glitched display you may observe is however probably more an effect of asynchronous display frequencies between the emulated TV screen and the output screen, which might result in it being more visible.

irixxxx commented 6 months ago

This video was grabbed from a real Mega Drive 2: https://www.youtube.com/watch?v=NBbd43cM9pY You can see the palette flicker very clearly, especially with reduced speed. I can't do much without elaborate video resampling, which is far beyond the scope of this emulator. Using a display with high framerates beyond 100 fps would probably improve the appearance. For the record: setting frame skip to 1 would also lead to the text to be displayed in one of the colors only.

In the end, this only leaves the question for the default setting of the auto region select: Prefer western languages (US EU JP), or prefer 60 Hz frame rate (US JP EU)? I'd appreciate some feedback here.

notaz commented 5 months ago

I can confirm this happens on a real console with a region switch, as soon as I you switch NTSC->PAL glitches appear on the weapon select screen and pressing reset doesn't recover from it. It seems the game assumes the region can never change (which is true on an unmodified console). Only a power cycle recovers from this. P_20240107_230939

irixxxx commented 5 months ago

I have checked this too and it behaves exactly like in the emulator. Since there's no feedback on the question of ordering of the region checks I think this is done.

irixxxx commented 5 months ago

Ah @notaz I just found a small bug in the cartridge region detector: if the new format region code is "E", it would be taken as old format for Europe ;-)