home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / basic / eventshell / Examples / !Redraw3 / !Redraw3 (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1996-03-20  |  10.5 KB  |  254 lines

  1.  > <Redraw3$Dir>.!Redraw3
  2.  "Hourglass_Smash":
  3. $;" at line "+
  4.  "<EvntShell$Path>ShellLibRT"
  5. shell_FatalError
  6.  "Hourglass_On"
  7.  "Wimp_SlotSize",-1,-1 
  8.  progsize%
  9. pagesize%=1<<10
  10. freespace%=&8000+progsize%
  11. =freespace%+pagesize%
  12. =freespace%
  13. shell_HeapManagerInit("<EvntShell$Path>",freespace%)
  14. shell_Init
  15.  -------------------- Load extension libraries -----------------------
  16.  "<EvntShell$Path>Extensions.DrawLib"
  17.  -------------------- Initialise Wimp and Resources ------------------
  18. -task%=
  19. shell_WimpInit_I( 200, "Redraw3" )
  20.  Uncomment the next two lines to enable debug tracing with ShellDBug..
  21. shell_TraceInit( "" )
  22. shell_TraceOn
  23. shell_ResourcesInit
  24. app_init
  25.  -------------------- Initialise Variables ----------------------------
  26. #G_closedown%     =
  27.  Set this to TRUE when you want the program to
  28. $!                       :
  29. R_Value = 0
  30. G_Value = 0
  31. B_Value = 0
  32.  -------------------- Miscelleanous Initialisation --------------------
  33.  "Hourglass_Off"
  34. shell_Error
  35. shell_Action( 
  36. shell_Poll_I( 0, task% ) )
  37.  _closedown%
  38. shell_Exit
  39.  ======================================================================
  40. app_init
  41. SetUp_Windows
  42. SetUp_Menus
  43. SetUp_IconBar
  44.  ===== Menu_Setup routines ======================================
  45. SetUp_Menus
  46.  void%
  47. C\MenuHandle_IconBar% = 
  48. shell_MenuNew( 
  49. shell_MessageNoArgs( "MTIBar" ), "Menu_IBar", 3 )
  50. DQMenuItem_Info%      = 
  51. shell_MenuAdd( 0, 
  52. shell_MessageNoArgs( "Info" ), "" )
  53. Eavoid%               = 
  54. shell_MenuAdd( 0, 
  55. shell_MessageNoArgs ("Quit" ), "_MenuSelect_Quit" )
  56. shell_AttachMenuDBox( MenuItem_Info%, "progInfo", "_PreOpenInfo", "" )
  57.  ===== Window_SetUp routines ====================================
  58. SetUp_Windows
  59.  width%, height%, width_pix%, height_pix%, mode%
  60.  xeigfactor%, yeigfactor%, object_type_sprite%, x_offset%, y_offset%
  61.  drawfile_block%
  62. width%      = 400
  63. height%     = 400
  64. width_pix%  = width%  / 2
  65. height_pix% = height% / 2
  66. mode%       = 20
  67. X8area_size%  = ( width_pix% * height_pix% / 2 + 100 )
  68. x_offset% = 60
  69. y_offset% = 60
  70. shell_DrawCreateFile( drawfile_buffer% )
  71. shell_DrawSpriteArea( drawfile_buffer%, area_size%, sprite_area% )
  72.  Initialise sprite area, create sprite..
  73. shell_SpriteAreaInit( sprite_area%, area_size% )
  74.  "OS_SpriteOp", 15 + 256, sprite_area%, "screen", 0, width_pix%, height_pix%, 20
  75.  Return 'handle' of created sprite area (actually the offset from the start
  76.  of the DrawFile buffer) in case the user wants to add graphics to it..
  77. f9sprite_area_handle% = sprite_area% - drawfile_buffer%
  78.  and remove any left hand wastage from the sprite..
  79. shell_SpriteRemoveLeftWastage( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize% )
  80.  now find the size and mode of the loaded sprite..
  81. shell_SpriteGetSize( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize%, width%, height% )
  82. shell_SpriteGetMode( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize%, mode% )
  83.  To scale the sprite image to the correct size for the mode it was
  84.  created in, find the size of pixels for that mode..
  85.  "OS_ReadModeVariable", mode%, 4 
  86.  , , xeigfactor%
  87.  "OS_ReadModeVariable", mode%, 5 
  88.  , , yeigfactor%
  89.  Adjust height and width accordingly..
  90. u$width%  = width%  << xeigfactor%
  91. v$height% = height% << yeigfactor%
  92. shell_Tracef0( "Beate0:"+
  93. ( sprite_area%!0  ) )
  94. shell_Tracef0( "Beate0:"+
  95. ( sprite_area%!4  ) )
  96. shell_Tracef0( "Beate0:"+
  97. ( sprite_area%!8  ) )
  98. shell_Tracef0( "Beate0:"+
  99. ( sprite_area%!12 ) )
  100. };drawfile_block% = drawfile_buffer% + drawfile_buffer%!4
  101.  Set bounding box of DrawFile (same size as sprite as we have only one
  102.  object)..
  103. Kdrawfile_block%!24 = x_offset% * 256                        :
  104.  OS units
  105. Kdrawfile_block%!28 = y_offset% * 256                        :
  106.  OS units
  107. Kdrawfile_block%!32 = ( drawfile_block%!24 ) + width%  * 256 :
  108.  OS units
  109. Kdrawfile_block%!36 = ( drawfile_block%!28 ) + height% * 256 :
  110.  OS units
  111.  Create Sprite object info (this overwrites the sprite area info which was
  112.  only needed for loading the sprite)..
  113. object_type_sprite% = 5
  114. ,drawfile_block%!40 = object_type_sprite%
  115. (drawfile_block%!44 = area_size% + 24
  116. Kdrawfile_block%!48 = x_offset% * 256                        :
  117.  OS units
  118. Kdrawfile_block%!52 = y_offset% * 256                        :
  119.  OS units
  120. Kdrawfile_block%!56 = ( drawfile_block%!48 ) + width%  * 256 :
  121.  OS units
  122. Kdrawfile_block%!60 = ( drawfile_block%!52 ) + height% * 256 :
  123.  OS units
  124.  PROCshell_DrawSaveFile( drawfile_buffer%, "RAM::RamDisc0.$.paul" )
  125. shell_CreateWindowStatic( "mainw", mainw% )
  126. shell_AttachUserRedraw( mainw%, "_redraw" )
  127. _redraw( blk%, x%, y% )
  128.  Actually perform the rendering of the DrawFile (shouldn't need to change
  129.  anything here). Note that if no file is loaded then rendering is
  130.  not attempted as this would probably crash the machine!
  131.  scl, xpos, ypos, width, height, yorg, xorg
  132.  drawfile_buffer% <> 0 
  133. shell_DrawGetBoundingBox( drawfile_buffer%, xpos, ypos, width, height, 
  134. *  yorg = -( 160 + height + ypos ) + y%
  135.   xorg = x% - xpos + 60
  136. shell_DrawRenderFile( drawfile_buffer%, xorg, yorg, blk%, 
  137.  ===== IconBar_SetUp routines ===================================
  138. SetUp_IconBar
  139. ^sicon=
  140. shell_Iconbar( -1, "!" + 
  141. shell_GetAppName, "", 120, MenuHandle_IconBar%, 0, 0, 0 )
  142. shell_AttachHelpTag( -1, sicon, "iconbar" )
  143. shell_AttachClickSelect( -1, sicon, "_ClickSelect_IconBar" )
  144.  ===== Dialog_PreOpen routines ==================================
  145. _PreOpenInfo( window_handle% )
  146. shell_IconPutData( window_handle%, 0, 
  147. shell_MessageNoArgs( "progInfo0" ), 0 )
  148. shell_IconPutData( window_handle%, 1, 
  149. shell_MessageNoArgs( "progInfo1" ), 0 )
  150. shell_IconPutData( window_handle%, 2, 
  151. shell_MessageNoArgs( "progInfo2" ), 0 )
  152. shell_IconPutData( window_handle%, 3, 
  153. shell_MessageNoArgs( "progInfo3" ), 0 )
  154.  ===== Dialog_PostOpen routines =================================
  155.  ===== Click_Select routines ====================================
  156. _ClickSelect_IconBar( wh%,icon% )
  157. shell_OpenWindowStatic( mainw% )
  158.  ===== Click_Adjust routines ====================================
  159.  ===== Menu_Select routines =====================================
  160. _MenuSelect_Quit( blk% )
  161. _closedown% = 
  162.  ===== Menu_Warning routines ====================================
  163.  ===== Data_Load routines =======================================
  164.  ===== Data_Save routines =======================================
  165.  ===== User application routines ================================
  166. shell_DoBackgroundTask
  167. do_pattern
  168.  "Wimp_ForceRedraw", mainw%, 0, -3000, 3000, 0
  169. do_pattern
  170.  v0%, v1%, v2%, v3%, Palette_Entry%
  171.  sprite_area%
  172. Wsprite_area% = 
  173. shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
  174. shell_DrawSpriteBeginModify( drawfile_buffer%, area_size%, sprite_area_handle% )
  175.  "XOS_SpriteOp", 60 + 256, sprite_area%, "screen" 
  176.  v0%, v1%, v2%, v3%
  177.  29,0;0;
  178.  Choose a random 24 bit colour..
  179. B_Value = 
  180. ( 100 )
  181. G_Value = 
  182. ( 100 )
  183. R_Value = 
  184. ( 100 )
  185.  plot lines
  186.  FOR loop% = 1 TO 100
  187.    B_Value += 1
  188.    IF B_Value > 100 THEN B_Value = 0
  189.    Palette_Entry% = ( ( B_Value * 2.55 ) << 24 ) + ( ( G_Value * 2.55 ) << 16 ) + ( ( R_Value * 2.55 )<< 8 )
  190.    SYS "ColourTrans_SetGCOL", Palette_Entry%, , , 256, 0
  191.    MOVE 0,B_Value
  192.    DRAW BY 400,0
  193.  NEXT loop%
  194.  Plot triangles..
  195. mPalette_Entry% = ( ( B_Value * 2.55 ) << 24 ) + ( ( G_Value * 2.55 ) << 16 ) + ( ( R_Value * 2.55 )<< 8 )
  196.  "ColourTrans_SetGCOL", Palette_Entry%, , , 256, 0
  197. width%  = 400
  198. height% = 400
  199. ( width% ),
  200. ( height% )
  201. ( width% ),
  202. ( height% )
  203.  85, 
  204. ( width% ), 
  205. ( height% )
  206.  switch VDU output back to the screen..
  207.  "XOS_SpriteOp", v0%, v1%, v2%, v3%
  208. shell_DrawSpriteEndModify( drawfile_buffer%, sprite_area_handle% )
  209.  ================= End Of User Application ======================
  210. +*|Start PROCshell_DrawSpriteBeginModify
  211. shell_DrawSpriteBeginModify( drawfile_buffer%, area_size%, sprite_area_handle% )
  212.  sprite_area_ptr%
  213. [sprite_area_ptr% = 
  214. shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
  215.  PROCshell_Tracef0( "" )
  216.  PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!0  ) )
  217.  PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!4  ) )
  218.  PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!8  ) )
  219.  PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!12 ) )
  220.  Store the current contents of the drawfile buffer where we will restore the
  221.  sprite area header to..
  222. 'store_word00% = sprite_area_ptr%!00
  223. 'store_word04% = sprite_area_ptr%!04
  224. 'store_word08% = sprite_area_ptr%!08
  225. 'store_word12% = sprite_area_ptr%!12
  226.  ..and create the sprite area header so that the sprite can be accessed..
  227.  9sprite_area_ptr%!00 = area_size%  :
  228.  sprite area size
  229. !Hsprite_area_ptr%!04 = 1           :
  230.  nr of sprites contained in area
  231. "5sprite_area_ptr%!08 = 
  232. shell_SpritesGetHeaderSize
  233. #)sprite_area_ptr%!12 = area_size% - 40
  234.  PROCshell_Tracef0( "" )
  235.  PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!0  ) )
  236.  PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!4  ) )
  237.  PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!8  ) )
  238.  PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!12 ) )
  239. -**|Stop PROCshell_DrawSpriteBeginModify
  240. 1)*|Start PROCshell_DrawSpriteEndModify
  241. shell_DrawSpriteEndModify( drawfile_buffer%, sprite_area_handle% )
  242.  sprite_area_ptr%
  243. 6[sprite_area_ptr% = 
  244. shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
  245. 7'sprite_area_ptr%!00 = store_word00%
  246. 8'sprite_area_ptr%!04 = store_word04%
  247. 9'sprite_area_ptr%!08 = store_word08%
  248. :'sprite_area_ptr%!12 = store_word12%
  249. >(*|Stop PROCshell_DrawSpriteEndModify
  250. @(*|Start FNshell_DrawSpriteGetAreaPtr
  251. shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
  252. B,= drawfile_buffer% + sprite_area_handle%
  253. D'*|Stop FNshell_DrawSpriteGetAreaPtr
  254.