我20多年前第一门语言Basic和quick basic 4.5做的五子棋

      今天是9012年9月,人已到中年,我怎么突然找到这个很有记念意义的DOS下的五子棋和Quick Basic源程序,当年用到了DOS下的鼠标中断调用,用到了读取16点和24点阵字库,记念一下我逝去的青春 ,现在自已也看不明白当年怎么写的,注释都没有,满处是跳转。

源代码:

TYPE RegType
     ax    AS INTEGER
     bx    AS INTEGER
     cx    AS INTEGER
     dx    AS INTEGER
     bp    AS INTEGER
     si    AS INTEGER
     di    AS INTEGER
     flags AS INTEGER
END TYPE
DIM SHARED r AS RegType
DECLARE SUB INTERRUPT
DIM whitex(1000), whitey(1000), blackx(1000), blacky(1000)
SCREEN 12
HZK24$ = "HZK24K"
HZK16$ = "HZK16"
POSIT$ = "LONG"
IX1 = 200: IX2 = 110: IX3 = 480: IX4 = 200: MODE$ = "BOXON"
GOSUB VRBOX
SPACE = 32: XTMP = 270: YTMP = 130: FCOLOR = 15
T$(0) = "五子棋"
GOSUB DISPLAY24
XTMP = 269: YTMP = 129: FCOLOR = 8
GOSUB DISPLAY24
IX1 = 230: IX2 = 160: IX3 = 445: IX4 = 160: MODE$ = "BOXON"
GOSUB VRBOX
SPACE = 0: XTMP = 225: YTMP = 170: FCOLOR = 1
T$(0) = "版本为1.0主程序设计人王涛"
GOSUB DISPLAY16
LOCATE 14, 23: PRINT "Designed & Editor by Realwind_software 1998.6"
SLEEP 5
TOP:
ERASE whitex, whitey, blackx, blacky
WINNER = 0: W = 0: V = 0
CLS
PALETTE 0, 40 * 65536 + 40 * 256 + 40
PALETTE 8, 0: PALETTE 6, 0
FOR i = 30 TO 430 STEP 25
LINE (i, 30)-(i, 430), 8
LINE (30, i)-(430, i), 8
LINE (i - 1, 30)-(i - 1, 430), 8
LINE (30, i - 1)-(430, i - 1), 8
NEXT
IX1 = 10: IX2 = 10: IX3 = 450: IX4 = 450: MODE$ = "BOXON_EMP"
GOSUB VRBOX
IX1 = 460: IX2 = 25: IX3 = 600: IX4 = 55: MODE$ = "BOXON"
GOSUB VRBOX
IX1 = 455: IX2 = 10: IX3 = 620: IX4 = 450: MODE$ = "BOXON_EMP"
GOSUB VRBOX
SPACE = 16: XTMP = 480: YTMP = 30: FCOLOR = 1
T$(0) = "五子棋"
GOSUB DISPLAY24
SPACE = 25: XTMP = 460: YTMP = 60: FCOLOR = 15
T$(0) = "王涛设计"
GOSUB DISPLAY16
SPACE = 25: XTMP = 461: YTMP = 61: FCOLOR = 8
GOSUB DISPLAY16
RANDOMIZE TIMER
SPACE = 0: FCOLOR = 9
IF CINT(RND) + 1 = 1 THEN
    FLAG = 1: XTMP = 520: YTMP = 150
    T$(0) = "白方先走."
    GOSUB DISPLAY16
    GOSUB white
  ELSE
    FLAG = 0: XTMP = 520: YTMP = 100
    T$(0) = "黑方先走."
    GOSUB DISPLAY16
    GOSUB BLACK
