Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IDEAL
- MODEL small
- STACK 100h
- DATASEG
- Snake dw 32160, 32164, 32168, 32172, 32176, 32180
- SnakeLength dw 6
- Direction db 2
- Runs dw 0
- ; --------------------------
- ; Your variables here
- ; --------------------------
- CODESEG
- proc DirectionTranslation ; Might need to change return method to Register, also maybe this proc is not needed
- cmp al, 17
- jb NoDirection
- jne SecondCheck
- cmp Direction, 3
- je NoDirection
- mov Direction, 1
- jmp EndProc
- SecondCheck:
- cmp al, 32
- ja NoDirection
- jne ThirdCheck
- cmp Direction, 2
- je NoDirection
- mov Direction, 4
- jmp EndProc
- ThirdCheck:
- cmp al, 31
- ja NoDirection
- jne FourthCheck
- cmp Direction, 1
- je NoDirection
- mov Direction, 3
- jmp EndProc
- FourthCheck:
- cmp al, 30
- jne NoDirection
- cmp Direction, 4
- je NoDirection
- mov Direction, 2
- jmp EndProc
- NoDirection:
- mov al, 5
- EndProc:
- ret
- endp DirectionTranslation
- proc Delay
- mov dx, 1500
- DelayLoopOut:
- mov cx, 3000
- DelayLoopIn:
- loop DelayLoopIn
- dec dx
- cmp dx, 0
- ja DelayLoopOut
- ret
- endp Delay
- proc UpdateSnake
- mov bx, SnakeLength
- shl bx, 1
- sub bx, 2
- add bx, offset Snake
- mov si, [bx]
- mov al, 0
- call PrintLimb
- mov cx, SnakeLength
- sub cx, 1
- UpdateLoop:
- mov ax, [bx - 2]
- mov [bx], ax
- sub bx, 2
- loop UpdateLoop
- cmp Direction, 1
- jne SecondUpdate
- sub [bx], 1280
- mov si, [bx]
- cmp es:si, 0
- je EndProc2
- jmp PlayerDead
- SecondUpdate:
- cmp Direction, 2
- jne ThirdUpdate
- sub [bx], 4
- mov si, [bx]
- cmp [byte ptr es:si], 0
- je EndProc2
- jmp PlayerDead
- ThirdUpdate:
- cmp Direction, 3
- jne FourthUpdate
- add [bx], 1280
- mov si, [bx]
- cmp es:si, 0
- je EndProc2
- jmp PlayerDead
- FourthUpdate:
- add [bx], 4
- mov si, [bx]
- cmp es:si, 0
- je EndProc2
- PlayerDead:
- mov dl, 1
- EndProc2:
- mov al, 4
- call PrintLimb
- mov si, [bx + 2]
- mov al, 3
- call PrintLimb
- ret
- endp UpdateSnake
- proc PrintLimb
- push cx
- mov cx, 3
- mov dx, 3
- sub si, 321
- PrintLimbLoop:
- mov es:si, al
- inc si
- dec dx
- cmp dx, 0
- jne PrintLimbLoop
- mov dx, 3
- add si, 317
- loop PrintLimbLoop
- pop cx
- ret
- endp PrintLimb
- proc PrintWalls
- mov cx, 199
- mov si, 0
- FirstSide:
- mov es:si, 5
- add si, 320
- loop FirstSide
- mov cx, 320
- inc si
- SecondSide:
- mov es:si, 5
- inc si
- loop SecondSide
- mov cx, 200
- sub si, 320
- ThirdSide:
- mov es:si, 5
- sub si, 320
- loop ThirdSide
- mov cx, 320
- dec si
- FourthSide:
- sub es:si, 5
- dec si
- loop FourthSide
- ret
- endp PrintWalls
- start:
- mov ax, @data
- mov ds, ax
- mov ax, 13h
- int 10h
- mov ax, 0A000h
- mov es, ax
- call PrintWalls
- mov cx, SnakeLength
- sub cx, 1
- mov bx, offset Snake
- mov si, [bx]
- mov al, 4
- call PrintLimb
- add bx, 2
- mov al, 3
- FirstPrint:
- mov si, [bx]
- call PrintLimb
- add bx, 2
- loop FirstPrint
- WaitForDirection:
- xor ah, ah
- int 16h
- mov al, ah
- call DirectionTranslation
- cmp al, 5
- je WaitForDirection
- GameLoop:
- in al, 64h
- cmp al, 10b
- je NoNewPress
- in al, 60h
- call DirectionTranslation
- NoNewPress:
- call Delay
- call UpdateSnake
- cmp dl, 1
- je GameOver
- jmp GameLoop
- GameOver:
- exit:
- mov ax, 4c00h
- int 21h
- END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement