Il 0% ha trovato utile questo documento (0 voti)
2 visualizzazioni53 pagine

Check

Caricato da

rizwanarshad042
Copyright
© All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato DOC, PDF, TXT o leggi online su Scribd
Il 0% ha trovato utile questo documento (0 voti)
2 visualizzazioni53 pagine

Check

Caricato da

rizwanarshad042
Copyright
© All Rights Reserved
Per noi i diritti sui contenuti sono una cosa seria. Se sospetti che questo contenuto sia tuo, rivendicalo qui.
Formati disponibili
Scarica in formato DOC, PDF, TXT o leggi online su Scribd

[org 0x0100]

JMP start

;----------TEXT TO DISPLAY IN GAME------------

difficulty: db 'EASY'
size3: dw size3-difficulty
score: db 'SCORE : 000'
size4: dw size4-score
timer: db '00:11'
size5: dw size5-timer
mistakes: db ' MISTAKES : 1 / 3 '
size6: dw size6-mistakes
notes: db ' NOTES '
size7: dw size7-notes
notes_extend: db '(Press I:On O:Off)'
size8: dw size8-notes_extend
undo: db ' UNDO '
size9: dw size9-undo
undo_extend: db ' (Press U) '
size10: dw size10-undo_extend
erase: db ' ERASE '
size11: dw size11-erase
erase_extend: db ' (Press E) '
size12: dw size12-erase_extend
failed: db 'Failed', 0
length6: dw 6
game_completed: db 'Game Completed', 0
length7: dw 14
successful: db 'Successful', 0
length8: dw 10
score_last: db 'Score', 0
length9: dw 5
time: db 'Time', 0
length10: dw 4
mistakes_last: db 'Mistakes', 0
length11: dw 8
new_game: db 'Press 1 for New Game', 0
length12: dw 20
exit: db 'Press Esc for Exit', 0
length13: dw 18
time_value: db '12:45', 0
length14: dw 5
score_value: db '1234', 0
length15: dw 4
mistakes_value: db '3', 0
length16: dw 1
select_level: db ' Select Level ', 0
length2: dw 17
easy: db ' Easy ', 0
length3: dw 17
medium: db ' Medium ', 0
length4: dw 17
hard: db ' Hard ', 0
length5: dw 17
pointer_flag: db 1
option: db 1

;---------------------------------------------

; subroutine to clear the screen

clrscr:

push es
push cx
push di
mov ax, 0xb800
mov es, ax ; point es to video base
xor di, di ; point di to top left column
mov al, 0x20 ; space char in normal attribute
mov cx, 2000 ; number of screen locations
cld ; auto increment mode
rep stosw ; clear the whole screen
pop di
pop cx
pop es

ret

; ---------display 9 number cards on the left--------

number_cards:

pusha

MOV AH, 00110100b

nine_cards:

mov al,201 ;top left corner


mov [es:di],ax
add di,2
mov al,205 ;double horizontal bar
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov al,187 ;top right corner
mov [es:di],ax
add di,2

add di,150

mov al,186 ;double vertical bar


mov [es:di],ax
add di,4

MOV AH, 00110000b


mov al,dl ;the dl starts from number 1 upto 9 (to be displayed in each
number card)
mov [es:di],ax
add di,4

MOV AH, 00110100b


mov al,186
mov [es:di],ax
add di,2

add di,150

mov al,200 ;bottom left corner


mov [es:di],ax
add di,2
mov al,205
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov al,188 ;bottom right corner
mov [es:di],ax
add di,2

add di,150

popa

ret

; ---------Print Grid---------------

print_boxes:

mov cx,6 ;loop counter for 6 rows


mov dx,66 ;160 will be added evertime...used for checking line end
mov si,24 ;horizontal line change after every 3 boxes
mov bx,1920 ;used for comparison to see if 3 row is reached after
every 2nd row

add di,4

MOV AH, 00110000b

add di,30 ;for positioning--------------


add dx,di;same as above
add bx,di

add si,di ;adjust after positioning

mov al,201 ;top left corner


mov [es:di],ax
add di,2

horizontal_bars:

mov al,205 ;double horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

cmp di,si ;after every 3 boxes


jnz .next

mov al,203 ;double line after every 3 boxes


