;Compile into a .COM file
TITLE   CGA test program
.MODEL TINY
.8086		 ;Use 8086 code
.DATA

AUTHOR	DB	"Made by Dennis Katsonis",0ah,0dh,24h

.CODE
.STARTUP

START:

	MOV     AX,0B800h
	MOV     ES,AX           ;and ES to start of video mem for CGA
	XOR     DI,DI
	MOV     AX,0005h
	INT     10h
	MOV     AH,0Bh
	MOV     BX,0100h
	INT     10h

	MOV     CX,8000d
LOOP1:
	DEC     CX

	MOV     BL,11101001B    ;Each 2 bits represents 1 pixel
	MOV     ES:[DI],BL
	INC     DI
	TEST    CX,CX
	JNE     LOOP1
	MOV     CX,8000d        ;copy 8000 bytes (8000 x 4 = 32000 pixels)
	MOV     DI,8192         ;point DI to second half of video mem
				;which is NOT immediately after the first half

LOOP2:
	DEC     CX

	MOV     BL,00110101B    ;Fill with a different colour
	MOV     ES:[DI],BL
	INC     DI
	TEST    CX,CX
	JNE     LOOP2

	MOV     AH,07h
	INT     21h             ;Wait for a keypress
	MOV     AX,0003h                ;Set back to text mode
	INT     10h
	MOV     DX,OFFSET AUTHOR         ;Print my name
	MOV     AH,09h
	INT     21h

	MOV     AX,4C00H         ; Send exit code to dos
	INT     21H             ; Send command to DOS

AUTHOR          DB      "Made by Dennis Katsonis",0ah,0dh,24h


END
