hex007 / freej2me

A free J2ME emulator with libretro, awt and sdl2 frontends.
Other
469 stars 71 forks source link

Torn graphics - TowerBloxx #17

Open hex007 opened 6 years ago

hex007 commented 6 years ago

Game : TowerBloxx

Graphics are torn as shown below.

screenshot from 2017-09-26 23-39-30

screenshot from 2017-09-26 23-39-37

hex007 commented 6 years ago

@nikita36078 This also affects your application.

nikita36078 commented 6 years ago

@hex007 Buffer clearing fixes this issue in J2ME Loader, but it also makes menus invisible(gameplay looks ok), so another solution is needed.

hex007 commented 6 years ago

@nikita36078 I think this might be a clipping issue. The previous graphics are not being cleared.

Where are you clearing the buffer to get the partial result. Could you paste some code?

hex007 commented 6 years ago

Was able to achieve this by commenting gc.setClip(int, int, int, int); and drawing a rectangular boundary over the clip area. Including gc.setClip causes the problem

@recompileorg @nikita36078 any insights ?

https://github.com/hex007/freej2me/blob/076a86b46a18f1c39461e2dabb169bb697ca0c00/src/org/recompile/mobile/PlatformGraphics.java#L275-L282

screenshot from 2017-09-29 13-43-59

recompileorg commented 6 years ago

I'd guess that there is some difference between setClip on j2se vs j2me.

Tower Blocks doesn't seem to run at all on the AWT build on Windows. I can't reproduce the problem there.

hex007 commented 6 years ago

I tried it on Kemulator just to test and It works as expected.

EDIT: The AWT build on linux works but persons and clouds are not rendered. On the next screen the grid and buildings are not shown.

hex007 commented 6 years ago

@recompileorg Are we using double buffering? @nikita36078 Suggests that might help solve this issue.

recompileorg commented 6 years ago

Yes, though I don't see why that would make a difference here.

hex007 commented 6 years ago

Tower Blocks doesn't seem to run at all on the AWT build on Windows. I can't reproduce the problem there.

Did you try the SDL build?

recompileorg commented 6 years ago

No, nor did I try the libretro build. Though the differences reported here, and some other oddities I've seen, lead me to believe there is an incompatibility between java implementations that is leading to the difference in behavior as the front end shouldn't have any effect on those issues.

It might not be a good idea to rely on graphics2d clipping, and instead handle it in other ways, like rendering to a temporary area and copying the area inside the clipping region over.

hex007 commented 6 years ago

Can you compare between Oracle JDK and openJDK on Windows?


Technically both frames should look the same but they dont. The binaries are from the same build on the same system using freej2me-sdl.jar and freej2me.jar respectively.

On Linux (Fedora x64 Open/JDK) SDL frame is different than AWT frame at the same instance of the game; Tower Bloxx > Build City

SDL Screenshot screenshot from 2017-09-30 22-28-30

Awt screenshot screenshot from 2017-09-30 22-29-07

recompileorg commented 6 years ago

That is curious, as the exact same data is being sent to the AWT UI as the SDL UI.

nikita36078 commented 6 years ago

I checked KEmulator code, it uses Graphics2D methods for clipping and as we can see, it works properly.

hex007 commented 6 years ago

@nikita36078 Where did you get Kemulator source from?

nikita36078 commented 6 years ago

I decompiled it with Bytecode Viewer, KEmulator isnt open source unfortunately

hex007 commented 6 years ago

@recompileorg Are you able to reproduce this?

hex007 commented 6 years ago

@nikita36078 Smali code?

nikita36078 commented 6 years ago

@hex007 No, Bytecode Viewer can generate Java pseudocode and it is readable enough.

hex007 commented 6 years ago

@nikita36078 Do you use Windows or Linux? Can you try comparing SDL interfave vs awt

nikita36078 commented 6 years ago

@hex007 I use Windows, and TowerBloxx stucks at game logo, I dont know why.