END IF
XTMP = 461: YTMP = 100: FCOLOR = 1
T$(0) = "黑方:"
GOSUB DISPLAY16
XTMP = 461: YTMP = 150: FCOLOR = 1
T$(0) = "白方:"
GOSUB DISPLAY16
LOCATE 12, 58: PRINT W
LOCATE 9, 58: PRINT V
XTMP = 20: YTMP = 455: FCOLOR = 1
T$(0) = "F1帮助信息"
GOSUB DISPLAY16
XTMP = 140: YTMP = 455
T$(0) = "F2记录走法"
GOSUB DISPLAY16
XTMP = 260: YTMP = 455
T$(0) = "F3读取走法"
GOSUB DISPLAY16
XTMP = 380: YTMP = 455
T$(0) = "F4复盘"
GOSUB DISPLAY16
IF Rp = 1 THEN RETURN
r.ax = 1: INTERRUPT 51, r, r: r.ax = 3
DO
N$ = INKEY$
INTERRUPT 51, r, r
IF r.bx = 1 AND FLAG = 0 THEN
    r.ax = 2
    INTERRUPT 51, r, r
    FLAG = 1
    GOSUB CHECK
END IF
IF r.bx = 2 AND FLAG = 1 THEN
    r.ax = 2
    INTERRUPT 51, r, r
    FLAG = 0
    GOSUB CHECK
END IF
r.ax = 1
INTERRUPT 51, r, r
r.ax = 3
IF N$ = CHR$(0) + ";" THEN GOSUB F1
IF N$ = CHR$(0) + "<" THEN GOSUB F2
IF N$ = CHR$(0) + "=" THEN GOSUB F3
IF N$ = CHR$(0) + ">" THEN
    ERASE whitex, whitey, blackx, blacky
    WINNER = 0: Rp = 0
    GOTO TOP
END IF
MAIN:
LOOP WHILE N$ <> CHR$(27)
SCREEN 0
PRINT "Realwind_software by 1998.6 Programmer WANGTAO !"
END
CHECK:
IF r.cx >= 25 AND r.cx <= 445 AND r.dx >= 25 AND r.dx <= 445 THEN
Txtmp = r.cx \ 25
tx = 25 * Txtmp + 5
Tytmp = r.dx \ 25
ty = 25 * Tytmp + 5
FOR M = 0 TO 1000
IF Txtmp = whitex(M) AND Tytmp = whitey(M) THEN
    SPACE = 0: XTMP = 455: YTMP = 200: FCOLOR = 1
    T$(0) = "不能把棋子放在这儿."
    GOSUB DISPLAY16
    FLAG = ABS(FLAG - 1): r.bx = 0: RETURN
END IF
IF Txtmp = blackx(M) AND Tytmp = blacky(M) THEN
    SPACE = 0: XTMP = 455: YTMP = 200: FCOLOR = 1
    T$(0) = "不能把棋子放在这儿."
    GOSUB DISPLAY16
    FLAG = ABS(FLAG - 1): r.bx = 0: RETURN
