123 lines
1.3 KiB
PHP
123 lines
1.3 KiB
PHP
; conio.inc
|
|
; real mode console input / output functions
|
|
; Author: Josh Holtrop
|
|
; Date: 01/04/05
|
|
; Modified: 01/04/05
|
|
|
|
|
|
con_getkey:
|
|
xor ax, ax
|
|
int 0x16
|
|
ret
|
|
|
|
|
|
con_move_cursor: ;con_move_cursor(word location)
|
|
push bp
|
|
mov bp, sp
|
|
push ax
|
|
|
|
mov ax, [bp + 4]
|
|
mov [cursor], ax
|
|
call con_write_cursor
|
|
|
|
pop ax
|
|
pop bp
|
|
ret
|
|
|
|
|
|
con_clear:
|
|
pusha
|
|
|
|
mov ax, 0xB800
|
|
mov es, ax
|
|
mov di, 0
|
|
mov ax, 0x0720
|
|
mov cx, 2000
|
|
rep stosw
|
|
mov [cursor], word 0
|
|
call con_write_cursor
|
|
|
|
popa
|
|
ret
|
|
|
|
|
|
con_putstring: ;con_putstring(char *str)
|
|
push bp
|
|
mov bp, sp
|
|
pusha
|
|
|
|
mov si, [bp + 4]
|
|
putstring_loop:
|
|
lodsb
|
|
or al, al
|
|
jz putstring_done
|
|
mov ah, 0x07
|
|
push ax
|
|
call con_putc
|
|
add sp, 2
|
|
jmp putstring_loop
|
|
|
|
putstring_done:
|
|
popa
|
|
pop bp
|
|
ret
|
|
|
|
|
|
con_putc: ;con_putc(char chr)
|
|
push bp
|
|
mov bp, sp
|
|
pusha
|
|
|
|
mov ax, 0xB800
|
|
mov es, ax
|
|
mov di, [cursor]
|
|
mov ax, [bp + 4]
|
|
cmp al, 10
|
|
jz putc_return
|
|
stosw
|
|
jmp putc_update
|
|
putc_return:
|
|
mov ax, di
|
|
mov bl, 160
|
|
div bl ; quotient in al, remainder in ah
|
|
shr ax, 8
|
|
sub di, ax
|
|
add di, 160
|
|
putc_update:
|
|
mov [cursor], di
|
|
call con_write_cursor
|
|
popa
|
|
pop bp
|
|
ret
|
|
|
|
|
|
con_write_cursor:
|
|
pusha
|
|
|
|
mov ax, [cursor]
|
|
shr ax, 1
|
|
|
|
mov bl, al
|
|
mov dx, 0x03D4
|
|
mov al, 0x0E
|
|
out dx, al
|
|
|
|
inc dx
|
|
mov al, ah
|
|
out dx, al
|
|
|
|
dec dx
|
|
mov al, 0x0F
|
|
out dx, al
|
|
|
|
inc dx
|
|
mov al, bl
|
|
out dx, al
|
|
|
|
popa
|
|
ret
|
|
|
|
|
|
cursor: dw 0
|
|
|