home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 644 / MeteoroidSrc.sis (.txt) next >
EPOC Installation Package  |  2000-08-24  |  107KB  |  2,821 lines

  1. \MyStuff\Projects\Programming\OPL\Meteoroid\Sysram1.sis\MyStuff\Projects\Programming\OPL\Meteoroid\MUSIC.SIS\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\ini.opm!:\Meteoroid\ini.opm\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\PC_Bar.opm!:\Meteoroid\PC_Bar.opm\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\music.oxh!:\Meteoroid\music.oxh\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Pc_bar.omh!:\Meteoroid\Pc_bar.omh\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\ini.omh!:\Meteoroid\ini.omh\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Loader.oph!:\Meteoroid\Loader.oph\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\defaults.oph!:\Meteoroid\defaults.oph\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\constants.oph!:\Meteoroid\constants.oph\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\declarations.oph!:\Meteoroid\declarations.oph\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Meteoroid.hlp!:\Meteoroid\Meteoroid.hlp\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Meteoroid.mbm!:\Meteoroid\Meteoroid.mbm\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Meteoroid.icn!:\Meteoroid\Meteoroid.icn\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Meteoroid!:\Meteoroid\Meteoroid\MyStuff\Projects\Programming\OPL\Meteoroid\SrcRelease\Readme!:\Meteoroid\ReadmeMr. Meteoroid Game Sources
  2. \epoc32\release\MARM\rel\Sysram1.opx!:\System\OPX\Sysram1.opxSysram1 OPX 
  3.  Symbian Ltdy
  4. Sound
  5. Z:\SYSTEM\PROGRAMS\.EXE
  6. ::Main
  7. ApMIME
  8. EUSER[100000c1].DLL
  9. OPLR[10000077].DLL
  10. APGRFX[1000011b].DLL
  11. BAFL[1000004e].DLL
  12. EDBMS[100000df].DLL
  13. EFSRV[100000bd].DLL
  14. CONE[1000004d].DLL
  15. APPARC[100000de].DLL
  16. APFILE[1000013f].DLL
  17. WS32[1000017d].DLL
  18. 000D0T0`0l0x0
  19. 0 ;$;,;\?`?
  20. 2$2P2
  21. 3,3034383<3@3D3H3L3P3T3X3\3`3d3h3l3p3t3x3|3
  22. 5$505<5H5T5`5l5x5
  23. 6 6,686D6P6\6h6t6
  24. 7(747@7L7X7d7p7|7
  25. 8$808<8H8T8`8l8x8
  26. 9 9,989D9P9\9h9t9
  27. RnZ21
  28. \epoc32\RELEASE\MARM\REL\Music.opx!:\SYSTEM\OPX\Music.opxMusic OPX 
  29. Symbian Ltdy
  30. Sound
  31. EUSER[100000c1].DLL
  32. OPLR[10000077].DLL
  33. 000D0T0`0l0x0
  34. 485D5P5\5h5t5
  35. 6(646@6L6X6d6p6|6
  36. 6T7X7\7
  37. D:\opm\ini\ini.pre
  38. INI_VERSION%
  39. +*.ini file creation and modification module
  40. 1999 SymbianK(
  41. This module can only be usedO
  42. within an OPL applicationO
  43. __CREATEINI%
  44. "K+4 SELECT name,string,integer,long,float FROM deftableK
  45. NAME$
  46. STRING$
  47. LONG&
  48. FLOAT
  49. "K+; FIELDS name(32),string(255),integer,long,float TO deftableK
  50. NAME$
  51. STRING$
  52. LONG&
  53. FLOAT
  54. __FINDINI&
  55. NAME$'
  56. STRING$'
  57. __FINDINI&
  58. NAME$'
  59. INT%$
  60. __FINDINI&
  61. NAME$'
  62. LONG&%
  63. __FINDINI&
  64. NAME$'
  65. FLOAT&
  66. __FINDINI&
  67. NAME$'
  68. STRING$'
  69. STRING$#
  70. __FINDINI&
  71. NAME$'
  72. INT%$
  73. INT% 
  74. __FINDINI&
  75. NAME$'
  76. LONG&%
  77. LONG&!
  78. __FINDINI&
  79. NAME$'
  80. FLOAT&
  81. FLOAT"
  82.     INI_OPEN%
  83. INI_WRITE$
  84.     INI_CLOSE
  85. INILastUsedFileO
  86.     INI_OPEN%
  87.     INI_READ$
  88.     INI_CLOSE
  89. INILastUsedFileO
  90. __FINDINI&
  91. INIMAIN'
  92.     INI_OPEN%
  93. __CREATEINI%
  94.     INI_CLOSEF
  95. __FINDINI&h
  96. INI_WRITE$
  97. INI_WRITE%
  98. INI_WRITE&n
  99.     INI_WRITE
  100.     INI_READ$6
  101.     INI_READ%
  102.     INI_READ&>
  103. INI_READ
  104. SETLASTUSEDFILE%D
  105. GETLASTUSEDFILE$
  106. INI_DELETE&
  107. INI_VERSION%g
  108. SYSRAM1
  109. $D:\Development\OPM\pc_bar\pc_bar.pre!
  110. PC_BAR_VERSION%
  111. Progress bar module
  112. 1999 SymbianK(
  113. This module can only be usedO
  114. within an OPL applicationO
  115. _PC_FONTSIZE&
  116. _PC_BAR_INITIALISE&    
  117. _PC_DESTROY_STRUCT
  118. O?8`[
  119. _PC_BAR_INITIALISE&    
  120. _PC_DESTROY_STRUCT
  121. _PC_BAR_INITIALISE&    
  122. _PC_COLOUR
  123. _PC_DESTROY_STRUCT
  124. _PC_DESTROY_STRUCT
  125. {IWCO
  126. _PC_DESTROY_STRUCT
  127. {IWCO
  128. _PC_DESTROY_STRUCT
  129. {IWCO
  130. _PC_COLOUR
  131. {IWCO
  132. {IWCO
  133. |VWB}O
  134. PC_MAIN9
  135. _PC_DESTROY_STRUCT
  136. _PC_BAR_INITIALISE&
  137. _PC_FONTSIZE&
  138. _PC_COLOUR
  139. PC_FREEBAR&Z
  140.     PC_GIBAR&
  141. PC_ALERTBAR&s
  142. PC_DESTROY_FREEBARz
  143. PC_DESTROY_GIBAR
  144. PC_DESTROY_ALERTBAR4    
  145. PC_BAR_UPDATE%
  146. PC_BAR_VERSION%J
  147. REM ALARM.OXH
  148. REM Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
  149. CONST KOpxMusicUid&=&10000B91
  150. CONST KOpxMusicVersion%=$500
  151. DECLARE OPX MUSIC,KOpxMusicUid&,KOpxMusicVersion%
  152.     MusicDTMF:(aDtmf$) : 1
  153.     MusicSetVolume:(aVolume%) : 2
  154.     MusicNote:(aPitch&, anAmplitude&): 3
  155.     MusicStop: : 4
  156. END DECLARE
  157. *TextEd.app
  158. "REM PC_BAR.OMH version 1.03
  159. rem Header File for PC_BAR.OPM
  160. rem Copyright (c) 1999 Symbian Ltd. All rights reserved.
  161. REM Bar Text Format
  162. REM ---------------
  163. CONST KPcBarTextNone%=0
  164. CONST KPcBarTextPercent%=1
  165. CONST KPcBarTextNumber%=2
  166. REM Colours
  167. REM Bar Colour - 2 Colour
  168. REM ---------------------
  169. CONST KPcBarColourWhite&=&F0F0F0
  170. CONST KPcBarColourBlack&=&000000
  171. CONST KPcBarColorWhite&=&F0F0F0
  172. CONST KPcBarColorBlack&=&000000
  173. REM Bar Color - 4 Color (plus white and black)
  174. REM --------------------------------------------
  175. CONST KPcBarColourDkGrey&=&505050
  176. CONST KPcBarColourLtGrey&=&A0A0A0
  177. CONST KPcBarColorDkGrey&=&505050
  178. CONST KPcBarColorLtGrey&=&A0A0A0
  179. REM Bar Color - 16 Color (plus white and black)
  180. REM ---------------------------------------------
  181. CONST KPcBarColourGrey1&=&101010
  182. CONST KPcBarColourGrey2&=&202020
  183. CONST KPcBarColourGrey3&=&303030
  184. CONST KPcBarColourGrey4&=&404040
  185. CONST KPcBarColourGrey5&=&505050
  186. CONST KPcBarColourGrey6&=&606060
  187. CONST KPcBarColourGrey7&=&707070
  188. CONST KPcBarColourGrey8&=&808080
  189. CONST KPcBarColourGrey9&=&909090
  190. CONST KPcBarColourGrey10&=&A0A0A0
  191. CONST KPcBarColourGrey11&=&B0B0B0
  192. CONST KPcBarColourGrey12&=&C0C0C0
  193. CONST KPcBarColourGrey13&=&D0D0D0
  194. CONST KPcBarColourGrey14&=&E0E0E0
  195. CONST KPcBarColorGrey1&=&101010
  196. CONST KPcBarColorGrey2&=&202020
  197. CONST KPcBarColorGrey3&=&303030
  198. CONST KPcBarColorGrey4&=&404040
  199. CONST KPcBarColorGrey5&=&505050
  200. CONST KPcBarColorGrey6&=&606060
  201. CONST KPcBarColorGrey7&=&707070
  202. CONST KPcBarColorGrey8&=&808080
  203. CONST KPcBarColorGrey9&=&909090
  204. CONST KPcBarColorGrey10&=&A0A0A0
  205. CONST KPcBarColorGrey11&=&B0B0B0
  206. CONST KPcBarColorGrey12&=&C0C0C0
  207. CONST KPcBarColorGrey13&=&D0D0D0
  208. CONST KPcBarColorGrey14&=&E0E0E0
  209. REM Freebar Direction
  210. REM -----------------
  211. CONST KPcBarHorizontal%=0
  212. CONST KPcBarVertical%=1
  213. REM External declarations
  214. EXTERNAL pc_gibar&:(location%, textformat%)
  215. EXTERNAL pc_alertbar&:(title$, textabove$, textbelow$, textformat%, divisions%)
  216. EXTERNAL pc_destroy_freebar:(freebar&)
  217. EXTERNAL pc_destroy_gibar:(gibar&)
  218. EXTERNAL pc_destroy_alertbar:(alertbar&)
  219. EXTERNAL pc_bar_update%:(bar&,position%)
  220. EXTERNAL pc_freebar&:(winID%,x%,y%,length%,width%,direction%,textformat%,forecolour&,backcolour&,divisions%)
  221. EXTERNAL pc_bar_Version%:
  222. *TextEd.app
  223. m    rem INI.OMH version 1.03
  224. rem Header File for INI.OPM
  225. rem Copyright (c) 1999 Symbian Ltd. All rights reserved.
  226. EXTERNAL inimain:
  227. EXTERNAL INI_Open%:(inifile$)
  228. EXTERNAL INI_Close:(inifile$)
  229. EXTERNAL INI_WRITE$:(name$,string$)
  230. EXTERNAL INI_WRITE%:(name$,int%)
  231. EXTERNAL INI_WRITE&:(name$,long&)
  232. EXTERNAL INI_WRITE:(name$,float)
  233. EXTERNAL INI_READ$:(name$,default$)
  234. EXTERNAL INI_READ%:(name$,default%)
  235. EXTERNAL INI_READ&:(name$,default&)
  236. EXTERNAL INI_READ:(name$,default)
  237. EXTERNAL SETLASTUSEDFILE%:(inifile$,FileName$)
  238. EXTERNAL GETLASTUSEDFILE$:(IniFile$)
  239. EXTERNAL INI_Delete:(name$)
  240. EXTERNAL INI_Version%:
  241. *TextEd.app
  242. REM Constants for the OPM Loader procedures
  243. CONST KStandardOPMPath$="\System\OPM\"
  244. CONST KOPMExtension$=".OPM"
  245. * OPM STUFF *
  246.  Headers from procedures in file "Loader.tpl", included
  247.  with OPMs downloaded from Symbian.
  248. EXTERNAL OPM_FileLoc$:(file$)
  249. EXTERNAL OPM_LoadModule:(modulename$)
  250. EXTERNAL OPM_UnloadModule:(modulename$)
  251. *TextEd.app
  252. REM *******************************
  253. REM ****                       ****
  254. REM ****  MR. METEOROID GAME   ****
  255. REM ****      v0.85(beta)      ****
  256. REM **** 
  257. 2000 Malcolm Tyrrell ****
  258. REM ****                       ****
  259. REM *******************************
  260. REM **************************
  261. REM ****                  ****
  262. REM **** Program Defaults ****
  263. REM ****                  ****
  264. REM **************************
  265. REM *****************
  266. REM ****         ****
  267. REM **** License ****
  268. REM ****         ****
  269. REM *****************
  270. REM You can redistribute, modify this source code and/or use bits
  271. REM of it in your programs. Hurray!
  272. REM ******************
  273. REM ****          ****
  274. REM **** Warranty ****
  275. REM ****          ****
  276. REM ******************
  277. REM This source is distributed in the hope that it will be useful,
  278. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  279. REM MERCHANTABILITY or FITNESS
  280. PARTICULAR PURPOSE.
  281. REM See the help file for details.
  282. * Application defaults *
  283.  s,x,k,m
  284. CONST D_app_initKey1%= 115
  285. CONST D_app_initKey2%= 120
  286. CONST D_app_initKey3%= 107
  287. CONST D_app_initKey4%= 109
  288. * Sound defaults *
  289. CONST D_sound_on%=Kfalse%
  290. CONST D_sound_volume%=2
  291. * High Score defaults *
  292.  there should be K_hs_tableSize% of these
  293. CONST D_hs_name1$="AAA"
  294. CONST D_hs_name2$="AAA"
  295. CONST D_hs_name3$="AAA"
  296. CONST D_hs_name4$="AAA"
  297. CONST D_hs_name5$="AAA"
  298.  there should be K_hs_tableSize% of these
  299. CONST D_hs_score1&=2000
  300. CONST D_hs_score2&=1000
  301. CONST D_hs_score3&=500
  302. CONST D_hs_score4&=250
  303. CONST D_hs_score5&=100
  304. *TextEd.app
  305. 9DREM *******************************
  306. REM ****                       ****
  307. REM ****  MR. METEOROID GAME   ****
  308. REM ****      v0.85(beta)      ****
  309. REM **** 
  310. 2000 Malcolm Tyrrell ****
  311. REM ****                       ****
  312. REM *******************************
  313. REM ******************************
  314. REM ****                      ****
  315. REM **** Constant Definitions ****
  316. REM ****                      ****
  317. REM ******************************
  318. REM *****************
  319. REM ****         ****
  320. REM **** License ****
  321. REM ****         ****
  322. REM *****************
  323. REM You can redistribute, modify this source code and/or use bits
  324. REM of it in your programs. Hurray!
  325. REM ******************
  326. REM ****          ****
  327. REM **** Warranty ****
  328. REM ****          ****
  329. REM ******************
  330. REM This source is distributed in the hope that it will be useful,
  331. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  332. REM MERCHANTABILITY or FITNESS
  333. PARTICULAR PURPOSE.
  334. REM See the help file for details.
  335. * Application constants *
  336. CONST K_app_name$="Mr. Meteoroid Game"
  337. CONST K_app_version$="v0.85beta"
  338. CONST K_app_uid&=268458080
  339.  the filebase is used for the main directory, the .app/.opo,
  340.  .mbm, .ini and .hlp files.
  341. CONST K_app_fileBase$="Meteoroid"
  342.  these match G_app_state%
  343. CONST K_app_stateLeaveApp%=10
  344. CONST K_app_stateInApp%=20
  345. CONST K_app_stateRestartGame%=30
  346. CONST K_app_stateInGame%=40
  347. CONST K_app_stateInLevel%=50
  348. CONST K_app_stateInPause%=60
  349. * Game Constants *
  350. CONST K_game_initEnergy%=200
  351. CONST K_game_maxNumAsts%=4
  352. CONST K_game_levelBonus&=56
  353. * Level Constants *
  354.  this is a ratio of the space window size
  355. CONST K_level_normAstSpeed=0.00888
  356. CONST K_level_normBaseRot=0
  357.  Timing constants
  358. CONST K_level_astMoveTimeDelay&=33000
  359.  Time interval between each time each asteroid is drawn
  360. CONST K_level_astDrawTimeDelay&=80000
  361. * HiScore Constants *
  362.  having too many entries in the table, could be a problem
  363.  on small screens.
  364. CONST K_hs_tableSize%=5
  365. * Graphic Constants *
  366. CONST K_factor&=10000
  367. * Base Constants *
  368.  these two are ratios of the space window size
  369. CONST K_base_initBaseSize=0.125
  370. CONST K_base_maxBaseSize=0.33333
  371.  these two are ratios of the base size
  372. CONST K_base_borderFactor=0.9
  373. CONST K_base_ShieldFactor=0.06666
  374.  by experiment, these values seem to work.
  375. CONST K_base_labelXOffset& = -40000
  376. CONST K_base_labelYOffset& = 60000
  377. * Asteroid Constants *
  378. CONST K_ast_smallScore&=11
  379. CONST K_ast_bigScore&=23
  380. CONST K_ast_smallDamage%=45
  381. CONST K_ast_bigDamage%=80
  382. * Bitmap Stuff *
  383. CONST K_bm_extension$=".mbm"
  384.  indices into the file K_app_fileBase$+K_bm_extension$
  385. CONST K_bm_titleMrIndex%=0
  386. CONST K_bm_titleMeteoroidIndex%=1
  387. CONST K_bm_titleGameIndex%=2
  388. CONST K_bm_panelScoreIndex%=3
  389. CONST K_bm_panelEnergyIndex%=4
  390. CONST K_bm_screenBGIndex%=5
  391. CONST K_bm_bigAstIndex%=6
  392. CONST K_bm_bigAstMaskIndex%=7
  393. CONST K_bm_smallAstIndex%=8
  394. CONST K_bm_smallAstMaskIndex%=9
  395. * Space Stuff *
  396.  Sensible limit values
  397.  Reasons why I limit the size of the space window,
  398.  given that the game code would will scale:
  399.  the sprites are fixed
  400.  the font on the base is fixed
  401.  in large space windows, the sprites would jump too much
  402. CONST K_space_minSize%=160
  403. CONST K_space_maxSize%=240
  404. * Title Stuff *
  405. CONST K_title_xDim%=120
  406.  these are limits, it can have values in between
  407. CONST K_title_yDimBig%=140
  408. CONST K_title_yDimSmall%=80
  409. * Panel Stuff *
  410. CONST K_panel_xDim%=120
  411.  these are limits, it can have values in between
  412. CONST K_panel_yDimBig%=140
  413. CONST K_panel_yDimSmall%=80
  414.  this font kind of matches the size of the prerendered 
  415.  "Score/Energy" text
  416. CONST K_panel_scoreFont&=KFontArialNormal18&
  417. CONST K_panel_scoreFontHeight%=17
  418.  time interval between panel updates
  419. CONST K_panel_timeDelay&=150000
  420. * Sound Stuff *
  421. CONST K_sound_highPitch&=600
  422. CONST K_sound_midPitch&=475
  423. CONST K_sound_lowPitch&=300
  424. CONST K_sound_amplitude%=100
  425. CONST K_sound_duration&=20000
  426. * High Score Stuff *
  427.  this is also used by the panel and the game over dialog.
  428. CONST K_hs_numDigits%=9
  429. * .ini file stuff *
  430. CONST K_init_drive$="C:"
  431. CONST K_init_path$="\System\Apps\"
  432. CONST K_init_extension$=".ini"
  433. * Help file stuff *
  434. CONST K_help_extension$=".hlp"
  435. *TextEd.app
  436. BREM *******************************
  437. REM ****                       ****
  438. REM ****  MR. METEOROID GAME   ****
  439. REM ****      v0.85(beta)      ****
  440. REM **** 
  441. 2000 Malcolm Tyrrell ****
  442. REM ****                       ****
  443. REM *******************************
  444. REM ********************************
  445. REM ****                        ****
  446. REM **** Procedure Declarations ****
  447. REM ****                        ****
  448. REM ********************************
  449. REM *****************
  450. REM ****         ****
  451. REM **** License ****
  452. REM ****         ****
  453. REM *****************
  454. REM You can redistribute, modify this source code and/or use bits
  455. REM of it in your programs. Hurray!
  456. REM ******************
  457. REM ****          ****
  458. REM **** Warranty ****
  459. REM ****          ****
  460. REM ******************
  461. REM This source is distributed in the hope that it will be useful,
  462. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  463. REM MERCHANTABILITY or FITNESS
  464. PARTICULAR PURPOSE.
  465. REM See the help file for details.
  466. * The Main Procedure *
  467. EXTERNAL main:
  468. * Application Stuff *
  469. EXTERNAL app_initialise:
  470. EXTERNAL app_loop:
  471. EXTERNAL app_close:
  472. EXTERNAL _app_getPathAndDrive:
  473. * Game Stuff *
  474. EXTERNAL game_initialise:
  475. EXTERNAL game_loop:
  476. EXTERNAL game_close:
  477. * Level Stuff *
  478. EXTERNAL level_initialise:(level%)
  479. EXTERNAL level_loop:(level%)
  480. EXTERNAL level_close:
  481. EXTERNAL _level_astInitialise:(num%)
  482. EXTERNAL _level_astCheck:(timenow&)
  483. EXTERNAL _level_numAstsAt%:(level%)
  484. * Pause Stuff *
  485. EXTERNAL pause_initialise:
  486. EXTERNAL pause_loop:
  487. EXTERNAL pause_close:
  488. * BASE GRAPHICS STUFF *
  489. EXTERNAL base_initialise:
  490. EXTERNAL base_draw:
  491. EXTERNAL base_delete:
  492. EXTERNAL base_updateShield:(shield%)
  493. EXTERNAL base_growBase:
  494. EXTERNAL base_rotateBase:
  495. EXTERNAL base_moveBase:(dispFactor)
  496. EXTERNAL base_close:
  497. EXTERNAL _base_drawBase:(see%)
  498. EXTERNAL _base_drawShield:(see%)
  499. EXTERNAL _base_drawLabels:(see%)
  500. EXTERNAL _base_drawSquare:(factor&,x&,y&,size&,rot)
  501. EXTERNAL _base_drawEdge:(factor&,x&,y&,size&,rot,edge%)
  502. EXTERNAL _base_setGrey:(grey%)
  503. * Asteroid Graphics Stuff *
  504. EXTERNAL ast_initialise:(num%,size%)
  505. EXTERNAL ast_draw:(num%)
  506. EXTERNAL ast_explode:(num%)
  507. EXTERNAL ast_newStartPosition:(num%)
  508. EXTERNAL ast_updateProperties:(num%,speed&)
  509. EXTERNAL ast_close:(num%)
  510. EXTERNAL _ast_createSmallAst&:
  511. EXTERNAL _ast_createBigAst&:
  512. * Screen Stuff *
  513. EXTERNAL screen_initialise:
  514. EXTERNAL screen_close:
  515. EXTERNAL _screen_arrange:(screen_xDim%,screen_yDim%)
  516. EXTERNAL _screen_SizeNotSupported:
  517. * Space Window Stuff *
  518. EXTERNAL space_initialise:(xPos%,yPos%,xDim%,yDim%)
  519. EXTERNAL space_close:
  520. EXTERNAL _space_build:(xPos%,yPos%,xDim%,yDim%)
  521. * Title Window Stuff *
  522. EXTERNAL title_initialise:(xPos%,yPos%,xDim%,yDim%)
  523. EXTERNAL title_close:
  524. EXTERNAL _title_build:(xPos%,yPos%,xDim%,yDim%)
  525. * Panel graphics *
  526. EXTERNAL panel_initialise:(xPos%,yPos%,xDim%,yDim%)
  527. EXTERNAL panel_check:(timenow&)
  528. EXTERNAL panel_update:
  529. EXTERNAL panel_close:
  530. EXTERNAL _panel_build:(xPos%,yPos%,xDim%,yDim%)
  531. EXTERNAL _panel_printScore:
  532. EXTERNAL _panel_printEnergy:
  533. * .ini File Stuff *
  534. EXTERNAL init_initialise:
  535. EXTERNAL init_useDefaults:
  536. EXTERNAL init_close:
  537. EXTERNAL _init_readInits:
  538. EXTERNAL _init_writeInits:
  539. * Bitmap Stuff *
  540. EXTERNAL bm_initialise:
  541. EXTERNAL bm_close:
  542. * Menu
  543. EXTERNAL menu_display:
  544. * Commands *
  545. EXTERNAL cmd_checkSysKey%:(key&)
  546. EXTERNAL cmd_restart:
  547. EXTERNAL cmd_exit:
  548. EXTERNAL cmd_quit:
  549. EXTERNAL cmd_pause:
  550. * Help Stuff *
  551. EXTERNAL help_initialise:
  552. EXTERNAL help_display:
  553. EXTERNAL help_close:
  554. * Preferences *
  555. EXTERNAL pref_change_keys:
  556. EXTERNAL pref_restore_defaults:
  557. * About *
  558. EXTERNAL about_display:
  559. * High Scores *
  560. EXTERNAL hs_display:
  561. EXTERNAL hs_gameover%:(score&)
  562. EXTERNAL _hs_getPlayerName$:
  563. * Sound Stuff *
  564. EXTERNAL sound_initialise:
  565. EXTERNAL sound_setupDialog:
  566. EXTERNAL sound_highBeep:
  567. EXTERNAL sound_midBeep:
  568. EXTERNAL sound_lowBeep:
  569. EXTERNAL sound_check:(timeNow&)
  570. EXTERNAL sound_stop:
  571. EXTERNAL sound_close:
  572. * Misc Tools *
  573. EXTERNAL misc_padWithZeroes$:(width%,number&)
  574. EXTERNAL misc_confirm%:(title$,question$)
  575. * Test Stuff *
  576. EXTERNAL test_specificDevices:
  577. *TextEd.app
  578. "Data.app
  579. Table1
  580. ColA9
  581. ColB9
  582. ColA10
  583. ColB10
  584. ColA12
  585. ColB12
  586. Table1
  587. Title:
  588. *Help Text:
  589. &Keywords:
  590. Arial
  591. I'd like to thank:
  592.  Glenn Strong for discussion and beta testing.
  593.  Ray Larabie for his lovely 
  594. Soviet
  595.  font. Check out his other fonts at http://www.larabiefonts.com
  596.  The GNU project for their Warranty. (I would have GPLed this program if it didn't use Symbian's OPMs).
  597. . I encourage you to use bits of it in your own projects (with the condition that they also are GPLed 
  598.  see the GPL).
  599. Sketch
  600. &Paint.app
  601. Sketch
  602. &Paint.app
  603. NO WARRANTY
  604. BECAUSE THE PROGRAM IS FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM 
  605. AS IS
  606.  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPARE OR CORRECTION.
  607. IN NO EVENT UNLESS REQUIRED BY LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCULDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  608. Mr. Meteoroid Game
  609. "Welcomes to you, fellow shield-operatron of planetoid defence. Again we must defendinate our glorious planetoid against descending space-bits. If only we can achievify high scorings before our inevitable doomage
  610. Introduction
  611. Mr. Meteoroid Game v0.85beta
  612. 2000 Malcolm Tyrrell.
  613. A lo-fi game for you to enjoy.
  614.     The Game
  615. The object of the game is to gain lots of points. Points are gained when a meteoroid strikes your shield, or when you pass a level.
  616. The game ends when you have lost all your energy. You lose energy when a meteoroid strikes your base.
  617.     Controls
  618. You use keys to activate your shields.
  619. The key for each shield is marked on the side of the base that it protects.
  620. You can change the keys. Use the menu command: "Change Keys
  621. Scoring
  622. Points are given as follows:
  623. 11 points for a 
  624. 23 points for a 
  625. 56 points for each level passed.
  626. Sound
  627. If you wish to enable beeps, you can switch on sound. Use the "Sound Setup
  628. " controls in the menu.
  629. On slower devices, this may cause the game to slow down slightly.
  630.     Warranty
  631. License
  632. Mr. Meteoroid Game is 
  633. 2000 Malcolm Tyrrell.
  634. This program is freeware; you may freely distribute it.
  635.     Contacts
  636. e-mail: tyrrelmr@cs.tcd.ie
  637. www:  http://www.cs.tcd.ie/Malcolm.Tyrrell
  638. Source Available
  639. The complete source code is available for your perusal and should have come with the program. If do you use any bits of it in your own programs, I encourage you to make them open source. I do not demand it.
  640. Acknowledgements
  641. REM *******************************
  642. REM ****                       ****
  643. REM ****  MR. METEOROID GAME   ****
  644. REM ****      v0.85(beta)      ****
  645. REM **** 
  646. 2000 Malcolm Tyrrell ****
  647. REM ****                       ****
  648. REM *******************************
  649. REM **************************
  650. REM ****                  ****
  651. REM **** Main Source Code ****
  652. REM ****                  ****
  653. REM **************************
  654. REM *****************
  655. REM ****         ****
  656. REM **** License ****
  657. REM ****         ****
  658. REM *****************
  659. REM You can redistribute, modify this source code and/or use bits
  660. REM of it in your programs. Hurray!
  661. REM ******************
  662. REM ****          ****
  663. REM **** Warranty ****
  664. REM ****          ****
  665. REM ******************
  666. REM This source is distributed in the hope that it will be useful,
  667. REM but WITHOUT ANY WARRANTY; without even the implied warranty of
  668. REM MERCHANTABILITY or FITNESS
  669. PARTICULAR PURPOSE.
  670. REM See the help file for details.
  671. REM ***************
  672. REM ****       ****
  673. REM **** Hello ****
  674. REM ****       ****
  675. REM ***************
  676. REM I hope you enjoy reading and using this code, I'm permitting
  677. REM its distribution in the hope that people will be inspired to
  678. REM write free and open applications for EPOC (and in general).
  679. REM I welcome you comments: e-mail me at tyrrelmr@cs.tcd.ie
  680. REM Enjoy,
  681. REM Malcolm.
  682. REM ***************
  683. REM ****       ****
  684. REM **** ToDos ****
  685. REM ****       ****
  686. REM ***************
  687.  Pause problem.
  688.  Menu key problem.
  689.  Check consistency of user key selections.
  690.  Move timing code into modules
  691. REM   
  692.  reconsider timing code: is it too power hungry?
  693.  Error Handling: (add some)
  694.  Introduce reinitialise procedures for graphics elements
  695.  add toolbar support
  696. REM   
  697.  prevent switching during game due to scaling problem
  698.  move user interaction into module
  699.  rethink menu
  700.  Bug fixes
  701. REM   
  702.  if any!
  703.  Confirm it behaves on other devices
  704.  internationalisation, using Symbian tools
  705. REM   
  706.  request contribution
  707. REM   
  708.  ideally all within one .sis file
  709.  Re-do help file properly using Aleppo tool from Symbian
  710.  Add soundtrack by FSOL
  711.  Add textured 3D-rendered graphics
  712.  Add Macro5 macro support
  713.  Add Gameboy Printer support
  714.  Take over Europe using genetically modified army of
  715. REM   superpeople
  716. REM *******************************
  717. REM ****                       ****
  718. REM **** Included Header Files ****
  719. REM ****                       ****
  720. REM *******************************
  721. * Built in OPHs *
  722.  Standard Constants
  723. INCLUDE "const.oph"
  724. * Downloaded OPHs *
  725.  The OPM Loader, included at the end of this file.
  726. INCLUDE "LOADER.oph"
  727. * Built in OPXs *
  728.  System
  729. INCLUDE "system.oxh"
  730.  Sprite stuff
  731. INCLUDE "Bmp.oxh"
  732.  Timing stuff
  733. INCLUDE "Date.oxh"
  734. * Downloaded OPXs *
  735.  music opx for beeps
  736. INCLUDE "music.oxh"
  737. * Downloaded OPMs *
  738.  OPM for handling .ini files
  739. INCLUDE "ini.omh"
  740.  Percent Bar OPM used for energy bar
  741. INCLUDE "pc_bar.omh"
  742. * App-specific OPHs *
  743.  App Constants
  744. INCLUDE "constants.oph"
  745.  Default Values,
  746.  (these are used if no .ini file is found)
  747. INCLUDE "defaults.oph"
  748.  External Declarations of procedures.
  749. INCLUDE "declarations.oph"
  750. REM ***************************
  751. REM ****                   ****
  752. REM **** Application Stuff ****
  753. REM ****                   ****
  754. REM ***************************
  755.  Constants can't be used here, unfortunately.
  756. REM #### Ensure app-name consistant with K_app_fileBase$
  757.  to install the game as an application, 
  758.  remove the "REM*" from the following lines.
  759.  press Ctrl+L and wait.
  760.  Copy the following four files into /System/Apps/Meteoroid/ on the
  761.    current drive.
  762.    - Meteoroid.mbm
  763.    - Meteoroid.hlp
  764.    - ini.opm
  765.    - pc_bar.opm
  766.  The icon should now be on the Extras bar.
  767. REM* APP Meteoroid,K_app_uid&
  768. REM*     ICON "Meteoroid.icn"
  769. REM*     CAPTION K_app_fileBase$,KLangEnglish%
  770. REM*     CAPTION K_app_fileBase$,KLangAmerican%
  771. REM* ENDA
  772. REM *****************
  773. REM ****         ****
  774. REM **** TESTING ****
  775. REM ****         ****
  776. REM *****************
  777.  for testing against other EPOC devices without using
  778.  the emulator.
  779. REM In order to test:
  780. REM **** FIRST  ****
  781. REM Set "T_test%" to true
  782.  CONST T_test%=Kfalse%
  783. REM CONST T_test%=Ktrue%
  784. REM **** SECOND ****
  785. REM uncomment relevant values in 
  786. REM the procedure "test_specificDevice:"
  787. REM **************************
  788. REM ****                  ****
  789. REM **** Declare External ****
  790. REM ****                  ****
  791. REM **************************
  792. DECLARE EXTERNAL
  793. REM ****************************
  794. REM ****                    ****
  795. REM **** The Main Procedure ****
  796. REM ****                    ****
  797. REM ****************************
  798. PROC main:
  799.     REM 
  800. * Application Globals *
  801.     REM 
  802.  The installation drive and path
  803.     GLOBAL G_app_drive$(2)
  804.     GLOBAL G_app_path$(KMaxStringLen%)
  805.     REM 
  806.  Holds one of the state constants: K_app_state
  807.     GLOBAL G_app_state%
  808.     REM 
  809.  when passing between app states, interact with user or not?
  810.     GLOBAL G_app_interact%
  811.     REM 
  812.  The keys (which control the shields)
  813.     GLOBAL G_app_key%(4)
  814.     REM 
  815. * Game Globals *
  816.     GLOBAL G_game_energy%
  817.     GLOBAL G_game_score&
  818.     REM 
  819. * Level Globals *
  820.     REM 
  821.  the number of asteroids in the level    
  822.     GLOBAL G_level_numKills%
  823.     GLOBAL G_level_astDrawTimeLast&(K_game_maxNumAsts%)
  824.     GLOBAL G_level_astTrav%
  825.     REM 
  826. * Screen Globals *
  827.     REM 
  828.  dimention of screen    
  829.     GLOBAL G_screen_xDim%, G_screen_yDim%
  830.     REM 
  831. * Background Globals *
  832.     REM 
  833.  the background window
  834.     GLOBAL G_bg_window%
  835.     REM 
  836. * Space Globals *
  837.     REM 
  838.  the space window and its dimensions
  839.     GLOBAL G_space_window%
  840.     REM 
  841.  its dimensions relative to K_factor&
  842.     GLOBAL G_space_xDim&, G_space_yDim&
  843.     REM 
  844. * Title Globals *
  845.     GLOBAL G_title_window%
  846.     REM 
  847. * Panel Globals *
  848.     GLOBAL G_panel_window%
  849.     GLOBAL G_panel_energyBar&
  850.     GLOBAL G_panel_timeLast&
  851.     GLOBAL G_panel_score&
  852.     GLOBAL G_panel_energy%
  853.     GLOBAL G_panel_scoreYPos%
  854.     GLOBAL G_panel_scoreWidth%
  855.     REM 
  856. * Help Globals *
  857.     GLOBAL G_help_thread&
  858.     REM 
  859. * High Score Globals *
  860.     GLOBAL G_hs_name$(5,8)
  861.     GLOBAL G_hs_score&(5)
  862.     REM 
  863. * Sound Globals *
  864.     GLOBAL G_sound_on%,G_sound_volume%,G_sound_playing%
  865.     GLOBAL G_sound_start&
  866.     REM 
  867. * Base Globals *
  868.     REM 
  869.  the properties of the space base
  870.     GLOBAL G_base_x&, G_base_y&
  871.     GLOBAL G_base_size&, G_base_rot, G_base_shield%
  872.     REM 
  873. * Asteroid Globals *
  874.     REM 
  875.  Max number of asteroids
  876.     GLOBAL G_level_numAsts%
  877.     REM 
  878.  x and y co-ords
  879.     GLOBAL G_ast_x&(K_game_maxNumAsts%)
  880.     GLOBAL G_ast_y&(K_game_maxNumAsts%)
  881.     REM 
  882.  their radii
  883.     GLOBAL G_ast_r&(K_game_maxNumAsts%)
  884.     REM 
  885.  their speed
  886.     GLOBAL G_ast_speed&(K_game_maxNumAsts%)
  887.     REM 
  888.  the movement deltas
  889.     GLOBAL G_ast_dx&(K_game_maxNumAsts%)
  890.     GLOBAL G_ast_dy&(K_game_maxNumAsts%)
  891.     REM 
  892.  the side they will collide with
  893.     GLOBAL G_ast_side%(K_game_maxNumAsts%)
  894.     REM 
  895.  the distance from the centre they will hit the base at
  896.     GLOBAL G_ast_distToBase&(K_game_maxNumAsts%)
  897.     REM 
  898.  the distance from the centre they will hit the shield at
  899.     GLOBAL G_ast_distToShield&(K_game_maxNumAsts%)
  900.     REM 
  901.  the score the asteroid is worth
  902.     GLOBAL G_ast_score&(K_game_maxNumAsts%)
  903.     REM 
  904.  the damage the asteroid will cause
  905.     GLOBAL G_ast_damage%(K_game_maxNumAsts%)
  906.     REM 
  907.  their sprites
  908.     GLOBAL G_ast_sprite&(K_game_maxNumAsts%)
  909.     REM 
  910. * Bitmap Globals *
  911.     REM 
  912.  The pattern for the main background
  913.     REM 
  914.  (uses built in gLOADBIT() keyword)
  915.     GLOBAL G_bm_screenBG%
  916.     REM 
  917.  The title in a nice font
  918.     GLOBAL G_bm_titleMr%,G_bm_titleMeteoroid%,G_bm_titleGame%
  919.     REM 
  920.  the bitmap handles for the sprites
  921.     GLOBAL G_bm_bigAst&,G_bm_bigAstMask&
  922.     GLOBAL G_bm_smallAst&,G_bm_smallAstMask&
  923.     REM 
  924.  the height and width of the asteroid bitmaps
  925.     GLOBAL G_bm_bigAstXDim%
  926.     GLOBAL G_bm_smallAstXDim%
  927.     GLOBAL G_bm_panelScore%,G_bm_panelEnergy%
  928.     REM 
  929. * Application starts here *
  930.     app_initialise:
  931.     app_loop:
  932.     app_close:
  933. REM ***************************
  934. REM ****                   ****
  935. REM **** Application Stuff ****
  936. REM ****                   ****
  937. REM ***************************
  938. PROC app_initialise:
  939.     EXTERNAL G_app_state%,G_app_interact%
  940.     LOCAL now&,spaceXPos%,spaceYPos%
  941.     BUSY "Initialising
  942.     IF T_test%
  943.         test_specificDevices:
  944.     ENDIF
  945.     _app_getPathAndDrive:
  946.     init_initialise:
  947.     help_initialise:
  948.     REM 
  949.  initialise random number generator
  950.     now&=DTNow&:
  951.     RANDOMIZE DTMICRO&:(now&)
  952.     DTDeleteDateTime:(now&)
  953.     REM 
  954.  initialise graphics stuff
  955.     bm_initialise:
  956.     REM 
  957.  set up graphics
  958.     screen_initialise:
  959.     BUSY OFF
  960.     REM 
  961.  Set state
  962.     G_app_state%=K_app_stateInApp%
  963.     G_app_interact%=KTrue%
  964. PROC app_loop:
  965.     EXTERNAL G_app_state%,G_app_interact%,G_game_score&
  966.     LOCAL choice%
  967.     REM 
  968.  the main loop
  969.         IF G_app_interact%
  970.             LOCK ON
  971.             dINIT K_app_name$
  972.             dTEXT "","Press 
  973. Enter
  974.             dTEXT "","to begin play
  975.             dBUTTONS "Exit",%e,"Menu",(%m OR KDButtonPlainKey%),"Play",KKeyEnter%
  976.             choice%=DIALOG
  977.             LOCK OFF
  978.             IF choice%=%e
  979.                 cmd_exit:
  980.             REM 
  981.  I'd much rather use the MENU key here, but how?
  982.             ELSEIF choice%=%m
  983.                 menu_display:
  984.             ELSEIF choice%=KKeyEnter%
  985.                 G_app_state%=K_app_stateInGame%
  986.             ENDIF
  987.         ENDIF
  988.         IF G_app_state%>K_app_stateInApp%
  989.             REM 
  990.  Enter a game
  991.             game_initialise:
  992.             game_loop:
  993.             game_close:
  994.             IF G_app_interact%
  995.                 IF hs_gameover%:(G_game_score&)
  996.                     hs_display:
  997.                 ENDIF
  998.             ENDIF
  999.             IF G_app_state%=K_app_stateInApp%
  1000.                 G_app_interact%=KTrue%
  1001.             ELSEIF G_app_state%=K_app_stateRestartGame%
  1002.                 G_app_state%=K_app_stateInGame%
  1003.                 G_app_interact%=KFalse%
  1004.             ENDIF
  1005.         ENDIF
  1006.     UNTIL G_app_state%<K_app_stateInApp%
  1007. PROC app_close:
  1008.     REM 
  1009.  for safety, write the .ini file straight away first.
  1010.     init_close:
  1011.     screen_close:
  1012.     bm_close:
  1013.     help_close:
  1014. PROC _app_getPathAndDrive:
  1015.     EXTERNAL G_app_drive$,G_app_path$
  1016.     LOCAL command$(KMaxStringLen%)
  1017.     REM 
  1018.  command$ is the full path of the command used to start
  1019.     REM 
  1020.  the program.
  1021.     command$=CMD$(KCmdAppName%)
  1022.     G_app_drive$=LEFT$(command$,2)
  1023.     REM #### need to introduce an extra -4 when compiling as a .opo
  1024.     REM G_app_path$=MID$(command$,3,LEN(command$)-3-(2*(LEN(K_app_fileBase$))))
  1025.     G_app_path$=MID$(command$,3,LEN(command$)-4-3-(2*(LEN(K_app_fileBase$))))
  1026. REM ********************
  1027. REM ****            ****
  1028. REM **** Game Stuff ****
  1029. REM ****            ****
  1030. REM ********************
  1031. PROC game_initialise:
  1032.     EXTERNAL G_game_score&,G_game_energy%
  1033.     EXTERNAL G_app_state%,G_app_interact%
  1034.     G_game_score&=0
  1035.     G_game_energy%=K_game_initEnergy%
  1036.     panel_update:
  1037.     sound_initialise:
  1038.     base_initialise:
  1039.     REM 
  1040.  if the state is where it should be, return to 
  1041.     REM 
  1042.  interactive mode.
  1043.     IF G_app_state%=K_app_stateInGame%
  1044.         G_app_interact%=Ktrue%
  1045.     ENDIF
  1046. PROC game_loop:
  1047.     EXTERNAL G_app_state%,G_app_interact%,G_level_numKills%
  1048.     LOCAL level%
  1049.     REM 
  1050.  Loop through levels
  1051.         level%=level%+1
  1052.         REM 
  1053.  game loop always performs a level loop
  1054.         G_app_state%=K_app_stateInLevel%
  1055.         IF G_app_state%>K_app_stateInGame%
  1056.             REM 
  1057.  move on to level state
  1058.             level_initialise:(level%)
  1059.             level_loop:(level%)
  1060.             level_close:
  1061.             IF G_app_state%=K_app_stateInGame%
  1062.                 G_app_interact%=KTrue%
  1063.             ENDIF
  1064.         ENDIF
  1065.     UNTIL G_app_state%<K_app_stateInGame%
  1066. PROC game_close:
  1067.     sound_close:
  1068.     REM 
  1069.  check for high score only if leaving nicely
  1070.     base_close:
  1071. REM *********************
  1072. REM ****             ****
  1073. REM **** Level Stuff ****
  1074. REM ****             ****
  1075. REM *********************
  1076. PROC level_initialise:(level%)
  1077.     EXTERNAL G_level_numAsts%,G_level_numKills%,G_ast_damage%()
  1078.     EXTERNAL G_base_rot,G_base_shield%,G_base_size&
  1079.     EXTERNAL G_space_xDim&
  1080.     EXTERNAL G_app_state%,G_app_interact%
  1081.     EXTERNAL G_level_astDrawTimeLast&,G_level_astTrav%
  1082.     LOCAL num%,speed&,small%
  1083.     sound_midBeep:
  1084.     IF level%>1
  1085.         base_rotateBase:
  1086.     ENDIF
  1087.     base_growBase:
  1088.     base_moveBase:(1)
  1089.     G_base_shield%=0
  1090.     base_draw:
  1091.     REM 
  1092.  initialise asteroid properties
  1093.     G_level_numAsts%=_level_numAstsAt%:(level%)
  1094.     G_level_numKills%=10
  1095.     num%=1
  1096.         _level_astInitialise:(num%)
  1097.         num%=num%+1
  1098.     UNTIL num%>G_level_numAsts%
  1099.     REM 
  1100.  prepare the asteroid-drawing time structures
  1101.     G_level_astTrav%=1
  1102.     REM 
  1103.  if the state is where it should be, return to
  1104.     REM 
  1105.  interactive mode.
  1106.     IF G_app_state%=K_app_stateInLevel%
  1107.         G_app_interact%=Ktrue%
  1108.     ENDIF
  1109. PROC level_loop:(level%)
  1110.     EXTERNAL G_app_state%,G_app_interact%
  1111.     EXTERNAL G_app_key%(),G_level_numAsts%
  1112.     EXTERNAL G_ast_x&(),G_ast_y&(),G_ast_dx&(),G_ast_dy&()
  1113.     EXTERNAL G_ast_distToShield&(),G_ast_side%(),G_ast_distToBase&()
  1114.     EXTERNAL G_ast_score&(),G_ast_damage%()
  1115.     EXTERNAL G_base_x&,G_base_y&,G_base_shield%,G_game_energy%
  1116.     EXTERNAL G_game_score&
  1117.     EXTERNAL G_level_numKills%,G_space_xDim&
  1118.     LOCAL num%,base_ast_dist&,kills%
  1119.     LOCAL stat%,thisEvent&(16)
  1120.     REM 
  1121. * Time stamps for the loop *
  1122.     REM 
  1123.  Time at last loop end
  1124.     LOCAL timenow&
  1125.     REM 
  1126.  Time that the asteroids were last moved
  1127.     LOCAL astMoveTimeLast&
  1128.     REM 
  1129.  WARNING: One big procedure coming up! It really needs to
  1130.     REM 
  1131.  be broken up. Some day
  1132.     REM 
  1133.  It also should be noted that I didn't bother learning
  1134.     REM 
  1135.  exactly how event handling should be done.
  1136.     REM 
  1137.  initialise timestamps
  1138.     timenow&=DTNow&:
  1139.     astMoveTimeLast&=DTNow&:
  1140.     REM 
  1141.  make sure that any pending event gets dealt with
  1142.     GETEVENTA32 stat%,thisEvent&()
  1143.         REM 
  1144. * Draw asteroids *
  1145.         _level_astCheck:(timenow&)
  1146.         REM 
  1147. * Move asteroids *
  1148.         IF DTMicrosDiff&:(astMoveTimeLast&,timenow&)>K_level_astMoveTimeDelay&
  1149.             REM 
  1150.  it's time to move the asteroids
  1151.             num%=1
  1152.             DO
  1153.                 REM 
  1154. * move asteroids towards base *
  1155.                 G_ast_x&(num%)=G_ast_x&(num%)+G_ast_dx&(num%)
  1156.                 G_ast_y&(num%)=G_ast_y&(num%)+G_ast_dy&(num%)
  1157.                 REM 
  1158. * Detect collision with shield *
  1159.                 base_ast_dist&=(((G_ast_x&(num%)-G_base_x&)/K_factor&)**2+((G_ast_y&(num%)-G_base_y&)/K_factor&)**2)
  1160.                 IF base_ast_dist& < G_ast_distToBase&(num%)
  1161.                     REM 
  1162. * asteroid hits base *
  1163.                     REM 
  1164.  destroy asteroid
  1165.                     ast_explode:(num%)
  1166.                     sound_lowBeep:
  1167.                     ast_newStartPosition:(num%)
  1168.                     REM 
  1169.  increase kills
  1170.                     kills%=kills%+1
  1171.                     IF kills%<=G_level_numKills%-G_level_numAsts%
  1172.                         REM 
  1173.  if more asteroids are necessary, reset this one
  1174.                         ast_updateProperties:(num%,K_level_normAstSpeed*G_space_xDim&)
  1175.                     ELSEIF kills%=G_level_numKills%
  1176.                         REM 
  1177.  level finished,
  1178.                         REM 
  1179.  update score
  1180.                         G_game_score&=G_game_score&+K_game_levelBonus&
  1181.                         REM 
  1182.  and leave the level loop
  1183.                         G_app_state%=K_app_stateInGame%
  1184.                     ENDIF
  1185.                     REM 
  1186.  decrease energy force
  1187.                     G_game_energy%=G_game_energy%-G_ast_damage%(num%)
  1188.                     IF G_game_energy%<=0
  1189.                         REM 
  1190.  player out of energy, exit the game
  1191.                         G_app_state%=K_app_stateInApp%
  1192.                     ENDIF
  1193.                 ELSEIF base_ast_dist& < G_ast_distToShield&(num%)
  1194.                     REM 
  1195. * asteroid is close enough to hit a shield *
  1196.                     IF G_base_shield% AND ((G_ast_side%(num%) AND (2**(G_base_shield%-1)))>0)
  1197.                         REM 
  1198. * asteroid actually hits the current shield *
  1199.                         REM 
  1200.  destroy asteroid
  1201.                         ast_explode:(num%)
  1202.                         sound_highBeep:
  1203.                         ast_newStartPosition:(num%)
  1204.                         REM 
  1205.  increase kills
  1206.                         kills%=kills%+1
  1207.                         IF kills%<=G_level_numKills%-G_level_numAsts%
  1208.                             REM 
  1209.  if more asteroids are necessary, reset this one
  1210.                             ast_updateProperties:(num%,K_level_normAstSpeed*G_space_xDim&)
  1211.                         ELSEIF kills%=G_level_numKills%
  1212.                             REM 
  1213.  level finished
  1214.                             REM 
  1215.  update the score
  1216.                             G_game_score&=G_game_score&+K_game_levelBonus&
  1217.                             REM 
  1218.  and leave the level loop
  1219.                             G_app_state%=K_app_stateInGame%
  1220.                         ENDIF
  1221.                         REM 
  1222.  increase score
  1223.                         G_game_score&=G_game_score&+G_ast_score&(num%)
  1224.                     ENDIF
  1225.                 ENDIF
  1226.                 num%=num%+1
  1227.             UNTIL num%>G_level_numAsts%
  1228.             DTDeleteDateTime:(astMoveTimeLast&)
  1229.             astMoveTimeLast&=DTNow&:
  1230.         ENDIF
  1231.         REM 
  1232. * print scores and energy *
  1233.         panel_check:(timeNow&)
  1234.         REM 
  1235. * Terminate playing sounds *
  1236.         sound_check:(timeNow&)
  1237.         REM 
  1238. * EVENT
  1239. HANDLING *
  1240.         IOYIELD
  1241.         REM 
  1242.  No event => stat=-46
  1243.         IF stat%<>-46
  1244.             IF (thisEvent&(KEvAType%) AND KEvNotKeyMask&) = 0
  1245.                 REM 
  1246.  the event is a key press
  1247.                 IF thisEvent&(KEvAKMod%)=KKmodControl%
  1248.                     REM 
  1249.  CTRL is modifying the key: check for system commands
  1250.                     IF cmd_checkSysKey%:(thisEvent&(1)+%a-1)
  1251.                         panel_check:(timenow&)
  1252.                         DTDeleteDateTime:(astMoveTimeLast&)
  1253.                         astMoveTimeLast&=DTNow&:
  1254.                     ENDIF
  1255.                 ENDIF
  1256.             ELSEIF thisEvent&(KEvAType%)=KEvKeyDown& AND
  1257. thisEvent&(KEvAKMod%)=0
  1258.                 REM 
  1259.  a key down event has been detected.
  1260.                 IF thisEvent&(3)+32=G_app_key%(1)
  1261.                     REM 
  1262.  adding 32 makes upper->lower case
  1263.                     base_updateShield:(1)
  1264.                 ELSEIF thisEvent&(3)+32=G_app_key%(2)
  1265.                     base_updateShield:(2)
  1266.                 ELSEIF thisEvent&(3)+32=G_app_key%(3)
  1267.                     base_updateShield:(3)
  1268.                 ELSEIF thisEvent&(3)+32=G_app_key%(4)
  1269.                     base_updateShield:(4)
  1270.                 ENDIF        
  1271.             ELSEIF thisEvent&(KEvAType%)=KEvKeyUp& AND
  1272. thisEvent&(KEvAKMod%)=0
  1273.                 IF G_base_shield%>0
  1274.                     REM 
  1275.  if the shield is on
  1276.                     IF thisEvent&(3)+32=G_app_key%(G_base_shield%)
  1277.                         REM 
  1278. and the shield's key is lifted, switch it off
  1279.                         base_updateShield:(0)
  1280.                     ENDIF
  1281.                 ENDIF
  1282.                 IF thisEvent&(3)=148 OR thisEvent&(3)=KKeySidebarMenu32%
  1283.                     REM 
  1284.  either the keyboard or silkscreen menu button has
  1285.                     REM 
  1286.  been pressed.
  1287.                     menu_display:
  1288.                     REM 
  1289.  because processing the menu and subsequent
  1290.                     REM 
  1291.  operations may take some time, reset the timers.
  1292.                     panel_check:(timenow&)
  1293.                     DTDeleteDateTime:(astMoveTimeLast&)
  1294.                     astMoveTimeLast&=DTNow&:
  1295.                 ENDIF
  1296.             ELSEIF thisEvent&(KEvAType%)=KEvFocusLost&
  1297.                 REM 
  1298.  the application has moved to the background,
  1299.                 REM 
  1300.  so pause the game.
  1301.                 cmd_pause:    
  1302.             ELSEIF thisEvent&(KEvAType%)=KEvCommand&
  1303.                 REM 
  1304.  the application receives a message from system.
  1305.                 REM 
  1306.  I'm not sure how this could happen, considering
  1307.                 REM 
  1308.  that the application pauses when in the background.
  1309.                 REM 
  1310.  Better to deal with it anyway.
  1311.                 IF LEFT$(GETCMD$,1)=KGetCmdLetterExit$
  1312.                     REM 
  1313.  the message is an "exit" message.
  1314.                     cmd_exit:
  1315.                 ENDIF
  1316.             ENDIF
  1317.         IF G_app_state%>K_app_stateInLevel%
  1318.             pause_initialise:
  1319.             pause_loop:
  1320.             pause_close:
  1321.             IF G_app_state%=K_app_stateInLevel%
  1322.                 G_app_interact%=KTrue%
  1323.             ENDIF
  1324.         ENDIF
  1325.             REM 
  1326.  Request the next event
  1327.             GETEVENTA32 stat%,thisEvent&()
  1328.         ENDIF
  1329.         REM 
  1330.  reset time structure
  1331.         DTDeleteDateTime:(timenow&)
  1332.         timenow&=DTNow&:
  1333.     UNTIL G_app_state%<K_app_stateInLevel%
  1334.     REM 
  1335.  Cancel interest in window server event
  1336.     GETEVENTC (stat%)
  1337.     REM 
  1338.  free memory held by date/time structure
  1339.     DTDeleteDateTime:(timenow&)
  1340. PROC level_close:
  1341.     EXTERNAL G_level_numAsts%,G_level_astDrawTimeLast&()
  1342.     LOCAL num%
  1343.     num%=1
  1344.         ast_close:(num%)
  1345.         DTDeleteDateTime:(G_level_astDrawTimeLast&(num%))
  1346.         num%=num%+1
  1347.     UNTIL num%>G_level_numAsts%
  1348.     base_delete:
  1349.     REM 
  1350.  update the score now to avoid delay
  1351.     panel_update:
  1352. PROC _level_astInitialise:(num%)
  1353.     EXTERNAL G_level_astDrawTimeLast&(),G_level_astTrav%
  1354.     EXTERNAL G_level_numAsts%,G_space_xDim&
  1355.     LOCAL small%,speed&
  1356.     small%=RND*2
  1357.     IF small%=0
  1358.         speed&=K_level_normAstSpeed*G_space_xDim&*1.12
  1359.     ELSE
  1360.         speed&=K_level_normAstSpeed*G_space_xDim&*0.88
  1361.     ENDIF
  1362.     ast_initialise:(num%,small%)
  1363.     ast_newStartPosition:(num%)
  1364.     ast_updateProperties:(num%,speed&)
  1365.     REM 
  1366.  time interval until next time it is drawn
  1367.     G_level_astDrawTimeLast&(num%)=DTNow&:
  1368. PROC _level_astCheck:(timenow&)
  1369.     EXTERNAL G_level_astDrawTimeLast&(),G_level_astTrav%,G_level_numAsts%
  1370.     IF DTMicrosDiff&:(G_level_astDrawTimeLast&(G_level_astTrav%),timenow&)>K_level_astDrawTimeDelay&
  1371.         REM 
  1372.  G_level_astTrav% traverses the current asteroids
  1373.         ast_draw:(G_level_astTrav%)
  1374.         REM 
  1375.  update time structures
  1376.         DTDeleteDateTime:(G_level_astDrawTimeLast&(G_level_astTrav%))
  1377.         G_level_astDrawTimeLast&(G_level_astTrav%)=DTNow&:
  1378.         REM 
  1379.  increment trav% to process next asteroid
  1380.         G_level_astTrav%=G_level_astTrav%+1
  1381.         IF G_level_astTrav%>G_level_numAsts%
  1382.             G_level_astTrav%=1
  1383.         ENDIF
  1384.     ENDIF
  1385. PROC _level_numAstsAt%:(level%)
  1386.     REM 
  1387.  Returns the number of asteroids in this particular level.
  1388.     REM 
  1389.  the pattern is 2,3,3,4,4,4,5,5,5,5,6,6,6,6,6,7
  1390.     LOCAL number%
  1391.     REM 
  1392.  solution of the quadratic equation: "n
  1393. -3n+2(2-l)=0"
  1394.     number%=(3+SQR((8*level%)-7))/2
  1395.     REM 
  1396.  of course, we can only support a maximum number.
  1397.     IF number%>K_game_maxNumAsts%
  1398.         number%=K_game_maxNumAsts%
  1399.     ENDIF
  1400.     RETURN number%
  1401. REM *********************
  1402. REM ****             ****
  1403. REM **** Pause Stuff ****
  1404. REM ****             ****
  1405. REM *********************
  1406. PROC pause_initialise:
  1407.     EXTERNAL G_app_state%,G_app_interact%
  1408.     REM 
  1409.  If state ius where it should be, return to interactive
  1410.     REM 
  1411.  mode.
  1412.     IF G_app_state%=K_app_stateInPause%
  1413.         G_app_interact%=Ktrue%
  1414.     ENDIF
  1415. PROC pause_loop:
  1416.     EXTERNAL G_app_state%
  1417.     REM #### replace with event loop!
  1418.     LOCK ON
  1419.     dINIT "Paused
  1420.     dBUTTONS "Play",KKeyEnter%
  1421.     DIALOG
  1422.     LOCK OFF
  1423.     REM 
  1424.  leave pause
  1425.     G_app_state%=K_app_stateInLevel%
  1426. PROC pause_close:
  1427. REM *****************************
  1428. REM ****                     ****
  1429. REM **** BASE GRAPHICS STUFF ****
  1430. REM ****                     ****
  1431. REM *****************************
  1432. PROC base_initialise:
  1433.     EXTERNAL G_base_x&,G_base_y&
  1434.     EXTERNAL G_space_xDim&,G_space_yDim&
  1435.     EXTERNAL G_base_size&,G_base_rot
  1436.     G_base_x&=(G_space_xDim&/2)
  1437.     G_base_y&=(G_space_yDim&/2)
  1438.     G_base_size&=K_base_initBaseSize*G_space_xDim&
  1439.     G_base_rot=K_level_normBaseRot
  1440. PROC base_draw:
  1441.     _base_drawBase:(Ktrue%)
  1442. PROC base_delete:
  1443.     _base_drawBase:(Kfalse%)
  1444. PROC base_updateShield:(shield%)
  1445.     EXTERNAL G_base_shield%
  1446.     REM 
  1447.  only do if the shield has changed
  1448.     IF shield%<>G_base_shield%
  1449.         _base_drawShield:(Kfalse%)
  1450.         G_base_shield%=shield%
  1451.         IF shield%>0
  1452.             _base_drawShield:(Ktrue%)
  1453.         ENDIF
  1454.     ENDIF
  1455. PROC base_rotateBase:
  1456.     EXTERNAL G_base_rot
  1457.     G_base_rot= 6.283*RND
  1458. PROC base_growBase:
  1459.     EXTERNAL G_base_size&,G_space_xDim&
  1460.     G_base_size&=1.075*G_base_size&
  1461.     IF G_base_size&>K_base_maxBaseSize*G_space_xDim&
  1462.         G_base_size&=K_base_maxBaseSize*G_space_xDim&
  1463.     ENDIF
  1464. PROC base_moveBase:(dispFactor)
  1465.     EXTERNAL G_space_xDim&,G_space_yDim&
  1466.     EXTERNAL G_base_x&,G_base_y&,G_base_size&
  1467.     LOCAL curDispRange&
  1468.     curDispRange&=(G_space_xDim&-(K_base_maxBaseSize*G_space_xDim&*2.5))*dispFactor
  1469.     G_base_x&=(G_space_xDim&/2)+(curDispRange&*(RND-0.5))
  1470.     G_base_y&=(G_space_yDim&/2)+(curDispRange&*(RND-0.5))
  1471. PROC base_close:
  1472.     _base_drawBase:(Kfalse%)
  1473. PROC _base_drawBase:(see%)
  1474.     EXTERNAL G_space_window%,G_base_shield%
  1475.     EXTERNAL G_base_x&,G_base_y&
  1476.     EXTERNAL G_base_size&,G_base_rot
  1477.     LOCAL size&,shield%
  1478.     gUSE G_space_window%
  1479.     REM 
  1480.  draw/delete inner and outer squares    
  1481.     IF see%
  1482.         _base_setGrey:(1)
  1483.     ELSE
  1484.         _base_setGrey:(3)
  1485.     ENDIF
  1486.     _base_drawSquare:(K_factor&,G_base_x&,G_base_y&,G_base_size&*K_base_borderFactor,G_base_rot)
  1487.     IF see%
  1488.         _base_setGrey:(0)
  1489.     ELSE
  1490.         _base_setGrey:(3)
  1491.     ENDIF
  1492.     _base_drawSquare:(K_factor&,G_base_x&,G_base_y&,G_base_size&,G_base_rot)
  1493.     REM 
  1494.  draw shield
  1495.     IF G_base_shield%<>0
  1496.         _base_drawShield:(see%)
  1497.     ENDIF
  1498.     REM 
  1499.  draw labels
  1500.     _base_drawLabels:(see%)
  1501. PROC _base_drawShield:(see%)
  1502.     EXTERNAL G_space_window%,G_base_shield%
  1503.     EXTERNAL G_base_x&,G_base_y&
  1504.     EXTERNAL G_base_size&,G_base_rot,G_space_xDim&
  1505.     LOCAL size&
  1506.     gUSE G_space_window%
  1507.     IF see%
  1508.         _base_setGrey:(0)
  1509.     ELSE
  1510.         _base_setGrey:(3)
  1511.     ENDIF
  1512.     REM 
  1513.  to force this value to be a long and not a floating point
  1514.     size&=G_base_size&+(K_base_shieldFactor*G_space_xDim&)
  1515.     _base_drawEdge:(K_factor&,G_base_x&,G_base_y&,size&,G_base_rot,G_base_shield%)
  1516. PROC _base_drawLabels:(see%)
  1517.     EXTERNAL G_base_size&,G_base_rot,G_base_x&,G_base_y&,G_app_key%()
  1518.     LOCAL l1&,l2&,x&(4),y&(4)
  1519.     REM 
  1520.  find coordinates
  1521.     l1&=((G_base_size&*K_base_borderFactor)*COS(G_base_rot)*66)/100
  1522.     l2&=((G_base_size&*K_base_borderFactor)*SIN(G_base_rot)*66)/100
  1523.     x&(1)=G_base_x&+(l2&-l1&)/2+K_base_labelXOffset&
  1524.     y&(1)=G_base_y&-(l2&+l1&)/2+K_base_labelYOffset&
  1525.     x&(2)=G_base_x&+(l1&+l2&)/2+K_base_labelXOffset&
  1526.     y&(2)=G_base_y&+(l2&-l1&)/2+K_base_labelYOffset&
  1527.     x&(3)=G_base_x&+(l1&-l2&)/2+K_base_labelXOffset&
  1528.     y&(3)=G_base_y&+(l1&+l2&)/2+K_base_labelYOffset&
  1529.     x&(4)=G_base_x&-(l1&+l2&)/2+K_base_labelXOffset&
  1530.     y&(4)=G_base_y&+(l1&-l2&)/2+K_base_labelYOffset&        
  1531.     REM 
  1532.  draw labels
  1533.     IF see%
  1534.         _base_setGrey:(0)
  1535.     ELSE
  1536.         _base_setGrey:(3)
  1537.     ENDIF
  1538.     gFONT KFontArialNormal15&
  1539.     gAT x&(1)/K_factor&,y&(1)/K_factor&
  1540.     gPRINT CHR$(G_app_key%(1))
  1541.     gAT x&(2)/K_factor&,y&(2)/K_factor&
  1542.     gPRINT CHR$(G_app_key%(2))
  1543.     gAT x&(3)/K_factor&,y&(3)/K_factor&
  1544.     gPRINT CHR$(G_app_key%(3))
  1545.     gAT x&(4)/K_factor&,y&(4)/K_factor&
  1546.     gPRINT CHR$(G_app_key%(4))
  1547. PROC _base_drawSquare:(factor&,x&,y&,size&,rot)
  1548.     REM 
  1549.  This is inefficient since each corner is calculated twice.
  1550.     REM 
  1551.  As it's only done once at level start, I don't care.
  1552.     _base_drawEdge:(factor&,x&,y&,size&,rot,1)
  1553.     _base_drawEdge:(factor&,x&,y&,size&,rot,2)
  1554.     _base_drawEdge:(factor&,x&,y&,size&,rot,3)
  1555.     _base_drawEdge:(factor&,x&,y&,size&,rot,4)
  1556. PROC _base_drawEdge:(factor&,x&,y&,size&,rot,edge%)
  1557.     REM 
  1558. * Draw a specific edge of a square with given position,*
  1559.     REM 
  1560. * size, rotation and grey. Lengths are w.r.t. to a     *
  1561.     REM 
  1562. * given factor.                                        *
  1563.     LOCAL l1&,l2&,x&(2),y&(2)
  1564.     REM 
  1565.  offsets
  1566.     l1&=size&*COS(rot)
  1567.     l2&=size&*SIN(rot)
  1568.     REM 
  1569.  which edge?
  1570.     IF edge%=1
  1571.         x&(1)=x&-l1&
  1572.         y&(1)=y&-l2&
  1573.         x&(2)=x&+l2&
  1574.         y&(2)=y&-l1&
  1575.     ELSEIF edge%=2
  1576.         x&(1)=x&+l2&
  1577.         y&(1)=y&-l1&
  1578.         x&(2)=x&+l1&
  1579.         y&(2)=y&+l2&
  1580.     ELSEIF edge%=3
  1581.         x&(1)=x&+l1&
  1582.         y&(1)=y&+l2&
  1583.         x&(2)=x&-l2&
  1584.         y&(2)=y&+l1&
  1585.     ELSE
  1586.         x&(1)=x&-l2&
  1587.         y&(1)=y&+l1&
  1588.         x&(2)=x&-l1&
  1589.         y&(2)=y&-l2&
  1590.     ENDIF
  1591.     REM 
  1592.  draw line
  1593.     gAT x&(1)/factor&,y&(1)/factor&
  1594.     gLINETO x&(2)/factor&,y&(2)/factor&
  1595. PROC _base_setGrey:(grey%)
  1596.     IF grey%=3
  1597.         gCOLOR 255,255,255
  1598.     ELSEIF grey%=2
  1599.         gCOLOR 170,170,170
  1600.     ELSEIF grey%=1
  1601.         gCOLOR 85,85,85
  1602.     ELSE
  1603.         gCOLOR 0,0,0
  1604.     ENDIF
  1605. REM **********************
  1606. REM ****              ****
  1607. REM **** Screen Stuff ****
  1608. REM ****              ****
  1609. REM **********************
  1610. PROC screen_initialise:
  1611.     EXTERNAL G_screen_xDim%,G_screen_yDim%,G_bm_screenBG%
  1612.     REM 
  1613.  return values from _screen_arrange:()
  1614.     GLOBAL R_space_xDim%,R_space_yDim%
  1615.     GLOBAL R_space_xPos%,R_space_yPos%
  1616.     GLOBAL R_title_xDim%,R_title_yDim%
  1617.     GLOBAL R_title_xPos%,R_title_yPos%
  1618.     GLOBAL R_panel_xDim%,R_panel_yDim%
  1619.     GLOBAL R_panel_xPos%,R_panel_yPos%
  1620.     gUSE KDefaultWin%
  1621.     REM 
  1622.  if we are testing, we should already have screen details
  1623.     REM 
  1624.  assigned.
  1625.     IF NOT T_test%
  1626.         REM 
  1627.  to find the screen size, find the height and width of
  1628.         REM 
  1629.  the default window.
  1630.         G_screen_xDim%=gWIDTH
  1631.         G_screen_yDim%=gHEIGHT
  1632.     ENDIF
  1633.     gPATT G_bm_screenBG%,G_screen_xDim%,G_screen_yDim%,0
  1634.     gXBORDER 2,$01
  1635.     _screen_arrange:(G_screen_xDim%,G_screen_yDim%)
  1636.     space_initialise:(R_space_xPos%,R_space_yPos%,R_space_xDim%,R_space_yDim%)
  1637.     title_initialise:(R_title_xPos%,R_title_yPos%,R_title_xDim%,R_title_yDim%)
  1638.     panel_initialise:(R_panel_xPos%,R_panel_yPos%,R_panel_xDim%,R_panel_yDim%)
  1639. PROC screen_close:
  1640.     panel_close:
  1641.     title_close:
  1642.     space_close:
  1643. PROC _screen_arrange:(screen_xDim%,screen_yDim%)
  1644.     EXTERNAL R_space_xDim%,R_space_yDim%
  1645.     EXTERNAL R_space_xPos%,R_space_yPos%
  1646.     EXTERNAL R_title_xDim%,R_title_yDim%
  1647.     EXTERNAL R_title_xPos%,R_title_yPos%
  1648.     EXTERNAL R_panel_xDim%,R_panel_yDim%
  1649.     EXTERNAL R_panel_xPos%,R_panel_yPos%
  1650.     LOCAL xPad%,yPad%,xRoom%,yRoom%,spaceSize%
  1651.     R_panel_xDim%=K_panel_xDim%
  1652.     R_title_xDim%=K_title_xDim%
  1653.     xRoom%=screen_xDim%-(R_title_xDim%+R_panel_xDim%)
  1654.     yRoom%=screen_yDim%
  1655.     IF xRoom%>K_space_minSize%
  1656.         REM 
  1657.  the screen has room for side-by-side windows
  1658. xRoom%<yRoom%
  1659.             REM 
  1660.  there is less horizontal room for the space window
  1661.             REM 
  1662.  leave 40% of the space as a border
  1663.             spaceSize%=xRoom%-((xRoom%-K_space_minSize%)*0.40)
  1664.         ELSE
  1665.             REM 
  1666.  there is less vertical room for the space window
  1667.             REM 
  1668.  leave 40% of the space as a border
  1669.             spaceSize%=yRoom%-((yRoom%-K_space_minSize%)*0.40)
  1670.         ENDIF
  1671.         REM 
  1672.  make sure the space window doesn't exceed the maximum
  1673.         REM #### rename constants
  1674.         IF spaceSize%>K_space_maxSize%
  1675.             spaceSize%=K_space_maxSize%
  1676.         ENDIF
  1677.         R_space_xDim%=spaceSize%
  1678.         R_space_yDim%=spaceSize%
  1679.         R_panel_yDim%=K_panel_yDimBig%
  1680.         R_title_yDim%=K_title_yDimBig%
  1681.         xPad%=(screen_xDim%-R_panel_xDim%-spaceSize%-R_title_xDim%)/4
  1682.         R_panel_xPos%=xPad%
  1683.         R_panel_yPos%=(screen_yDim%-R_panel_yDim%)/2
  1684.         R_space_xPos%=xPad%+R_panel_xDim%+xPad%
  1685.         R_space_yPos%=(screen_yDim%-R_space_yDim%)/2
  1686.         R_title_xPos%=xPad%+K_panel_xDim%+xPad%+R_space_xDim%+xPad%
  1687.         R_title_yPos%=(screen_yDim%-R_title_yDim%)/2
  1688.     ELSEIF yRoom%>=K_space_minSize%
  1689.         REM 
  1690.  currently only the Osaris
  1691.         REM 
  1692.  assume panel and title windows have same width
  1693.         xRoom%=screen_xDim%-R_title_xDim%
  1694. xRoom%<yRoom%
  1695.             REM 
  1696.  the is less horizontal room for the space window
  1697.             REM 
  1698.  leave 40% of the space as a border
  1699.             spaceSize%=xRoom%-((xRoom%-K_space_minSize%)*0.40)
  1700.         ELSE
  1701.             REM 
  1702.  the is less vertical room for the space window
  1703.             REM 
  1704.  leave 40% of the space as a border
  1705.             spaceSize%=yRoom%-((yRoom%-K_space_minSize%)*0.40)
  1706.         ENDIF
  1707.         REM 
  1708.  make sure the space window doesn't exceed the maximum
  1709.         IF spaceSize%>K_space_maxSize%
  1710.             spaceSize%=K_space_maxSize%
  1711.         ENDIF
  1712.         R_space_xDim%=spaceSize%
  1713.         R_space_yDim%=spaceSize%
  1714.         R_panel_yDim%=screen_yDim%/2-(((screen_yDim%/2)-K_panel_yDimSmall%)*0.40)
  1715.         R_title_yDim%=R_panel_yDim%
  1716.         xPad%=(screen_xDim%-R_title_xDim%-spaceSize%)/3
  1717.         yPad%=(screen_yDim%-R_panel_yDim%-R_title_yDim%)/3
  1718.         R_space_xPos%=xPad%+K_title_xDim%+xPad%
  1719.         R_space_yPos%=(screen_yDim%-R_space_yDim%)/2
  1720.         R_title_xPos%=xPad%
  1721.         R_title_yPos%=yPad%
  1722.         R_panel_xPos%=xPad%
  1723.         R_panel_yPos%=yPad%+R_title_yDim%+yPad%
  1724.     ELSE
  1725.         REM 
  1726.  The screen isn't wide enough
  1727.         _screen_sizeNotSupported:
  1728.     ENDIF
  1729. PROC _screen_sizeNotSupported:
  1730.     EXTERNAL G_app_state%
  1731.     REM #### this needs to be handled properly
  1732.     LOCK ON
  1733.     dINIT "Sorry!"
  1734.     dTEXT "","Your machine's screen size",2
  1735.     dTEXT "","is not supported (yet).",2
  1736.     dBUTTONS "Okay",KKeyEnter%
  1737.     DIALOG
  1738.     LOCK OFF
  1739.     G_app_state%=K_app_stateLeaveApp%
  1740. REM ****************************
  1741. REM ****                    ****
  1742. REM **** Space Window Stuff ****
  1743. REM ****                    ****
  1744. REM ****************************
  1745. PROC space_initialise:(xPos%,yPos%,xDim%,yDim%)
  1746.     _space_build:(xPos%,yPos%,xDim%,yDim%)
  1747. PROC space_close:
  1748.     EXTERNAL G_space_window%
  1749.     gCLOSE G_space_window%
  1750. PROC _space_build:(xPos%,yPos%,xDim%,yDim%)
  1751.     EXTERNAL G_space_window%
  1752.     EXTERNAL G_space_xDim&,G_space_yDim&
  1753.     G_space_window% = gCREATE(xPos%,yPos%,xDim%,yDim%,1,1)
  1754.     gXBORDER 2,$01
  1755.     G_space_xDim&=xDim%*K_factor&
  1756.     G_space_yDim&=yDim%*K_factor&
  1757. REM ****************************
  1758. REM ****                    ****
  1759. REM **** Title Window Stuff ****
  1760. REM ****                    ****
  1761. REM ****************************
  1762. PROC title_initialise:(xPos%,yPos%,xDim%,yDim%)
  1763.     _title_build:(xPos%,yPos%,xDim%,yDim%)
  1764. PROC title_close:
  1765.     EXTERNAL G_title_window%
  1766.     gCLOSE G_title_window%
  1767. PROC _title_build:(xPos%,yPos%,xDim%,yDim%)
  1768.     EXTERNAL G_title_window%
  1769.     EXTERNAL G_bm_titleMr%,G_bm_titleMeteoroid%,G_bm_titleGame%
  1770.     LOCAL xMrSize%,yMrSize%,xMeteoroidSize%,yMeteoroidSize%
  1771.     LOCAL xGameSize%,yGameSize%,yPad%
  1772.     REM 
  1773.  Because the title bitmaps are drawables, we can use gWIDTH
  1774.     REM 
  1775.  and gHEIGHT to get their dimentions
  1776.     gUSE G_bm_titleMr%
  1777.     xMrSize%=gWIDTH
  1778.     yMrSize%=gHEIGHT
  1779.     gUSE G_bm_titleMeteoroid%
  1780.     xMeteoroidSize%=gWIDTH
  1781.     yMeteoroidSize%=gHEIGHT
  1782.     gUSE G_bm_titleGame%
  1783.     xGameSize%=gWIDTH
  1784.     yGameSize%=gHEIGHT
  1785.     yPad%=(yDim%-yMrSize%-yMeteoroidSize%-yGameSize%)/4
  1786.     G_title_window%=gCREATE(xPos%,yPos%,xDim%,yDim%,1,1)
  1787.     gXBORDER 2,$01
  1788.     gAT (xDim%-xMrSize%)/2,yPad%
  1789.     gCOPY G_bm_titleMr%,0,0,xMrSize%,yMrSize%,3
  1790.     gAT (xDim%-xMeteoroidSize%)/2,yPad%+yMrSize%+yPad%
  1791.     gCOPY G_bm_titleMeteoroid%,0,0,xMeteoroidSize%,yMeteoroidSize%,3
  1792.     gAT (xDim%-xGameSize%)/2,yPad%+yMrSize%+yPad%+yMeteoroidSize%+yPad%
  1793.     gCOPY G_bm_titleGame%,0,0,xGameSize%,yGameSize%,3    
  1794. REM ************************
  1795. REM ****                ****
  1796. REM **** Panel graphics ****
  1797. REM ****                ****
  1798. REM ************************
  1799. PROC panel_initialise:(xPos%,yPos%,xDim%,yDim%)
  1800.     EXTERNAL G_panel_timeLast&,G_panel_score&,G_panel_energy%
  1801.     REM 
  1802.  load the pc_bar OPM
  1803.     REM #### commented out until symbian release final versions
  1804.     REM OPM_LoadModule:("pc_bar")
  1805.     LOADM("Pc_bar.opm")
  1806.     _panel_build:(xPos%,yPos%,xDim%,yDim%)
  1807.     G_panel_score&=0
  1808.     G_panel_energy%=K_game_initEnergy%
  1809.     _panel_printScore:
  1810.     _panel_printEnergy:
  1811.     REM 
  1812.  initialise the date time structure
  1813.     G_panel_timeLast&=DTNow&:
  1814. PROC panel_check:(timenow&)
  1815.     EXTERNAL G_panel_timeLast&
  1816.     REM 
  1817.  if a sufficient time interval has passed
  1818.     IF DTMicrosDiff&:(G_panel_timeLast&,timenow&)>K_panel_timeDelay&
  1819.         panel_update:
  1820.     ENDIF
  1821. PROC panel_update:
  1822.     EXTERNAL G_game_score&,G_panel_score&
  1823.     EXTERNAL G_game_energy%,G_panel_energy%
  1824.     EXTERNAL G_panel_timeLast&
  1825.     REM 
  1826.  If the score has changed
  1827.     IF G_game_score&<>G_panel_score&
  1828.         G_panel_score&=G_game_score&
  1829.         _panel_printScore:
  1830.     ENDIF
  1831.     REM 
  1832.  if the energy has changed
  1833.     IF G_game_energy%<>G_panel_energy%
  1834.         IF G_game_energy%>=0
  1835.             G_panel_energy%=G_game_energy%
  1836.         ELSE
  1837.             G_panel_energy%=0
  1838.         ENDIF
  1839.         _panel_printEnergy:
  1840.     ENDIF
  1841.     REM 
  1842.  reset the timer
  1843.     DTDeleteDateTime:(G_panel_timeLast&)
  1844.     G_panel_timeLast&=DTNow&:
  1845. PROC panel_close:
  1846.     EXTERNAL G_panel_energyBar&,G_panel_window%
  1847.     EXTERNAL G_panel_timeLast&
  1848.     pc_destroy_freebar:(G_panel_energyBar&)
  1849.     REM 
  1850.  unload the PC_bar OPM
  1851.     OPM_UnLoadModule:("pc_bar")
  1852.     REM 
  1853.  remove the window
  1854.     gCLOSE G_panel_window%
  1855.     REM 
  1856.  delete the time structure
  1857.     DTDeleteDateTime:(G_panel_timeLast&)
  1858. PROC _panel_build:(xPos%,yPos%,xDim%,yDim%)
  1859.     EXTERNAL G_panel_window%,G_panel_energyBar&
  1860.     EXTERNAL G_bm_panelScore%,G_bm_panelEnergy%
  1861.     EXTERNAL G_panel_scoreYPos%, G_panel_scoreWidth%
  1862.     LOCAL xScoreSize%,yScoreSize%,xEnergySize%,yEnergySize%
  1863.     LOCAL yPad%
  1864.     REM 
  1865.  Because the energy and score bitmaps are drawables, we
  1866.     REM 
  1867.  can use gWIDTH and gHEIGHT to get their dimentions.
  1868.     gUSE G_bm_panelScore%
  1869.     xScoreSize%=gWIDTH
  1870.     yScoreSize%=gHEIGHT
  1871.     gUSE G_bm_panelEnergy%
  1872.     xEnergySize%=gWIDTH
  1873.     yEnergySize%=gHEIGHT
  1874.     G_panel_window%=gCREATE(xPos%,yPos%,xDim%,yDim%,1,1)
  1875.     gXBORDER 2,$01
  1876.     yPad%=(yDim%-yScoreSize%-K_panel_scoreFontHeight%-yEnergySize%-yScoreSize%)/5
  1877.     gAT (xDim%-xScoreSize%)/2,yPad%
  1878.     gCOPY G_bm_panelScore%,0,0,xScoreSize%,yScoreSize%,3
  1879.     G_panel_scoreYPos%=yPad%+yScoreSize%+yPad%+K_panel_scoreFontHeight%-1
  1880.     G_panel_scoreWidth%=xDim%-20
  1881.     gAT (xDim%-xEnergySize%)/2,yPad%+yScoreSize%+yPad%+K_panel_scoreFontHeight%+yPad%
  1882.     gCOPY G_bm_panelEnergy%,0,0,xEnergySize%,yEnergySize%,3
  1883.     G_panel_energyBar&=pc_freebar&:(G_panel_window%,10,yDim%-yPad%,G_panel_scoreWidth%,yScoreSize%,KPcBarHorizontal%,KPcBarTextNone%,KPcBarColourBlack&,KPcBarColourWhite&,K_game_initEnergy%)
  1884. PROC _panel_printScore:
  1885.     EXTERNAL G_panel_score&,G_panel_window%
  1886.     EXTERNAL G_panel_scoreYPos%,G_panel_scoreWidth%
  1887.     gUSE G_panel_window%
  1888.     gCOLOR 0,0,0
  1889.     gFONT K_panel_scoreFont&
  1890.     gAT 10,G_panel_scoreYPos%
  1891.     gPRINTB misc_padWithZeroes$:(K_hs_numDigits%,G_panel_score&),G_panel_scoreWidth%,3,2
  1892. PROC _panel_printEnergy:
  1893.     EXTERNAL G_panel_energyBar&,G_panel_energy%
  1894.     pc_bar_update%:(G_panel_energyBar&,G_panel_energy%)
  1895. REM *********************************
  1896. REM ****                         ****
  1897. REM **** Asteroid Graphics Stuff ****
  1898. REM ****                         ****
  1899. REM *********************************
  1900. PROC ast_initialise:(num%,size%)
  1901.     EXTERNAL G_ast_sprite&(),G_ast_r&(),G_ast_dx&(),G_ast_dy&()
  1902.     EXTERNAL G_ast_score&(),G_ast_damage%()
  1903.     EXTERNAL G_bm_smallAstXDim%,G_bm_bigAstXDim%
  1904.     IF size%=0
  1905.         G_ast_sprite&(num%)=_ast_createSmallAst&:
  1906.         G_ast_r&(num%)=(G_bm_smallAstXDim%/2)*K_factor&
  1907.         G_ast_score&(num%)=K_ast_SmallScore&
  1908.         G_ast_damage%(num%)=K_ast_smallDamage%
  1909.         G_ast_dx&(num%)=0
  1910.         G_ast_dy&(num%)=0
  1911.     ELSEIF size%=1
  1912.         G_ast_sprite&(num%)=_ast_createBigAst&:
  1913.         G_ast_r&(num%)=(G_bm_bigAstXDim%/2)*K_factor&
  1914.         G_ast_score&(num%)=K_ast_bigScore&
  1915.         G_ast_damage%(num%)=K_ast_bigDamage%
  1916.         G_ast_dx&(num%)=0
  1917.         G_ast_dy&(num%)=0
  1918.     ENDIF
  1919. PROC ast_draw:(num%)
  1920.     EXTERNAL G_ast_sprite&(),G_ast_x&(),G_ast_y&(),G_ast_r&()
  1921.     SPRITEUSE:(G_ast_sprite&(num%))
  1922.     SPRITEPOS:((G_ast_x&(num%)-G_ast_r&(num%))/K_factor&,(G_ast_y&(num%)-G_ast_r&(num%))/K_factor&)
  1923. PROC ast_explode:(num%)
  1924.     EXTERNAL G_ast_dx&(),G_ast_dy&()
  1925.   REM 
  1926.  Unfortunately no visual explosion effects!
  1927.   REM 
  1928.  Just draw it in its final position
  1929.     ast_draw:(num%)
  1930.     REM 
  1931.  and stop it from moving
  1932.     G_ast_dx&(num%)=0
  1933.     G_ast_dy&(num%)=0
  1934. PROC ast_newStartPosition:(num%)
  1935.     EXTERNAL G_ast_x&(),G_ast_y&(),G_ast_r&()
  1936.     EXTERNAL G_space_xDim&,G_space_yDim&
  1937.     LOCAL random
  1938.     random=RND
  1939.     IF random < 0.25
  1940.         G_ast_x&(num%)=(RND*(G_space_xDim&+(G_ast_r&(num%)*2)))-G_ast_r&(num%)
  1941.         G_ast_y&(num%)=-G_ast_r&(num%)-500
  1942.     ELSEIF random < 0.5
  1943.         G_ast_x&(num%)=-G_ast_r&(num%)-500
  1944.         G_ast_y&(num%)=(RND*(G_space_yDim&+(G_ast_r&(num%)*2)))-G_ast_r&(num%)
  1945.     ELSEIF random < 0.75
  1946.         G_ast_x&(num%)=(RND*(G_space_xDim&+(G_ast_r&(num%)*2)))-G_ast_r&(num%)
  1947.         G_ast_y&(num%)=G_space_yDim&+G_ast_r&(num%)+500
  1948.     ELSE
  1949.         G_ast_x&(num%)=G_space_xDim&+G_ast_r&(num%)+500
  1950.         G_ast_y&(num%)=(RND*(G_space_yDim&+(G_ast_r&(num%)*2)))-G_ast_r&(num%)
  1951.     ENDIF
  1952. PROC ast_updateProperties:(num%,speed&)
  1953.     EXTERNAL G_base_x&,G_base_y&,G_base_rot,G_base_size&
  1954.     EXTERNAL G_ast_x&(),G_ast_y&(),G_ast_r&(),G_ast_dx&(),G_ast_dy&()
  1955.     EXTERNAL G_ast_side%(),G_ast_distToBase&()
  1956.     EXTERNAL G_ast_distToShield&(),G_space_xDim&
  1957.     LOCAL beta&,theta&,q1%,alpha,alpha&,qa%,side%,phi&,l&,h1&,h2&,rho1&,rho2&
  1958.     REM 
  1959.  WARNING: This is all based on paper calculations I've lost.
  1960.     REM 
  1961.  Look inside at your peril!
  1962.     REM 
  1963.  These calculations have to be performed in the middle of
  1964.     REM 
  1965.  a level. Therefore they have to be reasonably quick.
  1966.     REM 
  1967.  Notice that I use longs rather than floats for angles,
  1968.     REM 
  1969.  this is for speed.
  1970.     REM 
  1971. * STEP 1 *
  1972.     REM 
  1973.  find theta and q1
  1974.     theta&=G_base_rot*100000000
  1975.     q1%=1
  1976.     WHILE theta&>157079633
  1977.         theta&=theta&-157079633
  1978.         q1%=q1%+1
  1979.     ENDWH
  1980.     REM 
  1981. * STEP 2 *
  1982.     REM 
  1983.  find dx, dy, alpha and qa
  1984.     IF G_ast_x&(num%)>G_base_x&
  1985.         IF G_ast_y&(num%)>G_base_y&
  1986.             REM 
  1987.  quadrant 3
  1988.             qa%=3
  1989.             alpha=ATAN((G_ast_y&(num%)-G_base_y&)/(1.0*G_ast_x&(num%)-G_base_x&))
  1990.             REM 
  1991.  set deltas
  1992.             G_ast_dx&(num%)=-(speed&*COS(alpha))
  1993.             G_ast_dy&(num%)=-(speed&*SIN(alpha))
  1994.         ELSE
  1995.             REM 
  1996.  quadrant 2
  1997.             qa%=2
  1998.             alpha=ATAN((G_ast_x&(num%)-G_base_x&)/(1.0*G_base_y&-G_ast_y&(num%)))
  1999.             REM 
  2000.  set deltas
  2001.             G_ast_dx&(num%)=-(speed&*SIN(alpha))
  2002.             G_ast_dy&(num%)=(speed&*COS(alpha))
  2003.         ENDIF
  2004.     ELSE
  2005.         IF G_ast_y&(num%)>G_base_y&
  2006.             REM 
  2007.  quadrant 4
  2008.             qa%=4
  2009.             alpha=ATAN((G_base_x&-G_ast_x&(num%))/(1.0*G_ast_y&(num%)-G_base_y&))
  2010.             REM 
  2011.  set deltas
  2012.             G_ast_dx&(num%)=(speed&*SIN(alpha))
  2013.             G_ast_dy&(num%)=-(speed&*COS(alpha))
  2014.         ELSE
  2015.             REM 
  2016.  quadrant 1
  2017.             qa%=1
  2018.             alpha=ATAN((G_base_y&-G_ast_y&(num%))/(1.0*G_base_x&-G_ast_x&(num%)))
  2019.             REM 
  2020.  set deltas
  2021.             G_ast_dx&(num%)=(speed&*COS(alpha))
  2022.             G_ast_dy&(num%)=(speed&*SIN(alpha))
  2023.         ENDIF        
  2024.     ENDIF
  2025.     alpha&=alpha*100000000
  2026.     REM 
  2027. * STEP 3 *
  2028.     REM 
  2029.  calculate phi
  2030.     REM 78539816
  2031.     REM 157079633
  2032.     REM 314159265
  2033.     REM 
  2034.  this tolerence comes from play-testing
  2035.     IF ABS(theta&-alpha&)<17000000
  2036.         REM 
  2037. * Asteroid will hit a CORNER *
  2038.         REM 
  2039.  actually an approximation
  2040.         REM 
  2041.  find side*s*
  2042.         side%=qa%-q1%-1
  2043.         REM 
  2044.  the side anticlockwise from the asteroid
  2045.         IF side%<0
  2046.             side%=4+side%
  2047.         ENDIF
  2048.         G_ast_side%(num%)=2**side%
  2049.         REM 
  2050.  the side clockwise from the asteroid
  2051.         side%=side%+1
  2052.         IF side%=4
  2053.             side%=0
  2054.         ENDIF
  2055.         G_ast_side%(num%)=G_ast_side%(num%)+2**side%
  2056.         REM 
  2057.  distances
  2058.         REM 
  2059.  these are values only apply if alpha=theta
  2060.         REM 
  2061.  but use them as approximations anyway. Subtract 5 to
  2062.         REM 
  2063.  reduce the obviousness.
  2064.         G_ast_distToBase&(num%)=((G_base_size&+G_ast_r&(num%))/K_factor&)-5
  2065.         G_ast_distToShield&(num%)=((G_base_size&+K_base_shieldFactor*G_space_xDim&+G_ast_r&(num%))/K_factor&)-5
  2066.         G_ast_distToBase&(num%)=G_ast_distToBase&(num%)**2
  2067.         G_ast_distToShield&(num%)=G_ast_distToShield&(num%)**2
  2068.     ELSE
  2069.         REM 
  2070. * Asteroid will hit a SIDE *
  2071.         REM 
  2072.  find side
  2073.         side%=qa%-q1%
  2074.         IF alpha&<theta&
  2075.             side%=side%-1
  2076.         ENDIF
  2077.         IF side%<0
  2078.             side%=4+side%
  2079.         ENDIF
  2080.         G_ast_side%(num%)=2**side%
  2081.         REM 
  2082.  find distances by finding phi
  2083.         rho1&=theta&-78539816
  2084.         rho2&=theta&+78539816
  2085.         IF alpha&>rho2&
  2086.             phi&=157079633+rho2&-alpha&
  2087.         ELSEIF alpha&>theta&
  2088.             phi&=alpha&-rho1&
  2089.         ELSEIF alpha&>rho1&
  2090.             phi&=rho2&-alpha&
  2091.         ELSE
  2092.             phi&=314159265+alpha&-rho2&
  2093.         ENDIF
  2094.         l&=G_base_size&*0.7072
  2095.         h1&=(l&+G_ast_r&(num%))/K_factor&
  2096.         h2&=(l&+K_base_shieldFactor*G_space_xDim&+G_ast_r&(num%))/K_factor&
  2097.         G_ast_distToBase&(num%)=h1&/(SIN(phi&/100000000.0))
  2098.         G_ast_distToShield&(num%)=h2&/(SIN(phi&/100000000.0))
  2099.         G_ast_distToBase&(num%)=G_ast_distToBase&(num%)**2
  2100.         G_ast_distToShield&(num%)=G_ast_distToShield&(num%)**2
  2101.     ENDIF
  2102. PROC ast_close:(num%)
  2103.     EXTERNAL G_ast_sprite&()
  2104.     SPRITEDELETE:(G_ast_sprite&(num%))
  2105. PROC _ast_createSmallAst&:
  2106.     EXTERNAL G_space_window%,G_bm_smallAst&,G_bm_smallAstMask&
  2107.     EXTERNAL G_bm_smallAstXDim%
  2108.     LOCAL handle&
  2109.     handle&=SPRITECREATE&:(G_space_window%,-G_bm_smallAstXDim%-5,0,0)
  2110.     SPRITEAPPEND:(0,G_bm_smallAst&,G_bm_smallAstMask&,1,0,0)
  2111.     SPRITEDRAW:
  2112.     RETURN handle&
  2113. PROC _ast_createBigAst&:
  2114.     EXTERNAL G_space_window%,G_bm_bigAst&,G_bm_bigAstMask&
  2115.     EXTERNAL G_bm_bigAstXDim%
  2116.     LOCAL handle&
  2117.     handle&=SPRITECREATE&:(G_space_window%,-G_bm_bigAstXDim%-5,0,0)
  2118.     SPRITEAPPEND:(0,G_bm_bigAst&,G_bm_bigAstMask&,1,0,0)
  2119.     SPRITEDRAW:
  2120.     RETURN handle&
  2121. REM *************************
  2122. REM ****                 ****
  2123. REM **** .ini File Stuff ****
  2124. REM ****                 ****
  2125. REM *************************
  2126. PROC init_initialise:
  2127.     REM 
  2128.  load the INI OPM module for .ini stuff here
  2129.     REM #### Commented out until symbian release final versions of the opms
  2130.     REM OPM_LoadModule:("ini")
  2131.     LOADM("ini.opm")
  2132.     REM 
  2133.  Make sure that the directory C:\system\apps\meteoroid\
  2134.     REM 
  2135.  exists, as this is used for the .ini file.
  2136.     IF NOT EXIST(K_init_drive$+K_init_path$+K_app_fileBase$)
  2137.         MKDIR K_init_drive$+K_init_path$+K_app_fileBase$
  2138.     ENDIF
  2139.     REM 
  2140.  make sure user can't interrupt while the .ini file is in
  2141.     REM 
  2142.  use.
  2143.     ESCAPE
  2144.     REM 
  2145.  check for .ini file
  2146.     IF INI_Open%:(K_init_drive$+K_init_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_init_extension$)=-1
  2147.         REM #### unable to open .ini file, do something!
  2148.     ENDIF
  2149.     _init_readInits:
  2150.     REM 
  2151.  No point in leaving file open, as it won't get used
  2152.     REM 
  2153.  again until app closure
  2154.     INI_Close:(K_init_drive$+K_init_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_init_extension$)
  2155.     ESCAPE ON
  2156. PROC init_useDefaults:
  2157.     REM 
  2158.  Set preferences to the "hard-coded" constants.
  2159.     EXTERNAL G_app_key%(),G_sound_on%,G_sound_volume%
  2160.     G_app_key%(1)=D_app_initKey1%
  2161.     G_app_key%(2)=D_app_initKey2%
  2162.     G_app_key%(3)=D_app_initKey3%
  2163.     G_app_key%(4)=D_app_initKey4%
  2164.     G_sound_on%=D_sound_on%
  2165.     G_sound_volume%=D_sound_volume%
  2166. PROC init_close:
  2167.     REM 
  2168.  make sure user can't interrupt while the .ini file is in
  2169.     REM 
  2170.  use.
  2171.     ESCAPE OFF
  2172.     REM 
  2173.  save preferences and high scores to .ini file and close it
  2174.     IF INI_Open%:(K_init_drive$+K_init_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_init_extension$)=-1
  2175.         REM #### unable to open .ini file, do something!
  2176.     ENDIF
  2177.     _init_writeInits:
  2178.     INI_Close:(K_init_drive$+K_init_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_init_extension$)
  2179.     ESCAPE ON
  2180.     REM 
  2181.  unload the INI OPM
  2182.     OPM_UnLoadModule:("ini")
  2183. PROC _init_readInits:
  2184.     EXTERNAL G_app_key%(),G_hs_name$(),G_hs_score&()
  2185.     EXTERNAL G_sound_on%,G_sound_volume%
  2186.     REM 
  2187.  load initial values.
  2188.     REM 
  2189.  if no values are found, use the defaults 
  2190.     G_app_key%(1)=INI_Read%:("key1",D_app_initKey1%)
  2191.     G_app_key%(2)=INI_Read%:("key2",D_app_initKey2%)
  2192.     G_app_key%(3)=INI_Read%:("key3",D_app_initKey3%)
  2193.     G_app_key%(4)=INI_Read%:("key4",D_app_initKey4%)
  2194.     G_sound_on%=INI_Read%:("sound",D_sound_on%)
  2195.     G_sound_volume%=INI_Read%:("volume",D_sound_volume%)
  2196.     G_hs_name$(1)=INI_Read$:("name1",D_hs_name1$)
  2197.     G_hs_name$(2)=INI_Read$:("name2",D_hs_name2$)
  2198.     G_hs_name$(3)=INI_Read$:("name3",D_hs_name3$)
  2199.     G_hs_name$(4)=INI_Read$:("name4",D_hs_name4$)
  2200.     G_hs_name$(5)=INI_Read$:("name5",D_hs_name5$)
  2201.     G_hs_score&(1)=INI_Read&:("score1",D_hs_score1&)
  2202.     G_hs_score&(2)=INI_Read&:("score2",D_hs_score2&)
  2203.     G_hs_score&(3)=INI_Read&:("score3",D_hs_score3&)
  2204.     G_hs_score&(4)=INI_Read&:("score4",D_hs_score4&)
  2205.     G_hs_score&(5)=INI_Read&:("score5",D_hs_score5&)
  2206. PROC _init_writeInits:
  2207.     EXTERNAL G_app_key%(),G_hs_name$(),G_hs_score&()
  2208.     EXTERNAL G_sound_on%,G_sound_volume%
  2209.     REM 
  2210.  write preferences to .ini file
  2211.     INI_Write%:("key1",G_app_key%(1))
  2212.     INI_Write%:("key2",G_app_key%(2))
  2213.     INI_Write%:("key3",G_app_key%(3))
  2214.     INI_Write%:("key4",G_app_key%(4))
  2215.     INI_Write%:("sound",G_sound_on%)
  2216.     INI_Write%:("volume",G_sound_volume%)
  2217.     INI_Write$:("name1",G_hs_name$(1))
  2218.     INI_Write$:("name2",G_hs_name$(2))
  2219.     INI_Write$:("name3",G_hs_name$(3))
  2220.     INI_Write$:("name4",G_hs_name$(4))
  2221.     INI_Write$:("name5",G_hs_name$(5))
  2222.     INI_Write&:("score1",G_hs_score&(1))
  2223.     INI_Write&:("score2",G_hs_score&(2))
  2224.     INI_Write&:("score3",G_hs_score&(3))
  2225.     INI_Write&:("score4",G_hs_score&(4))
  2226.     INI_Write&:("score5",G_hs_score&(5))
  2227. REM **********************
  2228. REM ****              ****
  2229. REM **** Bitmap Stuff ****
  2230. REM ****              ****
  2231. REM **********************
  2232. PROC bm_initialise:
  2233.     REM 
  2234.  these are grouped here in order to make a single access
  2235.     REM 
  2236.  on the bitmap files
  2237.     EXTERNAL G_app_drive$,G_app_path$
  2238.     EXTERNAL G_bm_bigAst&,G_bm_bigAstMask&
  2239.     EXTERNAL G_bm_smallAst&,G_bm_smallAstMask&
  2240.     EXTERNAL G_bm_smallAstXDim%,G_bm_bigAstXDim%
  2241.     EXTERNAL G_bm_titleMr%,G_bm_titleMeteoroid%,G_bm_titleGame%
  2242.     EXTERNAL G_bm_panelEnergy%,G_bm_panelScore%
  2243.     EXTERNAL G_bm_screenBG%
  2244.     LOCAL temp%
  2245.     REM 
  2246.  This is an ugly way to find the width of the asteroids:
  2247.     REM 
  2248.  Load them into a drawable and find *its* width!
  2249.     REM 
  2250.  But it's the only way I can think of
  2251.     temp%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_bigAstIndex%)
  2252.     G_bm_bigAstXDim%=gWIDTH
  2253.     gCLOSE temp%
  2254.     temp%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_smallAstIndex%)
  2255.     G_bm_smallAstXDim%=gWIDTH
  2256.     gCLOSE temp%
  2257.     REM 
  2258.  Patterns
  2259.     REM 
  2260.  the background pattern for the screen window.
  2261.     REM 
  2262.  This is used in a bitmap drawable, so use gLOADBIT()
  2263.     G_bm_screenBG%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_screenBGIndex%)
  2264.     REM 
  2265.  Prerendered Text
  2266.     REM 
  2267.  These are used in bitmap drawables, so use gLOADBIT()
  2268.     G_bm_titleMr%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_titleMrIndex%)
  2269.     G_bm_titleMeteoroid%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_titleMeteoroidIndex%)
  2270.     G_bm_titleGame%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_titleGameIndex%)
  2271.     G_bm_panelScore%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_panelScoreIndex%)
  2272.     G_bm_panelEnergy%=gLOADBIT(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,0,K_bm_panelEnergyIndex%)
  2273.     REM 
  2274.  The Asteroids
  2275.     REM 
  2276.  these are used in sprites, so use BITMAPLOAD&:()
  2277.     G_bm_bigAst&=BITMAPLOAD&:(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,K_bm_bigAstIndex%)
  2278.     G_bm_bigAstMask&=BITMAPLOAD&:(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,K_bm_bigAstMaskIndex%)
  2279.     G_bm_smallAst&=BITMAPLOAD&:(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,K_bm_smallAstIndex%)
  2280.     G_bm_smallAstMask&=BITMAPLOAD&:(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_bm_extension$,K_bm_smallAstMaskIndex%)
  2281. PROC bm_close:
  2282.     EXTERNAL G_bm_bigAst&,G_bm_bigAstMask&
  2283.     EXTERNAL G_bm_smallAst&,G_bm_smallAstMask&
  2284.     EXTERNAL G_bm_screenBG%
  2285.     EXTERNAL G_bm_panelEnergy%,G_bm_panelScore%
  2286.     EXTERNAL G_bm_titleMr%,G_bm_titleMeteoroid%,G_bm_titleGame%
  2287.     BITMAPUNLOAD:(G_bm_bigAst&)
  2288.     BITMAPUNLOAD:(G_bm_bigAstMask&)
  2289.     BITMAPUNLOAD:(G_bm_smallAst&)
  2290.     BITMAPUNLOAD:(G_bm_smallAstMask&)
  2291.     gCLOSE G_bm_titleMr%
  2292.     gCLOSE G_bm_titleMeteoroid%
  2293.     gCLOSE G_bm_titleGame%
  2294.     gCLOSE G_bm_screenBG%
  2295.     gCLOSE G_bm_panelEnergy%
  2296.     gCLOSE G_bm_panelScore%
  2297. REM **************
  2298. REM ****      ****
  2299. REM **** Menu
  2300. REM ****      ****
  2301. REM **************
  2302. PROC menu_display:
  2303.     EXTERNAL G_app_state%
  2304.     LOCAL choice%,inGame%
  2305.     IF G_app_state%<K_app_stateInGame%
  2306.         inGame%=KMenuDimmed%
  2307.     ENDIF
  2308.     LOCK ON
  2309.   mINIT
  2310.   mCARD "Game","New Game",%n,"Pause",inGame%+%p,"Quit Game",-(inGame%+%q),"Close",%e
  2311.   mCARD "High Scores","View",%v
  2312.   mCARD "Tools","Change Keys
  2313. ",%k,"Sound Setup
  2314. ",%s,"Restore Defaults",-%r,"About",%a,"Help",%h
  2315.   choice%=MENU
  2316.   LOCK OFF
  2317.   cmd_checkSysKey%:(choice%)
  2318. REM ******************
  2319. REM ****          ****
  2320. REM **** Commands ****
  2321. REM ****          ****
  2322. REM ******************
  2323. PROC cmd_checkSysKey%:(key&)
  2324.     EXTERNAL G_app_state%
  2325.   IF key&=%a
  2326.       about_display:
  2327.       RETURN KTrue%
  2328.   ELSEIF key&=%k
  2329.       pref_change_keys:
  2330.       RETURN KTrue%
  2331.   ELSEIF key&=%v
  2332.       hs_display:
  2333.       RETURN KTrue%
  2334.   ELSEIF key&=%n
  2335.       IF G_app_state%>=K_app_stateInGame%
  2336.           IF misc_confirm%:(K_app_name$,"Leave current game?")
  2337.               cmd_restart:
  2338.             ENDIF
  2339.         ELSE
  2340.           cmd_restart:
  2341.       ENDIF    
  2342.      ELSEIF key&=%p
  2343.          cmd_pause:
  2344.          RETURN KTrue%
  2345.   ELSEIF key&=%e
  2346.       IF G_app_state%<K_app_stateInGame%
  2347.           REM 
  2348.  if we are not in a game, don't bother confirming.
  2349.           cmd_exit:
  2350.       ELSEIF misc_confirm%:("Exit "+K_app_name$,"Are you sure?")
  2351.           cmd_exit:
  2352.       ENDIF
  2353.       RETURN KTrue%
  2354.   ELSEIF key&=%q
  2355.       IF misc_confirm%:("Quit your game","Are you sure?")
  2356.           cmd_quit:
  2357.       ENDIF
  2358.       RETURN KTrue%
  2359.   ELSEIF key&=%r
  2360.       pref_restore_defaults:
  2361.       RETURN KTrue%
  2362.   ELSEIF key&=%s
  2363.       sound_setupDialog:
  2364.       RETURN KTrue%
  2365.   ELSEIF key&=%h
  2366.       help_display:
  2367.       RETURN KTrue%
  2368.   ELSE
  2369.       RETURN KFalse%
  2370.   ENDIF
  2371. PROC cmd_restart:
  2372.     EXTERNAL G_app_state%,G_app_interact%
  2373.     G_app_state%=K_app_stateRestartGame%
  2374.     G_app_interact%=Kfalse%
  2375. PROC cmd_exit:
  2376.     EXTERNAL G_app_state%,G_app_interact%
  2377.      G_app_state%=K_app_stateLeaveApp%
  2378.      G_app_interact%=Kfalse%    
  2379. PROC cmd_quit:
  2380.     EXTERNAL G_app_state%,G_app_interact%
  2381.      G_app_state%=K_app_stateInApp%
  2382.      G_app_interact%=Kfalse%
  2383. PROC cmd_pause:
  2384.     EXTERNAL G_app_state%
  2385.     G_app_state%=K_app_stateInPause%
  2386. REM ********************
  2387. REM ****            ****
  2388. REM **** Help Stuff ****
  2389. REM ****            ****
  2390. REM ********************
  2391. PROC help_initialise:
  2392.     REM 
  2393.  this procedure deliberately left blank!
  2394. PROC help_display:
  2395.     EXTERNAL G_help_thread&,G_app_drive$,G_app_path$
  2396.     IF EXIST(G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_help_extension$)
  2397.         REM 
  2398.  only attempt to open the help file if it exists
  2399.         IF G_help_thread&<>0
  2400.             REM 
  2401.  If we have already opened a help file, try to use it
  2402.             ONERR noHelpThread::
  2403.             SETFOREGROUNDBYTHREAD&:(G_help_thread&,0)
  2404.         ELSE
  2405.             noHelpThread::
  2406.             ONERR OFF
  2407.             REM 
  2408.  if we haven't, or if it's been closed, open a new one.
  2409.             G_help_thread&=RUNAPP&:("Data",G_app_drive$+G_app_path$+K_app_fileBase$+"\"+K_app_fileBase$+K_help_extension$,"",0)
  2410.         ENDIF
  2411.     ELSE
  2412.         REM 
  2413.  if there is no helpfile, discretely inform the user.
  2414.         gIPRINT "No helpfile found!"
  2415.     ENDIF
  2416. PROC help_close:
  2417.     EXTERNAL G_help_thread&
  2418.     IF G_help_thread&<>0
  2419.         REM 
  2420.  if a help file has been opened, try to close it.
  2421.         ONERR noHelpThread::
  2422.         ENDTASK&:(G_help_thread&,0)
  2423.     ENDIF
  2424.     REM 
  2425.  if it's already been closed, continue without caring.
  2426.     noHelpThread::
  2427.     ONERR OFF
  2428. REM *********************
  2429. REM ****             ****
  2430. REM **** Preferences ****
  2431. REM ****             ****
  2432. REM *********************
  2433. PROC pref_change_keys:
  2434.     EXTERNAL G_app_key%(),G_app_state%
  2435.     LOCAL choice%
  2436.     LOCAL key_1$(1),key_2$(1),key_3$(1),key_4$(1)
  2437.     REM 
  2438.  initialise edit boxes to current values
  2439.     key_1$=CHR$(G_app_key%(1))
  2440.     key_2$=CHR$(G_app_key%(2))
  2441.     key_3$=CHR$(G_app_key%(3))
  2442.     key_4$=CHR$(G_app_key%(4))
  2443.     LOCK ON
  2444.     dINIT "Change Keys"
  2445.     dEDIT key_1$,"Shield 1"
  2446.     dEDIT key_2$,"Shield 2"
  2447.     dEDIT key_3$,"Shield 3"
  2448.     dEDIT key_4$,"Shield 4"
  2449.     dBUTTONS "Cancel",-27,"Okay",13
  2450.     choice%=DIALOG
  2451.     LOCK OFF
  2452.     IF choice%=13
  2453.         IF G_app_state%>=K_app_stateInGame%
  2454.             REM 
  2455.  If we're in a game, update the old graphics
  2456.             base_delete:
  2457.         ENDIF
  2458.         REM #### check for consistancy
  2459.         G_app_key%(1)=ASC(key_1$)
  2460.         G_app_key%(2)=ASC(key_2$)
  2461.         G_app_key%(3)=ASC(key_3$)
  2462.         G_app_key%(4)=ASC(key_4$)
  2463.         IF G_app_state%>=K_app_stateInGame%
  2464.             REM 
  2465.  If we're in a game, draw new graphics
  2466.             base_draw:
  2467.         ENDIF
  2468.     ENDIF
  2469. PROC pref_restore_defaults:
  2470.     EXTERNAL G_app_state%
  2471.     IF misc_confirm%:("Restore Defaults","Are you sure?")
  2472.         IF G_app_state%>=K_app_stateInGame%
  2473.             REM 
  2474.  If we're in a game, delete old base graphics
  2475.           base_delete:
  2476.         ENDIF        
  2477.         REM 
  2478.  note that this doesn't affect the high scores
  2479.       init_useDefaults:
  2480.         IF G_app_state%>=K_app_stateInGame%
  2481.             REM 
  2482.  If we're in a game, draw new base graphics
  2483.             base_draw:
  2484.         ENDIF
  2485.   ENDIF
  2486. REM ***************
  2487. REM ****       ****
  2488. REM **** About ****
  2489. REM ****       ****
  2490. REM ***************
  2491. PROC about_display:
  2492.     LOCK ON
  2493.     dINIT "About "+K_app_name$
  2494.     dTEXT "",K_app_name$+" "+K_app_version$,2
  2495.     dTEXT "","
  2496. 2000 Malcolm Tyrrell",2
  2497.     dTEXT "","This program is freeware.",2
  2498.     dBUTTONS "Okay",KKeyEnter%
  2499.     DIALOG
  2500.     LOCK OFF
  2501. REM ******************
  2502. REM ****          ****
  2503. REM **** HiScores ****
  2504. REM ****          ****
  2505. REM ******************
  2506. PROC hs_display:
  2507.     EXTERNAL G_hs_score&(),G_hs_name$()
  2508.     LOCAL i%
  2509.     REM #### I'm worried that this dialog won't fit on smaller screens.
  2510.     LOCK ON
  2511.     dINIT "High Scores"
  2512.     i%=1
  2513.         dTEXT misc_padWithZeroes$:(K_hs_numdigits%,G_hs_score&(i%)),G_hs_name$(i%),2
  2514.         i%=i%+1
  2515.     UNTIL i%>K_hs_tableSize%
  2516.     dBUTTONS "Okay",KKeyEnter%
  2517.     DIALOG
  2518.     LOCK OFF
  2519. PROC hs_gameover%:(score&)
  2520.     EXTERNAL G_hs_score&(),G_hs_name$()
  2521.     LOCAL i%,pos%
  2522.     REM 
  2523.  display game over dialog
  2524.     LOCK ON
  2525.     dINIT "Game Over"
  2526.     dTEXT "","You scored",2
  2527.     dTEXT "",misc_padWithZeroes$:(K_hs_numDigits%,score&),2
  2528.     dBUTTONS "Okay",KKeyEnter%
  2529.     DIALOG
  2530.     LOCK OFF
  2531.     REM 
  2532.  find position in table for new score
  2533.     i%=K_hs_tableSize%
  2534.         IF score&>G_hs_score&(i%)
  2535.             pos%=i%
  2536.         ENDIF
  2537.         i%=i%-1
  2538.     UNTIL i%=0
  2539.     REM 
  2540.  if the score is high enough
  2541.     IF pos%>0
  2542.         REM 
  2543.  cascade lower scores
  2544.         i%=K_hs_tableSize%
  2545.         WHILE i%>pos%
  2546.             G_hs_name$(i%)=G_hs_name$(i%-1)
  2547.             G_hs_score&(i%)=G_hs_score&(i%-1)
  2548.             i%=i%-1
  2549.         ENDWH
  2550.         REM 
  2551.  put in newer ones
  2552.         G_hs_name$(pos%)=_hs_getPlayerName$:
  2553.         G_hs_score&(pos%)=score&
  2554.         RETURN Ktrue%
  2555.     ELSE
  2556.         RETURN Kfalse%
  2557.     ENDIF
  2558. PROC _hs_getPlayerName$:
  2559.     LOCAL newname$(8)
  2560.     newname$="AAA"
  2561.     LOCK ON
  2562.     dINIT "New High Score"
  2563.     dTEXT "","Congratulations!",2
  2564.     dTEXT "","You're in the high score table.",2
  2565.     dEDIT newname$,"Your Name"
  2566.     DIALOG
  2567.     LOCK OFF
  2568.     RETURN newname$
  2569. REM *********************
  2570. REM ****             ****
  2571. REM **** Sound Stuff ****
  2572. REM ****             ****
  2573. REM *********************
  2574. PROC sound_initialise:
  2575.     EXTERNAL G_sound_volume%,G_sound_playing%
  2576.     MusicSetVolume:(G_sound_volume%)
  2577.     G_sound_playing%=Kfalse%
  2578. PROC sound_setupDialog:
  2579.     EXTERNAL G_sound_on%,G_sound_volume%
  2580.     LOCK ON
  2581.     dINIT "Sound Setup"
  2582.     dCHECKBOX G_sound_on%,"Sound"
  2583.     dCHOICE G_sound_volume%,"Volume","Quiet,Medium,Loud"
  2584.     dBUTTONS "Cancel",-KKeyEsc%,"Okay",KKeyEnter%
  2585.     DIALOG
  2586.     LOCK OFF
  2587.     MusicSetVolume:(G_sound_volume%)
  2588. PROC sound_highBeep:
  2589.     EXTERNAL G_sound_on%,G_sound_playing%,G_sound_start&
  2590.     IF G_sound_on%
  2591.         MusicNote:(K_sound_highPitch&,K_sound_amplitude%)
  2592.         G_sound_playing%=Ktrue%
  2593.         G_sound_start&=DTNow&:
  2594.     ENDIF
  2595. PROC sound_midBeep:
  2596.     EXTERNAL G_sound_on%,G_sound_playing%,G_sound_start&
  2597.     IF G_sound_on%
  2598.         MusicNote:(K_sound_midPitch&,K_sound_amplitude%)
  2599.         G_sound_playing%=Ktrue%
  2600.         G_sound_start&=DTNow&:
  2601.     ENDIF
  2602. PROC sound_lowBeep:
  2603.     EXTERNAL G_sound_on%,G_sound_playing%,G_sound_start&
  2604.     IF G_sound_on%
  2605.         MusicNote:(K_sound_lowPitch&,K_sound_amplitude%)
  2606.         G_sound_playing%=Ktrue%
  2607.         G_sound_start&=DTNow&:
  2608.     ENDIF
  2609. PROC sound_check:(timenow&)
  2610.     EXTERNAL G_sound_playing%,G_sound_start&
  2611.     REM 
  2612.  Check even if sound is off
  2613.     IF G_sound_playing%
  2614.         IF DTMicrosDiff&:(G_sound_start&,timenow&)>K_sound_duration&
  2615.             sound_stop:
  2616.         ENDIF
  2617.     ENDIF
  2618. PROC sound_stop:
  2619.     EXTERNAL G_sound_playing%,G_sound_start&
  2620.     IF G_sound_playing%
  2621.         DTDeleteDateTime:(G_sound_start&)
  2622.         G_sound_playing%=KFalse%
  2623.     ENDIF
  2624.     musicStop:
  2625. PROC sound_close:
  2626.     EXTERNAL G_sound_playing%,G_sound_start&
  2627.     REM 
  2628.  just in case sound is currently playing
  2629.     sound_stop:
  2630.     musicStop:
  2631. REM ********************
  2632. REM ****            ****
  2633. REM **** Misc Tools ****
  2634. REM ****            ****
  2635. REM ********************
  2636. PROC misc_padWithZeroes$:(width%,number&)
  2637.     LOCAL i%
  2638.         i%=i%+1
  2639.     UNTIL (10**i%)>number&
  2640.     IF i%>width%
  2641.         REM 
  2642.  oops, score to big for width
  2643.         RETURN REPT$("9",width%)
  2644.     ENDIF
  2645.     RETURN REPT$("0",(width%-i%))+NUM$(number&,i%)
  2646. PROC misc_confirm%:(title$,question$)
  2647.     LOCAL choice%
  2648.     LOCK ON
  2649.     dINIT title$
  2650.     dTEXT "",question$
  2651.     dBUTTONS "No",-(%n OR KDButtonNoLabel% OR KDButtonPlainKey%),"Yes",(%y OR KDButtonNoLabel% OR KDButtonPlainKey%)
  2652.     choice%=DIALOG
  2653.     LOCK OFF
  2654.     IF choice%=%y
  2655.         RETURN Ktrue%
  2656.     ELSE
  2657.         RETURN Kfalse%
  2658.     ENDIF
  2659. REM ********************
  2660. REM ****            ****
  2661. REM **** Test Stuff ****
  2662. REM ****            ****
  2663. REM ********************
  2664. PROC test_specificDevices:
  2665.     REM 
  2666.  currently only screen sizes here.    
  2667.     EXTERNAL G_screen_xDim%,G_screen_yDim%
  2668.     REM 
  2669.  UNCOMMENT TO
  2670. SELECT
  2671.     REM 
  2672.  It probably would be nicer to do this with constants...
  2673.     REM 
  2674.  ah well!
  2675.     REM 
  2676.  Custom 1
  2677.     REM 
  2678.  this is the smallest supported screen size
  2679.     REM G_screen_xDim%=280
  2680.     REM G_screen_yDim%=160
  2681.     REM 
  2682.  Psion 5
  2683.     REM 
  2684.  OS: ER3
  2685.     REM    G_screen_xDim%=640
  2686.     REM G_screen_yDim%=240
  2687.     REM 
  2688.  Psion 5mx
  2689.     REM 
  2690.  OS: ER5
  2691.     REM    G_screen_xDim%=640
  2692.     REM G_screen_yDim%=240
  2693.     REM 
  2694.  Psion Revo
  2695.     REM 
  2696.  OS: ER5
  2697.     REM G_screen_xDim%=480
  2698.     REM G_screen_yDim%=160
  2699.     REM 
  2700.  Psion 7
  2701.     REM 
  2702.  OS: ER5
  2703.     REM    G_screen_xDim%=640
  2704.     REM G_screen_yDim%=480
  2705.     REM 
  2706.  Psion Netbook
  2707.     REM 
  2708.  OS: ER5
  2709.     REM    G_screen_xDim%=640
  2710.     REM G_screen_yDim%=480
  2711.     REM 
  2712.  Ericsson MC218
  2713.     REM 
  2714.  OS: ER5
  2715.     REM    G_screen_xDim%=640
  2716.     REM G_screen_yDim%=240
  2717.     REM 
  2718.  Geofox 1
  2719.     REM 
  2720.  OS: ER3
  2721.     REM 
  2722.  it has no touch screen. A sensitive pad was used instead.
  2723.     REM G_screen_xDim%=640
  2724.     REM G_screen_yDim%=320
  2725.     REM 
  2726.  Oregon Scientific Osaris
  2727.     REM 
  2728.  OS: ER4
  2729.     REM 
  2730.  the osaris screen is stretched horizontally.
  2731.     REM G_screen_xDim%=320
  2732.     REM G_screen_yDim%=200
  2733. REM *******************
  2734. REM ****           ****
  2735. REM **** OPM STUFF ****
  2736. REM ****           ****
  2737. REM *******************
  2738.  this stuff included from file "Loader.tpl", included
  2739.  with OPMs downloaded from Symbian.
  2740. REM *************************************************************
  2741. REM * The routines below are the standard OPM Load routines and *
  2742. REM * should be copied to all applications which use OPMs       *
  2743. REM *************************************************************
  2744. REM --------------------------------------------------------
  2745. REM Returns the file position if the file exists on C: or D:
  2746. REM --------------------------------------------------------
  2747. PROC OPM_FileLoc$:(file$)
  2748.     IF EXIST ("C:"+file$)
  2749.         RETURN "C:"+file$
  2750.     ELSE
  2751.         IF EXIST ("D:"+file$)
  2752.             RETURN "D:"+file$
  2753.         ELSE
  2754.             RETURN ""    REM File does not exist
  2755.         ENDIF
  2756.     ENDIF
  2757. REM -------------------------------------
  2758. REM Loads in a module held in /System/Opm
  2759. REM -------------------------------------
  2760. PROC OPM_LoadModule:(modulename$)
  2761.     LOCAL f$(255)
  2762.     f$=OPM_FileLoc$:("\System\Opm\"+modulename$+".opm")
  2763.     IF f$<>""
  2764.         LOADM f$ :REM Load the module
  2765.     ELSE
  2766.         ALERT("Cannot find the OPM:","\System\Opm\"+modulename$+".opm")
  2767.         STOP
  2768.     ENDIF
  2769. REM -------------------------------
  2770. REM Unloads in a module from memory
  2771. REM -------------------------------
  2772. PROC OPM_UnloadModule:(modulename$)
  2773.     LOCAL f$(255)
  2774.     f$=OPM_FileLoc$:("\System\Opm\"+modulename$+".opm")
  2775.     ONERR notloaded::
  2776.     UNLOADM f$
  2777. notloaded::
  2778.     ONERR OFF
  2779. *TextEd.app
  2780. Roman
  2781. &Heading 1L
  2782. Roman
  2783. &Heading 2L
  2784. Roman
  2785. &Heading 3L
  2786. .Bullet listO
  2787. Swiss
  2788. 6Bullet list 3O
  2789. Swiss
  2790. 6Bullet list 2O
  2791. Swiss
  2792.   footnoteO
  2793. Swiss
  2794.   footnoteO
  2795. Swiss
  2796. "Text boxO
  2797. TitleO
  2798. Mr. Meteoroid Game v0.85beta
  2799. 2000 Malcolm Tyrrell
  2800. Hello.
  2801. Thank you for your interest in this lo-fi game.
  2802. I developed it over a year ago, but I only released a source release due to a dependence on some OPMs from Symbian ( "ini.opm" and "pc_bar.opm" ).
  2803. Symbian still haven't released final versions of these, so I've included them in the app directory instead of linking against them in "\System\OPM\".
  2804. To Play
  2805. Open Meteoroid in Program and press "Ctrl+L". This will create "Meteoroid.opo". Tapping this file will run the game.
  2806. Sources
  2807. If you have downloaded the Sources the instructions on installing the game as an application follow:
  2808. Open Meteoroid in Program, search for "REM*" and remove all occurences.
  2809. Press "Ctrl+L", which will automatically put "Meteoroid.app" and "Meteoroid.aif" in "\System\Apps\Meteoroid\".
  2810. Now copy these four files from the current directory to "\System\Apps\Meteoroid\".
  2811. Meteoroid.mbm;
  2812. Meteoroid.hlp;
  2813. ini.opm, and 
  2814. pc_bar.opm.
  2815. There should now be a Meteoroid icon in the Extras bar.
  2816. There is no warranty whatsoever. You use this at your own risk, of course.
  2817. Enjoy,
  2818. Malcolm.
  2819. Roman
  2820. "Word.app
  2821.