add most of the xterm palette
This commit is contained in:
parent
cdaa4d1c68
commit
920c3ddaf6
58
boot.s
58
boot.s
|
@ -2,14 +2,65 @@
|
|||
|
||||
.global _start # the linker needs to find it
|
||||
_start:
|
||||
jmp _real_start
|
||||
jmp vga_init
|
||||
.ascii "I'm bootable!"
|
||||
|
||||
_real_start:
|
||||
_Xterm_grad:
|
||||
.byte 0x00, 0x5f / 4, 0x87 / 4, 0xaf / 4, 0xd7 / 4, 0xff / 4
|
||||
|
||||
vga_init:
|
||||
# enter mode 13h
|
||||
mov $0x13, %ax
|
||||
int $0x10
|
||||
|
||||
# prepare the xterm palette 16-231
|
||||
# bh - color id
|
||||
# dx - used up for the port number
|
||||
mov $16, %bh
|
||||
xor %ecx, %ecx # dumb as bullshit
|
||||
palette_loop:
|
||||
mov %bh, %al
|
||||
mov $0x3c8, %dx
|
||||
out %al, %dx
|
||||
inc %dx
|
||||
|
||||
sub $16, %al # the colors start at 16, real_id = id - 16
|
||||
mov $6, %bl
|
||||
|
||||
xor %ah, %ah
|
||||
div %bl # al = real_id / 6
|
||||
# ah = remainder
|
||||
mov %ah, %cl # cl = real_id % 6
|
||||
|
||||
xor %ah, %ah
|
||||
div %bl # al = real_id / 6 / 6
|
||||
# ah = remainder
|
||||
|
||||
# at this point
|
||||
# al - R
|
||||
# ah - G
|
||||
# cl - B (soon bl)
|
||||
|
||||
# because of some dumb as bullshit, i need to use ecx for stuff
|
||||
mov %cl, %bl
|
||||
|
||||
mov %al, %cl
|
||||
mov _Xterm_grad(%ecx), %al
|
||||
out %al, %dx
|
||||
|
||||
mov %ah, %cl
|
||||
mov _Xterm_grad(%ecx), %al
|
||||
out %al, %dx
|
||||
|
||||
mov %bl, %cl
|
||||
mov _Xterm_grad(%ecx), %al
|
||||
out %al, %dx
|
||||
|
||||
inc %bh
|
||||
jnz palette_loop # loop until 0
|
||||
# TODO first 16 + grayscale
|
||||
|
||||
before_loop:
|
||||
mov $0xA000, %ax # ES = vga memory
|
||||
mov %ax, %es
|
||||
|
||||
|
@ -37,7 +88,10 @@ not_eol:
|
|||
jl loop
|
||||
|
||||
incb %es:319
|
||||
end:
|
||||
hlt
|
||||
jmp end
|
||||
|
||||
# .fill (510-(.-_start))/4, 4, 0xc4c5c6c7 # color stripes for testing
|
||||
.fill 510-(.-_start), 1, 0x90 # fill with 0x90 (NOPs)
|
||||
.word 0xaa55 # boot sector magic
|
||||
|
|
Loading…
Reference in New Issue