home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1996-03-20 | 10.5 KB | 254 lines |
- > <Redraw3$Dir>.!Redraw3
- "Hourglass_Smash":
- $;" at line "+
- "<EvntShell$Path>ShellLibRT"
- shell_FatalError
- "Hourglass_On"
- "Wimp_SlotSize",-1,-1
- progsize%
- pagesize%=1<<10
- freespace%=&8000+progsize%
- =freespace%+pagesize%
- =freespace%
- shell_HeapManagerInit("<EvntShell$Path>",freespace%)
- shell_Init
- -------------------- Load extension libraries -----------------------
- "<EvntShell$Path>Extensions.DrawLib"
- -------------------- Initialise Wimp and Resources ------------------
- -task%=
- shell_WimpInit_I( 200, "Redraw3" )
- Uncomment the next two lines to enable debug tracing with ShellDBug..
- shell_TraceInit( "" )
- shell_TraceOn
- shell_ResourcesInit
- app_init
- -------------------- Initialise Variables ----------------------------
- #G_closedown% =
- Set this to TRUE when you want the program to
- $! :
- R_Value = 0
- G_Value = 0
- B_Value = 0
- -------------------- Miscelleanous Initialisation --------------------
- "Hourglass_Off"
- shell_Error
- shell_Action(
- shell_Poll_I( 0, task% ) )
- _closedown%
- shell_Exit
- ======================================================================
- app_init
- SetUp_Windows
- SetUp_Menus
- SetUp_IconBar
- ===== Menu_Setup routines ======================================
- SetUp_Menus
- void%
- C\MenuHandle_IconBar% =
- shell_MenuNew(
- shell_MessageNoArgs( "MTIBar" ), "Menu_IBar", 3 )
- DQMenuItem_Info% =
- shell_MenuAdd( 0,
- shell_MessageNoArgs( "Info" ), "" )
- Eavoid% =
- shell_MenuAdd( 0,
- shell_MessageNoArgs ("Quit" ), "_MenuSelect_Quit" )
- shell_AttachMenuDBox( MenuItem_Info%, "progInfo", "_PreOpenInfo", "" )
- ===== Window_SetUp routines ====================================
- SetUp_Windows
- width%, height%, width_pix%, height_pix%, mode%
- xeigfactor%, yeigfactor%, object_type_sprite%, x_offset%, y_offset%
- drawfile_block%
- width% = 400
- height% = 400
- width_pix% = width% / 2
- height_pix% = height% / 2
- mode% = 20
- X8area_size% = ( width_pix% * height_pix% / 2 + 100 )
- x_offset% = 60
- y_offset% = 60
- shell_DrawCreateFile( drawfile_buffer% )
- shell_DrawSpriteArea( drawfile_buffer%, area_size%, sprite_area% )
- Initialise sprite area, create sprite..
- shell_SpriteAreaInit( sprite_area%, area_size% )
- "OS_SpriteOp", 15 + 256, sprite_area%, "screen", 0, width_pix%, height_pix%, 20
- Return 'handle' of created sprite area (actually the offset from the start
- of the DrawFile buffer) in case the user wants to add graphics to it..
- f9sprite_area_handle% = sprite_area% - drawfile_buffer%
- and remove any left hand wastage from the sprite..
- shell_SpriteRemoveLeftWastage( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize% )
- now find the size and mode of the loaded sprite..
- shell_SpriteGetSize( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize%, width%, height% )
- shell_SpriteGetMode( sprite_area%, "", sprite_area% + _c_Sprites_AreaHeaderSize%, mode% )
- To scale the sprite image to the correct size for the mode it was
- created in, find the size of pixels for that mode..
- "OS_ReadModeVariable", mode%, 4
- , , xeigfactor%
- "OS_ReadModeVariable", mode%, 5
- , , yeigfactor%
- Adjust height and width accordingly..
- u$width% = width% << xeigfactor%
- v$height% = height% << yeigfactor%
- shell_Tracef0( "Beate0:"+
- ( sprite_area%!0 ) )
- shell_Tracef0( "Beate0:"+
- ( sprite_area%!4 ) )
- shell_Tracef0( "Beate0:"+
- ( sprite_area%!8 ) )
- shell_Tracef0( "Beate0:"+
- ( sprite_area%!12 ) )
- };drawfile_block% = drawfile_buffer% + drawfile_buffer%!4
- Set bounding box of DrawFile (same size as sprite as we have only one
- object)..
- Kdrawfile_block%!24 = x_offset% * 256 :
- OS units
- Kdrawfile_block%!28 = y_offset% * 256 :
- OS units
- Kdrawfile_block%!32 = ( drawfile_block%!24 ) + width% * 256 :
- OS units
- Kdrawfile_block%!36 = ( drawfile_block%!28 ) + height% * 256 :
- OS units
- Create Sprite object info (this overwrites the sprite area info which was
- only needed for loading the sprite)..
- object_type_sprite% = 5
- ,drawfile_block%!40 = object_type_sprite%
- (drawfile_block%!44 = area_size% + 24
- Kdrawfile_block%!48 = x_offset% * 256 :
- OS units
- Kdrawfile_block%!52 = y_offset% * 256 :
- OS units
- Kdrawfile_block%!56 = ( drawfile_block%!48 ) + width% * 256 :
- OS units
- Kdrawfile_block%!60 = ( drawfile_block%!52 ) + height% * 256 :
- OS units
- PROCshell_DrawSaveFile( drawfile_buffer%, "RAM::RamDisc0.$.paul" )
- shell_CreateWindowStatic( "mainw", mainw% )
- shell_AttachUserRedraw( mainw%, "_redraw" )
- _redraw( blk%, x%, y% )
- Actually perform the rendering of the DrawFile (shouldn't need to change
- anything here). Note that if no file is loaded then rendering is
- not attempted as this would probably crash the machine!
- scl, xpos, ypos, width, height, yorg, xorg
- drawfile_buffer% <> 0
- shell_DrawGetBoundingBox( drawfile_buffer%, xpos, ypos, width, height,
- * yorg = -( 160 + height + ypos ) + y%
- xorg = x% - xpos + 60
- shell_DrawRenderFile( drawfile_buffer%, xorg, yorg, blk%,
- ===== IconBar_SetUp routines ===================================
- SetUp_IconBar
- ^sicon=
- shell_Iconbar( -1, "!" +
- shell_GetAppName, "", 120, MenuHandle_IconBar%, 0, 0, 0 )
- shell_AttachHelpTag( -1, sicon, "iconbar" )
- shell_AttachClickSelect( -1, sicon, "_ClickSelect_IconBar" )
- ===== Dialog_PreOpen routines ==================================
- _PreOpenInfo( window_handle% )
- shell_IconPutData( window_handle%, 0,
- shell_MessageNoArgs( "progInfo0" ), 0 )
- shell_IconPutData( window_handle%, 1,
- shell_MessageNoArgs( "progInfo1" ), 0 )
- shell_IconPutData( window_handle%, 2,
- shell_MessageNoArgs( "progInfo2" ), 0 )
- shell_IconPutData( window_handle%, 3,
- shell_MessageNoArgs( "progInfo3" ), 0 )
- ===== Dialog_PostOpen routines =================================
- ===== Click_Select routines ====================================
- _ClickSelect_IconBar( wh%,icon% )
- shell_OpenWindowStatic( mainw% )
- ===== Click_Adjust routines ====================================
- ===== Menu_Select routines =====================================
- _MenuSelect_Quit( blk% )
- _closedown% =
- ===== Menu_Warning routines ====================================
- ===== Data_Load routines =======================================
- ===== Data_Save routines =======================================
- ===== User application routines ================================
- shell_DoBackgroundTask
- do_pattern
- "Wimp_ForceRedraw", mainw%, 0, -3000, 3000, 0
- do_pattern
- v0%, v1%, v2%, v3%, Palette_Entry%
- sprite_area%
- Wsprite_area% =
- shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
- shell_DrawSpriteBeginModify( drawfile_buffer%, area_size%, sprite_area_handle% )
- "XOS_SpriteOp", 60 + 256, sprite_area%, "screen"
- v0%, v1%, v2%, v3%
- 29,0;0;
- Choose a random 24 bit colour..
- B_Value =
- ( 100 )
- G_Value =
- ( 100 )
- R_Value =
- ( 100 )
- plot lines
- FOR loop% = 1 TO 100
- B_Value += 1
- IF B_Value > 100 THEN B_Value = 0
- Palette_Entry% = ( ( B_Value * 2.55 ) << 24 ) + ( ( G_Value * 2.55 ) << 16 ) + ( ( R_Value * 2.55 )<< 8 )
- SYS "ColourTrans_SetGCOL", Palette_Entry%, , , 256, 0
- MOVE 0,B_Value
- DRAW BY 400,0
- NEXT loop%
- Plot triangles..
- mPalette_Entry% = ( ( B_Value * 2.55 ) << 24 ) + ( ( G_Value * 2.55 ) << 16 ) + ( ( R_Value * 2.55 )<< 8 )
- "ColourTrans_SetGCOL", Palette_Entry%, , , 256, 0
- width% = 400
- height% = 400
- ( width% ),
- ( height% )
- ( width% ),
- ( height% )
- 85,
- ( width% ),
- ( height% )
- switch VDU output back to the screen..
- "XOS_SpriteOp", v0%, v1%, v2%, v3%
- shell_DrawSpriteEndModify( drawfile_buffer%, sprite_area_handle% )
- ================= End Of User Application ======================
- +*|Start PROCshell_DrawSpriteBeginModify
- shell_DrawSpriteBeginModify( drawfile_buffer%, area_size%, sprite_area_handle% )
- sprite_area_ptr%
- [sprite_area_ptr% =
- shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
- PROCshell_Tracef0( "" )
- PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!0 ) )
- PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!4 ) )
- PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!8 ) )
- PROCshell_Tracef0( "Beate1:"+STR$( sprite_area_ptr%!12 ) )
- Store the current contents of the drawfile buffer where we will restore the
- sprite area header to..
- 'store_word00% = sprite_area_ptr%!00
- 'store_word04% = sprite_area_ptr%!04
- 'store_word08% = sprite_area_ptr%!08
- 'store_word12% = sprite_area_ptr%!12
- ..and create the sprite area header so that the sprite can be accessed..
- 9sprite_area_ptr%!00 = area_size% :
- sprite area size
- !Hsprite_area_ptr%!04 = 1 :
- nr of sprites contained in area
- "5sprite_area_ptr%!08 =
- shell_SpritesGetHeaderSize
- #)sprite_area_ptr%!12 = area_size% - 40
- PROCshell_Tracef0( "" )
- PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!0 ) )
- PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!4 ) )
- PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!8 ) )
- PROCshell_Tracef0( "Beate2:"+STR$( sprite_area_ptr%!12 ) )
- -**|Stop PROCshell_DrawSpriteBeginModify
- 1)*|Start PROCshell_DrawSpriteEndModify
- shell_DrawSpriteEndModify( drawfile_buffer%, sprite_area_handle% )
- sprite_area_ptr%
- 6[sprite_area_ptr% =
- shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
- 7'sprite_area_ptr%!00 = store_word00%
- 8'sprite_area_ptr%!04 = store_word04%
- 9'sprite_area_ptr%!08 = store_word08%
- :'sprite_area_ptr%!12 = store_word12%
- >(*|Stop PROCshell_DrawSpriteEndModify
- @(*|Start FNshell_DrawSpriteGetAreaPtr
- shell_DrawSpriteGetAreaPtr( drawfile_buffer%, sprite_area_handle% )
- B,= drawfile_buffer% + sprite_area_handle%
- D'*|Stop FNshell_DrawSpriteGetAreaPtr
-