Home Download Musics Developers
API Sources Tools File Format Technicals

emu68 library documentation.


Detailed Description

68000 emulator.

Author:
Benjamin Gerard <ben@sashipa.com>


Files

file  emu68.h
 68K emulator API header.


Modules

68k emulator core
 The core of the 68k emulator.

Error message stack
 EMU68 error handling consists on a fixed size stack of messages.

68k IO plugger
 IO plugging and mapping facilities.

68k memory and IO manager
 Handling memory and I/O access.

Status Register (SR) definitions
 68K status register definitions.

Type definitions
 Definition of types used by EMU68 and SC68 related projects.


EMU68 internal struct access

io68_tEMU68_set_interrupt_io (io68_t *io)
 Set new interrupt IO.

void EMU68_set_registers (const reg68_t *r)
 Copy specified register set to EMU68 internal register set.

void EMU68_get_registers (reg68_t *r)
 Copy EMU68 internal register set to specified register set.

void EMU68_set_cycle (u32 cycle)
 Set EMU68 internal cycle counter.

u32 EMU68_get_cycle (void)
 Get EMU68 internal cycle counter.

reg68_t reg68
 EMU68 internal 68K register set structure.


Init functions

void EMU68_reset (void)
 68K Hardware Reset.

int EMU68_init (u8 *buffer, u32 maxmem)
 First time init.

void EMU68_kill (void)
 Clean exit.


EMU68 on-board memory access

int EMU68_memvalid (u32 dest, u32 sz)
 Check if a memory block is in 68K on-board memory range.

u8 EMU68_peek (u32 addr)
 Get byte in 68K onboard memory.

u8 EMU68_poke (u32 addr, u8 v)
 Put a byte in 68K onboard memory.

int EMU68_memput (u32 dest, u8 *src, u32 sz)
 Put a memory block to 68K on-board memory.

int EMU68_memget (u8 *dest, u32 src, u32 sz)
 Get 68K on-board memory into a memory block.


Execution functions

void EMU68_step (void)
 Execute one instruction.

void EMU68_level_and_interrupt (u32 cycleperpass)
 Execute until RTS.

void EMU68_cycle (u32 cycleperpass)
 Execute for given number of cycle.

void EMU68_break (u32 breakpc)
 Execute until PC reachs breakpoint.


Version checking functions

int EMU68_debugmode (void)
 Get EMU68 debug mode.


Function Documentation

io68_t* EMU68_set_interrupt_io io68_t io  ) 
 

Set new interrupt IO.

This version of EMU68 was specially build for SC68. For optimization purposes only one IO plugged chip could interrupt processor.

Parameters:
io Pointer to the only IO that could eventually interrupt.
Returns:
Pointer to previous interrupt IO.

void EMU68_reset void   ) 
 

68K Hardware Reset.

Perform following operations :

  • PC = 0
  • SR = 2700
  • A7 = end of mem - 4
  • All registers cleared
  • All IO reseted

int EMU68_init u8 buffer,
u32  maxmem
 

First time init.

The EMU68_init() function initializes the 68k emulator. The maxmem parameter is the size of the 68K memory. The function checks if its value is valid. It must be a power of 2 in the range [2^17..2^24], 128Kb to 16 Mb.

Warning:
- In normal mode (EMU68DEBUG not defined), the buffer must be 3 bytes larger than maxmem to prevent an overflow error that is not checked when accessing last bytes of memory as a long.
  • In debug mode (EMU68DEBUG defined) the buffer must be twice the maxmem value for the memory access control flags.
Parameters:
buffer 68K memory buffer.
maxmem 68K memory amount in byte (power of 2 only).
Returns:
error-code
Return values:
0 Success
<0 Failure

int EMU68_memvalid u32  dest,
u32  sz
 

Check if a memory block is in 68K on-board memory range.

Returns:
error-code
Return values:
0 Success
<0 Failure

u8 EMU68_peek u32  addr  ) 
 

Get byte in 68K onboard memory.

See also:
EMU68_poke()

u8 EMU68_poke u32  addr,
u8  v
 

Put a byte in 68K onboard memory.

See also:
EMU68_peek()

int EMU68_memput u32  dest,
u8 src,
u32  sz
 

Put a memory block to 68K on-board memory.

The function copy a memory block in 68K on-board memory after verifying that the operation access valid 68K memory.

See also:
EMU68_memget()

EMU68_memvalid()

int EMU68_memget u8 dest,
u32  src,
u32  sz
 

Get 68K on-board memory into a memory block.

The function copy a 68K on-board memory to a memory location after verifying that the operation access valid 68K memory.

See also:
EMU68_memput()

EMU68_memvalid()

void EMU68_level_and_interrupt u32  cycleperpass  ) 
 

Execute until RTS.

This function runs an emulation loop until stack address becomes higher than its value at start. After what, the interruption are tested and executed for this pass, with an execution time given in parameter whatever the time passed in the execution loop. This function is very specific to SC68 implementation.

void EMU68_break u32  breakpc  ) 
 

Execute until PC reachs breakpoint.

Parameters:
breakpc Breakpoint location

int EMU68_debugmode void   ) 
 

Get EMU68 debug mode.

Returns:
compile time debug mode
Return values:
0 normal mode.
1 debug mode.