Pong
I forgot to commit for a while and I haven't done much, but got the very basics of the game pong working. Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
@@ -16,8 +16,6 @@ os_set_graphics_mode:
|
||||
; y_start
|
||||
; colour
|
||||
os_draw_graphical_rectangle:
|
||||
pusha
|
||||
|
||||
; Tell BIOS we're changing 'da pixels!
|
||||
mov ah, 0Ch
|
||||
|
||||
@@ -28,21 +26,28 @@ os_draw_graphical_rectangle:
|
||||
|
||||
jmp .x_loop
|
||||
|
||||
.x_loop:
|
||||
int 10h
|
||||
cmp cx, [x_end]
|
||||
je .next_row
|
||||
inc cx
|
||||
call .x_loop
|
||||
.x_loop:
|
||||
int 10h
|
||||
cmp cx, [x_end]
|
||||
je .next_row
|
||||
inc cx
|
||||
call .x_loop
|
||||
|
||||
.next_row:
|
||||
mov cx, [x_start]
|
||||
cmp dx, [y_end]
|
||||
je .finish
|
||||
inc dx ; Increase Row
|
||||
call .x_loop
|
||||
.next_row:
|
||||
mov cx, [x_start]
|
||||
cmp dx, [y_end]
|
||||
je .finish
|
||||
inc dx ; Increase Row
|
||||
call .x_loop
|
||||
|
||||
.finish:
|
||||
popa
|
||||
Iret
|
||||
.finish:
|
||||
ret
|
||||
|
||||
|
||||
section .data
|
||||
x_start dw 0
|
||||
y_start dw 0
|
||||
x_end dw 0
|
||||
y_end dw 0
|
||||
colour db 1111b
|
||||
|
||||
|
@@ -1,162 +0,0 @@
|
||||
; ==================================================================
|
||||
; MikeOS -- The Mike Operating System kernel
|
||||
; Copyright (C) 2006 - 2021 MikeOS Developers -- see doc/LICENSE.TXT
|
||||
;
|
||||
; SCREEN HANDLING SYSTEM CALLS
|
||||
; ==================================================================
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; os_print_string -- Displays text
|
||||
; IN: SI = message location (zero-terminated string)
|
||||
; OUT: Nothing (registers preserved)
|
||||
|
||||
os_print_string:
|
||||
pusha
|
||||
|
||||
mov ah, 0Eh ; int 10h teletype function, we're telling the BIOS we will print something
|
||||
|
||||
.repeat:
|
||||
lodsb ; Get char from si into al
|
||||
cmp al, 0 ; Compare al to 0
|
||||
je .done ; If char is zero, end of string
|
||||
|
||||
int 10h ; Otherwise, print it
|
||||
jmp .repeat ; And move on to next char
|
||||
|
||||
.done:
|
||||
popa
|
||||
ret
|
||||
|
||||
; Exact same as the above procedure, but this adds a newline
|
||||
; after priting, similar to the difference between Rust's print! and println!
|
||||
os_print_string_nl: pusha
|
||||
|
||||
mov ah, 0Eh ; int 10h teletype function, we're telling the BIOS we will print something
|
||||
|
||||
.repeat:
|
||||
lodsb ; Get char from si into al
|
||||
cmp al, 0 ; Compare al to 0
|
||||
je .done ; If char is zero, end of string
|
||||
|
||||
int 10h ; Otherwise, print it
|
||||
jmp .repeat ; And move on to next char
|
||||
|
||||
.done:
|
||||
call os_print_newline
|
||||
popa
|
||||
ret
|
||||
|
||||
; --------------------------------------------
|
||||
|
||||
os_print_newline:
|
||||
pusha
|
||||
|
||||
mov ah, 03h
|
||||
int 10h
|
||||
|
||||
mov ah, 02h
|
||||
add dh, 1
|
||||
mov dl, 0
|
||||
int 10h
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
os_clear_screen:
|
||||
pusha
|
||||
|
||||
mov ah, 00h
|
||||
mov al, 03h ; Set video mode to textmode (80x25). 16 colors, 8 pages
|
||||
int 10h
|
||||
|
||||
mov ah, 02h
|
||||
mov dh, 0
|
||||
mov dl, 0
|
||||
int 10h
|
||||
|
||||
popa
|
||||
ret
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
; AX = key pressed
|
||||
os_read_input:
|
||||
mov ah, 11h ; BIOS call to check for key
|
||||
int 16h ; Interrupt
|
||||
jnz .key_pressed ; Jump if input isn't 0
|
||||
|
||||
hlt
|
||||
jmp os_read_input
|
||||
|
||||
.key_pressed:
|
||||
mov ah, 10h
|
||||
int 16h
|
||||
ret
|
||||
|
||||
; -------------------------------------------
|
||||
|
||||
os_display_input:
|
||||
pusha
|
||||
mov cx, prompt_length ; Characters remaining
|
||||
|
||||
.loop:
|
||||
call .check_key_pressed
|
||||
|
||||
jmp .loop
|
||||
|
||||
.check_key_pressed:
|
||||
call os_read_input
|
||||
|
||||
cmp al, 08h
|
||||
je .backspace
|
||||
|
||||
cmp al, 0Dh
|
||||
je .enter_key
|
||||
|
||||
cmp al, 1Bh
|
||||
je .esc_key
|
||||
|
||||
dec cx
|
||||
call .print_current_input
|
||||
ret
|
||||
|
||||
.esc_key:
|
||||
call os_reboot
|
||||
|
||||
.enter_key:
|
||||
mov al, 0
|
||||
stosb
|
||||
mov di, user_input
|
||||
popa
|
||||
call os_read_cli
|
||||
|
||||
.backspace:
|
||||
cmp cx, prompt_length ; If bx < 20
|
||||
jl .move_cursor_back ; then .move_cursor_back
|
||||
call .loop ; Else .loop
|
||||
|
||||
.move_cursor_back:
|
||||
mov ah, 0Eh
|
||||
|
||||
mov al, 08h
|
||||
int 10h
|
||||
mov al, 20h
|
||||
int 10h
|
||||
mov al, 08h
|
||||
int 10h
|
||||
|
||||
dec di
|
||||
inc cx
|
||||
jmp os_display_input
|
||||
|
||||
.print_current_input:
|
||||
stosb
|
||||
|
||||
mov ah, 0Eh
|
||||
int 10h
|
||||
|
||||
|
||||
ret
|
Reference in New Issue
Block a user