Parcourir la source

prepared for drawing frame

Phil il y a 5 ans
Parent
commit
8794d65807
1 fichiers modifiés avec 42 ajouts et 4 suppressions
  1. 42 4
      dino.asm

+ 42 - 4
dino.asm

@@ -15,10 +15,21 @@ section .data
 	ta db 0 ;tens
 	rcount db 0;
 	lb db 0xa; linebrak
+	tof db 0;	; top offset
+	lof db 0;	; left offset
+	gh db 42;	; game height
+	gw db 102;	; game width
+	scrst db 'Score: 000'	; score string
+	scrstln equ $ - scrst	; sore string length
+	tlc db 0xda		; top left corner
+	trc db 0xbf		; top right corner
+	llc db 0xd9		; lower left corner
+	lrc db 0xbe		; lower right corner
 
+	
 section .text
 	global _start
-
+		
 _start:
 	; get windwo size	
 	mov eax, SYS_IOCTL	; syscall ioctl
@@ -37,8 +48,23 @@ _start:
 	call print
 	jmp exit
 
+	;calc offset
+	;top	
+	mov ax, [srow]
+	sub ax, gh
+	div 2
+	mov [tof], al
+
+	;left
+	mov ax, [scol]
+	sub ax, gh
+	div 2
+	mov [lof], al
+
 	;print terminal
 print:
+
+topoffset:
 	mov eax, SYS_WRITE
 	mov ebx, STDOUT
 	mov ecx, lb
@@ -47,9 +73,21 @@ print:
 
 	inc byte [rcount]
 	mov al, [rcount]
-	cmp al, [srow]
-	jl print
-	ret
+	cmp al, [tof]
+	jl topoffset
+
+toprow:	 
+	mov eax, SYS_WRITE
+	mov ebx, STDOUT
+	mov ecx,  
+	mov edx, 1
+	int 0x80
+
+	inc byte [rcount]
+	mov al, [rcount]
+	cmp al, [tof]
+	jl toprow
+	
 
 exit:
 	;exit