home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-08-21 | 8.6 KB | 199 lines |
- > RedDragSrc
- Kvsn$="1.10":fnm$="ReducdDrag":date$="21 Aug 1994":
- or MID$(TIME$,5,11)
- ;bl$=
- 0:cr$=
- 13:lfcr$=
- 10+cr$:tab$=
- 9:esc$=
- 27:hspc$=
- *RemV=&15:
- Buffer Remove vector number
- <Service_Reset =&27:
- End of machine reset signalled
- FService_StartWimp =&49:
- Request by Desktop to start WIMP modules
- DService_StartedWimp=&4A:
- Desktop indicates all tasks now active
- XDragASprite_Stop=&62401
- 1codesize=&1000:
- org codesize:L%=org+codesize
- A%=%1100
- %1110
- %0010
- ?P%=0:O%=org :
- So that addresses are offsets within module
- [OPT A%
- G EQUD appstart ; Application start entry
- D EQUD init ; Initialisation entry
- B EQUD finalise ; Finalisation entry
- B EQUD servicecall ; Service call entry
- ? EQUD titlestring ; -> Title string
- > EQUD helpstring ; -> Help string
- M EQUD keywordtable ; -> Help/Command keyword table
- > ; And no SWIs...
- .keywordtable
- &.startupname EQUS "Desktop_"
- 4.titlestring EQUS "ReducedDrag"+bl$:
- align
- # EQUD startup
- !% EQUD &00000000
- ") EQUD startupsyntax
- #' EQUD startuphelp
- .zeroword
- &P.notindesktop EQUD 0 ; End of keyword table & error no.
- 'C.startuphelp EQUS "Use *Desktop to start ReducedDrag"+bl$
- )'.startupsyntax EQUS esc$+
- 1+bl$
-
- align
- ,G.fEscPressed EQUD 0 ; Has Escape been pressed
- .4; th keeps track of the state of our Wimp task -
- ; th = 0 => Not running
- 06; th =-1 => Not running, claimed Service_StartWimp
- 1J; th > 0 => Running, th is the task handle returned by Wimp_Initialise
- .th EQUD 0
- 4F.servicecall TEQ r1,#Service_Reset ; End of machine reset ?
- 5P TEQNE r1,#Service_StartWimp ; Is the Desktop starting up ?
- 6O TEQNE r1,#Service_StartedWimp ; Has the Desktop started ?
- 7" MOVNES PC,r14
- 8F TEQ r1,#Service_Reset ; End of machine reset ?
- 9? BEQ init ; Yes, so restart
- :" LDR r12,th
- ;1 CMP r1,#Service_StartWimp
- <L BEQ servstartwimp ; Is the Desktop starting up ?
- =K ; Must be Service_StartedWimp
- >L ADDS r12,r12,#1 ; *Command may have failed, so
- ?C STREQ r12,th ; `if (th==-1) th=0;'
- @" MOV PC,r14
- B;.servstartwimp TEQ r12,#0 ; Is th = 0 ?
- CN MVNEQ r12,#
- (-1) ; Yes => not running & not already
- DM STREQ r12,th ; tried to claim so set th = -1
- EL ADREQ r0,startupname ; r0 -> *Command to start task
- FG
- Q r1,#0 ; and claim the service call
- G" MOV PC,r14
- I,.startup STMFD r13!,{r0-r2,r14}
- JF MOV r2,r0 ; Point to *Command tail
- KK LDR r14,th ; Check for user trying it on
- L@ CMP r14,#0 ; r14 should be -1
- MA MOVMI r0,#2 ; Enter Application
- NA ADRMI r1,titlestring ; r1 -> module name
- O( SWIMI "XOS_Module"
- P+ LDMMIFD r13!,{r0-r2,PC}
- QJ ADR r0,notindesktop ; No Wimp tasks, so complain
- RD SWI "OS_GenerateError"; we're not in desktop
- T8.description ; Wimp task name is up to tab character
- UT.helpstring EQUS "Reduced Drag"+tab$+vsn$+" ("+date$+")
- Olly Betts"+bl$
- align
- XG; Well, here's the start sequence at last! We only want one of this
- YC; task running, so must shut down the old one if it is running.
- Z$; NB *NO* stack set up - beware!
- [!.appstart MOV r0,#0
- \/ SWI "XWimp_ReadSysInfo"
- ]! TEQ r0,#0
- ^% SWIEQ "OS_Exit"
- _J BLVC wimpclosedown ; Shut down any current task
- `D MOVVC r0,#300 ; Know about Wimp 3.00
- aJ LDRVC r1,TASK ; Indicate RISC OS Wimp task
- bB ADRVC r2,description ; r2 -> program name
- cQ ADRVC r3,zeroword ; For Wimp 3.00+, -> no msgs wanted
- d. SWIVC "XWimp_Initialise"
- e< MOVVC r4,r0 ; Wimp version
- fE STRVC r1,th ; Save Wimp task handle
- g$ MOVVC r0,#RemV
- h# ADRVC r1,remv
- i! MOVVC r2,#0
- j: SWIVC "XOS_Claim" ; Claim RemV
- k! MOVVC r0,#6
- lQ MOVVC r3,#256 ; Claim 256 bytes for Wimp_Poll blk
- m( SWIVC "XOS_Module"
- n! BVS error
- o! MOV r5,#0
- pB CMP r4,#300 ; Check Wimp version
- q$ BLT risc_os2
- r>
- R r5,r5,#1<<22 ; Check Poll word
- sF
- R r5,r5,#1 ; Don't return Null polls
- tD ADR r3,fEscPressed ; Address of Poll word
- u$.risc_os2 STR r2,[r12]
- v!.poll_lp MOV r0,r5
- w: LDR r1,[r12] ; Poll block
- x( SWI "XWimp_Poll"
- y! BVS error
- z" TEQ r0,#17
- {" TEQNE r0,#18
- BEQ msg
- }! TEQ r0,#0
- ~@ TEQNE r0,#13 ; PollWord_NonZero
- # BNE poll_lp
- * LDR r0,fEscPressed
- ! TEQ r0,#0
- # BEQ poll_lp
- F MOV r1,#0 ; Cancel drag by calling
- K STR r1,fEscPressed ; Clear `Escape pressed' flag
- G SWI "XWimp_DragBox" ; XWimp_DragBox with r1=0
- # B poll_lp
- '.msg LDR r0,[r1,#16]
- > TEQ r0,#0 ; Quit message ?
- # BNE poll_lp
- ).exit BL wimpclosedown
- % SWI "OS_Exit"
- B.error MOV r1,#%10 ; Cancel button only
- * ADR r2,description
- / SWI "XWimp_ReportError"
- B exit
- @; Called by module initialisation entry and on Service_Reset
- &.init STMFD r13!,{r14}
- " MOV r14,#0
- M STR r14,th ; Task not running, not claimed
- + STR r14,fEscPressed
- % LDMFD r13!,{PC}
- .finalise
- J; Calls Wimp_CloseDown if Wimp_Initialise has been successfully called
- @; (ie th > 0). It sets th = 0 to indicate task not running.
- 1; Also, the workspace and vector are released
- ; /X r0-r6
- ".wimpclosedown MOV r6,r14
- ; LDR r0,th ; Is th > 0 ?
- ! MOVS r0,r0
- < MOVPL r0,#RemV ; Release RemV
- # ADRPL r1,remv
- ! MOVPL r2,#0
- ) SWIPL "XOS_Release"
- ! LDRPL r0,th
- # LDRPL r1,TASK
- - SWIPL "XWimp_CloseDown"
- $ LDR r2,[r12]
- ! TEQ r2,#0
- ! MOVNE r0,#7
- H SWINE "XOS_Module" ; Release block if claimed
- ! MOV r0,#0
- $ STRNE r0,[r12]
- A STR r0,th ; Clear task handle
- ! MOV PC,r6
- "; Buffer remove vector routine
- Q.remv TEQ r1,#0 ; Exit if it's not the keybd buffer
- N STMEQFD r13!,{PC} ; PC gives PC 3 words in advance
- " MOV PC,r14
- ;
- I.TASK EQUS "TASK" ; Neatly fills one word gap
- ;
- E LDMCSFD r13!,{PC} ; Exit if remove failed
- ' TEQ r2,#
- (esc$)
- O LDMNEFD r13!,{PC} ; Coded for speed in general case
- H STR r2,fEscPressed ; Ignore if not in desktop
- % LDMFD r13!,{PC}
- "Size = ";P%" bytes"
- "OS_File",&0A,fnm$,&FFA,,org,O%
- "OS_Module",11,org,P%
- align
- next line allows shuffling of strings to reduce wastage
- 2)=0
- 3" byte(s) wasted by FNalign"
- 3:[OPTA%:EQUB0:]:
-