TITLE PGM16_2A.ASM: BALL DISPLAY
    PUBLIC SET_DISPLAY_MODE, DISPLAY_BALL
.MODEL SMALL
DRAW_ROW MACRO  X
     LOCAL L1
;draws a line from column 10 to column 300
    MOV AH,0CH ;draw pixel
    MOV AL,1   ;cyan
    MOV CX,10  ;column 10
    MOV DX,X   ;row X
L1: INT 10H
    INC CX     ;next column
    CMP CX,301 ;beyond column 300
    jl l1      ;no,repeat
    ENDM
;
DRAW_COLUMN MACRO   Y
    LOCAL L2
;draws a line in column Y from row 10 to row 189
    MOV AH,0CH    ;draw pixel
    MOV AL,1      ;cyan
    MOV CX,Y      ;column Y
    MOV DX,10     ;row 10
L2: INT 10H       
    INC DX        ;next row
    CMP DX,190    ;beyond row 189
    JL L2         ;no,repeat
    ENDM
;
.CODE
SET_DISPLAY_MODE  PROC
;set display mode and boundary
   MOV AH,0       ;set mode
   MOV AL,04H     ;mode 4,320*200 4 color
   INT 10H        
   MOV AH,0BH     ;select palette
   MOV BH,1
   MOV BL,1       ;palette 1
   INT 10H
   MOV BH,0       ;set background color
   MOV BL,2       ;green
   INT 10H
;draw boundary
   DRAW_ROW   10
   DRAW_ROW   189
   DRAW_COLUMN 10
   DRAW_COLUMN 300
   RET
SET_DISPLAY_MODE  ENDP


DISPLAY_BALL  PROC
;display ball at column CX and row DX with color given
;in AL
;input : AL =  color of ball
;CX column
;DX row

      MOV AH,0CH ;write pixel
      INT 10H    
      INC CX     ;pixel on next column 
      INT 10H
      INC DX     ;down 1  row
      INT 10H
      DEC CX     ;up 1 column
      INT 10H
      DEC DX     ;restor DX
      RET

DISPLAY_BALL ENDP
      END





      MOV
