Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Trying to understand snake.bat's realtime input system  (Read 4169 times)

0 Members and 1 Guest are viewing this topic.

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Trying to understand snake.bat's realtime input system
« on: April 01, 2014, 09:28:45 PM »
So I've been pondering this for quite a while, but I still cannot figure out how the real time input works in snake.bat.  If anyone understands it and would be willing to walk me though it's process, It would be much appreciated.

Link to snake.bat: http://www.dostips.com/forum/viewtopic.php?f=3&t=4741
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Trying to understand snake.bat's realtime input system
« Reply #1 on: April 01, 2014, 10:03:37 PM »
Maybe you should explain this:
Quote
real time input works
Batch programs do not have real time input.
They are batch programs.
By definition they are background tasks.

Explain what you think the program does. Then we can focus on just that little bit of code that does what you describe. That code is much to large to post here. Tell us what you think it does and somebody here with exact the few lines of code that do what you think it does.


foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Trying to understand snake.bat's realtime input system
« Reply #2 on: April 01, 2014, 11:18:09 PM »
It uses xcopy and a feature where the character is echoed, and that character is extracted to tell which character was pressed.

Post in the snake.bat thread and Dave is most often happy to answer specific questions

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: Trying to understand snake.bat's realtime input system
« Reply #3 on: April 02, 2014, 06:13:40 AM »
Post in the snake.bat thread and Dave is most often happy to answer specific questions
Agreed.  Why not go straight to the source and ask the question.

dbenham



    Greenhorn

    Thanked: 3
    • Experience: Expert
    • OS: Windows 7
    Re: Trying to understand snake.bat's realtime input system
    « Reply #4 on: November 23, 2014, 09:11:42 PM »
    The XCOPY input hack is not that complex. If you study the code and run some experiments, you should be able to figure it out.

    The interesting bit is how the game uses multiple processes and communicates between them via files. This is the critical design that allows the input to be non-blocking. See http://www.dostips.com/forum/viewtopic.php?p=31035#p31035 for a high level explanation of the inter-process communication.


    Dave Benham
    Dave Benham