Added some notes to various parts of the code base. Also simplified test patterns to ensure that we don't need to use leds_in_universe_range anywhere except in DMX buffer preparation

This commit is contained in:
Peter Slattery 2020-02-05 12:20:03 -08:00
parent 58ef0b460f
commit 75bb2ae86d
10 changed files with 69 additions and 87 deletions

View File

@ -503,7 +503,6 @@ HandleWindowsMessage (
else else
{ {
printf("Translated Char Not Recognized: %c\n", TranslatedChar); printf("Translated Char Not Recognized: %c\n", TranslatedChar);
//InvalidCodePath;
} }
*/ */
}break; }break;

View File

@ -113,6 +113,8 @@ GetWallClock ()
if (!QueryPerformanceCounter(&Time)) if (!QueryPerformanceCounter(&Time))
{ {
s32 Error = GetLastError(); s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath; InvalidCodePath;
} }
return (s64)Time.QuadPart; return (s64)Time.QuadPart;
@ -125,6 +127,8 @@ GetPerformanceFrequency ()
if (!QueryPerformanceFrequency(&Frequency)) if (!QueryPerformanceFrequency(&Frequency))
{ {
s32 Error = GetLastError(); s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath; InvalidCodePath;
} }
return (s64)Frequency.QuadPart; return (s64)Frequency.QuadPart;

View File

@ -83,9 +83,10 @@ ParseAssemblyVector (char* String)
return Result; return Result;
} }
internal void internal b32
ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer) ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
{ {
b32 HeaderIsValid = false;
if (CharArraysEqualUpToLength(Tokenizer->At, LED_STRIP_COUNT_IDENTIFIER, CharArrayLength(LED_STRIP_COUNT_IDENTIFIER))) if (CharArraysEqualUpToLength(Tokenizer->At, LED_STRIP_COUNT_IDENTIFIER, CharArrayLength(LED_STRIP_COUNT_IDENTIFIER)))
{ {
@ -95,19 +96,11 @@ ParseAssemblyFileHeader (assembly_definition* Assembly, tokenizer* Tokenizer)
if (CountToken.Type == AssemblyToken_Number) if (CountToken.Type == AssemblyToken_Number)
{ {
Assembly->LEDStripSize = ParseSignedIntUnsafe(CountToken.Token).SignedIntValue; Assembly->LEDStripSize = ParseSignedIntUnsafe(CountToken.Token).SignedIntValue;
} HeaderIsValid = true;
else
{
InvalidCodePath;
} }
EatWhitespace(Tokenizer); EatWhitespace(Tokenizer);
} }
else return HeaderIsValid;
{
// TODO(Peter): Handle corrupted files, try to recover?
InvalidCodePath;
}
} }
internal led_strip_definition internal led_strip_definition

View File

@ -92,19 +92,13 @@ internal void OpenColorPicker(app_state* State, v4* Address);
internal void internal void
TestPatternOne(assembly* Assembly, r32 Time) TestPatternOne(assembly* Assembly, r32 Time)
{ {
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++) for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
{
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
{ {
led LED = Assembly->LEDs[LEDIdx]; led LED = Assembly->LEDs[LEDIdx];
Assembly->Colors[LED.Index].R = 255; Assembly->Colors[LED.Index].R = 255;
Assembly->Colors[LED.Index].B = 255; Assembly->Colors[LED.Index].B = 255;
Assembly->Colors[LED.Index].G = 255; Assembly->Colors[LED.Index].G = 255;
} }
}
} }
internal void internal void
@ -127,12 +121,7 @@ TestPatternTwo(assembly* Assembly, r32 Time)
r32 OuterRadiusSquared = 1000000; r32 OuterRadiusSquared = 1000000;
r32 InnerRadiusSquared = 0; r32 InnerRadiusSquared = 0;
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++) for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
{
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
{ {
led LED = Assembly->LEDs[LEDIdx]; led LED = Assembly->LEDs[LEDIdx];
@ -164,7 +153,6 @@ TestPatternTwo(assembly* Assembly, r32 Time)
Assembly->Colors[LED.Index] = {}; Assembly->Colors[LED.Index] = {};
} }
} }
}
} }
internal void internal void
@ -178,12 +166,8 @@ TestPatternThree(assembly* Assembly, r32 Time)
r32 FadeDist = 35; r32 FadeDist = 35;
for (u32 Range = 0; Range < Assembly->LEDUniverseMapCount; Range++)
{ for (u32 LEDIdx = 0; LEDIdx < Assembly->LEDCount; LEDIdx++)
leds_in_universe_range LEDUniverseRange = Assembly->LEDUniverseMap[Range];
for (s32 LEDIdx = LEDUniverseRange.RangeStart;
LEDIdx < LEDUniverseRange.RangeOnePastLast;
LEDIdx++)
{ {
led LED = Assembly->LEDs[LEDIdx]; led LED = Assembly->LEDs[LEDIdx];
u8 Red = 0; u8 Red = 0;
@ -203,7 +187,6 @@ TestPatternThree(assembly* Assembly, r32 Time)
Assembly->Colors[LED.Index].B = Green; Assembly->Colors[LED.Index].B = Green;
Assembly->Colors[LED.Index].G = Green; Assembly->Colors[LED.Index].G = Green;
} }
}
} }
// END TEMPORARY PATTERNS // END TEMPORARY PATTERNS

View File

@ -5,15 +5,6 @@
// //
#ifndef FOLDHAUS_ASSEMBLY_CPP #ifndef FOLDHAUS_ASSEMBLY_CPP
internal s32
GetAssemblyMemorySizeFromDefinition(assembly_definition Definition, string Name)
{
s32 Result = (sizeof(led) + sizeof(pixel)) * Definition.TotalLEDCount;
Result += sizeof(leds_in_universe_range) * Definition.LEDStripCount;
Result += Name.Length;
return Result;
}
internal assembly internal assembly
ConstructAssemblyFromDefinition (assembly_definition Definition, ConstructAssemblyFromDefinition (assembly_definition Definition,
string AssemblyName, string AssemblyName,

View File

@ -22,6 +22,10 @@ union pixel
u8 Channels[3]; u8 Channels[3];
}; };
// NOTE(Peter): This structure is so we can keep track of
// what LEDs output to which DMX universe. You don't need
// to use it anywhere else, as all the data for patterns,
// colors, and groups is/will be stored elsewhere.
struct leds_in_universe_range struct leds_in_universe_range
{ {
s32 RangeStart; s32 RangeStart;

View File

@ -639,7 +639,8 @@ WinMain (
} }
else else
{ {
InvalidCodePath; MessageBox(MainWindow.Handle, "Unable to load application DLL at startup.\nAborting\n", "Set Up Error", MB_OK);
return -1;
} }
WSADATA WSAData; WSADATA WSAData;

View File

@ -22,6 +22,8 @@ PLATFORM_FREE(Win32Free)
if (!Result) if (!Result)
{ {
s32 Error = WSAGetLastError(); s32 Error = WSAGetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath; InvalidCodePath;
} }
return Result; return Result;

View File

@ -15,6 +15,8 @@ GetPerformanceFrequency ()
if (!QueryPerformanceFrequency(&Frequency)) if (!QueryPerformanceFrequency(&Frequency))
{ {
s32 Error = GetLastError(); s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath; InvalidCodePath;
} }
return (s64)Frequency.QuadPart; return (s64)Frequency.QuadPart;
@ -31,6 +33,8 @@ GetWallClock ()
if (!QueryPerformanceCounter(&Time)) if (!QueryPerformanceCounter(&Time))
{ {
s32 Error = GetLastError(); s32 Error = GetLastError();
// TODO(Peter): I'm waiting to see an error actually occur here
// to know what it could possibly be.
InvalidCodePath; InvalidCodePath;
} }
return (s64)Time.QuadPart; return (s64)Time.QuadPart;

View File

@ -21,8 +21,8 @@ x Hot Code Reloading
- Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h) - Enumerate Directory Contents (you started this in win32_foldhaus_fileio.h)
- -
- File Loading x File Loading
- Gracefully handle File Not found x Gracefully handle File Not found
- Buckets & Lists - Buckets & Lists
- Allow them to use memory arenas - Allow them to use memory arenas
@ -57,6 +57,7 @@ x Hot Code Reloading
- styling - styling
- text input - text input
- lister with icon options - lister with icon options
- panel system: destroy panel by extending it beyond its max, not just its min
- Sculpture View - Sculpture View
- mouse spatial interaction - handles, and hover for info - mouse spatial interaction - handles, and hover for info