2015年8月3日月曜日

サンプル;PushBon

ゲームPushBonです。

progloaderで「PushBon」をダウンロードすると、
 PushBon.bas
と必要データファイルが追加されます。



オリジナルは Oh!X 1989-11掲載のS-OS TTI(TinyTinyInterpreter)用です。
以下のリストはオリジナルのもの。動作確認はしてないので打ち込み間違いがあるかも。
これとX-BASIC版を見比べると、構造化の効果がわかるかも。

;
; PUSH BON  FOR TTI
;
;
  'C' WIDCH 40

;MAIN ROUTINE
   .R=0
9
   GOSUB 975 .G=5  GOSUB 980
      GOSUB 965  GOSUB 970
10
   LOCATE  25,15 "PUSH ANY KEY!!"
     LOCATE  25,15 "               "
    IF (G=0,10
11
     .T=0 .X=0 .Y=0 .D=0 .S=0
      GOSUB 980  BELL 1
12
     .B=0 GOSUB 900 GOSUB 953 GOSUB 993
     .B=6 GOSUB 953
13
     .K=(G IF K=0,13
       IF K='4,455
       IF K='6,456
       IF K='8,458
       IF K='2,457
       IF K='G,20
       IF K#' ,13
       GOSUB 300 INC S
       .A=0 ADC A IF A#0,20
       GOSUB 899
       GOSUB 250 IF O#0,23
       GOSUB 255 IF O#0,23
14
      GOSUB 1000
    GOTO 13

;GIVE UP!!!
20
   LOCATE 6,11 "             "
   LOCATE 6,12 "  GIVE UP!!  "
   LOCATE 6,13 "             "
     DEC  G GOSUB 980 BELL 2
25
     GOSUB 990 IF G=0,21
    GOSUB 965 GOSUB 970
   GOTO 11

;GAME OVER
21
   LOCATE 6,11 "* * * * * * *"
   LOCATE 6,12 " *GAME OVER* "
   LOCATE 6,13 "* * * * * * *"
   BELL 3
22
    IF (G#' ,22
   .R=0 GOTO 9

;ROUND CLEAR
23
   LOCATE 6,11 "* * * * * * *"
   LOCATE 6,12 " ROUND CLEAR "
   LOCATE 6,13 "* * * * * * *"
   BELL 3
24
    IF (G#' ,24
    INC R IF R<10,25
    .R=0 GOTO 25

;* BLOCK YOKO CHECK
250
   .H=$9F .I=00  .O=00
   .A=7 REPEAT
     .C=5 REPEAT
       WIND2 H,I .J=]
       @IF J=4 PUSH I PUSH H GOSUB 251 POP H POP I
      DEC C .I=I+1 ADC H
      UNTIL C=0
     .I=I+2 ADC H DEC A
     UNTIL A=0
    RETURN

251
   .L=2
252
    .I=I+1 ADC H WIND2 H,I
      .J=] IF J#4,254
       DEC  L IF L#0,252
      .O=10
254
      RETURN

;* BLOCK TATE CHECK
255
   .H=$9F .I=00  .O=00
   .A=7 REPEAT  PUSH H PUSH I
     .C=5 REPEAT
       WIND2 H,I .J=]
       @IF J=4 PUSH I PUSH H GOSUB 256 POP H POP I
      DEC C .I=I+7 ADC H
      UNTIL C=0
      POP I POP H
     .I=I+1 ADC H DEC A
      UNTIL A=0
    RETURN

256
   .L=2
257
    .I=I+7 ADC H WIND2 H,I
      .J=] IF J#4,258
      DEC  L IF L#0,257
     .O=10
258
     RETURN

;BLOCK PUSH
300
   .T=0
    PUSH X PUSH Y PUSH D
      @GOSUB D*5+150
    POP  D POP  Y POP  X
    BELL 1
   RETURN

;BLOCK UP PUSH
150
  @IF Y<2 RETURN
    DEC Y GOSUB 952 .J=B
    @IF J=5 RETURN
    @IF J=0 DEC S RETURN
151
    .Q=Y DEC Y  IF Q<1,352
      GOSUB 952 IF B#0,162
      GOSUB 390
    GOTO 151
352
    .Y=Q .B=J GOSUB 953
   RETURN

;BLOCK RIGHT PUSH
155
  @IF X>4 GOSUB 952 .J=B
   INC X GOSUB 952 .J=B
   @IF J=5 RETURN
   @IF J=0 DEC S RETURN
156
    .P=X INC X IF X>6,357
      GOSUB 952 IF B#0,167
      GOSUB 391
      GOTO 156
357
    .X=P .B=J GOSUB 953
   RETURN

;BLOCK DOWN PUSH
160
  @IF Y>4 RETURN
    INC Y GOSUB 952 .J=B
    @IF J=5 RETURN
    @IF J=0 DEC S RETURN
161
    .Q=Y INC Y IF Y>6,352
      GOSUB 952 IF B#0,162
      GOSUB 390
    GOTO 161
162
    .W=Y .V=X .U=B .Y=Q .B=J
   GOSUB 953 GOTO 370

;BLOCK LEFT PUSH
165
  @IF X<2 RETURN
    DEC X GOSUB 952 .J=B
    @IF J=5 RETURN
    @IF J=0 DEC S RETURN
166
    .P=X DEC X IF P<1,357
    GOSUB 952 IF B#0,167
    GOSUB 391
    GOTO 166
167
    .W=Y .V=X .U=B .X=P .B=J
   GOSUB 953 GOTO 370

;BLOCK WO HAJIKU
370
   @IF T>10 .T=0 RETURN
    INC T
    @IF U>4 RETURN
     IF J=2,371
     IF J=3,376
   IF U=2,374
   IF U=3,377
   RETURN

