diff --git a/pat80-emulator/main.c b/pat80-emulator/main.c index 828651c..0cd1971 100644 --- a/pat80-emulator/main.c +++ b/pat80-emulator/main.c @@ -26,8 +26,7 @@ typedef struct { } Machine; -Device *machine_find_device(Machine *self, zuint16 port) - { +Device *machine_find_device(Machine *self, zuint16 port) { zusize index = 0; for (; index < self->device_count; index++) @@ -35,40 +34,35 @@ Device *machine_find_device(Machine *self, zuint16 port) return &self->devices[index]; 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; - } +} -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) 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); 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); 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.fetch_opcode = self->cpu.fetch = @@ -90,11 +84,10 @@ void machine_initialize(Machine *self) self->cpu.options = Z80_MODEL_ZILOG_NMOS; /* Create and initialize devices... */ - } +} -void machine_power(Machine *self, zbool state) - { +void machine_power(Machine *self, zbool state) { if (state) { self->cycles = 0; @@ -102,13 +95,12 @@ void machine_power(Machine *self, zbool state) } z80_power(&self->cpu, state); - } +} -void machine_reset(Machine *self) - { +void machine_reset(Machine *self) { z80_instant_reset(&self->cpu); - } +} void machine_run(Machine *self) { z80_run(&self->cpu, Z80_MAXIMUM_CYCLES); @@ -166,4 +158,4 @@ int main(int argc, char *argv[]) { machine_power(&pat80, Z_TRUE); machine_reset(&pat80); machine_run(&pat80); -} \ No newline at end of file +}