Guest User

Untitled

a guest
Apr 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define fbc -s console Files\hq2x16.o
  2.  
  3. '#inclib "hq2x"
  4. 'declare sub HQ2X_16 (INBUFFER as any ptr,OUTBUFFER as any ptr,XRES as uinteger,YRES as uinteger,PITCH as uinteger)
  5.  
  6. #ifdef __FB_NDS__
  7. #include "Modules\fbLib.bas"
  8. #include "Modules\fbgfx.bas"
  9. #include "Modules/fmod.bas"
  10. #else
  11. #define SC2X_X 256
  12. #define SC2X_Y 192
  13. #include "MyTDT\Scale2x.bas"
  14. #ifdef __FB_WIN32__
  15. #include "Files\hq2x.bi"
  16. #endif
  17. #ifndef __FB_DOS__
  18. #include "fmod.bi"
  19. #endif
  20. #include "fbgfx.bi"
  21. #include "crt.bi"
  22. chdir exepath+"/NitroFiles/"
  23. 'chdir exepath+"/NitroF~1/"
  24. #endif
  25.  
  26. #ifdef __FB_WIN32__
  27. #include "windows.bi"
  28. #define Render_OpenGL
  29. #include "MyTDT\OpenGL.bas"
  30. #endif
  31.  
  32. #include "Files\Types.bas"
  33. #include "Files\Rounds.bas"
  34.  
  35. declare function ConvertPassword(CP1,CP2,CP3,CP4,CP5,as integer) as uinteger
  36. declare function DrwTxt(as integer,as integer,as string,as uinteger=rgb(255,255,255)) as integer
  37. declare sub LoadMap(as integer, as integer=0)
  38. declare sub DrawMap()
  39. declare sub UpdatePowerUp()
  40. declare sub NewPowerUp(as integer,as integer)
  41. declare sub DrawBall(as integer)
  42. declare function BallCollision(as integer) as integer
  43. declare sub LaserUpdate(NUM as integer)
  44. declare sub DrawHud()
  45. declare sub DrawStars()
  46. declare function DrawSprites() as integer
  47. declare sub UpdateAndSync()
  48. declare sub ShipBreaks(as integer=0)
  49. declare sub Screenlock2()
  50. declare sub Screenunlock2()
  51. declare sub UpdateAliens()
  52. declare sub InGame()
  53. declare sub Intro(as integer=0)
  54. declare sub CreateStars()
  55. declare sub SaveCpu()
  56. declare sub LoadConfig()
  57. declare sub SaveConfig()
  58. declare sub VideoInit()
  59.  
  60. #ifdef __FB_DOS__
  61. dim shared as integer xxx=0
  62. #define FSOUND_Init(p1,p2,p3) 0
  63. #define FSOUND_Sample_Load(p1,p2,p3,p4,p5) 0
  64. #define FSOUND_Sample_SetDefaults(p1,p2,p3,p4,p5) xxx=0
  65. #define FSOUND_PlaySound(p1,p2) xxx=0
  66. #define FSound_StopSound(p1) xxx=0
  67. #define FSOUND_Sample_Free(p1) xxx=0
  68. #define FSOUND_SetVolume(p1,p2) xxx=0
  69. #define FSOUND_SAMPLE any
  70. #endif
  71.  
  72. '175
  73. dim shared as any ptr Grap,Back,Font,Buff,Scr,InTitle,Explode
  74. dim shared as any ptr Stars,Doh,Buff2,Scr2,Aliens
  75. dim shared as byte ScrDouble,NoSound,ScrRender,ScrFilter
  76. dim shared as byte sndVol,DSIsTop = 1
  77. dim shared as FSOUND_SAMPLE ptr sndSpark,sndBrick,sndHit,sndHit2
  78. dim shared as FSOUND_SAMPLE ptr sndLaser,sndBounce,sndWarp,sndDoh
  79. dim shared as FSOUND_SAMPLE ptr sndRound,sndGameOver,sndDohHit
  80. dim shared as FSOUND_SAMPLE ptr sndDohBreak,sndShipBrk,sndAlienBrk
  81. dim shared as FSOUND_SAMPLE ptr MusTheme,MusStory,sndVoice
  82. dim shared as FSOUND_SAMPLE ptr VocBeam,VocCatch,vocDup,vocExt
  83. dim shared as FSOUND_SAMPLE ptr vocPlus,vocLaser,vocSlow
  84. dim shared as string FileName
  85.  
  86. scope 'Init
  87.   printf(!"Starting...\n")
  88.   LoadConfig()  
  89.   VideoInit()  
  90.   #ifdef __FB__LINUX__
  91.   FSOUND_SetOutput(FSOUND_OUTPUT_ALSA)
  92.   if FSOUND_Init(44100,16,0) = 0 then
  93.     FSOUND_SetOutput(FSOUND_OUTPUT_OSS)
  94.     if FSOUND_Init(44100,16,0) = 0 then
  95.       NoSound = 1
  96.     end if
  97.   end if
  98.   #else
  99.   if FSOUND_Init(44100,16,0) = 0 then NoSound = 1
  100.   #endif
  101.  
  102.   printf(!"Loading Sounds...\n")
  103.   #macro LoadSound(sndTarget,sndName,sndFlags)
  104.   sndTarget    = FSOUND_Sample_Load(FSOUND_FREE,sndName,FSOUND_NORMAL or sndFlags,0,0)
  105.   if sndTarget = 0 then Fail=1: printf "Failed to load: " sndName !"\n"
  106.   #endmacro
  107.   if NoSound = 0 then  
  108.     #ifdef __FB_NDS__
  109.     dim as integer Snd = (*cptr(uinteger ptr,&h4000500)) and &h7F
  110.     *cptr(uinteger ptr,&h4000500) = Snd or ((SndVol shl 5)-(sndVol shl 2))
  111.     #else
  112.     FSOUND_SetSFXMasterVolume((sndVol shl 6)-(sndVol shl 2))
  113.     #endif
  114.     dim as integer Fail
  115.     LoadSound(sndSpark   ,"Sounds/Eletric.wav"   ,FSOUND_LOOP_OFF)
  116.     LoadSound(sndBrick   ,"Sounds/Brick.wav"     ,FSOUND_LOOP_OFF)
  117.     LoadSound(sndHit     ,"Sounds/Hit3.wav"      ,FSOUND_LOOP_OFF)
  118.     LoadSound(sndHit2    ,"Sounds/Hit4.wav"      ,FSOUND_LOOP_OFF)
  119.     LoadSound(sndDoh     ,"Sounds/Doh.wav"       ,FSOUND_LOOP_OFF)
  120.     LoadSound(sndDohHit  ,"Sounds/DohHit.wav"    ,FSOUND_LOOP_OFF)
  121.     LoadSound(sndDohBreak,"Sounds/DohBreak.wav"  ,FSOUND_LOOP_OFF)
  122.     LoadSound(sndLaser   ,"Sounds/Laser.wav"     ,FSOUND_LOOP_OFF)
  123.     LoadSound(sndBounce  ,"Sounds/Bounce2.wav"   ,FSOUND_LOOP_OFF)
  124.     LoadSound(sndWarp    ,"Sounds/Warp.wav"      ,FSOUND_LOOP_BIDI)  
  125.     LoadSound(sndShipBrk ,"Sounds/ShipBreak.wav" ,FSOUND_LOOP_OFF)
  126.     LoadSound(sndAlienBrk,"Sounds/AlienBreak.wav",FSOUND_LOOP_OFF)  
  127.     LoadSound(VocBeam    ,"Voices/BeamUp.wav"    ,FSOUND_LOOP_OFF)
  128.     LoadSound(VocCatch   ,"Voices/Catch.wav"     ,FSOUND_LOOP_OFF)
  129.     LoadSound(VocDup     ,"Voices/Duplicate.wav" ,FSOUND_LOOP_OFF)
  130.     LoadSound(VocExt     ,"Voices/Extend.wav"    ,FSOUND_LOOP_OFF)
  131.     LoadSound(VocLaser   ,"Voices/LaserGun.wav"    ,FSOUND_LOOP_OFF)
  132.     LoadSound(VocPlus    ,"Voices/ExtraLife.wav" ,FSOUND_LOOP_OFF)
  133.     LoadSound(VocSlow    ,"Voices/SlowDown.wav"  ,FSOUND_LOOP_OFF)  
  134.     LoadSound(sndRound   ,"Music/105-Begin.wav"  ,FSOUND_LOOP_OFF)
  135.     LoadSound(sndGameOver,"Music/98-GameOver.wav",FSOUND_LOOP_OFF)  
  136.     if Fail then Sleep
  137.   end if
  138.  
  139.   printf(!"Loading Graphics...\n")
  140.   Font = ImageCreate(64,64): Explode = Font
  141.   Grap = ImageCreate(64,64)
  142.   Back = ImageCreate(256,192)
  143.  
  144.   Stars = ImageCreate(256,256,rgb(0,0,0))
  145.   Doh = ImageCreate(128,128)
  146.   Aliens = ImageCreate(128,64)
  147.  
  148.   FileName = "InTitle.bmp": printf FileName & !"\n"
  149.   if InTitle then bload FileName,InTitle
  150.   FileName = "Font.bmp": printf FileName & !"\n"
  151.   bload FileName,Font
  152.   FileName = "Aliens.bmp": printf FileName & !"\n"
  153.   bload FileName,Aliens
  154.  
  155.   printf !"Game Start...\n"
  156. end scope
  157.  
  158. const ShipY = 175
  159. dim shared as short CurrentLevel=1,RoundPieces=0
  160. dim shared as short MapStart,MapSize,RoundAlpha=0
  161. dim shared as double Sync
  162. dim shared LevelMap(15,10) as RoundData, MapAlpha(15,10) as single
  163. dim shared MapShake(15,10) as byte
  164. dim shared tBall(15) as BallData, tPowerUp(7) as PowerUpData
  165. dim shared as short ShipX=95,ShipSz=12,ShipLives=3
  166. dim shared as short SkipFrame,SkipFrame2,FrameWrap,Difficulty
  167. dim shared as short ShipBreak=-1,ShipOffX=0,IgnoreButton,xDIFF
  168. dim shared as short OldShipType, OldShipSz, ShipType, ShipFrames
  169. dim shared as short AutoCatch,ExitWarp,WarpOffset,GameOn
  170. dim shared as short DohX,DohY,DohFlash,DohLives,AlienCount
  171. dim shared as short NewAlienLeft,NewAlienRight,IsPause
  172. dim shared as single BallSpeed
  173. dim shared as short BallCount = 1, BallCatch = 0, BallSmooth = 1
  174. dim shared as short ShowRound=511,LockMouse=1,iButDown,UseMouse=1,OldMX
  175. dim shared as integer iMX,iMY,iMB,iNX,iNY,iNB
  176. dim shared as integer ShowScore,NewScore,ScoreBonus,LastScore
  177. dim shared as short PowerUpRate,PowerUpCheck,FirstCatch,CatchOffset
  178. dim shared as short LaserX(3),LaserY(3),LaserOffset(3),LastLaser
  179. dim shared as single WarpAngle(8) = {0.1,1.2,1.9,2.8,4,5.3,6.1,7}
  180. dim shared as string Key,sOldCode
  181. dim shared as single StarAng(15),StarSpd(15),StarOffX,StarOffY
  182. dim shared as Fragment tDohBlow(11,7),tDohShot(2)
  183. dim shared tAlien(7) as AlienStruct , AlienSz(3) as short = {6,7,5,7}
  184. dim shared as single MinSpeed=1.501,MouseAdjustX,MouseAdjustY
  185. dim shared as HighScoreStruct HighScore
  186.  
  187. randomize()
  188. ConvertPassword(NewScore,Difficulty,CurrentLevel,ShipLives,sOldCode,0)
  189. #define FullFrames
  190.  
  191. do
  192.  
  193.   CurrentLevel=1:RoundPieces=0:MapStart=0:MapSize=0:RoundAlpha=0
  194.   ShipLives=3:ShipX=95:ShipSz=12:SkipFrame=0:SkipFrame2=0:Difficulty=0
  195.   ShipBreak=-1:ShipOffX=0:IgnoreButton=0:xDIFF=0:OldShipType=0:OldShipSz=0
  196.   ShipType=0:ShipFrames=0:AutoCatch=0:ExitWarp=0:WarpOffset=0:GameOn=0
  197.   DohX=0:DohY=0:DohFlash=0:DohLives=0:AlienCount=0:IsPause=0:BallCatch=0
  198.   NewAlienLeft=-1:NewAlienRight=0:BallSpeed=0:BallCount=1:BallSmooth=1
  199.   ShowRound=511:LockMouse=1:iButDown=0:UseMouse=1:OldMX=0:LastScore=0
  200.   iMX=0:iMY=0:iMB=0:iNX=0:iNY=0:iNB=0:ShowScore=0:NewScore=0:ScoreBOnus=0
  201.   PowerUpRate=0:PowerUpCheck=0:FirstCatch=0:CatchOffset=0:StarOffY=0  
  202.  
  203.   Intro()
  204.   #ifdef __FB_NDS__
  205.   lcdMainOnTop()
  206.   #endif
  207.   InGame()
  208.  
  209. loop
  210.  
  211. sub Intro(IntroMode as integer=0)    
  212.   dim as any ptr White  
  213.   White = ImageCreate(512,512,rgb(255,255,255))
  214.   #ifdef __FB_NDS__
  215.   put(0,0),Back,alpha,1  
  216.   put(0,0),Stars,alpha,1
  217.   put(0,0),Font,alpha,1
  218.   put(0,0),White,alpha,1
  219.   line(0,0)-(255,191),0,bf
  220.   White = reallocate(White,1024)
  221.   flip: screensync  
  222.   lcdMainOnBottom()  
  223.   #endif
  224.  
  225.   AlienCount = 7: GameOn = 0
  226.   for CNT as integer = 0 to AlienCount
  227.     dim as integer AlienType = CNT and 3    
  228.     with tAlien(CNT)
  229.       .iFrame = 0
  230.       .iOldFrame = 0
  231.       .fX = 16+rnd*224
  232.       .fY = 16+rnd*160
  233.       .iType = AlienType shl 3
  234.       .iLast = AlienSz(AlienType)
  235.       .iSpd = ((AlienType and 1) xor 1)            
  236.       .fAng = (rnd*360)*PI
  237.       .fSX = sin(.fAng)/4
  238.       .fSY -= cos(.fAng)/4
  239.     end with    
  240.   next CNT
  241.  
  242.   while len(inkey)
  243.     sleep 0,1
  244.   wend
  245.   dim as integer IntroFrames=0,MusChan(1),ChanNum '1024
  246.   dim pMenu as zstring ptr ptr
  247.   dim as short MenuCount,MenuSelect,MenuChoose
  248.   dim as integer BlackFrame,KeyFrame
  249.   dim as short StarX,StarY,NewHighScore
  250.   dim as single MenuOffset,MenuTarget
  251.   dim as zstring ptr MainMenu(...) = { _
  252.   @"Main Menu",@"New Game",@"Continue",@"HighScores",@"Options",@"Quit"}
  253.   dim as zstring ptr NewGameMenu(...) = { _
  254.   @"Select Difficulty",@" Easy ",@"Medium",@" Hard "}
  255.   dim as zstring ptr ContinueMenu(...) = { _
  256.   @"Enter Continue Code",@"#3F7FFF|" }  
  257.   #ifndef __FB_NDS__  
  258.   dim as zstring ptr OptionsMenu(...) = { _
  259.   @"Options",@"Video Scale",@"Video Render", _
  260.   @"Video Filter", @"Volume Levels" }
  261.   dim as zstring ptr VideoScaleMenu(...) = { _
  262.   @"Video Scale",@"1x 256x192",@"2x 512x384",@"4x 1024x768" }
  263.   dim as zstring ptr VideoRenderMenu(...) = { _
  264.   @"Video Render", @"GDI Window", @"GDI Fullscreen", _
  265.   @"OpenGL Window",@"OpenGL Maximum", _
  266.   @"DDraw Window",@"DDraw Maximum" }  
  267.   dim as zstring ptr VideoFilterMenu(...) = { _
  268.   @"Video Filter", @"Resize2x-4x", @"HQ2x-4x", @"Rgb2x-4x" }  
  269.   #else
  270.   dim as zstring ptr OptionsMenu(...) = { _
  271.   @"Options",@"Volume Levels",@"Screen Select" }  
  272.   dim as zstring ptr ScreenSelectMenu(...) = { _
  273.   @"Screen Select",@"Top Screen",@"Bottom Screen" }
  274.   #endif
  275.   dim as zstring ptr VolumeLevelsMenu(...) = { _
  276.   @"Volume Levels",@"Mute",@"Low",@"Medium",@"High",@"Full"}
  277.  
  278.   dim as string EpiText,TextTemp
  279.   dim as string TextBuff,TextBuff2
  280.   static as string*8 CurColor(7) = { _
  281.   "#000000|","#00FF00|","#FFFF00|","#0000FF|", _
  282.   "#FF0000|","#FFFFFF|","#00FFFF|","#FF7F3F|" }
  283.  
  284.   pMenu = @MainMenu(0): MenuCount = 4
  285.   MenuTarget = 0: MenuSelect = 0: MenuOffset = -256
  286.  
  287.   #ifdef __FB_NDS__
  288.   #define KeyUp()     fb.SC_ButtonUP  , fb.SC_ButtonL
  289.   #define KeyDown()   fb.SC_ButtonDown, fb.SC_ButtonR
  290.   #define KeyChoose() Key[0] = 13 or Key[1] = fb.SC_ButtonStart or Key[1] = fb.SC_ButtonA
  291.   #define KeyBack()   Key[0] = 27 or Key[1] = fb.SC_ButtonSelect or Key[1] = fb.SC_ButtonB        
  292.   #define KeyBackSpace() 8,-fb.SC_ButtonX
  293.   #else
  294.   #define KeyUp()     fb.SC_UP
  295.   #define KeyDown()   fb.SC_Down
  296.   #define KeyChoose() Key[0] = 13
  297.   #define KeyBack()   Key[0] = 27
  298.   #define KeyBackSpace() 8
  299.   #endif
  300.  
  301.   do    
  302.     dim as string Key = inkey$
  303.     if len(Key) andalso Key[1] = asc("k") then end
  304.    
  305.     screenlock2    
  306.    
  307.     select case IntroMode
  308.     case 0 'Intro/Menu
  309.       select case IntroFrames
  310.       case 0 to 255      'Background IN
  311.         if IntroFrames = 0 then
  312.           FileName = "Arcade.bmp": printf FileName & !"\n"
  313.           bload FileName,Stars  
  314.           FileName = "Logo.bmp": printf FileName & !"\n"  
  315.           line Back,(0,0)-(255,191),rgb(255,255,255),bf
  316.           bload FileName,Back
  317.         end if
  318.         dim as integer Temp = IntroFrames+(IntroFrames shr 1)
  319.         if Temp > 253 then IntroFrames=384
  320.         line Buff,(0,0)-(255,191),rgb(0,0,0),bf
  321.         put Buff,(0,0),Stars,(0,0)-(255,191),alpha,Temp
  322.         if len(Key) then IntroFrames=255
  323.       case 256 to 511    'Background Wait
  324.         put Buff,(0,0),Stars,(0,0)-(255,191),pset      
  325.         if len(Key) then IntroFrames=511
  326.       case 512 to 639    'Mysoft Logo IN
  327.         put Buff,(0,0),Stars,(0,0)-(255,191),pset
  328.         put Buff,(0,49),Back,(0,0)-(255,92),alpha,(IntroFrames-512) shl 1      
  329.         if len(Key) then IntroFrames=639
  330.       case 640 to 959    'Logo Wait
  331.         put Buff,(0,0),Stars,(0,0)-(255,191),pset
  332.         put Buff,(0,49),Back,(0,0)-(255,92),trans
  333.         if len(Key) then IntroFrames=959
  334.       case 960 to 1023   'Screen White IN
  335.         put Buff,(0,0),Stars,(0,0)-(255,191),trans
  336.         put Buff,(0,49),Back,(0,0)-(255,92),trans
  337.         put Buff,(0,0),White,(0,0)-(255,191),Alpha,(IntroFrames-960) shl 2
  338.         if len(Key) then IntroFrames=1023
  339.       case 1024 to 1279  'Menu Appearing
  340.         if IntroFrames = 1024 then
  341.           CreateStars()
  342.           FileName = "Title.bmp": printf FileName & !"\n"
  343.           bload FileName,Back
  344.           scope
  345.             dim as integer Fail
  346.             if NoSound=0 then
  347.               MusTheme = FSOUND_Sample_Load(FSOUND_FREE,"Music/104-Theme.wav",FSOUND_NORMAL or FSOUND_LOOP_OFF,0,0)
  348.               if MusTheme = 0 then Fail=1:print "Failed to load: " "Music/104-Theme.wav"    
  349.             end if
  350.             if Fail then Sleep          
  351.           end scope                
  352.         end if
  353.         if IntroFrames = 1136 then
  354.           if MusTheme then
  355.             FSOUND_Sample_SetDefaults(MusTheme,-1,255,128,-1)
  356.             MusChan(0) = FSOUND_PlaySound(FSOUND_FREE,MusTheme)
  357.           end if
  358.         end if
  359.         dim as integer OffX = -128+(sin(IntroFrames*(1/256)))*128
  360.         dim as integer OffY = -128+(cos(IntroFrames*(1/220)))*128
  361.         for Y as integer = OffY to 255 step 256
  362.           for X as integer = OffX to 255 step 256
  363.             put Buff,(X,Y),Stars,pset
  364.           next X
  365.         next Y
  366.         UpdateAliens()
  367.         dim as integer Temp = cos((IntroFrames-1024)*(PI*(90/256))+.5)*184
  368.         if Temp < 0 then Temp = 0      
  369.         put Buff,(8,8+Temp),Back,(0,0)-(239,38),trans      
  370.         put Buff,(0,0),White,(0,0)-(255,191),Alpha,(1279-IntroFrames)
  371.         if len(Key) then
  372.           if IntroFrames < 1136 then IntroFrames = 1135 else IntroFrames=1279
  373.         end if
  374.       case else          'Menu Controls
  375.         scope 'Menu Anim
  376.           if IntroFrames=1280 then        
  377.             #ifndef __FB_NDS__
  378.             line White,(0,0)-(255,191),rgb(0,0,0),bf
  379.             #endif
  380.             BlackFrame = 0
  381.           end if      
  382.           if ((IntroFrames-1136) and 511)=0 andalso MusTheme then
  383.             ChanNum xor= 1
  384.             FSOUND_Sample_SetDefaults(MusTheme,-1,180,128,-1)
  385.             MusChan(ChanNum) = FSOUND_PlaySound(FSOUND_FREE,MusTheme)        
  386.           end if
  387.           dim as integer OffX = -128+(sin(IntroFrames*(1/256)))*128
  388.           dim as integer OffY = -128+(cos(IntroFrames*(1/220)))*128
  389.           for Y as integer = OffY to 255 step 256
  390.             for X as integer = OffX to 255 step 256
  391.               put Buff,(X,Y),Stars,pset
  392.             next X
  393.           next Y
  394.           UpdateAliens()
  395.           put Buff,(8,8),Back,(0,0)-(239,38),trans            
  396.         end scope
  397.         scope 'Menu Draw
  398.           dim as string TempMenu = **pMenu
  399.           var X = (128-(len(TempMenu) shl 2))-MenuOffset
  400.           DrwTxt(X,75,TempMenu,rgb(0,255,0))
  401.           if iButDown = 1 and MenuChoose = 0 then
  402.             if iMX >= X and iMY >= 75 then
  403.               if iMY <= 82 and iMX <= X+(len(TempMenu) shl 3) then                
  404.                 if sndHit then
  405.                   FSOUND_Sample_SetDefaults(sndHit,-1,64,128,-1)
  406.                   FSOUND_PlaySound(FSOUND_FREE,sndHit)        
  407.                 end if
  408.                 MenuSelect = -1:MenuChoose = 1: MenuTarget = 256
  409.               end if
  410.             end if
  411.           end if
  412.          
  413.           for CNT as integer = 0 to MenuCount
  414.             dim as short X=90+MenuOffset,Y=100+CNT*15
  415.             dim as uinteger iColor = rgb(255,255,255)
  416.             if MenuSelect = CNT then
  417.               iColor = rgb(63,127,255): X += sin(IntroFrames/8)*4
  418.             end if
  419.             if abs(MenuOffset-MenuTarget) > .1 then
  420.               if CNT = 0 then
  421.                 dim as single NewOffset = ((MenuOffset*7)+MenuTarget)*(1/8)
  422.                 if abs(NewOffset-MenuOffset) < .1 then
  423.                   Menuoffset=MenuTarget
  424.                 else
  425.                   MenuOffset=NewOffset        
  426.                 end if
  427.               end if
  428.               Y += sin(MenuOffset/(32+CNT))*12
  429.             end if
  430.             dim as string sTemp = *(pMenu[CNT+1])
  431.             if MenuCount > 0 then
  432.               if iButDown = 1 and MenuChoose = 0 then
  433.                 if iMX >= X and iMY >= Y then
  434.                   if iMY <= Y+7 then
  435.                     if iMX <= X+(len(sTemp) shl 3) then
  436.                       if MenuSelect = CNT then
  437.                         if sndBounce then
  438.                           FSOUND_Sample_SetDefaults(sndBounce,-1,64,128,-1)
  439.                           FSOUND_PlaySound(FSOUND_FREE,sndBounce)        
  440.                         end if                    
  441.                         MenuChoose = 1: MenuTarget = 256                    
  442.                       else
  443.                         if sndBrick then
  444.                           FSOUND_Sample_SetDefaults(sndBrick,-1,64,128,-1)
  445.                           FSOUND_PlaySound(FSOUND_FREE,sndBrick)        
  446.                         end if
  447.                         MenuSelect = CNT
  448.                       end if                  
  449.                     end if
  450.                   end if
  451.                 end if
  452.               end if
  453.               DrwTxt(X,Y,sTemp,iColor)
  454.             else
  455.               X = 128+MenuOffset-((len(sTemp)+2) shl 2)
  456.               sTemp += CurColor((IntroFrames shr 2) and 7)              
  457.               DrwTxt(X,Y,sTemp,rgb(255,255,255))
  458.               if len(TextBuff2) then
  459.                 dim as integer iSz = len(TextBuff2)
  460.                 for CNT as integer = 0 to iSz-1
  461.                   if TextBuff2[CNT] = asc("#") then iSz -= 7
  462.                 next CNT
  463.                 X = 128+MenuOffset-(Isz shl 2)
  464.                 Y = 100+(CNT+2)*15
  465.                 DrwTxt(X,Y,TextBuff2,rgb(255,255,255))
  466.               end if
  467.             end if          
  468.           next CNT
  469.         end scope        
  470.         scope 'Menu Specials
  471.           select case pMenu
  472.           case @ContinueMenu(0)
  473.             if len(Key) then
  474.               dim as integer iKey
  475.               if len(Key)=1 then iKey = Key[0] else iKey = -Key[1]
  476.               select case iKey
  477.               case KeyBackSpace()
  478.                 if len(TextBuff) then
  479.                   TextBuff2 = ""
  480.                   if len(TextBuff) <> 5 then
  481.                     TextBuff = left(TextBuff,len(TextBuff)-1)
  482.                   else
  483.                     TextBuff = left(TextBuff,len(TextBuff)-2)
  484.                   end if
  485.                 end if
  486.               case asc("A") to asc("Z"), asc("0") to asc("9")
  487.                 if len(TextBuff) < 9 then TextBuff += Key
  488.                 if len(TextBuff) = 4 then TextBuff += "-"
  489.               case asc("a") to asc("z")
  490.                 Key[0] xor= 32
  491.                 if len(TextBuff) < 9 then TextBuff += Key
  492.                 if len(TextBuff) = 4 then TextBuff += "-"
  493.               end select
  494.               ContinueMenu(1) = strptr(TextBuff)
  495.               if len(TextBuff) = 9 then
  496.                 dim as integer iScore
  497.                 dim as short iDiff,iLevel,iLives                
  498.                 if ConvertPassword(iScore,iDiff,iLevel,iLives,TextBuff,1) then
  499.                   TextBuff2 = "#FF0000Invalid Code"
  500.                 else
  501.                   TextBuff2 = "#3FFF7FLevel " & iLevel & " - " & trim$(*NewGameMenu(iDiff+1))
  502.                 end if
  503.               end if
  504.             end if
  505.           end select
  506.         end scope        
  507.         scope 'Menu Controls
  508.           getmouse iNX,iNY,,iNB
  509.           #ifndef __FB_NDS__
  510.           if ScrRender=3 or ScrRender=5 then
  511.             iNX *= MouseAdjustX: iNY *= MouseAdjustY
  512.           end if
  513.           #endif
  514.           if iNB <> -1 then            
  515.             iMX = iNX shr ScrDouble
  516.             iMY = iNY shr ScrDouble
  517.             iMB = iNB
  518.           end if
  519.           if iButDown > 0 then iButDown = -1
  520.           if (iMB and 1) then            
  521.             if iButDown = 0 then iButDown = 1
  522.           else
  523.             iButDown = 0
  524.           end if
  525.          
  526.           if MenuChoose = 0 then          
  527.             if len(Key) then
  528.               select case Key[1]
  529.               case KeyUp()
  530.                 if sndBrick then
  531.                   FSOUND_Sample_SetDefaults(sndBrick,-1,64,128,-1)
  532.                   FSOUND_PlaySound(FSOUND_FREE,sndBrick)        
  533.                 end if
  534.                 if MenuSelect = 0 then MenuSelect=MenuCount else MenuSelect -= 1
  535.               case KeyDown()
  536.                 FSOUND_Sample_SetDefaults(sndBrick,-1,64,128,-1)
  537.                 FSOUND_PlaySound(FSOUND_FREE,sndBrick)        
  538.                 if MenuSelect = MenuCount then MenuSelect=0 else MenuSelect += 1
  539.               end select
  540.               if KeyChoose() then
  541.                 if sndBounce then
  542.                   FSOUND_Sample_SetDefaults(sndBounce,-1,64,128,-1)
  543.                   FSOUND_PlaySound(FSOUND_FREE,sndBounce)        
  544.                 end if
  545.                 MenuChoose = 1: MenuTarget = 256
  546.               elseif KeyBack() then
  547.                 if sndHit then
  548.                   FSOUND_Sample_SetDefaults(sndHit,-1,64,128,-1)
  549.                   FSOUND_PlaySound(FSOUND_FREE,sndHit)        
  550.                 end if
  551.                 MenuSelect = -1:MenuChoose = 1: MenuTarget = 256
  552.               end if
  553.             end if
  554.           end if
  555.         end scope        
  556.         scope 'Menu Selection
  557.           if BlackFrame then
  558.            
  559.             #ifdef __FB_NDS__          
  560.             if len(Key)=0 andalso fb.KeyboardIsON then
  561.               dim as integer CNT
  562.               for CNT=-255 to 255
  563.                 if multikey(CNT) then exit for
  564.               next CNT
  565.               if CNT>255 then
  566.                 fb.KeyboardIsON = 0    
  567.                 lcdMainOnBottom()
  568.               end if          
  569.             end if
  570.             #endif
  571.            
  572.             if (IntroFrames-BlackFrame) > 127 then
  573.               if MusTheme then
  574.                 if MusChan(0) then FSound_StopSound(MusChan(0))
  575.                 if MusChan(1) then FSound_StopSound(MusChan(1))
  576.                 FSOUND_Sample_Free(MusTheme)
  577.               end if
  578.               if MenuChoose = -2 then
  579.                 IntroFrames = 0: IntroMode = 1: continue do
  580.               elseif MenuChoose = -3 then
  581.                 IntroFrames = 0: IntroMode = 3: continue do
  582.               else              
  583.                 exit do
  584.               end if
  585.             end if
  586.             #ifdef __FB_NDS__
  587.             gfx.TextureColor = 0
  588.             put Buff,(0,0),White,(0,0)-(255,191),alpha,(IntroFrames-BlackFrame) shl 1
  589.             gfx.TextureColor = -1
  590.             #else
  591.             put Buff,(0,0),White,(0,0)-(255,191),alpha,(IntroFrames-BlackFrame) shl 1
  592.             #endif
  593.           else
  594.             if abs(MenuOffset-256) < .1 then            
  595.               select case pMenu
  596.               case @MainMenu(0)      '------ Main Menu ------
  597.                 select case MenuSelect
  598.                 case 0    'New Game
  599.                   pMenu = @NewGameMenu(0): MenuCount = 2: MenuSelect = 1
  600.                 case 1    'Continue
  601.                   pMenu = @ContinueMenu(0)
  602.                   TextBuff = sOldCode : MenuCount = 0: MenuSelect = 0
  603.                   ContinueMenu(1) = strptr(TextBuff)                   
  604.                   if len(TextBuff) = 9 then
  605.                     dim as integer iScore
  606.                     dim as short iDiff,iLevel,iLives                
  607.                     if ConvertPassword(iScore,iDiff,iLevel,iLives,TextBuff,1) then
  608.                       TextBuff2 = "#FF0000Invalid Code"
  609.                     else
  610.                       TextBuff2 = "#3FFF7FLevel " & iLevel & " - " & trim$(*NewGameMenu(iDiff+1))
  611.                     end if
  612.                   end if
  613.                   #ifdef __FB_NDS__
Add Comment
Please, Sign In to add comment