Thanks to Julio Marchi for this space in MSX All
10The declaration "MAXFILES=2" is necessary for the OPEN #2 command to open the game records file, once the #1 is already used by the graphic mode writing.
The line 10 is executed once. From here, we call the sub-routine that reads the five game records from a file and store the data in two arrays.
2100 ' Le recordes do arquivo 2110 OPEN"balao.dat"FOR INPUT AS #2 2120 DIM HI(5) : DIM NO$(5) 2130 FOR I=1 TO 5 2140 INPUT #2, NO$(I) 2150 INPUT #2, A$: HI(I)=VAL(A$) 2160 NEXT 2170 CLOSE 2Line 15 was introduced to allow the game return to the main menu after game over.
The variable DR is used as a flag to indicate if the current screen has already been drawn on page 1.
The MSX screen mode is changed to 5, which introduces remarkable changes from screen 2.
40 RESTORE:A$="":FORF=0TO7:READD$:A$=A$+CHR$(VAL("&B"+D$)):NEXTF:SPRITE$(0)=A$Line 45 creates a color pattern for each sprite line (sprites mode 2). The CHR$(n) value indicates the color of the line.
The balloon was enlarged.
Sub-routines for drawing the screens
130 ' ** TELA ** 140 TIME=0Line 144 hides the balloon while the screen is drawn.
If the current screen has already been created, only copies it from page 1 to 0 (jumps to the line 185). Else, clear page 0 and writes a message "Tela n" while the screen is being drawing in background, on page 1.
The command SET PAGE 0,1 sets the visible page to 0 and the use page to 1 (where all the actions are directed to).
Once the screen drawing is over, the page copy sub-routine is called (GOSUB 2000).
2000 ' Animacao de entrada da tela 2010 FOR Y1=0 TO 7:FOR Y2=0 TO 211 STEP 8 2020 COPY(0,Y1+Y2)-(255,Y1+Y2),1 TO (0,Y1+Y2),0 2030 NEXT Y2,Y1 2040 RETURN
General changes on screen sub-routines
The scenario background color was changed to blue on all screens.
First, the interest area is delimited. Then, we paint the screen with blue 7, restricted to the red 6 color.
LINE(10,10)-(240,180),6,B:PAINT(15,175),7,6On screen 1, we close the obstacle polygon. This allow us to paint the object inside.
Besides painting each obstacle from inside, we painted the area that the obstacles will be drawn with a filled rectangle using the desired color. So, when painting the screen with blue color, the closed polygons will not be affected, but only the scenario.
The initial balloon coordinates where removed from the screens sub-routines and placed on a new sub-routine together.
2050 ' Define coordenadas iniciais do balao 2060 IF S=1 THEN X=150:Y=130:RETURN 2070 IF S=2 THEN X=220:Y=160:RETURN 2080 IF S=3 THEN X=15:Y=150:RETURN 2090 IF S=4 THEN X=200:Y=160:RETURN 2095 RETURN
200 ' ** LOOP PRINCIPAL ** 210 ST=STICK(Q):IFST=0THEN250 220 IFST=1THENY=Y-1:GOTO 260Two new movements were introduced: up-right and up-left.
330 LI=LI-1 340 PLAY"O4L5CCCD#DDCCCC"When the balloon hits, the blue background is replaced by a palette effect, which ranges from dark-red to light-red and vice-versa.
Now the score is based on a time of 2 minutes instead of 30 seconds.
1300 COLOR1:CLSChanges: all options on screen, accepts low case letters and ranking option (letter D).
Writing the best 5 scores sub-routine :
2200 ' Imprime recordes 2210 SCREEN 0:COLOR1,15,15 2220 PRINT"Recordes:":PRINT 2230 FOR I=1 TO 5 2240 PRINT I;"- ";NO$(I); 2250 LOCATE 15 : PRINT HI(I) 2260 NEXT 2270 PRINT:PRINT"Tecle algo ...":A$=INPUT$(1) 2280 RETURN
Display all four screens
The end of the game
This sub-routine was converted to screen 5, adding a new sub-routine to capture the player's name, if the player scores better than one of the top 5 records.
It is expected from the keyboard: letters, space, backspace or enter.
After filling the name, a sub-routine is called to place the current score on the records list (GOSUB 2300).
Insert on records list sub-routine:
2300 ' Adiciona novo recorde e grava 2310 I=1 2320 IF SC<=HI(I) AND I<6 THEN I=I+1 : GOTO 2320 2330 IF I=6 THEN RETURN 2340 FOR F=4 TO I STEP -1 2350 NO$(F+1) = NO$(F) : HI(F+1)=HI(F) 2360 NEXT F 2370 NO$(I)=NM$ : HI(I)=SC 2380 OPEN"balao.dat"FOR OUTPUT AS#2 2390 FOR I=1 TO 5 : PRINT#2, NO$(I)+","+STR$(HI(I)) : NEXT 2395 CLOSE2:RETURNInstead of only one record, now there are five. To get here, the player must score at least more than the 5th place on the records list.
Once the list is modified, the file is updated.
Systems and Computing Engineer
Expert in Image Processing and Artificial Intelligence
© MarMSX 1999-2021