home *** CD-ROM | disk | FTP | other *** search
- /*
- * Main entry point for MicroEmacs for the Macintosh. With MPW C,
- * this routine is set up as the main entry point, and placed in the
- * same segment as _DataInit(). It calls _DataInit() to initialize
- * the a5-based data, then sets up the size of the application heap,
- * and jumps to the real main routine. The main routine unloads this
- * segment, and all active segments are loaded into high memory, thus
- * reducing heap fragmentation. In addition, we lose _RTInit(),
- * _RTExit(), and exit(), thus saving about 1k of code.
- *
- * We do not use library routines with MPW, since we want to set up
- * the app heap before any other 'CODE' segments are loaded. Thus
- * the inlines.
- *
- * With the Aztec compiler, we do not gain as much as we do with
- * MPW C, since the data is in 'CODE' #1, but we do gain some
- * since we still get to call MaxApplZone() before library routines.
- *
- * Under LightSpeed, the utility of doing things this way is
- * questionable, but it probably doesn't hurt.
- */
- #ifdef macintosh
- #define MPWC
- #define MPW_COMPATIBLE
- #else
- #ifndef MPU68000
- #define LSC
- #else
- #define MPW_COMPATIBLE
- #endif
- #endif
- #ifdef MPW_COMPATIBLE
- #include <Resources.h>
- #include <QuickDraw.h>
- #include <Menus.h>
- #include <Fonts.h>
- #include <TextEdit.h>
- #include <Scrap.h>
- #include <Windows.h>
- #include <Dialogs.h>
- #define THEPORT qd.thePort
- #endif
- #ifdef LSC
- #include <ResourceMgr.h>
- #include <QuickDraw.h>
- #include <FontMgr.h>
- #include <WindowMgr.h>
- #include <MenuMgr.h>
- #include <DialogMgr.h>
- #define THEPORT thePort
- #endif
- #ifdef MPWC
- pascal void PopA0(adr)
- char *adr;
- extern 0x205f; /* move.l (a7)+,a0 */
- pascal void _SetApplLimit()
- extern 0xA02D;
- pascal void romMaxApplZone()
- extern 0xA063;
- pascal void JMPA0() /* jmp (a0) */
- extern 0x4ED0;
- pascal void UNLKA6() /* unlk a6 */
- extern 0x4E5E;
- #define SetApplLimit(a) PopA0(a);_SetApplLimit();
- #define jump(a) PopA0(a);JMPA0();
- #define __SEG__ %A5Init
- #endif
- #ifdef MPU68000
- pascal void romMaxApplZone() = 0xA063;
- #endif
- #ifdef LSC
- #define Croot main
- #endif
- #ifndef IS_64K_ROM
- #define IS_64K_ROM ((*((short *) 0x28E) & 0xF000) == 0xF000)
- #endif
- Croot() /* <<-- Entry. */
- {
- int i;
- extern maineventloop();
- extern exit();
- #ifdef MPWC
- _DataInit(); /* All after this is defined as InLine macros. */
- #endif
- ReleaseResource(GetResource('CODE',0));
- #ifdef MPU68000
- #asm /* LightSpeed C stinks! */
- lea -20480(a7),a0
- dc.w $a02d ; SetApplLimit
- #endasm
- #else
- SetApplLimit((char *)&i- 20480); /* Program needs stack! */
- #endif
- #ifdef MPW_COMPATIBLE
- if(IS_64K_ROM){
- MaxApplZone();
- }else{
- romMaxApplZone(); /* Heap, too! */
- }
- #else
- MaxApplZone();
- #endif
- InitGraf(&THEPORT);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(exit);
- InitCursor();
- LoadScrap();
- #ifdef MPWC
- UNLKA6(); /* Fix up stack. */
- jump(maineventloop); /* Bye, bye. */
- #else
- maineventloop();
- #endif
- }
-
-