home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / casm_sam.sit < prev    next >
Encoding:
Text File  |  1988-05-14  |  11.1 KB  |  469 lines

  1. 11-May-88 21:25:21-MDT,7689;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:25:10 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA03775; Wed, 11 May 88 21:25:45 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA29283; Wed, 11 May 88 21:25:42 MDT
  8. Date: Wed, 11 May 88 21:25:42 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8805120325.AA29283@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: SEPict.asm.shar
  13.  
  14. #--------------------------------CUT HERE-------------------------------------
  15. #! /bin/sh
  16. #
  17. # This is a shell archive.  Save this into a file, edit it
  18. # and delete all lines above this comment.  Then give this
  19. # file to sh by executing the command "sh file".  The files
  20. # will be extracted into the current directory owned by
  21. # you with default permissions.
  22. #
  23. # The files contained herein are:
  24. #
  25. #    3 SEPict.a
  26. #    3 SEPict.r
  27. #
  28. echo 'Extracting SEPict.a.'
  29. if test -f SEPict.a; then echo 'shar: will not overwrite SEPict.a'; else
  30. sed 's/^X//' << '________This_Is_The_END________' > SEPict.a
  31. X        TITLE            'SEPict - show the pictures in the SE ROM'
  32. X        
  33. X        INCLUDE         'Traps.a'
  34. X        INCLUDE         'ToolEqu.a'
  35. X        INCLUDE         'QuickEqu.a'
  36. X        INCLUDE         'SysEqu.a'
  37. X
  38. XReadyAlert                EQU        1000
  39. XNotAnSEAlert            EQU        1001
  40. XmyNoButton                EQU           1
  41. XmyOKButton                EQU           2
  42. XmDownMask                EQU           2
  43. XkeyDownMask                EQU           8
  44. X
  45. XPoint            RECORD            0
  46. Xv                DS.W            1
  47. Xh                DS.W            1
  48. X                ENDR
  49. X
  50. XEventRecord     RECORD            0
  51. Xwhat            DS.W            1
  52. Xmessage         DS.L            1
  53. Xwhen            DS.L            1
  54. Xwhere            DS.L            Point
  55. Xmodifiers        DS.W            1
  56. X                ENDR
  57. X
  58. XGlobalData        RECORD
  59. XmyEvent         DS.L            EventRecord
  60. X                ENDR
  61. X
  62. X        
  63. X; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  64. X
  65. XSEPict            MAIN
  66. X                WITH            GlobalData
  67. X
  68. X        PEA             -4(A5)
  69. X        _InitGraf
  70. X        _InitFonts
  71. X        MOVE.L            #$0000FFFF,D0
  72. X        _FlushEvents
  73. X        _InitWindows
  74. X        _InitMenus
  75. X        _TEInit
  76. X        PEA                TheEnd
  77. X        _InitDialogs
  78. X        _InitCursor
  79. X
  80. X        CLR.L            D7
  81. X        MOVE            ROMMapInsert,D7        ; save this away...
  82. X
  83. X        MOVE.L            ROMBase,A0            ; the pointer to ROM
  84. X        MOVE            8(A0),D0            ; the signature bytes
  85. X        CMPI            #$0276,D0            ; this is the SE, no...
  86. X        BNE.S            Oops
  87. X        
  88. X        MOVE.W            #0,-(A7)            ; WE ARE ON A MAC SE HERE!!!
  89. X        MOVE            #ReadyAlert,-(A7)
  90. X        MOVE.L            #0,-(A7)
  91. X        _CautionAlert
  92. X        MOVE.W            (A7)+,D0
  93. X        
  94. X        CMPI            #myNoButton,D0
  95. X        BEQ.S            TheEnd
  96. X        MOVE            #-1,ROMMapInsert
  97. X        
  98. X        JSR                GetTheWidget
  99. X        
  100. XMainLoop
  101. X        ADDQ.W            #4,D6
  102. X        ANDI.L            #$0000000C,D6        ; number MOD 12
  103. X        JSR                DisplayOnePict
  104. X        
  105. X        MOVEA.W            #120,A0
  106. X        _Delay
  107. X
  108. X        BRA.S            MainLoop
  109. X
  110. XOops
  111. X        CLR.W            -(A7)
  112. X        MOVE            #NotAnSEAlert,-(A7)
  113. X        MOVE.L            #0,-(A7)
  114. X        _StopAlert
  115. X        MOVE.W            (A7)+,D0
  116. X
  117. XTheEnd
  118. X        MOVE            D7,ROMMapInsert        ; restore the state...
  119. X        _ExitToShell
  120. X        
  121. X; ---------------------------------------------------------------------------------
  122. X
  123. XCheckEvents
  124. X        CLR.W            -(A7)                ; function result
  125. X        MOVE            #mDownMask+keyDownMask,-(A7)
  126. X        PEA                myEvent                ; a place to put the pointer to the event Record
  127. X        _GetNextEvent
  128. X        MOVE            (A7)+,D0
  129. X        BNE.S            TheEnd
  130. X        RTS
  131. X        
  132. X; ---------------------------------------------------------------------------------
  133. X
  134. XGetTheWidget
  135. X        SUBQ.W            #4,A7
  136. X        MOVE.L            #'bbmc',-(A7)
  137. X        CLR.W            -(A7)
  138. X        _GetResource
  139. X        MOVE.L            (A7)+,D0
  140. X        BEQ.S            TheEnd
  141. X        MOVEA.L            D0,A0
  142. X        MOVE.L            (A0),ApplScratch+0
  143. X        MOVEQ            #0,D6
  144. X        RTS
  145. X        
  146. X; ---------------------------------------------------------------------------------
  147. X
  148. XDisplayOnePict
  149. X        _HideCursor
  150. X        
  151. X        MOVE.L            ApplScratch+0,A0
  152. X        ADDA.W            D6,A0
  153. X        MOVE.L            (A0),D3
  154. X        MOVE.L            ApplScratch+0,ApplScratch+4
  155. X        ADD.L            D3,ApplScratch+4
  156. X        MOVE.L            ScrnBase,ApplScratch+8
  157. X        MOVE.L            #340,D3
  158. X@1
  159. X        PEA                ApplScratch+4
  160. X        PEA                ApplScratch+8
  161. X        MOVE.W            #72,-(A7)
  162. X        _UnpackBits
  163. X        
  164. X        BSR.S            CheckEvents
  165. X        SUBQ.L            #8,ApplScratch+8
  166. X        
  167. X        DBRA            D3,@1
  168. X
  169. X        PEA                ApplScratch+4
  170. X        PEA                ApplScratch+8
  171. X        MOVE.W            #64,-(A7)
  172. X        _UnpackBits
  173. X        
  174. X        _ShowCursor
  175. X        
  176. X        RTS
  177. X        
  178. X; ---------------------------------------------------------------------------------
  179. X
  180. X        END
  181. X
  182. ________This_Is_The_END________
  183. if test `wc -l < SEPict.a` -ne 151; then
  184.     echo 'shar: SEPict.a was damaged during transit'
  185.   echo '      (should have been 151 bytes)'
  186. fi
  187. fi        ; : end of overwriting check
  188. echo 'Extracting SEPict.r.'
  189. if test -f SEPict.r; then echo 'shar: will not overwrite SEPict.r'; else
  190. sed 's/^X//' << '________This_Is_The_END________' > SEPict.r
  191. X#include "Types.r"
  192. X
  193. Xresource 'ALRT' (1000, "Warning") {
  194. X    {66, 112, 270, 398},
  195. X    1000,
  196. X    {    /* array: 4 elements */
  197. X        /* [1] */
  198. X        OK, visible, sound1,
  199. X        /* [2] */
  200. X        OK, visible, sound1,
  201. X        /* [3] */
  202. X        OK, visible, sound1,
  203. X        /* [4] */
  204. X        OK, visible, sound1
  205. X    }
  206. X};
  207. X
  208. Xresource 'ALRT' (1001, "Not an SE") {
  209. X    {40, 40, 144, 280},
  210. X    1001,
  211. X    {    /* array: 4 elements */
  212. X        /* [1] */
  213. X        OK, visible, sound1,
  214. X        /* [2] */
  215. X        OK, visible, sound1,
  216. X        /* [3] */
  217. X        OK, visible, sound1,
  218. X        /* [4] */
  219. X        OK, visible, sound1
  220. X    }
  221. X};
  222. X
  223. Xresource 'DITL' (1000, "Warning") {
  224. X    {    /* array DITLarray: 4 elements */
  225. X        /* [1] */
  226. X        {168, 32, 192, 104},
  227. X        Button {
  228. X            enabled,
  229. X            "Quit"
  230. X        },
  231. X        /* [2] */
  232. X        {136, 32, 160, 104},
  233. X        Button {
  234. X            enabled,
  235. X            "Show me"
  236. X        },
  237. X        /* [3] */
  238. X        {8, 64, 128, 256},
  239. X        StaticText {
  240. X            disabled,
  241. X            "This program displays some interesting t"
  242. X            "hings that the Macintosh SE design team "
  243. X            "built into the ROM of the SE.\n\nClick the"
  244. X            " mouse or press a key to return to the F"
  245. X            "inder..."
  246. X        },
  247. X        /* [4] */
  248. X        {136, 144, 172, 253},
  249. X        Picture {
  250. X            enabled,
  251. X            1000
  252. X        }
  253. X    }
  254. X};
  255. X
  256. Xresource 'DITL' (1001, "Not an SE") {
  257. X    {    /* array DITLarray: 2 elements */
  258. X        /* [1] */
  259. X        {64, 136, 88, 208},
  260. X        Button {
  261. X            enabled,
  262. X            "Sorry"
  263. X        },
  264. X        /* [2] */
  265. X        {8, 64, 48, 232},
  266. X        StaticText {
  267. X            enabled,
  268. X            "This program only runs on a Macintosh SE"
  269. X            "."
  270. X        }
  271. X    }
  272. X};
  273. X
  274. Xresource 'PICT' (1000) {
  275. X    460,
  276. X    {169, 140, 205, 249},
  277. X    $"1101 0100 0A00 A900 8C00 CD00 F998 0010"
  278. X    $"00A9 0088 00CD 0100 00A9 008C 00CD 00F9"
  279. X    $"00A9 008C 00CD 00F9 0000 0501 001C F300"
  280. X    $"0501 0038 F300 0501 0030 F300 0B07 03AE"
  281. X    $"0820 2440 0040 F900 0B07 07DF 0820 0440"
  282. X    $"0040 F900 0C08 0FFE 054B 6EE6 7072 40FA"
  283. X    $"000C 080F FC05 4C24 4948 4A40 FA00 0C08"
  284. X    $"0FFC 0288 244F 484A 40FA 000C 080F FC02"
  285. X    $"8824 4848 4A40 FA00 0C08 0FFE 0288 2226"
  286. X    $"4871 C0FA 0009 010F FFFB 0000 40FA 000A"
  287. X    $"0107 FFFC 0001 0180 FA00 0501 03FE F300"
  288. X    $"0501 01DC F300 02F1 000C 0800 0007 1000"
  289. X    $"0041 0360 FA00 0C08 0000 0890 0000 6301"
  290. X    $"20FA 000D 0900 0008 3991 3055 3126 58FB"
  291. X    $"000D 0900 0007 124A 4849 0929 60FB 000C"
  292. X    $"FE00 0693 CA78 4139 2F40 FB00 0D09 0000"
  293. X    $"0892 0440 4149 2840 FB00 0D09 0000 0709"
  294. X    $"8430 4139 2640 FB00 02F1 0002 F100 02F1"
  295. X    $"0002 F100 02F1 0010 0C00 0001 0006 0070"
  296. X    $"0000 0200 0010 FE00 100C 0000 0100 0200"
  297. X    $"8800 0002 0000 10FE 0011 0D00 0002 9CE2"
  298. X    $"6081 9D9C 9732 C017 18FF 0011 0D00 0002"
  299. X    $"9292 9082 5252 924B 0014 A4FF 0011 0D00"
  300. X    $"0007 D292 F082 5252 927A 0014 A0FF 0011"
  301. X    $"0D00 0004 5292 808A 5252 9242 0014 A4FF"
  302. X    $"0011 0F00 0004 5CE2 6071 925C 7132 0414"
  303. X    $"9880 000E FE00 0110 80FE 0003 1000 0004"
  304. X    $"FD00 0EFE 0001 1080 FE00 0310 0000 08FD"
  305. X    $"00FF"
  306. X};
  307. X
  308. X
  309. ________This_Is_The_END________
  310. if test `wc -l < SEPict.r` -ne 118; then
  311.     echo 'shar: SEPict.r was damaged during transit'
  312.   echo '      (should have been 118 bytes)'
  313. fi
  314. fi        ; : end of overwriting check
  315. exit 0
  316. 11-May-88 21:25:45-MDT,4021;000000000000
  317. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  318. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:25:40 MDT
  319. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  320.     id AA03863; Wed, 11 May 88 21:26:17 MDT
  321. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  322.     id AA29290; Wed, 11 May 88 21:26:14 MDT
  323. Date: Wed, 11 May 88 21:26:14 MDT
  324. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  325. Message-Id: <8805120326.AA29290@sunset.utah.edu>
  326. To: rthum@simtel20.arpa
  327. Subject: SampleINIT.asm.c
  328.  
  329. /*
  330.         SampleInit.c
  331.         April 22, 1988
  332.         Written by Juri Munkki
  333.  
  334.         This source code is in the public domain.
  335.         The author makes no guarantees.
  336.  
  337. Instructions
  338.  
  339.     I wrote this INIT as a sample to one of my clients.
  340.     They wished to monitor what the user does and generate
  341.     statistics on frequently used actions.
  342.     
  343.     This INIT does nothing useful. It modifies GetNextEvent
  344.     so that instead of returning autoKey events with the
  345.     spacebar, the # character is returned. It should be
  346.     quite a surprise to people who are used to using spaces
  347.     instead of tabs. :-) The INIT has no effect on DAs.
  348.  
  349.     You should have Lightspeed C to use this INIT. The
  350.     structure of an INIT depends highly on the development
  351.     system being used. Lightspeed C places global data
  352.     storage after the program code. This means that you
  353.     can't have more than 32K of code AND static variables.
  354.         
  355.     The INIT resource itself should have the "System Heap"
  356.     flag set or it will bomb sooner or later. (usually soon)
  357.  
  358.     Please remember to put a 'sysz' resource into your
  359.     INIT, if you're going to need a lot of space. Also
  360.     remember that any dynamic storage that should live
  361.     through launches should be in the system heap.
  362.     
  363.     I hope this helps those who are desperately trying to
  364.     patch the system.
  365.     
  366.         Juri Munkki
  367.         jmunkki@santra.hut.fi
  368.         jmunkki@fingate.bitnet
  369. */
  370.  
  371. #include <MacTypes.h>
  372. #include <OSUtil.h>
  373. #include <EventMgr.h>
  374.  
  375. #define  NextEventNum    0x970
  376.  
  377.         long    OldNextEvent;
  378.         long    ticker;
  379.     EventRecord    *theEvent;
  380.  
  381. void    DoEvent(doIt)
  382. int            doIt;
  383. {
  384.     if(doIt)
  385.         if(theEvent->what==autoKey)
  386.             if((theEvent->message & 0xFF) == ' ')
  387.                 theEvent->message+='#'-' ';
  388. }
  389.  
  390. void        NewGetEvent()
  391. {
  392. asm    {
  393.     move.l    (sp)+,A0    /*    Return address            */
  394.     move.l    (sp)+,A1    /*    Pointer to an EventRecord    */
  395.     move.w    (sp)+,D0    /*    EventMask            */
  396.  
  397.     move.l    A0,-(sp)    /*    Push return address for RTS    */
  398.     move.l    A4,-(sp)    /*    Save A4.            */
  399.     move.l    @1,A4        /*    Set A4 (static base reg)    */
  400.  
  401.     move.l    A1,theEvent    /*    Save the ER pointer        */
  402.  
  403.     clr.w    -(sp)        /*    Space for returned value    */
  404.     move.w  D0,-(sp)    /*    Push EventMask            */
  405.     move.l    A1,-(sp)    /*    Push ER pointer            */
  406.     move.l    OldNextEvent,A0    /*    Get ready to jsr        */
  407.     jsr    (A0)        /*    Do the old GetNextEvent        */
  408.     move.w    (sp),10(sp)    /*    Result to REAL result.
  409.                     Leave the result in the stack
  410.                     as a parameter for DoEvent    */
  411.     jsr    DoEvent        /*    Do our stuff            */
  412.     addq.l    #2,sp        /*    Remove parameter        */
  413.     move.l    (sp)+,A4    /*    Restore A4            */
  414.     rts
  415.  
  416.     @1    nop        /*    "Variable" space        */
  417.     }
  418. }
  419. /*    Save base reg at the end of the previous routine.
  420. **    This is clearly a kludge...
  421. */
  422. void    sa0()
  423. {
  424. asm    {
  425. @0    lea    @0-4,A1    
  426.     move.l    A0,(A1)
  427.     }
  428. }
  429. /*    Would you like to close a file before the system
  430. **    goes down? Would you like to play a sound before
  431. **    rebooting? This is where you place the code.
  432. */
  433. void    MyShutDown()
  434. {
  435.     SysBeep(10);
  436.     SysBeep(10);
  437. }
  438. /*    This part gets called once. It saves the pointer
  439. **    to us (our static storage), installs the patch and
  440. **    puts us in the shutdown queue.
  441. */
  442. void    main()
  443. {
  444.     Handle        myhandle;
  445.  
  446.     sa0();
  447. asm    {    movem.l        A0-A4,-(A7)
  448.         move.l        A0,A4
  449.         _RecoverHandle
  450.         move.l        A0,myhandle
  451.     }
  452.     if(Button())
  453.         SysBeep(10);    /*    Beep, if install was cancelled    */
  454.     else
  455.     {    DetachResource(myhandle);
  456.         HLock(myhandle);
  457.  
  458.         OldNextEvent=NGetTrapAddress(NextEventNum,ToolTrap);
  459.         NSetTrapAddress(NewGetEvent,NextEventNum,ToolTrap);
  460.  
  461.         ShutDwnInstall(MyShutDown,8);
  462.     }
  463.  
  464. asm    {    movem.l        (A7)+,A0-A4        }
  465. }
  466.     /*        File ends here!        */
  467.  
  468.  
  469.