Author Topic: DOSBox Frontend  (Read 5882 times)

0 Members and 1 Guest are viewing this topic.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
DOSBox Frontend
« on: February 19, 2020, 04:48:33 am »
I wrote a simple command line frontend for DOSBox. It is able to list, search and launch DOSBox applications real fast with minimal setup. Hopefully useful for those with a large library of dos apps who cannot be bothered putting in the effort with a more complex frontend, managing multiple conf files manually or typing the dos commands everytime they wish to open an app.

Works on Linux and Windows. macOS is not supported yet.

EDIT: Improved macOS compatible version posted below!
1.png
* 1.png (Filesize: 28.23 KB, Dimensions: 656x470, Views: 395)
2.png
* 2.png (Filesize: 76.54 KB, Dimensions: 656x470, Views: 398)
3.png
* 3.png (Filesize: 79.13 KB, Dimensions: 656x470, Views: 408)
4.png
* 4.png (Filesize: 118.66 KB, Dimensions: 1366x768, Views: 442)
« Last Edit: March 07, 2020, 12:48:27 pm by pforpond »
Loading Signature...

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: DOSBox Frontend
« Reply #1 on: February 19, 2020, 12:52:07 pm »
Is that LXLE by any chance?

Yep. I have a particularly old spare laptop that I like to use that really chugs so I have it running Lubuntu 🙂
Loading Signature...

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: DOSBox Frontend
« Reply #2 on: February 19, 2020, 07:23:22 pm »
I use Linux Mint and have tried the program in both version 1.3 and 1.4 of QB64.

F5 does nothing. All I did was cut and paste the program into the IDE and pressed F5.

Am I doing something wrong?

J
Logic is the beginning of wisdom.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: DOSBox Frontend
« Reply #3 on: February 20, 2020, 02:23:57 am »
I use Linux Mint and have tried the program in both version 1.3 and 1.4 of QB64.

F5 does nothing. All I did was cut and paste the program into the IDE and pressed F5.

Am I doing something wrong?

J

Interesting. On linux it seems the app needs to be run from the terminal. This issue seems to have slipped by me as I use an external IDE that uses terminal to control QB64 and launch my apps. The solution (for now): compile the code and then run from terminal :)
« Last Edit: February 20, 2020, 02:25:59 am by pforpond »
Loading Signature...

Offline keybone

  • Forum Regular
  • Posts: 116
  • My name a Nursultan Tulyakbay.
    • View Profile
Re: DOSBox Frontend
« Reply #4 on: February 20, 2020, 05:37:29 am »
But isnt typing in the DOS commands half the fun?
I am from a Kazakhstan, we follow the hawk.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: DOSBox Frontend
« Reply #5 on: February 20, 2020, 01:14:22 pm »
Quote
The solution (for now): compile the code and then run from terminal :)

I am familiar with compiling a program after the tarball has been extracted etc. but I have no idea as to how to compile a single qb64 program...

J

ps: keybone. Yes, it is fun!
« Last Edit: February 20, 2020, 01:15:43 pm by johnno56 »
Logic is the beginning of wisdom.

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: DOSBox Frontend
« Reply #6 on: February 22, 2020, 06:06:46 am »
I am familiar with compiling a program after the tarball has been extracted etc. but I have no idea as to how to compile a single qb64 program...

Either press F11 or select Make Exe Only in the QB64 menus :)
Screenshot 2020-02-22 at 11.04.19.png
* Screenshot 2020-02-22 at 11.04.19.png (Filesize: 286.7 KB, Dimensions: 1504x1068, Views: 364)
Loading Signature...

Offline pforpond

  • Newbie
  • Posts: 76
  • I am me
    • View Profile
Re: DOSBox Frontend
« Reply #7 on: March 07, 2020, 12:43:20 pm »
MacOS support and improvements with game exe searching :)