;LEFT BLOCK
371
   GOSUB 385
372
     .J=U .X=V .Y=W
    @GOTO D*5+151
374
   GOSUB  385 @GOTO D*5+151

;RIGHT BLOCK
376
    GOSUB 386 GOTO 372
377
    GOSUB 386 @GOTO D*5+151

;DIR LEFT TURN
385
   DEC D @IF D>121 .D=3
   RETURN

;DIR RIGHT TURN
386
   INC D @IF D=4 .D=0
   RETURN

;BLOCK ERASE MOVE
390
    PUSH Y .B=0 .Y=Q GOSUB 900 .B=0 GOSUB 953
      POP  Y .B=J GOSUB 900
    RETURN
391
    PUSH X .B=0 .X=P GOSUB 900 .B=0 GOSUB 953
      POP  X .B=J GOSUB 900
    RETURN

;CURSOR LEFT
455
   .D=3  IF X=0,12
     PUSH X .X=X-1 GOSUB 952
      @IF B#0 POP X GOTO 12
454
      .Q=X POP X  .B=0
         GOSUB 900 .B=0 GOSUB 953
       .X=Q GOSUB 993 .B=6 GOSUB 953
      GOTO 14

;CURSOR RIGHT
456
   .D=1  IF X=6,12
     PUSH X .X=X+1 GOSUB 952
      IF B=0,454
     POP X
   GOTO 12

;CURSOR DOWN
457
   .D=2  IF Y=6,12
     PUSH Y .Y=Y+1 GOSUB 952
      @IF B#0 POP Y GOTO 12
453
      .Q=Y POP Y  .B=0
       GOSUB 900 .B=0 GOSUB 953
     .Y=Q GOSUB 993 .B=6 GOSUB 953
    GOTO 14

;CURSOR UP
458
  .D=0  IF Y=0,12
     PUSH Y .Y=Y-1 GOSUB 952
      IF B=0,453
     POP  Y
   GOTO 12

;BLOCK PRINT
900
   .A=X*3+2 .C=Y*3+2 LOCATE A,C
    @IF B>5 .B=0
    IF B#5,902
       "."     CHR $7B "."     'DLLL'
       CHR $7B CHR $7B CHR $7B 'DLLL'
       "."     CHR $7B "."
    RETURN
902
    IF B#0,901
       "   " 'DLLL' "   " 'DLLL' "   "
       RETURN
901
    "+-+" 'DLLL' "I I" 'DLLL' "+-+"
        LOCATE A+1,C+1
        @GOTO  B+59
   RETURN
60
   " " RETURN
61
   "L" RETURN
62
   "R" RETURN
63
   "*" RETURN

;KVRAM ADDRESS
950
    .A=$9F .C=00 .F=Y
      .C=C+X ADC A
        IF F=0,951
        REPEAT
           .C=C+7 ADC A
           DEC F
        UNTIL F=0
951
    WIND2 A,C
   RETURN

;KVRAM READ
952
    GOSUB 950 .B=] RETURN

;KVRAM WRITE
953
    GOSUB 950 .]=B RETURN

;MEN ADDRESS
960
    .H=$A0 .I=00  IF R=0,961
     .D=R
      REPEAT
         .I=I+49 ADC H
         DEC D
      UNTIL D=0
961
   RETURN

;MEN TENSOU  READ
965
   GOSUB  960  .A=$9F .C=00
     .F=50 REPEAT
       WIND2 H,I .B=]
       WIND2 A,C .]=B
       .I=I+1 ADC H .C=C+1 ADC A
       DEC F
     UNTIL F=0
   RETURN

;MEN PRINT
970
     .Y=0  REPEAT
      .X=0  REPEAT
        GOSUB  950 .B=]
        GOSUB  900
        INC X   UNTIL X=7
      INC Y   UNTIL Y=7
   RETURN

;WAKU PRINT
975
   LOCATE 1,1  .A=23
     REPEAT  "*" DEC A
      UNTIL A=0
       .Y=2 REPEAT
        LOCATE  1,Y "*" DEC A
        .A=21 REPEAT " " DEC A
        UNTIL A=0  "*"
        INC Y UNTIL Y=23
       LOCATE 1,23  .A=23
      REPEAT "*" DEC  A
     UNTIL A=0
   RETURN

;SCREEN PRINT
980
   GOSUB 990
   GOSUB 899
   GOSUB 992
   GOSUB 991
RETURN

;TITLE PRINT
990
   LOCATE 25,2 " @@  @@@  @@ "
   LOCATE 25,3 "@           @"
   LOCATE 25,4 "@ PUSH BON! @"
   LOCATE 25,5 "@           @"
   LOCATE 25,6 " @@  @@@  @@ "
   LOCATE 25,21 "FOR TTI"
   LOCATE 27,23 "BY J.YAMADA"
   RETURN

;STEP PRINT
899
   LOCATE 26,8  "STEP  " PRT1 S
   RETURN

;ROUNT PRINT
991
   LOCATE 26,12 "ROUND " PRT1 R
   RETURN

;LIFE PRINT
992
   LOCATE 26,10 "LIFE  " PRT1 G
   RETURN

;DIRECTION PRINT
993
   LOCATE X*3+2,Y*3+2
    @GOSUB 50+D
   RETURN
50
   'R' "^" 'DL' "I" 'DL' "V"
   RETURN
51
   'D' "-->" RETURN
52
   'R' "I" 'DL' "I" 'DL' "V"
   RETURN
53
   'D' "<--" RETURN

;WAIT
1000
   .W=100 REPEAT .W=W-1 UNTIL W=0
   RETURN
END

0 件のコメント:

コメントを投稿