### First post, by Peter Swinkels

Hi,

I converted a Quick Basic program to work in GWBasic. At an emulated speed of 66 Mhz my program runs at an acceptable speed in Quick Basic, in GWBasic however it runs very slugglishly. It having been long a while ago I ever played with GWBasic can't figure out where exactly the problem might be. Yes, the interpreter is probably a bit slower, but that doesn't tell me what exactly is causing the massive slow down.

`10 DEFINT A-Z: GOSUB 900: END`

`20 FULLROW = 0`

`30 FOR PITY = 0 TO 15`

`40 FULLROW = -1`

`50 FOR PITX = 0 TO 9`

`60 IF MID$(PIT$, ((10 * PITY) + PITX) + 1, 1) = "0" THEN FULLROW = 0: GOTO 80`

`70 NEXT PITX`

`80 IF FULLROW THEN REMOVEDROW = PITY: GOSUB 1100`

`90 NEXT PITY`

`100 RETURN`

`110 DROPRATE! = 1`

`120 SHAPE = INT(RND * 6)`

`130 SHAPEANGLE = INT(RND * 4)`

`140 NEWANGLE = SHAPEANGLE`

`150 GOSUB 510`

`160 SHAPEMAP$ = ROTATEDMAP$`

`170 GOSUB 450`

`180 SHAPEX = RANDOMSHAPEX`

`190 SHAPEY = -4`

`200 RETURN`

`210 COLOR 4: LOCATE 3, 2`

`220 IF GAMEOVER THEN PRINT "Game over.": LOCATE , 2: PRINT "Press Enter to play a new game."; ELSE PRINT ; "Score:" + STR$(SCORE);`

`230 RETURN`

`240 LINE (116, 32)-STEP(92, 145), 15, B`

`250 LINE (116, 32)-STEP(92, 0), 0`

`260 FOR PITY = 0 TO 15`

`270 FOR PITX = 0 TO 9`

`280 IF GAMEOVER THEN BLOCKCOLOR$ = "4" ELSE BLOCKCOLOR$ = MID$(PIT$, ((10 * PITY) + PITX) + 1, 1)`

`290 DRAWX = PITX: DRAWY = PITY: GOSUB 320`

`300 NEXT PITX: NEXT PITY`

`310 RETURN`

`320 DRAWX = DRAWX * 9: DRAWY = DRAWY * 9`

`330 LINE (DRAWX + 117, DRAWY + 32)-STEP(9, 9), VAL("&H" + BLOCKCOLOR$), BF`

`340 LINE (DRAWX + 118, DRAWY + 33)-STEP(6, 6), 0, B`

`350 RETURN`

`360 FOR BLOCKX = 0 TO 3`

`370 FOR BLOCKY = 0 TO 3`

`380 PITX = SHAPEX + BLOCKX: PITY = SHAPEY + BLOCKY`

`390 IF PITX >= 0 AND PITX < 10 AND PITY >= 0 AND PITY < 16 THEN GOSUB 420`

`400 NEXT BLOCKY: NEXT BLOCKX`

`410 RETURN`

`420 IF ERASESHAPE THEN BLOCKCOLOR$ = MID$(PIT$, ((10 * PITY) + PITX) + 1, 1) ELSE BLOCKCOLOR$ = MID$(SHAPEMAP$, ((4 * BLOCKY) + BLOCKX) + 1, 1): IF BLOCKCOLOR$ = "0" THEN BLOCKCOLOR$ = MID$(PIT$, ((10 * PITY) + PITX) + 1, 1)`

`430 DRAWX = PITX: DRAWY = PITY: GOSUB 320`

`440 RETURN`

`450 INTENDEDSHAPEX = INT((RND * 10) - 1): RANDOMSHAPEX = 0`

`460 FOR XMOVE = 0 TO INTENDEDSHAPEX`

`470 MOVEDMAP$ = SHAPEMAP$: XDIRECTION = 1: YDIRECTION = 0: GOSUB 620`

`480 IF CANMOVE THEN RANDOMSHAPEX = RANDOMSHAPEX + 1 ELSE RETURN`

