Skip to content

Commit 2dd6798

Browse files
fix MID$ and improve demo massively
1 parent 2b1aeab commit 2dd6798

9 files changed

Lines changed: 212 additions & 97 deletions

File tree

build-usb.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
}
2626

2727
function run(string $cmd, array $env = []): void {
28-
echo ">> RUN: $cmd\n";
2928
$proc = proc_open($cmd, [1=>['pipe','w'], 2=>['pipe','w']], $pipes, null, $env + $_ENV);
3029
if (!is_resource($proc)) {
3130
throw new RuntimeException("failed to start: $cmd");
@@ -56,6 +55,8 @@ function align_up(int $x, int $a): int {
5655
ensure_file(LIMINE_BIN);
5756
ensure_file(LIMINE_CONF);
5857

58+
echo ">> Compressing root.iso.gz\n";
59+
5960
$root_gz = BUILD_DIR . '/root.iso.gz';
6061
run(sprintf("gzip -9 -n -c %s > %s", escapeshellarg(RR_ISO), escapeshellarg($root_gz)));
6162

@@ -75,16 +76,24 @@ function align_up(int $x, int $a): int {
7576
unlink(OUT_IMG);
7677
}
7778

79+
echo ">> Truncating " . OUT_IMG . "\n";
80+
7881
run(sprintf("truncate -s %d %s", $img_bytes, escapeshellarg(OUT_IMG)));
7982

83+
echo ">> Partitioning " . OUT_IMG . "\n";
84+
8085
run(sprintf("sgdisk -o -a 1 -n 1:34:2047 -t 1:ef02 -n 2:%d:0 -t 2:ef00 %s", $start_lba, escapeshellarg(OUT_IMG)));
8186
run(sprintf("sgdisk --hybrid 2:EE %s", escapeshellarg(OUT_IMG)));
8287
run(sprintf("printf 'a\n1\nw\n' | fdisk %s", escapeshellarg(OUT_IMG)));
8388

8489
$env = ['MTOOLS_SKIP_CHECK' => '1'];
8590

91+
echo ">> Formatting " . OUT_IMG . "\n";
92+
8693
run(sprintf("mformat -i %s@@%d -F -v %s ::", escapeshellarg(OUT_IMG), $offset_bytes, escapeshellarg(VOL_LABEL)), $env);
8794

95+
echo ">> Copying files to " . OUT_IMG . "\n";
96+
8897
$img_spec = escapeshellarg(OUT_IMG . '@@' . (string)$offset_bytes);
8998

9099
run("mmd -i $img_spec ::/EFI", $env);
@@ -97,9 +106,13 @@ function align_up(int $x, int $a): int {
97106
run(sprintf("mcopy -i %s %s ::/root.iso.gz", $img_spec, escapeshellarg($root_gz)), $env);
98107
run(sprintf("mcopy -i %s %s ::/limine.conf", $img_spec, escapeshellarg(LIMINE_CONF)), $env);
99108

109+
echo ">> Installing bootloader to " . OUT_IMG . "\n";
110+
100111
// Install BIOS bootloader
101112
run(sprintf("%s bios-install %s 1", escapeshellarg(LIMINE_BIN), escapeshellarg(OUT_IMG)));
102113

114+
echo ">> Fixup\n";
115+
103116
$fp = fopen(OUT_IMG, 'r+b');
104117
if ($fp === false) {
105118
throw new RuntimeException("failed to open image for MBR boot flag update");

include/pci.h

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,47 @@
66
#pragma once
77
#include <kernel.h>
88

9+
/**
10+
* @brief PCI subclass descriptor
11+
*
12+
* Represents a PCI subclass entry, including the subclass ID,
13+
* programming interface, and a human-readable description.
14+
*/
915
typedef struct {
10-
uint8_t id;
11-
uint8_t subclass;
12-
uint8_t progif;
13-
const char* description;
16+
uint8_t id; /**< Subclass ID */
17+
uint8_t subclass; /**< Subclass code */
18+
uint8_t progif; /**< Programming interface */
19+
const char* description; /**< Human-readable description */
1420
} pci_subclass;
1521

22+
/**
23+
* @brief Encoded PCI device address for configuration access
24+
*
25+
* This union represents the 32-bit value written to the PCI
26+
* configuration address port (0xCF8). It encodes bus, device,
27+
* function, and register offset fields.
28+
*
29+
* The layout matches the standard PCI configuration mechanism #1.
30+
*/
1631
typedef union pci_dev {
17-
uint32_t bits;
18-
struct {
19-
uint32_t always_zero : 2;
20-
uint32_t field_num : 6;
21-
uint32_t function_num : 3;
22-
uint32_t device_num : 5;
23-
uint32_t bus_num : 8;
24-
uint32_t reserved : 7;
25-
uint32_t enable : 1;
26-
};
32+
uint32_t bits; /**< Raw 32-bit encoded value */
33+
struct {
34+
uint32_t always_zero : 2; /**< Must be zero */
35+
uint32_t field_num : 6; /**< Register offset (DWORD aligned) */
36+
uint32_t function_num : 3; /**< Function number */
37+
uint32_t device_num : 5; /**< Device number */
38+
uint32_t bus_num : 8; /**< Bus number */
39+
uint32_t reserved : 7; /**< Reserved, must be zero */
40+
uint32_t enable : 1; /**< Enable bit (must be set to 1) */
41+
};
2742
} pci_dev_t;
2843

44+
/**
45+
* @brief Zero-initialised PCI device descriptor
46+
*
47+
* Used as a default or sentinel value when no valid PCI device
48+
* is selected.
49+
*/
2950
extern pci_dev_t dev_zero;
3051

3152
#define PCI_CONFIG_ADDRESS 0xCF8

os/images/cat.gif

2.15 MB
Loading

os/images/dance.gif

804 KB
Loading

os/programs/cube.rrbasic

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CX# = GRAPHICS_WIDTH / 2
66
CY# = GRAPHICS_HEIGHT / 2
77
SCALE# = 250
88
DIST# = 3
9+
SPEED# = 0.03
910

1011
PAGE OFF
1112
SPRITELOAD s1, "/images/s1.png"
@@ -121,55 +122,39 @@ DEF FNloop(q)
121122
NEXT
122123
RECTANGLE min_x# - 16, min_y# - 16, max_x# + 16, max_y# + 16
123124

124-
ANGLE# = ANGLE# + 0.07
125+
ANGLE# = ANGLE# + SPEED#
125126
SY# = SIN(ANGLE#)
126127
CYR# = COS(ANGLE#)
127-
SX# = SIN(ANGLE# * 0.7)
128-
CXR# = COS(ANGLE# * 0.7)
128+
SX# = SIN(ANGLE# * SPEED# * 3)
129+
CXR# = COS(ANGLE# * SPEED# * 3)
129130

130131
FOR I = 0 TO 7
131-
X# = VX#(I)
132-
Y# = VY#(I)
133-
Z# = VZ#(I)
134-
135-
X1# = X# * CYR# - Z# * SY#
136-
Z1# = X# * SY# + Z# * CYR#
137-
138-
Y1# = Y# * CXR# - Z1# * SX#
139-
Z2# = Y# * SX# + Z1# * CXR#
140-
132+
X1# = VX#(I) * CYR# - VZ#(I) * SY#
133+
Z1# = VX#(I) * SY# + VZ#(I) * CYR#
134+
Y1# = VY#(I) * CXR# - Z1# * SX#
135+
Z2# = VY#(I) * SX# + Z1# * CXR#
141136
Xr#(I) = X1#
142137
Yr#(I) = Y1#
143138
Zr#(I) = Z2#
144-
145139
DEN# = Z2# + DIST# + 0.00000000001
146-
147140
PX#(I) = CX# + (X1# * SCALE# / DEN#)
148141
PY#(I) = CY# + (Y1# * SCALE# / DEN#)
149-
150142
NEXT
151143

152144
FOR f = 0 TO 5
153-
a = F(f * 4 + 0)
154-
b = F(f * 4 + 1)
155-
c = F(f * 4 + 2)
156-
d = F(f * 4 + 3)
157-
DEPTH#(f) = (Zr#(a) + Zr#(b) + Zr#(c) + Zr#(d)) / 4
145+
DEPTH#(f) = (Zr#(F(f * 4 + 0)) + Zr#(F(f * 4 + 1)) + Zr#(F(f * 4 + 2)) + Zr#(F(f * 4 + 3))) / 4
158146
IDX(f) = f
159147
NEXT
160148

161149
ARRSORTBY IDX, DEPTH#, TRUE
162150

163151
FOR k = 0 TO 5
164152
f = IDX(k)
165-
166153
a = F(f * 4 + 0)
167154
b = F(f * 4 + 1)
168155
c = F(f * 4 + 2)
169156
d = F(f * 4 + 3)
170-
171157
PLOTQUAD s1, PX#(a),PY#(a), PX#(b),PY#(b), PX#(c),PY#(c), PX#(d),PY#(d)
172-
173158
NEXT
174159

175160
frame_len = TICKS - start

0 commit comments

Comments
 (0)