Compare commits

...

5 Commits

Author SHA1 Message Date
  Jakob Kjær-Kammersgaard 856f45c228 limited memory 5 years ago
  Jakob Kjær-Kammersgaard 2f6d427fd3 Stack now works in 32 bit 5 years ago
  Jakob Kjær-Kammersgaard d55e31b08c Merge branch 'master' of git.imada.sdu.dk:SingOS/SingOS into animation 5 years ago
  Jakob Kjær-Kammersgaard 91bc53bb87 Cool Animation 5 years ago
  Jakob Kjær-Kammersgaard 4b8a758262 320x200 5 years ago
6 changed files with 107 additions and 73 deletions
Split View
  1. +0
    -0
      DEBUG_32_GRAPHICS
  2. +2
    -0
      bootloader.nasm
  3. +10
    -15
      build
  4. +1
    -1
      build.sh
  5. +89
    -57
      go32bit.nasm
  6. +5
    -0
      kernel.nasm

+ 0
- 0
DEBUG_32_GRAPHICS View File


+ 2
- 0
bootloader.nasm View File

@ -28,6 +28,7 @@ start:
mov si, message ; Put address of the null-terminated string to output into 'si'
call print ; Call our string-printing routine
%ifdef DEBUG_MODE
mov si, enter_debug_mode
call print
call printCRLF
@ -43,6 +44,7 @@ start:
mov ah, 0x01 ; BIOS call to wait for key
int 0x16
jnz debug_mode
%endif
; entering system check:
mov si, enter_system_check

+ 10
- 15
build View File

@ -1,17 +1,12 @@
#!/usr/bin/bash
# if [ "$1" == "build" ] || [ "$1" == "run" ]; then
# nasm -fbin bootloader.nasm -o bootloader.bin
# nasm -fbin kernel.nasm -o kernel.bin
# cat bootloader.bin kernel.bin > SingOS.img
# if [ $1 == "run" ]; then
# qemu-system-x86_64 -drive index=0,format=raw,file=SingOS.img
# else
# bash -c "echo;echo;echo 'Press [ENTER] to exit'; read line"
# fi
# fi
# echo "Done"
sh build.sh
defines="-d DEBUG_32_GRAPHICS"
if nasm -fbin $defines bootloader.nasm -o bootloader.bin \
&& nasm -fbin $defines kernel.nasm -o kernel.bin
then
cat bootloader.bin kernel.bin > SingOS.img
qemu-system-x86_64 -soundhw pcspk -m 2M -drive index=0,format=raw,file=SingOS.img
else
echo "*** THERE WERE ERRORS ***"
read
fi

+ 1
- 1
build.sh View File

@ -7,7 +7,7 @@ if [ "$1" != "run" ]; then
fi
if [ "$1" != "make" ]; then
qemu-system-x86_64 -drive index=0,format=raw,file=SingOS.img
qemu-system-x86_64 -soundhw pcspk -drive index=0,format=raw,file=SingOS.img
fi
echo "Done"

+ 89
- 57
go32bit.nasm View File

@ -1,4 +1,3 @@
%define GDT_Paragraph 0x1000
%define GDT (GDT_Paragraph*16)
%define GDT_CodeSegIndex 1
@ -7,7 +6,8 @@
%define GDT_CodeSegmentSelector GDT_Selector(GDT_CodeSegIndex, 0, 0)
%define GDT_DataSegmentSelector GDT_Selector(GDT_DataSegIndex, 0, 0)
%define VIDEO 0xB8000
; %define VIDEO 0xB0000
%define VIDEO 0xA0000
; GDT Stuff
%define Data 0000b
@ -171,7 +171,7 @@ Go32Bit:
call Enable_A20
; Set screen mode
mov ax, 0x0003 ; AH=0 (Change video mode), AL=13h (Mode) = 320x200 - 256 colors
mov ax, 0x0013 ; AH=0 (Change video mode), AL=13h (Mode) = 320x200 - 256 colors
mov bx, 0x0000
int 0x10 ; Video BIOS interrupt
@ -183,7 +183,7 @@ Go32Bit:
mov cx, 1024
lea si, [GO32_COPY_BEGIN]
xor di, di
rep movsb
rep movsw
%assign GDT_SIZE 0
@ -242,65 +242,97 @@ ProtectedModeBaby:
mov gs, ax
; Setup stack
mov esp, 0xffffffff
mov esp, 2*1024*1024 ; 2 MiB
mov ebp, esp
mov ecx, 1000
back:
call DrawStuff
loop back
call Reboot
HALT:
cli
hlt
jmp HALT
; ------------------------------------------------------------------------------
Rand:
; IN: Nothing
; OUT: eax = next random number
xor eax, eax
imul eax, DWORD [NextRand], 1103515245
add eax, 12345
mov DWORD [NextRand], eax
shr eax, 16
and eax, 0x7fff
ret
NextRand: dd 14517
; ------------------------------------------------------------------------------
DrawStuff:
; IN: Nothing
; OUT: Nothing
push ebp
mov ebp, esp
pushad
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 ecx, 0
inc edx
cmp edx, 25
je BreakLoopRows
jmp LoopRows
BreakLoopRows:
WriteProtectedModeString:
cld
lea esi, [ProtectedWelcomeStr]
lea edi, [VIDEO+(80*2)*12+19*2]
.print_loop:
mov al, BYTE [esi]
test al, al
jz .break_print_loop
mov BYTE [edi], al
mov BYTE [edi+1], 0x0f
inc esi
inc edi
DrawLoop:
mov eax, ecx
mov ebp, DWORD [ViewX]
shr ebp, 0
add eax, ebp
imul eax, eax
; shr eax, 13
mov ebx, edx
add ebp, DWORD [ViewY]
shr ebp, 0
add ebx, ebp
imul ebx, ebx
; shr ebx, 5
add eax, ebx
shr eax, 11
mov [edi], al
inc edi
jmp .print_loop
.break_print_loop:
inc ecx
cmp ecx, 320
jne DrawLoop
HALT:
cli
hlt
jmp HALT
xor ecx, ecx
inc edx
cmp edx, 200
jne DrawLoop
add DWORD [ViewX], 1
add DWORD [ViewY], 1
popad
pop ebp
ret
DeltaX: db 0
DeltaY: db 0
ViewX: dd -160
ViewY: dd -100
ColorOff: db 0
; ------------------------------------------------------------------------------
Reboot:
in al, 0x64
test al, 00000010b ; Wait for an empty Input Buffer
jne Reboot
mov al, 0xFE
out 0x64, al ; Send the reboot call to the keyboard controller
jmp Reboot
;;;;;;;;;;;;;;;;;;;;;;;;
;; Strings
;;;;;;;;;;;;;;;;;;;;;;;;
ProtectedWelcomeStr: db " Placeholder for SingOS - 32 bit edition! ", 0
align 512

+ 5
- 0
kernel.nasm View File

@ -24,6 +24,11 @@ sing_loaded: ; SingOS is ready for the user:
mov bp, sp
sing_ready: ; SingOS is ready for the user:
%ifdef DEBUG_32_GRAPHICS
jmp Go32Bit
%endif
call os_clear_screen
mov si, welcome ; Put address of the null-terminated string to output into 'si'
call print ; Call our string-printing routine

Loading…
Cancel
Save