Emulator: code formatting
This commit is contained in:
parent
4bf29638ca
commit
882f258ad8
@ -26,8 +26,7 @@ typedef struct {
|
|||||||
} Machine;
|
} Machine;
|
||||||
|
|
||||||
|
|
||||||
Device *machine_find_device(Machine *self, zuint16 port)
|
Device *machine_find_device(Machine *self, zuint16 port) {
|
||||||
{
|
|
||||||
zusize index = 0;
|
zusize index = 0;
|
||||||
|
|
||||||
for (; index < self->device_count; index++)
|
for (; index < self->device_count; index++)
|
||||||
@ -35,40 +34,35 @@ Device *machine_find_device(Machine *self, zuint16 port)
|
|||||||
return &self->devices[index];
|
return &self->devices[index];
|
||||||
|
|
||||||
return Z_NULL;
|
return Z_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static zuint8 machine_cpu_read(Machine *self, zuint16 address)
|
static zuint8 machine_cpu_read(Machine *self, zuint16 address) {
|
||||||
{
|
|
||||||
return address < MEMORY_SIZE ? self->memory[address] : 0xFF;
|
return address < MEMORY_SIZE ? self->memory[address] : 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void machine_cpu_write(Machine *self, zuint16 address, zuint8 value)
|
static void machine_cpu_write(Machine *self, zuint16 address, zuint8 value) {
|
||||||
{
|
|
||||||
if (address >= ROM_SIZE && address < MEMORY_SIZE)
|
if (address >= ROM_SIZE && address < MEMORY_SIZE)
|
||||||
self->memory[address] = value;
|
self->memory[address] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static zuint8 machine_cpu_in(Machine *self, zuint16 port)
|
static zuint8 machine_cpu_in(Machine *self, zuint16 port) {
|
||||||
{
|
|
||||||
Device *device = machine_find_device(self, port);
|
Device *device = machine_find_device(self, port);
|
||||||
|
|
||||||
return device != Z_NULL ? device->read(device->context) : 0xFF;
|
return device != Z_NULL ? device->read(device->context) : 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void machine_cpu_out(Machine *self, zuint16 port, zuint8 value)
|
static void machine_cpu_out(Machine *self, zuint16 port, zuint8 value) {
|
||||||
{
|
|
||||||
Device *device = machine_find_device(self, port);
|
Device *device = machine_find_device(self, port);
|
||||||
|
|
||||||
if (device != Z_NULL) device->write(device->context, value);
|
if (device != Z_NULL) device->write(device->context, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void machine_initialize(Machine *self)
|
void machine_initialize(Machine *self) {
|
||||||
{
|
|
||||||
self->cpu.context = self;
|
self->cpu.context = self;
|
||||||
self->cpu.fetch_opcode =
|
self->cpu.fetch_opcode =
|
||||||
self->cpu.fetch =
|
self->cpu.fetch =
|
||||||
@ -90,11 +84,10 @@ void machine_initialize(Machine *self)
|
|||||||
self->cpu.options = Z80_MODEL_ZILOG_NMOS;
|
self->cpu.options = Z80_MODEL_ZILOG_NMOS;
|
||||||
|
|
||||||
/* Create and initialize devices... */
|
/* Create and initialize devices... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void machine_power(Machine *self, zbool state)
|
void machine_power(Machine *self, zbool state) {
|
||||||
{
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
self->cycles = 0;
|
self->cycles = 0;
|
||||||
@ -102,13 +95,12 @@ void machine_power(Machine *self, zbool state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
z80_power(&self->cpu, state);
|
z80_power(&self->cpu, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void machine_reset(Machine *self)
|
void machine_reset(Machine *self) {
|
||||||
{
|
|
||||||
z80_instant_reset(&self->cpu);
|
z80_instant_reset(&self->cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void machine_run(Machine *self) {
|
void machine_run(Machine *self) {
|
||||||
z80_run(&self->cpu, Z80_MAXIMUM_CYCLES);
|
z80_run(&self->cpu, Z80_MAXIMUM_CYCLES);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user