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 |
|
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
|
|
The main thread function.
This function is called by CreateCpuThread()
|
|
Creates a new CPU thread.
Creates a new thread in which processor is running. Called by DllMain when loading this dll.
|
|
Dll entry point.
|
|
Kills this thread.
|
|
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.
|
|
IO function mapped into some adress in memory.
Called directly when accesing adress to which is this function bound. Always write this function.
|
|
Recieves registered messages from emu6502 application. Called from another thread!! |
|
Handle of this thread |
|
ID of this thread |
|
Frekvency of procesor |
|
No. of instructions per milisecond |
|
TRUE if interrupt occures |
|
Can be used by two threads! |
|
Helper variable used for determining and correcting the CPU speed |
|
Start time of CPUs execution |
|
Used for synchronization (to make sure, thread has correctly ended) |
|
Last value of GetTickCount(); |
|
No of ticks from @start |