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

  1. #106
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Simply "growing" to fit every situation is wasteful.

    How so? When the program starts up, all buffers are empty. The user requests @(20). The buffer grows. Now, if the user only indexes up to 20 into the buffer during the entire execution of the program, then the buffer stays the same size, so no memory is wasted. It seems very efficient to me.
    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;
    }

  2. #107
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> where `poke_buffer[$]' may alter the source during execution, the interpreter, the integers, the integer array, and even the "play area" that it is supposed to poke.

    That's a novel idea (and certainly in keeping with the traditional behavior), but it's just insane. For one thing, it violates basic principles of writing robust software. If the user does something stupid, and the program mysteriously crashes, there won't be any way to detect why (unless you propose writing a debugger for it, too). Second, it could possibly introduce security-related issues (ie: a user loads a program that causes a heap or stack overflow, etc). I would rather have complete control of the interpreter at all times, and be able to produce intelligent responses to invalid conditions...
    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. #108
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Honestly?

    I'm thinking back to my days with "RPG Maker 2000" and "$ BASIC". ("RPG Maker 2000" was a wonderful toy. I'm saying it, and I knew C++ very well even then. Actually, it is still a wonderful toy. I can't remember the BASIC variant simply because I've been exposed to so many.)

    With both environments you had a limited number of variables available. (The BASIC variant having 5000 integers and 5000 reals for absolutely everything.) The thing is, at the time, there was a huge community. If you needed something cool, say a "Legend of Zelda" style menu or a nice live "HUD", chances our someone, probably me, had already written it. With the available memory so small you had to squeeze every last drop out of the variables, but even then, some stuff just needs a few variables. We did what we could and made a simple registry ("SUCH_AND_SUCH_MENU_SYSTEM:2210-2212"). I'm thinking of situations like that: where some downloaded source uses two or three high variables even though the client only uses the lowest thirty.

    Granted, with such small memory requirements, for 2000 `int32_t', it doesn't really matter.

    If the user does something stupid, and the program mysteriously crashes, there won't be any way to detect why (unless you propose writing a debugger for it, too).
    ^_^

    You mean, like C++?

    Soma

  4. #109
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Whatever the language. I'm saying that just like you don't use gets( ), or access raw memory specified from user input, or make SQL queries from data retrieved from HTML forms, or anything else that has not been completely validated by your program. It just creates unnecesarry problems. That's all.
    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;
    }

  5. #110
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    And by the way, your BASIC story was quite interesting. I never have had, erm, the honor of using the venerable language myself, but I can imagine it must have seemed fairly useful, at the time.
    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;
    }

  6. #111
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    Whatever the [...] unnecesarry problems.
    One of the reasons I like C++ is because it let's me do exactly what I want. If I blow my leg... my fault. You're just saying that you want a tool, in this case the interpreter, to prevent you from screwing up. When I'm not exploiting something, I'm right there with you; I want my tools to make my job easier. I'm not arguing with *anything* you're saying.

    I never have had, erm, the [...] useful, at the time.
    ^_^

    I don't think I've ever considered it actually useful. At the time, I didn't have any options for GUI beyond the WIN32API--which I will always hate with a passion. I could have my ideas fleshed out with such toys before I could get off the ground with C++ and the WIN32API. Ethck, the "message pump" alone is a bloody nightmare!

    Soma

  7. #112
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> WIN32API-- which I will always hate with a passion

    Yeah. It still makes my skin crawl and blood boil when I have to use any MS API. TAPI was one of my all time worst experiences, come to think of it. Data structures with countless members, all requiring complex initialization logic. I still have nightmares about it.

    >> the "message pump" alone is a bloody nightmare!

    Event driven systems are supposed to be more logical than procedural ones, but the WIN32 paradigm just makes things complicated. I have always wondered who came up with that system, and why!
    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;
    }

  8. #113
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Windows API is tricky sometimes. It can lead to Windows API failures. I don't know if that is a program error specifically or a problem with Windows itself.

    Paul

  9. #114
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by Sebastiani View Post
    >> To make it "binary compatible" with the existing assembly code, I think reading documentation may not be sufficient.

    Good point.
    That's true.

    Paul

  10. #115
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Just wanted to update everyone on where I'm at. So far, I've implemented LOCATE, GOTO, GOSUB, RETURN, IF, STOP, BEEP, POKE, PEEK, ABS, and RND, and right now I'm working on the FOR/NEXT construct. The one thing I haven't touched, and know for a fact doesn't work properly is keyboard input (arrow keys, backspace, etc).
    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. #116
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Ok, thanks for the update. Good luck with it.

    Paul

  12. #117
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by Sebastiani View Post
    >> Simply "growing" to fit every situation is wasteful.

    How so? When the program starts up, all buffers are empty. The user requests @(20). The buffer grows. Now, if the user only indexes up to 20 into the buffer during the entire execution of the program, then the buffer stays the same size, so no memory is wasted. It seems very efficient to me.
    That's true. The buffer is like that.

    Paul

  13. #118
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Getting close.

    It definitely still has some bugs to work out (right now it just hangs at the opening screen - possibly an input related problem), but it's coming along...
    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;
    }

  14. #119
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Looking good! Keep up the good work!

    Paul

  15. #120
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by phantomotap View Post
    Honestly?

    I'm thinking back to my days with "RPG Maker 2000" and "$ BASIC". ("RPG Maker 2000" was a wonderful toy. I'm saying it, and I knew C++ very well even then. Actually, it is still a wonderful toy. I can't remember the BASIC variant simply because I've been exposed to so many.)

    With both environments you had a limited number of variables available. (The BASIC variant having 5000 integers and 5000 reals for absolutely everything.) The thing is, at the time, there was a huge community. If you needed something cool, say a "Legend of Zelda" style menu or a nice live "HUD", chances our someone, probably me, had already written it. With the available memory so small you had to squeeze every last drop out of the variables, but even then, some stuff just needs a few variables. We did what we could and made a simple registry ("SUCH_AND_SUCH_MENU_SYSTEM:2210-2212"). I'm thinking of situations like that: where some downloaded source uses two or three high variables even though the client only uses the lowest thirty.

    Granted, with such small memory requirements, for 2000 `int32_t', it doesn't really matter.



    ^_^

    You mean, like C++?

    Soma
    I recall RPG maker 2000. It was a fun program to play around with and develop games with. I still have fond memories of designing maps for a game. Unfortunately, I never finished it.

    Paul

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