856
Calculator C / Re: [68k] Storing a value into n?
« on: June 03, 2012, 04:07:24 pm »Indeed, you're right, http://debrouxl.github.com/gcc4ti/htretval.html indicates that RETURN_VALUE can take an argumentWell, since the modified code works, I'm going to use it. But I have another problem.
I didn't remember about that capability, or even using it, but since I once compiled and ran all GCC4TI examples (finding and fixing several bugs inherited from TIGCC in the process), I did use it...
So I'm not sure at all why blue_bear_94's original code doesn't work...
Code: [Select]
// C Source File
// Created 6/3/2012; 2:16:41 PM
// Decthyth General 68k Libraries
#include <tigcclib.h>
//#define RETURN_VALUE n
void DlgError(const char* msg)
{
DlgMessage("Error",msg,BT_CANCEL,BT_NONE);
}
void WriteToNInt(long n)
{
push_longint(n);
VarStore(SYMSTR("n"),STOF_ESI,0,top_estack);
}
void WriteToNFloat(float n)
{
push_Float(n);
VarStore(SYMSTR("n"),STOF_ESI,0,top_estack);
}
short show_picvar (SYM_STR SymName, short x, short y, short Attr)
{
SYM_ENTRY *sym_entry = SymFindPtr (SymName, 0);
if (!sym_entry) return FALSE;
if (peek (HToESI (sym_entry->handle)) != PIC_TAG) return FALSE;
BitmapPut (x, y, HeapDeref (sym_entry->handle) + 2, ScrRect, Attr);
return TRUE;
}
// Main Function
/*
NOTE: When I say that a function returns a value,
I mean that the value is stored to n.
*/
void _main(void)
{
int mode;
unsigned char a;
ESI argptr=top_estack;
a=GetArgType(argptr);
if (a!=POSINT_TAG)
{
DlgError("First arg must be + int");
return;
}
mode=GetIntArg(argptr);
switch (mode)
{
case 0:
WriteToNFloat(0.11);
break;
case 1:
SYM_STR name;
int x,y,attr;
a=GetArgType(argptr);
if (a!=STR_TAG)
{
DlgError("Arg 2 must be string");
return;
}
name=GetSymstrArg(argptr);
a=GetArgType(argptr);
if (a!=POSINT_TAG)
{
DlgError("Arg 3 must be + int");
return;
}
x=GetIntArg(argptr);
a=GetArgType(argptr);
if (a!=POSINT_TAG)
{
DlgError("Arg 4 must be + int");
return;
}
y=GetIntArg(argptr);
a=GetArgType(argptr);
if (a!=POSINT_TAG)
{
DlgError("Arg 5 must be + int");
return;
}
attr=GetIntArg(argptr);
//*A_REVERSE, *A_NORMAL, *A_XOR, *A_SHADED, *A_REPLACE, *A_OR, *A_AND, A_THICK1, A_SHADE_V, A_SHADE_H, A_SHADE_NS, A_SHADE_PS
if (attr>=7)
{
DlgError("Wrong attribute");
return;
}
if (!show_picvar(name,x,y,attr))
{
DlgError("Pic does not exist");
}
}
}
produces an error "Expected expression before SYM_STR".Edit: Fixed. However, I am trying to see if a list has any true entries; here is my code. What do you suggest?
Code: [Select]
case 19:
a=GetArgType(argptr);
if (a!=LIST_TAG)
{
DlgError("Arg 2 must be list");
return;
}
temp3=argptr;
do
{
temp3=next_expression_index(temp3);
} while (!(*temp3==TRUE_TAG||*temp3==LIST_END_TAG||*temp3==END_TAG));
WriteToNBool(*temp3==TRUE_TAG);
WriteToNBool is a function to write a Boolean value to n:Code: [Select]
void WriteToNBool(int n)
{
push_quantum(0x2B+!!n);
VarStore(SYMSTR("n"),STOF_ESI,0,top_estack);
}