home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC15CDevSamples / Assembly / CDev.asm next >
Encoding:
Assembly Source File  |  1990-05-25  |  18.0 KB  |  462 lines  |  [04] ASCII Text (0x0000)

  1. ;############################################################
  2. ;#                                                          #
  3. ;#  File:           CDev.asm                                #
  4. ;#  Version:        3.0                                     #
  5. ;#  Author:                                                 #
  6. ;#  Copyright:      (c) 1989 by Apple Computer, Inc.        #
  7. ;#  Developer Technical Support Apple II Sample Code        #
  8. ;#                                                          #
  9. ;#  Description:    This file contains the assembler needed #
  10. ;#                  by the Shell CDEV on the IIGS.          #
  11. ;#                                                          #
  12. ;#----------------------------------------------------------#
  13. ;#                                                          #
  14. ;#  Development History:                                    #
  15. ;#                                                          #
  16. ;#  Who     Date        The Modification                    #
  17. ;#  ---     --------    ----------------                    #
  18. ;#                                                          #
  19. ;############################################################
  20.  
  21.          copy  E16.CDev
  22.  
  23. root     start
  24. ; just a dummy segment so all the code goes into the .A file
  25.          end
  26.  
  27. ;############################################################
  28. ;#                                                          #
  29. ;#  CDEV executable module                                  #
  30. ;#                                                          #
  31. ;############################################################
  32.  
  33. ; This routine is eventually linked and then placed into a CDev code resource.  The only
  34. ; requirements are that this routine is at the beginning of the resource so if the CDev has
  35. ; any other routines they must follow this one.  The CDev's resource fork is always opened
  36. ; when a call to the CDev is made.  The CDev can also assume that the current port is set to
  37. ; the control panel window except in the boot message, where QuickDraw isn't even started,
  38. ; and in the About message, where it is the port of the help window.  All normal managers 
  39. ; will be started up for all calls except the boot call, which will only have miscTools and
  40. ; Resource Manager started.
  41.  
  42. CDEV     start
  43.  
  44. save_dbr equ   $01
  45. retAddr  equ   $02
  46. data2    equ   $05
  47. data1    equ   $09
  48. message  equ   $0D
  49. retCode  equ   $0F
  50.  
  51.          phb                            ;save DBR
  52.          tsc                            ;get stack pointer
  53.          phd                            ;save original direct page
  54.          tcd                            ;make local direct page
  55.  
  56.          phk                            ;set DBR to PBR
  57.          plb
  58.  
  59.          stz   retCode                  ;initialize return code
  60.          stz   retCode+2
  61.  
  62.          lda   message                  ;get message value
  63.          cmp   #RunCDEV+1               ;valid message number?
  64.          bcc   good_message             ;yes...
  65.          lda   #reserved1               ;else put it in range
  66. good_message   anop
  67.          dec   a                        ;fix for indexing
  68.          asl   a                        ;multiply by 2
  69.          tax                            ;put into index register
  70.          lda   case_table,x             ;get address of correct routine
  71.          pha                            ;put on stack
  72.          rts                            ;and do the 'rts' trick
  73.  
  74. case_table     anop
  75.          dc    i2'Machine_msg-1'        ;case MachineCDEV
  76.          dc    i2'Boot_msg-1'           ;case BootCDEV
  77.          dc    i2'ShutDown_msg-1'       ;case ShutDownCDEV
  78.          dc    i2'Init_msg-1'           ;case InitCDEV
  79.          dc    i2'Close_msg-1'          ;case CloseCDEV
  80.          dc    i2'Events_msg-1'         ;case EventsCDEV
  81.          dc    i2'Create_msg-1'         ;case CreateCDEV
  82.          dc    i2'About_msg-1'          ;case AboutCDEV
  83.          dc    i2'Rect_msg-1'           ;case RectCDEV
  84.          dc    i2'Hit_msg-1'            ;case HitCDEV
  85.          dc    i2'Run_msg-1'            ;case RunCDEV
  86.          dc    i2'null_msg-1'           ;case reserved1 through NeverUsed2
  87.  
  88. ;----------------------------------------------------------------------------------------------------
  89. ; If the wantBoot flag is set, this routine will be called during the startup sequence.  The
  90. ; control panel takes care of drawing the "boot" icon.  When this call is made, the machine
  91. ; state is bad at best.  QuickDraw is not even started up.  The parameters to this call are
  92. ; undefined.
  93.  
  94. Boot_msg anop
  95.          bra   exit
  96.          
  97. ;----------------------------------------------------------------------------------------------------
  98. ; This is called if the wantMachine bit is set in the CDev flaags.  It enables the CDev to do
  99. ; further checking to see if it makes sense for the CDev to be visible to the user or not.
  100. ; For instance, if the CDev controls a setting for some hardware, we could check to see if
  101. ; the hardware is really connected.  The parameters are undefined for this call and the result
  102. ; is passed back as the function result.  0 = don't show this cdev, <>0 = show this CDev.
  103. ; The control panel will do some machine checking even before calling this routine by checking
  104. ; the ROM version number against the machine field of the CDev flags resource.
  105.  
  106. Machine_msg    anop
  107.          bra   exit
  108.  
  109. ;----------------------------------------------------------------------------------------------------
  110. ; If the wantCreate bit is set, this message is called with the control panel's window ptr 
  111. ; passed in data1.  The cdev must create any controls it has during this call.  The CDEV's 
  112. ; resource fork is open during this call so resource manager calls can be made.  All controls
  113. ; rectangles MUST be relative to 0,0.  The control panel handles offsetting controls
  114. ; to the proper place in the window.  Initialization of the controls needs to be done in
  115. ; the InitCDEV call.  Just create the controls in this call.
  116.  
  117. Create_msg     anop
  118.          jsr   do_Create                ;go create the controls
  119.          bra   exit                     ;then return to caller
  120.  
  121. ;----------------------------------------------------------------------------------------------------
  122. ; If the wantInit flag is set, then this message is passed with data1 = the control panel's
  123. ; window ptr.  By  this time the CreateCDEV call will have been made and thus the controls
  124. ; used by the CDEV created.  This call enables the CDEV to initialize the controls before 
  125. ; they are displayed.
  126.  
  127. Init_msg anop
  128.          jsr   do_Init
  129.          bra   exit
  130.  
  131. ;----------------------------------------------------------------------------------------------------
  132. ; If the wantAbout bit is set in the CDEV flags, this call is made when the user selects help.
  133. ; Data1 = window ptr to the help window.  The control panel automatically handles the icon, 
  134. ; author, and version # display.
  135.  
  136. About_msg      anop
  137.          jsr   do_About
  138.          bra   exit
  139.  
  140. ;----------------------------------------------------------------------------------------------------
  141. ; If a CDEV has a different size data rectangle depending on some state, like the printer & 
  142. ; modem port cdev's, then you can get a chance to tell the control panel this by setting the 
  143. ; wantRect bit in the CDEV flags.  In this call, data1 is a ptr to the rect and can be 
  144. ; directly modified by the CDEV.
  145.  
  146. Rect_msg anop
  147.          bra   exit
  148.  
  149. ;----------------------------------------------------------------------------------------------------
  150. ; If the wantEvents bit is set, the control panel will call this routine with data1 = ptr to
  151. ; the event record.  This allows the cdev to intercept and even *gasp* change the event record
  152. ; before it is handled by the control panel.
  153.  
  154. Events_msg     anop
  155.          bra   exit
  156.  
  157. ;----------------------------------------------------------------------------------------------------
  158. ; If the CDEV wants to know when a control has been "hit", it can set the wantHit bit in the
  159. ; CDEV flags.  When called, data1 = Hdl to Ctl Hit & data2 = Ctl ID of hit control.  This message
  160. ; allows the CDEV to perform actions based on the control that was selected by the user.
  161.  
  162. Hit_msg  anop
  163.          jsr   do_Hit
  164.          bra   exit
  165.  
  166. ;----------------------------------------------------------------------------------------------------
  167. ; This message is called if the "wantRun" bit is set in the CDEV flags.  It enables CDEVs like
  168. ; time to update the display.  It is called every 60th of a second - every time the DARun call
  169. ; is issued to the control panel. -no parameters are passed to this routine.
  170.  
  171. Run_msg  anop
  172.          bra   exit
  173.  
  174. ;----------------------------------------------------------------------------------------------------
  175. ; The CloseCDEV message is passed if the wantClose bit is set in the CDEV flags and the control
  176. ; panel is closing or when the user selects another CDEV.  During  this call data1 = windowPtr.
  177. ; In general, CDEVs can do any memory disposal and saving of settings during this call.  The
  178. ; disposal of the CDEV's controls is handled automatically by the Control Panel.
  179.  
  180. Close_msg      anop
  181.          bra   exit
  182.  
  183. ;----------------------------------------------------------------------------------------------------
  184. ; If the wantShutDown bit is set in the CDEV flags resource then this routine is called when
  185. ; the user either disables the CDEV or *someday* when the machine is being turned off.  It
  186. ; gives the CDEV a chance to turn itself off (or any hardware or software it controls).
  187. ; The parameters are undefined in this call.
  188.  
  189. ShutDown_msg   anop
  190.          bra   exit
  191.  
  192. ;----------------------------------------------------------------------------------------------------
  193. ; This label is here to handle any message values that are out of range.
  194.  
  195. null_msg anop
  196. ;----------------------------------------------------------------------------------------------------
  197.  
  198. exit     anop
  199.          lda   save_dbr                 ;get saved DBR and low byte of return address
  200.          sta   data1+2                  ;move up in stack frame
  201.          lda   retAddr+1                ;get high word of return address
  202.          sta   message                  ;move it up too
  203.          pld                            ;restore original direct page
  204.          tsc                            ;remove parms from stack
  205.          clc
  206.          adc   #10
  207.          tcs
  208.          plb                            ;restore original DBR
  209.          rtl                            ;and return to control panel shell
  210.  
  211. ;****************************************************************************************************
  212. ; do_Create - creates the popup controls
  213.  
  214. do_Create      anop
  215.          pha                            ;make room on stack for returned control handle
  216.          pha
  217.          pei   data1+2                  ;put window pointer on stack
  218.          pei   data1
  219.          pea   3                        ;referenceDesc = pointer to list of pointers
  220.          pea   CDEVLIST|-16             ;put address of pointer on stack
  221.          pea   CDEVLIST
  222.          ldx   #$3110                   ;NewControl2 call
  223.          jsl   $e10000
  224.          pla                            ;remove returned handle
  225.          pla
  226.          rts
  227.  
  228. ;****************************************************************************************************
  229. ; do_Init - sets the initial values of the popup controls
  230.  
  231. do_Init  anop
  232.          pea   1                        ;put current value of control on stack (for SetCtlValue)
  233.  
  234.          pha                            ;space for returned result
  235.          pha
  236.          pei   data1+2                  ;put window pointer on stack
  237.          pei   data1
  238.          pea   0
  239.          pea   1                        ;control ID
  240.          ldx   #$3010                   ;GetCtlHandleFromID call
  241.          jsl   $e10000
  242.  
  243.          ldx   #$1910                   ;SetCtlValue call
  244.          jsl   $e10000
  245.  
  246.          pea   1                        ;put current value of control on stack (for SetCtlValue)
  247.  
  248.          pha                            ;space for returned result
  249.          pha
  250.          pei   data1+2                  ;put window pointer on stack
  251.          pei   data1
  252.          pea   0
  253.          pea   2                        ;control ID
  254.          ldx   #$3010                   ;GetCtlHandleFromID call
  255.          jsl   $e10000
  256.  
  257.          ldx   #$1910                   ;SetCtlValue call
  258.          jsl   $e10000
  259.  
  260.          pea   1                        ;put current value of control on stack (for SetCtlValue)
  261.  
  262.          pha                            ;space for returned result
  263.          pha
  264.          pei   data1+2                  ;put window pointer on stack
  265.          pei   data1
  266.          pea   0
  267.          pea   3                        ;control ID
  268.          ldx   #$3010                   ;GetCtlHandleFromID call
  269.          jsl   $e10000
  270.  
  271.          ldx   #$1910                   ;SetCtlValue call
  272.          jsl   $e10000
  273.  
  274.          rts
  275.  
  276. ;****************************************************************************************************
  277. ; do_About - creates the About static text control
  278.  
  279. do_About anop
  280.          pha                            ;space for returned handle
  281.          pha
  282.          pei   data1+2                  ;put window pointer on stack
  283.          pei   data1
  284.          pea   0                        ;referenceDesc = pointer to single control
  285.          pea   ABOUTCDEV1|-16           ;put pointer to about stuff on stack
  286.          pea   ABOUTCDEV1
  287.          ldx   #$3110                   ;NewControl2 call
  288.          jsl   $e10000
  289.          pla                            ;remove returned handle
  290.          pla
  291.          rts
  292.  
  293. ;****************************************************************************************************
  294. ; do_Hit - handles a control 'hit'
  295.  
  296. do_Hit   anop
  297.          lda   data2                    ;get Control ID
  298.          cmp   #3                       ;is it three?
  299.          bcc   not_three                ;no...
  300.          pha                            ;else save value
  301.          ldx   #$2c03                   ;SysBeep call
  302.          jsl   $e10000
  303.          pla                            ;retrieve ctl id
  304. not_three      anop
  305.          cmp   #2                       ;two?
  306.          bcc   not_two
  307.          pha                            ;save value
  308.          ldx   #$2c03                   ;SysBeep
  309.          jsl   $e10000
  310.          pla
  311. not_two  anop
  312.          cmp   #1                       ;one?
  313.          bcc   not_one
  314.          ldx   #$2c03
  315.          jsl   $e10000
  316. not_one  anop
  317.          rts
  318.  
  319.          end
  320.  
  321. ;############################################################
  322. ;#                                                          #
  323. ;#  CDEV Control #1                                         #
  324. ;#                                                          #
  325. ;############################################################
  326.  
  327. CDEV1    data
  328.  
  329.          dc    i2'9'
  330.          dc    i4'1'
  331.          dc    i2'2,5,14,195'
  332.          dc    i4'$87000000'
  333.          dc    i2'$0040'
  334.          dc    i2'$1004'
  335.          dc    i4'0'
  336.          dc    i2'76'
  337.          dc    i4'CDEV1Menu'
  338.          dc    i2'1'
  339.  
  340. CDEV1Menu anop
  341.          dc    c'>> Item 1:\H'
  342.          dc    i2'1'
  343.          dc    i1'$0d'
  344.          dc    c'== Impressive!\H'
  345.          dc    i2'1'
  346.          dc    i1'$0d'
  347.          dc    c'== Elegant!\H'
  348.          dc    i2'2'
  349.          dc    i1'$0d'
  350.          dc    c'== Amazing!\H'
  351.          dc    i2'3'
  352.          dc    i1'$0d'
  353.          dc    c'== Stupendous!\H'
  354.          dc    i2'4'
  355.          dc    i1'$0d'
  356.          dc    c'.'
  357.          end
  358.  
  359. ;############################################################
  360. ;#                                                          #
  361. ;#  CDEV Control #2                                         #
  362. ;#                                                          #
  363. ;############################################################
  364.  
  365. CDEV2    data
  366.          dc    i2'9'
  367.          dc    i4'2'
  368.          dc    i2'17,5,29,195'
  369.          dc    i4'$87000000'
  370.          dc    i2'$0040'
  371.          dc    i2'$1004'
  372.          dc    i4'0'
  373.          dc    i2'80'
  374.          dc    i4'CDEV2Menu'
  375.          dc    i2'1'
  376.  
  377. CDEV2Menu anop
  378.          dc    c'>> Item 2:\H'
  379.          dc    i2'2'
  380.          dc    i1'$0d'
  381.          dc    c'== Wow!\H'
  382.          dc    i2'1'
  383.          dc    i1'$0d'
  384.          dc    c'== Golly!\H'
  385.          dc    i2'2'
  386.          dc    i1'$0d'
  387.          dc    c'== Holy Cow!\H'
  388.          dc    i2'3'
  389.          dc    i1'$0d'
  390.          dc    c'.'
  391.          end
  392.  
  393. ;############################################################
  394. ;#                                                          #
  395. ;#  CDEV Control #3                                         #
  396. ;#                                                          #
  397. ;############################################################
  398.  
  399. CDEV3    data
  400.          dc    i2'9'
  401.          dc    i4'3'
  402.          dc    i2'32,5,44,195'
  403.          dc    i4'$87000000'
  404.          dc    i2'$0040'
  405.          dc    i2'$1004'
  406.          dc    i4'0'
  407.          dc    i2'80'
  408.          dc    i4'CDEV3Menu'
  409.          dc    i2'1'
  410.  
  411. CDEV3Menu anop
  412.          dc    c'>> Item 3:\H'
  413.          dc    i2'3'
  414.          dc    i1'13'
  415.          dc    c'== Too Hip!\H'
  416.          dc    i2'1'
  417.          dc    i1'13'
  418.          dc    c'== That''s All!\H'
  419.          dc    i2'2'
  420.          dc    i1'13'
  421.          dc    c'.'
  422.          end
  423.  
  424. ;############################################################
  425. ;#                                                          #
  426. ;#  CDEV Control Lists                                      #
  427. ;#                                                          #
  428. ;############################################################
  429.  
  430. CDEVLIST data
  431.  
  432.          dc    i4'CDEV1'
  433.          dc    i4'CDEV2'
  434.          dc    i4'CDEV3'
  435.          dc    i4'0'
  436.  
  437.          end
  438.  
  439. ;############################################################
  440. ;#                                                          #
  441. ;#  CDEV 'About' control                                    #
  442. ;#                                                          #
  443. ;############################################################
  444.  
  445. AboutCDEV1     data
  446.  
  447.          dc    i2'8'
  448.          dc    i4'1'
  449.          dc    i2'38,5,138,280'
  450.          dc    i4'$81000000'
  451.          dc    i2'$0000'
  452.          dc    i2'$1000'
  453.          dc    i4'0'
  454.          dc    i4'theText'
  455.          dc    i2'endText-theText'
  456.          
  457. theText  anop
  458.          dc    c'This CDEV shows how easy it is to create a CDEV on the AppleIIgs.'
  459. endText  anop
  460.  
  461.          end
  462.