Microprocessor
Microprocessor
org 100h
jmp start
;functions area
print_com PROC
MOV DX, comtop
printcompo:
INC comcount
printpixel 308, DX, 0001b,1
INC DX
INC comcount
CMP comcount, 150
JNE printcompo
SUB comcount, 150
RET
print_com ENDP
print_ball PROC
printpixel ballx, bally, 00000001b,3
DEC ballx
DEC bally
printpixel ballx, bally, 00000001b,3
INC ballx
printpixel ballx, bally, 00000001b,3
sub ballx, 2
DEC bally
printpixel ballx, bally, 00000001b,3
inc ballx
printpixel ballx, bally, 00000001b,3
inc ballx
printpixel ballx, bally, 00000001b,3
inc ballx
printpixel ballx, bally, 00000001b,3
RET
print_ball ENDP
clearscreen proc
MOV AL, 13H ;changes the num of pixels to 640X480 with 16 colors
MOV AH, 0
INT 10H
ret
clearscreen ENDP
reprint proc
call clearscreen
call print_batt
call print_com
ret
reprint ENDP
baseprint proc
mov base, 0
printbase:
printpixel base, 0, 2, 2
INC base
CMP base, 320
JNE printbase
mov base, 0
printdownbase:
printpixel base, 199, 2, 2
INC base
CMP base, 320
JNE printdownbase
mov base, 0
printleftbase:
printpixel 0, base, 2, 2
INC base
CMP base, 199
JNE printleftbase
mov base, 0
printrightbase:
printpixel 319, base, 2, 2
INC base
CMP base, 199
JNE printrightbase
ret
baseprint EndP
;main move
balloop macro move
call move
CALL hitcheck
JMP checkahit
EndM
;LEFT UP
bdleftup PROC
call reprint
sub ballx, 14
dec bally
CALL print_ball
bdleftupreverse proc
ADD ballx, 11
INC bally
RET
bdleftupreverse ENDP
;LEFT DOWN
bdleftdown PROC
call reprint
sub ballx, 11
ADD bally, 10
CALL print_ball
MOV lastaction, bdleftdown
RET
bdleftdown ENDP
bdleftdownreverse proc
ADD ballx, 11
DEC bally
RET
bdleftdownreverse ENDP
;RIGHT UP
bdrightup PROC
call reprint
ADD ballx, 11
DEC bally
CALL print_ball
MOV lastaction, bdrightup
RET
bdrightup ENDP
bdrightupreverse proc
SUB ballx, 11
INC bally
RET
bdrightupreverse ENDP
;RIGHT DOWN
bdrightdown PROC
call reprint
ADD ballx, 10
ADD bally, 11
CALL print_ball
MOV lastaction, bdrightdown
RET
bdrightdown ENDP
bdrightdownreverse proc
SUB ballx, 11
DEC bally
RET
bdrightdownreverse ENDP
hitcheck PROC
;------batt and com check-------
MOV BH, 2H
MOV DX, ballx
MOV CX, bally
SUB CX, 2
MOV AH, 0Dh
INT 10H
CMP AL, 1
JE hitmovement
CMP AL, 3
JE comhitmovement
MOV BH, 2H
MOV DX, ballx
MOV CX, bally
ADD CX, 2
MOV AH, 0Dh
INT 10H
CMP AL, 1
JE hitmovement
CMP AL, 3
JE comhitmovement
MOV BH, 2H
MOV DX, ballx
MOV CX, bally
SUB DX, 2
MOV AH, 0Dh
INT 10H
CMP AL, 1
JE hitmovement
CMP AL, 3
JE comhitmovement
MOV BH, 2H
MOV DX, ballx
MOV CX, bally
ADD DX, 2
MOV AH, 0Dh
INT 10H
CMP AL, 1
JE hitmovement
CMP AL, 3
JE comhitmovement
;------base check-------
CMP bally, 1
JB upbasehitmovement
JE upbasehitmovement
CMP ballx, 1
JB leftbasehitmovement
JE leftbasehitmovement
CMP bally, 199
JA downbasehitmovement
JE downbasehitmovement
JMP nonhit
hitmovement:
MOV AH, 2CH ;TIMER
INT 21H
CMP DH, 30
JA NC1
JB NC13
NC13:
balloop bdrightup ;BALLOOP CONFIGURATION
JMP checkahit
NC1:
balloop bdrightdown ;BALLOOP CONFIGURATION
JMP checkahit
comhitmovement:
MOV AH, 2CH ;TIMER
INT 21H
CMP DH, 30
JA NC2
balloop bdleftdown ;BALLOOP CONFIGURATION
NC2:
balloop bdleftup ;BALLOOP CONFIGURATION
JMP checkahit
upbasehitmovement:
balloop bdrightdown
JMP checkahit
downbasehitmovement:
balloop bdrightup
JMP checkahit
rightbasehitmovement:
JMP END
leftbasehitmovement:
JMP END
nonhit:
ret
hitcheck EndP
;----------------------------------data area-------------------------
ballx DW 150
bally DW 90
p1score DW 0
p2score DW 0
lastaction DW bdleftup
base dw 0
start:
;----------START PAGE-------------
MOV AL, 1 ;PAGE NUMBER
MOV AH, 05H
INT 10H
WindowColor 0,0,80,25,01ch
;PRINT STARTMSG
printstring startmsg
;PRINT CREATOR(LidorMotai)
wrong:
MOV BH, 0 ;PAGE
MOV DH, 16 ;ROW
MOV DL, 23 ;COLUMN
MOV AH, 02H
INT 10H
right:
;-------------------GAME PAGE-------------------
MOV AX, 13H ;changes the num of pixels to 640X480 with 16 colors
INT 10H
; - - - - - - - - - - Game Code - - - - - - - -
CALL print_ball
CALL print_com
CALL print_batt
balloop bdleftup
;PLAYER1 - CLICK?
checkahit:
p1movecheck:
; PRINT BASE
CALL baseprint
delay 00000001b
;
;CMP p1score, 1
;JE score
MOV AL, 0
MOV AH, 01H
INT 16H
JZ noclick
MOV AH, 00H
INT 16H
P1UP:
CMP player1top, 4
JE checkahit
MOV AL, 13H ;changes the num of pixels to 640X480 with 16 colors
MOV AH, 0
INT 10H
CALL print_com
balloop lastaction
JMP hitcheck
CALL print_batt
JMP checkahit
P1DOWN:
CALL print_com
MOV AX, player1top
ADD AX, 4
MOV player1top, AX
CALL print_batt
balloop lastaction
JMP hitcheck
JMP checkahit
noclick:
balloop lastaction
JMP hitcheck
score:
call clearscreen
END:
Woo! Game. Hope you all have heard this pong game. It is the first computer
game ever created. It is like the tennis game. The game consists of two
switches/paddle (act like a racket) and a ball. The goal is to hit the ball to your
opponent region. If the opponent misses you score a point. It is no doubt a cool
game. It is also said that this game brought a revolution in the video gaming
industry. This project is designed with the help of the 8085 Microprocessor,
various chips, LEDs, Resistors, RAM, ROM, Peripheral ICs and many more. Give a
try to pong game.