Jump to content
IGNORED

Using cc65 from an Android tablet


karri

Recommended Posts

My old tablet broke and I got a brand new Huawei tablet 8" with phone capabilities for €159.

 

The OS is much more modern than in my old tablet so I decided to try if I could write Lynx code on it.

 

To my surprise it worked with some small tuning required.

 

1) Get Termux from the Google Apps store. It is free!

 

2) Open termux and type

pkg install git make clang

The clang is a C compiler required for compiling the cc65 compiler.

 

3) Get the latest repository from bitbucket for Lynx tools

git clone https://bitbucket.org/atarilynx/lynx.git

4) The automatic build script does not work as the tablet is not rooted. So we need to build and install all tools by hand.

cd lynx/tools/cc65
make -f make/clang.mak install

Congrats! You now have the C-tools installed needed for compiling your code.

 

There is one difference for running the tools. The packages are installed in a different position than before as we cannot get root access.

 

So you need some extra parameter on the command line when compiling.

 

I create a file Common.mk with the following content:

CC=cc65
AS=ca65
CL=cl65
SP=sp65
CP=cp
RM=rm -f
ECHO=echo
TOUCH=touch

CC65_HOME=$(PREFIX)/lib/cc65
CC65_INC=$(CC65_HOME)/include
CC65_ASMINC=$(CC65_HOME)/asminc

# Rule for making a *.o file out of a *.c file
%.o: %.c
    $(CC) -t lynx -I $(CC65_INC) $(CFLAGS) $(SEGMENTS) -o $(patsubst %c, %s, $(notdir $<)) $<
    $(AS) -t lynx -I $(CC65_ASMINC) -o $@ $(AFLAGS) $(*).s
    $(RM) $*.s

# Rule for making a *.o file out of a *.s file
%.o: %.s
    $(AS) -t lynx -I $(CC65_ASMINC) -o $@ $(AFLAGS) $<

# Rule for making a *.c file out of a *.pcx file
%.c : %.pcx
    $(SP) -r $< -c lynx-sprite,mode=packed -w $*.c,ident=$*,bytesperline=8

In my Makefile I can now compile something by writing:

include ../Common.mk

thisdir=deck1f

objects= \
    heartsmallf.o \
    spadesmallf.o \
    diamondsmallf.o \
    clubssmallf.o \

all: objlist

objlist: $(objects)
    $(RM) objlist

    for obj in $(objects); do $(ECHO) ../$(thisdir)/$$obj >> objlist; done

clean:
    $(RM) objlist $(objects)

I still have to figure out how to pass the compiled *lnx game to RetroArch for playing if. But there is probably some user writable directory for RetroArch.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

I wanted to try this out but I'm unsure what this error means. Maybe Android 5.0.1 is too old?

cc65/ser
for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65 sp65; \
  do make/install-sh -c -m 755 -s src/$f/$f /data/data/com.termux/files/usr/bin || exit $?; \
  done
install: can't stat 'src/ar65/ar65': No such file or directory
make: *** [make/clang.mak:150: install-bins] Error 1
$

Link to comment
Share on other sites

 

I wanted to try this out but I'm unsure what this error means. Maybe Android 5.0.1 is too old?

cc65/ser
for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65 sp65; \
  do make/install-sh -c -m 755 -s src/$f/$f /data/data/com.termux/files/usr/bin || exit $?; \
  done
install: can't stat 'src/ar65/ar65': No such file or directory
make: *** [make/clang.mak:150: install-bins] Error 1
$

 

could you do a

cd lynx/tools/cc65/src/ar65

ls

 

This should show several *.o files and also a green ar65 binary.

Link to comment
Share on other sites

It seems it didn't build, only c and h files there.

 

I tried this again:

cd lynx/tools/cc65
make -f make/clang.mak install

It gives the same error:

If you are denied permission to install or uninstall this package,
then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"
as either the root user or an administrator.

mkdir -m 755 /data/data/com.termux/files/usr/lib/cc65/tgi
for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65 sp65; \
  do make/install-sh -c -m 755 -s src/$f/$f /data/data/com.termux/files/usr/bin || exit $?; \
  done
install: can't stat 'src/ar65/ar65': No such file or directory
make: *** [make/clang.mak:150: install-bins] Error 1
$

I also tried the termux-setup-storage command, but that seems to be only for Android above v.6. I've been thinking about rooting my S4 for a long time, I think this would be a good reason (if it'd be needed). Just a pain to backup everything first :P

 

I don't know how to check if it's some sort of path issue either since I don't have access to the data/data folder.

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

It seems it didn't build, only c and h files there.

 

I tried this again:

cd lynx/tools/cc65
make -f make/clang.mak install

It gives the same error:

If you are denied permission to install or uninstall this package,
then you will need to do "make/gcc.mak install" or "make/gcc.mak uninstall"
as either the root user or an administrator.

mkdir -m 755 /data/data/com.termux/files/usr/lib/cc65/tgi
for f in ar65 ca65 cc65 cl65 co65 da65 ld65 od65 grc65 sp65; \
  do make/install-sh -c -m 755 -s src/$f/$f /data/data/com.termux/files/usr/bin || exit $?; \
  done
install: can't stat 'src/ar65/ar65': No such file or directory
make: *** [make/clang.mak:150: install-bins] Error 1
$

I also tried the termux-setup-storage command, but that seems to be only for Android above v.6. I've been thinking about rooting my S4 for a long time, I think this would be a good reason (if it'd be needed). Just a pain to backup everything first icon_razz.gif

 

I don't know how to check if it's some sort of path issue either since I don't have access to the data/data folder.

 

It may be that you tablet is too old. I am running Android 7 on a HUAWEI MediaPad T3. Before this I had a Samsung tablet that was stuck on some old Android. (Un)Fortunately I stepped on it one morning and it cracked. Installing cc65 on the old tablet turned out to be impossible even if rooted.

 

What happened when you tried to install the clang compiler (we are noy using gcc here)

pkg install git make clang

If this part succeeded and you have working binaries then the problem is just in finding out how to set the PREFIX to store the stuff in some valid user space. Rooting is not important at all in this case.

 

Is there a way to see the SD card or internal storage from Termux? like storage/downloads

 

In the Wikipedia for Termux the old versions do only allow execution from your HOME directory - not SD or emulated storage.

 

So you could make PREFIX point to your home directory and install everything there.

 

Find out what your home directory is.

 

cd

pwd

 

Then make an install directory for your cc65 stuff.

 

mkdir cc65

 

point PREFIX= to your HOME/cc65

 

and then run the install script for cc65.

Edited by karri
Link to comment
Share on other sites

It seems to me clang installed correctly, I didn't see any errors and it ended on a dollar sign, so that's weird.

 

I couldn't find the SD card in Termux. If I understand this correctly there's problems with Termux, the SD card and Android 5.1

https://github.com/termux/termux-app/issues/205

 

If I can't get it to work I could think about rooting my phone with some android 7 lineage/cyanogen distribution. I've been thinking about doing that for a long time anyways.

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

Congrats!

 

I actually coded a lot during my flight to Zagreb last week. All movement logic, floors, pickup objects it On Duty.

 

Now I got invited to Sotchi for some dance events at the end of February. The flights are even longer to get there so I might have time to finish some other Lynx projects.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...