; Constants VMEM equ 0xA000 ; Initializes 320x200 8-bit/256-color (13h) video graphics mode gfx_init_vga13: push ax mov ax, 0x0013 int 0x10 pop ax ret ; di = y*32+x ; ax = width ; bl = height ; bh = color ; ax/bl = 0 is undefined behavior. Don't do it. ; (To be clear, in the current implementation it just halts) _gfx_rect0: pusha push VMEM pop es mov dl, 0 ; row counter .row: add dl, 1 mov cx, 0 ; col counter .col: add cx, 1 mov [es:di], bh add di, 1 cmp cx, ax jnz .col sub di, ax ; di - width + 320. == x=x1; y++ add di, 320 cmp dl, bl jnz .row popa ret ; cx = x ; al = y ; dx = width ; bl = height ; bh = color gfx_rect: pusha ; Set di to y*320+x push bx push dx ; Don't forget, mul clobbers dx! mov ah, 0 mov bx, 320 mul bx add ax, cx mov di, ax pop dx pop bx ; AX CLOBBERED mov ax, dx call _gfx_rect0 popa ret ; di = y*320+x ; si = source color data ; ax = width ; bl = height ; ax/bl = 0 is undefined behavior. Don't do it. ; (To be clear, in the current implementation it just halts) _gfx_blit0: pusha push VMEM pop es mov dl, 0 ; row counter .row: add dl, 1 mov cx, 0 ; col counter .col: add cx, 1 mov dh, [si] cmp dh, 0xFF jz .ncp mov [es:di], dh .ncp: add di, 1 add si, 1 cmp cx, ax jnz .col sub di, ax ; di - width + 320. == x=x1; y++ add di, 320 cmp dl, bl jnz .row popa ret