Skip to content
This repository was archived by the owner on May 19, 2026. It is now read-only.

Commit 5f9ecfa

Browse files
Merge pull request #3 from JustAcoder617/master
nMaster
2 parents 5547ae8 + b7db6fe commit 5f9ecfa

9 files changed

Lines changed: 118 additions & 28 deletions

File tree

‎.github/workflows/discord_bot.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Discord Webhook Notification
2+
3+
on: [push]
4+
5+
jobs:
6+
notify:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout Code
10+
uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
14+
- name: Get Total Commits
15+
id: count
16+
run: |
17+
echo "total=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
18+
19+
- name: Discord Webhook Action
20+
uses: tsickert/discord-webhook@v5.3.0
21+
with:
22+
webhook-url: ${{ secrets.DISCORD_WEBHOOK }}
23+
embed-color: 3447003
24+
embed-thumbnail-url: "https://github.githubassets.com/images/modules/logos_page/Octocat.png"
25+
content: "😎️😏️🏗️💯️💻️🔥️ :ANOTHER LEGEND JUST PUSHED CODE!"
26+
embed-description: |
27+
The GOAT ```fix
28+
${{ github.actor }}
29+
``` just committed ```diff
30+
+ ${{ github.event.head_commit.message }}
31+
``` in the repo ```ini
32+
[${{ github.repository }}]
33+
``` at ```bash
34+
"${{ github.event.head_commit.timestamp }}"
35+
36+
```!! This is commit number ```yaml
37+
${{ steps.count.outputs.total }}
38+
``` for this repo. Keep up the great work! 🚀️.

‎apps/game/aleatorial.c‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include "aleatorial.h"
2+
#include "../../kernel_utils.h"
3+
#include "../../kernel_geral/math_utils.h"
4+
#include "../../kernel_geral/io.h"
5+
6+
void aleatorial(){
7+
k_clear_screen();
8+
k_print("------------- Aleatorial -----------");
9+
k_print("\n");
10+
k_print("Tente adivinhar um numero que eu (sua cpu) pensou (1 a 10): ");
11+
12+
uint16_t numero = rdtsc() % 10 + 1;
13+
int c = 0;
14+
15+
while (c == 0)
16+
{
17+
int resposta = k_scanf("i");
18+
int choice = *(int*)resposta;
19+
20+
if (numero > choice)
21+
{
22+
k_print("O numero e maior que esse.");
23+
k_print("\n");
24+
k_print("Digite outro numero: ");
25+
}
26+
else if (numero < choice)
27+
{
28+
k_print("O numero e menor que esse.");
29+
k_print("\n");
30+
k_print("Digite outro numero: ");
31+
}
32+
else
33+
{
34+
k_print("Parabens! voce acertou!!");
35+
k_print("\n");
36+
c = 1;
37+
}
38+
}
39+
}

‎apps/game/aleatorial.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#define ALEATORIAL_H
2+
3+
void aleatorial();

‎apps/system_monitor/monitor.c‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ extern int check_funcionando;
77
extern int check_interrupter;
88

