Skip to content

Commit

Permalink
Documentation WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
redcode committed Sep 22, 2023
1 parent 46a5ac9 commit 868c012
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions documentation/Usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Usage
#include <Z/constants/pointer.h> /* Z_NULL */
#include <Z80.h>
#define CYCLES_PER_FRAME 69888
#define CYCLES_AT_INT 24
#define CYCLES_PER_INT 32
#define ROM_SIZE 0x4000 /* 16 KiB */
#define MEMORY_SIZE 0x8000 /* 32 KiB */
typedef struct {
void* context;
zuint8 (* read)(void *context);
Expand Down Expand Up @@ -37,13 +43,14 @@ Usage
static zuint8 machine_cpu_read(Machine *self, zuint16 address)
{
return self->memory[address];
return address < MEMORY_SIZE ? self->memory[address] : 0xFF;
}
static void machine_cpu_write(Machine *self, zuint16 address, zuint8 value)
{
self->memory[address] = value;
if (address >= ROM_SIZE && address < MEMORY_SIZE)
self->memory[address] = value;
}
Expand All @@ -66,6 +73,7 @@ Usage
void machine_initialize(Machine *self)
{
self->cycles = 0;
self->cpu.context = self;
self->cpu.fetch_opcode =
self->cpu.fetch =
self->cpu.nop =
Expand All @@ -91,11 +99,7 @@ Usage
void machine_power(Machine *self, zboolean state)
{
if (state)
{
memset(self->memory, 0, 65536);
}
if (state) memset(self->memory, 0, 65536);
z80_power(&self->cpu, state);
}
Expand All @@ -106,10 +110,6 @@ Usage
}
#define CYCLES_PER_FRAME 69888
#define CYCLES_AT_INT 24
#define CYCLES_PER_INT 32
void machine_run_frame(Machine *self)
{
self->cycles += z80_execute(&self->cpu, CYCLES_AT_INT - self->cycles);
Expand Down

0 comments on commit 868c012

Please sign in to comment.