mov [es:di],ax
add di,2
add si,24
jmp .no_next

.next:
mov al,209 ;double horizontal + single vertical
mov [es:di],ax
add di,2

.no_next:
cmp di,dx
jnz horizontal_bars
add dx,160

mov al,205 ;double horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

mov al,187 ;top right corner


mov [es:di],ax
add di,2

add di,86 ;next line


mov si,di
add si,24

nine_times:

mov al,186 ;double vertical bar


mov [es:di],ax
add di,2

vertical_bars:

add di,6

cmp di,si
jnz .next1

mov al,186 ;double vertical bar


mov [es:di],ax
add di,2
add si,24
jmp .no_next1
.next1:
mov al,179 ;single vertical bar
mov [es:di],ax
add di,2

.no_next1:
cmp di,dx ;================
jnz vertical_bars

add dx,160

add di,6

mov al,186 ;double vertical bar


mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

mov [es:di],ax
add di,2

second_line:

add di,2
mov al,0x35 ;number 5
mov [es:di],ax
add di,4

cmp di,si
jnz .next2
mov al,186 ;double vertical bar
mov [es:di],ax
add di,2
add si,24
jmp .no_next2

.next2:
mov al,179 ;single vertical bar
mov [es:di],ax
add di,2

.no_next2:
cmp di,dx ;================
jnz second_line
add dx,160

add di,2

mov al,0x35 ;number 5


mov [es:di],ax
add di,4

mov al,186 ;double vertical bar


mov [es:di],ax
add di,2
add di,86

mov si,di
add si,24

mov [es:di],ax
add di,2

third_line:

add di,6

cmp di,si
jnz .next3
mov al,186 ;double vertical bar
mov [es:di],ax
add di,2
add si,24
jmp .no_next3

.next3:
mov al,179 ;single vertical bar
mov [es:di],ax
add di,2

.no_next3:
cmp di,dx ;================

jnz third_line
add dx,160
add di,6
mov al,186 ;vertical bar
mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

;yahan comparing krrhy hain ky 2lines wali me bhejna ha ya 3rd line


wali me

cmp di,bx ;S==============


jz fourth_3rdline

fourth_line:

.fourth_2lines:

mov al,199 ;double vertical bar + single horizontal bar


mov [es:di],ax
add di,2

.two_lines_next:

mov al,196 ;horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

cmp si,di
jnz .next5

mov al,215 ;cross double vertical bar + single horizontal bar


mov [es:di],ax
add di,2
add si,24
jmp .no_next5

.next5:

mov al,197 ;cross single bars


mov [es:di],ax
add di,2

.no_next5:

cmp di, dx
jnz .two_lines_next

add dx,160

mov al,196 ;single horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov al,182 ;right border double vertical bar + single horizontal bar
mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

jmp loop_check

fourth_3rdline:

mov al,204 ;double bars


mov [es:di],ax
add di,2

third_line_next:

mov al,205 ;double bars


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

cmp di,si
jnz .next4
mov al,206 ;cross double bars
mov [es:di],ax
add di,2
add si,24
jmp .no_next4

.next4:
mov al,216 ;cross double horizontal bar + single vertical bar
mov [es:di],ax
add di,2

.no_next4:
cmp di, dx
jnz third_line_next

add dx,160

mov al,205 ;double horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

mov al,185 ;right border double horizontal bar + double vertical bar
mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

add bx,1920

loop_check:
dec cx
cmp cx,0
jnz nine_times

ret

; ------Options Box On The Right------------

options_box:

pusha

mov ah,00001111b
mov di,756
mov si,0

.mistakes_display: ;mistakes text display

mov al,[mistakes+si]
mov [es:di],AX
add di,2
inc si
cmp si,[size6]
jnz .mistakes_display

mov di,914 ;starting of line (top left corner of box)


mov ah,00110100b
mov cx,38 ;width of box for upper line comparison
mov al,201 ;top left corner
mov [es:di],ax
add di,2

horizontal_line_of_box:
mov al,205 ;horizontal bar
mov [es:di],ax
add di,2
sub cx,2
cmp cx,0
jnz horizontal_line_of_box

mov al,187 ;top right corner


mov [es:di],ax
add di,2

mov cx,30 ;length of box

mov di,1074 ;starting of second line

