Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

cpudll.c File Reference


Detailed Description

This dll creates a cpu thread in which cpu is running. Also handles correct cpu timing and functionality of interrupt mechanism.

Definition in file cpudll.c.#include <windows.h>
#include <stdlib.h>
#include <tchar.h>
#include "../dllkit/dllkit.h"
#include "cpu.h"
#include "../usrmsgs.h"

Go to the source code of this file.

Enumerations

enum  THRSTATE { NOTSTARTED, RUNNING, ENDED }
enum  INTR { NONE, IRQ, NMI, RESET }

Functions

DWORD WINAPI CpuThreadFunc (LPVOID lpParam)
 The main thread function.

void CreateCpuThread ()
 Creates a new CPU thread.

void ExitCpuThread ()
 Kills this thread.

void ContExe ()
 Executes needed amount of instructions.

BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
 Dll entry point.

DLLEXPORT void __cdecl InitDll (INITDLLSTRUCT *ids, INITDLLINFO *idi)
 Inits dll data structures.

DLLEXPORT void __cdecl OnMessage (MESSAGEDLLSTRUCT *mds)
 Recieves registered messages from emu6502 application.

DLLEXPORT void __cdecl IOFunc (UINT adr, unsigned char *data, iomode mode)
 IO function mapped into some adress in memory.


Variables

UINT Freq = 1790000
UINT Frms = 1790
UINT start
UINT total
UINT secstart
UINT ticks
BOOL volatile Running
THRSTATE volatile ThreadState
INTR volatile Interrupt
HANDLE CpuThreadHandle
DWORD CpuThreadID
HANDLE hThisModule
MSGLIST Msgs
INITDLLSTRUCT info


Function Documentation

void ContExe  
 

Executes needed amount of instructions.

Executes appropriate amount of instructions according to given frequency. secstart must be set by CreateCpuThread() when called the first time

See also:
CreateCpuThread()

Definition at line 219 of file cpudll.c.

DWORD WINAPI CpuThreadFunc LPVOID    lpParam
 

The main thread function.

This function is called by CreateCpuThread()

Parameters:
lpParam  Value of this param doesn't matter
Returns :
Nothing

Definition at line 202 of file cpudll.c.

void CreateCpuThread  
 

Creates a new CPU thread.

Creates a new thread in which processor is running. Called by DllMain when loading this dll.

See also:
CpuThreadFunc , DllMain , ExitCpuThread

Definition at line 187 of file cpudll.c.

BOOL APIENTRY DllMain HANDLE    hModule,
DWORD    ul_reason_for_call,
LPVOID    lpReserved
 

Dll entry point.

Definition at line 62 of file cpudll.c.

void ExitCpuThread  
 

Kills this thread.

See also:
CreateCpuThread()

Definition at line 250 of file cpudll.c.

DLLEXPORT void __cdecl InitDll INITDLLSTRUCT   ids,
INITDLLINFO   idf
 

Inits dll data structures.

This function is called after dll is loaded. You have to implement this function. Useful informations are passed in its parameter. Also create, fill with messages to be catched and return MSGLIST structure.

Parameters:
ids  An INITDLLSTRUCT structure containig informations about calling emu6502 application.
idf  An INITDLLINFO structure which should be filled in this function
Note: if io memory boundaries to be reserved for this plugin are in conflict with some other plugin, previous settings will be overwritten!
Returns :
Filled MSGLIST of messages to be catched and forwarded to this plugin
See also:
OnMessage(MESSAGEDLLSTRUCT* mds) , INITDLLSTRUCT , INITDLLINFO

Definition at line 75 of file cpudll.c.

DLLEXPORT void __cdecl IOFunc UINT    adr,
unsigned char *    data,
iomode    mode
 

IO function mapped into some adress in memory.

Called directly when accesing adress to which is this function bound. Always write this function.

Parameters:
adr  Adress being accessed
data  Byte being read/written
mode  see iomode

Definition at line 172 of file cpudll.c.

DLLEXPORT void __cdecl OnMessage MESSAGEDLLSTRUCT   mds
 

Recieves registered messages from emu6502 application.

Called from another thread!!

Definition at line 113 of file cpudll.c.


Variable Documentation

HANDLE CpuThreadHandle
 

Handle of this thread

Definition at line 52 of file cpudll.c.

DWORD CpuThreadID
 

ID of this thread

Definition at line 53 of file cpudll.c.

UINT Freq = 1790000
 

Frekvency of procesor

Definition at line 24 of file cpudll.c.

UINT Frms = 1790
 

No. of instructions per milisecond

Definition at line 26 of file cpudll.c.

INTR volatile Interrupt
 

TRUE if interrupt occures

Definition at line 50 of file cpudll.c.

BOOL volatile Running
 

Can be used by two threads!

Definition at line 45 of file cpudll.c.

UINT secstart
 

Helper variable used for determining and correcting the CPU speed

Definition at line 40 of file cpudll.c.

UINT start
 

Start time of CPUs execution

Definition at line 38 of file cpudll.c.

THRSTATE volatile ThreadState
 

Used for synchronization (to make sure, thread has correctly ended)

Definition at line 46 of file cpudll.c.

UINT ticks
 

Last value of GetTickCount();

Definition at line 41 of file cpudll.c.

UINT total
 

No of ticks from @start

Definition at line 39 of file cpudll.c.


Generated on Fri Sep 6 18:32:15 2002 for Emu6502 by doxygen1.2.17