END IF
NEXT
Check1:
IF FLAG = 0 THEN
GOSUB white: whitex(W) = tx \ 25: whitey(W) = ty \ 25: W = W + 1
END IF
IF FLAG = 1 THEN
GOSUB BLACK: blackx(V) = tx \ 25: blacky(V) = ty \ 25: V = V + 1
END IF
IF FLAG = 0 THEN
CIRCLE (tx, ty), 10, 15: PAINT (tx, ty), 15: CIRCLE (tx, ty), 5, 7, , .8
END IF
IF FLAG = 1 THEN
CIRCLE (tx, ty), 10, 6: PAINT (tx, ty), 6: CIRCLE (tx, ty), 5, 7, , .8
END IF
LINE (455, 200)-(615, 216), 0, BF
IF FLAG = 0 THEN COLOR 1: LOCATE 12, 58: PRINT W
IF FLAG = 1 THEN COLOR 1: LOCATE 9, 58: PRINT V
SOUND 4440, .9
GOSUB WIN
IF WINNER = 1 THEN GOSUB Whitewinner: SLEEP: Rp = 0: GOTO TOP
IF WINNER = 2 THEN GOSUB Blackwinner: SLEEP: Rp = 0: GOTO TOP
END IF
RETURN
VRBOX:
SELECT CASE UCASE$(MODE$)
CASE IS = "BOXIN"
LINE (IX1, IX2)-(IX3, IX4), 7, BF
LINE (IX1 - 1, IX4 + 1)-(IX1 - 1, IX2 - 1), 8
LINE -(IX3 + 1, IX2 - 1), 8
LINE -(IX3 + 1, IX4 + 1), 15
LINE -(IX1 - 1, IX4 + 1), 15
CASE IS = "BOXON"
LINE (IX1, IX2)-(IX3, IX4), 7, BF
LINE (IX1 - 1, IX4 + 1)-(IX1 - 1, IX2 - 1), 15
LINE -(IX3 + 1, IX2 - 1), 15
LINE -(IX3 + 1, IX4 + 1), 8
LINE -(IX1 - 1, IX4 + 1), 8
CASE IS = "BOXIN_EMP"
LINE (IX1, IX2)-(IX3, IX4), 7, B
LINE (IX1 - 1, IX4 + 1)-(IX1 - 1, IX2 - 1), 8
LINE -(IX3 + 1, IX2 - 1), 8
LINE -(IX3 + 1, IX4 + 1), 15
LINE -(IX1 - 1, IX4 + 1), 15
CASE IS = "BOXON_EMP"
LINE (IX1, IX2)-(IX3, IX4), 7, B
LINE (IX1 - 1, IX4 + 1)-(IX1 - 1, IX2 - 1), 15
LINE -(IX3 + 1, IX2 - 1), 15
LINE -(IX3 + 1, IX4 + 1), 8
LINE -(IX1 - 1, IX4 + 1), 8
END SELECT
RETURN
DISPLAY24:
REM $DYNAMIC
REDIM M$(73)
TMP$ = SPACE$(1)
OPEN HZK24$ FOR BINARY AS #24
FOR CHECK = 1 TO 100
IF MID$(T$(o), 1, CHECK) = "" THEN CHECK = 100
TEMP1$ = MID$(T$(o), CHECK, 1)
IF TEMP1$ > CHR$(160) THEN p = p + 1
IF p = 2 THEN
x = (ASC(TEMP2$) - 160) * 100 + (ASC(TEMP1$) - 160): p = 0
rec = (x \ 100 - 16) * 94 + ((x - 101) - (x \ 100 - 1) * 100)
DD = rec * 72
IF DD > 0 THEN GET #24, DD, TMP$
FOR iz = 1 TO 73
GET #24, DD + iz, TMP$
M$(iz - 1) = TMP$
NEXT
FOR MEM1 = 0 TO 23
FOR MEM2 = 0 TO 2
T = 0: tmp1 = 256
FOR mem3 = 0 TO 7
IF M$(MEM1 * 3 + MEM2) > CHR$(7 - mem3) THEN
tmp1 = tmp1 / 2: tmp2 = (ASC(M$(MEM1 * 3 + MEM2)) \ tmp1) MOD 2
IF tmp2 = 1 THEN PSET (XTMP + MEM1, YTMP + MEM2 * 8 + mem3), FCOLOR
END IF
NEXT: NEXT: NEXT
IF UCASE$(POSIT$) = "WIDE" THEN YTMP = YTMP + 24 + SPACE
IF UCASE$(POSIT$) = "LONG" THEN XTMP = XTMP + 24 + SPACE
ELSE
TEMP2$ = TEMP1$
END IF
NEXT CHECK
CLOSE #24
RETURN
DISPLAY16:
OPEN HZK16$ FOR BINARY AS #16
FOR CHECK = 1 TO 100
IF MID$(T$(o), 1, CHECK) = "" THEN CHECK = 100
TEMP1$ = MID$(T$(o), CHECK, 1)
IF TEMP1$ > CHR$(160) AND TEMP1$ < CHR$(255) THEN p = p + 1: N = YTMP
IF p = 2 THEN
x = (ASC(TEMP2$) - 160) * 100 + (ASC(TEMP1$) - 160): p = 0
Y = 16
DD = (x - 100 - 1) * 32 - 3 - (INT(x / 100) - 1) * 6 * 32
IF DD > 0 THEN GET #16, DD, T
FOR MEM2 = 1 TO 16
a1 = VAL(OCT$(ASC(INPUT$(1, #16))))
a1 = (a1 \ 100) * 64 + ((a1 MOD 100) \ 10) * 8 + (a1 MOD 100) MOD 10
T = 0: t1 = 256
FOR MEM1 = 1 TO 8
t1 = t1 / 2: t2 = (a1 \ t1) MOD 2
IF t2 = 1 THEN PSET (XTMP + T, N), FCOLOR
T = T + 1
NEXT MEM1
a1 = VAL(OCT$(ASC(INPUT$(1, #16))))
a1 = (a1 \ 100) * 64 + ((a1 MOD 100) \ 10) * 8 + (a1 MOD 100) MOD 10
t1 = 256
FOR MEM1 = 1 TO 8
t1 = t1 / 2: t2 = (a1 \ t1) MOD 2
IF t2 = 1 THEN PSET (XTMP + T, N), FCOLOR
T = T + 1
NEXT MEM1
N = N + 1
NEXT MEM2
IF UCASE$(POSIT$) = "LONG" THEN XTMP = XTMP + Y + SPACE
IF UCASE$(POSIT$) = "WIDE" THEN YTMP = YTMP + Y + SPACE
ELSE
TEMP2$ = TEMP1$
END IF
NEXT CHECK
CLOSE #16
RETURN
BLACK:
IX1 = 460: IX2 = 100: IX3 = 508: IX4 = 116: MODE$ = "BOXON_EMP": GOSUB VRBOX
IX1 = 460: IX2 = 150: IX3 = 508: IX4 = 166: MODE$ = "BOXON_EMP": GOSUB VRBOX
IX1 = 460: IX2 = 100: IX3 = 508: IX4 = 116: MODE$ = "BOXIN_EMP": GOSUB VRBOX
RETURN
white:
IX1 = 460: IX2 = 100: IX3 = 508: IX4 = 116: MODE$ = "BOXON_EMP": GOSUB VRBOX
IX1 = 460: IX2 = 150: IX3 = 508: IX4 = 166: MODE$ = "BOXON_EMP": GOSUB VRBOX
IX1 = 460: IX2 = 150: IX3 = 508: IX4 = 166: MODE$ = "BOXIN_EMP": GOSUB VRBOX
RETURN
WIN:
IF FLAG = 0 THEN
    H = W
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = whitex(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = whitex(p3) AND whitey(p2) + 1 = whitey(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = whitex(p4) AND whitey(p3) + 1 = whitey(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = whitex(p5) AND whitey(p4) + 1 = whitey(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = whitex(p6) AND whitey(p5) + 1 = whitey(p6) THEN
    WINNER = 1
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = W
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = whitex(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = whitex(p3) AND whitey(p2) - 1 = whitey(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = whitex(p4) AND whitey(p3) - 1 = whitey(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = whitex(p5) AND whitey(p4) - 1 = whitey(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = whitex(p6) AND whitey(p5) - 1 = whitey(p6) THEN
    WINNER = 1
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = W
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = whitex(p2) AND Tytmp = whitey(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = whitex(p3) AND Tytmp = whitey(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = whitex(p4) AND Tytmp = whitey(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = whitex(p5) AND Tytmp = whitey(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = whitex(p6) AND Tytmp = whitey(p6) THEN WINNER = 1
    NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = W
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = whitey(p2) AND Txtmp = whitex(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = whitey(p3) AND Txtmp = whitex(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = whitey(p4) AND Txtmp = whitex(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = whitey(p5) AND Txtmp = whitex(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = whitey(p6) AND Txtmp = whitex(p6) THEN WINNER = 1
    NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
END IF
IF FLAG = 1 THEN
    H = V
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = blackx(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = blackx(p3) AND blacky(p2) + 1 = blacky(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = blackx(p4) AND blacky(p3) + 1 = blacky(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = blackx(p5) AND blacky(p4) + 1 = blacky(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = blackx(p6) AND blacky(p5) + 1 = blacky(p6) THEN
    WINNER = 2
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = V
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = blackx(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = blackx(p3) AND blacky(p2) - 1 = blacky(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = blackx(p4) AND blacky(p3) - 1 = blacky(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = blackx(p5) AND blacky(p4) - 1 = blacky(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = blackx(p6) AND blacky(p5) - 1 = blacky(p6) THEN
    WINNER = 2
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = V
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = blackx(p2) AND Tytmp = blacky(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = blackx(p3) AND Tytmp = blacky(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = blackx(p4) AND Tytmp = blacky(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = blackx(p5) AND Tytmp = blacky(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = blackx(p6) AND Tytmp = blacky(p6) THEN WINNER = 2
    NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
    H = V
    FOR p1 = 0 TO 17
    FOR p2 = 0 TO H
    IF p1 = blacky(p2) AND Txtmp = blackx(p2) THEN
    FOR p3 = 0 TO H
    IF p1 + 1 = blacky(p3) AND Txtmp = blackx(p3) THEN
    FOR p4 = 0 TO H
    IF p1 + 2 = blacky(p4) AND Txtmp = blackx(p4) THEN
    FOR p5 = 0 TO H
    IF p1 + 3 = blacky(p5) AND Txtmp = blackx(p5) THEN
    FOR p6 = 0 TO H
    IF p1 + 4 = blacky(p6) AND Txtmp = blackx(p6) THEN WINNER = 2
    NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    END IF: NEXT
    NEXT
END IF
RETURN
Whitewinner:
XTMP = 452: YTMP = 300: FCOLOR = 5
T$(0) = "白方获得胜利"
GOSUB DISPLAY24
GOSUB Sound1
RETURN
Blackwinner:
XTMP = 452: YTMP = 300: FCOLOR = 5
T$(0) = "黑方获得胜利"
GOSUB DISPLAY24
GOSUB Sound1
RETURN
F1:
SPACE = 0: XTMP = 460: YTMP = 230: FCOLOR = 12
T$(0) = "帮助信息:"
GOSUB DISPLAY16
SPACE = 0: XTMP = 460: YTMP = 246: FCOLOR = 12
T$(0) = "鼠标左键为黑方落子"
GOSUB DISPLAY16
SPACE = 0: XTMP = 460: YTMP = 262: FCOLOR = 12
T$(0) = "鼠标右键为白方落子"
GOSUB DISPLAY16
SLEEP
LINE (460, 230)-(610, 278), 0, BF
RETURN
F2:
SPACE = 0: XTMP = 460: YTMP = 230: FCOLOR = 12
T$(0) = "正在记录数据!"
GOSUB DISPLAY16
OPEN "CCH.SAV" FOR BINARY AS #1
CLOSE
KILL "cch.sav"
OPEN "cch.sav" FOR OUTPUT AS #1
WRITE #1, W, V
FOR s = 0 TO W
WRITE #1, 0, whitex(s), whitey(s)
NEXT
FOR s = 0 TO V
WRITE #1, 1, blackx(s), blacky(s)
NEXT
CLOSE
LINE (460, 230)-(570, 246), 0, BF
RETURN
F3:
Rp = 1
GOSUB TOP
r.ax = 2
INTERRUPT 51, r, r
SPACE = 0: XTMP = 460: YTMP = 230: FCOLOR = 12
T$(0) = "正在读取数据!"
GOSUB DISPLAY16
ERASE whitex, whitey, blackx, blacky
WINNER = 0: W = 0: V = 0
CLEAR
ON ERROR GOTO Nofile
OPEN "CCH.SAV" FOR INPUT AS #1
INPUT #1, W, V
W1 = W: V1 = V: W = 0: V = 0
FOR s = 0 TO W1 - 1
INPUT #1, FLAG, whitex(s), whitey(s)
tx = whitex(s) * 25 + 5: ty = whitey(s) * 25 + 5
GOSUB Check1
NEXT
INPUT #1, N, N, N
FOR s = 0 TO V1 - 1
INPUT #1, FLAG, blackx(s), blacky(s)
tx = blackx(s) * 25 + 5: ty = blacky(s) * 25 + 5
GOSUB Check1
NEXT
CLOSE
LINE (460, 230)-(570, 246), 0, BF
r.ax = 1
INTERRUPT 51, r, r
r.ax = 3
RETURN
Sound1:
PLAY "MB T90 o3l13cdededel5gl13el5al13egga"
RETURN
Nofile:
HZK16$ = "HZK16"
HZK24$ = "HZK24K"
POSIT$ = "LONG":
LINE (460, 230)-(570, 246), 0, BF
GOTO MAIN

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wangtao_028

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值