2024-03-19 22:24:30 +01:00
|
|
|
/*
|
|
|
|
* Emu48.h
|
|
|
|
*
|
|
|
|
* This file is part of Emu48
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Sebastien Carlier
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "types.h"
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
// cards status
|
2024-03-19 22:36:03 +01:00
|
|
|
#define PORT1_PRESENT ((cCurrentRomType=='S')?P1C:P2C)
|
|
|
|
#define PORT1_WRITE ((cCurrentRomType=='S')?P1W:P2W)
|
|
|
|
#define PORT2_PRESENT ((cCurrentRomType=='S')?P2C:P1C)
|
|
|
|
#define PORT2_WRITE ((cCurrentRomType=='S')?P2W:P1W)
|
2024-03-19 22:24:30 +01:00
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define BINARYHEADER48 "HPHP48-W"
|
|
|
|
#define BINARYHEADER49 "HPHP49-W"
|
|
|
|
|
|
|
|
#define S_ERR_NO 0 // stack errorcodes
|
2024-03-19 22:24:30 +01:00
|
|
|
#define S_ERR_BINARY 1
|
|
|
|
#define S_ERR_ASCII 2
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define NO_SERIAL "disabled" // port not open
|
2024-03-19 22:24:30 +01:00
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define PORT_CLOSE 0 // COM port status
|
2024-03-19 22:24:30 +01:00
|
|
|
#define PORT_WIRE 1
|
|
|
|
#define PORT_IR 2
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define HP_MNEMONICS FALSE // disassembler mnenomics mode
|
2024-03-19 22:24:30 +01:00
|
|
|
#define CLASS_MNEMONICS TRUE
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define MEM_MAP 0 // memory module definition
|
2024-03-19 22:24:30 +01:00
|
|
|
#define MEM_ROM 1
|
|
|
|
#define MEM_RAM 2
|
|
|
|
#define MEM_PORT1 3
|
|
|
|
#define MEM_PORT2 4
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
#define VIEW_SHORT FALSE // view of disassembler output
|
|
|
|
#define VIEW_LONG TRUE
|
|
|
|
|
|
|
|
#define DISP_POINTER 0x01 // defines for display area
|
|
|
|
#define DISP_MAIN 0x02
|
|
|
|
#define DISP_MENUE 0x04
|
|
|
|
#define DISP_ANNUN 0x08
|
|
|
|
|
2024-03-19 22:24:30 +01:00
|
|
|
// Emu48.c
|
|
|
|
extern HPALETTE hPalette;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern HPALETTE hOldPalette;
|
|
|
|
extern HANDLE hEventShutdn;
|
|
|
|
extern LPSTR szAppName;
|
|
|
|
extern LPSTR szTopic;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern LPSTR szTitle;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern CRITICAL_SECTION csGDILock;
|
|
|
|
extern CRITICAL_SECTION csKeyLock;
|
|
|
|
extern CRITICAL_SECTION csIOLock;
|
|
|
|
extern CRITICAL_SECTION csT1Lock;
|
|
|
|
extern CRITICAL_SECTION csT2Lock;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern CRITICAL_SECTION csRecvLock;
|
|
|
|
extern INT nArgc;
|
|
|
|
extern LPCTSTR *ppArgv;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern LARGE_INTEGER lFreq;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern LARGE_INTEGER lAppStart;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern DWORD idDdeInst;
|
|
|
|
extern UINT uCF_HpObj;
|
|
|
|
extern HINSTANCE hApp;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern HWND hWnd;
|
|
|
|
extern HDC hWindowDC;
|
|
|
|
extern BOOL bPort2IsShared;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern BOOL bAutoSave;
|
|
|
|
extern BOOL bAutoSaveOnExit;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern BOOL bAlwaysDisplayLog;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern HANDLE hThread;
|
|
|
|
extern DWORD lThreadId;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID SetWindowTitle(LPSTR szString);
|
2024-03-19 22:36:03 +01:00
|
|
|
extern VOID CopyItemsToClipboard(HWND hWnd);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID UpdateWindowStatus(VOID);
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
// Settings.c
|
2024-03-19 22:36:03 +01:00
|
|
|
extern VOID ReadSettings(VOID);
|
|
|
|
extern VOID WriteSettings(VOID);
|
2024-03-19 22:25:45 +01:00
|
|
|
extern VOID ReadLastDocument(LPTSTR szFileName, DWORD nSize);
|
|
|
|
extern VOID WriteLastDocument(LPCTSTR szFilename);
|
|
|
|
|
2024-03-19 22:24:30 +01:00
|
|
|
// Display.c
|
2024-03-19 22:25:45 +01:00
|
|
|
extern UINT nBackgroundX;
|
|
|
|
extern UINT nBackgroundY;
|
|
|
|
extern UINT nBackgroundW;
|
|
|
|
extern UINT nBackgroundH;
|
|
|
|
extern UINT nLcdX;
|
|
|
|
extern UINT nLcdY;
|
|
|
|
extern UINT nLcdDoubled;
|
|
|
|
extern LPBYTE pbyLcd;
|
|
|
|
extern HDC hLcdDC;
|
|
|
|
extern HDC hMainDC;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID UpdateContrast(BYTE byContrast);
|
|
|
|
extern VOID SetLcdColor(UINT nId, UINT nRed, UINT nGreen, UINT nBlue);
|
|
|
|
extern VOID CreateLcdBitmap(VOID);
|
|
|
|
extern VOID DestroyLcdBitmap(VOID);
|
|
|
|
extern BOOL CreateMainBitmap(LPSTR szFilename);
|
|
|
|
extern VOID DestroyMainBitmap(VOID);
|
|
|
|
extern VOID UpdateDisplayPointers(VOID);
|
|
|
|
extern VOID UpdateMainDisplay(VOID);
|
|
|
|
extern VOID UpdateMenuDisplay(VOID);
|
|
|
|
extern VOID WriteToMainDisplay(LPBYTE a, DWORD d, UINT s);
|
|
|
|
extern VOID WriteToMenuDisplay(LPBYTE a, DWORD d, UINT s);
|
|
|
|
extern VOID UpdateAnnunciators(VOID);
|
|
|
|
extern VOID ResizeWindow(VOID);
|
|
|
|
|
|
|
|
// Engine.c
|
|
|
|
extern BOOL bInterrupt;
|
|
|
|
extern UINT nState;
|
|
|
|
extern UINT nNextState;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern BOOL bRealSpeed;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern BOOL bKeySlow;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern CHIPSET Chipset;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern char szSerialWire[16];
|
|
|
|
extern char szSerialIr[16];
|
|
|
|
extern DWORD dwSXCycles;
|
|
|
|
extern DWORD dwGXCycles;
|
|
|
|
extern VOID AdjKeySpeed(VOID);
|
|
|
|
extern VOID SetSpeed(BOOL bAdjust);
|
|
|
|
extern VOID UpdateKdnBit(VOID);
|
|
|
|
extern BOOL WaitForSleepState(VOID);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern UINT SwitchToState(UINT nNewState);
|
|
|
|
extern UINT WorkerThread(LPVOID pParam);
|
|
|
|
extern DWORD Npack(BYTE *a, UINT s);
|
|
|
|
extern VOID Nunpack(BYTE *a, DWORD b, UINT s);
|
|
|
|
|
2024-03-19 22:25:45 +01:00
|
|
|
// Fetch.c
|
|
|
|
extern VOID EvalOpcode(LPBYTE I);
|
|
|
|
|
2024-03-19 22:24:30 +01:00
|
|
|
// Files.c
|
|
|
|
extern char szEmu48Directory[260];
|
|
|
|
extern char szCurrentDirectory[260];
|
|
|
|
extern char szCurrentKml[260];
|
|
|
|
extern char szBackupKml[260];
|
|
|
|
extern char szCurrentFilename[260];
|
|
|
|
extern char szBackupFilename[260];
|
|
|
|
extern char szBufferFilename[260];
|
|
|
|
extern char szPort2Filename[260];
|
|
|
|
extern LPBYTE pbyRom;
|
|
|
|
extern DWORD dwRomSize;
|
|
|
|
extern char cCurrentRomType;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern BOOL bRomWriteable;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern LPBYTE pbyPort2;
|
|
|
|
extern BOOL bPort2Writeable;
|
|
|
|
extern BOOL bPort2IsShared;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern DWORD dwPort2Size;
|
2024-03-19 22:24:30 +01:00
|
|
|
extern DWORD dwPort2Mask;
|
|
|
|
extern BOOL bBackup;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern WORD WriteStack(LPBYTE,DWORD);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern BOOL MapRom(LPCSTR szFilename);
|
|
|
|
extern VOID UnmapRom(VOID);
|
|
|
|
extern BOOL MapPort2(LPCSTR szFilename);
|
|
|
|
extern VOID UnmapPort2(VOID);
|
2024-03-19 22:36:03 +01:00
|
|
|
extern VOID UpdatePatches(BOOL bPatch);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern BOOL PatchRom(LPCSTR szFilename);
|
|
|
|
extern VOID ResetDocument(VOID);
|
|
|
|
extern BOOL NewDocument(VOID);
|
|
|
|
extern BOOL OpenDocument(LPCSTR szFilename);
|
|
|
|
extern BOOL SaveDocument(VOID);
|
|
|
|
extern BOOL SaveDocumentAs(LPCTSTR szFilename);
|
|
|
|
extern BOOL SaveBackup(VOID);
|
|
|
|
extern BOOL RestoreBackup(VOID);
|
|
|
|
extern BOOL ResetBackup(VOID);
|
|
|
|
extern BOOL GetOpenFilename(VOID);
|
|
|
|
extern BOOL GetSaveAsFilename(VOID);
|
|
|
|
extern BOOL GetLoadObjectFilename(VOID);
|
|
|
|
extern BOOL GetSaveObjectFilename(VOID);
|
|
|
|
extern BOOL LoadObject(LPCSTR szFilename);
|
|
|
|
extern BOOL SaveObject(LPCSTR szFilename);
|
|
|
|
extern HBITMAP LoadBitmapFile(LPCSTR szFilename);
|
|
|
|
|
|
|
|
// Timer.c
|
2024-03-19 22:25:45 +01:00
|
|
|
extern VOID SetHP48Time(VOID);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID StartTimers(VOID);
|
|
|
|
extern VOID StopTimers(VOID);
|
|
|
|
extern DWORD ReadT2(VOID);
|
|
|
|
extern VOID SetT2(DWORD dwValue);
|
|
|
|
extern BYTE ReadT1(VOID);
|
|
|
|
extern VOID SetT1(BYTE byValue);
|
|
|
|
|
|
|
|
// MOps.c
|
2024-03-19 22:25:45 +01:00
|
|
|
extern BOOL ioc_acc;
|
|
|
|
extern BOOL ir_ctrl_acc;
|
2024-03-19 22:36:03 +01:00
|
|
|
extern BOOL bFlashRomArray;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern BYTE disp;
|
|
|
|
extern LPBYTE RMap[256];
|
|
|
|
extern LPBYTE WMap[256];
|
|
|
|
extern VOID Map(BYTE a, BYTE b);
|
|
|
|
extern VOID RomSwitch(DWORD adr);
|
|
|
|
extern VOID Config(VOID);
|
|
|
|
extern VOID Uncnfg(VOID);
|
|
|
|
extern VOID Reset(VOID);
|
|
|
|
extern VOID C_Eq_Id(VOID);
|
2024-03-19 22:36:03 +01:00
|
|
|
extern VOID CpuReset(VOID);
|
2024-03-19 22:25:45 +01:00
|
|
|
extern BYTE GetLineCounter(VOID);
|
|
|
|
extern VOID Npeek(BYTE *a, DWORD d, UINT s);
|
|
|
|
extern VOID Nread(BYTE *a, DWORD d, UINT s);
|
|
|
|
extern VOID Nwrite(BYTE *a, DWORD d, UINT s);
|
|
|
|
extern BYTE Read2(DWORD d);
|
|
|
|
extern DWORD Read5(DWORD d);
|
|
|
|
extern VOID Write5(DWORD d, DWORD n);
|
|
|
|
extern VOID Write2(DWORD d, BYTE n);
|
|
|
|
extern VOID IOBit(DWORD d, BYTE b, BOOL s);
|
|
|
|
extern VOID ReadIO(BYTE *a, DWORD b, DWORD s);
|
|
|
|
extern VOID WriteIO(BYTE *a, DWORD b, DWORD s);
|
2024-03-19 22:24:30 +01:00
|
|
|
|
|
|
|
// Keyboard.c
|
2024-03-19 22:25:45 +01:00
|
|
|
extern VOID ScanKeyboard(BOOL bReset);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID KeyboardEvent(BOOL bPress, UINT out, UINT in);
|
|
|
|
|
|
|
|
// RPL.c
|
|
|
|
extern DWORD RPL_SkipOb(DWORD d);
|
|
|
|
extern DWORD RPL_ObjectSize(BYTE *o);
|
|
|
|
extern DWORD RPL_CreateTemp(DWORD l);
|
|
|
|
extern DWORD RPL_Pick(UINT l);
|
|
|
|
extern VOID RPL_Replace(DWORD n);
|
|
|
|
extern VOID RPL_Push(DWORD n);
|
|
|
|
|
|
|
|
// External.c
|
|
|
|
extern VOID External(CHIPSET* w);
|
|
|
|
|
|
|
|
// DDEserv.c
|
|
|
|
extern HDDEDATA CALLBACK DdeCallback(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD);
|
|
|
|
|
|
|
|
// Disasm.c
|
|
|
|
extern BOOL disassembler_mode;
|
|
|
|
extern WORD disassembler_map;
|
2024-03-19 22:25:45 +01:00
|
|
|
extern DWORD disassemble (DWORD addr, LPSTR out, BOOL view);
|
2024-03-19 22:24:30 +01:00
|
|
|
|
|
|
|
// Serial.c
|
|
|
|
extern WORD CommConnect(VOID);
|
|
|
|
extern VOID CommOpen(LPSTR strWirePort,LPSTR strIrPort);
|
|
|
|
extern VOID CommClose(VOID);
|
|
|
|
extern VOID CommSetBaud(VOID);
|
2024-03-19 22:36:03 +01:00
|
|
|
extern VOID UpdateUSRQ(VOID);
|
2024-03-19 22:24:30 +01:00
|
|
|
extern VOID CommTransmit(VOID);
|
|
|
|
extern VOID CommReceive(VOID);
|
|
|
|
|
|
|
|
// Message Boxes
|
|
|
|
static __inline int InfoMessage(LPCSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND);}
|
|
|
|
static __inline int AbortMessage(LPCSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);}
|
|
|
|
static __inline int YesNoMessage(LPCSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND);}
|
|
|
|
static __inline int YesNoCancelMessage(LPCSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND);}
|
|
|
|
|
|
|
|
// Missing Win32 API calls
|
|
|
|
static __inline LPSTR DuplicateString(LPCSTR szString)
|
|
|
|
{
|
|
|
|
UINT uLength = strlen(szString) + 1;
|
2024-03-19 22:25:45 +01:00
|
|
|
LPSTR szDup = LocalAlloc(LMEM_FIXED,uLength);
|
2024-03-19 22:24:30 +01:00
|
|
|
CopyMemory(szDup,szString,uLength);
|
|
|
|
return szDup;
|
|
|
|
}
|