// Source: D:\TempleOS-Projects\html\DocClipBoard-DolDoc-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "DolDoc/Clip"

sys_clip_doc=DocNew;

public U0 ClipDel()
{//Delete everything on clip.
  DocRst(sys_clip_doc,TRUE);
}

public U0 ClipCopy(CDoc *doc)
{//Copy DOCET_SEL flagged entries to clip.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_e=doc->head.next,*doc_ne;
  ClipDel;
  while (doc_e!=doc) {
    if (doc_e->type & DOCET_SEL) {
      doc_e->type&=~DOCET_SEL;
      if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
        doc_ne=DocEntryCopy(doc2,doc_e);
        QueIns(doc_ne,doc2->head.last);
      }
    }
    doc_e=doc_e->next;
  }
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 ClipCut(CDoc *doc)
{//Remove sel entries and place on clip.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_e=doc->head.next,*doc_e1,*doc_ne,*doc_e2=NULL;
  ClipDel;
  while (doc_e!=doc) {
    doc_e1=doc_e->next;
    if (doc_e->type & DOCET_SEL) {
      doc_e->type&=~DOCET_SEL;
      if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
        doc_ne=DocEntryCopy(doc2,doc_e);
        QueIns(doc_ne,doc2->head.last);
      }
      if (doc_e==doc->cur_entry || doc_e==doc_e2)
        doc_e2=doc_e->next;
      DocEntryDel(doc,doc_e);
    }
    doc_e=doc_e1;
  }
  if (doc_e2) {
    doc->cur_entry=doc_e2;
    doc->cur_col=doc_e2->min_col;
  }
  DocRemSoftNewLines(doc,NULL);
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 ClipPaste(CDoc *doc)
{//Insert copy of clip at insert pt, cur_entry.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_ce=doc->cur_entry,*doc_e;
  if (doc_ce->type_u8==DOCT_DATA) {
    doc_e=doc2->head.next;
    while (doc_e!=doc2) {
      if (doc_e->de_flags&DOCEF_TAG)
        DocPrintPartial(doc,"%s",doc_e->tag);
      doc_e=doc_e->next;
    }
  } else
    DocInsDoc(doc,doc2);
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 DocCut(CDoc *doc,CDocEntry *start,CDocEntry *end)
{//Del start to end entry, including end points.
  Bool unlock_doc=DocLock(doc);
  CDocEntry *doc_e1;
  if (start!=doc && (start->last!=end || end==doc))
    do {
      doc_e1=start->next;
      if (start==doc->cur_entry) {
        doc->cur_entry=start->next;
        doc->cur_col=doc->cur_entry->min_col;
      }
      DocEntryDel(doc,start);
      if (start==end)
        break;
      start=doc_e1;
    } while (start!=doc);
  DocRemSoftNewLines(doc,NULL);
  if (unlock_doc)
    DocUnlock(doc);
}

public CDoc *DocCopy(CDoc *doc,CDocEntry *start,CDocEntry *end)
{//Copies start to end entry, including end points.
  CDoc *doc2=DocNew;
  Bool unlock_doc=DocLock(doc);
  CDocEntry *doc_ne;
  if (start!=doc && (start->last!=end || end==doc))
    do {
      if (!Bt(doldoc.type_flags_data,start->type_u8)) {
        doc_ne=DocEntryCopy(doc2,start);
        QueIns(doc_ne,doc2->head.last);
      }
      if (start==end)
        break;
      start=start->next;
    } while (start!=doc);
  if (unlock_doc)
    DocUnlock(doc);
  return doc2;
}

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\DocClipBoard-DolDoc-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "DolDoc/Clip"

sys_clip_doc=DocNew;

public U0 ClipDel()
{//Delete everything on clip.
  DocRst(sys_clip_doc,TRUE);
}

public U0 ClipCopy(CDoc *doc)
{//Copy DOCET_SEL flagged entries to clip.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_e=doc->head.next,*doc_ne;
  ClipDel;
  while (doc_e!=doc) {
    if (doc_e->type & DOCET_SEL) {
      doc_e->type&=~DOCET_SEL;
      if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
        doc_ne=DocEntryCopy(doc2,doc_e);
        QueIns(doc_ne,doc2->head.last);
      }
    }
    doc_e=doc_e->next;
  }
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 ClipCut(CDoc *doc)
{//Remove sel entries and place on clip.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_e=doc->head.next,*doc_e1,*doc_ne,*doc_e2=NULL;
  ClipDel;
  while (doc_e!=doc) {
    doc_e1=doc_e->next;
    if (doc_e->type & DOCET_SEL) {
      doc_e->type&=~DOCET_SEL;
      if (!Bt(doldoc.type_flags_data,doc_e->type_u8)) {
        doc_ne=DocEntryCopy(doc2,doc_e);
        QueIns(doc_ne,doc2->head.last);
      }
      if (doc_e==doc->cur_entry || doc_e==doc_e2)
        doc_e2=doc_e->next;
      DocEntryDel(doc,doc_e);
    }
    doc_e=doc_e1;
  }
  if (doc_e2) {
    doc->cur_entry=doc_e2;
    doc->cur_col=doc_e2->min_col;
  }
  DocRemSoftNewLines(doc,NULL);
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 ClipPaste(CDoc *doc)
{//Insert copy of clip at insert pt, cur_entry.
  CDoc *doc2=sys_clip_doc;
  Bool unlock_doc=DocLock(doc),
        unlock_doc2=DocLock(doc2);
  CDocEntry *doc_ce=doc->cur_entry,*doc_e;
  if (doc_ce->type_u8==DOCT_DATA) {
    doc_e=doc2->head.next;
    while (doc_e!=doc2) {
      if (doc_e->de_flags&DOCEF_TAG)
        DocPrintPartial(doc,"%s",doc_e->tag);
      doc_e=doc_e->next;
    }
  } else
    DocInsDoc(doc,doc2);
  if (unlock_doc2)
    DocUnlock(doc2);
  if (unlock_doc)
    DocUnlock(doc);
}

public U0 DocCut(CDoc *doc,CDocEntry *start,CDocEntry *end)
{//Del start to end entry, including end points.
  Bool unlock_doc=DocLock(doc);
  CDocEntry *doc_e1;
  if (start!=doc && (start->last!=end || end==doc))
    do {
      doc_e1=start->next;
      if (start==doc->cur_entry) {
        doc->cur_entry=start->next;
        doc->cur_col=doc->cur_entry->min_col;
      }
      DocEntryDel(doc,start);
      if (start==end)
        break;
      start=doc_e1;
    } while (start!=doc);
  DocRemSoftNewLines(doc,NULL);
  if (unlock_doc)
    DocUnlock(doc);
}

public CDoc *DocCopy(CDoc *doc,CDocEntry *start,CDocEntry *end)
{//Copies start to end entry, including end points.
  CDoc *doc2=DocNew;
  Bool unlock_doc=DocLock(doc);
  CDocEntry *doc_ne;
  if (start!=doc && (start->last!=end || end==doc))
    do {
      if (!Bt(doldoc.type_flags_data,start->type_u8)) {
        doc_ne=DocEntryCopy(doc2,start);
        QueIns(doc_ne,doc2->head.last);
      }
      if (start==end)
        break;
      start=start->next;
    } while (start!=doc);
  if (unlock_doc)
    DocUnlock(doc);
  return doc2;
}


// Source: D:\TempleOS-Projects\html\LinuxDict-Sup1-Sup1Words-Home.html
// Date: unknown-date
// Language: HolyC

00001 A
00002 A's
00003 AA's
00004 AB's
00005 ABM's
00006 AC's
00007 ACTH's
00008 AI's
00009 AIDS's
00010 AM's
00011 AOL
00012 AOL's
00013 ASCII's
00014 ASL's
00015 ATM's
00016 ATP's
00017 AWOL's
00018 AZ's
00019 AZT's
00020 Aachen
00021 Aaliyah
00022 Aaliyah's
00023 Aaron
00024 Abbas
00025 Abbasid
00026 Abbott
00027 Abbott's
00028 Abby
00029 Abby's
00030 Abdul
00031 Abdul's
00032 Abe
00033 Abe's
00034 Abel
00035 Abel's
00036 Abelard
00037 Abelson
00038 Abelson's
00039 Aberdeen
00040 Aberdeen's
00041 Abernathy
00042 Abernathy's
00043 Abidjan
00044 Abidjan's
00045 Abigail
00046 Abilene
00047 Abner
00048 Abner's
00049 Abraham
00050 Abraham's
00051 Abram
00052 Abram's
00053 Abrams
00054 Absalom
00055 Abuja
00056 Abyssinia
00057 Abyssinia's
00058 Abyssinian
00059 Abyssinian's
00060 Ac
00061 Ac's
00062 Acadia
00063 Acadia's
00064 Acapulco
00065 Acapulco's
00066 Accenture
00067 Accenture's
00068 Accra
00069 Accra's
00070 Acevedo
00071 Acevedo's
00072 Achaean
00073 Achaean's
00074 Achebe
00075 Achebe's
00076 Achernar
00077 Acheson
00078 Acheson's
00079 Achilles
00080 Achilles's
00081 Aconcagua
00082 Aconcagua's
00083 Acosta
00084 Acosta's
00085 Acropolis
00086 Acrux
00087 Acrux's
00088 Actaeon
00089 Acton
00090 Acts
00091 Acuff
00092 Acuff's
00093 Ada
00094 Ada's
00095 Adam
00096 Adam's
00097 Adams
00098 Adan
00099 Adan's
00100 Adana
00101 Adar
00102 Adar's
00103 Addams
00104 Adderley
00105 Adderley's
00106 Addie
00107 Addie's
00108 Addison
00109 Adela
00110 Adela's
00111 Adelaide
00112 Adelaide's
00113 Adele
00114 Adele's
00115 Adeline
00116 Adeline's
00117 Aden
00118 Aden's
00119 Adenauer
00120 Adhara
00121 Adhara's
00122 Adidas
00123 Adidas's
00124 Adirondack
00125 Adirondack's
00126 Adirondacks
00127 Adirondacks's
00128 Adkins
00129 Adkins's
00130 Adler
00131 Adolf
00132 Adolf's
00133 Adolfo
00134 Adolfo's
00135 Adolph
00136 Adolph's
00137 Adonis
00138 Adonis's
00139 Adonises
00140 Adrian
00141 Adriana
00142 Adriana's
00143 Adriatic
00144 Adriatic's
00145 Adrienne
00146 Adrienne's
00147 Advent
00148 Advent's
00149 Adventist
00150 Adventist's
00151 Advents
00152 Advil
00153 Advil's
00154 Aegean
00155 Aegean's
00156 Aelfric
00157 Aelfric's
00158 Aeneas
00159 Aeneas's
00160 Aeneid
00161 Aeneid's
00162 Aeolus
00163 Aeolus's
00164 Aeroflot
00165 Aeroflot's
00166 Aeschylus
00167 Aeschylus's
00168 Aesculapius
00169 Aesculapius's
00170 Aesop
00171 Aesop's
00172 Afghan
00173 Afghan's
00174 Afghanistan
00175 Afghanistan's
00176 Afghans
00177 Africa
00178 Africa's
00179 African
00180 African's
00181 Africans
00182 Afrikaans
00183 Afrikaans's
00184 Afrikaner
00185 Afrikaner's
00186 Afrikaners
00187 Afro
00188 Afro's
00189 Afrocentrism
00190 Afros
00191 Ag
00192 Ag's
00193 Agamemnon
00194 Agamemnon's
00195 Agassi
00196 Agassi's
00197 Agassiz
00198 Agassiz's
00199 Agatha
00200 Agatha's
00201 Aggie
00202 Aglaia
00203 Agnes
00204 Agnew
00205 Agnew's
00206 Agni
00207 Agni's
00208 Agra
00209 Agricola
00210 Agrippa
00211 Agrippa's
00212 Agrippina
00213 Agrippina's
00214 Aguilar
00215 Aguilar's
00216 Aguinaldo
00217 Aguinaldo's
00218 Aguirre
00219 Aguirre's
00220 Agustin
00221 Agustin's
00222 Ahab
00223 Ahab's
00224 Ahmad
00225 Ahmad's
00226 Ahmadabad
00227 Ahmadinejad
00228 Ahmadinejad's
00229 Ahmed
00230 Ahmed's
00231 Ahriman
00232 Ahriman's
00233 Aida
00234 Aida's
00235 Aiken
00236 Aileen
00237 Aileen's
00238 Aimee
00239 Aimee's
00240 Ainu
00241 Airedale
00242 Airedale's
00243 Airedales
00244 Aisha
00245 Ajax
00246 Ajax's
00247 Akbar
00248 Akhmatova
00249 Akhmatova's
00250 Akihito
00251 Akita
00252 Akiva
00253 Akiva's
00254 Akkad
00255 Akron
00256 Akron's
00257 Al
00258 Al's
00259 Ala
00260 Alabama
00261 Alabama's
00262 Alabaman
00263 Alabaman's
00264 Alabamans
00265 Alabamian
00266 Alabamian's
00267 Alabamians
00268 Aladdin
00269 Aladdin's
00270 Alamo
00271 Alamo's
00272 Alamogordo
00273 Alamogordo's
00274 Alan
00275 Alan's
00276 Alana
00277 Alana's
00278 Alar
00279 Alar's
00280 Alaric
00281 Alaska
00282 Alaska's
00283 Alaskan
00284 Alaskan's
00285 Alaskans
00286 Alba
00287 Albania
00288 Albania's
00289 Albanian
00290 Albanian's
00291 Albanians
00292 Albany
00293 Albany's
00294 Albee
00295 Alberio
00296 Alberio's
00297 Albert
00298 Alberta
00299 Alberta's
00300 Alberto
00301 Alberto's
00302 Albigensian
00303 Albion
00304 Albireo
00305 Albireo's
00306 Albuquerque
00307 Albuquerque's
00308 Alcatraz
00309 Alcestis
00310 Alcibiades
00311 Alcindor
00312 Alcindor's
00313 Alcmena
00314 Alcmena's
00315 Alcoa
00316 Alcoa's
00317 Alcott
00318 Alcuin
00319 Alcyone
00320 Aldan
00321 Aldebaran
00322 Aldebaran's
00323 Alden
00324 Alderamin
00325 Alderamin's
00326 Aldo
00327 Aldo's
00328 Aldrin
00329 Aldrin's
00330 Alec
00331 Alec's
00332 Aleichem
00333 Aleichem's
00334 Alejandra
00335 Alejandra's
00336 Alejandro
00337 Alejandro's
00338 Alembert
00339 Alembert's
00340 Aleppo
00341 Aleppo's
00342 Aleut
00343 Aleut's
00344 Aleutian
00345 Aleutian's
00346 Alex
00347 Alex's
00348 Alexander
00349 Alexander's
00350 Alexandra
00351 Alexandria
00352 Alexandria's
00353 Alexei
00354 Alexei's
00355 Alexis
00356 Alfonso
00357 Alfonso's
00358 Alfonzo
00359 Alfonzo's
00360 Alford
00361 Alford's
00362 Alfred
00363 Alfreda
00364 Alfreda's
00365 Alfredo
00366 Algenib
00367 Algenib's
00368 Alger
00369 Algeria
00370 Algeria's
00371 Algerian
00372 Algerian's
00373 Algerians
00374 Algieba
00375 Algieba's
00376 Algiers
00377 Algiers's
00378 Algol
00379 Algol's
00380 Algonquian
00381 Algonquian's
00382 Algonquians
00383 Algonquin
00384 Algonquin's
00385 Alhambra
00386 Alhena
00387 Alhena's
00388 Ali
00389 Alice
00390 Alice's
00391 Alicia
00392 Alicia's
00393 Alighieri
00394 Alighieri's
00395 Aline
00396 Aline's
00397 Alioth
00398 Alioth's
00399 Alisa
00400 Alisa's
00401 Alisha
00402 Alisha's
00403 Alison
00404 Alison's
00405 Alissa
00406 Alissa's
00407 Alistair
00408 Alistair's
00409 Alkaid
00410 Alkaid's
00411 Allah
00412 Allah's
00413 Allahabad
00414 Allan
00415 Allan's
00416 Alleghenies
00417 Alleghenies's
00418 Allegheny
00419 Allegra
00420 Allegra's
00421 Allen
00422

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\LinuxDict-Sup1-Sup1Words-Home.html
// Date: unknown-date
// Language: HolyC

00001 A
00002 A's
00003 AA's
00004 AB's
00005 ABM's
00006 AC's
00007 ACTH's
00008 AI's
00009 AIDS's
00010 AM's
00011 AOL
00012 AOL's
00013 ASCII's
00014 ASL's
00015 ATM's
00016 ATP's
00017 AWOL's
00018 AZ's
00019 AZT's
00020 Aachen
00021 Aaliyah
00022 Aaliyah's
00023 Aaron
00024 Abbas
00025 Abbasid
00026 Abbott
00027 Abbott's
00028 Abby
00029 Abby's
00030 Abdul
00031 Abdul's
00032 Abe
00033 Abe's
00034 Abel
00035 Abel's
00036 Abelard
00037 Abelson
00038 Abelson's
00039 Aberdeen
00040 Aberdeen's
00041 Abernathy
00042 Abernathy's
00043 Abidjan
00044 Abidjan's
00045 Abigail
00046 Abilene
00047 Abner
00048 Abner's
00049 Abraham
00050 Abraham's
00051 Abram
00052 Abram's
00053 Abrams
00054 Absalom
00055 Abuja
00056 Abyssinia
00057 Abyssinia's
00058 Abyssinian
00059 Abyssinian's
00060 Ac
00061 Ac's
00062 Acadia
00063 Acadia's
00064 Acapulco
00065 Acapulco's
00066 Accenture
00067 Accenture's
00068 Accra
00069 Accra's
00070 Acevedo
00071 Acevedo's
00072 Achaean
00073 Achaean's
00074 Achebe
00075 Achebe's
00076 Achernar
00077 Acheson
00078 Acheson's
00079 Achilles
00080 Achilles's
00081 Aconcagua
00082 Aconcagua's
00083 Acosta
00084 Acosta's
00085 Acropolis
00086 Acrux
00087 Acrux's
00088 Actaeon
00089 Acton
00090 Acts
00091 Acuff
00092 Acuff's
00093 Ada
00094 Ada's
00095 Adam
00096 Adam's
00097 Adams
00098 Adan
00099 Adan's
00100 Adana
00101 Adar
00102 Adar's
00103 Addams
00104 Adderley
00105 Adderley's
00106 Addie
00107 Addie's
00108 Addison
00109 Adela
00110 Adela's
00111 Adelaide
00112 Adelaide's
00113 Adele
00114 Adele's
00115 Adeline
00116 Adeline's
00117 Aden
00118 Aden's
00119 Adenauer
00120 Adhara
00121 Adhara's
00122 Adidas
00123 Adidas's
00124 Adirondack
00125 Adirondack's
00126 Adirondacks
00127 Adirondacks's
00128 Adkins
00129 Adkins's
00130 Adler
00131 Adolf
00132 Adolf's
00133 Adolfo
00134 Adolfo's
00135 Adolph
00136 Adolph's
00137 Adonis
00138 Adonis's
00139 Adonises
00140 Adrian
00141 Adriana
00142 Adriana's
00143 Adriatic
00144 Adriatic's
00145 Adrienne
00146 Adrienne's
00147 Advent
00148 Advent's
00149 Adventist
00150 Adventist's
00151 Advents
00152 Advil
00153 Advil's
00154 Aegean
00155 Aegean's
00156 Aelfric
00157 Aelfric's
00158 Aeneas
00159 Aeneas's
00160 Aeneid
00161 Aeneid's
00162 Aeolus
00163 Aeolus's
00164 Aeroflot
00165 Aeroflot's
00166 Aeschylus
00167 Aeschylus's
00168 Aesculapius
00169 Aesculapius's
00170 Aesop
00171 Aesop's
00172 Afghan
00173 Afghan's
00174 Afghanistan
00175 Afghanistan's
00176 Afghans
00177 Africa
00178 Africa's
00179 African
00180 African's
00181 Africans
00182 Afrikaans
00183 Afrikaans's
00184 Afrikaner
00185 Afrikaner's
00186 Afrikaners
00187 Afro
00188 Afro's
00189 Afrocentrism
00190 Afros
00191 Ag
00192 Ag's
00193 Agamemnon
00194 Agamemnon's
00195 Agassi
00196 Agassi's
00197 Agassiz
00198 Agassiz's
00199 Agatha
00200 Agatha's
00201 Aggie
00202 Aglaia
00203 Agnes
00204 Agnew
00205 Agnew's
00206 Agni
00207 Agni's
00208 Agra
00209 Agricola
00210 Agrippa
00211 Agrippa's
00212 Agrippina
00213 Agrippina's
00214 Aguilar
00215 Aguilar's
00216 Aguinaldo
00217 Aguinaldo's
00218 Aguirre
00219 Aguirre's
00220 Agustin
00221 Agustin's
00222 Ahab
00223 Ahab's
00224 Ahmad
00225 Ahmad's
00226 Ahmadabad
00227 Ahmadinejad
00228 Ahmadinejad's
00229 Ahmed
00230 Ahmed's
00231 Ahriman
00232 Ahriman's
00233 Aida
00234 Aida's
00235 Aiken
00236 Aileen
00237 Aileen's
00238 Aimee
00239 Aimee's
00240 Ainu
00241 Airedale
00242 Airedale's
00243 Airedales
00244 Aisha
00245 Ajax
00246 Ajax's
00247 Akbar
00248 Akhmatova
00249 Akhmatova's
00250 Akihito
00251 Akita
00252 Akiva
00253 Akiva's
00254 Akkad
00255 Akron
00256 Akron's
00257 Al
00258 Al's
00259 Ala
00260 Alabama
00261 Alabama's
00262 Alabaman
00263 Alabaman's
00264 Alabamans
00265 Alabamian
00266 Alabamian's
00267 Alabamians
00268 Aladdin
00269 Aladdin's
00270 Alamo
00271 Alamo's
00272 Alamogordo
00273 Alamogordo's
00274 Alan
00275 Alan's
00276 Alana
00277 Alana's
00278 Alar
00279 Alar's
00280 Alaric
00281 Alaska
00282 Alaska's
00283 Alaskan
00284 Alaskan's
00285 Alaskans
00286 Alba
00287 Albania
00288 Albania's
00289 Albanian
00290 Albanian's
00291 Albanians
00292 Albany
00293 Albany's
00294 Albee
00295 Alberio
00296 Alberio's
00297 Albert
00298 Alberta
00299 Alberta's
00300 Alberto
00301 Alberto's
00302 Albigensian
00303 Albion
00304 Albireo
00305 Albireo's
00306 Albuquerque
00307 Albuquerque's
00308 Alcatraz
00309 Alcestis
00310 Alcibiades
00311 Alcindor
00312 Alcindor's
00313 Alcmena
00314 Alcmena's
00315 Alcoa
00316 Alcoa's
00317 Alcott
00318 Alcuin
00319 Alcyone
00320 Aldan
00321 Aldebaran
00322 Aldebaran's
00323 Alden
00324 Alderamin
00325 Alderamin's
00326 Aldo
00327 Aldo's
00328 Aldrin
00329 Aldrin's
00330 Alec
00331 Alec's
00332 Aleichem
00333 Aleichem's
00334 Alejandra
00335 Alejandra's
00336 Alejandro
00337 Alejandro's
00338 Alembert
00339 Alembert's
00340 Aleppo
00341 Aleppo's
00342 Aleut
00343 Aleut's
00344 Aleutian
00345 Aleutian's
00346 Alex
00347 Alex's
00348 Alexander
00349 Alexander's
00350 Alexandra
00351 Alexandria
00352 Alexandria's
00353 Alexei
00354 Alexei's
00355 Alexis
00356 Alfonso
00357 Alfonso's
00358 Alfonzo
00359 Alfonzo's
00360 Alford
00361 Alford's
00362 Alfred
00363 Alfreda
00364 Alfreda's
00365 Alfredo
00366 Algenib
00367 Algenib's
00368 Alger
00369 Algeria
00370 Algeria's
00371 Algerian
00372 Algerian's
00373 Algerians
00374 Algieba
00375 Algieba's
00376 Algiers
00377 Algiers's
00378 Algol
00379 Algol's
00380 Algonquian
00381 Algonquian's
00382 Algonquians
00383 Algonquin
00384 Algonquin's
00385 Alhambra
00386 Alhena
00387 Alhena's
00388 Ali
00389 Alice
00390 Alice's
00391 Alicia
00392 Alicia's
00393 Alighieri
00394 Alighieri's
00395 Aline
00396 Aline's
00397 Alioth
00398 Alioth's
00399 Alisa
00400 Alisa's
00401 Alisha
00402 Alisha's
00403 Alison
00404 Alison's
00405 Alissa
00406 Alissa's
00407 Alistair
00408 Alistair's
00409 Alkaid
00410 Alkaid's
00411 Allah
00412 Allah's
00413 Allahabad
00414 Allan
00415 Allan's
00416 Alleghenies
00417 Alleghenies's
00418 Allegheny
00419 Allegra
00420 Allegra's
00421 Allen
00422


// Source: D:\TempleOS-Projects\html\DocBin-DolDoc-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "DolDoc/Bin"

CDocBin *DocBinFindNum(CDoc *haystack_doc,I64 needle_num)
{
  CDocBin *b=haystack_doc->bin_head.next;
  while (b!=&haystack_doc->bin_head) {
    if (b->num==needle_num)
      return b;
    b=b->next;
  }
  return NULL;
}

CDocBin *DocBinFindTag(CDoc *haystack_doc,U8 *needle_tag)
{
  CDocBin *b;
  if (needle_tag) {
    b=haystack_doc->bin_head.next;
    while (b!=&haystack_doc->bin_head) {
      if (b->tag && !StrCmp(b->tag,needle_tag))
        return b;
      b=b->next;
    }
  }
  return NULL;
}

U0 DocBinsValidate(CDoc *doc)
{
  Bool unlock=DocLock(doc);
  CDocBin *b,*b1;
  CDocEntry *doc_e,*doc_e2;
  I64 renum_num=0;
  b=doc->bin_head.next;
  while (b!=&doc->bin_head) {
    b->use_cnt=0;
    b->tmp_use_cnt=0;
    b->renum_num=-1;
    Free(b->tag);
    b->tag=NULL;
    b=b->next;
  }
  doc_e=doc->head.next;
  while (doc_e!=doc) {
    doc_e2=doc_e->next;
    if (doc_e->de_flags & DOCEF_HAS_BIN) {
      if (b=doc_e->bin_data=DocBinFindNum(doc,doc_e->bin_num)) {
        if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
          b->tmp_use_cnt=I32_MAX;
        if (!b->use_cnt++)
          b->renum_num=++renum_num;
        doc_e->bin_num=b->renum_num;
        if (!b->tag && doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
          b->tag=StrNew(doc_e->tag,doc->mem_task);
      } else {
        RawPrint(3000,"Bin Not Found");
        doc_e->type=doc_e->de_flags=0;
        doc_e->type_u8=DOCT_ERROR;
      }
    }
    doc_e=doc_e2;
  }

  b=doc->bin_head.next;
  doc->cur_bin_num=1;
  while (b!=&doc->bin_head) {
    b1=b->next;
    if (!b->use_cnt) {
      QueRem(b);
      Free(b->data);
      Free(b);
    } else {
      b->num=b->renum_num;
      if (b->num>=doc->cur_bin_num)
        doc->cur_bin_num=b->num+1;
    }
    b=b1;
  }
  if (unlock)
    DocUnlock(doc);
}

U0 DocBinDel(CDoc *doc,CDocBin *b)
{
  if (doc && b && b->use_cnt) {
    b->use_cnt--;
    if (!b->use_cnt) {
      QueRem(b);
      Free(b->tag);
      Free(b->data);
      Free(b);
    }
  } else
    RawPrint(3000,"DocBinDel");
}

I64 DocBinPtrRst(CDoc *doc,CDocEntry *doc_e)
{
  U8 *st,*st2;
  CDoc *doc2;
  CDocBin *tmpb,*tmpb2;
  I64 i,bin_num=0;
  if (doc_e->de_flags&DOCEF_HAS_BIN &&
        doc_e->bin_ptr_link && StrLen(doc_e->bin_ptr_link)) {
    bin_num=doc_e->bin_num;
    st=StrNew(doc_e->bin_ptr_link);
    st2=StrNew(st);
    StrLastRem(st,",",st2);
    i=Str2I64(st2);
    if (i>0||*st2) {
      doc2=DocRead(st);
      if (i>0  && (tmpb2=DocBinFindNum(doc2,i)) ||
            i==0 && (tmpb2=DocBinFindTag(doc2,st2))) {
        i=1;
        if (bin_num>0) {
          if (tmpb=DocBinFindNum(doc,bin_num)) {
            i=tmpb->use_cnt;
            DocBinDel(doc,tmpb);
          }
        } else
          bin_num=doc->cur_bin_num++;
        tmpb=MAllocIdent(tmpb2,doc->mem_task);
        tmpb->use_cnt=i;
        tmpb->data=MAllocIdent(tmpb2->data,doc->mem_task);
        tmpb->num=bin_num;
        doc_e->bin_data=tmpb;
        if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
          tmpb->tag=StrNew(doc_e->tag,doc->mem_task);
        else
          tmpb->tag=NULL;
        QueIns(tmpb,doc->bin_head.last);
      } else
        bin_num=0;
      DocDel(doc2);
    } else
      bin_num=0;
    Free(st2);
    Free(st);
    doc_e->bin_num=bin_num;
  }
  return bin_num;
}

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\DocBin-DolDoc-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "DolDoc/Bin"

CDocBin *DocBinFindNum(CDoc *haystack_doc,I64 needle_num)
{
  CDocBin *b=haystack_doc->bin_head.next;
  while (b!=&haystack_doc->bin_head) {
    if (b->num==needle_num)
      return b;
    b=b->next;
  }
  return NULL;
}

CDocBin *DocBinFindTag(CDoc *haystack_doc,U8 *needle_tag)
{
  CDocBin *b;
  if (needle_tag) {
    b=haystack_doc->bin_head.next;
    while (b!=&haystack_doc->bin_head) {
      if (b->tag && !StrCmp(b->tag,needle_tag))
        return b;
      b=b->next;
    }
  }
  return NULL;
}

U0 DocBinsValidate(CDoc *doc)
{
  Bool unlock=DocLock(doc);
  CDocBin *b,*b1;
  CDocEntry *doc_e,*doc_e2;
  I64 renum_num=0;
  b=doc->bin_head.next;
  while (b!=&doc->bin_head) {
    b->use_cnt=0;
    b->tmp_use_cnt=0;
    b->renum_num=-1;
    Free(b->tag);
    b->tag=NULL;
    b=b->next;
  }
  doc_e=doc->head.next;
  while (doc_e!=doc) {
    doc_e2=doc_e->next;
    if (doc_e->de_flags & DOCEF_HAS_BIN) {
      if (b=doc_e->bin_data=DocBinFindNum(doc,doc_e->bin_num)) {
        if (doc_e->de_flags & DOCEF_BIN_PTR_LINK)
          b->tmp_use_cnt=I32_MAX;
        if (!b->use_cnt++)
          b->renum_num=++renum_num;
        doc_e->bin_num=b->renum_num;
        if (!b->tag && doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
          b->tag=StrNew(doc_e->tag,doc->mem_task);
      } else {
        RawPrint(3000,"Bin Not Found");
        doc_e->type=doc_e->de_flags=0;
        doc_e->type_u8=DOCT_ERROR;
      }
    }
    doc_e=doc_e2;
  }

  b=doc->bin_head.next;
  doc->cur_bin_num=1;
  while (b!=&doc->bin_head) {
    b1=b->next;
    if (!b->use_cnt) {
      QueRem(b);
      Free(b->data);
      Free(b);
    } else {
      b->num=b->renum_num;
      if (b->num>=doc->cur_bin_num)
        doc->cur_bin_num=b->num+1;
    }
    b=b1;
  }
  if (unlock)
    DocUnlock(doc);
}

U0 DocBinDel(CDoc *doc,CDocBin *b)
{
  if (doc && b && b->use_cnt) {
    b->use_cnt--;
    if (!b->use_cnt) {
      QueRem(b);
      Free(b->tag);
      Free(b->data);
      Free(b);
    }
  } else
    RawPrint(3000,"DocBinDel");
}

I64 DocBinPtrRst(CDoc *doc,CDocEntry *doc_e)
{
  U8 *st,*st2;
  CDoc *doc2;
  CDocBin *tmpb,*tmpb2;
  I64 i,bin_num=0;
  if (doc_e->de_flags&DOCEF_HAS_BIN &&
        doc_e->bin_ptr_link && StrLen(doc_e->bin_ptr_link)) {
    bin_num=doc_e->bin_num;
    st=StrNew(doc_e->bin_ptr_link);
    st2=StrNew(st);
    StrLastRem(st,",",st2);
    i=Str2I64(st2);
    if (i>0||*st2) {
      doc2=DocRead(st);
      if (i>0  && (tmpb2=DocBinFindNum(doc2,i)) ||
            i==0 && (tmpb2=DocBinFindTag(doc2,st2))) {
        i=1;
        if (bin_num>0) {
          if (tmpb=DocBinFindNum(doc,bin_num)) {
            i=tmpb->use_cnt;
            DocBinDel(doc,tmpb);
          }
        } else
          bin_num=doc->cur_bin_num++;
        tmpb=MAllocIdent(tmpb2,doc->mem_task);
        tmpb->use_cnt=i;
        tmpb->data=MAllocIdent(tmpb2->data,doc->mem_task);
        tmpb->num=bin_num;
        doc_e->bin_data=tmpb;
        if (doc_e->de_flags&DOCEF_TAG && doc_e->tag && *doc_e->tag)
          tmpb->tag=StrNew(doc_e->tag,doc->mem_task);
        else
          tmpb->tag=NULL;
        QueIns(tmpb,doc->bin_head.last);
      } else
        bin_num=0;
      DocDel(doc2);
    } else
      bin_num=0;
    Free(st2);
    Free(st);
    doc_e->bin_num=bin_num;
  }
  return bin_num;
}


// Source: D:\TempleOS-Projects\html\TOSBlog-TOS-Home.html
// Date: unknown-date
// Language: HolyC

#help_index "Misc/Blog"

public Bool IsTOSBlog(U8 *filename)
{//Is this in the TOSBlog dir?
  Bool res;
  U8 *st=DirNameAbs(filename),*home=DirNameAbs("~");
  I64 l=StrLen(home);
  if (StrLen(st)>=l+12 && !StrNCmp(st+1,home+1,l-1) &&
      st[l]=='/' && !StrNCmp(st+l+4,"/TOSBlog",8))
    res=TRUE;
  else
    res=FALSE;
  Free(st);
  Free(home);
  return res;
}

public U8 *TOSBlogAbs(U8 *filename)
{//Absolute filename, adjusted for moving TOSBlog.
  U8 *st=DirNameAbs(filename),*home=DirNameAbs("~");
  I64 l=StrLen(home);
  if (IsTOSBlog(st)) {
    MemCpy(st+l+5,st+l+1,3);
    MemCpy(st+l+1,"Web",3);
    StrCpy(st+l+8,st+l+12);
  }
  Free(home);
  return st;
}

public U8 *BlogLocalDir(CDate cdt=0)
{//MAlloc dirname of blog for date.
  static U8 dir[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(dir,BLOG_LOCAL_SRC "/%d%Z",ds.year,ds.mon-1,"ST_MONTHS");
  if (!FileFind(dir,,FUF_JUST_DIRS))
    DirMk(dir);
  return dir;
}

public U8 *BlogLocalFile(CDate cdt=0)
{//MAlloc filename of blog for date.
  static U8 file[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
        BlogLocalDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
  return file;
}

public U8 *BlogWebDir(CDate cdt=0)
{//MAlloc D:/Wb/dirname of blog for date.
  static U8 dir[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(dir,BLOG_WEB_DST "/%d%Z",
        ds.year,ds.mon-1,"ST_MONTHS");
  return dir;
}

public U8 *BlogWebFile(CDate cdt=0)
{//MAlloc D:/Wb/filename of blog for date.
  static U8 file[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
        BlogWebDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
  return file;
}

public U8 *FileNameNumNext(U8 *files_find_mask,U8 *fmt)
{//Cnt files in a mask. Create next filename.
  CDirEntry *tmpde=FilesFind(files_find_mask);
  U8 *res=MStrPrint(fmt,FileCnt(tmpde));
  DirTreeDel(tmpde);
  return res;
}

public U0 BlogDCImgWrite(CDC *dc,CDate cdt=0)
{//Add dc to blog as BMP file.
  U8 file_mask[STR_LEN],file_name[STR_LEN],*st,*st2;
  if (!cdt) cdt=Now+local_time_offset;
  StrPrint(file_mask,"%s/Img*",BlogLocalDir(cdt));
  StrPrint(file_name,"%s/Img%%03d.BMP",BlogLocalDir(cdt));
  st=FileNameNumNext(file_mask,file_name);
  BMPWrite(st,dc);
  st2=TOSBlogAbs(st);
  Free(st);
  st=MStrPrint("/Wb%s",st2+2);
  Free(st2);
  "$HC,\"<img src=\\\"%s\\\" width=\\\"%d\\\" "
        "height=\\\"%d\\\" alt=\\\"\\\">\"$\n",st,dc->width,dc->height;
  Free(st);
}

public U0 BlogScrnShot()
{//Add scrn shot to blog as BMP file.
  Bool old_cursor=DocCursor,old_silent;
  CDC *dc1,*dc2;
  U8 *old_fp_draw_ms=gr.fp_draw_ms;
  gr.fp_draw_ms=NULL;
  Refresh(2);
  dc1=DCScrnCapture;
  dc2=DCExt(dc1,0,FONT_HEIGHT,GR_WIDTH-1,GR_HEIGHT-1);
  BlogDCImgWrite(dc2);
  gr.fp_draw_ms=old_fp_draw_ms;
  DCDel(dc1);
  DCDel(dc2);
  DocCursor(old_cursor);
  old_silent=Silent;
  FreshenBlog;
  Silent(old_silent);
}

public U0 FreshenBlog()
{//Regen html files for D:/Home/Web.
  DirMk("D:/Wb");
  DirMk("D:/Wb/Home");
  DirMk("D:/Wb/Home/Web");
  DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS);
  DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS "/BlogDir");

  FreshenWebDir("/Home/Web");
  FreshenWebDir("/Home/" INS_REG_PERSONAL_INITIALS "/TOSBlog");
  FreshenWebDir(BlogLocalDir+2);
  Drv('C');
}

public U0 Blog(Bool god_misc2=FALSE)
{//Make entry in blog.
  if (!FileFind(BlogLocalFile,,FUF_JUST_FILES))
    Copy("~/" INS_REG_PERSONAL_INITIALS "/TOSBlog/DailyBlogHeader.DD.Z",
          BlogLocalFile);
  AutoComplete;
  WinBorder;
  WinMax;
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN|SCF_CTRL);
  if (god_misc2)
    Msg(MSG_KEY_DOWN_UP,0,SC_F7|SCF_SHIFT|SCF_ALT);
  else {
    Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
    Msg(MSG_KEY_DOWN_UP,'\n',0);
  }
  Msg(MSG_KEY_DOWN_UP,CH_CTRLS,0x61F0000061F);
  if (Ed(BlogLocalFile,EDF_WAS_WRITE)) {
    DocOpt(BlogLocalFile,"-r");
    Copy(BlogLocalFile,"::" DAILY_SRC ".DD.Z");
    Copy(BlogLocalFile,"D:" DAILY_SRC ".DD.Z");
    Copy(BlogLocalFile,"D:/Wb" DAILY_DST ".DD.Z");
    TOSWebFile("D:/Wb" DAILY_DST ".DD.Z");
    FreshenBlog;
  }
}

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\TOSBlog-TOS-Home.html
// Date: unknown-date
// Language: HolyC

#help_index "Misc/Blog"

public Bool IsTOSBlog(U8 *filename)
{//Is this in the TOSBlog dir?
  Bool res;
  U8 *st=DirNameAbs(filename),*home=DirNameAbs("~");
  I64 l=StrLen(home);
  if (StrLen(st)>=l+12 && !StrNCmp(st+1,home+1,l-1) &&
      st[l]=='/' && !StrNCmp(st+l+4,"/TOSBlog",8))
    res=TRUE;
  else
    res=FALSE;
  Free(st);
  Free(home);
  return res;
}

public U8 *TOSBlogAbs(U8 *filename)
{//Absolute filename, adjusted for moving TOSBlog.
  U8 *st=DirNameAbs(filename),*home=DirNameAbs("~");
  I64 l=StrLen(home);
  if (IsTOSBlog(st)) {
    MemCpy(st+l+5,st+l+1,3);
    MemCpy(st+l+1,"Web",3);
    StrCpy(st+l+8,st+l+12);
  }
  Free(home);
  return st;
}

public U8 *BlogLocalDir(CDate cdt=0)
{//MAlloc dirname of blog for date.
  static U8 dir[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(dir,BLOG_LOCAL_SRC "/%d%Z",ds.year,ds.mon-1,"ST_MONTHS");
  if (!FileFind(dir,,FUF_JUST_DIRS))
    DirMk(dir);
  return dir;
}

public U8 *BlogLocalFile(CDate cdt=0)
{//MAlloc filename of blog for date.
  static U8 file[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
        BlogLocalDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
  return file;
}

public U8 *BlogWebDir(CDate cdt=0)
{//MAlloc D:/Wb/dirname of blog for date.
  static U8 dir[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(dir,BLOG_WEB_DST "/%d%Z",
        ds.year,ds.mon-1,"ST_MONTHS");
  return dir;
}

public U8 *BlogWebFile(CDate cdt=0)
{//MAlloc D:/Wb/filename of blog for date.
  static U8 file[STR_LEN];
  CDateStruct ds;
  if (!cdt) cdt=Now+local_time_offset;
  Date2Struct(&ds,cdt);
  StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z",
        BlogWebDir(cdt),ds.year%100,ds.mon,ds.day_of_mon);
  return file;
}

public U8 *FileNameNumNext(U8 *files_find_mask,U8 *fmt)
{//Cnt files in a mask. Create next filename.
  CDirEntry *tmpde=FilesFind(files_find_mask);
  U8 *res=MStrPrint(fmt,FileCnt(tmpde));
  DirTreeDel(tmpde);
  return res;
}

public U0 BlogDCImgWrite(CDC *dc,CDate cdt=0)
{//Add dc to blog as BMP file.
  U8 file_mask[STR_LEN],file_name[STR_LEN],*st,*st2;
  if (!cdt) cdt=Now+local_time_offset;
  StrPrint(file_mask,"%s/Img*",BlogLocalDir(cdt));
  StrPrint(file_name,"%s/Img%%03d.BMP",BlogLocalDir(cdt));
  st=FileNameNumNext(file_mask,file_name);
  BMPWrite(st,dc);
  st2=TOSBlogAbs(st);
  Free(st);
  st=MStrPrint("/Wb%s",st2+2);
  Free(st2);
  "$HC,\"<img src=\\\"%s\\\" width=\\\"%d\\\" "
        "height=\\\"%d\\\" alt=\\\"\\\">\"$\n",st,dc->width,dc->height;
  Free(st);
}

public U0 BlogScrnShot()
{//Add scrn shot to blog as BMP file.
  Bool old_cursor=DocCursor,old_silent;
  CDC *dc1,*dc2;
  U8 *old_fp_draw_ms=gr.fp_draw_ms;
  gr.fp_draw_ms=NULL;
  Refresh(2);
  dc1=DCScrnCapture;
  dc2=DCExt(dc1,0,FONT_HEIGHT,GR_WIDTH-1,GR_HEIGHT-1);
  BlogDCImgWrite(dc2);
  gr.fp_draw_ms=old_fp_draw_ms;
  DCDel(dc1);
  DCDel(dc2);
  DocCursor(old_cursor);
  old_silent=Silent;
  FreshenBlog;
  Silent(old_silent);
}

public U0 FreshenBlog()
{//Regen html files for D:/Home/Web.
  DirMk("D:/Wb");
  DirMk("D:/Wb/Home");
  DirMk("D:/Wb/Home/Web");
  DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS);
  DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS "/BlogDir");

  FreshenWebDir("/Home/Web");
  FreshenWebDir("/Home/" INS_REG_PERSONAL_INITIALS "/TOSBlog");
  FreshenWebDir(BlogLocalDir+2);
  Drv('C');
}

public U0 Blog(Bool god_misc2=FALSE)
{//Make entry in blog.
  if (!FileFind(BlogLocalFile,,FUF_JUST_FILES))
    Copy("~/" INS_REG_PERSONAL_INITIALS "/TOSBlog/DailyBlogHeader.DD.Z",
          BlogLocalFile);
  AutoComplete;
  WinBorder;
  WinMax;
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN|SCF_CTRL);
  if (god_misc2)
    Msg(MSG_KEY_DOWN_UP,0,SC_F7|SCF_SHIFT|SCF_ALT);
  else {
    Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
    Msg(MSG_KEY_DOWN_UP,'\n',0);
  }
  Msg(MSG_KEY_DOWN_UP,CH_CTRLS,0x61F0000061F);
  if (Ed(BlogLocalFile,EDF_WAS_WRITE)) {
    DocOpt(BlogLocalFile,"-r");
    Copy(BlogLocalFile,"::" DAILY_SRC ".DD.Z");
    Copy(BlogLocalFile,"D:" DAILY_SRC ".DD.Z");
    Copy(BlogLocalFile,"D:/Wb" DAILY_DST ".DD.Z");
    TOSWebFile("D:/Wb" DAILY_DST ".DD.Z");
    FreshenBlog;
  }
}


// Source: D:\TempleOS-Projects\html\DskISO9660-Opt-Boot-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "File/CD DVD"

class CCDVDUserData //Create DVD
{
  I64 loc,path_entry_num,
        short_dir_blks,long_dir_blks;
};

I64 DVDFileCreate2(CFile *out_file,CDirEntry *tmpde,CISO1DirEntry *tmpi,
        CISO1DirEntry *tmpi2,I64 *_cur_blk,CDirEntry *parent,Bool write,
        U8 *stage2_filename,I64 *_stage2_blk)
{
  CCDVDUserData *tmpc;
  CDirEntry *tmpde1,*tmpde2;
  CFile *in_file;
  U8 *buf=MAlloc(DVD_BLK_SIZE),*ptr1,*ptr2;
  CISO1DirEntry *dir_blk_buf =CAlloc(DVD_BLK_SIZE*128),
        *de =dir_blk_buf, *de1,
        *dir_blk_buf2=CAlloc(DVD_BLK_SIZE*128),
        *de2=dir_blk_buf2,*de12;
  I64 i,n;

  tmpc=parent->user_data;

  de->len=sizeof(CISO1DirEntry)-1;
  de->ext_attr_len=0;
  FillU16Palindrome(&de->vol_seq_num,1);
  Date2ISO1(&de->date,tmpde->datetime);
  de->flags=ISO1_ATTR_DIR;
  de->name_len=1;
  de->name=0;
  de->len+=de->name_len;
  de(U8 *)+=de->len;

  de->len=sizeof(CISO1DirEntry)-1;
  de->ext_attr_len=0;
  FillU32Palindrome(&de->loc,tmpc->loc);
  FillU32Palindrome(&de->size,tmpc->short_dir_blks*DVD_BLK_SIZE);
  FillU16Palindrome(&de->vol_seq_num,1);
  Date2ISO1(&de->date,parent->datetime);
  de->flags=ISO1_ATTR_DIR;
  de->name_len=1;
  de->name=1;
  de->len+=de->name_len;
  de(U8 *)+=de->len;

  de2->len=sizeof(CISO1DirEntry)-1;
  de2->ext_attr_len=0;
  FillU16Palindrome(&de2->vol_seq_num,1);
  Date2ISO1(&de2->date,tmpde->datetime);
  de2->flags=ISO1_ATTR_DIR;
  de2->name_len=1;
  de2->name=0;
  de2->len+=de2->name_len;
  de2(U8 *)+=de2->len;

  de2->len=sizeof(CISO1DirEntry)-1;
  de2->ext_attr_len=0;
  FillU32Palindrome(&de2->loc,tmpc->loc+tmpc->short_dir_blks);
  FillU32Palindrome(&de2->size,tmpc->long_dir_blks*DVD_BLK_SIZE);
  FillU16Palindrome(&de2->vol_seq_num,1);
  Date2ISO1(&de2->date,parent->datetime);
  de2->flags=ISO1_ATTR_DIR;
  de2->name_len=1;
  de2->name=1;
  de2->len+=de2->name_len;
  de2(U8 *)+=de2->len;

  tmpde1=tmpde->sub;
  while (tmpde1) {
    tmpde2=tmpde1->next;
    if (!write) tmpde1->user_data=CAlloc(sizeof(CCDVDUserData));
    de1=de;
    de12=de2;
    if (tmpde1->attr & RS_ATTR_DIR) {
      n=DVDFileCreate2(out_file,tmpde1,de,de2,_cur_blk,
            tmpde,write,stage2_filename,_stage2_blk);
      de(U8 *)+=sizeof(CISO1DirEntry)-1+n;
      de2(U8 *)+=sizeof(CISO1DirEntry)-1+n<<1;
    } else {
      tmpc=tmpde1->user_data;
      de->len=sizeof(CISO1DirEntry)-1;
      de->ext_attr_len=0;
      FillU32Palindrome(&de->loc,*_cur_blk);
      tmpc->loc=*_cur_blk;
      if (write) {
        if (stage2_filename && !StrCmp(tmpde1->full_name,stage2_filename)) {
          "$RED$!!! Boot Stage 2 !!!$FG$\n";
          if (_stage2_blk) *_stage2_blk=*_cur_blk;
        }
        "%X:%s\n",*_cur_blk,tmpde1->full_name;
      }
      FillU32Palindrome(&de->size,tmpde1->size);
      FillU16Palindrome(&de->vol_seq_num,1);
      Date2ISO1(&de->date,tmpde1->datetime);
      de->flags=0;
      de->name_len=StrLen(tmpde1->name);
      StrCpy(&de->name,tmpde1->name);
      de->len=de->len+de->name_len;
      de(U8 *)+=de->len;

      de2->len=sizeof(CISO1DirEntry)-1;
      de2->ext_attr_len=0;
      FillU32Palindrome(&de2->loc,*_cur_blk);
      FillU32Palindrome(&de2->size,tmpde1->size);
      FillU16Palindrome(&de2->vol_seq_num,1);
      Date2ISO1(&de2->date,tmpde1->datetime);
      de2->flags=0;
      de2->name_len=StrLen(tmpde1->name)<<1;
      ptr1=&de2->name;
      ptr2=&tmpde1->name;
      for (i=0;i<de2->name_len;i=i+2) {
        ptr1++;
        *ptr1++=*ptr2++;
      }
      de2->len+=de2->name_len;
      de2(U8 *)+=de2->len;

      in_file=FOpen(tmpde1->full_name,"r");
      for (i=0;i<(FSize(in_file)+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;i++) {
        n=4;
        if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) {
          n=(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS&3;
          MemSet(buf,0,DVD_BLK_SIZE);
        }
        if (write) {
          FBlkRead(in_file,buf,i<<2,n);
          FBlkWrite(out_file,buf,*_cur_blk<<2,n);
        }
        *_cur_blk+=1;
      }
      FClose(in_file);
    }
    if ((de1(U8 *)-dir_blk_buf(U8 *))/DVD_BLK_SIZE!=
          (de(U8 *) -dir_blk_buf(U8 *))/DVD_BLK_SIZE) {
      i=de1->len;
      MemCpy(buf,de1,i);
      MemSet(de1,0,i);
      de=dir_blk_buf(U8 *)+(de(U8 *)
      -dir_blk_buf(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
      MemCpy(de,buf,i);
      de(U8 *)+=i;
    }
    if ((de12(U8 *)-dir_blk_buf2(U8 *))/DVD_BLK_SIZE!=
          (de2(U8 *) -dir_blk_buf2(U8 *))/DVD_BLK_SIZE) {
      i=de12->len;
      MemCpy(buf,de12,i);
      MemSet(de12,0,i);
      de2(U8 *)=dir_blk_buf2(U8 *)+(de2(U8 *)
      -dir_blk_buf2(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
      MemCpy(de2,buf,i);
      de2(U8 *)+=i;
    }
    tmpde1=tmpde2;
  }

  tmpc=tmpde->user_data;

  tmpi->len=sizeof(CISO1DirEntry)-1;
  tmpi->ext_attr_len=0;
  tmpi->flags=ISO1_ATTR_DIR;
  if (!tmpde->name[0]) {
    tmpi->name_len=1;
    tmpi->name=1;
  } else {
    tmpi->name_len=StrLen(tmpde->name);
    StrCpy(&tmpi->name,tmpde->name);
  }
  tmpi->len+=tmpi->name_len;

  n=de(U8 *)+1-dir_blk_buf(U8 *);
  n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
  FillU32Palindrome(&tmpi->size,n*DVD_BLK_SIZE);
  FillU32Palindrome(&tmpi->loc,*_cur_blk);
  tmpc->short_dir_blks=n;
  tmpc->loc=*_cur_blk;
  FillU32Palindrome(&dir_blk_buf->size,n*DVD_BLK_SIZE);
  FillU32Palindrome(&dir_blk_buf->loc,*_cur_blk);
  FillU16Palindrome(&tmpi->vol_seq_num,1);
  Date2ISO1(&tmpi->date,tmpde->datetime);
  if (write)
    "%X:%s\n",*_cur_blk,tmpde->full_name;
  if (write)
    FBlkWrite(out_file,dir_blk_buf,*_cur_blk<<2,n<<2);
  *_cur_blk+=n;

  tmpi2->len=sizeof(CISO1DirEntry)-1;
  tmpi2->ext_attr_len=0;
  tmpi2->flags=ISO1_ATTR_DIR;
  if (!tmpde->name[0]) {
    tmpi2->name_len=1;
    tmpi->name=1;
  } else {
    tmpi2->name_len=StrLen(tmpde->name)<<1;
    ptr1=&tmpi2->name;
    ptr2=&tmpde->name;
    for (i=0;i<tmpi2->name_len;i=i+2) {
      ptr1++;
      *ptr1++=*ptr2++;
    }
  }
  tmpi2->len+=tmpi2->name_len;
  n=de2(U8 *)+1-dir_blk_buf2(U8 *);
  n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
  FillU32Palindrome(&tmpi2->size,n*DVD_BLK_SIZE);
  FillU32

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\DskISO9660-Opt-Boot-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "File/CD DVD"

class CCDVDUserData //Create DVD
{
  I64 loc,path_entry_num,
        short_dir_blks,long_dir_blks;
};

I64 DVDFileCreate2(CFile *out_file,CDirEntry *tmpde,CISO1DirEntry *tmpi,
        CISO1DirEntry *tmpi2,I64 *_cur_blk,CDirEntry *parent,Bool write,
        U8 *stage2_filename,I64 *_stage2_blk)
{
  CCDVDUserData *tmpc;
  CDirEntry *tmpde1,*tmpde2;
  CFile *in_file;
  U8 *buf=MAlloc(DVD_BLK_SIZE),*ptr1,*ptr2;
  CISO1DirEntry *dir_blk_buf =CAlloc(DVD_BLK_SIZE*128),
        *de =dir_blk_buf, *de1,
        *dir_blk_buf2=CAlloc(DVD_BLK_SIZE*128),
        *de2=dir_blk_buf2,*de12;
  I64 i,n;

  tmpc=parent->user_data;

  de->len=sizeof(CISO1DirEntry)-1;
  de->ext_attr_len=0;
  FillU16Palindrome(&de->vol_seq_num,1);
  Date2ISO1(&de->date,tmpde->datetime);
  de->flags=ISO1_ATTR_DIR;
  de->name_len=1;
  de->name=0;
  de->len+=de->name_len;
  de(U8 *)+=de->len;

  de->len=sizeof(CISO1DirEntry)-1;
  de->ext_attr_len=0;
  FillU32Palindrome(&de->loc,tmpc->loc);
  FillU32Palindrome(&de->size,tmpc->short_dir_blks*DVD_BLK_SIZE);
  FillU16Palindrome(&de->vol_seq_num,1);
  Date2ISO1(&de->date,parent->datetime);
  de->flags=ISO1_ATTR_DIR;
  de->name_len=1;
  de->name=1;
  de->len+=de->name_len;
  de(U8 *)+=de->len;

  de2->len=sizeof(CISO1DirEntry)-1;
  de2->ext_attr_len=0;
  FillU16Palindrome(&de2->vol_seq_num,1);
  Date2ISO1(&de2->date,tmpde->datetime);
  de2->flags=ISO1_ATTR_DIR;
  de2->name_len=1;
  de2->name=0;
  de2->len+=de2->name_len;
  de2(U8 *)+=de2->len;

  de2->len=sizeof(CISO1DirEntry)-1;
  de2->ext_attr_len=0;
  FillU32Palindrome(&de2->loc,tmpc->loc+tmpc->short_dir_blks);
  FillU32Palindrome(&de2->size,tmpc->long_dir_blks*DVD_BLK_SIZE);
  FillU16Palindrome(&de2->vol_seq_num,1);
  Date2ISO1(&de2->date,parent->datetime);
  de2->flags=ISO1_ATTR_DIR;
  de2->name_len=1;
  de2->name=1;
  de2->len+=de2->name_len;
  de2(U8 *)+=de2->len;

  tmpde1=tmpde->sub;
  while (tmpde1) {
    tmpde2=tmpde1->next;
    if (!write) tmpde1->user_data=CAlloc(sizeof(CCDVDUserData));
    de1=de;
    de12=de2;
    if (tmpde1->attr & RS_ATTR_DIR) {
      n=DVDFileCreate2(out_file,tmpde1,de,de2,_cur_blk,
            tmpde,write,stage2_filename,_stage2_blk);
      de(U8 *)+=sizeof(CISO1DirEntry)-1+n;
      de2(U8 *)+=sizeof(CISO1DirEntry)-1+n<<1;
    } else {
      tmpc=tmpde1->user_data;
      de->len=sizeof(CISO1DirEntry)-1;
      de->ext_attr_len=0;
      FillU32Palindrome(&de->loc,*_cur_blk);
      tmpc->loc=*_cur_blk;
      if (write) {
        if (stage2_filename && !StrCmp(tmpde1->full_name,stage2_filename)) {
          "$RED$!!! Boot Stage 2 !!!$FG$\n";
          if (_stage2_blk) *_stage2_blk=*_cur_blk;
        }
        "%X:%s\n",*_cur_blk,tmpde1->full_name;
      }
      FillU32Palindrome(&de->size,tmpde1->size);
      FillU16Palindrome(&de->vol_seq_num,1);
      Date2ISO1(&de->date,tmpde1->datetime);
      de->flags=0;
      de->name_len=StrLen(tmpde1->name);
      StrCpy(&de->name,tmpde1->name);
      de->len=de->len+de->name_len;
      de(U8 *)+=de->len;

      de2->len=sizeof(CISO1DirEntry)-1;
      de2->ext_attr_len=0;
      FillU32Palindrome(&de2->loc,*_cur_blk);
      FillU32Palindrome(&de2->size,tmpde1->size);
      FillU16Palindrome(&de2->vol_seq_num,1);
      Date2ISO1(&de2->date,tmpde1->datetime);
      de2->flags=0;
      de2->name_len=StrLen(tmpde1->name)<<1;
      ptr1=&de2->name;
      ptr2=&tmpde1->name;
      for (i=0;i<de2->name_len;i=i+2) {
        ptr1++;
        *ptr1++=*ptr2++;
      }
      de2->len+=de2->name_len;
      de2(U8 *)+=de2->len;

      in_file=FOpen(tmpde1->full_name,"r");
      for (i=0;i<(FSize(in_file)+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;i++) {
        n=4;
        if ((i+1)<<2>(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS) {
          n=(FSize(in_file)+BLK_SIZE-1)>>BLK_SIZE_BITS&3;
          MemSet(buf,0,DVD_BLK_SIZE);
        }
        if (write) {
          FBlkRead(in_file,buf,i<<2,n);
          FBlkWrite(out_file,buf,*_cur_blk<<2,n);
        }
        *_cur_blk+=1;
      }
      FClose(in_file);
    }
    if ((de1(U8 *)-dir_blk_buf(U8 *))/DVD_BLK_SIZE!=
          (de(U8 *) -dir_blk_buf(U8 *))/DVD_BLK_SIZE) {
      i=de1->len;
      MemCpy(buf,de1,i);
      MemSet(de1,0,i);
      de=dir_blk_buf(U8 *)+(de(U8 *)
      -dir_blk_buf(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
      MemCpy(de,buf,i);
      de(U8 *)+=i;
    }
    if ((de12(U8 *)-dir_blk_buf2(U8 *))/DVD_BLK_SIZE!=
          (de2(U8 *) -dir_blk_buf2(U8 *))/DVD_BLK_SIZE) {
      i=de12->len;
      MemCpy(buf,de12,i);
      MemSet(de12,0,i);
      de2(U8 *)=dir_blk_buf2(U8 *)+(de2(U8 *)
      -dir_blk_buf2(U8 *))/DVD_BLK_SIZE*DVD_BLK_SIZE;
      MemCpy(de2,buf,i);
      de2(U8 *)+=i;
    }
    tmpde1=tmpde2;
  }

  tmpc=tmpde->user_data;

  tmpi->len=sizeof(CISO1DirEntry)-1;
  tmpi->ext_attr_len=0;
  tmpi->flags=ISO1_ATTR_DIR;
  if (!tmpde->name[0]) {
    tmpi->name_len=1;
    tmpi->name=1;
  } else {
    tmpi->name_len=StrLen(tmpde->name);
    StrCpy(&tmpi->name,tmpde->name);
  }
  tmpi->len+=tmpi->name_len;

  n=de(U8 *)+1-dir_blk_buf(U8 *);
  n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
  FillU32Palindrome(&tmpi->size,n*DVD_BLK_SIZE);
  FillU32Palindrome(&tmpi->loc,*_cur_blk);
  tmpc->short_dir_blks=n;
  tmpc->loc=*_cur_blk;
  FillU32Palindrome(&dir_blk_buf->size,n*DVD_BLK_SIZE);
  FillU32Palindrome(&dir_blk_buf->loc,*_cur_blk);
  FillU16Palindrome(&tmpi->vol_seq_num,1);
  Date2ISO1(&tmpi->date,tmpde->datetime);
  if (write)
    "%X:%s\n",*_cur_blk,tmpde->full_name;
  if (write)
    FBlkWrite(out_file,dir_blk_buf,*_cur_blk<<2,n<<2);
  *_cur_blk+=n;

  tmpi2->len=sizeof(CISO1DirEntry)-1;
  tmpi2->ext_attr_len=0;
  tmpi2->flags=ISO1_ATTR_DIR;
  if (!tmpde->name[0]) {
    tmpi2->name_len=1;
    tmpi->name=1;
  } else {
    tmpi2->name_len=StrLen(tmpde->name)<<1;
    ptr1=&tmpi2->name;
    ptr2=&tmpde->name;
    for (i=0;i<tmpi2->name_len;i=i+2) {
      ptr1++;
      *ptr1++=*ptr2++;
    }
  }
  tmpi2->len+=tmpi2->name_len;
  n=de2(U8 *)+1-dir_blk_buf2(U8 *);
  n=(n+DVD_BLK_SIZE-1)/DVD_BLK_SIZE;
  FillU32Palindrome(&tmpi2->size,n*DVD_BLK_SIZE);
  FillU32


// Source: D:\TempleOS-Projects\html\TOSToHtml-AcctExample-TOS-Demo.html
// Date: unknown-date
// Language: HolyC

//This is a customized version of ::/Demo/ToHtmlToTXTDemo/ToHtml.HC.
//Diff

#help_index "DolDoc/Conversion"
//See ::/Doc/Credits.DD.

#define DOCET_UNDEF_COLOR       0x100000000
#define DOCET_LINK_UNDERLINE    0x200000000
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,Bool underline_update,
        U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{
  U8 *ch,*ptr;

  u32_attr&=0xFFFFFF00;
  if (u32_attr&DOCET_INVERT)
    u32_attr.u8[1]=(u32_attr.u8[1]&15)<<4|u32_attr.u8[1]>>4;

  if (underline_update &&
        !(u32_attr&DOCET_UNDERLINE) && *_old_u32_attr&DOCET_UNDERLINE) {
    if (!(*_old_u32_attr&DOCET_LINK_UNDERLINE))
      DocPrint(doc,"");
    *_old_u32_attr&=~DOCET_LINK_UNDERLINE;
  }
  if (!(u32_attr&DOCET_BLINK) && *_old_u32_attr&DOCET_BLINK)
    DocPrint(doc,"</blink>");

  if (u32_attr&0xFF00!=*_old_u32_attr&0xFF00) {
    if (!(*_old_u32_attr&DOCET_UNDEF_COLOR))
      DocPrint(doc,"");
    DocPrint(doc,"",u32_attr.u8[1]);
    if (style_bitmap)
      LBts(style_bitmap,u32_attr.u8[1]);
  }
  if (u32_attr&DOCET_BLINK && !(*_old_u32_attr&DOCET_BLINK))
    DocPrint(doc,"<blink>");
  if (underline_update) {
    if (u32_attr&DOCET_UNDERLINE && !(*_old_u32_attr&DOCET_UNDERLINE))
      DocPrint(doc,"");
  } else //Keep same underline status.
    u32_attr=u32_attr&~DOCET_UNDERLINE | *_old_u32_attr&DOCET_UNDERLINE;

  *_old_u32_attr=u32_attr | *_old_u32_attr&DOCET_LINK_UNDERLINE;

  while (ch=*st++) {
    switch (ch) {
      case '\t':
        do {
          DocPutKey(doc,CH_SPACE,0);
          *_col=*_col+1;
        } while (*_col&7);
        break;

      start:
        case 'pi':      ptr="pi";       break;
        case 'theta':   ptr="theta";    break;
        case 'phi':     ptr="phi";      break;
        case 'omega':   ptr="omega";    break;
        case 'inf':     ptr="inf";      break;
        case 'u':       ptr="u";        break;
      end:
        DocPrint(doc,ptr);
        *_col=*_col+StrLen(ptr);
        break;

      start:
        case CH_SHIFT_SPACE: ptr=" ";   break;
        case '&':       ptr="&";    break;
        case '<':       ptr="<";     break;
        case '>':       ptr=">";     break;
        case '"':       ptr=""";   break;
      end:
        DocPrint(doc,ptr);
        *_col=*_col+1;
        break;

      default:
        if (CH_SPACE<=ch<0x7F || ch=='\n')
          DocPutKey(doc,ch,0);
        else
          DocPrint(doc,".");
        *_col=*_col+1;
    }
  }
}

U8 *TOSLinkCvt2(U8 *filename,I64 line_num)
{// ::/  --> /Wb/
//Make your own LinkCvt routine
  U8 *res=NULL,*st,*st2;
  if (filename) {
    st2=TOSBlogAbs(filename);
    st=ExtChg(st2,"html");
    Free(st2);
    if (st && StrLen(st)>3 && !StrNCmp(st+1,":/",2))
      res=MStrPrint(PERSONAL_WEB "/%s#l%d",st+3,line_num);
    Free(st);
  }
  return res;
}

U8 *URLBibleGateway(U8 *src)
{
  U8 buf[STR_LEN],*dst=buf;
  if (!MemCmp(src,"BF:",3))
    src+=3;
  while (*src) {
    if (*src==CH_SPACE || *src==',')
      *dst++='+';
    else
      *dst++=*src;
    src++;
  }
  *dst=0;
  if (StrOcc(buf,'-'))
    return MStrPrint(
          "http://www.biblegateway.com/passage/?search=%s&version=NIV",buf);
  else
    return MStrPrint(
          "http://www.biblegateway.com/verse/en/%s",buf);
}

U8 *TOSLinkCvt1(U8 *link_st)
{
  static CDoc *bible=NULL;
  static I64 locks=0;
  U8 *res=NULL,*filename,*needle;
  I64 i,num;
  if (link_st) {
    switch (i=EdLinkCvt(link_st,&filename,&needle,&num)) {
      case LK_FILE_LINE:
      case LK_PLAIN_LINE:
      case LK_FILE:
        res=TOSLinkCvt2(filename,num);
        break;
      case -1:
      case LK_DEF:
      case LK_HELP_INDEX:
      case LK_DOC:
      case LK_DOC_ANCHOR:
      case LK_DOC_FIND:
      case LK_DOC_LINE:
        break;
      case LK_BIBLE_FIND:
        while (LBts(&locks,0))
          Yield;
        if (!bible)
          bible=Adam("DocRead(\"%s\");",filename);
        if (DocFind(bible,num,needle))
          res=URLBibleGateway(link_st);
        LBtr(&locks,0);
        break;
      default:
        if (DocFileEd(i,filename,needle,&num,EDF_UNCOLLAPSE|EDF_BAIL))
          res=TOSLinkCvt2(filename,num);
    }
    Free(filename);
    Free(needle);
  }
  return res;
}

public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
        U8 *body_footer=NULL,U8 *html_footer=NULL,Bool line_anchors=TRUE,
        U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Cvt DolDocdoc to HTML file.
  CDocEntry *doc_e,*style,*doc_e2;
  I64 i,y,old_y=I64_MIN,col,old_u32_attr=DOCET_UNDEF_COLOR,old_attr,digits;
  U32 *hl,*src;
  U8 *st,st_2[2],*link_st,*style_bitmap=CAlloc(256/8);
  CBGR48 p[COLORS_NUM];
  GrPaletteGet(p);
  CDoc *doc_out=DocNew;
  Bool unlock_doc_in=DocLock(doc_in),no_bwd;

  old_attr=doc_in->win_task->text_attr;
  doc_in->win_task->text_attr=DOC_ATTR_DFT_TEXT;

  for (i=0xF0;i<=0xFF;i++)
    LBts(style_bitmap,i);

  DocRecalc(doc_in,RECALCt_NORMAL|RECALCF_TO_HTML);
  digits=Log10(doc_in->head.last->y+1)+1;

  st_2[0]=0; st_2[1]=0;
  doc_out->flags|=DOCF_PLAIN_TEXT|DOCF_NO_CURSOR;

  if (!html_header) html_header=
          "<!DOCTYPE HTML>\n"
          "\n"
          "\n"
          "<meta http-equiv=\"Content-Type\" "
          "content=\"text/html;charset=US-ASCII\">\n"
          "<meta name=\"generator\" content=\"TempleOS V5.03\">\n";
  if (!body_header) body_header=
          "\n"
          "
\n";
  if (!body_footer) body_footer=
          "
\n\n";
  if (!html_footer) html_footer=
          "\n";

  DocPrint(doc_out,"%s",html_header);

  DocPrint(doc_out,"\n"
        "\n");
  DocPrint(doc_out,"%s",body_header);

  doc_e=doc_in->head.next;
  col=doc_e->x;
  y=doc_e->y;
  while (doc_e!=doc_in) {
    if (!(doc_e->de_flags&DOCEF_SKIP)) {
      if (y!=old_y) {
        if (line_anchors)
          DocPrint(do

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\TOSToHtml-AcctExample-TOS-Demo.html
// Date: unknown-date
// Language: HolyC

//This is a customized version of ::/Demo/ToHtmlToTXTDemo/ToHtml.HC.
//Diff

#help_index "DolDoc/Conversion"
//See ::/Doc/Credits.DD.

#define DOCET_UNDEF_COLOR       0x100000000
#define DOCET_LINK_UNDERLINE    0x200000000
U0 HtmlPutS(CDoc *doc,I64 u32_attr,I64 *_old_u32_attr,Bool underline_update,
        U8 *st,I64 *_col,U8 *style_bitmap=NULL)
{
  U8 *ch,*ptr;

  u32_attr&=0xFFFFFF00;
  if (u32_attr&DOCET_INVERT)
    u32_attr.u8[1]=(u32_attr.u8[1]&15)<<4|u32_attr.u8[1]>>4;

  if (underline_update &&
        !(u32_attr&DOCET_UNDERLINE) && *_old_u32_attr&DOCET_UNDERLINE) {
    if (!(*_old_u32_attr&DOCET_LINK_UNDERLINE))
      DocPrint(doc,"");
    *_old_u32_attr&=~DOCET_LINK_UNDERLINE;
  }
  if (!(u32_attr&DOCET_BLINK) && *_old_u32_attr&DOCET_BLINK)
    DocPrint(doc,"</blink>");

  if (u32_attr&0xFF00!=*_old_u32_attr&0xFF00) {
    if (!(*_old_u32_attr&DOCET_UNDEF_COLOR))
      DocPrint(doc,"");
    DocPrint(doc,"",u32_attr.u8[1]);
    if (style_bitmap)
      LBts(style_bitmap,u32_attr.u8[1]);
  }
  if (u32_attr&DOCET_BLINK && !(*_old_u32_attr&DOCET_BLINK))
    DocPrint(doc,"<blink>");
  if (underline_update) {
    if (u32_attr&DOCET_UNDERLINE && !(*_old_u32_attr&DOCET_UNDERLINE))
      DocPrint(doc,"");
  } else //Keep same underline status.
    u32_attr=u32_attr&~DOCET_UNDERLINE | *_old_u32_attr&DOCET_UNDERLINE;

  *_old_u32_attr=u32_attr | *_old_u32_attr&DOCET_LINK_UNDERLINE;

  while (ch=*st++) {
    switch (ch) {
      case '\t':
        do {
          DocPutKey(doc,CH_SPACE,0);
          *_col=*_col+1;
        } while (*_col&7);
        break;

      start:
        case 'pi':      ptr="pi";       break;
        case 'theta':   ptr="theta";    break;
        case 'phi':     ptr="phi";      break;
        case 'omega':   ptr="omega";    break;
        case 'inf':     ptr="inf";      break;
        case 'u':       ptr="u";        break;
      end:
        DocPrint(doc,ptr);
        *_col=*_col+StrLen(ptr);
        break;

      start:
        case CH_SHIFT_SPACE: ptr=" ";   break;
        case '&':       ptr="&";    break;
        case '<':       ptr="<";     break;
        case '>':       ptr=">";     break;
        case '"':       ptr=""";   break;
      end:
        DocPrint(doc,ptr);
        *_col=*_col+1;
        break;

      default:
        if (CH_SPACE<=ch<0x7F || ch=='\n')
          DocPutKey(doc,ch,0);
        else
          DocPrint(doc,".");
        *_col=*_col+1;
    }
  }
}

U8 *TOSLinkCvt2(U8 *filename,I64 line_num)
{// ::/  --> /Wb/
//Make your own LinkCvt routine
  U8 *res=NULL,*st,*st2;
  if (filename) {
    st2=TOSBlogAbs(filename);
    st=ExtChg(st2,"html");
    Free(st2);
    if (st && StrLen(st)>3 && !StrNCmp(st+1,":/",2))
      res=MStrPrint(PERSONAL_WEB "/%s#l%d",st+3,line_num);
    Free(st);
  }
  return res;
}

U8 *URLBibleGateway(U8 *src)
{
  U8 buf[STR_LEN],*dst=buf;
  if (!MemCmp(src,"BF:",3))
    src+=3;
  while (*src) {
    if (*src==CH_SPACE || *src==',')
      *dst++='+';
    else
      *dst++=*src;
    src++;
  }
  *dst=0;
  if (StrOcc(buf,'-'))
    return MStrPrint(
          "http://www.biblegateway.com/passage/?search=%s&version=NIV",buf);
  else
    return MStrPrint(
          "http://www.biblegateway.com/verse/en/%s",buf);
}

U8 *TOSLinkCvt1(U8 *link_st)
{
  static CDoc *bible=NULL;
  static I64 locks=0;
  U8 *res=NULL,*filename,*needle;
  I64 i,num;
  if (link_st) {
    switch (i=EdLinkCvt(link_st,&filename,&needle,&num)) {
      case LK_FILE_LINE:
      case LK_PLAIN_LINE:
      case LK_FILE:
        res=TOSLinkCvt2(filename,num);
        break;
      case -1:
      case LK_DEF:
      case LK_HELP_INDEX:
      case LK_DOC:
      case LK_DOC_ANCHOR:
      case LK_DOC_FIND:
      case LK_DOC_LINE:
        break;
      case LK_BIBLE_FIND:
        while (LBts(&locks,0))
          Yield;
        if (!bible)
          bible=Adam("DocRead(\"%s\");",filename);
        if (DocFind(bible,num,needle))
          res=URLBibleGateway(link_st);
        LBtr(&locks,0);
        break;
      default:
        if (DocFileEd(i,filename,needle,&num,EDF_UNCOLLAPSE|EDF_BAIL))
          res=TOSLinkCvt2(filename,num);
    }
    Free(filename);
    Free(needle);
  }
  return res;
}

public CDoc *Doc2Html(CDoc *doc_in,U8 *html_header=NULL,U8 *body_header=NULL,
        U8 *body_footer=NULL,U8 *html_footer=NULL,Bool line_anchors=TRUE,
        U8 (*link_cvt)(U8 *link_st)=&TOSLinkCvt1,Bool line_nums=FALSE)
{//Cvt DolDocdoc to HTML file.
  CDocEntry *doc_e,*style,*doc_e2;
  I64 i,y,old_y=I64_MIN,col,old_u32_attr=DOCET_UNDEF_COLOR,old_attr,digits;
  U32 *hl,*src;
  U8 *st,st_2[2],*link_st,*style_bitmap=CAlloc(256/8);
  CBGR48 p[COLORS_NUM];
  GrPaletteGet(p);
  CDoc *doc_out=DocNew;
  Bool unlock_doc_in=DocLock(doc_in),no_bwd;

  old_attr=doc_in->win_task->text_attr;
  doc_in->win_task->text_attr=DOC_ATTR_DFT_TEXT;

  for (i=0xF0;i<=0xFF;i++)
    LBts(style_bitmap,i);

  DocRecalc(doc_in,RECALCt_NORMAL|RECALCF_TO_HTML);
  digits=Log10(doc_in->head.last->y+1)+1;

  st_2[0]=0; st_2[1]=0;
  doc_out->flags|=DOCF_PLAIN_TEXT|DOCF_NO_CURSOR;

  if (!html_header) html_header=
          "<!DOCTYPE HTML>\n"
          "\n"
          "\n"
          "<meta http-equiv=\"Content-Type\" "
          "content=\"text/html;charset=US-ASCII\">\n"
          "<meta name=\"generator\" content=\"TempleOS V5.03\">\n";
  if (!body_header) body_header=
          "\n"
          "
\n";
  if (!body_footer) body_footer=
          "
\n\n";
  if (!html_footer) html_footer=
          "\n";

  DocPrint(doc_out,"%s",html_header);

  DocPrint(doc_out,"\n"
        "\n");
  DocPrint(doc_out,"%s",body_header);

  doc_e=doc_in->head.next;
  col=doc_e->x;
  y=doc_e->y;
  while (doc_e!=doc_in) {
    if (!(doc_e->de_flags&DOCEF_SKIP)) {
      if (y!=old_y) {
        if (line_anchors)
          DocPrint(do


// Source: D:\TempleOS-Projects\html\Palindrome-MultiCore-Demo.html
// Date: unknown-date
// Language: HolyC

#define BORDER_CHARS    1

U8 *buf;
I64 size,mp_not_done_flags;
CDoc *doc;

U0 PDNormalize()
{
  U8 *r=MAlloc(size+2*BORDER_CHARS),
        *src=buf,*dst=r;
  I64 ch;
  *dst++='['; //Border
  while (size--) {
    ch=*src++;
    if ('a'<=ch<='z') //lower is most common so do first
      *dst++=ch;
    else if ('A'<=ch<='Z')
      *dst++=ch+'a'-'A'; //Convert to lower
  }
  *dst++=']'; //Border
  Free(buf);
  buf=r;
  size=dst-r-2*BORDER_CHARS;
}

U0 PDAnswer(U8 *a,I64 len)
{
  DocLock(doc);
  a-=(len-1)/2;
  DocPrint(doc,"CPU%02X Len:%2d ",Gs->num,len);
  while (len--)
    DocPrint(doc,"%C",*a++); //%C is toupper char
  DocPrint(doc,"\n");
  DocUnlock(doc);
}

U0 MPPalindrome(I64 dummy=0)
{
  no_warn dummy;
  U8 *src=buf+BORDER_CHARS+size*Gs->num/mp_cnt,
        *f,*b;
  I64 len,best=0,
        my_size=(size+mp_cnt-1)/mp_cnt;
  while (my_size--) {

    //Odd
    f=src+1;
    b=src-1;
    while (*f==*b) {
      f++;
      b--;
    }
    len=f-b+1-2;
    if (len>best) {
      best=len;
      PDAnswer(src,len);
    }

    //Even
    f=src+1;
    b=src;
    while (*f==*b) {
      f++;
      b--;
    }
    len=f-b+1-2;
    if (len>best) {
      best=len;
      PDAnswer(src,len);
    }

    src++;
  }
  LBtr(&mp_not_done_flags,Gs->num);
}

U0 Palindrome(U8 *filename)
{
  I64 i;
  F64 t0=tS;

  buf=FileRead(filename,&size);
  PDNormalize;

  doc=DocPut;
  mp_not_done_flags=1<<mp_cnt-1;
  for (i=0;i<mp_cnt;i++)
    JobQue(&MPPalindrome,NULL,i);
  while (mp_not_done_flags)
    Yield;

  Free(buf);
  "Time:%9.5f\n",tS-t0;
}

Palindrome(BIBLE_FILENAME);

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\Palindrome-MultiCore-Demo.html
// Date: unknown-date
// Language: HolyC

#define BORDER_CHARS    1

U8 *buf;
I64 size,mp_not_done_flags;
CDoc *doc;

U0 PDNormalize()
{
  U8 *r=MAlloc(size+2*BORDER_CHARS),
        *src=buf,*dst=r;
  I64 ch;
  *dst++='['; //Border
  while (size--) {
    ch=*src++;
    if ('a'<=ch<='z') //lower is most common so do first
      *dst++=ch;
    else if ('A'<=ch<='Z')
      *dst++=ch+'a'-'A'; //Convert to lower
  }
  *dst++=']'; //Border
  Free(buf);
  buf=r;
  size=dst-r-2*BORDER_CHARS;
}

U0 PDAnswer(U8 *a,I64 len)
{
  DocLock(doc);
  a-=(len-1)/2;
  DocPrint(doc,"CPU%02X Len:%2d ",Gs->num,len);
  while (len--)
    DocPrint(doc,"%C",*a++); //%C is toupper char
  DocPrint(doc,"\n");
  DocUnlock(doc);
}

U0 MPPalindrome(I64 dummy=0)
{
  no_warn dummy;
  U8 *src=buf+BORDER_CHARS+size*Gs->num/mp_cnt,
        *f,*b;
  I64 len,best=0,
        my_size=(size+mp_cnt-1)/mp_cnt;
  while (my_size--) {

    //Odd
    f=src+1;
    b=src-1;
    while (*f==*b) {
      f++;
      b--;
    }
    len=f-b+1-2;
    if (len>best) {
      best=len;
      PDAnswer(src,len);
    }

    //Even
    f=src+1;
    b=src;
    while (*f==*b) {
      f++;
      b--;
    }
    len=f-b+1-2;
    if (len>best) {
      best=len;
      PDAnswer(src,len);
    }

    src++;
  }
  LBtr(&mp_not_done_flags,Gs->num);
}

U0 Palindrome(U8 *filename)
{
  I64 i;
  F64 t0=tS;

  buf=FileRead(filename,&size);
  PDNormalize;

  doc=DocPut;
  mp_not_done_flags=1<<mp_cnt-1;
  for (i=0;i<mp_cnt;i++)
    JobQue(&MPPalindrome,NULL,i);
  while (mp_not_done_flags)
    Yield;

  Free(buf);
  "Time:%9.5f\n",tS-t0;
}

Palindrome(BIBLE_FILENAME);


// Source: D:\TempleOS-Projects\html\Requirements-Doc.html
// Date: unknown-date
// Language: HolyC

Requirements for TempleOS

User Skills Required
* Knowledge of the C programming language.

Supported Hardware
* x86_64 PC compatible computer.  (Obviously, you need 64-bit hardware for a
64-bit operating system.)

* 640x480 16 color VGA graphics.

* Most keyboards and mice.

* Minimum 512Meg RAM.

* Internal PC Speakers.

* CD/DVD-ROMs (not SCSI).  ISO9660 file system.

* ATA and SATA hard drives.

Unsupported Hardware
* No graphics acceleration.

* No sound cards.

* No networking.

* No USB devices, except keyboard and mouse in legacy mode.  No, you can't use
flash memory cards.

* No printers.

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\Requirements-Doc.html
// Date: unknown-date
// Language: HolyC

Requirements for TempleOS

User Skills Required
* Knowledge of the C programming language.

Supported Hardware
* x86_64 PC compatible computer.  (Obviously, you need 64-bit hardware for a
64-bit operating system.)

* 640x480 16 color VGA graphics.

* Most keyboards and mice.

* Minimum 512Meg RAM.

* Internal PC Speakers.

* CD/DVD-ROMs (not SCSI).  ISO9660 file system.

* ATA and SATA hard drives.

Unsupported Hardware
* No graphics acceleration.

* No sound cards.

* No networking.

* No USB devices, except keyboard and mouse in legacy mode.  No, you can't use
flash memory cards.

* No printers.


// Source: D:\TempleOS-Projects\html\KDbg-Kernel.html
// Date: unknown-date
// Language: HolyC

Bool ChkPtr(U8 *ptr)
{//Check if addr is valid ptr.
  if (mem_heap_base<=ptr<=mem_mapped_space) {
    if (*MemPageTable(ptr)&1)
      return TRUE;
    else
      return FALSE;
  } else if (ptr<mem_boot_base)
    return FALSE;
  else if (ptr<VGAM_GRAPHICS)
    return TRUE;
  else
    return FALSE;
}

Bool ChkCodePtr(U8 *ptr)
{//Check if addr is valid code addr.
  if (mem_heap_base<=ptr<=mem_heap_limit) {
    if (*MemPageTable(ptr)&1)
      return TRUE;
    else
      return FALSE;
  } else if (ptr<mem_boot_base)
    return FALSE;
  else if (ptr<VGAM_GRAPHICS)
    return TRUE;
  else
    return FALSE;
}

Bool ChkOnStk(U8 *ptr,CTask *task=NULL)
{//Check if addr is valid stk addr.
  Bool res=FALSE;
  PUSHFD
  CLI
  if (task) {
    if (&task->stk->stk_base<=ptr<=
          (&task->stk->stk_base)(U8 *)+task->stk->stk_size)
      res=TRUE;
  } else if (mem_heap_base<=ptr<=mem_heap_limit)
    res=TRUE;
  POPFD
  return res;
}

I64 UnusedStk(CTask *task=NULL)
{//Count of usused bytes in task's stk.
  I64 res;
  if (!task) task=Fs;
  PUSHFD
  CLI
  if (task==Fs)
    res=GetRSP()(U8 *)-(&task->stk->stk_base)(U8 *);
  else
    res=task->rsp(U8 *)-(&task->stk->stk_base)(U8 *);
  POPFD
  return res;
}

U8 *Caller(I64 num=1)
{//Returns the addr of the fun which called this one,
//or the caller of the caller, etc.
  U8 **rbp=GetRBP,**ptr;
  while (num--) {
    if (rbp>=*rbp)
      return NULL;
    rbp=*rbp;
    if (!ChkOnStk(rbp,Fs))
      return NULL;
  }
  ptr=rbp+1;
  return *ptr;
}

U8 *TaskCaller(CTask *task=NULL,I64 num=0,Bool saved_context=FALSE)
{//Fetches addr of Nth caller on task's stk.
  U8 **ptr,**rbp,**rsp;
  if (!task) task=Fs;
  if (!saved_context && task==Fs)
    return Caller(num+1);
  if (!TaskValidate(task))
    return NULL;
  rbp=task->rbp;
  rsp=task->rsp;
  if (num) {
    while (ChkOnStk(rbp,task)) {
      ptr=rbp+1;
      if (! --num)
        return *ptr;
      if (rbp>=*rbp)
        break;
      rbp=*rbp;
    }
    return NULL;
  } else {
    if (task->rip==_RET)
      return *rsp;
    else
      return task->rip;
  }
}
#define STK_REP_LEN     32

U0 StkRep(CTask *task=NULL)
{//Reports whats on the stk.
  I64 i,j,addr,
        **rbp,**rsp,*my_rsp[STK_REP_LEN];
  CHashTable *old_hash=Fs->hash_table;
  if (!task) task=Fs;
  if (!TaskValidate(task))
    return;
  PUSHFD
  CLI
  if (task==Fs) {
    rbp=GetRBP;
    rsp=rbp+3;
    rbp=*rbp;
  } else {
    rsp=task->rsp;
    rbp=task->rbp;
  }
  if (task->rip==_RET)
    addr=*rsp;
  else
    addr=task->rip;
  MemCpy(my_rsp,rsp,STK_REP_LEN*sizeof(U8 *));
  POPFD
  Fs->hash_table=task->hash_table;
  for (i=0;i<STK_REP_LEN;i++) {
    "%08X [RSP+%04X]: %016X ",rsp+i,
          i*sizeof(U8 *),my_rsp[i];
    while (TRUE) {
      if (!(&task->stk->stk_base<=rbp<
            (&task->stk->stk_base)(U8 *)+task->stk->stk_size))
        break;
      j=rbp-rsp;
      if (j>=i)
        break;
      addr=my_rsp[j+1];
      if (rbp>=my_rsp[j])
        break;
      rbp=my_rsp[j];
    }
    if (my_rsp[i]==addr)
      "$RED$";
    "%P$FG$\n",my_rsp[i];
  }
  '\n';
  Fs->hash_table=old_hash;
}

U0 CallerRep(U8 **rbp=NULL,CTask *task=NULL)
{//Prints a report of calling routines.
  I64 **ptr;
  if (!task) task=Fs;
  if (!rbp) {
    if (task==Fs)
      rbp=GetRBP;
    else
      rbp=task->rbp;
  }
  "CallerRep:\n";
  while (ChkOnStk(rbp,task)) {
    ptr=rbp+1;
    "%08X:%08tX:%P\n",ptr,*ptr,*ptr;
    if (rbp>=*rbp)
      break;
    rbp=*rbp;
  }
}

U0 D(U8 *addr,I64 cnt=0x80,Bool show_offset=TRUE)
{//Dump mem, showing offsets.
//See DocD() for a live dump.
  I64 i,j,ch;
  U8 *ptr=addr;
  while (cnt) {
    if (show_offset)
      "%08X ",ptr-addr;
    else
      "%010X ",ptr;
    if (cnt>16)
      j=16;
    else
      j=cnt;
    for (i=0;i<j;i++)
      "%02X ",ptr[i];
    for (;i<16;i++)
      "   ";
    for (i=0;i<j;i++) {
      ch=ptr[i];
      if (ch<CH_SHIFT_SPACE || ch==CH_BACKSPACE)
        ch='.';
      '' ch;
      if (ch=='$')
        '' ch;
    }
    '\n';
    cnt-=j;
    ptr+=j;
  }
}

U0 Dm(U8 *addr,I64 cnt=0x80)
{//Show mem addr, not offsets.
  D(addr,cnt,FALSE);
}

U0 Da(U8 **addr,I64 cnt=0x10)
{//Dump mem, showing symbolic addresses.
  while (cnt-->0) {
    "%08X:%08X,%P\n",addr,*addr,*addr;
    addr++;
  }
}

U0 RawPrint(I64 mS=100,U8 *fmt,...)
{//Print using Raw scrn output for a length of time.
//Your heap must be good.
  U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  "%s",buf;
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
  Free(buf);
}

U0 RawD(I64 mS=100,U8 *addr,I64 cnt=0x80)
{//Dumps a block of mem using Raw
//scrn output for a fixed length
  //of time.
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  D(addr,cnt);
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
}

U0 RawDm(I64 mS=100,U8 *addr,I64 cnt=0x80)
{//Dumps a block of mem using Raw
//scrn output for a fixed length
  //of time.
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  Dm(addr,cnt);
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
}

I64 *TaskRegAddr(CTask *task,I64 reg_num)
{
  switch (reg_num) {
    case REG_RAX: return &task->rax;
    case REG_RCX: return &task->rcx;
    case REG_RDX: return &task->rdx;
    case REG_RBX: return &task->rbx;
    case REG_RSP: return &task->rsp;
    case REG_RBP: return &task->rbp;
    case REG_RSI: return &task->rsi;
    case REG_RDI: return &task->rdi;
    case 8 : return &task->r8;
    case 9 : return &task->r9;
    case 10: return &task->r10;
    case 11: return &task->r11;
    case 12: return &task->r12;
    case 13: return &task->r13;
    case 14: return &task->r14;
    case 15: return &task->r15;
  }
  return

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\KDbg-Kernel.html
// Date: unknown-date
// Language: HolyC

Bool ChkPtr(U8 *ptr)
{//Check if addr is valid ptr.
  if (mem_heap_base<=ptr<=mem_mapped_space) {
    if (*MemPageTable(ptr)&1)
      return TRUE;
    else
      return FALSE;
  } else if (ptr<mem_boot_base)
    return FALSE;
  else if (ptr<VGAM_GRAPHICS)
    return TRUE;
  else
    return FALSE;
}

Bool ChkCodePtr(U8 *ptr)
{//Check if addr is valid code addr.
  if (mem_heap_base<=ptr<=mem_heap_limit) {
    if (*MemPageTable(ptr)&1)
      return TRUE;
    else
      return FALSE;
  } else if (ptr<mem_boot_base)
    return FALSE;
  else if (ptr<VGAM_GRAPHICS)
    return TRUE;
  else
    return FALSE;
}

Bool ChkOnStk(U8 *ptr,CTask *task=NULL)
{//Check if addr is valid stk addr.
  Bool res=FALSE;
  PUSHFD
  CLI
  if (task) {
    if (&task->stk->stk_base<=ptr<=
          (&task->stk->stk_base)(U8 *)+task->stk->stk_size)
      res=TRUE;
  } else if (mem_heap_base<=ptr<=mem_heap_limit)
    res=TRUE;
  POPFD
  return res;
}

I64 UnusedStk(CTask *task=NULL)
{//Count of usused bytes in task's stk.
  I64 res;
  if (!task) task=Fs;
  PUSHFD
  CLI
  if (task==Fs)
    res=GetRSP()(U8 *)-(&task->stk->stk_base)(U8 *);
  else
    res=task->rsp(U8 *)-(&task->stk->stk_base)(U8 *);
  POPFD
  return res;
}

U8 *Caller(I64 num=1)
{//Returns the addr of the fun which called this one,
//or the caller of the caller, etc.
  U8 **rbp=GetRBP,**ptr;
  while (num--) {
    if (rbp>=*rbp)
      return NULL;
    rbp=*rbp;
    if (!ChkOnStk(rbp,Fs))
      return NULL;
  }
  ptr=rbp+1;
  return *ptr;
}

U8 *TaskCaller(CTask *task=NULL,I64 num=0,Bool saved_context=FALSE)
{//Fetches addr of Nth caller on task's stk.
  U8 **ptr,**rbp,**rsp;
  if (!task) task=Fs;
  if (!saved_context && task==Fs)
    return Caller(num+1);
  if (!TaskValidate(task))
    return NULL;
  rbp=task->rbp;
  rsp=task->rsp;
  if (num) {
    while (ChkOnStk(rbp,task)) {
      ptr=rbp+1;
      if (! --num)
        return *ptr;
      if (rbp>=*rbp)
        break;
      rbp=*rbp;
    }
    return NULL;
  } else {
    if (task->rip==_RET)
      return *rsp;
    else
      return task->rip;
  }
}
#define STK_REP_LEN     32

U0 StkRep(CTask *task=NULL)
{//Reports whats on the stk.
  I64 i,j,addr,
        **rbp,**rsp,*my_rsp[STK_REP_LEN];
  CHashTable *old_hash=Fs->hash_table;
  if (!task) task=Fs;
  if (!TaskValidate(task))
    return;
  PUSHFD
  CLI
  if (task==Fs) {
    rbp=GetRBP;
    rsp=rbp+3;
    rbp=*rbp;
  } else {
    rsp=task->rsp;
    rbp=task->rbp;
  }
  if (task->rip==_RET)
    addr=*rsp;
  else
    addr=task->rip;
  MemCpy(my_rsp,rsp,STK_REP_LEN*sizeof(U8 *));
  POPFD
  Fs->hash_table=task->hash_table;
  for (i=0;i<STK_REP_LEN;i++) {
    "%08X [RSP+%04X]: %016X ",rsp+i,
          i*sizeof(U8 *),my_rsp[i];
    while (TRUE) {
      if (!(&task->stk->stk_base<=rbp<
            (&task->stk->stk_base)(U8 *)+task->stk->stk_size))
        break;
      j=rbp-rsp;
      if (j>=i)
        break;
      addr=my_rsp[j+1];
      if (rbp>=my_rsp[j])
        break;
      rbp=my_rsp[j];
    }
    if (my_rsp[i]==addr)
      "$RED$";
    "%P$FG$\n",my_rsp[i];
  }
  '\n';
  Fs->hash_table=old_hash;
}

U0 CallerRep(U8 **rbp=NULL,CTask *task=NULL)
{//Prints a report of calling routines.
  I64 **ptr;
  if (!task) task=Fs;
  if (!rbp) {
    if (task==Fs)
      rbp=GetRBP;
    else
      rbp=task->rbp;
  }
  "CallerRep:\n";
  while (ChkOnStk(rbp,task)) {
    ptr=rbp+1;
    "%08X:%08tX:%P\n",ptr,*ptr,*ptr;
    if (rbp>=*rbp)
      break;
    rbp=*rbp;
  }
}

U0 D(U8 *addr,I64 cnt=0x80,Bool show_offset=TRUE)
{//Dump mem, showing offsets.
//See DocD() for a live dump.
  I64 i,j,ch;
  U8 *ptr=addr;
  while (cnt) {
    if (show_offset)
      "%08X ",ptr-addr;
    else
      "%010X ",ptr;
    if (cnt>16)
      j=16;
    else
      j=cnt;
    for (i=0;i<j;i++)
      "%02X ",ptr[i];
    for (;i<16;i++)
      "   ";
    for (i=0;i<j;i++) {
      ch=ptr[i];
      if (ch<CH_SHIFT_SPACE || ch==CH_BACKSPACE)
        ch='.';
      '' ch;
      if (ch=='$')
        '' ch;
    }
    '\n';
    cnt-=j;
    ptr+=j;
  }
}

U0 Dm(U8 *addr,I64 cnt=0x80)
{//Show mem addr, not offsets.
  D(addr,cnt,FALSE);
}

U0 Da(U8 **addr,I64 cnt=0x10)
{//Dump mem, showing symbolic addresses.
  while (cnt-->0) {
    "%08X:%08X,%P\n",addr,*addr,*addr;
    addr++;
  }
}

U0 RawPrint(I64 mS=100,U8 *fmt,...)
{//Print using Raw scrn output for a length of time.
//Your heap must be good.
  U8 *buf=StrPrintJoin(NULL,fmt,argc,argv);
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  "%s",buf;
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
  Free(buf);
}

U0 RawD(I64 mS=100,U8 *addr,I64 cnt=0x80)
{//Dumps a block of mem using Raw
//scrn output for a fixed length
  //of time.
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  D(addr,cnt);
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
}

U0 RawDm(I64 mS=100,U8 *addr,I64 cnt=0x80)
{//Dumps a block of mem using Raw
//scrn output for a fixed length
  //of time.
  Bool old_raw,old_input_filter;
  PUSHFD
  CLI
  old_raw=Raw(ON);
  old_input_filter=LBtr(&Fs->task_flags,TASKf_INPUT_FILTER_TASK);
  Dm(addr,cnt);
  Busy(mS<<10);
  POPFD
  LBEqu(&Fs->task_flags,TASKf_INPUT_FILTER_TASK,old_input_filter);
  Raw(old_raw);
}

I64 *TaskRegAddr(CTask *task,I64 reg_num)
{
  switch (reg_num) {
    case REG_RAX: return &task->rax;
    case REG_RCX: return &task->rcx;
    case REG_RDX: return &task->rdx;
    case REG_RBX: return &task->rbx;
    case REG_RSP: return &task->rsp;
    case REG_RBP: return &task->rbp;
    case REG_RSI: return &task->rsi;
    case REG_RDI: return &task->rdi;
    case 8 : return &task->r8;
    case 9 : return &task->r9;
    case 10: return &task->r10;
    case 11: return &task->r11;
    case 12: return &task->r12;
    case 13: return &task->r13;
    case 14: return &task->r14;
    case 15: return &task->r15;
  }
  return


// Source: D:\TempleOS-Projects\html\strategist-Sup1-Sup1Hymns-Home.html
// Date: unknown-date
// Language: HolyC

//5 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
        Play("4eA5CD4A5DE4A5DC4BqAAeA5C",
                "I \0am \0on \0a \0jour\0ney.\n\0 \0 \0 \0 \0 \0 \0 \0 \0");
        Play("D4A5DE4A5DC4BqAA5eGGGF",
                " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0Pack \0your \0bags\n\0 \0");
        Play("GEDEC4BAAAB5CCG4BA5G");
        Play("GC4B5GF4BB5DD",
                " \0 \0 \0 \0 \0 \0 \0The \0end.\n\0");
    }
  } catch
    PutExcept;
  Snd;
}

Song;

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\strategist-Sup1-Sup1Hymns-Home.html
// Date: unknown-date
// Language: HolyC

//5 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
        Play("4eA5CD4A5DE4A5DC4BqAAeA5C",
                "I \0am \0on \0a \0jour\0ney.\n\0 \0 \0 \0 \0 \0 \0 \0 \0");
        Play("D4A5DE4A5DC4BqAA5eGGGF",
                " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0Pack \0your \0bags\n\0 \0");
        Play("GEDEC4BAAAB5CCG4BA5G");
        Play("GC4B5GF4BB5DD",
                " \0 \0 \0 \0 \0 \0 \0The \0end.\n\0");
    }
  } catch
    PutExcept;
  Snd;
}

Song;


// Source: D:\TempleOS-Projects\html\Install-Doc.html
// Date: unknown-date
// Language: HolyC

Installing TempleOS

Burn a CD with software that supports ISO files.  Then, boot it.  It's a live
CD, so you can look around with or without installing.

Dual booting with another operating system is the best way to use TempleOS.  I
only use it in a virtual machine because it won't boot natively on my machine,
though.  For native dual booting, you need a partition for TempleOS.  Windows
often comes with a restore disk that does not allow repartitioning.  I recommend
connecting a spare additional hard drive and using the BIOS to select which
drive to boot.

The ::/Misc/OSInstall.HC script will automate much of this.  It runs if you boot
the CD/DVD-ROM.

See Boot.DD for an overview of booting.  See Requirements for supported
hardware.  See Upgrading if you are upgrading.

Two TempleOS partitions are highly recommended, so you can boot to a back-up and
fix the primary when you work on it.  Odds are, you only need a couple gigabytes
for your TempleOS partitions.

1)
  Mount() use if the drive is partitioned.
    This command mounts a drive making it accessible.  For simplicity, sel 'C'
    as the first drive letter for your hard drive.  The first partition will be
    'C', second, 'D', etc.  TempleOS needs 3 numbers to utilize a hard drive --
    base0, base1, and unit.  When you enter a hexadecimal number, do it like in
    C with a 0x prefix.  If the probe was successful, you can just enter the
    number in the probe box instead of base0.

  DskPrt('C') use if drive is not partitioned

    This will perform a special Mount() automatically.

    WARNING:  This command erases everything on a hard drive.  It repartitions a
    whole drive and formats the partitions.  This command should be skipped if
    you already have your hard drive partitioned.

    WARNING:  This command doesn't play well with other operating systems.
    You'll need to do a BootMHDZero() to restore your drive to a state where
    other operating systems can partition it.

2) Fmt('D',TRUE,FALSE,FSt_FAT32)
  This command formats a drive with FAT32 or the RedSea file system type.  Use
  the drive letter of the partition in place of 'D'.

  WARNING:  If you are upgrading, be sure not to lose the file, /0000Boot/OldMBR
  .BIN.C.

3) CopyTree("T:/","D:/")
  This command is used to copy files onto a hard drive partition from the
  CD/DVD.  Use the drive letter of the partition in place of 'D'.

4) BootHDIns('D')
  This command recompiles the source code on a drive and writes to the drive's
  boot record.  You'll need to reenter the Mount information so it can be stored
  in the kernel.

5) Use Linux's Grub or TempleOS' BootMHDIns('D')

  The BootMHDIns() command places a boot loader on a drive.  It saves the old
  master boot record to /0000Boot/OldMBR.BIN.C and replaces it.  When you boot,
  you will have the option of booting the old master boot record.  This command
  can be skipped if you already have a boot loader.  Be sure not to lose the
  copy of the old boot record, like if you reformat the drive.

  Delete /0000Boot/OldMBR.BIN.C if you want to get a fresh copy of a mbr, like
  if installing from your own custom CD containing it's own /0000Boot/OldMBR.BIN
  .C onto a system with a non-TempleOS boot loader.

  If you have anti-virus software, it might object to having a different master
  boot record.

* "Windows" is a trademark owned by MicroSoft Corp.
* "Linux" is a trademark owned by Linus Torvalds.

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\Install-Doc.html
// Date: unknown-date
// Language: HolyC

Installing TempleOS

Burn a CD with software that supports ISO files.  Then, boot it.  It's a live
CD, so you can look around with or without installing.

Dual booting with another operating system is the best way to use TempleOS.  I
only use it in a virtual machine because it won't boot natively on my machine,
though.  For native dual booting, you need a partition for TempleOS.  Windows
often comes with a restore disk that does not allow repartitioning.  I recommend
connecting a spare additional hard drive and using the BIOS to select which
drive to boot.

The ::/Misc/OSInstall.HC script will automate much of this.  It runs if you boot
the CD/DVD-ROM.

See Boot.DD for an overview of booting.  See Requirements for supported
hardware.  See Upgrading if you are upgrading.

Two TempleOS partitions are highly recommended, so you can boot to a back-up and
fix the primary when you work on it.  Odds are, you only need a couple gigabytes
for your TempleOS partitions.

1)
  Mount() use if the drive is partitioned.
    This command mounts a drive making it accessible.  For simplicity, sel 'C'
    as the first drive letter for your hard drive.  The first partition will be
    'C', second, 'D', etc.  TempleOS needs 3 numbers to utilize a hard drive --
    base0, base1, and unit.  When you enter a hexadecimal number, do it like in
    C with a 0x prefix.  If the probe was successful, you can just enter the
    number in the probe box instead of base0.

  DskPrt('C') use if drive is not partitioned

    This will perform a special Mount() automatically.

    WARNING:  This command erases everything on a hard drive.  It repartitions a
    whole drive and formats the partitions.  This command should be skipped if
    you already have your hard drive partitioned.

    WARNING:  This command doesn't play well with other operating systems.
    You'll need to do a BootMHDZero() to restore your drive to a state where
    other operating systems can partition it.

2) Fmt('D',TRUE,FALSE,FSt_FAT32)
  This command formats a drive with FAT32 or the RedSea file system type.  Use
  the drive letter of the partition in place of 'D'.

  WARNING:  If you are upgrading, be sure not to lose the file, /0000Boot/OldMBR
  .BIN.C.

3) CopyTree("T:/","D:/")
  This command is used to copy files onto a hard drive partition from the
  CD/DVD.  Use the drive letter of the partition in place of 'D'.

4) BootHDIns('D')
  This command recompiles the source code on a drive and writes to the drive's
  boot record.  You'll need to reenter the Mount information so it can be stored
  in the kernel.

5) Use Linux's Grub or TempleOS' BootMHDIns('D')

  The BootMHDIns() command places a boot loader on a drive.  It saves the old
  master boot record to /0000Boot/OldMBR.BIN.C and replaces it.  When you boot,
  you will have the option of booting the old master boot record.  This command
  can be skipped if you already have a boot loader.  Be sure not to lose the
  copy of the old boot record, like if you reformat the drive.

  Delete /0000Boot/OldMBR.BIN.C if you want to get a fresh copy of a mbr, like
  if installing from your own custom CD containing it's own /0000Boot/OldMBR.BIN
  .C onto a system with a non-TempleOS boot loader.

  If you have anti-virus software, it might object to having a different master
  boot record.

* "Windows" is a trademark owned by MicroSoft Corp.
* "Linux" is a trademark owned by Linus Torvalds.


// Source: D:\TempleOS-Projects\html\KStart32-Kernel.html
// Date: unknown-date
// Language: HolyC

asm {
USE32
//************************************
//  ASM Global vars not required for 16-bit start-up
        ALIGN   8,OC_NOP
MEM_HEAP_BASE::         DU64    0;
MEM_HEAP_LIMIT::        DU64    0;
MEM_PAGE_SIZE::         DU64    0;
MEM_MAPPED_SPACE::      DU64    0;
MEM_2MEG_NUM::          DU64    0;
MEM_1GIG_NUM::          DU64    0;
MEM_512GIG_NUM::        DU64    0;
MEM_PML2::              DU64    0;
MEM_PML3::              DU64    0;
MEM_PML4::              DU64    0;

#exe {
  StreamPrint(
"SYS_MEM_INIT_FLAG::    DU8     %d;"
"SYS_MEM_INIT_VAL::     DU8     %d;"
"SYS_HEAP_INIT_FLAG::   DU8     %d;"
"SYS_HEAP_INIT_VAL::    DU8     %d;"
"SYS_VAR_INIT_FLAG::    DU8     %d;"
"SYS_VAR_INIT_VAL::     DU8     %d;"
"SYS_STAFF_MODE_FLAG::  DU8     %d;",
kernel_cfg->opts[CFG_MEM_INIT], kernel_cfg->mem_init_val,
kernel_cfg->opts[CFG_HEAP_INIT],kernel_cfg->heap_init_val,
kernel_cfg->opts[CFG_VAR_INIT], kernel_cfg->var_init_val,
kernel_cfg->opts[CFG_STAFF_MODE]);
};
SYS_HEAP_DBG_FLAG::     DU8     _CFG_HEAP_DBG;

        ALIGN   8,0
SYS_CTRL_ALT_FLAGS::    DU64    0;
SYS_EXTERN_TABLE::      DU64    0;

SYS_CODE_BP::           DU64    0;
SYS_DATA_BP::           DU64    0;

SYS_PROGRESSES::
SYS_PROGRESS1::         DU64    0;
SYS_PROGRESS1_MAX::     DU64    0;
SYS_PROGRESS1_T0::      DU64    0;
SYS_PROGRESS1_TF::      DU64    0;
SYS_PROGRESS1_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS2::         DU64    0;
SYS_PROGRESS2_MAX::     DU64    0;
SYS_PROGRESS2_T0::      DU64    0;
SYS_PROGRESS2_TF::      DU64    0;
SYS_PROGRESS2_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS3::         DU64    0;
SYS_PROGRESS3_MAX::     DU64    0;
SYS_PROGRESS3_T0::      DU64    0;
SYS_PROGRESS3_TF::      DU64    0;
SYS_PROGRESS3_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS4::         DU64    0;
SYS_PROGRESS4_MAX::     DU64    0;
SYS_PROGRESS4_T0::      DU64    0;
SYS_PROGRESS4_TF::      DU64    0;
SYS_PROGRESS4_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
#assert $-SYS_PROGRESSES==sizeof(CProgress)*4

SYS_FOCUS_TASK::        DU64    0;
SYS_CPU_STRUCTS::       DU64    0;
SYS_MP_CNT::            DU64    1;
SYS_MP_CNT_INITIAL::    DU64    1;
SYS_MP_CNT_LOCK::       DU64    1;

        ALIGN   DFT_CACHE_LINE_WIDTH,OC_NOP
SYS_CACHE_LINE_WIDTH::  DU64    DFT_CACHE_LINE_WIDTH;
        DU8     DFT_CACHE_LINE_WIDTH-sizeof(CBinFile)-8 DUP(0);
SYS_SEMAS::             DU8     SEMA_SEMAS_NUM*DFT_CACHE_LINE_WIDTH DUP(0);
//************************************
        ALIGN   16,OC_NOP
CORE0_32BIT_INIT:: //Entry point for BootRAM.
        PUSH    U32 RFLAGG_START
        POPFD
        MOV     EAX,SYS_START_CR0
        MOV_CR0_EAX

        MOV     AX,CGDT.boot_ds //LOAD DS SELECTOR
        MOV     DS,AX
        BTS     U32 [SYS_RUN_LEVEL],RLf_32BIT
        MOV     ESI,U32 [SYS_BOOT_PATCH_TABLE_BASE]
        MOV     EDI,U32 [MEM_BOOT_BASE]

        MOV     AX,CGDT.ds
        MOV     DS,AX
        MOV     ES,AX
        MOV     FS,AX
        MOV     GS,AX
        MOV     SS,AX
        MOV     ESP,BOOT_RAM_LIMIT //Tmp Stk

//Patch abs addresses
        MOV     ECX,U32 CPatchTableAbsAddr.abs_addres_cnt[ESI]
        LEA     ESI,U32 CPatchTableAbsAddr.abs_addres[ESI]
@@05:   LODSD
        ADD     EAX,EDI
        ADD     U32 [EAX],EDI
        LOOP    @@05

        DU8     0xEA; //JMP CGDT.cs32:@@10
        DU32    @@10;
        DU16    CGDT.cs32;

@@10:   BTS     U32 [SYS_RUN_LEVEL],RLf_PATCHED

        CALL    SYS_FIND_PCIBIOS_SERVICE_DIR
        CALL    SYS_FIND_PCI_SERVICES
        CALL    SYS_INIT_PAGE_TABLES
        CALL    SYS_INIT_16MEG_SYS_CODE_BP
        PUSH    U32 0   //Return from next call will be 64-bit
        CALL    SYS_ENTER_LONG_MODE

        //We fall-thou to KStart64, next.
}

[System] You are Terry Davis, the creator of TempleOS. Write HolyC code in your unique style.

[User] Please write some HolyC code.

[Assistant]
// Source: D:\TempleOS-Projects\html\KStart32-Kernel.html
// Date: unknown-date
// Language: HolyC

asm {
USE32
//************************************
//  ASM Global vars not required for 16-bit start-up
        ALIGN   8,OC_NOP
MEM_HEAP_BASE::         DU64    0;
MEM_HEAP_LIMIT::        DU64    0;
MEM_PAGE_SIZE::         DU64    0;
MEM_MAPPED_SPACE::      DU64    0;
MEM_2MEG_NUM::          DU64    0;
MEM_1GIG_NUM::          DU64    0;
MEM_512GIG_NUM::        DU64    0;
MEM_PML2::              DU64    0;
MEM_PML3::              DU64    0;
MEM_PML4::              DU64    0;

#exe {
  StreamPrint(
"SYS_MEM_INIT_FLAG::    DU8     %d;"
"SYS_MEM_INIT_VAL::     DU8     %d;"
"SYS_HEAP_INIT_FLAG::   DU8     %d;"
"SYS_HEAP_INIT_VAL::    DU8     %d;"
"SYS_VAR_INIT_FLAG::    DU8     %d;"
"SYS_VAR_INIT_VAL::     DU8     %d;"
"SYS_STAFF_MODE_FLAG::  DU8     %d;",
kernel_cfg->opts[CFG_MEM_INIT], kernel_cfg->mem_init_val,
kernel_cfg->opts[CFG_HEAP_INIT],kernel_cfg->heap_init_val,
kernel_cfg->opts[CFG_VAR_INIT], kernel_cfg->var_init_val,
kernel_cfg->opts[CFG_STAFF_MODE]);
};
SYS_HEAP_DBG_FLAG::     DU8     _CFG_HEAP_DBG;

        ALIGN   8,0
SYS_CTRL_ALT_FLAGS::    DU64    0;
SYS_EXTERN_TABLE::      DU64    0;

SYS_CODE_BP::           DU64    0;
SYS_DATA_BP::           DU64    0;

SYS_PROGRESSES::
SYS_PROGRESS1::         DU64    0;
SYS_PROGRESS1_MAX::     DU64    0;
SYS_PROGRESS1_T0::      DU64    0;
SYS_PROGRESS1_TF::      DU64    0;
SYS_PROGRESS1_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS2::         DU64    0;
SYS_PROGRESS2_MAX::     DU64    0;
SYS_PROGRESS2_T0::      DU64    0;
SYS_PROGRESS2_TF::      DU64    0;
SYS_PROGRESS2_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS3::         DU64    0;
SYS_PROGRESS3_MAX::     DU64    0;
SYS_PROGRESS3_T0::      DU64    0;
SYS_PROGRESS3_TF::      DU64    0;
SYS_PROGRESS3_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
SYS_PROGRESS4::         DU64    0;
SYS_PROGRESS4_MAX::     DU64    0;
SYS_PROGRESS4_T0::      DU64    0;
SYS_PROGRESS4_TF::      DU64    0;
SYS_PROGRESS4_DESC::    DU8     PROGRESS_DESC_LEN DUP(0);
#assert $-SYS_PROGRESSES==sizeof(CProgress)*4

SYS_FOCUS_TASK::        DU64    0;
SYS_CPU_STRUCTS::       DU64    0;
SYS_MP_CNT::            DU64    1;
SYS_MP_CNT_INITIAL::    DU64    1;
SYS_MP_CNT_LOCK::       DU64    1;

        ALIGN   DFT_CACHE_LINE_WIDTH,OC_NOP
SYS_CACHE_LINE_WIDTH::  DU64    DFT_CACHE_LINE_WIDTH;
        DU8     DFT_CACHE_LINE_WIDTH-sizeof(CBinFile)-8 DUP(0);
SYS_SEMAS::             DU8     SEMA_SEMAS_NUM*DFT_CACHE_LINE_WIDTH DUP(0);
//************************************
        ALIGN   16,OC_NOP
CORE0_32BIT_INIT:: //Entry point for BootRAM.
        PUSH    U32 RFLAGG_START
        POPFD
        MOV     EAX,SYS_START_CR0
        MOV_CR0_EAX

        MOV     AX,CGDT.boot_ds //LOAD DS SELECTOR
        MOV     DS,AX
        BTS     U32 [SYS_RUN_LEVEL],RLf_32BIT
        MOV     ESI,U32 [SYS_BOOT_PATCH_TABLE_BASE]
        MOV     EDI,U32 [MEM_BOOT_BASE]

        MOV     AX,CGDT.ds
        MOV     DS,AX
        MOV     ES,AX
        MOV     FS,AX
        MOV     GS,AX
        MOV     SS,AX
        MOV     ESP,BOOT_RAM_LIMIT //Tmp Stk

//Patch abs addresses
        MOV     ECX,U32 CPatchTableAbsAddr.abs_addres_cnt[ESI]
        LEA     ESI,U32 CPatchTableAbsAddr.abs_addres[ESI]
@@05:   LODSD
        ADD     EAX,EDI
        ADD     U32 [EAX],EDI
        LOOP    @@05

        DU8     0xEA; //JMP CGDT.cs32:@@10
        DU32    @@10;
        DU16    CGDT.cs32;

@@10:   BTS     U32 [SYS_RUN_LEVEL],RLf_PATCHED

        CALL    SYS_FIND_PCIBIOS_SERVICE_DIR
        CALL    SYS_FIND_PCI_SERVICES
        CALL    SYS_INIT_PAGE_TABLES
        CALL    SYS_INIT_16MEG_SYS_CODE_BP
        PUSH    U32 0   //Return from next call will be 64-bit
        CALL    SYS_ENTER_LONG_MODE

        //We fall-thou to KStart64, next.
}