Author Topic: Terminal EMU Launcher Src  (Read 3318 times)

0 Members and 1 Guest are viewing this topic.

Offline xra7en

  • Seasoned Forum Regular
  • Posts: 284
    • View Profile
Terminal EMU Launcher Src
« on: March 13, 2021, 08:16:38 am »
Available ONLY here. This app is a pet project of mine I started several years ago. I recently made some big improvements. Feel free to tinker and make suggestions. to this day I still use it. Very clean, and not cluttered with other non-essentials that many launchers have. I put it here as a thank you for QB64 devs and their hard work.


Someone was nice enough to put it here when it iwas in its infancy. that made me pretty proud!!

Unless you have your own icon, you will probably want to comment out these two lines at the top:
Code: QB64: [Select]
  1. $ExeIcon:'.\nin.ico'


REQUIRED UTILS.BI
This has many fun things I have added over the years, much of it was converted from my pascal days
LOL, I just saw my "INC" and "DEC" subs have an issue. Will have to turn them into functions.
I never used them in QB prob why I never caught it.
Code: QB64: [Select]
  1. '// DEC(X) -1 TO X
  2. '// INC(X) +1 TO X
  3. '// DISTANCE: DISTANCE BETWEEN 2 X,Y COORDS
  4. '// yesNo (default AS STRING)
  5.  
  6.  
  7. Sub DEC (X As Integer)
  8.     '============================================================================
  9.     '--- PASCAL FUNCTION: DECREASES X BY 1)
  10.     '============================================================================
  11.     X = X - 1
  12.  
  13. Sub INC (X As Integer)
  14.     '============================================================================
  15.     '--- PASCAL FUNCTION: INCREASE X BY 1)
  16.     '============================================================================
  17.     X = X + 1
  18.  
  19.  
  20. Function DISTANCE (X1, Y1, X2, Y2 As Integer)
  21.     '============================================================================
  22.     '--- DIST BETWEEN 2 POINTS
  23.     '============================================================================
  24.     DISTANCE = Sqr((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2)
  25.  
  26.  
  27. Function yesNo (default As String)
  28.     '// @default = when ENTER is pressed what will be the default answer
  29.  
  30.     Dim ans As String
  31.  
  32.     Do
  33.         ans = InKey$
  34.         ans = LCase$(ans)
  35.     Loop Until ans = "y" Or ans = "n" Or ans = Chr$(13) Or ans = ""
  36.  
  37.     If ans = Chr$(13) Or ans = "" Then ans = default
  38.  
  39.     If ans = "y" Then
  40.         yesNo = 1
  41.     Else
  42.         yesNo = 0
  43.     End If
  44.  
  45.  
  46. Function COUNT_TAGS (TEXT As String)
  47.     '//
  48.     '// RETURNS THE NUMBER OF LORD TAGS IN A STRING
  49.     '//
  50.     Dim I As Integer
  51.     If Len(TEXT) = 0 Then COUNT_TAGS = 0
  52.     Dim COUNT As Integer
  53.     Dim LENGTH As Integer
  54.     LENGTH = Len(TEXT)
  55.     COUNT = 0
  56.  
  57.     For I = 1 To LENGTH
  58.         If Mid$(TEXT, I, 1) = "`" Then COUNT = COUNT + 1
  59.  
  60.     Next
  61.     COUNT_TAGS = COUNT
  62.  
  63.  
  64.  
  65.  
  66. Sub CENTER (text As String, row As Integer)
  67.     '//
  68.     '// CENTER TEXT AS A SPECIFIED ROW
  69.     '//
  70.     Dim textLen, col As Integer
  71.     Dim TAGS As Integer
  72.  
  73.     If InStr(text, "`") >= 1 Then ' There is a tag
  74.  
  75.         TAGS = COUNT_TAGS(text) * 2
  76.         textLen = Int((Len(text) - TAGS) / 2)
  77.     Else
  78.         textLen = Int(Len(text) / 2)
  79.  
  80.     End If
  81.  
  82.     col = 40 - textLen
  83.     Locate row, col
  84.     If TAGS > 0 Then
  85.         LWRITE text
  86.     Else
  87.         Print text
  88.     End If
  89.  
  90.  
  91.  
  92. Sub LWRITE (TXT As String)
  93.     Dim i As Integer
  94.     '======================================================
  95.     '--- THIS IS A POPULAR COLOR ROUTINE BASED ON THE
  96.     '--- SETH ABLE L.O.R.D. BBS GAME COLOR FORMATTING
  97.     '=====================================================
  98.     Color 7 ' DEFAULT COLOR
  99.     For i = 1 To Len(TXT$)
  100.         ' CHECK FOR A COLOR CHANGE
  101.         If Mid$(TXT$, i, 1) = "`" Then
  102.             i = i + 1
  103.             Select Case Mid$(TXT, i, 1)
  104.                 Case "0": Color 10
  105.                 Case "1": Color 1
  106.                 Case "2": Color 2
  107.                 Case "3": Color 3
  108.                 Case "4": Color 4
  109.                 Case "5": Color 5
  110.                 Case "6": Color 6
  111.                 Case "7": Color 7
  112.                 Case "8": Color 8
  113.                 Case "9": Color 9
  114.                 Case "!": Color 11
  115.                 Case "@": Color 12
  116.                 Case "#": Color 13
  117.                 Case "$": Color 14
  118.                 Case "%": Color 15
  119.                 Case "n": Print '           new line
  120.                 Case "t": Print , ; '       TAB
  121.             End Select
  122.             i = i + 1
  123.  
  124.         End If
  125.         Print Mid$(TXT$, i, 1);
  126.     Next
  127.     Print ;
  128.  
  129. Sub LWRITELN (TXT As String)
  130.     LWRITE (TXT$)
  131.     Print
  132.  
  133. Sub EXPLODE (HAYSTACK As String, NEEDLE As String, EXPLODED_ARY() As String)
  134.     '//
  135.     '// speical thanks to SPRIGGYSPRIG for his inspiration to make this sub.
  136.     '// https://www.qb64.org/forum/index.php?topic=3721.0
  137.     '// USAGE
  138.     '//     EXPLODE DELIMITED STRING, DELIMETER, ARRAY TO RETURN
  139.     '//    EXAMPLE:  EXPLODE CONSOLE.Extentions, CHR$(32), SPLIT_EXT()
  140.     '//
  141.  
  142.     Dim CNT As Integer
  143.     Dim i As Integer
  144.     HAYSTACK = _Trim$(HAYSTACK)
  145.  
  146.     CNT = 1
  147.     For i = 1 To Len(HAYSTACK)
  148.         If Mid$(HAYSTACK, i, 1) <> NEEDLE Then
  149.             EXPLODED_ARY(CNT) = EXPLODED_ARY(CNT) + Mid$(HAYSTACK, i, 1)
  150.         Else
  151.             CNT = CNT + 1
  152.         End If
  153.     Next
  154.  
  155.  
  156. Sub HEADER (TXT As String, Y As Integer)
  157.     CENTER "`8 --`3------------=`!=`%[ " + TXT + " `%]=`!= `3------------`8-- ", Y
  158.     Print
  159.  
  160. Sub HR '                                        HR
  161.     LWRITELN ("`8 -  --`3------------------=`!=`%*`!=`3------------------`8--  - ")
  162.  
  163. Sub PAUSE (y As Integer)
  164.     Dim SPIN(10) As String '    spiner tile
  165.     Dim k As String '           dummy string to check for user input
  166.     Dim x As Integer '          spin array counter
  167.  
  168.     SPIN(1) = "*": SPIN(2) = "/": SPIN(3) = "-"
  169.     SPIN(4) = "\": SPIN(5) = "|": SPIN(6) = "/"
  170.     SPIN(7) = "-": SPIN(8) = "\": SPIN(9) = "|"
  171.  
  172.     x = 2
  173.     Do
  174.         Locate 24, 1
  175.         CENTER "`8 --`3------------=`!=`%[ " + SPIN(x) + " `%]=`!= `3------------`8-- ", y
  176.         x = x + 1: If x > 9 Then x = 2
  177.         k = InKey$
  178.         _Delay (.10)
  179.     Loop Until k > ""
  180.  
  181.  
  182.  

The main app

Terminal Launcher (aka Terminal Launch)
This is up to date as of last week (March 10, 2021)
TL.BAS
Code: QB64: [Select]
  1. _Title "TERMINAL LAUNCHER IV"
  2. $ExeIcon:'.\nin.ico'
  3.  
  4.  
  5. '// SIMPLE LAUNCHER
  6. '// CREATION DATE: 10/18/2020
  7. '// AUTHOR: R.SCORPIO
  8. '// VERY BASIC EMU LAUNCHER
  9.  
  10. '// WHATS NEW  FOR OCTOBER 2020
  11. '//     - IMPLIMENTED A DB FOR BETTER ORGANIATION AND SEARCHING
  12. '//     - NOW HAS SEARCH FUNCTION TO FIND SPECIFIC GAME(S)
  13.  
  14.  
  15. Const VERSION = "20210310.1145"
  16. Const DB_PATH = "db/"
  17. Const CONSOLE_DB = "CONSOLES.DB"
  18. Const TRUE = 1
  19. Const FALSE = 0
  20.  
  21. '// GFX
  22. Const DESKTOP = "²"
  23. Const SHADOW = "±"
  24. Const SURC = "¿"
  25. Const SULC = "Ú"
  26. Const SEDGE = "³"
  27. Const SBOTT = "Ä"
  28. Const STEE = "Å"
  29. Const STOPT = "Â"
  30. Const SBTMT = "Á"
  31. Const SLTEE = "Ã"
  32. Const SRTEE = "´"
  33.  
  34.  
  35.  
  36.  
  37.  
  38. Type tCONSOLE
  39.     Title As String * 52 '                  name of the console
  40.     RomDBName As String * 25 '              rom db name set by user, ext not required
  41.     Extentions As String * 25 '              accepted extensions
  42.     EMUCmd As String * 20 '                 emu.exe to run the roms
  43.     EMUParams As String * 100 '             command line params
  44.     EmuPath As String * 256 '               path to emu.exe
  45.     RomPath As String * 256 '               path to roms for this console
  46.     Str1 As String * 256 '                  future var
  47.     str2 As String * 256 '                  future var
  48.     num1 As Integer '                       future var
  49.     num2 As Integer '                       future var
  50.  
  51. Type tROMS
  52.     title As String * 128 '                 name of ROM
  53.     Filename As String * 120 '              filename of ROM
  54.     Str1 As String * 256 '                  future var
  55.     str2 As String * 256 '                  future var
  56.     num1 As Integer '                       future var
  57.     num2 As Integer '                       future var
  58.  
  59.  
  60.  
  61. Dim Shared CONSOLE As tCONSOLE '            100 consoles
  62. Dim Shared ROMS As tROMS '                   2k for SNES,GBA which are most popular
  63.  
  64. Dim Shared EXIT_APP As Integer '            1=YES, 0-NO (DEFAULT NO)
  65. Dim Shared YN As String * 1 '               SAME AS ABOVE
  66. Dim Shared SELECTED_CONSOLE As Integer
  67. Dim Shared SELECTEDCONSOLE As String
  68. Dim Shared SPLIT_EXT(10) As String '        NEEDED FOR SPLITTING EXTENTIONS FOR LISTING
  69.  
  70. Dim Shared I, K As Integer '                all kinds of loops and misc int needed
  71.  
  72.  
  73.  
  74. showTitle
  75. Dim ANS As String '                         User answers
  76.  
  77. Do ' Quitting??
  78.     Cls
  79.     INIT '                                  Initialize to basic stuff
  80.  
  81.     LOOP_MAIN:
  82.     Do '                                    loop for user choice
  83.         MAIN_MENU
  84.  
  85.         Do: ANS = UCase$(InKey$): Loop Until ANS > ""
  86.  
  87.         Select Case ANS
  88.             Case "C": SELECT_CONSOLE
  89.             Case "S": SETTINGS
  90.             Case "P": SELECT_GAME
  91.         End Select
  92.  
  93.     Loop Until ANS = "X" '                  kwwp loopinf unril user quits
  94.  
  95.     Do
  96.  
  97.         Cls
  98.         HEADER "`6Exit Terminal Launch IV", 1
  99.         CENTER "`3Are you sure to want to exit `8[`7Y`8/`7N`8]", 5
  100.         Do: ANS = UCase$(InKey$): Loop Until ANS = "Y" Or ANS = "N"
  101.     Loop Until ANS = "Y" Or ANS = "N"
  102.  
  103.     If ANS = "Y" Then SHOWOUTTRO
  104.  
  105.  
  106. Loop Until EXIT_APP = TRUE
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. '$include: 'UTILS.BI'
  117.  
  118.  
  119. Sub INIT
  120.     SELECTED_CONSOLE = 0
  121.     SELECTEDCONSOLE$ = "NONE"
  122.     EXIT_APP = FALSE
  123.     If Not _DirExists("DB") Then MkDir ("DB")
  124.  
  125.  
  126.  
  127.  
  128. Sub SETTINGS
  129.     Dim i As Integer
  130.     Do
  131.         Cls
  132.         HEADER "`#S E T T I N G S", 1
  133.         Print: Print
  134.  
  135.         LWRITELN "`t `#CONSOLE SETTINGS"
  136.         LWRITELN "`t `3======================="
  137.         LWRITELN "`t `%1`8. `7Add Console"
  138.         LWRITELN "`t `%2`8.`7 Edit Console"
  139.         LWRITELN "`t `%3`8.`7 Delete Console"
  140.         LWRITELN "`t `3------------------------"
  141.         LWRITELN "`t `40`8. `@EXIT SETTINGS"
  142.         Print
  143.         NA:
  144.         Do: Input "Option: "; i: Loop Until i < 4 And i > -1
  145.         If i > 6 And i < 10 Then GoTo NA
  146.  
  147.         Select Case i
  148.             Case 1: ADD_CONSOLE
  149.             Case 2: EDIT_CONSOLE
  150.             Case 3: DEL_CONSOLE
  151.  
  152.  
  153.         End Select
  154.  
  155.  
  156.     Loop Until i = 0
  157.     Cls
  158.  
  159.  
  160.  
  161.  
  162. Sub SELECT_CONSOLE
  163.  
  164.     Cls
  165.     If _FileExists(DB_PATH + CONSOLE_DB) = 0 Then
  166.         HEADER "`4CONSOLE LIBRARY DOES NOT EXISTS", 1
  167.         CENTER "`%C`7ontinue....", 15
  168.         Do: Loop Until InKey$ > ""
  169.         Exit Sub
  170.     End If
  171.  
  172.     HEADER "`&CONSOLE SELECTION", 1
  173.     Print: Print
  174.  
  175.     LIST_CONSOLES
  176.     HEADER "`%*", 15
  177.  
  178.     Print
  179.     LWRITE "`0S`2elect `0C`2onsole`8: `$": Input SELECTED_CONSOLE
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186. Sub MAIN_MENU
  187.     Cls
  188.     HEADER "M A I N  M E N U", 1
  189.     Print
  190.     CENTER "`6X `8= `7Exit Terminal Launch", 2: Print
  191.  
  192.     LWRITELN "                      `# _         _              _"
  193.     CENTER "`3[ `%P`7lay `3]  `3[ `%S`7ettings `3]   `3[ `%C`7onsole `3]", 4
  194.     Print
  195.     LWRITELN "`8                         |          |              |"
  196.     LWRITELN "`8                         |          |              +--> `%C`7hange `%C`7urrent `%C`7onsole"
  197.     LWRITELN "`8                         |          |"
  198.     LWRITELN "`8                         |          +-----------------> `%T-L`7auncher `%S`7ettings"
  199.     LWRITELN "`8                         |"
  200.     LWRITELN "`8                         +----------------------------> `%S`7elect/`%P`7lay `%G`7ame"
  201.  
  202.  
  203.  
  204.  
  205.     CENTER "`#Currently Selected Console", 13
  206.     If SELECTED_CONSOLE = 0 Then
  207.         CENTER "`% NONE ", 15
  208.     Else
  209.         CENTER "`%" + _Trim$(CONSOLE_NAME(SELECTED_CONSOLE)), 15
  210.         Print: Print
  211.  
  212.  
  213.     End If
  214.  
  215.  
  216.  
  217.  
  218. Function CONSOLE_NAME$ (SC As Integer)
  219.     Open DB_PATH + CONSOLE_DB For Random As #2 Len = Len(CONSOLE)
  220.     Get #2, SC, CONSOLE
  221.     Close #2
  222.     CONSOLE_NAME$ = CONSOLE.Title
  223.  
  224.  
  225. Sub showTitle
  226.  
  227.     Cls
  228.     CENTER "`5T E R M I N A L  L A U N C H E R", 2
  229.  
  230.     CENTER "`3Organize/play all your EMUZ here", 4
  231.  
  232.     Print: Print: Color 13
  233.     Print Space$(15) + "           ####                    ####"
  234.     Print Space$(15) + "           ####                    ####"
  235.     Print Space$(15) + "               ####            ####"
  236.     Print Space$(15) + "               ####            ####"
  237.     Print Space$(15) + "           ############################"
  238.     Print Space$(15) + "           ############################"
  239.     Print Space$(15) + "       ########    ############    ########"
  240.     Print Space$(15) + "       ########    ############    ########"
  241.     Print Space$(15) + "   ############################################"
  242.     Print Space$(15) + "   ############################################"
  243.     Print Space$(15) + "   ####    ############################    ####"
  244.     Print Space$(15) + "   ####    ############################    ####"
  245.     Print Space$(15) + "   ####    ####                    ####    ####"
  246.     Print Space$(15) + "   ####    ####        I V         ####    ####"
  247.     Print Space$(15) + "               ########    ########"
  248.     Print Space$(15) + "               ########    ########"
  249.  
  250.     CENTER "`8app design by r.scorpio (c)2018-2021     `7v" + VERSION, 23
  251.     PAUSE 25
  252.  
  253.  
  254.  
  255. Sub SPLITSTR (HAYSTACK As String, NEEDLE As String) ' SPLITS STRING BASED ON SPACE TODO: ADD FEATURE TO CHANGE NEEDLE
  256.  
  257.     Dim CNT As Integer
  258.     HAYSTACK = _Trim$(HAYSTACK)
  259.  
  260.     CNT = 1
  261.     For I = 1 To Len(HAYSTACK)
  262.         If Mid$(HAYSTACK, I, 1) <> NEEDLE Then
  263.             SPLIT_EXT(CNT) = SPLIT_EXT(CNT) + Mid$(HAYSTACK, I, 1)
  264.         Else
  265.             CNT = CNT + 1
  266.         End If
  267.  
  268.     Next
  269.  
  270. Sub HEADER (TXT As String, Y As Integer)
  271.     CENTER "`8 --`3------------=`!=`%[ " + TXT + " `%]=`!= `3------------`8-- ", Y
  272.     Print
  273.  
  274. Sub HR '                                        HR
  275.     LWRITELN ("`8 -  --`3------------------=`!=`%*`!=`3------------------`8--  - ")
  276.  
  277. Function USER_INPUT
  278.     Dim SPIN(10) As String '    spiner tile
  279.     Dim k As String '           dummy string to check for user input
  280.     Dim x As Integer '          spin array counter
  281.  
  282.     SPIN(1) = "*": SPIN(2) = "/": SPIN(3) = "-"
  283.     SPIN(4) = "\": SPIN(5) = "|": SPIN(6) = "/"
  284.     SPIN(7) = "-": SPIN(8) = "\": SPIN(9) = "|"
  285.  
  286.     x = 2
  287.     Do
  288.         Locate 24, 1
  289.         CENTER "`8 --`3------------=`!=`%[ " + SPIN(x) + " `%]=`!= `3------------`8-- ", 24
  290.         x = x + 1: If x > 9 Then x = 2
  291.         k = InKey$
  292.         _Delay (.10)
  293.         k = UCase$(k)
  294.     Loop Until k = "P" Or k = "S" Or k = "C" Or k = "X" Or k = "N" Or k = "Y"
  295.  
  296.     Select Case k
  297.         Case "P": USER_INPUT = 1
  298.         Case "S": USER_INPUT = 2
  299.         Case "C": USER_INPUT = 3
  300.         Case "X": USER_INPUT = 4
  301.         Case "Y": USER_INPUT = 9 ' USED FOR YES/NO
  302.         Case "N": USER_INPUT = 0 ' USED FOR YES/NO
  303.     End Select
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312. Sub PAUSE (y As Integer)
  313.     Dim SPIN(10) As String '    spiner tile
  314.     Dim k As String '           dummy string to check for user input
  315.     Dim x As Integer '          spin array counter
  316.  
  317.     SPIN(1) = "*": SPIN(2) = "/": SPIN(3) = "-"
  318.     SPIN(4) = "\": SPIN(5) = "|": SPIN(6) = "/"
  319.     SPIN(7) = "-": SPIN(8) = "\": SPIN(9) = "|"
  320.  
  321.     x = 2
  322.     Do
  323.         Locate 24, 1
  324.         CENTER "`8 --`3------------=`!=`%[ " + SPIN(x) + " `%]=`!= `3------------`8-- ", y
  325.         x = x + 1: If x > 9 Then x = 2
  326.         k = InKey$
  327.         _Delay (.10)
  328.     Loop Until k > ""
  329.  
  330. Sub SHOWOUTTRO
  331.  
  332.     CENTER "`$THANKS FOR CHECKKNG OUT TERMINAL LANCHER IV!!", 8
  333.     CENTER "`$FOR INQUIRIES: RICKSCORPIO64@GMAIL.COM", 10
  334.     End
  335.  
  336.  
  337. Sub LIST_CONSOLES
  338.     Dim ConsoleCnt As Integer
  339.     Dim i As Integer
  340.  
  341.     ConsoleCnt = 1
  342.     Color 7
  343.     Open DB_PATH + CONSOLE_DB For Random As #2 Len = Len(CONSOLE)
  344.     For i = 1 To Int(LOF(2) / Len(CONSOLE))
  345.  
  346.         If CONSOLE.Title > "" Then
  347.             Get #2, ConsoleCnt, CONSOLE
  348.             LWRITE "`% `t": Print _Trim$(Str$(ConsoleCnt));
  349.             LWRITE "`8": Print ". ";
  350.             LWRITE "`3": Print CONSOLE.Title
  351.             ConsoleCnt = ConsoleCnt + 1
  352.         End If
  353.  
  354.     Next
  355.  
  356.     Close #2
  357.  
  358. Sub EDIT_CONSOLE
  359.     Dim c_num As Integer
  360.     Dim Total_Records As Integer
  361.     Dim i As Integer
  362.  
  363.  
  364.     Cls
  365.  
  366.  
  367.     Print " _______ _____ _______ _______      ______ _______ _______ _______ "
  368.     Print "|    ___|     \_     _|_     _|    |      |       |    |  |     __|"
  369.     Print "|    ___|  --  ||   |_  |   |      |   ---|   -   |       |__     |"
  370.     Print "|_______|_____/_______| |___|      |______|_______|__|____|_______|"
  371.     Print "                                                                   "
  372.  
  373.  
  374.     Print
  375.     Print "Current Consoles"
  376.     Print "========================"
  377.     LIST_CONSOLES
  378.     Print "99. Cancel"
  379.     Print "------------------------"
  380.     Print
  381.  
  382.     Print "Enter console # to edit: ";: Input c_num
  383.     If c_num = 99 Then Exit Sub
  384.  
  385.     Print
  386.  
  387.  
  388.     Open DB_PATH + CONSOLE_DB For Random As #1 Len = Len(CONSOLE)
  389.     Total_Records = LOF(1) / Len(CONSOLE)
  390.     Get #1, c_num, CONSOLE
  391.     Do
  392.         Cls
  393.         Print "1. Full title of console... "; _Trim$(CONSOLE.Title)
  394.         Print "2. Database Name........... "; _Trim$(CONSOLE.RomDBName)
  395.         Print "3. List extensions......... "; _Trim$(CONSOLE.Extentions)
  396.         Print "4. Filename of emulator.... "; _Trim$(CONSOLE.EMUCmd)
  397.         Print "5. Commandline Params...... "; _Trim$(CONSOLE.EMUParams)
  398.         Print "6. Emulator Path........... "; _Trim$(CONSOLE.EmuPath)
  399.         Print "7. Path for assoc. ROMS.... "; _Trim$(CONSOLE.RomPath)
  400.         Print
  401.         Print "9. Apply Changes"
  402.         Print "0. Cancel Edit (no change)"
  403.         Input i
  404.  
  405.         Select Case i
  406.             Case 1: Input "Full title of console... "; CONSOLE.Title
  407.             Case 2: Input "Database Name........... "; CONSOLE.RomDBName
  408.             Case 3: Input "List extensions......... "; CONSOLE.Extentions
  409.             Case 4: Input "Filename of emulator.... "; CONSOLE.EMUCmd
  410.             Case 5: Input "Commandline Params...... "; CONSOLE.EMUParams
  411.             Case 6: Input "Emulator Path........... "; CONSOLE.EmuPath
  412.                 If Left$(CONSOLE.EmuPath, 1) = "-" Then
  413.                     CONSOLE.EmuPath = _Trim$(_Clipboard$)
  414.                 Else
  415.                     CONSOLE.EmuPath = _Trim$(CONSOLE.EmuPath)
  416.                 End If
  417.                 If Right$(_Trim$(CONSOLE.EmuPath), 1) <> "\" Then CONSOLE.EmuPath = _Trim$(CONSOLE.EmuPath) + "\"
  418.  
  419.             Case 7: Input "Path for assoc. ROMS.... "; CONSOLE.RomPath
  420.                 If Left$(CONSOLE.RomPath, 1) = "-" Then
  421.                     CONSOLE.RomPath = _Trim$(_Clipboard$)
  422.                 Else
  423.                     CONSOLE.RomPath = _Trim$(CONSOLE.RomPath)
  424.                 End If
  425.                 If Right$(CONSOLE.RomPath, 1) <> "\" Then CONSOLE.RomPath = CONSOLE.RomPath + "\"
  426.             Case 0: Close #1: Exit Sub
  427.         End Select
  428.     Loop Until i = 9
  429.     Put #1, c_num, CONSOLE
  430.     Print "Changes SUCCESSFULLY applied";
  431.     Input i
  432.  
  433.     Close #1
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440. Sub DEL_CONSOLE
  441.     Dim ConsoleNum As Integer
  442.     Dim RecNumber As Integer
  443.     Dim item As Integer
  444.     Dim ConsoleName As String
  445.  
  446.     DEL:
  447.     Cls
  448.     item = 1
  449.  
  450.  
  451.     Print " _____  _______ _____        ______ _______ _______ _______ "
  452.     Print "|     \|    ___|     |_     |      |       |    |  |     __|"
  453.     Print "|  --  |    ___|       |    |   ---|   -   |       |__     |"
  454.     Print "|_____/|_______|_______|    |______|_______|__|____|_______|"
  455.     Print "                                                            "
  456.  
  457.     Print
  458.     Print "Current Consoles"
  459.     Print "========================"
  460.     LIST_CONSOLES
  461.     Print "------------------------"
  462.     Print
  463.     Print "99. Cancel"
  464.  
  465.     Print
  466.     Input "Select console to delete: ", ConsoleNum
  467.     If ConsoleNum = 99 Then Exit Sub
  468.     Input "Are you sure? "; YN
  469.     If YN = "n" Or YN = "N" Then GoTo DEL
  470.  
  471.     Open DB_PATH + CONSOLE_DB For Random As #1 Len = Len(CONSOLE)
  472.     Open DB_PATH + "temp.db" For Random As #2 Len = Len(CONSOLE)
  473.     RecNumber = LOF(1) / Len(CONSOLE)
  474.     Dim i As Integer
  475.  
  476.     For i = 1 To Int(LOF(1) / Len(CONSOLE))
  477.         Get #1, item, CONSOLE
  478.         If item <> ConsoleNum Then
  479.             Put #2, , CONSOLE
  480.         Else
  481.             ConsoleName = _Trim$(CONSOLE.Title)
  482.  
  483.         End If
  484.         item = item + 1
  485.     Next
  486.     Close #2: Close #1
  487.  
  488.     Kill DB_PATH + CONSOLE_DB
  489.     Name DB_PATH + "temp.db" As DB_PATH + CONSOLE_DB
  490.  
  491.     LIST_CONSOLES
  492.  
  493.     Print "Console " + ConsoleName + " was deleted SUCCESSFULLY!"
  494.     Print "Press ENTER to continue..."
  495.     Input YN
  496.  
  497.  
  498. Function CLEANROM$ (TXT As String)
  499.     Dim pt1 As String
  500.     pt1 = ""
  501.     pt1 = Left$(TXT, InStr(TXT, ".") - 1)
  502.  
  503.     'IF INSTR(TXT, "(") > 0 THEN
  504.     '    pt1 = LEFT$(TXT, INSTR(TXT, "(") - 1)
  505.     '
  506.     'ELSE
  507.     '    pt1 = LEFT$(TXT, INSTR(TXT, ".") - 1)
  508.     'END IF
  509.  
  510.     CLEANROM = _Trim$(pt1)
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517. Sub CREATE_ROM_DB (DB_NAME As String)
  518.     Close #1: Close #2 ' stragglers?
  519.  
  520.     Dim ALINE As String
  521.  
  522.  
  523.     If Asc(CONSOLE.RomDBName) = 0 Then
  524.         CENTER "`4Console not selected", 17
  525.         Input I
  526.         Exit Sub
  527.     End If
  528.  
  529.  
  530.     Open DB_PATH + DB_NAME For Random As #1 Len = Len(ROMS)
  531.     'CREATE A TXT FILE LIST FROM ROM PATH TO WORK WITH
  532.     'Delete the old romlist if it exists
  533.     Shell _Hide "DEL /Q " + _Trim$(CONSOLE.RomPath) + "ROMLIST.TXT"
  534.  
  535.     'Need to split the space delimited string to an array
  536.     EXPLODE CONSOLE.Extentions, Chr$(32), SPLIT_EXT()
  537.  
  538.     'Create new romlist.txt using given extentions (ext)
  539.     'this will be the raw filename - we will clean up the display below
  540.     'PRINT "DEBUG EXECUTING: " + "DIR " + _TRIM$(CONSOLE.RomPath) + _TRIM$(CONSOLE.Extentions) + " /B /A-D /ON >" + _TRIM$(CONSOLE.RomPath) + "ROMLIST.TXT"
  541.     LWRITELN "`7Scanning `%" + _Trim$(CONSOLE.Title) + "`7 folder": Print
  542.  
  543.     For I = 1 To UBound(SPLIT_EXT)
  544.         If SPLIT_EXT(I) > "" Then
  545.  
  546.             Print "scanning: " + SPLIT_EXT(I)
  547.             Shell _Hide "DIR " + _Trim$(CONSOLE.RomPath) + SPLIT_EXT(I) + " /B /A-D /ON >>" + _Trim$(CONSOLE.RomPath) + "ROMLIST.TXT"
  548.         End If
  549.     Next
  550.     LWRITELN "`0Done...": _Delay (2)
  551.  
  552.     'Load the romlist.txt AND xfer cleaned title to the db
  553.     Open _Trim$(CONSOLE.RomPath) + "ROMLIST.TXT" For Input As #2
  554.     While Not EOF(2)
  555.         Line Input #2, ALINE
  556.         ROMS.Filename = ALINE
  557.         ROMS.title = CLEANROM(ALINE)
  558.         Put #1, , ROMS
  559.     Wend
  560.     Close #2 ' roms text file
  561.     Close #1 ' desired rom.db
  562.     'We're done, get out of here
  563.  
  564.  
  565. Sub PLAY_GAME
  566.  
  567.     Cls
  568.     HEADER "`$PLAY GAMES", 1
  569.     Print: Print
  570.     SELECT_CONSOLE
  571.  
  572.     Close #1 ' straggler TODO FIX THIS FIND OUT WHERE IT IS AT
  573.     Open DB_PATH + CONSOLE_DB For Random As #1 Len = Len(CONSOLE)
  574.  
  575.     Get #1, SELECTED_CONSOLE, CONSOLE
  576.     Close #1
  577.  
  578.     Print _Trim$(CONSOLE.Title) + " console selected"
  579.     SELECT_GAME
  580.  
  581.  
  582.  
  583. Sub SELECT_GAME
  584.     Dim GAME_NAME As String
  585.     Dim GAME_FOUND As Integer
  586.     Dim ROM_COUNT As Integer
  587.     Dim I As Integer
  588.     Dim FIND_STR As Integer
  589.  
  590.  
  591.     'MAKE A DB FILE EACH TIME. HAPPENS SO FAST IT IS NOT NOTICABLE
  592.     'IF WE CHECK FOR EXISTING, IT DOES NOT UPDATE WHEN NEW FILES ARE ADDED TO
  593.     'THE FOLDER
  594.     CREATE_ROM_DB (_Trim$(CONSOLE.RomDBName) + ".db")
  595.  
  596.     If Asc(CONSOLE.RomDBName) = 0 Then Exit Sub
  597.  
  598.     GAME_FOUND = 0
  599.     ROM_COUNT = 0
  600.     Cls
  601.     HEADER "`$GAME SELECTION", 1
  602.     Print: Print
  603.  
  604.     LWRITELN "`4Currently if you just press enter, it will display all ROMS with"
  605.     LWRITELN "`4no scrolling. So suggest to use the partial search. Will fix this later"
  606.     Print
  607.     LWRITE "`2Enter partial gamename search`8: `#": Input GAME_NAME
  608.     Print
  609.     LWRITELN "`#5ID     GAME NAME"
  610.     LWRITELN "`5============================================================="
  611.  
  612.     If GAME_NAME = "" Then Exit Sub '  return to menu - prevents the massive unscrollable list
  613.  
  614.     Open DB_PATH + _Trim$(CONSOLE.RomDBName) + ".db" For Random As #1 Len = Len(ROMS)
  615.  
  616.     For I = 1 To LOF(1) / Len(ROMS)
  617.  
  618.         Get #1, I, ROMS
  619.         FIND_STR = InStr(UCase$(ROMS.title), UCase$(GAME_NAME))
  620.  
  621.         If FIND_STR > 0 Then
  622.  
  623.             GAME_FOUND = TRUE
  624.             ' the following section just eyecandy for the id listing so it is
  625.             ' proportional
  626.             Color 15
  627.             If I < 10 Then
  628.                 Print " " + Str$(I);
  629.             Else
  630.                 Print Str$(I);
  631.             End If
  632.             Color 8
  633.             Print " .......... ";
  634.             Color 7
  635.             Print _Trim$(ROMS.title)
  636.  
  637.         End If
  638.  
  639.     Next I
  640.  
  641.     If GAME_FOUND = FALSE Then
  642.         Print "No game matching '" + _Trim$(GAME_NAME) + "'"
  643.         Print
  644.  
  645.         'Input GAME_NAME ' dummy pause
  646.         PAUSE (24)
  647.         Close #1 ' clean up on exit early
  648.         Exit Sub
  649.     Else
  650.         Print
  651.         Input "Enter game ID or 0 to exit: "; I
  652.         If I = 0 Then Exit Sub
  653.         ' GET GAME ID AND RUN IT
  654.         Get #1, I, ROMS
  655.         Print "Starting " + _Trim$(ROMS.title)
  656.         ' PRINT "DEBUG: "
  657.         ' PRINT _TRIM$(CONSOLE.EmuPath) + _TRIM$(CONSOLE.EMUCmd) + " " + CHR$(34) + " " + _TRIM$(CONSOLE.EMUParams) + " " + CHR$(34) + _TRIM$(CONSOLE.RomPath) + _TRIM$(ROMS.Filename) + CHR$(34)
  658.         ' PRINT "-----------------------------"
  659.         ' PRINT
  660.  
  661.         Shell Chr$(34) + _Trim$(CONSOLE.EmuPath) + _Trim$(CONSOLE.EMUCmd) + " " + Chr$(34) + " " + _Trim$(CONSOLE.EMUParams) + " " + Chr$(34) + _Trim$(CONSOLE.RomPath) + _Trim$(ROMS.Filename) + Chr$(34)
  662.     End If
  663.     Close #1
  664.  
  665.  
  666.  
  667. Sub ADD_CONSOLE
  668.     Dim RecNumber As Integer
  669.  
  670.     Print
  671.  
  672.     Cls
  673.     HEADER "ADD A CONSOLE TO THE LIBRARY", 1
  674.  
  675.  
  676.  
  677.     Do ' ADDING ANOTHER CONSOLE?
  678.         Do ' ENTRY CORRECT
  679.             HEADER "`!Current Consoles", 1
  680.             Print: Print
  681.  
  682.             If _FileExists(DB_PATH + CONSOLE_DB) Then
  683.                 LIST_CONSOLES
  684.  
  685.             Else
  686.                 LWRITELN "`@No consoles in the library yet"
  687.             End If
  688.  
  689.  
  690.             Print
  691.  
  692.  
  693.             Print "Add a console [Y/N]? ";: Input YN
  694.             If YN = "n" Or YN = "N" Then
  695.                 Close #1 'clean up
  696.                 Exit Sub
  697.             End If
  698.  
  699.             Print
  700.  
  701.             Open DB_PATH + CONSOLE_DB For Random As #1 Len = Len(CONSOLE)
  702.             RecNumber = LOF(1) / Len(CONSOLE)
  703.             Color 7
  704.  
  705.             Input "Full title of console... "; CONSOLE.Title
  706.             Input "Database Name........... "; CONSOLE.RomDBName
  707.             Input "ROM extensions.......... "; CONSOLE.Extentions
  708.             Input "Filename of emulator.... "; CONSOLE.EMUCmd
  709.             Input "Commandline Params...... "; CONSOLE.EMUParams
  710.             Print
  711.             LWRITELN "`$'-' `3to paste path(s)"
  712.             Input "Emulator Path........... "; CONSOLE.EmuPath
  713.             If Left$(CONSOLE.EmuPath, 1) = "-" Then
  714.                 CONSOLE.EmuPath = _Trim$(_Clipboard$)
  715.             Else
  716.                 CONSOLE.EmuPath = _Trim$(CONSOLE.EmuPath)
  717.             End If
  718.             If Right$(CONSOLE.EmuPath, 1) <> "\" Then CONSOLE.EmuPath = CONSOLE.EmuPath + "\"
  719.  
  720.             Input "Path for assoc. ROMS.... "; CONSOLE.RomPath
  721.             If Left$(CONSOLE.RomPath, 1) = "-" Then
  722.                 CONSOLE.RomPath = _Trim$(_Clipboard$)
  723.             Else
  724.                 CONSOLE.RomPath = _Trim$(CONSOLE.RomPath)
  725.             End If
  726.             If Right$(CONSOLE.RomPath, 1) <> "\" Then CONSOLE.RomPath = CONSOLE.RomPath + "\"
  727.  
  728.             Print
  729.             Print
  730.             Color 14
  731.             Do: Input "Everything Correct? (Y/n): "; YN
  732.                 YN = UCase$(YN)
  733.             Loop Until YN = "Y" Or YN = "N"
  734.  
  735.  
  736.         Loop Until YN = "Y" ' CONSOLE ENTRY
  737.  
  738.         Put #1, RecNumber + 1, CONSOLE
  739.         Close #1
  740.  
  741.  
  742.  
  743.         Print
  744.         Print "CONSOLE " + _Trim$(CONSOLE.Title) + " addes successfully!"
  745.         Print
  746.         Color 7
  747.         Do: Input "Enter Another? (Y/n): "; YN
  748.             YN = UCase$(YN)
  749.         Loop Until YN = "Y" Or YN = "N"
  750.  
  751.  
  752.     Loop Until YN = "N"
  753.     Close #1
  754.  
  755.  
  756.  
  757.  
  758.  
« Last Edit: March 13, 2021, 08:18:35 am by xra7en »
I just like re-writing old DOS book games into modern QB64 code - weird hobby, I know!