Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- P8086
- MyStack segment stack
- DB 64 dup('12345678')
- MyStack endS
- MyData segment
- ; --- Declare your variables here ---
- prompt1 DB "Which background? (0-31): $"
- prompt2 db "Which palette? (0-1): $"
- back db 01h
- pal db 01h
- cpixl db 0c0h
- cmask db 03fh
- xpos dw 160
- ypos dw 100
- color db 03h
- MyData endS
- MyCode segment ; Sets up the segment names for
- Assume CS:MyCode,ES:MyData
- include CONIO.INC
- include time.inc
- GetMask proc
- mov ax,xpos
- mov bl,04h
- div bl
- mov cl,3
- sub cl,ah
- mov ah,color
- shl ah,cl
- shl ah,cl
- mov cpixl,ah
- mov ah,03h
- shl ah,cl
- shl ah,cl
- not ah
- mov cmask,ah
- ret
- GetMask endp
- CheckKeys proc
- mov ah,08h
- int 21h
- cmp al,48h
- je up
- cmp al,4bh
- je left
- cmp al,4dh
- je right
- cmp al,50h
- je down
- jmp keysEnd
- ;We can butcher ax now. Yay.
- up:
- cmp ypos,00h
- jle keysEnd
- dec ypos
- mov ax,ypos
- mov bl,02h
- div bl
- cmp ah,0
- je evenUp
- add di,02000h
- sub di,80 ; 320/4
- jmp keysEnd
- evenUp:
- sub di,02000h
- jmp keysEnd
- left:
- cmp xpos,0
- jle keysEnd
- dec xpos
- mov ax,xpos
- mov bl,04h
- div bl
- cmp ah,3
- jne keysEnd
- sub di,1
- jmp keysEnd
- right:
- cmp xpos,319
- jge keysEnd
- inc xpos
- mov ax,xpos
- mov bl,04h
- div bl
- cmp ah,0
- jne keysEnd
- add di,1
- jmp keysEnd
- down:
- cmp ypos,199
- jge keysEnd
- inc ypos
- mov ax,ypos
- mov bl,02h
- div bl
- cmp ah,0
- je evenDown
- add di,02000h
- jmp keysEnd
- evenDown:
- sub di,02000h
- add di,80 ; 320/4
- keysEnd:
- ret
- CheckKeys endp
- clearscreen proc
- push di
- mov di,0
- MOV CX,320*200
- FillScreenLoop:
- MOV BYTE PTR [DI],00h
- inc di
- LOOP FillScreenLoop
- pop di
- ret
- clearscreen endp
- sketch proc
- mov ah,0
- mov al,04h
- int 10h
- mov ah,0Bh
- mov bh,0
- mov bl,back
- int 10h
- mov ah,0Bh
- mov bh,1
- mov bl,pal
- int 10h
- MOV AX,0B800h
- MOV DS,AX
- mov di,0fc8h
- loopy:
- mov bl,BYTE PTR [DI]
- and bl,cmask
- or bl,cpixl
- mov BYTE PTR [DI],bl
- MOV AH,08h
- INT 21h
- cmp al,1bh
- je quit
- cmp al,09h
- jne noTab
- inc color
- cmp color,3
- jle noTab
- mov color,0
- noTab:
- cmp al,20h
- jne noClear
- call clearScreen
- noClear:
- cmp al,00h
- jne ender
- call checkKeys
- call getMask
- ender:
- jmp loopy
- quit:
- MOV AH,0
- MOV AL,03h ;Restore the screen mode to 03h (the text screen).
- INT 10h
- ret
- sketch endp
- Main PROC ; Main procedure
- Start:
- MOV AX, MyData
- MOV ES, AX
- mov DS, AX
- enterBG:
- MOV AH,9
- LEA DX,ES:prompt1 ; Let DS:DX = offset of "prompt" within DS.
- INT 21h
- CALL InputDecWord
- cmp al,31
- jg enterBG
- cmp al,0
- jl enterBG
- mov back,al
- enterPal:
- MOV AH,9
- LEA DX,ES:prompt2 ; Let DS:DX = offset of "prompt" within DS.
- INT 21h
- CALL InputDecWord
- cmp al,1
- jg enterPal
- cmp al,0
- jl enterpal
- mov pal,al
- call sketch
- mov ah, 4ch
- xor al, al
- int 21h
- Main ENDP
- MyCode endS
- End Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement