touchHLE icon indicating copy to clipboard operation
touchHLE copied to clipboard

Fix read extended fopen flag

Open atasro2 opened this issue 1 year ago • 6 comments

Hi I was messing around with touchHLE to run an old iOS port of ace attorney which i got running eventually but the changes are too obtrusive and are just a result of unimplemented framework functionalities and unhandled error edge cases if you're interested I could share the steps I took to get the game running but it isn't very difficult for one to replicate it. anyways I digress the game's saves would not work properly and having a look at debug output from libc::stdio revealed that read extended was also appending to the file which definitely doesn't seem right so I thought i'd open this PR just in case.

atasro2 avatar Jun 16 '24 07:06 atasro2

Hello atasro2,

Nice to hear that!

I'm curious to learn more about your work, but in general we would prefer to have a proper functionality merged then stubs and this one of the reasons why reviewing big PRs are taking time. (I don't want to discourage your from opening a PR for your game here, quite contrary, but just keep that in mind ;) )

In order to submit your current fix, please follow the contribution guide (basically you'll need to push via a Gerrithub), so we can review and approve it.

ciciplusplus avatar Jun 16 '24 09:06 ciciplusplus

This is a single-line change, I think we can just cherry-pick it if necessary. It's probably not worth submitting to Gerrit.

I'm not sure if this change is right or not, I'll need to check the man pages and C standard later.

hikari-no-yume avatar Jun 16 '24 09:06 hikari-no-yume

Hi thanks for the input i've decided i'm probably going to clean up the changes I have made and remove the hacks that would make the game work properly and submit on gerrithub for consideration but very little of it would be cherry-pickable I imagine.

atasro2 avatar Jun 16 '24 09:06 atasro2

only Black screen touchHLE v0.2.2-73-g0b1c5b2 — https://touchhle.org/

touchHLE: Base path for touchHLE files: /storage/emulated/0/Android/data/org.touchhle.android/files No app specified, opening app picker. Use the --help flag to see command-line usage. touchHLE::window: Accelerometer detected: BMA255 Accelerometer/Temperature/Double-tap. touchHLE::gles: Creating an OpenGL ES 1.1 context: touchHLE::gles: Trying: Native OpenGL ES 1.1 touchHLE::gles: => Success! touchHLE::window: Driver info: OpenGL ES-CM 1.1 / Qualcomm / Adreno (TM) 308 Picked: /storage/emulated/0/Android/data/org.touchhle.android/files/touchHLE_apps/Ace Attorney 1.0.ipa App bundle info:

  • Display name: Ace Attorney
  • Version: 1.00.00
  • Identifier: jp.co.capcom.gspackuall
  • Internal name (canonical): gspackuall.app
  • Minimum OS version: 3.0

No options found for this app in touchHLE_default_options.txt No options found for this app in /storage/emulated/0/Android/data/org.touchhle.android/files/touchHLE_options.txt

touchHLE::window: Accelerometer detected: BMA255 Accelerometer/Temperature/Double-tap. touchHLE::gles: Creating an OpenGL ES 1.1 context: touchHLE::gles: Trying: Native OpenGL ES 1.1 touchHLE::gles: => Success! touchHLE::window: Driver info: OpenGL ES-CM 1.1 / Qualcomm / Adreno (TM) 308 touchHLE::mach_o: Loading armv6 slice for "gspackuall" touchHLE::environment: Warning: app binary depends on unexpected dylib "/usr/lib/libz.1.dylib" touchHLE::mach_o: Loading armv6 slice for "libstdc++.6.dylib" touchHLE::mach_o: Loading armv6 slice for "libgcc_s.1.dylib" touchHLE::dyld: Warning: unhandled external relocation "_OBJC_EHTYPE_id" in "gspackuall" at 0xfb874 touchHLE::dyld: Warning: unhandled non-lazy symbol "_kCAFilterNearest" at 0xef044 in "gspackuall" touchHLE::dyld: Warning: unhandled non-lazy symbol "___objc_personality_v0" at 0xef06c in "gspackuall" touchHLE::dyld: Warning: unhandled non-lazy symbol "_NSFileHandleNotificationFileHandleItem" at 0xef074 in "gspackuall" touchHLE::dyld: Warning: unhandled non-lazy symbol "_NSFileHandleConnectionAcceptedNotification" at 0xef078 in "gspackuall" touchHLE::dyld: Warning: unhandled non-lazy symbol "___mb_cur_max" at 0x3f48a654 in "libstdc++.6.dylib" CPU emulation begins now. touchHLE::libc::cxxabi: TODO: __cxa_atexit(GuestFunction(0x374ef884), 0x0, 0x3748a000) (unimplemented) touchHLE::libc::cxxabi: TODO: __cxa_atexit(GuestFunction(0x374ef8b8), 0x0, 0x3748a000) (unimplemented) touchHLE::frameworks::uikit::ui_nib: TODO: UIProxyObject replacement for IBFirstResponder, instance 0x374f7f80 left unreplaced touchHLE::frameworks::uikit::ui_touch: Couldn't find a view for touch at CGPoint { x: 79.88905, y: -75.55864 } in window 0x374f8100, discarding touchHLE::frameworks::uikit::ui_touch: Couldn't find a view for touch at CGPoint { x: 269.84744, y: -67.5642 } in window 0x374f8100, discarding touchHLE::frameworks::uikit::ui_touch: Couldn't find a view for touch at CGPoint { x: 239.22331, y: 559.1117 } in window 0x374f8100, discarding touchHLE::window: Received app-will-resign-active event. touchHLE::frameworks::uikit: Handling app-will-resign-active event: exiting.

makaher avatar Jun 16 '24 11:06 makaher

This change doesn't actually fix the game. however it fixes a mistake that I found while trying to run the game

atasro2 avatar Jun 16 '24 11:06 atasro2

@hikari-no-yume @ciciplusplus btw, this change does seem correct per the C man page -> https://www.man7.org/linux/man-pages/man3/fopen.3.html

   r+     Open for reading and writing.  The stream is positioned at
          the beginning of the file.

versus

   a      Open for appending (writing at end of file).  The file is
          created if it does not exist.  The stream is positioned at
          the end of the file.

and

   a+     Open for reading and appending (writing at end of file).
          The file is created if it does not exist.  Output is always
          appended to the end of the file.  POSIX is silent on what
          the initial read position is when using this mode.  For
          glibc, the initial file position for reading is at the
          beginning of the file, but for Android/BSD/MacOS, the
          initial file position for reading is at the end of the
          file.

Looks like a Gerrit patch set was created for it here: https://review.gerrithub.io/c/touchHLE/touchHLE/+/1196338

apexad avatar Sep 09 '25 14:09 apexad