diff --git a/ponydos.asm b/ponydos.asm index 09647b6..269a168 100644 --- a/ponydos.asm +++ b/ponydos.asm @@ -15,12 +15,15 @@ FILE_MAX_SIZE equ 128 jmp 0:start ; Thunks for application programs to use -; 0x7c05 +; 0x7c05 SYS_OPEN_FILE call open_file retf -; 0x7c09 +; 0x7c09 SYS_READ_SECTORS call read_sectors retf +; 0x7c0d SYS_DRAW_RECT +call draw_rect +retf start: cld @@ -91,6 +94,7 @@ initialize_screen: mov ch, 0x20 int 0x10 +draw: ; Set up segments for drawing routines push word 0xb800 pop es @@ -122,6 +126,61 @@ mainloop: ; Drawing subroutines ; ------------------------------------------------------------------ +; in: +; bx = width of input buffer +; cx = width of rectangle +; dx = height of rectangle +; ds:si = beginning of source data +; di = X +; bp = Y +draw_rect: + pusha + push es + + push word 0xb800 + pop es + + ; Calculate the starting address in the screen buffer + ; Assumes COLUMNS is 80 + ; X columns * 2 bytes / column + shl di, 1 + ; Y rows * 80 cells / row * 2 bytes / cell = Y * 160 bytes + ; bp * 160 = bp * 128 + bp * 32 = (bp<<7) + (bp<<5) + shl bp, 5 + add di, bp + shl bp, 2 + add di, bp + + ; Convert widths to bytes + shl bx, 1 + shl cx, 1 + + .loop: + ; Any rows left to copy? + cmp dx, 0 + je .end + dec dx + + ; Copy a row + push cx + rep movsb + pop cx + + ; Move to the next row in the input buffer + add si, bx + sub si, cx + + ; Move to the next row in the screen buffer + add di, 2*COLUMNS + sub di, cx + + jmp .loop + .end: + + pop es + popa + ret + ; requires: ; ds = 0 ; es = 0xb800 diff --git a/ponydos.inc b/ponydos.inc index 5273276..86b71fd 100644 --- a/ponydos.inc +++ b/ponydos.inc @@ -2,6 +2,7 @@ PONYDOS_SEG equ 0 SYS_OPEN_FILE equ 0x7c05 SYS_READ_SECTORS equ 0x7c09 +SYS_DRAW_RECT equ 0x7c0d GLOBAL_WALLPAPER equ 0x500 diff --git a/shell.asm b/shell.asm index ca0f379..a4c04e3 100644 --- a/shell.asm +++ b/shell.asm @@ -47,6 +47,27 @@ initialize: mov bx, GLOBAL_WALLPAPER call PONYDOS_SEG:SYS_READ_SECTORS + ; Draw a rectangle on-screen + mov bx, 5 + mov cx, 3 + mov dx, 3 + mov si, rect + mov di, 10 + mov bp, 3 + call PONYDOS_SEG:SYS_DRAW_RECT + + call wait_key ret wallpaper_name db 'wallpaper.bin', 0 + +%include "debug.inc" + +rect: + db '0', 0xf0, '1', 0xf1, '2', 0xf2, '3', 0xf3, '4', 0xf4 + db 'A', 0xf5, + times 4 db '*', 0xf0 + db 'B', 0xf6 + times 4 db '*', 0xf0 + db 'C', 0xf7 + times 4 db '*', 0xf0