/** * Set retval to internal ID for requested Native Feature, * or zero if feature is unknown/unsupported. * * Return true if caller is to proceed normally, * false if there was an exception. */ bool NatFeat_ID(Uint32 stack, Uint32 *retval) { const char *name; Uint32 ptr; int i; ptr = STMemory_ReadLong(stack); if ( !STMemory_CheckAreaType ( ptr, FEATNAME_MAX, ABFLAG_RAM | ABFLAG_ROM ) ) { M68000_BusError(ptr, BUS_ERROR_READ, BUS_ERROR_SIZE_BYTE, BUS_ERROR_ACCESS_DATA); return false; } name = (const char *)STMemory_STAddrToPointer ( ptr ); LOG_TRACE(TRACE_NATFEATS, "NF ID(0x%x \"%s\")\n", ptr, name); for (i = 0; i < ARRAYSIZE(features); i++) { if (strcmp(features[i].name, name) == 0) { *retval = IDX2MASTERID(i); return true; } } /* unknown feature */ *retval = 0; return true; }
/** * Set retval to internal ID for requested Native Feature, * or zero if feature is unknown/unsupported. * * Return true if caller is to proceed normally, * false if there was an exception. */ bool NatFeat_ID(Uint32 stack, Uint32 *retval) { const char *name; Uint32 ptr; int i; ptr = STMemory_ReadLong(stack); if (!STMemory_ValidArea(ptr, FEATNAME_MAX)) { M68000_BusError(ptr, BUS_ERROR_READ); return false; } name = (const char *)STRAM_ADDR(ptr); Dprintf(("NF ID(0x%x)\n", ptr)); Dprintf((" \"%s\"\n", name)); for (i = 0; i < ARRAYSIZE(features); i++) { if (strcmp(features[i].name, name) == 0) { *retval = IDX2MASTERID(i); return true; } } /* unknown feature */ *retval = 0; return true; }
uint32 nf_get_id(memptr stack) { char name[80]; memptr name_ptr = ReadInt32(stack); Atari2HostSafeStrncpy(name, name_ptr, sizeof(name)); D(bug("nf_get_id '%s'", name)); for(unsigned int i=0; i < nf_objs_cnt; i++) { if (strcasecmp(name, nf_objects[i]->name()) == 0) { D(bug("Found the NatFeat at %d", i)); return IDX2MASTERID(i); } } return 0; /* ID with given name not found */ }