home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / utilities / vmecontrol_2 / !VMEctrl / Source / !RunImage (.txt) next >
RISC OS BBC BASIC V Source  |  1995-09-19  |  13KB  |  611 lines

  1.  >!RunImage
  2. taskname$="VMECtrl"
  3. dirname$="<VMECtrl$dir>"
  4. iconname$="!VMECtrl"
  5. menuname$="VMECtrl"
  6. 0vmefiletype%=&9a5:savefiletype%=vmefiletype%
  7. painflag%=
  8. os3%=
  9. os3:soliddragon%=0
  10. inquire%=
  11. dieonsave%=
  12. datamodified%=
  13. nagg(
  14. $+" at line "+
  15.  taskid% 8:$taskid%="TASK"
  16. "Wimp_Initialise",200,!taskid%,taskname$ 
  17.  version%,taskhand%
  18.  block% 1024,ibm% 1024,winm% 1024,wblk% 1024,module% 4096
  19. "OS_File",255,dirname$+".VMEcontrol",module%,0 
  20.  ,,,,modulelength%
  21. "Hourglass_On"
  22. sprites
  23. templates
  24. initmenus
  25. initwindows
  26. iconid%=
  27. "Hourglass_Off"
  28. pollloop
  29. updatevmewindow
  30. pollloop
  31. "Wimp_Poll",1,block% 
  32.  reason%
  33.  reason% 
  34.  2 : 
  35. "Wimp_OpenWindow",,block%
  36.  3 : 
  37.  "Wimp_CloseWindow",,block%
  38.  9 : 
  39. menuclick(block%)
  40.  6 : 
  41. iconclicked(block%!12,block%!16)
  42.  8 : 
  43. keypressed(block%!24)
  44.  17,18:
  45.  7 : 
  46. keypressed(code%)
  47.  code%<>13 
  48. "Wimp_ProcessKey",code%:
  49. "Wimp_GetCaretPosition",,wblk%
  50. 2"  window%=!wblk%:icon%=wblk%!4
  51. 3.  buttons%=4:
  52.  simulate select by default!
  53.  window% 
  54. 5D    
  55.  save% : 
  56. selected(save%,0,-1):
  57. saveok:
  58. selected(save%,0,0)
  59. 6$    
  60. "Wimp_ProcessKey",code%
  61. nagg(nagg$)
  62. "Wimp_ReportError","    "+nagg$,1<<4,taskname$
  63. block%!0=-1
  64. block%!4=0
  65. block%!8=0 : 
  66.  Y DIRECTION
  67. B block%!12=76 : 
  68.  X DIRECTION
  69. block%!16=76
  70. block%!20=&2002
  71. $(block%+24)=iconname$
  72.  "Wimp_CreateIcon",,block% 
  73.  icon%
  74. =icon%
  75. nagg("Error in death throes!"):
  76.  b%=1 
  77.  (b%?fontarray%)>0 
  78. M     
  79.  i%=1 
  80.  (b%?fontarray%)
  81.       
  82. "Font_LoseFont",b%
  83. O        
  84. "Wimp_CloseDown",taskhand%,!taskid%
  85. click_type
  86. c%=block%!8
  87.  c%=4 
  88. select
  89.  c%=2 
  90. popupmenu(
  91.  c%=1 
  92. adjust
  93.  block%!16 
  94. saveack
  95. filedrop
  96. loadack
  97. dataopen
  98. filedrop
  99.  (block%!20=main% 
  100.  block%!20=-2) 
  101.  (block%!40=vmefiletype%) 
  102. checkload(
  103. file(block%+44),block%!40)
  104. file(where%)
  105. file$=""
  106.  ?where%
  107. file$+=
  108. (?where%)
  109. where%+=1
  110. =file$
  111. initmenus
  112. t"  i%=
  113. initmenu(ibm%,menuname$)
  114. u'  i%=
  115. additem(i%,"Info",0,inf_win%)
  116. v$  i%=
  117. additem(i%,"Save",0,save%)
  118. w"  i%=
  119. additem(i%,"Quit",-1,-1)
  120. y#  i%=
  121. initmenu(winm%,menuname$)
  122. z'  i%=
  123. additem(i%,"Info",0,inf_win%)
  124. {$  i%=
  125. additem(i%,"Save",0,save%)
  126. |"  i%=
  127. additem(i%,"Quit",-1,-1)
  128. popupmenu(bar%)
  129.  inquire% 
  130.  "Wimp_GetPointerInfo",,block%
  131. 2q=!block%:w=block%!4:w%=block%!12:i%=block%!16
  132.  bar% 
  133.  w=96+44*3 
  134.  w+=22
  135.  bar% 
  136.  menu%=ibm% 
  137.  menu%=winm%
  138.  "Wimp_CreateMenu",,menu%,q-64,w
  139. &lastmenu%=menu%:menx%=q-64:meny%=w
  140. templates
  141.  fontarray% 256
  142.  b%=0 
  143.  252 
  144. b%!fontarray%=0
  145.  infb% 500,infi% 128
  146.  autb% 864,auti% 204
  147.  savb% 600,savi% 328
  148.  maib% 1024,maii% 300
  149. "Wimp_OpenTemplate",,dirname$+".templates"
  150. Binf_win%=
  151. template("info",infb%,infi%,200,fontarray%,sprites%)
  152. Daut_win%=
  153. template("author",autb%,auti%,300,fontarray%,sprites%)
  154. ?save%=
  155. template("save",savb%,savi%,400,fontarray%,sprites%)
  156. Cmain%=
  157. template("vmectrl",maib%,maii%,1024,fontarray%,sprites%)
  158. "Wimp_CloseTemplate"
  159. template(name$,buf%,ind%,len%,fonts%,sprs%)
  160. "Wimp_LoadTemplate",,buf%,ind%,ind%+len%,fonts%,name$,0
  161. buf%!64=sprs%
  162. "Wimp_CreateWindow",,buf% 
  163.  handle%
  164. =handle%
  165. sprites
  166. #file%=
  167. (dirname$+".SpriteFile")
  168.  file%=0 
  169. nagg("Can't find spritefile!"):
  170. #file%)+128
  171. #file%
  172.  sprites% S%
  173. sprites%!0=S%
  174. sprites%!8=16
  175. "OS_SpriteOp",9+256,sprites%
  176. "OS_SpriteOp",10+256,sprites%,dirname$+".SPRITEFILE"
  177. select
  178. openwindow(main%)
  179. adjust
  180. openwindow(aut_win%)
  181. openwindow(window%)
  182. !wblk%=window%
  183. "Wimp_GetWindowState",,wblk%
  184. wblk%!28=-1
  185. flags%=wblk%!32
  186.  (flags% 
  187.  1<<16)=0 
  188.   !wblk%=window%
  189. "Wimp_GetWindowInfo",,wblk%
  190. /  mwid%=
  191. read_mode(-1,11)<<
  192. read_mode(-1,4)
  193. /  mhig%=
  194. read_mode(-1,12)<<
  195. read_mode(-1,5)
  196. !  width%=(wblk%!12)-(wblk%!4)
  197. "  height%=(wblk%!16)-(wblk%!8)
  198. "  wblk%!4=mwid% 
  199. 2 - width% 
  200.   wblk%!12=(wblk%!4)+width%
  201. $  wblk%!8=mhig% 
  202. 2 - height% 
  203.   wblk%!16=wblk%!8+height%
  204.   wblk%!28=-1
  205. "Wimp_OpenWindow",,wblk%
  206. pii(window%,icon%,text$)
  207. !wblk%=window%
  208. wblk%!4=icon%
  209. "Wimp_GetIconState",,wblk%
  210. %ot$=$(wblk%!28):$(wblk%!28)=text$
  211. wblk%!8=0
  212. wblk%!12=0
  213.  ot$<>text$ 
  214. "Wimp_SetIconState",,wblk%
  215. contents(window%,icon%)
  216. !wblk%=window%
  217. wblk%!4=icon%
  218. "Wimp_GetIconState",,wblk%
  219. =$(wblk%!28)
  220. closewindow(window%)
  221. !wblk%=window%
  222. "Wimp_CloseWindow",,wblk%
  223. changeval(window%,icon%,to$)
  224. !wblk%=window%
  225. wblk%!4=icon%
  226. "Wimp_GetIconState",,wblk%
  227. $(wblk%!32)=to$
  228. wblk%!8=0
  229. wblk%!12=0
  230. "Wimp_SetIconState",,wblk%
  231. selected(window%,icon%,well%)
  232. !wblk%=window%
  233. wblk%!4=icon%
  234. wblk%!12=1<<21
  235. wblk%!8=(-well%)<<21
  236. "Wimp_SetIconState",,wblk%
  237. isselected(win%,icon%)
  238. !wblk%=win%:wblk%!4=icon%
  239. "Wimp_GetIconState",,wblk%
  240. =((wblk%!24) 
  241.  1<<21)<>0
  242. menuselection(blk%,menu%)
  243. "Wimp_DecodeMenu",,menu%,blk%,wblk%+64
  244. =$(wblk%+64)
  245. menuclick(brtnd%)
  246. ,  item$=
  247. menuselection(brtnd%,lastmenu%)
  248.  PROCnagg(item$)
  249.  item$ 
  250.  "Quit" : 
  251. @    
  252.  "Info" : 
  253. "Wimp_CreateMenu",,-1:
  254. openwindow(aut_win%)
  255.  "Save" : 
  256. saveok
  257. openwindowxy(window%,x%,y%)
  258. !wblk%=window%
  259. "Wimp_GetWindowState",,wblk%
  260.   !wblk%=window%
  261. "Wimp_GetWindowInfo",,wblk%
  262. !  width%=(wblk%!12)-(wblk%!4)
  263.    hite%=(wblk%!16)-(wblk%!8)
  264.   wblk%!4=x%
  265.   wblk%!12=(wblk%!4)+width%
  266.   wblk%!16=y%
  267.   wblk%!8=(wblk%!16)-hite%
  268.   wblk%!28=-1
  269. "Wimp_OpenWindow",,wblk%
  270. saveclicked(xx%,yy%)
  271. openwindowxy(save%,xx%,yy%)
  272. initwindows
  273. changeval(save%,2,"Sfile_"+
  274. ~(vmefiletype%))
  275. pii(main%,3,
  276. pii(save%,1,"VME")
  277. selected(save%,4,
  278. updatevmewindow
  279. loadack
  280. block%!12=block%!8
  281. block%!16=4
  282.  "Wimp_SendMessage",19,block%,block%!4
  283. saveack
  284. name$=
  285. file(block%+44)
  286. leafname(name$)="" 
  287.  NO FILE NAME!
  288. block%!16=3
  289. "Wimp_SendMessage",17,block%,block%!4
  290. pii(save%,1,name$)
  291. saveok
  292. saveok
  293. closewindow(save%)
  294. "Wimp_CreateMenu",,-1
  295. / filename$=
  296. contents(save%,1)
  297. savefile(filename$)
  298.  dieonsave% 
  299. startdrag(window%,icon%)
  300. solid%=
  301. usedragasprite
  302. block%!0=window%
  303.  "Wimp_GetWindowState",,block%
  304. wx%=block%!4-block%!20
  305. wy%=block%!16-block%!24
  306. block%!4=icon%
  307.  "Wimp_GetIconState",,block%
  308. block%!0=window%
  309. block%!4=5
  310. block%!8+=wx%
  311. block%!12+=wy%
  312. block%!16+=wx%
  313. block%!20+=wy%-2
  314. block%!24=0
  315. block%!28=0
  316. D6block%!32=(
  317. read_mode(-1,11)+1)*2^
  318. read_mode(-1,4)
  319. E6block%!36=(
  320. read_mode(-1,12)+1)*2^
  321. read_mode(-1,5)
  322.  solid% 
  323. G"  spr$="file_"+
  324. ~savefiletype%
  325. "DragASprite_Start",%10001010,1,spr$,block%+8
  326.   soliddragon%=
  327.  "Wimp_DragBox",,block%
  328.   soliddragon%=
  329. read_mode(mode%,var%)
  330.  "OS_ReadModeVariable",mode%,var% 
  331.  ,,value%
  332. =value%
  333.  soliddragon% 
  334. "DragASprite_Stop"
  335.  "Wimp_GetPointerInfo",,block%
  336. mx%=block%!0
  337. my%=block%!4
  338. window%=block%!12
  339.  window%<1 
  340. ['name$=
  341. leafname(
  342. contents(save%,1))
  343. \#block%!0=44+((
  344.  name$ 
  345.  4)+1)*4
  346. block%!16=1
  347. block%!20=window%
  348. block%!24=-1
  349. block%!28=mx%
  350. block%!32=my%
  351. block%!36=&100
  352. block%!40=savefiletype%
  353. $(block%+44)=name$+
  354.  "Wimp_SendMessage",17,block%,window%
  355. leafname(name$)
  356. leaf$=""
  357.  name$<>"" 
  358. name$,1)<>"."
  359.   leaf$=
  360. name$,1)+leaf$
  361.   name$=
  362. name$)
  363. =leaf$
  364. pad(num%)
  365. "   "+
  366. (num%),4)
  367. "OS_Module",20,0,-1 
  368.  ,,,name$,,,v%
  369. u,=(name$="UtilityModule" 
  370.  v%>=&30000)<>0
  371. usedragasprite
  372. "OS_Byte",161,&1C 
  373.  ,,value%
  374. =(value% 
  375.  2)<>0 
  376.  os3%
  377. filedrag
  378. startdrag(save%,2)
  379. dataopen
  380. type%=block%!40
  381.  type%<>vmefiletype% 
  382. loadack
  383. name$=
  384. file(block%+44)
  385. checkload(name$,type%)
  386. checkload(name$,type%)
  387.  type% 
  388.  vmefiletype% : 
  389. loadfile(name$)
  390. linef(
  391.  a$,l%)
  392.  ll%,b$
  393.   b$=
  394. a$,l%)
  395. (b$)=l% 
  396. *    
  397. ".,! ?):%;",
  398. b$,1))=0 
  399.  b$<>""
  400.       b$=
  401. (b$)-1)
  402.         
  403.  b$="" 
  404. a$,l%)
  405.   a$=
  406. (a$)-
  407. (b$))
  408. b$,1)=" " 
  409. (b$)-1)
  410.  DEFFNquery(q$,a$,b$)
  411. "Wimp_ReportError","    "+q$+" OK="+b$+" Cancel="+a$,3 
  412.  ,bob%
  413. =bob%=1
  414. query(q$,a$,b$)
  415. *  qq$=
  416. linef(q$,32):
  417. pii(query%,3,qq$)
  418. *  qq$=
  419. linef(q$,32):
  420. pii(query%,4,qq$)
  421. *  qq$=
  422. linef(q$,40):
  423. pii(query%,5,qq$)
  424. *  qq$=
  425. linef(q$,40):
  426. pii(query%,6,qq$)
  427. pii(query%,2,a$):
  428. pii(query%,7,b$)
  429. openwindow(query%)
  430.   inquire%=
  431. pollloop
  432.  inquire%=
  433. =inqbut%
  434. loadfile(name$)
  435. pii(save%,1,name$)
  436.   loadfile$=name$
  437. "VME_LoadMap",loadfile$
  438. iconclicked(window%,icon%)
  439. buttons%=block%!8
  440.  window%<0 
  441.  icon%=iconid% 
  442. click_type:
  443.  (block%!8)=2 
  444.  window%=-2 
  445. popupmenu(icon%=iconid%):
  446.  window%=main% 
  447. popupmenu(
  448.  painflag% 
  449.  window%=pain% 
  450. popupmenu(
  451.  window% 
  452.  save% : 
  453.  icon% 
  454. &    
  455.  2 : 
  456.  buttons%>=16 
  457. filedrag
  458.  0 : 
  459. saveok
  460. E    
  461.  3 : 
  462. closewindow(save%):dieonsave%=
  463. "Wimp_CreateMenu",-1
  464. '    
  465.  4 : 
  466. isselected(save%,4) 
  467. 3               
  468.  : savefiletype%=vmefiletype%
  469. ,               
  470.   : savefiletype%=&FFA
  471.              
  472. =             
  473. changeval(save%,2,"Sfile_"+
  474. ~savefiletype%)
  475.  aut_win% : 
  476.  icon%=16 
  477. closewindow(aut_win%)
  478.  inf_win% : 
  479.  icon%=2 
  480. "Wimp_CreateMenu",,-1:
  481. openwindow(aut_win%)
  482.  main% : 
  483.  icon% 
  484. 4    
  485.  10 : 
  486. "VME_Control",
  487. isselected(main%,10)
  488. 7    
  489.  11 : 
  490. "VME_WriteMap",
  491. isselected(main%,11)
  492.  1  : 
  493. mode_down
  494.  2  : 
  495. mode_up
  496.  4  : mode%=
  497. modetest
  498. J              
  499.  mode%>=0 
  500. "VME_WriteMap",mode%,
  501. isselected(main%,4)
  502.  13 : 
  503. savewindow
  504. quit:
  505. initmenu(menu%,menuname$)
  506. 2$menu%=menuname$:               : 
  507.  menu title
  508. Emenu%?12=7:menu%?13=2           : 
  509.  title foreground & background
  510. Emenu%?14=7:menu%?15=0           : 
  511.  menu  foreground & background
  512. (menuname$)>5 
  513. "  menu%!16=(
  514. (menuname$)+1)*16
  515.   menu%!16=6*16
  516. 2menu%!20=44        : 
  517.  width & height of items
  518. @menu%!24=0                      : 
  519.  vertical gap twixt items
  520. =menu%+28
  521. additem(menu%,text$,last%,sub%)
  522.  last% 
  523.  !menu%=128 
  524.  !menu%=0
  525. menu%!4=sub%
  526. menu%!8=&7000021
  527. $(menu%+12)=text$
  528. =menu%+24
  529. updatevmewindow
  530. "VME_Status" 
  531.  vmeon%:vmeon%=vmeon%<>0
  532. "VME_ReadMap",
  533.  ,vmecfg%:vmecfg%=vmecfg%<>0
  534. pii(main%,12,"Mode "+
  535. #  ves%=
  536. isselected(main%,10)<>0
  537. #  vec%=
  538. isselected(main%,11)<>0
  539.  ves%<>vmeon% 
  540. selected(main%,10,vmeon%)
  541.  vec%<>vmecfg% 
  542. selected(main%,11,vmecfg%)
  543. 1  mode%=
  544. modetest:
  545.  mode%<0 
  546.  mode%=
  547. modetest
  548. "VME_ReadMap",mode% 
  549.  ,vmecfg%:vmecfg%=vmecfg%<>0
  550. "  vec%=
  551. isselected(main%,4)<>0
  552.  vec%<>vmecfg% 
  553. selected(main%,4,vmecfg%)
  554. modetest
  555. .  mode%=
  556. contents(main%,3)):nmode%=mode%
  557.  mode%<0 
  558. nagg("Hmm, negative mode number. Not good, Batman."):nmode%=0
  559.  mode%>127 
  560. nagg("Maximum mode number is 127"):nmode%=127
  561.  nmode%<>mode% 
  562. pii(main%,3,
  563. (nmode%)):mode%=-1
  564. =mode%
  565. mode_up
  566.   mode%=
  567. modetest
  568.  mode%<127 
  569. pii(main%,3,
  570. (mode%+1))
  571. mode_down
  572.   mode%=
  573. modetest
  574.  mode%>0 
  575. pii(main%,3,
  576. (mode%-1))
  577. savewindow
  578.  "Wimp_GetPointerInfo",,block%
  579. 2q=!block%:w=block%!4:w%=block%!12:i%=block%!16
  580. openwindowxy(save%,q,w)
  581. savefile(as$)
  582.  savefiletype% 
  583. ,    
  584.  vmefiletype% : 
  585. "VME_SaveMap",as$
  586. (    
  587.  &FFA         : 
  588. newmodule(as$)
  589. saveerror
  590.  filehandle% 
  591. #filehandle%
  592.   filehandle%=0
  593. nagg("File save operation failed: "+
  594. newmodule(saveas$)
  595. "  table%=module%+modulelength%
  596.  table%?-1<>255:table%-=1:
  597.  m%=0 
  598.      
  599. "VME_ReadMap",m% 
  600. #    
  601.  ?table%=m%:table%+=1
  602.   ?table%=128:table%+=1
  603. "XOS_File",10,saveas$,&FFA,,module%,table% 
  604.  err%
  605.  err%=10 
  606.   mp%=err%+4:mess$=""
  607.  ?mp%>31
  608.     mess$+=
  609. ?mp%:mp%+=1
  610. nagg("Module save operation failed: "+mess$)
  611.