home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / t / tornado / Guide / 3 < prev    next >
Encoding:
Text File  |  1995-09-23  |  5.7 KB  |  129 lines

  1. The Tornado shell
  2. -=-=-=-=-=-=-=-=-
  3.  
  4. Well, this time I can actually write something about the tornado shell - some
  5. it has been written, and much more finalised.
  6.  
  7. When you start up your RISC-OS computer, and display a directory containing
  8. !Tornado (tornado's resource directory), it loads itself in and installs its
  9. resources. TShell sets itself up as a Wimp task, and claims a section of
  10. application space on MEMC1/1a machines, or a dynamic area on later
  11. architectures. It then starts up the multitasker in the memory space, and
  12. starts up a small task which handles tornado's user interactions.
  13.    From hence, all files double clicked on in the filer are intercepted, and
  14. checked to see if they are wimp apps. If so, they are returned to the wimp,
  15. and if not a new memory domain is created, the image loaded in, and execution
  16. started.
  17.    The code is now preempted, and a handler is installed on WrchV which upon
  18. vdu output creates a 640x512x2 sprite, and redirects vdu output and the
  19. OS_ReadVduVariables into it (thus allowing most games to work). The task can
  20. run nicely in its window, or if the user chooses they can move the task to
  21. full screen use. Note that during full screen use, either full, partial or no
  22. multitasking is retained [1].
  23.    On the other hand, if the image calls Tornado_Initialise before outputting
  24. to the vdu, the handler is removed and tornado searches the home path for the
  25. options, templates, messages and menu files. These are all loaded in by
  26. tornado, and installed in memory.
  27.  
  28. Writing for tornado
  29. -=-=-=-=-=-=-=-=-=-
  30.  
  31. Code written for tornado is done using a visual editor, similar to that used
  32. on other platforms. You create an application, and then design the windows to
  33. be used in it. To the various parts of each window you attach code segments,
  34. written using Zap via the external edit protocol.
  35.    Probably the best way to explain this is to write a program, here and
  36. now. Ok then: how about a program which will update a window in real-time
  37. according to the amount of space available on a disc drive?
  38.  
  39. Firstly, you create a new application (which appears as a icon in the loaded
  40. apps window), and then you create a window in it by dragging the 'create
  41. window' tool onto the window icon. The new window pops up. Inside the window
  42. you create a text icon with "Free:" in it by dragging one of the predefined
  43. text icons into it, and beside it a green raised icon - also from the
  44. predefined icon library. Now, you use the Basic link tool to attach a section
  45. of Basic to that icon, and make the code callable on every refresh. Up pops
  46. an empty function in a Zap window:
  47.  
  48. DEF FNicon1
  49. LOCAL 
  50.  
  51. =
  52.  
  53. Now, you change this to:
  54.  
  55. DEF FNicon1(disc$)
  56. LOCAL free%
  57. REM By right I should check for other FS's
  58. SYS "ADFS_FreeSpace",disc$ TO free%
  59. =free%/4096
  60.  
  61. ... and change the code entry to
  62. 'wi=FNicon1(MID$("%ti",1,INSTR("%ti",":")))'. This, by the way, set the width
  63. of the icon this code is attached to to the returned result of FNicon1.
  64. FNicon1 is passed the result of 'MID$("%ti",1,INSTR("%ti",":"))', where %ti
  65. is replaced with the text in the title bar (which BTW would have code
  66. attached to it setting it to the media this window is referring to)
  67.    From hence, everytime the window is opened this code is called, and the
  68. bar set to the correct value. But this isn't real time, is it?
  69.  
  70. The trick is to set up a ticker. This is done by specifying a ticker
  71. countdown in cs, and every x cs the code is called. Here's the code:
  72.  
  73. DEF FNticker1(handle%)
  74. IF !updated% THEN SYS "Tornado_OpenWindow",handle%
  75. =0
  76.  
  77. This checks !updated, and if it's true reopens the window. BTW, the link code
  78. for this would be: 'FNticker1(%th)', where the handle of the window owning
  79. the icon is substituted in for %th.
  80.  
  81. But how would !updated% be altered. By setting up a handler, in this case a
  82. window create handler. This code gets called on every window created:
  83.  
  84. DEF FNhandler1(wkspace%,disc$)
  85.  LOCAL P%,N%,blk%,addr%
  86.  SYS "Tornado_Getblk",%1,0,1024 TO ,,,blk%
  87.  SYS "Tornado_Extblk",,0,+4,wkspace%
  88.  SYS "Tornado_Getaddr",,0,,wkspace% TO ,,addr%
  89.  !addr%=blk%
  90.  FOR N%=0 TO 2 STEP 2
  91.  P%=blk%
  92.  [OPT N%
  93.  .disc EQUS disc$:EQUB0:ALIGN
  94.  .upcallv
  95.  \Checks for alterations to the path at .disc, and sets .updated% if true
  96.  ...
  97.  .updated% EQUD 0
  98.  ]
  99.  NEXT
  100.  =1:REM This specifies we want to keep the wkspace passed to us
  101.  
  102. Of course, this will only allow one window to work at a time. To get around
  103. that, you would put updated% in the wkspace. The wkspace ptr can be passed
  104. via a substitution to any code linked to icons, handlers or tickers called
  105. from that window.
  106.  
  107. Of course, future versions of tornado will allow the ticker used above to be
  108. done automatically by tornado - tornado will check updated% for the task. But
  109. for the time being, this is as far as tornado goes.
  110.  
  111. Languages:
  112. -=-=-=-=-=
  113.  
  114. Although I used Basic to demonstrate tornado's visual style of writing, both
  115. C and assembler can be used as well. In fact, there is no reason why a
  116. mixture of C, Basic & assembler can't be used in the one program, and leaving
  117. the tornado editor with the problem of linking the lot together. Also
  118. supplied with the editor are libraries of code segments, which allow further
  119. standardisation and ease of program construction.
  120.    However, despite the loss of multithreading with Basic, Basic does contain
  121. one huge advantage over C and assembler - it's interpreted. This allows
  122. tornado to directly call functions in the image using EVAL. With C and
  123. assembler, large tables of function names and their offsets must be created -
  124. a real burden for a programmer. Of course, the editor will automate all that
  125. - but for now, it's a lot easier and simpler for us to write the lot for
  126. Basic - and extend for C and assembler later.
  127.   Anyway, Basic needs a bit of a boost. Acorn have definately been ignoring
  128. it in the last few years.
  129.