Skip to content

Commit e00f0d6

Browse files
committed
v1.5
1 parent 4ee0643 commit e00f0d6

35 files changed

Lines changed: 1308 additions & 2 deletions

index.html

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ <h1>An Independent Kernel <br><span>Built from Scratch</span></h1>
284284
<p class="subtitle">Not Linux. Not Windows. TiwutOS is a custom-built 32-bit operating system featuring a hybrid kernel, Python-style scripting, and a clean interface.</p>
285285

286286
<div class="cta-buttons">
287-
<a href="v1.4/TiwutOS.iso" class="btn btn-primary">Download v1.4</a>
287+
<a href="v1.5/TiwutOS.iso" class="btn btn-primary">Download v1.5</a>
288288
<a href="https://github.com/tiwut/TiwutOS" class="btn btn-secondary">View on GitHub</a>
289289
</div>
290290

291-
<img src="v1.4/screenshot.png" style="width: 100%; height: 100%; object-fit: cover; border-radius: 12px;">
291+
<img src="v1.5/screenshot.png" style="width: 100%; height: 100%; object-fit: cover; border-radius: 12px;">
292292
</header>
293293

294294
<section id="features">
@@ -339,6 +339,29 @@ <h2>Source Code</h2>
339339
<div class="section-title">
340340
<h3>GitHub (RAW)</h3>
341341
</div>
342+
<h4>v1.5</h4>
343+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/kernel.cpp">kernel.cpp</a>
344+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/kernel.h">kernel.h</a>
345+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/drivers.cpp">drivers.cpp</a>
346+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/utils.cpp">utils.cpp</a>
347+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/boot.asm">boot.asm</a>
348+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/link.ld">link.ld</a>
349+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/apps.cpp">apps.cpp</a>
350+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/graphics.cpp">graphics.cpp</a>
351+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/graphics.h">graphics.h</a>
352+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/gui.cpp">gui.cpp</a>
353+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/gui.h">gui.h</a>
354+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/io.cpp">io.cpp</a>
355+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/io.h">io.h</a>
356+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/keyboard.cpp">keyboard.cpp</a>
357+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/keyboard.h">keyboard.h</a>
358+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/os.h">os.h</a>
359+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/ports.h">ports.h</a>
360+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/screen.cpp">screen.cpp</a>
361+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/screen.h">screen.h</a>
362+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/types.h">types.h</a>
363+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/utils.cpp">utils.cpp</a>
364+
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.5/utils.h">utils.h</a>
342365
<h4>v1.4</h4>
343366
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.4/kernel.cpp">kernel.cpp</a>
344367
<a href="https://raw.githubusercontent.com/tiwut/TiwutOS/refs/heads/main/v1.4/kernel.h">kernel.h</a>

v1.5/TiwutOS.iso

9.9 MB
Binary file not shown.

v1.5/apps.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "os.h"
2+
3+
void strcpy(char* d, const char* s) { while(*s) *d++ = *s++; *d=0; }
4+
int strlen(const char* s) { int i=0; while(s[i])i++; return i; }
5+
void itoa(int n, char* b) {
6+
if(n==0){b[0]='0';b[1]=0;return;}
7+
int i=0,k=n; while(k>0){k/=10;i++;} b[i]=0;
8+
while(n>0){b[--i]=(n%10)+'0';n/=10;}
9+
}
10+
11+
void app_terminal_input(AppBuffer* term, char c) {
12+
if(c == '\n') {
13+
term->row++; term->col=0;
14+
strcpy(term->lines[term->row], "root@tiwut: ");
15+
term->col = 12;
16+
} else if(c == '\b') {
17+
if(term->col > 12) { term->col--; term->lines[term->row][term->col] = 0; }
18+
} else {
19+
if(term->col < 38) {
20+
term->lines[term->row][term->col] = c;
21+
term->lines[term->row][term->col+1] = 0;
22+
term->col++;
23+
}
24+
}
25+
if(term->row >= 9) term->row = 0;
26+
}

v1.5/boot.asm

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
bits 32
2+
section .multiboot
3+
align 4
4+
dd 0x1BADB002 ; Magic
5+
dd 0x00000007 ; Flags (Align | Mem | Video)
6+
dd - (0x1BADB002 + 0x00000007) ; Checksum
7+
dd 0, 0, 0, 0, 0
8+
dd 0 ; Mode (Linear)
9+
dd 1024 ; Width
10+
dd 768 ; Height
11+
dd 32 ; Depth
12+
13+
section .text
14+
global start
15+
extern kernel_main
16+
17+
start:
18+
cli
19+
mov esp, stack_top
20+
push ebx ; Push Multiboot Info
21+
push eax ; Push Magic
22+
call kernel_main
23+
hlt
24+
25+
section .bss
26+
align 16
27+
stack_bottom:
28+
resb 16384
29+
stack_top:

