-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 92745eb
Showing
53 changed files
with
2,871 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
bits 16 | ||
org 0x7c00 | ||
; | ||
; EGA register equates. | ||
; | ||
SC_INDEX equ 0x3c4 ; SC index register | ||
SC_MAP_MASK equ 2 ; SC map mask register | ||
GC_INDEX equ 0x3ce ; GC index register | ||
GC_SET_RESET equ 0 ; GC set/reset register | ||
GC_ENABLE_SET_RESET equ 1 ; GC enable set/reset register | ||
; | ||
; Macro to set indexed register INDEX of SC chip to SETTING. | ||
; | ||
%macro SETSC 2 | ||
mov dx, SC_INDEX | ||
mov al, %1 | ||
out dx, al | ||
inc dx | ||
mov al, %2 | ||
out dx, al | ||
dec dx | ||
%endmacro | ||
|
||
; | ||
; Macro to set indexed register INDEX of GC chip to SETTING. | ||
; | ||
%macro SETGC 2 | ||
mov dx, GC_INDEX | ||
mov al, %1 | ||
out dx, al | ||
inc dx | ||
mov al, %2 | ||
out dx, al | ||
dec dx | ||
%endmacro | ||
|
||
start: | ||
xor ax, ax ; AX=0 | ||
mov ds, ax ; DS=ES=0 because we use an org of 0x7c00 | ||
; Segment<<4+offset = 0x0000<<4+0x7c00 = 0x07c00 | ||
mov es, ax | ||
mov ss, ax | ||
mov sp, 0x7c00 ; SS:SP= 0x0000:0x7c00 stack just below bootloader | ||
cld ; Forward direction for string instructions like movsb | ||
|
||
Set_Video: | ||
mov ah, 0x41 ; Int 13h/AH=41h: Check if extensions present | ||
mov bx, 0x55aa | ||
int 0x13 | ||
cmp bx, 0xaa55 ; Is BX 0xaa55? | ||
mov ax, 12h ; Graphics mode (640x480x16) | ||
int 10h ; BIOS video call | ||
|
||
mov si, DAP ; Load BMP Sectors | ||
mov ah, 42h | ||
int 13h ; Read the BMP file | ||
|
||
|
||
; Segment that our BMP (and BMP header) was read into */ | ||
mov ax, 0x07e0 | ||
mov ds, ax | ||
|
||
mov di, [46] ; Get number of colors from DIB header | ||
test di, di | ||
jnz color_set ; If number of colors is 0 | ||
mov di, 2 ; then set to 2 (we assume BMP has color depth 1) | ||
|
||
color_set: | ||
mov si, [14] ; Get the offset of color table from DIB header | ||
add si, 14 ; Add the length of the BMP header to color table offset | ||
; to get actual offset of the color table | ||
xor bx, bx ; Curent color index to process = 0 | ||
|
||
.paletteloop: | ||
mov ch, [si+1] ; Get green value | ||
shr ch, 1 | ||
shr ch, 1 ; VGA color values are 6 bit. Shift 8-bit value in | ||
; color table entry right by 2 to get a 6-bit value | ||
mov cl, [si] ; Get blue value | ||
shr cl, 1 | ||
shr cl, 1 ; VGA color values are 6 bit. Shift 8-bit value in | ||
; color table entry right by 2 to get a 6-bit value | ||
mov dh, [si+2] ; Get red value | ||
shr dh, 1 | ||
shr dh, 1 ; VGA color values are 6 bit. Shift 8-bit value in | ||
; color table entry right by 2 to get a 6-bit value | ||
mov ax, 0x1010 ; Set palette entry for current color index | ||
int 0x10 | ||
|
||
inc bx ; Go to next color index | ||
add si, 4 ; Go to next memory offset where next colorentry starts | ||
dec di | ||
jnz .paletteloop ; Loop until we have processed all color entries | ||
|
||
SETSC SC_MAP_MASK, 0x0f ; must set map mask to enable all | ||
; planes, so set/reset values can | ||
; be written to planes 1, 2 & 3 | ||
; and CPU data can be written to | ||
; plane 0 (the blue plane) | ||
SETGC GC_ENABLE_SET_RESET, 0xe ; CPU data to plane 1, 2, & 3 will be | ||
; replaced by set/reset value | ||
SETGC GC_SET_RESET, 0x1 ; set/reset value is 0ffh for plane 0 | ||
; (the blue plane) and 0 for other | ||
; planes | ||
|
||
mov ax, 0xA000 | ||
mov es, ax ; 0xA000 = Memory segment for VGA/EGA graphics display | ||
|
||
mov si, [10] ; Get offset to pixel data from BMP header | ||
xor di, di ; Destination offset in video segment starts at 0x0000 | ||
mov cx, (640/8*480)/2 ; Total number of words (16-bit values) to copy | ||
rep movsw ; Move CX number of words from DS:DI to ES:SI | ||
pop ds | ||
jmp endloop ; We are finished go into infinite loop | ||
|
||
;Endless loop | ||
endloop: | ||
cli ; Disable interrupts | ||
.repeat: | ||
hlt ; Wait for next interrupt | ||
jmp .repeat ; Continue looping indefinitely | ||
|
||
SECTOR_SIZE equ 512 | ||
|
||
; Disk address packet | ||
DAP: | ||
db 10h, 0 | ||
dw (BMP_SIZE+(SECTOR_SIZE-1))/SECTOR_SIZE ; Number of sectors BMP uses (rounded up) | ||
dw 0x0000, 0x07e0 ; Read to 0x07e0:0x0000 = Phys Address 0x07e00 | ||
dq 1 ; (Start at second sector) | ||
|
||
;Fake MBR signature | ||
times 510 - ($ - $$) db 0 | ||
dw 0xAA55 | ||
|
||
;My bitmap | ||
bitmap: incbin "BSOD.bmp" ; Flipped image 640x480x1 | ||
BMP_SIZE equ $-bitmap ; Size of BMP in bytes | ||
times 32768 - ($ - $$) db 0 |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
cpu 386 | ||
bits 16 | ||
org 0h | ||
|
||
|
||
start: ;Ok, dont change this stuff either.. | ||
jmp short load_prog | ||
ident db "WobbyChip" | ||
|
||
;===================================================================================================================== | ||
|
||
load_prog: | ||
cld | ||
xor ax, ax | ||
mov ss, ax | ||
mov sp, 7c00h ;Setup stack | ||
|
||
mov ax, 8000h | ||
mov es, ax ;Initialize es w/ 8000h | ||
mov ds, ax ;Initialize ds w/ 8000h | ||
|
||
;===================================================================================================================== | ||
|
||
load_1: | ||
mov ax, 0206h ;Function/# of sec to read | ||
mov cx, 0001h ;0-5 sec # (counts from one), 6-7 hi cyl bits | ||
|
||
;MDP - Do not clobber DL, it still has the boot drive passed by BIOS | ||
mov dh, 00h ;Dh=head dl=drive (bit 7=hdd) | ||
mov bx, 0h ;Data buffer, points to es:0 | ||
int 13h | ||
cmp ah, 0 | ||
jne load_1 ;This is allowable because it is relative | ||
|
||
push es | ||
mov ax, counter_inc | ||
push ax | ||
retf | ||
|
||
;===================================================================================================================== | ||
|
||
print_str: | ||
push ax | ||
push di | ||
mov ah,0eh | ||
.getchar: | ||
lodsb ;Same as mov al,[si] and inc si | ||
test al, al ;Same as cmp al,0 | ||
jz .end | ||
int 10h | ||
jmp .getchar | ||
.end: | ||
pop di | ||
pop ax | ||
ret | ||
|
||
uint32_to_str: | ||
push edx | ||
push eax | ||
push ecx | ||
push bx | ||
push di | ||
xor bx, bx ;Digit count | ||
mov ecx, 10 ;Divisor | ||
.digloop: | ||
xor edx, edx ;Division will use 64-bit dividend in EDX:EAX | ||
div ecx ;Divide EDX:EAX by 10 ; EAX=Quotient ; EDX=Remainder(the current digit) | ||
add dl, '0' ;Convert digit to ASCII | ||
push dx ;Push on stack so digits can be popped off in everse order when finished | ||
inc bx ;Digit count += 1 | ||
test eax, eax | ||
jnz .digloop ;If dividend is zero then we are finished converting the number | ||
.popdigloop: ;Get digits from stack in reverse order we pushed them | ||
pop ax | ||
stosb ;Same as mov [ES:DI], al and inc di | ||
dec bx | ||
jne .popdigloop ;Loop until all digits have been popped | ||
mov al, 0 | ||
stosb ;NUL terminate string ; Same as mov [ES:DI], al and inc di | ||
pop di | ||
pop bx | ||
pop ecx | ||
pop eax | ||
pop edx | ||
ret | ||
|
||
;===================================================================================================================== | ||
|
||
counter_inc: | ||
mov eax, [number] | ||
mov di, strbuf ;ES:DI points to string buffer to store to | ||
call uint32_to_str ;Convert 32-bit unsigned value in EAX to ASCII string | ||
mov si, di ;DS:SI points to string buffer to print | ||
call print_str | ||
|
||
mov al, 13 ;Zero scancode | ||
mov ah, 0Eh ;Teletype character | ||
int 10h ;Call interrupt | ||
|
||
mov al, 10 ;Zero scancode | ||
mov ah, 0Eh ;Teletype character | ||
int 10h ;Call interrupt | ||
|
||
mov eax, [number] | ||
add eax, 1 ;Increase value by 1 | ||
mov [number], eax ;Store final value in number | ||
|
||
cmp eax, 1000 | ||
je timeout | ||
jmp counter_inc | ||
|
||
timeout: | ||
mov ah, 86h ;AH = 86 | ||
mov cx, 25 ;Set for timeout 50 | ||
int 15h ;Wait function | ||
|
||
counter_dec: | ||
mov eax, [number] | ||
mov di, strbuf ;ES:DI points to string buffer to store to | ||
call uint32_to_str ;Convert 32-bit unsigned value in EAX to ASCII string | ||
mov si, di ;DS:SI points to string buffer to print | ||
call print_str | ||
|
||
mov al, 13 ;Zero scancode | ||
mov ah, 0Eh ;Teletype character | ||
int 10h ;Call interrupt | ||
|
||
mov al, 10 ;Zero scancode | ||
mov ah, 0Eh ;Teletype character | ||
int 10h ;Call interrupt | ||
|
||
mov eax, [number] | ||
sub eax, 1 ;Decrease value by 1 | ||
mov [number], eax ;Store final value in number | ||
|
||
cmp eax, 0 | ||
je halt | ||
jmp counter_dec | ||
|
||
halt: | ||
hlt | ||
jmp halt | ||
|
||
;===================================================================================================================== | ||
|
||
MBR_Signature: | ||
number dd 0 | ||
strbuf db 0 | ||
times 510-($-$$) db 0 | ||
db 55h,0aah | ||
times 4096-($-$$) db 0 |
Oops, something went wrong.