flat assembler
Message board for the users of flat assembler.

Index > DOS > hide text-mode cursor

Author
Thread Post new topic Reply to topic
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
How to hide text-mode cursor?
I found a couple of examples on net but they don't work well under Win Xp console.
Post 18 Jun 2007, 19:03
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
http://board.flatassembler.net/topic.php?t=7199 (I tested that code under WinXP SP2 32-bits)
Post 18 Jun 2007, 19:17
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Code:

;==================
; Entry: DH = Row (Y)
;        DL = Column ( X)
;==================

HIDE_RESTORE_CURSOR:
       
         xor      cx,cx
         mov      es,cx
         mov      di,0450h             ; Bios Cursor 
         mov      [es:di],dx           ; Update System Variable   

         mov      al,dh
         mov      bl,80
         mul      bl                     ; Y * 80
         movzx    dx,dl         
         add      ax,dx               ; AX = Y * 80 + X

         mov      cx,ax                ; Save for later

         mov      dx,03d4h           ; CRT Register
         mov      al,0eh               ; INDEX High Side
         out      dx,ax

         add      al,1                  ; INDEX Low Side
         mov      ah,cl
         out      dx,ax     
        

OK ,before that you exit from your program ,you must
set valid row and column .

EXAMPLE: 

;=====
; HIDE   
;=====
                 MOV  DH,25
                 MOV  DL,0
                 CALL HIDE_RESTORE_CURSOR

;========
; RESTORE  
;========

                 MOV  DH,0
                 MOV  DL,0
                 CALL HIDE_RESTORE_CURSOR

      
Post 18 Jun 2007, 19:45
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Thank you people.
Both ways working but the first time only i open a new console window and run the program. If i exit back to dos and re-run program, cursor is still there... Sad
Win XP Prof SP2 my PC.
Post 18 Jun 2007, 20:13
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
You could try this:
Code:
;====================================================;; CursorShow.                                        ;====================================================;CursorShow:        push  cx        push  ax        mov   ch,0x0b         mov   cl,0x0c         mov   ah,1        int   10h        pop   ax        pop   cx        ret;====================================================;; CursorHide.                                          ;====================================================;CursorHide:        push  cx        push  ax        mov   ch,0x1c        mov   cl,0x1b        mov   ah,1        int   10h        pop   ax        pop   cx        ret      

But i have not tryed it in xp.
Post 19 Jun 2007, 03:31
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
please post your code Question
i don't understand your problem
Post 19 Jun 2007, 10:01
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Thank you Dex, still i'm having the same problem.
Just a test file DJ Mauretto. Like this one below:
Code:
org 100h

call CursorHide

xor ax,ax
int 16h

call CursorShow

int 20h

; routines
; ...

    


Script works fine the first time, i hit a key to exit, type program's name in console to run again, and the cursor flashing..
All scripts works fine on DosBox Emulator, but not on my XP console. Rolling Eyes
Post 19 Jun 2007, 16:18
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
This work fine on Xp Wink

Code:

org 100h
use16

    mov     ah,0fh
      int     10h
;======= 
; HIDE    
;======= 

     mov     dh,25 
        mov   dl,0 
        call   HIDE_RESTORE_CURSOR 

    sub     ax,ax
       int     16h

;========== 
; RESTORE   
;========== 

 mov     dh,1 
        mov    dl,0 
        call   HIDE_RESTORE_CURSOR 

    mov     ax,4c00h
    int     21h


;======================== 
; Entry: DH = Row (Y) 
;        DL = Column (X) 
;======================== 

HIDE_RESTORE_CURSOR: 
        
     push    es

      xor     cx,cx 
      mov     es,cx  
        mov     [es:0450h],dx            ; Update System Variable    

        mov      al,dh 
        mov      bl,80 
        mul      bl                   ; Y * 80 
        movzx    dx,dl          
        add      ax,dx                 ; AX = Y * 80 + X 

        mov      cx,ax                ; Save for later 

        mov      dx,03d4h              ; CRT Register 
        mov      al,0eh              ; INDEX High Side 
        out      dx,ax 

        add      al,1                      ; INDEX Low Side 
        mov      ah,cl 
        out      dx,ax      
         
   pop     es

      ret    
Post 19 Jun 2007, 18:14
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Still the same. I'm testing it on Win XP dos console, both on my desktop and laptop PC.
Thank you for your interest DJ Mauretto. I don't know why is doing that..
Post 19 Jun 2007, 18:36
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
Confused
maybe i don't uderstand the effect that you want...
in my xp pro sp2 it's ok..
i test it in this way:
run cmd.exe ,run program ,now cursor is out the screen
and program wait a key,type any key and the cursor is on.
run program another time ,cursor is out the screen ,
program wait any key ,type key and cursor is on..

OK ?
Post 19 Jun 2007, 18:45
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
exactly, i'm doing the same.
But only the first time cursor is out the screen. Mad
Post 19 Jun 2007, 18:52
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
do you use my code without any change ?
Post 19 Jun 2007, 18:56
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Yes, copy-paste..
Post 19 Jun 2007, 18:59
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto
type command in console mode , or press ALT+ENTER on cmd.exe Wink
it's cmd.exe problem...
anyway for dos console under Xp use command.com
Post 19 Jun 2007, 19:01
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Grazie DJ Mauretto Very Happy
All scripts are working.
Post 19 Jun 2007, 19:30
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.