Add windows

This commit is contained in:
Juhani Krekelä 2023-03-19 20:50:24 +02:00
parent 878cc67a83
commit d725407c5b
3 changed files with 113 additions and 18 deletions

View File

@ -10,6 +10,8 @@ variables = {
'mouse_column': None, 'mouse_column': None,
'mouse_row': None, 'mouse_row': None,
'mouse_buttons': None, 'mouse_buttons': None,
'window_chain_head': None,
'redraw': None,
} }
if len(sys.argv) != 3: if len(sys.argv) != 3:

View File

@ -87,7 +87,22 @@ draw:
mov di, mouse_column mov di, mouse_column
call flip_mouse_cursor call flip_mouse_cursor
; Draw windows
push cs ; Return segment
push word mainloop ; Return offset
mov bx, [window_chain_head]
mov ax, 0xf000
and ax, bx
push ax ; Call segment
;push word 0 ; Call offset
push cs ; Call offset
mov ax, WM_PAINT
retf
mainloop: mainloop:
cmp byte [redraw], 0
jne draw
mov bx, [di - mouse_column + mouse_x] mov bx, [di - mouse_column + mouse_x]
shr bx, 1 shr bx, 1
mov cx, [di - mouse_column + mouse_y] mov cx, [di - mouse_column + mouse_y]
@ -470,6 +485,9 @@ mouse_buttons resb 1
mouse_column resb 1 mouse_column resb 1
mouse_row resb 1 mouse_row resb 1
window_chain_head resw 1
redraw resb 1
; Last thing in bss ; Last thing in bss
boot_disk resb 1 boot_disk resb 1

111
shell.asm
View File

@ -3,7 +3,6 @@
cpu 8086 cpu 8086
bits 16 bits 16
org 0 org 0
process_event: process_event:
@ -26,6 +25,11 @@ process_event:
call initialize call initialize
.not_initialize: .not_initialize:
cmp ax, WM_PAINT
jne .not_paint
call paint
.not_paint:
pop es pop es
pop ds pop ds
pop bp pop bp
@ -47,27 +51,98 @@ initialize:
mov bx, GLOBAL_WALLPAPER mov bx, GLOBAL_WALLPAPER
call PONYDOS_SEG:SYS_READ_SECTORS call PONYDOS_SEG:SYS_READ_SECTORS
; Draw a rectangle on-screen ; Put window 1 in the window chain
mov bx, 5 mov ax, cs
mov cx, 3 add ax, 0x001
mov dx, 3 xchg [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
mov si, rect mov [next_window1], ax
mov di, 10
mov bp, 3 ; Put window 2 in the window chain
call PONYDOS_SEG:SYS_DRAW_RECT mov ax, cs
add ax, 0x002
xchg [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
mov [next_window2], ax
call wait_key
ret 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
mov byte [window.number], '1'
; Draw a rectangle on-screen
mov bx, 8
mov cx, 8
mov dx, 4
mov si, window
mov di, 10
mov bp, 3
call PONYDOS_SEG:SYS_DRAW_RECT
ret
.window2:
mov bx, [next_window2]
call forward_event
mov byte [window.number], '2'
mov bx, 8
mov cx, 8
mov dx, 4
mov si, window
mov di, 20
mov bp, 4
call PONYDOS_SEG:SYS_DRAW_RECT
ret
; 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:
ret
next_window1 dw 0
next_window2 dw 0
wallpaper_name db 'wallpaper.bin', 0 wallpaper_name db 'wallpaper.bin', 0
%include "debug.inc" %include "debug.inc"
rect: window:
db '0', 0xf0, '1', 0xf1, '2', 0xf2, '3', 0xf3, '4', 0xf4 db 'W', 0x0f, 'i', 0x0f, 'n', 0x0f, 'd', 0x0f, 'o', 0x0f, 'w', 0x0f, ' ', 0x0f,
db 'A', 0xf5, .number db '*', 0x0f
times 4 db '*', 0xf0 times 8 db ' ', 0xf0
db 'B', 0xf6 times 8 db ' ', 0xf0
times 4 db '*', 0xf0 times 8 db ' ', 0xf0
db 'C', 0xf7
times 4 db '*', 0xf0