other_lines: ;right and left vertical line of box

mov al,186 ;vertical bar


mov [es:di],ax
add di,40
mov al,186
mov [es:di],ax
add di,120

sub cx,2
cmp cx,0
jnz other_lines
mov cx,38 ;width of box for bottom line comparison

mov al,200 ;bottom left corner


mov [es:di],ax
add di,2

bottom_line:
mov al,205
mov [es:di],ax
add di,2
sub cx,2
cmp cx,0
jnz bottom_line

mov al, 188 ;bottom right corner


mov [es:di],ax
add di,2

;--------Options In Box--------------

mov ah,00110100b
mov di, 1240

mov al,175 ;arrow bullet point


mov [es:di],ax
add di,4

mov si,0

mov ah,01110100b
.notes_text: ;-----------
mov al,[notes+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size7]
jnz .notes_text

mov ah,00110001b
mov di, 1558
mov si,0

.notes_buttons:
mov al,[notes_extend+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size8]
jnz .notes_buttons

mov ah,00110100b
mov di, 2040

mov al,175 ;arrow bullet point


mov [es:di],ax
add di,4

mov si,0

mov ah,01110100b
.undo_text:;-----------
mov al,[undo+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size9]
jnz .undo_text

mov ah,00110001b
mov di, 2360
mov si,0

.undo_button:
mov al,[undo_extend+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size10]
jnz .undo_button

mov ah,00110100b
mov di, 2840

mov al,175 ;arrow bullet point


mov [es:di],ax
add di,4

mov si,0

mov ah,01110100b

.erase_text:;-----------
mov al,[erase+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size11]
jnz .erase_text

mov ah,00110001b
mov di, 3160
mov si,0

.erase_button:
mov al,[erase_extend+si]
mov [es:di],ax
add di,2
inc si
cmp si,[size12]
jnz .erase_button

popa

ret

last_3_rows:

mov cx,3 ;loop counter for 3 rows


mov dx,66 ;160 will be added evertime...used for checking line end
mov si,24 ;horizontal line change after every 3 boxes
mov bx,1760

add di,34;for positioning...yahan mul wala formula lgana he


add dx,di;same as above
add bx,di
add si,di ;adjust after positioning

three_times:

mov al,186 ;vertical bar (changed to thick bar)


mov [es:di],ax
add di,2

vertical_bars_3:

add di,6

cmp di,si
jnz next1

mov al,186 ;vertical bar


mov [es:di],ax
add di,2
add si,24
jmp no_next1

next1:
mov al,179 ;vertical bar
mov [es:di],ax
add di,2

no_next1:
cmp di,dx ;================
jnz vertical_bars_3
add dx,160
add di,6

mov al,186 ;vertical bar


mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

mov al,186 ;vertical bar


mov [es:di],ax
add di,2

second_line_3:

add di,2

mov al,0x35 ;number 5


mov [es:di],ax
add di,2

add di,2

cmp di,si ;================

jnz next2
mov al,186 ;vertical bar
mov [es:di],ax
add di,2
add si,24
jmp no_next2

next2:
mov al,179 ;vertical bar
mov [es:di],ax
add di,2

no_next2:
cmp di,dx ;================
jnz second_line_3
add dx,160

add di,2

mov al,0x35 ;number 5


mov [es:di],ax
add di,4

mov al,186 ;vertical bar


mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

mov al,186 ;vertical bar


mov [es:di],ax
add di,2

third_line_3:

add di,6

cmp di,si
jnz next3
mov al,186 ;vertical bar
mov [es:di],ax
add di,2
add si,24
jmp no_next3

next3:
mov al,179 ;vertical bar
mov [es:di],ax
add di,2

no_next3:
cmp di,dx ;================

jnz third_line_3
add dx,160
add di,6

mov al,186 ;vertical bar


mov [es:di],ax
add di,2

add di,86
mov si,di
add si,24

;yahan comparing krty hain ky 2lines wali me bhejna ha ya 3r line


wali me...

cmp di,bx ;================


jz fourth_3rdline_3

fourth_line_3:

fourth_2lines_3:

mov al,199 ;horizontal bar (in place of bottom left corner)


mov [es:di],ax
add di,2

two_lines_next_3:

mov al,196 ;horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

cmp si,di
jnz next5
mov al,215 ;horizontal bar
mov [es:di],ax
add di,2
add si,24
jmp no_next5

next5:

mov al,197 ;horizontal bar


mov [es:di],ax
add di,2

no_next5:

cmp di, dx
jnz two_lines_next_3

add dx,160

mov al,196 ;horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

mov al,182 ;horizontal bar (in place of bottom right corner)


mov [es:di],ax
add di,2

add di,86
mov si,di
add si,24

jmp loop_check_3

fourth_3rdline_3:

mov al,200 ;horizontal bar (in place of bottom left corner)


mov [es:di],ax
add di,2

third_line_next_3:

mov al,205 ;horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

cmp di,si
jnz next4

mov al,202 ;horizontal bar (in place of bottom left corner)


mov [es:di],ax
add di,2
add si,24
jmp no_next4
next4:
mov al,207 ;horizontal bar (in place of bottom left corner)
mov [es:di],ax
add di,2

no_next4:
cmp di, dx
jnz third_line_next_3

add dx,160

mov al,205 ;horizontal bar


mov [es:di],ax
add di,2
mov [es:di],ax
add di,2
mov [es:di],ax
add di,2

mov al,188 ;horizontal bar (in place of bottom right corner)


mov [es:di],ax
add di,2

add di,86

mov si,di
add si,24

add bx,1920

loop_check_3:
dec cx
cmp cx,0
jnz three_times

ret

;---------Ending Screen Display Subroutine-------------

; clear screen function and set background white


clearscreen:
push es
push ax
push di

mov ax, 0xb800


mov es, ax
xor di, di

clear_loop:
mov word [es:di], 0x3820
add di, 2
cmp di, 4000
jne clear_loop

pop di
pop ax
pop es
ret

; Function to print a string at specified x, y with attribute


print_string:
push bp
mov bp, sp
push es
push ax
push cx
push si
push di

mov ax, 0xb800


mov es, ax

mov al, 80
mul byte [bp + 10] ; AL * y
add ax, [bp + 12] ; Add x position
shl ax, 1
mov di, ax

mov si, [bp + 6] ; string memory


mov cx, [bp + 4] ; string length
mov ah, [bp + 8] ; attribute

printing:
mov al, [si]
mov [es:di], ax
add di, 2
add si, 1
sub cx, 1
jnz printing

pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 10
Draw_border2:
push es
push ax
push di

mov ax, 0xb800


mov es, ax

mov bx, 4
mov ax, 160
mul bx
add ax, 32
mov di, ax
mov cx, 40

top_border2:
mov word [es:di], 0x1F3D
add di, 2
dec cx
jnz top_border2

mov bx, 15
mov ax, 160
mul bx
add ax, 32
mov di, ax
mov cx, 40

bottom_border2:
mov word [es:di], 0x1F3D
add di, 2
dec cx
jnz bottom_border2
mov bx, 5
mov ax, 160
mul bx
add ax, 32
mov di, ax
mov cx, 11

left_border2:
mov word [es:di], 0x1F3D
add di, 160
dec cx
jnz left_border2

mov bx, 5
mov ax, 160
mul bx
add ax, 110
mov di, ax
mov cx, 11

right_border2:
mov word [es:di], 0x1F3D
add di, 160
dec cx
jnz right_border2

pop di
pop ax
pop es

ret
section .text
call hide_cursor

menu_printing:
mov ax, 32
push ax
mov ax, 8
push ax
mov ax, 0x1E
push ax
mov ax, select_level
push ax
push word [length2]
call print_string

mov ax, 32
push ax
mov ax, 11
push ax
cmp byte [pointer_flag], 1
je draw_easy_selected
jmp draw_easy
draw_easy_selected:
mov ax, 0x0C
jmp draw_easy
draw_easy:
push ax
mov ax, easy
push ax
push word [length3]
call print_string

mov ax, 32
push ax
mov ax, 13
push ax
cmp byte [pointer_flag], 2
je draw_medium_selected
jmp draw_medium
draw_medium_selected:
mov ax, 0x0C
jmp draw_medium
draw_medium:
push ax
mov ax, medium
push ax
push word [length4]
call print_string

