default:
    just --list

execute_rust_os:
    #!/usr/bin/env bash
    cd os-in-rust
    cargo bootimage
    qemu-system-x86_64 -drive format=raw,file=target/x86_64_target/debug/bootimage-os-in-rust.bin

run_gamarjoba: build_gamarjoba
    ./gamarjoba_munde/gamarjoba

build_gamarjoba:
    nasm -f elf64 -o gamarjoba_munde/gamarjoba.o gamarjoba_munde/gamarjoba.asm
    ld -o gamarjoba_munde/gamarjoba gamarjoba_munde/gamarjoba.o

build_baremetal_gamarjoba:
    #!/usr/bin/env bash
    cd baremetal_gamarjoba
    gcc -m32 -ffreestanding -o include.o -c include.c
    nasm -f elf32 -i ../common baremetal_gamarjoba.asm
    ld -m elf_i386 -nostdlib -T ../common/linker.ld baremetal_gamarjoba.o include.o -o baremetal_gamarjoba


run_baremetal_gamarjoba: build_baremetal_gamarjoba
    #!/usr/bin/env bash
    cd baremetal_gamarjoba
    qemu-system-i386 -kernel baremetal_gamarjoba


build_keyboard:
    #!/usr/bin/env bash
    cd keyboard
    gcc -m32 -ffreestanding -o c_keyboard.o -c c_keyboard.c
    rustc --emit obj -o rust_keyboard.o --target i686-unknown-linux-gnu keyboard.rs
    nasm -f elf32 -i ../common keyboard.asm
    ld -m elf_i386 -nostdlib -T ../common/linker.ld keyboard.o c_keyboard.o rust_keyboard.o -o keyboard_kernel

run_keyboard: build_keyboard
    qemu-system-i386 -kernel keyboard/keyboard_kernel

run_terminal_keyboard: build_keyboard
    qemu-system-i386 -display curses -kernel keyboard/keyboard_kernel

build_lightshow:
    #!/usr/bin/env bash
    cd lightshow
    rustc --emit obj -o lightshow_rust.o --target i686-unknown-linux-gnu -g lightshow.rs
    nasm -f elf32 -i ../common -g lightshow.asm
    ld -m elf_i386 -nostdlib -T ../common/linker.ld lightshow.o lightshow_rust.o -o lightshow

run_lightshow: build_lightshow
    qemu-system-i386 -kernel lightshow

debug_lightshow: build_lightshow
    qemu-system-i386 -kernel lightshow -gdb tcp::9999 -S
