cpu 8086 ;org 0x100 org 0 ; Set basic video mode (40-column text) mov ax,1 int 0x10 ; Put a nice picture in CGA RAM mov si,imageData mov ax,cs mov ds,ax mov ax,0xb800 mov es,ax xor di,di cld mov cx,8000 rep movsw ; Wait for vertical sync before reprogramming for consistency mov dx,0x3da waitForVerticalSync: in al,dx test al,8 jz waitForVerticalSync ; Disable flashing mov dl,0xd8 mov al,0x08 out dx,al ; Initial CRTC reprogramming mov dl,0xd4 mov ax,0x0009 ; Scanlines per row = 1 out dx,ax mov ax,0x7007 ; Vertical sync position = 112 out dx,ax mov ax,0x0503 ; Horizontal sync width = 5 out dx,ax ; We can't have more than 127 active scanlines in the top half or we'll be interrupted by vsync somewhere. ; The total number of scanlines (262) is greater than twice the maximum number of active scanlines (127) so we will need to use vertical total adjust ; Active scanlines 0..199 ; Lower blank 200..223 ; Vsync 224..226 ; Upper blank 227..261 ; We can't use vertical total adjust for the top half, so this is one of our adjusted registers ; Suppose we use a vertical total adjust of 30. Then we have 232 normal scanlines. ; If we have 100 scanlines in the top half, then the bottom half is too small, so this is one of our adjusted registers ; If we keep the vertical sync position at X and vary the vertical total between Y (