-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplong.asm
More file actions
76 lines (61 loc) · 1.13 KB
/
plong.asm
File metadata and controls
76 lines (61 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
; pong but better
TopRow: db 0
BottomRow: db 25
PlayerOneX: db 0
PlayerTwoX: db 0
Paddle: db "xxxxx", 0
ballX: db 0
ballY: db 0
Plong:
PlongLoop:
mov al, 00h
mov ah, 01h
int 0x16
jz afterInput
mov ah, 00h
int 0x16
cmp al, 'a'
je movPlayerOneLeft
cmp al, 'd'
je movPlayerOneRight
cmp al, 'j'
je movPlayerTwoLeft
cmp al, 'l'
je movPlayerTwoRight
afterInput:
call ClearScreen
mov dx, [PlayerOneX]
mov dh, [TopRow]
call setLine
mov bx, Paddle
call PrintString
mov dx, [PlayerTwoX]
mov dh, [BottomRow]
call setLine
mov bx, Paddle
call PrintString
jmp PlongLoop
movPlayerOneLeft:
mov bx, [PlayerOneX]
cmp bx, 00h
je afterInput
dec bx
mov [PlayerOneX], bx
jmp afterInput
movPlayerOneRight:
mov bx, [PlayerOneX]
inc bx
mov [PlayerOneX], bx
jmp afterInput
movPlayerTwoLeft:
mov bx, [PlayerTwoX]
cmp bx, 00h
dec bx
mov [PlayerTwoX], bx
jmp afterInput
movPlayerTwoRight:
mov bx, [PlayerTwoX]
inc bx
mov [PlayerTwoX], bx
jmp afterInput
ret