Przeglądaj źródła

Print in 32

IDT
Jakob Kjær-Kammersgaard 5 lat temu
rodzic
commit
56d4f2759a
1 zmienionych plików z 125 dodań i 41 usunięć
  1. +125
    -41
      go32bit.nasm

+ 125
- 41
go32bit.nasm Wyświetl plik

@ -184,7 +184,7 @@ Go32Bit:
;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ax, GDT_Paragraph
mov es, ax
mov cx, 1024
mov cx, 4096
lea si, [GO32_COPY_BEGIN]
xor di, di
rep movsb
@ -251,42 +251,63 @@ ProtectedModeBaby:
mov gs, ax
; Setup stack
mov esp, 0xffffffff
mov esp, 0x800000
mov ebp, esp
DrawStuff:
mov ecx, 0
mov edx, 0
lea edi, [VIDEO]
mov ax, 0x4000
LoopRows:
LoopCols:
mov bl, cl
and bl, dl
shl bl, 4
mov ah, bl
ror bl, 1
xor ah, bl
and ah, 0x70
mov al, dl
add al, cl
and al, 4
ror al, 1
or ah, al
mov al, 0
mov WORD [edi], ax
inc edi
inc edi
inc ecx
cmp ecx, 80
je BreakLoopCols
jmp LoopCols
BreakLoopCols:
mov al, '@'
DrawBG:
mov eax, [Px]
shr eax, 6
add eax, ecx
imul eax, eax
sar eax, 1
; mov ax, bx
mov ebx, [Py]
shr ebx, 6
add ebx, edx
imul ebx, ebx
add eax, ebx
; eax = x^2 + y^2
mov ebx, [ColorOffset]
; imul eax, ebx
sar ebx, 8
; mov ebp, eax
; mov bl, (0xda - 0xb3)
; div byte bl
; mov bl, ah
; add bl, 0xb3
; mov eax, ebp
; mov al, bl
; push eax
; push edx
; rdtsc
; mov ebx, eax
; shr ebx, 26
; pop edx
; pop eax
; mov ah, bl
add ah, bl
stosw
inc ecx
cmp ecx, 80
jne DrawBG
mov ecx, 0
inc edx
cmp edx, 25
je BreakLoopRows
jmp LoopRows
BreakLoopRows:
cmp edx, 24
jne DrawBG
WriteProtectedModeString:
cld
@ -317,47 +338,110 @@ WriteProtectedModeString:
; je .ThereWasSomething
.ThereWasNothing:
mov [Key], byte ' '
jmp .AfterThereWasSomething
jmp .PrintKeyLegend
; lea esi, [ProtectedWelcomeStr]
.KeyLeft:
mov [Key], byte 'L'
jmp .AfterThereWasSomething
add [Px], dword -1
jmp .PrintKeyLegend
.KeyUp:
mov [Key], byte 'U'
jmp .AfterThereWasSomething
add [Py], dword -1
jmp .PrintKeyLegend
.KeyRight:
mov [Key], byte 'R'
jmp .AfterThereWasSomething
add [Px], dword 1
jmp .PrintKeyLegend
.KeyDown:
mov [Key], byte 'D'
.AfterThereWasSomething:
add [Py], dword 1
.PrintKeyLegend:
lea esi, [ThereWasSomethingStr]
lea edi, [VIDEO+(80*2)*12+19*2]
lea edi, [VIDEO+(80*24 + (80-11))*2]
; lea edi, [VIDEO+(80*2)*12+30*2]
mov ah, 0x0f
.print_loop:
mov al, BYTE [esi]
test al, al
jz .break_print_loop
mov BYTE [edi], al
mov BYTE [edi+1], 0x0f
stosw
inc esi
inc edi
inc edi
jmp .print_loop
.break_print_loop:
lea edi, [VIDEO + (80*24 + 1)*2]
mov ecx, 40
xor eax, eax
rep stosw
lea edi, [VIDEO + (80*24 + 1)*2]
mov eax, dword [Px]
shr eax, 6
call StringifyEax10
lea edi, [VIDEO + (80*24 + 10)*2]
mov eax, dword [Py]
shr eax, 6
call StringifyEax10
add [ColorOffset], dword 1
jmp WriteProtectedModeString
jmp DrawStuff
HALT:
cli
hlt
jmp HALT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
StringifyEax10:
; Puts the stringified version of eax on the stack
; IN: eax = number to write
; IN: edi = base of where to write string
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pushad
mov ebx, 10 ; Divisor
xor ecx, ecx ; Digit count starts at 0
.loop_divide: ; finds digits and pushes them to stack
test eax, eax
jz .break_loop_divide
xor edx, edx
div ebx ; edx = (edx:eax)%ebx, eax = (edx:eax)/ebx
inc ecx ; Increase digit count
mov byte [.buffer + ecx], dl
jmp .loop_divide
.break_loop_divide:
; dec ecx
add edi, 16
sub edi, ecx
sub edi, ecx
.loop_print:
test ecx, ecx
jz .break_loop_print
mov al, byte [.buffer + ecx]
add al, '0' ; Convert to ascii
mov ah, 0x0f
stosw
dec ecx
jmp .loop_print
.break_loop_print:
popad
ret
.buffer times 40 db 0
;;;;;;;;;;;;;;;;;;;;;;;;
;; Strings
;;;;;;;;;;;;;;;;;;;;;;;;
ProtectedWelcomeStr: db " Placeholder for SingOS - 32 bit edition! ", 0
ThereWasSomethingStr: db " KEY = '"
Key: db " ' ", 0
Px: dd 0
Py: dd 0
ColorOffset: dw 0
align 512

Ładowanie…
Anuluj
Zapisz