Compare commits
4 Commits
8178c7a715
...
4cd5c0632a
Author | SHA1 | Date |
---|---|---|
Juhani Krekelä | 4cd5c0632a | |
Juhani Krekelä | d725407c5b | |
Juhani Krekelä | 878cc67a83 | |
Juhani Krekelä | f020b7ab2f |
6
Makefile
6
Makefile
|
@ -11,10 +11,10 @@ FS_FILES = wallpaper.bin shell.bin
|
|||
ponydos.img: ponydos.bin $(FS_FILES)
|
||||
$(PYTHON) assemble_floppy.py $@ ponydos.bin $(FS_FILES)
|
||||
|
||||
ponydos.inc: ponydos.asm ponydos_nosyscall.inc
|
||||
$(NASM) -fbin -d SYMBOLS -o /dev/null ponydos.asm | $(PYTHON) add_syscalls.py $@ ponydos_nosyscall.inc
|
||||
ponydos.inc: ponydos.asm ponydos_static.inc
|
||||
$(NASM) -fbin -d SYMBOLS -o /dev/null ponydos.asm | $(PYTHON) extract_symbols.py $@ ponydos_static.inc
|
||||
|
||||
ponydos.bin: ponydos_nosyscall.inc
|
||||
ponydos.bin: ponydos_static.inc
|
||||
|
||||
shell.bin: ponydos.inc
|
||||
|
||||
|
|
|
@ -6,6 +6,14 @@ syscalls = {
|
|||
'draw_rect': None,
|
||||
}
|
||||
|
||||
variables = {
|
||||
'mouse_column': None,
|
||||
'mouse_row': None,
|
||||
'mouse_buttons': None,
|
||||
'window_chain_head': None,
|
||||
'redraw': None,
|
||||
}
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print(f'Usage: {sys.argv[0]} outfile infile', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
@ -28,12 +36,12 @@ while True:
|
|||
section = None
|
||||
for line in mapfile:
|
||||
line = line.split()
|
||||
if len(line) == 4 and all(c == '-' for c in line[0]) and line[1] == 'Section' and all(c == '-' for c in line[3]):
|
||||
section = line[2]
|
||||
if section == '.text' and len(line) == 3:
|
||||
if len(line) == 3:
|
||||
address, _, name = line
|
||||
if name in syscalls:
|
||||
syscalls[name] = int(address, 16)
|
||||
if name in variables:
|
||||
variables[name] = int(address, 16)
|
||||
|
||||
header += f'\n;This was automatically generated\n'
|
||||
|
||||
|
@ -43,5 +51,13 @@ for syscall, address in syscalls.items():
|
|||
sys.exit(1)
|
||||
header += f'SYS_{syscall.upper()} equ 0x{address:x}\n'
|
||||
|
||||
header += '\n'
|
||||
|
||||
for variable, address in variables.items():
|
||||
if address is None:
|
||||
print(f'{sys.argv[0]}: Error: global {variable} not found', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
header += f'GLOBAL_{variable.upper()} equ 0x{address:x}\n'
|
||||
|
||||
with open(outfile, 'w') as f:
|
||||
f.write(header)
|
20
ponydos.asm
20
ponydos.asm
|
@ -1,7 +1,7 @@
|
|||
%ifdef SYMBOLS
|
||||
[map symbols]
|
||||
%endif
|
||||
%include "ponydos_nosyscall.inc"
|
||||
%include "ponydos_static.inc"
|
||||
|
||||
cpu 286
|
||||
bits 16
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ PONYDOS_SEG equ 0
|
|||
GLOBAL_WALLPAPER equ 0x500
|
||||
|
||||
WM_INITIALIZE equ 0
|
||||
WM_PAINT equ 1
|
|
@ -63,6 +63,8 @@ while index < len(ansitext):
|
|||
x = origin_x
|
||||
index += 1
|
||||
elif ansitext[index] == 10:
|
||||
for i in range(x, WIDTH):
|
||||
attributes[i][y] = (fgcolor, bgcolor)
|
||||
x = origin_x
|
||||
y += 1
|
||||
index += 1
|
||||
|
|
111
shell.asm
111
shell.asm
|
@ -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, 14
|
||||
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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
ANSI art is my
|
||||
[91mp[92ma[93ms[94ms[95mi[96mo[97mn[39m
|
||||
[45m[97mANSI art is my
|
||||
[91mp[92ma[93ms[94ms[95mi[96mo[97mn[97m
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue