2023-03-18 13:55:53 +00:00
|
|
|
%include "ponydos.inc"
|
|
|
|
|
|
|
|
cpu 8086
|
|
|
|
bits 16
|
|
|
|
|
2023-03-17 23:05:32 +00:00
|
|
|
org 0
|
2023-03-18 13:55:53 +00:00
|
|
|
|
|
|
|
process_event:
|
|
|
|
push ax
|
|
|
|
push bx
|
|
|
|
push cx
|
|
|
|
push dx
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
push bp
|
|
|
|
push ds
|
|
|
|
push es
|
|
|
|
|
|
|
|
mov bp, cs
|
|
|
|
mov ds, bp
|
|
|
|
mov es, bp
|
|
|
|
|
|
|
|
cmp ax, WM_INITIALIZE
|
|
|
|
jne .not_initialize
|
|
|
|
call initialize
|
|
|
|
.not_initialize:
|
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
cmp ax, WM_PAINT
|
|
|
|
jne .not_paint
|
|
|
|
call paint
|
|
|
|
.not_paint:
|
|
|
|
|
2023-03-18 13:55:53 +00:00
|
|
|
pop es
|
|
|
|
pop ds
|
|
|
|
pop bp
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop dx
|
|
|
|
pop cx
|
|
|
|
pop bx
|
|
|
|
pop ax
|
|
|
|
retf
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
; Set wallpaper
|
|
|
|
mov si, wallpaper_name
|
2023-03-19 15:02:10 +00:00
|
|
|
xor dx, dx
|
2023-03-18 13:55:53 +00:00
|
|
|
call PONYDOS_SEG:SYS_OPEN_FILE
|
|
|
|
|
|
|
|
mov bp, PONYDOS_SEG
|
|
|
|
mov es, bp
|
|
|
|
mov bx, GLOBAL_WALLPAPER
|
2023-03-19 14:39:35 +00:00
|
|
|
xor di, di ; read
|
|
|
|
call PONYDOS_SEG:SYS_MODIFY_SECTORS
|
2023-03-18 13:55:53 +00:00
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
; Put window 1 in the window chain
|
|
|
|
mov ax, cs
|
|
|
|
add ax, 0x001
|
|
|
|
xchg [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
|
|
|
|
mov [next_window1], ax
|
|
|
|
|
|
|
|
; Put window 2 in the window chain
|
|
|
|
mov ax, cs
|
|
|
|
add ax, 0x002
|
|
|
|
xchg [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
|
|
|
|
mov [next_window2], ax
|
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
; Temporary testing
|
|
|
|
mov ax, cs
|
|
|
|
mov es, ax
|
|
|
|
mov di, window_1 + 16
|
|
|
|
mov cx, 3
|
|
|
|
mov dx, 8
|
|
|
|
call print_ls
|
|
|
|
|
|
|
|
mov di, window_2 + 32
|
|
|
|
mov cx, 3
|
|
|
|
mov dx, 16
|
|
|
|
call print_ls
|
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
paint:
|
|
|
|
mov bp, cs
|
|
|
|
sub bx, bp
|
|
|
|
|
|
|
|
cmp bx, 0x001
|
|
|
|
je .window1
|
|
|
|
cmp bx, 0x002
|
|
|
|
je .window2
|
|
|
|
|
|
|
|
mov ax, bx
|
|
|
|
call hexprint16
|
|
|
|
call hang
|
|
|
|
|
|
|
|
.window1:
|
|
|
|
mov bx, [next_window1]
|
|
|
|
call forward_event
|
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
mov byte [window_1.number], '1'
|
2023-03-19 14:23:30 +00:00
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
; Draw a rectangle on-screen
|
|
|
|
mov bx, 8
|
|
|
|
mov cx, 8
|
|
|
|
mov dx, 4
|
2023-03-20 09:00:57 +00:00
|
|
|
mov si, window_1
|
2023-03-19 18:50:24 +00:00
|
|
|
mov di, 10
|
|
|
|
mov bp, 3
|
|
|
|
call PONYDOS_SEG:SYS_DRAW_RECT
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
.window2:
|
|
|
|
mov bx, [next_window2]
|
|
|
|
call forward_event
|
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
mov byte [window_2.number], '2'
|
2023-03-19 18:50:24 +00:00
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
mov bx, 16
|
|
|
|
mov cx, 16
|
2023-03-19 18:50:24 +00:00
|
|
|
mov dx, 4
|
2023-03-20 09:00:57 +00:00
|
|
|
mov si, window_2
|
2023-03-19 18:52:54 +00:00
|
|
|
mov di, 14
|
2023-03-20 09:00:57 +00:00
|
|
|
mov bp, 5
|
2023-03-19 18:50:24 +00:00
|
|
|
call PONYDOS_SEG:SYS_DRAW_RECT
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
; in
|
|
|
|
; cx = height of window (>= 1)
|
|
|
|
; dx = width of window in characters
|
|
|
|
; es:di = start of output
|
|
|
|
print_ls:
|
|
|
|
push bx
|
|
|
|
push cx
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
push bp
|
|
|
|
push ds
|
|
|
|
|
|
|
|
mov bp, PONYDOS_SEG
|
|
|
|
mov ds, bp
|
|
|
|
|
|
|
|
mov si, GLOBAL_DIRENTS + 2
|
|
|
|
|
|
|
|
.file_loop:
|
|
|
|
cmp word [ds:si - 2], 0
|
|
|
|
je .done
|
|
|
|
|
|
|
|
push cx
|
|
|
|
call strlen
|
|
|
|
mov bx, cx
|
|
|
|
pop cx
|
|
|
|
|
|
|
|
cmp bx, dx
|
|
|
|
jle .not_long_filename
|
|
|
|
mov bx, dx
|
|
|
|
.not_long_filename:
|
|
|
|
|
|
|
|
push si
|
|
|
|
push di
|
|
|
|
.copy:
|
|
|
|
movsb
|
|
|
|
inc di ; Formatting
|
|
|
|
dec bx
|
|
|
|
jnz .copy
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
|
|
|
|
; Move to next line
|
|
|
|
add di, dx
|
|
|
|
add di, dx
|
|
|
|
|
|
|
|
add si, FS_DIRENT_SIZE
|
|
|
|
cmp si, GLOBAL_DIRENTS + 0x200
|
|
|
|
jge .done
|
|
|
|
|
|
|
|
dec cx
|
|
|
|
jnz .file_loop
|
|
|
|
|
|
|
|
.done:
|
|
|
|
pop ds
|
|
|
|
pop bp
|
|
|
|
pop di
|
|
|
|
pop si
|
|
|
|
pop cx
|
|
|
|
pop bx
|
|
|
|
ret
|
|
|
|
|
|
|
|
; in:
|
|
|
|
; ds:si = string
|
|
|
|
; out:
|
|
|
|
; cx = stlen
|
|
|
|
strlen:
|
|
|
|
push ax
|
|
|
|
push di
|
|
|
|
push es
|
|
|
|
|
|
|
|
mov cx, ds
|
|
|
|
mov es, cx
|
|
|
|
mov di, si
|
|
|
|
|
|
|
|
mov cx, -1
|
|
|
|
xor ax, ax
|
|
|
|
repne scasb
|
|
|
|
not cx
|
|
|
|
dec cx
|
|
|
|
|
|
|
|
pop es
|
|
|
|
pop di
|
|
|
|
pop ax
|
|
|
|
ret
|
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
; in:
|
|
|
|
; bx = window ID
|
|
|
|
; out:
|
|
|
|
; clobbers di
|
|
|
|
forward_event:
|
|
|
|
cmp bx, 0
|
|
|
|
je .end
|
|
|
|
|
|
|
|
push cs ; Return segment
|
|
|
|
mov di, .end
|
|
|
|
push di ; Return offset
|
|
|
|
|
|
|
|
mov di, 0xf000
|
|
|
|
and di, bx
|
|
|
|
push di ; Call segment
|
|
|
|
xor di, di
|
|
|
|
push di ; Call offset
|
|
|
|
retf
|
|
|
|
|
|
|
|
.end:
|
2023-03-18 13:55:53 +00:00
|
|
|
ret
|
|
|
|
|
2023-03-19 18:50:24 +00:00
|
|
|
next_window1 dw 0
|
|
|
|
next_window2 dw 0
|
|
|
|
|
2023-03-18 13:55:53 +00:00
|
|
|
wallpaper_name db 'wallpaper.bin', 0
|
2023-03-19 14:23:30 +00:00
|
|
|
|
|
|
|
%include "debug.inc"
|
|
|
|
|
2023-03-20 09:00:57 +00:00
|
|
|
window_1:
|
2023-03-19 18:50:24 +00:00
|
|
|
db 'W', 0x0f, 'i', 0x0f, 'n', 0x0f, 'd', 0x0f, 'o', 0x0f, 'w', 0x0f, ' ', 0x0f,
|
|
|
|
.number db '*', 0x0f
|
|
|
|
times 8 db ' ', 0xf0
|
|
|
|
times 8 db ' ', 0xf0
|
|
|
|
times 8 db ' ', 0xf0
|
2023-03-20 09:00:57 +00:00
|
|
|
|
|
|
|
window_2:
|
|
|
|
db 'W', 0x0f, 'i', 0x0f, 'n', 0x0f, 'd', 0x0f, 'o', 0x0f, 'w', 0x0f, ' ', 0x0f,
|
|
|
|
.number db '*', 0x0f
|
|
|
|
times 8 db ' ', 0x0f
|
|
|
|
times 16 db ' ', 0xf0
|
|
|
|
times 16 db ' ', 0xf0
|
|
|
|
times 16 db ' ', 0xf0
|