Browse Source

introduced use of movsz and added error for termsize

Phil 4 năm trước cách đây
mục cha
commit
ff05d2ff8b
1 tập tin đã thay đổi với 24 bổ sung10 xóa
  1. 24 10
      dino.asm

+ 24 - 10
dino.asm

@@ -34,6 +34,10 @@ section .data
 	pls db 0x2b		;plus for corner
 	hl db 0x2d		;horizontal line |
 	vl db 0x7c		;vertical line -
+
+	;error
+	txt_error_term_dim db 'Error terminal got wrong dimensions'
+	txt_error_term_dim edu 35
 	
 	;timer
 	tfd RESB 4		;file descriptro
@@ -101,11 +105,11 @@ _start:
 	;top	
 	xor eax, eax
 	xor bx, bx
-	mov ax, [srow]
-	and ax, 0xFF		; bitmask so that only srow (1byte) is inside ax (2byte) else it is scol+srow
-	mov bx, [gh]
-	and bx, 0xFF
-	sub ax, bx		;screenrows - geameheight
+	movzx ax, [srow]	;move one byte fill rest with zero
+	;and ax, 0xFF		; bitmask so that only srow (1byte) is inside ax (2byte) else it is scol+srow
+	;mov bx, [gh]
+	;and bx, 0xFF
+	sub ax, [gh]		;screenrows - geameheight
 	mov bl, 2
 	div bl
 	mov al, 0x6
@@ -113,11 +117,11 @@ _start:
 	;jmp exit
 
 	;left
-	mov ax, [scol]
-	and ax, 0xFF
-	mov bx, [gw]
-	and bx, 0xFF
-	sub ax, bx
+	movxz ax, [scol]
+	;and ax, 0xFF
+	;mov bx, [gw]
+	;and bx, 0xFF
+	sub ax, [gw]
 	mov bl, 0x2
 	div bl
 	mov [lof], al
@@ -287,3 +291,13 @@ fd_wait:
 	mov edx, 0x20
 	int 0x80
 	ret
+
+
+error_term_dim:
+	mov eax, SYS_WRITE
+	mov ebx, STDOUT
+	mov ecx, txt_error_term_dim
+	mov edx, txt_error_term_dim_size
+	int 0x80
+
+	jmp exit