v1.5/boot.o

736 Bytes
Binary file not shown.

v1.5/boot.o

736 Bytes
Binary file not shown.

v1.5/build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "1. Cleaning..."
5+
rm -f *.o kernel.bin TiwutOS.iso
6+
7+
echo "2. Compiling C++ Files..."
8+
CPPFLAGS="-m32 -ffreestanding -fno-rtti -fno-exceptions -Wall -Wextra -c"
9+
10+
# We only compile kernel.cpp as it now contains all necessary logic (Utils, Screen, Keyboard)
11+
# This avoids ODR violations with old screen.cpp/keyboard.cpp
12+
g++ $CPPFLAGS kernel.cpp -o kernel.o
13+
14+
echo "3. Assembling Bootloader..."
15+
nasm -f elf32 boot.asm -o boot.o
16+
17+
echo "4. Linking..."
18+
# Only link boot.o and kernel.o
19+
ld -m elf_i386 -T link.ld -o kernel.bin boot.o kernel.o
20+
21+
echo "5. Building ISO..."
22+
mkdir -p isodir/boot/grub
23+
cat > isodir/boot/grub/grub.cfg << EOF
24+
set timeout=0
25+
set default=0
26+
menuentry "TiwutOS C++" { multiboot /boot/kernel.bin; boot; }
27+
EOF
28+
cp kernel.bin isodir/boot/kernel.bin
29+
grub-mkrescue -o TiwutOS.iso isodir
30+
31+
echo "6. Running..."
32+
qemu-system-i386 -cdrom TiwutOS.iso

v1.5/disk.img

32 MB
Binary file not shown.

v1.5/disk2.img

10 MB
Binary file not shown.

v1.5/drivers.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include "types.h"
2+
3+
const char kbd_map[128] = {
4+
0, 27, '1','2','3','4','5','6','7','8','9','0','-','=','\b',
5+
'\t','q','w','e','r','t','y','u','i','o','p','[',']','\n',
6+
0,'a','s','d','f','g','h','j','k','l',';','\'','`',
7+
0,'\\','z','x','c','v','b','n','m',',','.','/',0,'*',0,' '
8+
};
9+
10+
class Input {
11+
public:
12+
static char GetKey() {
13+
if(IO::inb(0x64)&1) {
14+
if(!(IO::inb(0x64)&0x20)) {
15+
uint8_t s = IO::inb(0x60);
16+
if(!(s&0x80) && s<128) return kbd_map[s];
17+
}
18+
}
19+
return 0;
20+
}
21+
};
22+
23+
class Mouse {
24+
public:
25+
static int x, y;
26+
static bool left;
27+
static uint8_t cycle;
28+
static int8_t pkt[3];
29+
30+
static void Init() {
31+
IO::outb(0x64, 0xA8); IO::outb(0x64, 0x20);
32+
uint8_t s = (IO::inb(0x60)|2);
33+
IO::outb(0x64, 0x60); IO::outb(0x60, s);
34+
IO::outb(0x64, 0xD4); IO::outb(0x60, 0xF4); IO::inb(0x60);
35+
x=512; y=384;
36+
}
37+
38+
static void Update() {
39+
if((IO::inb(0x64)&1) && (IO::inb(0x64)&0x20)) {
40+
uint8_t b = IO::inb(0x60);
41+
if(cycle==0 && (b&8)) { pkt[0]=b; cycle++; }
42+
else if(cycle==1) { pkt[1]=b; cycle++; }
43+
else if(cycle==2) {
44+
pkt[2]=b; cycle=0;
45+
left = (pkt[0] & 1);
46+
x += pkt[1]; y -= pkt[2];
47+
if(x<0)x=0; if(x>1020)x=1020;
48+
if(y<0)y=0; if(y>760)y=760;
49+
}
50+
}
51+
}
52+
};
53+
int Mouse::x=0; int Mouse::y=0; bool Mouse::left=false;
54+
uint8_t Mouse::cycle=0; int8_t Mouse::pkt[3];

0 commit comments

Comments
 (0)