TITLE DSHAPE -- costruct a shape from a shape table
;Constructa a shape on the screen using a shape table
data_seg segment
car 	db 7		   ;shape table
	db 52h,70h,0,0
	db 0b1h,70h,0,1
	db 0dbh,7,0,1
	db 0dbh,7,0,1
	db 4fh,7,1,0
	db 4fh,7,0,-3
	db 2,7,-2,1
data_seg ends
;------------------------------------------------------
code_seg segment
	assume cs:code_seg,ds:data_seg
main proc far
	push	ds		;for return
	sub	ax,ax
	push	ax
	mov	ax,data_seg	;initialize DS
	mov	ds,ax
	call	clear_screen	;clear the screen
	lea	di,car		;DI points to car
				;  shape table
	mov	dh,10		;body is on line 10
	mov	dl,10		;starting in col 10
	call	display_shape	;display the car
	ret
main endp
;--------------------------------------------------
clear_screen proc near
	push	ax		;save register
	push	bx
	push	cx
	push	dx
	mov	ah,6		;scroll up func.
	mov	al,0		;code to blank screen
	mov	ch,0		;upper left row
	mov	cl,0		;upper left column
	mov	dh,24		;lower right row
	mov	dl,79		;lower right column
	mov 	bh,7		;blank line attribute
	int	10h		;video ROM call
	pop	dx		;restore register
	pop	cx
	pop	bx
	pop	ax
	ret		    ;return to main program
clear_screen endp
;--------------------------------------------------
display_shape proc near
	push	ax	    ;save registers
Š	push	bx
	push	cx
	push	dx
	push	di
	mov	ah,0fh	    ;set BH to active page
	int	10h
	sub	ch,ch	    ;clear high byte of count
	mov	cl,[di]	    ;Cl holds char count
	inc	di	    ;DI points to first char
next_char:
	add	dh,[di+2]	;update row pointer
	add	dl,[di+3]	;and column pointer
	mov	ah,2		;mov cursor
	int	10h 
	mov	al,[di]		;fetch char value
	mov	bl,[di+1]	;and attribute
	push	cx
	mov	cx,1
	mov	ah,09	    ;write char to screen
	int	10h
	pop	cx
	add	di,4	    ;DI points to next char.
	loop	next_char
	pop	di	    ;when  all char. are
	pop	dx	    ;  displayed, restore
	pop	cx	    ;    registers
	pop	bx
	pop	ax
	ret
display_shape endp
;--------------------------------------------------
code_seg ends
  	 end main

