Skip to content

Commit

Permalink
I have a working version of showimage, but with the wrong palette.
Browse files Browse the repository at this point in the history
  • Loading branch information
halfgaar committed Oct 31, 2009
1 parent 86b3274 commit f3ea674
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
Binary file modified bigstuff.bin
Binary file not shown.
6 changes: 4 additions & 2 deletions bmp-image-data-start.txt
@@ -1,4 +1,6 @@
The two bytes at 0xA specifies the offset at which the BMP data begins. For
test image, that is 0x436.
test image (which I no longer use), that is 0x436.

The image I use now has data starting at 0x108. You have to add two because the
showimage bin file is two bytes bigger than I want it. The image is padded to 64k.

The image itself was 65078 bytes big, but I padded it to 64k
Binary file modified image.bmp
Binary file not shown.
Binary file added showimage
Binary file not shown.
19 changes: 7 additions & 12 deletions showimage.asm
@@ -1,8 +1,5 @@
segment .data

; This should be the location of the first pixel, skipping the BMP header and pallete.
pixel_pointer dw 0

segment .text

start:
Expand All @@ -21,6 +18,7 @@ load_image_to_mem
mov ax, 2000h ; ES:BX = 2000:0000
mov es, ax ;
mov bx, 0
mov ds, ax ; Set the datasegment to this segment, so that future reads will use this segment
mov ah, 2 ; Load disk data (to ES:BX)
mov al, 128 ; Load 128 sectors, 64 kbyte
mov ch, 0 ; Cylinder=0
Expand All @@ -33,18 +31,17 @@ load_image_to_mem
mov ah, 0x0c ; write pixel
mov cx, 0 ; x
mov dx, 199 ; y
mov al, 5 ; color will be purple if things go wrong
;mov bx, 438h ; If I use pixel_pointer, it doesn't start at the right place, it seems
mov bx, 110h ; If I use pixel_pointer, it doesn't start at the right place, it seems
mov al, [bx]

draw_next_pixel:
cmp cx, 320
jz goto_next_line

mov al, [pixel_pointer] ; color
int 10h

mov bx, [pixel_pointer]
inc bx
mov [pixel_pointer], bx
mov al, [bx]

inc cx ; x pos
jmp draw_next_pixel
Expand All @@ -53,7 +50,7 @@ goto_next_line:
cmp dx, 0
jz hang

dec dx ; y pos
dec dx ; y pos. Because BMP's are bottom-up, it starts at the bottom and then decreases.
mov cx, 0
jmp draw_next_pixel

Expand All @@ -69,7 +66,5 @@ hang: ; Hang!
jmp hang

; Without this, it won't boot for some reason.
; This and the bootloader are exactly 10 sectors long.
; FIXME: for some reason, this cannot be tuned so that the output file is 4608
; bytes long. It's 4606 or 4610.
; This and the bootloader are exactly 10 sectors +2 bytes long.
times 4608-($-$$) db 0

0 comments on commit f3ea674

Please sign in to comment.