俄罗斯方块代码.docx
- 文档编号:11745234
- 上传时间:2023-03-31
- 格式:DOCX
- 页数:30
- 大小:19.11KB
俄罗斯方块代码.docx
《俄罗斯方块代码.docx》由会员分享,可在线阅读,更多相关《俄罗斯方块代码.docx(30页珍藏版)》请在冰豆网上搜索。
俄罗斯方块代码
DATASEGMENT
SEGMENT1CDW0
OFF1CDW0
BOARDDW24DUP(?
),0FFFFH
YDB?
TYDB?
XRDB?
XLDB?
NOWDB?
DIREDB?
NXTDB?
TIMDB0
SPEEDDB0
CONDB0
DVDB0
FLGDB0
PADDW0H,3C0H,0H,0H;0
DW100H,100H,100H,100H
DW0H,3C0H,0H,0H
DW100H,100H,100H,100H
DW0H,180H,180H,0H;1
DW0H,180H,180H,0H
DW0H,180H,180H,0H
DW0H,180H,180H,0H
DW0H,380H,200H,0H;2
DW200H,200H,300H,0H
DW0H,80H,380H,0H
DW0H,300H,100H,100H
DW0H,380H,80H,0H;3
DW300H,200H,200H,0H
DW0H,200H,380H,0H
DW100H,100H,300H,0H
DW0H,180H,300H,0H;4
DW100H,180H,80H,0H
DW0H,180H,300H,0H
DW100H,180H,80H,0H
DW0H,300H,180H,0H;5
DW80H,180H,100H,0H
DW0H,300H,180H,0H
DW80H,180H,100H,0H
DW0H,380H,100H,0H;6
DW100H,180H,100H,0H
DW100H,380H,0H,0H
DW100H,300H,100H,0H
P1DW4DUP(?
)
P2DW4DUP(?
)
COLORDB00001001b,00001010b,00001011b,00001100b,00001101b,00001110b,00000001b
NCOLORDB?
SCOREDB5DUP('0'),'$'
PADMSGDB25DUP(219)
TMPMSGDB25DUP(?
)
STARTMSG1DB0DH,0AH,'Selectspeed.',0DH,0AH,'$'
STARTMSG2DB20H,20H,'1.Fast',0DH,0AH,'$'
STARTMSG3DB20H,20H,'2.Middle',0DH,0AH,'$'
STARTMSG4DB20H,20H,'3.Slow',0DH,0AH,'$'
STARTMSG5DB20H,20H,'0.Exit',0DH,0AH,'$'
ENDMSGDB0DH,0AH,'GoodBye!
',0DH,0AH,'$'
SCOREMSG1DB201,19dup(205),187
SCOREMSG2DB186,'Score:
',186
SCOREMSG3DB204,19dup(205),185
SCOREMSG4DB186,19dup(32),186
SCOREMSG5DB186,19dup(32),186
SCOREMSG6DB186,19dup(32),186
SCOREMSG7DB186,19dup(32),186
SCOREMSG8DB204,19dup(205),185
SCOREMSG9DB186,'Left:
A',186
SCOREMSG10DB186,'Right:
D',186
SCOREMSG11DB186,'Rotate:
S',186
SCOREMSG12DB186,'Down:
Tab',186
SCOREMSG13DB186,'-------------------',186
SCOREMSG14DB186,'Exit:
Esc',186
SCOREMSG15DB200,19dup(205),188
DATAENDS
STACKSEGMENTSTACK
DB200DUP(?
)
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,ES:
DATA,SS:
STACK
START:
MOVAX,DATA
MOVDS,AX
PUSHDS
;GETINT1CADRESS
MOVAL,1CH
MOVAH,35H
INT21H
MOVSEGMENT1C,ES
MOVOFF1C,BX
;SETINT1CADRESS
MOVDX,OFFSETINT1C
MOVAX,SEGINT1C
MOVDS,AX
MOVAL,1CH
MOVAH,25H
INT21H
POPDS
GAMEOVER:
;设置显示方式:
80*2516色文本
MOVAH,00H
MOVAL,03H
INT10H
SELECTSPEED:
;显示提示信息
MOVAH,09H
MOVDX,OFFSETSTARTMSG1
INT21H
MOVDX,OFFSETSTARTMSG2
INT21H
MOVDX,OFFSETSTARTMSG3
INT21H
MOVDX,OFFSETSTARTMSG4
INT21H
MOVDX,OFFSETSTARTMSG5
INT21H
;检测CTRL+BREAK或CTRL+C
MOVAH,08H
INT21H
SUBAL,'0'
MOVCL,AL
ANDAL,3
CMPAL,CL
JNESELECTSPEED
INCAL
INCCL
MULCL
CMPAL,1H
JEEXIT
MOVSPEED,AL
;SETGRAPHICS:
640*480*16色
MOVAH,00H
MOVAL,12H
INT10H
;设置调色板:
BH调色板ID,BL和ID使用的颜色
MOVAH,0BH
MOVBH,01
MOVBL,00H
INT10H
;STARTGAME
CALLINITGAME
CALLBEGIN
CALLDELAY
MOVTIM,0H
LOOP1:
STI
MOVAL,TIM
CMPAL,SPEED
JGTIME
MOVAH,1
INT16H
JZLOOP1
MOVAH,0
INT16H
CMPAL,1BH
JZEXIT
CMPAL,'a'
JZKA
CMPAL,'s'
JZKS
CMPAL,'d'
JZKD
CMPAL,09H
JNZTIME
KTAB:
CALLDELAY
CALLDOWN
CMPCON,1
JNEKTAB
CALLBEGIN
JMPLOOP1
KA:
CALLLEFT
JMPLOOP1
KS:
CALLROTATE
JMPLOOP1
KD:
CALLRIGHT
JMPLOOP1
TIME:
MOVTIM,0H
CALLDOWN
CMPCON,0
JELOOP1
CALLBEGIN
JMPLOOP1
EXIT:
;SETGRAPHICS
MOVAX,0003H
INT10H
MOVAX,DATA
MOVDS,AX
MOVDX,OFFSETENDMSG
MOVAH,09H
INT21H
;SETINT1CADRESS
MOVDX,OFF1C
MOVAX,SEGMENT1C
MOVDS,AX
MOVAL,1CH
MOVAH,25H
INT21H
MOVAX,4C00H
INT21H
INT1CPROC
STI
PUSHAX
PUSHDX
MOVAX,DATA
MOVDS,AX
INCTIM
POPDX
POPAX
IRET
INT1CENDP
DELAYPROCNEAR
PUSHCX
MOVCX,00FFH
LOOP20:
LOOPLOOP20
POPCX
RET
DELAYENDP
ROTATEPROCNEAR
MOVSI,OFFSETPAD
MOVAL,NOW
MOVAH,0H
MOVCL,32
MULCL
ADDSI,AX
MOVAL,DIRE
INCAL
ANDAL,03H
MOVAH,0H
MOVCL,8
MULCL
ADDSI,AX
MOVDI,OFFSETP2
MOVCX,04H
CLD
LOOP12:
PUSHCX
LODSW
MOVCL,XR
SHRAX,CL
MOVCL,XL
SHLAX,CL
STOSW
POPCX
LOOPLOOP12
CALLCHECK
CMPAL,0H
JNESKIP10
MOVBX,0000H
CALLDISPPAD
CALLCOPY21
INCDIRE
ANDDIRE,3H
MOVBH,00H
MOVBL,NCOLOR
CALLDISPPAD
SKIP10:
RET
ROTATEENDP
RIGHTPROCNEAR
CALLCOPY12
MOVSI,OFFSETP2
MOVCX,04H
LOOP7:
MOVAX,[SI]
SHRAX,1
MOV[SI],AX
INCSI
INCSI
LOOPLOOP7
CALLCHECK
CMPAL,0H
JNESKIP6
MOVBX,0000H
CALLDISPPAD
CALLCOPY21
CMPXL,0
JESKIP7
DECXL
DECXR
SKIP7:
INCXR
MOVBH,00H
MOVBL,NCOLOR
CALLDISPPAD
SKIP6:
RET
RIGHTENDP
LEFTPROCNEAR
CALLCOPY12
MOVSI,OFFSETP2
MOVCX,04H
LOOP10:
MOVAX,[SI]
SHLAX,1
MOV[SI],AX
INCSI
INCSI
LOOPLOOP10
CALLCHECK
CMPAL,0H
JNESKIP8
MOVBX,0000H
CALLDISPPAD
CALLCOPY21
CMPXR,0
JESKIP9
DECXR
DECXL
SKIP9:
INCXL
MOVBH,00H
MOVBL,NCOLOR
CALLDISPPAD
SKIP8:
RET
LEFTENDP
DOWNPROCNEAR
CALLCOPY12
INCTY
CALLCHECK
CMPAL,0H
JNESKIP5
MOVBX,0000H
CALLDISPPAD
CALLCOPY21
MOVBH,00H
MOVBL,NCOLOR
CALLDISPPAD
MOVCON,00H
RET
SKIP5:
CALLPUT
MOVCON,01H
RET
DOWNENDP
PUTPROCNEAR
MOVBH,0H
MOVBL,0h
CALLDISPPAD
MOVBH,0H
MOVBL,01011001b
CALLDISPPAD
INCSCORE[4]
MOVDV,01H
MOVAH,0H
MOVAL,Y
ADDAL,Y
MOVSI,OFFSETBOARD
ADDSI,AX
MOVDI,00H
MOVCX,04H
CLD
LOOP15:
LODSW
ORAX,P1[DI]
MOV[SI-2],AX
INCDI
INCDI
LOOPLOOP15
MOVSI,OFFSETBOARD
ADDSI,23*2
MOVDI,SI
MOVCX,20
MOVBH,00H
MOVFLG,00H
STD
LOOP13:
LODSW
CMPAX,0FFFFH
JNESKIP12
MOVFLG,0FFH
MOVAL,DV
SALAL,1
MOVDV,AL
JMPLOOP13
SKIP12:
STOSW
;PUSHAX
CMPFLG,0H
JESKIP70
PUSHCX
MOVDH,CL
ADDDH,03H
MOVDL,0AH
MOVBX,0000H
MOVBP,OFFSETPADMSG
MOVCX,20
PUSHAX
MOVAX,1300H
INT10H
POPAX
MOVCL,03H
SHLAX,CL
MOVCX,0AH
MOVDL,08H
LOOP14:
INCDL
INCDL
MOVBL,0H
SHLAX,1
JNCSKIP11
MOVBL,01011001b
SKIP11:
CALLDISPCELL
LOOPLOOP14
POPCX
SKIP70:
LOOPLOOP13
MOVAL,DV
SARAL,1
ADDSCORE[3],AL
MOVCX,05H
MOVSI,04H
LOOP16:
CMPSCORE[SI],'9'
JNGSKIP13
INCSCORE[SI-1]
SUBSCORE[SI],0AH
SKIP13:
DECSI
LOOPLOOP16
RET
PUTENDP
DISPSCOREPROCNEAR
MOVAX,DATA
MOVES,AX
MOVBP,OFFSETSCORE
MOVCX,05H
MOVDX,0635H
MOVBH,0H
MOVAL,0H
MOVBL,00110100B
MOVAH,13H
INT10H
RET
DISPSCOREENDP
DISPNEXTPROCNEAR
MOVAX,DATA
MOVES,AX
MOVBP,OFFSETTMPMSG
MOVDI,BP
MOVSI,OFFSETPAD
MOVAL,NXT
MOVAH,0
MOVBL,32
MULBL
ADDSI,AX
CLD
MOVCX,04H
LOOP8:
PUSHCX
LODSW
MOVCL,06H
SHLAX,CL
MOVCX,04H
LOOP9:
MOVBL,20H
SHLAX,1
JNCSKIP2
MOVBL,219
SKIP2:
MOV[DI],BL
INCDI
MOV[DI],BL
INCDI
LOOPLOOP9
MOVDX,0c30H
POPCX
SUBDH,CL
PUSHCX
MOVCX,08H
MOVBH,0H
PUSHSI
MOVAH,0H
MOVAL,NXT
MOVSI,AX
MOVBL,COLOR[SI]
POPSI
MOVAX,1300H
INT10H
POPCX
MOVDI,BP
LOOPLOOP8
RET
DISPNEXTENDP
COPY21PROCNEAR
CLD
MOVSI,OFFSETP2
MOVDI,OFFSETP1
MOVCX,08
REPMOVSB
MOVCL,TY
MOVY,CL
RET
COPY21ENDP
COPY12PROCNEAR
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,02H
MOVAX,1300H
INT10H
CMPBL,0H
JESKIP20
;CALCROW
MOVAH,0H
MOVAL,DH
MOVCL,16
MULCL
MOVSI,AX
;CALCCOL
MOVAH,0H
MOVAL,DL
MOVCL,8
MULCL
MOVDI,AX
;DRAW
MOVAX,0C00H
MOVDX,SI
ADDDX,15
MOVCX,16
LOOP21:
ADDCX,DI
DECCX
INT10H
INCCX
SUBCX,DI
LOOPLOOP21
MOVDX,SI
MOVCX,15
ADDDI,15
LOOP22:
PUSHCX
MOVCX,DI
INT10H
INCDX
POPCX
LOOPLOOP22
SUBDI,2
DECDX
MOVCX,13
LOOP23:
PUSHCX
DECDX
MOVCX,DI
INT10H
SUBCX,12
MOVAL,07H
INT10H
MOVAL,00H
POPCX
LOOPLOOP23
MOVAX,0C07H
MOVDX,SI
ADDDX,1
MOVCX,12
SUBDI,12
LOOP24:
ADDCX,DI
INT10H
SUBCX,DI
LOOPLOOP24
SKIP20:
POPSI
POPDI
POPDX
POPCX
POPBX
POPAX
RET
DISPCELLENDP
;初始化屏幕:
25*80
CLSPROCNEAR
MOVCX,0
MOVDH,24
MOVDL,79
MOVBH,0
MOVAX,600H
INT10H
RET
CLSENDP
RANDOMPROCNEAR
LOOP5:
INAX,40H
INCAL
ANDAL,07H
CMPAL,07H
JELOOP5
MOVNXT,AL
RET
RANDOMENDP
INITGAMEPROCNEAR
CALLCLS;初始化屏幕:
25*80
;DRAWTEXT_FRAME
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 俄罗斯方块 代码