X-Git-Url: https://eleni.mutantstargoat.com/git/?p=bootboot;a=blobdiff_plain;f=bb.asm;h=5f901bf5066d333aa224c8cce126e11ab283ee7c;hp=c28880edbec2b0680843c3ce277c4840e010890b;hb=b33f8cd778073038e38bc304618c4f2914c0f3b8;hpb=8d136d20a7fbf88f385d1a885977e081ed5dc89a diff --git a/bb.asm b/bb.asm index c28880e..5f901bf 100644 --- a/bb.asm +++ b/bb.asm @@ -1,3 +1,6 @@ +; author Eleni Maria Stea +; my x86 assembly helloworld :) + ; org: all instructions from now on start in 7c00h ; 7c00h is where the bios loads the 1st sector ; assembler formatting: @@ -22,6 +25,30 @@ out dx, al %endmacro +bios_param_block: + jmp start ; 2 bytes + nop ; 1 byte + ; start of BPB at offset 3 + db "BSPL 0.1" ; 03h: OEM ident, 8 bytes + dw 512 ; 0bh: bytes per sector + db 1 ; 0dh: sectors per cluster + dw 1 ; 0eh: reserved sectors (including boot record) + db 2 ; 10h: number of FATs + dw 224 ; 11h: number of dir entries + dw 2880 ; 13h: number of sectors in volume + db 0fh ; 15h: media descriptor type (f = 3.5" HD floppy) + dw 9 ; 16h: number of sectors per FAT + dw 18 ; 18h: number of sectors per track + dw 2 ; 1ah: number of heads + dd 0 ; 1ch: number of hidden sectors + dd 0 ; 20h: high bits of sector count + db 0 ; 24h: drive number + db 0 ; 25h: winnt flags + db 28h ; 26h: signature(?) + dd 0 ; 27h: volume serial number + db "BOOTBOOT "; 2bh: volume label, 11 bytes + db "FAT12 " ; 36h: filesystem id, 8 bytes + start: mov sp, 7c00h @@ -177,24 +204,31 @@ main_loop: ; draw lovebug mov di, (200 - 32) * 320 + 160 - 16 mov ax, [num_frames] + shr ax, 2 ; /4 + cmp ax, 200 - 32 + jz .end mov bx, ax shl ax, 8 shl bx, 6 add ax, bx sub di, ax call rand - and ax, 3 ; random value in 0, 15 - sub ax, 1 ; random value in -3, 12 + and ax, 3 ; random value in 0, 2 + sub ax, 1 ; random value in -1, 1 add di, ax mov si, lovebug call blit32 ; wait for vblank -.vsync: +.vsync_blank: mov dx, 3dah in al, dx + and al, 8 + jnz .vsync_blank +.vsync_visible: + in al, dx and al, 8 ; the 4th bit is 1 when we are in the vertical blanking period - jnz .vsync + jz .vsync_visible ; copy backbuffer to video memory push es @@ -211,8 +245,9 @@ main_loop: pop es inc word [num_frames] - cmp word [num_frames], 200 - 32 - jz .end +; moved above: +; cmp word [num_frames], 200 - 32 +; jz .end in al, 64h ; 60h = keyb data port, 64h = keyb status port and al, 1 ; 1 = OUTBUF_FULL = the keyb controller out buf is full @@ -234,6 +269,23 @@ main_loop: call print_num mov si, str_newline call print_str + + mov dx, 80h ; default to load from drive 80h + cmp byte [saved_drive_num], 80h + jnz .not_hd + inc dl ; next hd +.not_hd: +; load hard disk boot sector + xor ax, ax + mov es, ax + mov bx, 7c00h + mov ah, 02h + mov al, 1 + mov ch, 0 + mov cl, 1 + mov dh, 0 + int 13h + jnc 7c00h .inf_loop: jmp .inf_loop