From de4de4db133bfdabccc5318c30059681bcdc19a6 Mon Sep 17 00:00:00 2001 From: dpethes Date: Mon, 15 Jan 2018 21:06:02 +0100 Subject: [PATCH] fix some datatype mismatches in parsers to run properly in debug mode --- model_viewer/model_viewer.lpi | 8 -------- rs_units/hmt_parser.pas | 13 ++++++++++--- rs_units/hob_parser.pas | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/model_viewer/model_viewer.lpi b/model_viewer/model_viewer.lpi index c98787b..08c2ee1 100644 --- a/model_viewer/model_viewer.lpi +++ b/model_viewer/model_viewer.lpi @@ -125,14 +125,6 @@ - - - - - - - - diff --git a/rs_units/hmt_parser.pas b/rs_units/hmt_parser.pas index 88d2855..6eb872e 100644 --- a/rs_units/hmt_parser.pas +++ b/rs_units/hmt_parser.pas @@ -58,7 +58,7 @@ var image: TRSImage; buf: array[0..27] of byte; description: TImageDescription; - color_rgba: integer; + color_rgba: longword; pos: int64; u0, u1, bits_per_sample: byte; begin @@ -73,7 +73,7 @@ begin bits_per_sample := f.ReadByte; image.type_ := f.ReadByte; u1 := f.ReadByte; - color_rgba := f.ReadDWord; + color_rgba := f.ReadDWord; //unused? pos := f.Position; f.Seek(tex.name_offset, TSeekOrigin.soBeginning); @@ -85,9 +85,16 @@ begin image.sampleBits := description.sample_bits; image.paletteEntries := description.palette_entries; image.width := tex.width; - //if (image.width and 1) > 1 then image.width += 1; image.height := tex.height; + //fix stride in some images? + //if (image.width and 1) > 1 then image.width += 1; + //if (image.type_ = 4) and (image.sampleBits = 4) then + // if (image.width and 1) = 1 then begin + // image.width += 1; + // writeln('fix width'); + // end; + writeln('name: ', tex.name_string); writeln('size: ', tex.width, 'x', tex.height); writeln('subtype: ', image.type_); diff --git a/rs_units/hob_parser.pas b/rs_units/hob_parser.pas index 7818d92..a5cbab8 100644 --- a/rs_units/hob_parser.pas +++ b/rs_units/hob_parser.pas @@ -8,7 +8,7 @@ uses type TRGBA = record - color: integer; + color: longword; end; TTexCoord = record @@ -95,7 +95,7 @@ var face: THobFace; zero: integer; file_pos: integer; - color: integer; + color: longword; begin zero := f.ReadQWord; if (zero <> 0) then @@ -152,8 +152,8 @@ begin //uv coords if face.flags and FACE_UV > 0 then begin for k := 0 to face.ftype - 1 do begin - face.tex_coords[k].u := f.ReadWord; - face.tex_coords[k].v := f.ReadWord; + face.tex_coords[k].u := smallint(f.ReadWord); + face.tex_coords[k].v := smallint(f.ReadWord); end; end;