home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilsm / makeboot / !MakeBoot / Source (.txt) < prev   
RISC OS BBC BASIC V Source  |  1993-12-06  |  33KB  |  1,534 lines

  1.  ><MakeBoot$Dir>.Source
  2.  This application is FreeWare. (c) 1993 Dick Alstein
  3. Appl$="MakeBoot"
  4. Version$="1.14 (6-12-93)"
  5. error
  6. quit%=
  7. )mask%=1+(1<<4)+(1<<5)+(1<<11)+(1<<12)
  8.  "Wimp_Poll",mask%,blk% 
  9.  reason%
  10.  reason% 
  11.  1 : 
  12. redraw(blk%!0)
  13.  2 : 
  14.  "Wimp_OpenWindow",,blk%
  15.  blk%!0 
  16. !      
  17.  winhdl%(0),winhdl%(1)
  18. .        
  19.  "Wimp_GetPointerInfo",,ptrinfo%
  20.         
  21.  ptrinfo%!8=1 
  22. )          
  23.  "Filer_OpenDir "+bootdir$
  24.         
  25.         
  26.  -1) 
  27. )          
  28.  "Wimp_CloseWindow",,blk%
  29.         
  30.       
  31. '        
  32.  "Wimp_CloseWindow",,blk%
  33.         
  34.  6 : 
  35. mouseclick(blk%!0,blk%!4,blk%!8,blk%!12,blk%!16)
  36.  7 : 
  37. moveappl
  38.  8 : 
  39. key(blk%!0,blk%!4,blk%!24)
  40.  9 : 
  41. menuselect(blk%)
  42.  17,18 : 
  43. receive(blk%!4,blk%!8,blk%!16)
  44.  quit%
  45. msg_exit
  46.  "Wimp_CloseDown"
  47.  buf%,w%,i%
  48.  errblk% &100
  49.  "Wimp_Initialise",200,&4B534154,Appl$ 
  50.  osversion%,thistask%
  51. error : 
  52.  blk% &600
  53. indsize%=&600
  54.  indir% indsize%
  55. indirend%=indir%+indsize%
  56.  ptrinfo% 20
  57.  dragblk% 60
  58.  scrapblk% 256
  59.  "OS_ReadVarVal","MakeBoot$Dir",scrapblk%,256,0 
  60.  ,,len%
  61. scrapblk%?len%=13
  62. ApplDir$=$(scrapblk%)
  63. ApplPath$="MakeBootRes:"
  64. msg_init
  65. scrapblk%!0=-1
  66. :!scrapblk%!4=0 : scrapblk%!8=0
  67. ;%scrapblk%!12=82 : scrapblk%!16=68
  68. scrapblk%!20=&7000301A
  69. $(scrapblk%+24)="!makeboot"
  70.  "Wimp_CreateIcon",,scrapblk% 
  71.  baricon%
  72.  winhdl%(1)
  73.  wintitle%(1)
  74. maxapps%=256
  75.  "Wimp_OpenTemplate",,ApplPath$+"Templates"
  76. C"infowin%=
  77. loadtemplate("Info")
  78. D!$(blk%!(92+3*32+20))=Version$
  79. E'winhdl%(0)=
  80. loadtemplate("BootSeq")
  81. icon0xmin%=blk%!(92+0*32+0)
  82. icon0xmax%=blk%!(92+0*32+8)
  83. icon0ymin%=blk%!(92+0*32+4)
  84. icon1xmin%=blk%!(92+1*32+0)
  85. icon1xmax%=blk%!(92+1*32+8)
  86. icon2xmin%=blk%!(92+2*32+0)
  87. icon2xmax%=blk%!(92+2*32+8)
  88. itemheight%=80
  89. wintitle%(0)=blk%!76
  90.  i% (blk%!84)
  91. wintitle%(1)=i%
  92. blk%!76=wintitle%(1)
  93.  "Wimp_CreateWindow",,blk%+4 
  94.  winhdl%(1)
  95. S($(wintitle%(0))=
  96. msg_lookup0("BSEQ")
  97. T)$(wintitle%(1))=
  98. msg_lookup0("DBSEQ")
  99. U#filewin%=
  100. loadtemplate("Files")
  101. V#filename_dir%=blk%!(92+2*32+20)
  102. W$filename_leaf%=blk%!(92+3*32+20)
  103. X(saveseqwin%=
  104. loadtemplate("SaveSeq")
  105. Y"saveseq_dir%=blk%!(92+2*32+20)
  106. Z#saveseq_leaf%=blk%!(92+3*32+20)
  107. [(dialogwin%=
  108. loadtemplate("Dialogue")
  109. dial_msg%=blk%!(92+20)
  110. ]<dial_buttoncol%=(blk%!(92+1*32+16)) 
  111.  ((1<<2)+(&FF<<24))
  112.  dial_text%(3)
  113. _#dial_text%(1)=blk%!(92+1*32+20)
  114. `#dial_text%(2)=blk%!(92+2*32+20)
  115. a#dial_text%(3)=blk%!(92+3*32+20)
  116.  "Wimp_CloseTemplate"
  117. nractions%=6
  118.  action%(nractions%)
  119.  i%=0 
  120.  nractions%
  121.  buf% 16
  122.   action%(i%)=buf%
  123. $(action%(0))="Run"
  124. $(action%(1))="Boot"
  125. $(action%(2))="IconSprites"
  126. l!$(action%(3))="Filer_OpenDir"
  127. $(action%(4))="ToolSprites"
  128. $(action%(5))="Filer_Boot"
  129. $(action%(6))="RMLoad"
  130.  Action$(nractions%+1)
  131.  i%=0 
  132.  nractions%
  133. r)  Action$(i%)=
  134. upcase($(action%(i%)))
  135.  nrapps%(1)
  136. nrapps%(0)=0
  137. nrapps%(1)=0
  138. w8applblksize%=0     : 
  139.  size of a block for item data
  140. x#applblksize%+=256  : 
  141.  pathname
  142. y#applblksize%+=12   : 
  143.  leafname
  144. applblksize%+=4    : 
  145.  type
  146. {4applblksize%+=16   : 
  147.  name of sprite to display
  148. |!applblksize%+=4    : 
  149.  action
  150. },applblksize%+=4    : 
  151.  "disabled" switch
  152. ~%applblksize%+=256  : 
  153.  parameters
  154.  appl%(1,maxapps%) : 
  155.  pointers to item data blocks
  156. heap_init
  157. initmenus
  158. readscreenvars
  159.  display%(1)    : 
  160.  0 -> Name + Action,  1 -> Full info
  161.  winxmin%(1),winymin%(1),winxmax%(1),winymax%(1)
  162. choices_load
  163. selecticon(saveseqwin%,5,makebackup%)
  164.  changed%(1)
  165. changed%(0)=
  166. changed%(1)=
  167. 8shutdown_ok%=
  168.  allow shutdown with changes made?
  169. *bootdir$=
  170. striproot(ApplDir$)+".!Boot"
  171.  seqfname$(1)
  172. seqfname$(0)="!Run"
  173. seqfname$(1)="DeskBoot"
  174. loadall
  175. redraw(handle%)
  176.  w%,more%,top%,linenr%,lastline%
  177.  handle%=winhdl%(0) 
  178.   w%=0
  179.   w%=1
  180. blk%!0=handle%
  181.  "Wimp_RedrawWindow",,blk% 
  182.  more%
  183. #top%=blk%!16-blk%!24+icon0ymin%
  184.  more%
  185. *  linenr%=(top%-blk%!40) 
  186.  itemheight%
  187. ,  lastline%=(top%-blk%!32) 
  188.  itemheight%
  189.  linenr%<=lastline%
  190. 0    
  191.  (linenr%<nrapps%(w%)) 
  192.  (linenr%>=0) 
  193. )      
  194.  print item data for this line
  195.       b%=appl%(w%,linenr%)
  196. #      scrapblk%!0=icon0xmin%+12
  197.        scrapblk%!8=icon0xmax%
  198. 7      scrapblk%!12=icon0ymin%-(itemheight%*linenr%)
  199. 0      scrapblk%!4=(scrapblk%!12)-itemheight%
  200.       
  201.  b%!292 
  202. "        scrapblk%!16=&13400133
  203.       
  204. "        scrapblk%!16=&17000133
  205.       
  206.       scrapblk%!20=b%+256
  207.       scrapblk%!24=b%+272
  208.       scrapblk%!28=12
  209. '      
  210.  "Wimp_PlotIcon",,scrapblk%
  211.        scrapblk%!0=icon1xmin%
  212.        scrapblk%!8=icon1xmax%
  213.       
  214.  b%!292 
  215. "        scrapblk%!16=&13000131
  216.       
  217. "        scrapblk%!16=&1B000131
  218.       
  219. &      scrapblk%!20=action%(b%!288)
  220.       scrapblk%!28=-1
  221.       scrapblk%!32=16
  222. '      
  223.  "Wimp_PlotIcon",,scrapblk%
  224.       
  225.  display%(w%)=1 
  226. "        scrapblk%!0=icon2xmin%
  227. "        scrapblk%!8=icon2xmax%
  228.         
  229.  b%!292 
  230. $          scrapblk%!16=&13000131
  231.         
  232. $          scrapblk%!16=&18000131
  233.         
  234.         scrapblk%!20=b%+296
  235.         scrapblk%!28=-1
  236.         scrapblk%!32=256
  237. )        
  238.  "Wimp_PlotIcon",,scrapblk%
  239.       
  240.         
  241.     linenr%+=1
  242.  "Wimp_GetRectangle",,blk% 
  243.  more%
  244. coordtolinenr(w%,y%)
  245.  yc%,l%
  246. scrapblk%!0=winhdl%(w%)
  247.  "Wimp_GetWindowState",,scrapblk%
  248. /yc%=scrapblk%!16-scrapblk%!24+icon0ymin%-y%
  249.  yc%<0 
  250.   l%=-1
  251.   l%=yc% 
  252.  itemheight%
  253.  l%>nrapps%(w%) 
  254.  l%=nrapps%(w%)
  255. coordtofieldnr(w%,x%)
  256. scrapblk%!0=winhdl%(w%)
  257.  "Wimp_GetWindowState",,scrapblk%
  258.  x%-=scrapblk%!4-scrapblk%!20
  259.  x%<icon1xmin% 
  260.   f%=0
  261.  x%<icon2xmin% 
  262.     f%=1
  263.     f%=2
  264. addappl(w%,name$,type%,action%,args$,off%,nr%)
  265.  b%,i%,spr$
  266.  nrapps%(w%)=maxapps% 
  267. dialogue(0)
  268.  nr%<0 
  269.  nr%=0
  270.  nr%<nrapps%(w%) 
  271. 3    
  272.  inserting in sequence - shift other items
  273. #    
  274.  i%=nrapps%(w%) 
  275.  nr% 
  276. %      appl%(w%,i%+1)=appl%(w%,i%)
  277.     nr%=nrapps%(w%)
  278.    b%=
  279. heap_get(applblksize%)
  280.   appl%(w%,nr%)=b%
  281.   $(b%)=name$
  282.    $(b%+256)=
  283. leafname(name$)
  284.   b%!268=type%
  285.  type% 
  286. !    
  287.  0     : spr$="file_???"
  288. "    
  289.  &1000 : spr$="directory"
  290.  &2000
  291. #      
  292. sprexists($(b%+256)) 
  293.         spr$=$(b%+256)
  294.       
  295.         spr$="application"
  296.       
  297.  &FFFFFFFF
  298.       spr$="file_xxx"
  299.         
  300.        spr$="file_"+
  301. ~(type%)
  302.        
  303. sprexists(spr$) 
  304.         spr$="file_xxx"
  305.       
  306.   $(b%+272)="S"+spr$
  307.  action%=-1 
  308. +    
  309.  attach default action to new item
  310.  type% 
  311.       
  312.  &1000 : b%!288=3
  313.       
  314.  &2000
  315. *        
  316.  (osversion%>=300) 
  317.  (w%=1) 
  318.           b%!288=5
  319.         
  320. -          
  321. fileexists(name$+".!Boot") 
  322.             b%!288=1
  323.           
  324. 2            
  325. fileexists(name$+".!Sprites") 
  326.               b%!288=1
  327.             
  328.               b%!288=0
  329.             
  330.           
  331.         
  332.       
  333.  &FF9  : b%!288=2
  334.       
  335.  &FFA  : b%!288=6
  336.       
  337.   : b%!288=0
  338. &        
  339.     b%!288=action%
  340.   b%!292=off%
  341.   $(b%+296)=args$
  342.   nrapps%(w%)+=1
  343. setextent(w%)
  344. setchanged(w%,
  345. redrawfromline(w%,nr%)
  346. redrawline(w%,linenr%)
  347.  xmin%,ymin%,xmax%,ymax%
  348. xmin%=icon0xmin%+12
  349. xmax%=icon2xmax%
  350. 7*ymax%=icon0ymin%-(itemheight%*linenr%)
  351. ymin%=ymax%-itemheight%
  352.  "Wimp_ForceRedraw",winhdl%(w%),xmin%,ymin%,xmax%,ymax%
  353. redrawfromline(w%,linenr%)
  354.  xmin%,ymin%,xmax%,ymax%
  355. xmin%=icon0xmin%+12
  356. xmax%=icon2xmax%
  357. @*ymax%=icon0ymin%-(itemheight%*linenr%)
  358. ymin%=-10000
  359.  "Wimp_ForceRedraw",winhdl%(w%),xmin%,ymin%,xmax%,ymax%
  360. clearsequence(w%)
  361.  nrapps%(w%)>0
  362. deleteappl(w%,nrapps%(w%)-1)
  363. deleteappl(w%,nr%)
  364. heap_release(appl%(w%,nr%))
  365.  i%=nr% 
  366.  (nrapps%(w%)-1)
  367. P!  appl%(w%,i%)=appl%(w%,i%+1)
  368. nrapps%(w%)-=1
  369. redrawfromline(w%,nr%)
  370. setchanged(w%,
  371. setextent(w%)
  372. dirname(F$)
  373.  p%,q%
  374. F$,".",p%)
  375.  q% > 0 
  376.  p%=q%+1
  377.  q%=0
  378. F$,p%-2)
  379. errbox(err$,boxes%)
  380. errblk%!0=0
  381. $(errblk%+4)=err$+
  382.  "Wimp_ReportError",errblk%,boxes%,Appl$ 
  383.  ,click%
  384. =(click%=1)
  385. error
  386.  "Wimp_CloseDown" : 
  387. errbox(
  388. $+" (line "+
  389. )+")",3) 
  390.  "Wimp_CloseDown"
  391. direxists(f$)
  392.  type%,flags%
  393. type%=0
  394. (f$)>0 
  395.  "XOS_File",17,f$ 
  396.  type%;flags%
  397. =(type%=2)
  398. ((flags% 
  399.  1)=0)
  400. fileexists(f$)
  401.  type%,flags%
  402. type%=0
  403. (f$)>0 
  404.  "XOS_File",17,f$ 
  405.  type%;flags%
  406. =(type%=1)
  407. ((flags% 
  408.  1)=0)
  409. seqfname(i%)
  410. =bootdir$+"."+seqfname$(i%)
  411. key(window%,icon%,key%)
  412.  window% 
  413.  filewin%
  414. !    
  415.  (icon%=3) 
  416.  (key%=13) 
  417. #      bootdir$=$(filename_dir%)
  418. (      seqfname$(1)=$(filename_leaf%)
  419. #      
  420. selecticon(filewin%,4,1)
  421. "      
  422.  "Wimp_CreateMenu",,-1
  423. #      
  424. selecticon(filewin%,4,0)
  425.         
  426. #      
  427.  "Wimp_ProcessKey",key%
  428.         
  429. !    
  430.  "Wimp_ProcessKey",key%
  431. leafname(f$)
  432.  p%,q%
  433.   p%=q%+1
  434.   q%=
  435. f$,".",p%)
  436.  q%=0
  437. f$,p%)
  438.  --- split name of root directory from pathname ---
  439. striproot(f$)
  440.  p%,q%
  441. f$,"$")
  442.  q%>0
  443.   p%=q%
  444.   q%=
  445. f$,"$",p%+1)
  446. f$,p%)
  447. loadall
  448.  i%,loaderror%
  449. loaderror%=0
  450.  "Hourglass_On"
  451. direxists(bootdir$) 
  452.  i%=0 
  453. &    
  454. file