User:Zzo38/Emulator plugin format
From NESdev Wiki
Jump to navigationJump to search
Mapper
#define OPEN_BUS 0xFFFF #define CIRAM_BANK_0 0x8000 #define CIRAM_BANK_1 0x8400 #define BUS_CONFLICT 0x1000 typedef struct Mapper { // Provided by host NSF_Interface*nsf; const U8*prg_rom; U8*prg_ram; U8*prg_battery_ram; const U8*chr_rom; U8*chr_ram; U8*chr_battery_ram; // Provided by plugin void(*destroy)(Mapper*); void(*reset)(Mapper*); U16(*prg_read)(Mapper*,U16); U16(*prg_write)(Mapper*,U16,U8); U16(*chr_access)(Mapper*,U16); U16(*chr_read)(Mapper*,U16); U16(*chr_write)(Mapper*,U16,U8); void(*quick_save)(Mapper*,U8*); void(*quick_restore)(Mapper*,U8*); } Mapper; typedef struct Mapper_Info { U8 version; // R U8 mirroring; // R U16 id; // R U32 prg_rom_size; // R U32 prg_ram_size; // R/W U32 prg_battery_ram_size; // R/W U32 chr_rom_size; // R U32 chr_ram_size; // R/W U32 chr_battery_ram_size; // R/W FILE*ines; // R int save_size; // W U8 audio_ext; // W } Mapper_Info; int define_mapper(U16 id,const char*name,(Mapper*)(*init)(Mapper_Info*));
Input device
typedef struct InputDevice { // Provided by host U16 sound; // class 0 only U8 light; void(*irq_write)(InputDevice*,int); // class 0 only int(*irq_read)(InputDevice*); // class 0 only void(*display)(InputDevice*,UserDisplay*); // Provided by plugin void(*destroy)(InputDevice*); void(*connect)(InputDevice*); void(*disconnect)(InputDevice*); U8(*read)(InputDevice*); U8(*read_other)(InputDevice*); // class 0 only void(*write)(InputDevice*,U8); void(*note_off)(InputDevice*,U8,U8,U8); void(*note_on)(InputDevice*,U8,U8,U8); void(*key_pressure)(InputDevice*,U8,U8,U8); void(*parameter)(InputDevice*,U8,U8,U8); void(*program)(InputDevice*,U8,U8); void(*channel_pressure)(InputDevice*,U8,U8); void(*pitch_wheel)(InputDevice*,U8,U16); void(*sysex)(InputDevice*,U8*,U32); void(*tune_request)(InputDevice*); } InputDevice; int define_input_device(const char*name,int class,(InputDevice*)(*init)(void));