// Source: D:\TempleOS-Projects\html\BackLib-Compiler.html
// Date: unknown-date
// Language: HolyC

/*Intermediate Code to Machine Code

RAX,RBX,RCX and RDX can be clobbered by
each intermediate code's output code.
However, intermediate codes must be
coupled together based on the arg and
res type specifications in the
CICArg.  RAX is the most common reg
for coupling intermediate codes.

Internal calculations take place on
64-bit vals, so anything which has
found it's way into a reg has been
sign or zero extended to 64-bits.
*/

U0 ICU8(CIntermediateCode *tmpi,U8 b)
{
  tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICRex(CIntermediateCode *tmpi,U8 b)
{
  if (b)
    tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICOpSizeRex(CIntermediateCode *tmpi,U8 b)
{
  tmpi->ic_body[tmpi->ic_cnt++]=OC_OP_SIZE_PREFIX;
  if (b)
    tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICU16(CIntermediateCode *tmpi,U16 w)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U16)=w;
  tmpi->ic_cnt+=2;
}

U0 ICU24(CIntermediateCode *tmpi,U32 d)
{//Writes extra harmless overhanging byte.
  *(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
  tmpi->ic_cnt+=3;
}

U0 ICU32(CIntermediateCode *tmpi,U32 d)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
  tmpi->ic_cnt+=4;
}

U0 ICU64(CIntermediateCode *tmpi,U64 q)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U64)=q;
  tmpi->ic_cnt+=8;
}

U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
{
  I64 j,last_start;
  CIntermediateCode *tmpil1;
  if (optimize) {
    tmpil1=tmpi;
    if (tmpi->ic_last_start<0 && !tmpi->ic_cnt &&
          (tmpil1=OptLag1(tmpi)) && tmpil1->ic_last_start<0)
      tmpil1=NULL;
    if (tmpil1) {
      j=tmpil1->ic_cnt;
      if (tmpil1->ic_last_start==j-4 && tmpil1->ic_body[j-3]==0x83 &&
            tmpil1->ic_body[j-4]==0x48) {
        if (tmpil1->ic_body[j-2]==0xEC)
          j=-tmpil1->ic_body[j-1](I8);
        else if (tmpil1->ic_body[j-2]==0xC4)
          j=tmpil1->ic_body[j-1](I8);
        else
          j=0;
      } else if (tmpil1->ic_last_start==j-7 && tmpil1->ic_body[j-6]==0x81 &&
            tmpil1->ic_body[j-7]==0x48) {
        if (tmpil1->ic_body[j-5]==0xEC)
          j=-tmpil1->ic_body[j-4](I32);
        else if (tmpil1->ic_body[j-5]==0xC4)
          j=tmpil1->ic_body[j-4](I32);
        else
          j=0;
      } else
        j=0;
      if (j) {
        if (tmpi==tmpil1) {
          tmpi->ic_cnt=tmpi->ic_last_start;
          i+=j;
        } else if (!(tmpi->ic_flags&ICF_PREV_DELETED)) {
          tmpil1->ic_flags|=ICF_DEL_PREV_INS;
          tmpi->ic_flags=tmpi->ic_flags&~ICF_CODE_FINAL|ICF_PREV_DELETED;
          i+=j;
        }
      }
    }
  }
  last_start=tmpi->ic_cnt;
  if (i>0) {
    if (i<=I8_MAX)
      ICU32(tmpi,0xC48348+i<<24);
    else if (i<=I32_MAX) {
      ICU24(tmpi,0xC48148);
      ICU32(tmpi,i);
    } else
      throw('Compiler');
  } else if (i<0) {
    i=-i;
    if (i<=I8_MAX)
      ICU32(tmpi,0xEC8348+i<<24);
    else if (i<=I32_MAX) {
      ICU24(tmpi,0xEC8148);
      ICU32(tmpi,i);
    } else
      throw('Compiler');
  }
  if (optimize && tmpi->ic_cnt>last_start)
    tmpi->ic_last_start=last_start;
}

extern U0 ICMov(CIntermediateCode *tmpi,
        CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 rip);

#define MODR_REG                        0
#define MODR_INDIRECT_REG               1
#define MODR_D8_INDIRECT_REG            2
#define MODR_D32_INDIRECT_REG           3
#define MODR_SIB_INDIRECT_REG           4
#define MODR_SIB_D8_INDIRECT_REG        5
#define MODR_SIB_D32_INDIRECT_REG       6
#define MODR_RIP_REL                    7
#define MODR_RIP_REL_IMM_U32            8

I64 ICModr1(I64 r,CICType t2,I64 r2,I64 d2)
{//res.u8[0] is type
//res.u8[1] is REX
  //res.u8[2] is ModR
  //res.u8[3] is SIB
  I64 res=0;
  if (t2.raw_type<RT_I64)
    res.u8[1]=0x40;
  else
    res.u8[1]=0x48;
  if (r>7) {
    res.u8[1]+=4;
    r&=7;
  }
  switch (Bsr(t2)) {
    case MDf_REG:
      if (r2>7) {
        res.u8[1]++;
        r2&=7;
      }
      res.u8[2]=0xC0+r<<3+r2;
      res.u8[0]=MODR_REG;
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4 && r2<4))
        res.u8[1]=0;
      break;
    case MDf_DISP:
      if (r2>7) {
        res.u8[1]++;
        r2&=7;
      }
      if (!d2 && r2!=REG_RBP) {
        res.u8[2]=r<<3+r2;
        res.u8[0]=MODR_INDIRECT_REG;
      } else if (I8_MIN<=d2<=I8_MAX) {
        res.u8[2]=0x40+r<<3+r2;
        res.u8[0]=MODR_D8_INDIRECT_REG;
      } else {
        res.u8[2]=0x80+r<<3+r2;
        res.u8[0]=MODR_D32_INDIRECT_REG;
      }
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
    case MDf_SIB:
      if (7<r2.u8[0]<REG_NONE)
        res.u8[1]++;
      if (r2.u8[1]&15>7)
        res.u8[1]+=2;
      if (r2.u8[0]==REG_NONE) {
        res.u8[3]=5+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
        res.u8[2]=4+r<<3;
        res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
      } else {
        res.u8[3]=r2.u8[0]&7+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
        if (!d2 && r2.u8[0]&7!=REG_RBP) {
          res.u8[2]=4+r<<3;
          res.u8[0]=MODR_SIB_INDIRECT_REG;
        } else if (I8_MIN<=d2<=I8_MAX) {
          res.u8[2]=0x44+r<<3;
          res.u8[0]=MODR_SIB_D8_INDIRECT_REG;
        } else {
          res.u8[2]=0x84+r<<3;
          res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
        }
      }
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
    case MDf_RIP_DISP32:
      res.u8[2]=0x05+r<<3;
      res.u8[0]=MODR_RIP_REL;
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
  }
  return res;
}

U0 ICModr2(CIntermediateCode *tmpi,I64 i,CICType t=0,I64 d,I64 rip=0)
{
  switch [i.u8[0]] {
    case MODR_REG:
      break;
    case MODR_INDIRECT_REG:
      break;
    case MODR_D8_INDIRECT_REG:
      ICU8(tmpi,d);
      break;
    case MODR_D32_INDIRECT_REG:
      ICU32(tmpi,d);
      break;
    case MODR_SIB_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      break;
    case MODR_SIB_D8_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      ICU8(tmpi,d);
      break;
    case MODR_SIB_D32_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      ICU32(tmpi,d);
      break;
    case MODR_RIP_REL_IMM_U32:
      switc

[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\BackLib-Compiler.html
// Date: unknown-date
// Language: HolyC

/*Intermediate Code to Machine Code

RAX,RBX,RCX and RDX can be clobbered by
each intermediate code's output code.
However, intermediate codes must be
coupled together based on the arg and
res type specifications in the
CICArg.  RAX is the most common reg
for coupling intermediate codes.

Internal calculations take place on
64-bit vals, so anything which has
found it's way into a reg has been
sign or zero extended to 64-bits.
*/

U0 ICU8(CIntermediateCode *tmpi,U8 b)
{
  tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICRex(CIntermediateCode *tmpi,U8 b)
{
  if (b)
    tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICOpSizeRex(CIntermediateCode *tmpi,U8 b)
{
  tmpi->ic_body[tmpi->ic_cnt++]=OC_OP_SIZE_PREFIX;
  if (b)
    tmpi->ic_body[tmpi->ic_cnt++]=b;
}

U0 ICU16(CIntermediateCode *tmpi,U16 w)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U16)=w;
  tmpi->ic_cnt+=2;
}

U0 ICU24(CIntermediateCode *tmpi,U32 d)
{//Writes extra harmless overhanging byte.
  *(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
  tmpi->ic_cnt+=3;
}

U0 ICU32(CIntermediateCode *tmpi,U32 d)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U32)=d;
  tmpi->ic_cnt+=4;
}

U0 ICU64(CIntermediateCode *tmpi,U64 q)
{
  *(&tmpi->ic_body[tmpi->ic_cnt])(U64)=q;
  tmpi->ic_cnt+=8;
}

U0 ICAddRSP(CIntermediateCode *tmpi,I64 i,Bool optimize=TRUE)
{
  I64 j,last_start;
  CIntermediateCode *tmpil1;
  if (optimize) {
    tmpil1=tmpi;
    if (tmpi->ic_last_start<0 && !tmpi->ic_cnt &&
          (tmpil1=OptLag1(tmpi)) && tmpil1->ic_last_start<0)
      tmpil1=NULL;
    if (tmpil1) {
      j=tmpil1->ic_cnt;
      if (tmpil1->ic_last_start==j-4 && tmpil1->ic_body[j-3]==0x83 &&
            tmpil1->ic_body[j-4]==0x48) {
        if (tmpil1->ic_body[j-2]==0xEC)
          j=-tmpil1->ic_body[j-1](I8);
        else if (tmpil1->ic_body[j-2]==0xC4)
          j=tmpil1->ic_body[j-1](I8);
        else
          j=0;
      } else if (tmpil1->ic_last_start==j-7 && tmpil1->ic_body[j-6]==0x81 &&
            tmpil1->ic_body[j-7]==0x48) {
        if (tmpil1->ic_body[j-5]==0xEC)
          j=-tmpil1->ic_body[j-4](I32);
        else if (tmpil1->ic_body[j-5]==0xC4)
          j=tmpil1->ic_body[j-4](I32);
        else
          j=0;
      } else
        j=0;
      if (j) {
        if (tmpi==tmpil1) {
          tmpi->ic_cnt=tmpi->ic_last_start;
          i+=j;
        } else if (!(tmpi->ic_flags&ICF_PREV_DELETED)) {
          tmpil1->ic_flags|=ICF_DEL_PREV_INS;
          tmpi->ic_flags=tmpi->ic_flags&~ICF_CODE_FINAL|ICF_PREV_DELETED;
          i+=j;
        }
      }
    }
  }
  last_start=tmpi->ic_cnt;
  if (i>0) {
    if (i<=I8_MAX)
      ICU32(tmpi,0xC48348+i<<24);
    else if (i<=I32_MAX) {
      ICU24(tmpi,0xC48148);
      ICU32(tmpi,i);
    } else
      throw('Compiler');
  } else if (i<0) {
    i=-i;
    if (i<=I8_MAX)
      ICU32(tmpi,0xEC8348+i<<24);
    else if (i<=I32_MAX) {
      ICU24(tmpi,0xEC8148);
      ICU32(tmpi,i);
    } else
      throw('Compiler');
  }
  if (optimize && tmpi->ic_cnt>last_start)
    tmpi->ic_last_start=last_start;
}

extern U0 ICMov(CIntermediateCode *tmpi,
        CICType t1,I64 r1,I64 d1,CICType t2,I64 r2,I64 d2,I64 rip);

#define MODR_REG                        0
#define MODR_INDIRECT_REG               1
#define MODR_D8_INDIRECT_REG            2
#define MODR_D32_INDIRECT_REG           3
#define MODR_SIB_INDIRECT_REG           4
#define MODR_SIB_D8_INDIRECT_REG        5
#define MODR_SIB_D32_INDIRECT_REG       6
#define MODR_RIP_REL                    7
#define MODR_RIP_REL_IMM_U32            8

I64 ICModr1(I64 r,CICType t2,I64 r2,I64 d2)
{//res.u8[0] is type
//res.u8[1] is REX
  //res.u8[2] is ModR
  //res.u8[3] is SIB
  I64 res=0;
  if (t2.raw_type<RT_I64)
    res.u8[1]=0x40;
  else
    res.u8[1]=0x48;
  if (r>7) {
    res.u8[1]+=4;
    r&=7;
  }
  switch (Bsr(t2)) {
    case MDf_REG:
      if (r2>7) {
        res.u8[1]++;
        r2&=7;
      }
      res.u8[2]=0xC0+r<<3+r2;
      res.u8[0]=MODR_REG;
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4 && r2<4))
        res.u8[1]=0;
      break;
    case MDf_DISP:
      if (r2>7) {
        res.u8[1]++;
        r2&=7;
      }
      if (!d2 && r2!=REG_RBP) {
        res.u8[2]=r<<3+r2;
        res.u8[0]=MODR_INDIRECT_REG;
      } else if (I8_MIN<=d2<=I8_MAX) {
        res.u8[2]=0x40+r<<3+r2;
        res.u8[0]=MODR_D8_INDIRECT_REG;
      } else {
        res.u8[2]=0x80+r<<3+r2;
        res.u8[0]=MODR_D32_INDIRECT_REG;
      }
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
    case MDf_SIB:
      if (7<r2.u8[0]<REG_NONE)
        res.u8[1]++;
      if (r2.u8[1]&15>7)
        res.u8[1]+=2;
      if (r2.u8[0]==REG_NONE) {
        res.u8[3]=5+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
        res.u8[2]=4+r<<3;
        res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
      } else {
        res.u8[3]=r2.u8[0]&7+(r2.u8[1]&7)<<3+r2.u8[1]&0xC0;
        if (!d2 && r2.u8[0]&7!=REG_RBP) {
          res.u8[2]=4+r<<3;
          res.u8[0]=MODR_SIB_INDIRECT_REG;
        } else if (I8_MIN<=d2<=I8_MAX) {
          res.u8[2]=0x44+r<<3;
          res.u8[0]=MODR_SIB_D8_INDIRECT_REG;
        } else {
          res.u8[2]=0x84+r<<3;
          res.u8[0]=MODR_SIB_D32_INDIRECT_REG;
        }
      }
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
    case MDf_RIP_DISP32:
      res.u8[2]=0x05+r<<3;
      res.u8[0]=MODR_RIP_REL;
      if (res.u8[1]==0x40 && (t2.raw_type>=RT_I16 || r<4))
        res.u8[1]=0;
      break;
  }
  return res;
}

