refactor: namespace restructure of entire codebase
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Reorganize all source files into a hierarchical namespace structure with dot-separated unit names matching directory paths. Major changes: - src/prog/ -> src/app/ (app.*.pas) - src/fault/ -> src/arch/x86/fault/ (arch.x86.fault.*.pas) - src/isr/ -> src/arch/x86/isr/ (arch.x86.isr.*.pas) - src/include/ -> src/core/ (core.*.pas) + src/arch/x86/ - src/driver/ subtree reorganized with driver.* namespace prefixes - src/driver/storage/con/ -> src/driver/storage/ctl/ (Windows reserved name fix) - src/driver/storage/ split into con(ctl)/fs/vol/ subdirectories - src/driver/net/ flattened from l1-l5 layers to driver.net.*.pas - kernel.pas -> asuro.pas, faults.pas -> arch.x86.faults.pas - stdio.pas/syslog.pas -> io/io.stdio.pas, io/io.syslog.pas - processmanager.pas -> proc/proc.mgr.pas - lmemorymanager.pas -> memory/memory.heap.pas - Build scripts moved to toolchain/ - Added compat/ shims for lmemorymanager and types - Added doc/namespace.md tracking the refactor 197 files changed, 6292 insertions(+), 5526 deletions(-)
This commit is contained in:
1 parent
e922f086c2
commit
6fa008ed79
197 files changed
+6291
-5525
No files matched your search
@@ -0,0 +1,77 @@
|
||||
unit core.fmt.targa;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
memory.heap, core.gfx.texture;
|
||||
|
||||
type
|
||||
TTARGAColor = packed record
|
||||
b, g, r, a: uint8;
|
||||
end;
|
||||
PTARGAColor = ^TTARGAColor;
|
||||
|
||||
TTARGAHeader = packed record
|
||||
IDLength: uint8;
|
||||
ColorMapType: uint8;
|
||||
ImageType: uint8;
|
||||
ColorMapOrigin: uint16;
|
||||
ColorMapLength: uint16;
|
||||
ColorMapDepth: uint8;
|
||||
XOrigin: uint16;
|
||||
YOrigin: uint16;
|
||||
Width: uint16;
|
||||
Height: uint16;
|
||||
PixelDepth: uint8;
|
||||
ImageDescriptor: uint8;
|
||||
end;
|
||||
PTARGAHeader = ^TTARGAHeader;
|
||||
|
||||
Function Parse(buffer : puint8; len : uint32) : PTexture;
|
||||
|
||||
implementation
|
||||
|
||||
Function Parse(buffer : puint8; len : uint32) : PTexture;
|
||||
var
|
||||
header : PTARGAHeader;
|
||||
src : PTARGAColor;
|
||||
tex : PTexture;
|
||||
x, y : uint32;
|
||||
dstRow : uint32;
|
||||
topDown: boolean;
|
||||
|
||||
begin
|
||||
Parse := nil;
|
||||
if len < sizeof(TTARGAHeader) then exit;
|
||||
|
||||
header := PTARGAHeader(buffer);
|
||||
if (header^.ImageType <> 2) or (header^.PixelDepth <> 32) then exit;
|
||||
|
||||
{ Pixel data starts after the 18-byte header + any ID field. }
|
||||
src := PTARGAColor(buffer + sizeof(TTARGAHeader) + header^.IDLength);
|
||||
|
||||
{ Bit 5 of ImageDescriptor: 1 = top-to-bottom, 0 = bottom-to-top. }
|
||||
topDown := (header^.ImageDescriptor AND $20) <> 0;
|
||||
|
||||
tex := core.gfx.texture.newTexture(header^.Width, header^.Height);
|
||||
|
||||
for y := 0 to header^.Height - 1 do begin
|
||||
{ Flip vertically when origin is bottom-left (the TGA default). }
|
||||
if topDown then
|
||||
dstRow := y
|
||||
else
|
||||
dstRow := (header^.Height - 1) - y;
|
||||
|
||||
for x := 0 to header^.Width - 1 do begin
|
||||
tex^.Pixels[dstRow * header^.Width + x].b := src^.b;
|
||||
tex^.Pixels[dstRow * header^.Width + x].g := src^.g;
|
||||
tex^.Pixels[dstRow * header^.Width + x].r := src^.r;
|
||||
tex^.Pixels[dstRow * header^.Width + x].a := src^.a;
|
||||
Inc(src);
|
||||
end;
|
||||
end;
|
||||
|
||||
Parse := tex;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in new issue
Block a user