TIP: Click on subject to list as thread! ANSI
echo: cbm
to: ALL
from: HARRY POTTER
date: 2019-12-23 11:32:00
subject: Help needed debugging Tmp

Hi! I have yet to find the bug with my Template Creator 128 program. The Add
Template module seems to work up to the call to Fields. The debug code I placed
just after the call seems to run. But then, it does not display the New Format
prompt--even 
though it is supposed to, as it is a new template disk--and displays an Insert
Templates Disk message. I insert it and get the C128 Monitor. The PC is at
F4433, where there is no code there. Following is the erroneous code:
-------------------------
void tmp_add_main (void)
{
 //unsigned char i;
 //unsigned char /*i,*/ j;
        //char c;
 //struct dbentry* cur;
 //bzero (&tmp_db, sizeof(tmp_db));
 //bzero (&input, sizeof(input));
 //cleardb ();
//bordercolor (0);cgetc ();
 //bzero (&input, sizeof(input));
//bordercolor (1);cgetc ();
 instmpdiskp();

        tmpdb_open ();
//bgcolor (2);
 /*curtemplate.name[0]=*///input.fmt[0]=0;
 //fName.data.text=curtemplate.name;//input.name;
 fTmp.data.text=input.out;//input.tmp;
 //fType.data.sel.sel=(cur->filetype=0);
 fType.data.sel.num=4;
 fType.data.sel.values=filetypes;
 //input.type=0;
 fType.data.sel.sel=&input.type;
 //fFmt.data.text=curtemplate.fmt;//input.fmt;
 //FillFmt();
 i=fFmt.data.sel.num=input.fmtnum=input.type=0;
//bgcolor (3);
 for (; i<8; ++i) {
  //if (tmp_db.usedfmts&(1<>i)&1) {
   //usedfmts[j]=tmp_db.fmts[i];
   //*getfmt(fFmt.data.sel.num)=getfmt (usedfmtsnums[fFmt.data.sel.num]=i);
   usedfmts[fFmt.data.sel.num]=tmp_db.fmts[
(usedfmtsnums[fFmt.data.sel.num]=i)];
   //usedfmtsnums[j]=i;
   ++fFmt.data.sel.num;
  }
 }
//bgcolor (4);
 if (fFmt.data.sel.num<8) {
  //*getfmt(fFmt.data.sel.num)=snone;
  usedfmts[fFmt.data.sel.num]=snone;
  ++fFmt.data.sel.num;
 }
 //numfmtsavail=j;
 //input.fmtnum=0;
 fFmt.data.sel.sel=&input.fmtnum;
 //fFmt.data.sel.num=numfmtsavail;
 fFmt.data.sel.values=usedfmts;
        //cclearxy(i=0,23,39); cclearxy(0,24,39);
 i=j=input.tmp[0]=input.out[0]=0;
 //clearline (23); clearline (24);

 //gotoxy (0,24); prints ("Insert template disk...");
 //cgetc();
 //promptdisk (instmpdisk);
 //for (; i>3]&(1<<(i&7))); ++i);
 //for (; i<32 && *(unsigned long*)(&tmp_db.usedentries)&(1<j)&1; ++j);
 if (j==32) {
  //gotoxy (0, 23);  printscr ("Template disk full!\n"
  //     "Press any key to continue...");
  ///cgetc(); return;
  promptdisk ("Template disk full!"); return;
 }
 //cur=getdbent(j);//&tmp_db.entry[i];
 //fName.data.text=(cur=getent(j))->name;
 //fName.data.text=(cur=getdbent(j))->name;
 //cur=getdbent(j);
 //cur=getent(j);
 //input.type=0;
 //fFmt.data.text=&(cur=getent(j))->filetype;
 fTmp.data.text=input.tmp;
 fName.data.text=input.out;//cur->name;
//bgcolor (1);

 if (dialog(&fInTemp)) return;

bgcolor (3); cgetc ();

 cur=getent(j);
 //strcpy (cur->name, input.tmp);
 //cur->filetype=input.type;
//bgcolor (3); cgetc ();
 if (!strcmp(usedfmts[input.fmtnum], snone))
 //if (usedfmts[input.fmtnum]==snone)
 {
//bgcolor (4); cgetc ();
  for (i=0; (tmp_db.usedfmts>>i)&1; ++i);
//bgcolor (5); cgetc ();
  gotoy (17); 
//bgcolor (6); cgetc ();
  printf ("\nNew format name");
  GetInput (getfmt(i), 17);
  tmp_db.usedfmts|=1<fmt=i;
 //gotoxy (0,24); prints ("Insert input disk...   ");
 //cgetc();
 promptdisk ("Insert input disk...");
 //strcpy (curtemplate.name, input.tmp);
 //strcpy (curtemplate.fmt, input.fmt);
 //sprintf (fi,"0:%s,%c,r", input.name, filetypes[input.type][0]);
 //strcpy (curtemplate.name, input.tmp);
 //strcpy (curtemplate.fmt, input.fmt);
 //j=filetypes[input.type][0];
 //sprintf (fi,"%s,%c", curtemplate.name, filetypes[input.type][0]);
 //sprintf (fi, "%s,%c", curtemplate.name, j=filetypes[input.type][0]);
 //sprintf (fi, &qfilename[2], curtemplate.name,
j=filetypes[cur->filetype=input.type][0]);
//cputsxy (0,1, fi); cgetc();
 //cbm_open (filenum, 8, CBM_READ, fi);
 //openfile (CBM_READ);
 //openfile (curtemplate.name, CBM_READ);
 //openfile (cur->name, CBM_READ);
//promptdisk (input.tmp);
bgcolor (4); cgetc();//
 openfile (input.out, CBM_READ);
bgcolor (2);
#ifdef __C128__
 cur->size=/*curtemplate.size=*/bank1_cbm_read(filenum, 0x400, 0xF000);
#else
 cur->size=/*curtemplate.size=*/h_cbm_read(filenum, templatedata, 0x9800);
#endif
 //cur->size=h_cbm_read(filenum, curtemplate.data, 32767);
 //curtemplate.size=cbm_read(filenum, curtemplate.data, 32767);
bgcolor (3);
 cbm_close (filenum);
//chn15();
//clrscr(); printf ("size = %d\n", curtemplate.size); cgetc();
 //if ((signed) curtemplate.size<0) {
 if ((signed) cur->size==-1) {
  //gotobottom (); puts ("Error loading template!");
  //cgetc(); return;
  promptdisk ("Error loading template!");
  return;
 }
 //if (curtemplate.size==32767) {
 //if ((int)curtemplate.size<0) {
 if (!cbm_k_readst()&0x40) {
  //gotobottom (); puts ("Template too large!");
  //cgetc(); return;
  promptdisk ("Template too large!");
  return;
 }

 //strcpy (tmp_db.entry[i].name, curtemplate.name);
 strcpy (cur->name, input.tmp);
 //strcpy (cur->name, input.tmp);
 //cur->size=curtemplate.size;
 cur->filetype=input.type;
 //tmp_db.usedentries[i>>3]|=(1<<(i&7));
 __asm__ ("\tlda\t_j\n"
   //"\tpha\n"
   "\tand\t#7\n"
   "\ttay\n"
   //"\tpla\n"
   "\tlda\t_j\n"
   "\tlsr\n"
   "\tlsr\n"
   "\tlsr\n"
   "\ttax\n"
   //"\tlda\t_tmp_db+17,x\n"
   "\tlda\t#1\n"
   "\tcpy\t#0\n"
   "\tbeq\t@zz12\n"
   "@zz11:\n"
   "\tasl\n"
   "\tdey\n"
   "\tbne\t@zz11\n"
   "@zz12:\n"
   "\tora\t_tmp_db+18,x\n"
   "\tsta\t_tmp_db+18,x\n"
   );
 //*(unsigned long*)(&tmp_db.usedentries)|=(1<name, CBM_WRITE);
//printf ("ST: %d\n", (unsigned) cbm_k_readst()); cgetc();
 //h_cbm_write (filenum, curtemplate.data, cur->size=curtemplate.size);
#ifdef __C128__
 bank1_cbm_write (filenum, 0x400, cur->size);
#else
 h_cbm_write (filenum, templatedata, cur->size);
#endif
 //cbm_write (filenum, curtemplate.data, curtemplate.size);
//chn15();
 cbm_close (filenum);
}
-------------------------

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.