Thread: Converting MINI-BASIC in MASM over to C++?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Sounds good.

    Paul

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I haven't done much in the past couple of days, but I'll get back onto project soon, and hopefully have things worked out by the end of the week.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'm working, or was working, on it too.

    I'm almost positive I really do have the environment, size, and attribute issues fixed. (I wrote a simple driver to change the console to random sizes, and dump text with random colors which so far seems to "just work" and returns the console to the original state--minus the actual text.)

    I think I've patched a couple of other API bugs I noticed. (It is hard to be sure because I use a very thin US locale Windows XP environment.)

    I've separated the interpreter logic, the various "mini-basic" expansions and expectations, the editor logic, and the actual platform logic into separate chunks. (A few separate classes with simple abstractions. It certainly isn't my best work, but it is by far and away better than the original.)

    I've added the command "ALIAS" to the interpreter to support variable names. (Mechanically backed by a different approach to individual operations based on the simple fact that "simplify_expression"--replacing "EvalExpr" and various other bits--is always called before the line is otherwise parsed.)

    I've actually setup a few hooks so that it actually supports extensions without knowing how absolutely everything works. (I wanted to keep it reasonably simple; this too is by far from my best work, but you could actually add overloads and extensions without, more or less, having to rewrite everything.)

    I've also giving the source a general "spit and polish" dropping the crazy use of jumps, adding some targeted exceptions, and simplifying a few of the functions with extra support routines.

    What I've not done is added *all* of Sebastiani and matsp work back into the mix--just bits and pieces.

    Unfortunately, a friend of mine, a DBA monkey, is in a living nightmare of a recovery and I've lent him the time I had been spending on this.

    That said, you can stop finding reasons to bump this thread; what time I've spent on it was a game--I'm sure the others have similar reasons. If we want to stop working on it, we will; bumping the thread will not change that. If we don't want to stop working on it, we aren't going to forget about it. So... relax. You could, instead of pointlessly bumping the thread, actually help by rewriting the documentation--which according to you is simply wrong.

    Also, you two, I have something to discuss with you, but I've just run out of time... and in a truly bashworthy way. I'll try to get around to it later... with your permission of course.

    Soma

  4. #4
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Ok, I promise not to bump this post in the future. Thanks for the advice.

    Paul

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    The window command? What's the format?

    Paul

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Window width_expression, height_expression
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #7
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    NOTE: My machine has been behaving funny all afternoon. I'm going to run my magic disc on it tomorrow after I pull some stuff off the harddrive. With this in mind, please, please, don't download this if you don't have anti-virus/spyware running.

    Maybe the best approach [...] detect the current window size at startup.
    That's the approach I've taken.

    I think it was you Sebastiani that had the setup that refused the original resize source. Do you think you can try this? Actually, could a few people try it and let me know if it dumps an exception--to `std::clog'. (It doesn't on my machine, but that's a poor measure.)

    This should change the size several times and restore the console to the state it was in, minus the text, before the thing is executed.

    Soma

    [This is a UPX compressed executable. To be honest, I'm a little ashamed of the hackish approach I've used to glue some bits together and don't want it seen yet. ^_^;]

    [Yea, I forgot to include the bloody file.]

  8. #8
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Question about the source code: is it C++ or C?

    Paul

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Question about the source code: is it C++ or C?

    Paul
    I haven't seen the latest code, but what I wrote was nearly all C, with a small amount of C++ style to it.

    If we can get a consolidated source code, I'd like to have a look at making it more C++-style.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> NOTE: My machine has been behaving funny all afternoon. I'm going to run my magic disc on it tomorrow after I pull some stuff off the harddrive. With this in mind, please, please, don't download this if you don't have anti-virus/spyware running.

    Are you suggesting that I run a program built on a machine that may have a virus?

    >> To be honest, I'm a little ashamed of the hackish approach I've used to glue some bits together and don't want it seen yet.

    Nothing to be ashamed of. We can clean things up near then end. Go on and post what you have. Oh and by the way, I've been working some I/O issues myself. If you haven't resolved all of that yet (ie: handling special keys such as home, end, arrows, backspace, etc), let me know and I'll post that code as well. It's not incorporated into the main code yet, as I was testing all of that in a separate program...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  11. #11
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    That's fine with me. It would certainly be more streamlined, since we would have the STL at our disposal.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  12. #12
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    On the other hand, we should probably finish what we've already started before moving on to making it fully C++.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #13
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Sebastiani View Post
    On the other hand, we should probably finish what we've already started before moving on to making it fully C++.
    Agreed.

    I haven't done anything lately.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  14. #14
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    What's the difference between C and C++? I've always wondered.

    Paul

  15. #15
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    What's the difference between C and C++? I've always wondered.

    Paul
    In one way, not a lot. In another way, lots.

    The big difference comes with the philosophy behind the language, C++ is an object oriented language. C is a procedural langues, and not intended as an object oriented language (although it can technically be hammered into something that resembles object orientation).

    C++ is based on C, which means most C code can be compiled as C++, but "proper" C++ can not be compiled in a C compiler.



    To understand more of the differences, you probably need a better understanding of at least ONE of the languages.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting textBox1->Text into a basic string.
    By azjherben in forum C++ Programming
    Replies: 5
    Last Post: 06-07-2009, 08:27 PM
  2. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  3. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  4. VC++ 6 & MASM (eek)
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 07-16-2005, 10:00 AM