|
ASM Tetroid
![]() I seem to have a record of making tetris games, because they're fun (but mostly because I know how.) This is yet-another tetris clone, only remarkable because it was created with assembly language and runs under Windows (95 ... XP) using OpenGL. Here is a zip file containing the program and source. Here are a few flowcharts describing program operation:
RotatePieceCW PROC
LOCAL srcX:dword, srcY:dword, destX:dword, destY:dword, i:sdword, j:sdword, cell:byte
MOV EAX, currentPieceSize
MOV i, EAX
DEC i
.WHILE (i >= 0)
MOV EAX, currentPieceSize
MOV j, EAX
DEC j
.WHILE (j >= 0)
invoke GetPiece, currentPiece, currentPieceSize, i, j, ADDR cell
.IF (cell == 1)
MOV EAX, pieceX
ADD EAX, currentPieceSize
SUB EAX, 1
SUB EAX, j
MOV destX, EAX
MOV EAX, pieceY
ADD EAX, i
MOV destY, EAX
invoke GetBoard, destX, destY, ADDR cell
.IF (cell == 99)
JMP Failed
.ENDIF
.IF (destX < 0) || (destX >= 10)
JMP Failed
.ENDIF
.IF (destY < 0) || (destY >= 20)
JMP Failed
.ENDIF
.ENDIF
MOV cell, 0
DEC j
.ENDW
DEC i
.ENDW
MOV EAX, currentPieceSize
MOV j, EAX
DEC j
.WHILE (j >= 0)
MOV EAX, currentPieceSize
MOV i, EAX
DEC i
.WHILE (i >= 0)
MOV destX, 0
MOV destY, 0
MOV EAX, pieceX
ADD EAX, i
MOV destX, EAX
MOV EAX, pieceY
ADD EAX, j
MOV destY, EAX
invoke GetBoard, destX, destY, ADDR cell
.IF (cell == 1)
invoke SetBoard, destX, destY, 0
.ENDIF
DEC i
.ENDW
DEC j
.ENDW
MOV EAX, currentPieceSize
MOV i, EAX
DEC i
.WHILE (i >= 0)
MOV EAX, currentPieceSize
MOV j, EAX
DEC j
.WHILE (j >= 0)
MOV EAX, i
MOV EDX, j
invoke GetPiece, currentPiece, currentPieceSize, i, j, ADDR cell
.IF (cell == 1)
MOV EAX, pieceX
ADD EAX, currentPieceSize
SUB EAX, 1
SUB EAX, j
MOV destX, EAX
MOV EAX, pieceY
ADD EAX, i
MOV destY, EAX
invoke SetBoard, destX, destY, 1
.ENDIF
MOV destX, 0
MOV destY, 0
MOV EAX, currentPieceSize
SUB EAX, 1
SUB EAX, j
MOV destX, EAX
MOV EAX, i
MOV destY, EAX
MOV ECX, 0
MOV CL, cell
invoke SetPiece, currentPiece, i, j, 0
.IF (cell == 1)
LEA EAX, tempCurrentPieceMatrix
invoke SetPiece, ADDR tempCurrentPieceMatrix, destX, destY, 1
.ENDIF
MOV cell, 0
DEC j
.ENDW
DEC i
.ENDW
MOV EAX, 4
MOV i, EAX
DEC i
.WHILE (i >= 0)
MOV EAX, 4
MOV j, EAX
DEC j
.WHILE (j >= 0)
MOV EAX, j
MOV EDX, 4
MUL DX
ADD EAX, i
MOV ESI, EAX
LEA EAX, tempCurrentPieceMatrix
ADD EAX, ESI
MOV DL, [EAX]
MOV BL, 0
MOV [EAX], BL
LEA EAX, currentPieceMatrix
ADD EAX, ESI
MOV [EAX], DL
DEC j
.ENDW
DEC i
.ENDW
JMP Success
Failed:
MOV EAX, 0
ret
Success:
MOV EAX, 1
ret
RotatePieceCW ENDP
|