darkbox - A Fast and Portable IO Console Server

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
TSnake41
Posts: 12
Joined: 17 Dec 2016 12:49

darkbox - A Fast and Portable IO Console Server

#1 Post by TSnake41 » 15 Feb 2017 05:56

To avoid speed issues when using most of the console graphics command, I made darkbox.

What is this ?
This is a Batch IO Server which can work on Windows (cmd.exe) and *Nixes like GNU/Linux (with Dos9 Project).

What is a Batch IO Server ?
A Batch IO Server is a concept of external command directly derivated from Darkbatcher (the creator of batbox) in its command SuperBox, the main difference between these 2 commands is the way to send a command, while darkbox uses stdin/stdout, Superbox uses named pipes.
So, the aim is to build a thing, and do not detroy it to rebuild it again :mrgreen:, just keep the thing built how long we need it to get a better speed compared to others.

Where to download it ?
You can download darkbox in two version, they are almost the same (just executable flags in the Unix version :roll:).
Windows download : http://sachadee.org/Ts/darkbox/darkbox-dist.7z
Unix download : http://sachadee.org/Ts/darkbox/darkbox-dist.tar.xz

What features are supported in darkbox (only the IO server) ?
Throught the output server :
- Basic output operations (ASCII, Display text, new-line, cursor movement, local color, clear)
- Darkbox-internal operations (internal-wait/display-delay, quit (to stop properly darkbox))
- Advanced output operations (cursor origin, color reset, hide/show cursor)
Throught the executable it-self :
- Get if data is available in stdin (-kbh)
- Wait (external/batch delay) (-w t)
And throught the input server : Keyboard and mouse key handling simultaneously and possibly in non-blocking way (with -kbh).

Here are screenshots of some examples on both Windows and GNU/Linux (Archlinux)
nuancier.bat : http://pix.toile-libre.org/upload/original/1487159497.png http://pix.toile-libre.org/upload/original/1487159523.png
it.bat : http://pix.toile-libre.org/upload/original/1487159539.png http://pix.toile-libre.org/upload/original/1487159553.png
geometry.bat : http://pix.toile-libre.org/upload/original/1487159567.png http://pix.toile-libre.org/upload/original/1487159584.png

Here is the official english documentation, this explain how you should work with darkbox :

Code: Select all

 __        __        __   __
|  \  /\  |__) |__/ |__) /  \ \_/
|__/ /~~\ |  \ |  \ |__) \__/ / \

Darkbox fully portable fast I/O server, powerfull graphic command
Fully compatible with Dos9 Project.

Syntaxes:
    1) (process, code or "launcher" part) | darkbox
    2) darkbox -i | (process, code or "launcher" part)
    3) darkbox -w t
    4) darkbox -kbh (reduced: -k)

1) Start darkbox as output server.
2) Start darkbox as input server.
3) Wait t ms.
4) Return 1 if data is available in stdin,
   should be used for non-blocking input.

   NOTE: "bh" is not required but recommended for
         "a better code", so it's just cosmetic.

Output commands passing:
    Commands pass to stdin, so any command like type, more, echo,
    <nul set/p "=text" or whatever you can imagine send command to darkbox.

    So, you can store commands to files to reuses them easly, like sprites or
    something else.

    Also, darkbox accept both new syntax ('-') and batbox/tinybg syntax ('/') to
    begin command.

