Son of Hunky Punk app for Android, C & Java software dev


#1

With the goal of getting Git Glulx interpreter working on Android, I’m hacking on the code and hoping to draw attention from C developers who can help out. Be warned: I’m pretty weak on C programming, but this project is teaching me the nasty issues of all the ways a 64-bit long can go from C to Java.

C code - based off Gargoyle - Garglk

From what I have been able to put together from forum comments, support issues, and source code… the basic design of Son of Hunky Punk is to use function and data structures of Garglk when possible. Notable is this comment from retrobits on this very forum from 3 years ago: “I’ve recently began a new direction for Hunky Punk. Instead of building a new Android Glk implementation in Java (as the original author was doing), I plan to re-use most of the back-end C code from Gargoyle/garglk by interfacing with the Java UI elements of Android. I believe this will enable Hunky Punk to more easily stay up to date with the modern interpreters.” https://intfiction.org/t/tads-for-android/5462/1

The current need

I have upgraded Git interpreter to the latest 1.3.4 and solved a serious crash problem related to that upgrade. So what is next?

  • Unicode support. Right now the C functions for Unicode via Glk are not implemented and garbled output ends up on the screen.
  • Glulx windows. The basic windowing features of Glulx do not work. For example, Inform 7 code that uses “Flexible Windows by Jon Ingold” won’t work on Hunky Punk.
  • JPG/PNG graphic image display
  • many more smaller features and optional features such as sound

I consider Unicode the most important and first task to tackle, I need it for my current project, and Twisty for Android on Github already has working Unicode using the Git 1.3.4 interpreter. This is useful as a C to Java reference. However, it does not base itself off Gargoyle and has a very different C to Java interface setup. This branch of Twisty is now converted to Android Studio 2.2.2 and has the updated Git 1.3.4 interpreter: github.com/BroadcastGames/twist … _fleshout0

What to do in C, what to do in Java for Son of Hunkypunk

I’d like to try and keep things as much as possible in C, but I’m not really understanding the C code. I checked out the latest Gargoyle and cross-referenced some of the current files. From what I have been able to figure out so far:

  • functions that start with glk_ are the API wrappers, often stub functions. functions that start with gli_ are implementation?
  • garglk.h is mostly unmodified from Gargoyle’s current code. Sometimes ‘const’ is added to function parameters - as in the function gli_new_fileref - is this required for jaava?
  • I’m a bit lost why some functions like glk_stream_iterate return “stride_t” vs “stream_t” types and why these changes were made from Gargoyle when going to Android? Maybe this is a newer change in Gargoyle’s code since it was integrated?
  • A lot of the desired Unicode functions hit by #define GLK_MODULE_UNICODE are in Gargoyle’s source code file cgstream.c - for example, the function glk_put_string_uni. Attempts to simply add this file have proven fruitless. That file is built, you can see it in the make file: github.com/retrobits/son_of_hun … Android.mk - what needs to be done?

Help welcome!


#2

some slight progress to report. I was able to compile the NDK code for GLK_MODULE_UNICODE_NORM functions by adding …/garglk/cgunicod.c as a source to the andglk/Android.mk make file.


#3

Slightly more progress. Using the Gargoyle cgstream.c as a reference, I am now able to get the C code to compile with GLK_MODULE_UNICODE enabled. It’s not working (like Twisty app does), still more work to do. Latest is at: github.com/BroadcastGames/son_o … arglk_try0


#4

Some true progress! I took 30 or so lines of code from Twisty, mostly in how it buffers the output characters into a Java string from C code, and now I have working Unicode output!

Screen shot of Son of Hunky Punk, it now displays and behaves just like the Git interpreter built into the Inform 7 IDE when it comes to Unicode output. Screen shot from a real Android 7.0 mobile phone: raw.githubusercontent.com/Broad … preterA.ni

The code needs cleaned up and organized, but I now know how Twisty 2.0 app was able to get the Unicode data out of the Glulx into Android’s screen’s! Hacky mess here: github.com/BroadcastGames/son_o … f5c68b3bae


#5

If someone wants to try out the APK on their Android phone or Tablet, here it is: github.com/BroadcastGames/son_o … code_demo0


#6

I made a new release of the APK if anyone wants to try it out. github.com/BroadcastGames/son_o … code_demo1


#7

looks great,

However, i cant operate it as needed with any voice keyboard I’ve tried. When i say the ENTER command (“enter”, “return”, “new line”, “full stop”, “new paragraph”), sohp simply does a carriage return and awaits further input on a new line rather than the input being accepted. The app seems to require a soft keypress or hardware keypress of an enter key.