mov ax, 32
push ax
mov ax, 15
push ax
cmp byte [pointer_flag], 3
je draw_hard_selected
jmp draw_hard
draw_hard_selected:
mov ax, 0x0C
jmp draw_hard
draw_hard:
push ax
mov ax, hard
push ax
push word [length5]
call print_string
ret

check_key_press:
mov ah, 0x00
int 16h

cmp al, 0x0D


je enter_key_for_startingScreen

cmp ah, 0x48


je up_key
cmp ah, 0x50
je down_key

jmp key_wait

up_key:
cmp byte [pointer_flag], 1
jle wrap_to_bottom
dec byte [pointer_flag]
call clrscr
call menu_printing
jmp key_wait

down_key:
cmp byte [pointer_flag], 3
jge wrap_to_top
inc byte [pointer_flag]
call clrscr
call menu_printing
jmp key_wait

wrap_to_top:
mov byte [pointer_flag], 1
call clrscr
call menu_printing
jmp key_wait

wrap_to_bottom:
mov byte [pointer_flag], 3
call clrscr
call menu_printing
jmp key_wait

enter_key_for_startingScreen:
mov bl, byte [pointer_flag]
mov byte [option], bl

call clrscr
jmp next_start
check_key_press1:
mov ah, 0x00
int 16h

cmp al, 0x0D ; Enter key


je enter_key

cmp ah, 0x48 ; Up arrow key


je up_key1

cmp ah, 0x50 ; Down arrow key


je down_key1

jmp check_key_press1

up_key1:
cmp byte [pointer_flag], 1
jle wraping_to_bottom
dec byte [pointer_flag]
call ending_screen
jmp check_key_press1

down_key1:
cmp byte [pointer_flag], 2
jge wraping_to_top
inc byte [pointer_flag]
call ending_screen
jmp check_key_press1

wraping_to_top:
mov byte [pointer_flag], 1
call ending_screen
jmp check_key_press1

wraping_to_bottom:
mov byte [pointer_flag], 2
call ending_screen
jmp check_key_press1
enter_key:
mov bl, byte [pointer_flag]
mov byte [option], bl

call clrscr
cmp byte [option], 1
je start

cmp byte [option], 2


je exit
ex
;===================================================
;====================START==========================
;===================================================

start:
call clrscr1
call show_title

MOV ah,0x1 ;interrupt ------idhr enter key bhi aaskti


INT 0x21

CALL clrscr
MOV AX, 0xB800
MOV ES, AX
MOV SI, 0
MOV DI, 0
MOV al,0x20
MOV ah,00110111b

call clrscr
call menu_printing
key_wait:
call check_key_press
jmp key_wait

next_start:
MOV ah,0x1 ;interrupt ------idhr enter key bhi aaskti
INT 0x21
CALL clrscr
;-------Blue Background---------

background:
MOV [ES:DI], AX
ADD DI, 2

CMP DI, 4000


JNZ background

MOV AH, 0x47


MOV DI,360

;--------Print Number Cards----------

MOV AH, 00110000b

MOV BX,496
MOV DI,484
MOV CX,4
MOV dl,0x31

print_cards:

CALL number_cards
MOV DI,BX
INC DL
CALL number_cards
INC DL
ADD di,468
ADD bx,480

dec cx
cmp cx,0
jnz print_cards
CALL number_cards

;-----Display Difficulty----------

MOV si,0
MOV di,64
MOV ah,00110001b

difficulty_display:

MOV AL, [difficulty + SI]


MOV [ES:DI], AX
ADD DI, 2

INC SI
CMP SI, [size3]
JNZ difficulty_display

;---------Display Score-----------

MOV si,0
MOV di,130

score_display:
MOV AL, [score + SI]
MOV [ES:DI], AX
ADD DI, 2

INC SI
CMP SI, [size4]
JNZ score_display

;-------Dispay Timer----------

MOV si,0
MOV di,6

timer_display:

MOV AL, [timer + SI]


MOV [ES:DI], AX
ADD DI, 2

INC SI
CMP SI, [size5]
JNZ timer_display

;--------------Display Grid------------------

MOV si,0
MOV di,0
CALL print_boxes

;-------------Display Options Box-------------

CALL options_box

;-------------Ending Screen Code----------------

jmp check_arrow_keys ;if this is not written, then after displaying


above things, it will suddenly clrscr and display ending screen