99
void monitor_setup() {
10-
if (check_funcionando == 0) {
11-
k_print("O sistema de verificacao geral do kernel esta funcionando corretamente.");
12-
k_print("\n");
13-
} else {
14-
k_print("ATENCAO: A VERIFICAO GERAL DE ERROS DESTE KERNEL ESTA DESATIVADA POR UM MOTIVO DESCONHECIDO. E ALTAMENTE RECOMENDADO REINICIAR O COMPUTADOR, POIS, A QUALQUER MOMENTO, ELE PODE REINICIAR OU TRAVAR SEM JUSTIFICATIVA.");
15-
k_print("\n");
16-
return;
10+
k_clear_screen();
11+
k_print("------ System Monitor-------\n\n\n");
12+
k_print("bem vindo ao monitor de sistema do sample os!\n");
13+
if (check_funcionando==0)
14+
{
15+
k_print("a verificacao geral do sistema esta funcionando corretamente.\n\n");
16+
} else{
17+
k_print("a verificacao geral do sistema nao esta funcionando. E recomendado desligar o pc...\n\n");
1718
}
18-
19-
if (check_interrupter == 0) {
20-
k_print("A funcao do time interrupter handler está funcionando corretamente.");
21-
k_print("\n");
22-
} else {
23-
k_print("ATENCAO: A FUNCAO TIME INTERRUPTER HANDLER NAO ESTA FUNCIONANDO POR UM MOTIVO DESCONHECIDO. A VERIFICACAO CONTRA STACK_OVERFLOW ESTA DESATIVADA. E RECOMENDADO REINICIAR O COMPUTADOR.");
24-
k_print("\n");
19+
if (check_interrupter==1)
20+
{
21+
k_print("o sistema de interrupcoes de hardware esta funcionando\n");
22+
} else{
23+
k_print("o sistema de interrupcoes de hardware nao esta funcionando. Nao e muito perigoso, mas mesmo assim e recomendado desligar o pc...\n");
2524
}
2625
}

‎idt/idt.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ void idt_init();
3737
extern void gpf_handler(); // Vetor 13: General Protection Fault
3838
extern void div_zero_handler(); // Vetor 0: Divisão por zero
3939
extern void page_fault_handler(); // Vetor 14: Erro de memória
40-
extern void dummy_handler();
40+
extern void dummy_handler(); //simples dummy handler
4141
#endif

‎kernel_geral/math_utils.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "math_utils.h"
2+
#include "stdint.h"
3+
4+
uint64_t rdtsc() {
5+
//numeros aleatorios. É usado com , por exemplo: rdtsc() % 10 (gera um numero entre 0 e 9)
6+
uint32_t lo, hi;
7+
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
8+
return ((uint64_t)hi << 32) | lo;
9+
}

‎kernel_geral/math_utils.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define MATH_UTILS_H
2+
#include "stdint.h"
3+
4+
uint64_t rdtsc();

‎main.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "idt/pit.h"
77
#include "idt/idt.h"
88
#include "panic/panic.h"
9+
#include "apps/game/aleatorial.h"
910

1011
// Funcao vital para o hardware nao conflitar com a CPU
1112
void pic_remap() {
@@ -38,7 +39,7 @@ int main(){
3839
k_print("----- Ola! Bem-vindo ao SampeOs! -----\n");
3940

4041
while (1) {
41-
k_print("\nSelecione: 1. Calculadora | 2. Sair 3.Monitor de seguranca\n");
42+
k_print("\nSelecione: 1. Calculadora | 2. Sair 3.Monitor de seguranca 4.Jogo aleatorial\n");
4243
k_print("> ");
4344

4445
void* res = k_scanf("i");
@@ -47,18 +48,8 @@ int main(){
4748
if (choice == 1) {
4849
start_calculator();
4950
} else if (choice==4){
50-
k_print("Voce quer desligar o anti-virus do kernel? 1.sim 2.nao");
51-
void* res_sec = k_scanf("i");
52-
if (res_sec!=(void*)0)
53-
{
54-
int choice_sec=*(int*)res_sec;
55-
if (choice_sec==1)
56-
{
57-
k_print("Desligando checker da stack...");
58-
status_flag=0;
59-
continue;
60-
}
61-
}
51+
k_print("redirecionando...");
52+
aleatorial();
6253
}
6354
else if (choice == 2) {
6455
k_print("Desligando...");

‎makefile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ OBJS = boot.o \
2424
pit.o \
2525
panic.o \
2626
monitor.o \
27+
aleatorial.o \
28+
math.o \
2729

2830
# --- Regras Principais ---
2931

@@ -50,6 +52,8 @@ io.o: kernel_geral/io.c
5052
text.o: kernel_geral/text.c
5153
$(CC) $(CFLAGS) -c kernel_geral/text.c -o text.o
5254

55+
math.o: kernel_geral/math_utils.c
56+
$(CC) $(CFLAGS) -c kernel_geral/math_utils.c -o math.o
5357
# --- Pasta: security_check (O Vigia da Stack) ---
5458

5559
timer.o: security_check/timer.asm
@@ -62,6 +66,8 @@ stack_check.o: security_check/stack_check.c
6266
$(CC) $(CFLAGS) -c security_check/stack_check.c -o stack_check.o
6367

6468
# --- Pasta: apps (Calculadora e outros) ---
69+
aleatorial.o: apps/game/aleatorial.c
70+
$(CC) $(CFLAGS) -c apps/game/aleatorial.c -o aleatorial.o
6571

6672
calculator.o: apps/calculator.c
6773
$(CC) $(CFLAGS) -c apps/calculator.c -o calculator.o
@@ -79,6 +85,7 @@ main.o: main.c
7985
kernel_utils.o: kernel_utils.c
8086
$(CC) $(CFLAGS) -c kernel_utils.c -o kernel_utils.o
8187

88+
8289
# --- Comandos de Utilidade ---
8390

8491
run:

0 commit comments

Comments
 (0)