forked from offtopia/ponydos
Compare commits
8 commits
39e47a33e1
...
a496c5ce9d
Author | SHA1 | Date | |
---|---|---|---|
|
a496c5ce9d | ||
|
54a6755a5b | ||
|
5129f3f3b4 | ||
|
0b5fd0d84e | ||
|
3f5d4ebd16 | ||
|
8bea9d6120 | ||
|
cb77e27fb2 | ||
|
ceb7745b42 |
7 changed files with 293 additions and 90 deletions
13
README.md
13
README.md
|
@ -68,16 +68,5 @@ You don't.
|
||||||
|
|
||||||
#### How do I install PonyDOS?
|
#### How do I install PonyDOS?
|
||||||
|
|
||||||
At the moment, PonyOS is only offered as a live floppy disk image with no
|
At the moment, PonyDOS is only offered as a live floppy disk image with no
|
||||||
installation option, for your safety.
|
installation option, for your safety.
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
### Basic stuff
|
|
||||||
|
|
||||||
* be able to click on asm/text files in file listing to open
|
|
||||||
* delete the TODO from release README
|
|
||||||
|
|
||||||
### Nice to have
|
|
||||||
|
|
||||||
* ponysay
|
|
||||||
|
|
52
hello.asm
52
hello.asm
|
@ -51,9 +51,14 @@ process_event:
|
||||||
push es
|
push es
|
||||||
|
|
||||||
; On entry, ds and es will not be set correctly for us
|
; On entry, ds and es will not be set correctly for us
|
||||||
mov bp, cs
|
; WM_OPEN_FILE needs ds to be left-as is
|
||||||
mov ds, bp
|
cmp al, WM_OPEN_FILE
|
||||||
mov es, bp
|
je .no_set_ds
|
||||||
|
push cs
|
||||||
|
pop ds
|
||||||
|
.no_set_ds:
|
||||||
|
push cs
|
||||||
|
pop es
|
||||||
|
|
||||||
cmp al, WM_PAINT
|
cmp al, WM_PAINT
|
||||||
jne .not_paint
|
jne .not_paint
|
||||||
|
@ -79,7 +84,21 @@ process_event:
|
||||||
jmp .end
|
jmp .end
|
||||||
.not_unhook:
|
.not_unhook:
|
||||||
|
|
||||||
|
cmp al, WM_OPEN_FILE
|
||||||
|
jne .not_open_file
|
||||||
|
call event_open_file
|
||||||
|
jmp .end
|
||||||
|
.not_open_file:
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
|
cmp byte [exiting], 0
|
||||||
|
je .not_exiting
|
||||||
|
; Once we have deallocated our own memory, we may not call any
|
||||||
|
; external functions that might allocate. Safest place to do the
|
||||||
|
; deallocation is just before returning control to our caller
|
||||||
|
call deallocate_own_memory
|
||||||
|
.not_exiting:
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
|
@ -278,10 +297,7 @@ event_click:
|
||||||
jne .not_close
|
jne .not_close
|
||||||
.close:
|
.close:
|
||||||
call unhook_self_from_window_chain
|
call unhook_self_from_window_chain
|
||||||
; Nothing can call into us again after we unhook
|
mov byte [exiting], 1
|
||||||
; the window, so deallocate the memory we have
|
|
||||||
; reserved
|
|
||||||
call deallocate_own_memory
|
|
||||||
; We don't need to call request_redraw here, since
|
; We don't need to call request_redraw here, since
|
||||||
; it will be called unconditionally above
|
; it will be called unconditionally above
|
||||||
jmp .title_bar_end
|
jmp .title_bar_end
|
||||||
|
@ -316,7 +332,7 @@ event_click:
|
||||||
; out:
|
; out:
|
||||||
; clobbers everything
|
; clobbers everything
|
||||||
event_keyboard:
|
event_keyboard:
|
||||||
; Unlike other events, keyboard events are not forwarded
|
; Unlike most other events, keyboard events are not forwarded
|
||||||
; Since we do not care about the keyboard for this app, we just
|
; Since we do not care about the keyboard for this app, we just
|
||||||
; swallow the event
|
; swallow the event
|
||||||
ret
|
ret
|
||||||
|
@ -353,6 +369,24 @@ event_unhook:
|
||||||
mov ax, [window_next]
|
mov ax, [window_next]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; in:
|
||||||
|
; al = WM_OPEN_FILE
|
||||||
|
; ds:cx = filename
|
||||||
|
; ds ≠ cs
|
||||||
|
; out:
|
||||||
|
; ds = cs
|
||||||
|
; clobbers everything
|
||||||
|
event_open_file:
|
||||||
|
; File open events are sent specifically to a process, so we don't
|
||||||
|
; need to forward it
|
||||||
|
; Unlike other event handlers, event_open_file is called with ds
|
||||||
|
; still set to calling process's segment, so that it can read the
|
||||||
|
; passed-in filename. For simplicity of code running after the,
|
||||||
|
; event handlers, we set ds to point to our own segment on return
|
||||||
|
push cs
|
||||||
|
pop ds
|
||||||
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; Event handler subroutines
|
; Event handler subroutines
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
@ -643,6 +677,8 @@ request_redraw:
|
||||||
; Variables
|
; Variables
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
|
exiting db 0
|
||||||
|
|
||||||
window_title db 'Hello'
|
window_title db 'Hello'
|
||||||
.end:
|
.end:
|
||||||
WINDOW_TITLE_LEN equ window_title.end - window_title
|
WINDOW_TITLE_LEN equ window_title.end - window_title
|
||||||
|
|
41
memory.asm
41
memory.asm
|
@ -72,7 +72,21 @@ process_event:
|
||||||
jmp .end
|
jmp .end
|
||||||
.not_unhook:
|
.not_unhook:
|
||||||
|
|
||||||
|
cmp al, WM_OPEN_FILE
|
||||||
|
jne .not_open_file
|
||||||
|
call event_open_file
|
||||||
|
jmp .end
|
||||||
|
.not_open_file:
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
|
cmp byte [exiting], 0
|
||||||
|
je .not_exiting
|
||||||
|
; Once we have deallocated our own memory, we may not call any
|
||||||
|
; external functions that might allocate. Safest place to do the
|
||||||
|
; deallocation is just before returning control to our caller
|
||||||
|
call deallocate_own_memory
|
||||||
|
.not_exiting:
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
|
@ -267,10 +281,7 @@ event_click:
|
||||||
jne .not_close
|
jne .not_close
|
||||||
.close:
|
.close:
|
||||||
call unhook_self_from_window_chain
|
call unhook_self_from_window_chain
|
||||||
; Nothing can call into us again after we unhook
|
mov byte [exiting], 1
|
||||||
; the window, so deallocate the memory we have
|
|
||||||
; reserved
|
|
||||||
call deallocate_own_memory
|
|
||||||
; We don't need to call request_redraw here, since
|
; We don't need to call request_redraw here, since
|
||||||
; it will be called unconditionally above
|
; it will be called unconditionally above
|
||||||
jmp .title_bar_end
|
jmp .title_bar_end
|
||||||
|
@ -297,7 +308,7 @@ event_click:
|
||||||
; out:
|
; out:
|
||||||
; clobbers everything
|
; clobbers everything
|
||||||
event_keyboard:
|
event_keyboard:
|
||||||
; Unlike other events, keyboard events are not forwarded
|
; Unlike most other events, keyboard events are not forwarded
|
||||||
; Since we do not care about the keyboard for this app, we just
|
; Since we do not care about the keyboard for this app, we just
|
||||||
; swallow the event
|
; swallow the event
|
||||||
ret
|
ret
|
||||||
|
@ -334,6 +345,24 @@ event_unhook:
|
||||||
mov ax, [window_next]
|
mov ax, [window_next]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; in:
|
||||||
|
; al = WM_OPEN_FILE
|
||||||
|
; ds:cx = filename
|
||||||
|
; ds ≠ cs
|
||||||
|
; out:
|
||||||
|
; ds = cs
|
||||||
|
; clobbers everything
|
||||||
|
event_open_file:
|
||||||
|
; File open events are sent specifically to a process, so we don't
|
||||||
|
; need to forward it
|
||||||
|
; Unlike other event handlers, event_open_file is called with ds
|
||||||
|
; still set to calling process's segment, so that it can read the
|
||||||
|
; passed-in filename. For simplicity of code running after the,
|
||||||
|
; event handlers, we set ds to point to our own segment on return
|
||||||
|
push cs
|
||||||
|
pop ds
|
||||||
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; Event handler subroutines
|
; Event handler subroutines
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
@ -530,6 +559,8 @@ request_redraw:
|
||||||
; Variables
|
; Variables
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
|
exiting db 0
|
||||||
|
|
||||||
window_next dw 0xffff
|
window_next dw 0xffff
|
||||||
window_x dw 65
|
window_x dw 65
|
||||||
window_y dw 3
|
window_y dw 3
|
||||||
|
|
|
@ -8,8 +8,8 @@ bits 16
|
||||||
|
|
||||||
org 0x7c00
|
org 0x7c00
|
||||||
|
|
||||||
X_SENSITIVITY equ 1
|
X_SENSITIVITY equ 3
|
||||||
Y_SENSITIVITY equ 2
|
Y_SENSITIVITY equ 3
|
||||||
|
|
||||||
jmp 0:start
|
jmp 0:start
|
||||||
|
|
||||||
|
@ -328,7 +328,8 @@ shell_name db 'shell.bin', 0
|
||||||
; ds:si = file name
|
; ds:si = file name
|
||||||
; dx = non-zero => do not create new file
|
; dx = non-zero => do not create new file
|
||||||
; out:
|
; out:
|
||||||
; ax = LBA of first sector, 0 if no space left
|
; ax = LBA of first sector, 0 if no space left or if dx non-zero and the
|
||||||
|
; specified file was not found
|
||||||
; cx = length in sectors
|
; cx = length in sectors
|
||||||
; di = dirent address (in GLOBAL_DIRENTS)
|
; di = dirent address (in GLOBAL_DIRENTS)
|
||||||
; [Far calls only]
|
; [Far calls only]
|
||||||
|
@ -386,7 +387,7 @@ open_file:
|
||||||
|
|
||||||
.create_file:
|
.create_file:
|
||||||
test dx, dx
|
test dx, dx
|
||||||
jnz .return
|
jnz .error
|
||||||
|
|
||||||
; TODO: zero out the sector for this file?
|
; TODO: zero out the sector for this file?
|
||||||
inc word [es:di]
|
inc word [es:di]
|
||||||
|
|
|
@ -16,6 +16,7 @@ WM_PAINT equ 0
|
||||||
WM_MOUSE equ 1
|
WM_MOUSE equ 1
|
||||||
WM_KEYBOARD equ 2
|
WM_KEYBOARD equ 2
|
||||||
WM_UNHOOK equ 3
|
WM_UNHOOK equ 3
|
||||||
|
WM_OPEN_FILE equ 4
|
||||||
|
|
||||||
MOUSE_PRIMARY equ 0x01
|
MOUSE_PRIMARY equ 0x01
|
||||||
MOUSE_SECONDARY equ 0x02
|
MOUSE_SECONDARY equ 0x02
|
||||||
|
|
184
shell.asm
184
shell.asm
|
@ -150,8 +150,11 @@ process_event:
|
||||||
cmp al, WM_UNHOOK
|
cmp al, WM_UNHOOK
|
||||||
jne .not_remove
|
jne .not_remove
|
||||||
call unhook
|
call unhook
|
||||||
|
jmp .end
|
||||||
.not_remove:
|
.not_remove:
|
||||||
|
|
||||||
|
; We ignore WM_OPEN_FILE
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
cmp byte [open_windows], 0
|
cmp byte [open_windows], 0
|
||||||
jne .windows_open
|
jne .windows_open
|
||||||
|
@ -181,7 +184,7 @@ paint:
|
||||||
call get_window
|
call get_window
|
||||||
|
|
||||||
mov bx, [si + window.next]
|
mov bx, [si + window.next]
|
||||||
call forward_event
|
call send_event
|
||||||
|
|
||||||
cmp si, windows + WINDOW_ID_FILE_WINDOW*window.size
|
cmp si, windows + WINDOW_ID_FILE_WINDOW*window.size
|
||||||
jne .not_file_window
|
jne .not_file_window
|
||||||
|
@ -308,7 +311,7 @@ mouse:
|
||||||
mov cx, 0xffff
|
mov cx, 0xffff
|
||||||
mov bx, [si + window.next]
|
mov bx, [si + window.next]
|
||||||
mov al, WM_MOUSE
|
mov al, WM_MOUSE
|
||||||
call forward_event
|
call send_event
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.outside:
|
.outside:
|
||||||
|
@ -316,7 +319,7 @@ mouse:
|
||||||
pop cx
|
pop cx
|
||||||
mov bx, [si + window.next]
|
mov bx, [si + window.next]
|
||||||
mov al, WM_MOUSE
|
mov al, WM_MOUSE
|
||||||
call forward_event
|
call send_event
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; in:
|
; in:
|
||||||
|
@ -442,10 +445,10 @@ unhook:
|
||||||
|
|
||||||
; Forward the event
|
; Forward the event
|
||||||
mov bx, [si + window.next]
|
mov bx, [si + window.next]
|
||||||
call forward_event
|
call send_event
|
||||||
|
|
||||||
; Update next ID
|
; Update next ID
|
||||||
; If window.next was zero, forward_event will also return zero so
|
; If window.next was zero, send_event will also return zero so
|
||||||
; this is safe in all cases
|
; this is safe in all cases
|
||||||
mov [si + window.next], ax
|
mov [si + window.next], ax
|
||||||
|
|
||||||
|
@ -542,21 +545,56 @@ move:
|
||||||
pop dx
|
pop dx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------
|
||||||
|
; Launching
|
||||||
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
; out:
|
; out:
|
||||||
; clobbers everything
|
; clobbers everything
|
||||||
launch:
|
launch:
|
||||||
mov si, launch_filename
|
mov si, launch_filename
|
||||||
|
|
||||||
; Is it a .wall file?
|
; 4 letter file extension?
|
||||||
call strlen
|
call strlen
|
||||||
cmp cx, 5
|
cmp cx, 5
|
||||||
jb .not_wall
|
jb .less_than_5_chars
|
||||||
add si, cx
|
add si, cx
|
||||||
sub si, 5
|
sub si, 5
|
||||||
|
; .text
|
||||||
|
mov di, text_extension
|
||||||
|
call strcmp
|
||||||
|
je .text_file
|
||||||
|
; .wall
|
||||||
mov di, wall_extension
|
mov di, wall_extension
|
||||||
call strcmp
|
call strcmp
|
||||||
jne .not_wall
|
je .wallpaper
|
||||||
|
.less_than_5_chars:
|
||||||
|
|
||||||
|
; 3 letter file extension?
|
||||||
|
cmp cx, 4
|
||||||
|
jb .not_launchable ; No, too short
|
||||||
|
mov si, launch_filename
|
||||||
|
add si, cx
|
||||||
|
sub si, 4
|
||||||
|
; .asm
|
||||||
|
mov di, asm_extension
|
||||||
|
call strcmp
|
||||||
|
je .text_file
|
||||||
|
; .txt
|
||||||
|
mov di, txt_extension
|
||||||
|
call strcmp
|
||||||
|
je .text_file
|
||||||
|
; .bin
|
||||||
|
mov di, bin_extension
|
||||||
|
call strcmp
|
||||||
|
jne .not_launchable ; No extension matched
|
||||||
|
|
||||||
|
mov si, launch_filename
|
||||||
|
call launch_binary
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
.wallpaper:
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
mov es, ax
|
mov es, ax
|
||||||
mov si, launch_filename
|
mov si, launch_filename
|
||||||
|
@ -566,25 +604,70 @@ launch:
|
||||||
|
|
||||||
call set_wallpaper
|
call set_wallpaper
|
||||||
call request_redraw
|
call request_redraw
|
||||||
jmp .end
|
|
||||||
|
|
||||||
.not_wall:
|
ret
|
||||||
|
|
||||||
; Is it a .bin file?
|
.not_launchable:
|
||||||
cmp cx, 4
|
; Copy filename into the launch error dialog
|
||||||
jb .not_launchable ; No, too short
|
|
||||||
mov si, launch_filename
|
mov si, launch_filename
|
||||||
add si, cx
|
call show_launch_error
|
||||||
sub si, 4
|
ret
|
||||||
mov di, bin_extension
|
|
||||||
call strcmp
|
|
||||||
jne .not_launchable ; No, wrong extension
|
|
||||||
|
|
||||||
mov si, launch_filename
|
.text_file:
|
||||||
|
; Launch viewer.bin if it exists
|
||||||
|
mov si, viewer_file_name
|
||||||
|
call launch_binary
|
||||||
|
jc .viewer_not_found
|
||||||
|
|
||||||
|
; Send the WM_OPEN_FILE event to tell viewer the file we
|
||||||
|
; want it to open. launch_binary returned its segment in bx
|
||||||
|
; so we can just pass that to send_event, as window IDs are
|
||||||
|
; of the form segment | internal_id.
|
||||||
|
mov al, WM_OPEN_FILE
|
||||||
|
mov cx, launch_filename
|
||||||
|
call send_event
|
||||||
|
|
||||||
|
.viewer_not_found:
|
||||||
|
ret
|
||||||
|
|
||||||
|
; in:
|
||||||
|
; si = name of file not launchable
|
||||||
|
; out:
|
||||||
|
; clobbers everything
|
||||||
|
show_launch_error:
|
||||||
|
mov di, launch_error_dialog.filename
|
||||||
|
mov cx, FS_DIRENT_NAME_SIZE-1
|
||||||
|
mov ah, 0xf0
|
||||||
|
.copy:
|
||||||
|
lodsb
|
||||||
|
test al, al
|
||||||
|
je .copy_end
|
||||||
|
stosw
|
||||||
|
loop .copy
|
||||||
|
.copy_end:
|
||||||
|
; Zero out the rest
|
||||||
|
xor al, al
|
||||||
|
rep stosw
|
||||||
|
|
||||||
|
; Show dialog
|
||||||
|
mov ax, cs
|
||||||
|
add ax, WINDOW_ID_LAUNCH_ERROR
|
||||||
|
mov si, windows + WINDOW_ID_LAUNCH_ERROR*window.size
|
||||||
|
call show_window
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
; in:
|
||||||
|
; si = name of the binary to launch
|
||||||
|
; out:
|
||||||
|
; cf = error occured when launching binary
|
||||||
|
; bx = segment of the launched binary
|
||||||
|
; clobbers everything else
|
||||||
|
launch_binary:
|
||||||
mov dx, 1 ; Don't create a new file if not found
|
mov dx, 1 ; Don't create a new file if not found
|
||||||
call PONYDOS_SEG:SYS_OPEN_FILE
|
call PONYDOS_SEG:SYS_OPEN_FILE
|
||||||
test ax, ax
|
test ax, ax
|
||||||
jz .not_launchable
|
jz .file_not_found
|
||||||
|
|
||||||
push ax
|
push ax
|
||||||
push cx
|
push cx
|
||||||
|
@ -600,14 +683,7 @@ launch:
|
||||||
jz .found_free_segment
|
jz .found_free_segment
|
||||||
inc si
|
inc si
|
||||||
loop .find_free_segment
|
loop .find_free_segment
|
||||||
; Display an error dialog if we can't allocate a segment
|
jmp .out_of_memory
|
||||||
mov ax, cs
|
|
||||||
add ax, WINDOW_ID_OOM_ERROR
|
|
||||||
mov si, windows + WINDOW_ID_OOM_ERROR*window.size
|
|
||||||
call show_window
|
|
||||||
pop cx
|
|
||||||
pop ax
|
|
||||||
jmp .end
|
|
||||||
.found_free_segment:
|
.found_free_segment:
|
||||||
mov byte [es:si], 1 ; Mark as used
|
mov byte [es:si], 1 ; Mark as used
|
||||||
|
|
||||||
|
@ -623,34 +699,37 @@ launch:
|
||||||
xor di, di ; Read
|
xor di, di ; Read
|
||||||
call PONYDOS_SEG:SYS_MODIFY_SECTORS
|
call PONYDOS_SEG:SYS_MODIFY_SECTORS
|
||||||
|
|
||||||
|
push es ; Save the segment for return value
|
||||||
|
|
||||||
; Transfer control to the newly loaded binary
|
; Transfer control to the newly loaded binary
|
||||||
push cs ; Return segment
|
push cs ; Return segment
|
||||||
mov ax, .end
|
mov ax, .success
|
||||||
push ax ; Return offset
|
push ax ; Return offset
|
||||||
push es ; Call segment
|
push es ; Call segment
|
||||||
mov ax, PROC_INITIALIZE_ENTRYPOINT
|
mov ax, PROC_INITIALIZE_ENTRYPOINT
|
||||||
push ax ; Call offset
|
push ax ; Call offset
|
||||||
retf
|
retf
|
||||||
|
|
||||||
.end:
|
.success:
|
||||||
|
pop bx
|
||||||
|
clc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.not_launchable:
|
.file_not_found:
|
||||||
; Copy filename into the launch error dialog
|
call show_launch_error
|
||||||
mov si, launch_filename
|
jmp .error
|
||||||
mov di, launch_error_dialog.filename
|
|
||||||
mov cx, FS_DIRENT_NAME_SIZE-1
|
|
||||||
.loop:
|
|
||||||
lodsb
|
|
||||||
stosb
|
|
||||||
inc di
|
|
||||||
loop .loop
|
|
||||||
|
|
||||||
; Show dialog
|
.out_of_memory:
|
||||||
|
; Display an error dialog if we can't allocate a segment
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
add ax, WINDOW_ID_LAUNCH_ERROR
|
add ax, WINDOW_ID_OOM_ERROR
|
||||||
mov si, windows + WINDOW_ID_LAUNCH_ERROR*window.size
|
mov si, windows + WINDOW_ID_OOM_ERROR*window.size
|
||||||
call show_window
|
call show_window
|
||||||
|
pop cx
|
||||||
|
pop ax
|
||||||
|
|
||||||
|
.error:
|
||||||
|
stc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; out:
|
; out:
|
||||||
|
@ -675,7 +754,7 @@ set_wallpaper:
|
||||||
; bx = window ID
|
; bx = window ID
|
||||||
; out:
|
; out:
|
||||||
; ax = return value of event handler; 0 if window ID is 0
|
; ax = return value of event handler; 0 if window ID is 0
|
||||||
forward_event:
|
send_event:
|
||||||
push bp
|
push bp
|
||||||
|
|
||||||
cmp bx, 0
|
cmp bx, 0
|
||||||
|
@ -796,7 +875,7 @@ unhook_window:
|
||||||
mov bx, [es:GLOBAL_WINDOW_CHAIN_HEAD]
|
mov bx, [es:GLOBAL_WINDOW_CHAIN_HEAD]
|
||||||
|
|
||||||
mov al, WM_UNHOOK
|
mov al, WM_UNHOOK
|
||||||
call forward_event
|
call send_event
|
||||||
|
|
||||||
mov [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
|
mov [es:GLOBAL_WINDOW_CHAIN_HEAD], ax
|
||||||
|
|
||||||
|
@ -1130,14 +1209,20 @@ strcmp:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; Variables
|
; Constants
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
|
asm_extension db '.asm', 0
|
||||||
bin_extension db '.bin', 0
|
bin_extension db '.bin', 0
|
||||||
|
txt_extension db '.txt', 0
|
||||||
|
text_extension db '.text', 0
|
||||||
wall_extension db '.wall', 0
|
wall_extension db '.wall', 0
|
||||||
|
|
||||||
wallpaper_name db 'ponydos.wall'
|
viewer_file_name db 'viewer.bin', 0
|
||||||
times FS_DIRENT_NAME_SIZE-12 db 0
|
|
||||||
|
; ------------------------------------------------------------------
|
||||||
|
; Variables
|
||||||
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
disk_icon:
|
disk_icon:
|
||||||
db 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f
|
db 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f, 0x00, 0x0f
|
||||||
|
@ -1171,6 +1256,9 @@ windows:
|
||||||
|
|
||||||
open_windows db 0
|
open_windows db 0
|
||||||
|
|
||||||
|
wallpaper_name db 'ponydos.wall'
|
||||||
|
times FS_DIRENT_NAME_SIZE-12 db 0
|
||||||
|
|
||||||
launch_filename times FS_DIRENT_NAME_SIZE db 0
|
launch_filename times FS_DIRENT_NAME_SIZE db 0
|
||||||
|
|
||||||
section .bss
|
section .bss
|
||||||
|
|
75
viewer.asm
75
viewer.asm
|
@ -51,9 +51,14 @@ process_event:
|
||||||
push es
|
push es
|
||||||
|
|
||||||
; On entry, ds and es will not be set correctly for us
|
; On entry, ds and es will not be set correctly for us
|
||||||
mov bp, cs
|
; WM_OPEN_FILE needs ds to be left-as is
|
||||||
mov ds, bp
|
cmp al, WM_OPEN_FILE
|
||||||
mov es, bp
|
je .no_set_ds
|
||||||
|
push cs
|
||||||
|
pop ds
|
||||||
|
.no_set_ds:
|
||||||
|
push cs
|
||||||
|
pop es
|
||||||
|
|
||||||
cmp al, WM_PAINT
|
cmp al, WM_PAINT
|
||||||
jne .not_paint
|
jne .not_paint
|
||||||
|
@ -79,7 +84,18 @@ process_event:
|
||||||
jmp .end
|
jmp .end
|
||||||
.not_unhook:
|
.not_unhook:
|
||||||
|
|
||||||
|
cmp al, WM_OPEN_FILE
|
||||||
|
jne .not_open_file
|
||||||
|
call event_open_file
|
||||||
|
jmp .end
|
||||||
|
.not_open_file:
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
|
cmp byte [exiting], 0
|
||||||
|
je .not_exiting
|
||||||
|
call deallocate_own_memory
|
||||||
|
.not_exiting:
|
||||||
|
|
||||||
pop es
|
pop es
|
||||||
pop ds
|
pop ds
|
||||||
pop bp
|
pop bp
|
||||||
|
@ -579,7 +595,7 @@ event_click:
|
||||||
jne .not_cancel
|
jne .not_cancel
|
||||||
.cancel:
|
.cancel:
|
||||||
call unhook_self_from_window_chain
|
call unhook_self_from_window_chain
|
||||||
call deallocate_own_memory
|
mov byte [exiting], 1
|
||||||
jmp .end
|
jmp .end
|
||||||
.not_cancel:
|
.not_cancel:
|
||||||
cmp byte [bx], OK_COLOR
|
cmp byte [bx], OK_COLOR
|
||||||
|
@ -735,6 +751,39 @@ event_unhook:
|
||||||
mov ax, [window_next]
|
mov ax, [window_next]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; in:
|
||||||
|
; al = WM_OPEN_FILE
|
||||||
|
; ds:cx = filename
|
||||||
|
; ds ≠ cs
|
||||||
|
; out:
|
||||||
|
; ds = cs
|
||||||
|
; clobbers everything
|
||||||
|
event_open_file:
|
||||||
|
; Copy the file name over
|
||||||
|
mov si, cx
|
||||||
|
mov di, [es:cur_filename_address]
|
||||||
|
.copy_filename:
|
||||||
|
lodsb
|
||||||
|
test al, al
|
||||||
|
jz .copy_end
|
||||||
|
|
||||||
|
stosb
|
||||||
|
inc di
|
||||||
|
jmp .copy_filename
|
||||||
|
.copy_end:
|
||||||
|
mov [es:cur_filename_address], di
|
||||||
|
|
||||||
|
; Set ds to be as expected by most of the program
|
||||||
|
push cs
|
||||||
|
pop ds
|
||||||
|
|
||||||
|
; Mark that the filename came from WM_OPEN_FILE
|
||||||
|
mov byte [filename_from_wm_open_file], 1
|
||||||
|
|
||||||
|
call filename_ok
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
; Event handler subroutines
|
; Event handler subroutines
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
@ -742,15 +791,20 @@ event_unhook:
|
||||||
; out:
|
; out:
|
||||||
; clobbers si, di, cx
|
; clobbers si, di, cx
|
||||||
close_window:
|
close_window:
|
||||||
|
; If filename was from WM_OPEN_FILE event instead of user input,
|
||||||
|
; exit the app instead of going to name input dialog
|
||||||
|
cmp byte [filename_from_wm_open_file], 0
|
||||||
|
jne .exit_app
|
||||||
cmp word [window.data_address], oom_window_data
|
cmp word [window.data_address], oom_window_data
|
||||||
je .error_window
|
je .error_window
|
||||||
cmp word [window.data_address], ood_window_data
|
cmp word [window.data_address], ood_window_data
|
||||||
je .error_window
|
je .error_window
|
||||||
.not_error_window:
|
|
||||||
; Shut off app
|
.exit_app:
|
||||||
call unhook_self_from_window_chain
|
call unhook_self_from_window_chain
|
||||||
call deallocate_own_memory
|
mov byte [exiting], 1
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.error_window:
|
.error_window:
|
||||||
mov si, filename_window
|
mov si, filename_window
|
||||||
mov di, window
|
mov di, window
|
||||||
|
@ -1116,10 +1170,13 @@ request_redraw:
|
||||||
; Variables
|
; Variables
|
||||||
; ------------------------------------------------------------------
|
; ------------------------------------------------------------------
|
||||||
|
|
||||||
|
filename_from_wm_open_file db 0
|
||||||
|
exiting db 0
|
||||||
|
|
||||||
window_title times FS_DIRENT_NAME_SIZE db 0
|
window_title times FS_DIRENT_NAME_SIZE db 0
|
||||||
|
|
||||||
cur_file_address: dw 0 ; Segment
|
cur_file_address: dw 0
|
||||||
dw 0
|
dw 0 ; Segment
|
||||||
beg_file_address dw 0
|
beg_file_address dw 0
|
||||||
end_file_address dw 0
|
end_file_address dw 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue