hmml_to_html.c: Consolidate references [#16]

This commit is contained in:
Matt Mascarenhas 2017-03-30 03:57:04 +01:00
parent 04f2fcd529
commit ed4b8de12d
2 changed files with 189 additions and 541 deletions

View File

@ -14,6 +14,7 @@ typedef unsigned int bool;
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hmmlib.h"
typedef struct
@ -25,8 +26,18 @@ typedef struct
typedef struct
{
char *Source;
char *RefTitle;
char Timecode[8];
int Identifier;
} identifier;
typedef struct
{
char ID[1024];
char RefTitle[512];
char URL[372];
char Source[128];
identifier Identifier[12];
int IdentifierCount;
} ref_info;
#define ArrayCount(A) sizeof(A)/sizeof(*(A))
@ -40,6 +51,8 @@ ClaimBuffer(char *MemoryArena, int *ClaimedMemory, buffer *Buffer, int Size)
Buffer->Ptr = Buffer->Location;
}
#if 0
//TODO(matt): Rewrite me
ref_info
ParseRef(HMML_Reference RefInput)
{
@ -63,6 +76,9 @@ ParseRef(HMML_Reference RefInput)
return Info;
}
}
#endif
// TODO(matt): MakeReference()
int
TimecodeToSeconds(char *Timecode)
@ -97,7 +113,7 @@ TimecodeToSeconds(char *Timecode)
}
void
CopyBuffer(buffer *Src, buffer *Dest)
CopyBuffer(buffer *Dest, buffer *Src)
{
Src->Ptr = Src->Location;
while(*Src->Ptr)
@ -106,6 +122,18 @@ CopyBuffer(buffer *Src, buffer *Dest)
}
}
void
CopyString(char Dest[], char *Src)
{
int i = 0;
while(*Src)
{
Dest[i] = *Src++;
++i;
}
Dest[i] = '\0';
}
__attribute__ ((format (printf, 2, 3)))
void
CopyStringToBuffer(buffer *Dest, char *Format, ...)
@ -248,7 +276,6 @@ main(int ArgC, char **Args)
int ClaimedMemory = 0;
// NOTE(matt): Setup buffers and ptrs
#if 1
char *InPtr;
buffer Title;
@ -281,13 +308,16 @@ main(int ArgC, char **Args)
if(HMML.well_formed)
{
ClaimBuffer(MemoryArena, &ClaimedMemory, &Title, 1024 * 16);
ref_info ReferencesArray[200];
memset(ReferencesArray, 0, sizeof(ReferencesArray));
ClaimBuffer(MemoryArena, &ClaimedMemory, &Player, 1024 * 256);
bool HasQuoteMenu = FALSE;
bool HasReferenceMenu = FALSE;
int QuoteIdentifier = 945;
int QuoteIdentifier = 0x3b1;
int RefIdentifier = 1;
int UniqueRefs = 0;
CopyStringToBuffer(&Title,
" <div class=\"title\">\n"
@ -377,9 +407,41 @@ Readable);
" <div class=\"mouse_catcher\"></div>\n"
" <div class=\"refs\">\n");
CopyString(ReferencesArray[RefIdentifier - 1].ID, CurrentRef->editor);
CopyString(ReferencesArray[RefIdentifier - 1].RefTitle, "Title");
CopyString(ReferencesArray[RefIdentifier - 1].URL, "http://example.com/");
CopyString(ReferencesArray[RefIdentifier - 1].Source, "Source");
CopyString(ReferencesArray[RefIdentifier - 1].Identifier[ReferencesArray[RefIdentifier - 1].IdentifierCount].Timecode, Anno->time);
ReferencesArray[RefIdentifier - 1].Identifier[ReferencesArray[RefIdentifier - 1].IdentifierCount].Identifier = RefIdentifier;
++ReferencesArray[RefIdentifier - 1].IdentifierCount;
++UniqueRefs;
HasReferenceMenu = TRUE;
}
else
{
for(int i = 0; i < UniqueRefs; ++i)
{
if(!StringsDiffer(CurrentRef->editor, ReferencesArray[i].ID))
{
CopyString(ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Timecode, Anno->time);
ReferencesArray[i].Identifier[ReferencesArray[i].IdentifierCount].Identifier = RefIdentifier;
++ReferencesArray[i].IdentifierCount;
goto AppendedIdentifier;
}
}
CopyString(ReferencesArray[UniqueRefs].ID, CurrentRef->editor);
CopyString(ReferencesArray[UniqueRefs].RefTitle, "Title");
CopyString(ReferencesArray[UniqueRefs].URL, "http://example.com/");
CopyString(ReferencesArray[UniqueRefs].Source, "Source");
CopyString(ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Timecode, Anno->time);
ReferencesArray[UniqueRefs].Identifier[ReferencesArray[UniqueRefs].IdentifierCount].Identifier = RefIdentifier;
++ReferencesArray[UniqueRefs].IdentifierCount;
++UniqueRefs;
}
AppendedIdentifier:
if(!HasReference)
{
ClaimBuffer(MemoryArena, &ClaimedMemory, &AnnotationData, 128);
@ -392,27 +454,6 @@ Readable);
CopyStringToBuffer(&AnnotationData, ",%s", CurrentRef->editor);
}
CopyStringToBuffer(&ReferenceMenu,
" <a data-id=\"%s\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
" <span class=\"ref_content\">\n"
" <div class=\"source\">%s</div>\n"
" <div class=\"ref_title\">%s</div>\n"
" </span>\n"
// TODO(matt): Fill the div class="ref_indices" with <= 3 span
// class="ref_index" and ensure to put these <=3 spans on the same line without
// a space between them
" <div class=\"ref_indices\">\n"
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n"
" </div>\n"
" </a>\n",
CurrentRef->editor,
"http://example.com/",
"Source",
"Title",
TimecodeToSeconds(Anno->time),
RefIdentifier,
Anno->time);
CopyStringToBuffer(&Text, "<sup>%d</sup>", RefIdentifier);
++RefIndex;
@ -482,18 +523,18 @@ Anno->time);
}
CopyStringToBuffer(&AnnotationClass, "\"");
CopyBuffer(&AnnotationClass, &AnnotationHeader);
CopyBuffer(&AnnotationHeader, &AnnotationClass);
if(HasQuote || HasReference)
{
CopyStringToBuffer(&AnnotationData, "\"");
CopyBuffer(&AnnotationData, &AnnotationHeader);
CopyBuffer(&AnnotationHeader, &AnnotationData);
}
CopyStringToBuffer(&AnnotationHeader, ">\n");
ClaimBuffer(MemoryArena, &ClaimedMemory, &Annotation, 1024 * 4);
CopyBuffer(&AnnotationHeader, &Annotation);
CopyBuffer(&Annotation, &AnnotationHeader);
CopyStringToBuffer(&Annotation,
" <div class=\"content\"><span class=\"timecode\">%s</span>",
Anno->time);
@ -501,19 +542,19 @@ Anno->time);
if(HasCategory)
{
CopyStringToBuffer(&Category, "</span>");
CopyBuffer(&Category, &Text);
CopyBuffer(&Text, &Category);
}
*Text.Ptr = '\0';
CopyBuffer(&Text, &Annotation);
CopyBuffer(&Annotation, &Text);
CopyStringToBuffer(&Annotation, "</div>\n"
" <div class=\"progress faded\">\n"
" <div class=\"content\"><span class=\"timecode\">%s</span>",
Anno->time);
CopyBuffer(&Text, &Annotation);
CopyBuffer(&Annotation, &Text);
CopyStringToBuffer(&Annotation, "</div>\n"
" </div>\n"
@ -521,13 +562,13 @@ Anno->time);
" <div class=\"content\"><span class=\"timecode\">%s</span>",
Anno->time);
CopyBuffer(&Text, &Annotation);
CopyBuffer(&Annotation, &Text);
CopyStringToBuffer(&Annotation, "</div>\n"
" </div>\n"
" </div>\n");
CopyBuffer(&Annotation, &Player);
CopyBuffer(&Player, &Annotation);
ClaimedMemory -= Text.Size;
ClaimedMemory -= AnnotationHeader.Size;
@ -541,15 +582,45 @@ Anno->time);
CopyStringToBuffer(&QuoteMenu,
" </div>\n"
" </div>\n");
CopyBuffer(&QuoteMenu, &Title);
CopyBuffer(&Title, &QuoteMenu);
}
if(HasReferenceMenu)
{
for(int i = 0; i < UniqueRefs; ++i)
{
CopyStringToBuffer(&ReferenceMenu,
" <a data-id=\"%s\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
" <span class=\"ref_content\">\n"
" <div class=\"source\">%s</div>\n"
" <div class=\"ref_title\">%s</div>\n"
" </span>\n"
// TODO(matt): Fill the div class="ref_indices" with <= 3 span
// class="ref_index" and ensure to put these <=3 spans on the same line without
// a space between them
" <div class=\"ref_indices\">\n",
ReferencesArray[i].ID,
"http://example.com/",
"Source",
"Title");
for(int j = 0; j < ReferencesArray[i].IdentifierCount; ++j)
{
CopyStringToBuffer(&ReferenceMenu,
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n",
TimecodeToSeconds(ReferencesArray[i].Identifier[j].Timecode),
ReferencesArray[i].Identifier[j].Identifier,
ReferencesArray[i].Identifier[j].Timecode);
}
CopyStringToBuffer(&ReferenceMenu,
" </div>\n"
" </a>\n");
}
CopyStringToBuffer(&ReferenceMenu,
" </div>\n"
" </div>\n");
CopyBuffer(&ReferenceMenu, &Title);
CopyBuffer(&Title, &ReferenceMenu);
}
CopyStringToBuffer(&Title,
@ -575,8 +646,8 @@ Anno->time);
" <body>\n");
//NOTE(matt): Here is where we do all our CopyBuffer() calls
CopyBuffer(&Title, &Master);
CopyBuffer(&Player, &Master);
CopyBuffer(&Master, &Title);
CopyBuffer(&Master, &Player);
//
CopyStringToBuffer(&Master,
@ -679,319 +750,5 @@ Anno->time);
}
hmml_free(&HMML);
}
#else
char *InPtr;
buffer Working;
buffer Text;
buffer Out;
ClaimBuffer(MemoryArena, &ClaimedMemory, &Out, 1024 * 512);
for(int FileIndex = 1; FileIndex < ArgC; ++FileIndex)
{
FILE *InFile;
if(!(InFile = fopen(Args[FileIndex], "r")))
{
perror(Args[0]);
free(MemoryArena);
return 1;
}
HMML_Output HMML = hmml_parse_file(InFile);
fclose(InFile);
if(HMML.well_formed)
{
ClaimBuffer(MemoryArena, &ClaimedMemory, &Working, 1024 * 4);
sprintf(Working.Location,
"<html>\n"
" <head>\n"
" <meta charset=\"UTF-8\">\n"
"\n"
" <!-- Load the player -->\n"
" <script type=\"text/javascript\" src=\"player.js\"></script>\n"
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"
" </head>\n"
" <body>\n"
" <div class=\"title\">\n"
" <span class=\"episode_name\">%s</span>\n", HMML.metadata.title);
CopyBuffer(&Working, &Out);
int AnnotationIndex = 0;
int ReferenceIndex = 1;
while(AnnotationIndex < HMML.annotation_count)
{
if(HMML.annotations[AnnotationIndex].reference_count)
{
sprintf(Working.Location,
" <div class=\"refs_container\">\n"
" <span>References &#9660;</span>\n"
" <div class=\"mouse_catcher\"></div>\n"
" <div class=\"refs\">\n");
CopyBuffer(&Working, &Out);
while(AnnotationIndex < HMML.annotation_count)
{
for(int i = 0; i < HMML.annotations[AnnotationIndex].reference_count; ++i)
{
HMML_Reference *CurrentRef = HMML.annotations[AnnotationIndex].references + i;
// NOTE(matt): Consider removing the ref_index class if it ain't needed
sprintf(Working.Location,
" <a data-id=\"%d\" href=\"%s\" target=\"_blank\" class=\"ref\">\n"
" <span class=\"ref_content\">\n"
" <div class=\"source\">%s</div>\n"
" <div class=\"ref_title\">%s</div>\n"
" </span>\n"
// TODO(matt): Fill the div class="ref_indices" with <= 3 span
// class="ref_index" and ensure to put these <=3 spans on the same line without
// a space between them
" <div class=\"ref_indices\">\n"
" <span data-timestamp=\"%d\" class=\"timecode\"><span class=\"ref_index\">[%d]</span><span class=\"time\">%s</span></span>\n"
" </div>\n"
" </a>\n",
AnnotationIndex,
CurrentRef->url,
ParseRef(*CurrentRef).Source,
ParseRef(*CurrentRef).RefTitle,
TimecodeToSeconds(HMML.annotations[AnnotationIndex].time),
ReferenceIndex,
HMML.annotations[AnnotationIndex].time);
CopyBuffer(&Working, &Out);
++ReferenceIndex;
}
++AnnotationIndex;
}
sprintf(Working.Location,
" </div>\n"
" </div>\n");
CopyBuffer(&Working, &Out);
}
++AnnotationIndex;
}
sprintf(Working.Location,
" <span class=\"annotator_container\">Annotator: <span class=\"annotator\">%s</span></span>\n"
" </div>\n"
" <div class=\"player_container\">\n"
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
" <div class=\"markers_container\">\n", HMML.metadata.annotator, HMML.metadata.id);
CopyBuffer(&Working, &Out);
int DataRef = 1;
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
{
sprintf(Working.Location,
" <div class=\"marker");
CopyBuffer(&Working, &Out);
ClaimBuffer(MemoryArena, &ClaimedMemory, &Text, 1024);
int Inc = 0;
if(HMML.annotations[AnnotationIndex].author)
{
sprintf(Working.Location, " authored");
CopyBuffer(&Working, &Out);
Inc = sprintf(Text.Ptr, "<span class=\"author\" style=\"color: #%X;\">%s</span> ",
StringToColourHash(HMML.annotations[AnnotationIndex].author), HMML.annotations[AnnotationIndex].author);
Text.Ptr += Inc;
}
if(HMML.annotations[AnnotationIndex].marker_count)
{
for(int MarkerIndex = 0; MarkerIndex < HMML.annotations[AnnotationIndex].marker_count; ++MarkerIndex)
{
if(!StringsDiffer("blackboard", HMML.annotations[AnnotationIndex].markers[MarkerIndex].marker) &&
HMML.annotations[AnnotationIndex].markers[MarkerIndex].type == HMML_CATEGORY)
{
sprintf(Working.Location, " blackboard");
CopyBuffer(&Working, &Out);
}
}
}
sprintf(Working.Location, "\" data-timestamp=\"%d\"", TimecodeToSeconds(HMML.annotations[AnnotationIndex].time));
CopyBuffer(&Working, &Out);
InPtr = HMML.annotations[AnnotationIndex].text;
if(HMML.annotations[AnnotationIndex].reference_count) // || HMML.annotations[AnnotationIndex].is_quote)
{
sprintf(Working.Location, " data-ref=\"%d\"", AnnotationIndex);
CopyBuffer(&Working, &Out);
for(int RefLocalIndex = 0; RefLocalIndex < HMML.annotations[AnnotationIndex].reference_count; ++RefLocalIndex)
{
while(InPtr - HMML.annotations[AnnotationIndex].text < HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset)
{
*Text.Ptr++ = *InPtr++;
}
if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2)
{
if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].page)
{
Inc = sprintf(Text.Ptr, "%s",
HMML.annotations[AnnotationIndex].references[RefLocalIndex].page);
}
else if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].site)
{
Inc = sprintf(Text.Ptr, "%s",
HMML.annotations[AnnotationIndex].references[RefLocalIndex].site);
}
else if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].title)
{
Inc = sprintf(Text.Ptr, "%s",
HMML.annotations[AnnotationIndex].references[RefLocalIndex].title);
}
else
{
fprintf(stderr, "%s: Potentially incomplete reference at %s:%d\n",
Args[0],
Args[FileIndex],
HMML.annotations[AnnotationIndex].line);
}
Text.Ptr += Inc;
}
if(HMML.annotations[AnnotationIndex].references[RefLocalIndex].offset <= 2 && Text.Ptr[-1] == ' ')
{
--Text.Ptr;
}
Inc = sprintf(Text.Ptr, "<sup>%d</sup>", DataRef);
Text.Ptr += Inc;
++DataRef;
}
}
*Out.Ptr++ = '>';
*Out.Ptr++ = '\n';
CopyStringToBuffer(&Text, InPtr);
*Text.Ptr = '\0';
sprintf(Working.Location,
" <div class=\"content\"><span class=\"timecode\">%s</span>%s</div>\n"
" <div class=\"progress faded\">\n"
" <div class=\"content\"><span class=\"timecode\">%s</span>%s</div>\n"
" </div>\n"
" <div class=\"progress main\">\n"
" <div class=\"content\"><span class=\"timecode\">%s</span>%s</div>\n"
" </div>\n"
" </div>\n",
HMML.annotations[AnnotationIndex].time,
Text.Location,
HMML.annotations[AnnotationIndex].time,
Text.Location,
HMML.annotations[AnnotationIndex].time,
Text.Location);
CopyBuffer(&Working, &Out);
ClaimedMemory -= Text.Size;
}
sprintf(Working.Location,
" </div>\n"
" </div>\n"
" <script>\n"
" var player = new Player(document.querySelector(\".player_container\"), onRefChanged);\n"
" window.addEventListener(\"resize\", function() { player.updateSize(); });\n"
" document.addEventListener(\"keypress\", function(ev) {\n"
" switch (ev.key) {\n"
" case 'n':\n"
" case 'd':\n"
" case 's': {\n"
" player.jumpToNextMarker();\n"
" } break;\n"
"\n"
" case 'p':\n"
" case 'a':\n"
" case 'w': {\n"
" player.jumpToPrevMarker();\n"
" } break;\n"
" }\n"
"});\n"
"\n"
"var refTimecodes = document.querySelectorAll(\".refs .ref .timecode\");\n"
"for (var i = 0; i < refTimecodes.length; ++i) {\n"
" refTimecodes[i].addEventListener(\"click\", function(ev) {\n"
" if (player) {\n"
" var time = ev.currentTarget.getAttribute(\"data-timestamp\");\n"
" player.setTime(parseInt(time, 10));\n"
" player.play();\n"
" ev.preventDefault();\n"
" ev.stopPropagation();\n"
" return false;\n"
" }\n"
" });\n"
"}\n"
"\n"
"var refSources = document.querySelectorAll(\".refs .ref\");\n"
"for (var i = 0; i < refSources.length; ++i) {\n"
" refSources[i].addEventListener(\"click\", function(ev) {\n"
" if (player) {\n"
" player.pause();\n"
" }\n"
" });\n"
"}\n"
"\n"
"function onRefChanged(ref) {\n"
" var sourceMenus = document.querySelectorAll(\".refs_container\");\n"
" for (var MenuIndex = 0; MenuIndex < sourceMenus.length; ++MenuIndex)\n"
" {\n"
" var SetMenu = 0;\n"
" if (ref !== undefined && ref !== null) {\n"
" var refElements = sourceMenus[MenuIndex].querySelectorAll(\".refs .ref\");\n"
" var refs = ref.split(\",\");\n"
"\n"
" for (var i = 0; i < refElements.length; ++i) {\n"
" if (refs.includes(refElements[i].getAttribute(\"data-id\"))) {\n"
" refElements[i].classList.add(\"current\");\n"
" SetMenu = 1;\n"
" } else {\n"
" refElements[i].classList.remove(\"current\");\n"
" }\n"
" }\n"
" if(SetMenu) {\n"
" sourceMenus[MenuIndex].classList.add(\"current\");\n"
" } else {\n"
" sourceMenus[MenuIndex].classList.remove(\"current\");\n"
" }\n"
"\n"
" } else {\n"
" sourceMenus[MenuIndex].classList.remove(\"current\");\n"
" var refs = sourceMenus[MenuIndex].querySelectorAll(\".refs .ref\");\n"
" for (var i = 0; i < refs.length; ++i) {\n"
" refs[i].classList.remove(\"current\");\n"
" }\n"
" }\n"
" }\n"
"}\n"
" </script>\n"
" </body>\n"
"</html>\n");
CopyBuffer(&Working, &Out);
FILE *OutFile;
//char *OutFilename;
//sprintf(OutFilename, "%s.html", Args[FileIndex]);
if(!(OutFile = fopen("out.html", "w")))
{
perror(Args[0]);
return 1;
}
fwrite(Out.Location, Out.Ptr - Out.Location, 1, OutFile);
fclose(OutFile);
}
else
{
fprintf(stderr, "%s:%d: %s\n", Args[FileIndex], HMML.error.line, HMML.error.message);
}
hmml_free(&HMML);
}
#endif
free(MemoryArena);
}

View File

@ -8,63 +8,52 @@
</head>
<body>
<div class="title">
<span class="episode_name">Studying the Machine Interrupt Registers</span>
<span class="episode_name">Coloured Nicks</span>
<div class="refs_container">
<span>Quotes &#9660;</span>
<div class="mouse_catcher"></div>
<div class="refs">
<span data-id="&#945;" class="ref">
<span class="ref_content">
<div class="source">#1 • Quote date</div>
<div class="ref_title">Quote text</div>
</span>
<div class="ref_indices">
<span data-timestamp="176" class="timecode"><span class="ref_index">[&#945;]</span><span class="time">2:56</span></span>
</div>
</span>
<span data-id="&#946;" class="ref">
<span class="ref_content">
<div class="source">#2 • Quote date</div>
<div class="ref_title">Quote text</div>
</span>
<div class="ref_indices">
<span data-timestamp="312" class="timecode"><span class="ref_index">[&#946;]</span><span class="time">5:12</span></span>
</div>
</span>
</div>
</div>
<div class="refs_container">
<span>References &#9660;</span>
<div class="mouse_catcher"></div>
<div class="refs">
<a data-id="3" href="https://github.com/ucb-bar/rocket/blob/master/src/main/scala/instructions.scala" target="_blank" class="ref">
<a data-id="serge_rgb" href="http://example.com/" target="_blank" class="ref">
<span class="ref_content">
<div class="source">GitHub</div>
<div class="ref_title">instructions.scala</div>
<div class="source">Source</div>
<div class="ref_title">Title</div>
</span>
<div class="ref_indices">
<span data-timestamp="543" class="timecode"><span class="ref_index">[1]</span><span class="time">9:03</span></span>
<span data-timestamp="60" class="timecode"><span class="ref_index">[1]</span><span class="time">1:00</span></span>
</div>
</a>
<a data-id="3" href="https://en.wikipedia.org/wiki/Register-transfer_level" target="_blank" class="ref">
<a data-id="milton_forum" href="http://example.com/" target="_blank" class="ref">
<span class="ref_content">
<div class="source">Wikipedia</div>
<div class="ref_title">Register-transfer level</div>
<div class="source">Source</div>
<div class="ref_title">Title</div>
</span>
<div class="ref_indices">
<span data-timestamp="543" class="timecode"><span class="ref_index">[2]</span><span class="time">9:03</span></span>
</div>
</a>
<a data-id="4" href="https://forums.sifive.com/t/confusion-regarding-freedom-e-sdk-inline-asm/383" target="_blank" class="ref">
<span class="ref_content">
<div class="source">SiFive Forums</div>
<div class="ref_title">Confusion Regarding Freedom E SDK inline asm</div>
</span>
<div class="ref_indices">
<span data-timestamp="955" class="timecode"><span class="ref_index">[3]</span><span class="time">15:55</span></span>
</div>
</a>
<a data-id="6" href="https://riscv.org/specifications" target="_blank" class="ref">
<span class="ref_content">
<div class="source">RISC-V</div>
<div class="ref_title">User-Level ISA Specification v2.1</div>
</span>
<div class="ref_indices">
<span data-timestamp="1344" class="timecode"><span class="ref_index">[4]</span><span class="time">22:24</span></span>
</div>
</a>
<a data-id="8" href="http://ericw.ca/notes/a-tiny-guide-to-gcc-inline-assembly.html" target="_blank" class="ref">
<span class="ref_content">
<div class="source">ericw.</div>
<div class="ref_title">A Tiny Guide to GCC Inline Assembly</div>
</span>
<div class="ref_indices">
<span data-timestamp="1733" class="timecode"><span class="ref_index">[5]</span><span class="time">28:53</span></span>
</div>
</a>
<a data-id="10" href="https://riscv.org/specifications/privileged-isa/" target="_blank" class="ref">
<span class="ref_content">
<div class="source">RISC-V</div>
<div class="ref_title">Draft Privileged ISA Specification v1.9.1</div>
</span>
<div class="ref_indices">
<span data-timestamp="2421" class="timecode"><span class="ref_index">[6]</span><span class="time">40:21</span></span>
<span data-timestamp="60" class="timecode"><span class="ref_index">[2]</span><span class="time">1:00</span></span>
<span data-timestamp="624" class="timecode"><span class="ref_index">[3]</span><span class="time">10:24</span></span>
</div>
</a>
</div>
@ -74,157 +63,49 @@
<div class="player_container">
<div class="video_container" data-videoId="ug5WkCROkOk"></div>
<div class="markers_container">
<div class="marker" data-timestamp="6">
<div class="content"><span class="timecode">0:06</span>Recap and set the stage for the day</div>
<div data-timestamp="60" class="marker authored cat_rendering research" data-ref="serge_rgb,milton_forum">
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
<div class="progress faded">
<div class="content"><span class="timecode">0:06</span>Recap and set the stage for the day</div>
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">0:06</span>Recap and set the stage for the day</div>
<div class="content"><span class="timecode">1:00</span><span class="author" style="color: #69D036;">insofaras</span> Some text referring to <a href="https://handmade.network/m/zilarrezko" target="blank" style="color: #8624DC; text-decoration: none">Zilarrezko</a> about this thing<sup>1</sup> regarding triangle intersections he saw in the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forums<sup>2</sup><span class="categories"><div class="category rendering"></div></span></div>
</div>
</div>
<div class="marker blackboard" data-timestamp="51">
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
<div data-timestamp="176" class="marker" data-ref="&#945;">
<div class="content"><span class="timecode">2:56</span>&#8220;Quote text&#8221;<sup>&#945;</sup></div>
<div class="progress faded">
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
<div class="content"><span class="timecode">2:56</span>&#8220;Quote text&#8221;<sup>&#945;</sup></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">0:51</span>Intuition on two's complement</div>
<div class="content"><span class="timecode">2:56</span>&#8220;Quote text&#8221;<sup>&#945;</sup></div>
</div>
</div>
<div class="marker blackboard" data-timestamp="250">
<div class="content"><span class="timecode">4:10</span>We are counting with zeroes</div>
<div data-timestamp="312" class="marker blackboard cat_mathematics" data-ref="&#946;">
<div class="content"><span class="timecode">5:12</span>Matrix multiplication<sup>&#946;</sup><span class="categories"><div class="category mathematics"></div></span></div>
<div class="progress faded">
<div class="content"><span class="timecode">4:10</span>We are counting with zeroes</div>
<div class="content"><span class="timecode">5:12</span>Matrix multiplication<sup>&#946;</sup><span class="categories"><div class="category mathematics"></div></span></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">4:10</span>We are counting with zeroes</div>
<div class="content"><span class="timecode">5:12</span>Matrix multiplication<sup>&#946;</sup><span class="categories"><div class="category mathematics"></div></span></div>
</div>
</div>
<div class="marker" data-timestamp="543" data-ref="3">
<div class="content"><span class="timecode">9:03</span>Revisit instructions.scala<sup>1</sup> and research register-transfer level<sup>2</sup></div>
<div data-timestamp="624" class="marker" data-ref="milton_forum">
<div class="content"><span class="timecode">10:24</span>More stuff referring to the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forum post<sup>3</sup></div>
<div class="progress faded">
<div class="content"><span class="timecode">9:03</span>Revisit instructions.scala<sup>1</sup> and research register-transfer level<sup>2</sup></div>
<div class="content"><span class="timecode">10:24</span>More stuff referring to the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forum post<sup>3</sup></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">9:03</span>Revisit instructions.scala<sup>1</sup> and research register-transfer level<sup>2</sup></div>
<div class="content"><span class="timecode">10:24</span>More stuff referring to the <a href="https://milton.handmade.network/" target="blank" style="color: #8369CF; text-decoration: none">milton</a> forum post<sup>3</sup></div>
</div>
</div>
<div class="marker blackboard" data-timestamp="955" data-ref="4">
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
<div data-timestamp="642" class="marker">
<div class="content"><span class="timecode">10:42</span>Some text. Simples!</div>
<div class="progress faded">
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
<div class="content"><span class="timecode">10:42</span>Some text. Simples!</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">15:55</span>Come to understand how to specify that rs1 represents an immediate or a register, thanks to the reply to the "Confusion Regarding Freedom E SDK inline asm" forum thread<sup>3</sup></div>
</div>
</div>
<div class="marker blackboard" data-timestamp="1105">
<div class="content"><span class="timecode">18:25</span>Read clear_csr() to put csrrc into perspective with our new understanding of pseudo-instructions and the i vs r hints</div>
<div class="progress faded">
<div class="content"><span class="timecode">18:25</span>Read clear_csr() to put csrrc into perspective with our new understanding of pseudo-instructions and the i vs r hints</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">18:25</span>Read clear_csr() to put csrrc into perspective with our new understanding of pseudo-instructions and the i vs r hints</div>
</div>
</div>
<div class="marker" data-timestamp="1344" data-ref="6">
<div class="content"><span class="timecode">22:24</span>Read about CSRRCI in the CSR Instructions section of the User-Level ISA Specification<sup>4</sup></div>
<div class="progress faded">
<div class="content"><span class="timecode">22:24</span>Read about CSRRCI in the CSR Instructions section of the User-Level ISA Specification<sup>4</sup></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">22:24</span>Read about CSRRCI in the CSR Instructions section of the User-Level ISA Specification<sup>4</sup></div>
</div>
</div>
<div class="marker" data-timestamp="1385">
<div class="content"><span class="timecode">23:05</span>Walk through clear_csr() again</div>
<div class="progress faded">
<div class="content"><span class="timecode">23:05</span>Walk through clear_csr() again</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">23:05</span>Walk through clear_csr() again</div>
</div>
</div>
<div class="marker blackboard" data-timestamp="1733" data-ref="8">
<div class="content"><span class="timecode">28:53</span>GNU Assembly Syntax: Constraints and Syntax<sup>5</sup></div>
<div class="progress faded">
<div class="content"><span class="timecode">28:53</span>GNU Assembly Syntax: Constraints and Syntax<sup>5</sup></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">28:53</span>GNU Assembly Syntax: Constraints and Syntax<sup>5</sup></div>
</div>
</div>
<div class="marker" data-timestamp="2115">
<div class="content"><span class="timecode">35:15</span>Continue reading clear_csr()</div>
<div class="progress faded">
<div class="content"><span class="timecode">35:15</span>Continue reading clear_csr()</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">35:15</span>Continue reading clear_csr()</div>
</div>
</div>
<div class="marker" data-timestamp="2421" data-ref="10">
<div class="content"><span class="timecode">40:21</span>Pop back up to the top of the stack, to reset_demo(), and read about the currently allocated RISC-V machine-level CSR addresses<sup>6</sup></div>
<div class="progress faded">
<div class="content"><span class="timecode">40:21</span>Pop back up to the top of the stack, to reset_demo(), and read about the currently allocated RISC-V machine-level CSR addresses<sup>6</sup></div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">40:21</span>Pop back up to the top of the stack, to reset_demo(), and read about the currently allocated RISC-V machine-level CSR addresses<sup>6</sup></div>
</div>
</div>
<div class="marker" data-timestamp="2651">
<div class="content"><span class="timecode">44:11</span>Read about Machine Interrupt Registers, including the mie (machine interrupt-enable) register</div>
<div class="progress faded">
<div class="content"><span class="timecode">44:11</span>Read about Machine Interrupt Registers, including the mie (machine interrupt-enable) register</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">44:11</span>Read about Machine Interrupt Registers, including the mie (machine interrupt-enable) register</div>
</div>
</div>
<div class="marker" data-timestamp="2966">
<div class="content"><span class="timecode">49:26</span>Note how common it is in plic_driver.c for us to compute an address of a memory mapped register in order to mess with interrupts</div>
<div class="progress faded">
<div class="content"><span class="timecode">49:26</span>Note how common it is in plic_driver.c for us to compute an address of a memory mapped register in order to mess with interrupts</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">49:26</span>Note how common it is in plic_driver.c for us to compute an address of a memory mapped register in order to mess with interrupts</div>
</div>
</div>
<div class="marker" data-timestamp="3105">
<div class="content"><span class="timecode">51:45</span>A few words on the sponge mode that we're in</div>
<div class="progress faded">
<div class="content"><span class="timecode">51:45</span>A few words on the sponge mode that we're in</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">51:45</span>A few words on the sponge mode that we're in</div>
</div>
</div>
<div class="marker" data-timestamp="3170">
<div class="content"><span class="timecode">52:50</span>Continue reading about the Machine Interrupt Registers</div>
<div class="progress faded">
<div class="content"><span class="timecode">52:50</span>Continue reading about the Machine Interrupt Registers</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">52:50</span>Continue reading about the Machine Interrupt Registers</div>
</div>
</div>
<div class="marker" data-timestamp="3513">
<div class="content"><span class="timecode">58:33</span>Return to demo_gpio.c and come to understand the clear_csr() calls in relation to the documentation</div>
<div class="progress faded">
<div class="content"><span class="timecode">58:33</span>Return to demo_gpio.c and come to understand the clear_csr() calls in relation to the documentation</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">58:33</span>Return to demo_gpio.c and come to understand the clear_csr() calls in relation to the documentation</div>
</div>
</div>
<div class="marker" data-timestamp="4008">
<div class="content"><span class="timecode">1:06:48</span>We're out of time for today</div>
<div class="progress faded">
<div class="content"><span class="timecode">1:06:48</span>We're out of time for today</div>
</div>
<div class="progress main">
<div class="content"><span class="timecode">1:06:48</span>We're out of time for today</div>
<div class="content"><span class="timecode">10:42</span>Some text. Simples!</div>
</div>
</div>
</div>
@ -272,27 +153,37 @@ for (var i = 0; i < refSources.length; ++i) {
}
function onRefChanged(ref) {
if (ref !== undefined && ref !== null) {
document.querySelector(".refs_container").classList.add("current");
var refElements = document.querySelectorAll(".refs .ref");
var refs = ref.split(",");
var sourceMenus = document.querySelectorAll(".refs_container");
for (var MenuIndex = 0; MenuIndex < sourceMenus.length; ++MenuIndex)
{
var SetMenu = 0;
if (ref !== undefined && ref !== null) {
var refElements = sourceMenus[MenuIndex].querySelectorAll(".refs .ref");
var refs = ref.split(",");
for (var i = 0; i < refElements.length; ++i) {
if (refs.includes(refElements[i].getAttribute("data-id"))) {
refElements[i].classList.add("current");
} else {
refElements[i].classList.remove("current");
for (var i = 0; i < refElements.length; ++i) {
if (refs.includes(refElements[i].getAttribute("data-id"))) {
refElements[i].classList.add("current");
SetMenu = 1;
} else {
refElements[i].classList.remove("current");
}
}
if(SetMenu) {
sourceMenus[MenuIndex].classList.add("current");
} else {
sourceMenus[MenuIndex].classList.remove("current");
}
} else {
sourceMenus[MenuIndex].classList.remove("current");
var refs = sourceMenus[MenuIndex].querySelectorAll(".refs .ref");
for (var i = 0; i < refs.length; ++i) {
refs[i].classList.remove("current");
}
}
} else {
document.querySelector(".refs_container").classList.remove("current");
var refs = document.querySelectorAll(".refs .ref");
for (var i = 0; i < refs.length; ++i) {
refs[i].classList.remove("current");
}
}
}
</script>
</body>
</html>