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_row': None,
'mouse_buttons': None,
'window_chain_head': None,
'redraw': None,
}
if len(sys.argv) != 3:

View File

@ -87,7 +87,22 @@ draw:
mov di, mouse_column
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:
cmp byte [redraw], 0
jne draw
mov bx, [di - mouse_column + mouse_x]
shr bx, 1
mov cx, [di - mouse_column + mouse_y]
@ -470,6 +485,9 @@ mouse_buttons resb 1
mouse_column resb 1
mouse_row resb 1
window_chain_head resw 1
redraw resb 1
; Last thing in bss
boot_disk resb 1

111
shell.asm
View File

@ -3,7 +3,6 @@
cpu 8086
bits 16
org 0
process_event:
@ -26,6 +25,11 @@ process_event:
call initialize
.not_initialize:
cmp ax, WM_PAINT
jne .not_paint
call paint
.not_paint:
pop es
pop ds
pop bp
@ -47,27 +51,98 @@ 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
; 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
call wait_key
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
%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
window:
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