home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / programming / basic / blitzandpieces / sysrep.asc < prev    next >
Encoding:
Text File  |  1999-05-14  |  4.0 KB  |  200 lines

  1. ; simple system report program :
  2.  
  3. ; could be useful to include in archives, and have
  4. ; your users give an accurate description of their
  5. ; system...best if packed with StoneCracker though :)
  6.  
  7. ; jamesboyd@all-hail.freeserve.co.uk
  8.  
  9. WBStartup
  10.  
  11. ; size-saving version of "Lisa" command, but can't use in a function :(
  12. MOVE.w $dff07c,d0
  13. PutReg d0,chip.w ; "chip" variable is Shared in ChipSet {} function
  14.  
  15. Function$ LoadScreenFont {f.w}
  16.  
  17.   *scr.Screen=Peek.l(Addr Screen(Used Screen))
  18.     If *scr=0 Then Function Return ""
  19.  
  20.   *scfont.TextAttr=*scr.Screen\Font
  21.     If *scfont=0 Then Function Return ""
  22.  
  23. ; In AmigaDOS we trust :
  24.   fheight.b=*scfont.TextAttr\ta_YSize
  25.   fname$=Peek$(*scfont.TextAttr\ta_Name)
  26.  
  27. LoadFont f,fname$,fheight:Function Return Str$(f)+":"+fname$+":"+Str$(fheight)
  28. End Function
  29.  
  30. ; 0 = 68000
  31. ; 1 = 68010
  32. ; 2 = 68020
  33. ; 3 = 68030
  34. ; 4 = 68040    ; note - no 5! ;)
  35. ; 6 = 68060
  36.  
  37. Function.b GetCPU {}
  38.  
  39.   cpu.b=0
  40.   *e.ExecBase = Peek.l(4)
  41.  
  42.   #AFF_68060=(1 LSL 7)                  ; flag for 060, not in Blitz includes
  43.  
  44.   If *e
  45.  
  46.   If *e\AttnFlags & #AFF_68010          ; gotta do it like this,
  47.     If *e\AttnFlags & #AFF_68020        ; cos each processor has the
  48.       If *e\AttnFlags & #AFF_68030      ; flags of the previous processor
  49.         If *e\AttnFlags & #AFF_68040    ; set, too...
  50.           If *e\AttnFlags & #AFF_68060
  51.             cpu=6
  52.           Else cpu=4
  53.           EndIf
  54.         Else cpu=3
  55.         EndIf
  56.       Else cpu=2
  57.       EndIf
  58.     Else cpu=1
  59.     EndIf
  60.   Else cpu=0
  61.   EndIf
  62.  
  63.   EndIf
  64.  
  65. Function Return cpu
  66. End Function
  67.  
  68. ; 0 = No FPU
  69. ; 1 = 68881 FPU
  70. ; 2 = 68882 FPU
  71. ; 3 = 68040 FPU (no math emulation) ; 040.library not loaded
  72. ; 4 = 68040 FPU (math emulation)
  73. ; 5 = 68060 FPU (no math emulation) ; 060.library not loaded
  74. ; 6 = 68060 FPU (math emulation)
  75.  
  76. Function.b GetFPU {}
  77.  
  78.   fpu.b=0
  79.   *e.ExecBase = Peek.l(4)
  80.  
  81.   #AFF_68060=(1 LSL 7)
  82.  
  83.   If *e
  84.  
  85.   If *e\AttnFlags & #AFF_68881
  86.     If *e\AttnFlags & #AFF_68882
  87.       fpu=2
  88.     Else fpu=1
  89.     EndIf
  90.  
  91.     If *e\AttnFlags & #AFF_FPU40
  92.       fpu=4                         ; 68040 FPU (math emulation)
  93.       If *e\AttnFlags & #AFF_68060  ; check for 060...
  94.         fpu=6                       ; 68060 FPU (math emulation)
  95.       EndIf
  96.     EndIf
  97.  
  98.   Else fpu=0                        ; No 68881 or 68882
  99.  
  100.     If *e\AttnFlags & #AFF_FPU40    ; check if it's an 040 without 6888x emulation...
  101.       fpu=3                         ; 68040 FPU (no math emulation)
  102.       If *e\AttnFlags & #AFF_68060  ; check for 060...
  103.         fpu=5                       ; 68060 FPU (no math emulation)
  104.       EndIf
  105.     EndIf
  106.  
  107.   EndIf
  108.  
  109.   EndIf
  110.  
  111. Function Return fpu
  112. End Function
  113.  
  114. Function.w KickVersion {}
  115.   e$="exec.library"
  116.   *lib.Library=OpenLibrary_(&e$,33)
  117.  
  118.   If *lib
  119.     v.w=*lib\lib_Version
  120.   CloseLibrary_ *lib
  121.   EndIf
  122.   Function Return v
  123. End Function
  124.  
  125. Function.w WBColours {}
  126. Function Return 2^WBDepth
  127. End Function
  128.  
  129. Function.s ChipSet {}
  130.  
  131. SHARED chip
  132.  
  133. Select chip
  134.   Case $00
  135.     chip$="OCS"
  136.   Case $F7
  137.     chip$="ECS"
  138.   Case $F8
  139.     chip$="AGA"
  140.   Case $F9
  141.     chip$="AA (Prototype)"
  142. Default
  143.   chip$="unknown"
  144. End Select
  145.  
  146. Function Return chip$
  147. End Function
  148.  
  149. FindScreen 0,"Workbench Screen"
  150.  
  151. a$=LoadScreenFont{0}
  152. a$=Replace$("Workbench font : "+Right$(a$,Len(a$)-Instr(a$,":"))+"|",".font","")
  153.  
  154. a$+"CPU : 680"+Str$(GetCPU{})+"0|"
  155.  
  156. a$+"FPU : "
  157.  
  158. a.b=GetFPU{}
  159.  
  160. Select a
  161.   Case 0
  162.     a$+"No FPU"
  163.   Case 1
  164.     a$+"68881 FPU"
  165.   Case 2
  166.     a$+"68882 FPU"
  167.   Case 3
  168.     a$+"68040 FPU (no math emulation)"
  169.   Case 4
  170.     a$+"68040 FPU (math emulation)"
  171.   Case 5
  172.     a$+"68060 FPU (no math emulation)"
  173.   Case 6
  174.     a$+"68060 FPU (math emulation)"
  175. End Select
  176.  
  177. a$+"|"
  178.  
  179. a$+"Kickstart : "+Str$(KickVersion{})+"|"
  180.  
  181. a$+"Workbench colours : "+Str$(WBColours{})+"|"
  182.  
  183. a$+"Chipset : "+ChipSet{}
  184.  
  185. If Request ("SysRep","System Analysis :||"+a$,"Create report|End")
  186.  
  187.   If WriteFile (0,"RAM:SysRep.txt")
  188.     a$=Replace$(a$,"|",Chr$(10))
  189.     FileOutput 0
  190.     NPrint a$
  191.     CloseFile 0:PopOutput
  192.     Request "","Created report as RAM:SysRep.txt","OK"
  193.   Else Request "","Couldn't generate RAM:SysRep.txt","Doh!"
  194.   EndIf
  195.  
  196. EndIf
  197.  
  198. End
  199.  
  200.