Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DopefishJustin
Created February 26, 2012 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DopefishJustin/1918971 to your computer and use it in GitHub Desktop.
Save DopefishJustin/1918971 to your computer and use it in GitHub Desktop.
Testcase for emscripten issue 131
#include <stdio.h>
typedef void genf(void);
union cpuinfo
{
long long i;
void * p;
genf * f;
char * s;
genf * setinfo;
genf * init;
genf * reset;
genf * exit;
genf * execute;
genf * burn;
genf * translate;
genf * read;
genf * write;
genf * readop;
genf * debug_init;
genf * disassemble;
genf * import_state;
genf * export_state;
genf * import_string;
genf * export_string;
int * icount;
genf * internal_map8;
genf * internal_map16;
genf * internal_map32;
genf * internal_map64;
genf * default_map8;
genf * default_map16;
genf * default_map32;
genf * default_map64;
};
class legacy_cpu_device;
typedef void (*cpu_get_info_func)(legacy_cpu_device *device, unsigned int state, cpuinfo *info);
void cpu_get_info_z80(legacy_cpu_device *device, unsigned int state, cpuinfo *info)
{
info->i = 132;
}
class legacy_cpu_device {
public:
legacy_cpu_device();
protected:
cpu_get_info_func m_get_info;
long long get_legacy_int(unsigned int state) const;
};
legacy_cpu_device::legacy_cpu_device()
{
m_get_info = &cpu_get_info_z80;
int tokenbytes = get_legacy_int(0x04000);
printf("tokenbytes is %i\n", tokenbytes);
//if (tokenbytes == 0)
// throw emu_fatalerror("Device %s specifies a 0 context size!\n", tag);
}
long long legacy_cpu_device::get_legacy_int(unsigned int state) const
{
union cpuinfo info = { 0 };
printf("doing get_legacy_int for state %u\n",state);
(*m_get_info)(const_cast<legacy_cpu_device *>(this), state, &info);
printf("info.i is now %lld\n", info.i);
return info.i;
}
int main() {
legacy_cpu_device *bar = new legacy_cpu_device;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment