home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI03.ARJ / ictari.03 / ASSEMBLY / WHICHTOS.S < prev   
Text File  |  1985-11-20  |  5KB  |  177 lines

  1. ; Thanks to the Untouchables for the cart detect etc.
  2. ; The TOS version finder was in the book 'Introducing Atari ST Machine
  3. ; Code'   I hope they don't mind us nicking it! (I re-wrote it a bit).
  4.  
  5. ; This code finds out :-    which TOS you have
  6. ;            if the sys_base is valid
  7. ;            if you have an STE
  8. ;            if you have 1 meg or half
  9. ;            if there are cartridges 
  10.  
  11. ; This code is just an example of how to find some system settings.
  12.  
  13. ; Note:-  you can only detect user carts like the Ultimate Ripper if
  14. ; they are switched on.
  15. ; I do not know how to find out the memory config properly so someone
  16. ; else will have to show you.
  17. ; Errm...   thats it.        T.S.C.
  18.  
  19.             pea    0.w        supervisor mode
  20.             move.w      #$20,-(sp)
  21.             trap        #1
  22.             addq.l       #6,sp
  23.             move.l      d0,oldsp
  24.  
  25. oldsp    dc.l    0
  26.     
  27.     bsr    ste_hard        run all checks
  28.     bsr    checkmeg
  29.     bsr    carty
  30.     bsr    tos_check
  31.     
  32. cont    bsr    print
  33.     bsr    wait
  34.  
  35.     pea    oldsp        back to user mode
  36.             move.w      #$20,-(sp)
  37.             trap        #1
  38.             add.l       #6,sp
  39.  
  40.     pea    0.w        quit
  41.     trap    #1      
  42.  
  43. ***************************************************************************
  44. * Check for some carts
  45.  
  46. carty    cmp.l    #$fa52235f,$fa0000    diagnostix cartridge?
  47.     bne.s    nextbit
  48.     lea    nostix,a0
  49.     bsr    print
  50.     bra    honda
  51. nextbit    cmp.l    #$abcdef42,$fa0000    user cartridge? (rippers etc)
  52.     bne.s    kein_cart
  53.     lea    ripper,a0
  54.     bsr    print
  55.     bra    honda
  56. kein_cart    lea    cartless,a0
  57.     bsr    print
  58. honda    rts
  59.  
  60. ***************************************************************************
  61. * One way of checking for a meg of memory!
  62.  
  63. checkmeg    move.l    #"Meg!",$80000    
  64.     cmp.l    #"Meg!",$80000
  65.     bne.s    halfmeg
  66.     lea    meg_mess,a0
  67.     bsr    print
  68.     bra    endy
  69. halfmeg    lea    half_meg,a0
  70.     bsr    print
  71. endy    rts
  72.  
  73. ***************************************************************************
  74. * All this bit checks for valid system base and finds TOS number
  75.  
  76. tos_check    move.l      $4f2,a0        get system base address, _sysbase
  77.             move.l      a0,sys_base       save for later use
  78.             add.l       #$14,a0           add $14 to get '_os_magic' value 
  79.             move.l      (a0),a1
  80.             move.l      (a1),d0
  81.  
  82. *  should be 'magic' number #$87654321 in d0. This should be tested
  83. *  to confirm that we have a valid sys_base. Assume ok (not anymore!).
  84.  
  85.     bsr    base_ok?
  86.  
  87.             clr.l       d0
  88.             move.l      sys_base,a0
  89.             addq.l       #2,a0            add 2 to get actual TOS versions
  90.             move.w      (a0),d0
  91.     cmpi.w      #$100,d0        100 = tos 1.0 (1986)
  92.             beq.s        tos1    
  93.             cmpi.w      #$102,d0        102 = tos 1.2 + blitter (1987)
  94.             beq.s        tos2
  95.             cmpi.w      #$104,d0        104 = tos 1.4 (1988)
  96.             beq.s        tos3
  97.             cmpi.w      #$106,d0        106 = STE tos 1.6 with blitter
  98.             beq.s        tos4
  99.             bra         no_recog       if we are here the tos was not recognised !
  100.  
  101. tos1    lea      tos_v1,a0        this bit puts the correct message
  102.             bra        cont        in a0 so it can be printed
  103. tos2    lea      tos_v2,a0
  104.             bra        cont
  105. tos3    lea      tos_v3,a0
  106.             bra        cont
  107. tos4    lea      tos_v4,a0
  108.     bra    cont
  109. no_recog    lea    not_tos,a0
  110.     bra    cont
  111.  
  112. ; sys_base check by T.S.C.
  113. ; We really only need to check one part of d0 for the valid sys_base but 
  114. ; lets do both anyway.
  115.  
  116. base_ok?    cmpi.w    #$4321,d0        check 1st part
  117.     bne.s    badnews        oh oh  invalid sys_base !
  118.     swap    d0    
  119.  
  120. ; swap high and low order words so we can get at the rest of the number.
  121.  
  122.     cmpi.w    #$8765,d0        check 2nd part
  123.     beq.s    itsok        ok?  so its a valid sys_base
  124.     bra    badnews        oh oh  invalid sys_base !
  125.     rts
  126.  
  127. badnews    lea    bad_base,a0
  128.     bra    cont        exit cos invalid sys_base
  129. itsok    lea    ok_base,a0
  130.     bsr    print
  131.     rts
  132. ***************************************************************************
  133. * Check for STE
  134.  
  135. ste_hard    cmp.l    #$e00000,$4.w    
  136.     bge.s    notste
  137.     lea    bugger,a0
  138.     bsr    print
  139.     bra    ian
  140. notste    lea    no_e_in_it,a0
  141.     bsr    print
  142. ian    rts
  143.  
  144. ***************************************************************************
  145. print    move.l      a0,-(sp)      print message
  146.            move.w      #9,-(sp)  
  147.            trap        #1
  148.            addq.l      #6,sp     
  149.     rts
  150. wait    move.w    #7,-(sp)        wait for a key
  151.     trap    #1
  152.     addq.l    #2,sp
  153.     rts
  154.  
  155.     section data
  156.  
  157. sys_base    ds.l    1
  158. meg_mess    dc.b    "1 Meg Memory",13,10,0
  159. half_meg    dc.b    "512k Memory",13,10,0
  160. bad_base    dc.b    "Invald System Base!!!",0
  161. ok_base    dc.b    "Valid System Base",13,10,0
  162. tos_v1    dc.b    "TOS Version 1.00",0
  163. tos_v2    dc.b    "TOS Version 1.2",0
  164. tos_v3    dc.b    "TOS Version 1.4",0
  165. tos_v4    dc.b    "TOS Version STE 1.6",0
  166. not_tos    dc.b    "TOS not recognised!!!",0
  167. no_e_in_it    dc.b    "This Is An STF/STFM",13,10,0
  168. bugger    dc.b    "This Is An STE",13,10,0
  169. nostix    dc.b    "There Is A Diagnostic Cartridge Plugged In",13,10,0
  170. ripper    dc.b    "There Is A User Cartridge Plugged In And Active",13,10,0
  171. cartless    dc.b    "No Cartridges Detected/Active",13,10,0
  172.     even
  173.  
  174.  
  175.  
  176.  
  177.