home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / customise / welcomea / !WelcomeA / Source (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1993-06-28  |  22.5 KB  |  626 lines

  1.   >Source
  2.   Create a module that provides an alternative desktop Welcome
  3.      A sprite spinning from a random position to the center of the screen
  4.      We use floating point because the parameters to PutSpriteTransformed
  5.      are in draw units (1/256 OS) and multiplying would otherwise need
  6.      64-bit arithmetic
  7.      Now has compressed picture (saves 4K) & only claims workspace while
  8.      animating (saving about 200 bytes!)
  9.      Assumes sprite needs no pixtrans to plot.  Ie YOU must ensure
  10.      sprites has same bits-per-pixel AND palette for configured desktop MODE
  11.      Handles sprite in high/low rez on screen low/high rez
  12.  1.00 18-Jun-1993 working version
  13.  1.10 27-Jun-1993 distributed version with docs + exageratted y start pos
  14.   MACHINE:  Archimedes
  15.   LANGUAGE: BBC BASIC V v1.05
  16.   AUTHOR:   Cy Booker,
  17.             86 Church View, Main Road, Crockenhill, Swanley, Kent.
  18.             BR8 8JW
  19.  "<BasicV$Lib>.LibHandler"  :  
  20. _handle_library_error
  21. _hard_initialise_LibHandler( 20, 011 )
  22. FDebug_Wimp%=
  23. :Debug%=
  24. :On_Lib_Error_MODE%=-1:
  25.  Desktop Development
  26.  "XHourglass_On"
  27.  "XHourglass_Off":
  28. _handle_library_error
  29. 6  In$  = 
  30. sysvar("MakeDesktopWelcomeModule$Input")
  31. 7  Out$ = 
  32. sysvar("MakeDesktopWelcomeModule$Output")
  33. >  NFrames = 
  34. sysvar("MakeDesktopWelcomeModule$NFrames"))
  35.  NFrames < 1 
  36.  1, "Invalid value for system variable MakeDesktopWelcomeModule$NFrames"
  37. k  Banked_P = (
  38. sysvar("MakeDesktopWelcomeModule$Buffered")) = 
  39. ("Y"))       :
  40.  boolean, => no flicker
  41.  \  Test_P = 
  42.                                                          :
  43.  boolean, => test
  44. !%  ModuleTitle$ = "WelcomeAnimate"
  45. "R  ModuleHelp$ = "WelcomeAnimate"+ 
  46. (9)+ "1.10 (27 Jun 1993)"         :
  47.  Module
  48.   Now to load in the library files used by this program.
  49. _load_library( "<BasicV_Assembler$Lib>.Misc", 020 )
  50. _load_library( "<BasicV_Assembler$Lib>.Services", 008 )
  51. _load_library( "<BasicV_Assembler$Lib>.VduExt", 001 )
  52. _load_library( "<BasicV_Assembler$Lib>.Flop", 004 )
  53. _load_library( "<BasicV_Assembler$Lib>.SpriteVar", 004 )
  54. _assemble( 160000 )               :
  55.  large for 32K decompress workspace
  56.  Test_P 
  57. -4    
  58.  "OS_ServiceCall",, Service_DesktopWelcome
  59.  "Created "+ Out$
  60.  "XHourglass_Off"
  61.  *********************************************************************
  62.  * Assemble all the code.
  63.  * IN:   code_size% == size of code to use.
  64.  * OUT:  code% <-- Byte array containing code.
  65. _assemble( code_size% )
  66.  lr, sp, pc, gb
  67.  pass%, P%, O%, L%
  68.  code% code_size%
  69.    gb      = 12
  70.    sp      = 13
  71.    lr      = 14
  72.    pc      = 15
  73.    PSR_Z   = 1 << 30
  74.    PSR_C   = 1 << 29
  75.    PSR_V   = 1 << 28
  76. C#   L%      = code% + code_size%
  77. _Services(code%, L%)
  78. _VduExt(code%, L%)
  79. _SpriteVar(code%, L%)
  80. GC   
  81. _Load_And_Parse_SpriteFile               :
  82.  after SpriteVar
  83. _Constants(code%, L%)
  84. I%   
  85.  "XHourglass_Percentage", 10
  86. J%   
  87.  pass%= %1100 
  88.  %1110 
  89.  %0010
  90.       P% = 0 : O% = code%
  91.       
  92. _assemble_Module
  93.       
  94.  (pass% 
  95.  2)=0 
  96. N"        
  97.  P%= code% 
  98.  O%-1 
  99.           !P% = 0
  100.         
  101. Q(      
  102.  "XHourglass_Percentage", 50
  103.       
  104.  pass%
  105. T%   
  106.  "XHourglass_Percentage", 99
  107. V/   
  108.  "OS_File", 10, Out$, &FFA,, code%, O%
  109. W@   
  110.  "OS_Module", ModHandReason_CopyArea, code%, O% - code%
  111.  *********************************************************************
  112. _assemble_Module
  113. [OPT pass%
  114. ](        EQUD    0 ;Module_Start_Code
  115. ^.        EQUD    Module_Initialisation_Code
  116. _/        EQUD    0 ;Module_Finalisation_Code
  117. `/        EQUD    Module_Service_Call_Handler
  118. a'        EQUD    Module_Title_String
  119. b&        EQUD    Module_Help_String
  120. c<        EQUD    0 ;Module_Help_And_Command_Keyword_Table
  121. d1.Module_Title_String    EQUS ModuleTitle$+ 
  122. e0.Module_Help_String     EQUS ModuleHelp$+ 
  123.         ALIGN
  124. gM\------------------------------------------------------------------------
  125. i/; In    R10 = pointer to environment string
  126. j';       R11 = instantination number
  127. k);       R12 = pointer to private word
  128. ; Out   PSR_V
  129. ; Bad   R0-R6, R12
  130. .Module_Initialisation_Code
  131. p"        B       xensure_screen
  132. qM\------------------------------------------------------------------------
  133. ; In    R1 = service number
  134. t);       R12 = pointer to private word
  135. uH; Out   R1 = 0 if claiming, R0, R2-R8 may be altered if intercepting
  136. ; Bad   R12
  137. x .Module_Service_Call_Handler
  138. y/        TEQ     R1, #Service_DesktopWelcome
  139.         MOVneS  pc, lr
  140. {&        STMFD   (sp)!, {R0-R5, lr}
  141. |,        MOV     R0, #ModHandReason_Claim
  142. }!        
  143. mov("", 3, sizeof_G)
  144. ~         SWI     "XOS_Module"
  145. ;        LDMvsFD (sp)!, {R0-R5, pc}^             ; Damn!
  146.         MOV     gb, R2
  147. flop("SMFD    sp!, {F0-F3}")
  148.         MOV     lr, #0
  149. %        MOV     R3, #G_SpriteArea
  150. .loop   SUBS    R3, R3, #4
  151. D        STRhs   lr, [gb, R3]                    ; Zero workspace
  152.         Bhi     loop
  153.         BL      init_rnd
  154. "        BL      xensure_screen
  155. "        BLvc    xexpand_sprite
  156. #        BLvc    xinit_animation
  157.          BLvc    xinit_screen
  158.         MOVvc   R4, #0
  159. .loop   MOVvc   R0, R4
  160.          MOVvc   R1, #NFrames
  161. #        BLvc    xplot_animation
  162.         Bvs     err_service
  163.         ADD     R4, R4, #1
  164.          CMP     R4, #NFrames
  165.         Ble     loop
  166. .err_service
  167. flop("LMFD    sp!, {F0-F3}")
  168. #        BL      xrestore_screen
  169.         MOV     R2, gb
  170. +        MOV     R0, #ModHandReason_Free
  171. G        SWI     "XOS_Module"                    ; Release workspace
  172. &        LDMFD   (sp)!, {R0-R5, lr}
  173.         MOV     R1, #0
  174.         MOVS    pc, lr
  175. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176. ;; Choose a random starting point, and a random rotation
  177. %.vars   EQUD    VduExt_XWindLimit
  178. %        EQUD    VduExt_YWindLimit
  179. %        EQUD    VduExt_XEigFactor
  180. %        EQUD    VduExt_YEigFactor
  181.         EQUD -1
  182. J.sprite_width   EQUD Width%                     ; set when load sprite
  183. H.sprite_height  EQUD Height%                    ; units are 1/256 os
  184. .xinit_animation
  185. &        STMFD   (sp)!, {R4-R5, lr}
  186.         SUB     sp, sp, #16
  187.         ADR     R0, vars
  188.         MOV     R1, sp
  189. *        SWI     "XOS_ReadVduVariables"
  190. "        LDMFD   (sp)!, {R1-R4}
  191. &        LDMvsFD (sp)!, {R4-R5, pc}
  192.         ADD     R1, R1, #1
  193.         ADD     R2, R2, #1
  194. I        MOV     R4, R2, LSL R4                  ; OS height of screen
  195. #        MOV     R0, R1, LSL R3 
  196. T        MOV     R5, R0, LSL #8 - 1              ; Screen center in 1/256 OS unit
  197.         ADD     R0, R5, R5
  198. S        BL      rnd_lo                          ; Choose random point on screen
  199. flop("FLT     F0, R0")
  200. flop("STF     F0, [gb, #G_StartXC]")
  201.         SUB     R0, R5, R0
  202. flop("FLT     F0, R0")
  203. flop("STF     F0, [gb, #G_DeltaXC]")          ; Distance XC moves to get to center
  204. &        ADD     R0, R4, R4, LSL #1
  205. @        MOV     R0, R0, LSL #8                  ; 3/2*height
  206.         BL      rnd_lo
  207. I        SUB     R0, R0, R4, LSL #8 - 2          ; [-1/4, +5/4)*height
  208. flop("FLT     F0, R0")
  209. flop("STF     F0, [gb, #G_StartYC]")
  210. &        ADD     R4, R4, R4, LSL #2
  211. C        MOV     R4, R4, LSL #8 - 3              ; 5/8 up screen
  212.         SUB     R0, R4, R0
  213. flop("FLT     F0, R0")
  214. flop("STF     F0, [gb, #G_DeltaYC]")
  215.         BL      rnd
  216. "        MOV     R0, R0, LSR #2
  217. flop("FLT     F0, R0")
  218. W        MOV     R1, #&40000000 / 8              ; / 8 to save a multiply by 8 later
  219. flop("FLT     F1, R1")
  220. flop("DVF     F0, F0, F1")                    ; F0 = random [0, 8.0)
  221. flop("ATN     F1, #1.0")                      ; F1 = 
  222. flop("MUF     F0, F0, F1")                    ; F0 = random [0, 2*
  223. flop("STF     F0, [gb, #G_StartAngle]")
  224. $        LDR     R0, sprite_width
  225. %        LDR     R1, sprite_height
  226. flop("FLT     F0, R0")
  227. flop("STF     F0, [gb, #G_Width]")            ; os width / 2 * 256
  228. flop("FLT     F1, R1")
  229. flop("STF     F1, [gb, #G_Height]")
  230. &        LDMFD   (sp)!, {R4-R5, pc}
  231. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  232. 1; Prepare two bank screen (allocating memory)
  233. ; And initialise ChangedBox
  234. .xinit_screen
  235.         STMFD   (sp)!, {lr}
  236.         MVN     R0, #0
  237. *        MOV     R1, #VduExt_XEigFactor
  238. *        SWI     "XOS_ReadModeVariable"
  239. +        STRvc   R2, [gb, #G_XEigFactor]
  240. *        MOVvc   R1, #VduExt_YEigFactor
  241. *        SWIvc   "XOS_ReadModeVariable"
  242. +        STRvc   R2, [gb, #G_YEigFactor]
  243.         MVNvc   R0, #0
  244. $        SWIvc   "XOS_ChangedBox"
  245. D        STRvc   R0, [gb, #G_ChangedBox]         ; Note old state
  246. #        BLvc    xinit_two_banks
  247. <        MOVvc   R0, #1                          ; Enable
  248. $        SWIvc   "XOS_ChangedBox"
  249. ;        MOVvc   R0, #2                          ; Reset
  250. $        SWIvc   "XOS_ChangedBox"
  251.         LDMFD   (sp)!, {pc}
  252. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  253. .xunplot_sprite
  254. &        STMFD   (sp)!, {R4-R8, lr}
  255.  Banked_P 
  256. [OPT pass%
  257. $        
  258. gb("", 4, G_UnPlotBBox)
  259. X        LDMIA   R4, {R5-R8}                     ; What need to unplot on next screen
  260.         MVN     R0, #0
  261. $        SWI     "XOS_ChangedBox"
  262. G        LDMvcIB R1, {R0-R3}                     ; What just plotted
  263. J        STMvcIA R4, {R0-R3}                     ; Store for next frame
  264. )        LDRvc   R1, [gb, #G_PlotBank]
  265.         MOVvc   R0, #113
  266. O        SWIvc   "XOS_Byte"                      ; Display what just plotted
  267. )        LDRvc   R1, [gb, #G_PlotBank]
  268. @        RSBvc   R1, R1, #3                      ; Toggle 1/2
  269. )        STRvc   R1, [gb, #G_PlotBank]
  270. 4        MOVvc   R0, #112                        
  271. O        SWIvc   "XOS_Byte"                      ; Plot to screen now hidden
  272. [OPT pass%
  273.         MVN     R0, #0
  274. $        SWI     "XOS_ChangedBox"
  275.         LDMvcIB R1, {R5-R8}
  276. [OPT pass%          
  277.         SUBvc   R5, R5, #1
  278.         SUBvc   R6, R6, #1
  279.         ADDvc   R7, R7, #1
  280.         ADDvc   R8, R8, #1
  281.         MOVvc   R0, #&84
  282. O        SWIvc   "XWimp_SetColour"               ; Background, wimp colour 4
  283. +        LDRvc   R3, [gb, #G_XEigFactor]
  284. +        LDRvc   R4, [gb, #G_YEigFactor]
  285.         MOVvc   R0, #19
  286. E        SWIvc   "XOS_Byte"                      ; Pause one frame
  287.         MOVvc   R0, #&44
  288. "        MOVvc   R1, R5, LSL R3
  289. "        MOVvc   R2, R6, LSL R4
  290. I        SWIvc   "XOS_Plot"                      ; Move to bottom left
  291.         MOVvc   R0, #&67
  292. "        MOVvc   R1, R7, LSL R3
  293. "        MOVvc   R2, R8, LSL R4
  294. O        SWIvc   "XOS_Plot"                      ; Rectangle fill background
  295. <        MOVvc   R0, #1                          ; Enable
  296. $        SWIvc   "XOS_ChangedBox"
  297.  ;        MOVvc   R0, #2                          ; Reset
  298. !$        SWIvc   "XOS_ChangedBox"
  299. "&        LDMFD   (sp)!, {R4-R8, pc}
  300. #R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  301. .xrestore_screen
  302.         STMFD   (sp)!, {lr}
  303. '+        LDRvc   R0, [gb, #G_ChangedBox]
  304.         
  305. vc   R0, R0, #1
  306. )D        SWIvc   "XOS_ChangedBox"                ; Restore status
  307. *"        BLvc    xinit_one_bank
  308.         LDMFD   (sp)!, {pc}
  309. ,R;~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  310. ; In    -
  311. ; Out   -
  312. .init_rnd
  313.         MOV     R0, #3
  314. 3&        STMFD   (sp)!, {R0-R1, lr}
  315.         MOV     R1, sp
  316.         MOV     R0, #14
  317.         SWI     "XOS_Word"
  318. 7"        LDMFD   (sp)!, {R1-R2}
  319. 8'        ADDS    R0, R0, R1, ROR #13
  320. 9'        RSCS    R0, R0, R2, ROR #11
  321. :         ADDeq   R0, R0, #&CB
  322. ;%        STR     R0, [gb, #G_Seed]
  323. <         LDMFD   (sp)!, {pc}^
  324. =R;~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  325. ; In    -
  326. ; Out   R0 = random 32-bit
  327. C%        LDR     R0, [gb, #G_Seed]
  328. DJ        
  329.      R1, R0, #1 << 29        ; These values obtained by trial
  330. EJ        ADD     R1, R1, R1              ; and error.  The algorithm is
  331. FA        
  332.      R0, R1, R0, ROR #13     ; old hat, GFSR I think
  333. G%        STR     R0, [gb, #G_Seed]
  334.         MOVS    pc, lr
  335. IR;~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  336. K ; In    R0 = unsigned 32-bit
  337. L(; Out   R0 = random in range [0, R0)
  338. .rnd_lo
  339. O#        STMFD   (sp)!, {R0, lr}
  340.         BL      rnd
  341.         LDMFD   (sp)!, {R1}
  342.         BL      udivmod
  343. S?        MOV     R0, R1                          ; Remainder
  344. T         LDMFD   (sp)!, {pc}^
  345. UR;~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  346. ; In    R0 = unsigned
  347. X#;       R1 = unsigned, non-zero
  348. Y4; Out   R0 = R0 / R1 (rounded down towards zero)
  349. ;       R1 = R0 
  350. [6; Note  if R1 = 0 then get stuck in infinite loop!
  351. .udivmod
  352.         
  353. divrem(2, 0, 1, 3)
  354.         MOV     R1, R0
  355.         MOV     R0, R2
  356.         MOVS    pc, lr
  357. bR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  358.  Banked_P 
  359. [OPT pass%
  360. g>; This ensures there is enough screen memory for two banks
  361. .xensure_screen
  362.         STMFD   (sp)!, {lr}
  363.         MVN     R0, #0
  364. l*        MOV     R1, #VduExt_ScreenSize
  365. m*        SWI     "XOS_ReadModeVariable"
  366. nN        ADDvc   R3, R2, R2                      ; Need twice screen memory
  367. o<        MOVvc   R0, #2                          ; Screen
  368. p)        SWIvc   "XOS_ReadDynamicArea"
  369.         LDMvsFD (sp)!, {pc}
  370.         SUBS    R1, R3, R1
  371. s<        MOVgt   R0, #2                          ; Screen
  372. tA        SWIgt   "XOS_ChangeDynamicArea"         ; Enlargen it
  373.         LDMFD   (sp)!, {pc}
  374. wB; This is called in init_screen to set up the G_UnPlotBBox bit
  375. x"; And to page the correct bank
  376. .xinit_two_banks
  377.         STMFD   (sp)!, {lr}
  378. |"        BL      xensure_screen
  379.         MVNvc   R0, #0
  380. ~*        MOVvc   R1, #VduExt_YWindLimit
  381. *        SWIvc   "XOS_ReadModeVariable"
  382.         MOVvc   R3, R2
  383. *        MOVvc   R1, #VduExt_XWindLimit
  384. *        SWIvc   "XOS_ReadModeVariable"
  385.         MOVvc   R0, #0
  386.         MOVvc   R1, #0
  387. '        
  388. gb("vc", lr, G_UnPlotBBox)
  389. ^        STMvcIA lr, {R0-R3}                     ; Set up so clear bank 2 first time use it
  390.         MOVvc   R1, #1
  391. )        STRvc   R1, [gb, #G_PlotBank]
  392.         MOVvc   R0, #113
  393. D        SWIvc   "XOS_Byte"                      ; Display bank 1
  394.         MOVvc   R1, #1
  395.         MOVvc   R0, #112
  396. E        SWIvc   "XOS_Byte"                      ; Write to bank 1
  397.         LDMFD   (sp)!, {pc}
  398. $; Called when finished animation
  399. J; Note that if we try restoring screen memory, then Wimp gets confused
  400. .xinit_one_bank        
  401.         STMFD   (sp)!, {lr}
  402.         MOV     R0, #113
  403.         MOV     R1, #1
  404. T        SWI     "XOS_Byte"                      ; Display bank 1                
  405.         MOV     R0, #112
  406.         MOV     R0, #1
  407.         SWI     "XOS_Byte"
  408.         LDMFD   (sp)!, {pc}
  409. [OPT pass%
  410. 2; If not banked then these routines do nothing
  411. .xinit_one_bank
  412. .xinit_two_banks
  413. .xensure_screen
  414. "        BICS    pc, lr, #PSR_V
  415. [OPT pass%
  416. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  417. !; Plot one frame of animation
  418. ; In    R0 = [0..R1]
  419. !;       R1 = number of frames
  420. ; Out   -
  421.         d       = 7
  422.         xc      = 6
  423.         yc      = 5
  424. .        angle   = d             :
  425.  careful
  426.         cos     = 4
  427. .        sin     = angle         :
  428.  careful
  429.         w       = 3
  430.         h       = 2
  431.         
  432.  leaves F0/F1 free
  433. [OPT pass%
  434. .xplot_animation
  435. &        STMFD   (sp)!, {R4-R7, lr}
  436. flop("SMFD    sp!, {F4-F7}")
  437. flop("FLT     F0, R0")
  438. flop("FLT     F1, R1")
  439. flop("DVF     d, F0, F1")                     ; d= in range [0..1]
  440. flop("ATN     F0, #1.0")
  441. flop("MUF     F0, F0, #2.0")                  ; F0 = 
  442. flop("MUF     d, d, F0")
  443. flop("SIN     d, d")                          ; d= 
  444. /2) in range [0..1]
  445. flop("LDF     F0, [gb, #G_DeltaXC]")
  446. flop("LDF     F1, [gb, #G_DeltaYC]")
  447. flop("MUF     F0, F0, d")
  448. flop("MUF     F1, F1, d")
  449. flop("LDF     xc, [gb, #G_StartXC]")
  450. flop("LDF     yc, [gb, #G_StartYC]")
  451. flop("ADF     xc, xc, F0")                    ; xc= StartXC + F4*DeltaXC
  452. flop("ADF     yc, yc, F1")                    ; yc= StartYC + F4*DeltaYC
  453. flop("LDF     w, [gb, #G_Width]")
  454. flop("LDF     h, [gb, #G_Height]")
  455. flop("MUF     w, w, d")                       ; w = w * d (linear size grow)
  456. flop("MUF     h, h, d")
  457. flop("LDF     F0, [gb, #G_StartAngle]")
  458. flop("RSF     F1, d, #1.0")
  459. flop("MUF     angle, F0, F1")
  460. flop("COS     cos, angle")
  461. flop("SIN     sin, angle")
  462. .        ; x0 = xc-w*
  463.   y0 = yc-w*
  464. .        ; x1 = xc+w*
  465.   y1 = yc+w*
  466. .        ; x2 = xc+w*
  467.   y2 = yc+w*
  468. flop("MUF     F0, w, cos")
  469. flop("MUF     F1, h, sin")
  470. flop("ADF     F1, F0, F1")                    ; F1 = w*
  471. flop("SUF     F0, xc, F1")
  472. flop("FIX     R0, F0")                        ; R0 = x0
  473. flop("ADF     F0, xc, F1")
  474. flop("FIX     R4, F0")                        ; R4 = x2
  475. flop("MUF     F1, h, sin")
  476. flop("MUF     F1, F1, #2.0")
  477. flop("SUF     F0, F0, F1")            
  478. flop("FIX     R2, F0")                        ; R2 = x1
  479. flop("MUF     F0, w, sin")
  480. flop("MUF     F1, h, cos")
  481. flop("SUF     F1, F0, F1")                    ; F1 = w*
  482. flop("SUF     F0, yc, F1")
  483. flop("FIX     R1, F0")                        ; R1 = y0
  484. flop("ADF     F0, yc, F1")
  485. flop("FIX     R5, F0")                        ; R5 = y2
  486. flop("MUF     F1, h, cos")
  487. flop("MUF     F1, F1, #2.0")
  488. flop("ADF     F0, F0, F1")
  489. flop("FIX     R3, F0")                        ; R3 = y1
  490. flop("LMFD    sp!, {F4-F7}")
  491. "        SUB     sp, sp, #4*2*4
  492.         MOV     R6, sp
  493.         SUB     R7, R0, R2
  494. G        ADD     R7, R4, R7                      ; x3 = x2 + x0 - x1
  495.         SUB     lr, R1, R3
  496. G        ADD     lr, R5, lr                      ; y3 = y2 + y0 - y1
  497. 4        STMIA   R6, {R0,R1, R2,R3, R4,R5, R7,lr}
  498. "        BL      xunplot_sprite
  499. A        MOVvc   R0, #&200 
  500.  SpriteReason_PutSpriteTransformed
  501. &        
  502. gb("vc", 1, G_SpriteArea)
  503. &        LDRvc   R2, [R1, #saFirst]
  504.         ADDvc   R2, R1, R2
  505. K        MOVvc   R3, #1                          ; Transform, not matrix
  506. H        MOVvc   R5, #8                          ; Use mask if exists
  507. J        MOVvc   R7, #0                          ; No translation table
  508. "        SWIvc   "XOS_SpriteOp"
  509. "        ADD     sp, sp, #4*2*4
  510. &        LDMFD   (sp)!, {R4-R7, pc}
  511. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  512. .xexpand_sprite
  513. &        STMFD   (sp)!, {R4-R5, lr}
  514. P        MOV     R0, #0                          ; Flags (fast decompression)
  515. #        
  516. gb("", 1, G_WorkSpace)
  517. '        ADR     R2, compressed_data
  518. '        LDR     R3, compressed_size
  519.     $        
  520. gb("", 4, G_SpriteArea)
  521. )        LDR     R5, decompressed_size
  522. (        SWI     "XSquash_Decompress"
  523. &        LDMFD   (sp)!, {R4-R5, pc}
  524. 3.compressed_size        EQUD sizeof_Compressed%
  525. 3.decompressed_size      EQUD sizeof_SpriteArea%
  526. .compressed_data
  527.   P% += sizeof_Compressed%
  528.   O% += sizeof_Compressed%
  529. aadr(P%)>L% 
  530.  1, "Assembler out of space"
  531.  pass% 
  532. x    
  533.  "Squash_Compress", 0, WorkSpace%, SpriteArea%, sizeof_SpriteArea%, 
  534. aadr(compressed_data), sizeof_Compressed%
  535. _Constants(code%, L%)
  536.  O%, P%, pass%
  537.   pass% = %1110
  538. O%=code%:P%=0:[OPT pass%
  539. =.G_PrivateWord          EQUD 0  ; pointer to private word
  540. F.G_XEigFactor           EQUD 0  ; VduExt variable for current mode
  541.  F.G_YEigFactor           EQUD 0  ; VduExt variable for current mode
  542. !P.G_ChangedBox           EQUD 0  ; bit 0 is enable state before we changed it
  543. "8.G_Seed                 EQUD 0  ; random number seed
  544. #3.G_StartXC              
  545. r(8)  ; floating point
  546. $3.G_StartYC              
  547. r(8)  ; floating point
  548. %3.G_DeltaXC              
  549. r(8)  ; floating point
  550. &3.G_DeltaYC              
  551. r(8)  ; floating point
  552. '3.G_StartAngle           
  553. r(8)  ; floating point
  554. (3.G_Width                
  555. r(8)  ; floating point
  556. )3.G_Height               
  557. r(8)  ; floating point
  558.  Banked_P 
  559. [OPT pass%
  560. -H.G_UnPlotBBox           
  561. r(16) ; x0,y0,x1,y1 inclusive pixel co-ords
  562. .1.G_PlotBank             EQUD 0  ; toggles 1/2
  563. [OPT pass%
  564. 2*.G_SpriteArea   
  565. r(sizeof_SpriteArea%)
  566. 3C.G_WorkSpace    
  567. r(sizeof_WorkSpace%)          ; all 32K of it!
  568. .sizeof_G
  569. _Load_And_Parse_SpriteFile
  570.  t%, length%, s%, sp%, size%, w%, h%, x%, y%
  571.  "OS_File", 17, In$ 
  572.  t%,,,,length%
  573.  t%<>1 
  574.  1, "Can't find file "+ In$
  575.   length% += 4
  576.  s% length%
  577.   !s% = length%
  578.  "OS_SpriteOp", &100+SpriteReason_LoadSpriteFile, s%, In$
  579.   sp% = s% + s%!saFirst
  580. A%  size% = s%!saFirst + sp%!spNext
  581.   s%!saEnd = size%
  582.   s%!saFree = size%
  583.   s%!saNumber = 1
  584.  the above makes the first sprite the only sprite
  585.  "OS_SpriteOp", &200+SpriteReason_ReadSpriteSize, s%, sp% 
  586.  ,,, w%, h%,, mode%
  587.  "OS_ReadModeVariable", mode%, VduExt_XEigFactor 
  588.  ,, x%
  589.  "OS_ReadModeVariable", mode%, VduExt_YEigFactor 
  590.  ,, y%
  591.   w% = w% << x%
  592.   h% = h% << y%
  593. KJ  Width% = w%/2 * 256                   :
  594.  width radius, in draw units
  595. LK  Height% = h%/2 * 256                  :
  596.  height radius, in draw units
  597. M   sizeof_SpriteArea% = size%
  598.   SpriteArea% = s%
  599.  "Squash_Compress", 8, size%, s% 
  600.  sizeof_WorkSpace%, sizeof_Compressed%
  601.  WorkSpace% sizeof_WorkSpace%
  602.  buffer% sizeof_Compressed%
  603.  "Squash_Compress", 0, WorkSpace%, s%, size%, buffer%, sizeof_Compressed% 
  604.  ,,,,, n%
  605.   sizeof_Compressed% -= n%
  606.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  607. sysvar(var$)
  608.  size%, type%, buf%
  609.  "XOS_ReadVarVal", var$, 0, -1, 0, 1 
  610.  ,, size%,, type%
  611.  size% = 0 
  612. [6    
  613.  1, "System variable `"+ var$+ "' undefined."
  614. ]K    
  615.  type%=1 
  616.  1, "Bad system variable `"+ var$+ "', it's a number."
  617.     size% = -size%
  618.  buf% size%
  619. `3    
  620.  "OS_ReadVarVal", var$, buf%, size%, 0, 1
  621.     buf%?(size%-1) = 13
  622.     var$ = $buf%
  623. = var$
  624. _Wimp_Error(A%,A$):
  625. _Wimp_CloseDown:
  626.