Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiHow-To'sTech Partner

How To Run Turbo Pascal On An Android Phone!

How To Run Turbo Pascal On An Android Phone

Here’s a guest blog post by Jim McKeeth, Embarcadero MVP and US Director of GDK Software Why run Turbo Pascal on Android? Because we can!


As part of the Turbo Pascal 40th birthday celebration (combined with Delphi’s 29th birthday) I did a short demo of running Turbo Pascal on Android under Termux using DOSBox. This goes into a little more detail of how to install and set it up. I was running on my Samsung Galaxy Z Fold 5, but this should work on most Android devices with reasonable specs. No root or developer mode required.

termux on android
turbo breakout on android

Where can I see the video of running Turbo Pascal on an Android phone?

Here’s the video!

What are the instructions on how to run Turbo Pascal on an Android device?

Termux is a terminal emulator that allows you to run Linux programs on your Android phone (no root required). DOSBox is a x86 MS-DOS emulator that runs on a variety of platforms. There are other Linux terminal emulators for Android. I’ve used Andronix before and really like it (I have a paid subscription for it even), but Termux appears to be one of the more popular, well supported, and documented options, so that is what I’m using here.

You will need to download Turbo Pascal 7 or otherwise have a copy. It used to be in the Borland/Embarcadero software museum, but that appears to be offline. At this point it might be considered abandonware, but that is a bit of a nebulous definition. You can find it on a few other places around the Internet. None of these links are endorsed by Embarcadero or Idera, so download at your own risk.

How to copy Turbo Pascal to your Android device?

You need to extract the version of Turbo Pascal into a folder on your Android device, and then provide the full path after you run the termux-setup-storage command to get access to the device storage. The root of your Android device’s Internal Memory storage will show up as shared, so if you put a folder called DOSBox in there, then you will access it from within Termux as ~/storage/shared/dosbox.

Next install Termux from F-Droid or GitHub (not Google Play Store)

How do I set up Termux?

  • Upgrade installed packages and connect to x11 package repository:
    • pkg upgrade
    • pkg install x11-repo

  • (optional) Install SSH Server, set password and get username, and start ssh.
      • pkg install openssh -y

      • passwd

      • whoami

      • sshd

      • Check to see if it is running and on what port:
          • logcat -s 'sshd:*'

      • Kill the server:
          • pkill sshd

  • Install DOSBox & VNC Server, then configure access to storage
      • pkg install dosbox -y

      • pkg install tigervnc -y

      • vncserver -localhost

      • export DISPLAY=":1"

      • termux-setup-storage

      • dosbox

  • Install a VNC Viewer and connect. I used RealVNC Viewer, but any VNC viewer on the local network should work
  • Mount the external folder in DOSBox then run Turbo Pascal 7
    • mount c ~/storage/shared/dosbox
    • c:
    • cd TP7bin
    • turbo

Here is a transcript of the video showing how to install Turbo Pascal on Android

[00:00] I’ve done this before with Andronix, but today I’m going to use Termux. Maybe I’ll another one with Andronix. One note about Termux, though, it’s in the Google Play Store, but if you go into the about, it says not to use it anymore, that you want to go to this link here to see other options.

[00:18] And here it will tell you to, use F-Droid. Instead. So that’s what we’re going to do. If you do look in Google Play, but onto the bottom here, you’ll see this is version 0.101. But if we go to F-Droid and search for Termux you’ll see that this is version. 0.118, which is the latest on the GitHub page.

[00:46] If you don’t know how to install F-Droid, I’ll include a link for that. It’s pretty straightforward. You just download the APK and enable the permission. None of this requires root or anything like that, or even developer options to be on, but I’ve always got developer options on personally.

[01:04] Asks for notifications. We’re going to say, okay.

[01:08] First thing I’m going to do is package upgrade, which will upgrade all the packages, and I’m going to do “-y”, but it’s still going to prompt me for some file overwrites, but I’m going to use an external keyboard while it does this, because that’s a whole lot easier for me. I believe there’s six file overwrites that’s going to prompt me for. One.

[01:36] There we go. Now I’m going to do package install. Open SSH.

[01:55] This is going to install a SSH server so that I can connect remotely,

[02:02] but I do need to set a password. There we go.

[02:16] And then find out my username, which is always going to be some weird. Thing. There we go: u0_a753 so I can connect remotely. If I scroll all the way back up to the top here, you’ll see it says X 11, right Pose right there.

[02:32] So I want to install that PKG. X 11. This is the package repository that includes DOSBox, which is what we need to run Turbo Pascal,

[02:46] So now I can do package install DOSBox. If you run this and it doesn’t find it, that’s because you haven’t installed the x11 repository there we go. Now DOSBox is installed

[03:17] and then do Log Cat, SSHD.

[03:31] We will see it’s listening on Port 8022. And it is Ctrl+C, which you can use the CTRL right here, on the screen, and then the onscreen keyboard, or via remote keyboard, whichever way you want to.

