                                                       /(
            /(____ ____________  _________   ___  ___ (__)  _____)\
           |      \|         \ \/  ___    `\|   \|   |/  \ /      |
           |   |   |   |___   .  ,  |   |   |    |   |    |   |   | pt/jp
       ___ |   |   :   __|__  :  |  |   |   :   ,    :    :   |___| ___
       )   |   |   .       |  |  |  |   '   .   |    .    .   |   |   (
    ... \  |   '  ____________|__|______________|\__________  `   |  / ...
    :    \ |     / % d e m o n i c  p r o d u c t i o n z % \     |//    :
    :....  |    / __________________________________________ \    |  ....:
        :. |__// .... .. . .. ... .. .  . .. ... .. . .. .... \___| .:
  
  ============================================================================
    XQTR // andr01d.zapto.org:999                              December 2022
  ============================================================================


  This is a HOW-TO, for installing DOSEMU on a LINUX machine and use it to 
  launch and run DOS DOOR apps and games. The original guide i followed is 
  here:

  https://medium.com/retro-future/lets-add-a-dos-game-to-enigma-1-2-41f257deaa3c

  ...which was also based on a guide made by DEADBEATZ.
  
  
  1. DOSEMU INSTALL
  -----------------
  
  Add the repository and install the appropriate package:

    sudo add-apt-repository ppa:dosemu2/ppa
    sudo apt-get update
    sudo apt install dosemu2
  
  If you get an fdpp error, try to install it with:
  
    sudo apt-get install fdpp
    
  ...at least, that solved the problem for me.
  
  
  2. GET DOSEMU IMAGE
  -------------------

  DEADBEATZ made a nice DOSEMU "image" for easy installation of the whole thing.
  You just get it with GIT from its repo. Clone it somewhere temporary.

    git clone https://github.com/deadbeatz/mystic_a45.git

  Now you need to copy the contents of the mystic_a45/dosemu folder, to the
  one in your home directory ( ~/.dosemu ). Notice there are some hidden files
  in there!!! You can use any file manager or just CP from a linux terminal
  like:

    cp -R ~/temp/mystic_a45/dosemu/* .dosemurc .dosemurc_nocom ~/.dosemu
    
  This command will copy also the two hidden files.
  
  
  3. TEST
  -------
  
  At this point you can test dosemu:

    dosemu -f ~/.dosemu/.dosemurc_nocom

  If that loads DOS, cool. Type ‘exit’ and hit return to quit dosemu.


  4. RUNDOOR.SH - DOOR LAUNCHER SCRIPT
  ------------------------------------
  
  - Now we need a BASH script to launch DOSEMU with the selected DOOR app. Copy 
    paste the following script and name it something like rundoor.sh. Don't 
    forget to make it executable, with: chmod +x rundoor.sh
  
  - The script also needs unix2dos to be installed. Make sure you have it.
  
  - Put the script in a folder, inside your BBS software directory.

  - Change the directories, the script using, to the ones your BBS has.
  
  - To add more DOORs, populate the CASE statement at the end of the script, 
    to match paramaters, name, folders for the new DOOR. You can see i added
    a record, for Anagram.

=== SCRIPT ===================================================================

#!/bin/bash
trap '' 2
# $1 Node number
# $2 Door Call Name
# $3 Doorfile type :1 DOOR.SYS :2 CHAIN.TXT
stty cols 80 rows 25

BBSROOT=/home/bbs
NODE=$BBSROOT/temp$1
MYNAME=$(sed -n '36p' $BBSROOT/temp$1/DOOR.SYS)

# Define root directory for DOSEMU hdd
DROOT=/home/bbs/.dosemu/drive_c/nodes/temp$1
DOSNODE='C:\\nodes\\temp'$1'\\DOOR.SYS'

#EXTNODE=/opt/share/node$1
# Convert DOOR.SYS to DOS line endings
unix2dos $NODE/DOOR.SYS 2>/dev/null

# Define node directory inside DOSEMU filesystem
cp $NODE/DOOR.SYS $DROOT/DOOR.SYS
#cp $NODE/DOOR.SYS $EXTNODE

# Generate a random lowercase 4 digit code for batch file uniqueness
RAND=$(tr -dc a-f0-9 2>/dev/null  </dev/urandom | head -c 4)

FILE=RUN$RAND.BAT

# Convert to lowercase for linux
DOOR=$(echo "$2" | tr '[:upper:]' '[:lower:]')

run_batch(){
    # Arg 1 = NODE
    # Arg 2 = FILE (batch filename)
    # Arg 3 = DROOT (dosemu node folder)
    /usr/bin/dosemu -E "C:\\NODES\\TEMP$1\\$2" 1>/dev/null 2>&1
    rm $3/$2
    rm $3/DOOR.SYS
}

case "$DOOR" in
    dark)
        echo -e '\r@echo off \r' > $DROOT/$FILE
        echo -e 'c: \r' >> $DROOT/$FILE
        echo -e 'cd c:\\doors\\darkness\\ \r' >> $DROOT/$FILE
        echo -e 'dark16 /n'$1' \r' >> $DROOT/$FILE
        echo -e 'exitemu' >> $DROOT/$FILE
        unix2dos $DROOT/$FILE 2>/dev/null
        run_batch $1 $FILE $DROOT
        ;;
    anagram)
        echo -e '\r@echo off \r' > $DROOT/$FILE
        echo -e 'c: \r' >> $DROOT/$FILE
        echo -e 'cd c:\\doors\\anagram\\ \r' >> $DROOT/$FILE
        echo -e 'anagram /n'$1' /d'$DOSNODE' \r' >> $DROOT/$FILE
        echo -e 'exitemu' >> $DROOT/$FILE
        unix2dos $DROOT/$FILE 2>/dev/null
        run_batch $1 $FILE $DROOT
        ;;

    *)
        echo "Invalid option"
        ;;
esac
trap 2

=== END ======================================================================


  4. ADD DOORs
  ------------
  
  With this setup, you can copy new DOORs inside the ~/.dosemu/drive_c/doors,
  directory. This way you can have all of your DOORs inside a folder, keep 
  backups, organize them, etc. No need to change something else, in the DOSEMU
  setup.
  
  Now, to be able to launch the DOOR from your BBS, you want to add a custom
  entry for the new DOOR, into your BBS. Lets take Mystic BBS for example.
  
  Go into the Mystic Configuration editor, edit the main theme and open the 
  DOORS menu. Add a new entry and edit the text to what you like. The important
  stuff is the command in the Action List. Press / and insert a new Command, 
  now edit it.
  
  Set Command to DD, Exec external program. Set Data to something similar with
  this:
  
  /home/bbs/rundoor.sh %3 anagram 1
  
  Lets explain it a bit more. /home/bbs is the folder where you put the 
  rundoor.sh script from above.
  
  - %3, is a mystic mci code for the Node number.
  - anagram, is a shortcode/parameter for the rundoor.sh script to launch the 
    specific DOOR.
  - 1, is the paramater to tell rundoor.sh to use the DOOR.SYS drop file
  
  Save the command option and go test to see if everything is OK. You should
  be able to run any DOS DOOR now.
  
  
  5. MORE...
  ----------
  
  Something i noticed, is that inside the ~/.dosemu/drive_c/nodes directory,
  needs to be created directories named, temp1, temp2, temp3 etc. Make sure
  to create them, as the script doesn't do that. You can do it with any 
  file manager or in the terminal, inside that dir, give the command:
  
  mkdir temp{1..9}
  
  ...and it will create temp1, temp2... temp8, temp9 directories. ;)


  Below are a copy of the files the DOSEMU image from deadbeatz needs to run.
  You can get X00 from the Net and create the rest your self. I only put these 
  here, in case the Github repo vanish.
  
=== .dosemurc_nocom ==========================================================
$_cpu = "80486"                 
$_cpu_emu = "vm86"              
$_hogthreshold = (10)           
$_external_char_set = "cp437"    
$_internal_char_set = "cp437"   
$_layout = "us"                 
$_rawkeyboard = (0)             
$_joy_device = ""               
$_speaker = ""                  
$_sound = (off)
=== END ======================================================================

=== userhook.sys =============================================================
device=c:\x00\x00.sys E
=== END ======================================================================


Directory Structure of: ~/.dosemu/

+-- [4.7K]  boot.log
+-- [4.7K]  boot.log.1
+-- [3.9K]  boot.log.2
+-- [4.6K]  boot.log.3
+-- [ 253]  disclaimer
+-- [ 314]  .dosemurc_nocom
+-- [4.0K]  drive_c
|   +-- [4.0K]  doors
|   |   +-- [4.0K]  anagram    // DOOR directories 
|   |   +-- [4.0K]  darkness
|   +-- [4.0K]  nodes
|   |   +-- [4.0K]  temp1      // Temp dirs for each node
|   |   +-- [4.0K]  temp2
|   |   +-- [4.0K]  temp3
|   |   +-- [4.0K]  temp4
|   |   +-- [4.0K]  temp5
|   |   +-- [4.0K]  temp6
|   |   +-- [4.0K]  temp7
|   |   +-- [4.0K]  temp8
|   |   +-- [4.0K]  temp9
|   +-- [4.0K]  tmp
|   +-- [  24]  userhook.sys   
|   +-- [4.0K]  x00
|       +-- [ 20K]  BOB.ZIP
|       +-- [ 625]  BOOT.COM
|       +-- [ 716]  BYPASS.OBJ
|       +-- [6.9K]  CHLLAPI.ZIP
|       +-- [ 39K]  FOSSIL.CHT
|       +-- [ 23K]  HISTORY.DOC
|       +-- [5.4K]  LICENSE.TXT
|       +-- [3.7K]  QBHLLAPI.ZIP
|       +-- [ 494]  README.DOC
|       +-- [3.3K]  TPHLLAPI.ZIP
|       +-- [103K]  x00150.zip
|       +-- [ 62K]  X00REF.DOC
|       +-- [ 17K]  X00.SYS
|       +-- [ 60K]  X00USER.DOC
|       +-- [ 23K]  XU.DOC
|       +-- [7.3K]  XU.EXE
+-- [4.0K]  run
+-- [  77]  stderr.log.12728
+-- [  77]  stderr.log.13941




         _____         _   _              ____          _   _ 
        |  _  |___ ___| |_| |_ ___ ___   |    \ ___ ___|_|_| |        8888
        |     |   | . |  _|   | -_|  _|  |  |  |  _| . | | . |     8 888888 8
        |__|__|_|_|___|_| |_|_|___|_|    |____/|_| |___|_|___|     8888888888
                                                                   8888888888
                DoNt Be aNoTHeR DrOiD fOR tHe SySteM               88 8888 88
                                                                   8888888888
 /: HaM RaDiO   /: ANSi ARt!     /: MySTiC MoDS   /: DooRS         '88||||88'
 /: NeWS        /: WeATheR       /: FiLEs         /: zer0net        ''8888"'
 /: GaMeS       /: TeXtFiLeS     /: PrEPardNeSS   /: FsxNet            88
 /: TuTors      /: bOOkS/PdFs    /: SuRVaViLiSM   /:            8 8 88888888888
                                                              888 8888][][][888
   TeLNeT : andr01d.zapto.org:9999 / ssh: 8888                  8 888888##88888
   SySoP  : xqtr                   eMAiL: xqtr@gmx.com          8 8888.####.888
   DoNaTe : https://paypal.me/xqtr                              8 8888##88##888