Code: QB64: [Select]
  1. REM dosbox frontend
  2. REM dp 2020
  3.  
  4. IF INSTR(_OS$, "[WINDOWS]") THEN LET ros$ = "win"
  5. IF INSTR(_OS$, "[LINUX]") THEN LET ros$ = "lnx"
  6. IF INSTR(_OS$, "[MACOSX]") THEN LET ros$ = "mac"
  7. setup:
  8. REM loads games folder location AND checks IF it exists
  9. 10 IF _FILEEXISTS("dbfe.ddf") THEN
  10.     OPEN "dbfe.ddf" FOR INPUT AS #1
  11.     INPUT #1, rootdir$, confdir$, confname$, dosboxexe$
  12.     CLOSE #1
  13.     IF _DIREXISTS(rootdir$) THEN
  14.         REM nothing
  15.     ELSE
  16.         PRINT: PRINT "Cannot find games folder!"
  17.         IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "rm dbfe.ddf"
  18.         IF ros$ = "win" THEN SHELL _HIDE "del dbfe.ddf"
  19.         GOTO 10
  20.     END IF
  21.     PRINT "Please type in the location of your games folder..."
  22.     INPUT rootdir$
  23.     IF _DIREXISTS(rootdir$) THEN
  24.         OPEN "dbfe.ddf" FOR OUTPUT AS #1
  25.         PRINT #1, rootdir$
  26.         CLOSE #1
  27.     ELSE
  28.         PRINT: PRINT "Cannot find games folder!"
  29.         IF _FILEEXISTS("dbfe.ddf") THEN
  30.             IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "rm dbfe.ddf"
  31.             IF ros$ = "win" THEN SHELL _HIDE "del dbfe.ddf"
  32.         END IF
  33.         GOTO 10
  34.     END IF
  35.     IF ros$ = "win" OR ros$ = "lnx" THEN PRINT "Please type in the location of your dosbox conf folder (must ONLY contain unedited conf file)..."
  36.     IF ros$ = "mac" THEN PRINT "Please type in the location of your dosbox preferences folder..."
  37.     INPUT confdir$
  38.     IF _DIREXISTS(confdir$) THEN
  39.         OPEN "dbfe.ddf" FOR APPEND AS #1
  40.         PRINT #1, confdir$
  41.         CLOSE #1
  42.         IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "ls '" + confdir$ + "' > temp.ddf"
  43.         IF ros$ = "win" THEN SHELL _HIDE "dir /b " + CHR$(34) + confdir$ + CHR$(34) + " > temp.ddf"
  44.         IF ros$ = "lnx" OR ros$ = "win" THEN
  45.                 REM conf finder (linux and windows)
  46.                         OPEN "temp.ddf" FOR INPUT AS #1
  47.                         INPUT #1, confname$
  48.                         CLOSE #1
  49.             LET findconf% = INSTR(findconf% + 1, confname$, ".conf")
  50.             IF findconf% THEN
  51.                 IF ros$ = "lnx" THEN SHELL _HIDE "rm temp.ddf"
  52.                 IF ros$ = "win" THEN SHELL _HIDE "del temp.ddf"
  53.                 OPEN "dbfe.ddf" FOR APPEND AS #1
  54.                 PRINT #1, confname$
  55.                 CLOSE #1
  56.                 LET findconf% = 0
  57.             ELSE
  58.                 PRINT: PRINT "Cannot find conf file in folder!"
  59.                 IF _FILEEXISTS("dbfe.ddf") THEN
  60.                     IF ros$ = "lnx" THEN SHELL _HIDE "rm dbfe.ddf"
  61.                     IF ros$ = "win" THEN SHELL _HIDE "del dbfe.ddf"
  62.                 END IF
  63.                 GOTO 10
  64.             END IF
  65.         END IF
  66.         IF ros$ = "mac" THEN
  67.                         REM conf finder (macos)
  68.                         OPEN "temp.ddf" FOR INPUT AS #1
  69.                         DO
  70.                                 INPUT #1, confname$
  71.                                 LET findconf% = INSTR(findconf% + 1, confname$, "DOSBox")
  72.                         LOOP UNTIL findconf% OR EOF(1)
  73.                         CLOSE #1
  74.                         IF findconf% THEN
  75.                                 SHELL _HIDE "rm temp.ddf"
  76.                                 OPEN "dbfe.ddf" FOR APPEND AS #1
  77.                                 PRINT #1, confname$
  78.                                 CLOSE #1
  79.                                 LET findconf% = 0
  80.                         ELSE
  81.                                 PRINT: PRINT "Cannot find preference file in folder!"
  82.                                 SHELL _HIDE "rm dbfe.ddf"
  83.                                 GOTO 10
  84.                         END IF
  85.         END IF
  86.     ELSE
  87.         PRINT: PRINT "Cannot find preference folder!"
  88.         IF _FILEEXISTS("dbfe.ddf") THEN
  89.             IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "rm dbfe.ddf"
  90.             IF ros$ = "win" THEN SHELL _HIDE "del dbfe.ddf"
  91.         END IF
  92.         GOTO 10
  93.     END IF
  94. IF ros$ = "win" THEN
  95.     IF dosboxexe$ = "" THEN
  96.         PRINT "Please type in the location of your dosbox program folder..."
  97.         INPUT dosboxwin$
  98.         SHELL _HIDE "dir /b " + CHR$(34) + dosboxwin$ + CHR$(34) + " > temp.ddf"
  99.         OPEN "temp.ddf" FOR INPUT AS #1
  100.         DO
  101.             INPUT #1, temp$
  102.             LET finddosbox% = INSTR(finddosbox% + 1, UCASE$(temp$), "DOSBOX.EXE")
  103.             IF finddosbox% THEN
  104.                 LET dosboxexe$ = dosboxwin$ + "\" + "dosbox.exe"
  105.                 LET finddosbox% = 0
  106.             END IF
  107.         LOOP UNTIL EOF(1) OR dosboxexe$ <> ""
  108.         CLOSE #1
  109.         IF dosboxexe$ = "" THEN
  110.             PRINT: PRINT "Cannot find dosbox exe in folder!"
  111.             IF _FILEEXISTS("dbfe.ddf") THEN
  112.                 SHELL _HIDE "del dbfe.ddf"
  113.             END IF
  114.             SHELL _HIDE "del temp.ddf"
  115.             GOTO 10
  116.         ELSE
  117.             OPEN "dbfe.ddf" FOR APPEND AS #1
  118.             PRINT #1, dosboxexe$
  119.             CLOSE #1
  120.             SHELL _HIDE "del temp.ddf"
  121.         END IF
  122.     END IF
  123.     OPEN "dbfe.ddf" FOR APPEND AS #1
  124.     PRINT #1, "notwindows"
  125.     CLOSE #1
  126. IF ros$ = "win" THEN PRINT "Dosbox found at: " + dosboxexe$
  127. PRINT "Games folder found at: " + rootdir$
  128. PRINT "Conf file found at: " + confdir$
  129. PRINT "Conf file name is: " + confname$
  130. PRINT "Building database..."
  131. IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "ls '" + rootdir$ + "' > dosgamedb.ddf"
  132. IF ros$ = "win" THEN SHELL _HIDE "dir /b " + CHR$(34) + rootdir$ + CHR$(34) + " > dosgamedb.ddf"
  133. OPEN "dosgamedb.ddf" FOR INPUT AS #1
  134.     LET numberofgames = numberofgames + 1
  135.     INPUT #1, templine$
  136. GOTO menu
  137.  
  138. menu:
  139. REM menu
  140. PRINT "DOSBOX FRONTEND"
  141. PRINT "1) Quick Launch"
  142. PRINT "2) List Games"
  143. PRINT "3) Search for Games"
  144. PRINT "4) Change Folders"
  145. PRINT "5) Quit"
  146. IF a = 1 THEN GOTO quicklaunch
  147. IF a = 2 THEN GOTO listgames
  148. IF a = 3 THEN GOTO searchgames
  149. IF a = 4 THEN GOTO changedir
  150. IF a = 5 THEN
  151.     IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "rm dosgamedb.ddf": SHELL _HIDE "rm dosexedb.ddf"
  152.     IF ros$ = "win" THEN SHELL _HIDE "del dosgamedb.ddf": SHELL _HIDE "del dosexedb.ddf"
  153.     SYSTEM
  154. GOTO menu
  155.  
  156. searchgames:
  157. REM searches FOR a game
  158. INPUT "Insert Search Term: "; gamesearch$
  159. IF gamesearch$ = "" THEN GOTO menu
  160. LET dbline = 0
  161. LET dbloop = 0
  162. OPEN "dosgamedb.ddf" FOR INPUT AS #1
  163.     DO
  164.         LET dbline = dbline + 1
  165.         INPUT #1, gamedir$
  166.         LET findsearch% = INSTR(findsearch% + 1, UCASE$(gamedir$), UCASE$(gamesearch$))
  167.         IF findsearch% THEN
  168.             LET dbloop = dbloop + 1
  169.             PRINT dbline; " - " + gamedir$
  170.             LET findsearch% = 0
  171.         END IF
  172.     LOOP UNTIL dbloop = 20 OR EOF(1)
  173.     LET dbloop = 0
  174.     IF EOF(1) THEN PRINT "End of Search Results!"
  175.     PRINT "Type in a game number. ENTER) Next Page. Q) Quit."
  176.    50 INPUT a$
  177.     IF UCASE$(a$) = "Q" THEN GOTO menu
  178.     IF a$ <> "" THEN
  179.         LET gameno = VAL(a$)
  180.         IF gameno > 0 THEN GOSUB launchgame: GOTO menu
  181.         GOTO 50
  182.     END IF
  183. GOTO menu
  184.  
  185. quicklaunch:
  186. REM quick launches a game
  187. INPUT "Insert Game Number: "; gameno
  188. IF gameno = 0 THEN GOTO menu
  189. GOSUB launchgame
  190. GOTO menu
  191.  
  192. changedir:
  193. REM changes game directory
  194. LET rootdir$ = ""
  195. IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "rm dbfe.ddf"
  196. IF ros$ = "win" THEN SHELL _HIDE "del dbfe.ddf"
  197. GOTO setup
  198.  
  199. listgames:
  200. REM lists games
  201. LET dbline = 0
  202. LET dbloop = 0
  203. OPEN "dosgamedb.ddf" FOR INPUT AS #1
  204.     DO
  205.         LET dbline = dbline + 1
  206.         LET dbloop = dbloop + 1
  207.         INPUT #1, gamedir$
  208.         PRINT dbline; " - " + gamedir$
  209.     LOOP UNTIL dbloop = 20 OR EOF(1)
  210.     IF EOF(1) THEN PRINT "End of Game List!"
  211.     PRINT "Type in a game number. ENTER) Next Page. Q) Quit."
  212.    20 INPUT a$
  213.     IF UCASE$(a$) = "Q" THEN CLOSE #1: GOTO menu
  214.     IF UCASE$(a$) <> "" THEN
  215.         REM launch game
  216.         LET gameno = VAL(a$)
  217.         IF gameno > 0 THEN GOSUB launchgame: GOTO menu
  218.         GOTO 20
  219.     END IF
  220.     LET dbloop = 0
  221. GOTO menu
  222.  
  223. launchgame:
  224. REM launches games?
  225. IF gameno > numberofgames THEN PRINT: PRINT "The total number of games available is "; numberofgames: RETURN
  226. LET dbloop2 = 0
  227. OPEN "dosgamedb.ddf" FOR INPUT AS #1
  228.     LET dbloop2 = dbloop2 + 1
  229.     INPUT #1, gamedir$
  230. LOOP UNTIL dbloop2 = gameno
  231. IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "ls '" + rootdir$ + "/" + gamedir$ + "' > dosexedb.ddf"
  232. IF ros$ = "win" THEN SHELL _HIDE "dir /b " + CHR$(34) + rootdir$ + "\" + gamedir$ + CHR$(34) + " > dosexedb.ddf"
  233. PRINT gamedir$ + " - Available Executables"
  234. LET dbloop2 = 0
  235. OPEN "dosexedb.ddf" FOR INPUT AS #1
  236.     INPUT #1, gameexe$
  237.     LET findexe% = INSTR(findexe% + 1, gameexe$, ".exe")
  238.     LET findcom% = INSTR(findcom% + 1, gameexe$, ".com")
  239.     LET findbat% = INSTR(findbat% + 1, gameexe$, ".bat")
  240.     LET findcapexe% = INSTR(findcapexe% + 1, gameexe$, ".EXE")
  241.     LET findcapcom% = INSTR(findcapcom% + 1, gameexe$, ".COM")
  242.     LET findcapbat% = INSTR(findcapbat% + 1, gameexe$, ".BAT")
  243.     IF findexe% OR findcom% OR findbat% OR findcapexe% OR findcapcom% OR findcapbat% THEN
  244.         LET dbloop2 = dbloop2 + 1
  245.         PRINT dbloop2; " - " + gameexe$
  246.         LET findexe% = 0
  247.         LET findcom% = 0
  248.         LET findbat% = 0
  249.         LET findcapexe% = 0
  250.         LET findcapcom% = 0
  251.         LET findcapbat% = 0
  252.     END IF
  253. LET numberofexe = dbloop2
  254. IF numberofexe = 0 THEN PRINT "No executable files found!": RETURN
  255. PRINT "Type in a launch number. Q) Quit."
  256. 30 INPUT b$
  257. IF UCASE$(b$) = "Q" THEN RETURN
  258. IF UCASE$(b$) <> "" THEN
  259.     REM launch game
  260.     LET exeno = VAL(b$)
  261.     IF exeno > 0 THEN GOSUB launchexe: GOTO menu
  262. GOTO 30
  263.  
  264. launchexe:
  265. REM launches a game exe
  266. IF exeno > numberofexe THEN PRINT: PRINT "The total number of executable files available is "; numberofexe: RETURN
  267. LET dbloop3 = 0
  268. OPEN "dosexedb.ddf" FOR INPUT AS #1
  269.     INPUT #1, gameexe$
  270.     LET findexe% = INSTR(findexe% + 1, gameexe$, ".exe")
  271.     LET findcom% = INSTR(findcom% + 1, gameexe$, ".com")
  272.     LET findbat% = INSTR(findbat% + 1, gameexe$, ".bat")
  273.     LET findcapexe% = INSTR(findcapexe% + 1, gameexe$, ".EXE")
  274.     LET findcapcom% = INSTR(findcapcom% + 1, gameexe$, ".COM")
  275.     LET findcapbat% = INSTR(findcapbat% + 1, gameexe$, ".BAT")
  276.     IF findexe% OR findcom% OR findbat% OR findcapexe% OR findcapcom% OR findcapbat% THEN
  277.         LET dbloop3 = dbloop3 + 1
  278.         LET findexe% = 0
  279.         LET findcom% = 0
  280.         LET findbat% = 0
  281.         LET findcapexe% = 0
  282.         LET findcapcom% = 0
  283.         LET findcapbat% = 0
  284.     END IF
  285. LOOP UNTIL dbloop3 = exeno
  286. PRINT: PRINT "Launching " + gamedir$ + " [" + gameexe$ + "]...": PRINT
  287. IF ros$ = "lnx" OR ros$ = "mac" THEN SHELL _HIDE "cp '" + confdir$ + "/" + confname$ + "' ."
  288. IF ros$ = "win" THEN SHELL _HIDE "copy " + CHR$(34) + confdir$ + "\" + confname$ + CHR$(34) + " " + confname$
  289. IF ros$ = "win" OR ros$ = "lnx" THEN OPEN confname$ FOR APPEND AS #1
  290. IF ros$ = "mac" THEN OPEN confdir$ + confname$ FOR APPEND AS #1
  291. PRINT #1, ""
  292. IF ros$ = "lnx" OR ros$ = "mac" THEN PRINT #1, "mount c " + CHR$(34) + rootdir$ + "/" + gamedir$ + CHR$(34)
  293. IF ros$ = "win" THEN PRINT #1, "mount c " + CHR$(34) + rootdir$ + "\" + gamedir$ + CHR$(34)
  294. PRINT #1, "c:"
  295. PRINT #1, gameexe$
  296. PRINT #1, "exit"
  297. REM launch dosbox
  298. IF ros$ = "lnx" THEN SHELL "dosbox -conf " + confname$
  299. IF ros$ = "win" THEN SHELL CHR$(34) + dosboxexe$ + CHR$(34) + " -conf " + confname$
  300. IF ros$ = "mac" THEN SHELL "open -a dosbox"
  301. IF ros$ = "mac" THEN
  302.         PRINT: PRINT "Press ENTER to finish playing..."
  303.         INPUT temp$
  304. REM post game commands
  305. IF ros$ = "lnx" THEN SHELL _HIDE "rm " + confname$
  306. IF ros$ = "win" THEN SHELL _HIDE "del " + confname$
  307. IF ros$ = "mac" THEN
  308.         SHELL _HIDE "rm '" + confdir$ + "/" + confname$ + "'"
  309.         SHELL _HIDE "cp '" + confname$ + "' '" + confdir$ + "/" + confname$ + "'"
  310.         SHELL _HIDE "rm '" + confname$ + "'"
  311.  
Loading Signature...