captainys / TOWNSEMU

FM Towns Emulator "Tsugaru"
BSD 3-Clause "New" or "Revised" License
236 stars 17 forks source link

Raiden is cropped #90

Open ualaa1 opened 1 year ago

ualaa1 commented 1 year ago

See screenshot. Can be easily seen on title screen bandicam 2023-07-07 23-31-31-646

captainys commented 1 year ago

Thanks for the report! I didn't notice it. RAIDEN is using 256x256, 2X scaling mode, which makes the visible area 512x512 1X pixels. I was limiting the vertical range to 480.

I can easily make it 512. However, if I do so, you will see the bottom two lines that are not supposed to be visible. I'm not sure if it was happening in the real hardware. I started it on my real FM TOWNS 2MX, but my LCD monitor shows only up to 480 pixels vertically on this frequency, therefore I could not confirm. (My LCD monitor cropped it exactly as your screenshot).

Anyway, at least whole screen will be visible by making it 512. I made this change and pushed the source here. Are you able to build by yourself and try?

ualaa1 commented 1 year ago

It seems better, at least everything is visible but now there is garbage on the bottom of the screen. Is that the bottom 2 lines you were talking about? bandicam 2023-07-09 15-05-52-046 bandicam 2023-07-09 15-05-28-139

captainys commented 1 year ago

It could have been like this in the real hardware. I checked the code, but the problem is VSYNC interrupt handler only updates the VRAM offset register, and the bottom two lines are filled outside of the VSYNC interrupt. If both are done in the VSYNC interrupt, this artifact should be invisible, but it does not seem to be done that way. I do have some real FM TOWNS hardware, but the LCD monitor connected to my TOWNS crops below 480 lines (240 lines in 2X scaling), so line 248 and line 249 are not visible anyway. At this time, I cannot find any reason in the RAIDEN code that hides bottom two lines artifact.

pinterior commented 1 year ago

AFAIR Tsugaru read (and render) whole VRAM contents instantly, but real TOWNS read it over 16ms. does this difference cause the problem?

captainys commented 1 year ago

I thought about it, too. If two lines are filled immediately after or reasonably soon after VSYNC, while CRTC is rendering upper part of the monitor, and then VRAM offset is updated somewhere down, the artifact may not be visible. However, it looks to be opposite. Somewhere in the main loop fills the bottom two lines, and then VRAM offset is updated in VSYNC interrupt handler. It is too late to hide the bottom two lines (to become the top two lines).

Another possibility is CRTC may render only 254 lines (or height minus 2 lines) when sprite is enabled. First two lines is used for sprite-clear pattern. So, maybe CRTC ignore two lines. I can add this ad-hoc change to my CRTC code, but I'm reluctant.

bcc2528 commented 1 year ago

I don't know if that will be of help or not, but

on real hardware FM TOWNS II UX https://www.youtube.com/watch?v=2MMCJrsVTcs bottom line not visible because it is outside the display area of CRT.

on FM TOWNS Marty https://www.youtube.com/watch?v=FLpCBzolcqA visible bottom line

The CRTC does not disable the line, but seems to make it invisible depending on the display area of the CRT.

captainys commented 1 year ago

Thanks! It does help! As can be seen on the Marty video, artifact of the bottom two lines are visible. However, depending on the monitor, the artifact may be hidden by the plastic frame of the monitor. I guess Tsugaru is now rendering it correctly.