Professional Web Applications Themes

Help required - old (but "canonical") stuff - Mac Programming

I've recently entered an intense bout of nostalgia and digged up my old Mac Plus at my parents' house. To my great horror, I saw that I missed about 20% of my disks, sometimes it would be only one of a series of multiple disks for some games. Really frustrating. I'm trying to surpass what I did with the machine during my childhood by taking up the Inside Macintosh doentation and trying to program stuff in C. I've set up a webpage for my progress - it's only begun. Just forget the very simplistic design of the webpage - I ...

  1. #1

    Default Help required - old (but "canonical") stuff

    I've recently entered an intense bout of nostalgia and digged up my old
    Mac Plus at my parents' house. To my great horror, I saw that I missed
    about 20% of my disks, sometimes it would be only one of a series of
    multiple disks for some games. Really frustrating.

    I'm trying to surpass what I did with the machine during my childhood by
    taking up the Inside Macintosh doentation and trying to program stuff
    in C. I've set up a webpage for my progress - it's only begun. Just
    forget the very simplistic design of the webpage - I didn't and don't
    want to spend much time on it.

    68k.xt10.net

    I have a lot of questions about impasses I'm currently having right now.
    Some of it is simple, some of it is less. Here's a short first list:

    1) Hiding the menu bar altogether. I don't want to toggle it with
    mouse-overs, I want it gone. How? It should be really simple, but I'm
    having 0 success finding this simple information on the web or in my books.

    2) Opening a PICT file with the System 6 (and under) call "SFGetFile"
    (rather than "StandardGetFile"). I'm writing the value of what that
    function returns on the screen, and so far it's been negative codes.
    StandardGetFile (for System 7 and up) returns no values (it's a "pascal
    void" function).

    3) The philosophy behind implementing machine-independant timers - this
    will be essential for game programming. I don't want it to go too fast
    for more recent machines.

    4) Offscreen bitmaps/bitimages, or offscreen grafport. How do you do it
    with whatever is available in the first three Inside Macintosh books, if
    at all possible. Are GWorld stuff specific to System 7 and up? I don't
    want to use that. The most aggravating thing with the function
    DrawPicture, is that I've been unable to draw that image anywhere but on
    the screen. I would like to be able to deal with PICT resources, draw
    them offscreen on some bit images and then be able to use the fast
    CopyBits function as I wish.

    That is all for now. I hope there are some veteran programmers among
    myou. If not, well at least I might enjoy a public for my tests and games!
    MichaŽl Guest

  2. #2

    Default Help required - old (but "canonical") stuff

    I've recently entered an intense bout of nostalgia and digged up my
    old Mac Plus at my parents' house. To my great horror, I saw that I
    missed about 20% of my disks, sometimes it would be only one of a
    series of multiple disks for some games. Really frustrating.

    I'm trying to surpass what I did with the machine during my childhood
    by taking up the Inside Macintosh doentation and trying to program
    stuff in C. I've set up a webpage for my progress - it's only begun.
    Just forget the very simplistic design of the webpage - I didn't and
    don't want to spend much time on it.

    68k.xt10.net

    I have a lot of questions about impasses I'm currently having right
    now. Some of it is simple, some of it is less. Here's a short first
    list:

    1) Hiding the menu bar altogether. I don't want to toggle it with
    mouse-overs, I want it gone. How? It should be really simple, but I'm
    having 0 success finding this simple information on the web or in my
    books.

    2) Opening a PICT file with the System 6 (and under) call "SFGetFile"
    (rather than "StandardGetFile"). I'm writing the value of what that
    function returns on the screen, and so far it's been negative codes.
    StandardGetFile (for System 7 and up) returns no values (it's a
    "pascal void" function).

    3) The philosophy behind implementing machine-independant timers -
    this will be essential for game programming. I don't want it to go too
    fast for more recent machines.

    4) Offscreen bitmaps/bitimages, or offscreen grafport. How do you do
    it with whatever is available in the first three Inside Macintosh
    books, if at all possible. Are GWorld stuff specific to System 7 and
    up? I don't want to use that. The most aggravating thing with the
    function DrawPicture, is that I've been unable to draw that image
    anywhere but on the screen. I would like to be able to deal with PICT
    resources, draw them offscreen on some bit images and then be able to
    use the fast CopyBits function as I wish.

    That is all for now. I hope there are some veteran programmers among
    myou. If not, well at least I might enjoy a public for my tests and
    games!
    Mu0n Guest

  3. #3

    Default Re: Help required - old (but "canonical") stuff

    In article <3xQnc.81289$videotron.net>,
    Michael Juneau <ca> wrote:
     

    There are a few ways to do it. Availability and appropriateness varies
    with the OS release you're working under. For something that you're
    doing on a Plus, probably you're looking to mess with the MBarHeight
    system global.
     

    What kinds of negative codes?

     

    Look for info on something called the Time Manager.

     

    If you're on a Plus, you can at least use Volume 4 as well. But you
    don't need to for this. You allocate a GrafPort, set it as current, draw
    to your heart's content, and then use CopyBits to get it to the screen.
    You'll want to learn to use VBL interrupts to schedule your screen
    writes.
     

    Yep.
     

    By happenstance, I'm looking to get rid of my old Mac programming docs
    and am willing to part with them for the cost of shipping. In addition
    to listing a full set of IM on eBay, I've got - still unlisted - a few
    non-Apple books like Dave Mark's introductory books. They were excellent
    for their day.

    --
    Standard output is like your butt. Everyone has one. When using a bathroom,
    they all default to going into a toilet. However, a person can redirect his
    "standard output" to somewhere else, if he so chooses. - Jeremy Nixon
    Gregory Guest

  4. #4

    Default Re: Help required - old (but "canonical") stuff

    In article <3xQnc.81289$videotron.net>,
    Michael Juneau <ca> wrote:
     

    It isn't. I think a command for hiding the menu bar wasn't added until
    7.5 or so. Before that, you had to use GetMBarHeight() to measure the
    menu bar, calculate the rect based on the main screen rect, and then
    "punch it out" of the "gray region".
     

    No idea what you're talking about. You may want to show us some code.
    Though I have to admit I never really did any programming until I had
    7.0.
     

    Could you clarify? I usually just remember the time I last did
    something (GetTicks() or TickCount() or whatever it was called) and then
    did a compare, not doing anything if the most recent event was too
    recent. You can do this at idle time, or if that doesn't yield the
    correct performance, do it in a tight loop and call GetNextEvent() or
    WaitNextEvent() only every n-th time around.

    But on a Plus, any timing code you insert may already cause a slowdown
    that may be noticeable (this is from my memories of my first attempts at
    doing color graphics with an LC I, so maybe I just did something else
    wrong back then).
     

    That's a little tricky. You might want to look for old source code from
    that time. I think the Dartmouth XCMD collection HyperCard stack
    contained source code for XCMDs that created a GrafPort of their own and
    used that as an offscreen drawing canvas. But I barely remember that as
    I just used GWorlds instead.
     

    Well, veteran would be too much said for me, but I *did* come across
    the occasional bit of System 6 code.

    Cheers,
    -- Uli

    http://www.zathras.de
    Uli Guest

  5. Moderated Post

    Default Re: Help required - old (but "canonical") stuff

    Removed by Administrator
    Uli Guest
    Moderated Post

  6. #6

    Default Re: Help required - old (but "canonical") stuff

    Thanks to you two for your fast responses.

    1) I do have IM volume 4, also from one of the mid-eighties editions.

    2) Here's a source code of my attempt to use SFGetFile. Just overlook
    the "NewLoadMethod" which will attempt to use StandardGetFile. It's
    just not finished, or even started yet.

    "OldLoadMethod" simply brings up a SFGetFile dialog box, allows you to
    load PICT files and *should* draw it. I modified my code from the
    first time around (that old version is lost, unfortunately) but it
    seems now that it freezes somewhere in "OldLoadMethod" before it
    completes its execution.

    Source code in browser: http://68k.xt10.net/code/graphx6.c.txt
    Source code in a .sit file, along with a dummy PICT file:
    http://68k.xt10.net/files/SFGetFile.sit

    3) About what I'm trying to do with these "time managers" like you
    call them, is to simply produce "game events" where something happens
    every 1 second, for example, and I want it machine independant (of
    course if too much is computed on a Mac Plus, perhaps the program will
    miss its mark, but I'll be the manager of that).
    Mu0n Guest

  7. #7

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    You are looping, calling GetNextEvent. One of the fields of the
    EventRecord is the .when field, which is the number of ticks since the
    machine was booted. A tick is 1/60th of a second. The .when field will
    overflow eventually, but it is extremely unlikely that your Mac will be
    up that long, so don't worry about it.

    to schedule something for a second after now:

    target = TickCount() + 60;

    .....
    GetNextEvent(...
    HandleEvent(e);
    if(target < e.when){
    DoSomething();
    target = 0xFFFFFFFF;
    }
    David Guest

  8. #8

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    SFTypeList myFileTypes;
    myFileTypes[0]='PICT';

    I'm not sure (haven't got the headers here), but judging from other
    parts of the Classic Toolbox, SFTypeList is declared as OSType*,
    OSType[] or OSType[0]. Thus, you're probably stomping your stack here.
    Try:

    OSType[1] myFileTypes;
    myFileTypes[0] = 'PICT';

    Also, I'm not sure about the StdProcs stuff you are doing there. What is
    this trying to achieve? To draw a picture, you don't need it.

    Confused,
    -- Uli
    http://www.zathras.de
    Uli Guest

  9. #9

    Default Re: Help required - old (but "canonical") stuff

    David Phillip Oster <org> wrote in message news:<sf.sbcglobal.net>... 

    Ok, on the Mac Plus, events seem to follow that TickCount standard,
    where 60 ticks = 1 second. When I tried it in Basilisk II, events
    scheduled to trigger every second where going as fast as possible. My
    event was a SysBeep(1). I realize this function call behaves
    differently between these OS but there's clearly also a difference in
    the passage of time between these two environments. I don't think I'll
    support System 7 and up if it turns out to be too much of a hassle.
    Mu0n Guest

  10. #10

    Default Re: Help required - old (but "canonical") stuff

    Uli Kusterer <de> wrote in message news:<t-online.com>... 


    Did you mean OSType myFileTypes[1]?
    OSType[1] myFileTypes doesn't compile.

    Either way, that piece of the code works, because SFGetFile clearly
    only displays 'PICT' files in the file open dialog.

    Also, the customized Proc for reading or opening a PICT confuses me
    too; I tried to compile an example I took from the web. I can't find
    it again, but it looked a lot like what is described in this page of
    the online IM: http://developer.apple.com/doentation/mac/QuickDraw/QuickDraw-334.html#MARKER-9-60

    I tried commenting out everything related to this customized
    procedure, but it still doesn't work.
    Mu0n Guest

  11. #11

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     
    >
    > Ok, on the Mac Plus, events seem to follow that TickCount standard,
    > where 60 ticks = 1 second. When I tried it in Basilisk II, events
    > scheduled to trigger every second where going as fast as possible. My
    > event was a SysBeep(1). I realize this function call behaves
    > differently between these OS but there's clearly also a difference in
    > the passage of time between these two environments. I don't think I'll
    > support System 7 and up if it turns out to be too much of a hassle.[/ref]

    Supporting System 7 shouldn't be a hassle at all. Can you clarify what
    you tried to do and what you observed?

    --
    Standard output is like your butt. Everyone has one. When using a bathroom,
    they all default to going into a toilet. However, a person can redirect his
    "standard output" to somewhere else, if he so chooses. - Jeremy Nixon
    Gregory Guest

  12. #12

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    On some versions of the system, SysBeep(1) blocks until the sound
    completes. If you have a long sound, this will throw your timing off.
    David Guest

  13. #13

    Default Re: Help required - old (but "canonical") stuff

    Gregory Weston <com> wrote in message news:<comcast.net>...
     


    I'll illustrate with a compiled program.

    Source code in browser: http://68k.xt10.net/code/BeepClock.c.txt
    Program in .sit file: http://68k.xt10.net/files/BeepClock.sit

    Try it in both settings - press a key to exit the program. (emulator
    or real machines, both have worked on my end and reproduce the results
    listed below:)

    System 6: The program simply tries to emit a SysBeep(1) (shortest
    possible system "beep", I suppose) every 60 ticks. The exact condition
    is this one: whenever GetTick()/60 != 0 && GetTick()%60=0, so that it
    falls on round numbers of seconds. The short duration of SysBeep is
    there to ensure that the actual sound won't last longer than a second
    so as to not skip any second. I was worried the loop might sometimes
    erratically take more time and we would stop hearing a SysBeep(1) at
    some times, but it seems to be fairly solid.

    System 7: The system beep is whatever sound is set in the control
    panel. The program just seems to ignore how GetTick works and simply
    beeps as frequently as possible.
    Mu0n Guest

  14. #14

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     
    >
    >
    > I'll illustrate with a compiled program.
    >
    > Source code in browser: http://68k.xt10.net/code/BeepClock.c.txt
    > Program in .sit file: http://68k.xt10.net/files/BeepClock.sit
    >[/ref]
     

    By System 7, beeps were asynch, so the first time it hits "wutup.when %
    60 == 0", it beeps. That takes nearly no time at all (less than a tick)
    and so it comes back and since the time hasn't advanced more than a
    tick, it beeps a second time, and perhaps so on for third or fourth time
    as well. At some point, wutup.when % 60 isn't 0, but several beeps have
    been "queued up", and it'll come back to wutup.when % 60 == 0 before the
    beeps have completed from the first time through, it'll queue up some
    more, etc...


    How about something more like:

    nextTime = 0;
    while (!exitflag) {
    if (TickCount() > nextTime) {
    nextTime = TickCount() + 60;
    SysBeep(1);
    }
    GetNextEvent(everyEvent, &wutup);
    if (wutup.what == keyDown) break;
    }
    Glenn Guest

  15. #15

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    Uh, yes, sorry about that.
     

    I just Googled, and it looks like SFTypeList is defined as OSType[4],
    so I guess this is moot.

    But anyway, if it *had* been OSType[0] instead, it wouldn't have
    mattered whether you get only PICT files. You'd still have been stomping
    on stack space that didn't belong to you, and thus a crash happening
    later could have been triggered by that. That's why memory errors are so
    hard to fix. The point at which they happen may be a dozen lines (or
    even hours) later than the point at which the memory was cobbled in the
    first place.
     

    Wait, are you opening a PICT file, or what are you trying to do? PICT
    _resources_ are usually loaded by doing:

    PicHandle thePic = GetPicture(128);

    Where 128 is the ID number of whatever resource you want to load. Now
    you have a PicHandle that you can get rid of using KillPicture(), draw
    using DrawPicture() etc.

    What you have to watch out for here is that the "current resource file"
    must be set to the file containing your PICT. Your application's res
    fork is opened at startup by default, but if you're opening resource
    files of your own, you'll have to restore it later.

    If you're loading a PICT file, you have to skip past the 512 byte header
    every PICT file contains in its data fork. The StdProcs stuff is
    completely unnecessary in this case, AFAIK.

    Cheers,
    -- Uli
    http://www.zathras.de
    Uli Guest

  16. #16

    Default Re: Help required - old (but "canonical") stuff

    Uli Kusterer <de> wrote in message news:<t-online.com>...
     

    I've already successfully loaded up resource files and displayed
    pictures from them. I'm trying to do it with the data fork of pictures
    I've done in MacDraw or other similar programs. I know that there is a
    512 byte header that I have to skip, but for the life of me, I can't
    figure out why the code doesn't work. I've tried to simplify it as
    much as I could, and it never seems to work. The first thing I tried
    to do was to cut off that custom StdProcs thing, which in retrospect,
    I think it was done as a way to break the size limitations of PICT
    files (which is 32k IIRC).

    The crucial step in FSRead is to decide the kind of pointer to the
    reading buffer that you'll pass as an argument to FSRead. Should it be
    the address of a PicHandle? The address to a PicPtr? The address to a
    Picture?

    I've also tried to do the reverse: create a dummy "generic file" in
    which I'd write a string of text with FSWrite. It doesn't even work.

    Can someone out there write the shortest program they can that
    demonstrate FSOpen, FSRead and FSWrite? I'd be very grateful and it
    would restore my faith in mac C.

    Thanks! ;)
    Mu0n Guest

  17. #17

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    Can't get your old message to display right now, but you are using
    FSetPos() or whatever the call was named, with fsFromStart and a 512
    offset, right? And then you'd FSGetEOF() or FSGetLength() or
    FSGetLogicalEOF() or whatever it was called to get the file size, and
    read that many bytes -512.
     

    PicHandle itself may have a limit of 32k if you're doing Basic
    Quickdraw (as opposed to Color Quickdraw), which sounds like the case
    for a Mac Plus.
     

    You'll need to allocate a PicHandle of the proper size. A Handle is
    basically a pointer to a pointer (though not every pointer to a pointer
    is a Handle), so to use it like any other pointer, you'll have to
    de-reference it once. So *myPicHandle would be what you'd pass to FSRead
    if it takes a Ptr.
     

    You'll have to create the file and open it before you can write to it.
     

    I don't have the old MacOS headers anywhere in reach, but if you could
    provide me with the prototypes for the open/create/read/write/getlength
    etc. functions I could probably write something that should be very
    close to correct code.

    gone to memorize his lines now,
    -- Uli
    http://www.zathras.de
    Uli Guest

  18. #18

    Default Re: Help required - old (but "canonical") stuff

    In article <google.com>,
    ca (Mu0n) wrote:
     

    Are you sure those files are PICT files? MacDraw's native format was not
    PICT.
     

    WARNING: No compiler has ever seen this code.
    WARNING: I copy-pasted this from old archives.
    WARNING: this code will contain errors (missing #includes, at least)

    short OldFile()
    {
    SFTypeList myTypes;
    SFReply reply;
    short result = 0;
    Point where = {50, 50};
    myTypes[ 0] = 'TEXT';

    SFGetFile( where, "\pSelect a file", 0L, 1, myTypes, 0L, &reply);

    if( reply.good)
    {
    FSOpen( reply.fName, reply.vRefNum, &result);
    }
    return result;
    }

    int main( int argc, char * argv[])
    {
    int result = EXIT_FAILURE;
    const short file = OldFile();
    if( file != 0)
    {
    char buffer[ 20];
    long count = sizeof( buffer);
    // Real programs do error-checking here
    (void)SetFPos( file, fsFromStart, 0);
    (void)FSRead( file, &count, buffer);
    (void)SetFPos( file, fsFromStart, sizeof( buffer));
    (void)FSWrite( file, &count, buffer);
    (void)FSClose( file);
    result = EXIT_SUCCESS;
    }
    return result;
    }

    Reinder
    Reinder Guest

  19. #19

    Default Re: Help required - old (but "canonical") stuff

    Thanks for taking the time. I adapted and corrected your example,
    which, while very close to what I had attempted myself, still is a
    step in the right direction. Here is my adaptation:

    #include <Quickdraw.h>
    #include <Events.h>
    #include <Windows.h>
    #include <StandardFile.h>
    #include <OSUtils.h>

    #define EXIT_FAILURE 0
    #define EXIT_SUCCESS 1

    short OldFile(void);

    short OldFile()
    {
    SFTypeList myTypes;
    SFReply reply;
    short result=0;
    Point where={50,50};
    myTypes[0]='PICT';
    SFGetFile(where,"\pSelect a file",0L,1,myTypes,0L,&reply);
    if(reply.good)
    {
    FSOpen(reply.fName,reply.vRefNum,&result);
    }
    return result;
    }


    int main(int argc, char * argv[])
    {
    int result=EXIT_FAILURE;
    PicHandle myPicture;
    long count;
    WindowRecord mywin;
    WindowPtr mywinptr;
    Rect r,windowrect;
    EventRecord wutup;
    short file;

    InitGraf(&qd.thePort);
    InitWindows();
    InitCursor();

    windowrect=qd.screenBits.bounds;
    mywinptr=NewWindow(&mywin,&windowrect,"\p",true,2, (WindowPtr)-1,true,0);
    SetPort(mywinptr);
    FlushEvents(everyEvent,0);

    file=OldFile();
    if(file !=0)
    {
    count = sizeof(PicHandle);
    SetFPos(file,fsFromStart,512);
    FSRead(file,&count,*myPicture);
    FSClose(file);
    result=EXIT_SUCCESS;
    }
    HLock((Handle)myPicture);
    r=(*myPicture)->picFrame;
    DrawPicture(myPicture,&r);
    HUnlock((Handle)myPicture);

    while(!Button());
    }

    // The program doesn't display anything, but at least it doesn't crash
    (in other words, the behavior is similar to several of my own
    attempts).
    Mu0n Guest

  20. #20

    Default Re: Help required - old (but "canonical") stuff

    > I don't have the old MacOS headers anywhere in reach, but if you could 

    pascal OSErr FSOpen(ConstStr255Param fileName, short vRefNum, short
    *refNum);

    pascal OSErr Create(ConstStr255Param fileName, short vRefNum, OSType
    creator, OSType fileType);

    pascal OSErr FSWrite(short refNum, long *count, const void *buffPtr);

    pascal OSErr FSClose(short refNum);

    getlength doesn't exist, I assume you want the function to get the
    size of a structure or variable type? In all the examples I saw, they
    simply use the std C sizeof(variable type)
    Mu0n Guest

Page 1 of 3 123 LastLast

Similar Threads

  1. Acrobat 8 has twice failed to launch due to"required component was not found"
    By Gary_Gray@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 16
    Last Post: January 22nd, 06:58 PM
  2. #39712 [NEW]: Installation failure "Program Required"
    By kemputer at optushome dot com dot au in forum PHP Bugs
    Replies: 13
    Last Post: January 3rd, 02:41 PM
  3. Replies: 1
    Last Post: March 31st, 04:31 PM
  4. "A required resource cannot be loaded" - Problem Solved.
    By mmewhort@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: April 14th, 09:29 AM
  5. NEone getting spam: subject -->"Partnership required"?
    By Mercy in forum Microsoft Access
    Replies: 2
    Last Post: September 14th, 05:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139