U0 ICModr2(CIntermediateCode *tmpi,I64 i,CICType t=0,I64 d,I64 rip=0)
{
  switch [i.u8[0]] {
    case MODR_REG:
      break;
    case MODR_INDIRECT_REG:
      break;
    case MODR_D8_INDIRECT_REG:
      ICU8(tmpi,d);
      break;
    case MODR_D32_INDIRECT_REG:
      ICU32(tmpi,d);
      break;
    case MODR_SIB_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      break;
    case MODR_SIB_D8_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      ICU8(tmpi,d);
      break;
    case MODR_SIB_D32_INDIRECT_REG:
      ICU8(tmpi,i.u8[3]);
      ICU32(tmpi,d);
      break;
    case MODR_RIP_REL_IMM_U32:
      switc


// Source: D:\TempleOS-Projects\html\advantage-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("5eC4sAA5eC4sAA5eD4AB5RCqE4sBB5eEDFE",
            "Bill \0 \0 \0Gates... \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0Life's \0not \0fair.\n\0");
      Play("5C4A5qCsDD4AAeB5RCDsCC4BB5eE4A5FsEE",
            "Heavy \0 \0weights... \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0Done \0my \0share!\n\0 \0");
      Play("5G4G5G4G5qG4eBBB5FsD4G5eD4sBGBGeBA5sGF4eG",
            "God's \0 \0 \0 \0World?  \0 \0 \0 \0"
            "Per\0fect\0 \0ly \0 \0 \0 \0 \0 \0 \0just.\n\0 \0 \0");
      Play("5sG4G5G4G5qG4eBBB5FsD4G5eD4sBGBGeBA5sGF4eG",
            "Thank's \0 \0 \0 \0Bill, \0 \0 \0 \0"
            "but \0God \0 \0we \0 \0 \0 \0 \0 \0 \0trust.\n\0 \0 \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\advantage-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("5eC4sAA5eC4sAA5eD4AB5RCqE4sBB5eEDFE",
            "Bill \0 \0 \0Gates... \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0Life's \0not \0fair.\n\0");
      Play("5C4A5qCsDD4AAeB5RCDsCC4BB5eE4A5FsEE",
            "Heavy \0 \0weights... \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0Done \0my \0share!\n\0 \0");
      Play("5G4G5G4G5qG4eBBB5FsD4G5eD4sBGBGeBA5sGF4eG",
            "God's \0 \0 \0 \0World?  \0 \0 \0 \0"
            "Per\0fect\0 \0ly \0 \0 \0 \0 \0 \0 \0just.\n\0 \0 \0");
      Play("5sG4G5G4G5qG4eBBB5FsD4G5eD4sBGBGeBA5sGF4eG",
            "Thank's \0 \0 \0 \0Bill, \0 \0 \0 \0"
            "but \0God \0 \0we \0 \0 \0 \0 \0 \0 \0trust.\n\0 \0 \0");
    }
  } catch
    PutExcept;
  Snd;
}

Song;


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

U0 Song()
{//Song by Terry A. Davis
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  try //Catch <CTRL-ALT-c> exit
    while (!ScanChar) {
      Play("6hEqDC5B6CDhE",
            "God \0is \0a \0g\0od \0of \0love.\n\0");
      Play("5GqFEFhG6E",
            " \0 \0 \0 \0 \0He \0");
      Play("6qDC5B6CDhE5G",
            "wat\0ches \0us \0from \0a\0bove.\n\0 \0");
      Play("5qFEFhGB6qC",
            " \0 \0 \0 \0Our \0world \0");
      Play("6DhCeDC5hBG",
            "is\0n't \0al\0ways \0nice.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0Be\0fore \0");
      Play("6C5B6CDhE5G",
            "you \0gr\0ipe \0think \0twice.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0He \0wat\0");
      Play("6C5B6CDhE5G",
            "ches \0us \0from \0a\0bove.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0He'll \0smack \0");
      Play("6C5B6CDhE5G",
            "you \0with \0out \0a \0glove.\n\0 \0");
      Play("5qFEFhGB6qC",
            " \0 \0 \0 \0Our \0world \0");
      Play("6DhCeDC5hBG",
            "is\0n't \0al\0ways \0nice.\n\0 \0");
      Play("5qFEFhG");
    }
  catch
    PutExcept;
  '\n';
  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\OhGreat-Snd-Demo.html
// Date: unknown-date
// Language: HolyC

U0 Song()
{//Song by Terry A. Davis
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  try //Catch <CTRL-ALT-c> exit
    while (!ScanChar) {
      Play("6hEqDC5B6CDhE",
            "God \0is \0a \0g\0od \0of \0love.\n\0");
      Play("5GqFEFhG6E",
            " \0 \0 \0 \0 \0He \0");
      Play("6qDC5B6CDhE5G",
            "wat\0ches \0us \0from \0a\0bove.\n\0 \0");
      Play("5qFEFhGB6qC",
            " \0 \0 \0 \0Our \0world \0");
      Play("6DhCeDC5hBG",
            "is\0n't \0al\0ways \0nice.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0Be\0fore \0");
      Play("6C5B6CDhE5G",
            "you \0gr\0ipe \0think \0twice.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0He \0wat\0");
      Play("6C5B6CDhE5G",
            "ches \0us \0from \0a\0bove.\n\0 \0");
      Play("5qFEFhG6EqD",
            " \0 \0 \0 \0He'll \0smack \0");
      Play("6C5B6CDhE5G",
            "you \0with \0out \0a \0glove.\n\0 \0");
      Play("5qFEFhGB6qC",
            " \0 \0 \0 \0Our \0world \0");
      Play("6DhCeDC5hBG",
            "is\0n't \0al\0ways \0nice.\n\0 \0");
      Play("5qFEFhG");
    }
  catch
    PutExcept;
  '\n';
  Snd;
}

Song;


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

GR graphics files are 8-bits-per-pixels but only 4-bits of color, with
transparency and no palette.  Compression is the standard TempleOS LZW
compression.

#define DCF_COMPRESSED          1 //This is the only saved flag.
#define DCF_PALETTE             2

#define TRANSPARENT             0xFF
#define BLACK                   0
#define BLUE                    1
#define GREEN                   2
#define CYAN                    3
#define RED                     4
#define PURPLE                  5
#define BROWN                   6
#define LTGRAY                  7
#define DKGRAY                  8
#define LTBLUE                  9
#define LTGREEN                 10
#define LTCYAN                  11
#define LTRED                   12
#define LTPURPLE                13
#define YELLOW                  14
#define WHITE                   15

class CBGR48
{
  U16   r,g,b,pad;
};

CBGR48 gr_palette_std[16]={
0x000000000000,0x00000000AAAA,0x0000AAAA0000,0x0000AAAAAAAA,
0xAAAA00000000,0xAAAA0000AAAA,0xAAAA55550000,0xAAAAAAAAAAAA,
0x555555555555,0x55555555FFFF,0x5555FFFF5555,0x5555FFFFFFFF,
0xFFFF55555555,0xFFFF5555FFFF,0xFFFFFFFF5555,0xFFFFFFFFFFFF};

class GRFile
{
  I32   width;
  I32   width_internal; //Rounded-up to multiple of 8.
  I32   height;
  I32   flags;          //DCF_COMPRESSED? See ::/Kernel/Compress.HC.
  CBGR48 palette[16];   //Included if DCF_PALETTE.
  U8    body[];
};

See DCSave(), GRWrite(), DCLoad(), and GRRead().

[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\GRFiles-Doc.html
// Date: unknown-date
// Language: HolyC

GR graphics files are 8-bits-per-pixels but only 4-bits of color, with
transparency and no palette.  Compression is the standard TempleOS LZW
compression.

#define DCF_COMPRESSED          1 //This is the only saved flag.
#define DCF_PALETTE             2

#define TRANSPARENT             0xFF
#define BLACK                   0
#define BLUE                    1
#define GREEN                   2
#define CYAN                    3
#define RED                     4
#define PURPLE                  5
#define BROWN                   6
#define LTGRAY                  7
#define DKGRAY                  8
#define LTBLUE                  9
#define LTGREEN                 10
#define LTCYAN                  11
#define LTRED                   12
#define LTPURPLE                13
#define YELLOW                  14
#define WHITE                   15

class CBGR48
{
  U16   r,g,b,pad;
};

CBGR48 gr_palette_std[16]={
0x000000000000,0x00000000AAAA,0x0000AAAA0000,0x0000AAAAAAAA,
0xAAAA00000000,0xAAAA0000AAAA,0xAAAA55550000,0xAAAAAAAAAAAA,
0x555555555555,0x55555555FFFF,0x5555FFFF5555,0x5555FFFFFFFF,
0xFFFF55555555,0xFFFF5555FFFF,0xFFFFFFFF5555,0xFFFFFFFFFFFF};

class GRFile
{
  I32   width;
  I32   width_internal; //Rounded-up to multiple of 8.
  I32   height;
  I32   flags;          //DCF_COMPRESSED? See ::/Kernel/Compress.HC.
  CBGR48 palette[16];   //Included if DCF_PALETTE.
  U8    body[];
};

See DCSave(), GRWrite(), DCLoad(), and GRRead().


// Source: D:\TempleOS-Projects\html\childish-Psalmody-Examples-Apps.html
// Date: unknown-date
// Language: HolyC

//9 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Be \0like \0 \0a \0 \0child \0 \0 \0 \0"
            "some \0 \0re\0 \0spect.\n\0 \0 \0 \0 \0 \0");
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Ma\0tur\0 \0i\0 \0ty \0 \0 \0 \0don't \0 \0"
            "ne\0 \0glect.\n\0 \0 \0 \0 \0 \0");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
    }
  } 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\childish-Psalmody-Examples-Apps.html
// Date: unknown-date
// Language: HolyC

//9 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Be \0like \0 \0a \0 \0child \0 \0 \0 \0"
            "some \0 \0re\0 \0spect.\n\0 \0 \0 \0 \0 \0");
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Ma\0tur\0 \0i\0 \0ty \0 \0 \0 \0don't \0 \0"
            "ne\0 \0glect.\n\0 \0 \0 \0 \0 \0");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
    }
  } 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\Varoom-Games-Demo.html
// Date: unknown-date
// Language: HolyC

<1>/* Graphics Not Rendered in HTML */

    <2>/* Graphics Not Rendered in HTML */

    <3>/* Graphics Not Rendered in HTML */

    <4>/* Graphics Not Rendered in HTML */

                 <5>/* Graphics Not Rendered in HTML */

                 <6>/* Graphics Not Rendered in HTML */

RegDft("TempleOS/Varoom","F64 best_score=9999;\n");
RegExe("TempleOS/Varoom");

F64 distance,t0,tf;
Bool game_over;

#define BORDER          7500
#define RADIUS          10000
#define WIDTH           2000
#define SHOULDER        200
#define D_theta         (2*pi/360)   //Curve track slice is one degree.
#define D_S             (2*pi*RADIUS/360) //Straight track is degree at 10000.
#define DIPS            5
#define DIP_DEPTH       50
class Track
{
  Track *next,*last;
  I32 num;
  CColorROPU16 c,pad;
  I64 x,z;
  F64 theta,d;
  CD3I32 left[4],center[4],right[4];
} track_head,
  *track_start[MP_PROCESSORS_NUM],*track_end[MP_PROCESSORS_NUM];

CDC *track_map;
#define MAP_BITS        9
I64 t_minx,t_maxx,t_minz,t_maxz;

#define BUSHES_NUM      512
class Bush
{
  CD3I32 p;
  Bool sym,pad[3];
  U8 *img;
} b[BUSHES_NUM];

#define CARS_NUM        8
class Car
{
  CD3I32 p;
  F64 theta,dtheta,speed;
  U8 *img;
  Track *t;
} c[CARS_NUM];

I64 DipY(I64 x,I64 z)
{
  F64 m,a;
  R2P(&m,&a,x,z);
  return DIP_DEPTH*m*Cos(DIPS*a)/RADIUS;
}

#define CAR_LENGTH      400

F64 Diptheta(I64 x,I64 z,F64 theta)
{
  F64 y_front,y_back;
  y_front=DipY(x-CAR_LENGTH/2*Cos(theta),z-CAR_LENGTH/2*Sin(theta));
  y_back =DipY(x+CAR_LENGTH/2*Cos(theta),z+CAR_LENGTH/2*Sin(theta));
  return ASin((y_front-y_back)/CAR_LENGTH);
}

Track *TrackFind(Track *_tmpt,I64 x,I64 z)
{
  Track *res=_tmpt,*tmpt;
  I64 dd,best=SqrI64(res->x-x)+SqrI64(res->z-z);

  tmpt=_tmpt;
  while (TRUE) {
    tmpt=tmpt->next;
    if (tmpt==&track_head)
      tmpt=tmpt->next;
    dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
    if (dd<best) {
      best=dd;
      res=tmpt;
    } else
      break;
  }
  tmpt=_tmpt;
  while (TRUE) {
    tmpt=tmpt->last;
    if (tmpt==&track_head)
      tmpt=tmpt->last;
    dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
    if (dd<best) {
      best=dd;
      res=tmpt;
    } else
      break;
  }
  return res;
}

U0 TrackSlice(F64 *_x,F64 *_z,F64 theta,F64 d)
{
  F64 x=*_x,z=*_z,c=Cos(theta),s=Sin(theta),dx=d*s,dz=-d*c;
  Track *tmpt,*last=track_head.last;
  if (last==&track_head)
    last=NULL;

  tmpt=CAlloc(sizeof(Track));
  if (last) {
    MemCpy(&tmpt->center[0],&last->center[3],sizeof(CD3I32));
    MemCpy(&tmpt->center[1],&last->center[2],sizeof(CD3I32));
  }
  tmpt->center[2].x=x+(WIDTH/2)*c+dx;
  tmpt->center[2].z=z+(WIDTH/2)*s+dz;
  tmpt->center[2].y=DipY(tmpt->center[2].x,tmpt->center[2].z);
  tmpt->center[3].x=x-(WIDTH/2)*c+dx;
  tmpt->center[3].z=z-(WIDTH/2)*s+dz;
  tmpt->center[3].y=DipY(tmpt->center[3].x,tmpt->center[3].z);

  if (last) {
    MemCpy(&tmpt->left[0],&last->left[3],sizeof(CD3I32));
    MemCpy(&tmpt->left[1],&last->left[2],sizeof(CD3I32));
  }
  tmpt->left[2].x=x-(WIDTH/2)*c+dx;
  tmpt->left[2].z=z-(WIDTH/2)*s+dz;
  tmpt->left[2].y=DipY(tmpt->left[2].x,tmpt->left[2].z);
  tmpt->left[3].x=x-(WIDTH/2+SHOULDER)*c+dx;
  tmpt->left[3].z=z-(WIDTH/2+SHOULDER)*s+dz;
  tmpt->left[3].y=DipY(tmpt->left[3].x,tmpt->left[3].z);

  if (last) {
    MemCpy(&tmpt->right[0],&last->right[3],sizeof(CD3I32));
    MemCpy(&tmpt->right[1],&last->right[2],sizeof(CD3I32));
  }
  tmpt->right[2].x=x+(WIDTH/2+SHOULDER)*c+dx;
  tmpt->right[2].z=z+(WIDTH/2+SHOULDER)*s+dz;
  tmpt->right[2].y=DipY(tmpt->right[2].x,tmpt->right[2].z);
  tmpt->right[3].x=x+(WIDTH/2)*c+dx;
  tmpt->right[3].z=z+(WIDTH/2)*s+dz;
  tmpt->right[3].y=DipY(tmpt->right[3].x,tmpt->right[3].z);

  tmpt->x=x;
  tmpt->z=z;
  tmpt->theta=theta;
  tmpt->num=track_head.last->num+1;
  tmpt->d  =track_head.last->d+d;

  QueIns(tmpt,track_head.last);

  if (tmpt->num&1)
    tmpt->c=RED;
  else
    tmpt->c=WHITE;

  if (x<t_minx) t_minx=x;
  if (x>t_maxx) t_maxx=x;
  if (z<t_minz) t_minz=z;
  if (z>t_maxz) t_maxz=z;

  x+=dx;
  *_x=x;
  z+=dz;
  *_z=z;

  if (x<t_minx) t_minx=x;
  if (x>t_maxx) t_maxx=x;
  if (z<t_minz) t_minz=z;
  if (z>t_maxz) t_maxz=z;
}

U0 CoupleEnds()
{
  Track *first=track_head.next,*last=track_head.last;
  MemCpy(&first->center[0],&last->center[3],sizeof(CD3I32));
  MemCpy(&first->center[1],&last->center[2],sizeof(CD3I32));
  MemCpy(&first->left[0]  ,&last->left[3]  ,sizeof(CD3I32));
  MemCpy(&first->left[1]  ,&last->left[2]  ,sizeof(CD3I32));
  MemCpy(&first->right[0] ,&last->right[3] ,sizeof(CD3I32));
  MemCpy(&first->right[1] ,&last->right[2] ,sizeof(CD3I32));
}

U0 InitTrack()
{
  I64 i,j;
  Track *tmpt;
  F64 x,z,theta,d;

  MemSet(&track_head,0,sizeof(Track));
  QueInit(&track_head);

  t_minx=t_minz=I64_MAX;
  t_maxx=t_maxz=I64_MIN;

  x=0; z=0; theta=0;
  for (d=0;d<6*RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (d=0;d<RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<90;i++,theta-=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (i=0;i<90;i++,theta-=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (d=0;d<RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);

  CoupleEnds;

  tmpt=track_head.next;
  for (i=0;i<mp_cnt;i++) {
    j=(i+1)*track_head.last->num/mp_cnt+1;
    track_start[i]=tmpt;
    while (tmpt!=&track_head && tmpt->num!=j)
      tmpt=tmpt->next;
    track_end[i]=tmpt;
  }

  t_minx-=BORDER; t_minz-=BORDER;
  t_maxx+=BORDER; t_maxz+=BORDER;
  track_map=DCNew((t_maxx-t_minx+1<<MAP_BITS-1)>>MAP_BITS,
        (t_maxz-t_minz+1<<MAP_BITS-1)>>MAP_BITS);

  track_map->color=LTGRAY;
  GrRect(track_map,0,0,track_map->width,track_map->height);
  tmpt=track_head.next;
  track_map->color=YELLOW;
  track_map->thick=3;
  while (tmpt!=&track_head) {
    GrPlot3(track_map,

[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\Varoom-Games-Demo.html
// Date: unknown-date
// Language: HolyC

<1>/* Graphics Not Rendered in HTML */

    <2>/* Graphics Not Rendered in HTML */

    <3>/* Graphics Not Rendered in HTML */

    <4>/* Graphics Not Rendered in HTML */

                 <5>/* Graphics Not Rendered in HTML */

                 <6>/* Graphics Not Rendered in HTML */

RegDft("TempleOS/Varoom","F64 best_score=9999;\n");
RegExe("TempleOS/Varoom");

F64 distance,t0,tf;
Bool game_over;

#define BORDER          7500
#define RADIUS          10000
#define WIDTH           2000
#define SHOULDER        200
#define D_theta         (2*pi/360)   //Curve track slice is one degree.
#define D_S             (2*pi*RADIUS/360) //Straight track is degree at 10000.
#define DIPS            5
#define DIP_DEPTH       50
class Track
{
  Track *next,*last;
  I32 num;
  CColorROPU16 c,pad;
  I64 x,z;
  F64 theta,d;
  CD3I32 left[4],center[4],right[4];
} track_head,
  *track_start[MP_PROCESSORS_NUM],*track_end[MP_PROCESSORS_NUM];

CDC *track_map;
#define MAP_BITS        9
I64 t_minx,t_maxx,t_minz,t_maxz;

#define BUSHES_NUM      512
class Bush
{
  CD3I32 p;
  Bool sym,pad[3];
  U8 *img;
} b[BUSHES_NUM];

#define CARS_NUM        8
class Car
{
  CD3I32 p;
  F64 theta,dtheta,speed;
  U8 *img;
  Track *t;
} c[CARS_NUM];

I64 DipY(I64 x,I64 z)
{
  F64 m,a;
  R2P(&m,&a,x,z);
  return DIP_DEPTH*m*Cos(DIPS*a)/RADIUS;
}

#define CAR_LENGTH      400

F64 Diptheta(I64 x,I64 z,F64 theta)
{
  F64 y_front,y_back;
  y_front=DipY(x-CAR_LENGTH/2*Cos(theta),z-CAR_LENGTH/2*Sin(theta));
  y_back =DipY(x+CAR_LENGTH/2*Cos(theta),z+CAR_LENGTH/2*Sin(theta));
  return ASin((y_front-y_back)/CAR_LENGTH);
}

Track *TrackFind(Track *_tmpt,I64 x,I64 z)
{
  Track *res=_tmpt,*tmpt;
  I64 dd,best=SqrI64(res->x-x)+SqrI64(res->z-z);

  tmpt=_tmpt;
  while (TRUE) {
    tmpt=tmpt->next;
    if (tmpt==&track_head)
      tmpt=tmpt->next;
    dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
    if (dd<best) {
      best=dd;
      res=tmpt;
    } else
      break;
  }
  tmpt=_tmpt;
  while (TRUE) {
    tmpt=tmpt->last;
    if (tmpt==&track_head)
      tmpt=tmpt->last;
    dd=SqrI64(tmpt->x-x)+SqrI64(tmpt->z-z);
    if (dd<best) {
      best=dd;
      res=tmpt;
    } else
      break;
  }
  return res;
}

U0 TrackSlice(F64 *_x,F64 *_z,F64 theta,F64 d)
{
  F64 x=*_x,z=*_z,c=Cos(theta),s=Sin(theta),dx=d*s,dz=-d*c;
  Track *tmpt,*last=track_head.last;
  if (last==&track_head)
    last=NULL;

  tmpt=CAlloc(sizeof(Track));
  if (last) {
    MemCpy(&tmpt->center[0],&last->center[3],sizeof(CD3I32));
    MemCpy(&tmpt->center[1],&last->center[2],sizeof(CD3I32));
  }
  tmpt->center[2].x=x+(WIDTH/2)*c+dx;
  tmpt->center[2].z=z+(WIDTH/2)*s+dz;
  tmpt->center[2].y=DipY(tmpt->center[2].x,tmpt->center[2].z);
  tmpt->center[3].x=x-(WIDTH/2)*c+dx;
  tmpt->center[3].z=z-(WIDTH/2)*s+dz;
  tmpt->center[3].y=DipY(tmpt->center[3].x,tmpt->center[3].z);

  if (last) {
    MemCpy(&tmpt->left[0],&last->left[3],sizeof(CD3I32));
    MemCpy(&tmpt->left[1],&last->left[2],sizeof(CD3I32));
  }
  tmpt->left[2].x=x-(WIDTH/2)*c+dx;
  tmpt->left[2].z=z-(WIDTH/2)*s+dz;
  tmpt->left[2].y=DipY(tmpt->left[2].x,tmpt->left[2].z);
  tmpt->left[3].x=x-(WIDTH/2+SHOULDER)*c+dx;
  tmpt->left[3].z=z-(WIDTH/2+SHOULDER)*s+dz;
  tmpt->left[3].y=DipY(tmpt->left[3].x,tmpt->left[3].z);

  if (last) {
    MemCpy(&tmpt->right[0],&last->right[3],sizeof(CD3I32));
    MemCpy(&tmpt->right[1],&last->right[2],sizeof(CD3I32));
  }
  tmpt->right[2].x=x+(WIDTH/2+SHOULDER)*c+dx;
  tmpt->right[2].z=z+(WIDTH/2+SHOULDER)*s+dz;
  tmpt->right[2].y=DipY(tmpt->right[2].x,tmpt->right[2].z);
  tmpt->right[3].x=x+(WIDTH/2)*c+dx;
  tmpt->right[3].z=z+(WIDTH/2)*s+dz;
  tmpt->right[3].y=DipY(tmpt->right[3].x,tmpt->right[3].z);

  tmpt->x=x;
  tmpt->z=z;
  tmpt->theta=theta;
  tmpt->num=track_head.last->num+1;
  tmpt->d  =track_head.last->d+d;

  QueIns(tmpt,track_head.last);

  if (tmpt->num&1)
    tmpt->c=RED;
  else
    tmpt->c=WHITE;

  if (x<t_minx) t_minx=x;
  if (x>t_maxx) t_maxx=x;
  if (z<t_minz) t_minz=z;
  if (z>t_maxz) t_maxz=z;

  x+=dx;
  *_x=x;
  z+=dz;
  *_z=z;

  if (x<t_minx) t_minx=x;
  if (x>t_maxx) t_maxx=x;
  if (z<t_minz) t_minz=z;
  if (z>t_maxz) t_maxz=z;
}

U0 CoupleEnds()
{
  Track *first=track_head.next,*last=track_head.last;
  MemCpy(&first->center[0],&last->center[3],sizeof(CD3I32));
  MemCpy(&first->center[1],&last->center[2],sizeof(CD3I32));
  MemCpy(&first->left[0]  ,&last->left[3]  ,sizeof(CD3I32));
  MemCpy(&first->left[1]  ,&last->left[2]  ,sizeof(CD3I32));
  MemCpy(&first->right[0] ,&last->right[3] ,sizeof(CD3I32));
  MemCpy(&first->right[1] ,&last->right[2] ,sizeof(CD3I32));
}

U0 InitTrack()
{
  I64 i,j;
  Track *tmpt;
  F64 x,z,theta,d;

  MemSet(&track_head,0,sizeof(Track));
  QueInit(&track_head);

  t_minx=t_minz=I64_MAX;
  t_maxx=t_maxz=I64_MIN;

  x=0; z=0; theta=0;
  for (d=0;d<6*RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (d=0;d<RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<90;i++,theta-=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (i=0;i<90;i++,theta-=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);
  for (d=0;d<RADIUS;d+=D_S)
    TrackSlice(&x,&z,theta,D_S);
  for (i=0;i<180;i++,theta+=D_theta)
    TrackSlice(&x,&z,theta,D_theta*RADIUS);

  CoupleEnds;

  tmpt=track_head.next;
  for (i=0;i<mp_cnt;i++) {
    j=(i+1)*track_head.last->num/mp_cnt+1;
    track_start[i]=tmpt;
    while (tmpt!=&track_head && tmpt->num!=j)
      tmpt=tmpt->next;
    track_end[i]=tmpt;
  }

  t_minx-=BORDER; t_minz-=BORDER;
  t_maxx+=BORDER; t_maxz+=BORDER;
  track_map=DCNew((t_maxx-t_minx+1<<MAP_BITS-1)>>MAP_BITS,
        (t_maxz-t_minz+1<<MAP_BITS-1)>>MAP_BITS);

  track_map->color=LTGRAY;
  GrRect(track_map,0,0,track_map->width,track_map->height);
  tmpt=track_head.next;
  track_map->color=YELLOW;
  track_map->thick=3;
  while (tmpt!=&track_head) {
    GrPlot3(track_map,


// Source: D:\TempleOS-Projects\html\PsalmodyMain-Psalmody-Apps.html
// Date: unknown-date
// Language: HolyC

#define PSMR_FLAT               -8
#define PSMR_SHARP              -7
#define PSMR_TIE                -6
#define PSMR_REST               -5
#define PSMR_INS_NOTE           -4
#define PSMR_DELETE_NOTE        -3
#define PSMR_SET_WORD           -2

F64 PopUpDuration()
{
  I64 i;
  CDoc *doc=DocNew;
  DocPrint(doc,"$GREEN$$MU,\"Set Word\",LE=PSMR_SET_WORD$\n"
        "$MU,\"Toggle Sharp\",LE=PSMR_SHARP$\n"
        "$MU,\"Toggle Flat\",LE=PSMR_FLAT$\n"
        "$MU,\"Toggle Tie\",LE=PSMR_TIE$\n"
        "$MU,\"Make Rest\",LE=PSMR_REST$\n"
        "$MU,\"Insert Note\",LE=PSMR_INS_NOTE$\n"
        "$MU,\"Delete Note\",LE=PSMR_DELETE_NOTE$\n\n");
  for (i=0;i<PSM_DURATIONS_NUM;i++)
    DocPrint(doc,"$MU,\"%7.5f\",LE=%d$\n",psm_durations[i],i);
  DocPrint(doc,"\n$MU,\"CANCEL\",LE=DOCM_CANCEL$\n");
  i=PopUpMenu(doc);
  DocDel(doc);
  return i;
}

U0 PsmRightClick(I64 x,I64 y)
{
  U8 *st,*st2;
  PsmNote *tmpn,*tmpn1;
  I64 i,old_doc_flags;
  if (DocPut) old_doc_flags=DocPut->flags;
  psm.cur_note=tmpn=PsmFindNote(x,y);
  if (tmpn!=&psm.head) {
    Fs->win_inhibit=WIG_USER_TASK_DFT;
    i=PopUpDuration;
    if (0<=i<PSM_DURATIONS_NUM) {
      if (tmpn->type==PSMT_NOTE)
        tmpn->duration=i;
    } else {
      switch (i) {
        case PSMR_REST:
          if (tmpn->type==PSMT_NOTE)
            tmpn->ona=ONA_REST;
          break;
        case PSMR_SHARP:
          if (tmpn->type==PSMT_NOTE && tmpn->ona!=ONA_REST) {
            if (Btr(&tmpn->flags,PSMf_FLAT))
              tmpn->ona++;
            if (Btc(&tmpn->flags,PSMf_SHARP))
              tmpn->ona--;
            else
              tmpn->ona++;
          }
          break;
        case PSMR_FLAT:
          if (tmpn->type==PSMT_NOTE && tmpn->ona!=ONA_REST) {
            if (Btr(&tmpn->flags,PSMf_SHARP))
              tmpn->ona--;
            if (Btc(&tmpn->flags,PSMf_FLAT))
              tmpn->ona++;
            else
              tmpn->ona--;
          }
          break;
        case PSMR_TIE:
          if (tmpn->type==PSMT_NOTE)
            Btc(&tmpn->flags,PSMf_TIE);
          break;
        case PSMR_SET_WORD:
          if (tmpn->type==PSMT_NOTE) {
            if (DocPut) DocPut->flags&=~DOCF_FORM;
            if (PsmHasWords(tmpn->word))
              st2=MStrPrint("\nWord(\"%Q\"):",tmpn->word);
            else
              st2=MStrPrint("\nWord(\"\"):");
            DocBottom;
            st=GetStr(st2);
            Free(st2);
            Free(tmpn->word);
            if (*st) {
              tmpn->word=MStrPrint("%q",st);
              Free(st);
            } else
              tmpn->word=StrNew(" ");
            if (DocPut) DocPut->flags=DocPut->flags&
                    ~DOCF_FORM|old_doc_flags&DOCF_FORM;
          }
          break;
        case PSMR_INS_NOTE:
          tmpn1=PsmNoteCopy(tmpn);
          QueIns(tmpn1,tmpn);
          break;
        case PSMR_DELETE_NOTE:
          psm.cur_note=tmpn->next;
          QueRem(tmpn);
          PsmNoteDel(tmpn);
          break;
      }
    }
    PsmSetWidth(psm.cur_note);
    Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
          -WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU-WIF_SELF_CTRLS;
  }
}

U0 PsmLeftClickPickNoteBox(I64 duration)
{
  I64 o,n,msg_code,arg1,arg2;
  PsmNote *tmpn,*tmpn1;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    if (msg_code==MSG_MS_MOVE) {
      DrawDC2;
      DrawNote(psm.dc2,arg1,arg2,duration);
    }
  } while (msg_code!=MSG_MS_L_UP);
  if (arg2<13*FONT_HEIGHT) {
    if (arg1>psm.head.last->x)
      tmpn1=psm.head.last;
    else if (arg1<psm.head.next->x)
      tmpn1=&psm.head;
    else
      tmpn1=PsmFindNote(arg1-PSM_NOTE_SPACING/2,arg2);
    tmpn=CAlloc(sizeof(PsmNote));
    tmpn->type=PSMT_NOTE;
    arg2=arg2/4-15;
    n=arg2%7;
    o=4+arg2/-7;
    if (n<0) {
      n+=7;
      o++;
    }
    n=psm_note_inverse_map[n];
    if (n<3)
      o--;
    tmpn->ona=Note2Ona(n,o);
    tmpn->duration=duration;
    PsmSetWidth(tmpn);
    QueIns(tmpn,tmpn1);
    psm.cur_note=tmpn->next;
  }
  DrawDC2;
}

U0 PsmLeftClickPickMeterBox(I64 top,I64 bottom)
{
  I64 msg_code,arg1,arg2;
  PsmNote *tmpn,*tmpn1;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    if (msg_code==MSG_MS_MOVE) {
      DrawDC2;
      DrawTimeSignature(psm.dc2,arg1,arg2,top,bottom);
    }
  } while (msg_code!=MSG_MS_L_UP);
  if (arg2<13*FONT_HEIGHT) {
    if (arg1>=psm.head.x)
      tmpn1=psm.head.last;
    else if (arg1<psm.head.next->x)
      tmpn1=&psm.head;
    else
      tmpn1=PsmFindNote(arg1-PSM_NOTE_SPACING/2,arg2);
    tmpn=CAlloc(sizeof(PsmNote));
    tmpn->type=PSMT_METER;
    tmpn->meter_top=top;
    tmpn->meter_bottom=bottom;
    PsmSetWidth(tmpn);
    QueIns(tmpn,tmpn1);
    psm.cur_note=tmpn->next;
  }
  DrawDC2;
}

U0 PsmLeftClickStaffPtr(I64 x,I64 y)
{
  PsmNote *tmpn,*tmpn1;
  I64 o,n,msg_code,arg1,arg2,n_original,o_original;
  psm.cur_note=tmpn=PsmFindNote(x,y);
  if (tmpn!=&psm.head) {
    if (tmpn->type==PSMT_NOTE) {
      o_original=Ona2Octave(tmpn->ona);
      n_original=Ona2Note  (tmpn->ona);
      do {
        msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
        if (msg_code==MSG_MS_L_UP) {
          tmpn1=PsmFindNote(arg1,arg2);
          if (tmpn1==&psm.head || tmpn1==tmpn)
            goto move_note;
          else {
            Free(tmpn1->word);
            tmpn1->word=tmpn->word;
            tmpn->word=NULL;
            tmpn->ona=Note2Ona(n_original,o_original);
          }
        } else {
move_note:
          arg2=arg2/4-15;
          n=arg2%7;
          o=4+arg2/-7;
          if (n<0) {
            n+=7;
            o++;
          }
          n=psm_note_inverse_map[n];
          if (n<3)
            o--;
          tmpn->ona=Note2Ona(n,o);
        }
      } while (msg_code!=MSG_MS_L_UP);
      PsmSetWidth(tmpn);
    }
  }
}

U0 PsmLeftClickStaffBox(I64 x,I64 y)
{
  I64 msg_code,arg1,arg2;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    DrawDC2;
    psm.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
    GrBorder(psm.dc

[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\PsalmodyMain-Psalmody-Apps.html
// Date: unknown-date
// Language: HolyC

#define PSMR_FLAT               -8
#define PSMR_SHARP              -7
#define PSMR_TIE                -6
#define PSMR_REST               -5
#define PSMR_INS_NOTE           -4
#define PSMR_DELETE_NOTE        -3
#define PSMR_SET_WORD           -2

F64 PopUpDuration()
{
  I64 i;
  CDoc *doc=DocNew;
  DocPrint(doc,"$GREEN$$MU,\"Set Word\",LE=PSMR_SET_WORD$\n"
        "$MU,\"Toggle Sharp\",LE=PSMR_SHARP$\n"
        "$MU,\"Toggle Flat\",LE=PSMR_FLAT$\n"
        "$MU,\"Toggle Tie\",LE=PSMR_TIE$\n"
        "$MU,\"Make Rest\",LE=PSMR_REST$\n"
        "$MU,\"Insert Note\",LE=PSMR_INS_NOTE$\n"
        "$MU,\"Delete Note\",LE=PSMR_DELETE_NOTE$\n\n");
  for (i=0;i<PSM_DURATIONS_NUM;i++)
    DocPrint(doc,"$MU,\"%7.5f\",LE=%d$\n",psm_durations[i],i);
  DocPrint(doc,"\n$MU,\"CANCEL\",LE=DOCM_CANCEL$\n");
  i=PopUpMenu(doc);
  DocDel(doc);
  return i;
}

U0 PsmRightClick(I64 x,I64 y)
{
  U8 *st,*st2;
  PsmNote *tmpn,*tmpn1;
  I64 i,old_doc_flags;
  if (DocPut) old_doc_flags=DocPut->flags;
  psm.cur_note=tmpn=PsmFindNote(x,y);
  if (tmpn!=&psm.head) {
    Fs->win_inhibit=WIG_USER_TASK_DFT;
    i=PopUpDuration;
    if (0<=i<PSM_DURATIONS_NUM) {
      if (tmpn->type==PSMT_NOTE)
        tmpn->duration=i;
    } else {
      switch (i) {
        case PSMR_REST:
          if (tmpn->type==PSMT_NOTE)
            tmpn->ona=ONA_REST;
          break;
        case PSMR_SHARP:
          if (tmpn->type==PSMT_NOTE && tmpn->ona!=ONA_REST) {
            if (Btr(&tmpn->flags,PSMf_FLAT))
              tmpn->ona++;
            if (Btc(&tmpn->flags,PSMf_SHARP))
              tmpn->ona--;
            else
              tmpn->ona++;
          }
          break;
        case PSMR_FLAT:
          if (tmpn->type==PSMT_NOTE && tmpn->ona!=ONA_REST) {
            if (Btr(&tmpn->flags,PSMf_SHARP))
              tmpn->ona--;
            if (Btc(&tmpn->flags,PSMf_FLAT))
              tmpn->ona++;
            else
              tmpn->ona--;
          }
          break;
        case PSMR_TIE:
          if (tmpn->type==PSMT_NOTE)
            Btc(&tmpn->flags,PSMf_TIE);
          break;
        case PSMR_SET_WORD:
          if (tmpn->type==PSMT_NOTE) {
            if (DocPut) DocPut->flags&=~DOCF_FORM;
            if (PsmHasWords(tmpn->word))
              st2=MStrPrint("\nWord(\"%Q\"):",tmpn->word);
            else
              st2=MStrPrint("\nWord(\"\"):");
            DocBottom;
            st=GetStr(st2);
            Free(st2);
            Free(tmpn->word);
            if (*st) {
              tmpn->word=MStrPrint("%q",st);
              Free(st);
            } else
              tmpn->word=StrNew(" ");
            if (DocPut) DocPut->flags=DocPut->flags&
                    ~DOCF_FORM|old_doc_flags&DOCF_FORM;
          }
          break;
        case PSMR_INS_NOTE:
          tmpn1=PsmNoteCopy(tmpn);
          QueIns(tmpn1,tmpn);
          break;
        case PSMR_DELETE_NOTE:
          psm.cur_note=tmpn->next;
          QueRem(tmpn);
          PsmNoteDel(tmpn);
          break;
      }
    }
    PsmSetWidth(psm.cur_note);
    Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS
          -WIF_SELF_BORDER-WIF_FOCUS_TASK_MENU-WIF_SELF_CTRLS;
  }
}

U0 PsmLeftClickPickNoteBox(I64 duration)
{
  I64 o,n,msg_code,arg1,arg2;
  PsmNote *tmpn,*tmpn1;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    if (msg_code==MSG_MS_MOVE) {
      DrawDC2;
      DrawNote(psm.dc2,arg1,arg2,duration);
    }
  } while (msg_code!=MSG_MS_L_UP);
  if (arg2<13*FONT_HEIGHT) {
    if (arg1>psm.head.last->x)
      tmpn1=psm.head.last;
    else if (arg1<psm.head.next->x)
      tmpn1=&psm.head;
    else
      tmpn1=PsmFindNote(arg1-PSM_NOTE_SPACING/2,arg2);
    tmpn=CAlloc(sizeof(PsmNote));
    tmpn->type=PSMT_NOTE;
    arg2=arg2/4-15;
    n=arg2%7;
    o=4+arg2/-7;
    if (n<0) {
      n+=7;
      o++;
    }
    n=psm_note_inverse_map[n];
    if (n<3)
      o--;
    tmpn->ona=Note2Ona(n,o);
    tmpn->duration=duration;
    PsmSetWidth(tmpn);
    QueIns(tmpn,tmpn1);
    psm.cur_note=tmpn->next;
  }
  DrawDC2;
}

U0 PsmLeftClickPickMeterBox(I64 top,I64 bottom)
{
  I64 msg_code,arg1,arg2;
  PsmNote *tmpn,*tmpn1;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    if (msg_code==MSG_MS_MOVE) {
      DrawDC2;
      DrawTimeSignature(psm.dc2,arg1,arg2,top,bottom);
    }
  } while (msg_code!=MSG_MS_L_UP);
  if (arg2<13*FONT_HEIGHT) {
    if (arg1>=psm.head.x)
      tmpn1=psm.head.last;
    else if (arg1<psm.head.next->x)
      tmpn1=&psm.head;
    else
      tmpn1=PsmFindNote(arg1-PSM_NOTE_SPACING/2,arg2);
    tmpn=CAlloc(sizeof(PsmNote));
    tmpn->type=PSMT_METER;
    tmpn->meter_top=top;
    tmpn->meter_bottom=bottom;
    PsmSetWidth(tmpn);
    QueIns(tmpn,tmpn1);
    psm.cur_note=tmpn->next;
  }
  DrawDC2;
}

U0 PsmLeftClickStaffPtr(I64 x,I64 y)
{
  PsmNote *tmpn,*tmpn1;
  I64 o,n,msg_code,arg1,arg2,n_original,o_original;
  psm.cur_note=tmpn=PsmFindNote(x,y);
  if (tmpn!=&psm.head) {
    if (tmpn->type==PSMT_NOTE) {
      o_original=Ona2Octave(tmpn->ona);
      n_original=Ona2Note  (tmpn->ona);
      do {
        msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
        if (msg_code==MSG_MS_L_UP) {
          tmpn1=PsmFindNote(arg1,arg2);
          if (tmpn1==&psm.head || tmpn1==tmpn)
            goto move_note;
          else {
            Free(tmpn1->word);
            tmpn1->word=tmpn->word;
            tmpn->word=NULL;
            tmpn->ona=Note2Ona(n_original,o_original);
          }
        } else {
move_note:
          arg2=arg2/4-15;
          n=arg2%7;
          o=4+arg2/-7;
          if (n<0) {
            n+=7;
            o++;
          }
          n=psm_note_inverse_map[n];
          if (n<3)
            o--;
          tmpn->ona=Note2Ona(n,o);
        }
      } while (msg_code!=MSG_MS_L_UP);
      PsmSetWidth(tmpn);
    }
  }
}

U0 PsmLeftClickStaffBox(I64 x,I64 y)
{
  I64 msg_code,arg1,arg2;
  do {
    msg_code=GetMsg(&arg1,&arg2,1<<MSG_MS_L_UP|1<<MSG_MS_MOVE);
    DrawDC2;
    psm.dc2->color=ROPF_DITHER+WHITE<<16+BLACK;
    GrBorder(psm.dc


[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\childish-Psalmody-Examples-Apps.html
// Date: unknown-date
// Language: HolyC

//9 has words
U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Be \0like \0 \0a \0 \0child \0 \0 \0 \0"
            "some \0 \0re\0 \0spect.\n\0 \0 \0 \0 \0 \0");
      Play("5qEsCDCDqCDeEGsE4B5E4B5eC4B5sD4A5D4A",
            "Ma\0tur\0 \0i\0 \0ty \0 \0 \0 \0don't \0 \0"
            "ne\0 \0glect.\n\0 \0 \0 \0 \0 \0");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
      Play("4eB5DqF4sGAGAqAAA5etD4AA5sD4B5D4B");
    }
  } catch
    PutExcept;
  Snd;
}

Song;


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

#help_index "Misc/TOS"

#define VIDEO_FRAME_RATE        29.97

#define FG_JUST_AUDIO   0
#define FG_BOOT_DRV     1
#define FG_RAM_DRV      2
I64     fg_mode=FG_RAM_DRV;
Bool    fg_on =FALSE;

U0 FrameGrabberTask(I64)
{//#!/bin/bash
//for f in ./ScrnShots/*.Z; do ./Bin/TOSZ $f; done
  //ffmpeg -r 8 -i VID%05d.BMP -y Movie.avi
  I64 frame_num=0;
  U8  buf[STR_LEN],buf2[STR_LEN],*st_dir;
  F64 end_time=tS;
  Silent;       //no output to scrn
  if (fg_mode==FG_RAM_DRV)
    st_dir="B:/Tmp/ScrnShots";
  else
    st_dir="::/Tmp/ScrnShots";
  DirMk(st_dir);
  while (fg_on) {
    StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
    StrCpy(buf2,buf);
    BMPScrnCapture(buf);
    while (TRUE) {
      end_time+=1.0/VIDEO_FRAME_RATE;
      if (end_time<tS) {
        StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
        Copy(buf2,buf);
      } else
        break;
    }
    SleepUntil(cnts.jiffies+(end_time-tS)*JIFFY_FREQ);
  }
}

I64 CopyVideo()
{
  I64 res=0;
  Del("D:/Tmp/*.SND");
  if (fg_mode==FG_JUST_AUDIO)
    SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35,2.5);
  else {
    SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35);
    DelTree("D:/Tmp/ScrnShots");
    if (fg_mode==FG_RAM_DRV) {
      res=CopyTree("B:/Tmp/ScrnShots","D:/Tmp/ScrnShots");
      "Unused Space: %12.6fMeg\n",DrvUnused('B')/1024.0/1024.0;
    } else
      res=CopyTree("::/Tmp/ScrnShots","D:/Tmp/ScrnShots");
    "$BK,1$Files Copied:%d$BK,0$ Time:%8.3fm\n",
          res,res/60.0/VIDEO_FRAME_RATE;
  }
  return res;
}

public U0 FrameGrabberToggle()
{//The frame grabber saves BMP files to D:/Tmp/ScrnShots.
  static F64 last_time=0;
  if (tS-last_time>3.0) {
    last_time=tS;
    if (fg_on) {
      fg_on=FALSE;
      Snd;
      wall->record=snd.record=FALSE;
      Sleep(1000);
      User("CopyVideo;Exit;\n");
    } else {
      fg_on=TRUE;
      if (fg_mode!=FG_JUST_AUDIO)
        Spawn(&FrameGrabberTask,NULL,"Frame Grabber");
      wall->record=snd.record=TRUE;
      Snd;
    }
  }
}

public U0 JukeSong(I64 num,I64 passes=2)
{//Make movie of one song.
  if (!fg_on)
    FrameGrabberToggle;
  JukeSongsPuppet("~/Sup1/Sup1Hymns",passes,num,num+1);
  if (fg_on)
    FrameGrabberToggle;
}

public U0 JukeLines(I64 start_line,I64 end_line)
{//Make movie of many lines of songs.
  if (!fg_on)
    FrameGrabberToggle;
  JukeSongsPuppet("~/Sup1/Sup1Hymns",,start_line*5,end_line*5);
  if (fg_on)
    FrameGrabberToggle;
}

public U0 DskChkAll()
{//DskChk on C & D.
  U8 *ptr=TOS_HDS;
  while (*ptr)
    DskChk(*ptr++);
}

public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
{//Use OCR to make a text DolDoc from CDC.
  U8 byte_bit_cnts[256];
  I64 i,j,*ptr,row,col,ch,best_ch,score,best_score,
        cur_char_image,diff_image,total_score=0;
  CDoc *doc=DocNew;

  MemSet(byte_bit_cnts,0,sizeof(byte_bit_cnts));
  for (i=0;i<256;i++)
    for (j=0;j<7;j++)
      if (Bt(&i,j))
        byte_bit_cnts[i]++;

  for (row=0;row<dc->height/FONT_HEIGHT;row++) {
    for (col=0;col<dc->width/FONT_WIDTH;col++) {

      cur_char_image=0;
      for (i=0;i<FONT_HEIGHT;i++)
        for (j=0;j<FONT_WIDTH;j++)
          if (GrPeek(dc,col*FONT_WIDTH+j+dx,row*FONT_HEIGHT+i+dy)!=WHITE)
            LBts(&cur_char_image,i*8+j);

      best_score=I64_MAX;
      best_ch=0;
      ptr=&text.font[32];
      for (ch=32;ch<127;ch++) {
        diff_image=*ptr++ ^ cur_char_image;
        score=0;
        for (i=0;i<8;i++)
          score+=byte_bit_cnts[diff_image.u8[i]];
        if (score<best_score) {
          best_score=score;
          best_ch=ch;
        }
      }
      if (best_ch=='$')
        DocPrint(doc,"$$");
      else
        DocPrint(doc,"%c",best_ch);
      total_score+=best_score;
    }
    DocPrint(doc,"\n");
  }
  if (_total_score) *_total_score=total_score;
  return doc;
}

public U0 BMP2Doc(U8 *_in_name,U8 *_out_name=NULL)
{//Use OCR to make a text DolDoc from BMP file.
  U8 *in_name,*out_name;
  I64 dx,dy,score,best_score=I64_MAX;
  CDC *dc;
  CDoc *doc;
  in_name=ExtDft(_in_name,"BMP");
  if (_out_name)
    out_name=ExtDft(_out_name,"DD.Z");
  else
    out_name=ExtChg(_in_name,"DD.Z");
  if (dc=BMPRead(in_name)) {
    for (dy=-3;dy<=4;dy++)
      for (dx=-3;dx<=4;dx++) {
        doc=DC2Doc(dc,dx,dy,&score);
        if (score<best_score) {
          best_score=score;
          StrCpy(&doc->filename.name,out_name);
          DocWrite(doc);
        }
        DocDel(doc);
      }
  }
  Free(in_name);
  Free(out_name);
}

U0 TOSTheme()
{
  if (!fg_on)
    PopUp("Sleep(50);FrameGrabberToggle;");
  ExeFile("~/Sup1/Sup1Graphics/TOS/TOSTheme.HC");
  DocClear;
}

#define MEM_TEST_SIZE   1024*1024
U0 MemTest()
{
  U8 *b;
  while (sys_data_bp->alloced_u8s-sys_data_bp->used_u8s>0x1000000) {
    b=MAlloc(MEM_TEST_SIZE,Fs->data_heap);
    MemSet(b,0x88,MSize(b));
    "Data:%X\n",sys_data_bp->alloced_u8s-sys_data_bp->used_u8s;
    Yield;
  }
  while (sys_code_bp->alloced_u8s-sys_code_bp->used_u8s>0x1000000) {
    b=MAlloc(MEM_TEST_SIZE,Fs->code_heap);
    MemSet(b,0x88,MSize(b));
    "Code:%X\n",sys_code_bp->alloced_u8s-sys_code_bp->used_u8s;
    Yield;
  }
}

public I64 Profanity(
        U8 *needle_filename="~/Sup1/Sup1Blog/Profanity.DD.Z",
        U8 *files_find_mask="/*",U8 *fu_flags=NULL)
{//Scan for profanity.
  CCmpCtrl *cc;
  I64 res=0;
  if (FileFind(needle_filename)) {
    cc=CmpCtrlNew(MStrPrint("#include \"%s\"",needle_filename));
    while (Lex(cc))
      if (cc->token==TK_IDENT)
        res+=Find(cc->cur_str,files_find_mask,fu_flags);
    CmpCtrlDel(cc);
  }
  return res;
}

U0 TOSChgLog2()
{
  InStr("\"Ed(\\\"::/Doc/ChgLog.DD.Z\\\");\n\";
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_UP|SCF_CTRL);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,CH_CTRLY,0);
  Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
  Msg(MSG_KEY_DOWN_UP,CH_ESC,0);"
  "\"Exit;\n\";");
}

public U0 TOSChgLog()
{//Opdate ChgLog file.
  User("TOSChgLog2;\n");
}

[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\TOSMisc-AcctExample-TOS-Demo.html
// Date: unknown-date
// Language: HolyC

#help_index "Misc/TOS"

#define VIDEO_FRAME_RATE        29.97

#define FG_JUST_AUDIO   0
#define FG_BOOT_DRV     1
#define FG_RAM_DRV      2
I64     fg_mode=FG_RAM_DRV;
Bool    fg_on =FALSE;

U0 FrameGrabberTask(I64)
{//#!/bin/bash
//for f in ./ScrnShots/*.Z; do ./Bin/TOSZ $f; done
  //ffmpeg -r 8 -i VID%05d.BMP -y Movie.avi
  I64 frame_num=0;
  U8  buf[STR_LEN],buf2[STR_LEN],*st_dir;
  F64 end_time=tS;
  Silent;       //no output to scrn
  if (fg_mode==FG_RAM_DRV)
    st_dir="B:/Tmp/ScrnShots";
  else
    st_dir="::/Tmp/ScrnShots";
  DirMk(st_dir);
  while (fg_on) {
    StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
    StrCpy(buf2,buf);
    BMPScrnCapture(buf);
    while (TRUE) {
      end_time+=1.0/VIDEO_FRAME_RATE;
      if (end_time<tS) {
        StrPrint(buf,"%s/VID%05d.BMP.Z",st_dir,frame_num++);
        Copy(buf2,buf);
      } else
        break;
    }
    SleepUntil(cnts.jiffies+(end_time-tS)*JIFFY_FREQ);
  }
}

I64 CopyVideo()
{
  I64 res=0;
  Del("D:/Tmp/*.SND");
  if (fg_mode==FG_JUST_AUDIO)
    SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35,2.5);
  else {
    SndFileCreate("D:/Tmp/Audio",0.115,0.0,WF_SQUARE,0.45,0.35);
    DelTree("D:/Tmp/ScrnShots");
    if (fg_mode==FG_RAM_DRV) {
      res=CopyTree("B:/Tmp/ScrnShots","D:/Tmp/ScrnShots");
      "Unused Space: %12.6fMeg\n",DrvUnused('B')/1024.0/1024.0;
    } else
      res=CopyTree("::/Tmp/ScrnShots","D:/Tmp/ScrnShots");
    "$BK,1$Files Copied:%d$BK,0$ Time:%8.3fm\n",
          res,res/60.0/VIDEO_FRAME_RATE;
  }
  return res;
}

public U0 FrameGrabberToggle()
{//The frame grabber saves BMP files to D:/Tmp/ScrnShots.
  static F64 last_time=0;
  if (tS-last_time>3.0) {
    last_time=tS;
    if (fg_on) {
      fg_on=FALSE;
      Snd;
      wall->record=snd.record=FALSE;
      Sleep(1000);
      User("CopyVideo;Exit;\n");
    } else {
      fg_on=TRUE;
      if (fg_mode!=FG_JUST_AUDIO)
        Spawn(&FrameGrabberTask,NULL,"Frame Grabber");
      wall->record=snd.record=TRUE;
      Snd;
    }
  }
}

public U0 JukeSong(I64 num,I64 passes=2)
{//Make movie of one song.
  if (!fg_on)
    FrameGrabberToggle;
  JukeSongsPuppet("~/Sup1/Sup1Hymns",passes,num,num+1);
  if (fg_on)
    FrameGrabberToggle;
}

public U0 JukeLines(I64 start_line,I64 end_line)
{//Make movie of many lines of songs.
  if (!fg_on)
    FrameGrabberToggle;
  JukeSongsPuppet("~/Sup1/Sup1Hymns",,start_line*5,end_line*5);
  if (fg_on)
    FrameGrabberToggle;
}

public U0 DskChkAll()
{//DskChk on C & D.
  U8 *ptr=TOS_HDS;
  while (*ptr)
    DskChk(*ptr++);
}

public CDoc *DC2Doc(CDC *dc,I64 dx=0,I64 dy=0,I64 *_total_score=NULL)
{//Use OCR to make a text DolDoc from CDC.
  U8 byte_bit_cnts[256];
  I64 i,j,*ptr,row,col,ch,best_ch,score,best_score,
        cur_char_image,diff_image,total_score=0;
  CDoc *doc=DocNew;

  MemSet(byte_bit_cnts,0,sizeof(byte_bit_cnts));
  for (i=0;i<256;i++)
    for (j=0;j<7;j++)
      if (Bt(&i,j))
        byte_bit_cnts[i]++;

  for (row=0;row<dc->height/FONT_HEIGHT;row++) {
    for (col=0;col<dc->width/FONT_WIDTH;col++) {

      cur_char_image=0;
      for (i=0;i<FONT_HEIGHT;i++)
        for (j=0;j<FONT_WIDTH;j++)
          if (GrPeek(dc,col*FONT_WIDTH+j+dx,row*FONT_HEIGHT+i+dy)!=WHITE)
            LBts(&cur_char_image,i*8+j);

      best_score=I64_MAX;
      best_ch=0;
      ptr=&text.font[32];
      for (ch=32;ch<127;ch++) {
        diff_image=*ptr++ ^ cur_char_image;
        score=0;
        for (i=0;i<8;i++)
          score+=byte_bit_cnts[diff_image.u8[i]];
        if (score<best_score) {
          best_score=score;
          best_ch=ch;
        }
      }
      if (best_ch=='$')
        DocPrint(doc,"$$");
      else
        DocPrint(doc,"%c",best_ch);
      total_score+=best_score;
    }
    DocPrint(doc,"\n");
  }
  if (_total_score) *_total_score=total_score;
  return doc;
}

public U0 BMP2Doc(U8 *_in_name,U8 *_out_name=NULL)
{//Use OCR to make a text DolDoc from BMP file.
  U8 *in_name,*out_name;
  I64 dx,dy,score,best_score=I64_MAX;
  CDC *dc;
  CDoc *doc;
  in_name=ExtDft(_in_name,"BMP");
  if (_out_name)
    out_name=ExtDft(_out_name,"DD.Z");
  else
    out_name=ExtChg(_in_name,"DD.Z");
  if (dc=BMPRead(in_name)) {
    for (dy=-3;dy<=4;dy++)
      for (dx=-3;dx<=4;dx++) {
        doc=DC2Doc(dc,dx,dy,&score);
        if (score<best_score) {
          best_score=score;
          StrCpy(&doc->filename.name,out_name);
          DocWrite(doc);
        }
        DocDel(doc);
      }
  }
  Free(in_name);
  Free(out_name);
}

U0 TOSTheme()
{
  if (!fg_on)
    PopUp("Sleep(50);FrameGrabberToggle;");
  ExeFile("~/Sup1/Sup1Graphics/TOS/TOSTheme.HC");
  DocClear;
}

#define MEM_TEST_SIZE   1024*1024
U0 MemTest()
{
  U8 *b;
  while (sys_data_bp->alloced_u8s-sys_data_bp->used_u8s>0x1000000) {
    b=MAlloc(MEM_TEST_SIZE,Fs->data_heap);
    MemSet(b,0x88,MSize(b));
    "Data:%X\n",sys_data_bp->alloced_u8s-sys_data_bp->used_u8s;
    Yield;
  }
  while (sys_code_bp->alloced_u8s-sys_code_bp->used_u8s>0x1000000) {
    b=MAlloc(MEM_TEST_SIZE,Fs->code_heap);
    MemSet(b,0x88,MSize(b));
    "Code:%X\n",sys_code_bp->alloced_u8s-sys_code_bp->used_u8s;
    Yield;
  }
}

public I64 Profanity(
        U8 *needle_filename="~/Sup1/Sup1Blog/Profanity.DD.Z",
        U8 *files_find_mask="/*",U8 *fu_flags=NULL)
{//Scan for profanity.
  CCmpCtrl *cc;
  I64 res=0;
  if (FileFind(needle_filename)) {
    cc=CmpCtrlNew(MStrPrint("#include \"%s\"",needle_filename));
    while (Lex(cc))
      if (cc->token==TK_IDENT)
        res+=Find(cc->cur_str,files_find_mask,fu_flags);
    CmpCtrlDel(cc);
  }
  return res;
}

U0 TOSChgLog2()
{
  InStr("\"Ed(\\\"::/Doc/ChgLog.DD.Z\\\");\n\";
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_UP|SCF_CTRL);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN);
  Msg(MSG_KEY_DOWN_UP,CH_CTRLY,0);
  Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT);
  Msg(MSG_KEY_DOWN_UP,CH_ESC,0);"
  "\"Exit;\n\";");
}

public U0 TOSChgLog()
{//Opdate ChgLog file.
  User("TOSChgLog2;\n");
}


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

/* To run this, do a directory, right click on
this file's name and sel "InFile".
Or, type InFile(filename);
See InFile in the glossary for more info.
*/

I64 i;
for (i=0;i<3;i++)
  "Dir;\n";

"$RED$//Press a letter to complete the mask$FG$\n";
"Dir(\"*.";
I64 ch=GetChar(,FALSE); //Prompt for first digit of mask
"%c*\");\n",ch;

[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\InDir-InFile-Demo.html
// Date: unknown-date
// Language: HolyC

/* To run this, do a directory, right click on
this file's name and sel "InFile".
Or, type InFile(filename);
See InFile in the glossary for more info.
*/

I64 i;
for (i=0;i<3;i++)
  "Dir;\n";

"$RED$//Press a letter to complete the mask$FG$\n";
"Dir(\"*.";
I64 ch=GetChar(,FALSE); //Prompt for first digit of mask
"%c*\");\n",ch;


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

U8 *old_font=text.font;

// See ::/Kernel/FontStd.HC, ::/Demo/ScrnCodes.HC,
//::/Demo/ExtChars.HC, and ::/Demo/Graphics/FontEd.HC.

U64 waves[4]={
0x0011AA440011AA44,0x0022558800225588,
0x0044AA110044AA11,0x0088552200885522};

U0 AnimateEndCB()
{
  text.font=old_font;
  Exit;
}

U0 AnimateTask(I64)
{
  I64 i;
  U64 *font=MAlloc(256*8);
  Fs->task_end_cb=&AnimateEndCB;
  MemCpy(font,text.font,256*8);
  text.font=font;
  while (TRUE) {
    font[CH_SPACE]=waves[i++&0x3];
    Sleep(100);
  }
}

Spawn(&AnimateTask,NULL,"Animate",,Fs);
TaskRep;

[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\CharAnimation-Graphics-Demo.html
// Date: unknown-date
// Language: HolyC

U8 *old_font=text.font;

// See ::/Kernel/FontStd.HC, ::/Demo/ScrnCodes.HC,
//::/Demo/ExtChars.HC, and ::/Demo/Graphics/FontEd.HC.

U64 waves[4]={
0x0011AA440011AA44,0x0022558800225588,
0x0044AA110044AA11,0x0088552200885522};

U0 AnimateEndCB()
{
  text.font=old_font;
  Exit;
}

U0 AnimateTask(I64)
{
  I64 i;
  U64 *font=MAlloc(256*8);
  Fs->task_end_cb=&AnimateEndCB;
  MemCpy(font,text.font,256*8);
  text.font=font;
  while (TRUE) {
    font[CH_SPACE]=waves[i++&0x3];
    Sleep(100);
  }
}

Spawn(&AnimateTask,NULL,"Animate",,Fs);
TaskRep;


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

//5 has graphics
#define R1      13
#define R2      21

U0 DrawIt(CTask *,CDC *dc)
{
  static F64 theta=0;
  I64 x1=200,y1=20,x2=x1,y2=y1+R2;
  F64 tt=Beat%16.0,phi;
  theta+=1/(tt*tt+1);
  dc->color=BLACK;
  dc->thick=4;
  GrCircle3(dc,x2,y2,0,R2+10);
  for (phi=theta;phi<theta+2*pi;phi+=pi/3) {
    dc->color=BLACK;
    dc->thick=2;
    GrCircle3(dc,x2+R2*Cos(phi),y2-R2*Sin(phi),0,8);
    dc->color=WHITE;
    dc->thick=2;
    GrCircle3(dc,x2+(R2+15)*Cos(phi+pi/6),y2-(R2+15)*Sin(phi+pi/6),0,3);
  }
  dc->color=BROWN;
  GrFloodFill(dc,x2+R2*Cos(phi),y2-R2*Sin(phi));
  dc->color=DKGRAY;
  GrFloodFill(dc,x2,y2);
  dc->thick=6;
  dc->color=RED;
  GrCircle3(dc,x1,y1,0,R1-6);
  dc->color=DKGRAY;
  GrCircle3(dc,x1,y1,0,R1-2);
  dc->color=LTGRAY;
  GrRect(dc,x1-2,y1-R2-1,4,10);
  GrCircle3(dc,x1,y1,0,R1);
  dc->color=RED;
  GrFloodFill(dc,x1,y1,TRUE);
  dc->color=BLACK;
  GrFloodFill(dc,x1,y1);
}

U0 Song()
{
  CTask *task;
  SettingsPush; //See SettingsPush
  Fs->draw_it=&DrawIt;
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    task=PopUpViewPrint("Mark,14:37\n");
    TaskWait(task);
    WinHorz(Fs->win_left,TEXT_COLS-10,task);
    WinVert(Fs->win_bottom+3,Fs->win_bottom+15,task);
    while (!ScanKey) {
      "$GREEN$Jesus talking...$FG$\n";
      Play("4eB5C4qBsG5D4G5DetCGFsC4B5C4B5etCG4BeB5G4sB5C4B5C",
            "Stay \0a\0wake.\n\0 \0 \0 \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("4eB5C4qBsG5D4G5DetCGFsC4B5C4B5etCG4BeB5G4sB5C4B5C",
            "Stay \0a\0wake.\n\0 \0 \0 \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("5qDsD4B5D4BetAG5G4qBGsA5D4A5DqDetGFD",
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"
            "I \0 \0am \0a \0dead \0 \0man.\n\0");
      Play("5qDsD4B5D4BetAG5G4qBGsA5D4A5DqDetGFD",
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"
            "I \0 \0am \0a \0dead \0 \0man.\n\0");
    }
  } catch
    PutExcept;
  SettingsPop;
}

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\awake-Sup1-Sup1Hymns-Home.html
// Date: unknown-date
// Language: HolyC

//5 has graphics
#define R1      13
#define R2      21

U0 DrawIt(CTask *,CDC *dc)
{
  static F64 theta=0;
  I64 x1=200,y1=20,x2=x1,y2=y1+R2;
  F64 tt=Beat%16.0,phi;
  theta+=1/(tt*tt+1);
  dc->color=BLACK;
  dc->thick=4;
  GrCircle3(dc,x2,y2,0,R2+10);
  for (phi=theta;phi<theta+2*pi;phi+=pi/3) {
    dc->color=BLACK;
    dc->thick=2;
    GrCircle3(dc,x2+R2*Cos(phi),y2-R2*Sin(phi),0,8);
    dc->color=WHITE;
    dc->thick=2;
    GrCircle3(dc,x2+(R2+15)*Cos(phi+pi/6),y2-(R2+15)*Sin(phi+pi/6),0,3);
  }
  dc->color=BROWN;
  GrFloodFill(dc,x2+R2*Cos(phi),y2-R2*Sin(phi));
  dc->color=DKGRAY;
  GrFloodFill(dc,x2,y2);
  dc->thick=6;
  dc->color=RED;
  GrCircle3(dc,x1,y1,0,R1-6);
  dc->color=DKGRAY;
  GrCircle3(dc,x1,y1,0,R1-2);
  dc->color=LTGRAY;
  GrRect(dc,x1-2,y1-R2-1,4,10);
  GrCircle3(dc,x1,y1,0,R1);
  dc->color=RED;
  GrFloodFill(dc,x1,y1,TRUE);
  dc->color=BLACK;
  GrFloodFill(dc,x1,y1);
}

U0 Song()
{
  CTask *task;
  SettingsPush; //See SettingsPush
  Fs->draw_it=&DrawIt;
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    task=PopUpViewPrint("Mark,14:37\n");
    TaskWait(task);
    WinHorz(Fs->win_left,TEXT_COLS-10,task);
    WinVert(Fs->win_bottom+3,Fs->win_bottom+15,task);
    while (!ScanKey) {
      "$GREEN$Jesus talking...$FG$\n";
      Play("4eB5C4qBsG5D4G5DetCGFsC4B5C4B5etCG4BeB5G4sB5C4B5C",
            "Stay \0a\0wake.\n\0 \0 \0 \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("4eB5C4qBsG5D4G5DetCGFsC4B5C4B5etCG4BeB5G4sB5C4B5C",
            "Stay \0a\0wake.\n\0 \0 \0 \0 \0 \0 \0 \0"
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("5qDsD4B5D4BetAG5G4qBGsA5D4A5DqDetGFD",
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"
            "I \0 \0am \0a \0dead \0 \0man.\n\0");
      Play("5qDsD4B5D4BetAG5G4qBGsA5D4A5DqDetGFD",
            " \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0"
            "I \0 \0am \0a \0dead \0 \0man.\n\0");
    }
  } catch
    PutExcept;
  SettingsPop;
}

Song;


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

VirtualBox Install
VirtualBox works on Linux or Windows.
You can look at my VirtualBox Linux Bash Scripts.  You need 512+ Meg of RAM.

Use VirtualBox to run the ISO in a virtual machine by aiming the CD/DVD at
TempleOSCD.ISO.

I don't think this works, anymore.
Install virtualbox-fuse package if you are running debian/ubuntu.
>sudo vdfuse -f image.vdi /mnt/TempleOS
>sudo mount -o loop /mnt/TempleOS/Partition2 /mnt/TempleOSD

See Virtual Box Documentation.

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

[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\InsVirtualBox-Web-Home.html
// Date: unknown-date
// Language: HolyC

VirtualBox Install
VirtualBox works on Linux or Windows.
You can look at my VirtualBox Linux Bash Scripts.  You need 512+ Meg of RAM.

Use VirtualBox to run the ISO in a virtual machine by aiming the CD/DVD at
TempleOSCD.ISO.

I don't think this works, anymore.
Install virtualbox-fuse package if you are running debian/ubuntu.
>sudo vdfuse -f image.vdi /mnt/TempleOS
>sudo mount -o loop /mnt/TempleOS/Partition2 /mnt/TempleOSD

See Virtual Box Documentation.

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


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

//5 has words

-] Reward1
  CallExtStr("JukeReward",""
  -] Reward2

    "anyhow agility Spenser's Nannie's "
    "lettering's educational Leticia's gobbler "
    "impales Susana incubators Julliard's "
    "Yahoo's Spirograph's joblessness fastenings "
    "prosecutor's quells collage's bluefish "

  );

U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
      Play("5eEEE4B5DDD4A5CCCDEC4qA",
            "Spring\0ing \0down\n\0the \0bun\0ny \0trail.\n\0"
            " \0Hap\0py \0rush.\n\0There's \0hay \0to \0bail.\n\0");
      Play("5eCEE4A5FEDEEDCDECqE",
            "Ada \0wise?\n\0 \0 \0Thun\0der \0sighs.\n\0"
            " \0 \0 \0 \0 \0Great \0big \0fail.\n\0");
      Play("eG4AqA5Ge.CsCqF4eABAGB5sFG",
            "Bob\0-n-\0 \0weave?\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("eG4AqA5Ge.CsCqF4eABA5C4B5sFG",
            "Heft\0y \0 \0heave.\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \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\codes-Sup1-Sup1Hymns-Home.html
// Date: unknown-date
// Language: HolyC

//5 has words

-] Reward1
  CallExtStr("JukeReward",""
  -] Reward2

    "anyhow agility Spenser's Nannie's "
    "lettering's educational Leticia's gobbler "
    "impales Susana incubators Julliard's "
    "Yahoo's Spirograph's joblessness fastenings "
    "prosecutor's quells collage's bluefish "

  );

U0 Song()
{
  Fs->task_end_cb=&SndTaskEndCB;
  MusicSettingsRst;
  music.tempo= 2.480;
  music.stacatto_factor= 0.902;
  try {
    while (!ScanKey) {
      Play("5eEEE4B5DDD4A5CCCDEC4qA",
            "Spring\0ing \0down\n\0the \0bun\0ny \0trail.\n\0"
            " \0Hap\0py \0rush.\n\0There's \0hay \0to \0bail.\n\0");
      Play("5eCEE4A5FEDEEDCDECqE",
            "Ada \0wise?\n\0 \0 \0Thun\0der \0sighs.\n\0"
            " \0 \0 \0 \0 \0Great \0big \0fail.\n\0");
      Play("eG4AqA5Ge.CsCqF4eABAGB5sFG",
            "Bob\0-n-\0 \0weave?\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
      Play("eG4AqA5Ge.CsCqF4eABA5C4B5sFG",
            "Heft\0y \0 \0heave.\n\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0");
    }
  } catch
    PutExcept;
  Snd;
}

Song;


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

Compiler Index

::/Doc/Asm.DD

::/Doc/Directives.DD

::/Doc/Options.DD

::/Doc/PreProcessor.DD

::/Doc/ScopingLinkage.DD

See Hello World.

[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\CompilerOverview-Doc.html
// Date: unknown-date
// Language: HolyC

Compiler Index

::/Doc/Asm.DD

::/Doc/Directives.DD

::/Doc/Options.DD

::/Doc/PreProcessor.DD

::/Doc/ScopingLinkage.DD

See Hello World.


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

#help_index "Memory/Task"
public I64 TaskMemAlloced(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task, used+unused.
  I64 res;
  if (!task) task=Fs;
  if (override_validate || TaskValidate(task)) {
    res=task->code_heap->alloced_u8s;
    if (task->code_heap!=task->data_heap)
      res+=task->data_heap->alloced_u8s;
    return res;
  } else
    return 0;
}

public I64 TaskMemUsed(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task and in use.
  I64 res;
  if (!task) task=Fs;
  if (override_validate || TaskValidate(task)) {
    res=task->code_heap->used_u8s;
    if (task->data_heap!=task->code_heap)
      res+=task->data_heap->used_u8s;
    return res;
  } else
    return 0;
}

#help_index "Memory/Task;Debugging/Heap;Memory/Debugging"
public Bool HeapRep(CTask *task)
{//Report status of task's heap.
  I64 i,cnt;
  CMemUnused *uum;

  if (!task || task==Fs) {
    "Task can't HeapRep on self.\n";
    return FALSE;
  }
  if (!TaskValidate(task)) return FALSE;

  PUSHFD
  CLI
  while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
    PAUSE
  if (task->data_heap!=task->code_heap)
    while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
      PAUSE

  for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
    cnt=0;
    uum=task->code_heap->heap_hash[i];
    while (uum) {
      cnt+=uum->size;
      uum=uum->next;
    }
    if (task->data_heap!=task->code_heap) {
      uum=task->data_heap->heap_hash[i];
      while (uum) {
        cnt+=uum->size;
        uum=uum->next;
      }
    }
    if (cnt)
      "%03X:%08X\n",i<<3,cnt;
  }
  '\n';

  uum=task->code_heap->malloc_free_lst;
  while (uum) {
    "%X, ",uum->size;
    uum=uum->next;
  }
  if (task->data_heap!=task->code_heap) {
    uum=task->data_heap->malloc_free_lst;
    while (uum) {
      "%X, ",uum->size;
      uum=uum->next;
    }
  }

  if (task->data_heap!=task->code_heap)
    LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
  LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
  POPFD

  '\n';
}

#help_index "Memory/HeapCtrl;Debugging/Heap;Memory/Debugging"
public Bool IsInHeapCtrl(U8 *a,CHeapCtrl *hc,Bool lock=TRUE)
{//Check addr if in HeapCtrl.
  CMemBlk *m;
  PUSHFD
  CLI
  if (lock)
    while (LBts(&hc->locked_flags,HClf_LOCKED))
      PAUSE
  m=hc->next_mem_blk;
  while (m!=&hc->next_mem_blk) {
    if (a>=m && a<m(U8 *)+m->pags<<MEM_PAG_BITS) {
      if (lock)
        LBtr(&hc->locked_flags,HClf_LOCKED);
      POPFD
      return TRUE;
    }
    m=m->next;
  }
  if (lock)
    LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return FALSE;
}

public Bool HeapCtrlWalk(CHeapCtrl *hc)
{//Check integrity of HeapCtrl.
  I64 i;
  CMemUnused *uum;

  PUSHFD
  CLI
  while (LBts(&hc->locked_flags,HClf_LOCKED))
    PAUSE

  for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
    uum=hc->heap_hash[i];
    while (uum) {
      if (!IsInHeapCtrl(uum,hc,FALSE))
        goto hc_false;
      uum=uum->next;
    }
  }
  uum=hc->malloc_free_lst;
  while (uum) {
    if (!IsInHeapCtrl(uum,hc,FALSE))
      goto hc_false;
    uum=uum->next;
  }

  #if _CFG_HEAP_DBG
  CMemUsed *um,*um1;
  um1=(&hc->next_um)(U8 *)-offset(CMemUsed.next);
  um=um1->next;
  while (um!=um1) {
    if (!IsInHeapCtrl(um,hc,FALSE))
      goto hc_false;
    um=um->next;
  }
#endif

  LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return TRUE;

  hc_false:
  LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return FALSE;
}

#help_index "Memory/Task;Debugging/Heap;Memory/Debugging"
public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
{//Check addr if in task's heaps.
  if (!task) task=Fs;
  if (TaskValidate(task) && (IsInHeapCtrl(a,task->code_heap,lock)||
        task->data_heap!=task->code_heap &&
        IsInHeapCtrl(a,task->data_heap,lock)))
    return TRUE;
  else
    return FALSE;
}

public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heaps.
  if (!task) task=Fs;
  if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) ||
        task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
    return FALSE;
  else
    return TRUE;
}

[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\AMem-Adam.html
// Date: unknown-date
// Language: HolyC

#help_index "Memory/Task"
public I64 TaskMemAlloced(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task, used+unused.
  I64 res;
  if (!task) task=Fs;
  if (override_validate || TaskValidate(task)) {
    res=task->code_heap->alloced_u8s;
    if (task->code_heap!=task->data_heap)
      res+=task->data_heap->alloced_u8s;
    return res;
  } else
    return 0;
}

public I64 TaskMemUsed(CTask *task=NULL,Bool override_validate=FALSE)
{//Count of bytes alloced to a task and in use.
  I64 res;
  if (!task) task=Fs;
  if (override_validate || TaskValidate(task)) {
    res=task->code_heap->used_u8s;
    if (task->data_heap!=task->code_heap)
      res+=task->data_heap->used_u8s;
    return res;
  } else
    return 0;
}

#help_index "Memory/Task;Debugging/Heap;Memory/Debugging"
public Bool HeapRep(CTask *task)
{//Report status of task's heap.
  I64 i,cnt;
  CMemUnused *uum;

  if (!task || task==Fs) {
    "Task can't HeapRep on self.\n";
    return FALSE;
  }
  if (!TaskValidate(task)) return FALSE;

  PUSHFD
  CLI
  while (LBts(&task->code_heap->locked_flags,HClf_LOCKED))
    PAUSE
  if (task->data_heap!=task->code_heap)
    while (LBts(&task->data_heap->locked_flags,HClf_LOCKED))
      PAUSE

  for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
    cnt=0;
    uum=task->code_heap->heap_hash[i];
    while (uum) {
      cnt+=uum->size;
      uum=uum->next;
    }
    if (task->data_heap!=task->code_heap) {
      uum=task->data_heap->heap_hash[i];
      while (uum) {
        cnt+=uum->size;
        uum=uum->next;
      }
    }
    if (cnt)
      "%03X:%08X\n",i<<3,cnt;
  }
  '\n';

  uum=task->code_heap->malloc_free_lst;
  while (uum) {
    "%X, ",uum->size;
    uum=uum->next;
  }
  if (task->data_heap!=task->code_heap) {
    uum=task->data_heap->malloc_free_lst;
    while (uum) {
      "%X, ",uum->size;
      uum=uum->next;
    }
  }

  if (task->data_heap!=task->code_heap)
    LBtr(&task->data_heap->locked_flags,HClf_LOCKED);
  LBtr(&task->code_heap->locked_flags,HClf_LOCKED);
  POPFD

  '\n';
}

#help_index "Memory/HeapCtrl;Debugging/Heap;Memory/Debugging"
public Bool IsInHeapCtrl(U8 *a,CHeapCtrl *hc,Bool lock=TRUE)
{//Check addr if in HeapCtrl.
  CMemBlk *m;
  PUSHFD
  CLI
  if (lock)
    while (LBts(&hc->locked_flags,HClf_LOCKED))
      PAUSE
  m=hc->next_mem_blk;
  while (m!=&hc->next_mem_blk) {
    if (a>=m && a<m(U8 *)+m->pags<<MEM_PAG_BITS) {
      if (lock)
        LBtr(&hc->locked_flags,HClf_LOCKED);
      POPFD
      return TRUE;
    }
    m=m->next;
  }
  if (lock)
    LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return FALSE;
}

public Bool HeapCtrlWalk(CHeapCtrl *hc)
{//Check integrity of HeapCtrl.
  I64 i;
  CMemUnused *uum;

  PUSHFD
  CLI
  while (LBts(&hc->locked_flags,HClf_LOCKED))
    PAUSE

  for (i=0;i<MEM_HEAP_HASH_SIZE>>3;i++) {
    uum=hc->heap_hash[i];
    while (uum) {
      if (!IsInHeapCtrl(uum,hc,FALSE))
        goto hc_false;
      uum=uum->next;
    }
  }
  uum=hc->malloc_free_lst;
  while (uum) {
    if (!IsInHeapCtrl(uum,hc,FALSE))
      goto hc_false;
    uum=uum->next;
  }

  #if _CFG_HEAP_DBG
  CMemUsed *um,*um1;
  um1=(&hc->next_um)(U8 *)-offset(CMemUsed.next);
  um=um1->next;
  while (um!=um1) {
    if (!IsInHeapCtrl(um,hc,FALSE))
      goto hc_false;
    um=um->next;
  }
#endif

  LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return TRUE;

  hc_false:
  LBtr(&hc->locked_flags,HClf_LOCKED);
  POPFD
  return FALSE;
}

#help_index "Memory/Task;Debugging/Heap;Memory/Debugging"
public Bool IsInHeap(U8 *a,CTask *task=NULL,Bool lock=TRUE)
{//Check addr if in task's heaps.
  if (!task) task=Fs;
  if (TaskValidate(task) && (IsInHeapCtrl(a,task->code_heap,lock)||
        task->data_heap!=task->code_heap &&
        IsInHeapCtrl(a,task->data_heap,lock)))
    return TRUE;
  else
    return FALSE;
}

public Bool HeapWalk(CTask *task=NULL)
{//Check integrity of task's heaps.
  if (!task) task=Fs;
  if (!TaskValidate(task) || !HeapCtrlWalk(task->code_heap) ||
        task->data_heap!=task->code_heap && !HeapCtrlWalk(task->data_heap))
    return FALSE;
  else
    return TRUE;
}


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

/*This does a really crappy job of
suggesting spellings.  Write a better
one for fun.
*/

U8 *SuggestMatchForm(U8 *src)
{
  I64 ch,ch1=0;
  U8 *res=MStrUtil(src,SUF_TO_UPPER),*dst;
  dst=src=res;
  while (ch=*src++)  {
    if (!StrOcc("AEIOU",ch)) {
      if (ch=='C') ch='K';
      if (ch=='Z') ch='S';
      if (ch!=ch1) //double chars to single
        *dst++=ch;
    }
    ch1=ch;
  }
  *dst=0;
  return res;
}

/*Fmt of word lst entry:
  U8 ACD_WORD_CHAR
  U8 word[] with terminating zero
  I16 block; //definition offset in ::/Adam/AutoComplete/ACDefs.DATA
*/

Bool SuggestSpelling(U8 *word)
{
  U8 *dict=acd.word_lst,
        *pf=SuggestMatchForm(word),
        *wf;
  I64 len=StrLen(pf),
        num_cols=Fs->win_width/16,
        col=0;
  if (len)
    while (*dict) {
      wf=SuggestMatchForm(dict+1);
      if (!StrNCmp(pf,wf,len)) {
        "%16s",dict+1;
        if (++col>=num_cols) {
          col=0;
          '\n';
        }
      }
      Free(wf);
      dict+=StrLen(dict+1)+4;
    }
  Free(pf);
  '\n';
  return ToBool(len);
}

U0 SuggestSpellingDemo()
{
  U8 *w;
  while (TRUE) {
    w=GetStr("Word:");
    if (*w) {
      SuggestSpelling(w);
      Free(w);
    } else
      break;
  }
}

//If you "Adam Include" this file, it will
//install this command as a hot-key.

U0 CtrlAltL(I64)
{
//ac.cur_word is only set if AutoComplete
  //is running.
  if (!TaskValidate(ac.task)) {
    AutoComplete(ON);
    Sleep(500);
  }
  PopUp("if (SuggestSpelling(ac.cur_word)) View;");
}

if (Fs!=adam_task)
  SuggestSpellingDemo;
else {
  CtrlAltCBSet('L',&CtrlAltL,"Cmd /Suggest Spelling");
//Appears in the Adam Task Window
  "<CTRL-ALT-l> installed\n";
}

//Note: It would be more appropriate
//to define a key in MyPutKey().

[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\SuggestSpelling-Demo.html
// Date: unknown-date
// Language: HolyC

/*This does a really crappy job of
suggesting spellings.  Write a better
one for fun.
*/

U8 *SuggestMatchForm(U8 *src)
{
  I64 ch,ch1=0;
  U8 *res=MStrUtil(src,SUF_TO_UPPER),*dst;
  dst=src=res;
  while (ch=*src++)  {
    if (!StrOcc("AEIOU",ch)) {
      if (ch=='C') ch='K';
      if (ch=='Z') ch='S';
      if (ch!=ch1) //double chars to single
        *dst++=ch;
    }
    ch1=ch;
  }
  *dst=0;
  return res;
}

/*Fmt of word lst entry:
  U8 ACD_WORD_CHAR
  U8 word[] with terminating zero
  I16 block; //definition offset in ::/Adam/AutoComplete/ACDefs.DATA
*/

Bool SuggestSpelling(U8 *word)
{
  U8 *dict=acd.word_lst,
        *pf=SuggestMatchForm(word),
        *wf;
  I64 len=StrLen(pf),
        num_cols=Fs->win_width/16,
        col=0;
  if (len)
    while (*dict) {
      wf=SuggestMatchForm(dict+1);
      if (!StrNCmp(pf,wf,len)) {
        "%16s",dict+1;
        if (++col>=num_cols) {
          col=0;
          '\n';
        }
      }
      Free(wf);
      dict+=StrLen(dict+1)+4;
    }
  Free(pf);
  '\n';
  return ToBool(len);
}

U0 SuggestSpellingDemo()
{
  U8 *w;
  while (TRUE) {
    w=GetStr("Word:");
    if (*w) {
      SuggestSpelling(w);
      Free(w);
    } else
      break;
  }
}

//If you "Adam Include" this file, it will
//install this command as a hot-key.

U0 CtrlAltL(I64)
{
//ac.cur_word is only set if AutoComplete
  //is running.
  if (!TaskValidate(ac.task)) {
    AutoComplete(ON);
    Sleep(500);
  }
  PopUp("if (SuggestSpelling(ac.cur_word)) View;");
}

if (Fs!=adam_task)
  SuggestSpellingDemo;
else {
  CtrlAltCBSet('L',&CtrlAltL,"Cmd /Suggest Spelling");
//Appears in the Adam Task Window
  "<CTRL-ALT-l> installed\n";
}

//Note: It would be more appropriate
//to define a key in MyPutKey().


// Source: D:\TempleOS-Projects\html\honestly-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.758;
  try {
    while (!ScanKey) {
      Play("4qBeABqAGABhG",
            "Earn\0est\0y?  \0 \0 \0Not \0the \0best.\n\0");
      Play("5sCCCC4qBsAAAAqG5sCCCCqE4GR",
            "Grov\0 \0el\0 \0ing?  \0 \0 \0 \0 \0 \0"
            "What \0 \0 \0 \0a \0mess.\n\0 \0");
      Play("4sB5D4B5D4AGAGetAA5EsGCGCetFFEqDFeE4G",
            "Cre\0 \0a\0 \0tion \0 \0 \0 \0st\0or\0y \0 \0 \0 \0 \0"
            "is \0 \0 \0 \0quite \0hip\0stir!\n\0");
      Play("4sB5D4B5D4AGAGetAA5EsGCGCetFFEqDFeE4G",
            "(Rec\0 \0re\0 \0a\0 \0tion\0 \0 \0 \0al \0 \0 \0 \0 \0"
            "bad \0 \0 \0 \0 \0trip\0stir.)\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\honestly-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.758;
  try {
    while (!ScanKey) {
      Play("4qBeABqAGABhG",
            "Earn\0est\0y?  \0 \0 \0Not \0the \0best.\n\0");
      Play("5sCCCC4qBsAAAAqG5sCCCCqE4GR",
            "Grov\0 \0el\0 \0ing?  \0 \0 \0 \0 \0 \0"
            "What \0 \0 \0 \0a \0mess.\n\0 \0");
      Play("4sB5D4B5D4AGAGetAA5EsGCGCetFFEqDFeE4G",
            "Cre\0 \0a\0 \0tion \0 \0 \0 \0st\0or\0y \0 \0 \0 \0 \0"
            "is \0 \0 \0 \0quite \0hip\0stir!\n\0");
      Play("4sB5D4B5D4AGAGetAA5EsGCGCetFFEqDFeE4G",
            "(Rec\0 \0re\0 \0a\0 \0tion\0 \0 \0 \0al \0 \0 \0 \0 \0"
            "bad \0 \0 \0 \0 \0trip\0stir.)\n\0");
    }
  } catch
    PutExcept;
  Snd;
}

Song;


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

Old TempleOS Videos
The keys that I press are shown in the upper right corner during the videos.

    The Grand Vision                    TempleOS Grand Tour
#1: TempleOS Tour                       Yet Another Tour
#2: TempleOS Tour                       Clean Kernel Rebuild and MakeAll
#1: Compiler Walk-Through               Debugging
#2: Compiler Walk-Through               Start-Up Code (Older Video)
#1: User Interface Tutorial             Terry Davis' Account Files
#2: User Interface Tutorial             New Scheme for Home Directory.  Account Files Explained
#1: System Guide                        Having Fun. Task Record and CPUCore Record
#2: System Guide                        Adam Directory
#3: System Guide                        Kernel Code Overview
#1: Bad Code Find Tool                  Seductive Destructive Fun
#2: Bad Code Find Tool                  Mini JIT Compiler (Warm-Up)
    Assembler/Compiler Code Walk-Thru   Accts, Adam, Passwords, FindFiles, FOpen, Include, RootDir
    RedSea FileSystem                   RedSea Disk Clus Fun
    X-Caliber, RawHide, Wenceslas       FlatTop
    Hilarious Angry Rant

[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\OldTOSVideos-Web-Home.html
// Date: unknown-date
// Language: HolyC

Old TempleOS Videos
The keys that I press are shown in the upper right corner during the videos.

    The Grand Vision                    TempleOS Grand Tour
#1: TempleOS Tour                       Yet Another Tour
#2: TempleOS Tour                       Clean Kernel Rebuild and MakeAll
#1: Compiler Walk-Through               Debugging
#2: Compiler Walk-Through               Start-Up Code (Older Video)
#1: User Interface Tutorial             Terry Davis' Account Files
#2: User Interface Tutorial             New Scheme for Home Directory.  Account Files Explained
#1: System Guide                        Having Fun. Task Record and CPUCore Record
#2: System Guide                        Adam Directory
#3: System Guide                        Kernel Code Overview
#1: Bad Code Find Tool                  Seductive Destructive Fun
#2: Bad Code Find Tool                  Mini JIT Compiler (Warm-Up)
    Assembler/Compiler Code Walk-Thru   Accts, Adam, Passwords, FindFiles, FOpen, Include, RootDir
    RedSea FileSystem                   RedSea Disk Clus Fun
    X-Caliber, RawHide, Wenceslas       FlatTop
    Hilarious Angry Rant


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

U0 MemDemo()
{
  I64 i;
"$HL,1$$BLACK$
#define MEM_PAG_BITS            9
#define MEM_PAG_SIZE            (1<<MEM_PAG_BITS)
#define MEM_HEAP_HASH_SIZE      1024
#define MEM_FREE_PAG_HASH_SIZE  0x100
#define MEM_EXTRA_HASH2_PAGS    2

public class CBlkPool
{
  CMemBlk *free_pag_hash[MEM_FREE_PAG_HASH_SIZE],
          *free_pag_hash2[64-MEM_PAG_BITS];
};

public class CHeapCtrl
{
  CBlkPool *bp;
  CMemUnused *heap_hash[MEM_HEAP_HASH_SIZE/sizeof(U8 *)];
};

public class CTask //The Fs segment reg points to current CTask.
{
  CHeapCtrl *code_heap,*data_heap;
};
$HL,0$$FG$

";

  "$PURPLE$Chunks in increments of 8 bytes, owned by the task.$FG$\n";
  for (i=sizeof(CMemUnused);i<MEM_HEAP_HASH_SIZE;i+=8)
    if (i==0x48)
      "...\n";
    else if (!(0x48<i<0x3C8))
      "Fs->data_heap->heap_hash[%X/8]"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
  "\n\n";

  "$PURPLE$Pages of 512 bytes, owned by the system.$FG$\n";
  for (i=MEM_HEAP_HASH_SIZE;i<MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE;
        i+=MEM_PAG_SIZE)
    if (i==0x1200)
      "...\n";
    else if (!(0x1200<i<0x1F200))
      "Fs->data_heap->bp->free_pag_hash[%X/512]"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
  "\n\n";

  "$PURPLE$Powers of two, owned by the system.$FG$\n";
  for (i=Bsf(MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE);i<64;i++)
    if (i==0x1A)
      "...\n";
    else if (!(0x1A<=i<=0x36))
      "Fs->data_heap->bp->free_pag_hash2[%X] %016X"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i,
          1<<i+MEM_EXTRA_HASH2_PAGS*MEM_PAG_SIZE;
  "\n\n";
}

MemDemo;

[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\MemDemo-Demo.html
// Date: unknown-date
// Language: HolyC

U0 MemDemo()
{
  I64 i;
"$HL,1$$BLACK$
#define MEM_PAG_BITS            9
#define MEM_PAG_SIZE            (1<<MEM_PAG_BITS)
#define MEM_HEAP_HASH_SIZE      1024
#define MEM_FREE_PAG_HASH_SIZE  0x100
#define MEM_EXTRA_HASH2_PAGS    2

public class CBlkPool
{
  CMemBlk *free_pag_hash[MEM_FREE_PAG_HASH_SIZE],
          *free_pag_hash2[64-MEM_PAG_BITS];
};

public class CHeapCtrl
{
  CBlkPool *bp;
  CMemUnused *heap_hash[MEM_HEAP_HASH_SIZE/sizeof(U8 *)];
};

public class CTask //The Fs segment reg points to current CTask.
{
  CHeapCtrl *code_heap,*data_heap;
};
$HL,0$$FG$

";

  "$PURPLE$Chunks in increments of 8 bytes, owned by the task.$FG$\n";
  for (i=sizeof(CMemUnused);i<MEM_HEAP_HASH_SIZE;i+=8)
    if (i==0x48)
      "...\n";
    else if (!(0x48<i<0x3C8))
      "Fs->data_heap->heap_hash[%X/8]"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
  "\n\n";

  "$PURPLE$Pages of 512 bytes, owned by the system.$FG$\n";
  for (i=MEM_HEAP_HASH_SIZE;i<MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE;
        i+=MEM_PAG_SIZE)
    if (i==0x1200)
      "...\n";
    else if (!(0x1200<i<0x1F200))
      "Fs->data_heap->bp->free_pag_hash[%X/512]"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i;
  "\n\n";

  "$PURPLE$Powers of two, owned by the system.$FG$\n";
  for (i=Bsf(MEM_FREE_PAG_HASH_SIZE*MEM_PAG_SIZE);i<64;i++)
    if (i==0x1A)
      "...\n";
    else if (!(0x1A<=i<=0x36))
      "Fs->data_heap->bp->free_pag_hash2[%X] %016X"
          "$BLACK$ -->$FG$[X]$BLACK$ -->$FG$[X]$BLACK$ -->$FG$\n",i,
          1<<i+MEM_EXTRA_HASH2_PAGS*MEM_PAG_SIZE;
  "\n\n";
}

MemDemo;