[03:42] The easiest way to get your Wi-Fi information is to go into your Settings, go down to About Phone, and go to status information, and you’ll see it right there. Yeah, both IPv6 and IPv4 IP address.

[03:59] This is mostly to show that it’s possible, but you can SSH into it now. So notice I’m specifying the port number 8022, and that username that I got from there. First time you do it, I didn’t set up the key, so I’m going to say yes, I’m going to keep the fingerprint.

[04:15] And then I use a password I specified, and now I’m in Termux remotely from my Windows computer. So I’m going to go back to doing it on the Android device, but just wanted to show that you can SSH into it if you set this up this way.

[04:33] All right, I think we’re on the home stretch now. First thing I want to do is I want to tell Termux to acquire a wake lock this way it will not go to sleep in the background, and it’s going to say, Hey, are you sure you want to stop optimizing the battery?

[04:46] Yep, that’s what I want. So I’ve got DOSBox installed, but in order to view DOSBox, even though it’s DOS, which is a text interface, it’s still being done graphically.

[05:00] I need to install Tiger VNC.

[05:12] So now I’m going to set the VNC server up. VNC server. Let’s get, ask for a password, make sure you make it a good one. And I don’t view only password.

[05:31] So now VNC is running on localhost:1, so display one.

[05:36] So I want to say export display equals colon one and that will tell DOSBox to export to display VNC one.

[05:52] So right now, if I do a ls, there’s nothing in my home directory.

[05:58] But if I say termux-setup-storage, this should prompt me. To, yep. Okay. It’s going to prompt me for permissions now to access my storage. And so if I look here, I go into storage. So if I go. These are all the common folders you would access on your Android if you’re using a file explorer. So I’m going to go into Shared, and I’ve already created a folder here called DOSBox,

[06:32] and in here is Turbo Pascal seven.

[06:34] All right, so now I’m ready to start DOSBox. Let’s go DOSBox.

[06:37] All right, so DOSBox is running. Now I need to switch over to VNC. I’ve got real VNC viewer installed on my Android device, although I could connect from any other device as well to do this too. And for completion purposes, I would show installing it. So make sure you get the right one. It’s real VNC Limited.

[07:04] It’s real VNC viewer. There’s other ones out there, but this is the one that I found worked well. For open source projects, there’s a lot of times people will make clones of them that aren’t very good. So it is tricky sometimes to know the right one you want. Okay.

[07:21] Get started. I want to add. Okay. And we’re going to go 127.0.0.1, and I want 5901 and we’ll call this.

[07:41] All right, and so now connect, no, I don’t want you to warn me every time.. Password, whatever password you typed in earlier. And also remember password. Okay, it’s got a little tutorial here. I’m going to skip that for now. Skip tutorial. Okay, so I’m in DOSBox now. So in order to access the folder that has my Turbo Pascal in it, I have to say

[08:15] Mount and I’ll say C, and that will be, storage, if I remember this correctly. /storage/shared/dosbox So now if I go to C drive,

[08:32] aha, it is in here. Oh, so there’s a .nomedia file in there that I added as well, because that will keep any graphics gallery programs from going through and finding images and saying, Ooh, look, it’s an image. ‘ cause there’s a couple things that miss as image

[In the line below type the slashes in the other way – the blog insists on getting them wrong]

[08:51] could add this to the path.

[08:53] And there we go. I am in running Turbo Pascal seven on my Android device. So let’s say open, actually I’ll go file change directory and we’ll go examples.

[09:31] Oh gosh. Let’s try breakout. Why not? So you change directory so that when you open it. There’s multiple files in here that make this up, and so we’ll see breakout, it uses screen, count, bricks, et cetera. If you don’t do this, then it won’t find the rest of those files. In Turo Pascal, there is no dproj or DPR file.

[09:56] Like there’s in Delphi that specifies locations of other folders and files and stuff like that. So that was an important, thing to do. So now I’ll run. And I can change the typematic rate. I’m going to say yes. Uh, press up arrow. We’ll go with that. Um, I’ll try that.

[10:50] That little dot there is the mouse cursor from VNC. Okay. So not really the best experience for Breakout on this, but there you go. We’re running Turbo Pascal and making and running programs on an Android device.


How To Run Turbo Pascal On An Android Phone Delphi logo

Do you want to try some of these examples for yourself? Why not download a free trial of the latest version of RAD Studio with Delphi?

This article was written by an Embarcadero MVP.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Director of Delphi Consulting for GDK Software USA. Many software related patents, including swipe and pattern unlock and search engines. First Silver and Gold Delphi badges on Stack Overflow Former Developer Advocate for Embarcadero Technologies. Long time fan of programming, especially with Delphi. Author, Podcaster/YouTuber, Improvisor, Public Speaker, Father, and Friend.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES