| Tim Windelschmidt | 8e19fa4 | 2024-11-12 13:39:43 +0000 | [diff] [blame] | 1 | org 7c00h |
| 2 | |
| 3 | start: |
| 4 | jmp main |
| 5 | |
| 6 | ; si: string data, null terminated |
| 7 | ; di: start offset |
| 8 | writestring: |
| 9 | mov al, [si] |
| 10 | or al, al |
| 11 | jz writestring_done |
| 12 | inc si |
| 13 | mov byte [fs:di], al |
| 14 | add di, 2 |
| 15 | jmp writestring |
| 16 | writestring_done: |
| 17 | ret |
| 18 | |
| 19 | ; si: rle encoded data (high bit == color, lower 7: length) |
| 20 | ; di: start offset |
| 21 | writegfx: |
| 22 | mov al, [si] |
| 23 | or al, al |
| 24 | jz writegfx_done |
| 25 | inc si |
| 26 | |
| 27 | mov cl, al |
| 28 | and cx, 0b01111111 |
| 29 | shr al, 7 |
| 30 | |
| 31 | writegfx_nextinner: |
| 32 | or al, al |
| 33 | jz writegfx_space |
| 34 | mov byte [fs:di], 'M' |
| 35 | writegfx_space: |
| 36 | add di, 2 |
| 37 | sub cx, 1 |
| 38 | jz writegfx |
| 39 | jmp writegfx_nextinner |
| 40 | writegfx_done: |
| 41 | ret |
| 42 | |
| 43 | main: |
| 44 | xor ax, ax |
| 45 | mov ds, ax |
| 46 | |
| 47 | ; set mode 3 (text 80x25, 16 color) |
| 48 | mov ax, 0x3 |
| 49 | int 0x10 |
| 50 | |
| 51 | ; set up fs segment to point at framebuffer |
| 52 | mov ax, 0xb800 |
| 53 | mov fs, ax |
| 54 | |
| 55 | mov di, 4 |
| 56 | mov si, logo |
| 57 | call writegfx |
| 58 | |
| 59 | mov di, 3400 |
| 60 | mov si, line1 |
| 61 | call writestring |
| 62 | |
| 63 | mov di, 3544 |
| 64 | mov si, line2 |
| 65 | call writestring |
| 66 | |
| 67 | end: |
| 68 | jmp end |
| 69 | |
| 70 | ; Workaround to pass file as argument |
| 71 | %macro incdef 1 |
| 72 | %push _incdef_ |
| 73 | %defstr %$file %{1} |
| 74 | %include %{$file} |
| 75 | %pop |
| 76 | %endmacro |
| 77 | |
| 78 | incdef LOGO |
| 79 | |
| 80 | line1: |
| 81 | db "Hi there! Didn't see you coming in.", 0 |
| 82 | |
| 83 | line2: |
| 84 | db "Unfortunately, Metropolis can only boot in UEFI mode.", 0 |
| 85 | |
| 86 | db 0x55 |
| 87 | db 0xAA |
| 88 | |
| 89 | ; We don't fill the rest with zeros, as this is done by mkimage and friends. |