home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / utilities / utilsd / drwimp / Utils / !MakeApp2 / Source (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-09-03  |  12KB  |  484 lines

  1.  ><MakeApp2$Dir>.Source
  2.  This application is FreeWare. (c) 1994 Dick Alstein
  3. Appl$="MakeApp2"
  4. "ApplVersion$="1.00 (3-Sep-94)"
  5. error
  6. quit%=
  7.     5mask%=(1<<0)+(1<<4)+(1<<5)+(1<<7)+(1<<11)+(1<<12)
  8.  "Wimp_Poll",mask%,blk% 
  9.  reason%
  10.  reason% 
  11. (    
  12.  2 : 
  13.  "Wimp_OpenWindow",,blk%
  14. )    
  15.  3 : 
  16.  "Wimp_CloseWindow",,blk%
  17. ?    
  18.  6 : 
  19. mouseclick(blk%!0,blk%!4,blk%!8,blk%!12,blk%!16)
  20.      
  21.  7 : 
  22. startsavedialogue
  23. *    
  24.  8 : 
  25.  "Wimp_ProcessKey",blk%!24
  26.  9 : 
  27. menuselect(blk%)
  28. 1    
  29.  17,18 : 
  30. receive(blk%!4,blk%!8,blk%!16)
  31.  quit%
  32.  "Wimp_CloseDown"
  33.  tfn$
  34.  errblk% &100
  35.  "Wimp_Initialise",200,&4B534154,Appl$ 
  36.  osversion%,thistask%
  37. error
  38.  scrapblk% 256
  39. blksize%=16*1024
  40.  blk% blksize%
  41. indsize%=&200
  42.  indir% indsize%
  43. indirend%=indir%+indsize%
  44.  ptrinfo% 24
  45. scrapblk%!0=-1
  46. &!scrapblk%!4=0 : scrapblk%!8=0
  47. '%scrapblk%!12=68 : scrapblk%!16=68
  48. scrapblk%!20=&7000301A
  49. $(scrapblk%+24)="!MakeApp2"
  50.  "Wimp_CreateIcon",,scrapblk% 
  51.  baricon%
  52.  osversion%<310 
  53. ,&  tfn$="<MakeApp2$Dir>.Templates2"
  54. .%  tfn$="<MakeApp2$Dir>.Templates"
  55.  "Wimp_OpenTemplate",,tfn$
  56. 1"infowin%=
  57. loadtemplate("Info")
  58. 2%$(blk%!(92+7*32+20))=ApplVersion$
  59. 3%savewin%=
  60. loadtemplate("SaveBox")
  61. 4 savefname%=blk%!(92+0*32+20)
  62. 5$optwin%=
  63. loadtemplate("Options")
  64. 6"outputfname%=blk%!(92+5*32+20)
  65.  "Wimp_CloseTemplate"
  66. initmenus
  67. readscreenvars
  68. status_load
  69. selecticon(optwin%,1,preserveargs%)
  70. selecticon(optwin%,3,sameleafname%)
  71. selecticon(optwin%,4,
  72.  sameleafname%)
  73. codesize%=&200
  74.  armcode% codesize%
  75. loadprologue
  76. dirname(F$)
  77.  p%,q%
  78. F$,".",p%)
  79.  q% > 0 
  80.  p%=q%+1
  81.  q%=0
  82. F$,p%-2)
  83. errbox(err$,boxes%)
  84. errblk%!0=0
  85. $(errblk%+4)=err$+
  86.  "Wimp_ReportError",errblk%,boxes%,Appl$ 
  87.  ,click%
  88. =(click%=1)
  89. error
  90.  "Wimp_CloseDown" : 
  91. errbox(
  92. $+" (line "+
  93. )+")",3) 
  94.  "Wimp_CloseDown"
  95. fileexists(f$)
  96.  type%,flags%
  97. type%=0
  98. (f$)>0 
  99.  "XOS_File",17,f$ 
  100.  type%;flags%
  101. =(type%=1)
  102. ((flags% 
  103.  1)=0)
  104. filesize(f$)
  105.  size%
  106. (f$)>0 
  107.  "OS_File",17,f$ 
  108.  ,,,,size%
  109. =size%
  110. initmenus
  111.  "MenuUtil_Initialise",010,0
  112.  "MenuUtil_New",,Appl$ 
  113.  mainmenu%
  114.  "MenuUtil_Add",mainmenu%,"Info" 
  115.  item_info%
  116.  "MenuUtil_Add",mainmenu%,"Options..." 
  117.  item_options%
  118.  "MenuUtil_Add",mainmenu%,"Quit" 
  119.  item_quit%
  120.  "MenuUtil_SubMenu",item_info%,infowin%
  121. leafname(f$)
  122.  p%,q%
  123.   p%=q%+1
  124.   q%=
  125. f$,".",p%)
  126.  q%=0
  127. f$,p%)
  128. loadprologue
  129.  fn$,f%
  130. ~!fn$="<MakeApp2$Dir>.Prologue"
  131.  prologuesize%=
  132. filesize(fn$)
  133.  prologue% prologuesize%
  134.  "OS_GBPB",4,f%,prologue%,prologuesize%
  135.  prologue%?i%<>&FF
  136. 4  prologue%?i%=0       : 
  137.  set the line no. to 0
  138.   prologue%?(i%+1)=0
  139. 2  i%+=prologue%?(i%+2) : 
  140.  on to the next line
  141. 9prologuesize%=i%-1 : 
  142.  omit the terminating &0D + &FF
  143. loadtemplate(name$)
  144.  handle%
  145.  "Wimp_CloseTemplate" : 
  146. error
  147.  "Wimp_LoadTemplate",,blk%+4,indir%,indirend%,-1,name$,0 
  148.  ,,indir%
  149.  "Wimp_CreateWindow",,blk%+4 
  150.  handle%
  151. =handle%
  152. menuselect(selection%)
  153.  "Wimp_GetPointerInfo",,ptrinfo%
  154.  selection%!0 
  155. openoptionswin
  156.     quit%=
  157.  (ptrinfo%!8 
  158. showmenu(0)
  159. mouseclick(xpos%,ypos%,button%,wndw%,icon%)
  160.  wndw% 
  161.  button% 
  162.       
  163.         
  164. openoptionswin
  165.       
  166.         
  167. showmenu(blk%)
  168.         
  169.  savewin%
  170.  icon% 
  171.       
  172.  1 : 
  173. startsavedrag
  174.         
  175.  optwin%
  176.  icon% 
  177.       
  178. )        preserveargs%=
  179.  preserveargs%
  180.       
  181.         sameleafname%=
  182.       
  183.         sameleafname%=
  184.       
  185.         
  186. status_save
  187.         scrapblk%!0=optwin%
  188. ,        
  189.  "Wimp_CloseWindow",,scrapblk%
  190.       
  191.         scrapblk%!0=optwin%
  192. ,        
  193.  "Wimp_CloseWindow",,scrapblk%
  194.         
  195. openoptionswin
  196.  dx%,dy%
  197.     dx%=0
  198.     dy%=0
  199. blk%!0=optwin%
  200.  "Wimp_GetWindowState",,blk%
  201.  (blk%!32 
  202.  (1<<16))=0 
  203.  center window to screen if not already open
  204. .  dx%=(screensize_x%-(blk%!12+blk%!4)) 
  205. .  dy%=(screensize_y%-(blk%!16+blk%!8)) 
  206. blk%!4=blk%!4+dx%
  207. blk%!8=blk%!8+dy%
  208. blk%!12=blk%!12+dx%
  209. blk%!16=blk%!16+dy%
  210. blk%!28=-1
  211.  "Wimp_OpenWindow",,blk%
  212. readscreenvars
  213.  xeig%,yeig%,xpixels%,ypixels%
  214.  "OS_ReadModeVariable",-1,4 
  215.  ,,xeig%
  216.  "OS_ReadModeVariable",-1,5 
  217.  ,,yeig%
  218.  "OS_ReadModeVariable",-1,11 
  219.  ,,xpixels%
  220.  "OS_ReadModeVariable",-1,12 
  221.  ,,ypixels%
  222. Escreensize_x%=(xpixels%+1)*(1<<xeig%) : 
  223.  screen size in OS units
  224. )screensize_y%=(ypixels%+1)*(1<<yeig%)
  225. receive(sender%,ref%,code%)
  226.  ack%,icon%,window%,fname$,ftype%,fsize%,hlp$
  227. ack%=0
  228.  sender% <> thistask% 
  229.  code% 
  230.  0 : quit%=
  231. $      outputfname$=
  232. str(blk%+44)
  233.       
  234. startconversion
  235. "      
  236.  "Wimp_CreateMenu",,-1
  237.       ack%=3
  238.       window%=blk%!20
  239.       icon%=blk%!24
  240.       fname$=
  241. str(blk%+44)
  242.       ftype%=blk%!40
  243.       
  244.  (ftype%=&FFB) 
  245.         inputfname$=fname$
  246.         inputfsize%=blk%!36
  247.         
  248.  sameleafname% 
  249. 2          $(savefname%)=
  250. leafname(inputfname$)
  251.         
  252. +          $(savefname%)=$(outputfname%)
  253.         
  254.          scrapblk%!0=savewin%
  255. /        
  256.  "Wimp_GetWindowState",,scrapblk%
  257. .        
  258.  "Wimp_GetPointerInfo",,ptrinfo%
  259. -        
  260.  (window%=-2)
  261. (icon%=baricon%) 
  262. >          xpos%=ptrinfo%!0-((scrapblk%!12-scrapblk%!4)
  263. /          ypos%=96+scrapblk%!16-scrapblk%!8
  264.         
  265. >          xpos%=ptrinfo%!0-((scrapblk%!12-scrapblk%!4)
  266. >          ypos%=ptrinfo%!4+((scrapblk%!16-scrapblk%!8)
  267.         
  268. 6        
  269.  "Wimp_CreateMenu",,savewin%,xpos%,ypos%
  270.       
  271.  &400C1
  272.       
  273. readscreenvars
  274.  ack%<>0 
  275.     blk%!0=256
  276.     blk%!12=ref%
  277.     blk%!16=ack%
  278. -    
  279.  "Wimp_SendMessage",17,blk%,sender%
  280. selecticon(window%,icon%,f%)
  281. scrapblk%!0=window%
  282. scrapblk%!4=icon%
  283.   scrapblk%!8=1<<21
  284.   scrapblk%!8=0
  285. scrapblk%!12=1<<21
  286.  "Wimp_SetIconState",,scrapblk%
  287. iconselected(window%,icon%)
  288. scrapblk%!0=window%
  289. scrapblk%!4=icon%
  290.  "Wimp_GetIconState",,scrapblk%
  291. #=((scrapblk%!24) 
  292.  (1<<21)) > 0
  293. shadeicon(window%,icon%,f%)
  294. scrapblk%!0=window%
  295. scrapblk%!4=icon%
  296.   scrapblk%!8=(1<<22)
  297.   scrapblk%!8=0
  298. scrapblk%!12=1<<22
  299.  "Wimp_SetIconState",,scrapblk%
  300. showmenu(blkptr%)
  301.  "MenuUtil_Show",mainmenu%,blkptr%
  302. startsavedialogue
  303.  dragasprite% 
  304.  "DragASprite_Stop"
  305. blk%!0=64
  306. blk%!12=0
  307. blk%!16=1
  308.  "Wimp_GetPointerInfo",,ptrinfo%
  309. blk%!20=ptrinfo%!12
  310. blk%!24=ptrinfo%!16
  311. blk%!28=ptrinfo%!0
  312. blk%!32=ptrinfo%!4
  313. blk%!36=inputfsize%
  314. blk%!40=&FF8
  315. ;*$(blk%+44)=
  316. leafname($(savefname%))+
  317.  "Wimp_SendMessage",17,blk%,ptrinfo%!12,ptrinfo%!16
  318. startsavedrag
  319.  b%,win0x%,win0y%
  320. scrapblk%!0=savewin%
  321.  "Wimp_GetWindowState",,scrapblk%
  322. C#win0x%=scrapblk%!4-scrapblk%!20
  323. D$win0y%=scrapblk%!16-scrapblk%!24
  324. scrapblk%!0=savewin%
  325. scrapblk%!4=1
  326.  "Wimp_GetIconState",,scrapblk%
  327. blk%!4=5
  328. blk%!8=scrapblk%!8+win0x%
  329. blk%!12=scrapblk%!12+win0y%
  330. blk%!16=scrapblk%!16+win0x%
  331. blk%!20=scrapblk%!20+win0y%
  332.  "Wimp_GetPointerInfo",,ptrinfo%
  333. blk%!24=blk%!8-ptrinfo%!0
  334. blk%!28=blk%!12-ptrinfo%!4
  335. P,blk%!32=screensize_x%+blk%!16-ptrinfo%!0
  336. Q,blk%!36=screensize_y%+blk%!20-ptrinfo%!4
  337.  "OS_Byte",161,&1C 
  338.  ,,b%
  339. dragasprite%=(b% 
  340.  2)<>0
  341.  dragasprite% 
  342.  "DragASprite_Start",&A1,1,"file_ff8",blk%+8,blk%+24
  343.  "Wimp_DragBox",1,blk%
  344. status_default
  345. preserveargs%=
  346. sameleafname%=
  347. $(outputfname%)="!RunImage"
  348. status_load
  349.  ofn$
  350. d#F%=
  351.  ("<MakeApp2$Dir>.Options")
  352.  F%=0 
  353. status_default
  354.  #F% : 
  355. error : 
  356. status_default : 
  357. #F%,preserveargs%,sameleafname%,ofn$
  358.   $(outputfname%)=ofn$
  359. status_save
  360. q#F%=
  361.  ("<MakeApp2$Dir>.Options")
  362.  #F% : 
  363. error : 
  364. #F%,preserveargs%,sameleafname%,$(outputfname%)
  365. str(s%)
  366.  i%,n$
  367.  (s%?i%>=32) 
  368.  (i%<255)
  369.   n$+=
  370. (s%?i%)
  371.   i%+=1
  372. startconversion
  373.  fi%,fo%,bytesnotread%
  374. )inputfilesize%=
  375. filesize(inputfname$)
  376. assemble
  377.  inputfname$
  378.  inputfname$=outputfname$ 
  379.   fo%=
  380.  "<Wimp$Scrap>"
  381.   fo%=
  382.  outputfname$
  383.  (fi%<>0) 
  384.  (fo%<>0) 
  385.  "OS_GBPB",2,fo%,code_start,(program_start-code_start)
  386.  preserveargs% 
  387. 2    
  388.  "OS_GBPB",2,fo%,prologue%,prologuesize%
  389.  copy original program to output
  390. ;    
  391.  "OS_GBPB",4,fi%,blk%,blksize% 
  392.  ,,,bytesnotread%
  393. 8    
  394.  "OS_GBPB",2,fo%,blk%,(blksize%-bytesnotread%)
  395.  inputfname$=outputfname$ 
  396. +    
  397.  "OS_File",18,"<Wimp$Scrap>",&FF8
  398. 5    
  399.  "Copy <Wimp$Scrap> "+inputfname$+" ~C D F "
  400. )    
  401.  "OS_File",18,outputfname$,&FF8
  402. assemble
  403.     LR=14
  404.     PC=15
  405.  preserveargs% 
  406. /  programsize%=prologuesize%+inputfilesize%
  407. !  programsize%=inputfilesize%
  408. dblquote$=
  409.  pass%=8 
  410.   P%=armcode%
  411.   L%=armcode%+codesize%
  412.   [ OPT pass%
  413. .code_start
  414. #  ; copy Basic program to &9000
  415.   LDR     R1,program_size
  416.   LDR     R2,program_end
  417.   LDR     R3,program_dest
  418. .copyabyte
  419.   LDRB    R0,[R2],#-1
  420.   STRB    R0,[R3],#-1
  421.   SUBS    R1,R1,#1
  422.   BNE     copyabyte
  423.  preserveargs% 
  424.   [ OPT pass%
  425. "  ; construct new command line
  426. G  SWI     "OS_GetEnv"        ; get pointer to original command line
  427.    ADR     R2,newcmdline_rest
  428. O.copyachar                   ; copy first part (=name