home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser 2002 January / STC_CD_01_2002.iso / SCENE / IMATROLL / SRC / SYS / EXIT.S < prev    next >
Text File  |  2001-11-28  |  6KB  |  225 lines

  1. ; Falcon demoshell
  2. ; February 3, 2000
  3. ;
  4. ; Anders Eriksson
  5. ; ae@dhs.nu
  6. ;
  7. ; exit.s
  8.  
  9.  
  10. ; --------------------------------------------------------------
  11.         section    text
  12. ; --------------------------------------------------------------
  13.  
  14.  
  15.  
  16. ;---------------------------------------------------------------
  17. ;        runlevel based exit
  18. ;---------------------------------------------------------------
  19.  
  20.  
  21. exit:        cmp.w    #9,runlevel                ;9=interupts
  22.         blt.s    .r8                    ;next
  23.         bsr.w    restore_ints                ;restore interups
  24. ;---------------------------------------------------------------
  25. .r8:        cmp.w    #8,runlevel                ;8=music
  26.         blt.s    .r7                    ;next
  27.         nop                ;
  28.         bsr.w    dspmod_end                ;restore dspmod                        ;                    ;
  29. ;---------------------------------------------------------------
  30. .r7:        cmp.w    #7,runlevel                ;7=keyklick
  31.         blt.s    .r6                    ;next
  32.         bsr.w    restore_click                ;restore keyclick
  33. ;---------------------------------------------------------------
  34. .r6:        cmp.w    #6,runlevel                ;6=video
  35.         blt.s    .r5                    ;next
  36.         bsr.w    restore_video                ;restore video
  37. ;---------------------------------------------------------------
  38. .r5:        cmp.w    #5,runlevel                ;5=supervisor
  39.         blt.s    .r4                    ;next
  40.         move.l    save_stack,-(sp)            ;exit supervisor
  41.         move.w    #32,-(sp)                ;
  42.         trap    #1                    ;
  43.         addq.l    #6,sp                    ;
  44. ;---------------------------------------------------------------
  45. .r4:        cmp.w    #4,runlevel                ;4=dta
  46.         blt.s    .r3                    ;next
  47.         bsr.w    restore_dta
  48. ;---------------------------------------------------------------
  49. .r3:                                ;3=gem (unused)
  50. ;---------------------------------------------------------------
  51. .r2:        cmp.w    #2,runlevel                ;2=Locksnd()
  52.         blt.s    .r1                    ;next
  53.         bsr.w    unlocksnd                ;unlock soundsystem
  54. ;---------------------------------------------------------------
  55. .r1:        cmp.w    #1,runlevel                ;1=Dsp_Lock()
  56.         bsr.w    dsp_unlock                ;unlock the dsp
  57. ;---------------------------------------------------------------
  58.                         ;
  59. .printfile:    tst.l    filename                ;see if print filename
  60.         beq.s    .print_error                ;
  61.         move.l    filename,d0                ;print filename
  62.         bsr.w    cconws                    ;
  63.  
  64. .print_error:    tst.l    error_adr                ;see if print error message
  65.         beq.w    .pterm                    ;
  66.         move.l    error_adr,d0                ;print error message
  67.         bsr.w    cconws                    ;
  68.  
  69.         bsr.w    crawcin                    ;wait key
  70.  
  71. .pterm:        clr.w    -(sp)                    ;pterm()
  72.         trap    #1                    ;
  73.  
  74.  
  75.  
  76. ; --------------------------------------------------------------
  77. ;        exit subroutines
  78. ; --------------------------------------------------------------
  79.  
  80. cconws:        move.l    d0,-(sp)                ;cconws()
  81.         move.w    #9,-(sp)                ;
  82.         trap    #1                    ;
  83.         addq.l    #6,sp                    ;
  84.         rts
  85.  
  86. crawcin:    move.w    #7,-(sp)                ;crawcin()
  87.         trap    #1                    ;
  88.         addq.l    #2,sp                    ;
  89.         rts                        ;
  90.  
  91. restore_click:    move.b    save_keymode,$484.w            ;restore keyclick
  92.         rts
  93.  
  94. restore_ints:    move.w    sr,d0                    ;save sr
  95.         move.w    #$2700,sr                ;ints off
  96.         move.l    save_vbl,$70.w                ;vbl
  97.         move.l    save_timer_d,$110.w            ;timer_d
  98.         lea.l    save_mfp,a0                ;mfp regs
  99.         move.b    (a0)+,$fffffa09.w            ;
  100.         move.b    (a0)+,$fffffa15.w            ;
  101.         move.b    (a0)+,$fffffa1d.w            ;
  102.         move.b    (a0)+,$fffffa25.w            ;
  103.         move.w    d0,sr                    ;ints back
  104.         rts
  105.     
  106.  
  107. restore_video:    lea.l    save_video,a0                ;restore video
  108.         clr.w   $ffff8266.w                ;falcon-shift clear
  109.         move.l    (a0)+,$ffff8200.w            ;videobase_address:h&m
  110.         move.w    (a0)+,$ffff820c.w            ;l
  111.         move.l    (a0)+,$ffff8282.w            ;h-regs
  112.         move.l    (a0)+,$ffff8286.w            ;
  113.         move.l    (a0)+,$ffff828a.w            ;
  114.         move.l    (a0)+,$ffff82a2.w            ;v-regs
  115.         move.l    (a0)+,$ffff82a6.w            ;
  116.         move.l    (a0)+,$ffff82aa.w            ;
  117.         move.w    (a0)+,$ffff82c0.w            ;vco
  118.         move.w    (a0)+,$ffff82c2.w            ;c_s
  119.         move.l    (a0)+,$ffff820e.w            ;offset
  120.         move.w    (a0)+,$ffff820a.w            ;sync
  121.             move.b  (a0)+,$ffff8256.w            ;p_o
  122.             tst.b   (a0)+                   ;st(e) comptaible mode?
  123.             bne.s   .ok
  124.         move.l    a0,-(sp)                ;wait for vbl
  125.         move.w    #37,-(sp)                ;to avoid syncerrors
  126.         trap    #14                    ;in falcon monomodes
  127.         addq.l    #2,sp                    ;
  128.         movea.l    (sp)+,a0                ;
  129.                move.w  (a0),$ffff8266.w            ;falcon-shift
  130.         bra.s    .video_restored
  131. .ok:        move.w  2(a0),$ffff8260.w            ;st-shift
  132.         lea.l    save_video,a0
  133.         move.w    32(a0),$ffff82c2.w            ;c_s
  134.         move.l    34(a0),$ffff820e.w            ;offset        
  135. .video_restored:
  136.         lea.l    $ffff9800.w,a0                ;restore falcon palette
  137.         lea.l    save_pal,a1                ;
  138.         move.w    #256-1,d7                ;
  139. .loop:        move.l    (a1)+,(a0)+                ;
  140.         dbra    d7,.loop                ;
  141.         movem.l    (a1),d0-d7                ;restore st palette
  142.         movem.l    d0-d7,$ffff8240.w            ;
  143.         rts
  144.  
  145.  
  146. restore_dta:    move.l    save_dta,-(sp)                ;fsetdta() restore dta
  147.         move.w    #$1a,-(sp)                ;
  148.         trap    #1                    ;
  149.         addq.l    #6,sp                    ;
  150.         rts
  151.  
  152. dsp_unlock:    move.w    #$69,-(sp)                ;Dsp_Unlock()
  153.         trap    #14                    ;
  154.         addq.l    #2,sp                    ;
  155.         rts
  156.  
  157.  
  158. unlocksnd:    move.w    #$81,-(sp)                ;Unlocksnd()
  159.         trap    #14                    ;
  160.         addq.l    #2,sp                    ;
  161.         rts                        ;
  162.  
  163.  
  164.  
  165. ; --------------------------------------------------------------
  166.         section    data
  167. ; --------------------------------------------------------------
  168.  
  169.         even
  170.  
  171. error_adr:    ds.l    1
  172.  
  173. exit_nostram_text:
  174.         dc.b    13,10
  175.         dc.b    "Sorry, you don't have enough free ST-RAM",13,10
  176.         dc.b    "to run this demo.",13,10,13,10
  177.         dc.b    "Press any key to exit.",13,10,0
  178.         even
  179.  
  180. exit_mono_text:    dc.b    13,10
  181.         dc.b    "Sorry, this demo does not work with",13,10
  182.         dc.b    "monochrome monitors.",13,10,13,10
  183.         dc.b    "Press any key to exit.",13,10,0
  184.         even
  185.  
  186. exit_dsplocked_text:
  187.         dc.b    13,10
  188.         dc.b    "The DSP is already in use by anohter",13,10
  189.         dc.b    "application.",13,10,13,10
  190.         dc.b    "Press any key to exit.",13,10,0
  191.         even
  192.  
  193. exit_sndlocked_text:
  194.         dc.b    13,10
  195.         dc.b    "The Falcon audio subsystem already in",13,10
  196.         dc.b    "use by another application.",13,10,13,10
  197.         dc.b    "Press any key to exit.",13,10,0
  198.         even
  199.  
  200.         ifne    dspmodmusic
  201. exit_nomodram_text:
  202.         dc.b    13,10
  203.         dc.b    "Sorry, you don't have enough free",13,10
  204.         dc.b    "ST-RAM or TT-RAM to run this demo.",13,10,13,10
  205.         dc.b    "Press any key to exit.",13,10,0
  206.         even
  207.         endc
  208.  
  209. exit_musicnotfound_text:
  210.         dc.b    13,10
  211.         dc.b    "Sorry, the musicfile was not found.",13,10,13,10
  212.         dc.b    "Press any key to exit.",13,10,0
  213.         even
  214.  
  215. exit_filenotfound_text:
  216.         dc.b    13,10
  217.         dc.b    "Sorry, the file was not found.",13,10,13,10
  218.         dc.b    "Press any key to exit.",13,10,0
  219.         even
  220.  
  221.  
  222. ; --------------------------------------------------------------
  223.         section    text
  224. ; --------------------------------------------------------------
  225.