By Deano

## Writing your own selection menu In some Atari demos they have a main menu where you can select a sub menu to load. We can do the same thing in STOS. This routine below allows you to move a character up and down a scrolling platform which is a kind of hallway with doors. You move your character to the door, press fire and the routine loads up the demo behind that door. For Example, going to door 12 will load up demo 12 and so on. I can supply the source code with graphics to this routine if you write to me with a disk and return postage. 10 key off : hide on : curs off : flash off : mode 0 20 : 30 rem SET UP SCROLLING WINDOW SIZE AND VARIBLES 40 : 50 landscape 0,40,330,170,0,1 : MY=92 : Y=MY : XX=4 : XB=80 : YB=112 : IR=0 : IL=5 : M=2 : IMR=0 : IML=0 : J=0 : JUMP=0 : S4=start(4) : S5=start(5) : S6=start( 6) : dim DEMO$(12) 60 : 70 rem ENTER DEMO NAMES INTO ARRAY AND GET DOOR CO-ORDINATES 80 : 90 for D=1 to 12 : read DEMO$(D) : next D 100 A=block amount(S6,12) : dim DX(A+1),DY(A+1) : xy block S6,varptr(DX(1)),varptr(DY(1)),12,A 110 : 120 rem GET PALETTE OF WORLD BLOCKS AND SET LOGIC SCREEN TO BACK SCREEN 130 : 140 A=palt(S5) : logic=back 150 : 160 rem START OF LOOP 170 : 180 landscape logic,S5,S6,X,Y,0 190 : 200 rem CHECK TB (TOP OF SPRITE) AND BB (BOTTOM OF SPRITE) 210 : 220 TB=which block(S6,XB+8,Y+YB-40) : BB=which block(S6,XB+8,Y+YB-12) 230 : 240 rem CHECK IF SPRITE IS ON A WALKING BLOCK AND MOVE SCROLLING ABOUT 250 : 260 if TB=14 then JUMP=1 270 if BB<>14 and JUMP=1 and YB<112 then YB=YB+XX : goto 460 280 if BB<>14 and JUMP=1 then Y=Y+XX : goto 460 290 if BB=14 then JUMP=0 300 : 310 rem CHECK IF JOYSTICK PUSHED UP AND MOVE MAP OR SPRITE 320 : 330 if jup and Y>0 and TB<>14 and JUMP=0 then Y=Y-XX 340 if jup and Y=0 and TB<>14 and YB>30 and JUMP=0 then YB=YB-XX 350 : 360 rem CHECK IF SPRITE STILL IN AIR 370 : 380 J=joy : if BB<>14 and J=0 then JUMP=1 390 J=joy : if BB<>14 and J=4 then JUMP=1 400 J=joy : if BB<>14 and J=8 then JUMP=1 410 : 420 rem CHECK IF SPRITE OUTSIDE DOOR THEN GET THE DOOR NUMBER THEN PRINT NAME OF DEMO. IF FIRE PRESSED THEN GOTO LOADING DEMO ROUTINE 430 : 440 DB=which block(start(6),XB+8,Y+YB-24) : if DB=12 or DB=13 then gosub 690 else D00R=0 450 if D00R<>0 then locate 14,23 : print DEMO$(D00R) else locate 14,23 : print space$(20) 460 if fire and D00R<>0 then goto 750 470 : 480 rem CHECK FOR SPRITE MOVING LEFT AND ANIMATE IT 490 : 500 if jleft and XB>12 then XB=XB-XX : M=1 : inc IML : if IML=3 then inc IL : IML=0 : if IL=8 then IL=4 510 : 520 rem CHECK FOR SPRITE MOVING RIGHT AND ANIMATE IT 530 : 540 if jright and XB<284 then XB=XB+XX : M=2 : inc IMR : if IMR=3 then inc IR : IMR=0 : if IR=4 then IR=0 550 : 560 rem MAKE SURE CO-ORDINATES DON'T GO OVER THEIR LIMITS 570 : 580 if XB>284 then XB=284 : if XB<12 then XB=12 590 if Y>MY then Y=MY 600 : 610 rem PUT BOBS IN SCREEN FACING EITHER LEFT (M=1) OR RIGHT (M=2) 620 : 630 if M=1 then bob logic,S4,IL,XB,YB,0 640 if M=2 then bob logic,S4,IR,XB,YB,0 650 : 660 rem SWAP SCREEN AND GO BACK TO START OF LOOP 670 : 680 screen swap : wait vbl goto 180 690 : 700 rem THE DOOR CHECKING ROUTINE 710 : 720 for D=1 to 12 730 if XB>=DX(D) and XB<=DX(D)+32 and Y+YB>DY(D) then D00R=D 740 next D : return 750 : 760 rem THE DEMO LOADING ROUTINE 770 : 780 logic=physic : cls : F$="LOADING"+str$(D00R)+".PRG" : locate 0,7 : print F$ 790 : 800 rem THE DEMO NAMES 810 : 820 data "DEMO ONE","DEMO TWO","DEMO THREE","DEMO FOUR","DEMO FIVE","DEMO SIX","DEMO SEVEN","DEMO EIGHT","DEMO NINE","DEMO TEN","DEMO ELEVEN","DEMO TWELVE" The graphics are wall blocks that make up the hallway and there are some other blocks that make up the doors. There are four 16x16 blocks that make up the door and all we do is check for them colliding with the main character. A number is returned and we use that to discover which door number he is at.