Output command format:
    Commands follow this format

    -(execution_count)<commands as letters>
    REMARK: '-' can be replaced by '/'

    So each <commands as letters> run (execution_count) times (or 1 time if undefined).

    NOTES:
        - You can escape chracters (" or spaces without double quotes) with '\'
        - With double quotes, new lines are considerated as characters like any others.
        - No commands will produce an error (Parsing error: No command specified).
        - Commands should be in litterals ONLY (Parsing error: Invalid litterals)
        - Commands are case-insensitive.

    TRICK:
        You can write your commands througth multiples echoes :
            echo -5dn "This is a"
            echo      "small text"
            echo      "throught"
            echo      "multiples"
            echo      "lines"

Launcher (and working variations):
    Official launchers:

        Original (first) :
            @Echo off
            call game.bat | darkbox

        Original with Input server
            @Echo off
            darkbox -i | call game.bat | darkbox

        Enhanced (only in one file) :
            @Echo off
            if defined __ goto :(code)
            set __=.
            call %0 %* | darkbox
            set __=
            pause>NUL
            goto :eof

            "call" is facultative

        Enhanced with Input server
            @Echo off
            if defined __ goto :(code)
            set __=.
            darkbox -i | call %0 %* | darkbox
            set __=
            pause>NUL
            goto :eof

            "call" is facultative.

    Unofficial launcher (variants):
        @echo off
        if not defined $ (
            set "$=1"
            (
              call "%~f0" %*
            ) | darkbox
            exit/b
        )

Output commands reference:

    ASCII:
        -a Integer

        Usage : Print the character corresponding to the integer

    Newline:
        -n

        Usage : Go to the next line

    Color:
        -c color
        color is in hexadecimal format.

        Usage : Change the current color
               0xF0 : Background
               0x0F : Foreground

    Goto:
        -g x y

        Usage : Move cursor to (x;y)

    Hide/Show cursor:
        -h 0/1

        Usage : Hide or show cursor

    Clear Screen:
        -s

        Usage : Clear console

    Origin:
        -o x y

        Usage : Change goto origin

    Reset:
        -r

        Usage : Reset foreground and background colors

    Quit:
        -q

        Usage : Properly stop darkbox

    Wait:
        -w t

        Usage : Wait t miliseconds

        NOTE: Wait is internal to darkbox, it
              do not interrupt batch execution.

        REMARK: Wait flush stdout even if t is null.

Input callback reference:

    Mouse:
        m x y b

        x: Mouse X position
        y: Mouse Y position
        b: Mouse button

    Keyboard press:
        k key

        key: Key code.

List of supported mouse buttons :
    1: NOTHING (mouse movement)
    2: LEFT_BUTTON
    3: RIGHT_BUTTON
    4: DOUBLE LEFT_BUTTON (portability issues known (*NIX))
    5: DOUBLE RIGHT_BUTTON (portability issues known (*NIX))
    6: MIDDLE_BUTTON
    7: SCROLL_UP (portability issues known (Win32))
    8: SCROLL_DOWN (portability issues known (Win32))
    9: RELEASE

See also:
    Official post : http://batch.xoo.it/t5526-Dev-Darkbox-TSnake41.htm
    Snake game : http://batch.xoo.it/t5614-Batch-Snake-IK-DC.htm
    Exquation : http://batch.xoo.it/t5654-Batch-Exquation-IK-DC.htm

    tests for examples of uses

    C library core/core_i in "lib" directory (part of darkbox project)

    Dos9 project : dos9.org
    darkbox_i and darkbox_t


If you need more help, you can ask me or see examples in the "tests" directory :mrgreen:.

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: darkbox - A Fast and Portable IO Console Server

#2 Post by PaperTronics » 25 Apr 2017 00:55

Wow! Tsnake! You did some great work!I have a question:

Are there some other programs or games that you have made?

I wanna post about them on my website : thebateam.org

It's a wonder how no one has replied on your post from 2 months

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: darkbox - A Fast and Portable IO Console Server

#3 Post by ShadowThief » 25 Apr 2017 15:13

PaperTronics wrote:It's a wonder how no one has replied on your post from 2 months

Because none of us downloaded it because we have no use for it?

Also, you made a post about this on your site back in January - http://www.thebateam.org/2017/01/darkbo ... ake41.html - why are you just now posting about this?

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: darkbox - A Fast and Portable IO Console Server

#4 Post by misol101 » 26 Apr 2017 02:00

I'd like to thank Tsnake though for the idea to run as an IO server, don't know why I didn't think of it myself. It has been implemented as an option for cmdgfx, and will see the light of day whenever I can be bothered to finish the new version.

(Cmdgfx is another mostly useless program, but has amassed 300+ downloads by now, so that's something at least :) )

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: darkbox - A Fast and Portable IO Console Server

#5 Post by Compo » 26 Apr 2017 05:10

ShadowThief wrote:
PaperTronics wrote:It's a wonder how no one has replied on your post from 2 months
Because none of us downloaded it because we have no use for it?
It's only just slightly more useful that a batch text to speech engine!

ShadowThief wrote:Also, you made a post about this on your site back in January - http://www.thebateam.org/2017/01/darkbo ... ake41.html - why are you just now posting about this?
Because the two of them have pre-agreed this post whilst pretending that they've met through happy coincidence.

PaperTronics
Posts: 118
Joined: 02 Apr 2017 06:11

Re: darkbox - A Fast and Portable IO Console Server

#6 Post by PaperTronics » 27 Apr 2017 09:02

Compo wrote:It's only just slightly more useful that a batch text to speech engine!


There are ways you can use Speecher, e.g To make a YT vid,etc..
It depends on your thinking :!: :wink:

TSnake41
Posts: 12
Joined: 17 Dec 2016 12:49

Re: darkbox - A Fast and Portable IO Console Server

#7 Post by TSnake41 » 28 Apr 2017 16:33

I'd like to thank Tsnake though for the idea to run as an IO server, don't know why I didn't think of it myself. It has been implemented as an option for cmdgfx, and will see the light of day whenever I can be bothered to finish the new version.

(Cmdgfx is another mostly useless program, but has amassed 300+ downloads by now, so that's something at least :) )
The cmdgfx git repository has some interesting stuff, I should check it soon :mrgreen:. (mainly for 3D stuff)

Are there some other programs or games that you have made?
Yes, in the Darkbox Project there is many others commands (must are work in progress), elsewhere, I am the creator of httpBat and it's main external command (SockeT), you can check it here : https://gitlab.com/TSnake41/httpBat/tree/master
The project can seem inactive, but I am working in a new version of SockeT (this version is a part of Darkbox project) using a new syntax more efficient, faster, and more flexible to make a new version of httpBat.
SockeT is an external command to use TCP/IP through batch scripts, the aim is to provide a way to make multiplayer games, or to create more technical batch projects, like httpBat.
In the future, I will make Dos9 (cmd.exe alternative by DarkBatcher) and cmd.exe compatible batch games using darkbox (and co.) and socket.


I added a git repository so you can check source code changes and upcoming stuff.
git repository url : https://gitlab.com/TSnake41/darkbox

Kvc
Posts: 26
Joined: 13 Jun 2017 06:44
Location: India
Contact:

Re: darkbox - A Fast and Portable IO Console Server

#8 Post by Kvc » 13 Jun 2017 06:55

ShadowThief wrote:Also, you made a post about this on your site back in January - http://www.thebateam.org/2017/01/darkbo ... ake41.html - why are you just now posting about this?
Because the two of them have pre-agreed this post whilst pretending that they've met through happy coincidence.[/quote]

Hi To the DosTips Community! I'm Just a new member of DosTips, My friend Papertronics Gave me idea to join here too... And, Coincidentally - i read something that I even can;t believe.

The www.thebateam.org {aka Batch Archive, or TheBATeam}: I'm the co-founder of the Website. And, Maintaining most of the articles there. And, None of the article is pre-agreed with anyone. If I've not chosen to post about any of your creation yet. It's only because, I haven't yet find any of that on the web. If i'll find one - and it seems interesting & useful. TheBATeam will definitely consider writing about it. But, that doesn't mean - i'll pre-agree with anyone before writing about my experience with batch and the plugin / creation.

And, the DarkBox is a great way to overcome the limitations of the batch. with fast & short way. So, whenevr we'll get time to write about it. I'll definately write about it. :)

I'm new to the community, and maybe - i'll not be that much active. But, everyone is doing their work honestly. And, everyone deserves respect. :) :wink: :wink: :wink:

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: darkbox - A Fast and Portable IO Console Server

#9 Post by aGerman » 13 Jun 2017 13:23

I was struggling whether or not to approve this post. I understand your irritation Kvc and I rather should have deleted Compo's post. I hope everything was said now.
This forum is not the place for personal discord. If this point needs further clarification please use Private Messaging.
Thank you!

Steffen

DQ2000
Posts: 38
Joined: 07 Aug 2019 17:26

Re: darkbox - A Fast and Portable IO Console Server

#10 Post by DQ2000 » 18 Dec 2019 05:56

Hi, how exactly does this work?

Post Reply