im trying to make a function that can paint a box of any size (and colour, using any ascii char) to the screen in order to make a game in asm.

My problem is, when i try to make it print just one full line, it dosnt seem to be able to handle it =( in my main it can print a nice box with a shadow and a line down one side of the screen - but when it comes to printing one full line accross it cant handle it!!

Can anyone help? thanks in advance

void ClearWindow(BYTE Left, BYTE Top, BYTE Right, BYTE Bottom, BYTE Char,BYTE Colour)

asm {
	xor ax, ax                 //clear ax
	xor bx, bx				   //clear bx

    mov ax, SCREEN_SEG	       //move into ax memory location of the start of the screen memory location	
	mov es, ax	               // move ax into the extra segment reg	
	xor ax, ax                 //clear ax again
	mov al, Top				   // move in to al (bottom of ax) the Top var		
	mov bl, SCREEN_WIDTH*2     //make bl the screen width (needs to be doubled for the two mem locations)
	mul bl					   //multiply bl by itself, the answer goes to bx
	xor bl, bl				   //clear bl
	mov bl, Left			   //move into bl the Left var	
	shl bl, 1				   //shift the bl reg left
	add ax, bx				   //add ax and bx reg		
	mov di, ax				   //move ax into destination index		
	xor ax, ax				   //clear ax
	mov al, Bottom			   //move the Bottom var into al          
	sub al, Top				   // subtract top from al (which is in the al reg)		
	push    ax				   // push ax onto the stack	
	xor ax, ax				   //clear the ax register
	xor bx, bx				   //clear the bx register
	xor dx, dx				   //clear the dx register					
	mov al, Right			   //move the Right var into al		
	sub al, Left			   //subtract Left from the al register   
	mov bx, ax				   //move ax into bx	
	mov bh, 1					
//This is the start of the clearscreen printing 
asm {
	xor ax, ax				   //clear ax register
	mov al, SCREEN_WIDTH*2	   //make al the screen width (needs to be doubled for the two mem locations)	
	sub al, bl				   //subtract bl from al		
	mov cx, ax				   //move ax into cx	
	sub cx, 1				   //minus 1 from cx			
	mov bh, 1				   //move 1 into bh
    xor ax, ax				   //clear ax register
    mov al, Char			   //move the print char var into the first part of ax
    mov ah, Colour			   //move into the second half of ah the colour var

  asm { 
	mov es:[di], ax
	add di, 2				   //add 2 to the di reg
	cmp bh, bl				   //compare bh to bl
	je  IncDI				   //jump to IncDI if they are equal
	inc bh					   //incrament bh reg
	loop PrintClr			   //loop back to start of PrintClr

asm {
	inc di						//incrament di reg
	loop IncDI					//go back to IncDI

asm { 
	cmp dh, 1					//check if dh is 1
	jl EndClr					//jump to the EndClr
	cmp dh, dl					//compare dh to dl				   
	je ExitClr					//jump if equal to ExitClr

	inc dh						//incrament to dh register
	jmp SClear					//jump to SClear

asm { 
	pop dx						//put dx on to the stack
	mov dh, 1					//move 1 into dh
	jmp SClear					//jump tp SClear
ExitClr:						//	

void main()
ClearWindow(0,0,80,0,219, BLUE);
ClearWindow(0,0,1,24,219, GREEN);

Frank recently posted the following code in the alt.lang.asm newsgroup.

; nasm -f bin -o hwnoint.com hwnoint.asm

org 100h

     push word 0B800h    ; segment of video memory
     pop es              ; (because stosw uses es:di)
     mov di, (10 * 80 + 30) * 2  ; offset into screen
         ; (row * width + column) * 2 bytes/character
     mov si, msg         ; offset of our string
     mov ah, 0B0h        ; color (blinking black on cyan)
     lodsb               ; get byte from [ds:si] into al
                         ; and increment si for next one
     or al, al           ; this doesn't change al, but sets
     jz depart           ; the flags - if zero, we're done
     stosw               ; stores ax (char & color) to [es:si]
                         ; and add 2 to di for next one
     jmp short top       ; do more
     ret                 ; return to dos (or other caller)

msg db " Look, Ma! No ints! ",0  ; note 0, not '$', terminated
                                  ; '$' is just for int 21h/9


This article has been dead for over six months. Start a new discussion instead.