ending_screen:

call clearscreen
call Draw_border2

; Print "Game Completed"


mov ax, 28
push ax
mov ax, 9
push ax
mov ax, 0x3A
push ax
mov ax, game_completed
push ax
push word [length7]
call print_string
; Print "Score"
mov ax, 11
push ax
mov ax, 18
push ax
mov ax, 0x1B
push ax
mov ax, score_last
push ax
push word [length9]
call print_string

; Print Score Value


mov ax, 18
push ax
mov ax, 18
push ax
mov ax, 0x3c
push ax
mov ax, score_value
push ax
push word [length15]
call print_string

; Print "Time"
mov ax, 35
push ax
mov ax, 18
push ax
mov ax, 0x1B
push ax
mov ax, time
push ax
push word [length10]
call print_string

; Print Time Value


mov ax, 41
push ax
mov ax, 18
push ax
mov ax, 0x3c
push ax
mov ax, time_value
push ax
push word [length14]
call print_string

; Print "Mistakes"
mov ax, 55
push ax
mov ax, 18
push ax
mov ax, 0x1B
push ax
mov ax, mistakes_last
push ax
push word [length11]
call print_string

; Print Mistakes Value


mov ax, 65
push ax
mov ax, 18
push ax
mov ax, 0x3c
push ax
mov ax, mistakes_value
push ax
push word [length16]
call print_string

; Print "New Game"


mov ax, 28
push ax
mov ax, 20
push ax
mov ax, 0x3B
push ax
mov ax, new_game
push ax
push word [length12]
call print_string

; Print "Exit"
mov ax, 29
push ax
mov ax, 22
push ax
mov ax, 0x3B
push ax
mov ax, exit
push ax
push word [length13]
call print_string

; Check if mistakes equals 3 then it jumps to failed otherwise to


successful
mov al, [mistakes_value]
cmp al, 3
jne print_failed

; Print "Successful"
mov ax, 32 ; X coordinate
push ax
mov ax, 12 ; Y coordinate
push ax
mov ax, 0x3B ; Attribute
push ax
mov ax, successful ; Memory
push ax
push word [length8] ; Length
call print_string
jmp check_arrow_keys

print_failed:
; Print "Failed"
mov ax, 32 ; X coordinate
push ax
mov ax, 12 ; Y coordinate
push ax
mov ax, 0x3B ; Attribute
push ax
mov ax, failed ; Memory
push ax
push word [length6] ; Length
call print_string

ret

;-------------check arrow keys-----------------

check_arrow_keys:

MOV AH, 0x00 ; BIOS keyboard interrupt to read a key


INT 0x16 ; Call BIOS interrupt

CMP AH, 0x48 ; Compare if the scan code is for the up arrow key
JE up_arrow_action ; Jump if up arrow key is pressed

CMP AH, 0x50 ; Compare if the scan code is for the down arrow
key
JE down_arrow_action ; Jump if down arrow key is pressed
CMP AH, 0x4D ; Compare if the scan code is for the right arrow
key
JE right_arrow_action ; Jump if right arrow key is pressed

CMP AH, 0x01 ; Compare if the scan code is for the Esc key
JE end ; Jump if Esc key is pressed

CMP AH, 0x02 ; Compare if the scan code is for the 1 key
JE start ; Jump if Esc key is pressed

; ---------Code for handling up arrow key press---------


up_arrow_action:

MOV si,0
MOV di,0
call clrscr
call background

MOV ah,0x1 ;interrupt


INT 0x21

JMP check_arrow_keys

; ---------Code for handling down arrow key press---------


down_arrow_action:

call clrscr

MOV ah,00110000b
MOV si,0
MOV di,0
call last_3_rows
MOV ah,0x1 ;interrupt
INT 0x21

JMP check_arrow_keys

; -------Code for handling right arrow key press----------


right_arrow_action:

call ending_screen

JMP check_arrow_keys

end:

MOV AX, 0x4C00


INT 0x21

;-------------Opening Screen Related Code------------------

; in:
; si = number of 55.56 ms to wait
sleep:
mov ah, 0
int 1ah
mov bx, dx
.wait:
mov ah, 0
int 1ah
sub dx, bx
cmp dx, si
jl .wait
ret

clrscr1:

pusha
mov di,0
mov ax,0xb800
mov es,ax
mov al,0x20
mov ah,00110000b

nextt:
mov [es:di],ax
add di,2
cmp di,4000
jnz nextt

popa

ret

hide_cursor:
mov ah, 02h
mov bh, 0
mov dh, 25
mov dl, 0
int 10h
ret

clear_keyboard_buffer:
mov ah, 1
int 16h
jz .end
mov ah, 0h ; retrieve key from buffer
int 16h
jmp clear_keyboard_buffer
.end:
ret

exit_process:
mov ah, 4ch
int 21h
ret

buffer_clear:
mov bx, 0
.next:
mov byte [buffer + bx], ' '
inc bx
cmp bx, 2000
jnz .next
ret

; in:
; bl = char
; cx = col
; dl = row
buffer_write:
mov di, buffer
mov al, 80
mul dl
add ax, cx
add di, ax
mov byte [di], bl
ret

; in:
; cx = col
; dx = row
; out:
; bl = char
buffer_read:
mov di, buffer
mov al, 80
mul dl
add ax, cx
add di, ax
mov bl, [di]
ret

; in:
; si = string address
; di = buffer destination offset
buffer_print_string:
.next:
mov al, [si]
cmp al, 0
jz .end
mov byte [buffer + di], al
inc di
inc si
jmp .next
.end:
ret

buffer_render:
mov ax, 0b800h
mov es, ax
mov di, buffer
mov si, 0

.write:
mov bl,[di]
mov byte [es:si], bl
inc di
add si, 2
cmp si, 4000
jnz .write
ret

show_title:
call buffer_clear
call buffer_render
mov si, 18
call sleep
mov si, 0
.next:
mov bx, [.title + si]
mov byte [buffer + bx], 219
push si
call buffer_render
mov si, 1
call sleep
pop si
add si, 2
cmp si, 310
jl .next
mov si, .text_1
mov di, 1624
call buffer_print_string
mov si, .text_2
mov di, 1781
call buffer_print_string
call clear_keyboard_buffer

.wait_for_key:
mov si, .text_4
mov di, 1388
call buffer_print_string
call buffer_render
mov si, 5
call sleep
mov ah, 1
int 16h
jnz .continue
mov si, .text_3
mov di, 1388
call buffer_print_string
call buffer_render
mov si, 10
call sleep
mov ah, 1
int 16h
jz .wait_for_key

.continue:
mov ah, 0
int 16h
ret

.title:
;----S-----
dw 0336, 0335, 0334, 0333, 0332, 0331, 0330, 0329, 0409, 0489
dw 0569, 0649, 0650, 0651, 0652, 0653, 0654, 0655, 0656, 0736
dw 0816, 0896, 0976, 0975, 0974, 0973, 0972, 0971, 0970, 0969
;----U-----
dw
0339,0419,0499,0579,0659,0739,0819,0899,0979,0980,0981,0982
dw
0983,0984,0985,0986,0906,0826,0746,0666,0586,0506,0426,0346
;----D-----
dw
0989,0909,0829,0749,0669,0589,0509,0429,0349,0350,0351,0352
dw
0353,0354,0435,0436,0516,0596,0676,0756,0836,0916,0915,0994
dw 0993,0992,0991,0990,0989
;----O-----
dw
0361,0362,0363,0364,0365,0366,0447,0527,0607,0687,0767,0847
dw
0927,1006,1005,1004,1003,1002,1001,0920,0840,0760,0680,0600
dw 0520,0440
;----K-----
dw
0372,0452,0532,0612,0692,0772,0852,0932,1012,0379,0458,0537
dw 0616,0615,0694,0693,0775,0776,0857,0938,1019
;----U-----
dw
0383,0463,0543,0623,0703,0783,0863,0943,1023,1024,1025,1026
dw
1027,1028,1029,1030,0950,0870,0790,0710,0630,0550,0470,0390

.text_1:
db " DEVELOPED BY ABDUR AND RIZWAN ", 0
.text_2:
db "(USE ARROW KEYS TO NAVIGATE THE GRID)", 0
.text_3:
db "PRESS ANY KEY TO START", 0
.text_4:
db " ", 0

section .bss

buffer resb 2000

;---------------------THE END---------------------------

Potrebbero piacerti anche