`490 NEXT XMOVE`

`500 RETURN`

`510 GOSUB 720`

`520 IF NEWANGLE = 0 THEN ROTATEDMAP$ = MAP$: RETURN`

`530 ROTATEDMAP$ = STRING$(4 * 4, "0")`

`540 FOR BLOCKX = 0 TO 3`

`550 FOR BLOCKY = 0 TO 3`

`560 IF NEWANGLE = 1 THEN NEWBLOCKX = 3 - BLOCKY: NEWBLOCKY = BLOCKX`

`570 IF NEWANGLE = 2 THEN NEWBLOCKX = 3 - BLOCKX: NEWBLOCKY = 3 - BLOCKY`

`580 IF NEWANGLE = 3 THEN NEWBLOCKX = BLOCKY: NEWBLOCKY = 3 - BLOCKX`

`590 MID$(ROTATEDMAP$, ((4 * NEWBLOCKY) + NEWBLOCKX) + 1, 1) = MID$(MAP$, ((4 * BLOCKY) + BLOCKX) + 1, 1)`

`600 NEXT BLOCKY: NEXT BLOCKX`

`610 RETURN`

`620 CANMOVE = -1`

`630 FOR BLOCKY = 0 TO 3`

`640 FOR BLOCKX = 0 TO 3`

`650 IF NOT MID$(MOVEDMAP$, ((4 * BLOCKY) + BLOCKX) + 1, 1) = "0" THEN GOSUB 680`

`660 NEXT BLOCKX: NEXT BLOCKY`

`670 RETURN`

`680 PITX = (SHAPEX + BLOCKX) + XDIRECTION: PITY = (SHAPEY + BLOCKY) + YDIRECTION`

`690 IF PITX >= 0 AND PITX < 10 AND PITY >= 0 AND PITY < 16 THEN IF NOT MID$(PIT$, (((10 * PITY) + PITX) + 1), 1) = "0" THEN CANMOVE = 0: RETURN`

`700 IF PITX < 0 OR PITX >= 10 OR PITY >= 16 THEN CANMOVE = 0: RETURN`

`710 RETURN`

`720 MAP$ = ""`

`730 IF SHAPE = 0 THEN MAP$ = "0000333300000000"`

`740 IF SHAPE = 1 THEN MAP$ = "0000111000100000"`

`750 IF SHAPE = 2 THEN MAP$ = "0000666060000000"`

`760 IF SHAPE = 3 THEN MAP$ = "00000EE00EE00000"`

`770 IF SHAPE = 4 THEN MAP$ = "0000022022000000"`

`780 IF SHAPE = 5 THEN MAP$ = "0000555005000000"`

`790 IF SHAPE = 7 THEN MAP$ = "0000440004400000"`

`800 RETURN`

`810 RANDOMIZE TIMER: KEY OFF: PLAY "ML L64": SCREEN 7: CLS : COLOR 9`

`820 LOCATE 1, 1: PRINT "GWBlocks v1.00": PRINT "By: Peter Swinkels, ***2021***";`

`830 GOSUB 110`

`840 GAMEOVER = 0`

`850 PIT$ = STRING$(10 * 16, "0")`

`860 SCORE = 0`

`870 GOSUB 240`

`880 GOSUB 210`

`890 RETURN`

`900 GOSUB 810`

`910 STARTTIME! = TIMER`

`920 WHILE NOT KEYV$ = CHR$(27)`

`930 KEYV$ = ""`

`940 WHILE KEYV$ = ""`

`950 IF (NOT GAMEOVER) AND (TIMER >= STARTTIME! + DROPRATE! OR STARTTIME! > TIMER) THEN GOSUB 1290: STARTTIME! = TIMER`

`960 KEYV$ = INKEY$`

`970 WEND`

`980 ERASESHAPE = -1: GOSUB 360`

`990 IF KEYV$ = CHR$(27) THEN SCREEN 0: END`

`1000 IF GAMEOVER AND KEYV$ = CHR$(13) THEN GOSUB 810`

`1010 IF (NOT GAMEOVER) AND (KEYV$ = "A" OR KEYV$ = "a") THEN GOSUB 1170`

`1020 IF (NOT GAMEOVER) AND (KEYV$ = CHR$(0) + "K") THEN MOVEDMAP$ = SHAPEMAP$: XDIRECTION = -1: YDIRECTION = 0: GOSUB 620`

`1030 IF (NOT GAMEOVER) AND (KEYV$ = CHR$(0) + "M") THEN MOVEDMAP$ = SHAPEMAP$: XDIRECTION = 1: YDIRECTION = 0: GOSUB 620`

`1040 IF (NOT GAMEOVER) AND (KEYV$ = CHR$(0) + "K" AND CANMOVE) THEN SHAPEX = SHAPEX - 1`

`1050 IF (NOT GAMEOVER) AND (KEYV$ = CHR$(0) + "M" AND CANMOVE) THEN SHAPEX = SHAPEX + 1`

`1060 IF (NOT GAMEOVER) AND (KEYV$ = " ") THEN DROPRATE! = 0`

`1070 ERASESHAPE = 0: GOSUB 360`

`1080 WEND`

`1090 RETURN`

`1100 FOR PITROWY = REMOVEDROW TO 0 STEP -1`

`1110 FOR PITX = 0 TO 10 - 1`

`1120 IF PITROWY = 0 THEN BLOCKCOLOR$ = "0" ELSE BLOCKCOLOR$ = MID$(PIT$, ((10 * (PITROWY - 1)) + PITX) + 1, 1)`

`1130 MID$(PIT$, ((10 * PITROWY) + PITX) + 1, 1) = BLOCKCOLOR$`

`1140 NEXT PITX: NEXT PITROWY`

`1150 SCORE = SCORE + 1`

`1160 RETURN`

`1170 IF SHAPEANGLE = 3 THEN NEWANGLE = 0 ELSE NEWANGLE = SHAPEANGLE + 1`

`1180 GOSUB 510`

`1190 MOVEDMAP$ = ROTATEDMAP$: XDIRECTION = 0: YDIRECTION = 0: GOSUB 620`

`1200 IF CANMOVE THEN SHAPEANGLE = NEWANGLE: SHAPEMAP$ = ROTATEDMAP$`

`1210 RETURN`

`1220 PLAY "N21"`

`1230 FOR BLOCKY = 0 TO 3`

`1240 FOR BLOCKX = 0 TO 3`

`1250 PITX = SHAPEX + BLOCKX: PITY = SHAPEY + BLOCKY`

`1260 IF (PITX >= 0 AND PITX < 10 AND PITY >= 0 AND PITY < 16) AND (NOT MID$(SHAPEMAP$, ((4 * BLOCKY) + BLOCKX) + 1, 1) = "0") THEN MID$(PIT$, ((10 * PITY) + PITX) + 1, 1) = MID$(SHAPEMAP$, ((4 * BLOCKY) + BLOCKX) + 1, 1)`

`1270 NEXT BLOCKX: NEXT BLOCKY`

`1280 RETURN`

`1290 MOVEDMAP$ = SHAPEMAP$: XDIRECTION = 0: YDIRECTION = 1: GOSUB 620`

`1300 IF CANMOVE THEN GOSUB 1320 ELSE GOSUB 1360`

`1310 RETURN`

`1320 ERASESHAPE = -1: GOSUB 360`

`1330 IF DROPRATE! > 0 THEN SOUND 37, .3`

`1340 SHAPEY = SHAPEY + 1: ERASESHAPE = 0: GOSUB 360`

`1350 RETURN`

`1360 GOSUB 1220`

`1370 GAMEOVER = (SHAPEY < 0)`

`1380 GOSUB 20`

`1390 GOSUB 240`

`1400 GOSUB 210`

`1410 IF NOT GAMEOVER THEN GOSUB 110: ERASESHAPE = 0: GOSUB 360`

`1420 RETURN`

I am using Quick Basic 4.5 as an editor and am trying to get to run the above smoothly in GWBasic 2.23. Does anyone have any idea here?