diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 184f33adb1..4b3dc85c60 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -293,7 +293,7 @@ static int ListActionCommands (const char *pattern) #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const WORD *) (d))) +#define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) @@ -317,7 +317,7 @@ DWORD SuperFastHash (const char *data, size_t len) hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; - data += 2*sizeof (WORD); + data += 2*sizeof (uint16_t); hash += hash >> 11; } @@ -326,7 +326,7 @@ DWORD SuperFastHash (const char *data, size_t len) { case 3: hash += get16bits (data); hash ^= hash << 16; - hash ^= data[sizeof (WORD)] << 18; + hash ^= data[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); @@ -371,7 +371,7 @@ DWORD SuperFastHashI (const char *data, size_t len) hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; - data += 2*sizeof (WORD); + data += 2*sizeof (uint16_t); hash += hash >> 11; } @@ -380,7 +380,7 @@ DWORD SuperFastHashI (const char *data, size_t len) { case 3: hash += get16bits (data); hash ^= hash << 16; - hash ^= tolower(data[sizeof (WORD)]) << 18; + hash ^= tolower(data[sizeof (uint16_t)]) << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); diff --git a/src/decallib.cpp b/src/decallib.cpp index c8bdfb9ba8..511e2231f9 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -76,7 +76,7 @@ public: { Choices.ReplaceValues(from, to); } - void AddDecal (FDecalBase *decal, WORD weight) + void AddDecal (FDecalBase *decal, uint16_t weight) { Choices.AddEntry (decal, weight); } @@ -94,7 +94,7 @@ struct FDecalLib::FTranslation DWORD StartColor, EndColor; FTranslation *Next; - WORD Index; + uint16_t Index; }; struct FDecalAnimator @@ -422,7 +422,7 @@ void FDecalLib::ReadDecals(FScanner &sc) } } -WORD FDecalLib::GetDecalID (FScanner &sc) +uint16_t FDecalLib::GetDecalID (FScanner &sc) { sc.MustGetString (); if (!IsNum (sc.String)) @@ -437,14 +437,14 @@ WORD FDecalLib::GetDecalID (FScanner &sc) { sc.ScriptError ("Decal ID must be between 1 and 65535"); } - return (WORD)num; + return (uint16_t)num; } } void FDecalLib::ParseDecal (FScanner &sc) { FString decalName; - WORD decalNum; + uint16_t decalNum; FDecalTemplate newdecal; FTextureID picnum; int lumpnum; @@ -569,7 +569,7 @@ void FDecalLib::ParseDecal (FScanner &sc) void FDecalLib::ParseDecalGroup (FScanner &sc) { FString groupName; - WORD decalNum; + uint16_t decalNum; FDecalBase *targetDecal; FDecalGroup *group; @@ -871,7 +871,7 @@ void FDecalLib::ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *r root->ReplaceDecalRef (from, to); } -void FDecalLib::AddDecal (const char *name, WORD num, const FDecalTemplate &decal) +void FDecalLib::AddDecal (const char *name, uint16_t num, const FDecalTemplate &decal) { FDecalTemplate *newDecal = new FDecalTemplate; @@ -944,7 +944,7 @@ void FDecalLib::AddDecal (FDecalBase *decal) } } -const FDecalTemplate *FDecalLib::GetDecalByNum (WORD num) const +const FDecalTemplate *FDecalLib::GetDecalByNum (uint16_t num) const { if (num == 0) { @@ -972,7 +972,7 @@ const FDecalTemplate *FDecalLib::GetDecalByName (const char *name) const return NULL; } -FDecalBase *FDecalLib::ScanTreeForNum (const WORD num, FDecalBase *root) +FDecalBase *FDecalLib::ScanTreeForNum (const uint16_t num, FDecalBase *root) { while (root != NULL) { @@ -1109,7 +1109,7 @@ FDecalLib::FTranslation::FTranslation (DWORD start, DWORD end) table[i] = ColorMatcher.Pick (ri >> 24, gi >> 24, bi >> 24); } table[0] = table[1]; - Index = (WORD)TRANSLATION(TRANSLATION_Decals, tablei >> 8); + Index = (uint16_t)TRANSLATION(TRANSLATION_Decals, tablei >> 8); } FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (DWORD start, DWORD end) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index a5dc66a5bb..2aecd8e99b 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -641,7 +641,7 @@ void PInt::SetValue(void *addr, int val) } else if (Size == 2) { - *(WORD *)addr = val; + *(uint16_t *)addr = val; } else if (Size == 8) { @@ -677,7 +677,7 @@ int PInt::GetValueInt(void *addr) const } else if (Size == 2) { - return Unsigned ? *(WORD *)addr : *(SWORD *)addr; + return Unsigned ? *(uint16_t *)addr : *(SWORD *)addr; } else if (Size == 8) { // truncated output diff --git a/src/mus2midi.h b/src/mus2midi.h index 930f0a10bd..7b61f9e853 100644 --- a/src/mus2midi.h +++ b/src/mus2midi.h @@ -41,38 +41,38 @@ #include #include "doomtype.h" -#define MIDI_SYSEX ((BYTE)0xF0) // SysEx begin -#define MIDI_SYSEXEND ((BYTE)0xF7) // SysEx end -#define MIDI_META ((BYTE)0xFF) // Meta event begin -#define MIDI_META_TEMPO ((BYTE)0x51) -#define MIDI_META_EOT ((BYTE)0x2F) // End-of-track -#define MIDI_META_SSPEC ((BYTE)0x7F) // System-specific event +#define MIDI_SYSEX ((uint8_t)0xF0) // SysEx begin +#define MIDI_SYSEXEND ((uint8_t)0xF7) // SysEx end +#define MIDI_META ((uint8_t)0xFF) // Meta event begin +#define MIDI_META_TEMPO ((uint8_t)0x51) +#define MIDI_META_EOT ((uint8_t)0x2F) // End-of-track +#define MIDI_META_SSPEC ((uint8_t)0x7F) // System-specific event -#define MIDI_NOTEOFF ((BYTE)0x80) // + note + velocity -#define MIDI_NOTEON ((BYTE)0x90) // + note + velocity -#define MIDI_POLYPRESS ((BYTE)0xA0) // + pressure (2 bytes) -#define MIDI_CTRLCHANGE ((BYTE)0xB0) // + ctrlr + value -#define MIDI_PRGMCHANGE ((BYTE)0xC0) // + new patch -#define MIDI_CHANPRESS ((BYTE)0xD0) // + pressure (1 byte) -#define MIDI_PITCHBEND ((BYTE)0xE0) // + pitch bend (2 bytes) +#define MIDI_NOTEOFF ((uint8_t)0x80) // + note + velocity +#define MIDI_NOTEON ((uint8_t)0x90) // + note + velocity +#define MIDI_POLYPRESS ((uint8_t)0xA0) // + pressure (2 bytes) +#define MIDI_CTRLCHANGE ((uint8_t)0xB0) // + ctrlr + value +#define MIDI_PRGMCHANGE ((uint8_t)0xC0) // + new patch +#define MIDI_CHANPRESS ((uint8_t)0xD0) // + pressure (1 byte) +#define MIDI_PITCHBEND ((uint8_t)0xE0) // + pitch bend (2 bytes) -#define MUS_NOTEOFF ((BYTE)0x00) -#define MUS_NOTEON ((BYTE)0x10) -#define MUS_PITCHBEND ((BYTE)0x20) -#define MUS_SYSEVENT ((BYTE)0x30) -#define MUS_CTRLCHANGE ((BYTE)0x40) -#define MUS_SCOREEND ((BYTE)0x60) +#define MUS_NOTEOFF ((uint8_t)0x00) +#define MUS_NOTEON ((uint8_t)0x10) +#define MUS_PITCHBEND ((uint8_t)0x20) +#define MUS_SYSEVENT ((uint8_t)0x30) +#define MUS_CTRLCHANGE ((uint8_t)0x40) +#define MUS_SCOREEND ((uint8_t)0x60) typedef struct { - DWORD Magic; - WORD SongLen; - WORD SongStart; - WORD NumChans; - WORD NumSecondaryChans; - WORD NumInstruments; - WORD Pad; - // WORD UsedInstruments[NumInstruments]; + uint32_t Magic; + uint16_t SongLen; + uint16_t SongStart; + uint16_t NumChans; + uint16_t NumSecondaryChans; + uint16_t NumInstruments; + uint16_t Pad; + // uint16_t UsedInstruments[NumInstruments]; } MUSHeader; #endif //__MUS2MIDI_H__ diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 687a27a433..9968f7e52c 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -79,15 +79,15 @@ struct FRandomSoundList } } - WORD *Sounds; // A list of sounds that can result for the following id - WORD SfxHead; // The sound id used to reference this list - WORD NumSounds; + uint16_t *Sounds; // A list of sounds that can result for the following id + uint16_t SfxHead; // The sound id used to reference this list + uint16_t NumSounds; }; struct FPlayerClassLookup { FString Name; - WORD ListIndex[3]; // indices into PlayerSounds (0xffff means empty) + uint16_t ListIndex[3]; // indices into PlayerSounds (0xffff means empty) }; // Used to lookup a sound like "*grunt". This contains all player sounds for @@ -1070,7 +1070,7 @@ void S_AddLocalSndInfo(int lump) static void S_AddSNDINFO (int lump) { bool skipToEndIf; - TArray list; + TArray list; FScanner sc(lump); skipToEndIf = false; @@ -1395,7 +1395,7 @@ static void S_AddSNDINFO (int lump) sc.MustGetStringName ("{"); while (sc.GetString () && !sc.Compare ("}")) { - WORD sfxto = S_FindSoundTentative (sc.String); + uint16_t sfxto = S_FindSoundTentative (sc.String); if (sfxto == random.SfxHead) { Printf("Definition of random sound '%s' refers to itself recursively.", sc.String); @@ -1410,11 +1410,11 @@ static void S_AddSNDINFO (int lump) } else if (list.Size() > 1) { // Only add non-empty random lists - random.NumSounds = (WORD)list.Size(); - S_sfx[random.SfxHead].link = (WORD)S_rnd.Push (random); + random.NumSounds = (uint16_t)list.Size(); + S_sfx[random.SfxHead].link = (uint16_t)S_rnd.Push (random); S_sfx[random.SfxHead].bRandomHeader = true; - S_rnd[S_sfx[random.SfxHead].link].Sounds = new WORD[random.NumSounds]; - memcpy (S_rnd[S_sfx[random.SfxHead].link].Sounds, &list[0], sizeof(WORD)*random.NumSounds); + S_rnd[S_sfx[random.SfxHead].link].Sounds = new uint16_t[random.NumSounds]; + memcpy (S_rnd[S_sfx[random.SfxHead].link].Sounds, &list[0], sizeof(uint16_t)*random.NumSounds); S_sfx[random.SfxHead].NearLimit = -1; } } @@ -1700,7 +1700,7 @@ static int S_AddPlayerGender (int classnum, int gender) if (index == 0xffff) { index = PlayerSounds.Reserve (1); - PlayerClassLookups[classnum].ListIndex[gender] = (WORD)index; + PlayerClassLookups[classnum].ListIndex[gender] = (uint16_t)index; } return index; } diff --git a/src/s_sound.h b/src/s_sound.h index 00c7d05870..f3df32e650 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -50,17 +50,17 @@ struct sfxinfo_t SWORD NearLimit; // 0 means unlimited float LimitRange; // Range for sound limiting (squared for faster computations) - WORD bRandomHeader:1; - WORD bPlayerReserve:1; - WORD bLoadRAW:1; - WORD bPlayerCompat:1; - WORD b16bit:1; - WORD bUsed:1; - WORD bSingular:1; - WORD bTentative:1; - WORD bPlayerSilent:1; // This player sound is intentionally silent. + unsigned bRandomHeader:1; + unsigned bPlayerReserve:1; + unsigned bLoadRAW:1; + unsigned bPlayerCompat:1; + unsigned b16bit:1; + unsigned bUsed:1; + unsigned bSingular:1; + unsigned bTentative:1; + unsigned bPlayerSilent:1; // This player sound is intentionally silent. - WORD RawRate; // Sample rate to use when bLoadRAW is true + int RawRate; // Sample rate to use when bLoadRAW is true int LoopStart; // -1 means no specific loop defined diff --git a/src/sound/music_dumb.cpp b/src/sound/music_dumb.cpp index fe1fbbb767..3c48dac7be 100644 --- a/src/sound/music_dumb.cpp +++ b/src/sound/music_dumb.cpp @@ -80,26 +80,26 @@ typedef struct tagITFILEHEADER { DWORD id; // 0x4D504D49 char songname[26]; - WORD reserved1; // 0x1004 - WORD ordnum; - WORD insnum; - WORD smpnum; - WORD patnum; - WORD cwtv; - WORD cmwt; - WORD flags; - WORD special; - BYTE globalvol; - BYTE mv; - BYTE speed; - BYTE tempo; - BYTE sep; - BYTE zero; - WORD msglength; + uint16_t reserved1; // 0x1004 + uint16_t ordnum; + uint16_t insnum; + uint16_t smpnum; + uint16_t patnum; + uint16_t cwtv; + uint16_t cmwt; + uint16_t flags; + uint16_t special; + uint8_t globalvol; + uint8_t mv; + uint8_t speed; + uint8_t tempo; + uint8_t sep; + uint8_t zero; + uint16_t msglength; DWORD msgoffset; DWORD reserved2; - BYTE chnpan[64]; - BYTE chnvol[64]; + uint8_t chnpan[64]; + uint8_t chnvol[64]; } FORCE_PACKED ITFILEHEADER, *PITFILEHEADER; typedef struct MODMIDICFG @@ -242,7 +242,7 @@ static void ReadDUH(DUH * duh, input_mod *info, bool meta, bool dos) // //========================================================================== -static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) +static bool ReadIT(const uint8_t * ptr, unsigned size, input_mod *info, bool meta) { PITFILEHEADER pifh = (PITFILEHEADER) ptr; if ((!ptr) || (size < 0x100)) return false; @@ -327,7 +327,7 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) if (pos < size) { - WORD val16 = LittleShort( *(WORD *)(ptr + pos) ); + uint16_t val16 = LittleShort( *(uint16_t *)(ptr + pos) ); pos += 2; if (pos + val16 * 8 < size) pos += val16 * 8; } @@ -395,24 +395,24 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) offset = (DWORD *)(ptr + 0xC0 + LittleShort(pifh->ordnum) + LittleShort(pifh->insnum) * 4 + LittleShort(pifh->smpnum) * 4); - BYTE chnmask[64]; + uint8_t chnmask[64]; for (n = 0, l = LittleShort(pifh->patnum); n < l; n++) { memset(chnmask, 0, sizeof(chnmask)); DWORD offset_n = LittleLong( offset[n] ); if ((!offset_n) || (offset_n + 4 >= size)) continue; - unsigned len = LittleShort(*(WORD *)(ptr + offset_n)); - unsigned rows = LittleShort(*(WORD *)(ptr + offset_n + 2)); + unsigned len = LittleShort(*(uint16_t *)(ptr + offset_n)); + unsigned rows = LittleShort(*(uint16_t *)(ptr + offset_n + 2)); if ((rows < 4) || (rows > 256)) continue; if (offset_n + 8 + len > size) continue; unsigned i = 0; - const BYTE * p = ptr + offset_n + 8; + const uint8_t * p = ptr + offset_n + 8; unsigned nrow = 0; while (nrow < rows) { if (i >= len) break; - BYTE b = p[i++]; + uint8_t b = p[i++]; if (!b) { nrow++; @@ -464,7 +464,7 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) typedef struct tdumbfile_mem_status { - const BYTE *ptr; + const uint8_t *ptr; unsigned int offset, size; } dumbfile_mem_status; @@ -537,15 +537,15 @@ static DUMBFILE_SYSTEM mem_dfs = { // //========================================================================== -DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, BYTE *start, FileReader &reader, int lenhave, int lenfull) +DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, uint8_t *start, FileReader &reader, int lenhave, int lenfull) { filestate->size = lenfull; filestate->offset = 0; if (lenhave >= lenfull) - filestate->ptr = (BYTE *)start; + filestate->ptr = (uint8_t *)start; else { - BYTE *mem = new BYTE[lenfull]; + uint8_t *mem = new uint8_t[lenfull]; memcpy(mem, start, lenhave); if (reader.Read(mem + lenhave, lenfull - lenhave) != (lenfull - lenhave)) { @@ -758,7 +758,7 @@ MusInfo *MOD_OpenSong(FileReader &reader) int headsize; union { - BYTE start[64]; + uint8_t start[64]; DWORD dstart[64/4]; }; dumbfile_mem_status filestate; @@ -891,7 +891,7 @@ MusInfo *MOD_OpenSong(FileReader &reader) if ( ! duh ) { is_dos = false; - if (filestate.ptr == (BYTE *)start) + if (filestate.ptr == (uint8_t *)start) { if (!(f = dumb_read_allfile(&filestate, start, reader, headsize, size))) { @@ -938,9 +938,9 @@ MusInfo *MOD_OpenSong(FileReader &reader) // Reposition file pointer for other codecs to do their checks. reader.Seek(fpos, SEEK_SET); } - if (filestate.ptr != (BYTE *)start) + if (filestate.ptr != (uint8_t *)start) { - delete[] const_cast(filestate.ptr); + delete[] const_cast(filestate.ptr); } return state; } @@ -982,7 +982,7 @@ bool input_mod::read(SoundStream *stream, void *buffer, int sizebytes, void *use ((float *)buffer)[i] = (((int *)buffer)[i] / (float)(1 << 24)) * mod_dumb_mastervolume; } } - buffer = (BYTE *)buffer + written * 8; + buffer = (uint8_t *)buffer + written * 8; sizebytes -= written * 8; } state->crit_sec.Leave(); diff --git a/src/sound/music_timidity_mididevice.cpp b/src/sound/music_timidity_mididevice.cpp index df87a92987..401c34af79 100644 --- a/src/sound/music_timidity_mididevice.cpp +++ b/src/sound/music_timidity_mididevice.cpp @@ -51,18 +51,18 @@ struct FmtChunk { DWORD ChunkID; DWORD ChunkLen; - WORD FormatTag; - WORD Channels; + uint16_t FormatTag; + uint16_t Channels; DWORD SamplesPerSec; DWORD AvgBytesPerSec; - WORD BlockAlign; - WORD BitsPerSample; - WORD ExtensionSize; - WORD ValidBitsPerSample; + uint16_t BlockAlign; + uint16_t BitsPerSample; + uint16_t ExtensionSize; + uint16_t ValidBitsPerSample; DWORD ChannelMask; DWORD SubFormatA; - WORD SubFormatB; - WORD SubFormatC; + uint16_t SubFormatB; + uint16_t SubFormatC; BYTE SubFormatD[8]; }; @@ -136,7 +136,7 @@ int TimidityMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD // //========================================================================== -void TimidityMIDIDevice::PrecacheInstruments(const WORD *instruments, int count) +void TimidityMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count) { for (int i = 0; i < count; ++i) { diff --git a/src/v_pfx.h b/src/v_pfx.h index d2b29a4829..87c15c8286 100644 --- a/src/v_pfx.h +++ b/src/v_pfx.h @@ -58,9 +58,9 @@ struct PfxState } Bits16; struct { - uint32 Red; - uint32 Green; - uint32 Blue; + uint32_t Red; + uint32_t Green; + uint32_t Blue; } Bits32; } Masks; BYTE RedShift; @@ -70,7 +70,7 @@ struct PfxState BITFIELD BlueLeft:1; BITFIELD GreenLeft:1; - void SetFormat (int bits, uint32 redMask, uint32 greenMask, uint32 blueMask); + void SetFormat (int bits, uint32_t redMask, uint32_t greenMask, uint32_t blueMask); void (*SetPalette) (const PalEntry *pal); void (*Convert) (BYTE *src, int srcpitch, void *dest, int destpitch, int destwidth, int destheight, diff --git a/src/w_zip.h b/src/w_zip.h index 4f51a13cc0..4d79ac0e21 100644 --- a/src/w_zip.h +++ b/src/w_zip.h @@ -5,53 +5,53 @@ // FZipCentralInfo struct FZipEndOfCentralDirectory { - DWORD Magic; - WORD DiskNumber; - WORD FirstDisk; - WORD NumEntries; - WORD NumEntriesOnAllDisks; - DWORD DirectorySize; - DWORD DirectoryOffset; - WORD ZipCommentLength; + uint32_t Magic; + uint16_t DiskNumber; + uint16_t FirstDisk; + uint16_t NumEntries; + uint16_t NumEntriesOnAllDisks; + uint32_t DirectorySize; + uint32_t DirectoryOffset; + uint16_t ZipCommentLength; } FORCE_PACKED; // FZipFileInfo struct FZipCentralDirectoryInfo { - DWORD Magic; + uint32_t Magic; BYTE VersionMadeBy[2]; BYTE VersionToExtract[2]; - WORD Flags; - WORD Method; - WORD ModTime; - WORD ModDate; - DWORD CRC32; - DWORD CompressedSize; - DWORD UncompressedSize; - WORD NameLength; - WORD ExtraLength; - WORD CommentLength; - WORD StartingDiskNumber; - WORD InternalAttributes; - DWORD ExternalAttributes; - DWORD LocalHeaderOffset; + uint16_t Flags; + uint16_t Method; + uint16_t ModTime; + uint16_t ModDate; + uint32_t CRC32; + uint32_t CompressedSize; + uint32_t UncompressedSize; + uint16_t NameLength; + uint16_t ExtraLength; + uint16_t CommentLength; + uint16_t StartingDiskNumber; + uint16_t InternalAttributes; + uint32_t ExternalAttributes; + uint32_t LocalHeaderOffset; // file name and other variable length info follows } FORCE_PACKED; // FZipLocalHeader struct FZipLocalFileHeader { - DWORD Magic; + uint32_t Magic; BYTE VersionToExtract[2]; - WORD Flags; - WORD Method; - WORD ModTime; - WORD ModDate; - DWORD CRC32; - DWORD CompressedSize; - DWORD UncompressedSize; - WORD NameLength; - WORD ExtraLength; + uint16_t Flags; + uint16_t Method; + uint16_t ModTime; + uint16_t ModDate; + uint32_t CRC32; + uint32_t CompressedSize; + uint32_t UncompressedSize; + uint16_t NameLength; + uint16_t ExtraLength; // file name and other variable length info follows } FORCE_PACKED;