2024-09-25: Updated to version 1.67
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
This commit is contained in:
parent
22744c9772
commit
0a4432a193
67 changed files with 32277 additions and 31986 deletions
|
@ -342,11 +342,13 @@ NCE3 | nc. | RAM 128KB | nc. | Slt2 32KB-4MB | RAM 128KB
|
|||
|
||||
- Load Memory Data...
|
||||
|
||||
The "Load Memory Data" dialog box allows loading memory dump files to the specified address inside the Saturn address area. The specified address must point to RAM, writing into ROM areas isn't possible. The memory dump file must be in packed data format, meaning each byte in file contain two Saturn data nibbles with the low nibble containing the even and the high nibble the following odd address. The disadvantage of packed files is that you cannot load memory files with an odd number of data nibbles, but the advantage is that you can directly load an assembler output to memory.
|
||||
The "Load Memory Data" dialog box allows loading memory dump files to the specified address inside the Saturn address area. The specified address must point to RAM, writing into ROM areas isn't possible. The memory dump file maybe in packed data format (8-bit), meaning each byte in file contain two Saturn data nibbles with the low nibble containing the even and the high nibble the following odd address or in unpacked data format (4-bit) with 4-bit in each byte.
|
||||
|
||||
The Auto mode tries to detect the packed or unpacked data format automatically. This may fail, when the memory dump only contain 00-Bytes, then all upper 4 bit are always zero which is an indicator for an unpacked data format. If you're not sure if the Auto detection will work, use the manual data format selection please.
|
||||
|
||||
- Save Memory Data...
|
||||
|
||||
The "Save Memory Data" dialog box allows saving the data of the specified Saturn address area into a memory dump file. The memory dump file contain the data in packed data format, meaning each byte in file contain two Saturn data nibbles with the low nibble containing the even and the high nibble the following odd address.
|
||||
The "Save Memory Data" dialog box allows saving the data of the specified Saturn address area into a memory dump file. The memory dump file may contain the data in packed data format (8-bit), meaning each byte in file contain two Saturn data nibbles with the low nibble containing the even and the high nibble the following odd address or in unpacked data format (4-bit) with 4-bit in each byte.
|
||||
|
||||
- RPL Object Viewer...
|
||||
|
||||
|
@ -393,4 +395,4 @@ The Miscellaneous window show you the internal state of the interrupt flag, the
|
|||
You can change the values by pressing the left mouse button over the old content.
|
||||
|
||||
|
||||
08/12/19 (c) by Christoph Gießelink
|
||||
04/19/24 (c) by Christoph Gießelink
|
||||
|
|
BIN
Emu48.exe
BIN
Emu48.exe
Binary file not shown.
30
Emu48.htm
30
Emu48.htm
|
@ -526,10 +526,10 @@ h3 { color:red; font-size:1.1em; }
|
|||
"String" object in stack level 1 to the clipboard. On all
|
||||
other objects, the command will be ignored. This prevents sending
|
||||
binary objects to the clipboard.</p>
|
||||
<p>The decimal point (radix mark) of "Real Numbers" in the
|
||||
clipboard is equal to the calculator setting. This is important when
|
||||
you try to paste the numbers into a program using the locale settings
|
||||
of the host operating system.</p>
|
||||
<p>The decimal point of "Real Numbers" in the clipboard is
|
||||
equal to the calculator setting. This is important when you try to
|
||||
paste the numbers into a program using the locale settings of the host
|
||||
operating system.</p>
|
||||
<h2><a name=ss9.5>9.5 Paste Stack</a></h2>
|
||||
<p>This menu item is enabled for the HP48SX, HP48GX and the HP49G
|
||||
emulation.</p>
|
||||
|
@ -539,14 +539,18 @@ h3 { color:red; font-size:1.1em; }
|
|||
object. Is the content a complex number object, the number will be
|
||||
saved as "Complex Number" object, otherwise cases as
|
||||
"String" object.</p>
|
||||
<p>To import "Real or Complex Numbers" from the clipboard, the
|
||||
decimal point (radix mark) of the clipboard and calculator <u>must</u>
|
||||
match. A real or complex number is only detected in the case of valid
|
||||
real number characters in the clipboard. Especially heading and tailing
|
||||
white spaces aren't valid number characters also.</p>
|
||||
<p>Complex numbers must be in the form <i>(a,b)</i> when using the point
|
||||
radix mark or in the form <i>(a;b)</i> when using the comma radix mark.
|
||||
The Cartesian or algebraic form <i>a+bi</i> is not supported.</p>
|
||||
<p>To import "Real Numbers" from the clipboard, the decimal
|
||||
point character of the clipboard and calculator <u>must not match</u> any
|
||||
more. There's an auto detection for decoding the thousands separator and
|
||||
decimal point character. The thousands separator is removed at decoding.
|
||||
A real number is detected in the case of valid real number characters in
|
||||
the clipboard.</p>
|
||||
<p>"Complex Numbers" must be in the form <i>(a,b)</i> when
|
||||
using the decimal point or in the form <i>(a;b)</i> when using the decimal
|
||||
comma. Using a thousands separator is not allowed in complex number
|
||||
strings because in decimal point mode, the comma is used as separator
|
||||
between real and imaginary part of the number. The Cartesian or algebraic
|
||||
form <i>a+bi</i> is not supported.</p>
|
||||
<h2><a name=ss9.6>9.6 Reset Calculator</a></h2>
|
||||
<p>This emulates the Reset pin of the internal CPU.</p>
|
||||
<h2><a name=ss9.7>9.7 Backup</a></h2>
|
||||
|
@ -636,7 +640,7 @@ h3 { color:red; font-size:1.1em; }
|
|||
</table>
|
||||
<h1><a name=s14>14. License</a></h1>
|
||||
<p>Emu48 - A HP38G/39G/40G/48SX/48GX/49G Emulator<br>
|
||||
Copyright (C) 2022 Christoph Gießelink</p>
|
||||
Copyright (C) 2024 Christoph Gießelink</p>
|
||||
<p>This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Known bugs and restrictions of Emu48 V1.66
|
||||
Known bugs and restrictions of Emu48 V1.67
|
||||
------------------------------------------
|
||||
|
||||
- the following I/O bits aren't emulated (incomplete)
|
||||
|
@ -47,4 +47,4 @@ Known bugs and restrictions of Emu48 V1.66
|
|||
- quitting the emulator while programming the flash isn't allowed,
|
||||
because the content of flash state machine isn't saved so far
|
||||
|
||||
06/20/23 (c) by Christoph Gießelink, c dot giesselink at gmx dot de
|
||||
09/23/24 (c) by Christoph Gießelink, c dot giesselink at gmx dot de
|
||||
|
|
|
@ -1,191 +1,191 @@
|
|||
/*
|
||||
* cardcopy, (c) 2000 Christoph Giesselink (cgiess@swol.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
|
||||
#define VERSION "2.1"
|
||||
|
||||
#define FT_ERR 0 // illegal format
|
||||
#define FT_NEW 1 // empty file
|
||||
#define FT_SXGX 2 // Emu48 HP48SX/GX state file
|
||||
|
||||
#define _KB(n) ((n)*1024*2) // KB in state file
|
||||
#define HP48SIG "Emu48 Document\xFE" // HP48 state file signature
|
||||
|
||||
|
||||
UINT CheckType(char *lpszFileName)
|
||||
{
|
||||
BYTE pbyFileSignature[16];
|
||||
HANDLE hFile;
|
||||
DWORD FileSizeHigh,FileSizeLow;
|
||||
|
||||
UINT nType = FT_ERR;
|
||||
|
||||
hFile = CreateFile(lpszFileName,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return FT_NEW;
|
||||
|
||||
// check filesize
|
||||
FileSizeLow = GetFileSize(hFile,&FileSizeHigh);
|
||||
if (FileSizeHigh == 0 && (FileSizeLow == _KB(32) || FileSizeLow == _KB(128)))
|
||||
nType = FileSizeLow; // return card size
|
||||
|
||||
// Read and Compare signature
|
||||
ReadFile(hFile,pbyFileSignature,sizeof(pbyFileSignature),&FileSizeLow,NULL);
|
||||
if (FileSizeLow == sizeof(pbyFileSignature) && strcmp(pbyFileSignature,HP48SIG) == 0)
|
||||
nType = FT_SXGX;
|
||||
|
||||
CloseHandle(hFile);
|
||||
return nType;
|
||||
}
|
||||
|
||||
BOOL SeekData(HANDLE hFile,UINT *nPortSize)
|
||||
{
|
||||
BYTE byBuffer[16];
|
||||
CHIPSET *pChipset;
|
||||
UINT i;
|
||||
DWORD lBytes;
|
||||
|
||||
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
|
||||
|
||||
// read and check signature
|
||||
ReadFile(hFile,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(HP48SIG) || strcmp(byBuffer,HP48SIG) != 0) return TRUE;
|
||||
|
||||
// read KML file length
|
||||
ReadFile(hFile,&i,sizeof(i),&lBytes,NULL);
|
||||
if (lBytes != sizeof(i)) return TRUE;
|
||||
|
||||
// skip KML file name
|
||||
SetFilePointer(hFile,i,NULL,FILE_CURRENT);
|
||||
|
||||
// read CHIPSET structure length
|
||||
ReadFile(hFile,&i,sizeof(i),&lBytes,NULL);
|
||||
if (lBytes != sizeof(i)) return TRUE;
|
||||
|
||||
// read CHIPSET structure
|
||||
if ((pChipset = LocalAlloc(LMEM_FIXED,i)) == NULL)
|
||||
return TRUE;
|
||||
|
||||
ReadFile(hFile,pChipset,i,&lBytes,NULL);
|
||||
if (lBytes != i) { LocalFree(pChipset); return TRUE; }
|
||||
|
||||
// skip port0
|
||||
SetFilePointer(hFile,_KB(pChipset->Port0Size),NULL,FILE_CURRENT);
|
||||
|
||||
*nPortSize = _KB(pChipset->Port1Size); // expected filesize
|
||||
|
||||
LocalFree(pChipset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CopyData(HANDLE hFileSource,HANDLE hFileDest,UINT nSize)
|
||||
{
|
||||
BYTE byBuffer[16];
|
||||
INT i;
|
||||
DWORD lBytes;
|
||||
|
||||
assert(nSize % sizeof(byBuffer) == 0);
|
||||
for (i = nSize / sizeof(byBuffer); i > 0; --i)
|
||||
{
|
||||
ReadFile(hFileSource,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(byBuffer)) return TRUE;
|
||||
|
||||
WriteFile(hFileDest,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(byBuffer)) return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFileSource,hFileDest;
|
||||
UINT nSourceType,nDestType;
|
||||
UINT nError = 0;
|
||||
|
||||
printf("HP48 Port1 Import/Export Tool for Emu48 V" VERSION "\n");
|
||||
if (argc != 3)
|
||||
{
|
||||
printf("\nUsage:\n\t%s <SourceFile> <DestinationFile>\n\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check source file type
|
||||
nSourceType = CheckType(argv[1]);
|
||||
if (nSourceType == FT_ERR || nSourceType == FT_NEW)
|
||||
{
|
||||
printf("Error: Illegal source file type\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// check destination file type
|
||||
nDestType = CheckType(argv[2]);
|
||||
if (nDestType == FT_ERR)
|
||||
{
|
||||
printf("Error: Illegal destination file type\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
// open source file
|
||||
hFileSource = CreateFile(argv[1],GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
|
||||
if (hFileSource != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hFileDest = CreateFile(argv[2],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL);
|
||||
if (hFileDest != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
BOOL bFormatErr = FALSE;
|
||||
|
||||
if (nSourceType == FT_SXGX) bFormatErr |= SeekData(hFileSource,&nSourceType);
|
||||
if (nDestType == FT_SXGX) bFormatErr |= SeekData(hFileDest,&nDestType);
|
||||
|
||||
if (!bFormatErr && (nSourceType == nDestType || nDestType == FT_NEW))
|
||||
{
|
||||
assert(nSourceType > FT_SXGX);
|
||||
CopyData(hFileSource,hFileDest,nSourceType);
|
||||
puts("Copy successful.");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Non matching file size or format\n");
|
||||
nError = 4;
|
||||
}
|
||||
|
||||
CloseHandle(hFileDest);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Can't open destination file %s\n",argv[2]);
|
||||
nError = 5;
|
||||
}
|
||||
|
||||
CloseHandle(hFileSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Can't open source file %s\n",argv[1]);
|
||||
nError = 6;
|
||||
}
|
||||
|
||||
return nError;
|
||||
}
|
||||
/*
|
||||
* cardcopy, (c) 2000 Christoph Giesselink (cgiess@swol.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
|
||||
#define VERSION "2.1"
|
||||
|
||||
#define FT_ERR 0 // illegal format
|
||||
#define FT_NEW 1 // empty file
|
||||
#define FT_SXGX 2 // Emu48 HP48SX/GX state file
|
||||
|
||||
#define _KB(n) ((n)*1024*2) // KB in state file
|
||||
#define HP48SIG "Emu48 Document\xFE" // HP48 state file signature
|
||||
|
||||
|
||||
UINT CheckType(char *lpszFileName)
|
||||
{
|
||||
BYTE pbyFileSignature[16];
|
||||
HANDLE hFile;
|
||||
DWORD FileSizeHigh,FileSizeLow;
|
||||
|
||||
UINT nType = FT_ERR;
|
||||
|
||||
hFile = CreateFile(lpszFileName,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return FT_NEW;
|
||||
|
||||
// check filesize
|
||||
FileSizeLow = GetFileSize(hFile,&FileSizeHigh);
|
||||
if (FileSizeHigh == 0 && (FileSizeLow == _KB(32) || FileSizeLow == _KB(128)))
|
||||
nType = FileSizeLow; // return card size
|
||||
|
||||
// Read and Compare signature
|
||||
ReadFile(hFile,pbyFileSignature,sizeof(pbyFileSignature),&FileSizeLow,NULL);
|
||||
if (FileSizeLow == sizeof(pbyFileSignature) && strcmp(pbyFileSignature,HP48SIG) == 0)
|
||||
nType = FT_SXGX;
|
||||
|
||||
CloseHandle(hFile);
|
||||
return nType;
|
||||
}
|
||||
|
||||
BOOL SeekData(HANDLE hFile,UINT *nPortSize)
|
||||
{
|
||||
BYTE byBuffer[16];
|
||||
CHIPSET *pChipset;
|
||||
UINT i;
|
||||
DWORD lBytes;
|
||||
|
||||
SetFilePointer(hFile,0,NULL,FILE_BEGIN);
|
||||
|
||||
// read and check signature
|
||||
ReadFile(hFile,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(HP48SIG) || strcmp(byBuffer,HP48SIG) != 0) return TRUE;
|
||||
|
||||
// read KML file length
|
||||
ReadFile(hFile,&i,sizeof(i),&lBytes,NULL);
|
||||
if (lBytes != sizeof(i)) return TRUE;
|
||||
|
||||
// skip KML file name
|
||||
SetFilePointer(hFile,i,NULL,FILE_CURRENT);
|
||||
|
||||
// read CHIPSET structure length
|
||||
ReadFile(hFile,&i,sizeof(i),&lBytes,NULL);
|
||||
if (lBytes != sizeof(i)) return TRUE;
|
||||
|
||||
// read CHIPSET structure
|
||||
if ((pChipset = LocalAlloc(LMEM_FIXED,i)) == NULL)
|
||||
return TRUE;
|
||||
|
||||
ReadFile(hFile,pChipset,i,&lBytes,NULL);
|
||||
if (lBytes != i) { LocalFree(pChipset); return TRUE; }
|
||||
|
||||
// skip port0
|
||||
SetFilePointer(hFile,_KB(pChipset->Port0Size),NULL,FILE_CURRENT);
|
||||
|
||||
*nPortSize = _KB(pChipset->Port1Size); // expected filesize
|
||||
|
||||
LocalFree(pChipset);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL CopyData(HANDLE hFileSource,HANDLE hFileDest,UINT nSize)
|
||||
{
|
||||
BYTE byBuffer[16];
|
||||
INT i;
|
||||
DWORD lBytes;
|
||||
|
||||
assert(nSize % sizeof(byBuffer) == 0);
|
||||
for (i = nSize / sizeof(byBuffer); i > 0; --i)
|
||||
{
|
||||
ReadFile(hFileSource,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(byBuffer)) return TRUE;
|
||||
|
||||
WriteFile(hFileDest,byBuffer,sizeof(byBuffer),&lBytes,NULL);
|
||||
if (lBytes != sizeof(byBuffer)) return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFileSource,hFileDest;
|
||||
UINT nSourceType,nDestType;
|
||||
UINT nError = 0;
|
||||
|
||||
printf("HP48 Port1 Import/Export Tool for Emu48 V" VERSION "\n");
|
||||
if (argc != 3)
|
||||
{
|
||||
printf("\nUsage:\n\t%s <SourceFile> <DestinationFile>\n\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check source file type
|
||||
nSourceType = CheckType(argv[1]);
|
||||
if (nSourceType == FT_ERR || nSourceType == FT_NEW)
|
||||
{
|
||||
printf("Error: Illegal source file type\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
// check destination file type
|
||||
nDestType = CheckType(argv[2]);
|
||||
if (nDestType == FT_ERR)
|
||||
{
|
||||
printf("Error: Illegal destination file type\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
// open source file
|
||||
hFileSource = CreateFile(argv[1],GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
|
||||
if (hFileSource != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
hFileDest = CreateFile(argv[2],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL);
|
||||
if (hFileDest != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
BOOL bFormatErr = FALSE;
|
||||
|
||||
if (nSourceType == FT_SXGX) bFormatErr |= SeekData(hFileSource,&nSourceType);
|
||||
if (nDestType == FT_SXGX) bFormatErr |= SeekData(hFileDest,&nDestType);
|
||||
|
||||
if (!bFormatErr && (nSourceType == nDestType || nDestType == FT_NEW))
|
||||
{
|
||||
assert(nSourceType > FT_SXGX);
|
||||
CopyData(hFileSource,hFileDest,nSourceType);
|
||||
puts("Copy successful.");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Non matching file size or format\n");
|
||||
nError = 4;
|
||||
}
|
||||
|
||||
CloseHandle(hFileDest);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Can't open destination file %s\n",argv[2]);
|
||||
nError = 5;
|
||||
}
|
||||
|
||||
CloseHandle(hFileSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Error: Can't open source file %s\n",argv[1]);
|
||||
nError = 6;
|
||||
}
|
||||
|
||||
return nError;
|
||||
}
|
|
@ -1,103 +1,103 @@
|
|||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
LPBYTE Port0;
|
||||
LPBYTE Port1;
|
||||
LPBYTE Port2;
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon;
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
||||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
LPBYTE Port0;
|
||||
LPBYTE Port1;
|
||||
LPBYTE Port2;
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon;
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
|
@ -1,401 +1,401 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define HP38G 0
|
||||
#define HP48S 1
|
||||
#define HP48G 2
|
||||
|
||||
LPBYTE pRom;
|
||||
WORD wCRC;
|
||||
WORD wType;
|
||||
|
||||
static WORD crc_table[16] =
|
||||
{
|
||||
0x0000, 0x1081, 0x2102, 0x3183, 0x4204, 0x5285, 0x6306, 0x7387,
|
||||
0x8408, 0x9489, 0xA50A, 0xB58B, 0xC60C, 0xD68D, 0xE70E, 0xF78F
|
||||
};
|
||||
static __inline VOID CRC(BYTE nib)
|
||||
{
|
||||
wCRC = (WORD)((wCRC>>4)^crc_table[(wCRC^nib)&0xf]);
|
||||
}
|
||||
|
||||
BOOL CheckCRC()
|
||||
{
|
||||
DWORD dwD0, dwD1;
|
||||
WORD wRomCRC;
|
||||
UINT i;
|
||||
DWORD dwBase = 0x00000;
|
||||
UINT nPass = 0;
|
||||
UINT nPasses = (wType != HP48S)?2:1;
|
||||
|
||||
again:
|
||||
|
||||
wRomCRC = pRom[dwBase+0x7FFFC]
|
||||
|(pRom[dwBase+0x7FFFD]<<4)
|
||||
|(pRom[dwBase+0x7FFFE]<<8)
|
||||
|(pRom[dwBase+0x7FFFF]<<12);
|
||||
|
||||
wCRC = 0x0000;
|
||||
dwD0 = dwBase + 0x00000;
|
||||
dwD1 = dwBase + 0x40000;
|
||||
do
|
||||
{
|
||||
for (i=0; i<16; i++) CRC(pRom[dwD0+i]);
|
||||
for (i=0; i<16; i++) CRC(pRom[dwD1+i]);
|
||||
dwD0 += 16;
|
||||
dwD1 += 16;
|
||||
} while (dwD0&0x3FFFF);
|
||||
|
||||
if (wCRC==0xFFFF)
|
||||
{
|
||||
printf("CRC%i: %04X Ok\n", nPass, wRomCRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CRC%i: %04X Failed (%04X)\n", nPass, wRomCRC, wCRC);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (++nPass == nPasses) return TRUE;
|
||||
|
||||
dwBase += 0x80000;
|
||||
goto again;
|
||||
|
||||
}
|
||||
|
||||
static BYTE Asc2Nib(char c)
|
||||
{
|
||||
if (c<'0') return 0;
|
||||
if (c<='9') return c-'0';
|
||||
if (c<'A') return 0;
|
||||
if (c<='F') return c-'A'+10;
|
||||
if (c<'a') return 0;
|
||||
if (c<='f') return c-'a'+10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWORD Asc2Nib5(LPBYTE lpBuf)
|
||||
{
|
||||
return (
|
||||
((DWORD)Asc2Nib(lpBuf[0])<<16)
|
||||
|((DWORD)Asc2Nib(lpBuf[1])<<12)
|
||||
|((DWORD)Asc2Nib(lpBuf[2])<<8)
|
||||
|((DWORD)Asc2Nib(lpBuf[3])<<4)
|
||||
|((DWORD)Asc2Nib(lpBuf[4])));
|
||||
}
|
||||
|
||||
static BOOL IsHP(DWORD dwAddress)
|
||||
{
|
||||
char cH = (pRom[dwAddress + 1] << 4) | pRom[dwAddress];
|
||||
char cP = (pRom[dwAddress + 3] << 4) | pRom[dwAddress + 2];
|
||||
return cH == 'H' && cP == 'P';
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFile;
|
||||
HANDLE hMap;
|
||||
HANDLE hOut;
|
||||
LPBYTE pIn;
|
||||
DWORD dwSizeLo;
|
||||
BYTE szVersion[16];
|
||||
UINT i,uLen;
|
||||
DWORD dwAddress;
|
||||
|
||||
DWORD dwAddrOffset = 0x00000;
|
||||
|
||||
BOOL bFormatDetected = FALSE;
|
||||
|
||||
BOOL bUnpack = FALSE;
|
||||
BOOL bSwap = FALSE;
|
||||
BOOL bText = FALSE;
|
||||
BOOL bDA19 = FALSE;
|
||||
BOOL bPack = FALSE;
|
||||
|
||||
int iArg = 1; // first argument
|
||||
|
||||
if (argc < 2 || argc > 4)
|
||||
{
|
||||
printf("Usage:\n\t%s [-p] <old-rom-dump> [<new-rom-dump>]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (*argv[iArg] == '-') // an option
|
||||
{
|
||||
if (strcmp(argv[iArg],"-p") == 0) // option "-p", pack result ROM image
|
||||
{
|
||||
bPack = TRUE; // pack target ROM image
|
||||
--argc; // option is not an argument
|
||||
}
|
||||
++iArg; // first file argument
|
||||
}
|
||||
|
||||
pRom = (LPBYTE) malloc(512*1024*2);
|
||||
if (pRom == NULL)
|
||||
{
|
||||
printf("Memory Allocation Failed !");
|
||||
return 1;
|
||||
}
|
||||
|
||||
hFile = CreateFile(argv[iArg],GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(pRom);
|
||||
printf("Cannot open file %s.\n", argv[iArg]);
|
||||
return 1;
|
||||
}
|
||||
dwSizeLo = GetFileSize(hFile, NULL);
|
||||
hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hMap == NULL)
|
||||
{
|
||||
free(pRom);
|
||||
CloseHandle(hFile);
|
||||
puts("CreateFileMapping failed.");
|
||||
return 1;
|
||||
}
|
||||
pIn = (LPBYTE) MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
|
||||
if (pIn == NULL)
|
||||
{
|
||||
free(pRom);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
puts("MapViewOfFile failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2 && !bFormatDetected; ++i)
|
||||
{
|
||||
switch (pIn[0+dwAddrOffset])
|
||||
{
|
||||
case '0':
|
||||
if (pIn[1+dwAddrOffset]!='0') break;
|
||||
if (pIn[2+dwAddrOffset]!='0') break;
|
||||
if (pIn[3+dwAddrOffset]!='0') break;
|
||||
if (pIn[4+dwAddrOffset]!='0') break;
|
||||
if (pIn[5+dwAddrOffset]!=':') break;
|
||||
bText = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x23:
|
||||
bUnpack = TRUE;
|
||||
bSwap = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x32:
|
||||
bUnpack = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x03:
|
||||
bSwap = TRUE;
|
||||
case 0x02:
|
||||
if (pIn[1+dwAddrOffset] == (bSwap ? 0x02 : 0x03))
|
||||
{
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
}
|
||||
bSwap = FALSE;
|
||||
default:
|
||||
dwAddrOffset = dwSizeLo / 2;
|
||||
bDA19 = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFormatDetected)
|
||||
{
|
||||
free(pRom);
|
||||
UnmapViewOfFile(pIn);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
printf("Stopped, unknown format.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bUnpack) printf("Unpacking nibbles.\n");
|
||||
if (bSwap) printf("Swapping nibbles.\n");
|
||||
if (bText) printf("Reading text file.\n");
|
||||
if (bDA19) printf("Swapping banks.\n");
|
||||
|
||||
if (bText)
|
||||
{
|
||||
DWORD i = 0;
|
||||
while (i<dwSizeLo)
|
||||
{
|
||||
DWORD d = Asc2Nib5(pIn+i);
|
||||
i+=6;
|
||||
pRom[d+0x0] = Asc2Nib(pIn[i+0x0]);
|
||||
pRom[d+0x1] = Asc2Nib(pIn[i+0x1]);
|
||||
pRom[d+0x2] = Asc2Nib(pIn[i+0x2]);
|
||||
pRom[d+0x3] = Asc2Nib(pIn[i+0x3]);
|
||||
pRom[d+0x4] = Asc2Nib(pIn[i+0x4]);
|
||||
pRom[d+0x5] = Asc2Nib(pIn[i+0x5]);
|
||||
pRom[d+0x6] = Asc2Nib(pIn[i+0x6]);
|
||||
pRom[d+0x7] = Asc2Nib(pIn[i+0x7]);
|
||||
pRom[d+0x8] = Asc2Nib(pIn[i+0x8]);
|
||||
pRom[d+0x9] = Asc2Nib(pIn[i+0x9]);
|
||||
pRom[d+0xA] = Asc2Nib(pIn[i+0xA]);
|
||||
pRom[d+0xB] = Asc2Nib(pIn[i+0xB]);
|
||||
pRom[d+0xC] = Asc2Nib(pIn[i+0xC]);
|
||||
pRom[d+0xD] = Asc2Nib(pIn[i+0xD]);
|
||||
pRom[d+0xE] = Asc2Nib(pIn[i+0xE]);
|
||||
pRom[d+0xF] = Asc2Nib(pIn[i+0xF]);
|
||||
i+=16;
|
||||
while ((i<dwSizeLo)&&((pIn[i]==0x0D)||(pIn[i]==0x0A))) i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bUnpack)
|
||||
{
|
||||
if (bSwap)
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i++)
|
||||
{
|
||||
BYTE byC = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[(i<<1) ] = byC>>4;
|
||||
pRom[(i<<1)+1] = byC&0xF;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i++)
|
||||
{
|
||||
BYTE byC = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[(i<<1) ] = byC&0xF;
|
||||
pRom[(i<<1)+1] = byC>>4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bSwap)
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i+=2)
|
||||
{
|
||||
BYTE a, b;
|
||||
a = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
b = pIn[(i+1+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[i] = b;
|
||||
pRom[i+1] = a;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bDA19)
|
||||
{
|
||||
assert(dwAddrOffset == dwSizeLo/2);
|
||||
CopyMemory(&pRom[0] , &pIn[dwAddrOffset], dwAddrOffset);
|
||||
CopyMemory(&pRom[dwAddrOffset], &pIn[0] , dwAddrOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyMemory(pRom, pIn, dwSizeLo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnmapViewOfFile(pIn);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (bText||bUnpack||bSwap||bDA19)
|
||||
{
|
||||
printf("File converted.\n\n");
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// HP38G
|
||||
wType = HP38G;
|
||||
dwAddress = 0x7FFAF;
|
||||
uLen = 10;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// HP48SX
|
||||
wType = HP48S;
|
||||
dwAddress = 0x7FFF0;
|
||||
uLen = 6;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// HP48GX
|
||||
wType = HP48G;
|
||||
dwAddress = 0x7FFBF;
|
||||
uLen = 6;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// unknown
|
||||
uLen = 0;
|
||||
}
|
||||
while (0);
|
||||
|
||||
printf("ROM Model Detected : HP%c8%c\n",(wType == HP38G)?'3':'4',(wType != HP48S)?'G':'S');
|
||||
|
||||
for (i=0; i<uLen; ++i)
|
||||
{
|
||||
szVersion[i] = pRom[dwAddress + (i<<1) + 1] << 4;
|
||||
szVersion[i] |= pRom[dwAddress + (i<<1)];
|
||||
}
|
||||
szVersion[i] = 0;
|
||||
|
||||
printf("ROM Version : %s\n", szVersion);
|
||||
|
||||
ZeroMemory(pRom+0x100, 0x40); // clear IO register area
|
||||
|
||||
if (CheckCRC())
|
||||
{
|
||||
printf("ROM CRC Test Passed.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ROM CRC Test FAILED !\n");
|
||||
}
|
||||
|
||||
if (argc == 3) // write target file
|
||||
{
|
||||
DWORD dwWritten;
|
||||
|
||||
// size of target file
|
||||
DWORD dwRomSize = (wType != HP48S)?(512*1024*2):(256*1024*2);
|
||||
|
||||
hOut = CreateFile(argv[iArg+1],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(pRom);
|
||||
printf("Cannot open file %s.\n", argv[iArg+1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bPack) // pack target ROM image
|
||||
{
|
||||
LPBYTE pbySrc,pbyDest;
|
||||
DWORD i;
|
||||
|
||||
dwRomSize /= 2; // packed image has half of size
|
||||
|
||||
// pack data
|
||||
pbySrc = pbyDest = pRom;
|
||||
for (i = 0; i < dwRomSize; i++)
|
||||
{
|
||||
*pbyDest = *pbySrc++;
|
||||
*pbyDest |= *pbySrc++ << 4;
|
||||
pbyDest++;
|
||||
}
|
||||
}
|
||||
|
||||
WriteFile(hOut,pRom,dwRomSize,&dwWritten,NULL);
|
||||
CloseHandle(hOut);
|
||||
}
|
||||
|
||||
free(pRom);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define HP38G 0
|
||||
#define HP48S 1
|
||||
#define HP48G 2
|
||||
|
||||
LPBYTE pRom;
|
||||
WORD wCRC;
|
||||
WORD wType;
|
||||
|
||||
static WORD crc_table[16] =
|
||||
{
|
||||
0x0000, 0x1081, 0x2102, 0x3183, 0x4204, 0x5285, 0x6306, 0x7387,
|
||||
0x8408, 0x9489, 0xA50A, 0xB58B, 0xC60C, 0xD68D, 0xE70E, 0xF78F
|
||||
};
|
||||
static __inline VOID CRC(BYTE nib)
|
||||
{
|
||||
wCRC = (WORD)((wCRC>>4)^crc_table[(wCRC^nib)&0xf]);
|
||||
}
|
||||
|
||||
BOOL CheckCRC()
|
||||
{
|
||||
DWORD dwD0, dwD1;
|
||||
WORD wRomCRC;
|
||||
UINT i;
|
||||
DWORD dwBase = 0x00000;
|
||||
UINT nPass = 0;
|
||||
UINT nPasses = (wType != HP48S)?2:1;
|
||||
|
||||
again:
|
||||
|
||||
wRomCRC = pRom[dwBase+0x7FFFC]
|
||||
|(pRom[dwBase+0x7FFFD]<<4)
|
||||
|(pRom[dwBase+0x7FFFE]<<8)
|
||||
|(pRom[dwBase+0x7FFFF]<<12);
|
||||
|
||||
wCRC = 0x0000;
|
||||
dwD0 = dwBase + 0x00000;
|
||||
dwD1 = dwBase + 0x40000;
|
||||
do
|
||||
{
|
||||
for (i=0; i<16; i++) CRC(pRom[dwD0+i]);
|
||||
for (i=0; i<16; i++) CRC(pRom[dwD1+i]);
|
||||
dwD0 += 16;
|
||||
dwD1 += 16;
|
||||
} while (dwD0&0x3FFFF);
|
||||
|
||||
if (wCRC==0xFFFF)
|
||||
{
|
||||
printf("CRC%i: %04X Ok\n", nPass, wRomCRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CRC%i: %04X Failed (%04X)\n", nPass, wRomCRC, wCRC);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (++nPass == nPasses) return TRUE;
|
||||
|
||||
dwBase += 0x80000;
|
||||
goto again;
|
||||
|
||||
}
|
||||
|
||||
static BYTE Asc2Nib(char c)
|
||||
{
|
||||
if (c<'0') return 0;
|
||||
if (c<='9') return c-'0';
|
||||
if (c<'A') return 0;
|
||||
if (c<='F') return c-'A'+10;
|
||||
if (c<'a') return 0;
|
||||
if (c<='f') return c-'a'+10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWORD Asc2Nib5(LPBYTE lpBuf)
|
||||
{
|
||||
return (
|
||||
((DWORD)Asc2Nib(lpBuf[0])<<16)
|
||||
|((DWORD)Asc2Nib(lpBuf[1])<<12)
|
||||
|((DWORD)Asc2Nib(lpBuf[2])<<8)
|
||||
|((DWORD)Asc2Nib(lpBuf[3])<<4)
|
||||
|((DWORD)Asc2Nib(lpBuf[4])));
|
||||
}
|
||||
|
||||
static BOOL IsHP(DWORD dwAddress)
|
||||
{
|
||||
char cH = (pRom[dwAddress + 1] << 4) | pRom[dwAddress];
|
||||
char cP = (pRom[dwAddress + 3] << 4) | pRom[dwAddress + 2];
|
||||
return cH == 'H' && cP == 'P';
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFile;
|
||||
HANDLE hMap;
|
||||
HANDLE hOut;
|
||||
LPBYTE pIn;
|
||||
DWORD dwSizeLo;
|
||||
BYTE szVersion[16];
|
||||
UINT i,uLen;
|
||||
DWORD dwAddress;
|
||||
|
||||
DWORD dwAddrOffset = 0x00000;
|
||||
|
||||
BOOL bFormatDetected = FALSE;
|
||||
|
||||
BOOL bUnpack = FALSE;
|
||||
BOOL bSwap = FALSE;
|
||||
BOOL bText = FALSE;
|
||||
BOOL bDA19 = FALSE;
|
||||
BOOL bPack = FALSE;
|
||||
|
||||
int iArg = 1; // first argument
|
||||
|
||||
if (argc < 2 || argc > 4)
|
||||
{
|
||||
printf("Usage:\n\t%s [-p] <old-rom-dump> [<new-rom-dump>]\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (*argv[iArg] == '-') // an option
|
||||
{
|
||||
if (strcmp(argv[iArg],"-p") == 0) // option "-p", pack result ROM image
|
||||
{
|
||||
bPack = TRUE; // pack target ROM image
|
||||
--argc; // option is not an argument
|
||||
}
|
||||
++iArg; // first file argument
|
||||
}
|
||||
|
||||
pRom = (LPBYTE) malloc(512*1024*2);
|
||||
if (pRom == NULL)
|
||||
{
|
||||
printf("Memory Allocation Failed !");
|
||||
return 1;
|
||||
}
|
||||
|
||||
hFile = CreateFile(argv[iArg],GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(pRom);
|
||||
printf("Cannot open file %s.\n", argv[iArg]);
|
||||
return 1;
|
||||
}
|
||||
dwSizeLo = GetFileSize(hFile, NULL);
|
||||
hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (hMap == NULL)
|
||||
{
|
||||
free(pRom);
|
||||
CloseHandle(hFile);
|
||||
puts("CreateFileMapping failed.");
|
||||
return 1;
|
||||
}
|
||||
pIn = (LPBYTE) MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0);
|
||||
if (pIn == NULL)
|
||||
{
|
||||
free(pRom);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
puts("MapViewOfFile failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2 && !bFormatDetected; ++i)
|
||||
{
|
||||
switch (pIn[0+dwAddrOffset])
|
||||
{
|
||||
case '0':
|
||||
if (pIn[1+dwAddrOffset]!='0') break;
|
||||
if (pIn[2+dwAddrOffset]!='0') break;
|
||||
if (pIn[3+dwAddrOffset]!='0') break;
|
||||
if (pIn[4+dwAddrOffset]!='0') break;
|
||||
if (pIn[5+dwAddrOffset]!=':') break;
|
||||
bText = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x23:
|
||||
bUnpack = TRUE;
|
||||
bSwap = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x32:
|
||||
bUnpack = TRUE;
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
case 0x03:
|
||||
bSwap = TRUE;
|
||||
case 0x02:
|
||||
if (pIn[1+dwAddrOffset] == (bSwap ? 0x02 : 0x03))
|
||||
{
|
||||
bFormatDetected = TRUE;
|
||||
break;
|
||||
}
|
||||
bSwap = FALSE;
|
||||
default:
|
||||
dwAddrOffset = dwSizeLo / 2;
|
||||
bDA19 = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bFormatDetected)
|
||||
{
|
||||
free(pRom);
|
||||
UnmapViewOfFile(pIn);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
printf("Stopped, unknown format.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bUnpack) printf("Unpacking nibbles.\n");
|
||||
if (bSwap) printf("Swapping nibbles.\n");
|
||||
if (bText) printf("Reading text file.\n");
|
||||
if (bDA19) printf("Swapping banks.\n");
|
||||
|
||||
if (bText)
|
||||
{
|
||||
DWORD i = 0;
|
||||
while (i<dwSizeLo)
|
||||
{
|
||||
DWORD d = Asc2Nib5(pIn+i);
|
||||
i+=6;
|
||||
pRom[d+0x0] = Asc2Nib(pIn[i+0x0]);
|
||||
pRom[d+0x1] = Asc2Nib(pIn[i+0x1]);
|
||||
pRom[d+0x2] = Asc2Nib(pIn[i+0x2]);
|
||||
pRom[d+0x3] = Asc2Nib(pIn[i+0x3]);
|
||||
pRom[d+0x4] = Asc2Nib(pIn[i+0x4]);
|
||||
pRom[d+0x5] = Asc2Nib(pIn[i+0x5]);
|
||||
pRom[d+0x6] = Asc2Nib(pIn[i+0x6]);
|
||||
pRom[d+0x7] = Asc2Nib(pIn[i+0x7]);
|
||||
pRom[d+0x8] = Asc2Nib(pIn[i+0x8]);
|
||||
pRom[d+0x9] = Asc2Nib(pIn[i+0x9]);
|
||||
pRom[d+0xA] = Asc2Nib(pIn[i+0xA]);
|
||||
pRom[d+0xB] = Asc2Nib(pIn[i+0xB]);
|
||||
pRom[d+0xC] = Asc2Nib(pIn[i+0xC]);
|
||||
pRom[d+0xD] = Asc2Nib(pIn[i+0xD]);
|
||||
pRom[d+0xE] = Asc2Nib(pIn[i+0xE]);
|
||||
pRom[d+0xF] = Asc2Nib(pIn[i+0xF]);
|
||||
i+=16;
|
||||
while ((i<dwSizeLo)&&((pIn[i]==0x0D)||(pIn[i]==0x0A))) i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bUnpack)
|
||||
{
|
||||
if (bSwap)
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i++)
|
||||
{
|
||||
BYTE byC = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[(i<<1) ] = byC>>4;
|
||||
pRom[(i<<1)+1] = byC&0xF;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i++)
|
||||
{
|
||||
BYTE byC = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[(i<<1) ] = byC&0xF;
|
||||
pRom[(i<<1)+1] = byC>>4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bSwap)
|
||||
{
|
||||
DWORD i;
|
||||
for (i=0; i<dwSizeLo; i+=2)
|
||||
{
|
||||
BYTE a, b;
|
||||
a = pIn[(i+dwAddrOffset)&(dwSizeLo-1)];
|
||||
b = pIn[(i+1+dwAddrOffset)&(dwSizeLo-1)];
|
||||
pRom[i] = b;
|
||||
pRom[i+1] = a;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(bDA19)
|
||||
{
|
||||
assert(dwAddrOffset == dwSizeLo/2);
|
||||
CopyMemory(&pRom[0] , &pIn[dwAddrOffset], dwAddrOffset);
|
||||
CopyMemory(&pRom[dwAddrOffset], &pIn[0] , dwAddrOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyMemory(pRom, pIn, dwSizeLo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnmapViewOfFile(pIn);
|
||||
CloseHandle(hMap);
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (bText||bUnpack||bSwap||bDA19)
|
||||
{
|
||||
printf("File converted.\n\n");
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// HP38G
|
||||
wType = HP38G;
|
||||
dwAddress = 0x7FFAF;
|
||||
uLen = 10;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// HP48SX
|
||||
wType = HP48S;
|
||||
dwAddress = 0x7FFF0;
|
||||
uLen = 6;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// HP48GX
|
||||
wType = HP48G;
|
||||
dwAddress = 0x7FFBF;
|
||||
uLen = 6;
|
||||
if (IsHP(dwAddress)) break;
|
||||
|
||||
// unknown
|
||||
uLen = 0;
|
||||
}
|
||||
while (0);
|
||||
|
||||
printf("ROM Model Detected : HP%c8%c\n",(wType == HP38G)?'3':'4',(wType != HP48S)?'G':'S');
|
||||
|
||||
for (i=0; i<uLen; ++i)
|
||||
{
|
||||
szVersion[i] = pRom[dwAddress + (i<<1) + 1] << 4;
|
||||
szVersion[i] |= pRom[dwAddress + (i<<1)];
|
||||
}
|
||||
szVersion[i] = 0;
|
||||
|
||||
printf("ROM Version : %s\n", szVersion);
|
||||
|
||||
ZeroMemory(pRom+0x100, 0x40); // clear IO register area
|
||||
|
||||
if (CheckCRC())
|
||||
{
|
||||
printf("ROM CRC Test Passed.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ROM CRC Test FAILED !\n");
|
||||
}
|
||||
|
||||
if (argc == 3) // write target file
|
||||
{
|
||||
DWORD dwWritten;
|
||||
|
||||
// size of target file
|
||||
DWORD dwRomSize = (wType != HP48S)?(512*1024*2):(256*1024*2);
|
||||
|
||||
hOut = CreateFile(argv[iArg+1],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(pRom);
|
||||
printf("Cannot open file %s.\n", argv[iArg+1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bPack) // pack target ROM image
|
||||
{
|
||||
LPBYTE pbySrc,pbyDest;
|
||||
DWORD i;
|
||||
|
||||
dwRomSize /= 2; // packed image has half of size
|
||||
|
||||
// pack data
|
||||
pbySrc = pbyDest = pRom;
|
||||
for (i = 0; i < dwRomSize; i++)
|
||||
{
|
||||
*pbyDest = *pbySrc++;
|
||||
*pbyDest |= *pbySrc++ << 4;
|
||||
pbyDest++;
|
||||
}
|
||||
}
|
||||
|
||||
WriteFile(hOut,pRom,dwRomSize,&dwWritten,NULL);
|
||||
CloseHandle(hOut);
|
||||
}
|
||||
|
||||
free(pRom);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,3 +1,89 @@
|
|||
Service Pack 67 for Emu48 Version 1.0
|
||||
|
||||
DEBUGGER.C
|
||||
- changed position of debugger window with a default position marker
|
||||
- changed function Debugger(), in case WM_INITDIALOG set windows
|
||||
position only if given windows position don't contain the default
|
||||
position marker
|
||||
- changed function OnToolDebug(), on dialog creation set main window
|
||||
as parent window
|
||||
- changed function LoadMemData() and SaveMemData(), changed function
|
||||
prototype by adding a bit mode flag to load or save data in 8-bit
|
||||
or 4-bit mode
|
||||
- changed function DebugMemLoad() and DebugMemSave(), added decoding
|
||||
of radio buttons and adjusted to new prototypes of function
|
||||
LoadMemData() and SaveMemData()
|
||||
|
||||
EMU48.C
|
||||
- bugfix in function WinMain(), changed UNICODE command line
|
||||
argument decoding to prevent memory leak and added WSAStartup() /
|
||||
WSACleanup() network stack sequence calling once
|
||||
|
||||
EMU48.H
|
||||
- extern declaration of global variable
|
||||
|
||||
EMU48.RC
|
||||
- changed IDD_DEBUG_MEMSAVE and IDD_DEBUG_MEMLOAD, added radio
|
||||
buttons to select bit width of memory files
|
||||
- changed version and copyright
|
||||
|
||||
FETCH.C
|
||||
- changed all tables, added braces around each table element for
|
||||
Clang compatibility
|
||||
|
||||
LODEPNG.C
|
||||
- changed implementation file to LodePNG version 20230410 with
|
||||
unmarked typecast patches for x64 compatibility, Copyright (c)
|
||||
2005-2023 Lode Vandevenne
|
||||
|
||||
LODEPNG.H
|
||||
- changed header file to LodePNG version 20230410
|
||||
|
||||
MOPS.C
|
||||
- changed function ReadT2Acc(), changed CPU slow down
|
||||
implementation, on SMP systems a CriticalSection is treated as a
|
||||
mutex object which is much slower, so short consecutive
|
||||
CriticalSections of the same object should be avoided
|
||||
- changed function ReadIO(), changed CPU slow down implementation
|
||||
for the TBF bit in the TCS (0x112) register, on SMP systems a
|
||||
CriticalSection is treated as a mutex object which is much slower,
|
||||
so short consecutive CriticalSections of the same object should be
|
||||
avoided
|
||||
|
||||
RESOURCE.H
|
||||
- added definitions
|
||||
|
||||
SERIAL.C
|
||||
- changed function CommOpen(), removed assertion for UART on
|
||||
|
||||
SETTINGS.C
|
||||
- changed function ReadSettings() and WriteSettings(), added item
|
||||
"LocaleDecimalPoint" in section [Emulator] in the INI-File
|
||||
|
||||
STACK.C
|
||||
- added variable bLocaleDecimalPoint for choosing the decimal point
|
||||
given by the calculator or the Windows Locale setting
|
||||
- added function CheckThousandGroup(), check if character is the
|
||||
thousand separator
|
||||
- added function GetClpbrdDecimalPoint(), get decimal point from
|
||||
clipboard
|
||||
- changed function SetBcd(), accept number string with thousand
|
||||
separator now
|
||||
- changed function GetRadix(), added possibility of using the
|
||||
Windows Locale instead of calculator setting
|
||||
- changed function OnStackPaste(), get get decimal point for real
|
||||
and complex numbers from clipboard instead from calculator
|
||||
|
||||
TIMER.C
|
||||
- changed function SetHP48Time(), use one loop for clock and auto
|
||||
off writing, use function UpCRC() for CRC calculation and removed
|
||||
intermediate buffer for writing the CRC
|
||||
|
||||
UDP.C
|
||||
- changed function SendByteUdp(), moved WSAStartup() / WSACleanup()
|
||||
sequence to function WinMain()
|
||||
|
||||
|
||||
Service Pack 66 for Emu48 Version 1.0
|
||||
|
||||
DISRPL.C
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
/*
|
||||
* color.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define COLOR_BLACK 0x00000000
|
||||
#define COLOR_MAROON 0x00000080
|
||||
#define COLOR_GREEN 0x00008000
|
||||
#define COLOR_OLIVE 0x00008080
|
||||
#define COLOR_NAVY 0x00800000
|
||||
#define COLOR_PURPLE 0x00800080
|
||||
#define COLOR_TEAL 0x00808000
|
||||
#define COLOR_GRAY 0x00808080
|
||||
#define COLOR_SILVER 0x00C0C0C0
|
||||
#define COLOR_RED 0x000000FF
|
||||
#define COLOR_LIME 0x0000FF00
|
||||
#define COLOR_YELLOW 0x0000FFFF
|
||||
#define COLOR_BLUE 0x00FF0000
|
||||
#define COLOR_FUCHSIA 0x00FF00FF
|
||||
#define COLOR_AQUA 0x00FFFF00
|
||||
#define COLOR_LTGRAY 0x00C0C0C0
|
||||
#define COLOR_DKGRAY 0x00808080
|
||||
#define COLOR_WHITE 0x00FFFFFF
|
||||
/*
|
||||
* color.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define COLOR_BLACK 0x00000000
|
||||
#define COLOR_MAROON 0x00000080
|
||||
#define COLOR_GREEN 0x00008000
|
||||
#define COLOR_OLIVE 0x00008080
|
||||
#define COLOR_NAVY 0x00800000
|
||||
#define COLOR_PURPLE 0x00800080
|
||||
#define COLOR_TEAL 0x00808000
|
||||
#define COLOR_GRAY 0x00808080
|
||||
#define COLOR_SILVER 0x00C0C0C0
|
||||
#define COLOR_RED 0x000000FF
|
||||
#define COLOR_LIME 0x0000FF00
|
||||
#define COLOR_YELLOW 0x0000FFFF
|
||||
#define COLOR_BLUE 0x00FF0000
|
||||
#define COLOR_FUCHSIA 0x00FF00FF
|
||||
#define COLOR_AQUA 0x00FFFF00
|
||||
#define COLOR_LTGRAY 0x00C0C0C0
|
||||
#define COLOR_DKGRAY 0x00808080
|
||||
#define COLOR_WHITE 0x00FFFFFF
|
|
@ -1,89 +1,89 @@
|
|||
/*
|
||||
* Cursor.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2004 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
|
||||
// hand cursor AND mask
|
||||
static CONST BYTE ANDmaskCursor[] =
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xF3, 0xFF, 0xFF, // 1111 1111 1111 0011 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE0, 0x7F, 0xFF, // 1111 1111 1110 0000 0111 1111 1111 1111
|
||||
0xFF, 0xE0, 0x0F, 0xFF, // 1111 1111 1110 0000 0000 1111 1111 1111
|
||||
0xFF, 0xE0, 0x03, 0xFF, // 1111 1111 1110 0000 0000 0011 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFE, 0x20, 0x00, 0xFF, // 1111 1110 0010 0000 0000 0000 1111 1111
|
||||
0xFE, 0x00, 0x00, 0xFF, // 1111 1110 0000 0000 0000 0000 1111 1111
|
||||
0xFE, 0x00, 0x00, 0xFF, // 1111 1110 0000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x00, 0x00, 0xFF, // 1111 1111 0000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x80, 0x00, 0xFF, // 1111 1111 1000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x80, 0x00, 0xFF, // 1111 1111 1000 0000 0000 0000 1111 1111
|
||||
0xFF, 0xC0, 0x00, 0xFF, // 1111 1111 1100 0000 0000 0000 1111 1111
|
||||
0xFF, 0xC0, 0x01, 0xFF, // 1111 1111 1100 0000 0000 0001 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
};
|
||||
|
||||
// hand cursor XOR mask
|
||||
static CONST BYTE XORmaskCursor[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0D, 0x80, 0x00, // 0000 0000 0000 1101 1000 0000 0000 0000
|
||||
0x00, 0x0D, 0xB0, 0x00, // 0000 0000 0000 1101 1011 0000 0000 0000
|
||||
0x00, 0x0D, 0xB4, 0x00, // 0000 0000 0000 1101 1011 0100 0000 0000
|
||||
0x00, 0x0D, 0xB6, 0x00, // 0000 0000 0000 1101 1011 0110 0000 0000
|
||||
0x00, 0xCF, 0xF6, 0x00, // 0000 0000 1100 1111 1111 0110 0000 0000
|
||||
0x00, 0xEF, 0xFE, 0x00, // 0000 0000 1110 1111 1111 1110 0000 0000
|
||||
0x00, 0x6F, 0xFE, 0x00, // 0000 0000 0110 1111 1111 1110 0000 0000
|
||||
0x00, 0x2F, 0xFE, 0x00, // 0000 0000 0010 1111 1111 1110 0000 0000
|
||||
0x00, 0x3F, 0xFE, 0x00, // 0000 0000 0011 1111 1111 1110 0000 0000
|
||||
0x00, 0x1F, 0xFE, 0x00, // 0000 0000 0001 1111 1111 1110 0000 0000
|
||||
0x00, 0x1F, 0xFC, 0x00, // 0000 0000 0001 1111 1111 1100 0000 0000
|
||||
0x00, 0x0F, 0xFC, 0x00, // 0000 0000 0000 1111 1111 1100 0000 0000
|
||||
0x00, 0x0F, 0xFC, 0x00, // 0000 0000 0000 1111 1111 1100 0000 0000
|
||||
0x00, 0x07, 0xF8, 0x00, // 0000 0000 0000 0111 1111 1000 0000 0000
|
||||
0x00, 0x07, 0xF8, 0x00, // 0000 0000 0000 0111 1111 1000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00 // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
};
|
||||
|
||||
HCURSOR CreateHandCursor(VOID)
|
||||
{
|
||||
return CreateCursor(hApp,12,5,32,32,ANDmaskCursor,XORmaskCursor);
|
||||
}
|
||||
/*
|
||||
* Cursor.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2004 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
|
||||
// hand cursor AND mask
|
||||
static CONST BYTE ANDmaskCursor[] =
|
||||
{
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xF3, 0xFF, 0xFF, // 1111 1111 1111 0011 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE1, 0xFF, 0xFF, // 1111 1111 1110 0001 1111 1111 1111 1111
|
||||
0xFF, 0xE0, 0x7F, 0xFF, // 1111 1111 1110 0000 0111 1111 1111 1111
|
||||
0xFF, 0xE0, 0x0F, 0xFF, // 1111 1111 1110 0000 0000 1111 1111 1111
|
||||
0xFF, 0xE0, 0x03, 0xFF, // 1111 1111 1110 0000 0000 0011 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFE, 0x20, 0x00, 0xFF, // 1111 1110 0010 0000 0000 0000 1111 1111
|
||||
0xFE, 0x00, 0x00, 0xFF, // 1111 1110 0000 0000 0000 0000 1111 1111
|
||||
0xFE, 0x00, 0x00, 0xFF, // 1111 1110 0000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x00, 0x00, 0xFF, // 1111 1111 0000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x80, 0x00, 0xFF, // 1111 1111 1000 0000 0000 0000 1111 1111
|
||||
0xFF, 0x80, 0x00, 0xFF, // 1111 1111 1000 0000 0000 0000 1111 1111
|
||||
0xFF, 0xC0, 0x00, 0xFF, // 1111 1111 1100 0000 0000 0000 1111 1111
|
||||
0xFF, 0xC0, 0x01, 0xFF, // 1111 1111 1100 0000 0000 0001 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFF, 0xE0, 0x01, 0xFF, // 1111 1111 1110 0000 0000 0001 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xF0, 0x03, 0xFF, // 1111 1111 1111 0000 0000 0011 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
0xFF, 0xFF, 0xFF, 0xFF // 1111 1111 1111 1111 1111 1111 1111 1111
|
||||
};
|
||||
|
||||
// hand cursor XOR mask
|
||||
static CONST BYTE XORmaskCursor[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0C, 0x00, 0x00, // 0000 0000 0000 1100 0000 0000 0000 0000
|
||||
0x00, 0x0D, 0x80, 0x00, // 0000 0000 0000 1101 1000 0000 0000 0000
|
||||
0x00, 0x0D, 0xB0, 0x00, // 0000 0000 0000 1101 1011 0000 0000 0000
|
||||
0x00, 0x0D, 0xB4, 0x00, // 0000 0000 0000 1101 1011 0100 0000 0000
|
||||
0x00, 0x0D, 0xB6, 0x00, // 0000 0000 0000 1101 1011 0110 0000 0000
|
||||
0x00, 0xCF, 0xF6, 0x00, // 0000 0000 1100 1111 1111 0110 0000 0000
|
||||
0x00, 0xEF, 0xFE, 0x00, // 0000 0000 1110 1111 1111 1110 0000 0000
|
||||
0x00, 0x6F, 0xFE, 0x00, // 0000 0000 0110 1111 1111 1110 0000 0000
|
||||
0x00, 0x2F, 0xFE, 0x00, // 0000 0000 0010 1111 1111 1110 0000 0000
|
||||
0x00, 0x3F, 0xFE, 0x00, // 0000 0000 0011 1111 1111 1110 0000 0000
|
||||
0x00, 0x1F, 0xFE, 0x00, // 0000 0000 0001 1111 1111 1110 0000 0000
|
||||
0x00, 0x1F, 0xFC, 0x00, // 0000 0000 0001 1111 1111 1100 0000 0000
|
||||
0x00, 0x0F, 0xFC, 0x00, // 0000 0000 0000 1111 1111 1100 0000 0000
|
||||
0x00, 0x0F, 0xFC, 0x00, // 0000 0000 0000 1111 1111 1100 0000 0000
|
||||
0x00, 0x07, 0xF8, 0x00, // 0000 0000 0000 0111 1111 1000 0000 0000
|
||||
0x00, 0x07, 0xF8, 0x00, // 0000 0000 0000 0111 1111 1000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00, // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
0x00, 0x00, 0x00, 0x00 // 0000 0000 0000 0000 0000 0000 0000 0000
|
||||
};
|
||||
|
||||
HCURSOR CreateHandCursor(VOID)
|
||||
{
|
||||
return CreateCursor(hApp,12,5,32,32,ANDmaskCursor,XORmaskCursor);
|
||||
}
|
|
@ -1,182 +1,182 @@
|
|||
/*
|
||||
* DdeServ.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1998 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
HDDEDATA CALLBACK DdeCallback(UINT iType,UINT iFmt,HCONV hConv,
|
||||
HSZ hsz1,HSZ hsz2,HDDEDATA hData,
|
||||
DWORD dwData1,DWORD dwData2)
|
||||
{
|
||||
TCHAR *psz,szBuffer[32];
|
||||
HDDEDATA hReturn;
|
||||
LPBYTE lpData,lpHeader;
|
||||
DWORD dwAddress,dwSize,dwLoop,dwIndex;
|
||||
UINT nStkLvl;
|
||||
BOOL bSuccess;
|
||||
|
||||
// disable stack loading items on HP38G, HP39/40G
|
||||
BOOL bStackEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E';
|
||||
|
||||
switch (iType)
|
||||
{
|
||||
case XTYP_CONNECT:
|
||||
// get service name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
if (0 != lstrcmp(szBuffer,szAppName))
|
||||
return (HDDEDATA) FALSE;
|
||||
// get topic name
|
||||
DdeQueryString(idDdeInst,hsz1,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
return (HDDEDATA) (INT_PTR) (0 == lstrcmp(szBuffer,szTopic));
|
||||
|
||||
case XTYP_POKE:
|
||||
// quit on models without stack or illegal data format or not in running state
|
||||
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
|
||||
return (HDDEDATA) DDE_FNOTPROCESSED;
|
||||
|
||||
// get item name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
nStkLvl = _tcstoul(szBuffer,&psz,10);
|
||||
if (*psz != 0 || nStkLvl < 1) // invalid number format
|
||||
return (HDDEDATA) DDE_FNOTPROCESSED;
|
||||
|
||||
SuspendDebugger(); // suspend debugger
|
||||
bDbgAutoStateCtrl = FALSE; // disable automatic debugger state control
|
||||
|
||||
if (!(Chipset.IORam[BITOFFSET]&DON)) // HP off
|
||||
{
|
||||
// turn on HP
|
||||
KeyboardEvent(TRUE,0,0x8000);
|
||||
Sleep(dwWakeupDelay);
|
||||
KeyboardEvent(FALSE,0,0x8000);
|
||||
}
|
||||
|
||||
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
|
||||
{
|
||||
hReturn = DDE_FNOTPROCESSED;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_SLEEP);
|
||||
|
||||
bSuccess = FALSE;
|
||||
|
||||
// get data and size
|
||||
lpData = DdeAccessData(hData,&dwSize);
|
||||
|
||||
// has object length header
|
||||
if (lpData && dwSize >= sizeof(DWORD))
|
||||
{
|
||||
dwIndex = *(LPDWORD) lpData; // object length
|
||||
|
||||
if (dwIndex <= dwSize - sizeof(DWORD))
|
||||
{
|
||||
// reserve unpacked object length memory
|
||||
LPBYTE pbyMem = (LPBYTE) malloc(dwIndex * 2);
|
||||
|
||||
if (pbyMem != NULL)
|
||||
{
|
||||
// copy data and write to stack
|
||||
CopyMemory(pbyMem+dwIndex,lpData+sizeof(DWORD),dwIndex);
|
||||
bSuccess = (WriteStack(nStkLvl,pbyMem,dwIndex) == S_ERR_NO);
|
||||
free(pbyMem); // free memory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DdeUnaccessData(hData);
|
||||
|
||||
SwitchToState(SM_RUN); // run state
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_RUN);
|
||||
|
||||
if (bSuccess == FALSE)
|
||||
{
|
||||
hReturn = DDE_FNOTPROCESSED;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
KeyboardEvent(TRUE,0,0x8000);
|
||||
Sleep(dwWakeupDelay);
|
||||
KeyboardEvent(FALSE,0,0x8000);
|
||||
// wait for sleep mode
|
||||
while (Chipset.Shutdn == FALSE) Sleep(0);
|
||||
hReturn = (HDDEDATA) DDE_FACK;
|
||||
|
||||
cancel:
|
||||
bDbgAutoStateCtrl = TRUE; // enable automatic debugger state control
|
||||
ResumeDebugger();
|
||||
return hReturn;
|
||||
|
||||
case XTYP_REQUEST:
|
||||
// quit on models without stack or illegal data format or not in running state
|
||||
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
|
||||
return NULL;
|
||||
|
||||
// get item name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
nStkLvl = _tcstoul(szBuffer,&psz,10);
|
||||
if (*psz != 0 || nStkLvl < 1) // invalid number format
|
||||
return NULL;
|
||||
|
||||
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
|
||||
return NULL;
|
||||
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_SLEEP);
|
||||
|
||||
dwAddress = RPL_Pick(nStkLvl); // pick address of stack level "item" object
|
||||
if (dwAddress == 0)
|
||||
{
|
||||
SwitchToState(SM_RUN); // run state
|
||||
return NULL;
|
||||
}
|
||||
dwLoop = dwSize = (RPL_SkipOb(dwAddress) - dwAddress + 1) / 2;
|
||||
|
||||
lpHeader = (Chipset.type != 'X') ? (LPBYTE) BINARYHEADER48 : (LPBYTE) BINARYHEADER49;
|
||||
|
||||
// length of binary header
|
||||
dwIndex = (DWORD) strlen((LPCSTR) lpHeader);
|
||||
|
||||
// size of objectsize + header + object
|
||||
dwSize += dwIndex + sizeof(DWORD);
|
||||
|
||||
// reserve memory
|
||||
if ((lpData = (LPBYTE) malloc(dwSize)) == NULL)
|
||||
{
|
||||
SwitchToState(SM_RUN); // run state
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// save data length
|
||||
*(DWORD *)lpData = dwLoop + dwIndex;
|
||||
|
||||
// copy header
|
||||
memcpy(lpData + sizeof(DWORD),lpHeader,dwIndex);
|
||||
|
||||
// copy data
|
||||
for (dwIndex += sizeof(DWORD);dwLoop--;++dwIndex,dwAddress += 2)
|
||||
lpData[dwIndex] = Read2(dwAddress);
|
||||
|
||||
// write data
|
||||
hReturn = DdeCreateDataHandle(idDdeInst,lpData,dwSize,0,hsz2,iFmt,0);
|
||||
free(lpData);
|
||||
|
||||
SwitchToState(SM_RUN); // run state
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_RUN);
|
||||
|
||||
return hReturn;
|
||||
}
|
||||
return NULL;
|
||||
UNREFERENCED_PARAMETER(hConv);
|
||||
UNREFERENCED_PARAMETER(dwData1);
|
||||
UNREFERENCED_PARAMETER(dwData2);
|
||||
}
|
||||
/*
|
||||
* DdeServ.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1998 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
HDDEDATA CALLBACK DdeCallback(UINT iType,UINT iFmt,HCONV hConv,
|
||||
HSZ hsz1,HSZ hsz2,HDDEDATA hData,
|
||||
DWORD dwData1,DWORD dwData2)
|
||||
{
|
||||
TCHAR *psz,szBuffer[32];
|
||||
HDDEDATA hReturn;
|
||||
LPBYTE lpData,lpHeader;
|
||||
DWORD dwAddress,dwSize,dwLoop,dwIndex;
|
||||
UINT nStkLvl;
|
||||
BOOL bSuccess;
|
||||
|
||||
// disable stack loading items on HP38G, HP39/40G
|
||||
BOOL bStackEnable = cCurrentRomType!='6' && cCurrentRomType!='A' && cCurrentRomType!='E';
|
||||
|
||||
switch (iType)
|
||||
{
|
||||
case XTYP_CONNECT:
|
||||
// get service name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
if (0 != lstrcmp(szBuffer,szAppName))
|
||||
return (HDDEDATA) FALSE;
|
||||
// get topic name
|
||||
DdeQueryString(idDdeInst,hsz1,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
return (HDDEDATA) (INT_PTR) (0 == lstrcmp(szBuffer,szTopic));
|
||||
|
||||
case XTYP_POKE:
|
||||
// quit on models without stack or illegal data format or not in running state
|
||||
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
|
||||
return (HDDEDATA) DDE_FNOTPROCESSED;
|
||||
|
||||
// get item name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
nStkLvl = _tcstoul(szBuffer,&psz,10);
|
||||
if (*psz != 0 || nStkLvl < 1) // invalid number format
|
||||
return (HDDEDATA) DDE_FNOTPROCESSED;
|
||||
|
||||
SuspendDebugger(); // suspend debugger
|
||||
bDbgAutoStateCtrl = FALSE; // disable automatic debugger state control
|
||||
|
||||
if (!(Chipset.IORam[BITOFFSET]&DON)) // HP off
|
||||
{
|
||||
// turn on HP
|
||||
KeyboardEvent(TRUE,0,0x8000);
|
||||
Sleep(dwWakeupDelay);
|
||||
KeyboardEvent(FALSE,0,0x8000);
|
||||
}
|
||||
|
||||
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
|
||||
{
|
||||
hReturn = DDE_FNOTPROCESSED;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_SLEEP);
|
||||
|
||||
bSuccess = FALSE;
|
||||
|
||||
// get data and size
|
||||
lpData = DdeAccessData(hData,&dwSize);
|
||||
|
||||
// has object length header
|
||||
if (lpData && dwSize >= sizeof(DWORD))
|
||||
{
|
||||
dwIndex = *(LPDWORD) lpData; // object length
|
||||
|
||||
if (dwIndex <= dwSize - sizeof(DWORD))
|
||||
{
|
||||
// reserve unpacked object length memory
|
||||
LPBYTE pbyMem = (LPBYTE) malloc(dwIndex * 2);
|
||||
|
||||
if (pbyMem != NULL)
|
||||
{
|
||||
// copy data and write to stack
|
||||
CopyMemory(pbyMem+dwIndex,lpData+sizeof(DWORD),dwIndex);
|
||||
bSuccess = (WriteStack(nStkLvl,pbyMem,dwIndex) == S_ERR_NO);
|
||||
free(pbyMem); // free memory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DdeUnaccessData(hData);
|
||||
|
||||
SwitchToState(SM_RUN); // run state
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_RUN);
|
||||
|
||||
if (bSuccess == FALSE)
|
||||
{
|
||||
hReturn = DDE_FNOTPROCESSED;
|
||||
goto cancel;
|
||||
}
|
||||
|
||||
KeyboardEvent(TRUE,0,0x8000);
|
||||
Sleep(dwWakeupDelay);
|
||||
KeyboardEvent(FALSE,0,0x8000);
|
||||
// wait for sleep mode
|
||||
while (Chipset.Shutdn == FALSE) Sleep(0);
|
||||
hReturn = (HDDEDATA) DDE_FACK;
|
||||
|
||||
cancel:
|
||||
bDbgAutoStateCtrl = TRUE; // enable automatic debugger state control
|
||||
ResumeDebugger();
|
||||
return hReturn;
|
||||
|
||||
case XTYP_REQUEST:
|
||||
// quit on models without stack or illegal data format or not in running state
|
||||
if (!bStackEnable || iFmt != uCF_HpObj || nState != SM_RUN)
|
||||
return NULL;
|
||||
|
||||
// get item name
|
||||
DdeQueryString(idDdeInst,hsz2,szBuffer,ARRAYSIZEOF(szBuffer),0);
|
||||
nStkLvl = _tcstoul(szBuffer,&psz,10);
|
||||
if (*psz != 0 || nStkLvl < 1) // invalid number format
|
||||
return NULL;
|
||||
|
||||
if (WaitForSleepState()) // wait for cpu SHUTDN then sleep state
|
||||
return NULL;
|
||||
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_SLEEP);
|
||||
|
||||
dwAddress = RPL_Pick(nStkLvl); // pick address of stack level "item" object
|
||||
if (dwAddress == 0)
|
||||
{
|
||||
SwitchToState(SM_RUN); // run state
|
||||
return NULL;
|
||||
}
|
||||
dwLoop = dwSize = (RPL_SkipOb(dwAddress) - dwAddress + 1) / 2;
|
||||
|
||||
lpHeader = (Chipset.type != 'X') ? (LPBYTE) BINARYHEADER48 : (LPBYTE) BINARYHEADER49;
|
||||
|
||||
// length of binary header
|
||||
dwIndex = (DWORD) strlen((LPCSTR) lpHeader);
|
||||
|
||||
// size of objectsize + header + object
|
||||
dwSize += dwIndex + sizeof(DWORD);
|
||||
|
||||
// reserve memory
|
||||
if ((lpData = (LPBYTE) malloc(dwSize)) == NULL)
|
||||
{
|
||||
SwitchToState(SM_RUN); // run state
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// save data length
|
||||
*(DWORD *)lpData = dwLoop + dwIndex;
|
||||
|
||||
// copy header
|
||||
memcpy(lpData + sizeof(DWORD),lpHeader,dwIndex);
|
||||
|
||||
// copy data
|
||||
for (dwIndex += sizeof(DWORD);dwLoop--;++dwIndex,dwAddress += 2)
|
||||
lpData[dwIndex] = Read2(dwAddress);
|
||||
|
||||
// write data
|
||||
hReturn = DdeCreateDataHandle(idDdeInst,lpData,dwSize,0,hsz2,iFmt,0);
|
||||
free(lpData);
|
||||
|
||||
SwitchToState(SM_RUN); // run state
|
||||
while (nState!=nNextState) Sleep(0);
|
||||
_ASSERT(nState==SM_RUN);
|
||||
|
||||
return hReturn;
|
||||
}
|
||||
return NULL;
|
||||
UNREFERENCED_PARAMETER(hConv);
|
||||
UNREFERENCED_PARAMETER(dwData1);
|
||||
UNREFERENCED_PARAMETER(dwData2);
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,39 +1,39 @@
|
|||
/*
|
||||
* debugger.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// breakpoint type definitions
|
||||
#define BP_EXEC 0x01 // code breakpoint
|
||||
#define BP_READ 0x02 // read memory breakpoint
|
||||
#define BP_WRITE 0x04 // write memory breakpoint
|
||||
#define BP_RPL 0x08 // RPL breakpoint
|
||||
#define BP_ACCESS (BP_READ|BP_WRITE) // read/write memory breakpoint
|
||||
|
||||
// breakpoint notify definitions
|
||||
#define BN_ASM 0 // ASM breakpoint
|
||||
#define BN_RPL 1 // RPL breakpoint
|
||||
#define BN_ASM_BT 2 // ASM and RPL breakpoint
|
||||
|
||||
// debugger state definitions
|
||||
#define DBG_SUSPEND -1
|
||||
#define DBG_OFF 0
|
||||
#define DBG_RUN 1
|
||||
#define DBG_STEPINTO 2
|
||||
#define DBG_STEPOVER 3
|
||||
#define DBG_STEPOUT 4
|
||||
|
||||
// debugger.c
|
||||
extern VOID UpdateDbgCycleCounter(VOID);
|
||||
extern BOOL CheckBreakpoint(DWORD dwAddr, DWORD wRange, UINT nType);
|
||||
extern VOID NotifyDebugger(INT nType);
|
||||
extern VOID DisableDebugger(VOID);
|
||||
extern LRESULT OnToolDebug(VOID);
|
||||
extern VOID LoadBreakpointList(HANDLE hFile);
|
||||
extern VOID SaveBreakpointList(HANDLE hFile);
|
||||
extern VOID CreateBackupBreakpointList(VOID);
|
||||
extern VOID RestoreBackupBreakpointList(VOID);
|
||||
/*
|
||||
* debugger.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// breakpoint type definitions
|
||||
#define BP_EXEC 0x01 // code breakpoint
|
||||
#define BP_READ 0x02 // read memory breakpoint
|
||||
#define BP_WRITE 0x04 // write memory breakpoint
|
||||
#define BP_RPL 0x08 // RPL breakpoint
|
||||
#define BP_ACCESS (BP_READ|BP_WRITE) // read/write memory breakpoint
|
||||
|
||||
// breakpoint notify definitions
|
||||
#define BN_ASM 0 // ASM breakpoint
|
||||
#define BN_RPL 1 // RPL breakpoint
|
||||
#define BN_ASM_BT 2 // ASM and RPL breakpoint
|
||||
|
||||
// debugger state definitions
|
||||
#define DBG_SUSPEND -1
|
||||
#define DBG_OFF 0
|
||||
#define DBG_RUN 1
|
||||
#define DBG_STEPINTO 2
|
||||
#define DBG_STEPOVER 3
|
||||
#define DBG_STEPOUT 4
|
||||
|
||||
// debugger.c
|
||||
extern VOID UpdateDbgCycleCounter(VOID);
|
||||
extern BOOL CheckBreakpoint(DWORD dwAddr, DWORD wRange, UINT nType);
|
||||
extern VOID NotifyDebugger(INT nType);
|
||||
extern VOID DisableDebugger(VOID);
|
||||
extern LRESULT OnToolDebug(VOID);
|
||||
extern VOID LoadBreakpointList(HANDLE hFile);
|
||||
extern VOID SaveBreakpointList(HANDLE hFile);
|
||||
extern VOID CreateBackupBreakpointList(VOID);
|
||||
extern VOID RestoreBackupBreakpointList(VOID);
|
File diff suppressed because it is too large
Load diff
|
@ -1,221 +1,221 @@
|
|||
/*
|
||||
* dismem.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2012 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
|
||||
typedef struct // type of model memory mapping
|
||||
{
|
||||
BYTE byType; // calculator type
|
||||
CONST LPBYTE *ppbyNCE1; // NCE1 data
|
||||
CONST DWORD *pdwNCE1Size; // NCE1 size
|
||||
CONST LPBYTE *ppbyNCE2; // NCE2 data
|
||||
CONST DWORD *pdwNCE2Size; // NCE2 size
|
||||
CONST LPBYTE *ppbyCE1; // CE1 data
|
||||
CONST DWORD *pdwCE1Size; // CE1 size
|
||||
CONST LPBYTE *ppbyCE2; // CE2 data
|
||||
CONST DWORD *pdwCE2Size; // CE2 size
|
||||
CONST LPBYTE *ppbyNCE3; // NCE3 data
|
||||
CONST DWORD *pdwNCE3Size; // NCE3 size
|
||||
} MODEL_MAP_T;
|
||||
|
||||
static CONST LPBYTE pbyNoMEM = NULL; // no memory module
|
||||
|
||||
static CONST MODEL_MAP_T MemMap[] =
|
||||
{
|
||||
{
|
||||
0, // default
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'6', // HP38G (64K)
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'A', // HP38G
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'E', // HP39/40G
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM part 1
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&Port2, &Chipset.Port2Size // RAM part 2
|
||||
},
|
||||
{
|
||||
'G', // HP48GX
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&Port1, &Chipset.Port1Size, // Card slot 1
|
||||
&pbyPort2, &dwPort2Size // Card slot 2
|
||||
},
|
||||
{
|
||||
'S', // HP48SX
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&Port1, &Chipset.Port1Size, // Card slot 1
|
||||
&pbyPort2, &dwPort2Size, // Card slot 2
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'X', // HP49G
|
||||
&pbyRom, &dwRomSize, // Flash
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&Port1, &Chipset.Port1Size, // Port 1 part 1
|
||||
&Port2, &Chipset.Port2Size // Port 1 part 2
|
||||
}
|
||||
};
|
||||
|
||||
static MODEL_MAP_T CONST *pMapping = MemMap; // model specific memory mapping
|
||||
static enum MEM_MAPPING eMapType = MEM_MMU; // MMU memory mapping
|
||||
|
||||
static LPBYTE pbyMapData = NULL;
|
||||
static DWORD dwMapDataSize = 0;
|
||||
static DWORD dwMapDataMask = 0;
|
||||
|
||||
BOOL SetMemRomType(BYTE cCurrentRomType)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
pMapping = MemMap; // init default mapping
|
||||
|
||||
// scan for all table entries
|
||||
for (i = 0; i < ARRAYSIZEOF(MemMap); ++i)
|
||||
{
|
||||
if (MemMap[i].byType == cCurrentRomType)
|
||||
{
|
||||
pMapping = &MemMap[i]; // found entry
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SetMemMapType(enum MEM_MAPPING eType)
|
||||
{
|
||||
BOOL bSucc = TRUE;
|
||||
|
||||
eMapType = eType;
|
||||
|
||||
switch (eMapType)
|
||||
{
|
||||
case MEM_MMU:
|
||||
pbyMapData = NULL; // data
|
||||
dwMapDataSize = 512 * 1024 * 2; // data size
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE1:
|
||||
pbyMapData = *pMapping->ppbyNCE1;
|
||||
dwMapDataSize = *pMapping->pdwNCE1Size; // ROM size is always in nibbles
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE2:
|
||||
pbyMapData = *pMapping->ppbyNCE2;
|
||||
dwMapDataSize = *pMapping->pdwNCE2Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_CE1:
|
||||
pbyMapData = *pMapping->ppbyCE1;
|
||||
dwMapDataSize = *pMapping->pdwCE1Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_CE2:
|
||||
pbyMapData = *pMapping->ppbyCE2;
|
||||
dwMapDataSize = *pMapping->pdwCE2Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE3:
|
||||
pbyMapData = *pMapping->ppbyNCE3;
|
||||
dwMapDataSize = *pMapping->pdwNCE3Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
default: _ASSERT(FALSE);
|
||||
pbyMapData = NULL;
|
||||
dwMapDataSize = 0;
|
||||
dwMapDataMask = 0;
|
||||
bSucc = FALSE;
|
||||
}
|
||||
return bSucc;
|
||||
}
|
||||
|
||||
enum MEM_MAPPING GetMemMapType(VOID)
|
||||
{
|
||||
return eMapType;
|
||||
}
|
||||
|
||||
BOOL GetMemAvail(enum MEM_MAPPING eType)
|
||||
{
|
||||
switch (eType)
|
||||
{
|
||||
case MEM_MMU: return TRUE;
|
||||
case MEM_NCE1: return *pMapping->ppbyNCE1 != NULL;
|
||||
case MEM_NCE2: return *pMapping->ppbyNCE2 != NULL;
|
||||
case MEM_CE1: return *pMapping->ppbyCE1 != NULL;
|
||||
case MEM_CE2: return *pMapping->ppbyCE2 != NULL;
|
||||
case MEM_NCE3: return *pMapping->ppbyNCE3 != NULL;
|
||||
default: _ASSERT(FALSE);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD GetMemDataSize(VOID)
|
||||
{
|
||||
return dwMapDataSize;
|
||||
}
|
||||
|
||||
DWORD GetMemDataMask(VOID)
|
||||
{
|
||||
return dwMapDataMask;
|
||||
}
|
||||
|
||||
BYTE GetMemNib(DWORD *p)
|
||||
{
|
||||
BYTE byVal;
|
||||
|
||||
if (pbyMapData == NULL)
|
||||
{
|
||||
Npeek(&byVal, *p, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
byVal = pbyMapData[*p];
|
||||
}
|
||||
*p = (*p + 1) & dwMapDataMask;
|
||||
return byVal;
|
||||
}
|
||||
|
||||
VOID GetMemPeek(BYTE *a, DWORD d, UINT s)
|
||||
{
|
||||
if (pbyMapData == NULL)
|
||||
{
|
||||
Npeek(a, d, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; s > 0; --s, ++d)
|
||||
{
|
||||
*a++ = pbyMapData[d & dwMapDataMask];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* dismem.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2012 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
|
||||
typedef struct // type of model memory mapping
|
||||
{
|
||||
BYTE byType; // calculator type
|
||||
CONST LPBYTE *ppbyNCE1; // NCE1 data
|
||||
CONST DWORD *pdwNCE1Size; // NCE1 size
|
||||
CONST LPBYTE *ppbyNCE2; // NCE2 data
|
||||
CONST DWORD *pdwNCE2Size; // NCE2 size
|
||||
CONST LPBYTE *ppbyCE1; // CE1 data
|
||||
CONST DWORD *pdwCE1Size; // CE1 size
|
||||
CONST LPBYTE *ppbyCE2; // CE2 data
|
||||
CONST DWORD *pdwCE2Size; // CE2 size
|
||||
CONST LPBYTE *ppbyNCE3; // NCE3 data
|
||||
CONST DWORD *pdwNCE3Size; // NCE3 size
|
||||
} MODEL_MAP_T;
|
||||
|
||||
static CONST LPBYTE pbyNoMEM = NULL; // no memory module
|
||||
|
||||
static CONST MODEL_MAP_T MemMap[] =
|
||||
{
|
||||
{
|
||||
0, // default
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'6', // HP38G (64K)
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'A', // HP38G
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'E', // HP39/40G
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM part 1
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&pbyNoMEM, NULL, // nc.
|
||||
&Port2, &Chipset.Port2Size // RAM part 2
|
||||
},
|
||||
{
|
||||
'G', // HP48GX
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&Port1, &Chipset.Port1Size, // Card slot 1
|
||||
&pbyPort2, &dwPort2Size // Card slot 2
|
||||
},
|
||||
{
|
||||
'S', // HP48SX
|
||||
&pbyRom, &dwRomSize, // ROM
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&Port1, &Chipset.Port1Size, // Card slot 1
|
||||
&pbyPort2, &dwPort2Size, // Card slot 2
|
||||
&pbyNoMEM, NULL // nc.
|
||||
},
|
||||
{
|
||||
'X', // HP49G
|
||||
&pbyRom, &dwRomSize, // Flash
|
||||
&Port0, &Chipset.Port0Size, // RAM
|
||||
&pbyNoMEM, NULL, // BS
|
||||
&Port1, &Chipset.Port1Size, // Port 1 part 1
|
||||
&Port2, &Chipset.Port2Size // Port 1 part 2
|
||||
}
|
||||
};
|
||||
|
||||
static MODEL_MAP_T CONST *pMapping = MemMap; // model specific memory mapping
|
||||
static enum MEM_MAPPING eMapType = MEM_MMU; // MMU memory mapping
|
||||
|
||||
static LPBYTE pbyMapData = NULL;
|
||||
static DWORD dwMapDataSize = 0;
|
||||
static DWORD dwMapDataMask = 0;
|
||||
|
||||
BOOL SetMemRomType(BYTE cCurrentRomType)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
pMapping = MemMap; // init default mapping
|
||||
|
||||
// scan for all table entries
|
||||
for (i = 0; i < ARRAYSIZEOF(MemMap); ++i)
|
||||
{
|
||||
if (MemMap[i].byType == cCurrentRomType)
|
||||
{
|
||||
pMapping = &MemMap[i]; // found entry
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL SetMemMapType(enum MEM_MAPPING eType)
|
||||
{
|
||||
BOOL bSucc = TRUE;
|
||||
|
||||
eMapType = eType;
|
||||
|
||||
switch (eMapType)
|
||||
{
|
||||
case MEM_MMU:
|
||||
pbyMapData = NULL; // data
|
||||
dwMapDataSize = 512 * 1024 * 2; // data size
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE1:
|
||||
pbyMapData = *pMapping->ppbyNCE1;
|
||||
dwMapDataSize = *pMapping->pdwNCE1Size; // ROM size is always in nibbles
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE2:
|
||||
pbyMapData = *pMapping->ppbyNCE2;
|
||||
dwMapDataSize = *pMapping->pdwNCE2Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_CE1:
|
||||
pbyMapData = *pMapping->ppbyCE1;
|
||||
dwMapDataSize = *pMapping->pdwCE1Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_CE2:
|
||||
pbyMapData = *pMapping->ppbyCE2;
|
||||
dwMapDataSize = *pMapping->pdwCE2Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
case MEM_NCE3:
|
||||
pbyMapData = *pMapping->ppbyNCE3;
|
||||
dwMapDataSize = *pMapping->pdwNCE3Size * 1024 * 2;
|
||||
dwMapDataMask = dwMapDataSize - 1; // size mask
|
||||
break;
|
||||
default: _ASSERT(FALSE);
|
||||
pbyMapData = NULL;
|
||||
dwMapDataSize = 0;
|
||||
dwMapDataMask = 0;
|
||||
bSucc = FALSE;
|
||||
}
|
||||
return bSucc;
|
||||
}
|
||||
|
||||
enum MEM_MAPPING GetMemMapType(VOID)
|
||||
{
|
||||
return eMapType;
|
||||
}
|
||||
|
||||
BOOL GetMemAvail(enum MEM_MAPPING eType)
|
||||
{
|
||||
switch (eType)
|
||||
{
|
||||
case MEM_MMU: return TRUE;
|
||||
case MEM_NCE1: return *pMapping->ppbyNCE1 != NULL;
|
||||
case MEM_NCE2: return *pMapping->ppbyNCE2 != NULL;
|
||||
case MEM_CE1: return *pMapping->ppbyCE1 != NULL;
|
||||
case MEM_CE2: return *pMapping->ppbyCE2 != NULL;
|
||||
case MEM_NCE3: return *pMapping->ppbyNCE3 != NULL;
|
||||
default: _ASSERT(FALSE);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DWORD GetMemDataSize(VOID)
|
||||
{
|
||||
return dwMapDataSize;
|
||||
}
|
||||
|
||||
DWORD GetMemDataMask(VOID)
|
||||
{
|
||||
return dwMapDataMask;
|
||||
}
|
||||
|
||||
BYTE GetMemNib(DWORD *p)
|
||||
{
|
||||
BYTE byVal;
|
||||
|
||||
if (pbyMapData == NULL)
|
||||
{
|
||||
Npeek(&byVal, *p, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
byVal = pbyMapData[*p];
|
||||
}
|
||||
*p = (*p + 1) & dwMapDataMask;
|
||||
return byVal;
|
||||
}
|
||||
|
||||
VOID GetMemPeek(BYTE *a, DWORD d, UINT s)
|
||||
{
|
||||
if (pbyMapData == NULL)
|
||||
{
|
||||
Npeek(a, d, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; s > 0; --s, ++d)
|
||||
{
|
||||
*a++ = pbyMapData[d & dwMapDataMask];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
* disrpl.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2008 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// RPL platform type
|
||||
#define RPL_P1 (1<<0) // Clamshell without RRP
|
||||
#define RPL_P2 (RPL_P1 | (1<<1)) // Pioneer / Clamshell
|
||||
#define RPL_P3 (RPL_P2 | (1<<2)) // Charlemagne
|
||||
#define RPL_P4 (RPL_P3 | (1<<3)) // Alcuin
|
||||
#define RPL_P5 (RPL_P4 | (1<<4)) // V'ger
|
||||
|
||||
extern DWORD dwRplPlatform; // RPL platform
|
||||
extern BOOL bRplViewName; // show entry point name
|
||||
extern BOOL bRplViewAddr; // show adress
|
||||
extern BOOL bRplViewBin; // show binary data
|
||||
extern BOOL bRplViewAsm; // show ASM code instead of hex data
|
||||
extern BYTE (*RplReadNibble)(DWORD *p); // read nibble function pointer
|
||||
extern DWORD RplSkipObject(DWORD dwAddr);
|
||||
extern LPTSTR RplDecodeObject(DWORD dwAddr, DWORD *pdwNxtAddr);
|
||||
extern LPTSTR RplCreateObjView(DWORD dwStartAddr, DWORD dwEndAddr, BOOL bSingleObj);
|
||||
/*
|
||||
* disrpl.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2008 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// RPL platform type
|
||||
#define RPL_P1 (1<<0) // Clamshell without RRP
|
||||
#define RPL_P2 (RPL_P1 | (1<<1)) // Pioneer / Clamshell
|
||||
#define RPL_P3 (RPL_P2 | (1<<2)) // Charlemagne
|
||||
#define RPL_P4 (RPL_P3 | (1<<3)) // Alcuin
|
||||
#define RPL_P5 (RPL_P4 | (1<<4)) // V'ger
|
||||
|
||||
extern DWORD dwRplPlatform; // RPL platform
|
||||
extern BOOL bRplViewName; // show entry point name
|
||||
extern BOOL bRplViewAddr; // show adress
|
||||
extern BOOL bRplViewBin; // show binary data
|
||||
extern BOOL bRplViewAsm; // show ASM code instead of hex data
|
||||
extern BYTE (*RplReadNibble)(DWORD *p); // read nibble function pointer
|
||||
extern DWORD RplSkipObject(DWORD dwAddr);
|
||||
extern LPTSTR RplDecodeObject(DWORD dwAddr, DWORD *pdwNxtAddr);
|
||||
extern LPTSTR RplCreateObjView(DWORD dwStartAddr, DWORD dwEndAddr, BOOL bSingleObj);
|
File diff suppressed because it is too large
Load diff
|
@ -1,454 +1,455 @@
|
|||
/*
|
||||
* emu48.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
|
||||
#define _KB(a) ((a)*2*1024)
|
||||
|
||||
#define HARDWARE "Yorke" // emulator hardware
|
||||
#define MODELS "6AEGSX" // valid calculator models
|
||||
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
// cards status
|
||||
#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)
|
||||
|
||||
#define BINARYHEADER48 "HPHP48-W"
|
||||
#define BINARYHEADER49 "HPHP49-W"
|
||||
|
||||
#define BIN_FILTER "Port Data File (*.BIN)\0*.BIN\0All Files (*.*)\0*.*\0"
|
||||
#define HP_FILTER "HP Binary Object (*.HP;*.LIB)\0*.HP;*.LIB\0All Files (*.*)\0*.*\0"
|
||||
|
||||
#define CF_HPOBJ "CF_HPOBJ" // clipboard format for DDE
|
||||
|
||||
// CPU cycles in 16384 Hz time frame
|
||||
#define T2CYCLES ((cCurrentRomType=='S')?dwSXCycles:dwGXCycles)
|
||||
|
||||
#define SM_RUN 0 // states of cpu emulation thread
|
||||
#define SM_INVALID 1
|
||||
#define SM_RETURN 2
|
||||
#define SM_SLEEP 3
|
||||
|
||||
#define S_ERR_NO 0 // stack errorcodes
|
||||
#define S_ERR_OBJECT 1
|
||||
#define S_ERR_BINARY 2
|
||||
#define S_ERR_ASCII 3
|
||||
|
||||
#define BAD_OB (0xFFFFFFFF) // bad object
|
||||
|
||||
#define NO_SERIAL "disabled" // port not open
|
||||
|
||||
#define HP_MNEMONICS FALSE // disassembler mnenomics mode
|
||||
#define CLASS_MNEMONICS TRUE
|
||||
|
||||
#define MACRO_OFF 0 // macro recorder off
|
||||
#define MACRO_NEW 1
|
||||
#define MACRO_PLAY 2
|
||||
|
||||
#define DISP_POINTER 0x01 // defines for display area
|
||||
#define DISP_MAIN 0x02
|
||||
#define DISP_MENUE 0x04
|
||||
|
||||
#define ROMPAGESIZE (1<<12) // ROM dirty page size in nibbles
|
||||
|
||||
// window styles
|
||||
#define STYLE_TITLE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_OVERLAPPED)
|
||||
#define STYLE_NOTITLE (WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX|WS_CLIPSIBLINGS)
|
||||
|
||||
// WM_COPYDATA identifier
|
||||
#define CDID_FILENAME 1 // send file name
|
||||
|
||||
// macro to check for valid calculator model
|
||||
#define isModelValid(m) (m != 0 && strchr(MODELS,m) != NULL)
|
||||
|
||||
// values for mapping area
|
||||
enum MMUMAP { M_IO, M_ROM, M_RAM, M_P1, M_P2, M_BS };
|
||||
|
||||
// values for disassembler memory mapping modes
|
||||
enum MEM_MAPPING { MEM_MMU, MEM_NCE1, MEM_NCE2, MEM_CE1, MEM_CE2, MEM_NCE3 };
|
||||
|
||||
// Kermit CRC calculation
|
||||
static __inline WORD UpCRC(WORD wCRC, BYTE nib) { return (wCRC >> 4) ^ (((wCRC ^ nib) & 0xf) * 0x1081); }
|
||||
|
||||
// Emu48.c
|
||||
extern HPALETTE hPalette;
|
||||
extern HPALETTE hOldPalette;
|
||||
extern HANDLE hEventShutdn;
|
||||
extern LPTSTR szAppName;
|
||||
extern LPTSTR szTopic;
|
||||
extern LPTSTR szTitle;
|
||||
extern CRITICAL_SECTION csGDILock;
|
||||
extern CRITICAL_SECTION csLcdLock;
|
||||
extern CRITICAL_SECTION csKeyLock;
|
||||
extern CRITICAL_SECTION csIOLock;
|
||||
extern CRITICAL_SECTION csT1Lock;
|
||||
extern CRITICAL_SECTION csT2Lock;
|
||||
extern CRITICAL_SECTION csTxdLock;
|
||||
extern CRITICAL_SECTION csRecvLock;
|
||||
extern CRITICAL_SECTION csSlowLock;
|
||||
extern CRITICAL_SECTION csDbgLock;
|
||||
extern INT nArgc;
|
||||
extern LPCTSTR *ppArgv;
|
||||
extern LARGE_INTEGER lFreq;
|
||||
extern LARGE_INTEGER lAppStart;
|
||||
extern DWORD idDdeInst;
|
||||
extern UINT uCF_HpObj;
|
||||
extern HINSTANCE hApp;
|
||||
extern HWND hWnd;
|
||||
extern HWND hDlgDebug;
|
||||
extern HWND hDlgFind;
|
||||
extern HWND hDlgProfile;
|
||||
extern HWND hDlgRplObjView;
|
||||
extern HDC hWindowDC;
|
||||
extern DWORD dwTColor;
|
||||
extern DWORD dwTColorTol;
|
||||
extern HRGN hRgn;
|
||||
extern HCURSOR hCursorArrow;
|
||||
extern HCURSOR hCursorHand;
|
||||
extern UINT uWaveDevId;
|
||||
extern DWORD dwWakeupDelay;
|
||||
extern BOOL bAutoSave;
|
||||
extern BOOL bAutoSaveOnExit;
|
||||
extern BOOL bSaveDefConfirm;
|
||||
extern BOOL bStartupBackup;
|
||||
extern BOOL bAlwaysDisplayLog;
|
||||
extern BOOL bLoadObjectWarning;
|
||||
extern BOOL bShowTitle;
|
||||
extern BOOL bShowMenu;
|
||||
extern BOOL bAlwaysOnTop;
|
||||
extern BOOL bActFollowsMouse;
|
||||
extern BOOL bClientWinMove;
|
||||
extern BOOL bSingleInstance;
|
||||
extern HANDLE hThread;
|
||||
extern VOID SetWindowTitle(LPCTSTR szString);
|
||||
extern VOID ForceForegroundWindow(HWND hWnd);
|
||||
extern VOID CopyItemsToClipboard(HWND hWnd);
|
||||
|
||||
// mru.c
|
||||
extern BOOL MruInit(UINT nNum);
|
||||
extern VOID MruCleanup(VOID);
|
||||
extern VOID MruAdd(LPCTSTR lpszEntry);
|
||||
extern VOID MruRemove(UINT nIndex);
|
||||
extern VOID MruMoveTop(UINT nIndex);
|
||||
extern UINT MruEntries(VOID);
|
||||
extern UINT MruID(LPCTSTR lpszEntry);
|
||||
extern VOID MruFilename(UINT nIndex, LPTSTR szFilename, UINT nBuffersize);
|
||||
extern VOID MruUpdateMenu(HMENU hMenu);
|
||||
extern VOID MruWriteList(VOID);
|
||||
extern VOID MruReadList(VOID);
|
||||
|
||||
// Settings.c
|
||||
extern VOID ReadSettings(VOID);
|
||||
extern VOID WriteSettings(VOID);
|
||||
extern VOID ReadLastDocument(LPTSTR szFileName, DWORD nSize);
|
||||
extern VOID WriteLastDocument(LPCTSTR szFilename);
|
||||
extern VOID ReadSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize);
|
||||
extern VOID WriteSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPTSTR lpData);
|
||||
extern INT ReadSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault);
|
||||
extern VOID WriteSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nValue);
|
||||
extern VOID DelSettingsKey(LPCTSTR lpszSection, LPCTSTR lpszEntry);
|
||||
|
||||
// Display.c
|
||||
extern BOOL bGrayscale;
|
||||
extern UINT nBackgroundX;
|
||||
extern UINT nBackgroundY;
|
||||
extern UINT nBackgroundW;
|
||||
extern UINT nBackgroundH;
|
||||
extern UINT nLcdX;
|
||||
extern UINT nLcdY;
|
||||
extern UINT nLcdZoom;
|
||||
extern UINT nGdiXZoom;
|
||||
extern UINT nGdiYZoom;
|
||||
extern HDC hLcdDC;
|
||||
extern HDC hMainDC;
|
||||
extern HDC hAnnunDC;
|
||||
extern BYTE (*GetLineCounter)(VOID);
|
||||
extern VOID (*StartDisplay)(BYTE byInitial);
|
||||
extern VOID (*StopDisplay)(VOID);
|
||||
extern VOID UpdateContrast(BYTE byContrast);
|
||||
extern VOID SetLcdColor(UINT nId, UINT nRed, UINT nGreen, UINT nBlue);
|
||||
extern VOID SetLcdMode(BOOL bMode);
|
||||
extern VOID CreateLcdBitmap(VOID);
|
||||
extern VOID DestroyLcdBitmap(VOID);
|
||||
extern BOOL CreateMainBitmap(LPCTSTR szFilename);
|
||||
extern VOID DestroyMainBitmap(VOID);
|
||||
extern BOOL CreateAnnunBitmap(LPCTSTR szFilename);
|
||||
extern VOID DestroyAnnunBitmap(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(DWORD dwUpdateMask);
|
||||
extern VOID ResizeWindow(VOID);
|
||||
|
||||
// Engine.c
|
||||
extern BOOL bInterrupt;
|
||||
extern UINT nState;
|
||||
extern UINT nNextState;
|
||||
extern BOOL bEnableSlow;
|
||||
extern BOOL bRealSpeed;
|
||||
extern BOOL bKeySlow;
|
||||
extern BOOL bSoundSlow;
|
||||
extern UINT nOpcSlow;
|
||||
extern CHIPSET Chipset;
|
||||
extern TCHAR szSerialWire[16];
|
||||
extern TCHAR szSerialIr[16];
|
||||
extern DWORD dwSXCycles;
|
||||
extern DWORD dwGXCycles;
|
||||
extern HANDLE hEventDebug;
|
||||
extern BOOL bDbgAutoStateCtrl;
|
||||
extern INT nDbgState;
|
||||
extern BOOL bDbgNOP3;
|
||||
extern BOOL bDbgCode;
|
||||
extern BOOL bDbgRPL;
|
||||
extern BOOL bDbgSkipInt;
|
||||
extern DWORD dwDbgStopPC;
|
||||
extern DWORD dwDbgRplPC;
|
||||
extern DWORD dwDbgRstkp;
|
||||
extern DWORD dwDbgRstk;
|
||||
extern DWORD *pdwInstrArray;
|
||||
extern WORD wInstrSize;
|
||||
extern WORD wInstrWp;
|
||||
extern WORD wInstrRp;
|
||||
extern VOID (*fnOutTrace)(VOID);
|
||||
extern VOID SuspendDebugger(VOID);
|
||||
extern VOID ResumeDebugger(VOID);
|
||||
extern VOID CheckSerial(VOID);
|
||||
extern VOID InitAdjustSpeed(VOID);
|
||||
extern VOID AdjKeySpeed(VOID);
|
||||
extern VOID SetSpeed(BOOL bAdjust);
|
||||
extern VOID UpdateKdnBit(VOID);
|
||||
extern BOOL WaitForSleepState(VOID);
|
||||
extern UINT SwitchToState(UINT nNewState);
|
||||
extern UINT WorkerThread(LPVOID pParam);
|
||||
|
||||
// Fetch.c
|
||||
extern VOID EvalOpcode(LPBYTE I);
|
||||
|
||||
// Files.c
|
||||
extern TCHAR szEmuDirectory[MAX_PATH];
|
||||
extern TCHAR szCurrentDirectory[MAX_PATH];
|
||||
extern TCHAR szCurrentKml[MAX_PATH];
|
||||
extern TCHAR szBackupKml[MAX_PATH];
|
||||
extern TCHAR szCurrentFilename[MAX_PATH];
|
||||
extern TCHAR szBackupFilename[MAX_PATH];
|
||||
extern TCHAR szBufferFilename[MAX_PATH];
|
||||
extern TCHAR szPort2Filename[MAX_PATH];
|
||||
extern BOOL bDocumentAvail;
|
||||
extern BYTE cCurrentRomType;
|
||||
extern UINT nCurrentClass;
|
||||
extern LPBYTE Port0;
|
||||
extern LPBYTE Port1;
|
||||
extern LPBYTE Port2;
|
||||
extern LPBYTE pbyRom;
|
||||
extern BOOL bRomWriteable;
|
||||
extern DWORD dwRomSize;
|
||||
extern LPBYTE pbyRomDirtyPage;
|
||||
extern DWORD dwRomDirtyPageSize;
|
||||
extern WORD wRomCrc;
|
||||
extern BOOL bRomCrcCorrection;
|
||||
extern LPBYTE pbyPort2;
|
||||
extern BOOL bPort2Writeable;
|
||||
extern BOOL bPort2IsShared;
|
||||
extern DWORD dwPort2Size;
|
||||
extern DWORD dwPort2Mask;
|
||||
extern WORD wPort2Crc;
|
||||
extern BOOL bBackup;
|
||||
extern VOID SetWindowLocation(HWND hWnd,INT nPosX,INT nPosY);
|
||||
extern DWORD GetCutPathName(LPCTSTR szFileName,LPTSTR szBuffer,DWORD dwBufferLength,INT nCutLength);
|
||||
extern VOID SetWindowPathTitle(LPCTSTR szFileName);
|
||||
extern BOOL CheckForBeepPatch(VOID);
|
||||
extern BOOL PatchNibble(DWORD dwAddress, BYTE byPatch);
|
||||
extern VOID UpdatePatches(BOOL bPatch);
|
||||
extern BOOL PatchRom(LPCTSTR szFilename);
|
||||
extern BOOL CrcRom(WORD *pwChk);
|
||||
extern BOOL MapRom(LPCTSTR szFilename);
|
||||
extern VOID UnmapRom(VOID);
|
||||
extern BOOL MapPort2(LPCTSTR szFilename);
|
||||
extern VOID UnmapPort2(VOID);
|
||||
extern VOID ResetDocument(VOID);
|
||||
extern BOOL NewDocument(VOID);
|
||||
extern BOOL OpenDocument(LPCTSTR 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(LPCTSTR lpstrFilter,LPCTSTR lpstrDefExt);
|
||||
extern BOOL GetSaveObjectFilename(LPCTSTR lpstrFilter,LPCTSTR lpstrDefExt);
|
||||
extern WORD WriteStack(UINT nStkLevel,LPBYTE lpBuf,DWORD dwSize);
|
||||
extern BOOL LoadObject(LPCTSTR szFilename);
|
||||
extern BOOL SaveObject(LPCTSTR szFilename);
|
||||
extern BOOL LoadIconFromFile(LPCTSTR szFilename);
|
||||
extern VOID LoadIconDefault(VOID);
|
||||
extern HBITMAP LoadBitmapFile(LPCTSTR szFilename,BOOL bPalette);
|
||||
extern HRGN CreateRgnFromBitmap(HBITMAP hBmp,COLORREF color,DWORD dwTol);
|
||||
|
||||
// Romcrc.c
|
||||
extern VOID RebuildRomCrc(VOID);
|
||||
|
||||
// Timer.c
|
||||
extern VOID SetHP48Time(VOID);
|
||||
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
|
||||
extern BOOL bFlashRomArray;
|
||||
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);
|
||||
extern enum MMUMAP MapData(DWORD d);
|
||||
extern VOID CpuReset(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, BOOL bUpdate);
|
||||
extern VOID WriteIO(BYTE *a, DWORD b, DWORD s);
|
||||
|
||||
// Lowbat.c
|
||||
extern BOOL bLowBatDisable;
|
||||
extern VOID StartBatMeasure(VOID);
|
||||
extern VOID StopBatMeasure(VOID);
|
||||
extern VOID GetBatteryState(BOOL *pbLBI, BOOL *pbVLBI);
|
||||
|
||||
// Keyboard.c
|
||||
extern DWORD dwKeyMinDelay;
|
||||
extern VOID ScanKeyboard(BOOL bActive, BOOL bReset);
|
||||
extern VOID KeyboardEvent(BOOL bPress, UINT out, UINT in);
|
||||
|
||||
// Keymacro.c
|
||||
extern INT nMacroState;
|
||||
extern INT nMacroTimeout;
|
||||
extern BOOL bMacroRealSpeed;
|
||||
extern DWORD dwMacroMinDelay;
|
||||
extern VOID KeyMacroRecord(BOOL bPress, UINT out, UINT in);
|
||||
extern LRESULT OnToolMacroNew(VOID);
|
||||
extern LRESULT OnToolMacroPlay(VOID);
|
||||
extern LRESULT OnToolMacroStop(VOID);
|
||||
extern LRESULT OnToolMacroSettings(VOID);
|
||||
|
||||
// Redeye.c
|
||||
extern VOID IrPrinter(BYTE c);
|
||||
|
||||
// Udp.c
|
||||
extern TCHAR szUdpServer[1024];
|
||||
extern WORD wUdpPort;
|
||||
extern VOID ResetUdp(VOID);
|
||||
extern BOOL SendByteUdp(BYTE byData);
|
||||
|
||||
// Stack.c
|
||||
extern BOOL bDetectClpObject;
|
||||
extern LRESULT OnStackCopy(VOID);
|
||||
extern LRESULT OnStackPaste(VOID);
|
||||
|
||||
// RPL.c
|
||||
extern BOOL RPL_GetSystemFlag(INT nFlag);
|
||||
extern DWORD RPL_SkipOb(DWORD d);
|
||||
extern DWORD RPL_ObjectSize(BYTE *o,DWORD s);
|
||||
extern DWORD RPL_CreateTemp(DWORD l);
|
||||
extern UINT RPL_Depth(VOID);
|
||||
extern DWORD RPL_Pick(UINT l);
|
||||
extern VOID RPL_Replace(DWORD n);
|
||||
extern VOID RPL_Push(UINT l,DWORD n);
|
||||
|
||||
// SndEnum.c
|
||||
extern VOID SetSoundDeviceList(HWND hWnd,UINT uDeviceID);
|
||||
|
||||
// Sound.c
|
||||
extern DWORD dwWaveVol;
|
||||
extern DWORD dwWaveTime;
|
||||
extern BOOL SoundAvailable(UINT uDeviceID);
|
||||
extern BOOL SoundGetDeviceID(UINT *puDeviceID);
|
||||
extern BOOL SoundOpen(UINT uDeviceID);
|
||||
extern VOID SoundClose(VOID);
|
||||
extern VOID SoundOut(CHIPSET* w, WORD wOut);
|
||||
extern VOID SoundBeep(DWORD dwFrequency, DWORD dwDuration);
|
||||
|
||||
// DDEserv.c
|
||||
extern HDDEDATA CALLBACK DdeCallback(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD);
|
||||
|
||||
// Dismem.c
|
||||
extern BOOL SetMemRomType(BYTE cCurrentRomType);
|
||||
extern BOOL SetMemMapType(enum MEM_MAPPING eType);
|
||||
extern enum MEM_MAPPING GetMemMapType(VOID);
|
||||
extern BOOL GetMemAvail(enum MEM_MAPPING eType);
|
||||
extern DWORD GetMemDataSize(VOID);
|
||||
extern DWORD GetMemDataMask(VOID);
|
||||
extern BYTE GetMemNib(DWORD *p);
|
||||
extern VOID GetMemPeek(BYTE *a, DWORD d, UINT s);
|
||||
|
||||
// Disasm.c
|
||||
extern BOOL disassembler_mode;
|
||||
extern BOOL disassembler_symb;
|
||||
extern DWORD disassemble(DWORD addr, LPTSTR out);
|
||||
|
||||
// Symbfile.c
|
||||
extern BOOL RplTableEmpty(VOID);
|
||||
extern BOOL RplLoadTable(LPCTSTR lpszFilename);
|
||||
extern VOID RplDeleteTable(VOID);
|
||||
extern LPCTSTR RplGetName(DWORD dwAddr);
|
||||
extern BOOL RplGetAddr(LPCTSTR lpszName, DWORD *pdwAddr);
|
||||
|
||||
// Serial.c
|
||||
extern BOOL CommIsOpen(VOID);
|
||||
extern BOOL CommOpen(LPTSTR strWirePort,LPTSTR strIrPort);
|
||||
extern VOID CommClose(VOID);
|
||||
extern VOID CommSetBaud(VOID);
|
||||
extern BOOL UpdateUSRQ(VOID);
|
||||
extern VOID CommTxBRK(VOID);
|
||||
extern VOID CommTransmit(VOID);
|
||||
extern VOID CommReceive(VOID);
|
||||
|
||||
// Cursor.c
|
||||
extern HCURSOR CreateHandCursor(VOID);
|
||||
|
||||
#if defined _USRDLL // DLL version
|
||||
// Emu48dll.c
|
||||
extern VOID (CALLBACK *pEmuDocumentNotify)(LPCTSTR lpszFilename);
|
||||
extern BOOL DLLCreateWnd(LPCTSTR lpszFilename, LPCTSTR lpszPort2Name);
|
||||
extern BOOL DLLDestroyWnd(VOID);
|
||||
|
||||
// Symbfile.c
|
||||
#define RplGetName(a) NULL // for linking
|
||||
#endif
|
||||
|
||||
// Message Boxes
|
||||
static __inline int InfoMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND);}
|
||||
static __inline int AbortMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);}
|
||||
static __inline int YesNoMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND);}
|
||||
static __inline int YesNoCancelMessage(LPCTSTR szMessage,UINT uStyle) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|uStyle);}
|
||||
|
||||
// Missing Win32 API calls
|
||||
static __inline LPTSTR DuplicateString(LPCTSTR szString)
|
||||
{
|
||||
UINT uLength = lstrlen(szString) + 1;
|
||||
LPTSTR szDup = (LPTSTR) malloc(uLength*sizeof(szDup[0]));
|
||||
lstrcpy(szDup,szString);
|
||||
return szDup;
|
||||
}
|
||||
/*
|
||||
* Emu48.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "types.h"
|
||||
|
||||
#define _KB(a) ((a)*2*1024)
|
||||
|
||||
#define HARDWARE "Yorke" // emulator hardware
|
||||
#define MODELS "6AEGSX" // valid calculator models
|
||||
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
// cards status
|
||||
#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)
|
||||
|
||||
#define BINARYHEADER48 "HPHP48-W"
|
||||
#define BINARYHEADER49 "HPHP49-W"
|
||||
|
||||
#define BIN_FILTER "Port Data File (*.BIN)\0*.BIN\0All Files (*.*)\0*.*\0"
|
||||
#define HP_FILTER "HP Binary Object (*.HP;*.LIB)\0*.HP;*.LIB\0All Files (*.*)\0*.*\0"
|
||||
|
||||
#define CF_HPOBJ "CF_HPOBJ" // clipboard format for DDE
|
||||
|
||||
// CPU cycles in 16384 Hz time frame
|
||||
#define T2CYCLES ((cCurrentRomType=='S')?dwSXCycles:dwGXCycles)
|
||||
|
||||
#define SM_RUN 0 // states of cpu emulation thread
|
||||
#define SM_INVALID 1
|
||||
#define SM_RETURN 2
|
||||
#define SM_SLEEP 3
|
||||
|
||||
#define S_ERR_NO 0 // stack errorcodes
|
||||
#define S_ERR_OBJECT 1
|
||||
#define S_ERR_BINARY 2
|
||||
#define S_ERR_ASCII 3
|
||||
|
||||
#define BAD_OB (0xFFFFFFFF) // bad object
|
||||
|
||||
#define NO_SERIAL "disabled" // port not open
|
||||
|
||||
#define HP_MNEMONICS FALSE // disassembler mnenomics mode
|
||||
#define CLASS_MNEMONICS TRUE
|
||||
|
||||
#define MACRO_OFF 0 // macro recorder off
|
||||
#define MACRO_NEW 1
|
||||
#define MACRO_PLAY 2
|
||||
|
||||
#define DISP_POINTER 0x01 // defines for display area
|
||||
#define DISP_MAIN 0x02
|
||||
#define DISP_MENUE 0x04
|
||||
|
||||
#define ROMPAGESIZE (1<<12) // ROM dirty page size in nibbles
|
||||
|
||||
// window styles
|
||||
#define STYLE_TITLE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_OVERLAPPED)
|
||||
#define STYLE_NOTITLE (WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX|WS_CLIPSIBLINGS)
|
||||
|
||||
// WM_COPYDATA identifier
|
||||
#define CDID_FILENAME 1 // send file name
|
||||
|
||||
// macro to check for valid calculator model
|
||||
#define isModelValid(m) (m != 0 && strchr(MODELS,m) != NULL)
|
||||
|
||||
// values for mapping area
|
||||
enum MMUMAP { M_IO, M_ROM, M_RAM, M_P1, M_P2, M_BS };
|
||||
|
||||
// values for disassembler memory mapping modes
|
||||
enum MEM_MAPPING { MEM_MMU, MEM_NCE1, MEM_NCE2, MEM_CE1, MEM_CE2, MEM_NCE3 };
|
||||
|
||||
// Kermit CRC calculation
|
||||
static __inline WORD UpCRC(WORD wCRC, BYTE nib) { return (wCRC >> 4) ^ (((wCRC ^ nib) & 0xf) * 0x1081); }
|
||||
|
||||
// Emu48.c
|
||||
extern HPALETTE hPalette;
|
||||
extern HPALETTE hOldPalette;
|
||||
extern HANDLE hEventShutdn;
|
||||
extern LPTSTR szAppName;
|
||||
extern LPTSTR szTopic;
|
||||
extern LPTSTR szTitle;
|
||||
extern CRITICAL_SECTION csGDILock;
|
||||
extern CRITICAL_SECTION csLcdLock;
|
||||
extern CRITICAL_SECTION csKeyLock;
|
||||
extern CRITICAL_SECTION csIOLock;
|
||||
extern CRITICAL_SECTION csT1Lock;
|
||||
extern CRITICAL_SECTION csT2Lock;
|
||||
extern CRITICAL_SECTION csTxdLock;
|
||||
extern CRITICAL_SECTION csRecvLock;
|
||||
extern CRITICAL_SECTION csSlowLock;
|
||||
extern CRITICAL_SECTION csDbgLock;
|
||||
extern INT nArgc;
|
||||
extern LPCTSTR *ppArgv;
|
||||
extern LARGE_INTEGER lFreq;
|
||||
extern LARGE_INTEGER lAppStart;
|
||||
extern DWORD idDdeInst;
|
||||
extern UINT uCF_HpObj;
|
||||
extern HINSTANCE hApp;
|
||||
extern HWND hWnd;
|
||||
extern HWND hDlgDebug;
|
||||
extern HWND hDlgFind;
|
||||
extern HWND hDlgProfile;
|
||||
extern HWND hDlgRplObjView;
|
||||
extern HDC hWindowDC;
|
||||
extern DWORD dwTColor;
|
||||
extern DWORD dwTColorTol;
|
||||
extern HRGN hRgn;
|
||||
extern HCURSOR hCursorArrow;
|
||||
extern HCURSOR hCursorHand;
|
||||
extern UINT uWaveDevId;
|
||||
extern DWORD dwWakeupDelay;
|
||||
extern BOOL bAutoSave;
|
||||
extern BOOL bAutoSaveOnExit;
|
||||
extern BOOL bSaveDefConfirm;
|
||||
extern BOOL bStartupBackup;
|
||||
extern BOOL bAlwaysDisplayLog;
|
||||
extern BOOL bLoadObjectWarning;
|
||||
extern BOOL bShowTitle;
|
||||
extern BOOL bShowMenu;
|
||||
extern BOOL bAlwaysOnTop;
|
||||
extern BOOL bActFollowsMouse;
|
||||
extern BOOL bClientWinMove;
|
||||
extern BOOL bSingleInstance;
|
||||
extern HANDLE hThread;
|
||||
extern VOID SetWindowTitle(LPCTSTR szString);
|
||||
extern VOID ForceForegroundWindow(HWND hWnd);
|
||||
extern VOID CopyItemsToClipboard(HWND hWnd);
|
||||
|
||||
// mru.c
|
||||
extern BOOL MruInit(UINT nNum);
|
||||
extern VOID MruCleanup(VOID);
|
||||
extern VOID MruAdd(LPCTSTR lpszEntry);
|
||||
extern VOID MruRemove(UINT nIndex);
|
||||
extern VOID MruMoveTop(UINT nIndex);
|
||||
extern UINT MruEntries(VOID);
|
||||
extern UINT MruID(LPCTSTR lpszEntry);
|
||||
extern VOID MruFilename(UINT nIndex, LPTSTR szFilename, UINT nBuffersize);
|
||||
extern VOID MruUpdateMenu(HMENU hMenu);
|
||||
extern VOID MruWriteList(VOID);
|
||||
extern VOID MruReadList(VOID);
|
||||
|
||||
// Settings.c
|
||||
extern VOID ReadSettings(VOID);
|
||||
extern VOID WriteSettings(VOID);
|
||||
extern VOID ReadLastDocument(LPTSTR szFileName, DWORD nSize);
|
||||
extern VOID WriteLastDocument(LPCTSTR szFilename);
|
||||
extern VOID ReadSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize);
|
||||
extern VOID WriteSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPTSTR lpData);
|
||||
extern INT ReadSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault);
|
||||
extern VOID WriteSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nValue);
|
||||
extern VOID DelSettingsKey(LPCTSTR lpszSection, LPCTSTR lpszEntry);
|
||||
|
||||
// Display.c
|
||||
extern BOOL bGrayscale;
|
||||
extern UINT nBackgroundX;
|
||||
extern UINT nBackgroundY;
|
||||
extern UINT nBackgroundW;
|
||||
extern UINT nBackgroundH;
|
||||
extern UINT nLcdX;
|
||||
extern UINT nLcdY;
|
||||
extern UINT nLcdZoom;
|
||||
extern UINT nGdiXZoom;
|
||||
extern UINT nGdiYZoom;
|
||||
extern HDC hLcdDC;
|
||||
extern HDC hMainDC;
|
||||
extern HDC hAnnunDC;
|
||||
extern BYTE (*GetLineCounter)(VOID);
|
||||
extern VOID (*StartDisplay)(BYTE byInitial);
|
||||
extern VOID (*StopDisplay)(VOID);
|
||||
extern VOID UpdateContrast(BYTE byContrast);
|
||||
extern VOID SetLcdColor(UINT nId, UINT nRed, UINT nGreen, UINT nBlue);
|
||||
extern VOID SetLcdMode(BOOL bMode);
|
||||
extern VOID CreateLcdBitmap(VOID);
|
||||
extern VOID DestroyLcdBitmap(VOID);
|
||||
extern BOOL CreateMainBitmap(LPCTSTR szFilename);
|
||||
extern VOID DestroyMainBitmap(VOID);
|
||||
extern BOOL CreateAnnunBitmap(LPCTSTR szFilename);
|
||||
extern VOID DestroyAnnunBitmap(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(DWORD dwUpdateMask);
|
||||
extern VOID ResizeWindow(VOID);
|
||||
|
||||
// Engine.c
|
||||
extern BOOL bInterrupt;
|
||||
extern UINT nState;
|
||||
extern UINT nNextState;
|
||||
extern BOOL bEnableSlow;
|
||||
extern BOOL bRealSpeed;
|
||||
extern BOOL bKeySlow;
|
||||
extern BOOL bSoundSlow;
|
||||
extern UINT nOpcSlow;
|
||||
extern CHIPSET Chipset;
|
||||
extern TCHAR szSerialWire[16];
|
||||
extern TCHAR szSerialIr[16];
|
||||
extern DWORD dwSXCycles;
|
||||
extern DWORD dwGXCycles;
|
||||
extern HANDLE hEventDebug;
|
||||
extern BOOL bDbgAutoStateCtrl;
|
||||
extern INT nDbgState;
|
||||
extern BOOL bDbgNOP3;
|
||||
extern BOOL bDbgCode;
|
||||
extern BOOL bDbgRPL;
|
||||
extern BOOL bDbgSkipInt;
|
||||
extern DWORD dwDbgStopPC;
|
||||
extern DWORD dwDbgRplPC;
|
||||
extern DWORD dwDbgRstkp;
|
||||
extern DWORD dwDbgRstk;
|
||||
extern DWORD *pdwInstrArray;
|
||||
extern WORD wInstrSize;
|
||||
extern WORD wInstrWp;
|
||||
extern WORD wInstrRp;
|
||||
extern VOID (*fnOutTrace)(VOID);
|
||||
extern VOID SuspendDebugger(VOID);
|
||||
extern VOID ResumeDebugger(VOID);
|
||||
extern VOID CheckSerial(VOID);
|
||||
extern VOID InitAdjustSpeed(VOID);
|
||||
extern VOID AdjKeySpeed(VOID);
|
||||
extern VOID SetSpeed(BOOL bAdjust);
|
||||
extern VOID UpdateKdnBit(VOID);
|
||||
extern BOOL WaitForSleepState(VOID);
|
||||
extern UINT SwitchToState(UINT nNewState);
|
||||
extern UINT WorkerThread(LPVOID pParam);
|
||||
|
||||
// Fetch.c
|
||||
extern VOID EvalOpcode(LPBYTE I);
|
||||
|
||||
// Files.c
|
||||
extern TCHAR szEmuDirectory[MAX_PATH];
|
||||
extern TCHAR szCurrentDirectory[MAX_PATH];
|
||||
extern TCHAR szCurrentKml[MAX_PATH];
|
||||
extern TCHAR szBackupKml[MAX_PATH];
|
||||
extern TCHAR szCurrentFilename[MAX_PATH];
|
||||
extern TCHAR szBackupFilename[MAX_PATH];
|
||||
extern TCHAR szBufferFilename[MAX_PATH];
|
||||
extern TCHAR szPort2Filename[MAX_PATH];
|
||||
extern BOOL bDocumentAvail;
|
||||
extern BYTE cCurrentRomType;
|
||||
extern UINT nCurrentClass;
|
||||
extern LPBYTE Port0;
|
||||
extern LPBYTE Port1;
|
||||
extern LPBYTE Port2;
|
||||
extern LPBYTE pbyRom;
|
||||
extern BOOL bRomWriteable;
|
||||
extern DWORD dwRomSize;
|
||||
extern LPBYTE pbyRomDirtyPage;
|
||||
extern DWORD dwRomDirtyPageSize;
|
||||
extern WORD wRomCrc;
|
||||
extern BOOL bRomCrcCorrection;
|
||||
extern LPBYTE pbyPort2;
|
||||
extern BOOL bPort2Writeable;
|
||||
extern BOOL bPort2IsShared;
|
||||
extern DWORD dwPort2Size;
|
||||
extern DWORD dwPort2Mask;
|
||||
extern WORD wPort2Crc;
|
||||
extern BOOL bBackup;
|
||||
extern VOID SetWindowLocation(HWND hWnd,INT nPosX,INT nPosY);
|
||||
extern DWORD GetCutPathName(LPCTSTR szFileName,LPTSTR szBuffer,DWORD dwBufferLength,INT nCutLength);
|
||||
extern VOID SetWindowPathTitle(LPCTSTR szFileName);
|
||||
extern BOOL CheckForBeepPatch(VOID);
|
||||
extern BOOL PatchNibble(DWORD dwAddress, BYTE byPatch);
|
||||
extern VOID UpdatePatches(BOOL bPatch);
|
||||
extern BOOL PatchRom(LPCTSTR szFilename);
|
||||
extern BOOL CrcRom(WORD *pwChk);
|
||||
extern BOOL MapRom(LPCTSTR szFilename);
|
||||
extern VOID UnmapRom(VOID);
|
||||
extern BOOL MapPort2(LPCTSTR szFilename);
|
||||
extern VOID UnmapPort2(VOID);
|
||||
extern VOID ResetDocument(VOID);
|
||||
extern BOOL NewDocument(VOID);
|
||||
extern BOOL OpenDocument(LPCTSTR 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(LPCTSTR lpstrFilter,LPCTSTR lpstrDefExt);
|
||||
extern BOOL GetSaveObjectFilename(LPCTSTR lpstrFilter,LPCTSTR lpstrDefExt);
|
||||
extern WORD WriteStack(UINT nStkLevel,LPBYTE lpBuf,DWORD dwSize);
|
||||
extern BOOL LoadObject(LPCTSTR szFilename);
|
||||
extern BOOL SaveObject(LPCTSTR szFilename);
|
||||
extern BOOL LoadIconFromFile(LPCTSTR szFilename);
|
||||
extern VOID LoadIconDefault(VOID);
|
||||
extern HBITMAP LoadBitmapFile(LPCTSTR szFilename,BOOL bPalette);
|
||||
extern HRGN CreateRgnFromBitmap(HBITMAP hBmp,COLORREF color,DWORD dwTol);
|
||||
|
||||
// Romcrc.c
|
||||
extern VOID RebuildRomCrc(VOID);
|
||||
|
||||
// Timer.c
|
||||
extern VOID SetHP48Time(VOID);
|
||||
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
|
||||
extern BOOL bFlashRomArray;
|
||||
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);
|
||||
extern enum MMUMAP MapData(DWORD d);
|
||||
extern VOID CpuReset(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, BOOL bUpdate);
|
||||
extern VOID WriteIO(BYTE *a, DWORD b, DWORD s);
|
||||
|
||||
// Lowbat.c
|
||||
extern BOOL bLowBatDisable;
|
||||
extern VOID StartBatMeasure(VOID);
|
||||
extern VOID StopBatMeasure(VOID);
|
||||
extern VOID GetBatteryState(BOOL *pbLBI, BOOL *pbVLBI);
|
||||
|
||||
// Keyboard.c
|
||||
extern DWORD dwKeyMinDelay;
|
||||
extern VOID ScanKeyboard(BOOL bActive, BOOL bReset);
|
||||
extern VOID KeyboardEvent(BOOL bPress, UINT out, UINT in);
|
||||
|
||||
// Keymacro.c
|
||||
extern INT nMacroState;
|
||||
extern INT nMacroTimeout;
|
||||
extern BOOL bMacroRealSpeed;
|
||||
extern DWORD dwMacroMinDelay;
|
||||
extern VOID KeyMacroRecord(BOOL bPress, UINT out, UINT in);
|
||||
extern LRESULT OnToolMacroNew(VOID);
|
||||
extern LRESULT OnToolMacroPlay(VOID);
|
||||
extern LRESULT OnToolMacroStop(VOID);
|
||||
extern LRESULT OnToolMacroSettings(VOID);
|
||||
|
||||
// Redeye.c
|
||||
extern VOID IrPrinter(BYTE c);
|
||||
|
||||
// Udp.c
|
||||
extern TCHAR szUdpServer[1024];
|
||||
extern WORD wUdpPort;
|
||||
extern VOID ResetUdp(VOID);
|
||||
extern BOOL SendByteUdp(BYTE byData);
|
||||
|
||||
// Stack.c
|
||||
extern BOOL bDetectClpObject;
|
||||
extern BOOL bLocaleDecimalPoint;
|
||||
extern LRESULT OnStackCopy(VOID);
|
||||
extern LRESULT OnStackPaste(VOID);
|
||||
|
||||
// RPL.c
|
||||
extern BOOL RPL_GetSystemFlag(INT nFlag);
|
||||
extern DWORD RPL_SkipOb(DWORD d);
|
||||
extern DWORD RPL_ObjectSize(BYTE *o,DWORD s);
|
||||
extern DWORD RPL_CreateTemp(DWORD l);
|
||||
extern UINT RPL_Depth(VOID);
|
||||
extern DWORD RPL_Pick(UINT l);
|
||||
extern VOID RPL_Replace(DWORD n);
|
||||
extern VOID RPL_Push(UINT l,DWORD n);
|
||||
|
||||
// SndEnum.c
|
||||
extern VOID SetSoundDeviceList(HWND hWnd,UINT uDeviceID);
|
||||
|
||||
// Sound.c
|
||||
extern DWORD dwWaveVol;
|
||||
extern DWORD dwWaveTime;
|
||||
extern BOOL SoundAvailable(UINT uDeviceID);
|
||||
extern BOOL SoundGetDeviceID(UINT *puDeviceID);
|
||||
extern BOOL SoundOpen(UINT uDeviceID);
|
||||
extern VOID SoundClose(VOID);
|
||||
extern VOID SoundOut(CHIPSET* w, WORD wOut);
|
||||
extern VOID SoundBeep(DWORD dwFrequency, DWORD dwDuration);
|
||||
|
||||
// DDEserv.c
|
||||
extern HDDEDATA CALLBACK DdeCallback(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD, DWORD);
|
||||
|
||||
// Dismem.c
|
||||
extern BOOL SetMemRomType(BYTE cCurrentRomType);
|
||||
extern BOOL SetMemMapType(enum MEM_MAPPING eType);
|
||||
extern enum MEM_MAPPING GetMemMapType(VOID);
|
||||
extern BOOL GetMemAvail(enum MEM_MAPPING eType);
|
||||
extern DWORD GetMemDataSize(VOID);
|
||||
extern DWORD GetMemDataMask(VOID);
|
||||
extern BYTE GetMemNib(DWORD *p);
|
||||
extern VOID GetMemPeek(BYTE *a, DWORD d, UINT s);
|
||||
|
||||
// Disasm.c
|
||||
extern BOOL disassembler_mode;
|
||||
extern BOOL disassembler_symb;
|
||||
extern DWORD disassemble(DWORD addr, LPTSTR out);
|
||||
|
||||
// Symbfile.c
|
||||
extern BOOL RplTableEmpty(VOID);
|
||||
extern BOOL RplLoadTable(LPCTSTR lpszFilename);
|
||||
extern VOID RplDeleteTable(VOID);
|
||||
extern LPCTSTR RplGetName(DWORD dwAddr);
|
||||
extern BOOL RplGetAddr(LPCTSTR lpszName, DWORD *pdwAddr);
|
||||
|
||||
// Serial.c
|
||||
extern BOOL CommIsOpen(VOID);
|
||||
extern BOOL CommOpen(LPTSTR strWirePort,LPTSTR strIrPort);
|
||||
extern VOID CommClose(VOID);
|
||||
extern VOID CommSetBaud(VOID);
|
||||
extern BOOL UpdateUSRQ(VOID);
|
||||
extern VOID CommTxBRK(VOID);
|
||||
extern VOID CommTransmit(VOID);
|
||||
extern VOID CommReceive(VOID);
|
||||
|
||||
// Cursor.c
|
||||
extern HCURSOR CreateHandCursor(VOID);
|
||||
|
||||
#if defined _USRDLL // DLL version
|
||||
// Emu48dll.c
|
||||
extern VOID (CALLBACK *pEmuDocumentNotify)(LPCTSTR lpszFilename);
|
||||
extern BOOL DLLCreateWnd(LPCTSTR lpszFilename, LPCTSTR lpszPort2Name);
|
||||
extern BOOL DLLDestroyWnd(VOID);
|
||||
|
||||
// Symbfile.c
|
||||
#define RplGetName(a) NULL // for linking
|
||||
#endif
|
||||
|
||||
// Message Boxes
|
||||
static __inline int InfoMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONINFORMATION|MB_SETFOREGROUND);}
|
||||
static __inline int AbortMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);}
|
||||
static __inline int YesNoMessage(LPCTSTR szMessage) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND);}
|
||||
static __inline int YesNoCancelMessage(LPCTSTR szMessage,UINT uStyle) {return MessageBox(hWnd, szMessage, szTitle, MB_APPLMODAL|MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|uStyle);}
|
||||
|
||||
// Missing Win32 API calls
|
||||
static __inline LPTSTR DuplicateString(LPCTSTR szString)
|
||||
{
|
||||
UINT uLength = lstrlen(szString) + 1;
|
||||
LPTSTR szDup = (LPTSTR) malloc(uLength*sizeof(szDup[0]));
|
||||
lstrcpy(szDup,szString);
|
||||
return szDup;
|
||||
}
|
|
@ -303,7 +303,7 @@ FONT 8, "MS Sans Serif"
|
|||
BEGIN
|
||||
ICON IDI_EMU48,IDC_STATIC,7,6,20,20,SS_REALSIZEIMAGE
|
||||
LTEXT "",IDC_VERSION,29,6,151,8,NOT WS_GROUP
|
||||
LTEXT "Copyright © 2023 Christoph Gießelink && Sébastien Carlier",
|
||||
LTEXT "Copyright © 2024 Christoph Gießelink && Sébastien Carlier",
|
||||
IDC_STATIC,29,18,181,8
|
||||
DEFPUSHBUTTON "OK",IDOK,215,12,39,14
|
||||
EDITTEXT IDC_LICENSE,7,33,247,112,ES_MULTILINE | ES_AUTOHSCROLL |
|
||||
|
@ -622,7 +622,11 @@ BEGIN
|
|||
EDITTEXT IDC_DEBUG_DATA_STARTADDR,101,27,37,14
|
||||
LTEXT "End Address (hexadecimal):",IDC_STATIC,7,46,88,8
|
||||
EDITTEXT IDC_DEBUG_DATA_ENDADDR,101,44,37,14
|
||||
PUSHBUTTON "OK",IDOK,207,27,50,14
|
||||
CONTROL "8-bit",IDC_DEBUG_DATA_SAVE_8BIT,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,158,30,29,10
|
||||
CONTROL "4-bit",IDC_DEBUG_DATA_SAVE_4BIT,"Button",
|
||||
BS_AUTORADIOBUTTON,214,30,29,10
|
||||
PUSHBUTTON "OK",IDOK,151,44,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,207,44,50,14
|
||||
END
|
||||
|
||||
|
@ -636,7 +640,13 @@ BEGIN
|
|||
PUSHBUTTON "Browse",IDC_DEBUG_DATA_BUT,207,7,50,14
|
||||
LTEXT "Start Address (hexadecimal):",IDC_STATIC,7,30,90,8
|
||||
EDITTEXT IDC_DEBUG_DATA_STARTADDR,101,27,37,14
|
||||
PUSHBUTTON "OK",IDOK,207,27,50,14
|
||||
CONTROL "Auto",IDC_DEBUG_DATA_LOAD_ABIT,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,155,29,29,10
|
||||
CONTROL "8-bit",IDC_DEBUG_DATA_LOAD_8BIT,"Button",
|
||||
BS_AUTORADIOBUTTON,189,29,29,10
|
||||
CONTROL "4-bit",IDC_DEBUG_DATA_LOAD_4BIT,"Button",
|
||||
BS_AUTORADIOBUTTON,223,29,29,10
|
||||
PUSHBUTTON "OK",IDOK,151,44,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,207,44,50,14
|
||||
END
|
||||
|
||||
|
@ -723,8 +733,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,6,6,0
|
||||
PRODUCTVERSION 1,6,6,0
|
||||
FILEVERSION 1,6,7,0
|
||||
PRODUCTVERSION 1,6,7,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -741,12 +751,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Christoph Gießelink & Sebastien Carlier\0"
|
||||
VALUE "FileDescription", "HP38/39/40/48/49 Emulator\0"
|
||||
VALUE "FileVersion", "1, 6, 6, 0\0"
|
||||
VALUE "FileVersion", "1, 6, 7, 0\0"
|
||||
VALUE "InternalName", "Emu48\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2023\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2024\0"
|
||||
VALUE "OriginalFilename", "Emu48.exe\0"
|
||||
VALUE "ProductName", "Emu48\0"
|
||||
VALUE "ProductVersion", "1, 6, 6, 0\0"
|
||||
VALUE "ProductVersion", "1, 6, 7, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32510.428
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32505.173
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Emu48", "Emu48.vcxproj", "{D259D821-B668-408E-B5DF-F0C7B42E6726}"
|
||||
EndProject
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -27,24 +27,24 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Unicode|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
|
|
778
Sources/Emu48/FETCH.C
Normal file
778
Sources/Emu48/FETCH.C
Normal file
|
@ -0,0 +1,778 @@
|
|||
/*
|
||||
* fetch.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
#define F 0xFF // F = function
|
||||
|
||||
typedef const struct
|
||||
{
|
||||
LPCVOID pLnk;
|
||||
const DWORD dwTyp;
|
||||
} JMPTAB, *PJMPTAB;
|
||||
|
||||
// jump tables
|
||||
static JMPTAB oF_[] =
|
||||
{
|
||||
{ (LPCVOID) oF0, F },
|
||||
{ (LPCVOID) oF1, F },
|
||||
{ (LPCVOID) oF2, F },
|
||||
{ (LPCVOID) oF3, F },
|
||||
{ (LPCVOID) oF4, F },
|
||||
{ (LPCVOID) oF5, F },
|
||||
{ (LPCVOID) oF6, F },
|
||||
{ (LPCVOID) oF7, F },
|
||||
{ (LPCVOID) oF8, F },
|
||||
{ (LPCVOID) oF9, F },
|
||||
{ (LPCVOID) oFA, F },
|
||||
{ (LPCVOID) oFB, F },
|
||||
{ (LPCVOID) oFC, F },
|
||||
{ (LPCVOID) oFD, F },
|
||||
{ (LPCVOID) oFE, F },
|
||||
{ (LPCVOID) oFF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oE_[] =
|
||||
{
|
||||
{ (LPCVOID) oE0, F },
|
||||
{ (LPCVOID) oE1, F },
|
||||
{ (LPCVOID) oE2, F },
|
||||
{ (LPCVOID) oE3, F },
|
||||
{ (LPCVOID) oE4, F },
|
||||
{ (LPCVOID) oE5, F },
|
||||
{ (LPCVOID) oE6, F },
|
||||
{ (LPCVOID) oE7, F },
|
||||
{ (LPCVOID) oE8, F },
|
||||
{ (LPCVOID) oE9, F },
|
||||
{ (LPCVOID) oEA, F },
|
||||
{ (LPCVOID) oEB, F },
|
||||
{ (LPCVOID) oEC, F },
|
||||
{ (LPCVOID) oED, F },
|
||||
{ (LPCVOID) oEE, F },
|
||||
{ (LPCVOID) oEF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oD_[] =
|
||||
{
|
||||
{ (LPCVOID) oD0, F },
|
||||
{ (LPCVOID) oD1, F },
|
||||
{ (LPCVOID) oD2, F },
|
||||
{ (LPCVOID) oD3, F },
|
||||
{ (LPCVOID) oD4, F },
|
||||
{ (LPCVOID) oD5, F },
|
||||
{ (LPCVOID) oD6, F },
|
||||
{ (LPCVOID) oD7, F },
|
||||
{ (LPCVOID) oD8, F },
|
||||
{ (LPCVOID) oD9, F },
|
||||
{ (LPCVOID) oDA, F },
|
||||
{ (LPCVOID) oDB, F },
|
||||
{ (LPCVOID) oDC, F },
|
||||
{ (LPCVOID) oDD, F },
|
||||
{ (LPCVOID) oDE, F },
|
||||
{ (LPCVOID) oDF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oC_[] =
|
||||
{
|
||||
{ (LPCVOID) oC0, F },
|
||||
{ (LPCVOID) oC1, F },
|
||||
{ (LPCVOID) oC2, F },
|
||||
{ (LPCVOID) oC3, F },
|
||||
{ (LPCVOID) oC4, F },
|
||||
{ (LPCVOID) oC5, F },
|
||||
{ (LPCVOID) oC6, F },
|
||||
{ (LPCVOID) oC7, F },
|
||||
{ (LPCVOID) oC8, F },
|
||||
{ (LPCVOID) oC9, F },
|
||||
{ (LPCVOID) oCA, F },
|
||||
{ (LPCVOID) oCB, F },
|
||||
{ (LPCVOID) oCC, F },
|
||||
{ (LPCVOID) oCD, F },
|
||||
{ (LPCVOID) oCE, F },
|
||||
{ (LPCVOID) oCF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oBb_[] =
|
||||
{
|
||||
{ (LPCVOID) oBb0, F },
|
||||
{ (LPCVOID) oBb1, F },
|
||||
{ (LPCVOID) oBb2, F },
|
||||
{ (LPCVOID) oBb3, F },
|
||||
{ (LPCVOID) oBb4, F },
|
||||
{ (LPCVOID) oBb5, F },
|
||||
{ (LPCVOID) oBb6, F },
|
||||
{ (LPCVOID) oBb7, F },
|
||||
{ (LPCVOID) oBb8, F },
|
||||
{ (LPCVOID) oBb9, F },
|
||||
{ (LPCVOID) oBbA, F },
|
||||
{ (LPCVOID) oBbB, F },
|
||||
{ (LPCVOID) oBbC, F },
|
||||
{ (LPCVOID) oBbD, F },
|
||||
{ (LPCVOID) oBbE, F },
|
||||
{ (LPCVOID) oBbF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oBa_[] =
|
||||
{
|
||||
{ (LPCVOID) oBa0, F },
|
||||
{ (LPCVOID) oBa1, F },
|
||||
{ (LPCVOID) oBa2, F },
|
||||
{ (LPCVOID) oBa3, F },
|
||||
{ (LPCVOID) oBa4, F },
|
||||
{ (LPCVOID) oBa5, F },
|
||||
{ (LPCVOID) oBa6, F },
|
||||
{ (LPCVOID) oBa7, F },
|
||||
{ (LPCVOID) oBa8, F },
|
||||
{ (LPCVOID) oBa9, F },
|
||||
{ (LPCVOID) oBaA, F },
|
||||
{ (LPCVOID) oBaB, F },
|
||||
{ (LPCVOID) oBaC, F },
|
||||
{ (LPCVOID) oBaD, F },
|
||||
{ (LPCVOID) oBaE, F },
|
||||
{ (LPCVOID) oBaF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oB_[] =
|
||||
{
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBa_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 },
|
||||
{ (LPCVOID) oBb_, 2 }
|
||||
};
|
||||
|
||||
static JMPTAB oAb_[] =
|
||||
{
|
||||
{ (LPCVOID) oAb0, F },
|
||||
{ (LPCVOID) oAb1, F },
|
||||
{ (LPCVOID) oAb2, F },
|
||||
{ (LPCVOID) oAb3, F },
|
||||
{ (LPCVOID) oAb4, F },
|
||||
{ (LPCVOID) oAb5, F },
|
||||
{ (LPCVOID) oAb6, F },
|
||||
{ (LPCVOID) oAb7, F },
|
||||
{ (LPCVOID) oAb8, F },
|
||||
{ (LPCVOID) oAb9, F },
|
||||
{ (LPCVOID) oAbA, F },
|
||||
{ (LPCVOID) oAbB, F },
|
||||
{ (LPCVOID) oAbC, F },
|
||||
{ (LPCVOID) oAbD, F },
|
||||
{ (LPCVOID) oAbE, F },
|
||||
{ (LPCVOID) oAbF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oAa_[] =
|
||||
{
|
||||
{ (LPCVOID) oAa0, F },
|
||||
{ (LPCVOID) oAa1, F },
|
||||
{ (LPCVOID) oAa2, F },
|
||||
{ (LPCVOID) oAa3, F },
|
||||
{ (LPCVOID) oAa4, F },
|
||||
{ (LPCVOID) oAa5, F },
|
||||
{ (LPCVOID) oAa6, F },
|
||||
{ (LPCVOID) oAa7, F },
|
||||
{ (LPCVOID) oAa8, F },
|
||||
{ (LPCVOID) oAa9, F },
|
||||
{ (LPCVOID) oAaA, F },
|
||||
{ (LPCVOID) oAaB, F },
|
||||
{ (LPCVOID) oAaC, F },
|
||||
{ (LPCVOID) oAaD, F },
|
||||
{ (LPCVOID) oAaE, F },
|
||||
{ (LPCVOID) oAaF, F }
|
||||
};
|
||||
|
||||
static JMPTAB oA_[] =
|
||||
{
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAa_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 },
|
||||
{ (LPCVOID) oAb_, 2 }
|
||||
};
|
||||
|
||||
static JMPTAB o9b_[] =
|
||||
{
|
||||
{ (LPCVOID) o9b0, F },
|
||||
{ (LPCVOID) o9b1, F },
|
||||
{ (LPCVOID) o9b2, F },
|
||||
{ (LPCVOID) o9b3, F },
|
||||
{ (LPCVOID) o9b4, F },
|
||||
{ (LPCVOID) o9b5, F },
|
||||
{ (LPCVOID) o9b6, F },
|
||||
{ (LPCVOID) o9b7, F },
|
||||
{ (LPCVOID) o9b8, F },
|
||||
{ (LPCVOID) o9b9, F },
|
||||
{ (LPCVOID) o9bA, F },
|
||||
{ (LPCVOID) o9bB, F },
|
||||
{ (LPCVOID) o9bC, F },
|
||||
{ (LPCVOID) o9bD, F },
|
||||
{ (LPCVOID) o9bE, F },
|
||||
{ (LPCVOID) o9bF, F }
|
||||
};
|
||||
|
||||
static JMPTAB o9a_[] =
|
||||
{
|
||||
{ (LPCVOID) o9a0, F },
|
||||
{ (LPCVOID) o9a1, F },
|
||||
{ (LPCVOID) o9a2, F },
|
||||
{ (LPCVOID) o9a3, F },
|
||||
{ (LPCVOID) o9a4, F },
|
||||
{ (LPCVOID) o9a5, F },
|
||||
{ (LPCVOID) o9a6, F },
|
||||
{ (LPCVOID) o9a7, F },
|
||||
{ (LPCVOID) o9a8, F },
|
||||
{ (LPCVOID) o9a9, F },
|
||||
{ (LPCVOID) o9aA, F },
|
||||
{ (LPCVOID) o9aB, F },
|
||||
{ (LPCVOID) o9aC, F },
|
||||
{ (LPCVOID) o9aD, F },
|
||||
{ (LPCVOID) o9aE, F },
|
||||
{ (LPCVOID) o9aF, F }
|
||||
};
|
||||
|
||||
static JMPTAB o9_[] =
|
||||
{
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9a_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 },
|
||||
{ (LPCVOID) o9b_, 2 }
|
||||
};
|
||||
|
||||
static JMPTAB o8B_[] =
|
||||
{
|
||||
{ (LPCVOID) o8B0, F },
|
||||
{ (LPCVOID) o8B1, F },
|
||||
{ (LPCVOID) o8B2, F },
|
||||
{ (LPCVOID) o8B3, F },
|
||||
{ (LPCVOID) o8B4, F },
|
||||
{ (LPCVOID) o8B5, F },
|
||||
{ (LPCVOID) o8B6, F },
|
||||
{ (LPCVOID) o8B7, F },
|
||||
{ (LPCVOID) o8B8, F },
|
||||
{ (LPCVOID) o8B9, F },
|
||||
{ (LPCVOID) o8BA, F },
|
||||
{ (LPCVOID) o8BB, F },
|
||||
{ (LPCVOID) o8BC, F },
|
||||
{ (LPCVOID) o8BD, F },
|
||||
{ (LPCVOID) o8BE, F },
|
||||
{ (LPCVOID) o8BF, F }
|
||||
};
|
||||
|
||||
static JMPTAB o8A_[] =
|
||||
{
|
||||
{ (LPCVOID) o8A0, F },
|
||||
{ (LPCVOID) o8A1, F },
|
||||
{ (LPCVOID) o8A2, F },
|
||||
{ (LPCVOID) o8A3, F },
|
||||
{ (LPCVOID) o8A4, F },
|
||||
{ (LPCVOID) o8A5, F },
|
||||
{ (LPCVOID) o8A6, F },
|
||||
{ (LPCVOID) o8A7, F },
|
||||
{ (LPCVOID) o8A8, F },
|
||||
{ (LPCVOID) o8A9, F },
|
||||
{ (LPCVOID) o8AA, F },
|
||||
{ (LPCVOID) o8AB, F },
|
||||
{ (LPCVOID) o8AC, F },
|
||||
{ (LPCVOID) o8AD, F },
|
||||
{ (LPCVOID) o8AE, F },
|
||||
{ (LPCVOID) o8AF, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81B_[] =
|
||||
{
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o81B2, F },
|
||||
{ (LPCVOID) o81B3, F },
|
||||
{ (LPCVOID) o81B4, F },
|
||||
{ (LPCVOID) o81B5, F },
|
||||
{ (LPCVOID) o81B6, F },
|
||||
{ (LPCVOID) o81B7, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F },
|
||||
{ (LPCVOID) o_invalid4, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81Af2_[] =
|
||||
{
|
||||
{ (LPCVOID) o81Af20, F },
|
||||
{ (LPCVOID) o81Af21, F },
|
||||
{ (LPCVOID) o81Af22, F },
|
||||
{ (LPCVOID) o81Af23, F },
|
||||
{ (LPCVOID) o81Af24, F },
|
||||
{ (LPCVOID) o81Af21, F },
|
||||
{ (LPCVOID) o81Af22, F },
|
||||
{ (LPCVOID) o81Af23, F },
|
||||
{ (LPCVOID) o81Af28, F },
|
||||
{ (LPCVOID) o81Af29, F },
|
||||
{ (LPCVOID) o81Af2A, F },
|
||||
{ (LPCVOID) o81Af2B, F },
|
||||
{ (LPCVOID) o81Af2C, F },
|
||||
{ (LPCVOID) o81Af29, F },
|
||||
{ (LPCVOID) o81Af2A, F },
|
||||
{ (LPCVOID) o81Af2B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81Af1_[] =
|
||||
{
|
||||
{ (LPCVOID) o81Af10, F },
|
||||
{ (LPCVOID) o81Af11, F },
|
||||
{ (LPCVOID) o81Af12, F },
|
||||
{ (LPCVOID) o81Af13, F },
|
||||
{ (LPCVOID) o81Af14, F },
|
||||
{ (LPCVOID) o81Af11, F },
|
||||
{ (LPCVOID) o81Af12, F },
|
||||
{ (LPCVOID) o81Af13, F },
|
||||
{ (LPCVOID) o81Af18, F },
|
||||
{ (LPCVOID) o81Af19, F },
|
||||
{ (LPCVOID) o81Af1A, F },
|
||||
{ (LPCVOID) o81Af1B, F },
|
||||
{ (LPCVOID) o81Af1C, F },
|
||||
{ (LPCVOID) o81Af19, F },
|
||||
{ (LPCVOID) o81Af1A, F },
|
||||
{ (LPCVOID) o81Af1B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81Af0_[] =
|
||||
{
|
||||
{ (LPCVOID) o81Af00, F },
|
||||
{ (LPCVOID) o81Af01, F },
|
||||
{ (LPCVOID) o81Af02, F },
|
||||
{ (LPCVOID) o81Af03, F },
|
||||
{ (LPCVOID) o81Af04, F },
|
||||
{ (LPCVOID) o81Af01, F },
|
||||
{ (LPCVOID) o81Af02, F },
|
||||
{ (LPCVOID) o81Af03, F },
|
||||
{ (LPCVOID) o81Af08, F },
|
||||
{ (LPCVOID) o81Af09, F },
|
||||
{ (LPCVOID) o81Af0A, F },
|
||||
{ (LPCVOID) o81Af0B, F },
|
||||
{ (LPCVOID) o81Af0C, F },
|
||||
{ (LPCVOID) o81Af09, F },
|
||||
{ (LPCVOID) o81Af0A, F },
|
||||
{ (LPCVOID) o81Af0B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81A_[] =
|
||||
{
|
||||
{ (LPCVOID) o81Af0_, 5 },
|
||||
{ (LPCVOID) o81Af1_, 5 },
|
||||
{ (LPCVOID) o81Af2_, 5 },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F }
|
||||
};
|
||||
|
||||
static JMPTAB o819_[] =
|
||||
{
|
||||
{ (LPCVOID) o819f0, F },
|
||||
{ (LPCVOID) o819f1, F },
|
||||
{ (LPCVOID) o819f2, F },
|
||||
{ (LPCVOID) o819f3, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F }
|
||||
};
|
||||
|
||||
static JMPTAB o818_[] =
|
||||
{
|
||||
{ (LPCVOID) o818f0x, F },
|
||||
{ (LPCVOID) o818f1x, F },
|
||||
{ (LPCVOID) o818f2x, F },
|
||||
{ (LPCVOID) o818f3x, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o818f8x, F },
|
||||
{ (LPCVOID) o818f9x, F },
|
||||
{ (LPCVOID) o818fAx, F },
|
||||
{ (LPCVOID) o818fBx, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F },
|
||||
{ (LPCVOID) o_invalid6, F }
|
||||
};
|
||||
|
||||
static JMPTAB o81_[] =
|
||||
{
|
||||
{ (LPCVOID) o810, F },
|
||||
{ (LPCVOID) o811, F },
|
||||
{ (LPCVOID) o812, F },
|
||||
{ (LPCVOID) o813, F },
|
||||
{ (LPCVOID) o814, F },
|
||||
{ (LPCVOID) o815, F },
|
||||
{ (LPCVOID) o816, F },
|
||||
{ (LPCVOID) o817, F },
|
||||
{ (LPCVOID) o818_, 4 },
|
||||
{ (LPCVOID) o819_, 4 },
|
||||
{ (LPCVOID) o81A_, 4 },
|
||||
{ (LPCVOID) o81B_, 3 },
|
||||
{ (LPCVOID) o81C, F },
|
||||
{ (LPCVOID) o81D, F },
|
||||
{ (LPCVOID) o81E, F },
|
||||
{ (LPCVOID) o81F, F }
|
||||
};
|
||||
|
||||
static JMPTAB o8081_[] =
|
||||
{
|
||||
{ (LPCVOID) o80810, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F },
|
||||
{ (LPCVOID) o_invalid5, F }
|
||||
};
|
||||
|
||||
static JMPTAB o808_[] =
|
||||
{
|
||||
{ (LPCVOID) o8080, F },
|
||||
{ (LPCVOID) o8081_, 4 },
|
||||
{ (LPCVOID) o8082X, F },
|
||||
{ (LPCVOID) o8083, F },
|
||||
{ (LPCVOID) o8084n, F },
|
||||
{ (LPCVOID) o8085n, F },
|
||||
{ (LPCVOID) o8086n, F },
|
||||
{ (LPCVOID) o8087n, F },
|
||||
{ (LPCVOID) o8088n, F },
|
||||
{ (LPCVOID) o8089n, F },
|
||||
{ (LPCVOID) o808An, F },
|
||||
{ (LPCVOID) o808Bn, F },
|
||||
{ (LPCVOID) o808C, F },
|
||||
{ (LPCVOID) o808D, F },
|
||||
{ (LPCVOID) o808E, F },
|
||||
{ (LPCVOID) o808F, F }
|
||||
};
|
||||
|
||||
static JMPTAB o80_[] =
|
||||
{
|
||||
{ (LPCVOID) o800, F },
|
||||
{ (LPCVOID) o801, F },
|
||||
{ (LPCVOID) o802, F },
|
||||
{ (LPCVOID) o803, F },
|
||||
{ (LPCVOID) o804, F },
|
||||
{ (LPCVOID) o805, F },
|
||||
{ (LPCVOID) o806, F },
|
||||
{ (LPCVOID) o807, F },
|
||||
{ (LPCVOID) o808_, 3 },
|
||||
{ (LPCVOID) o809, F },
|
||||
{ (LPCVOID) o80A, F },
|
||||
{ (LPCVOID) o80B, F },
|
||||
{ (LPCVOID) o80Cn, F },
|
||||
{ (LPCVOID) o80Dn, F },
|
||||
{ (LPCVOID) o80E, F },
|
||||
{ (LPCVOID) o80Fn, F }
|
||||
};
|
||||
|
||||
static JMPTAB o8_[] =
|
||||
{
|
||||
{ (LPCVOID) o80_, 2 },
|
||||
{ (LPCVOID) o81_, 2 },
|
||||
{ (LPCVOID) o82n, F },
|
||||
{ (LPCVOID) o83n, F },
|
||||
{ (LPCVOID) o84n, F },
|
||||
{ (LPCVOID) o85n, F },
|
||||
{ (LPCVOID) o86n, F },
|
||||
{ (LPCVOID) o87n, F },
|
||||
{ (LPCVOID) o88n, F },
|
||||
{ (LPCVOID) o89n, F },
|
||||
{ (LPCVOID) o8A_, 2 },
|
||||
{ (LPCVOID) o8B_, 2 },
|
||||
{ (LPCVOID) o8Cd4, F },
|
||||
{ (LPCVOID) o8Dd5, F },
|
||||
{ (LPCVOID) o8Ed4, F },
|
||||
{ (LPCVOID) o8Fd5, F }
|
||||
};
|
||||
|
||||
static JMPTAB o15_[] =
|
||||
{
|
||||
{ (LPCVOID) o150a, F },
|
||||
{ (LPCVOID) o151a, F },
|
||||
{ (LPCVOID) o152a, F },
|
||||
{ (LPCVOID) o153a, F },
|
||||
{ (LPCVOID) o154a, F },
|
||||
{ (LPCVOID) o155a, F },
|
||||
{ (LPCVOID) o156a, F },
|
||||
{ (LPCVOID) o157a, F },
|
||||
{ (LPCVOID) o158x, F },
|
||||
{ (LPCVOID) o159x, F },
|
||||
{ (LPCVOID) o15Ax, F },
|
||||
{ (LPCVOID) o15Bx, F },
|
||||
{ (LPCVOID) o15Cx, F },
|
||||
{ (LPCVOID) o15Dx, F },
|
||||
{ (LPCVOID) o15Ex, F },
|
||||
{ (LPCVOID) o15Fx, F }
|
||||
};
|
||||
|
||||
static JMPTAB o14_[] =
|
||||
{
|
||||
{ (LPCVOID) o140, F },
|
||||
{ (LPCVOID) o141, F },
|
||||
{ (LPCVOID) o142, F },
|
||||
{ (LPCVOID) o143, F },
|
||||
{ (LPCVOID) o144, F },
|
||||
{ (LPCVOID) o145, F },
|
||||
{ (LPCVOID) o146, F },
|
||||
{ (LPCVOID) o147, F },
|
||||
{ (LPCVOID) o148, F },
|
||||
{ (LPCVOID) o149, F },
|
||||
{ (LPCVOID) o14A, F },
|
||||
{ (LPCVOID) o14B, F },
|
||||
{ (LPCVOID) o14C, F },
|
||||
{ (LPCVOID) o14D, F },
|
||||
{ (LPCVOID) o14E, F },
|
||||
{ (LPCVOID) o14F, F }
|
||||
};
|
||||
|
||||
static JMPTAB o13_[] =
|
||||
{
|
||||
{ (LPCVOID) o130, F },
|
||||
{ (LPCVOID) o131, F },
|
||||
{ (LPCVOID) o132, F },
|
||||
{ (LPCVOID) o133, F },
|
||||
{ (LPCVOID) o134, F },
|
||||
{ (LPCVOID) o135, F },
|
||||
{ (LPCVOID) o136, F },
|
||||
{ (LPCVOID) o137, F },
|
||||
{ (LPCVOID) o138, F },
|
||||
{ (LPCVOID) o139, F },
|
||||
{ (LPCVOID) o13A, F },
|
||||
{ (LPCVOID) o13B, F },
|
||||
{ (LPCVOID) o13C, F },
|
||||
{ (LPCVOID) o13D, F },
|
||||
{ (LPCVOID) o13E, F },
|
||||
{ (LPCVOID) o13F, F }
|
||||
};
|
||||
|
||||
static JMPTAB o12_[] =
|
||||
{
|
||||
{ (LPCVOID) o120, F },
|
||||
{ (LPCVOID) o121, F },
|
||||
{ (LPCVOID) o122, F },
|
||||
{ (LPCVOID) o123, F },
|
||||
{ (LPCVOID) o124, F },
|
||||
{ (LPCVOID) o121, F },
|
||||
{ (LPCVOID) o122, F },
|
||||
{ (LPCVOID) o123, F },
|
||||
{ (LPCVOID) o128, F },
|
||||
{ (LPCVOID) o129, F },
|
||||
{ (LPCVOID) o12A, F },
|
||||
{ (LPCVOID) o12B, F },
|
||||
{ (LPCVOID) o12C, F },
|
||||
{ (LPCVOID) o129, F },
|
||||
{ (LPCVOID) o12A, F },
|
||||
{ (LPCVOID) o12B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o11_[] =
|
||||
{
|
||||
{ (LPCVOID) o110, F },
|
||||
{ (LPCVOID) o111, F },
|
||||
{ (LPCVOID) o112, F },
|
||||
{ (LPCVOID) o113, F },
|
||||
{ (LPCVOID) o114, F },
|
||||
{ (LPCVOID) o111, F },
|
||||
{ (LPCVOID) o112, F },
|
||||
{ (LPCVOID) o113, F },
|
||||
{ (LPCVOID) o118, F },
|
||||
{ (LPCVOID) o119, F },
|
||||
{ (LPCVOID) o11A, F },
|
||||
{ (LPCVOID) o11B, F },
|
||||
{ (LPCVOID) o11C, F },
|
||||
{ (LPCVOID) o119, F },
|
||||
{ (LPCVOID) o11A, F },
|
||||
{ (LPCVOID) o11B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o10_[] =
|
||||
{
|
||||
{ (LPCVOID) o100, F },
|
||||
{ (LPCVOID) o101, F },
|
||||
{ (LPCVOID) o102, F },
|
||||
{ (LPCVOID) o103, F },
|
||||
{ (LPCVOID) o104, F },
|
||||
{ (LPCVOID) o101, F },
|
||||
{ (LPCVOID) o102, F },
|
||||
{ (LPCVOID) o103, F },
|
||||
{ (LPCVOID) o108, F },
|
||||
{ (LPCVOID) o109, F },
|
||||
{ (LPCVOID) o10A, F },
|
||||
{ (LPCVOID) o10B, F },
|
||||
{ (LPCVOID) o10C, F },
|
||||
{ (LPCVOID) o109, F },
|
||||
{ (LPCVOID) o10A, F },
|
||||
{ (LPCVOID) o10B, F }
|
||||
};
|
||||
|
||||
static JMPTAB o1_[] =
|
||||
{
|
||||
{ (LPCVOID) o10_, 2 },
|
||||
{ (LPCVOID) o11_, 2 },
|
||||
{ (LPCVOID) o12_, 2 },
|
||||
{ (LPCVOID) o13_, 2 },
|
||||
{ (LPCVOID) o14_, 2 },
|
||||
{ (LPCVOID) o15_, 2 },
|
||||
{ (LPCVOID) o16x, F },
|
||||
{ (LPCVOID) o17x, F },
|
||||
{ (LPCVOID) o18x, F },
|
||||
{ (LPCVOID) o19d2, F },
|
||||
{ (LPCVOID) o1Ad4, F },
|
||||
{ (LPCVOID) o1Bd5, F },
|
||||
{ (LPCVOID) o1Cx, F },
|
||||
{ (LPCVOID) o1Dd2, F },
|
||||
{ (LPCVOID) o1Ed4, F },
|
||||
{ (LPCVOID) o1Fd5, F }
|
||||
};
|
||||
|
||||
static JMPTAB o0E_[] =
|
||||
{
|
||||
{ (LPCVOID) o0Ef0, F },
|
||||
{ (LPCVOID) o0Ef1, F },
|
||||
{ (LPCVOID) o0Ef2, F },
|
||||
{ (LPCVOID) o0Ef3, F },
|
||||
{ (LPCVOID) o0Ef4, F },
|
||||
{ (LPCVOID) o0Ef5, F },
|
||||
{ (LPCVOID) o0Ef6, F },
|
||||
{ (LPCVOID) o0Ef7, F },
|
||||
{ (LPCVOID) o0Ef8, F },
|
||||
{ (LPCVOID) o0Ef9, F },
|
||||
{ (LPCVOID) o0EfA, F },
|
||||
{ (LPCVOID) o0EfB, F },
|
||||
{ (LPCVOID) o0EfC, F },
|
||||
{ (LPCVOID) o0EfD, F },
|
||||
{ (LPCVOID) o0EfE, F },
|
||||
{ (LPCVOID) o0EfF, F }
|
||||
};
|
||||
|
||||
static JMPTAB o0_[] =
|
||||
{
|
||||
{ (LPCVOID) o00, F },
|
||||
{ (LPCVOID) o01, F },
|
||||
{ (LPCVOID) o02, F },
|
||||
{ (LPCVOID) o03, F },
|
||||
{ (LPCVOID) o04, F },
|
||||
{ (LPCVOID) o05, F },
|
||||
{ (LPCVOID) o06, F },
|
||||
{ (LPCVOID) o07, F },
|
||||
{ (LPCVOID) o08, F },
|
||||
{ (LPCVOID) o09, F },
|
||||
{ (LPCVOID) o0A, F },
|
||||
{ (LPCVOID) o0B, F },
|
||||
{ (LPCVOID) o0C, F },
|
||||
{ (LPCVOID) o0D, F },
|
||||
{ (LPCVOID) o0E_, 3 },
|
||||
{ (LPCVOID) o0F, F }
|
||||
};
|
||||
|
||||
static JMPTAB o_[] =
|
||||
{
|
||||
{ (LPCVOID) o0_, 1 },
|
||||
{ (LPCVOID) o1_, 1 },
|
||||
{ (LPCVOID) o2n, F },
|
||||
{ (LPCVOID) o3X, F },
|
||||
{ (LPCVOID) o4d2, F },
|
||||
{ (LPCVOID) o5d2, F },
|
||||
{ (LPCVOID) o6d3, F },
|
||||
{ (LPCVOID) o7d3, F },
|
||||
{ (LPCVOID) o8_, 1 },
|
||||
{ (LPCVOID) o9_, 1 },
|
||||
{ (LPCVOID) oA_, 1 },
|
||||
{ (LPCVOID) oB_, 1 },
|
||||
{ (LPCVOID) oC_, 1 },
|
||||
{ (LPCVOID) oD_, 1 },
|
||||
{ (LPCVOID) oE_, 1 },
|
||||
{ (LPCVOID) oF_, 1 }
|
||||
};
|
||||
|
||||
// opcode dispatcher
|
||||
VOID EvalOpcode(LPBYTE I)
|
||||
{
|
||||
DWORD dwIndex = 0;
|
||||
PJMPTAB pJmpTab = o_;
|
||||
|
||||
do
|
||||
{
|
||||
_ASSERT(I[dwIndex] <= 0xf); // found packed data
|
||||
pJmpTab = &pJmpTab[I[dwIndex]]; // table entry by opcode
|
||||
dwIndex = pJmpTab->dwTyp; // next pointer type
|
||||
pJmpTab = (PJMPTAB) pJmpTab->pLnk; // next pointer to table/function
|
||||
}
|
||||
while (dwIndex != F); // reference to table? -> again
|
||||
|
||||
((VOID (*)(LPBYTE)) pJmpTab)(I); // call function
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,40 +1,40 @@
|
|||
/*
|
||||
* i28f160.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2000 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define WSMVER 0 // version of flash implementation structure
|
||||
|
||||
#define WSMSET WSMset_t
|
||||
typedef struct
|
||||
{
|
||||
BYTE byType[4]; // "WSM"
|
||||
UINT uSize; // size of this structure
|
||||
BYTE byVersion; // WSM version
|
||||
|
||||
BOOL bRomArray; // copy of bFlashRomArray
|
||||
DWORD dwLockCnfg; // block lock table (32 entries)
|
||||
UINT uWrState; // state of write function WSM
|
||||
UINT uRdState; // state of read function WSM
|
||||
BYTE byStatusReg; // status register
|
||||
BYTE byExStatusReg; // extended status register
|
||||
BYTE byWrite1No; // no. of written data in write buffer1
|
||||
BYTE byWrite1Size; // no. of valid data in write buffer1
|
||||
DWORD dwWrite1Addr; // destination address of buffer1
|
||||
BYTE pbyWrite1[32]; // write buffer1
|
||||
// BYTE byWrite2No; // no. of written data in write buffer2
|
||||
// BYTE byWrite2Size; // no. of valid data in write buffer2
|
||||
// DWORD dwWrite2Addr; // destination address of buffer2
|
||||
// BYTE pbyWrite2[32]; // write buffer2
|
||||
} WSMset_t;
|
||||
|
||||
// i28f160.h
|
||||
extern WSMSET WSMset;
|
||||
extern BOOL bWP;
|
||||
extern VOID FlashInit(VOID);
|
||||
extern VOID FlashRead(BYTE *a, DWORD d, UINT s);
|
||||
extern VOID FlashWrite(BYTE *a, DWORD d, UINT s);
|
||||
/*
|
||||
* i28f160.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2000 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define WSMVER 0 // version of flash implementation structure
|
||||
|
||||
#define WSMSET WSMset_t
|
||||
typedef struct
|
||||
{
|
||||
BYTE byType[4]; // "WSM"
|
||||
UINT uSize; // size of this structure
|
||||
BYTE byVersion; // WSM version
|
||||
|
||||
BOOL bRomArray; // copy of bFlashRomArray
|
||||
DWORD dwLockCnfg; // block lock table (32 entries)
|
||||
UINT uWrState; // state of write function WSM
|
||||
UINT uRdState; // state of read function WSM
|
||||
BYTE byStatusReg; // status register
|
||||
BYTE byExStatusReg; // extended status register
|
||||
BYTE byWrite1No; // no. of written data in write buffer1
|
||||
BYTE byWrite1Size; // no. of valid data in write buffer1
|
||||
DWORD dwWrite1Addr; // destination address of buffer1
|
||||
BYTE pbyWrite1[32]; // write buffer1
|
||||
// BYTE byWrite2No; // no. of written data in write buffer2
|
||||
// BYTE byWrite2Size; // no. of valid data in write buffer2
|
||||
// DWORD dwWrite2Addr; // destination address of buffer2
|
||||
// BYTE pbyWrite2[32]; // write buffer2
|
||||
} WSMset_t;
|
||||
|
||||
// i28f160.h
|
||||
extern WSMSET WSMset;
|
||||
extern BOOL bWP;
|
||||
extern VOID FlashInit(VOID);
|
||||
extern VOID FlashRead(BYTE *a, DWORD d, UINT s);
|
||||
extern VOID FlashWrite(BYTE *a, DWORD d, UINT s);
|
|
@ -1,154 +1,154 @@
|
|||
/*
|
||||
* io.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// I/O addresses without mapping offset
|
||||
#define BITOFFSET 0x00 // Display bit offset and DON
|
||||
#define CRC 0x04 // Crc (16 bit, LSB first)
|
||||
#define LPD 0x08 // Low Power Detection
|
||||
#define LPE 0x09 // Low Power detection Enable
|
||||
#define ANNCTRL 0x0b // Annunciator Control (2 nibble)
|
||||
#define BAUD 0x0d // Baudrate (Bit 2-0)
|
||||
#define CARDCTL 0x0e // card control
|
||||
#define CARDSTAT 0x0f // card status
|
||||
#define IOC 0x10 // IO CONTROL
|
||||
#define RCS 0x11 // RCS
|
||||
#define TCS 0x12 // TCS
|
||||
#define CRER 0x13 // CRER
|
||||
#define RBR_LSB 0x14 // RBR low nibble
|
||||
#define RBR_MSB 0x15 // RBR high nibble
|
||||
#define TBR_LSB 0x16 // TBR low nibble
|
||||
#define TBR_MSB 0x17 // TBR high nibble
|
||||
#define SRQ1 0x18 // SRQ1
|
||||
#define SRQ2 0x19 // SRQ2
|
||||
#define IR_CTRL 0x1a // IR CONTROL
|
||||
#define LCR 0x1c // Led Control Register
|
||||
#define LBR 0x1d // Led Buffer Register
|
||||
#define DISP1CTL 0x20 // Display Start Address
|
||||
#define LINENIBS 0x25 // Display Line Offset
|
||||
#define LINECOUNT 0x28 // Display Line Counter
|
||||
#define TIMER1_CTRL 0x2e // Timer1 Control
|
||||
#define TIMER2_CTRL 0x2f // Timer2 Control
|
||||
#define DISP2CTL 0x30 // Display Secondary Start Address
|
||||
#define TIMER1 0x37 // Timer1 (4 bit)
|
||||
#define TIMER2 0x38 // Timer2 (32 bit, LSB first)
|
||||
|
||||
// 0x00 Display bit offset and DON [DON OFF2 OFF1 OFF0]
|
||||
#define DON 0x08 // Display On
|
||||
#define OFF2 0x04 // Display OFFset Bit2
|
||||
#define OFF1 0x02 // Display OFFset Bit1
|
||||
#define OFF0 0x01 // Display OFFset Bit0
|
||||
|
||||
// 0x08 Low Power Detection [LB2 LB1 LB0 VLBI]
|
||||
#define LB2 0x08 // Low Battery indicator memory port 2
|
||||
#define LB1 0x04 // Low Battery indicator memory port 1
|
||||
#define LB0 0x02 // Low Battery indicator system battery
|
||||
#define VLBI 0x01 // Very Low Battery Indicator
|
||||
|
||||
// 0x09 Low Power detection Enable [ELBI EVLBI GRAM RST]
|
||||
#define ELBI 0x08 // Enable Low Battery Indicator
|
||||
#define EVLBI 0x04 // Enable Very Low Battery Indicator
|
||||
#define GRAM 0x02 // Glitch sensitive RAM
|
||||
#define RST 0x01 // ReSeT
|
||||
|
||||
// 0x0b Annunciator Control [AON XTRA LA6 LA5] [LA4 LA3 LA2 LA1]
|
||||
#define AON 0x80 // Annunciators on
|
||||
#define LXTRA 0x40 // does nothing
|
||||
#define LA6 0x20 // LA6 - Transmitting
|
||||
#define LA5 0x10 // LA5 - Busy
|
||||
#define LA4 0x08 // LA4 - Alert
|
||||
#define LA3 0x04 // LA3 - Alpha
|
||||
#define LA2 0x02 // LA2 - ALT Shift
|
||||
#define LA1 0x01 // LA1 - Shift
|
||||
|
||||
// 0x0d SERIAL Baud Rate [UCK BD2 BD1 BD0]
|
||||
#define UCK 0x08 // Uart ClocK
|
||||
#define BD2 0x04 // BauDrate Bit2
|
||||
#define BD1 0x02 // BauDrate Bit1
|
||||
#define BD0 0x01 // BauDrate Bit0
|
||||
|
||||
// 0x0e Card Control [ECDT RCDT SMP SWINT]
|
||||
#define ECDT 0x08 // Enable Card Detect
|
||||
#define RCDT 0x04 // Run Card Detect
|
||||
#define SMP 0x02 // Set module pulled
|
||||
#define SWINT 0x01 // Software Interrupt
|
||||
|
||||
// 0x0f Card Status [P2W P1W P2C P1C]
|
||||
#define P2W 0x08 // High when Port2 writeable
|
||||
#define P1W 0x04 // High when Port1 writeable
|
||||
#define P2C 0x02 // High when Card in Port2 inserted
|
||||
#define P1C 0x01 // High when Card in Port1 inserted
|
||||
|
||||
// 0x10 Serial I/O Control [SON ETBE ERBF ERBZ]
|
||||
#define SON 0x08 // Serial on
|
||||
#define ETBE 0x04 // Interrupt on transmit buffer empty
|
||||
#define ERBF 0x02 // Interrupt on receive buffer full
|
||||
#define ERBZ 0x01 // Interrupt on receiver busy
|
||||
|
||||
// 0x11 Serial Receive Control/Status [RX RER RBZ RBF]
|
||||
#define RX 0x08 // Rx pin state (read-only)
|
||||
#define RER 0x04 // Receiver error
|
||||
#define RBZ 0x02 // Receiver busy
|
||||
#define RBF 0x01 // Receive buffer full
|
||||
|
||||
// 0x12 Serial Transmit Control/Status [BRK LPB TBZ TBF]
|
||||
#define BRK 0x08 // Break
|
||||
#define LPB 0x04 // Loopback
|
||||
#define TBZ 0x02 // Transmitter busy
|
||||
#define TBF 0x01 // Transmit buffer full
|
||||
|
||||
// 0x18 Service Request Register 1 [ISRQ TSRQ USRQ VSRQ]
|
||||
#define ISRQ 0x08 // IR receiver pulls NINT2
|
||||
#define TSRQ 0x04 // Timer pulls NINT2
|
||||
#define USRQ 0x02 // UART pulls NINT2
|
||||
#define VSRQ 0x01 // VLBI pulls NINT2
|
||||
|
||||
// 0x19 Service Request Register 2 [KDN NINT2 NINT LSRQ]
|
||||
#define KDN 0x08 // Bit set when ON Key or Key Interrupt
|
||||
#define NINT2 0x04 // State of NINT2
|
||||
#define NINT 0x02 // State of NINT
|
||||
#define LSRQ 0x01 // LED driver pulls NINT2
|
||||
|
||||
// 0x1a IR Control Register [IRI EIRU EIRI IRE]
|
||||
#define IRI 0x08 // IR input (read-only)
|
||||
#define EIRU 0x04 // Enable IR UART mode
|
||||
#define EIRI 0x02 // Enable IR interrupt
|
||||
#define IRE 0x01 // IR event
|
||||
|
||||
// 0x1c Led Control Register [LED ELBE LBZ LBF]
|
||||
#define LED 0x08 // Turn on LED
|
||||
#define ELBE 0x04 // Enable Interrupt on Led Buffer empty
|
||||
#define LBZ 0x02 // Led Port Busy
|
||||
#define LBF 0x01 // Led Buffer Full
|
||||
|
||||
// 0x1d Led Buffer Register [0 0 0 LBO] (bits 1-3 read zero)
|
||||
#define LBO 0x01
|
||||
|
||||
// 0x28 Display Line Counter LSB [LC3 LC2 LC1 LC0]
|
||||
#define LC3 0x08 // LC3 - Line Counter Bit3
|
||||
#define LC2 0x04 // LC2 - Line Counter Bit2
|
||||
#define LC1 0x02 // LC1 - Line Counter Bit1
|
||||
#define LC0 0x01 // LC0 - Line Counter Bit0
|
||||
|
||||
// 0x29 Display Line Counter MSB [DA19 M32 LC5 LC4]
|
||||
#define DA19 0x08 // Drive A[19]
|
||||
#define M32 0x04 // Multiplex 32 way
|
||||
#define LC5 0x02 // LC5 - Line Counter Bit5
|
||||
#define LC4 0x01 // LC4 - Line Counter Bit4
|
||||
|
||||
// 0x2e Timer1 Control [SRQ WKE INT XTRA]
|
||||
#define SRQ 0x08 // Service request
|
||||
#define WKE 0x04 // Wake up
|
||||
#define INTR 0x02 // Interrupt
|
||||
#define XTRA 0x01 // Extra function
|
||||
|
||||
// 0x2f Timer2 Control [SRQ WKE INT RUN]
|
||||
#define SRQ 0x08 // Service request
|
||||
#define WKE 0x04 // Wake up
|
||||
#define INTR 0x02 // Interrupt
|
||||
#define RUN 0x01 // Timer run
|
||||
/*
|
||||
* io.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
// I/O addresses without mapping offset
|
||||
#define BITOFFSET 0x00 // Display bit offset and DON
|
||||
#define CRC 0x04 // Crc (16 bit, LSB first)
|
||||
#define LPD 0x08 // Low Power Detection
|
||||
#define LPE 0x09 // Low Power detection Enable
|
||||
#define ANNCTRL 0x0b // Annunciator Control (2 nibble)
|
||||
#define BAUD 0x0d // Baudrate (Bit 2-0)
|
||||
#define CARDCTL 0x0e // card control
|
||||
#define CARDSTAT 0x0f // card status
|
||||
#define IOC 0x10 // IO CONTROL
|
||||
#define RCS 0x11 // RCS
|
||||
#define TCS 0x12 // TCS
|
||||
#define CRER 0x13 // CRER
|
||||
#define RBR_LSB 0x14 // RBR low nibble
|
||||
#define RBR_MSB 0x15 // RBR high nibble
|
||||
#define TBR_LSB 0x16 // TBR low nibble
|
||||
#define TBR_MSB 0x17 // TBR high nibble
|
||||
#define SRQ1 0x18 // SRQ1
|
||||
#define SRQ2 0x19 // SRQ2
|
||||
#define IR_CTRL 0x1a // IR CONTROL
|
||||
#define LCR 0x1c // Led Control Register
|
||||
#define LBR 0x1d // Led Buffer Register
|
||||
#define DISP1CTL 0x20 // Display Start Address
|
||||
#define LINENIBS 0x25 // Display Line Offset
|
||||
#define LINECOUNT 0x28 // Display Line Counter
|
||||
#define TIMER1_CTRL 0x2e // Timer1 Control
|
||||
#define TIMER2_CTRL 0x2f // Timer2 Control
|
||||
#define DISP2CTL 0x30 // Display Secondary Start Address
|
||||
#define TIMER1 0x37 // Timer1 (4 bit)
|
||||
#define TIMER2 0x38 // Timer2 (32 bit, LSB first)
|
||||
|
||||
// 0x00 Display bit offset and DON [DON OFF2 OFF1 OFF0]
|
||||
#define DON 0x08 // Display On
|
||||
#define OFF2 0x04 // Display OFFset Bit2
|
||||
#define OFF1 0x02 // Display OFFset Bit1
|
||||
#define OFF0 0x01 // Display OFFset Bit0
|
||||
|
||||
// 0x08 Low Power Detection [LB2 LB1 LB0 VLBI]
|
||||
#define LB2 0x08 // Low Battery indicator memory port 2
|
||||
#define LB1 0x04 // Low Battery indicator memory port 1
|
||||
#define LB0 0x02 // Low Battery indicator system battery
|
||||
#define VLBI 0x01 // Very Low Battery Indicator
|
||||
|
||||
// 0x09 Low Power detection Enable [ELBI EVLBI GRAM RST]
|
||||
#define ELBI 0x08 // Enable Low Battery Indicator
|
||||
#define EVLBI 0x04 // Enable Very Low Battery Indicator
|
||||
#define GRAM 0x02 // Glitch sensitive RAM
|
||||
#define RST 0x01 // ReSeT
|
||||
|
||||
// 0x0b Annunciator Control [AON XTRA LA6 LA5] [LA4 LA3 LA2 LA1]
|
||||
#define AON 0x80 // Annunciators on
|
||||
#define LXTRA 0x40 // does nothing
|
||||
#define LA6 0x20 // LA6 - Transmitting
|
||||
#define LA5 0x10 // LA5 - Busy
|
||||
#define LA4 0x08 // LA4 - Alert
|
||||
#define LA3 0x04 // LA3 - Alpha
|
||||
#define LA2 0x02 // LA2 - ALT Shift
|
||||
#define LA1 0x01 // LA1 - Shift
|
||||
|
||||
// 0x0d SERIAL Baud Rate [UCK BD2 BD1 BD0]
|
||||
#define UCK 0x08 // Uart ClocK
|
||||
#define BD2 0x04 // BauDrate Bit2
|
||||
#define BD1 0x02 // BauDrate Bit1
|
||||
#define BD0 0x01 // BauDrate Bit0
|
||||
|
||||
// 0x0e Card Control [ECDT RCDT SMP SWINT]
|
||||
#define ECDT 0x08 // Enable Card Detect
|
||||
#define RCDT 0x04 // Run Card Detect
|
||||
#define SMP 0x02 // Set module pulled
|
||||
#define SWINT 0x01 // Software Interrupt
|
||||
|
||||
// 0x0f Card Status [P2W P1W P2C P1C]
|
||||
#define P2W 0x08 // High when Port2 writeable
|
||||
#define P1W 0x04 // High when Port1 writeable
|
||||
#define P2C 0x02 // High when Card in Port2 inserted
|
||||
#define P1C 0x01 // High when Card in Port1 inserted
|
||||
|
||||
// 0x10 Serial I/O Control [SON ETBE ERBF ERBZ]
|
||||
#define SON 0x08 // Serial on
|
||||
#define ETBE 0x04 // Interrupt on transmit buffer empty
|
||||
#define ERBF 0x02 // Interrupt on receive buffer full
|
||||
#define ERBZ 0x01 // Interrupt on receiver busy
|
||||
|
||||
// 0x11 Serial Receive Control/Status [RX RER RBZ RBF]
|
||||
#define RX 0x08 // Rx pin state (read-only)
|
||||
#define RER 0x04 // Receiver error
|
||||
#define RBZ 0x02 // Receiver busy
|
||||
#define RBF 0x01 // Receive buffer full
|
||||
|
||||
// 0x12 Serial Transmit Control/Status [BRK LPB TBZ TBF]
|
||||
#define BRK 0x08 // Break
|
||||
#define LPB 0x04 // Loopback
|
||||
#define TBZ 0x02 // Transmitter busy
|
||||
#define TBF 0x01 // Transmit buffer full
|
||||
|
||||
// 0x18 Service Request Register 1 [ISRQ TSRQ USRQ VSRQ]
|
||||
#define ISRQ 0x08 // IR receiver pulls NINT2
|
||||
#define TSRQ 0x04 // Timer pulls NINT2
|
||||
#define USRQ 0x02 // UART pulls NINT2
|
||||
#define VSRQ 0x01 // VLBI pulls NINT2
|
||||
|
||||
// 0x19 Service Request Register 2 [KDN NINT2 NINT LSRQ]
|
||||
#define KDN 0x08 // Bit set when ON Key or Key Interrupt
|
||||
#define NINT2 0x04 // State of NINT2
|
||||
#define NINT 0x02 // State of NINT
|
||||
#define LSRQ 0x01 // LED driver pulls NINT2
|
||||
|
||||
// 0x1a IR Control Register [IRI EIRU EIRI IRE]
|
||||
#define IRI 0x08 // IR input (read-only)
|
||||
#define EIRU 0x04 // Enable IR UART mode
|
||||
#define EIRI 0x02 // Enable IR interrupt
|
||||
#define IRE 0x01 // IR event
|
||||
|
||||
// 0x1c Led Control Register [LED ELBE LBZ LBF]
|
||||
#define LED 0x08 // Turn on LED
|
||||
#define ELBE 0x04 // Enable Interrupt on Led Buffer empty
|
||||
#define LBZ 0x02 // Led Port Busy
|
||||
#define LBF 0x01 // Led Buffer Full
|
||||
|
||||
// 0x1d Led Buffer Register [0 0 0 LBO] (bits 1-3 read zero)
|
||||
#define LBO 0x01
|
||||
|
||||
// 0x28 Display Line Counter LSB [LC3 LC2 LC1 LC0]
|
||||
#define LC3 0x08 // LC3 - Line Counter Bit3
|
||||
#define LC2 0x04 // LC2 - Line Counter Bit2
|
||||
#define LC1 0x02 // LC1 - Line Counter Bit1
|
||||
#define LC0 0x01 // LC0 - Line Counter Bit0
|
||||
|
||||
// 0x29 Display Line Counter MSB [DA19 M32 LC5 LC4]
|
||||
#define DA19 0x08 // Drive A[19]
|
||||
#define M32 0x04 // Multiplex 32 way
|
||||
#define LC5 0x02 // LC5 - Line Counter Bit5
|
||||
#define LC4 0x01 // LC4 - Line Counter Bit4
|
||||
|
||||
// 0x2e Timer1 Control [SRQ WKE INT XTRA]
|
||||
#define SRQ 0x08 // Service request
|
||||
#define WKE 0x04 // Wake up
|
||||
#define INTR 0x02 // Interrupt
|
||||
#define XTRA 0x01 // Extra function
|
||||
|
||||
// 0x2f Timer2 Control [SRQ WKE INT RUN]
|
||||
#define SRQ 0x08 // Service request
|
||||
#define WKE 0x04 // Wake up
|
||||
#define INTR 0x02 // Interrupt
|
||||
#define RUN 0x01 // Timer run
|
|
@ -1,131 +1,131 @@
|
|||
/*
|
||||
* keyboard.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
DWORD dwKeyMinDelay = 50; // minimum time for key hold
|
||||
|
||||
static WORD Keyboard_GetIR(VOID)
|
||||
{
|
||||
WORD r = 0;
|
||||
|
||||
// OR[0:8] are wired on Clarke/Yorke chip
|
||||
if (Chipset.out==0) return 0;
|
||||
if (Chipset.out&0x001) r|=Chipset.Keyboard_Row[0];
|
||||
if (Chipset.out&0x002) r|=Chipset.Keyboard_Row[1];
|
||||
if (Chipset.out&0x004) r|=Chipset.Keyboard_Row[2];
|
||||
if (Chipset.out&0x008) r|=Chipset.Keyboard_Row[3];
|
||||
if (Chipset.out&0x010) r|=Chipset.Keyboard_Row[4];
|
||||
if (Chipset.out&0x020) r|=Chipset.Keyboard_Row[5];
|
||||
if (Chipset.out&0x040) r|=Chipset.Keyboard_Row[6];
|
||||
if (Chipset.out&0x080) r|=Chipset.Keyboard_Row[7];
|
||||
if (Chipset.out&0x100) r|=Chipset.Keyboard_Row[8];
|
||||
return r;
|
||||
}
|
||||
|
||||
VOID ScanKeyboard(BOOL bActive, BOOL bReset)
|
||||
{
|
||||
// bActive = TRUE -> function called by direct read (A=IN, C=IN, RSI)
|
||||
// FALSE -> function called by 1ms keyboard poll simulation
|
||||
// bReset = TRUE -> Reset Chipset.in interrupt state register
|
||||
// FALSE -> generate interrupt only for new pressed keys
|
||||
|
||||
// keyboard read not active?
|
||||
if (!( bActive || Chipset.Shutdn || Chipset.IR15X
|
||||
|| (Chipset.intk && (Chipset.IORam[TIMER2_CTRL]&RUN) != 0)))
|
||||
{
|
||||
EnterCriticalSection(&csKeyLock);
|
||||
{
|
||||
Chipset.in &= ~0x8000; // remove ON key
|
||||
}
|
||||
LeaveCriticalSection(&csKeyLock);
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&csKeyLock); // synchronize
|
||||
{
|
||||
BOOL bKbdInt;
|
||||
|
||||
WORD wOldIn = Chipset.in; // save old Chipset.in state
|
||||
|
||||
UpdateKdnBit(); // update KDN bit
|
||||
Chipset.dwKdnCycles = (DWORD) (Chipset.cycles & 0xFFFFFFFF);
|
||||
|
||||
Chipset.in = Keyboard_GetIR(); // update Chipset.in register
|
||||
Chipset.in |= Chipset.IR15X; // add ON key
|
||||
|
||||
// interrupt for any new pressed keys?
|
||||
bKbdInt = (Chipset.in && (wOldIn & 0x1FF) == 0) || Chipset.IR15X || bReset;
|
||||
|
||||
// update keyboard interrupt pending flag when 1ms keyboard scan is disabled
|
||||
Chipset.intd = Chipset.intd || (bKbdInt && !Chipset.intk);
|
||||
|
||||
// keyboard interrupt enabled?
|
||||
bKbdInt = bKbdInt && Chipset.intk;
|
||||
|
||||
// interrupt at ON key pressed
|
||||
bKbdInt = bKbdInt || Chipset.IR15X != 0;
|
||||
|
||||
// no interrupt if still inside interrupt service routine
|
||||
bKbdInt = bKbdInt && Chipset.inte;
|
||||
|
||||
if (Chipset.in != 0) // any key pressed
|
||||
{
|
||||
if (bKbdInt) // interrupt enabled
|
||||
{
|
||||
Chipset.SoftInt = TRUE; // interrupt request
|
||||
bInterrupt = TRUE; // exit emulation loop
|
||||
}
|
||||
|
||||
if (Chipset.Shutdn) // cpu sleeping
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Chipset.intd = FALSE; // no keyboard interrupt pending
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&csKeyLock);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID KeyboardEvent(BOOL bPress, UINT out, UINT in)
|
||||
{
|
||||
if (nState != SM_RUN) // not in running state
|
||||
return; // ignore key
|
||||
|
||||
KeyMacroRecord(bPress,out,in); // save all keyboard events
|
||||
|
||||
if (in == 0x8000) // ON key ?
|
||||
{
|
||||
Chipset.IR15X = bPress?0x8000:0x0000; // refresh special ON key flag
|
||||
}
|
||||
else
|
||||
{
|
||||
// "out" is outside Keyboard_Row
|
||||
if (out >= ARRAYSIZEOF(Chipset.Keyboard_Row)) return;
|
||||
|
||||
// in &= 0x1FF; // only IR[0:8] are wired on Clarke/Yorke chip
|
||||
|
||||
_ASSERT(out < ARRAYSIZEOF(Chipset.Keyboard_Row));
|
||||
if (bPress) // key pressed
|
||||
Chipset.Keyboard_Row[out] |= in; // set key marker in keyboard row
|
||||
else
|
||||
Chipset.Keyboard_Row[out] &= (~in); // clear key marker in keyboard row
|
||||
}
|
||||
AdjKeySpeed(); // adjust key repeat speed
|
||||
ScanKeyboard(FALSE,FALSE); // update Chipset.in register by 1ms keyboard poll
|
||||
Sleep(dwKeyMinDelay); // hold key state for a definite time
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* keyboard.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
DWORD dwKeyMinDelay = 50; // minimum time for key hold
|
||||
|
||||
static WORD Keyboard_GetIR(VOID)
|
||||
{
|
||||
WORD r = 0;
|
||||
|
||||
// OR[0:8] are wired on Clarke/Yorke chip
|
||||
if (Chipset.out==0) return 0;
|
||||
if (Chipset.out&0x001) r|=Chipset.Keyboard_Row[0];
|
||||
if (Chipset.out&0x002) r|=Chipset.Keyboard_Row[1];
|
||||
if (Chipset.out&0x004) r|=Chipset.Keyboard_Row[2];
|
||||
if (Chipset.out&0x008) r|=Chipset.Keyboard_Row[3];
|
||||
if (Chipset.out&0x010) r|=Chipset.Keyboard_Row[4];
|
||||
if (Chipset.out&0x020) r|=Chipset.Keyboard_Row[5];
|
||||
if (Chipset.out&0x040) r|=Chipset.Keyboard_Row[6];
|
||||
if (Chipset.out&0x080) r|=Chipset.Keyboard_Row[7];
|
||||
if (Chipset.out&0x100) r|=Chipset.Keyboard_Row[8];
|
||||
return r;
|
||||
}
|
||||
|
||||
VOID ScanKeyboard(BOOL bActive, BOOL bReset)
|
||||
{
|
||||
// bActive = TRUE -> function called by direct read (A=IN, C=IN, RSI)
|
||||
// FALSE -> function called by 1ms keyboard poll simulation
|
||||
// bReset = TRUE -> Reset Chipset.in interrupt state register
|
||||
// FALSE -> generate interrupt only for new pressed keys
|
||||
|
||||
// keyboard read not active?
|
||||
if (!( bActive || Chipset.Shutdn || Chipset.IR15X
|
||||
|| (Chipset.intk && (Chipset.IORam[TIMER2_CTRL]&RUN) != 0)))
|
||||
{
|
||||
EnterCriticalSection(&csKeyLock);
|
||||
{
|
||||
Chipset.in &= ~0x8000; // remove ON key
|
||||
}
|
||||
LeaveCriticalSection(&csKeyLock);
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&csKeyLock); // synchronize
|
||||
{
|
||||
BOOL bKbdInt;
|
||||
|
||||
WORD wOldIn = Chipset.in; // save old Chipset.in state
|
||||
|
||||
UpdateKdnBit(); // update KDN bit
|
||||
Chipset.dwKdnCycles = (DWORD) (Chipset.cycles & 0xFFFFFFFF);
|
||||
|
||||
Chipset.in = Keyboard_GetIR(); // update Chipset.in register
|
||||
Chipset.in |= Chipset.IR15X; // add ON key
|
||||
|
||||
// interrupt for any new pressed keys?
|
||||
bKbdInt = (Chipset.in && (wOldIn & 0x1FF) == 0) || Chipset.IR15X || bReset;
|
||||
|
||||
// update keyboard interrupt pending flag when 1ms keyboard scan is disabled
|
||||
Chipset.intd = Chipset.intd || (bKbdInt && !Chipset.intk);
|
||||
|
||||
// keyboard interrupt enabled?
|
||||
bKbdInt = bKbdInt && Chipset.intk;
|
||||
|
||||
// interrupt at ON key pressed
|
||||
bKbdInt = bKbdInt || Chipset.IR15X != 0;
|
||||
|
||||
// no interrupt if still inside interrupt service routine
|
||||
bKbdInt = bKbdInt && Chipset.inte;
|
||||
|
||||
if (Chipset.in != 0) // any key pressed
|
||||
{
|
||||
if (bKbdInt) // interrupt enabled
|
||||
{
|
||||
Chipset.SoftInt = TRUE; // interrupt request
|
||||
bInterrupt = TRUE; // exit emulation loop
|
||||
}
|
||||
|
||||
if (Chipset.Shutdn) // cpu sleeping
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Chipset.intd = FALSE; // no keyboard interrupt pending
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&csKeyLock);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
VOID KeyboardEvent(BOOL bPress, UINT out, UINT in)
|
||||
{
|
||||
if (nState != SM_RUN) // not in running state
|
||||
return; // ignore key
|
||||
|
||||
KeyMacroRecord(bPress,out,in); // save all keyboard events
|
||||
|
||||
if (in == 0x8000) // ON key ?
|
||||
{
|
||||
Chipset.IR15X = bPress?0x8000:0x0000; // refresh special ON key flag
|
||||
}
|
||||
else
|
||||
{
|
||||
// "out" is outside Keyboard_Row
|
||||
if (out >= ARRAYSIZEOF(Chipset.Keyboard_Row)) return;
|
||||
|
||||
// in &= 0x1FF; // only IR[0:8] are wired on Clarke/Yorke chip
|
||||
|
||||
_ASSERT(out < ARRAYSIZEOF(Chipset.Keyboard_Row));
|
||||
if (bPress) // key pressed
|
||||
Chipset.Keyboard_Row[out] |= in; // set key marker in keyboard row
|
||||
else
|
||||
Chipset.Keyboard_Row[out] &= (~in); // clear key marker in keyboard row
|
||||
}
|
||||
AdjKeySpeed(); // adjust key repeat speed
|
||||
ScanKeyboard(FALSE,FALSE); // update Chipset.in register by 1ms keyboard poll
|
||||
Sleep(dwKeyMinDelay); // hold key state for a definite time
|
||||
return;
|
||||
}
|
|
@ -1,337 +1,337 @@
|
|||
/*
|
||||
* Keymacro.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2004 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "resource.h"
|
||||
#include "emu48.h"
|
||||
#include "kml.h"
|
||||
|
||||
#define KEYMACROHEAD "Emu-KeyMacro" // macro signature
|
||||
|
||||
#define MIN_SPEED 0
|
||||
#define MAX_SPEED 500
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwTime; // elapsed time
|
||||
DWORD dwKeyEvent; // key code
|
||||
} KeyData;
|
||||
|
||||
INT nMacroState = MACRO_OFF;
|
||||
INT nMacroTimeout = MIN_SPEED;
|
||||
BOOL bMacroRealSpeed = TRUE;
|
||||
DWORD dwMacroMinDelay = 0; // minimum macro play key hold time in ms
|
||||
|
||||
static DWORD dwTimeRef;
|
||||
|
||||
static HANDLE hMacroFile = INVALID_HANDLE_VALUE;
|
||||
static HANDLE hEventPlay = NULL;
|
||||
static HANDLE hThreadEv = NULL;
|
||||
|
||||
static VOID InitializeOFN(LPOPENFILENAME ofn)
|
||||
{
|
||||
ZeroMemory((LPVOID)ofn, sizeof(OPENFILENAME));
|
||||
ofn->lStructSize = sizeof(OPENFILENAME);
|
||||
ofn->hwndOwner = hWnd;
|
||||
ofn->Flags = OFN_EXPLORER|OFN_HIDEREADONLY;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// thread playing keys
|
||||
//
|
||||
static DWORD WINAPI EventThread(LPVOID pParam)
|
||||
{
|
||||
DWORD dwRead = 0;
|
||||
DWORD dwData = 0,dwTime = 0;
|
||||
|
||||
while (WaitForSingleObject(hEventPlay,dwTime) == WAIT_TIMEOUT)
|
||||
{
|
||||
if (dwRead != 0) // data read
|
||||
{
|
||||
UINT nIn = (dwData >> 0) & 0xFFFF;
|
||||
UINT nOut = (dwData >> 16) & 0xFF;
|
||||
BOOL bPress = (dwData >> 24) & 0xFF;
|
||||
|
||||
PlayKey(nOut,nIn,bPress);
|
||||
}
|
||||
|
||||
dwTime = nMacroTimeout; // set default speed
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
// read next data element
|
||||
if ( !ReadFile(hMacroFile,&dwData,sizeof(dwData),&dwRead,NULL)
|
||||
|| dwRead != sizeof(dwData))
|
||||
{
|
||||
// play record empty -> quit
|
||||
PostMessage(hWnd,WM_COMMAND,ID_TOOL_MACRO_STOP,0);
|
||||
return 0; // exit on file end
|
||||
}
|
||||
|
||||
if ((dwData & 0x80000000) != 0) // time information
|
||||
{
|
||||
if (bMacroRealSpeed) // realspeed from data
|
||||
{
|
||||
dwTime = dwData & 0x7FFFFFFF;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// hold the key state the minimum macro play key hold time
|
||||
if (dwTime < dwMacroMinDelay) dwTime = dwMacroMinDelay;
|
||||
|
||||
dwTime -= dwKeyMinDelay; // remove the actual key hold time
|
||||
// set negative number to zero
|
||||
if ((dwTime & 0x80000000) != 0) dwTime = 0;
|
||||
break; // got key information
|
||||
}
|
||||
}
|
||||
return 0; // exit on stop
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
//
|
||||
// callback function for recording keys
|
||||
//
|
||||
VOID KeyMacroRecord(BOOL bPress, UINT out, UINT in)
|
||||
{
|
||||
if (nMacroState == MACRO_NEW) // save key event
|
||||
{
|
||||
KeyData Data;
|
||||
DWORD dwWritten;
|
||||
|
||||
dwWritten = GetTickCount(); // time reference
|
||||
Data.dwTime = (dwWritten - dwTimeRef);
|
||||
Data.dwTime |= 0x80000000; // set time marker
|
||||
dwTimeRef = dwWritten;
|
||||
|
||||
Data.dwKeyEvent = (bPress & 0xFF);
|
||||
Data.dwKeyEvent = (Data.dwKeyEvent << 8) | (out & 0xFF);
|
||||
Data.dwKeyEvent = (Data.dwKeyEvent << 16) | (in & 0xFFFF);
|
||||
|
||||
// save key event in file
|
||||
WriteFile(hMacroFile,&Data,sizeof(Data),&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == sizeof(Data));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for save new keyboard macro
|
||||
//
|
||||
LRESULT OnToolMacroNew(VOID)
|
||||
{
|
||||
TCHAR szMacroFile[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
DWORD dwExtensionLength,dwWritten;
|
||||
|
||||
// get filename for saving
|
||||
InitializeOFN(&ofn);
|
||||
ofn.lpstrFilter =
|
||||
_T("Keyboard Macro Files (*.MAC)\0*.MAC\0")
|
||||
_T("All Files (*.*)\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("MAC");
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = szMacroFile;
|
||||
ofn.lpstrFile[0] = 0;
|
||||
ofn.nMaxFile = ARRAYSIZEOF(szMacroFile);
|
||||
ofn.Flags |= OFN_CREATEPROMPT|OFN_OVERWRITEPROMPT;
|
||||
if (GetSaveFileName(&ofn) == FALSE) return 0;
|
||||
|
||||
// open file for writing
|
||||
hMacroFile = CreateFile(szMacroFile,
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (hMacroFile == INVALID_HANDLE_VALUE) return 0;
|
||||
|
||||
// write header
|
||||
WriteFile(hMacroFile,KEYMACROHEAD,sizeof(KEYMACROHEAD) - 1,&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == (DWORD) strlen(KEYMACROHEAD));
|
||||
|
||||
// write extension length
|
||||
dwExtensionLength = 0; // no extension
|
||||
WriteFile(hMacroFile,&dwExtensionLength,sizeof(dwExtensionLength),&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == sizeof(dwExtensionLength));
|
||||
|
||||
nMacroState = MACRO_NEW;
|
||||
|
||||
MessageBox(hWnd,
|
||||
_T("Press OK to begin to record the Macro."),
|
||||
_T("Macro Recorder"),
|
||||
MB_OK|MB_ICONINFORMATION);
|
||||
|
||||
dwTimeRef = GetTickCount(); // time reference
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for play keyboard macro
|
||||
//
|
||||
LRESULT OnToolMacroPlay(VOID)
|
||||
{
|
||||
BYTE byHeader[sizeof(KEYMACROHEAD)-1];
|
||||
TCHAR szMacroFile[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
DWORD dwExtensionLength,dwRead,dwThreadId;
|
||||
|
||||
InitializeOFN(&ofn);
|
||||
ofn.lpstrFilter =
|
||||
_T("Keyboard Macro Files (*.MAC)\0*.MAC\0")
|
||||
_T("All Files (*.*)\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("MAC");
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = szMacroFile;
|
||||
ofn.lpstrFile[0] = 0;
|
||||
ofn.nMaxFile = ARRAYSIZEOF(szMacroFile);
|
||||
ofn.Flags |= OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST;
|
||||
if (GetOpenFileName(&ofn) == FALSE) return 0;
|
||||
|
||||
// open file for Reading
|
||||
hMacroFile = CreateFile(szMacroFile,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (hMacroFile == INVALID_HANDLE_VALUE) return 0;
|
||||
|
||||
// read header
|
||||
ReadFile(hMacroFile,byHeader,sizeof(byHeader),&dwRead,NULL);
|
||||
if ( dwRead != sizeof(byHeader)
|
||||
|| memcmp(byHeader,KEYMACROHEAD,dwRead) != 0)
|
||||
{
|
||||
MessageBox(hWnd,
|
||||
_T("Wrong keyboard macro file format."),
|
||||
_T("Macro Recorder"),
|
||||
MB_OK|MB_ICONSTOP);
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read extension length
|
||||
ReadFile(hMacroFile,&dwExtensionLength,sizeof(dwExtensionLength),&dwRead,NULL);
|
||||
if (dwRead != sizeof(dwExtensionLength))
|
||||
{
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read extension
|
||||
while (dwExtensionLength-- > 0)
|
||||
{
|
||||
BYTE byData;
|
||||
|
||||
ReadFile(hMacroFile,&byData,sizeof(byData),&dwRead,NULL);
|
||||
if (dwRead != sizeof(byData))
|
||||
{
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// event for quit playing
|
||||
hEventPlay = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
nMacroState = MACRO_PLAY;
|
||||
|
||||
// start playing thread
|
||||
VERIFY(hThreadEv = CreateThread(NULL,0,&EventThread,NULL,0,&dwThreadId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for stop recording/playing
|
||||
//
|
||||
LRESULT OnToolMacroStop(VOID)
|
||||
{
|
||||
if (nMacroState != MACRO_OFF)
|
||||
{
|
||||
if (hEventPlay) // playing keys
|
||||
{
|
||||
// stop playing thread
|
||||
SetEvent(hEventPlay); // quit play loop
|
||||
|
||||
WaitForSingleObject(hThreadEv,INFINITE);
|
||||
CloseHandle(hThreadEv);
|
||||
hThreadEv = NULL;
|
||||
|
||||
CloseHandle(hEventPlay); // close playing keys event
|
||||
hEventPlay = NULL;
|
||||
}
|
||||
|
||||
// macro file open
|
||||
if (hMacroFile != INVALID_HANDLE_VALUE) CloseHandle(hMacroFile);
|
||||
|
||||
nMacroState = MACRO_OFF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// activate/deactivate slider
|
||||
//
|
||||
static VOID SliderEnable(HWND hDlg,BOOL bEnable)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_SLOW),bEnable);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_FAST),bEnable);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_SLIDER),bEnable);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Macro settings dialog
|
||||
//
|
||||
static INT_PTR CALLBACK MacroProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// set slider
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETRANGE,FALSE,MAKELONG(0,MAX_SPEED-MIN_SPEED));
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETTICFREQ,MAX_SPEED/10,0);
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETPOS,TRUE,MAX_SPEED-nMacroTimeout);
|
||||
|
||||
// set button
|
||||
CheckDlgButton(hDlg,bMacroRealSpeed ? IDC_MACRO_REAL : IDC_MACRO_MANUAL,BST_CHECKED);
|
||||
SliderEnable(hDlg,!bMacroRealSpeed);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_MACRO_REAL:
|
||||
SliderEnable(hDlg,FALSE);
|
||||
return TRUE;
|
||||
case IDC_MACRO_MANUAL:
|
||||
SliderEnable(hDlg,TRUE);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
// get macro data
|
||||
nMacroTimeout = MAX_SPEED - (INT) SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_GETPOS,0,0);
|
||||
bMacroRealSpeed = IsDlgButtonChecked(hDlg,IDC_MACRO_REAL);
|
||||
// no break
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
}
|
||||
|
||||
LRESULT OnToolMacroSettings(VOID)
|
||||
{
|
||||
if (DialogBox(hApp, MAKEINTRESOURCE(IDD_MACROSET), hWnd, (DLGPROC)MacroProc) == -1)
|
||||
AbortMessage(_T("Macro Dialog Box Creation Error !"));
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Keymacro.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2004 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "resource.h"
|
||||
#include "Emu48.h"
|
||||
#include "kml.h"
|
||||
|
||||
#define KEYMACROHEAD "Emu-KeyMacro" // macro signature
|
||||
|
||||
#define MIN_SPEED 0
|
||||
#define MAX_SPEED 500
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwTime; // elapsed time
|
||||
DWORD dwKeyEvent; // key code
|
||||
} KeyData;
|
||||
|
||||
INT nMacroState = MACRO_OFF;
|
||||
INT nMacroTimeout = MIN_SPEED;
|
||||
BOOL bMacroRealSpeed = TRUE;
|
||||
DWORD dwMacroMinDelay = 0; // minimum macro play key hold time in ms
|
||||
|
||||
static DWORD dwTimeRef;
|
||||
|
||||
static HANDLE hMacroFile = INVALID_HANDLE_VALUE;
|
||||
static HANDLE hEventPlay = NULL;
|
||||
static HANDLE hThreadEv = NULL;
|
||||
|
||||
static VOID InitializeOFN(LPOPENFILENAME ofn)
|
||||
{
|
||||
ZeroMemory((LPVOID)ofn, sizeof(OPENFILENAME));
|
||||
ofn->lStructSize = sizeof(OPENFILENAME);
|
||||
ofn->hwndOwner = hWnd;
|
||||
ofn->Flags = OFN_EXPLORER|OFN_HIDEREADONLY;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// thread playing keys
|
||||
//
|
||||
static DWORD WINAPI EventThread(LPVOID pParam)
|
||||
{
|
||||
DWORD dwRead = 0;
|
||||
DWORD dwData = 0,dwTime = 0;
|
||||
|
||||
while (WaitForSingleObject(hEventPlay,dwTime) == WAIT_TIMEOUT)
|
||||
{
|
||||
if (dwRead != 0) // data read
|
||||
{
|
||||
UINT nIn = (dwData >> 0) & 0xFFFF;
|
||||
UINT nOut = (dwData >> 16) & 0xFF;
|
||||
BOOL bPress = (dwData >> 24) & 0xFF;
|
||||
|
||||
PlayKey(nOut,nIn,bPress);
|
||||
}
|
||||
|
||||
dwTime = nMacroTimeout; // set default speed
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
// read next data element
|
||||
if ( !ReadFile(hMacroFile,&dwData,sizeof(dwData),&dwRead,NULL)
|
||||
|| dwRead != sizeof(dwData))
|
||||
{
|
||||
// play record empty -> quit
|
||||
PostMessage(hWnd,WM_COMMAND,ID_TOOL_MACRO_STOP,0);
|
||||
return 0; // exit on file end
|
||||
}
|
||||
|
||||
if ((dwData & 0x80000000) != 0) // time information
|
||||
{
|
||||
if (bMacroRealSpeed) // realspeed from data
|
||||
{
|
||||
dwTime = dwData & 0x7FFFFFFF;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// hold the key state the minimum macro play key hold time
|
||||
if (dwTime < dwMacroMinDelay) dwTime = dwMacroMinDelay;
|
||||
|
||||
dwTime -= dwKeyMinDelay; // remove the actual key hold time
|
||||
// set negative number to zero
|
||||
if ((dwTime & 0x80000000) != 0) dwTime = 0;
|
||||
break; // got key information
|
||||
}
|
||||
}
|
||||
return 0; // exit on stop
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
//
|
||||
// callback function for recording keys
|
||||
//
|
||||
VOID KeyMacroRecord(BOOL bPress, UINT out, UINT in)
|
||||
{
|
||||
if (nMacroState == MACRO_NEW) // save key event
|
||||
{
|
||||
KeyData Data;
|
||||
DWORD dwWritten;
|
||||
|
||||
dwWritten = GetTickCount(); // time reference
|
||||
Data.dwTime = (dwWritten - dwTimeRef);
|
||||
Data.dwTime |= 0x80000000; // set time marker
|
||||
dwTimeRef = dwWritten;
|
||||
|
||||
Data.dwKeyEvent = (bPress & 0xFF);
|
||||
Data.dwKeyEvent = (Data.dwKeyEvent << 8) | (out & 0xFF);
|
||||
Data.dwKeyEvent = (Data.dwKeyEvent << 16) | (in & 0xFFFF);
|
||||
|
||||
// save key event in file
|
||||
WriteFile(hMacroFile,&Data,sizeof(Data),&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == sizeof(Data));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for save new keyboard macro
|
||||
//
|
||||
LRESULT OnToolMacroNew(VOID)
|
||||
{
|
||||
TCHAR szMacroFile[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
DWORD dwExtensionLength,dwWritten;
|
||||
|
||||
// get filename for saving
|
||||
InitializeOFN(&ofn);
|
||||
ofn.lpstrFilter =
|
||||
_T("Keyboard Macro Files (*.MAC)\0*.MAC\0")
|
||||
_T("All Files (*.*)\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("MAC");
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = szMacroFile;
|
||||
ofn.lpstrFile[0] = 0;
|
||||
ofn.nMaxFile = ARRAYSIZEOF(szMacroFile);
|
||||
ofn.Flags |= OFN_CREATEPROMPT|OFN_OVERWRITEPROMPT;
|
||||
if (GetSaveFileName(&ofn) == FALSE) return 0;
|
||||
|
||||
// open file for writing
|
||||
hMacroFile = CreateFile(szMacroFile,
|
||||
GENERIC_READ|GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (hMacroFile == INVALID_HANDLE_VALUE) return 0;
|
||||
|
||||
// write header
|
||||
WriteFile(hMacroFile,KEYMACROHEAD,sizeof(KEYMACROHEAD) - 1,&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == (DWORD) strlen(KEYMACROHEAD));
|
||||
|
||||
// write extension length
|
||||
dwExtensionLength = 0; // no extension
|
||||
WriteFile(hMacroFile,&dwExtensionLength,sizeof(dwExtensionLength),&dwWritten,NULL);
|
||||
_ASSERT(dwWritten == sizeof(dwExtensionLength));
|
||||
|
||||
nMacroState = MACRO_NEW;
|
||||
|
||||
MessageBox(hWnd,
|
||||
_T("Press OK to begin to record the Macro."),
|
||||
_T("Macro Recorder"),
|
||||
MB_OK|MB_ICONINFORMATION);
|
||||
|
||||
dwTimeRef = GetTickCount(); // time reference
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for play keyboard macro
|
||||
//
|
||||
LRESULT OnToolMacroPlay(VOID)
|
||||
{
|
||||
BYTE byHeader[sizeof(KEYMACROHEAD)-1];
|
||||
TCHAR szMacroFile[MAX_PATH];
|
||||
OPENFILENAME ofn;
|
||||
DWORD dwExtensionLength,dwRead,dwThreadId;
|
||||
|
||||
InitializeOFN(&ofn);
|
||||
ofn.lpstrFilter =
|
||||
_T("Keyboard Macro Files (*.MAC)\0*.MAC\0")
|
||||
_T("All Files (*.*)\0*.*\0");
|
||||
ofn.lpstrDefExt = _T("MAC");
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFile = szMacroFile;
|
||||
ofn.lpstrFile[0] = 0;
|
||||
ofn.nMaxFile = ARRAYSIZEOF(szMacroFile);
|
||||
ofn.Flags |= OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST;
|
||||
if (GetOpenFileName(&ofn) == FALSE) return 0;
|
||||
|
||||
// open file for Reading
|
||||
hMacroFile = CreateFile(szMacroFile,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (hMacroFile == INVALID_HANDLE_VALUE) return 0;
|
||||
|
||||
// read header
|
||||
ReadFile(hMacroFile,byHeader,sizeof(byHeader),&dwRead,NULL);
|
||||
if ( dwRead != sizeof(byHeader)
|
||||
|| memcmp(byHeader,KEYMACROHEAD,dwRead) != 0)
|
||||
{
|
||||
MessageBox(hWnd,
|
||||
_T("Wrong keyboard macro file format."),
|
||||
_T("Macro Recorder"),
|
||||
MB_OK|MB_ICONSTOP);
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read extension length
|
||||
ReadFile(hMacroFile,&dwExtensionLength,sizeof(dwExtensionLength),&dwRead,NULL);
|
||||
if (dwRead != sizeof(dwExtensionLength))
|
||||
{
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read extension
|
||||
while (dwExtensionLength-- > 0)
|
||||
{
|
||||
BYTE byData;
|
||||
|
||||
ReadFile(hMacroFile,&byData,sizeof(byData),&dwRead,NULL);
|
||||
if (dwRead != sizeof(byData))
|
||||
{
|
||||
CloseHandle(hMacroFile);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// event for quit playing
|
||||
hEventPlay = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
nMacroState = MACRO_PLAY;
|
||||
|
||||
// start playing thread
|
||||
VERIFY(hThreadEv = CreateThread(NULL,0,&EventThread,NULL,0,&dwThreadId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// message handler for stop recording/playing
|
||||
//
|
||||
LRESULT OnToolMacroStop(VOID)
|
||||
{
|
||||
if (nMacroState != MACRO_OFF)
|
||||
{
|
||||
if (hEventPlay) // playing keys
|
||||
{
|
||||
// stop playing thread
|
||||
SetEvent(hEventPlay); // quit play loop
|
||||
|
||||
WaitForSingleObject(hThreadEv,INFINITE);
|
||||
CloseHandle(hThreadEv);
|
||||
hThreadEv = NULL;
|
||||
|
||||
CloseHandle(hEventPlay); // close playing keys event
|
||||
hEventPlay = NULL;
|
||||
}
|
||||
|
||||
// macro file open
|
||||
if (hMacroFile != INVALID_HANDLE_VALUE) CloseHandle(hMacroFile);
|
||||
|
||||
nMacroState = MACRO_OFF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// activate/deactivate slider
|
||||
//
|
||||
static VOID SliderEnable(HWND hDlg,BOOL bEnable)
|
||||
{
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_SLOW),bEnable);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_FAST),bEnable);
|
||||
EnableWindow(GetDlgItem(hDlg,IDC_MACRO_SLIDER),bEnable);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Macro settings dialog
|
||||
//
|
||||
static INT_PTR CALLBACK MacroProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// set slider
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETRANGE,FALSE,MAKELONG(0,MAX_SPEED-MIN_SPEED));
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETTICFREQ,MAX_SPEED/10,0);
|
||||
SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_SETPOS,TRUE,MAX_SPEED-nMacroTimeout);
|
||||
|
||||
// set button
|
||||
CheckDlgButton(hDlg,bMacroRealSpeed ? IDC_MACRO_REAL : IDC_MACRO_MANUAL,BST_CHECKED);
|
||||
SliderEnable(hDlg,!bMacroRealSpeed);
|
||||
return TRUE;
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_MACRO_REAL:
|
||||
SliderEnable(hDlg,FALSE);
|
||||
return TRUE;
|
||||
case IDC_MACRO_MANUAL:
|
||||
SliderEnable(hDlg,TRUE);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
// get macro data
|
||||
nMacroTimeout = MAX_SPEED - (INT) SendDlgItemMessage(hDlg,IDC_MACRO_SLIDER,TBM_GETPOS,0,0);
|
||||
bMacroRealSpeed = IsDlgButtonChecked(hDlg,IDC_MACRO_REAL);
|
||||
// no break
|
||||
case IDCANCEL:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
}
|
||||
|
||||
LRESULT OnToolMacroSettings(VOID)
|
||||
{
|
||||
if (DialogBox(hApp, MAKEINTRESOURCE(IDD_MACROSET), hWnd, (DLGPROC)MacroProc) == -1)
|
||||
AbortMessage(_T("Macro Dialog Box Creation Error !"));
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,133 +1,133 @@
|
|||
/*
|
||||
* kml.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
#define LEX_BLOCK 0
|
||||
#define LEX_COMMAND 1
|
||||
#define LEX_PARAM 2
|
||||
|
||||
typedef enum eTokenId
|
||||
{
|
||||
TOK_NONE, //0
|
||||
TOK_ANNUNCIATOR, //1
|
||||
TOK_BACKGROUND, //2
|
||||
TOK_IFPRESSED, //3
|
||||
TOK_RESETFLAG, //4
|
||||
TOK_SCANCODE, //5
|
||||
TOK_HARDWARE, //6
|
||||
TOK_MENUITEM, //7
|
||||
TOK_SYSITEM, //8
|
||||
TOK_INTEGER, //9
|
||||
TOK_SETFLAG, //10
|
||||
TOK_RELEASE, //11
|
||||
TOK_VIRTUAL, //12
|
||||
TOK_INCLUDE, //13
|
||||
TOK_NOTFLAG, //14
|
||||
TOK_STRING, //15
|
||||
TOK_GLOBAL, //16
|
||||
TOK_AUTHOR, //17
|
||||
TOK_BITMAP, //18
|
||||
TOK_ZOOMXY, //19
|
||||
TOK_OFFSET, //20
|
||||
TOK_BUTTON, //21
|
||||
TOK_IFFLAG, //22
|
||||
TOK_ONDOWN, //23
|
||||
TOK_NOHOLD, //24
|
||||
TOK_LOCALE, //25
|
||||
TOK_TOPBAR, //26
|
||||
TOK_MENUBAR, //27
|
||||
TOK_TITLE, //28
|
||||
TOK_OUTIN, //29
|
||||
TOK_PATCH, //30
|
||||
TOK_PRINT, //31
|
||||
TOK_DEBUG, //32
|
||||
TOK_COLOR, //33
|
||||
TOK_MODEL, //34
|
||||
TOK_CLASS, //35
|
||||
TOK_PRESS, //36
|
||||
TOK_IFMEM, //37
|
||||
TOK_SCALE, //38
|
||||
TOK_TYPE, //39
|
||||
TOK_SIZE, //40
|
||||
TOK_DOWN, //41
|
||||
TOK_ZOOM, //42
|
||||
TOK_ELSE, //43
|
||||
TOK_ONUP, //44
|
||||
TOK_ICON, //45
|
||||
TOK_EOL, //46
|
||||
TOK_MAP, //47
|
||||
TOK_ROM, //48
|
||||
TOK_VGA, //49
|
||||
TOK_LCD, //50
|
||||
TOK_END //51
|
||||
} TokenId;
|
||||
|
||||
#define TYPE_NONE 00
|
||||
#define TYPE_INTEGER 01
|
||||
#define TYPE_STRING 02
|
||||
|
||||
typedef struct KmlToken
|
||||
{
|
||||
TokenId eId;
|
||||
DWORD nParams;
|
||||
DWORD nLen;
|
||||
LPCTSTR szName;
|
||||
} KmlToken;
|
||||
|
||||
typedef struct KmlLine
|
||||
{
|
||||
struct KmlLine* pNext;
|
||||
TokenId eCommand;
|
||||
DWORD_PTR nParam[6];
|
||||
} KmlLine;
|
||||
|
||||
typedef struct KmlBlock
|
||||
{
|
||||
TokenId eType;
|
||||
DWORD nId;
|
||||
struct KmlLine* pFirstLine;
|
||||
struct KmlBlock* pNext;
|
||||
} KmlBlock;
|
||||
|
||||
#define BUTTON_NOHOLD 0x0001
|
||||
#define BUTTON_VIRTUAL 0x0002
|
||||
typedef struct KmlButton
|
||||
{
|
||||
UINT nId;
|
||||
BOOL bDown;
|
||||
UINT nType;
|
||||
DWORD dwFlags;
|
||||
UINT nOx, nOy;
|
||||
UINT nDx, nDy;
|
||||
UINT nCx, nCy;
|
||||
UINT nOut, nIn;
|
||||
KmlLine* pOnDown;
|
||||
KmlLine* pOnUp;
|
||||
} KmlButton;
|
||||
|
||||
typedef struct KmlAnnunciator
|
||||
{
|
||||
UINT nOx, nOy;
|
||||
UINT nDx, nDy;
|
||||
UINT nCx, nCy;
|
||||
} KmlAnnunciator;
|
||||
|
||||
extern KmlBlock* pKml;
|
||||
extern BOOL DisplayChooseKml(CHAR cType);
|
||||
extern VOID FreeBlocks(KmlBlock* pBlock);
|
||||
extern VOID DrawAnnunciator(UINT nId, BOOL bOn);
|
||||
extern VOID ReloadButtons(BYTE *Keyboard_Row, UINT nSize);
|
||||
extern VOID RefreshButtons(RECT *rc);
|
||||
extern BOOL MouseIsButton(DWORD x, DWORD y);
|
||||
extern VOID MouseButtonDownAt(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID MouseButtonUpAt(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID MouseMovesTo(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID RunKey(BYTE nId, BOOL bPressed);
|
||||
extern VOID PlayKey(UINT nOut, UINT nIn, BOOL bPressed);
|
||||
extern BOOL InitKML(LPCTSTR szFilename, BOOL bNoLog);
|
||||
extern VOID KillKML(VOID);
|
||||
/*
|
||||
* kml.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
#define LEX_BLOCK 0
|
||||
#define LEX_COMMAND 1
|
||||
#define LEX_PARAM 2
|
||||
|
||||
typedef enum eTokenId
|
||||
{
|
||||
TOK_NONE, //0
|
||||
TOK_ANNUNCIATOR, //1
|
||||
TOK_BACKGROUND, //2
|
||||
TOK_IFPRESSED, //3
|
||||
TOK_RESETFLAG, //4
|
||||
TOK_SCANCODE, //5
|
||||
TOK_HARDWARE, //6
|
||||
TOK_MENUITEM, //7
|
||||
TOK_SYSITEM, //8
|
||||
TOK_INTEGER, //9
|
||||
TOK_SETFLAG, //10
|
||||
TOK_RELEASE, //11
|
||||
TOK_VIRTUAL, //12
|
||||
TOK_INCLUDE, //13
|
||||
TOK_NOTFLAG, //14
|
||||
TOK_STRING, //15
|
||||
TOK_GLOBAL, //16
|
||||
TOK_AUTHOR, //17
|
||||
TOK_BITMAP, //18
|
||||
TOK_ZOOMXY, //19
|
||||
TOK_OFFSET, //20
|
||||
TOK_BUTTON, //21
|
||||
TOK_IFFLAG, //22
|
||||
TOK_ONDOWN, //23
|
||||
TOK_NOHOLD, //24
|
||||
TOK_LOCALE, //25
|
||||
TOK_TOPBAR, //26
|
||||
TOK_MENUBAR, //27
|
||||
TOK_TITLE, //28
|
||||
TOK_OUTIN, //29
|
||||
TOK_PATCH, //30
|
||||
TOK_PRINT, //31
|
||||
TOK_DEBUG, //32
|
||||
TOK_COLOR, //33
|
||||
TOK_MODEL, //34
|
||||
TOK_CLASS, //35
|
||||
TOK_PRESS, //36
|
||||
TOK_IFMEM, //37
|
||||
TOK_SCALE, //38
|
||||
TOK_TYPE, //39
|
||||
TOK_SIZE, //40
|
||||
TOK_DOWN, //41
|
||||
TOK_ZOOM, //42
|
||||
TOK_ELSE, //43
|
||||
TOK_ONUP, //44
|
||||
TOK_ICON, //45
|
||||
TOK_EOL, //46
|
||||
TOK_MAP, //47
|
||||
TOK_ROM, //48
|
||||
TOK_VGA, //49
|
||||
TOK_LCD, //50
|
||||
TOK_END //51
|
||||
} TokenId;
|
||||
|
||||
#define TYPE_NONE 00
|
||||
#define TYPE_INTEGER 01
|
||||
#define TYPE_STRING 02
|
||||
|
||||
typedef struct KmlToken
|
||||
{
|
||||
TokenId eId;
|
||||
DWORD nParams;
|
||||
DWORD nLen;
|
||||
LPCTSTR szName;
|
||||
} KmlToken;
|
||||
|
||||
typedef struct KmlLine
|
||||
{
|
||||
struct KmlLine* pNext;
|
||||
TokenId eCommand;
|
||||
DWORD_PTR nParam[6];
|
||||
} KmlLine;
|
||||
|
||||
typedef struct KmlBlock
|
||||
{
|
||||
TokenId eType;
|
||||
DWORD nId;
|
||||
struct KmlLine* pFirstLine;
|
||||
struct KmlBlock* pNext;
|
||||
} KmlBlock;
|
||||
|
||||
#define BUTTON_NOHOLD 0x0001
|
||||
#define BUTTON_VIRTUAL 0x0002
|
||||
typedef struct KmlButton
|
||||
{
|
||||
UINT nId;
|
||||
BOOL bDown;
|
||||
UINT nType;
|
||||
DWORD dwFlags;
|
||||
UINT nOx, nOy;
|
||||
UINT nDx, nDy;
|
||||
UINT nCx, nCy;
|
||||
UINT nOut, nIn;
|
||||
KmlLine* pOnDown;
|
||||
KmlLine* pOnUp;
|
||||
} KmlButton;
|
||||
|
||||
typedef struct KmlAnnunciator
|
||||
{
|
||||
UINT nOx, nOy;
|
||||
UINT nDx, nDy;
|
||||
UINT nCx, nCy;
|
||||
} KmlAnnunciator;
|
||||
|
||||
extern KmlBlock* pKml;
|
||||
extern BOOL DisplayChooseKml(CHAR cType);
|
||||
extern VOID FreeBlocks(KmlBlock* pBlock);
|
||||
extern VOID DrawAnnunciator(UINT nId, BOOL bOn);
|
||||
extern VOID ReloadButtons(BYTE *Keyboard_Row, UINT nSize);
|
||||
extern VOID RefreshButtons(RECT *rc);
|
||||
extern BOOL MouseIsButton(DWORD x, DWORD y);
|
||||
extern VOID MouseButtonDownAt(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID MouseButtonUpAt(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID MouseMovesTo(UINT nFlags, DWORD x, DWORD y);
|
||||
extern VOID RunKey(BYTE nId, BOOL bPressed);
|
||||
extern VOID PlayKey(UINT nOut, UINT nIn, BOOL bPressed);
|
||||
extern BOOL InitKML(LPCTSTR szFilename, BOOL bNoLog);
|
||||
extern VOID KillKML(VOID);
|
|
@ -664,7 +664,7 @@ which is possible in case of only 0 or 1 present symbols. */
|
|||
static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
|
||||
static const unsigned headsize = 1u << FIRSTBITS; /*size of the first table*/
|
||||
static const unsigned mask = (1u << FIRSTBITS) /*headsize*/ - 1u;
|
||||
unsigned i, numpresent, pointer, size; /*total table size*/
|
||||
size_t i, numpresent, pointer, size; /*total table size*/
|
||||
unsigned* maxlens = (unsigned*)lodepng_malloc(headsize * sizeof(unsigned));
|
||||
if(!maxlens) return 83; /*alloc fail*/
|
||||
|
||||
|
@ -683,7 +683,7 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
|
|||
size = headsize;
|
||||
for(i = 0; i < headsize; ++i) {
|
||||
unsigned l = maxlens[i];
|
||||
if(l > FIRSTBITS) size += (1u << (l - FIRSTBITS));
|
||||
if(l > FIRSTBITS) size += (((size_t)1) << (l - FIRSTBITS));
|
||||
}
|
||||
tree->table_len = (unsigned char*)lodepng_malloc(size * sizeof(*tree->table_len));
|
||||
tree->table_value = (unsigned short*)lodepng_malloc(size * sizeof(*tree->table_value));
|
||||
|
@ -701,8 +701,8 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
|
|||
unsigned l = maxlens[i];
|
||||
if(l <= FIRSTBITS) continue;
|
||||
tree->table_len[i] = l;
|
||||
tree->table_value[i] = pointer;
|
||||
pointer += (1u << (l - FIRSTBITS));
|
||||
tree->table_value[i] = (unsigned short)pointer;
|
||||
pointer += (((size_t)1) << (l - FIRSTBITS));
|
||||
}
|
||||
lodepng_free(maxlens);
|
||||
|
||||
|
@ -726,7 +726,7 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
|
|||
unsigned index = reverse | (j << l);
|
||||
if(tree->table_len[index] != 16) return 55; /*invalid tree: long symbol shares prefix with short symbol*/
|
||||
tree->table_len[index] = l;
|
||||
tree->table_value[index] = i;
|
||||
tree->table_value[index] = (unsigned short)i;
|
||||
}
|
||||
} else {
|
||||
/*long symbol, shares prefix with other long symbols in first lookup table, needs second lookup*/
|
||||
|
@ -743,7 +743,7 @@ static unsigned HuffmanTree_makeTable(HuffmanTree* tree) {
|
|||
unsigned reverse2 = reverse >> FIRSTBITS; /* l - FIRSTBITS bits */
|
||||
unsigned index2 = start + (reverse2 | (j << (l - FIRSTBITS)));
|
||||
tree->table_len[index2] = l;
|
||||
tree->table_value[index2] = i;
|
||||
tree->table_value[index2] = (unsigned short)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2886,7 +2886,7 @@ static unsigned lodepng_chunk_createv(ucvector* out,
|
|||
}
|
||||
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outsize,
|
||||
unsigned length, const char* type, const unsigned char* data) {
|
||||
size_t length, const char* type, const unsigned char* data) {
|
||||
ucvector v = ucvector_init(*out, *outsize);
|
||||
unsigned error = lodepng_chunk_createv(&v, length, type, data);
|
||||
*out = v.data;
|
||||
|
@ -3363,7 +3363,7 @@ unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source) {
|
|||
static void addColorBits(unsigned char* out, size_t index, unsigned bits, unsigned in) {
|
||||
unsigned m = bits == 1 ? 7 : bits == 2 ? 3 : 1; /*8 / bits - 1*/
|
||||
/*p = the partial index in the byte, e.g. with 4 palettebits it is 0 for first half or 1 for second half*/
|
||||
unsigned p = (unsigned)index & m;
|
||||
unsigned p = (unsigned) index & m;
|
||||
in &= (1u << bits) - 1u; /*filter out any other bits of the input value*/
|
||||
in = in << (bits * (m - p));
|
||||
if(p == 0) out[index * bits / 8u] = in;
|
||||
|
@ -5889,7 +5889,7 @@ static size_t ilog2i(size_t i) {
|
|||
l = ilog2(i);
|
||||
/* approximate i*log2(i): l is integer logarithm, ((i - (1u << l)) << 1u)
|
||||
linearly approximates the missing fractional part multiplied by i */
|
||||
return i * l + ((i - ((size_t) 1u << l)) << 1u);
|
||||
return i * l + ((i - (((size_t)1) << l)) << 1u);
|
||||
}
|
||||
|
||||
static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h,
|
|
@ -1001,7 +1001,7 @@ and data separately. The type is a 4-letter string.
|
|||
The out variable and outsize are updated to reflect the new reallocated buffer.
|
||||
Returne error code (0 if it went ok)
|
||||
*/
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outsize, unsigned length,
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outsize, size_t length,
|
||||
const char* type, const unsigned char* data);
|
||||
|
||||
|
|
@ -1,122 +1,122 @@
|
|||
/*
|
||||
* lowbat.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2006 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
// #define BAT_SIMULATION // switch low bat simulation
|
||||
|
||||
#define BAT_FREQ (60*1000) // bat update time in ms (real machine = 60us, HP28C = 60s)
|
||||
|
||||
BOOL bLowBatDisable = FALSE;
|
||||
|
||||
static HANDLE hCThreadBat = NULL;
|
||||
static HANDLE hEventBat;
|
||||
|
||||
static DWORD WINAPI LowBatThread(LPVOID pParam)
|
||||
{
|
||||
BOOL bLBI,bVLBI;
|
||||
|
||||
do
|
||||
{
|
||||
GetBatteryState(&bLBI,&bVLBI); // get battery state
|
||||
|
||||
// very low bat detection
|
||||
bVLBI = bVLBI && (Chipset.IORam[LPE] & EVLBI) != 0;
|
||||
|
||||
IOBit(LPD,VLBI,bVLBI); // set VLBI
|
||||
IOBit(SRQ1,VSRQ,bVLBI); // and service bit
|
||||
|
||||
if (bVLBI) // VLBI detected
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
|
||||
if (Chipset.Shutdn) // CPU shut down
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
}
|
||||
while (WaitForSingleObject(hEventBat,BAT_FREQ) == WAIT_TIMEOUT);
|
||||
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
VOID StartBatMeasure(VOID)
|
||||
{
|
||||
DWORD dwThreadId;
|
||||
|
||||
if (hCThreadBat) // Bat measuring thread running
|
||||
return; // -> quit
|
||||
|
||||
// event to cancel Bat refresh loop
|
||||
hEventBat = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
VERIFY(hCThreadBat = CreateThread(NULL,0,&LowBatThread,NULL,0,&dwThreadId));
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StopBatMeasure(VOID)
|
||||
{
|
||||
if (hCThreadBat == NULL) // thread stopped
|
||||
return; // -> quit
|
||||
|
||||
SetEvent(hEventBat); // leave Bat update thread
|
||||
WaitForSingleObject(hCThreadBat,INFINITE);
|
||||
CloseHandle(hCThreadBat);
|
||||
hCThreadBat = NULL; // set flag Bat update stopped
|
||||
CloseHandle(hEventBat); // close Bat event
|
||||
return;
|
||||
}
|
||||
|
||||
VOID GetBatteryState(BOOL *pbLBI, BOOL *pbVLBI)
|
||||
{
|
||||
#if defined BAT_SIMULATION
|
||||
switch (GetPrivateProfileInt(_T("LowBat"),_T("Level"),2,_T(".\\Lowbat.ini")))
|
||||
{
|
||||
case 0: // empty
|
||||
*pbLBI = TRUE;
|
||||
*pbVLBI = TRUE;
|
||||
break;
|
||||
case 1: // low
|
||||
*pbLBI = TRUE;
|
||||
*pbVLBI = FALSE;
|
||||
break;
|
||||
default: // full
|
||||
*pbLBI = FALSE;
|
||||
*pbVLBI = FALSE;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
SYSTEM_POWER_STATUS sSps;
|
||||
|
||||
*pbLBI = FALSE; // no battery warning
|
||||
*pbVLBI = FALSE;
|
||||
|
||||
VERIFY(GetSystemPowerStatus(&sSps));
|
||||
|
||||
// low bat emulation enabled and battery powered
|
||||
if (!bLowBatDisable && sSps.ACLineStatus == AC_LINE_OFFLINE)
|
||||
{
|
||||
// on critical battery state make sure that lowbat flag is also set
|
||||
if ((sSps.BatteryFlag & BATTERY_FLAG_CRITICAL) != 0)
|
||||
sSps.BatteryFlag |= BATTERY_FLAG_LOW;
|
||||
|
||||
// low bat detection
|
||||
*pbLBI = ((sSps.BatteryFlag & BATTERY_FLAG_LOW) != 0);
|
||||
|
||||
// very low bat detection
|
||||
*pbVLBI = ((sSps.BatteryFlag & BATTERY_FLAG_CRITICAL) != 0);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* lowbat.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2006 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
// #define BAT_SIMULATION // switch low bat simulation
|
||||
|
||||
#define BAT_FREQ (60*1000) // bat update time in ms (real machine = 60us, HP28C = 60s)
|
||||
|
||||
BOOL bLowBatDisable = FALSE;
|
||||
|
||||
static HANDLE hCThreadBat = NULL;
|
||||
static HANDLE hEventBat;
|
||||
|
||||
static DWORD WINAPI LowBatThread(LPVOID pParam)
|
||||
{
|
||||
BOOL bLBI,bVLBI;
|
||||
|
||||
do
|
||||
{
|
||||
GetBatteryState(&bLBI,&bVLBI); // get battery state
|
||||
|
||||
// very low bat detection
|
||||
bVLBI = bVLBI && (Chipset.IORam[LPE] & EVLBI) != 0;
|
||||
|
||||
IOBit(LPD,VLBI,bVLBI); // set VLBI
|
||||
IOBit(SRQ1,VSRQ,bVLBI); // and service bit
|
||||
|
||||
if (bVLBI) // VLBI detected
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
|
||||
if (Chipset.Shutdn) // CPU shut down
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
}
|
||||
while (WaitForSingleObject(hEventBat,BAT_FREQ) == WAIT_TIMEOUT);
|
||||
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
VOID StartBatMeasure(VOID)
|
||||
{
|
||||
DWORD dwThreadId;
|
||||
|
||||
if (hCThreadBat) // Bat measuring thread running
|
||||
return; // -> quit
|
||||
|
||||
// event to cancel Bat refresh loop
|
||||
hEventBat = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
VERIFY(hCThreadBat = CreateThread(NULL,0,&LowBatThread,NULL,0,&dwThreadId));
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StopBatMeasure(VOID)
|
||||
{
|
||||
if (hCThreadBat == NULL) // thread stopped
|
||||
return; // -> quit
|
||||
|
||||
SetEvent(hEventBat); // leave Bat update thread
|
||||
WaitForSingleObject(hCThreadBat,INFINITE);
|
||||
CloseHandle(hCThreadBat);
|
||||
hCThreadBat = NULL; // set flag Bat update stopped
|
||||
CloseHandle(hEventBat); // close Bat event
|
||||
return;
|
||||
}
|
||||
|
||||
VOID GetBatteryState(BOOL *pbLBI, BOOL *pbVLBI)
|
||||
{
|
||||
#if defined BAT_SIMULATION
|
||||
switch (GetPrivateProfileInt(_T("LowBat"),_T("Level"),2,_T(".\\Lowbat.ini")))
|
||||
{
|
||||
case 0: // empty
|
||||
*pbLBI = TRUE;
|
||||
*pbVLBI = TRUE;
|
||||
break;
|
||||
case 1: // low
|
||||
*pbLBI = TRUE;
|
||||
*pbVLBI = FALSE;
|
||||
break;
|
||||
default: // full
|
||||
*pbLBI = FALSE;
|
||||
*pbVLBI = FALSE;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
SYSTEM_POWER_STATUS sSps;
|
||||
|
||||
*pbLBI = FALSE; // no battery warning
|
||||
*pbVLBI = FALSE;
|
||||
|
||||
VERIFY(GetSystemPowerStatus(&sSps));
|
||||
|
||||
// low bat emulation enabled and battery powered
|
||||
if (!bLowBatDisable && sSps.ACLineStatus == AC_LINE_OFFLINE)
|
||||
{
|
||||
// on critical battery state make sure that lowbat flag is also set
|
||||
if ((sSps.BatteryFlag & BATTERY_FLAG_CRITICAL) != 0)
|
||||
sSps.BatteryFlag |= BATTERY_FLAG_LOW;
|
||||
|
||||
// low bat detection
|
||||
*pbLBI = ((sSps.BatteryFlag & BATTERY_FLAG_LOW) != 0);
|
||||
|
||||
// very low bat detection
|
||||
*pbVLBI = ((sSps.BatteryFlag & BATTERY_FLAG_CRITICAL) != 0);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,380 +1,380 @@
|
|||
/*
|
||||
* mru.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2007 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "resource.h"
|
||||
#include "emu48.h"
|
||||
|
||||
static TCHAR szOriginal[MAX_PATH] = _T("");
|
||||
|
||||
static LPTSTR *ppszFiles = NULL; // pointer to MRU table
|
||||
static UINT nEntry = 0; // no. of MRU entries
|
||||
|
||||
static BOOL GetMenuPosForId(HMENU hMenu, UINT nItem, HMENU *phMruMenu, UINT *pnMruPos)
|
||||
{
|
||||
HMENU hSubMenu;
|
||||
UINT i,nID,nMaxID;
|
||||
|
||||
nMaxID = GetMenuItemCount(hMenu);
|
||||
for (i = 0; i < nMaxID; ++i)
|
||||
{
|
||||
nID = GetMenuItemID(hMenu,i); // get ID
|
||||
|
||||
if (nID == 0) continue; // separator or invalid command
|
||||
|
||||
if (nID == (UINT)-1) // possibly a popup menu
|
||||
{
|
||||
hSubMenu = GetSubMenu(hMenu,i); // try to get handle to popup menu
|
||||
if (hSubMenu != NULL) // it's a popup menu
|
||||
{
|
||||
// recursive search
|
||||
if (GetMenuPosForId(hSubMenu,nItem,phMruMenu,pnMruPos))
|
||||
return TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nID == nItem) // found ID
|
||||
{
|
||||
*phMruMenu = hMenu; // remember menu and position
|
||||
*pnMruPos = i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL MruInit(UINT nNum)
|
||||
{
|
||||
HMENU hMenu = GetMenu(hWnd); // main menu
|
||||
if (hMenu == NULL) return FALSE; // failed, no menu bar
|
||||
|
||||
_ASSERT(ppszFiles == NULL); // MRU already initialized
|
||||
|
||||
// no. of files in MRU list
|
||||
nEntry = ReadSettingsInt(_T("MRU"),_T("FileCount"),nNum);
|
||||
|
||||
if (nEntry > 0) // allocate MRU table
|
||||
{
|
||||
// create MRU table
|
||||
if ((ppszFiles = (LPTSTR *) malloc(nEntry * sizeof(*ppszFiles))) == NULL)
|
||||
return FALSE;
|
||||
|
||||
// fill each entry
|
||||
for (nNum = 0; nNum < nEntry; ++nNum)
|
||||
ppszFiles[nNum] = NULL;
|
||||
|
||||
MruReadList(); // read actual MRU list
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID MruCleanup(VOID)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
MruWriteList(); // write actual MRU list
|
||||
|
||||
if (ppszFiles != NULL) // table defined
|
||||
{
|
||||
for (i = 0; i < nEntry; ++i) // cleanup each entry
|
||||
{
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
free(ppszFiles[i]); // cleanup entry
|
||||
}
|
||||
|
||||
free(ppszFiles); // free table
|
||||
ppszFiles = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruAdd(LPCTSTR lpszEntry)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart;
|
||||
UINT i;
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// get full path name
|
||||
GetFullPathName(lpszEntry,ARRAYSIZEOF(szFilename),szFilename,&lpFilePart);
|
||||
|
||||
// look if entry is already in table
|
||||
for (i = 0; i < nEntry; ++i)
|
||||
{
|
||||
// already in table -> quit
|
||||
if ( ppszFiles[i] != NULL // valid entry
|
||||
&& lstrcmpi(ppszFiles[i],szFilename) == 0)
|
||||
{
|
||||
MruMoveTop(i); // move to top and update menu
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
i = nEntry - 1; // last index
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
free(ppszFiles[i]); // free oldest entry
|
||||
|
||||
for (; i > 0; --i) // move old entries 1 line down
|
||||
{
|
||||
ppszFiles[i] = ppszFiles[i-1];
|
||||
}
|
||||
|
||||
// add new entry to top
|
||||
ppszFiles[0] = DuplicateString(szFilename);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruRemove(UINT nIndex)
|
||||
{
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
free(ppszFiles[nIndex]); // free entry
|
||||
|
||||
for (; nIndex < nEntry - 1; ++nIndex) // move below entries 1 line up
|
||||
{
|
||||
ppszFiles[nIndex] = ppszFiles[nIndex+1];
|
||||
}
|
||||
|
||||
ppszFiles[nIndex] = NULL; // clear last line
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruMoveTop(UINT nIndex)
|
||||
{
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
LPTSTR lpszEntry = ppszFiles[nIndex];// remember selected entry
|
||||
|
||||
for (; nIndex > 0; --nIndex) // move above entries 1 line down
|
||||
{
|
||||
ppszFiles[nIndex] = ppszFiles[nIndex-1];
|
||||
}
|
||||
|
||||
ppszFiles[0] = lpszEntry; // insert entry on top
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UINT MruEntries(VOID)
|
||||
{
|
||||
return nEntry;
|
||||
}
|
||||
|
||||
UINT MruID(LPCTSTR lpszEntry)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart;
|
||||
UINT i;
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// get full path name
|
||||
GetFullPathName(lpszEntry,ARRAYSIZEOF(szFilename),szFilename,&lpFilePart);
|
||||
|
||||
// look if entry is already in table
|
||||
for (i = 0; i < nEntry; ++i)
|
||||
{
|
||||
if ( ppszFiles[i] != NULL // valid entry
|
||||
&& lstrcmpi(ppszFiles[i],szFilename) == 0)
|
||||
{
|
||||
return i; // return ID
|
||||
}
|
||||
}
|
||||
}
|
||||
return (UINT) -1; // not found
|
||||
}
|
||||
|
||||
VOID MruFilename(UINT nIndex, LPTSTR szFilename, UINT nBuffersize)
|
||||
{
|
||||
*szFilename = 0; // not found
|
||||
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
_ASSERT(ppszFiles[nIndex] != NULL); // valid entry
|
||||
lstrcpyn(szFilename,ppszFiles[nIndex],nBuffersize);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruUpdateMenu(HMENU hMenu)
|
||||
{
|
||||
TCHAR szCurPath[MAX_PATH];
|
||||
BOOL bEmpty;
|
||||
UINT i;
|
||||
|
||||
if (hMenu != NULL) // have menu
|
||||
{
|
||||
HMENU hMruMenu; // menu handle for MRU list
|
||||
UINT nMruPos; // insert position for MRU list
|
||||
|
||||
_ASSERT(IsMenu(hMenu)); // validate menu handle
|
||||
|
||||
// search for menu position of ID_FILE_MRU_FILE1
|
||||
if (GetMenuPosForId(hMenu,ID_FILE_MRU_FILE1,&hMruMenu,&nMruPos))
|
||||
{
|
||||
if (*szOriginal == 0) // get orginal value of first MRU entry
|
||||
{
|
||||
VERIFY(GetMenuString(hMruMenu,nMruPos,szOriginal,ARRAYSIZEOF(szOriginal),MF_BYPOSITION));
|
||||
}
|
||||
|
||||
if (nEntry == 0) // kill MRU menu entry
|
||||
{
|
||||
// delete MRU menu
|
||||
DeleteMenu(hMruMenu,nMruPos,MF_BYPOSITION);
|
||||
|
||||
// delete the following separator
|
||||
_ASSERT((GetMenuState(hMruMenu,nMruPos,MF_BYPOSITION) & MF_SEPARATOR) != 0);
|
||||
DeleteMenu(hMruMenu,nMruPos,MF_BYPOSITION);
|
||||
}
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// delete all menu entries
|
||||
for (i = 0; DeleteMenu(hMenu,ID_FILE_MRU_FILE1+i,MF_BYCOMMAND) != FALSE; ++i) { }
|
||||
|
||||
// check if MRU list is empty
|
||||
for (bEmpty = TRUE, i = 0; bEmpty && i < nEntry; ++i)
|
||||
{
|
||||
bEmpty = (ppszFiles[i] == NULL);
|
||||
}
|
||||
|
||||
if (bEmpty) // MRU list is empty
|
||||
{
|
||||
// fill with orginal string
|
||||
VERIFY(InsertMenu(hMruMenu,nMruPos,MF_STRING|MF_BYPOSITION|MF_GRAYED,ID_FILE_MRU_FILE1,szOriginal));
|
||||
return;
|
||||
}
|
||||
|
||||
// current directory
|
||||
GetCurrentDirectory(ARRAYSIZEOF(szCurPath),szCurPath);
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
TCHAR szMenuname[2*MAX_PATH+3];
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart,lpszPtr;
|
||||
|
||||
// check if file path and current path is identical
|
||||
if (GetFullPathName(ppszFiles[i],ARRAYSIZEOF(szFilename),szFilename,&lpFilePart))
|
||||
{
|
||||
TCHAR szCutname[MAX_PATH];
|
||||
|
||||
*(lpFilePart-1) = 0; // devide path and name
|
||||
|
||||
// name is current directory -> use only name
|
||||
if (lstrcmpi(szCurPath,szFilename) == 0)
|
||||
{
|
||||
// short name view
|
||||
}
|
||||
else
|
||||
{
|
||||
// full name view
|
||||
lpFilePart = ppszFiles[i];
|
||||
}
|
||||
|
||||
// cut filename to fit into menu
|
||||
GetCutPathName(lpFilePart,szCutname,ARRAYSIZEOF(szCutname),36);
|
||||
lpFilePart = szCutname;
|
||||
|
||||
// adding accelerator key
|
||||
lpszPtr = szMenuname;
|
||||
*lpszPtr++ = _T('&');
|
||||
*lpszPtr++ = _T('0') + ((i + 1) % 10);
|
||||
*lpszPtr++ = _T(' ');
|
||||
|
||||
// copy file to view buffer and expand & to &&
|
||||
while (*lpFilePart != 0)
|
||||
{
|
||||
if (*lpFilePart == _T('&'))
|
||||
{
|
||||
*lpszPtr++ = *lpFilePart;
|
||||
}
|
||||
*lpszPtr++ = *lpFilePart++;
|
||||
}
|
||||
*lpszPtr = 0;
|
||||
|
||||
VERIFY(InsertMenu(hMruMenu,nMruPos+i,
|
||||
MF_STRING|MF_BYPOSITION,ID_FILE_MRU_FILE1+i,
|
||||
szMenuname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruWriteList(VOID)
|
||||
{
|
||||
TCHAR szItemname[32];
|
||||
UINT i;
|
||||
|
||||
if (nEntry > 0)
|
||||
{
|
||||
// no. of files in MRU list
|
||||
WriteSettingsInt(_T("MRU"),_T("FileCount"),nEntry);
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
_ASSERT(ppszFiles != NULL); // MRU not initialized
|
||||
wsprintf(szItemname,_T("File%d"),i+1);
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
WriteSettingsString(_T("MRU"),szItemname,ppszFiles[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DelSettingsKey(_T("MRU"),szItemname);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruReadList(VOID)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
TCHAR szItemname[32];
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
_ASSERT(ppszFiles != NULL); // MRU not initialized
|
||||
|
||||
wsprintf(szItemname,_T("File%d"),i+1);
|
||||
ReadSettingsString(_T("MRU"),szItemname,_T(""),szFilename,ARRAYSIZEOF(szFilename));
|
||||
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
free(ppszFiles[i]); // free entry
|
||||
ppszFiles[i] = NULL; // clear last line
|
||||
}
|
||||
|
||||
if (*szFilename) // read a valid entry
|
||||
{
|
||||
ppszFiles[i] = DuplicateString(szFilename);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* mru.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2007 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "resource.h"
|
||||
#include "Emu48.h"
|
||||
|
||||
static TCHAR szOriginal[MAX_PATH] = _T("");
|
||||
|
||||
static LPTSTR *ppszFiles = NULL; // pointer to MRU table
|
||||
static UINT nEntry = 0; // no. of MRU entries
|
||||
|
||||
static BOOL GetMenuPosForId(HMENU hMenu, UINT nItem, HMENU *phMruMenu, UINT *pnMruPos)
|
||||
{
|
||||
HMENU hSubMenu;
|
||||
UINT i,nID,nMaxID;
|
||||
|
||||
nMaxID = GetMenuItemCount(hMenu);
|
||||
for (i = 0; i < nMaxID; ++i)
|
||||
{
|
||||
nID = GetMenuItemID(hMenu,i); // get ID
|
||||
|
||||
if (nID == 0) continue; // separator or invalid command
|
||||
|
||||
if (nID == (UINT)-1) // possibly a popup menu
|
||||
{
|
||||
hSubMenu = GetSubMenu(hMenu,i); // try to get handle to popup menu
|
||||
if (hSubMenu != NULL) // it's a popup menu
|
||||
{
|
||||
// recursive search
|
||||
if (GetMenuPosForId(hSubMenu,nItem,phMruMenu,pnMruPos))
|
||||
return TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nID == nItem) // found ID
|
||||
{
|
||||
*phMruMenu = hMenu; // remember menu and position
|
||||
*pnMruPos = i;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL MruInit(UINT nNum)
|
||||
{
|
||||
HMENU hMenu = GetMenu(hWnd); // main menu
|
||||
if (hMenu == NULL) return FALSE; // failed, no menu bar
|
||||
|
||||
_ASSERT(ppszFiles == NULL); // MRU already initialized
|
||||
|
||||
// no. of files in MRU list
|
||||
nEntry = ReadSettingsInt(_T("MRU"),_T("FileCount"),nNum);
|
||||
|
||||
if (nEntry > 0) // allocate MRU table
|
||||
{
|
||||
// create MRU table
|
||||
if ((ppszFiles = (LPTSTR *) malloc(nEntry * sizeof(*ppszFiles))) == NULL)
|
||||
return FALSE;
|
||||
|
||||
// fill each entry
|
||||
for (nNum = 0; nNum < nEntry; ++nNum)
|
||||
ppszFiles[nNum] = NULL;
|
||||
|
||||
MruReadList(); // read actual MRU list
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID MruCleanup(VOID)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
MruWriteList(); // write actual MRU list
|
||||
|
||||
if (ppszFiles != NULL) // table defined
|
||||
{
|
||||
for (i = 0; i < nEntry; ++i) // cleanup each entry
|
||||
{
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
free(ppszFiles[i]); // cleanup entry
|
||||
}
|
||||
|
||||
free(ppszFiles); // free table
|
||||
ppszFiles = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruAdd(LPCTSTR lpszEntry)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart;
|
||||
UINT i;
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// get full path name
|
||||
GetFullPathName(lpszEntry,ARRAYSIZEOF(szFilename),szFilename,&lpFilePart);
|
||||
|
||||
// look if entry is already in table
|
||||
for (i = 0; i < nEntry; ++i)
|
||||
{
|
||||
// already in table -> quit
|
||||
if ( ppszFiles[i] != NULL // valid entry
|
||||
&& lstrcmpi(ppszFiles[i],szFilename) == 0)
|
||||
{
|
||||
MruMoveTop(i); // move to top and update menu
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
i = nEntry - 1; // last index
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
free(ppszFiles[i]); // free oldest entry
|
||||
|
||||
for (; i > 0; --i) // move old entries 1 line down
|
||||
{
|
||||
ppszFiles[i] = ppszFiles[i-1];
|
||||
}
|
||||
|
||||
// add new entry to top
|
||||
ppszFiles[0] = DuplicateString(szFilename);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruRemove(UINT nIndex)
|
||||
{
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
free(ppszFiles[nIndex]); // free entry
|
||||
|
||||
for (; nIndex < nEntry - 1; ++nIndex) // move below entries 1 line up
|
||||
{
|
||||
ppszFiles[nIndex] = ppszFiles[nIndex+1];
|
||||
}
|
||||
|
||||
ppszFiles[nIndex] = NULL; // clear last line
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruMoveTop(UINT nIndex)
|
||||
{
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
LPTSTR lpszEntry = ppszFiles[nIndex];// remember selected entry
|
||||
|
||||
for (; nIndex > 0; --nIndex) // move above entries 1 line down
|
||||
{
|
||||
ppszFiles[nIndex] = ppszFiles[nIndex-1];
|
||||
}
|
||||
|
||||
ppszFiles[0] = lpszEntry; // insert entry on top
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UINT MruEntries(VOID)
|
||||
{
|
||||
return nEntry;
|
||||
}
|
||||
|
||||
UINT MruID(LPCTSTR lpszEntry)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart;
|
||||
UINT i;
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// get full path name
|
||||
GetFullPathName(lpszEntry,ARRAYSIZEOF(szFilename),szFilename,&lpFilePart);
|
||||
|
||||
// look if entry is already in table
|
||||
for (i = 0; i < nEntry; ++i)
|
||||
{
|
||||
if ( ppszFiles[i] != NULL // valid entry
|
||||
&& lstrcmpi(ppszFiles[i],szFilename) == 0)
|
||||
{
|
||||
return i; // return ID
|
||||
}
|
||||
}
|
||||
}
|
||||
return (UINT) -1; // not found
|
||||
}
|
||||
|
||||
VOID MruFilename(UINT nIndex, LPTSTR szFilename, UINT nBuffersize)
|
||||
{
|
||||
*szFilename = 0; // not found
|
||||
|
||||
// MRU initialized and index inside valid range
|
||||
if (ppszFiles != NULL && nIndex < nEntry)
|
||||
{
|
||||
_ASSERT(ppszFiles[nIndex] != NULL); // valid entry
|
||||
lstrcpyn(szFilename,ppszFiles[nIndex],nBuffersize);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruUpdateMenu(HMENU hMenu)
|
||||
{
|
||||
TCHAR szCurPath[MAX_PATH];
|
||||
BOOL bEmpty;
|
||||
UINT i;
|
||||
|
||||
if (hMenu != NULL) // have menu
|
||||
{
|
||||
HMENU hMruMenu; // menu handle for MRU list
|
||||
UINT nMruPos; // insert position for MRU list
|
||||
|
||||
_ASSERT(IsMenu(hMenu)); // validate menu handle
|
||||
|
||||
// search for menu position of ID_FILE_MRU_FILE1
|
||||
if (GetMenuPosForId(hMenu,ID_FILE_MRU_FILE1,&hMruMenu,&nMruPos))
|
||||
{
|
||||
if (*szOriginal == 0) // get orginal value of first MRU entry
|
||||
{
|
||||
VERIFY(GetMenuString(hMruMenu,nMruPos,szOriginal,ARRAYSIZEOF(szOriginal),MF_BYPOSITION));
|
||||
}
|
||||
|
||||
if (nEntry == 0) // kill MRU menu entry
|
||||
{
|
||||
// delete MRU menu
|
||||
DeleteMenu(hMruMenu,nMruPos,MF_BYPOSITION);
|
||||
|
||||
// delete the following separator
|
||||
_ASSERT((GetMenuState(hMruMenu,nMruPos,MF_BYPOSITION) & MF_SEPARATOR) != 0);
|
||||
DeleteMenu(hMruMenu,nMruPos,MF_BYPOSITION);
|
||||
}
|
||||
|
||||
if (ppszFiles != NULL) // MRU initialized
|
||||
{
|
||||
_ASSERT(nEntry > 0); // must have entries
|
||||
|
||||
// delete all menu entries
|
||||
for (i = 0; DeleteMenu(hMenu,ID_FILE_MRU_FILE1+i,MF_BYCOMMAND) != FALSE; ++i) { }
|
||||
|
||||
// check if MRU list is empty
|
||||
for (bEmpty = TRUE, i = 0; bEmpty && i < nEntry; ++i)
|
||||
{
|
||||
bEmpty = (ppszFiles[i] == NULL);
|
||||
}
|
||||
|
||||
if (bEmpty) // MRU list is empty
|
||||
{
|
||||
// fill with orginal string
|
||||
VERIFY(InsertMenu(hMruMenu,nMruPos,MF_STRING|MF_BYPOSITION|MF_GRAYED,ID_FILE_MRU_FILE1,szOriginal));
|
||||
return;
|
||||
}
|
||||
|
||||
// current directory
|
||||
GetCurrentDirectory(ARRAYSIZEOF(szCurPath),szCurPath);
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
TCHAR szMenuname[2*MAX_PATH+3];
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
LPTSTR lpFilePart,lpszPtr;
|
||||
|
||||
// check if file path and current path is identical
|
||||
if (GetFullPathName(ppszFiles[i],ARRAYSIZEOF(szFilename),szFilename,&lpFilePart))
|
||||
{
|
||||
TCHAR szCutname[MAX_PATH];
|
||||
|
||||
*(lpFilePart-1) = 0; // devide path and name
|
||||
|
||||
// name is current directory -> use only name
|
||||
if (lstrcmpi(szCurPath,szFilename) == 0)
|
||||
{
|
||||
// short name view
|
||||
}
|
||||
else
|
||||
{
|
||||
// full name view
|
||||
lpFilePart = ppszFiles[i];
|
||||
}
|
||||
|
||||
// cut filename to fit into menu
|
||||
GetCutPathName(lpFilePart,szCutname,ARRAYSIZEOF(szCutname),36);
|
||||
lpFilePart = szCutname;
|
||||
|
||||
// adding accelerator key
|
||||
lpszPtr = szMenuname;
|
||||
*lpszPtr++ = _T('&');
|
||||
*lpszPtr++ = _T('0') + ((i + 1) % 10);
|
||||
*lpszPtr++ = _T(' ');
|
||||
|
||||
// copy file to view buffer and expand & to &&
|
||||
while (*lpFilePart != 0)
|
||||
{
|
||||
if (*lpFilePart == _T('&'))
|
||||
{
|
||||
*lpszPtr++ = *lpFilePart;
|
||||
}
|
||||
*lpszPtr++ = *lpFilePart++;
|
||||
}
|
||||
*lpszPtr = 0;
|
||||
|
||||
VERIFY(InsertMenu(hMruMenu,nMruPos+i,
|
||||
MF_STRING|MF_BYPOSITION,ID_FILE_MRU_FILE1+i,
|
||||
szMenuname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruWriteList(VOID)
|
||||
{
|
||||
TCHAR szItemname[32];
|
||||
UINT i;
|
||||
|
||||
if (nEntry > 0)
|
||||
{
|
||||
// no. of files in MRU list
|
||||
WriteSettingsInt(_T("MRU"),_T("FileCount"),nEntry);
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
_ASSERT(ppszFiles != NULL); // MRU not initialized
|
||||
wsprintf(szItemname,_T("File%d"),i+1);
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
WriteSettingsString(_T("MRU"),szItemname,ppszFiles[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DelSettingsKey(_T("MRU"),szItemname);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID MruReadList(VOID)
|
||||
{
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
TCHAR szItemname[32];
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < nEntry; ++i) // add menu entries
|
||||
{
|
||||
_ASSERT(ppszFiles != NULL); // MRU not initialized
|
||||
|
||||
wsprintf(szItemname,_T("File%d"),i+1);
|
||||
ReadSettingsString(_T("MRU"),szItemname,_T(""),szFilename,ARRAYSIZEOF(szFilename));
|
||||
|
||||
if (ppszFiles[i] != NULL) // valid entry
|
||||
{
|
||||
free(ppszFiles[i]); // free entry
|
||||
ppszFiles[i] = NULL; // clear last line
|
||||
}
|
||||
|
||||
if (*szFilename) // read a valid entry
|
||||
{
|
||||
ppszFiles[i] = DuplicateString(szFilename);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,443 +1,443 @@
|
|||
/*
|
||||
* opcodes.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define PCHANGED ((void)(F_s[0]=Chipset.P,F_l[1]=Chipset.P+1))
|
||||
#define INTERRUPT ((void)(Chipset.SoftInt=TRUE,bInterrupt=TRUE))
|
||||
|
||||
extern UINT F_s[16];
|
||||
extern UINT F_l[16];
|
||||
|
||||
extern VOID o00(LPBYTE I); // RTNSXM
|
||||
extern VOID o01(LPBYTE I); // RTN
|
||||
extern VOID o02(LPBYTE I); // RTNSC
|
||||
extern VOID o03(LPBYTE I); // RTNCC
|
||||
extern VOID o04(LPBYTE I); // SETHEX
|
||||
extern VOID o05(LPBYTE I); // SETDEC
|
||||
extern VOID o06(LPBYTE I); // RSTK=C
|
||||
extern VOID o07(LPBYTE I); // C=RSTK
|
||||
extern VOID o08(LPBYTE I); // CLRST
|
||||
extern VOID o09(LPBYTE I); // C=ST
|
||||
extern VOID o0A(LPBYTE I); // ST=C
|
||||
extern VOID o0B(LPBYTE I); // CSTEX
|
||||
extern VOID o0C(LPBYTE I); // P=P+1
|
||||
extern VOID o0D(LPBYTE I); // P=P-1
|
||||
extern VOID o0Ef0(LPBYTE I); // A=A&B f
|
||||
extern VOID o0Ef1(LPBYTE I); // B=B&C f
|
||||
extern VOID o0Ef2(LPBYTE I); // C=C&A f
|
||||
extern VOID o0Ef3(LPBYTE I); // D=D&C f
|
||||
extern VOID o0Ef4(LPBYTE I); // B=B&A f
|
||||
extern VOID o0Ef5(LPBYTE I); // C=C&B f
|
||||
extern VOID o0Ef6(LPBYTE I); // A=A&C f
|
||||
extern VOID o0Ef7(LPBYTE I); // C=C&D f
|
||||
extern VOID o0Ef8(LPBYTE I); // A=A!B f
|
||||
extern VOID o0Ef9(LPBYTE I); // B=B!C f
|
||||
extern VOID o0EfA(LPBYTE I); // C=C!A f
|
||||
extern VOID o0EfB(LPBYTE I); // D=D!C f
|
||||
extern VOID o0EfC(LPBYTE I); // B=B!A f
|
||||
extern VOID o0EfD(LPBYTE I); // C=C!B f
|
||||
extern VOID o0EfE(LPBYTE I); // A=A!C f
|
||||
extern VOID o0EfF(LPBYTE I); // C=C!D f
|
||||
extern VOID o0F(LPBYTE I); // RTI
|
||||
extern VOID o100(LPBYTE I); // R0=A W
|
||||
extern VOID o101(LPBYTE I); // R1=A W
|
||||
extern VOID o102(LPBYTE I); // R2=A W
|
||||
extern VOID o103(LPBYTE I); // R3=A W
|
||||
extern VOID o104(LPBYTE I); // R4=A W
|
||||
extern VOID o108(LPBYTE I); // R0=C W
|
||||
extern VOID o109(LPBYTE I); // R1=C W
|
||||
extern VOID o10A(LPBYTE I); // R2=C W
|
||||
extern VOID o10B(LPBYTE I); // R3=C W
|
||||
extern VOID o10C(LPBYTE I); // R4=C W
|
||||
extern VOID o110(LPBYTE I); // A=R0 W
|
||||
extern VOID o111(LPBYTE I); // A=R1 W
|
||||
extern VOID o112(LPBYTE I); // A=R2 W
|
||||
extern VOID o113(LPBYTE I); // A=R3 W
|
||||
extern VOID o114(LPBYTE I); // A=R4 W
|
||||
extern VOID o118(LPBYTE I); // C=R0 W
|
||||
extern VOID o119(LPBYTE I); // C=R1 W
|
||||
extern VOID o11A(LPBYTE I); // C=R2 W
|
||||
extern VOID o11B(LPBYTE I); // C=R3 W
|
||||
extern VOID o11C(LPBYTE I); // C=R4 W
|
||||
extern VOID o120(LPBYTE I); // AR0EX W
|
||||
extern VOID o121(LPBYTE I); // AR1EX W
|
||||
extern VOID o122(LPBYTE I); // AR2EX W
|
||||
extern VOID o123(LPBYTE I); // AR3EX W
|
||||
extern VOID o124(LPBYTE I); // AR4EX W
|
||||
extern VOID o128(LPBYTE I); // CR0EX W
|
||||
extern VOID o129(LPBYTE I); // CR1EX W
|
||||
extern VOID o12A(LPBYTE I); // CR2EX W
|
||||
extern VOID o12B(LPBYTE I); // CR3EX W
|
||||
extern VOID o12C(LPBYTE I); // CR4EX W
|
||||
extern VOID o130(LPBYTE I); // D0=A
|
||||
extern VOID o131(LPBYTE I); // D1=A
|
||||
extern VOID o132(LPBYTE I); // AD0EX
|
||||
extern VOID o133(LPBYTE I); // AD1EX
|
||||
extern VOID o134(LPBYTE I); // D0=C
|
||||
extern VOID o135(LPBYTE I); // D1=C
|
||||
extern VOID o136(LPBYTE I); // CD0EX
|
||||
extern VOID o137(LPBYTE I); // CD1EX
|
||||
extern VOID o138(LPBYTE I); // D0=AS
|
||||
extern VOID o139(LPBYTE I); // D1=AS
|
||||
extern VOID o13A(LPBYTE I); // AD0XS
|
||||
extern VOID o13B(LPBYTE I); // AD1XS
|
||||
extern VOID o13C(LPBYTE I); // D0=CS
|
||||
extern VOID o13D(LPBYTE I); // D1=CS
|
||||
extern VOID o13E(LPBYTE I); // CD0XS
|
||||
extern VOID o13F(LPBYTE I); // CD1XS
|
||||
extern VOID o140(LPBYTE I); // DAT0=A A
|
||||
extern VOID o141(LPBYTE I); // DAT0=A A
|
||||
extern VOID o144(LPBYTE I); // DAT0=C A
|
||||
extern VOID o145(LPBYTE I); // DAT1=C A
|
||||
extern VOID o148(LPBYTE I); // DAT0=A B
|
||||
extern VOID o149(LPBYTE I); // DAT1=A B
|
||||
extern VOID o14C(LPBYTE I); // DAT0=C B
|
||||
extern VOID o14D(LPBYTE I); // DAT1=C B
|
||||
extern VOID o142(LPBYTE I); // A=DAT0 A
|
||||
extern VOID o143(LPBYTE I); // A=DAT1 A
|
||||
extern VOID o146(LPBYTE I); // C=DAT0 A
|
||||
extern VOID o147(LPBYTE I); // C=DAT1 A
|
||||
extern VOID o14A(LPBYTE I); // A=DAT0 B
|
||||
extern VOID o14B(LPBYTE I); // A=DAT1 B
|
||||
extern VOID o14E(LPBYTE I); // C=DAT0 B
|
||||
extern VOID o14F(LPBYTE I); // C=DAT0 B
|
||||
extern VOID o150a(LPBYTE I); // DAT0=A a
|
||||
extern VOID o151a(LPBYTE I); // DAT1=A a
|
||||
extern VOID o154a(LPBYTE I); // DAT0=C a
|
||||
extern VOID o155a(LPBYTE I); // DAT1=C a
|
||||
extern VOID o152a(LPBYTE I); // A=DAT0 a
|
||||
extern VOID o153a(LPBYTE I); // A=DAT1 a
|
||||
extern VOID o156a(LPBYTE I); // C=DAT0 a
|
||||
extern VOID o157a(LPBYTE I); // C=DAT1 a
|
||||
extern VOID o158x(LPBYTE I); // DAT0=A x
|
||||
extern VOID o159x(LPBYTE I); // DAT1=A x
|
||||
extern VOID o15Cx(LPBYTE I); // DAT0=C x
|
||||
extern VOID o15Dx(LPBYTE I); // DAT1=C x
|
||||
extern VOID o15Ax(LPBYTE I); // A=DAT0 x
|
||||
extern VOID o15Bx(LPBYTE I); // A=DAT1 x
|
||||
extern VOID o15Ex(LPBYTE I); // C=DAT0 x
|
||||
extern VOID o15Fx(LPBYTE I); // C=DAT1 x
|
||||
extern VOID o16x(LPBYTE I); // D0=D0+ (n+1)
|
||||
extern VOID o17x(LPBYTE I); // D1=D1+ (n+1)
|
||||
extern VOID o18x(LPBYTE I); // D0=D0- (n+1)
|
||||
extern VOID o19d2(LPBYTE I); // D0=(2) #dd
|
||||
extern VOID o1Ad4(LPBYTE I); // D0=(4) #dddd
|
||||
extern VOID o1Bd5(LPBYTE I); // D0=(5) #ddddd
|
||||
extern VOID o1Cx(LPBYTE I); // D1=D1- (n+1)
|
||||
extern VOID o1Dd2(LPBYTE I); // D1=(2) #dd
|
||||
extern VOID o1Ed4(LPBYTE I); // D1=(4) #dddd
|
||||
extern VOID o1Fd5(LPBYTE I); // D1=(5) #ddddd
|
||||
extern VOID o2n(LPBYTE I); // P= n
|
||||
extern VOID o3X(LPBYTE I); // LCHEX
|
||||
extern VOID o4d2(LPBYTE I); // GOC #dd
|
||||
extern VOID o5d2(LPBYTE I); // GONC
|
||||
extern VOID o6d3(LPBYTE I); // GOTO
|
||||
extern VOID o7d3(LPBYTE I); // GOSUB
|
||||
extern VOID o800(LPBYTE I); // OUT=CS
|
||||
extern VOID o801(LPBYTE I); // OUT=C
|
||||
extern VOID o802(LPBYTE I); // A=IN
|
||||
extern VOID o803(LPBYTE I); // C=IN
|
||||
extern VOID o804(LPBYTE I); // UNCNFG
|
||||
extern VOID o805(LPBYTE I); // CONFIG
|
||||
extern VOID o806(LPBYTE I); // C=ID
|
||||
extern VOID o807(LPBYTE I); // SHUTDN
|
||||
extern VOID o8080(LPBYTE I); // INTON
|
||||
extern VOID o80810(LPBYTE I); // RSI
|
||||
extern VOID o8082X(LPBYTE I); // LA
|
||||
extern VOID o8083(LPBYTE I); // BUSCB
|
||||
extern VOID o8084n(LPBYTE I); // ABIT=0 n
|
||||
extern VOID o8085n(LPBYTE I); // ABIT=1 n
|
||||
extern VOID o8086n(LPBYTE I); // ?ABIT=0 n
|
||||
extern VOID o8087n(LPBYTE I); // ?ABIT=1 n
|
||||
extern VOID o8088n(LPBYTE I); // CBIT=0 n
|
||||
extern VOID o8089n(LPBYTE I); // CBIT=1 n
|
||||
extern VOID o808An(LPBYTE I); // ?CBIT=0 n
|
||||
extern VOID o808Bn(LPBYTE I); // ?CBIT=1 n
|
||||
extern VOID o808C(LPBYTE I); // PC=(A)
|
||||
extern VOID o808D(LPBYTE I); // BUSCD
|
||||
extern VOID o808E(LPBYTE I); // PC=(C)
|
||||
extern VOID o808F(LPBYTE I); // INTOFF
|
||||
extern VOID o809(LPBYTE I); // C+P+1 - HEX MODE
|
||||
extern VOID o80A(LPBYTE I); // RESET
|
||||
extern VOID o80B(LPBYTE I); // BUSCC
|
||||
extern VOID o80Cn(LPBYTE I); // C=P n
|
||||
extern VOID o80Dn(LPBYTE I); // P=C n
|
||||
extern VOID o80E(LPBYTE I); // SREQ?
|
||||
extern VOID o80Fn(LPBYTE I); // CPEX n
|
||||
extern VOID o810(LPBYTE I); // ASLC
|
||||
extern VOID o811(LPBYTE I); // BSLC
|
||||
extern VOID o812(LPBYTE I); // CSLC
|
||||
extern VOID o813(LPBYTE I); // DSLC
|
||||
extern VOID o814(LPBYTE I); // ASRC
|
||||
extern VOID o815(LPBYTE I); // BSRC
|
||||
extern VOID o816(LPBYTE I); // CSRC
|
||||
extern VOID o817(LPBYTE I); // DSRC
|
||||
extern VOID o818f0x(LPBYTE I); // A=A+x+1 f
|
||||
extern VOID o818f1x(LPBYTE I); // B=B+x+1 f
|
||||
extern VOID o818f2x(LPBYTE I); // C=C+x+1 f
|
||||
extern VOID o818f3x(LPBYTE I); // D=D+x+1 f
|
||||
extern VOID o818f8x(LPBYTE I); // A=A-x-1 f
|
||||
extern VOID o818f9x(LPBYTE I); // B=B-x-1 f
|
||||
extern VOID o818fAx(LPBYTE I); // C=C-x-1 f
|
||||
extern VOID o818fBx(LPBYTE I); // D=D-x-1 f
|
||||
extern VOID o819f0(LPBYTE I); // ASRB.F
|
||||
extern VOID o819f1(LPBYTE I); // BSRB.F
|
||||
extern VOID o819f2(LPBYTE I); // CSRB.F
|
||||
extern VOID o819f3(LPBYTE I); // DSRB.F
|
||||
extern VOID o81Af00(LPBYTE I); // R0=A.F f
|
||||
extern VOID o81Af01(LPBYTE I); // R1=A.F f
|
||||
extern VOID o81Af02(LPBYTE I); // R2=A.F f
|
||||
extern VOID o81Af03(LPBYTE I); // R3=A.F f
|
||||
extern VOID o81Af04(LPBYTE I); // R4=A.F f
|
||||
extern VOID o81Af08(LPBYTE I); // R0=C.F f
|
||||
extern VOID o81Af09(LPBYTE I); // R1=C.F f
|
||||
extern VOID o81Af0A(LPBYTE I); // R2=C.F f
|
||||
extern VOID o81Af0B(LPBYTE I); // R3=C.F f
|
||||
extern VOID o81Af0C(LPBYTE I); // R4=C.F f
|
||||
extern VOID o81Af10(LPBYTE I); // A=R0.F f
|
||||
extern VOID o81Af11(LPBYTE I); // A=R1.F f
|
||||
extern VOID o81Af12(LPBYTE I); // A=R2.F f
|
||||
extern VOID o81Af13(LPBYTE I); // A=R3.F f
|
||||
extern VOID o81Af14(LPBYTE I); // A=R4.F f
|
||||
extern VOID o81Af18(LPBYTE I); // C=R0.F f
|
||||
extern VOID o81Af19(LPBYTE I); // C=R1.F f
|
||||
extern VOID o81Af1A(LPBYTE I); // C=R2.F f
|
||||
extern VOID o81Af1B(LPBYTE I); // C=R3.F f
|
||||
extern VOID o81Af1C(LPBYTE I); // C=R4.F f
|
||||
extern VOID o81Af20(LPBYTE I); // AR0EX.F f
|
||||
extern VOID o81Af21(LPBYTE I); // AR1EX.F f
|
||||
extern VOID o81Af22(LPBYTE I); // AR2EX.F f
|
||||
extern VOID o81Af23(LPBYTE I); // AR3EX.F f
|
||||
extern VOID o81Af24(LPBYTE I); // AR4EX.F f
|
||||
extern VOID o81Af28(LPBYTE I); // CR0EX.F f
|
||||
extern VOID o81Af29(LPBYTE I); // CR1EX.F f
|
||||
extern VOID o81Af2A(LPBYTE I); // CR2EX.F f
|
||||
extern VOID o81Af2B(LPBYTE I); // CR3EX.F f
|
||||
extern VOID o81Af2C(LPBYTE I); // CR4EX.F f
|
||||
extern VOID o81B2(LPBYTE I); // PC=A
|
||||
extern VOID o81B3(LPBYTE I); // PC=C
|
||||
extern VOID o81B4(LPBYTE I); // A=PC
|
||||
extern VOID o81B5(LPBYTE I); // C=PC
|
||||
extern VOID o81B6(LPBYTE I); // APCEX
|
||||
extern VOID o81B7(LPBYTE I); // CPCEX
|
||||
extern VOID o81C(LPBYTE I); // ASRB
|
||||
extern VOID o81D(LPBYTE I); // BSRB
|
||||
extern VOID o81E(LPBYTE I); // CSRB
|
||||
extern VOID o81F(LPBYTE I); // DSRB
|
||||
extern VOID o82n(LPBYTE I); // HST=0 m
|
||||
extern VOID o83n(LPBYTE I); // ?HST=0 m
|
||||
extern VOID o84n(LPBYTE I); // ST=0 n
|
||||
extern VOID o85n(LPBYTE I); // ST=1 n
|
||||
extern VOID o86n(LPBYTE I); // ?ST=0 n
|
||||
extern VOID o87n(LPBYTE I); // ?ST=1 n
|
||||
extern VOID o88n(LPBYTE I); // ?P# n
|
||||
extern VOID o89n(LPBYTE I); // ?P= n
|
||||
extern VOID o8A0(LPBYTE I); // ?A=B A
|
||||
extern VOID o8A1(LPBYTE I); // ?B=C A
|
||||
extern VOID o8A2(LPBYTE I); // ?C=A A
|
||||
extern VOID o8A3(LPBYTE I); // ?D=C A
|
||||
extern VOID o8A4(LPBYTE I); // ?A#B A
|
||||
extern VOID o8A5(LPBYTE I); // ?B#C A
|
||||
extern VOID o8A6(LPBYTE I); // ?C#A A
|
||||
extern VOID o8A7(LPBYTE I); // ?D#C A
|
||||
extern VOID o8A8(LPBYTE I); // ?A=0 A
|
||||
extern VOID o8A9(LPBYTE I); // ?B=0 A
|
||||
extern VOID o8AA(LPBYTE I); // ?C=0 A
|
||||
extern VOID o8AB(LPBYTE I); // ?D=0 A
|
||||
extern VOID o8AC(LPBYTE I); // ?A#0 A
|
||||
extern VOID o8AD(LPBYTE I); // ?B#0 A
|
||||
extern VOID o8AE(LPBYTE I); // ?C#0 A
|
||||
extern VOID o8AF(LPBYTE I); // ?D#0 A
|
||||
extern VOID o8B0(LPBYTE I); // ?A>B A
|
||||
extern VOID o8B1(LPBYTE I); // ?B>C A
|
||||
extern VOID o8B2(LPBYTE I); // ?C>A A
|
||||
extern VOID o8B3(LPBYTE I); // ?D>C A
|
||||
extern VOID o8B4(LPBYTE I); // ?A<B A
|
||||
extern VOID o8B5(LPBYTE I); // ?B<C A
|
||||
extern VOID o8B6(LPBYTE I); // ?C<A A
|
||||
extern VOID o8B7(LPBYTE I); // ?D<C A
|
||||
extern VOID o8B8(LPBYTE I); // ?A>=B A
|
||||
extern VOID o8B9(LPBYTE I); // ?B>=C A
|
||||
extern VOID o8BA(LPBYTE I); // ?C>=A A
|
||||
extern VOID o8BB(LPBYTE I); // ?D>=C A
|
||||
extern VOID o8BC(LPBYTE I); // ?A<=B A
|
||||
extern VOID o8BD(LPBYTE I); // ?B<=C A
|
||||
extern VOID o8BE(LPBYTE I); // ?C<=A A
|
||||
extern VOID o8BF(LPBYTE I); // ?D<=C A
|
||||
extern VOID o8Cd4(LPBYTE I); // GOLONG #dddd
|
||||
extern VOID o8Dd5(LPBYTE I); // GOVLNG #ddddd
|
||||
extern VOID o8Ed4(LPBYTE I); // GOSUBL #dddd
|
||||
extern VOID o8Fd5(LPBYTE I); // GOSBVL #ddddd
|
||||
extern VOID o9a0(LPBYTE I); // ?A=B f
|
||||
extern VOID o9a1(LPBYTE I); // ?B=C f
|
||||
extern VOID o9a2(LPBYTE I); // ?C=A f
|
||||
extern VOID o9a3(LPBYTE I); // ?D=C f
|
||||
extern VOID o9a4(LPBYTE I); // ?A#B f
|
||||
extern VOID o9a5(LPBYTE I); // ?B#C f
|
||||
extern VOID o9a6(LPBYTE I); // ?C#A f
|
||||
extern VOID o9a7(LPBYTE I); // ?D#C f
|
||||
extern VOID o9a8(LPBYTE I); // ?A=0 f
|
||||
extern VOID o9a9(LPBYTE I); // ?B=0 f
|
||||
extern VOID o9aA(LPBYTE I); // ?C=0 f
|
||||
extern VOID o9aB(LPBYTE I); // ?D=0 f
|
||||
extern VOID o9aC(LPBYTE I); // ?A#0 f
|
||||
extern VOID o9aD(LPBYTE I); // ?B#0 f
|
||||
extern VOID o9aE(LPBYTE I); // ?C#0 f
|
||||
extern VOID o9aF(LPBYTE I); // ?D#0 f
|
||||
extern VOID o9b0(LPBYTE I); // ?A>B f
|
||||
extern VOID o9b1(LPBYTE I); // ?B>C f
|
||||
extern VOID o9b2(LPBYTE I); // ?C>A f
|
||||
extern VOID o9b3(LPBYTE I); // ?D>C f
|
||||
extern VOID o9b4(LPBYTE I); // ?A<B f
|
||||
extern VOID o9b5(LPBYTE I); // ?B<C f
|
||||
extern VOID o9b6(LPBYTE I); // ?C<A f
|
||||
extern VOID o9b7(LPBYTE I); // ?D<C f
|
||||
extern VOID o9b8(LPBYTE I); // ?A>=B f
|
||||
extern VOID o9b9(LPBYTE I); // ?B>=C f
|
||||
extern VOID o9bA(LPBYTE I); // ?C>=A f
|
||||
extern VOID o9bB(LPBYTE I); // ?D>=C f
|
||||
extern VOID o9bC(LPBYTE I); // ?A<=B f
|
||||
extern VOID o9bD(LPBYTE I); // ?B<=C f
|
||||
extern VOID o9bE(LPBYTE I); // ?C<=A f
|
||||
extern VOID o9bF(LPBYTE I); // ?D<=C f
|
||||
extern VOID oAa0(LPBYTE I); // A=A+B f
|
||||
extern VOID oAa1(LPBYTE I); // B=B+C f
|
||||
extern VOID oAa2(LPBYTE I); // C=C+A f
|
||||
extern VOID oAa3(LPBYTE I); // D=D+C f
|
||||
extern VOID oAa4(LPBYTE I); // A=A+A f
|
||||
extern VOID oAa5(LPBYTE I); // B=B+B f
|
||||
extern VOID oAa6(LPBYTE I); // C=C+C f
|
||||
extern VOID oAa7(LPBYTE I); // D=D+D f
|
||||
extern VOID oAa8(LPBYTE I); // B=B+A f
|
||||
extern VOID oAa9(LPBYTE I); // C=C+B f
|
||||
extern VOID oAaA(LPBYTE I); // A=A+C f
|
||||
extern VOID oAaB(LPBYTE I); // C=C+D f
|
||||
extern VOID oAaC(LPBYTE I); // A=A-1 f
|
||||
extern VOID oAaD(LPBYTE I); // B=B-1 f
|
||||
extern VOID oAaE(LPBYTE I); // C=C-1 f
|
||||
extern VOID oAaF(LPBYTE I); // D=D-1 f
|
||||
extern VOID oAb0(LPBYTE I); // A=0 f
|
||||
extern VOID oAb1(LPBYTE I); // B=0 f
|
||||
extern VOID oAb2(LPBYTE I); // C=0 f
|
||||
extern VOID oAb3(LPBYTE I); // D=0 f
|
||||
extern VOID oAb4(LPBYTE I); // A=B f
|
||||
extern VOID oAb5(LPBYTE I); // B=C f
|
||||
extern VOID oAb6(LPBYTE I); // C=A f
|
||||
extern VOID oAb7(LPBYTE I); // D=C f
|
||||
extern VOID oAb8(LPBYTE I); // B=A f
|
||||
extern VOID oAb9(LPBYTE I); // C=B f
|
||||
extern VOID oAbA(LPBYTE I); // A=C f
|
||||
extern VOID oAbB(LPBYTE I); // C=D f
|
||||
extern VOID oAbC(LPBYTE I); // ABEX f
|
||||
extern VOID oAbD(LPBYTE I); // BCEX f
|
||||
extern VOID oAbE(LPBYTE I); // CAEX f
|
||||
extern VOID oAbF(LPBYTE I); // DCEX f
|
||||
extern VOID oBa0(LPBYTE I); // A=A-B f
|
||||
extern VOID oBa1(LPBYTE I); // B=B-C f
|
||||
extern VOID oBa2(LPBYTE I); // C=C-A f
|
||||
extern VOID oBa3(LPBYTE I); // D=D-C f
|
||||
extern VOID oBa4(LPBYTE I); // A=A+1 f
|
||||
extern VOID oBa5(LPBYTE I); // B=B+1 f
|
||||
extern VOID oBa6(LPBYTE I); // C=C+1 f
|
||||
extern VOID oBa7(LPBYTE I); // D=D+1 f
|
||||
extern VOID oBa8(LPBYTE I); // B=B-A f
|
||||
extern VOID oBa9(LPBYTE I); // C=C-B f
|
||||
extern VOID oBaA(LPBYTE I); // A=A-C f
|
||||
extern VOID oBaB(LPBYTE I); // C=C-D f
|
||||
extern VOID oBaC(LPBYTE I); // A=B-A f
|
||||
extern VOID oBaD(LPBYTE I); // B=C-B f
|
||||
extern VOID oBaE(LPBYTE I); // C=A-C f
|
||||
extern VOID oBaF(LPBYTE I); // D=C-D f
|
||||
extern VOID oBb0(LPBYTE I); // ASL f
|
||||
extern VOID oBb1(LPBYTE I); // BSL f
|
||||
extern VOID oBb2(LPBYTE I); // CSL f
|
||||
extern VOID oBb3(LPBYTE I); // DSL f
|
||||
extern VOID oBb4(LPBYTE I); // ASR f
|
||||
extern VOID oBb5(LPBYTE I); // BSR f
|
||||
extern VOID oBb6(LPBYTE I); // CSR f
|
||||
extern VOID oBb7(LPBYTE I); // DSR f
|
||||
extern VOID oBb8(LPBYTE I); // A=-A f
|
||||
extern VOID oBb9(LPBYTE I); // B=-B f
|
||||
extern VOID oBbA(LPBYTE I); // C=-C f
|
||||
extern VOID oBbB(LPBYTE I); // D=-D f
|
||||
extern VOID oBbC(LPBYTE I); // A=-A-1 f
|
||||
extern VOID oBbD(LPBYTE I); // B=-B-1 f
|
||||
extern VOID oBbE(LPBYTE I); // C=-C-1 f
|
||||
extern VOID oBbF(LPBYTE I); // D=-D-1 f
|
||||
extern VOID oC0(LPBYTE I); // A=A+B A
|
||||
extern VOID oC1(LPBYTE I); // B=B+C A
|
||||
extern VOID oC2(LPBYTE I); // C=C+A A
|
||||
extern VOID oC3(LPBYTE I); // D=D+C A
|
||||
extern VOID oC4(LPBYTE I); // A=A+A A
|
||||
extern VOID oC5(LPBYTE I); // B=B+B A
|
||||
extern VOID oC6(LPBYTE I); // C=C+C A
|
||||
extern VOID oC7(LPBYTE I); // D=D+D A
|
||||
extern VOID oC8(LPBYTE I); // B=B+A A
|
||||
extern VOID oC9(LPBYTE I); // C=C+B A
|
||||
extern VOID oCA(LPBYTE I); // A=A+C A
|
||||
extern VOID oCB(LPBYTE I); // C=C+D A
|
||||
extern VOID oCC(LPBYTE I); // A=A-1 A
|
||||
extern VOID oCD(LPBYTE I); // B=B-1 A
|
||||
extern VOID oCE(LPBYTE I); // C=C-1 A
|
||||
extern VOID oCF(LPBYTE I); // D=D-1 A
|
||||
extern VOID oD0(LPBYTE I); // A=0 A
|
||||
extern VOID oD1(LPBYTE I); // B=0 A
|
||||
extern VOID oD2(LPBYTE I); // C=0 A
|
||||
extern VOID oD3(LPBYTE I); // D=0 A
|
||||
extern VOID oD4(LPBYTE I); // A=B A
|
||||
extern VOID oD5(LPBYTE I); // B=C A
|
||||
extern VOID oD6(LPBYTE I); // C=A A
|
||||
extern VOID oD7(LPBYTE I); // D=C A
|
||||
extern VOID oD8(LPBYTE I); // B=A A
|
||||
extern VOID oD9(LPBYTE I); // C=B A
|
||||
extern VOID oDA(LPBYTE I); // A=C A
|
||||
extern VOID oDB(LPBYTE I); // C=D A
|
||||
extern VOID oDC(LPBYTE I); // ABEX
|
||||
extern VOID oDD(LPBYTE I); // BCEX
|
||||
extern VOID oDE(LPBYTE I); // CAEX
|
||||
extern VOID oDF(LPBYTE I); // DCEX
|
||||
extern VOID oE0(LPBYTE I); // A=A-B A
|
||||
extern VOID oE1(LPBYTE I); // B=B-C A
|
||||
extern VOID oE2(LPBYTE I); // C=C-A A
|
||||
extern VOID oE3(LPBYTE I); // D=D-C A
|
||||
extern VOID oE4(LPBYTE I); // A=A+1 A
|
||||
extern VOID oE5(LPBYTE I); // B=B+1 A
|
||||
extern VOID oE6(LPBYTE I); // C=C+1 A
|
||||
extern VOID oE7(LPBYTE I); // D=D+1 A
|
||||
extern VOID oE8(LPBYTE I); // B=B-A A
|
||||
extern VOID oE9(LPBYTE I); // C=C-B A
|
||||
extern VOID oEA(LPBYTE I); // A=A-C A
|
||||
extern VOID oEB(LPBYTE I); // C=C-D A
|
||||
extern VOID oEC(LPBYTE I); // A=B-A A
|
||||
extern VOID oED(LPBYTE I); // B=C-B A
|
||||
extern VOID oEE(LPBYTE I); // C=A-C A
|
||||
extern VOID oEF(LPBYTE I); // D=C-D A
|
||||
extern VOID oF0(LPBYTE I); // ASL A
|
||||
extern VOID oF1(LPBYTE I); // BSL A
|
||||
extern VOID oF2(LPBYTE I); // CSL A
|
||||
extern VOID oF3(LPBYTE I); // DSL A
|
||||
extern VOID oF4(LPBYTE I); // ASR A
|
||||
extern VOID oF5(LPBYTE I); // BSR A
|
||||
extern VOID oF6(LPBYTE I); // CSR A
|
||||
extern VOID oF7(LPBYTE I); // DSR A
|
||||
extern VOID oF8(LPBYTE I); // A=-A A
|
||||
extern VOID oF9(LPBYTE I); // B=-B A
|
||||
extern VOID oFA(LPBYTE I); // C=-C A
|
||||
extern VOID oFB(LPBYTE I); // D=-D A
|
||||
extern VOID oFC(LPBYTE I); // A=-A-1 A
|
||||
extern VOID oFD(LPBYTE I); // B=-B-1 A
|
||||
extern VOID oFE(LPBYTE I); // C=-C-1 A
|
||||
extern VOID oFF(LPBYTE I); // D=-D-1 A
|
||||
|
||||
extern VOID o_invalid3(LPBYTE I);
|
||||
extern VOID o_invalid4(LPBYTE I);
|
||||
extern VOID o_invalid5(LPBYTE I);
|
||||
extern VOID o_invalid6(LPBYTE I);
|
||||
|
||||
extern VOID o_goyes3(LPBYTE I);
|
||||
extern VOID o_goyes5(LPBYTE I);
|
||||
/*
|
||||
* opcodes.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#define PCHANGED ((void)(F_s[0]=Chipset.P,F_l[1]=Chipset.P+1))
|
||||
#define INTERRUPT ((void)(Chipset.SoftInt=TRUE,bInterrupt=TRUE))
|
||||
|
||||
extern UINT F_s[16];
|
||||
extern UINT F_l[16];
|
||||
|
||||
extern VOID o00(LPBYTE I); // RTNSXM
|
||||
extern VOID o01(LPBYTE I); // RTN
|
||||
extern VOID o02(LPBYTE I); // RTNSC
|
||||
extern VOID o03(LPBYTE I); // RTNCC
|
||||
extern VOID o04(LPBYTE I); // SETHEX
|
||||
extern VOID o05(LPBYTE I); // SETDEC
|
||||
extern VOID o06(LPBYTE I); // RSTK=C
|
||||
extern VOID o07(LPBYTE I); // C=RSTK
|
||||
extern VOID o08(LPBYTE I); // CLRST
|
||||
extern VOID o09(LPBYTE I); // C=ST
|
||||
extern VOID o0A(LPBYTE I); // ST=C
|
||||
extern VOID o0B(LPBYTE I); // CSTEX
|
||||
extern VOID o0C(LPBYTE I); // P=P+1
|
||||
extern VOID o0D(LPBYTE I); // P=P-1
|
||||
extern VOID o0Ef0(LPBYTE I); // A=A&B f
|
||||
extern VOID o0Ef1(LPBYTE I); // B=B&C f
|
||||
extern VOID o0Ef2(LPBYTE I); // C=C&A f
|
||||
extern VOID o0Ef3(LPBYTE I); // D=D&C f
|
||||
extern VOID o0Ef4(LPBYTE I); // B=B&A f
|
||||
extern VOID o0Ef5(LPBYTE I); // C=C&B f
|
||||
extern VOID o0Ef6(LPBYTE I); // A=A&C f
|
||||
extern VOID o0Ef7(LPBYTE I); // C=C&D f
|
||||
extern VOID o0Ef8(LPBYTE I); // A=A!B f
|
||||
extern VOID o0Ef9(LPBYTE I); // B=B!C f
|
||||
extern VOID o0EfA(LPBYTE I); // C=C!A f
|
||||
extern VOID o0EfB(LPBYTE I); // D=D!C f
|
||||
extern VOID o0EfC(LPBYTE I); // B=B!A f
|
||||
extern VOID o0EfD(LPBYTE I); // C=C!B f
|
||||
extern VOID o0EfE(LPBYTE I); // A=A!C f
|
||||
extern VOID o0EfF(LPBYTE I); // C=C!D f
|
||||
extern VOID o0F(LPBYTE I); // RTI
|
||||
extern VOID o100(LPBYTE I); // R0=A W
|
||||
extern VOID o101(LPBYTE I); // R1=A W
|
||||
extern VOID o102(LPBYTE I); // R2=A W
|
||||
extern VOID o103(LPBYTE I); // R3=A W
|
||||
extern VOID o104(LPBYTE I); // R4=A W
|
||||
extern VOID o108(LPBYTE I); // R0=C W
|
||||
extern VOID o109(LPBYTE I); // R1=C W
|
||||
extern VOID o10A(LPBYTE I); // R2=C W
|
||||
extern VOID o10B(LPBYTE I); // R3=C W
|
||||
extern VOID o10C(LPBYTE I); // R4=C W
|
||||
extern VOID o110(LPBYTE I); // A=R0 W
|
||||
extern VOID o111(LPBYTE I); // A=R1 W
|
||||
extern VOID o112(LPBYTE I); // A=R2 W
|
||||
extern VOID o113(LPBYTE I); // A=R3 W
|
||||
extern VOID o114(LPBYTE I); // A=R4 W
|
||||
extern VOID o118(LPBYTE I); // C=R0 W
|
||||
extern VOID o119(LPBYTE I); // C=R1 W
|
||||
extern VOID o11A(LPBYTE I); // C=R2 W
|
||||
extern VOID o11B(LPBYTE I); // C=R3 W
|
||||
extern VOID o11C(LPBYTE I); // C=R4 W
|
||||
extern VOID o120(LPBYTE I); // AR0EX W
|
||||
extern VOID o121(LPBYTE I); // AR1EX W
|
||||
extern VOID o122(LPBYTE I); // AR2EX W
|
||||
extern VOID o123(LPBYTE I); // AR3EX W
|
||||
extern VOID o124(LPBYTE I); // AR4EX W
|
||||
extern VOID o128(LPBYTE I); // CR0EX W
|
||||
extern VOID o129(LPBYTE I); // CR1EX W
|
||||
extern VOID o12A(LPBYTE I); // CR2EX W
|
||||
extern VOID o12B(LPBYTE I); // CR3EX W
|
||||
extern VOID o12C(LPBYTE I); // CR4EX W
|
||||
extern VOID o130(LPBYTE I); // D0=A
|
||||
extern VOID o131(LPBYTE I); // D1=A
|
||||
extern VOID o132(LPBYTE I); // AD0EX
|
||||
extern VOID o133(LPBYTE I); // AD1EX
|
||||
extern VOID o134(LPBYTE I); // D0=C
|
||||
extern VOID o135(LPBYTE I); // D1=C
|
||||
extern VOID o136(LPBYTE I); // CD0EX
|
||||
extern VOID o137(LPBYTE I); // CD1EX
|
||||
extern VOID o138(LPBYTE I); // D0=AS
|
||||
extern VOID o139(LPBYTE I); // D1=AS
|
||||
extern VOID o13A(LPBYTE I); // AD0XS
|
||||
extern VOID o13B(LPBYTE I); // AD1XS
|
||||
extern VOID o13C(LPBYTE I); // D0=CS
|
||||
extern VOID o13D(LPBYTE I); // D1=CS
|
||||
extern VOID o13E(LPBYTE I); // CD0XS
|
||||
extern VOID o13F(LPBYTE I); // CD1XS
|
||||
extern VOID o140(LPBYTE I); // DAT0=A A
|
||||
extern VOID o141(LPBYTE I); // DAT0=A A
|
||||
extern VOID o144(LPBYTE I); // DAT0=C A
|
||||
extern VOID o145(LPBYTE I); // DAT1=C A
|
||||
extern VOID o148(LPBYTE I); // DAT0=A B
|
||||
extern VOID o149(LPBYTE I); // DAT1=A B
|
||||
extern VOID o14C(LPBYTE I); // DAT0=C B
|
||||
extern VOID o14D(LPBYTE I); // DAT1=C B
|
||||
extern VOID o142(LPBYTE I); // A=DAT0 A
|
||||
extern VOID o143(LPBYTE I); // A=DAT1 A
|
||||
extern VOID o146(LPBYTE I); // C=DAT0 A
|
||||
extern VOID o147(LPBYTE I); // C=DAT1 A
|
||||
extern VOID o14A(LPBYTE I); // A=DAT0 B
|
||||
extern VOID o14B(LPBYTE I); // A=DAT1 B
|
||||
extern VOID o14E(LPBYTE I); // C=DAT0 B
|
||||
extern VOID o14F(LPBYTE I); // C=DAT0 B
|
||||
extern VOID o150a(LPBYTE I); // DAT0=A a
|
||||
extern VOID o151a(LPBYTE I); // DAT1=A a
|
||||
extern VOID o154a(LPBYTE I); // DAT0=C a
|
||||
extern VOID o155a(LPBYTE I); // DAT1=C a
|
||||
extern VOID o152a(LPBYTE I); // A=DAT0 a
|
||||
extern VOID o153a(LPBYTE I); // A=DAT1 a
|
||||
extern VOID o156a(LPBYTE I); // C=DAT0 a
|
||||
extern VOID o157a(LPBYTE I); // C=DAT1 a
|
||||
extern VOID o158x(LPBYTE I); // DAT0=A x
|
||||
extern VOID o159x(LPBYTE I); // DAT1=A x
|
||||
extern VOID o15Cx(LPBYTE I); // DAT0=C x
|
||||
extern VOID o15Dx(LPBYTE I); // DAT1=C x
|
||||
extern VOID o15Ax(LPBYTE I); // A=DAT0 x
|
||||
extern VOID o15Bx(LPBYTE I); // A=DAT1 x
|
||||
extern VOID o15Ex(LPBYTE I); // C=DAT0 x
|
||||
extern VOID o15Fx(LPBYTE I); // C=DAT1 x
|
||||
extern VOID o16x(LPBYTE I); // D0=D0+ (n+1)
|
||||
extern VOID o17x(LPBYTE I); // D1=D1+ (n+1)
|
||||
extern VOID o18x(LPBYTE I); // D0=D0- (n+1)
|
||||
extern VOID o19d2(LPBYTE I); // D0=(2) #dd
|
||||
extern VOID o1Ad4(LPBYTE I); // D0=(4) #dddd
|
||||
extern VOID o1Bd5(LPBYTE I); // D0=(5) #ddddd
|
||||
extern VOID o1Cx(LPBYTE I); // D1=D1- (n+1)
|
||||
extern VOID o1Dd2(LPBYTE I); // D1=(2) #dd
|
||||
extern VOID o1Ed4(LPBYTE I); // D1=(4) #dddd
|
||||
extern VOID o1Fd5(LPBYTE I); // D1=(5) #ddddd
|
||||
extern VOID o2n(LPBYTE I); // P= n
|
||||
extern VOID o3X(LPBYTE I); // LCHEX
|
||||
extern VOID o4d2(LPBYTE I); // GOC #dd
|
||||
extern VOID o5d2(LPBYTE I); // GONC
|
||||
extern VOID o6d3(LPBYTE I); // GOTO
|
||||
extern VOID o7d3(LPBYTE I); // GOSUB
|
||||
extern VOID o800(LPBYTE I); // OUT=CS
|
||||
extern VOID o801(LPBYTE I); // OUT=C
|
||||
extern VOID o802(LPBYTE I); // A=IN
|
||||
extern VOID o803(LPBYTE I); // C=IN
|
||||
extern VOID o804(LPBYTE I); // UNCNFG
|
||||
extern VOID o805(LPBYTE I); // CONFIG
|
||||
extern VOID o806(LPBYTE I); // C=ID
|
||||
extern VOID o807(LPBYTE I); // SHUTDN
|
||||
extern VOID o8080(LPBYTE I); // INTON
|
||||
extern VOID o80810(LPBYTE I); // RSI
|
||||
extern VOID o8082X(LPBYTE I); // LA
|
||||
extern VOID o8083(LPBYTE I); // BUSCB
|
||||
extern VOID o8084n(LPBYTE I); // ABIT=0 n
|
||||
extern VOID o8085n(LPBYTE I); // ABIT=1 n
|
||||
extern VOID o8086n(LPBYTE I); // ?ABIT=0 n
|
||||
extern VOID o8087n(LPBYTE I); // ?ABIT=1 n
|
||||
extern VOID o8088n(LPBYTE I); // CBIT=0 n
|
||||
extern VOID o8089n(LPBYTE I); // CBIT=1 n
|
||||
extern VOID o808An(LPBYTE I); // ?CBIT=0 n
|
||||
extern VOID o808Bn(LPBYTE I); // ?CBIT=1 n
|
||||
extern VOID o808C(LPBYTE I); // PC=(A)
|
||||
extern VOID o808D(LPBYTE I); // BUSCD
|
||||
extern VOID o808E(LPBYTE I); // PC=(C)
|
||||
extern VOID o808F(LPBYTE I); // INTOFF
|
||||
extern VOID o809(LPBYTE I); // C+P+1 - HEX MODE
|
||||
extern VOID o80A(LPBYTE I); // RESET
|
||||
extern VOID o80B(LPBYTE I); // BUSCC
|
||||
extern VOID o80Cn(LPBYTE I); // C=P n
|
||||
extern VOID o80Dn(LPBYTE I); // P=C n
|
||||
extern VOID o80E(LPBYTE I); // SREQ?
|
||||
extern VOID o80Fn(LPBYTE I); // CPEX n
|
||||
extern VOID o810(LPBYTE I); // ASLC
|
||||
extern VOID o811(LPBYTE I); // BSLC
|
||||
extern VOID o812(LPBYTE I); // CSLC
|
||||
extern VOID o813(LPBYTE I); // DSLC
|
||||
extern VOID o814(LPBYTE I); // ASRC
|
||||
extern VOID o815(LPBYTE I); // BSRC
|
||||
extern VOID o816(LPBYTE I); // CSRC
|
||||
extern VOID o817(LPBYTE I); // DSRC
|
||||
extern VOID o818f0x(LPBYTE I); // A=A+x+1 f
|
||||
extern VOID o818f1x(LPBYTE I); // B=B+x+1 f
|
||||
extern VOID o818f2x(LPBYTE I); // C=C+x+1 f
|
||||
extern VOID o818f3x(LPBYTE I); // D=D+x+1 f
|
||||
extern VOID o818f8x(LPBYTE I); // A=A-x-1 f
|
||||
extern VOID o818f9x(LPBYTE I); // B=B-x-1 f
|
||||
extern VOID o818fAx(LPBYTE I); // C=C-x-1 f
|
||||
extern VOID o818fBx(LPBYTE I); // D=D-x-1 f
|
||||
extern VOID o819f0(LPBYTE I); // ASRB.F
|
||||
extern VOID o819f1(LPBYTE I); // BSRB.F
|
||||
extern VOID o819f2(LPBYTE I); // CSRB.F
|
||||
extern VOID o819f3(LPBYTE I); // DSRB.F
|
||||
extern VOID o81Af00(LPBYTE I); // R0=A.F f
|
||||
extern VOID o81Af01(LPBYTE I); // R1=A.F f
|
||||
extern VOID o81Af02(LPBYTE I); // R2=A.F f
|
||||
extern VOID o81Af03(LPBYTE I); // R3=A.F f
|
||||
extern VOID o81Af04(LPBYTE I); // R4=A.F f
|
||||
extern VOID o81Af08(LPBYTE I); // R0=C.F f
|
||||
extern VOID o81Af09(LPBYTE I); // R1=C.F f
|
||||
extern VOID o81Af0A(LPBYTE I); // R2=C.F f
|
||||
extern VOID o81Af0B(LPBYTE I); // R3=C.F f
|
||||
extern VOID o81Af0C(LPBYTE I); // R4=C.F f
|
||||
extern VOID o81Af10(LPBYTE I); // A=R0.F f
|
||||
extern VOID o81Af11(LPBYTE I); // A=R1.F f
|
||||
extern VOID o81Af12(LPBYTE I); // A=R2.F f
|
||||
extern VOID o81Af13(LPBYTE I); // A=R3.F f
|
||||
extern VOID o81Af14(LPBYTE I); // A=R4.F f
|
||||
extern VOID o81Af18(LPBYTE I); // C=R0.F f
|
||||
extern VOID o81Af19(LPBYTE I); // C=R1.F f
|
||||
extern VOID o81Af1A(LPBYTE I); // C=R2.F f
|
||||
extern VOID o81Af1B(LPBYTE I); // C=R3.F f
|
||||
extern VOID o81Af1C(LPBYTE I); // C=R4.F f
|
||||
extern VOID o81Af20(LPBYTE I); // AR0EX.F f
|
||||
extern VOID o81Af21(LPBYTE I); // AR1EX.F f
|
||||
extern VOID o81Af22(LPBYTE I); // AR2EX.F f
|
||||
extern VOID o81Af23(LPBYTE I); // AR3EX.F f
|
||||
extern VOID o81Af24(LPBYTE I); // AR4EX.F f
|
||||
extern VOID o81Af28(LPBYTE I); // CR0EX.F f
|
||||
extern VOID o81Af29(LPBYTE I); // CR1EX.F f
|
||||
extern VOID o81Af2A(LPBYTE I); // CR2EX.F f
|
||||
extern VOID o81Af2B(LPBYTE I); // CR3EX.F f
|
||||
extern VOID o81Af2C(LPBYTE I); // CR4EX.F f
|
||||
extern VOID o81B2(LPBYTE I); // PC=A
|
||||
extern VOID o81B3(LPBYTE I); // PC=C
|
||||
extern VOID o81B4(LPBYTE I); // A=PC
|
||||
extern VOID o81B5(LPBYTE I); // C=PC
|
||||
extern VOID o81B6(LPBYTE I); // APCEX
|
||||
extern VOID o81B7(LPBYTE I); // CPCEX
|
||||
extern VOID o81C(LPBYTE I); // ASRB
|
||||
extern VOID o81D(LPBYTE I); // BSRB
|
||||
extern VOID o81E(LPBYTE I); // CSRB
|
||||
extern VOID o81F(LPBYTE I); // DSRB
|
||||
extern VOID o82n(LPBYTE I); // HST=0 m
|
||||
extern VOID o83n(LPBYTE I); // ?HST=0 m
|
||||
extern VOID o84n(LPBYTE I); // ST=0 n
|
||||
extern VOID o85n(LPBYTE I); // ST=1 n
|
||||
extern VOID o86n(LPBYTE I); // ?ST=0 n
|
||||
extern VOID o87n(LPBYTE I); // ?ST=1 n
|
||||
extern VOID o88n(LPBYTE I); // ?P# n
|
||||
extern VOID o89n(LPBYTE I); // ?P= n
|
||||
extern VOID o8A0(LPBYTE I); // ?A=B A
|
||||
extern VOID o8A1(LPBYTE I); // ?B=C A
|
||||
extern VOID o8A2(LPBYTE I); // ?C=A A
|
||||
extern VOID o8A3(LPBYTE I); // ?D=C A
|
||||
extern VOID o8A4(LPBYTE I); // ?A#B A
|
||||
extern VOID o8A5(LPBYTE I); // ?B#C A
|
||||
extern VOID o8A6(LPBYTE I); // ?C#A A
|
||||
extern VOID o8A7(LPBYTE I); // ?D#C A
|
||||
extern VOID o8A8(LPBYTE I); // ?A=0 A
|
||||
extern VOID o8A9(LPBYTE I); // ?B=0 A
|
||||
extern VOID o8AA(LPBYTE I); // ?C=0 A
|
||||
extern VOID o8AB(LPBYTE I); // ?D=0 A
|
||||
extern VOID o8AC(LPBYTE I); // ?A#0 A
|
||||
extern VOID o8AD(LPBYTE I); // ?B#0 A
|
||||
extern VOID o8AE(LPBYTE I); // ?C#0 A
|
||||
extern VOID o8AF(LPBYTE I); // ?D#0 A
|
||||
extern VOID o8B0(LPBYTE I); // ?A>B A
|
||||
extern VOID o8B1(LPBYTE I); // ?B>C A
|
||||
extern VOID o8B2(LPBYTE I); // ?C>A A
|
||||
extern VOID o8B3(LPBYTE I); // ?D>C A
|
||||
extern VOID o8B4(LPBYTE I); // ?A<B A
|
||||
extern VOID o8B5(LPBYTE I); // ?B<C A
|
||||
extern VOID o8B6(LPBYTE I); // ?C<A A
|
||||
extern VOID o8B7(LPBYTE I); // ?D<C A
|
||||
extern VOID o8B8(LPBYTE I); // ?A>=B A
|
||||
extern VOID o8B9(LPBYTE I); // ?B>=C A
|
||||
extern VOID o8BA(LPBYTE I); // ?C>=A A
|
||||
extern VOID o8BB(LPBYTE I); // ?D>=C A
|
||||
extern VOID o8BC(LPBYTE I); // ?A<=B A
|
||||
extern VOID o8BD(LPBYTE I); // ?B<=C A
|
||||
extern VOID o8BE(LPBYTE I); // ?C<=A A
|
||||
extern VOID o8BF(LPBYTE I); // ?D<=C A
|
||||
extern VOID o8Cd4(LPBYTE I); // GOLONG #dddd
|
||||
extern VOID o8Dd5(LPBYTE I); // GOVLNG #ddddd
|
||||
extern VOID o8Ed4(LPBYTE I); // GOSUBL #dddd
|
||||
extern VOID o8Fd5(LPBYTE I); // GOSBVL #ddddd
|
||||
extern VOID o9a0(LPBYTE I); // ?A=B f
|
||||
extern VOID o9a1(LPBYTE I); // ?B=C f
|
||||
extern VOID o9a2(LPBYTE I); // ?C=A f
|
||||
extern VOID o9a3(LPBYTE I); // ?D=C f
|
||||
extern VOID o9a4(LPBYTE I); // ?A#B f
|
||||
extern VOID o9a5(LPBYTE I); // ?B#C f
|
||||
extern VOID o9a6(LPBYTE I); // ?C#A f
|
||||
extern VOID o9a7(LPBYTE I); // ?D#C f
|
||||
extern VOID o9a8(LPBYTE I); // ?A=0 f
|
||||
extern VOID o9a9(LPBYTE I); // ?B=0 f
|
||||
extern VOID o9aA(LPBYTE I); // ?C=0 f
|
||||
extern VOID o9aB(LPBYTE I); // ?D=0 f
|
||||
extern VOID o9aC(LPBYTE I); // ?A#0 f
|
||||
extern VOID o9aD(LPBYTE I); // ?B#0 f
|
||||
extern VOID o9aE(LPBYTE I); // ?C#0 f
|
||||
extern VOID o9aF(LPBYTE I); // ?D#0 f
|
||||
extern VOID o9b0(LPBYTE I); // ?A>B f
|
||||
extern VOID o9b1(LPBYTE I); // ?B>C f
|
||||
extern VOID o9b2(LPBYTE I); // ?C>A f
|
||||
extern VOID o9b3(LPBYTE I); // ?D>C f
|
||||
extern VOID o9b4(LPBYTE I); // ?A<B f
|
||||
extern VOID o9b5(LPBYTE I); // ?B<C f
|
||||
extern VOID o9b6(LPBYTE I); // ?C<A f
|
||||
extern VOID o9b7(LPBYTE I); // ?D<C f
|
||||
extern VOID o9b8(LPBYTE I); // ?A>=B f
|
||||
extern VOID o9b9(LPBYTE I); // ?B>=C f
|
||||
extern VOID o9bA(LPBYTE I); // ?C>=A f
|
||||
extern VOID o9bB(LPBYTE I); // ?D>=C f
|
||||
extern VOID o9bC(LPBYTE I); // ?A<=B f
|
||||
extern VOID o9bD(LPBYTE I); // ?B<=C f
|
||||
extern VOID o9bE(LPBYTE I); // ?C<=A f
|
||||
extern VOID o9bF(LPBYTE I); // ?D<=C f
|
||||
extern VOID oAa0(LPBYTE I); // A=A+B f
|
||||
extern VOID oAa1(LPBYTE I); // B=B+C f
|
||||
extern VOID oAa2(LPBYTE I); // C=C+A f
|
||||
extern VOID oAa3(LPBYTE I); // D=D+C f
|
||||
extern VOID oAa4(LPBYTE I); // A=A+A f
|
||||
extern VOID oAa5(LPBYTE I); // B=B+B f
|
||||
extern VOID oAa6(LPBYTE I); // C=C+C f
|
||||
extern VOID oAa7(LPBYTE I); // D=D+D f
|
||||
extern VOID oAa8(LPBYTE I); // B=B+A f
|
||||
extern VOID oAa9(LPBYTE I); // C=C+B f
|
||||
extern VOID oAaA(LPBYTE I); // A=A+C f
|
||||
extern VOID oAaB(LPBYTE I); // C=C+D f
|
||||
extern VOID oAaC(LPBYTE I); // A=A-1 f
|
||||
extern VOID oAaD(LPBYTE I); // B=B-1 f
|
||||
extern VOID oAaE(LPBYTE I); // C=C-1 f
|
||||
extern VOID oAaF(LPBYTE I); // D=D-1 f
|
||||
extern VOID oAb0(LPBYTE I); // A=0 f
|
||||
extern VOID oAb1(LPBYTE I); // B=0 f
|
||||
extern VOID oAb2(LPBYTE I); // C=0 f
|
||||
extern VOID oAb3(LPBYTE I); // D=0 f
|
||||
extern VOID oAb4(LPBYTE I); // A=B f
|
||||
extern VOID oAb5(LPBYTE I); // B=C f
|
||||
extern VOID oAb6(LPBYTE I); // C=A f
|
||||
extern VOID oAb7(LPBYTE I); // D=C f
|
||||
extern VOID oAb8(LPBYTE I); // B=A f
|
||||
extern VOID oAb9(LPBYTE I); // C=B f
|
||||
extern VOID oAbA(LPBYTE I); // A=C f
|
||||
extern VOID oAbB(LPBYTE I); // C=D f
|
||||
extern VOID oAbC(LPBYTE I); // ABEX f
|
||||
extern VOID oAbD(LPBYTE I); // BCEX f
|
||||
extern VOID oAbE(LPBYTE I); // CAEX f
|
||||
extern VOID oAbF(LPBYTE I); // DCEX f
|
||||
extern VOID oBa0(LPBYTE I); // A=A-B f
|
||||
extern VOID oBa1(LPBYTE I); // B=B-C f
|
||||
extern VOID oBa2(LPBYTE I); // C=C-A f
|
||||
extern VOID oBa3(LPBYTE I); // D=D-C f
|
||||
extern VOID oBa4(LPBYTE I); // A=A+1 f
|
||||
extern VOID oBa5(LPBYTE I); // B=B+1 f
|
||||
extern VOID oBa6(LPBYTE I); // C=C+1 f
|
||||
extern VOID oBa7(LPBYTE I); // D=D+1 f
|
||||
extern VOID oBa8(LPBYTE I); // B=B-A f
|
||||
extern VOID oBa9(LPBYTE I); // C=C-B f
|
||||
extern VOID oBaA(LPBYTE I); // A=A-C f
|
||||
extern VOID oBaB(LPBYTE I); // C=C-D f
|
||||
extern VOID oBaC(LPBYTE I); // A=B-A f
|
||||
extern VOID oBaD(LPBYTE I); // B=C-B f
|
||||
extern VOID oBaE(LPBYTE I); // C=A-C f
|
||||
extern VOID oBaF(LPBYTE I); // D=C-D f
|
||||
extern VOID oBb0(LPBYTE I); // ASL f
|
||||
extern VOID oBb1(LPBYTE I); // BSL f
|
||||
extern VOID oBb2(LPBYTE I); // CSL f
|
||||
extern VOID oBb3(LPBYTE I); // DSL f
|
||||
extern VOID oBb4(LPBYTE I); // ASR f
|
||||
extern VOID oBb5(LPBYTE I); // BSR f
|
||||
extern VOID oBb6(LPBYTE I); // CSR f
|
||||
extern VOID oBb7(LPBYTE I); // DSR f
|
||||
extern VOID oBb8(LPBYTE I); // A=-A f
|
||||
extern VOID oBb9(LPBYTE I); // B=-B f
|
||||
extern VOID oBbA(LPBYTE I); // C=-C f
|
||||
extern VOID oBbB(LPBYTE I); // D=-D f
|
||||
extern VOID oBbC(LPBYTE I); // A=-A-1 f
|
||||
extern VOID oBbD(LPBYTE I); // B=-B-1 f
|
||||
extern VOID oBbE(LPBYTE I); // C=-C-1 f
|
||||
extern VOID oBbF(LPBYTE I); // D=-D-1 f
|
||||
extern VOID oC0(LPBYTE I); // A=A+B A
|
||||
extern VOID oC1(LPBYTE I); // B=B+C A
|
||||
extern VOID oC2(LPBYTE I); // C=C+A A
|
||||
extern VOID oC3(LPBYTE I); // D=D+C A
|
||||
extern VOID oC4(LPBYTE I); // A=A+A A
|
||||
extern VOID oC5(LPBYTE I); // B=B+B A
|
||||
extern VOID oC6(LPBYTE I); // C=C+C A
|
||||
extern VOID oC7(LPBYTE I); // D=D+D A
|
||||
extern VOID oC8(LPBYTE I); // B=B+A A
|
||||
extern VOID oC9(LPBYTE I); // C=C+B A
|
||||
extern VOID oCA(LPBYTE I); // A=A+C A
|
||||
extern VOID oCB(LPBYTE I); // C=C+D A
|
||||
extern VOID oCC(LPBYTE I); // A=A-1 A
|
||||
extern VOID oCD(LPBYTE I); // B=B-1 A
|
||||
extern VOID oCE(LPBYTE I); // C=C-1 A
|
||||
extern VOID oCF(LPBYTE I); // D=D-1 A
|
||||
extern VOID oD0(LPBYTE I); // A=0 A
|
||||
extern VOID oD1(LPBYTE I); // B=0 A
|
||||
extern VOID oD2(LPBYTE I); // C=0 A
|
||||
extern VOID oD3(LPBYTE I); // D=0 A
|
||||
extern VOID oD4(LPBYTE I); // A=B A
|
||||
extern VOID oD5(LPBYTE I); // B=C A
|
||||
extern VOID oD6(LPBYTE I); // C=A A
|
||||
extern VOID oD7(LPBYTE I); // D=C A
|
||||
extern VOID oD8(LPBYTE I); // B=A A
|
||||
extern VOID oD9(LPBYTE I); // C=B A
|
||||
extern VOID oDA(LPBYTE I); // A=C A
|
||||
extern VOID oDB(LPBYTE I); // C=D A
|
||||
extern VOID oDC(LPBYTE I); // ABEX
|
||||
extern VOID oDD(LPBYTE I); // BCEX
|
||||
extern VOID oDE(LPBYTE I); // CAEX
|
||||
extern VOID oDF(LPBYTE I); // DCEX
|
||||
extern VOID oE0(LPBYTE I); // A=A-B A
|
||||
extern VOID oE1(LPBYTE I); // B=B-C A
|
||||
extern VOID oE2(LPBYTE I); // C=C-A A
|
||||
extern VOID oE3(LPBYTE I); // D=D-C A
|
||||
extern VOID oE4(LPBYTE I); // A=A+1 A
|
||||
extern VOID oE5(LPBYTE I); // B=B+1 A
|
||||
extern VOID oE6(LPBYTE I); // C=C+1 A
|
||||
extern VOID oE7(LPBYTE I); // D=D+1 A
|
||||
extern VOID oE8(LPBYTE I); // B=B-A A
|
||||
extern VOID oE9(LPBYTE I); // C=C-B A
|
||||
extern VOID oEA(LPBYTE I); // A=A-C A
|
||||
extern VOID oEB(LPBYTE I); // C=C-D A
|
||||
extern VOID oEC(LPBYTE I); // A=B-A A
|
||||
extern VOID oED(LPBYTE I); // B=C-B A
|
||||
extern VOID oEE(LPBYTE I); // C=A-C A
|
||||
extern VOID oEF(LPBYTE I); // D=C-D A
|
||||
extern VOID oF0(LPBYTE I); // ASL A
|
||||
extern VOID oF1(LPBYTE I); // BSL A
|
||||
extern VOID oF2(LPBYTE I); // CSL A
|
||||
extern VOID oF3(LPBYTE I); // DSL A
|
||||
extern VOID oF4(LPBYTE I); // ASR A
|
||||
extern VOID oF5(LPBYTE I); // BSR A
|
||||
extern VOID oF6(LPBYTE I); // CSR A
|
||||
extern VOID oF7(LPBYTE I); // DSR A
|
||||
extern VOID oF8(LPBYTE I); // A=-A A
|
||||
extern VOID oF9(LPBYTE I); // B=-B A
|
||||
extern VOID oFA(LPBYTE I); // C=-C A
|
||||
extern VOID oFB(LPBYTE I); // D=-D A
|
||||
extern VOID oFC(LPBYTE I); // A=-A-1 A
|
||||
extern VOID oFD(LPBYTE I); // B=-B-1 A
|
||||
extern VOID oFE(LPBYTE I); // C=-C-1 A
|
||||
extern VOID oFF(LPBYTE I); // D=-D-1 A
|
||||
|
||||
extern VOID o_invalid3(LPBYTE I);
|
||||
extern VOID o_invalid4(LPBYTE I);
|
||||
extern VOID o_invalid5(LPBYTE I);
|
||||
extern VOID o_invalid6(LPBYTE I);
|
||||
|
||||
extern VOID o_goyes3(LPBYTE I);
|
||||
extern VOID o_goyes5(LPBYTE I);
|
|
@ -1,462 +1,462 @@
|
|||
/*
|
||||
* ops.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
#define NFunpack(a, b, f) Nunpack((a)+F_s[f], b, F_l[f])
|
||||
#define NFread(a, b, f) Nread((a)+F_s[f], b, F_l[f])
|
||||
#define NFwrite(a, b, f) Nwrite((a)+F_s[f], b, F_l[f])
|
||||
#define NFcopy(a, b, f) memcpy((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFxchg(a, b, f) Nxchg((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFadd(a, b, f) Nadd((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFsub(a, b, f) Nsub((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFrsub(a, b, f) Nrsub((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFand(a, b, f) Nand((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFor(a, b, f) Nor((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFzero(a,f) memset((a)+F_s[f], 0, F_l[f])
|
||||
#define NFpack(a, f) Npack((a)+F_s[f], F_l[f])
|
||||
#define NFinc(a, f) Ninc(a, F_l[f], F_s[f])
|
||||
#define NFdec(a, f) Ndec(a, F_l[f], F_s[f])
|
||||
#define NFnot(a, f) Nnot((a)+F_s[f], F_l[f])
|
||||
#define NFneg(a, f) Nneg((a)+F_s[f], F_l[f])
|
||||
#define NFsl(a, f) Nsl((a)+F_s[f], F_l[f])
|
||||
#define NFsr(a, f) Nsr((a)+F_s[f], F_l[f])
|
||||
#define NFsrb(a, f) Nsrb((a)+F_s[f], F_l[f])
|
||||
#define TFe(a, b, f) Te((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFa(a, b, f) Ta((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFb(a, b, f) Tb((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFz(a, f) Tz((a)+F_s[f], F_l[f])
|
||||
#define TFne(a, b, f) Tne((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFae(a, b, f) Tae((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFbe(a, b, f) Tbe((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFnz(a, f) Tnz((a)+F_s[f], F_l[f])
|
||||
|
||||
static __inline LPBYTE FASTPTR(DWORD d)
|
||||
{
|
||||
static BYTE pbyNULL[21];
|
||||
LPBYTE lpbyPage;
|
||||
DWORD u, v;
|
||||
|
||||
d &= 0xFFFFF; // handle address overflows
|
||||
|
||||
u = d >> 12; // page
|
||||
v = d & 0xFFF; // offset
|
||||
|
||||
if ( !(Chipset.IOCfig && ((d & 0xFFFC0) == Chipset.IOBase))
|
||||
&& RMap[u] != NULL // page valid
|
||||
&& ( v < 0x1000 - ARRAYSIZEOF(pbyNULL) // complete opcode inside page
|
||||
// or next page continue linear addressing
|
||||
|| (RMap[u] + 0x1000 == RMap[(u+1) & (ARRAYSIZEOF(RMap)-1)])
|
||||
)
|
||||
)
|
||||
{
|
||||
lpbyPage = RMap[u] + v; // full address
|
||||
}
|
||||
else
|
||||
{
|
||||
lpbyPage = pbyNULL; // memory allocation
|
||||
Npeek(lpbyPage, d, ARRAYSIZEOF(pbyNULL)); // fill with data (LAHEX + 16 digits = longest opcode)
|
||||
}
|
||||
return lpbyPage;
|
||||
}
|
||||
|
||||
static __inline void rstkpush(DWORD d)
|
||||
{
|
||||
Chipset.rstk[Chipset.rstkp] = d;
|
||||
Chipset.rstkp=(Chipset.rstkp+1)&7;
|
||||
}
|
||||
|
||||
static __inline DWORD rstkpop(VOID)
|
||||
{
|
||||
DWORD r;
|
||||
|
||||
Chipset.rstkp=(Chipset.rstkp-1)&7;
|
||||
r = Chipset.rstk[Chipset.rstkp];
|
||||
Chipset.rstk[Chipset.rstkp] = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline DWORD Npack(BYTE *a, UINT s)
|
||||
{
|
||||
DWORD r = 0;
|
||||
|
||||
while (s--) r = (r<<4)|a[s];
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline VOID Nunpack(BYTE *a, DWORD b, UINT s)
|
||||
{
|
||||
for (; s>0; --s) { *a++ = (BYTE)(b&0xf); b>>=4; }
|
||||
}
|
||||
|
||||
static __inline void Nxchg(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
BYTE X[16];
|
||||
|
||||
memcpy(X, b, s);
|
||||
memcpy(b, a, s);
|
||||
memcpy(a, X, s);
|
||||
}
|
||||
|
||||
static __inline void Ninc(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
if (Chipset.mode_dec)
|
||||
{
|
||||
BYTE c = 1;
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
// illegal number in dec mode
|
||||
if (a[i] >= 10) a[i] &= 0x7;
|
||||
|
||||
a[i] += c;
|
||||
c = (a[i] >= 10);
|
||||
if (c) a[i] -= 10;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
a[i]++;
|
||||
if (a[i] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void Ninc16(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
a[i&0xf]++;
|
||||
if (a[i&0xf] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i&0xf] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Nincx(BYTE *a, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i]++;
|
||||
if (a[i] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Ndec(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
a[i]--;
|
||||
if ((a[i] & 0xF0) == 0) // check overflow
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] += cBase;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Ndec16(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
a[i&0xf]--;
|
||||
if (a[i&0xf] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i&0xf] += 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Nadd(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
// illegal number in dec mode
|
||||
if (a[i] >= cBase) a[i] &= 0x7;
|
||||
|
||||
a[i] += b[i] + c;
|
||||
if (a[i] >= cBase)
|
||||
{
|
||||
a[i] -= cBase;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nsub(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i] = a[i] - b[i] - c;
|
||||
if ((a[i] & 0xF0) != 0) // check overflow
|
||||
{
|
||||
a[i] += cBase;
|
||||
// illegal number in dec mode
|
||||
if ((a[i] & 0xF0) != 0) a[i] &= 0x7;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nrsub(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i] = b[i] - a[i] - c;
|
||||
if ((a[i] & 0xF0) != 0) // check overflow
|
||||
{
|
||||
a[i] += cBase;
|
||||
// illegal number in dec mode
|
||||
if ((a[i] & 0xF0) != 0) a[i] &= 0x7;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nand(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--) a[s] &= b[s];
|
||||
}
|
||||
|
||||
static __inline void Nor(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--) a[s] |= b[s];
|
||||
}
|
||||
|
||||
static __inline void Nnot(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE cBase = Chipset.mode_dec ? 9 : 15;
|
||||
|
||||
while (s--)
|
||||
{
|
||||
a[s] = cBase - a[s];
|
||||
if ((a[s] & 0xF0) != 0) // check overflow (dec mode only)
|
||||
a[s] &= 0x7;
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Nneg(BYTE *a, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=0; i<s && a[i]==0; ++i) { } // search for non-zero digit
|
||||
if ((Chipset.carry = (i!=s))) // value was non-zero
|
||||
{
|
||||
BYTE cBase = Chipset.mode_dec ? 9 : 15;
|
||||
|
||||
_ASSERT(a[i] > 0); // check for non-zero digit
|
||||
for (--a[i]; i<s; ++i)
|
||||
{
|
||||
a[i] = cBase - a[i];
|
||||
if ((a[i] & 0xF0) != 0) // check overflow (dec mode only)
|
||||
a[i] &= 0x7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void Nsl(BYTE *a, UINT s)
|
||||
{
|
||||
while (--s) a[s] = a[s-1];
|
||||
*a = 0;
|
||||
}
|
||||
|
||||
static __inline void Nslc(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE c = a[s-1];
|
||||
|
||||
while (--s) a[s] = a[s-1];
|
||||
*a = c;
|
||||
}
|
||||
|
||||
static __inline void Nsr(BYTE *a, UINT s)
|
||||
{
|
||||
if (*a) Chipset.HST |= SB;
|
||||
while (--s) { *a = a[1]; a++; }
|
||||
*a = 0;
|
||||
}
|
||||
|
||||
static __inline void Nsrc(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE c = *a;
|
||||
|
||||
if (c) Chipset.HST |= SB;
|
||||
while (--s) { *a = a[1]; a++; }
|
||||
*a = c;
|
||||
}
|
||||
|
||||
static __inline void Nsrb(BYTE *a, UINT s)
|
||||
{
|
||||
if (*a & 1) Chipset.HST |= SB;
|
||||
while (--s)
|
||||
{
|
||||
*a >>= 1;
|
||||
*a |= ((a[1] & 1) << 3);
|
||||
a++;
|
||||
}
|
||||
*a >>= 1;
|
||||
}
|
||||
|
||||
static __inline void Nbit0(BYTE *a, UINT b)
|
||||
{
|
||||
a[b>>2] &= ~(1<<(b&3));
|
||||
}
|
||||
|
||||
static __inline void Nbit1(BYTE *a, UINT b)
|
||||
{
|
||||
a[b>>2] |= 1<<(b&3);
|
||||
}
|
||||
|
||||
static __inline void Tbit0(BYTE *a, UINT b)
|
||||
{
|
||||
Chipset.carry = ((a[b>>2] & (1<<(b&3))) == 0);
|
||||
}
|
||||
|
||||
static __inline void Tbit1(BYTE *a, UINT b)
|
||||
{
|
||||
Chipset.carry = ((a[b>>2] & (1<<(b&3))) != 0);
|
||||
}
|
||||
|
||||
static __inline void Te(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=b[s])
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Tne(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=b[s])
|
||||
{
|
||||
Chipset.carry = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Tz(BYTE *a, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=0)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Tnz(BYTE *a, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=0)
|
||||
{
|
||||
Chipset.carry = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Ta(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]>b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tb(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]<b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tae(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]>=b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tbe(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]<=b[s]);
|
||||
}
|
||||
/*
|
||||
* ops.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
#define NFunpack(a, b, f) Nunpack((a)+F_s[f], b, F_l[f])
|
||||
#define NFread(a, b, f) Nread((a)+F_s[f], b, F_l[f])
|
||||
#define NFwrite(a, b, f) Nwrite((a)+F_s[f], b, F_l[f])
|
||||
#define NFcopy(a, b, f) memcpy((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFxchg(a, b, f) Nxchg((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFadd(a, b, f) Nadd((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFsub(a, b, f) Nsub((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFrsub(a, b, f) Nrsub((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFand(a, b, f) Nand((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFor(a, b, f) Nor((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define NFzero(a,f) memset((a)+F_s[f], 0, F_l[f])
|
||||
#define NFpack(a, f) Npack((a)+F_s[f], F_l[f])
|
||||
#define NFinc(a, f) Ninc(a, F_l[f], F_s[f])
|
||||
#define NFdec(a, f) Ndec(a, F_l[f], F_s[f])
|
||||
#define NFnot(a, f) Nnot((a)+F_s[f], F_l[f])
|
||||
#define NFneg(a, f) Nneg((a)+F_s[f], F_l[f])
|
||||
#define NFsl(a, f) Nsl((a)+F_s[f], F_l[f])
|
||||
#define NFsr(a, f) Nsr((a)+F_s[f], F_l[f])
|
||||
#define NFsrb(a, f) Nsrb((a)+F_s[f], F_l[f])
|
||||
#define TFe(a, b, f) Te((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFa(a, b, f) Ta((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFb(a, b, f) Tb((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFz(a, f) Tz((a)+F_s[f], F_l[f])
|
||||
#define TFne(a, b, f) Tne((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFae(a, b, f) Tae((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFbe(a, b, f) Tbe((a)+F_s[f], (b)+F_s[f], F_l[f])
|
||||
#define TFnz(a, f) Tnz((a)+F_s[f], F_l[f])
|
||||
|
||||
static __inline LPBYTE FASTPTR(DWORD d)
|
||||
{
|
||||
static BYTE pbyNULL[21];
|
||||
LPBYTE lpbyPage;
|
||||
DWORD u, v;
|
||||
|
||||
d &= 0xFFFFF; // handle address overflows
|
||||
|
||||
u = d >> 12; // page
|
||||
v = d & 0xFFF; // offset
|
||||
|
||||
if ( !(Chipset.IOCfig && ((d & 0xFFFC0) == Chipset.IOBase))
|
||||
&& RMap[u] != NULL // page valid
|
||||
&& ( v < 0x1000 - ARRAYSIZEOF(pbyNULL) // complete opcode inside page
|
||||
// or next page continue linear addressing
|
||||
|| (RMap[u] + 0x1000 == RMap[(u+1) & (ARRAYSIZEOF(RMap)-1)])
|
||||
)
|
||||
)
|
||||
{
|
||||
lpbyPage = RMap[u] + v; // full address
|
||||
}
|
||||
else
|
||||
{
|
||||
lpbyPage = pbyNULL; // memory allocation
|
||||
Npeek(lpbyPage, d, ARRAYSIZEOF(pbyNULL)); // fill with data (LAHEX + 16 digits = longest opcode)
|
||||
}
|
||||
return lpbyPage;
|
||||
}
|
||||
|
||||
static __inline void rstkpush(DWORD d)
|
||||
{
|
||||
Chipset.rstk[Chipset.rstkp] = d;
|
||||
Chipset.rstkp=(Chipset.rstkp+1)&7;
|
||||
}
|
||||
|
||||
static __inline DWORD rstkpop(VOID)
|
||||
{
|
||||
DWORD r;
|
||||
|
||||
Chipset.rstkp=(Chipset.rstkp-1)&7;
|
||||
r = Chipset.rstk[Chipset.rstkp];
|
||||
Chipset.rstk[Chipset.rstkp] = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline DWORD Npack(BYTE *a, UINT s)
|
||||
{
|
||||
DWORD r = 0;
|
||||
|
||||
while (s--) r = (r<<4)|a[s];
|
||||
return r;
|
||||
}
|
||||
|
||||
static __inline VOID Nunpack(BYTE *a, DWORD b, UINT s)
|
||||
{
|
||||
for (; s>0; --s) { *a++ = (BYTE)(b&0xf); b>>=4; }
|
||||
}
|
||||
|
||||
static __inline void Nxchg(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
BYTE X[16];
|
||||
|
||||
memcpy(X, b, s);
|
||||
memcpy(b, a, s);
|
||||
memcpy(a, X, s);
|
||||
}
|
||||
|
||||
static __inline void Ninc(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
if (Chipset.mode_dec)
|
||||
{
|
||||
BYTE c = 1;
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
// illegal number in dec mode
|
||||
if (a[i] >= 10) a[i] &= 0x7;
|
||||
|
||||
a[i] += c;
|
||||
c = (a[i] >= 10);
|
||||
if (c) a[i] -= 10;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
a[i]++;
|
||||
if (a[i] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void Ninc16(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
a[i&0xf]++;
|
||||
if (a[i&0xf] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i&0xf] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Nincx(BYTE *a, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i]++;
|
||||
if (a[i] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] -= 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Ndec(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
// no register wrap
|
||||
_ASSERT(i < ARRAYSIZEOF(((CHIPSET *) NULL)->A));
|
||||
|
||||
a[i]--;
|
||||
if ((a[i] & 0xF0) == 0) // check overflow
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i] += cBase;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Ndec16(BYTE *a, UINT s, UINT d)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=d; i<s+d; ++i)
|
||||
{
|
||||
a[i&0xf]--;
|
||||
if (a[i&0xf] < 16)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
a[i&0xf] += 16;
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Nadd(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
// illegal number in dec mode
|
||||
if (a[i] >= cBase) a[i] &= 0x7;
|
||||
|
||||
a[i] += b[i] + c;
|
||||
if (a[i] >= cBase)
|
||||
{
|
||||
a[i] -= cBase;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nsub(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i] = a[i] - b[i] - c;
|
||||
if ((a[i] & 0xF0) != 0) // check overflow
|
||||
{
|
||||
a[i] += cBase;
|
||||
// illegal number in dec mode
|
||||
if ((a[i] & 0xF0) != 0) a[i] &= 0x7;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nrsub(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
BYTE c = 0;
|
||||
BYTE cBase = Chipset.mode_dec ? 10 : 16;
|
||||
|
||||
for (i=0; i<s; ++i)
|
||||
{
|
||||
a[i] = b[i] - a[i] - c;
|
||||
if ((a[i] & 0xF0) != 0) // check overflow
|
||||
{
|
||||
a[i] += cBase;
|
||||
// illegal number in dec mode
|
||||
if ((a[i] & 0xF0) != 0) a[i] &= 0x7;
|
||||
c = 1;
|
||||
}
|
||||
else
|
||||
c = 0;
|
||||
}
|
||||
Chipset.carry = (c==1);
|
||||
}
|
||||
|
||||
static __inline void Nand(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--) a[s] &= b[s];
|
||||
}
|
||||
|
||||
static __inline void Nor(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--) a[s] |= b[s];
|
||||
}
|
||||
|
||||
static __inline void Nnot(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE cBase = Chipset.mode_dec ? 9 : 15;
|
||||
|
||||
while (s--)
|
||||
{
|
||||
a[s] = cBase - a[s];
|
||||
if ((a[s] & 0xF0) != 0) // check overflow (dec mode only)
|
||||
a[s] &= 0x7;
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Nneg(BYTE *a, UINT s)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i=0; i<s && a[i]==0; ++i) { } // search for non-zero digit
|
||||
if ((Chipset.carry = (i!=s))) // value was non-zero
|
||||
{
|
||||
BYTE cBase = Chipset.mode_dec ? 9 : 15;
|
||||
|
||||
_ASSERT(a[i] > 0); // check for non-zero digit
|
||||
for (--a[i]; i<s; ++i)
|
||||
{
|
||||
a[i] = cBase - a[i];
|
||||
if ((a[i] & 0xF0) != 0) // check overflow (dec mode only)
|
||||
a[i] &= 0x7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static __inline void Nsl(BYTE *a, UINT s)
|
||||
{
|
||||
while (--s) a[s] = a[s-1];
|
||||
*a = 0;
|
||||
}
|
||||
|
||||
static __inline void Nslc(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE c = a[s-1];
|
||||
|
||||
while (--s) a[s] = a[s-1];
|
||||
*a = c;
|
||||
}
|
||||
|
||||
static __inline void Nsr(BYTE *a, UINT s)
|
||||
{
|
||||
if (*a) Chipset.HST |= SB;
|
||||
while (--s) { *a = a[1]; a++; }
|
||||
*a = 0;
|
||||
}
|
||||
|
||||
static __inline void Nsrc(BYTE *a, UINT s)
|
||||
{
|
||||
BYTE c = *a;
|
||||
|
||||
if (c) Chipset.HST |= SB;
|
||||
while (--s) { *a = a[1]; a++; }
|
||||
*a = c;
|
||||
}
|
||||
|
||||
static __inline void Nsrb(BYTE *a, UINT s)
|
||||
{
|
||||
if (*a & 1) Chipset.HST |= SB;
|
||||
while (--s)
|
||||
{
|
||||
*a >>= 1;
|
||||
*a |= ((a[1] & 1) << 3);
|
||||
a++;
|
||||
}
|
||||
*a >>= 1;
|
||||
}
|
||||
|
||||
static __inline void Nbit0(BYTE *a, UINT b)
|
||||
{
|
||||
a[b>>2] &= ~(1<<(b&3));
|
||||
}
|
||||
|
||||
static __inline void Nbit1(BYTE *a, UINT b)
|
||||
{
|
||||
a[b>>2] |= 1<<(b&3);
|
||||
}
|
||||
|
||||
static __inline void Tbit0(BYTE *a, UINT b)
|
||||
{
|
||||
Chipset.carry = ((a[b>>2] & (1<<(b&3))) == 0);
|
||||
}
|
||||
|
||||
static __inline void Tbit1(BYTE *a, UINT b)
|
||||
{
|
||||
Chipset.carry = ((a[b>>2] & (1<<(b&3))) != 0);
|
||||
}
|
||||
|
||||
static __inline void Te(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=b[s])
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Tne(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=b[s])
|
||||
{
|
||||
Chipset.carry = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Tz(BYTE *a, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=0)
|
||||
{
|
||||
Chipset.carry = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = TRUE;
|
||||
}
|
||||
|
||||
static __inline void Tnz(BYTE *a, UINT s)
|
||||
{
|
||||
while (s--)
|
||||
{
|
||||
if (a[s]!=0)
|
||||
{
|
||||
Chipset.carry = TRUE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chipset.carry = FALSE;
|
||||
}
|
||||
|
||||
static __inline void Ta(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]>b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tb(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]<b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tae(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]>=b[s]);
|
||||
}
|
||||
|
||||
static __inline void Tbe(BYTE *a, BYTE *b, UINT s)
|
||||
{
|
||||
while (--s) if (a[s]!=b[s]) break;
|
||||
Chipset.carry = (a[s]<=b[s]);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// PCH.C
|
||||
//
|
||||
|
||||
#include "pch.h"
|
||||
//
|
||||
// PCH.C
|
||||
//
|
||||
|
||||
#include "pch.h"
|
|
@ -1,112 +1,112 @@
|
|||
//
|
||||
// PCH.H
|
||||
//
|
||||
|
||||
#define _WIN32_IE 0x0200
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
#include <conio.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#if !defined VERIFY
|
||||
#if defined _DEBUG
|
||||
#define VERIFY(f) _ASSERT(f)
|
||||
#else // _DEBUG
|
||||
#define VERIFY(f) ((VOID)(f))
|
||||
#endif // _DEBUG
|
||||
#endif // _VERIFY
|
||||
|
||||
#if !defined INVALID_SET_FILE_POINTER
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
#if !defined INVALID_FILE_ATTRIBUTES
|
||||
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
#if !defined GWLP_USERDATA
|
||||
#define GWLP_USERDATA GWL_USERDATA
|
||||
#endif
|
||||
|
||||
#if !defined GCLP_HCURSOR
|
||||
#define GCLP_HCURSOR GCL_HCURSOR
|
||||
#endif
|
||||
|
||||
#if !defined IDC_HAND // Win2k specific definition
|
||||
#define IDC_HAND MAKEINTRESOURCE(32649)
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1200 // missing type definition in the MSVC6.0 SDK and earlier
|
||||
#define __unaligned
|
||||
#define SetWindowLongPtr SetWindowLong
|
||||
#define GetWindowLongPtr GetWindowLong
|
||||
#define SetClassLongPtr SetClassLong
|
||||
#define GetClassLongPtr GetClassLong
|
||||
typedef SIZE_T DWORD_PTR, *PDWORD_PTR;
|
||||
typedef ULONG ULONG_PTR, *PULONG_PTR;
|
||||
typedef LONG LONG_PTR, *PLONG_PTR;
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_CURRENT_VERSION
|
||||
#define PROCESS_POWER_THROTTLING_CURRENT_VERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
|
||||
#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x04
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1900 // add until VS2015 from processthreadsapi.h
|
||||
enum { ProcessPowerThrottling = 4 };
|
||||
|
||||
typedef struct _PROCESS_POWER_THROTTLING_STATE {
|
||||
ULONG Version;
|
||||
ULONG ControlMask;
|
||||
ULONG StateMask;
|
||||
} PROCESS_POWER_THROTTLING_STATE, * PPROCESS_POWER_THROTTLING_STATE;
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1400 // valid for VS2005 and later
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='x86' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='ia64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='amd64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='*' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
// PCH.H
|
||||
//
|
||||
|
||||
#define _WIN32_IE 0x0200
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
#include <conio.h>
|
||||
#include <crtdbg.h>
|
||||
|
||||
#if !defined VERIFY
|
||||
#if defined _DEBUG
|
||||
#define VERIFY(f) _ASSERT(f)
|
||||
#else // _DEBUG
|
||||
#define VERIFY(f) ((VOID)(f))
|
||||
#endif // _DEBUG
|
||||
#endif // _VERIFY
|
||||
|
||||
#if !defined INVALID_SET_FILE_POINTER
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
#if !defined INVALID_FILE_ATTRIBUTES
|
||||
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
#if !defined GWLP_USERDATA
|
||||
#define GWLP_USERDATA GWL_USERDATA
|
||||
#endif
|
||||
|
||||
#if !defined GCLP_HCURSOR
|
||||
#define GCLP_HCURSOR GCL_HCURSOR
|
||||
#endif
|
||||
|
||||
#if !defined IDC_HAND // Win2k specific definition
|
||||
#define IDC_HAND MAKEINTRESOURCE(32649)
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1200 // missing type definition in the MSVC6.0 SDK and earlier
|
||||
#define __unaligned
|
||||
#define SetWindowLongPtr SetWindowLong
|
||||
#define GetWindowLongPtr GetWindowLong
|
||||
#define SetClassLongPtr SetClassLong
|
||||
#define GetClassLongPtr GetClassLong
|
||||
typedef SIZE_T DWORD_PTR, *PDWORD_PTR;
|
||||
typedef ULONG ULONG_PTR, *PULONG_PTR;
|
||||
typedef LONG LONG_PTR, *PLONG_PTR;
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_CURRENT_VERSION
|
||||
#define PROCESS_POWER_THROTTLING_CURRENT_VERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
|
||||
#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x04
|
||||
#endif
|
||||
|
||||
#if _MSC_VER <= 1900 // add until VS2015 from processthreadsapi.h
|
||||
enum { ProcessPowerThrottling = 4 };
|
||||
|
||||
typedef struct _PROCESS_POWER_THROTTLING_STATE {
|
||||
ULONG Version;
|
||||
ULONG ControlMask;
|
||||
ULONG StateMask;
|
||||
} PROCESS_POWER_THROTTLING_STATE, * PPROCESS_POWER_THROTTLING_STATE;
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1400 // valid for VS2005 and later
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='x86' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='ia64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='amd64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='*' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#endif
|
||||
#endif
|
|
@ -1,57 +1,57 @@
|
|||
/*
|
||||
* pngcrc.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2023 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/* CRC polynomial: 0xedb88320 */
|
||||
static const unsigned lodepng_crc32_table[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
/*Return the CRC of the bytes buf[0..len-1].*/
|
||||
unsigned lodepng_crc32(const unsigned char* data, size_t length)
|
||||
{
|
||||
unsigned r = 0xffffffffu;
|
||||
while (length--)
|
||||
{
|
||||
r = lodepng_crc32_table[(r ^ *data++) & 0xffu] ^ (r >> 8u);
|
||||
}
|
||||
return ~r;
|
||||
}
|
||||
/*
|
||||
* pngcrc.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2023 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
|
||||
/* CRC polynomial: 0xedb88320 */
|
||||
static const unsigned lodepng_crc32_table[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
/*Return the CRC of the bytes buf[0..len-1].*/
|
||||
unsigned lodepng_crc32(const unsigned char* data, size_t length)
|
||||
{
|
||||
unsigned r = 0xffffffffu;
|
||||
while (length--)
|
||||
{
|
||||
r = lodepng_crc32_table[(r ^ *data++) & 0xffu] ^ (r >> 8u);
|
||||
}
|
||||
return ~r;
|
||||
}
|
|
@ -1,177 +1,177 @@
|
|||
/*
|
||||
* redeye.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2011 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
#define ERR_CHAR 127 // character for transfer error
|
||||
|
||||
#define H1 0x78
|
||||
#define H2 0xE6
|
||||
#define H3 0xD5
|
||||
#define H4 0x8B
|
||||
|
||||
// HP redeye correction masks
|
||||
static CONST BYTE byEmask[] = { H1, H2, H3, H4 };
|
||||
|
||||
static __inline UINT MAX(UINT a, UINT b)
|
||||
{
|
||||
return (a>b)?a:b;
|
||||
}
|
||||
|
||||
static __inline BYTE Parity(BYTE b)
|
||||
{
|
||||
b ^= (b >> 4);
|
||||
b ^= (b >> 2);
|
||||
b ^= (b >> 1);
|
||||
return b & 1;
|
||||
}
|
||||
|
||||
static __inline BYTE CreateCorrectionBits(BYTE b)
|
||||
{
|
||||
UINT i;
|
||||
BYTE byVal = 0;
|
||||
|
||||
for (i = 0; i < ARRAYSIZEOF(byEmask);++i)
|
||||
{
|
||||
byVal <<= 1;
|
||||
byVal |= Parity((BYTE) (b & byEmask[i]));
|
||||
}
|
||||
return byVal;
|
||||
}
|
||||
|
||||
static __inline WORD CorrectData(WORD wData,WORD wMissed)
|
||||
{
|
||||
while ((wMissed & 0xFF) != 0) // clear every missed bit in data area
|
||||
{
|
||||
BYTE byBitMask;
|
||||
|
||||
// detect valid H(i) mask
|
||||
WORD wMi = 0x800; // first M(i) bit
|
||||
INT i = 0; // index to first H(i) mask
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if ((wMissed & wMi) == 0) // possible valid mask
|
||||
{
|
||||
_ASSERT(i < ARRAYSIZEOF(byEmask));
|
||||
|
||||
// select bit to correct
|
||||
byBitMask = wMissed & byEmask[i];
|
||||
|
||||
if (Parity(byBitMask)) // only one bit set (parity odd)
|
||||
break; // -> valid H(i) mask
|
||||
}
|
||||
|
||||
wMi >>= 1; // next M(i) bit
|
||||
i++; // next H(i) mask
|
||||
}
|
||||
|
||||
// correct bit with H(i) mask
|
||||
wMissed ^= byBitMask; // clear this missed bit
|
||||
|
||||
// parity odd -> wrong data value
|
||||
if (Parity((BYTE) ((wData & byEmask[i]) ^ ((wData & wMi) >> 8))))
|
||||
wData ^= byBitMask; // correct value
|
||||
}
|
||||
return wData & 0xFF; // only data byte is correct
|
||||
}
|
||||
|
||||
VOID IrPrinter(BYTE c)
|
||||
{
|
||||
static INT nFrame = 0; // frame counter
|
||||
static DWORD dwData = 0; // half bit data container
|
||||
static INT nStart = 0; // frame counter disabled
|
||||
|
||||
BOOL bLSRQ;
|
||||
|
||||
dwData = (dwData << 1) | (c & LBO); // grab the last 32 bit send through IR
|
||||
|
||||
// Led Service ReQuest on Led Buffer Empty enabled
|
||||
bLSRQ = (Chipset.IORam[LCR] & ELBE) != 0;
|
||||
|
||||
IOBit(SRQ2,LSRQ,bLSRQ); // update LSRQ bit
|
||||
if (bLSRQ) // interrupt on Led Buffer Empty enabled
|
||||
{
|
||||
Chipset.SoftInt = TRUE; // execute interrupt
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
|
||||
// HP40G and HP49G have no IR transmitter Led
|
||||
if ((cCurrentRomType == 'E' && nCurrentClass == 40) || cCurrentRomType == 'X')
|
||||
return;
|
||||
|
||||
if (nFrame == 0) // waiting for start bit condition
|
||||
{
|
||||
if ((dwData & 0x3F) == 0x07) // start bit condition (000111 pattern)
|
||||
{
|
||||
nStart = 1; // enable frame counter
|
||||
}
|
||||
}
|
||||
|
||||
if (nFrame == 24) // 24 half bit received
|
||||
{
|
||||
INT i;
|
||||
|
||||
WORD wData = 0; // data container
|
||||
WORD wMissed = 0; // missed bit container
|
||||
INT nCount = 0; // no. of missed bits
|
||||
|
||||
nFrame = 0; // reset for next character
|
||||
nStart = 0; // disable frame counter
|
||||
|
||||
// separate to data and missed bits
|
||||
for (i = 0; i < 12; ++i) // 12 bit frames
|
||||
{
|
||||
BYTE b = (BYTE) (dwData & 3); // last 2 half bits
|
||||
|
||||
if (b == 0x0 || b == 0x3) // illegal half bit combination
|
||||
{
|
||||
wMissed |= (1 << i); // this is a missed bit
|
||||
++nCount; // incr. number of missed bits
|
||||
}
|
||||
else // valid data bit
|
||||
{
|
||||
wData |= ((b >> 1) << i); // add data bit
|
||||
}
|
||||
dwData >>= 2; // next 2 half bits
|
||||
}
|
||||
|
||||
if (nCount <= 2) // error can be fixed
|
||||
{
|
||||
BYTE byOrgParity,byNewParity;
|
||||
|
||||
byOrgParity = wData >> 8; // the original parity information with missed bits
|
||||
byNewParity = ~(wMissed >> 8); // missed bit mask for recalculated parity
|
||||
|
||||
if (nCount > 0) // error correction
|
||||
{
|
||||
wData = CorrectData(wData,wMissed);
|
||||
}
|
||||
|
||||
wData &= 0xFF; // remove parity information
|
||||
|
||||
// recalculate parity data
|
||||
byNewParity &= CreateCorrectionBits((BYTE) wData);
|
||||
|
||||
// wrong parity
|
||||
if (byOrgParity != byNewParity)
|
||||
wData = ERR_CHAR; // character for transfer error
|
||||
}
|
||||
else
|
||||
{
|
||||
wData = ERR_CHAR; // character for transfer error
|
||||
}
|
||||
|
||||
SendByteUdp((BYTE) wData); // send data byte
|
||||
return;
|
||||
}
|
||||
nFrame += nStart; // next frame
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* redeye.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2011 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
#define ERR_CHAR 127 // character for transfer error
|
||||
|
||||
#define H1 0x78
|
||||
#define H2 0xE6
|
||||
#define H3 0xD5
|
||||
#define H4 0x8B
|
||||
|
||||
// HP redeye correction masks
|
||||
static CONST BYTE byEmask[] = { H1, H2, H3, H4 };
|
||||
|
||||
static __inline UINT MAX(UINT a, UINT b)
|
||||
{
|
||||
return (a>b)?a:b;
|
||||
}
|
||||
|
||||
static __inline BYTE Parity(BYTE b)
|
||||
{
|
||||
b ^= (b >> 4);
|
||||
b ^= (b >> 2);
|
||||
b ^= (b >> 1);
|
||||
return b & 1;
|
||||
}
|
||||
|
||||
static __inline BYTE CreateCorrectionBits(BYTE b)
|
||||
{
|
||||
UINT i;
|
||||
BYTE byVal = 0;
|
||||
|
||||
for (i = 0; i < ARRAYSIZEOF(byEmask);++i)
|
||||
{
|
||||
byVal <<= 1;
|
||||
byVal |= Parity((BYTE) (b & byEmask[i]));
|
||||
}
|
||||
return byVal;
|
||||
}
|
||||
|
||||
static __inline WORD CorrectData(WORD wData,WORD wMissed)
|
||||
{
|
||||
while ((wMissed & 0xFF) != 0) // clear every missed bit in data area
|
||||
{
|
||||
BYTE byBitMask;
|
||||
|
||||
// detect valid H(i) mask
|
||||
WORD wMi = 0x800; // first M(i) bit
|
||||
INT i = 0; // index to first H(i) mask
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
if ((wMissed & wMi) == 0) // possible valid mask
|
||||
{
|
||||
_ASSERT(i < ARRAYSIZEOF(byEmask));
|
||||
|
||||
// select bit to correct
|
||||
byBitMask = wMissed & byEmask[i];
|
||||
|
||||
if (Parity(byBitMask)) // only one bit set (parity odd)
|
||||
break; // -> valid H(i) mask
|
||||
}
|
||||
|
||||
wMi >>= 1; // next M(i) bit
|
||||
i++; // next H(i) mask
|
||||
}
|
||||
|
||||
// correct bit with H(i) mask
|
||||
wMissed ^= byBitMask; // clear this missed bit
|
||||
|
||||
// parity odd -> wrong data value
|
||||
if (Parity((BYTE) ((wData & byEmask[i]) ^ ((wData & wMi) >> 8))))
|
||||
wData ^= byBitMask; // correct value
|
||||
}
|
||||
return wData & 0xFF; // only data byte is correct
|
||||
}
|
||||
|
||||
VOID IrPrinter(BYTE c)
|
||||
{
|
||||
static INT nFrame = 0; // frame counter
|
||||
static DWORD dwData = 0; // half bit data container
|
||||
static INT nStart = 0; // frame counter disabled
|
||||
|
||||
BOOL bLSRQ;
|
||||
|
||||
dwData = (dwData << 1) | (c & LBO); // grab the last 32 bit send through IR
|
||||
|
||||
// Led Service ReQuest on Led Buffer Empty enabled
|
||||
bLSRQ = (Chipset.IORam[LCR] & ELBE) != 0;
|
||||
|
||||
IOBit(SRQ2,LSRQ,bLSRQ); // update LSRQ bit
|
||||
if (bLSRQ) // interrupt on Led Buffer Empty enabled
|
||||
{
|
||||
Chipset.SoftInt = TRUE; // execute interrupt
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
|
||||
// HP40G and HP49G have no IR transmitter Led
|
||||
if ((cCurrentRomType == 'E' && nCurrentClass == 40) || cCurrentRomType == 'X')
|
||||
return;
|
||||
|
||||
if (nFrame == 0) // waiting for start bit condition
|
||||
{
|
||||
if ((dwData & 0x3F) == 0x07) // start bit condition (000111 pattern)
|
||||
{
|
||||
nStart = 1; // enable frame counter
|
||||
}
|
||||
}
|
||||
|
||||
if (nFrame == 24) // 24 half bit received
|
||||
{
|
||||
INT i;
|
||||
|
||||
WORD wData = 0; // data container
|
||||
WORD wMissed = 0; // missed bit container
|
||||
INT nCount = 0; // no. of missed bits
|
||||
|
||||
nFrame = 0; // reset for next character
|
||||
nStart = 0; // disable frame counter
|
||||
|
||||
// separate to data and missed bits
|
||||
for (i = 0; i < 12; ++i) // 12 bit frames
|
||||
{
|
||||
BYTE b = (BYTE) (dwData & 3); // last 2 half bits
|
||||
|
||||
if (b == 0x0 || b == 0x3) // illegal half bit combination
|
||||
{
|
||||
wMissed |= (1 << i); // this is a missed bit
|
||||
++nCount; // incr. number of missed bits
|
||||
}
|
||||
else // valid data bit
|
||||
{
|
||||
wData |= ((b >> 1) << i); // add data bit
|
||||
}
|
||||
dwData >>= 2; // next 2 half bits
|
||||
}
|
||||
|
||||
if (nCount <= 2) // error can be fixed
|
||||
{
|
||||
BYTE byOrgParity,byNewParity;
|
||||
|
||||
byOrgParity = wData >> 8; // the original parity information with missed bits
|
||||
byNewParity = ~(wMissed >> 8); // missed bit mask for recalculated parity
|
||||
|
||||
if (nCount > 0) // error correction
|
||||
{
|
||||
wData = CorrectData(wData,wMissed);
|
||||
}
|
||||
|
||||
wData &= 0xFF; // remove parity information
|
||||
|
||||
// recalculate parity data
|
||||
byNewParity &= CreateCorrectionBits((BYTE) wData);
|
||||
|
||||
// wrong parity
|
||||
if (byOrgParity != byNewParity)
|
||||
wData = ERR_CHAR; // character for transfer error
|
||||
}
|
||||
else
|
||||
{
|
||||
wData = ERR_CHAR; // character for transfer error
|
||||
}
|
||||
|
||||
SendByteUdp((BYTE) wData); // send data byte
|
||||
return;
|
||||
}
|
||||
nFrame += nStart; // next frame
|
||||
return;
|
||||
}
|
|
@ -1,263 +1,268 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Emu48.rc
|
||||
//
|
||||
#define IDM_DEBUG_SETTINGS 0x0010
|
||||
#define IDI_EMU48 100
|
||||
#define IDR_MENU 101
|
||||
#define IDM_MENU 102
|
||||
#define IDR_DEBUG 103
|
||||
#define IDR_DEBUG_TOOLBAR 104
|
||||
#define IDR_DEBUG_CODE 105
|
||||
#define IDR_DEBUG_MEM 106
|
||||
#define IDR_DEBUG_STACK 107
|
||||
#define IDB_CHECKBOX 108
|
||||
#define IDD_ABOUT 109
|
||||
#define IDD_SET_GENERAL 110
|
||||
#define IDD_SET_MEMORY 111
|
||||
#define IDD_SET_PERIPHERAL 112
|
||||
#define IDD_CHOOSEKML 113
|
||||
#define IDD_KMLLOG 114
|
||||
#define IDD_DISASM 115
|
||||
#define IDD_DEBUG 116
|
||||
#define IDD_NEWVALUE 117
|
||||
#define IDD_ENTERADR 118
|
||||
#define IDD_BREAKEDIT 119
|
||||
#define IDD_ENTERBREAK 120
|
||||
#define IDD_INSTRUCTIONS 121
|
||||
#define IDD_WRITEONLYREG 122
|
||||
#define IDD_FIND 123
|
||||
#define IDD_PROFILE 124
|
||||
#define IDD_RPLVIEW 125
|
||||
#define IDD_MACROSET 126
|
||||
#define IDD_DEBUG_MEMSAVE 127
|
||||
#define IDD_DEBUG_MEMLOAD 128
|
||||
#define IDD_DEBUG_SETTINGS 129
|
||||
#define IDD_TRACE 130
|
||||
#define IDC_REALSPEED 1000
|
||||
#define IDC_GRAYSCALE 1001
|
||||
#define IDC_ALWAYSONTOP 1002
|
||||
#define IDC_ACTFOLLOWSMOUSE 1003
|
||||
#define IDC_SINGLEINSTANCE 1004
|
||||
#define IDC_AUTOSAVE 1005
|
||||
#define IDC_AUTOSAVEONEXIT 1006
|
||||
#define IDC_OBJECTLOADWARNING 1007
|
||||
#define IDC_SHOWTITLE 1008
|
||||
#define IDC_SHOWMENU 1009
|
||||
#define IDC_ALWAYSDISPLOG 1010
|
||||
#define IDC_PORT1EN 1011
|
||||
#define IDC_PORT1WR 1012
|
||||
#define IDC_PORT2ISSHARED 1013
|
||||
#define IDC_PORT2WR 1014
|
||||
#define IDC_PORT2 1015
|
||||
#define IDC_PORT2LOAD 1016
|
||||
#define IDC_IR_ADDR 1017
|
||||
#define IDC_IR_PORT 1018
|
||||
#define IDC_WIRE 1019
|
||||
#define IDC_IR 1020
|
||||
#define IDC_EMUDIR 1021
|
||||
#define IDC_EMUDIRSEL 1022
|
||||
#define IDC_UPDATE 1023
|
||||
#define IDC_KMLSCRIPT 1024
|
||||
#define IDC_AUTHOR 1025
|
||||
#define IDC_TITLE 1026
|
||||
#define IDC_KMLLOG 1027
|
||||
#define IDC_VERSION 1028
|
||||
#define IDC_LICENSE 1029
|
||||
#define IDC_DISASM_WIN 1030
|
||||
#define IDC_DISASM_MODE_TEXT 1031
|
||||
#define IDC_DISASM_MODE 1032
|
||||
#define IDC_DISASM_MODULE 1033
|
||||
#define IDC_DISASM_HP 1034
|
||||
#define IDC_DISASM_CLASS 1035
|
||||
#define IDC_ADDRESS 1036
|
||||
#define IDC_DISASM_ADR 1037
|
||||
#define IDC_DISASM_NEXT 1038
|
||||
#define IDC_DISASM_COPY 1039
|
||||
#define IDC_DEBUG_CODE 1040
|
||||
#define IDC_STATIC_CODE 1041
|
||||
#define IDC_STATIC_REGISTERS 1042
|
||||
#define IDC_STATIC_MEMORY 1043
|
||||
#define IDC_STATIC_STACK 1044
|
||||
#define IDC_REG_A 1045
|
||||
#define IDC_REG_B 1046
|
||||
#define IDC_REG_C 1047
|
||||
#define IDC_REG_D 1048
|
||||
#define IDC_REG_R0 1049
|
||||
#define IDC_REG_R1 1050
|
||||
#define IDC_REG_R2 1051
|
||||
#define IDC_REG_R3 1052
|
||||
#define IDC_REG_R4 1053
|
||||
#define IDC_REG_D0 1054
|
||||
#define IDC_REG_D1 1055
|
||||
#define IDC_REG_P 1056
|
||||
#define IDC_REG_PC 1057
|
||||
#define IDC_REG_OUT 1058
|
||||
#define IDC_REG_IN 1059
|
||||
#define IDC_REG_ST 1060
|
||||
#define IDC_REG_CY 1061
|
||||
#define IDC_REG_MODE 1062
|
||||
#define IDC_REG_MP 1063
|
||||
#define IDC_REG_SR 1064
|
||||
#define IDC_REG_SB 1065
|
||||
#define IDC_REG_XM 1066
|
||||
#define IDC_MISC_INT 1067
|
||||
#define IDC_MISC_KEY 1068
|
||||
#define IDC_MISC_BS 1069
|
||||
#define IDC_NEWVALUE 1070
|
||||
#define IDC_ENTERADR 1071
|
||||
#define IDC_DEBUG_MEM 1072
|
||||
#define IDC_DEBUG_MEM_ADDR 1073
|
||||
#define IDC_DEBUG_MEM_COL0 1074
|
||||
#define IDC_DEBUG_MEM_COL1 1075
|
||||
#define IDC_DEBUG_MEM_COL2 1076
|
||||
#define IDC_DEBUG_MEM_COL3 1077
|
||||
#define IDC_DEBUG_MEM_COL4 1078
|
||||
#define IDC_DEBUG_MEM_COL5 1079
|
||||
#define IDC_DEBUG_MEM_COL6 1080
|
||||
#define IDC_DEBUG_MEM_COL7 1081
|
||||
#define IDC_DEBUG_MEM_TEXT 1082
|
||||
#define IDC_DEBUG_DATA_FILE 1083
|
||||
#define IDC_DEBUG_DATA_BUT 1084
|
||||
#define IDC_DEBUG_DATA_STARTADDR 1085
|
||||
#define IDC_DEBUG_DATA_ENDADDR 1086
|
||||
#define IDC_DEBUG_SET_SYMB 1087
|
||||
#define IDC_DEBUG_SET_MODEL 1088
|
||||
#define IDC_DEBUG_SET_FILE 1089
|
||||
#define IDC_DEBUG_SET_BROWSE 1090
|
||||
#define IDC_DEBUG_STACK 1091
|
||||
#define IDC_STATIC_BREAKPOINT 1092
|
||||
#define IDC_BREAKEDIT_ADD 1093
|
||||
#define IDC_BREAKEDIT_DELETE 1094
|
||||
#define IDC_BREAKEDIT_WND 1095
|
||||
#define IDC_STATIC_MMU 1096
|
||||
#define IDC_MMU_IO_A 1097
|
||||
#define IDC_MMU_NCE2_A 1098
|
||||
#define IDC_MMU_CE1_A 1099
|
||||
#define IDC_MMU_CE2_A 1100
|
||||
#define IDC_MMU_NCE3_A 1101
|
||||
#define IDC_MMU_IO_S 1102
|
||||
#define IDC_MMU_CE1_S 1103
|
||||
#define IDC_MMU_CE2_S 1104
|
||||
#define IDC_MMU_NCE2_S 1105
|
||||
#define IDC_MMU_NCE3_S 1106
|
||||
#define IDC_STATIC_MISC 1107
|
||||
#define IDC_MISC_BS_TXT 1108
|
||||
#define IDC_INSTR_TEXT 1109
|
||||
#define IDC_INSTR_CODE 1110
|
||||
#define IDC_INSTR_COPY 1111
|
||||
#define IDC_INSTR_CLEAR 1112
|
||||
#define IDC_PROFILE_LASTCYCLES 1113
|
||||
#define IDC_PROFILE_LASTTIME 1114
|
||||
#define IDC_BPCODE 1115
|
||||
#define IDC_BPRPL 1116
|
||||
#define IDC_BPACCESS 1117
|
||||
#define IDC_BPREAD 1118
|
||||
#define IDC_BPWRITE 1119
|
||||
#define IDC_FIND_DATA 1120
|
||||
#define IDC_FIND_PREV 1121
|
||||
#define IDC_FIND_NEXT 1122
|
||||
#define IDC_FIND_ASCII 1123
|
||||
#define IDC_ADDR20_24 1124
|
||||
#define IDC_ADDR25_27 1125
|
||||
#define IDC_ADDR28_29 1126
|
||||
#define IDC_ADDR30_34 1127
|
||||
#define IDC_RPLVIEW_DATA 1128
|
||||
#define IDC_MACRO_SLOW 1129
|
||||
#define IDC_MACRO_FAST 1130
|
||||
#define IDC_MACRO_SLIDER 1131
|
||||
#define IDC_MACRO_REAL 1132
|
||||
#define IDC_MACRO_MANUAL 1133
|
||||
#define IDC_SOUND_SLIDER 1134
|
||||
#define IDC_SOUND_DEVICE 1135
|
||||
#define IDC_TRACE_FILE 1136
|
||||
#define IDC_TRACE_BROWSE 1137
|
||||
#define IDC_TRACE_NEW 1138
|
||||
#define IDC_TRACE_APPEND 1139
|
||||
#define IDC_TRACE_REGISTER 1140
|
||||
#define IDC_TRACE_MMU 1141
|
||||
#define IDC_TRACE_OPCODE 1142
|
||||
#define ID_FILE_NEW 40001
|
||||
#define ID_FILE_OPEN 40002
|
||||
#define ID_FILE_SAVE 40003
|
||||
#define ID_FILE_SAVEAS 40004
|
||||
#define ID_FILE_EXIT 40005
|
||||
#define ID_VIEW_COPY 40006
|
||||
#define ID_VIEW_SETTINGS 40007
|
||||
#define ID_VIEW_RESET 40008
|
||||
#define ID_OBJECT_LOAD 40009
|
||||
#define ID_OBJECT_SAVE 40010
|
||||
#define ID_ABOUT 40011
|
||||
#define ID_HELP_TOPICS 40012
|
||||
#define ID_FILE_CLOSE 40013
|
||||
#define ID_BACKUP_SAVE 40014
|
||||
#define ID_BACKUP_RESTORE 40015
|
||||
#define ID_BACKUP_DELETE 40016
|
||||
#define ID_VIEW_SCRIPT 40017
|
||||
#define ID_STACK_COPY 40019
|
||||
#define ID_STACK_PASTE 40020
|
||||
#define ID_TOOL_DISASM 40021
|
||||
#define ID_TOOL_DEBUG 40022
|
||||
#define ID_TOOL_MACRO_RECORD 40023
|
||||
#define ID_TOOL_MACRO_PLAY 40024
|
||||
#define ID_TOOL_MACRO_STOP 40025
|
||||
#define ID_TOOL_MACRO_SETTINGS 40026
|
||||
#define ID_DEBUG_RUN 40027
|
||||
#define ID_DEBUG_RUNCURSOR 40028
|
||||
#define ID_DEBUG_STEP 40029
|
||||
#define ID_DEBUG_STEPOVER 40030
|
||||
#define ID_DEBUG_BREAK 40031
|
||||
#define ID_DEBUG_STEPOUT 40032
|
||||
#define ID_DEBUG_CANCEL 40033
|
||||
#define ID_BREAKPOINTS_SETBREAK 40034
|
||||
#define ID_BREAKPOINTS_CODEEDIT 40035
|
||||
#define ID_BREAKPOINTS_CLEARALL 40036
|
||||
#define ID_BREAKPOINTS_NOP3 40037
|
||||
#define ID_BREAKPOINTS_DOCODE 40038
|
||||
#define ID_BREAKPOINTS_RPL 40039
|
||||
#define ID_DEBUG_CODE_GOADR 40040
|
||||
#define ID_DEBUG_CODE_GOPC 40041
|
||||
#define ID_DEBUG_CODE_SETPCTOSELECT 40042
|
||||
#define ID_DEBUG_CODE_PREVPCO 40043
|
||||
#define ID_DEBUG_CODE_NEXTPCO 40044
|
||||
#define ID_DEBUG_MEM_GOADR 40045
|
||||
#define ID_DEBUG_MEM_GOPC 40046
|
||||
#define ID_DEBUG_MEM_GOD0 40047
|
||||
#define ID_DEBUG_MEM_GOD1 40048
|
||||
#define ID_DEBUG_MEM_GOSTACK 40049
|
||||
#define ID_DEBUG_MEM_FNONE 40050
|
||||
#define ID_DEBUG_MEM_FADDR 40051
|
||||
#define ID_DEBUG_MEM_FPC 40052
|
||||
#define ID_DEBUG_MEM_FD0 40053
|
||||
#define ID_DEBUG_MEM_FD1 40054
|
||||
#define ID_DEBUG_MEM_FIND 40055
|
||||
#define ID_DEBUG_MEM_MAP 40056
|
||||
#define ID_DEBUG_MEM_NCE1 40057
|
||||
#define ID_DEBUG_MEM_NCE2 40058
|
||||
#define ID_DEBUG_MEM_CE1 40059
|
||||
#define ID_DEBUG_MEM_CE2 40060
|
||||
#define ID_DEBUG_MEM_NCE3 40061
|
||||
#define ID_DEBUG_MEM_SAVE 40062
|
||||
#define ID_DEBUG_MEM_LOAD 40063
|
||||
#define ID_DEBUG_MEM_RPLVIEW 40064
|
||||
#define ID_DEBUG_STACK_PUSH 40065
|
||||
#define ID_DEBUG_STACK_POP 40066
|
||||
#define ID_DEBUG_STACK_MODIFY 40067
|
||||
#define ID_INTR_STEPOVERINT 40068
|
||||
#define ID_INFO_LASTINSTRUCTIONS 40069
|
||||
#define ID_INFO_PROFILE 40070
|
||||
#define ID_INFO_WRITEONLYREG 40071
|
||||
#define ID_TRACE_SETTINGS 40072
|
||||
#define ID_TRACE_ENABLE 40073
|
||||
#define ID_FILE_MRU_FILE1 40100
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 131
|
||||
#define _APS_NEXT_COMMAND_VALUE 40074
|
||||
#define _APS_NEXT_CONTROL_VALUE 1143
|
||||
#define _APS_NEXT_SYMED_VALUE 109
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Emu48.rc
|
||||
//
|
||||
#define IDM_DEBUG_SETTINGS 0x0010
|
||||
#define IDI_EMU48 100
|
||||
#define IDR_MENU 101
|
||||
#define IDM_MENU 102
|
||||
#define IDR_DEBUG 103
|
||||
#define IDR_DEBUG_TOOLBAR 104
|
||||
#define IDR_DEBUG_CODE 105
|
||||
#define IDR_DEBUG_MEM 106
|
||||
#define IDR_DEBUG_STACK 107
|
||||
#define IDB_CHECKBOX 108
|
||||
#define IDD_ABOUT 109
|
||||
#define IDD_SET_GENERAL 110
|
||||
#define IDD_SET_MEMORY 111
|
||||
#define IDD_SET_PERIPHERAL 112
|
||||
#define IDD_CHOOSEKML 113
|
||||
#define IDD_KMLLOG 114
|
||||
#define IDD_DISASM 115
|
||||
#define IDD_DEBUG 116
|
||||
#define IDD_NEWVALUE 117
|
||||
#define IDD_ENTERADR 118
|
||||
#define IDD_BREAKEDIT 119
|
||||
#define IDD_ENTERBREAK 120
|
||||
#define IDD_INSTRUCTIONS 121
|
||||
#define IDD_WRITEONLYREG 122
|
||||
#define IDD_FIND 123
|
||||
#define IDD_PROFILE 124
|
||||
#define IDD_RPLVIEW 125
|
||||
#define IDD_MACROSET 126
|
||||
#define IDD_DEBUG_MEMSAVE 127
|
||||
#define IDD_DEBUG_MEMLOAD 128
|
||||
#define IDD_DEBUG_SETTINGS 129
|
||||
#define IDD_TRACE 130
|
||||
#define IDC_REALSPEED 1000
|
||||
#define IDC_GRAYSCALE 1001
|
||||
#define IDC_ALWAYSONTOP 1002
|
||||
#define IDC_ACTFOLLOWSMOUSE 1003
|
||||
#define IDC_SINGLEINSTANCE 1004
|
||||
#define IDC_AUTOSAVE 1005
|
||||
#define IDC_AUTOSAVEONEXIT 1006
|
||||
#define IDC_OBJECTLOADWARNING 1007
|
||||
#define IDC_SHOWTITLE 1008
|
||||
#define IDC_SHOWMENU 1009
|
||||
#define IDC_ALWAYSDISPLOG 1010
|
||||
#define IDC_PORT1EN 1011
|
||||
#define IDC_PORT1WR 1012
|
||||
#define IDC_PORT2ISSHARED 1013
|
||||
#define IDC_PORT2WR 1014
|
||||
#define IDC_PORT2 1015
|
||||
#define IDC_PORT2LOAD 1016
|
||||
#define IDC_IR_ADDR 1017
|
||||
#define IDC_IR_PORT 1018
|
||||
#define IDC_WIRE 1019
|
||||
#define IDC_IR 1020
|
||||
#define IDC_EMUDIR 1021
|
||||
#define IDC_EMUDIRSEL 1022
|
||||
#define IDC_UPDATE 1023
|
||||
#define IDC_KMLSCRIPT 1024
|
||||
#define IDC_AUTHOR 1025
|
||||
#define IDC_TITLE 1026
|
||||
#define IDC_KMLLOG 1027
|
||||
#define IDC_VERSION 1028
|
||||
#define IDC_LICENSE 1029
|
||||
#define IDC_DISASM_WIN 1030
|
||||
#define IDC_DISASM_MODE_TEXT 1031
|
||||
#define IDC_DISASM_MODE 1032
|
||||
#define IDC_DISASM_MODULE 1033
|
||||
#define IDC_DISASM_HP 1034
|
||||
#define IDC_DISASM_CLASS 1035
|
||||
#define IDC_ADDRESS 1036
|
||||
#define IDC_DISASM_ADR 1037
|
||||
#define IDC_DISASM_NEXT 1038
|
||||
#define IDC_DISASM_COPY 1039
|
||||
#define IDC_DEBUG_CODE 1040
|
||||
#define IDC_STATIC_CODE 1041
|
||||
#define IDC_STATIC_REGISTERS 1042
|
||||
#define IDC_STATIC_MEMORY 1043
|
||||
#define IDC_STATIC_STACK 1044
|
||||
#define IDC_REG_A 1045
|
||||
#define IDC_REG_B 1046
|
||||
#define IDC_REG_C 1047
|
||||
#define IDC_REG_D 1048
|
||||
#define IDC_REG_R0 1049
|
||||
#define IDC_REG_R1 1050
|
||||
#define IDC_REG_R2 1051
|
||||
#define IDC_REG_R3 1052
|
||||
#define IDC_REG_R4 1053
|
||||
#define IDC_REG_D0 1054
|
||||
#define IDC_REG_D1 1055
|
||||
#define IDC_REG_P 1056
|
||||
#define IDC_REG_PC 1057
|
||||
#define IDC_REG_OUT 1058
|
||||
#define IDC_REG_IN 1059
|
||||
#define IDC_REG_ST 1060
|
||||
#define IDC_REG_CY 1061
|
||||
#define IDC_REG_MODE 1062
|
||||
#define IDC_REG_MP 1063
|
||||
#define IDC_REG_SR 1064
|
||||
#define IDC_REG_SB 1065
|
||||
#define IDC_REG_XM 1066
|
||||
#define IDC_MISC_INT 1067
|
||||
#define IDC_MISC_KEY 1068
|
||||
#define IDC_MISC_BS 1069
|
||||
#define IDC_NEWVALUE 1070
|
||||
#define IDC_ENTERADR 1071
|
||||
#define IDC_DEBUG_MEM 1072
|
||||
#define IDC_DEBUG_MEM_ADDR 1073
|
||||
#define IDC_DEBUG_MEM_COL0 1074
|
||||
#define IDC_DEBUG_MEM_COL1 1075
|
||||
#define IDC_DEBUG_MEM_COL2 1076
|
||||
#define IDC_DEBUG_MEM_COL3 1077
|
||||
#define IDC_DEBUG_MEM_COL4 1078
|
||||
#define IDC_DEBUG_MEM_COL5 1079
|
||||
#define IDC_DEBUG_MEM_COL6 1080
|
||||
#define IDC_DEBUG_MEM_COL7 1081
|
||||
#define IDC_DEBUG_MEM_TEXT 1082
|
||||
#define IDC_DEBUG_DATA_FILE 1083
|
||||
#define IDC_DEBUG_DATA_BUT 1084
|
||||
#define IDC_DEBUG_DATA_STARTADDR 1085
|
||||
#define IDC_DEBUG_DATA_ENDADDR 1086
|
||||
#define IDC_DEBUG_DATA_SAVE_8BIT 1087
|
||||
#define IDC_DEBUG_DATA_SAVE_4BIT 1088
|
||||
#define IDC_DEBUG_DATA_LOAD_8BIT 1089
|
||||
#define IDC_DEBUG_DATA_LOAD_4BIT 1090
|
||||
#define IDC_DEBUG_DATA_LOAD_ABIT 1091
|
||||
#define IDC_DEBUG_SET_SYMB 1092
|
||||
#define IDC_DEBUG_SET_MODEL 1093
|
||||
#define IDC_DEBUG_SET_FILE 1094
|
||||
#define IDC_DEBUG_SET_BROWSE 1095
|
||||
#define IDC_DEBUG_STACK 1096
|
||||
#define IDC_STATIC_BREAKPOINT 1097
|
||||
#define IDC_BREAKEDIT_ADD 1098
|
||||
#define IDC_BREAKEDIT_DELETE 1099
|
||||
#define IDC_BREAKEDIT_WND 1100
|
||||
#define IDC_STATIC_MMU 1101
|
||||
#define IDC_MMU_IO_A 1102
|
||||
#define IDC_MMU_NCE2_A 1103
|
||||
#define IDC_MMU_CE1_A 1104
|
||||
#define IDC_MMU_CE2_A 1105
|
||||
#define IDC_MMU_NCE3_A 1106
|
||||
#define IDC_MMU_IO_S 1107
|
||||
#define IDC_MMU_CE1_S 1108
|
||||
#define IDC_MMU_CE2_S 1109
|
||||
#define IDC_MMU_NCE2_S 1110
|
||||
#define IDC_MMU_NCE3_S 1111
|
||||
#define IDC_STATIC_MISC 1112
|
||||
#define IDC_MISC_BS_TXT 1113
|
||||
#define IDC_INSTR_TEXT 1114
|
||||
#define IDC_INSTR_CODE 1115
|
||||
#define IDC_INSTR_COPY 1116
|
||||
#define IDC_INSTR_CLEAR 1117
|
||||
#define IDC_PROFILE_LASTCYCLES 1118
|
||||
#define IDC_PROFILE_LASTTIME 1119
|
||||
#define IDC_BPCODE 1120
|
||||
#define IDC_BPRPL 1121
|
||||
#define IDC_BPACCESS 1122
|
||||
#define IDC_BPREAD 1123
|
||||
#define IDC_BPWRITE 1124
|
||||
#define IDC_FIND_DATA 1125
|
||||
#define IDC_FIND_PREV 1126
|
||||
#define IDC_FIND_NEXT 1127
|
||||
#define IDC_FIND_ASCII 1128
|
||||
#define IDC_ADDR20_24 1129
|
||||
#define IDC_ADDR25_27 1130
|
||||
#define IDC_ADDR28_29 1131
|
||||
#define IDC_ADDR30_34 1132
|
||||
#define IDC_RPLVIEW_DATA 1133
|
||||
#define IDC_MACRO_SLOW 1134
|
||||
#define IDC_MACRO_FAST 1135
|
||||
#define IDC_MACRO_SLIDER 1136
|
||||
#define IDC_MACRO_REAL 1137
|
||||
#define IDC_MACRO_MANUAL 1138
|
||||
#define IDC_SOUND_SLIDER 1139
|
||||
#define IDC_SOUND_DEVICE 1140
|
||||
#define IDC_TRACE_FILE 1141
|
||||
#define IDC_TRACE_BROWSE 1142
|
||||
#define IDC_TRACE_NEW 1143
|
||||
#define IDC_TRACE_APPEND 1144
|
||||
#define IDC_TRACE_REGISTER 1145
|
||||
#define IDC_TRACE_MMU 1146
|
||||
#define IDC_TRACE_OPCODE 1147
|
||||
#define ID_FILE_NEW 40001
|
||||
#define ID_FILE_OPEN 40002
|
||||
#define ID_FILE_SAVE 40003
|
||||
#define ID_FILE_SAVEAS 40004
|
||||
#define ID_FILE_EXIT 40005
|
||||
#define ID_VIEW_COPY 40006
|
||||
#define ID_VIEW_SETTINGS 40007
|
||||
#define ID_VIEW_RESET 40008
|
||||
#define ID_OBJECT_LOAD 40009
|
||||
#define ID_OBJECT_SAVE 40010
|
||||
#define ID_ABOUT 40011
|
||||
#define ID_HELP_TOPICS 40012
|
||||
#define ID_FILE_CLOSE 40013
|
||||
#define ID_BACKUP_SAVE 40014
|
||||
#define ID_BACKUP_RESTORE 40015
|
||||
#define ID_BACKUP_DELETE 40016
|
||||
#define ID_VIEW_SCRIPT 40017
|
||||
#define ID_STACK_COPY 40019
|
||||
#define ID_STACK_PASTE 40020
|
||||
#define ID_TOOL_DISASM 40021
|
||||
#define ID_TOOL_DEBUG 40022
|
||||
#define ID_TOOL_MACRO_RECORD 40023
|
||||
#define ID_TOOL_MACRO_PLAY 40024
|
||||
#define ID_TOOL_MACRO_STOP 40025
|
||||
#define ID_TOOL_MACRO_SETTINGS 40026
|
||||
#define ID_DEBUG_RUN 40027
|
||||
#define ID_DEBUG_RUNCURSOR 40028
|
||||
#define ID_DEBUG_STEP 40029
|
||||
#define ID_DEBUG_STEPOVER 40030
|
||||
#define ID_DEBUG_BREAK 40031
|
||||
#define ID_DEBUG_STEPOUT 40032
|
||||
#define ID_DEBUG_CANCEL 40033
|
||||
#define ID_BREAKPOINTS_SETBREAK 40034
|
||||
#define ID_BREAKPOINTS_CODEEDIT 40035
|
||||
#define ID_BREAKPOINTS_CLEARALL 40036
|
||||
#define ID_BREAKPOINTS_NOP3 40037
|
||||
#define ID_BREAKPOINTS_DOCODE 40038
|
||||
#define ID_BREAKPOINTS_RPL 40039
|
||||
#define ID_DEBUG_CODE_GOADR 40040
|
||||
#define ID_DEBUG_CODE_GOPC 40041
|
||||
#define ID_DEBUG_CODE_SETPCTOSELECT 40042
|
||||
#define ID_DEBUG_CODE_PREVPCO 40043
|
||||
#define ID_DEBUG_CODE_NEXTPCO 40044
|
||||
#define ID_DEBUG_MEM_GOADR 40045
|
||||
#define ID_DEBUG_MEM_GOPC 40046
|
||||
#define ID_DEBUG_MEM_GOD0 40047
|
||||
#define ID_DEBUG_MEM_GOD1 40048
|
||||
#define ID_DEBUG_MEM_GOSTACK 40049
|
||||
#define ID_DEBUG_MEM_FNONE 40050
|
||||
#define ID_DEBUG_MEM_FADDR 40051
|
||||
#define ID_DEBUG_MEM_FPC 40052
|
||||
#define ID_DEBUG_MEM_FD0 40053
|
||||
#define ID_DEBUG_MEM_FD1 40054
|
||||
#define ID_DEBUG_MEM_FIND 40055
|
||||
#define ID_DEBUG_MEM_MAP 40056
|
||||
#define ID_DEBUG_MEM_NCE1 40057
|
||||
#define ID_DEBUG_MEM_NCE2 40058
|
||||
#define ID_DEBUG_MEM_CE1 40059
|
||||
#define ID_DEBUG_MEM_CE2 40060
|
||||
#define ID_DEBUG_MEM_NCE3 40061
|
||||
#define ID_DEBUG_MEM_SAVE 40062
|
||||
#define ID_DEBUG_MEM_LOAD 40063
|
||||
#define ID_DEBUG_MEM_RPLVIEW 40064
|
||||
#define ID_DEBUG_STACK_PUSH 40065
|
||||
#define ID_DEBUG_STACK_POP 40066
|
||||
#define ID_DEBUG_STACK_MODIFY 40067
|
||||
#define ID_INTR_STEPOVERINT 40068
|
||||
#define ID_INFO_LASTINSTRUCTIONS 40069
|
||||
#define ID_INFO_PROFILE 40070
|
||||
#define ID_INFO_WRITEONLYREG 40071
|
||||
#define ID_TRACE_SETTINGS 40072
|
||||
#define ID_TRACE_ENABLE 40073
|
||||
#define ID_FILE_MRU_FILE1 40100
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 131
|
||||
#define _APS_NEXT_COMMAND_VALUE 40074
|
||||
#define _APS_NEXT_CONTROL_VALUE 1148
|
||||
#define _APS_NEXT_SYMED_VALUE 109
|
||||
#endif
|
||||
#endif
|
|
@ -1,250 +1,250 @@
|
|||
/*
|
||||
* romcrc.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2022 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "ops.h"
|
||||
|
||||
// flash page types
|
||||
#define BOOT 0x86
|
||||
#define FS 0x18
|
||||
#define SYSTEM 0x32
|
||||
#define ROM 0x0F
|
||||
#define RAM 0xF0
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore HP38G/HP48GX/SX ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
// Clarke/Yorke CRC for HP38G and HP48GX/SX
|
||||
#define a0 0x0 // Start Address
|
||||
#define d0 (n0*16) // Address offset
|
||||
#define n0 0x4000 // Reads/Half-Sector
|
||||
#define s0 1 // #Sectors (Sector Size=2*d)
|
||||
|
||||
// rebuild of the calculator =CHECKSUM function for the Clarke and the Yorke chip ROM
|
||||
static WORD Checksum(LPBYTE pbyROM, DWORD dwStart, DWORD dwOffset, INT nReads, INT nSector)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
WORD wCrc = 0;
|
||||
|
||||
for (;nSector > 0; --nSector) // evaluate each sector
|
||||
{
|
||||
LPBYTE pbyAddr1 = pbyROM + dwStart;
|
||||
LPBYTE pbyAddr2 = pbyAddr1 + dwOffset;
|
||||
|
||||
for (i = 0; i < nReads; ++i) // no. of reads in sector
|
||||
{
|
||||
for (j = 0; j < 16; ++j) wCrc = UpCRC(wCrc,*pbyAddr1++);
|
||||
for (j = 0; j < 16; ++j) wCrc = UpCRC(wCrc,*pbyAddr2++);
|
||||
}
|
||||
|
||||
dwStart += 2 * dwOffset; // next start page
|
||||
}
|
||||
return wCrc;
|
||||
}
|
||||
|
||||
// calculate proper checksum to produce final CRC of FFFF
|
||||
static __inline WORD CalcChksum(WORD wCrc, WORD wChksum)
|
||||
{
|
||||
WORD q, r = wCrc, s = wChksum;
|
||||
|
||||
// first take the last 4-nib back out of the CRC
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
|
||||
// calculate new checksum to correct the CRC
|
||||
s = 0xf831; // required MSNs to make goal
|
||||
q = (q<<4) | ((r ^ s) & 0xf); // get 1st (least sig) nib
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
return q;
|
||||
}
|
||||
|
||||
static VOID CorrectCrc(DWORD dwAddrCrc, WORD wCrc)
|
||||
{
|
||||
if (wCrc != 0xFFFF) // wrong crc result
|
||||
{
|
||||
INT s;
|
||||
|
||||
// get actual crc correction value
|
||||
const WORD wChkAct = (pbyRom[dwAddrCrc+0] << 12)
|
||||
| (pbyRom[dwAddrCrc+1] << 8)
|
||||
| (pbyRom[dwAddrCrc+2] << 4)
|
||||
| (pbyRom[dwAddrCrc+3]);
|
||||
|
||||
wCrc = CalcChksum(wCrc,wChkAct); // calculate new checksum
|
||||
|
||||
for (s = 3; s >= 0; --s) // write new checksum
|
||||
{
|
||||
PatchNibble(dwAddrCrc + s,(BYTE) (wCrc & 0xf));
|
||||
wCrc >>= 4;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore HP49G ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
static VOID CorrectFlashCrc(LPBYTE pbyMem, DWORD dwSize, DWORD dwOffset, DWORD dwLength)
|
||||
{
|
||||
// address overflow (data length + 4 nibble CRC)
|
||||
if (dwOffset + dwLength + 4 <= dwSize)
|
||||
{
|
||||
WORD wRefCrc,wCrc = 0;
|
||||
|
||||
pbyMem += dwOffset; // start address
|
||||
|
||||
for (; dwLength > 0; --dwLength) // update CRC
|
||||
{
|
||||
wCrc = UpCRC(wCrc,*pbyMem++);
|
||||
}
|
||||
|
||||
wRefCrc = (WORD) Npack(pbyMem,4); // read reference CRC
|
||||
|
||||
if(wRefCrc != wCrc) // wrong page CRC
|
||||
{
|
||||
INT s;
|
||||
|
||||
// linear CRC address in ROM
|
||||
DWORD dwAddrCrc = (DWORD) (pbyMem - pbyRom);
|
||||
|
||||
wRefCrc = wCrc; // working copy of CRC
|
||||
for (s = 0; s < 4; ++s) // write new checksum
|
||||
{
|
||||
PatchNibble(dwAddrCrc++,(BYTE) (wRefCrc & 0xf));
|
||||
wRefCrc >>= 4;
|
||||
}
|
||||
|
||||
_ASSERT(wCrc == (WORD) Npack(pbyMem,4));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashRom(LPBYTE pbyMem, DWORD dwSize)
|
||||
{
|
||||
CorrectFlashCrc(pbyMem,dwSize,0x20A,Npack(pbyMem+0x20A,5));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashSystem(LPBYTE pbyMem, DWORD dwSize)
|
||||
{
|
||||
CorrectFlashCrc(pbyMem,dwSize,0x20A,Npack(pbyMem+0x100,5));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashPage(LPBYTE pbyMem, DWORD dwSize, DWORD dwPage)
|
||||
{
|
||||
_ASSERT(dwPage >= 0 && dwPage < 16);
|
||||
|
||||
dwPage *= _KB(128); // convert page no. to data offset
|
||||
if (dwPage + _KB(128) <= dwSize) // page inside flash chip
|
||||
{
|
||||
BYTE byType;
|
||||
|
||||
pbyMem += dwPage; // page address
|
||||
dwPage = _KB(128); // page size
|
||||
|
||||
// get bank type
|
||||
byType = (BYTE) Npack(pbyMem+0x200,2);
|
||||
if (byType == BOOT) // 1st half of page is the boot bank
|
||||
{
|
||||
pbyMem += _KB(64); // 2nd half of page
|
||||
dwPage = _KB(64); // page size
|
||||
|
||||
// get bank type
|
||||
byType = (BYTE) Npack(pbyMem+0x200,2);
|
||||
}
|
||||
|
||||
_ASSERT(dwPage == _KB(64) || dwPage == _KB(128));
|
||||
|
||||
switch (byType)
|
||||
{
|
||||
case FS: // FRBankFileSystem
|
||||
case ROM: // FRBankRom
|
||||
CorrectFlashRom(pbyMem,dwPage);
|
||||
break;
|
||||
case SYSTEM: // FRBankSystem
|
||||
CorrectFlashSystem(pbyMem,dwPage);
|
||||
break;
|
||||
case RAM: // FRBankRam
|
||||
default: // illegal bank identifier
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectAllFlashPages(VOID)
|
||||
{
|
||||
DWORD dwPage;
|
||||
|
||||
// check CRC of all pages
|
||||
CONST DWORD dwLastPage = dwRomSize / _KB(128);
|
||||
for (dwPage = 0; dwPage < dwLastPage; ++dwPage)
|
||||
{
|
||||
// correct CRC of page
|
||||
CorrectFlashPage(pbyRom,dwRomSize,dwPage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
VOID RebuildRomCrc(VOID)
|
||||
{
|
||||
// HP38G, HP48GX, HP48SX
|
||||
if ((strchr("6AGS",cCurrentRomType)) && dwRomSize >= _KB(256))
|
||||
{
|
||||
// first 256KB
|
||||
CorrectCrc(0x7FFFC,Checksum(pbyRom,a0,d0,n0,s0));
|
||||
}
|
||||
// HP38G, HP48GX
|
||||
if ((strchr("6AG",cCurrentRomType)) && dwRomSize == _KB(512))
|
||||
{
|
||||
// second 256KB
|
||||
CorrectCrc(0xFFFFC,Checksum(pbyRom,a0+_KB(256),d0,n0,s0));
|
||||
}
|
||||
// HP39G/40G
|
||||
if (cCurrentRomType == 'E')
|
||||
{
|
||||
// has no Crc
|
||||
}
|
||||
// HP49G
|
||||
if (cCurrentRomType == 'X' && dwRomSize == _KB(2048))
|
||||
{
|
||||
CorrectAllFlashPages(); // go through all pages
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* romcrc.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2022 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "ops.h"
|
||||
|
||||
// flash page types
|
||||
#define BOOT 0x86
|
||||
#define FS 0x18
|
||||
#define SYSTEM 0x32
|
||||
#define ROM 0x0F
|
||||
#define RAM 0xF0
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore HP38G/HP48GX/SX ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
// Clarke/Yorke CRC for HP38G and HP48GX/SX
|
||||
#define a0 0x0 // Start Address
|
||||
#define d0 (n0*16) // Address offset
|
||||
#define n0 0x4000 // Reads/Half-Sector
|
||||
#define s0 1 // #Sectors (Sector Size=2*d)
|
||||
|
||||
// rebuild of the calculator =CHECKSUM function for the Clarke and the Yorke chip ROM
|
||||
static WORD Checksum(LPBYTE pbyROM, DWORD dwStart, DWORD dwOffset, INT nReads, INT nSector)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
WORD wCrc = 0;
|
||||
|
||||
for (;nSector > 0; --nSector) // evaluate each sector
|
||||
{
|
||||
LPBYTE pbyAddr1 = pbyROM + dwStart;
|
||||
LPBYTE pbyAddr2 = pbyAddr1 + dwOffset;
|
||||
|
||||
for (i = 0; i < nReads; ++i) // no. of reads in sector
|
||||
{
|
||||
for (j = 0; j < 16; ++j) wCrc = UpCRC(wCrc,*pbyAddr1++);
|
||||
for (j = 0; j < 16; ++j) wCrc = UpCRC(wCrc,*pbyAddr2++);
|
||||
}
|
||||
|
||||
dwStart += 2 * dwOffset; // next start page
|
||||
}
|
||||
return wCrc;
|
||||
}
|
||||
|
||||
// calculate proper checksum to produce final CRC of FFFF
|
||||
static __inline WORD CalcChksum(WORD wCrc, WORD wChksum)
|
||||
{
|
||||
WORD q, r = wCrc, s = wChksum;
|
||||
|
||||
// first take the last 4-nib back out of the CRC
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
s >>= 4;
|
||||
r = (((r >> 12) * 0x811) ^ (r << 4) ^ (s & 0xf));
|
||||
|
||||
// calculate new checksum to correct the CRC
|
||||
s = 0xf831; // required MSNs to make goal
|
||||
q = (q<<4) | ((r ^ s) & 0xf); // get 1st (least sig) nib
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
r = (r>>4) ^ ((s & 0xf) * 0x1081);
|
||||
s >>= 4;
|
||||
q = (q<<4) | ((r ^ s) & 0xf);
|
||||
return q;
|
||||
}
|
||||
|
||||
static VOID CorrectCrc(DWORD dwAddrCrc, WORD wCrc)
|
||||
{
|
||||
if (wCrc != 0xFFFF) // wrong crc result
|
||||
{
|
||||
INT s;
|
||||
|
||||
// get actual crc correction value
|
||||
const WORD wChkAct = (pbyRom[dwAddrCrc+0] << 12)
|
||||
| (pbyRom[dwAddrCrc+1] << 8)
|
||||
| (pbyRom[dwAddrCrc+2] << 4)
|
||||
| (pbyRom[dwAddrCrc+3]);
|
||||
|
||||
wCrc = CalcChksum(wCrc,wChkAct); // calculate new checksum
|
||||
|
||||
for (s = 3; s >= 0; --s) // write new checksum
|
||||
{
|
||||
PatchNibble(dwAddrCrc + s,(BYTE) (wCrc & 0xf));
|
||||
wCrc >>= 4;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore HP49G ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
static VOID CorrectFlashCrc(LPBYTE pbyMem, DWORD dwSize, DWORD dwOffset, DWORD dwLength)
|
||||
{
|
||||
// address overflow (data length + 4 nibble CRC)
|
||||
if (dwOffset + dwLength + 4 <= dwSize)
|
||||
{
|
||||
WORD wRefCrc,wCrc = 0;
|
||||
|
||||
pbyMem += dwOffset; // start address
|
||||
|
||||
for (; dwLength > 0; --dwLength) // update CRC
|
||||
{
|
||||
wCrc = UpCRC(wCrc,*pbyMem++);
|
||||
}
|
||||
|
||||
wRefCrc = (WORD) Npack(pbyMem,4); // read reference CRC
|
||||
|
||||
if(wRefCrc != wCrc) // wrong page CRC
|
||||
{
|
||||
INT s;
|
||||
|
||||
// linear CRC address in ROM
|
||||
DWORD dwAddrCrc = (DWORD) (pbyMem - pbyRom);
|
||||
|
||||
wRefCrc = wCrc; // working copy of CRC
|
||||
for (s = 0; s < 4; ++s) // write new checksum
|
||||
{
|
||||
PatchNibble(dwAddrCrc++,(BYTE) (wRefCrc & 0xf));
|
||||
wRefCrc >>= 4;
|
||||
}
|
||||
|
||||
_ASSERT(wCrc == (WORD) Npack(pbyMem,4));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashRom(LPBYTE pbyMem, DWORD dwSize)
|
||||
{
|
||||
CorrectFlashCrc(pbyMem,dwSize,0x20A,Npack(pbyMem+0x20A,5));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashSystem(LPBYTE pbyMem, DWORD dwSize)
|
||||
{
|
||||
CorrectFlashCrc(pbyMem,dwSize,0x20A,Npack(pbyMem+0x100,5));
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectFlashPage(LPBYTE pbyMem, DWORD dwSize, DWORD dwPage)
|
||||
{
|
||||
_ASSERT(dwPage >= 0 && dwPage < 16);
|
||||
|
||||
dwPage *= _KB(128); // convert page no. to data offset
|
||||
if (dwPage + _KB(128) <= dwSize) // page inside flash chip
|
||||
{
|
||||
BYTE byType;
|
||||
|
||||
pbyMem += dwPage; // page address
|
||||
dwPage = _KB(128); // page size
|
||||
|
||||
// get bank type
|
||||
byType = (BYTE) Npack(pbyMem+0x200,2);
|
||||
if (byType == BOOT) // 1st half of page is the boot bank
|
||||
{
|
||||
pbyMem += _KB(64); // 2nd half of page
|
||||
dwPage = _KB(64); // page size
|
||||
|
||||
// get bank type
|
||||
byType = (BYTE) Npack(pbyMem+0x200,2);
|
||||
}
|
||||
|
||||
_ASSERT(dwPage == _KB(64) || dwPage == _KB(128));
|
||||
|
||||
switch (byType)
|
||||
{
|
||||
case FS: // FRBankFileSystem
|
||||
case ROM: // FRBankRom
|
||||
CorrectFlashRom(pbyMem,dwPage);
|
||||
break;
|
||||
case SYSTEM: // FRBankSystem
|
||||
CorrectFlashSystem(pbyMem,dwPage);
|
||||
break;
|
||||
case RAM: // FRBankRam
|
||||
default: // illegal bank identifier
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline VOID CorrectAllFlashPages(VOID)
|
||||
{
|
||||
DWORD dwPage;
|
||||
|
||||
// check CRC of all pages
|
||||
CONST DWORD dwLastPage = dwRomSize / _KB(128);
|
||||
for (dwPage = 0; dwPage < dwLastPage; ++dwPage)
|
||||
{
|
||||
// correct CRC of page
|
||||
CorrectFlashPage(pbyRom,dwRomSize,dwPage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Restore ROM CRC
|
||||
//#
|
||||
//################
|
||||
|
||||
VOID RebuildRomCrc(VOID)
|
||||
{
|
||||
// HP38G, HP48GX, HP48SX
|
||||
if ((strchr("6AGS",cCurrentRomType)) && dwRomSize >= _KB(256))
|
||||
{
|
||||
// first 256KB
|
||||
CorrectCrc(0x7FFFC,Checksum(pbyRom,a0,d0,n0,s0));
|
||||
}
|
||||
// HP38G, HP48GX
|
||||
if ((strchr("6AG",cCurrentRomType)) && dwRomSize == _KB(512))
|
||||
{
|
||||
// second 256KB
|
||||
CorrectCrc(0xFFFFC,Checksum(pbyRom,a0+_KB(256),d0,n0,s0));
|
||||
}
|
||||
// HP39G/40G
|
||||
if (cCurrentRomType == 'E')
|
||||
{
|
||||
// has no Crc
|
||||
}
|
||||
// HP49G
|
||||
if (cCurrentRomType == 'X' && dwRomSize == _KB(2048))
|
||||
{
|
||||
CorrectAllFlashPages(); // go through all pages
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -1,453 +1,453 @@
|
|||
/*
|
||||
* rpl.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "ops.h"
|
||||
#include "io.h"
|
||||
|
||||
//| 38G | 39G | 40G | 48SX | 48GX | 49G | Name
|
||||
//#F0688 #806E9 #806E9 #7056A #806E9 #806E9 =TEMPOB
|
||||
//#F068D #806EE #806EE #7056F #806EE #806EE =TEMPTOP
|
||||
//#F0692 #806F3 #806F3 #70574 #806F3 #806F3 =RSKTOP (B)
|
||||
//#F0697 #806F8 #806F8 #70579 #806F8 #806F8 =DSKTOP (D1)
|
||||
//#F069C #806FD #806FD #7057E #806FD #806FD =EDITLINE
|
||||
//#F0DEA #80E9B #80E9B #7066E #807ED #80E9B =AVMEM (D)
|
||||
//#F0705 #8076B #8076B #705B0 #8072F #8076B =INTRPPTR (D0)
|
||||
//#F0E42 #80F02 #80F02 #706C5 #80843 #80F02 =SystemFlags
|
||||
|
||||
#define TEMPOB ((cCurrentRomType=='S')?0x7056A:0x806E9)
|
||||
#define TEMPTOP ((cCurrentRomType=='S')?0x7056F:0x806EE)
|
||||
#define RSKTOP ((cCurrentRomType=='S')?0x70574:0x806F3)
|
||||
#define DSKTOP ((cCurrentRomType=='S')?0x70579:0x806F8)
|
||||
#define EDITLINE ((cCurrentRomType=='S')?0x7057E:0x806FD)
|
||||
#define AVMEM ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x7066E:0x807ED):0x80E9B)
|
||||
#define INTRPPTR ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x705B0:0x8072F):0x8076B)
|
||||
#define SYSTEMFLAGS ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x706C5:0x80843):0x80F02)
|
||||
|
||||
#define DOINT 0x02614 // Precision Integer (HP49G)
|
||||
#define DOLNGREAL 0x0263A // Precision Real (HP49G)
|
||||
#define DOLNGCMP 0x02660 // Precision Complex (HP49G)
|
||||
#define DOMATRIX 0x02686 // Symbolic matrix (HP49G)
|
||||
#define DOFLASHP 0x026AC // Flash PTR (HP49G)
|
||||
#define DOAPLET 0x026D5 // Aplet (HP49G)
|
||||
#define DOMINIFONT 0x026FE // Mini Font (HP49G)
|
||||
#define DOBINT 0x02911 // System Binary
|
||||
#define DOREAL 0x02933 // Real
|
||||
#define DOEREL 0x02955 // Long Real
|
||||
#define DOCMP 0x02977 // Complex
|
||||
#define DOECMP 0x0299D // Long Complex
|
||||
#define DOCHAR 0x029BF // Character
|
||||
#define DOARRY 0x029E8 // Array
|
||||
#define DOLNKARRY 0x02A0A // Linked Array
|
||||
#define DOCSTR 0x02A2C // String
|
||||
#define DOHSTR 0x02A4E // Binary Integer
|
||||
#define DOLIST 0x02A74 // List
|
||||
#define DORRP 0x02A96 // Directory
|
||||
#define DOSYMB 0x02AB8 // Algebraic
|
||||
#define DOEXT 0x02ADA // Unit
|
||||
#define DOTAG 0x02AFC // Tagged
|
||||
#define DOGROB 0x02B1E // Graphic
|
||||
#define DOLIB 0x02B40 // Library
|
||||
#define DOBAK 0x02B62 // Backup
|
||||
#define DOEXT0 0x02B88 // Library Data
|
||||
#define DOEXT1 0x02BAA // Reserved 1, ACcess PoinTeR (HP48GX and later)
|
||||
#define DOEXT2 0x02BCC // Reserved 2, Font (HP49G)
|
||||
#define DOEXT3 0x02BEE // Reserved 3
|
||||
#define DOEXT4 0x02C10 // Reserved 4
|
||||
#define DOCOL 0x02D9D // Program
|
||||
#define DOCODE 0x02DCC // Code
|
||||
#define DOIDNT 0x02E48 // Global Name
|
||||
#define DOLAM 0x02E6D // Local Name
|
||||
#define DOROMP 0x02E92 // XLIB Name
|
||||
#define SEMI 0x0312B // ;
|
||||
|
||||
#define GARBAGECOL 0x0613E // =GARBAGECOL entry for HP48S/G and HP49G
|
||||
|
||||
// check for Metakernel version
|
||||
#define METAKERNEL Metakernel()
|
||||
|
||||
// search for "MDGKER:MK2.30" or "MDGKER:PREVIE" in port1 of a HP48GX
|
||||
static BOOL Metakernel(VOID)
|
||||
{
|
||||
BOOL bMkDetect = FALSE;
|
||||
|
||||
// card in slot1 of a HP48GX enabled
|
||||
if (cCurrentRomType=='G' && Port1 && Chipset.cards_status & PORT1_PRESENT)
|
||||
{
|
||||
// check for Metakernel string "MDGKER:"
|
||||
if (!strncmp((LPCSTR) &Port1[12],"\xD\x4\x4\x4\x7\x4\xB\x4\x5\x4\x2\x5\xA\x3",14))
|
||||
{
|
||||
bMkDetect = TRUE; // Metakernel detected
|
||||
// check for "MK"
|
||||
if (!strncmp((LPCSTR) &Port1[26],"\xD\x4\xB\x4",4))
|
||||
{
|
||||
// get version number
|
||||
WORD wVersion = ((Port1[30] * 10) + Port1[34]) * 10
|
||||
+ Port1[36];
|
||||
|
||||
// version newer then V2.30, then compatible with HP OS
|
||||
bMkDetect = (wVersion <= 230);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bMkDetect;
|
||||
}
|
||||
|
||||
static DWORD RPL_GarbageCol(VOID) // RPL variables must be in system RAM
|
||||
{
|
||||
CHIPSET OrgChipset;
|
||||
DWORD dwAVMEM;
|
||||
|
||||
// only for HP48SX, HP48GX and HP49G
|
||||
_ASSERT(cCurrentRomType == 'S' || cCurrentRomType == 'G' || cCurrentRomType == 'X');
|
||||
|
||||
OrgChipset = Chipset; // save original chipset
|
||||
|
||||
// entry for =GARBAGECOL
|
||||
Chipset.P = 0; // P=0
|
||||
Chipset.mode_dec = FALSE; // hex mode
|
||||
Chipset.pc = GARBAGECOL; // =GARBAGECOL entry
|
||||
rstkpush(0xFFFFF); // return address for stopping
|
||||
|
||||
while (Chipset.pc != 0xFFFFF) // wait for stop address
|
||||
{
|
||||
EvalOpcode(FASTPTR(Chipset.pc)); // execute opcode
|
||||
}
|
||||
|
||||
dwAVMEM = Npack(Chipset.C,5); // available AVMEM
|
||||
Chipset = OrgChipset; // restore original chipset
|
||||
return dwAVMEM;
|
||||
}
|
||||
|
||||
BOOL RPL_GetSystemFlag(INT nFlag)
|
||||
{
|
||||
DWORD dwAddr;
|
||||
BYTE byMask,byFlag;
|
||||
|
||||
_ASSERT(nFlag > 0); // first flag is 1
|
||||
|
||||
// calculate memory address and bit mask
|
||||
dwAddr = SYSTEMFLAGS + (nFlag - 1) / 4;
|
||||
byMask = 1 << ((nFlag - 1) & 0x3);
|
||||
|
||||
Npeek(&byFlag,dwAddr,sizeof(byFlag));
|
||||
return (byFlag & byMask) != 0;
|
||||
}
|
||||
|
||||
DWORD RPL_SkipOb(DWORD d)
|
||||
{
|
||||
BYTE X[8];
|
||||
DWORD n, l;
|
||||
|
||||
Npeek(X,d,5);
|
||||
n = Npack(X, 5); // read prolog
|
||||
switch (n)
|
||||
{
|
||||
case DOFLASHP: l = (cCurrentRomType!='X') ? 5 : 12; break; // Flash PTR (HP49G)
|
||||
case DOBINT: l = 10; break; // System Binary
|
||||
case DOREAL: l = 21; break; // Real
|
||||
case DOEREL: l = 26; break; // Long Real
|
||||
case DOCMP: l = 37; break; // Complex
|
||||
case DOECMP: l = 47; break; // Long Complex
|
||||
case DOCHAR: l = 7; break; // Character
|
||||
case DOROMP: l = 11; break; // XLIB Name
|
||||
case DOMATRIX: // Symbolic matrix (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOLIST: // List
|
||||
case DOSYMB: // Algebraic
|
||||
case DOEXT: // Unit
|
||||
case DOCOL: // Program
|
||||
n=d+5;
|
||||
do
|
||||
{
|
||||
d=n; n=RPL_SkipOb(d);
|
||||
} while (d!=n);
|
||||
return n+5;
|
||||
case SEMI: return d; // SEMI
|
||||
case DOIDNT: // Global Name
|
||||
case DOLAM: // Local Name
|
||||
case DOTAG: // Tagged
|
||||
Npeek(X,d+5,2); n = 7 + Npack(X,2)*2;
|
||||
return RPL_SkipOb(d+n);
|
||||
case DORRP: // Directory
|
||||
d+=8;
|
||||
n = Read5(d);
|
||||
if (n==0)
|
||||
{
|
||||
return d+5;
|
||||
}
|
||||
else
|
||||
{
|
||||
d+=n;
|
||||
Npeek(X,d,2);
|
||||
n = Npack(X,2)*2 + 4;
|
||||
return RPL_SkipOb(d+n);
|
||||
}
|
||||
case DOINT: // Precision Integer (HP49G)
|
||||
case DOAPLET: // Aplet (HP49G)
|
||||
case DOMINIFONT: // Mini Font (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOARRY: // Array
|
||||
case DOLNKARRY: // Linked Array
|
||||
case DOCSTR: // String
|
||||
case DOHSTR: // Binary Integer
|
||||
case DOGROB: // Graphic
|
||||
case DOLIB: // Library
|
||||
case DOBAK: // Backup
|
||||
case DOEXT0: // Library Data
|
||||
case DOEXT1: // Reserved 1
|
||||
if (n == DOEXT1 && cCurrentRomType != 'S')
|
||||
{
|
||||
// on HP48G series and later interpreted as DOACPTR
|
||||
l = 15; break; // ACcess PoinTeR
|
||||
break;
|
||||
}
|
||||
case DOEXT2: // Reserved 2, Font (HP49G)
|
||||
case DOEXT3: // Reserved 3
|
||||
case DOEXT4: // Reserved 4
|
||||
case DOCODE: // Code
|
||||
l = 5+Read5(d+5);
|
||||
break;
|
||||
case DOLNGREAL: // Precision Real (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
}
|
||||
break;
|
||||
case DOLNGCMP: // Precision Complex (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
}
|
||||
break;
|
||||
default: return d+5;
|
||||
}
|
||||
return d+l;
|
||||
}
|
||||
|
||||
DWORD RPL_ObjectSize(BYTE *o,DWORD s)
|
||||
{
|
||||
DWORD n, l = 0;
|
||||
|
||||
if (s < 5) return BAD_OB; // size too small for prolog
|
||||
n = Npack(o,5); // read prolog
|
||||
switch (n)
|
||||
{
|
||||
case DOFLASHP: l = (cCurrentRomType!='X') ? 5 : 12; break; // Flash PTR (HP49G)
|
||||
case DOBINT: l = 10; break; // System Binary
|
||||
case DOREAL: l = 21; break; // Real
|
||||
case DOEREL: l = 26; break; // Long Real
|
||||
case DOCMP: l = 37; break; // Complex
|
||||
case DOECMP: l = 47; break; // Long Complex
|
||||
case DOCHAR: l = 7; break; // Character
|
||||
case DOROMP: l = 11; break; // XLIB Name
|
||||
case DOMATRIX: // Symbolic matrix (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOLIST: // List
|
||||
case DOSYMB: // Algebraic
|
||||
case DOEXT: // Unit
|
||||
case DOCOL: // Program
|
||||
n = 5; // prolog length
|
||||
do
|
||||
{
|
||||
l += n;
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // get new object
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
}
|
||||
while (n);
|
||||
l += 5;
|
||||
break;
|
||||
case SEMI: l = 0; break; // SEMI
|
||||
case DOIDNT: // Global Name
|
||||
case DOLAM: // Local Name
|
||||
case DOTAG: // Tagged
|
||||
if (s < 5 + 2) return BAD_OB;
|
||||
l = 7 + Npack(o+5,2) * 2; // prolog + name length
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // get new object
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
l += n;
|
||||
break;
|
||||
case DORRP: // Directory
|
||||
if (s < 8 + 5) return BAD_OB;
|
||||
n = Npack(o+8,5);
|
||||
if (n == 0) // empty dir
|
||||
{
|
||||
l = 13;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = 8 + n;
|
||||
if (s < l + 2) return BAD_OB;
|
||||
n = Npack(o+l,2) * 2 + 4;
|
||||
l += n;
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // next rrp
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
l += n;
|
||||
}
|
||||
break;
|
||||
case DOINT: // Precision Integer (HP49G)
|
||||
case DOAPLET: // Aplet (HP49G)
|
||||
case DOMINIFONT: // Mini Font (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOARRY: // Array
|
||||
case DOLNKARRY: // Linked Array
|
||||
case DOCSTR: // String
|
||||
case DOHSTR: // Binary Integer
|
||||
case DOGROB: // Graphic
|
||||
case DOLIB: // Library
|
||||
case DOBAK: // Backup
|
||||
case DOEXT0: // Library Data
|
||||
case DOEXT1: // Reserved 1
|
||||
if (n == DOEXT1 && cCurrentRomType != 'S')
|
||||
{
|
||||
// on HP48G series and later interpreted as DOACPTR
|
||||
l = 15; break; // ACcess PoinTeR
|
||||
break;
|
||||
}
|
||||
case DOEXT2: // Reserved 2, Font (HP49G)
|
||||
case DOEXT3: // Reserved 3
|
||||
case DOEXT4: // Reserved 4
|
||||
case DOCODE: // Code
|
||||
if (s < 5 + 5) return BAD_OB;
|
||||
l = 5 + Npack(o+5,5);
|
||||
break;
|
||||
case DOLNGREAL: // Precision Real (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
}
|
||||
break;
|
||||
case DOLNGCMP: // Precision Complex (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
}
|
||||
break;
|
||||
default: l = 5;
|
||||
}
|
||||
return (s >= l) ? l : BAD_OB;
|
||||
}
|
||||
|
||||
DWORD RPL_CreateTemp(DWORD l)
|
||||
{
|
||||
DWORD a, b, c;
|
||||
BYTE *p;
|
||||
|
||||
l += 6; // memory for link field (5) + marker (1) and end
|
||||
b = Read5(RSKTOP); // tail address of rtn stack
|
||||
c = Read5(DSKTOP); // top of data stack
|
||||
if ((b+l)>c) // there's not enough memory to move DSKTOP
|
||||
{
|
||||
RPL_GarbageCol(); // do a garbage collection
|
||||
b = Read5(RSKTOP); // reload tail address of rtn stack
|
||||
c = Read5(DSKTOP); // reload top of data stack
|
||||
}
|
||||
if ((b+l)>c) return 0; // check if now there's enough memory to move DSKTOP
|
||||
a = Read5(TEMPTOP); // tail address of top object
|
||||
Write5(TEMPTOP, a+l); // adjust new end of top object
|
||||
Write5(RSKTOP, b+l); // adjust new end of rtn stack
|
||||
Write5(AVMEM, (c-b-l)/5); // calculate free memory (*5 nibbles)
|
||||
p = (LPBYTE) malloc(b-a); // move down rtn stack
|
||||
Npeek(p,a,b-a);
|
||||
Nwrite(p,a+l,b-a);
|
||||
free(p);
|
||||
Write5(a+l-5,l); // set object length field
|
||||
return (a+1); // return base address of new object
|
||||
}
|
||||
|
||||
UINT RPL_Depth(VOID)
|
||||
{
|
||||
return (Read5(EDITLINE) - Read5(DSKTOP)) / 5 - 1;
|
||||
}
|
||||
|
||||
DWORD RPL_Pick(UINT l)
|
||||
{
|
||||
DWORD stkp;
|
||||
|
||||
_ASSERT(l > 0); // first stack element is one
|
||||
if (l == 0) return 0;
|
||||
if (METAKERNEL) ++l; // Metakernel support
|
||||
if (RPL_Depth() < l) return 0; // not enough elements on stack
|
||||
stkp = Read5(DSKTOP) + (l-1)*5;
|
||||
return Read5(stkp); // return object address
|
||||
}
|
||||
|
||||
VOID RPL_Replace(DWORD n)
|
||||
{
|
||||
DWORD stkp;
|
||||
|
||||
stkp = Read5(DSKTOP);
|
||||
if (METAKERNEL) stkp+=5; // Metakernel support
|
||||
Write5(stkp,n);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID RPL_Push(UINT l,DWORD n)
|
||||
{
|
||||
UINT i;
|
||||
DWORD stkp, avmem;
|
||||
|
||||
if (l > RPL_Depth() + 1) return; // invalid stack level
|
||||
|
||||
avmem = Read5(AVMEM); // amount of free memory
|
||||
if (avmem == 0) return; // no memory free
|
||||
avmem--; // fetch memory
|
||||
Write5(AVMEM,avmem); // save new amount of free memory
|
||||
|
||||
if (METAKERNEL) ++l; // Metakernel, save MK object on stack level 1
|
||||
|
||||
stkp = Read5(DSKTOP) - 5; // get pointer of new stack level 1
|
||||
Write5(DSKTOP,stkp); // save it
|
||||
|
||||
for (i = 1; i < l; ++i) // move down stack level entries before insert pos
|
||||
{
|
||||
Write5(stkp,Read5(stkp+5)); // move down stack level entry
|
||||
stkp += 5; // next stack entry
|
||||
}
|
||||
|
||||
Write5(stkp,n); // save pointer of new object on given stack level
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* rpl.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "ops.h"
|
||||
#include "io.h"
|
||||
|
||||
//| 38G | 39G | 40G | 48SX | 48GX | 49G | Name
|
||||
//#F0688 #806E9 #806E9 #7056A #806E9 #806E9 =TEMPOB
|
||||
//#F068D #806EE #806EE #7056F #806EE #806EE =TEMPTOP
|
||||
//#F0692 #806F3 #806F3 #70574 #806F3 #806F3 =RSKTOP (B)
|
||||
//#F0697 #806F8 #806F8 #70579 #806F8 #806F8 =DSKTOP (D1)
|
||||
//#F069C #806FD #806FD #7057E #806FD #806FD =EDITLINE
|
||||
//#F0DEA #80E9B #80E9B #7066E #807ED #80E9B =AVMEM (D)
|
||||
//#F0705 #8076B #8076B #705B0 #8072F #8076B =INTRPPTR (D0)
|
||||
//#F0E42 #80F02 #80F02 #706C5 #80843 #80F02 =SystemFlags
|
||||
|
||||
#define TEMPOB ((cCurrentRomType=='S')?0x7056A:0x806E9)
|
||||
#define TEMPTOP ((cCurrentRomType=='S')?0x7056F:0x806EE)
|
||||
#define RSKTOP ((cCurrentRomType=='S')?0x70574:0x806F3)
|
||||
#define DSKTOP ((cCurrentRomType=='S')?0x70579:0x806F8)
|
||||
#define EDITLINE ((cCurrentRomType=='S')?0x7057E:0x806FD)
|
||||
#define AVMEM ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x7066E:0x807ED):0x80E9B)
|
||||
#define INTRPPTR ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x705B0:0x8072F):0x8076B)
|
||||
#define SYSTEMFLAGS ((cCurrentRomType!='X')?((cCurrentRomType=='S')?0x706C5:0x80843):0x80F02)
|
||||
|
||||
#define DOINT 0x02614 // Precision Integer (HP49G)
|
||||
#define DOLNGREAL 0x0263A // Precision Real (HP49G)
|
||||
#define DOLNGCMP 0x02660 // Precision Complex (HP49G)
|
||||
#define DOMATRIX 0x02686 // Symbolic matrix (HP49G)
|
||||
#define DOFLASHP 0x026AC // Flash PTR (HP49G)
|
||||
#define DOAPLET 0x026D5 // Aplet (HP49G)
|
||||
#define DOMINIFONT 0x026FE // Mini Font (HP49G)
|
||||
#define DOBINT 0x02911 // System Binary
|
||||
#define DOREAL 0x02933 // Real
|
||||
#define DOEREL 0x02955 // Long Real
|
||||
#define DOCMP 0x02977 // Complex
|
||||
#define DOECMP 0x0299D // Long Complex
|
||||
#define DOCHAR 0x029BF // Character
|
||||
#define DOARRY 0x029E8 // Array
|
||||
#define DOLNKARRY 0x02A0A // Linked Array
|
||||
#define DOCSTR 0x02A2C // String
|
||||
#define DOHSTR 0x02A4E // Binary Integer
|
||||
#define DOLIST 0x02A74 // List
|
||||
#define DORRP 0x02A96 // Directory
|
||||
#define DOSYMB 0x02AB8 // Algebraic
|
||||
#define DOEXT 0x02ADA // Unit
|
||||
#define DOTAG 0x02AFC // Tagged
|
||||
#define DOGROB 0x02B1E // Graphic
|
||||
#define DOLIB 0x02B40 // Library
|
||||
#define DOBAK 0x02B62 // Backup
|
||||
#define DOEXT0 0x02B88 // Library Data
|
||||
#define DOEXT1 0x02BAA // Reserved 1, ACcess PoinTeR (HP48GX and later)
|
||||
#define DOEXT2 0x02BCC // Reserved 2, Font (HP49G)
|
||||
#define DOEXT3 0x02BEE // Reserved 3
|
||||
#define DOEXT4 0x02C10 // Reserved 4
|
||||
#define DOCOL 0x02D9D // Program
|
||||
#define DOCODE 0x02DCC // Code
|
||||
#define DOIDNT 0x02E48 // Global Name
|
||||
#define DOLAM 0x02E6D // Local Name
|
||||
#define DOROMP 0x02E92 // XLIB Name
|
||||
#define SEMI 0x0312B // ;
|
||||
|
||||
#define GARBAGECOL 0x0613E // =GARBAGECOL entry for HP48S/G and HP49G
|
||||
|
||||
// check for Metakernel version
|
||||
#define METAKERNEL Metakernel()
|
||||
|
||||
// search for "MDGKER:MK2.30" or "MDGKER:PREVIE" in port1 of a HP48GX
|
||||
static BOOL Metakernel(VOID)
|
||||
{
|
||||
BOOL bMkDetect = FALSE;
|
||||
|
||||
// card in slot1 of a HP48GX enabled
|
||||
if (cCurrentRomType=='G' && Port1 && Chipset.cards_status & PORT1_PRESENT)
|
||||
{
|
||||
// check for Metakernel string "MDGKER:"
|
||||
if (!strncmp((LPCSTR) &Port1[12],"\xD\x4\x4\x4\x7\x4\xB\x4\x5\x4\x2\x5\xA\x3",14))
|
||||
{
|
||||
bMkDetect = TRUE; // Metakernel detected
|
||||
// check for "MK"
|
||||
if (!strncmp((LPCSTR) &Port1[26],"\xD\x4\xB\x4",4))
|
||||
{
|
||||
// get version number
|
||||
WORD wVersion = ((Port1[30] * 10) + Port1[34]) * 10
|
||||
+ Port1[36];
|
||||
|
||||
// version newer then V2.30, then compatible with HP OS
|
||||
bMkDetect = (wVersion <= 230);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bMkDetect;
|
||||
}
|
||||
|
||||
static DWORD RPL_GarbageCol(VOID) // RPL variables must be in system RAM
|
||||
{
|
||||
CHIPSET OrgChipset;
|
||||
DWORD dwAVMEM;
|
||||
|
||||
// only for HP48SX, HP48GX and HP49G
|
||||
_ASSERT(cCurrentRomType == 'S' || cCurrentRomType == 'G' || cCurrentRomType == 'X');
|
||||
|
||||
OrgChipset = Chipset; // save original chipset
|
||||
|
||||
// entry for =GARBAGECOL
|
||||
Chipset.P = 0; // P=0
|
||||
Chipset.mode_dec = FALSE; // hex mode
|
||||
Chipset.pc = GARBAGECOL; // =GARBAGECOL entry
|
||||
rstkpush(0xFFFFF); // return address for stopping
|
||||
|
||||
while (Chipset.pc != 0xFFFFF) // wait for stop address
|
||||
{
|
||||
EvalOpcode(FASTPTR(Chipset.pc)); // execute opcode
|
||||
}
|
||||
|
||||
dwAVMEM = Npack(Chipset.C,5); // available AVMEM
|
||||
Chipset = OrgChipset; // restore original chipset
|
||||
return dwAVMEM;
|
||||
}
|
||||
|
||||
BOOL RPL_GetSystemFlag(INT nFlag)
|
||||
{
|
||||
DWORD dwAddr;
|
||||
BYTE byMask,byFlag;
|
||||
|
||||
_ASSERT(nFlag > 0); // first flag is 1
|
||||
|
||||
// calculate memory address and bit mask
|
||||
dwAddr = SYSTEMFLAGS + (nFlag - 1) / 4;
|
||||
byMask = 1 << ((nFlag - 1) & 0x3);
|
||||
|
||||
Npeek(&byFlag,dwAddr,sizeof(byFlag));
|
||||
return (byFlag & byMask) != 0;
|
||||
}
|
||||
|
||||
DWORD RPL_SkipOb(DWORD d)
|
||||
{
|
||||
BYTE X[8];
|
||||
DWORD n, l;
|
||||
|
||||
Npeek(X,d,5);
|
||||
n = Npack(X, 5); // read prolog
|
||||
switch (n)
|
||||
{
|
||||
case DOFLASHP: l = (cCurrentRomType!='X') ? 5 : 12; break; // Flash PTR (HP49G)
|
||||
case DOBINT: l = 10; break; // System Binary
|
||||
case DOREAL: l = 21; break; // Real
|
||||
case DOEREL: l = 26; break; // Long Real
|
||||
case DOCMP: l = 37; break; // Complex
|
||||
case DOECMP: l = 47; break; // Long Complex
|
||||
case DOCHAR: l = 7; break; // Character
|
||||
case DOROMP: l = 11; break; // XLIB Name
|
||||
case DOMATRIX: // Symbolic matrix (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOLIST: // List
|
||||
case DOSYMB: // Algebraic
|
||||
case DOEXT: // Unit
|
||||
case DOCOL: // Program
|
||||
n=d+5;
|
||||
do
|
||||
{
|
||||
d=n; n=RPL_SkipOb(d);
|
||||
} while (d!=n);
|
||||
return n+5;
|
||||
case SEMI: return d; // SEMI
|
||||
case DOIDNT: // Global Name
|
||||
case DOLAM: // Local Name
|
||||
case DOTAG: // Tagged
|
||||
Npeek(X,d+5,2); n = 7 + Npack(X,2)*2;
|
||||
return RPL_SkipOb(d+n);
|
||||
case DORRP: // Directory
|
||||
d+=8;
|
||||
n = Read5(d);
|
||||
if (n==0)
|
||||
{
|
||||
return d+5;
|
||||
}
|
||||
else
|
||||
{
|
||||
d+=n;
|
||||
Npeek(X,d,2);
|
||||
n = Npack(X,2)*2 + 4;
|
||||
return RPL_SkipOb(d+n);
|
||||
}
|
||||
case DOINT: // Precision Integer (HP49G)
|
||||
case DOAPLET: // Aplet (HP49G)
|
||||
case DOMINIFONT: // Mini Font (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOARRY: // Array
|
||||
case DOLNKARRY: // Linked Array
|
||||
case DOCSTR: // String
|
||||
case DOHSTR: // Binary Integer
|
||||
case DOGROB: // Graphic
|
||||
case DOLIB: // Library
|
||||
case DOBAK: // Backup
|
||||
case DOEXT0: // Library Data
|
||||
case DOEXT1: // Reserved 1
|
||||
if (n == DOEXT1 && cCurrentRomType != 'S')
|
||||
{
|
||||
// on HP48G series and later interpreted as DOACPTR
|
||||
l = 15; break; // ACcess PoinTeR
|
||||
break;
|
||||
}
|
||||
case DOEXT2: // Reserved 2, Font (HP49G)
|
||||
case DOEXT3: // Reserved 3
|
||||
case DOEXT4: // Reserved 4
|
||||
case DOCODE: // Code
|
||||
l = 5+Read5(d+5);
|
||||
break;
|
||||
case DOLNGREAL: // Precision Real (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
}
|
||||
break;
|
||||
case DOLNGCMP: // Precision Complex (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
l += Read5(d+l);
|
||||
}
|
||||
break;
|
||||
default: return d+5;
|
||||
}
|
||||
return d+l;
|
||||
}
|
||||
|
||||
DWORD RPL_ObjectSize(BYTE *o,DWORD s)
|
||||
{
|
||||
DWORD n, l = 0;
|
||||
|
||||
if (s < 5) return BAD_OB; // size too small for prolog
|
||||
n = Npack(o,5); // read prolog
|
||||
switch (n)
|
||||
{
|
||||
case DOFLASHP: l = (cCurrentRomType!='X') ? 5 : 12; break; // Flash PTR (HP49G)
|
||||
case DOBINT: l = 10; break; // System Binary
|
||||
case DOREAL: l = 21; break; // Real
|
||||
case DOEREL: l = 26; break; // Long Real
|
||||
case DOCMP: l = 37; break; // Complex
|
||||
case DOECMP: l = 47; break; // Long Complex
|
||||
case DOCHAR: l = 7; break; // Character
|
||||
case DOROMP: l = 11; break; // XLIB Name
|
||||
case DOMATRIX: // Symbolic matrix (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOLIST: // List
|
||||
case DOSYMB: // Algebraic
|
||||
case DOEXT: // Unit
|
||||
case DOCOL: // Program
|
||||
n = 5; // prolog length
|
||||
do
|
||||
{
|
||||
l += n;
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // get new object
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
}
|
||||
while (n);
|
||||
l += 5;
|
||||
break;
|
||||
case SEMI: l = 0; break; // SEMI
|
||||
case DOIDNT: // Global Name
|
||||
case DOLAM: // Local Name
|
||||
case DOTAG: // Tagged
|
||||
if (s < 5 + 2) return BAD_OB;
|
||||
l = 7 + Npack(o+5,2) * 2; // prolog + name length
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // get new object
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
l += n;
|
||||
break;
|
||||
case DORRP: // Directory
|
||||
if (s < 8 + 5) return BAD_OB;
|
||||
n = Npack(o+8,5);
|
||||
if (n == 0) // empty dir
|
||||
{
|
||||
l = 13;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = 8 + n;
|
||||
if (s < l + 2) return BAD_OB;
|
||||
n = Npack(o+l,2) * 2 + 4;
|
||||
l += n;
|
||||
if (l > s) return BAD_OB; // prevent negative size argument
|
||||
n = RPL_ObjectSize(o+l,s-l); // next rrp
|
||||
if (n == BAD_OB) return BAD_OB; // buffer overflow
|
||||
l += n;
|
||||
}
|
||||
break;
|
||||
case DOINT: // Precision Integer (HP49G)
|
||||
case DOAPLET: // Aplet (HP49G)
|
||||
case DOMINIFONT: // Mini Font (HP49G)
|
||||
if (cCurrentRomType!='X')
|
||||
{
|
||||
l = 5;
|
||||
break;
|
||||
}
|
||||
case DOARRY: // Array
|
||||
case DOLNKARRY: // Linked Array
|
||||
case DOCSTR: // String
|
||||
case DOHSTR: // Binary Integer
|
||||
case DOGROB: // Graphic
|
||||
case DOLIB: // Library
|
||||
case DOBAK: // Backup
|
||||
case DOEXT0: // Library Data
|
||||
case DOEXT1: // Reserved 1
|
||||
if (n == DOEXT1 && cCurrentRomType != 'S')
|
||||
{
|
||||
// on HP48G series and later interpreted as DOACPTR
|
||||
l = 15; break; // ACcess PoinTeR
|
||||
break;
|
||||
}
|
||||
case DOEXT2: // Reserved 2, Font (HP49G)
|
||||
case DOEXT3: // Reserved 3
|
||||
case DOEXT4: // Reserved 4
|
||||
case DOCODE: // Code
|
||||
if (s < 5 + 5) return BAD_OB;
|
||||
l = 5 + Npack(o+5,5);
|
||||
break;
|
||||
case DOLNGREAL: // Precision Real (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
}
|
||||
break;
|
||||
case DOLNGCMP: // Precision Complex (HP49G)
|
||||
l = 5;
|
||||
if (cCurrentRomType=='X')
|
||||
{
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
if (s < l + 5) return BAD_OB;
|
||||
l += Npack(o+l,5);
|
||||
}
|
||||
break;
|
||||
default: l = 5;
|
||||
}
|
||||
return (s >= l) ? l : BAD_OB;
|
||||
}
|
||||
|
||||
DWORD RPL_CreateTemp(DWORD l)
|
||||
{
|
||||
DWORD a, b, c;
|
||||
BYTE *p;
|
||||
|
||||
l += 6; // memory for link field (5) + marker (1) and end
|
||||
b = Read5(RSKTOP); // tail address of rtn stack
|
||||
c = Read5(DSKTOP); // top of data stack
|
||||
if ((b+l)>c) // there's not enough memory to move DSKTOP
|
||||
{
|
||||
RPL_GarbageCol(); // do a garbage collection
|
||||
b = Read5(RSKTOP); // reload tail address of rtn stack
|
||||
c = Read5(DSKTOP); // reload top of data stack
|
||||
}
|
||||
if ((b+l)>c) return 0; // check if now there's enough memory to move DSKTOP
|
||||
a = Read5(TEMPTOP); // tail address of top object
|
||||
Write5(TEMPTOP, a+l); // adjust new end of top object
|
||||
Write5(RSKTOP, b+l); // adjust new end of rtn stack
|
||||
Write5(AVMEM, (c-b-l)/5); // calculate free memory (*5 nibbles)
|
||||
p = (LPBYTE) malloc(b-a); // move down rtn stack
|
||||
Npeek(p,a,b-a);
|
||||
Nwrite(p,a+l,b-a);
|
||||
free(p);
|
||||
Write5(a+l-5,l); // set object length field
|
||||
return (a+1); // return base address of new object
|
||||
}
|
||||
|
||||
UINT RPL_Depth(VOID)
|
||||
{
|
||||
return (Read5(EDITLINE) - Read5(DSKTOP)) / 5 - 1;
|
||||
}
|
||||
|
||||
DWORD RPL_Pick(UINT l)
|
||||
{
|
||||
DWORD stkp;
|
||||
|
||||
_ASSERT(l > 0); // first stack element is one
|
||||
if (l == 0) return 0;
|
||||
if (METAKERNEL) ++l; // Metakernel support
|
||||
if (RPL_Depth() < l) return 0; // not enough elements on stack
|
||||
stkp = Read5(DSKTOP) + (l-1)*5;
|
||||
return Read5(stkp); // return object address
|
||||
}
|
||||
|
||||
VOID RPL_Replace(DWORD n)
|
||||
{
|
||||
DWORD stkp;
|
||||
|
||||
stkp = Read5(DSKTOP);
|
||||
if (METAKERNEL) stkp+=5; // Metakernel support
|
||||
Write5(stkp,n);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID RPL_Push(UINT l,DWORD n)
|
||||
{
|
||||
UINT i;
|
||||
DWORD stkp, avmem;
|
||||
|
||||
if (l > RPL_Depth() + 1) return; // invalid stack level
|
||||
|
||||
avmem = Read5(AVMEM); // amount of free memory
|
||||
if (avmem == 0) return; // no memory free
|
||||
avmem--; // fetch memory
|
||||
Write5(AVMEM,avmem); // save new amount of free memory
|
||||
|
||||
if (METAKERNEL) ++l; // Metakernel, save MK object on stack level 1
|
||||
|
||||
stkp = Read5(DSKTOP) - 5; // get pointer of new stack level 1
|
||||
Write5(DSKTOP,stkp); // save it
|
||||
|
||||
for (i = 1; i < l; ++i) // move down stack level entries before insert pos
|
||||
{
|
||||
Write5(stkp,Read5(stkp+5)); // move down stack level entry
|
||||
stkp += 5; // next stack entry
|
||||
}
|
||||
|
||||
Write5(stkp,n); // save pointer of new object on given stack level
|
||||
return;
|
||||
}
|
|
@ -1,401 +1,400 @@
|
|||
/*
|
||||
* Serial.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1998 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
#define INTERRUPT ((void)(Chipset.SoftInt=TRUE,bInterrupt=TRUE))
|
||||
|
||||
// state of USRQ
|
||||
#define NINT2ERBZ ((Chipset.IORam[IOC] & (SON | ERBZ)) == (SON | ERBZ) && (Chipset.IORam[RCS] & RBZ) != 0)
|
||||
#define NINT2ERBF ((Chipset.IORam[IOC] & (SON | ERBF)) == (SON | ERBF) && (Chipset.IORam[RCS] & RBF) != 0)
|
||||
#define NINT2ETBE ((Chipset.IORam[IOC] & (SON | ETBE)) == (SON | ETBE) && (Chipset.IORam[TCS] & TBF) == 0)
|
||||
|
||||
#define NINT2USRQ (NINT2ERBZ || NINT2ERBF || NINT2ETBE)
|
||||
|
||||
static HANDLE hComm = NULL;
|
||||
|
||||
static HANDLE hCThreadTxd;
|
||||
static HANDLE hCThreadEv;
|
||||
|
||||
static HANDLE hEventTxd;
|
||||
static BOOL bWriting;
|
||||
static BYTE tbr;
|
||||
|
||||
static BOOL bReading;
|
||||
static BYTE cBuffer[32];
|
||||
static WORD nRp;
|
||||
static DWORD dwBytesRead;
|
||||
|
||||
static DWORD WINAPI TransmitThread(LPVOID pParam)
|
||||
{
|
||||
OVERLAPPED osWr = { 0 };
|
||||
|
||||
osWr.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
|
||||
while (bWriting)
|
||||
{
|
||||
WaitForSingleObject(hEventTxd,INFINITE);
|
||||
if (bWriting)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
if (!WriteFile(hComm,(LPCVOID) &tbr,1,&dwWritten,&osWr))
|
||||
if (GetLastError() == ERROR_IO_PENDING)
|
||||
GetOverlappedResult(hComm,&osWr,&dwWritten,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(osWr.hEvent); // close write event handle
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
static DWORD WINAPI EventThread(LPVOID pParam)
|
||||
{
|
||||
DWORD dwEvent;
|
||||
|
||||
bReading = TRUE; // flag for SerialThread started
|
||||
while (bReading)
|
||||
{
|
||||
_ASSERT(hComm != NULL);
|
||||
WaitCommEvent(hComm,&dwEvent,NULL); // wait for serial event
|
||||
if (dwEvent & EV_RXCHAR) // signal char received
|
||||
{
|
||||
CommReceive(); // get data
|
||||
// interrupt request and emulation thread down
|
||||
if (Chipset.SoftInt && Chipset.Shutdn)
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
if (dwEvent & EV_TXEMPTY) // signal transmit buffer empty
|
||||
{
|
||||
IOBit(TCS,TBZ,FALSE); // clear transmitter busy bit
|
||||
CommTransmit(); // check for new char to transmit
|
||||
}
|
||||
if (dwEvent & EV_ERR) // signal error received
|
||||
{
|
||||
DWORD dwError;
|
||||
|
||||
ClearCommError(hComm,&dwError,NULL);
|
||||
if (dwError & (CE_FRAME | CE_OVERRUN | CE_BREAK))
|
||||
IOBit(RCS,RER,TRUE); // receiver error
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
BOOL CommIsOpen(VOID)
|
||||
{
|
||||
return hComm != NULL; // have COM port handle
|
||||
}
|
||||
|
||||
BOOL CommOpen(LPTSTR strWirePort,LPTSTR strIrPort)
|
||||
{
|
||||
COMMTIMEOUTS CommTimeouts = { MAXDWORD, 0L, 0L, 0L, 0L };
|
||||
|
||||
LPCTSTR strPort = (Chipset.IORam[IR_CTRL] & EIRU) ? strIrPort : strWirePort;
|
||||
|
||||
_ASSERT(Chipset.IORam[IOC] & SON); // UART on
|
||||
CommClose(); // close port if already open
|
||||
|
||||
dwBytesRead = 0L; // no bytes received
|
||||
|
||||
if (lstrcmp(strPort, _T(NO_SERIAL))) // port defined
|
||||
{
|
||||
TCHAR szDevice[256] = _T("\\\\.\\");
|
||||
|
||||
// check if device buffer is big enough
|
||||
_ASSERT(lstrlen(szDevice) + lstrlen(strPort) < (INT) ARRAYSIZEOF(szDevice));
|
||||
if (lstrlen(szDevice) + lstrlen(strPort) >= (INT) ARRAYSIZEOF(szDevice))
|
||||
return hComm != NULL;
|
||||
|
||||
_tcscat(szDevice,strPort); // device name
|
||||
hComm = CreateFile(szDevice,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
|
||||
if (hComm != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwThreadId;
|
||||
|
||||
nRp = 0; // reset receiver state
|
||||
|
||||
SetCommTimeouts(hComm,&CommTimeouts);
|
||||
CommSetBaud();
|
||||
|
||||
CommTxBRK(); // update BRK condition
|
||||
|
||||
// event to transmit character
|
||||
hEventTxd = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
// create char transmit handler
|
||||
bWriting = TRUE;
|
||||
hCThreadTxd = CreateThread(NULL,0,&TransmitThread,NULL,CREATE_SUSPENDED,&dwThreadId);
|
||||
_ASSERT(hCThreadTxd);
|
||||
SetThreadPriority(hCThreadTxd,THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(hCThreadTxd); // start thread
|
||||
|
||||
// create Comm event handler
|
||||
bReading = FALSE;
|
||||
SetCommMask(hComm,EV_RXCHAR | EV_TXEMPTY | EV_ERR); // event on RX, TX, error
|
||||
hCThreadEv = CreateThread(NULL,0,&EventThread,NULL,CREATE_SUSPENDED,&dwThreadId);
|
||||
_ASSERT(hCThreadEv);
|
||||
SetThreadPriority(hCThreadEv,THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(hCThreadEv); // start thread
|
||||
while (!bReading) Sleep(0); // wait for SerialThread started
|
||||
}
|
||||
else
|
||||
{
|
||||
hComm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
wsprintf(buffer,_T("COM port %s.\n"),hComm ? _T("opened"): _T("open error"));
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
return hComm != NULL;
|
||||
}
|
||||
|
||||
VOID CommClose(VOID)
|
||||
{
|
||||
if (hComm != NULL) // port open
|
||||
{
|
||||
// workaround to fix problems with some Kermit server programs
|
||||
// reason: on one hand we have the character transmitting time base on the
|
||||
// selected baudrate, on the other hand the time between sending the last
|
||||
// character and closing the port. The last time is much longer on the real
|
||||
// calculator than on the emulator running at full speed, therefore the
|
||||
// slow down time on the emulator
|
||||
Sleep(25); // slow down time
|
||||
|
||||
bReading = FALSE; // kill event thread
|
||||
SetCommMask(hComm,0L); // clear all events and force WaitCommEvent to return
|
||||
WaitForSingleObject(hCThreadEv,INFINITE);
|
||||
CloseHandle(hCThreadEv);
|
||||
|
||||
bWriting = FALSE; // kill write thread
|
||||
SetEvent(hEventTxd); // continue write thread
|
||||
WaitForSingleObject(hCThreadTxd,INFINITE);
|
||||
CloseHandle(hCThreadTxd);
|
||||
|
||||
CloseHandle(hEventTxd); // close Txd event
|
||||
CloseHandle(hComm); // close port
|
||||
hComm = NULL;
|
||||
#if defined DEBUG_SERIAL
|
||||
OutputDebugString(_T("COM port closed.\n"));
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommSetBaud(VOID)
|
||||
{
|
||||
if (hComm != NULL)
|
||||
{
|
||||
const DWORD dwBaudrates[] = { 1200, 1920, 2400, 3840, 4800, 7680, 9600, 15360 };
|
||||
|
||||
DCB dcb;
|
||||
|
||||
ZeroMemory(&dcb,sizeof(dcb));
|
||||
dcb.DCBlength = sizeof(dcb);
|
||||
dcb.BaudRate = dwBaudrates[Chipset.IORam[BAUD] & 0x7];
|
||||
dcb.fBinary = TRUE;
|
||||
dcb.fParity = TRUE;
|
||||
dcb.fOutxCtsFlow = FALSE;
|
||||
dcb.fOutxDsrFlow = FALSE;
|
||||
dcb.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
dcb.fDsrSensitivity = FALSE;
|
||||
dcb.fOutX = FALSE;
|
||||
dcb.fErrorChar = FALSE;
|
||||
dcb.fNull = FALSE;
|
||||
dcb.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
dcb.fAbortOnError = FALSE; // may changed in further implementations
|
||||
dcb.ByteSize = 8;
|
||||
dcb.Parity = NOPARITY; // no parity check, emulated by software
|
||||
dcb.StopBits = TWOSTOPBITS;
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
wsprintf(buffer,_T("CommsetBaud: %ld\n"),dcb.BaudRate);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
SetCommState(hComm,&dcb);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL UpdateUSRQ(VOID) // USRQ handling
|
||||
{
|
||||
BOOL bUSRQ = NINT2USRQ;
|
||||
IOBit(SRQ1,USRQ,bUSRQ); // update USRQ bit
|
||||
return bUSRQ;
|
||||
}
|
||||
|
||||
VOID CommTxBRK(VOID)
|
||||
{
|
||||
if (Chipset.IORam[TCS] & BRK) // BRK condition
|
||||
{
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
// abort data transfer
|
||||
PurgeComm(hComm,PURGE_TXABORT | PURGE_TXCLEAR);
|
||||
SetCommBreak(hComm); // set into BRK state
|
||||
}
|
||||
|
||||
// TBF and TBZ bits of TCS are undefined
|
||||
|
||||
if (Chipset.IORam[TCS] & LPB) // is loopback bit set
|
||||
{
|
||||
dwBytesRead = nRp = 0; // clear receive buffer
|
||||
cBuffer[dwBytesRead++] = 0; // save character in receive buffer
|
||||
|
||||
CommReceive(); // receive available byte
|
||||
IOBit(RCS,RER,TRUE); // receiver error (no stop bit)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
ClearCommBreak(hComm); // clear BRK state
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommTransmit(VOID)
|
||||
{
|
||||
BOOL bTxChar = FALSE;
|
||||
|
||||
EnterCriticalSection(&csTxdLock);
|
||||
if ( (Chipset.IORam[TCS] & TBZ) == 0 // transmitter not busy
|
||||
&& (Chipset.IORam[TCS] & TBF) != 0) // transmit buffer full
|
||||
{
|
||||
tbr = (Chipset.IORam[TBR_MSB] << 4) | Chipset.IORam[TBR_LSB];
|
||||
|
||||
IOBit(TCS,TBF,FALSE); // clear transmit buffer full bit
|
||||
IOBit(TCS,TBZ,TRUE); // set transmitter busy bit
|
||||
|
||||
bTxChar = TRUE;
|
||||
}
|
||||
LeaveCriticalSection(&csTxdLock);
|
||||
|
||||
if (bTxChar) // character to transmit
|
||||
{
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
if (isprint(tbr))
|
||||
wsprintf(buffer,_T("-> '%c'\n"),tbr);
|
||||
else
|
||||
wsprintf(buffer,_T("-> %02X\n"),tbr);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Chipset.IORam[TCS] & LPB) // is loopback bit set
|
||||
{
|
||||
if (dwBytesRead == 0) nRp = 0; // no character received, reset read pointer
|
||||
cBuffer[nRp+dwBytesRead] = tbr; // save character in receive buffer
|
||||
++dwBytesRead;
|
||||
|
||||
CommReceive(); // receive available byte
|
||||
}
|
||||
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
SetEvent(hEventTxd); // write TBR byte
|
||||
}
|
||||
else
|
||||
{
|
||||
IOBit(TCS,TBZ,FALSE); // clear transmitter busy bit
|
||||
}
|
||||
}
|
||||
if (UpdateUSRQ()) // update USRQ bit
|
||||
INTERRUPT;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommReceive(VOID)
|
||||
{
|
||||
OVERLAPPED os = { 0 };
|
||||
|
||||
if (!(Chipset.IORam[IOC] & SON)) // UART off
|
||||
{
|
||||
dwBytesRead = 0L; // no bytes received
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&csRecvLock);
|
||||
do
|
||||
{
|
||||
if (Chipset.IORam[RCS] & RBF) // receive buffer full
|
||||
break;
|
||||
|
||||
// reject reading if com port is closed and not whole operation
|
||||
if (hComm) // com port open
|
||||
{
|
||||
UINT uCnt = 0; // retry counter
|
||||
|
||||
while (dwBytesRead == 0L) // buffer empty
|
||||
{
|
||||
if (ReadFile(hComm,cBuffer,sizeof(cBuffer),&dwBytesRead,&os) == FALSE)
|
||||
dwBytesRead = 0L;
|
||||
else // bytes received
|
||||
nRp = 0; // reset read pointer
|
||||
|
||||
// something received or passed 1st retry
|
||||
if (dwBytesRead != 0L || ++uCnt > 1)
|
||||
break; // quit
|
||||
|
||||
Sleep(1); // workaround, retry 1ms later
|
||||
}
|
||||
}
|
||||
|
||||
if (dwBytesRead == 0L) // receive buffer empty
|
||||
break;
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
if (isprint(cBuffer[nRp]))
|
||||
wsprintf(buffer,_T("<- '%c'\n"),cBuffer[nRp]);
|
||||
else
|
||||
wsprintf(buffer,_T("<- %02X\n"),cBuffer[nRp]);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
Chipset.IORam[RBR_MSB] = (cBuffer[nRp] >> 4);
|
||||
Chipset.IORam[RBR_LSB] = (cBuffer[nRp] & 0x0f);
|
||||
++nRp;
|
||||
--dwBytesRead;
|
||||
|
||||
Chipset.IORam[RCS] |= RBF; // receive buffer full
|
||||
if (UpdateUSRQ()) // update USRQ bit
|
||||
INTERRUPT;
|
||||
}
|
||||
while (FALSE);
|
||||
LeaveCriticalSection(&csRecvLock);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Serial.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1998 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "io.h"
|
||||
|
||||
#define INTERRUPT ((void)(Chipset.SoftInt=TRUE,bInterrupt=TRUE))
|
||||
|
||||
// state of USRQ
|
||||
#define NINT2ERBZ ((Chipset.IORam[IOC] & (SON | ERBZ)) == (SON | ERBZ) && (Chipset.IORam[RCS] & RBZ) != 0)
|
||||
#define NINT2ERBF ((Chipset.IORam[IOC] & (SON | ERBF)) == (SON | ERBF) && (Chipset.IORam[RCS] & RBF) != 0)
|
||||
#define NINT2ETBE ((Chipset.IORam[IOC] & (SON | ETBE)) == (SON | ETBE) && (Chipset.IORam[TCS] & TBF) == 0)
|
||||
|
||||
#define NINT2USRQ (NINT2ERBZ || NINT2ERBF || NINT2ETBE)
|
||||
|
||||
static HANDLE hComm = NULL;
|
||||
|
||||
static HANDLE hCThreadTxd;
|
||||
static HANDLE hCThreadEv;
|
||||
|
||||
static HANDLE hEventTxd;
|
||||
static BOOL bWriting;
|
||||
static BYTE tbr;
|
||||
|
||||
static BOOL bReading;
|
||||
static BYTE cBuffer[32];
|
||||
static WORD nRp;
|
||||
static DWORD dwBytesRead;
|
||||
|
||||
static DWORD WINAPI TransmitThread(LPVOID pParam)
|
||||
{
|
||||
OVERLAPPED osWr = { 0 };
|
||||
|
||||
osWr.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
|
||||
while (bWriting)
|
||||
{
|
||||
WaitForSingleObject(hEventTxd,INFINITE);
|
||||
if (bWriting)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
if (!WriteFile(hComm,(LPCVOID) &tbr,1,&dwWritten,&osWr))
|
||||
if (GetLastError() == ERROR_IO_PENDING)
|
||||
GetOverlappedResult(hComm,&osWr,&dwWritten,TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(osWr.hEvent); // close write event handle
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
static DWORD WINAPI EventThread(LPVOID pParam)
|
||||
{
|
||||
DWORD dwEvent;
|
||||
|
||||
bReading = TRUE; // flag for SerialThread started
|
||||
while (bReading)
|
||||
{
|
||||
_ASSERT(hComm != NULL);
|
||||
WaitCommEvent(hComm,&dwEvent,NULL); // wait for serial event
|
||||
if (dwEvent & EV_RXCHAR) // signal char received
|
||||
{
|
||||
CommReceive(); // get data
|
||||
// interrupt request and emulation thread down
|
||||
if (Chipset.SoftInt && Chipset.Shutdn)
|
||||
{
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
}
|
||||
if (dwEvent & EV_TXEMPTY) // signal transmit buffer empty
|
||||
{
|
||||
IOBit(TCS,TBZ,FALSE); // clear transmitter busy bit
|
||||
CommTransmit(); // check for new char to transmit
|
||||
}
|
||||
if (dwEvent & EV_ERR) // signal error received
|
||||
{
|
||||
DWORD dwError;
|
||||
|
||||
ClearCommError(hComm,&dwError,NULL);
|
||||
if (dwError & (CE_FRAME | CE_OVERRUN | CE_BREAK))
|
||||
IOBit(RCS,RER,TRUE); // receiver error
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
UNREFERENCED_PARAMETER(pParam);
|
||||
}
|
||||
|
||||
BOOL CommIsOpen(VOID)
|
||||
{
|
||||
return hComm != NULL; // have COM port handle
|
||||
}
|
||||
|
||||
BOOL CommOpen(LPTSTR strWirePort,LPTSTR strIrPort)
|
||||
{
|
||||
COMMTIMEOUTS CommTimeouts = { MAXDWORD, 0L, 0L, 0L, 0L };
|
||||
|
||||
LPCTSTR strPort = (Chipset.IORam[IR_CTRL] & EIRU) ? strIrPort : strWirePort;
|
||||
|
||||
CommClose(); // close port if already open
|
||||
|
||||
dwBytesRead = 0L; // no bytes received
|
||||
|
||||
if (lstrcmp(strPort, _T(NO_SERIAL))) // port defined
|
||||
{
|
||||
TCHAR szDevice[256] = _T("\\\\.\\");
|
||||
|
||||
// check if device buffer is big enough
|
||||
_ASSERT(lstrlen(szDevice) + lstrlen(strPort) < (INT) ARRAYSIZEOF(szDevice));
|
||||
if (lstrlen(szDevice) + lstrlen(strPort) >= (INT) ARRAYSIZEOF(szDevice))
|
||||
return hComm != NULL;
|
||||
|
||||
_tcscat(szDevice,strPort); // device name
|
||||
hComm = CreateFile(szDevice,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
|
||||
if (hComm != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwThreadId;
|
||||
|
||||
nRp = 0; // reset receiver state
|
||||
|
||||
SetCommTimeouts(hComm,&CommTimeouts);
|
||||
CommSetBaud();
|
||||
|
||||
CommTxBRK(); // update BRK condition
|
||||
|
||||
// event to transmit character
|
||||
hEventTxd = CreateEvent(NULL,FALSE,FALSE,NULL);
|
||||
|
||||
// create char transmit handler
|
||||
bWriting = TRUE;
|
||||
hCThreadTxd = CreateThread(NULL,0,&TransmitThread,NULL,CREATE_SUSPENDED,&dwThreadId);
|
||||
_ASSERT(hCThreadTxd);
|
||||
SetThreadPriority(hCThreadTxd,THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(hCThreadTxd); // start thread
|
||||
|
||||
// create Comm event handler
|
||||
bReading = FALSE;
|
||||
SetCommMask(hComm,EV_RXCHAR | EV_TXEMPTY | EV_ERR); // event on RX, TX, error
|
||||
hCThreadEv = CreateThread(NULL,0,&EventThread,NULL,CREATE_SUSPENDED,&dwThreadId);
|
||||
_ASSERT(hCThreadEv);
|
||||
SetThreadPriority(hCThreadEv,THREAD_PRIORITY_ABOVE_NORMAL);
|
||||
ResumeThread(hCThreadEv); // start thread
|
||||
while (!bReading) Sleep(0); // wait for SerialThread started
|
||||
}
|
||||
else
|
||||
{
|
||||
hComm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
wsprintf(buffer,_T("COM port %s.\n"),hComm ? _T("opened"): _T("open error"));
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
return hComm != NULL;
|
||||
}
|
||||
|
||||
VOID CommClose(VOID)
|
||||
{
|
||||
if (hComm != NULL) // port open
|
||||
{
|
||||
// workaround to fix problems with some Kermit server programs
|
||||
// reason: on one hand we have the character transmitting time base on the
|
||||
// selected baudrate, on the other hand the time between sending the last
|
||||
// character and closing the port. The last time is much longer on the real
|
||||
// calculator than on the emulator running at full speed, therefore the
|
||||
// slow down time on the emulator
|
||||
Sleep(25); // slow down time
|
||||
|
||||
bReading = FALSE; // kill event thread
|
||||
SetCommMask(hComm,0L); // clear all events and force WaitCommEvent to return
|
||||
WaitForSingleObject(hCThreadEv,INFINITE);
|
||||
CloseHandle(hCThreadEv);
|
||||
|
||||
bWriting = FALSE; // kill write thread
|
||||
SetEvent(hEventTxd); // continue write thread
|
||||
WaitForSingleObject(hCThreadTxd,INFINITE);
|
||||
CloseHandle(hCThreadTxd);
|
||||
|
||||
CloseHandle(hEventTxd); // close Txd event
|
||||
CloseHandle(hComm); // close port
|
||||
hComm = NULL;
|
||||
#if defined DEBUG_SERIAL
|
||||
OutputDebugString(_T("COM port closed.\n"));
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommSetBaud(VOID)
|
||||
{
|
||||
if (hComm != NULL)
|
||||
{
|
||||
const DWORD dwBaudrates[] = { 1200, 1920, 2400, 3840, 4800, 7680, 9600, 15360 };
|
||||
|
||||
DCB dcb;
|
||||
|
||||
ZeroMemory(&dcb,sizeof(dcb));
|
||||
dcb.DCBlength = sizeof(dcb);
|
||||
dcb.BaudRate = dwBaudrates[Chipset.IORam[BAUD] & 0x7];
|
||||
dcb.fBinary = TRUE;
|
||||
dcb.fParity = TRUE;
|
||||
dcb.fOutxCtsFlow = FALSE;
|
||||
dcb.fOutxDsrFlow = FALSE;
|
||||
dcb.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
dcb.fDsrSensitivity = FALSE;
|
||||
dcb.fOutX = FALSE;
|
||||
dcb.fErrorChar = FALSE;
|
||||
dcb.fNull = FALSE;
|
||||
dcb.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
dcb.fAbortOnError = FALSE; // may changed in further implementations
|
||||
dcb.ByteSize = 8;
|
||||
dcb.Parity = NOPARITY; // no parity check, emulated by software
|
||||
dcb.StopBits = TWOSTOPBITS;
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
wsprintf(buffer,_T("CommsetBaud: %ld\n"),dcb.BaudRate);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
SetCommState(hComm,&dcb);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL UpdateUSRQ(VOID) // USRQ handling
|
||||
{
|
||||
BOOL bUSRQ = NINT2USRQ;
|
||||
IOBit(SRQ1,USRQ,bUSRQ); // update USRQ bit
|
||||
return bUSRQ;
|
||||
}
|
||||
|
||||
VOID CommTxBRK(VOID)
|
||||
{
|
||||
if (Chipset.IORam[TCS] & BRK) // BRK condition
|
||||
{
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
// abort data transfer
|
||||
PurgeComm(hComm,PURGE_TXABORT | PURGE_TXCLEAR);
|
||||
SetCommBreak(hComm); // set into BRK state
|
||||
}
|
||||
|
||||
// TBF and TBZ bits of TCS are undefined
|
||||
|
||||
if (Chipset.IORam[TCS] & LPB) // is loopback bit set
|
||||
{
|
||||
dwBytesRead = nRp = 0; // clear receive buffer
|
||||
cBuffer[dwBytesRead++] = 0; // save character in receive buffer
|
||||
|
||||
CommReceive(); // receive available byte
|
||||
IOBit(RCS,RER,TRUE); // receiver error (no stop bit)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
ClearCommBreak(hComm); // clear BRK state
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommTransmit(VOID)
|
||||
{
|
||||
BOOL bTxChar = FALSE;
|
||||
|
||||
EnterCriticalSection(&csTxdLock);
|
||||
if ( (Chipset.IORam[TCS] & TBZ) == 0 // transmitter not busy
|
||||
&& (Chipset.IORam[TCS] & TBF) != 0) // transmit buffer full
|
||||
{
|
||||
tbr = (Chipset.IORam[TBR_MSB] << 4) | Chipset.IORam[TBR_LSB];
|
||||
|
||||
IOBit(TCS,TBF,FALSE); // clear transmit buffer full bit
|
||||
IOBit(TCS,TBZ,TRUE); // set transmitter busy bit
|
||||
|
||||
bTxChar = TRUE;
|
||||
}
|
||||
LeaveCriticalSection(&csTxdLock);
|
||||
|
||||
if (bTxChar) // character to transmit
|
||||
{
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
if (isprint(tbr))
|
||||
wsprintf(buffer,_T("-> '%c'\n"),tbr);
|
||||
else
|
||||
wsprintf(buffer,_T("-> %02X\n"),tbr);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Chipset.IORam[TCS] & LPB) // is loopback bit set
|
||||
{
|
||||
if (dwBytesRead == 0) nRp = 0; // no character received, reset read pointer
|
||||
cBuffer[nRp+dwBytesRead] = tbr; // save character in receive buffer
|
||||
++dwBytesRead;
|
||||
|
||||
CommReceive(); // receive available byte
|
||||
}
|
||||
|
||||
if (hComm != NULL) // com port open
|
||||
{
|
||||
SetEvent(hEventTxd); // write TBR byte
|
||||
}
|
||||
else
|
||||
{
|
||||
IOBit(TCS,TBZ,FALSE); // clear transmitter busy bit
|
||||
}
|
||||
}
|
||||
if (UpdateUSRQ()) // update USRQ bit
|
||||
INTERRUPT;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID CommReceive(VOID)
|
||||
{
|
||||
OVERLAPPED os = { 0 };
|
||||
|
||||
if (!(Chipset.IORam[IOC] & SON)) // UART off
|
||||
{
|
||||
dwBytesRead = 0L; // no bytes received
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&csRecvLock);
|
||||
do
|
||||
{
|
||||
if (Chipset.IORam[RCS] & RBF) // receive buffer full
|
||||
break;
|
||||
|
||||
// reject reading if com port is closed and not whole operation
|
||||
if (hComm) // com port open
|
||||
{
|
||||
UINT uCnt = 0; // retry counter
|
||||
|
||||
while (dwBytesRead == 0L) // buffer empty
|
||||
{
|
||||
if (ReadFile(hComm,cBuffer,sizeof(cBuffer),&dwBytesRead,&os) == FALSE)
|
||||
dwBytesRead = 0L;
|
||||
else // bytes received
|
||||
nRp = 0; // reset read pointer
|
||||
|
||||
// something received or passed 1st retry
|
||||
if (dwBytesRead != 0L || ++uCnt > 1)
|
||||
break; // quit
|
||||
|
||||
Sleep(1); // workaround, retry 1ms later
|
||||
}
|
||||
}
|
||||
|
||||
if (dwBytesRead == 0L) // receive buffer empty
|
||||
break;
|
||||
|
||||
#if defined DEBUG_SERIAL
|
||||
{
|
||||
TCHAR buffer[256];
|
||||
if (isprint(cBuffer[nRp]))
|
||||
wsprintf(buffer,_T("<- '%c'\n"),cBuffer[nRp]);
|
||||
else
|
||||
wsprintf(buffer,_T("<- %02X\n"),cBuffer[nRp]);
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
Chipset.IORam[RBR_MSB] = (cBuffer[nRp] >> 4);
|
||||
Chipset.IORam[RBR_LSB] = (cBuffer[nRp] & 0x0f);
|
||||
++nRp;
|
||||
--dwBytesRead;
|
||||
|
||||
Chipset.IORam[RCS] |= RBF; // receive buffer full
|
||||
if (UpdateUSRQ()) // update USRQ bit
|
||||
INTERRUPT;
|
||||
}
|
||||
while (FALSE);
|
||||
LeaveCriticalSection(&csRecvLock);
|
||||
return;
|
||||
}
|
|
@ -1,308 +1,310 @@
|
|||
/*
|
||||
* settings.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2000 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "i28f160.h"
|
||||
|
||||
// #define REGISTRY // use registry instead of *.ini file
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Low level subroutines
|
||||
//#
|
||||
//################
|
||||
|
||||
#if !defined REGISTRY
|
||||
|
||||
// INI-file handling
|
||||
|
||||
#if !defined EMU48_INI
|
||||
#define EMU48_INI "Emu48.ini"
|
||||
#endif
|
||||
|
||||
#define ReadString(sec,key,dv,v,sv) GetPrivateProfileString(sec,key,dv,v,sv,_T(EMU48_INI))
|
||||
#define ReadInt(sec,key,dv) GetPrivateProfileInt(sec,key,dv,_T(EMU48_INI));
|
||||
#define WriteString(sec,key,v) WritePrivateProfileString(sec,key,v,_T(EMU48_INI))
|
||||
#define WriteInt(sec,key,v) WritePrivateProfileInt(sec,key,v,_T(EMU48_INI))
|
||||
#define DelKey(sec,key) WritePrivateProfileString(sec,key,NULL,_T(EMU48_INI))
|
||||
|
||||
static BOOL WritePrivateProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue, LPCTSTR lpszFilename)
|
||||
{
|
||||
TCHAR s[16];
|
||||
wsprintf(s,_T("%i"),nValue);
|
||||
return WritePrivateProfileString(lpszSection, lpszEntry, s, lpszFilename);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// registry handling
|
||||
|
||||
#if !defined REGISTRYKEY
|
||||
#define REGISTRYKEY "Software\\Emu48"
|
||||
#endif
|
||||
|
||||
#define ReadString(sec,key,dv,v,sv) GetRegistryString(sec,key,dv,v,sv)
|
||||
#define ReadInt(sec,key,dv) GetRegistryInt(sec,key,dv)
|
||||
#define WriteString(sec,key,v) WriteReg(sec,key,REG_SZ,(BYTE *) v,(lstrlen(v)+1) * sizeof(*v))
|
||||
#define WriteInt(sec,key,v) WriteReg(sec,key,REG_DWORD,(BYTE *) &v,sizeof(int))
|
||||
#define DelKey(sec,key) DelReg(sec,key)
|
||||
|
||||
static VOID ReadReg(LPCTSTR lpSubKey, LPCTSTR lpValueName, LPBYTE lpData, DWORD *pdwSize)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode,dwType;
|
||||
HKEY hKey;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey);
|
||||
if (retCode == ERROR_SUCCESS)
|
||||
{
|
||||
retCode = RegQueryValueEx(hKey,lpValueName,NULL,&dwType,lpData,pdwSize);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
if (retCode != ERROR_SUCCESS) // registry entry not found
|
||||
*pdwSize = 0; // return zero size
|
||||
return;
|
||||
}
|
||||
|
||||
static BOOL WriteReg(LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode;
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,_T(""),
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
_ASSERT(retCode == ERROR_SUCCESS);
|
||||
|
||||
RegSetValueEx(hKey,lpValueName,0,dwType,lpData,cbData);
|
||||
RegCloseKey(hKey);
|
||||
return retCode == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL DelReg(LPCTSTR lpSubKey, LPCTSTR lpValueName)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode;
|
||||
HKEY hKey;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,
|
||||
KEY_SET_VALUE,
|
||||
&hKey);
|
||||
if (retCode == ERROR_SUCCESS)
|
||||
{
|
||||
retCode = RegDeleteValue(hKey,lpValueName);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
return retCode == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static DWORD GetRegistryString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize)
|
||||
{
|
||||
// buffer size in bytes
|
||||
DWORD dwBufSize = dwSize * sizeof(*lpData);
|
||||
|
||||
ReadReg(lpszSection,lpszEntry,(LPBYTE) lpData,&dwBufSize);
|
||||
if (dwBufSize == 0)
|
||||
{
|
||||
lstrcpyn(lpData,lpDefault,dwSize);
|
||||
dwSize = lstrlen(lpData);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwSize = (dwBufSize / sizeof(*lpData)) - 1;
|
||||
}
|
||||
return dwSize;
|
||||
}
|
||||
|
||||
static UINT GetRegistryInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault)
|
||||
{
|
||||
UINT nValue;
|
||||
DWORD dwSize = sizeof(nValue);
|
||||
|
||||
ReadReg(lpszSection,lpszEntry,(LPBYTE) &nValue,&dwSize);
|
||||
return dwSize ? nValue : nDefault;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Public functions
|
||||
//#
|
||||
//################
|
||||
|
||||
VOID ReadSettings(VOID)
|
||||
{
|
||||
// Files
|
||||
ReadString(_T("Files"),_T("Emu48Directory"),szCurrentDirectory,szEmuDirectory,ARRAYSIZEOF(szEmuDirectory));
|
||||
bAutoSave = ReadInt(_T("Files"),_T("AutoSave"),bAutoSave);
|
||||
bAutoSaveOnExit = ReadInt(_T("Files"),_T("AutoSaveOnExit"),bAutoSaveOnExit);
|
||||
bSaveDefConfirm = ReadInt(_T("Files"),_T("SaveDefaultConfirm"),bSaveDefConfirm);
|
||||
bStartupBackup = ReadInt(_T("Files"),_T("StartupBackup"),bStartupBackup);
|
||||
bLoadObjectWarning = ReadInt(_T("Files"),_T("LoadObjectWarning"),bLoadObjectWarning);
|
||||
// Port2
|
||||
bPort2IsShared = ReadInt(_T("Port2"),_T("IsShared"),bPort2IsShared);
|
||||
ReadString(_T("Port2"),_T("Filename"),_T("SHARED.BIN"),szPort2Filename,ARRAYSIZEOF(szPort2Filename));
|
||||
// KML
|
||||
bAlwaysDisplayLog = ReadInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog);
|
||||
// Debugger
|
||||
wInstrSize = ReadInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize);
|
||||
// Disassembler
|
||||
disassembler_mode = ReadInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode);
|
||||
disassembler_symb = ReadInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb);
|
||||
// Emulator
|
||||
bShowTitle = ReadInt(_T("Emulator"),_T("ShowTitle"),bShowTitle);
|
||||
bShowMenu = ReadInt(_T("Emulator"),_T("ShowMenu"),bShowMenu);
|
||||
bAlwaysOnTop = ReadInt(_T("Emulator"),_T("AlwaysOnTop"),bAlwaysOnTop);
|
||||
bActFollowsMouse = ReadInt(_T("Emulator"),_T("ActivationFollowsMouse"),bActFollowsMouse);
|
||||
bClientWinMove = ReadInt(_T("Emulator"),_T("ClientWinMove"),bClientWinMove);
|
||||
bSingleInstance = ReadInt(_T("Emulator"),_T("SingleInstance"),bSingleInstance);
|
||||
bRealSpeed = ReadInt(_T("Emulator"),_T("RealSpeed"),bRealSpeed);
|
||||
dwSXCycles = ReadInt(_T("Emulator"),_T("SXCycles"),dwSXCycles);
|
||||
dwGXCycles = ReadInt(_T("Emulator"),_T("GXCycles"),dwGXCycles);
|
||||
dwKeyMinDelay = ReadInt(_T("Emulator"),_T("KeyMinDelay"),dwKeyMinDelay);
|
||||
dwWakeupDelay = ReadInt(_T("Emulator"),_T("WakeupDelay"),dwWakeupDelay);
|
||||
bGrayscale = ReadInt(_T("Emulator"),_T("Grayscale"),bGrayscale);
|
||||
uWaveDevId = ReadInt(_T("Emulator"),_T("WaveDeviceId"),uWaveDevId);
|
||||
dwWaveVol = ReadInt(_T("Emulator"),_T("WaveVolume"),dwWaveVol);
|
||||
dwWaveTime = ReadInt(_T("Emulator"),_T("WaveTime"),dwWaveTime);
|
||||
// LowBat
|
||||
bLowBatDisable = ReadInt(_T("LowBat"),_T("Disable"),bLowBatDisable);
|
||||
// Macro
|
||||
bMacroRealSpeed = ReadInt(_T("Macro"),_T("RealSpeed"),bMacroRealSpeed);
|
||||
nMacroTimeout = ReadInt(_T("Macro"),_T("ReplayTimeout"),nMacroTimeout);
|
||||
dwMacroMinDelay = ReadInt(_T("Macro"),_T("KeyMinDelay"),dwMacroMinDelay);
|
||||
// IrPrinter
|
||||
ReadString(_T("IrPrinter"),_T("Address"),szUdpServer,szUdpServer,ARRAYSIZEOF(szUdpServer));
|
||||
wUdpPort = ReadInt(_T("IrPrinter"),_T("Port"),wUdpPort);
|
||||
// Serial
|
||||
ReadString(_T("Serial"),_T("Wire"),_T(NO_SERIAL),szSerialWire,ARRAYSIZEOF(szSerialWire));
|
||||
ReadString(_T("Serial"),_T("Ir"),_T(NO_SERIAL),szSerialIr,ARRAYSIZEOF(szSerialIr));
|
||||
// ROM
|
||||
bRomWriteable = ReadInt(_T("ROM"),_T("Writeable"),bRomWriteable);
|
||||
bWP = ReadInt(_T("ROM"),_T("WP#"),bWP);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteSettings(VOID)
|
||||
{
|
||||
// Files
|
||||
WriteString(_T("Files"),_T("Emu48Directory"),szEmuDirectory);
|
||||
WriteInt(_T("Files"),_T("AutoSave"),bAutoSave);
|
||||
WriteInt(_T("Files"),_T("AutoSaveOnExit"),bAutoSaveOnExit);
|
||||
WriteInt(_T("Files"),_T("SaveDefaultConfirm"),bSaveDefConfirm);
|
||||
WriteInt(_T("Files"),_T("StartupBackup"),bStartupBackup);
|
||||
WriteInt(_T("Files"),_T("LoadObjectWarning"),bLoadObjectWarning);
|
||||
// Port2
|
||||
WriteInt(_T("Port2"),_T("IsShared"),bPort2IsShared);
|
||||
WriteString(_T("Port2"),_T("Filename"),szPort2Filename);
|
||||
// KML
|
||||
WriteInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog);
|
||||
// Debugger
|
||||
WriteInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize);
|
||||
// Disassembler
|
||||
WriteInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode);
|
||||
WriteInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb);
|
||||
// Emulator
|
||||
WriteInt(_T("Emulator"),_T("ShowTitle"),bShowTitle);
|
||||
WriteInt(_T("Emulator"),_T("ShowMenu"),bShowMenu);
|
||||
WriteInt(_T("Emulator"),_T("AlwaysOnTop"),bAlwaysOnTop);
|
||||
WriteInt(_T("Emulator"),_T("ActivationFollowsMouse"),bActFollowsMouse);
|
||||
WriteInt(_T("Emulator"),_T("ClientWinMove"),bClientWinMove);
|
||||
WriteInt(_T("Emulator"),_T("SingleInstance"),bSingleInstance);
|
||||
WriteInt(_T("Emulator"),_T("RealSpeed"),bRealSpeed);
|
||||
WriteInt(_T("Emulator"),_T("SXCycles"),dwSXCycles);
|
||||
WriteInt(_T("Emulator"),_T("GXCycles"),dwGXCycles);
|
||||
WriteInt(_T("Emulator"),_T("KeyMinDelay"),dwKeyMinDelay);
|
||||
WriteInt(_T("Emulator"),_T("WakeupDelay"),dwWakeupDelay);
|
||||
WriteInt(_T("Emulator"),_T("Grayscale"),bGrayscale);
|
||||
WriteInt(_T("Emulator"),_T("WaveDeviceId"),uWaveDevId);
|
||||
WriteInt(_T("Emulator"),_T("WaveVolume"),dwWaveVol);
|
||||
WriteInt(_T("Emulator"),_T("WaveTime"),dwWaveTime);
|
||||
// LowBat
|
||||
WriteInt(_T("LowBat"),_T("Disable"),bLowBatDisable);
|
||||
// Macro
|
||||
WriteInt(_T("Macro"),_T("RealSpeed"),bMacroRealSpeed);
|
||||
WriteInt(_T("Macro"),_T("ReplayTimeout"),nMacroTimeout);
|
||||
WriteInt(_T("Macro"),_T("KeyMinDelay"),dwMacroMinDelay);
|
||||
// IrPrinter
|
||||
WriteString(_T("IrPrinter"),_T("Address"),szUdpServer);
|
||||
WriteInt(_T("IrPrinter"),_T("Port"),wUdpPort);
|
||||
// Serial
|
||||
WriteString(_T("Serial"),_T("Wire"),szSerialWire);
|
||||
WriteString(_T("Serial"),_T("Ir"),szSerialIr);
|
||||
// ROM
|
||||
WriteInt(_T("ROM"),_T("Writeable"),bRomWriteable);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID ReadLastDocument(LPTSTR szFilename, DWORD nSize)
|
||||
{
|
||||
ReadString(_T("Files"),_T("LastDocument"),_T(""),szFilename,nSize);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteLastDocument(LPCTSTR szFilename)
|
||||
{
|
||||
WriteString(_T("Files"),_T("LastDocument"),szFilename);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID ReadSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize)
|
||||
{
|
||||
ReadString(lpszSection,lpszEntry,lpDefault,lpData,dwSize);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPTSTR lpData)
|
||||
{
|
||||
WriteString(lpszSection,lpszEntry,lpData);
|
||||
return;
|
||||
}
|
||||
|
||||
INT ReadSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault)
|
||||
{
|
||||
return ReadInt(lpszSection,lpszEntry,nDefault);
|
||||
}
|
||||
|
||||
VOID WriteSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nValue)
|
||||
{
|
||||
WriteInt(lpszSection,lpszEntry,nValue);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID DelSettingsKey(LPCTSTR lpszSection, LPCTSTR lpszEntry)
|
||||
{
|
||||
DelKey(lpszSection,lpszEntry);
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* settings.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2000 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "i28f160.h"
|
||||
|
||||
// #define REGISTRY // use registry instead of *.ini file
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Low level subroutines
|
||||
//#
|
||||
//################
|
||||
|
||||
#if !defined REGISTRY
|
||||
|
||||
// INI-file handling
|
||||
|
||||
#if !defined EMU48_INI
|
||||
#define EMU48_INI "Emu48.ini"
|
||||
#endif
|
||||
|
||||
#define ReadString(sec,key,dv,v,sv) GetPrivateProfileString(sec,key,dv,v,sv,_T(EMU48_INI))
|
||||
#define ReadInt(sec,key,dv) GetPrivateProfileInt(sec,key,dv,_T(EMU48_INI));
|
||||
#define WriteString(sec,key,v) WritePrivateProfileString(sec,key,v,_T(EMU48_INI))
|
||||
#define WriteInt(sec,key,v) WritePrivateProfileInt(sec,key,v,_T(EMU48_INI))
|
||||
#define DelKey(sec,key) WritePrivateProfileString(sec,key,NULL,_T(EMU48_INI))
|
||||
|
||||
static BOOL WritePrivateProfileInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, int nValue, LPCTSTR lpszFilename)
|
||||
{
|
||||
TCHAR s[16];
|
||||
wsprintf(s,_T("%i"),nValue);
|
||||
return WritePrivateProfileString(lpszSection, lpszEntry, s, lpszFilename);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// registry handling
|
||||
|
||||
#if !defined REGISTRYKEY
|
||||
#define REGISTRYKEY "Software\\Emu48"
|
||||
#endif
|
||||
|
||||
#define ReadString(sec,key,dv,v,sv) GetRegistryString(sec,key,dv,v,sv)
|
||||
#define ReadInt(sec,key,dv) GetRegistryInt(sec,key,dv)
|
||||
#define WriteString(sec,key,v) WriteReg(sec,key,REG_SZ,(BYTE *) v,(lstrlen(v)+1) * sizeof(*v))
|
||||
#define WriteInt(sec,key,v) WriteReg(sec,key,REG_DWORD,(BYTE *) &v,sizeof(int))
|
||||
#define DelKey(sec,key) DelReg(sec,key)
|
||||
|
||||
static VOID ReadReg(LPCTSTR lpSubKey, LPCTSTR lpValueName, LPBYTE lpData, DWORD *pdwSize)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode,dwType;
|
||||
HKEY hKey;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey);
|
||||
if (retCode == ERROR_SUCCESS)
|
||||
{
|
||||
retCode = RegQueryValueEx(hKey,lpValueName,NULL,&dwType,lpData,pdwSize);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
if (retCode != ERROR_SUCCESS) // registry entry not found
|
||||
*pdwSize = 0; // return zero size
|
||||
return;
|
||||
}
|
||||
|
||||
static BOOL WriteReg(LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode;
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,_T(""),
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisposition);
|
||||
_ASSERT(retCode == ERROR_SUCCESS);
|
||||
|
||||
RegSetValueEx(hKey,lpValueName,0,dwType,lpData,cbData);
|
||||
RegCloseKey(hKey);
|
||||
return retCode == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL DelReg(LPCTSTR lpSubKey, LPCTSTR lpValueName)
|
||||
{
|
||||
TCHAR lpKey[256] = _T(REGISTRYKEY) _T("\\");
|
||||
|
||||
DWORD retCode;
|
||||
HKEY hKey;
|
||||
|
||||
lstrcat(lpKey, lpSubKey); // full registry key
|
||||
|
||||
retCode = RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
lpKey,
|
||||
0,
|
||||
KEY_SET_VALUE,
|
||||
&hKey);
|
||||
if (retCode == ERROR_SUCCESS)
|
||||
{
|
||||
retCode = RegDeleteValue(hKey,lpValueName);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
return retCode == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static DWORD GetRegistryString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize)
|
||||
{
|
||||
// buffer size in bytes
|
||||
DWORD dwBufSize = dwSize * sizeof(*lpData);
|
||||
|
||||
ReadReg(lpszSection,lpszEntry,(LPBYTE) lpData,&dwBufSize);
|
||||
if (dwBufSize == 0)
|
||||
{
|
||||
lstrcpyn(lpData,lpDefault,dwSize);
|
||||
dwSize = lstrlen(lpData);
|
||||
}
|
||||
else
|
||||
{
|
||||
dwSize = (dwBufSize / sizeof(*lpData)) - 1;
|
||||
}
|
||||
return dwSize;
|
||||
}
|
||||
|
||||
static UINT GetRegistryInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault)
|
||||
{
|
||||
UINT nValue;
|
||||
DWORD dwSize = sizeof(nValue);
|
||||
|
||||
ReadReg(lpszSection,lpszEntry,(LPBYTE) &nValue,&dwSize);
|
||||
return dwSize ? nValue : nDefault;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Public functions
|
||||
//#
|
||||
//################
|
||||
|
||||
VOID ReadSettings(VOID)
|
||||
{
|
||||
// Files
|
||||
ReadString(_T("Files"),_T("Emu48Directory"),szCurrentDirectory,szEmuDirectory,ARRAYSIZEOF(szEmuDirectory));
|
||||
bAutoSave = ReadInt(_T("Files"),_T("AutoSave"),bAutoSave);
|
||||
bAutoSaveOnExit = ReadInt(_T("Files"),_T("AutoSaveOnExit"),bAutoSaveOnExit);
|
||||
bSaveDefConfirm = ReadInt(_T("Files"),_T("SaveDefaultConfirm"),bSaveDefConfirm);
|
||||
bStartupBackup = ReadInt(_T("Files"),_T("StartupBackup"),bStartupBackup);
|
||||
bLoadObjectWarning = ReadInt(_T("Files"),_T("LoadObjectWarning"),bLoadObjectWarning);
|
||||
// Port2
|
||||
bPort2IsShared = ReadInt(_T("Port2"),_T("IsShared"),bPort2IsShared);
|
||||
ReadString(_T("Port2"),_T("Filename"),_T("SHARED.BIN"),szPort2Filename,ARRAYSIZEOF(szPort2Filename));
|
||||
// KML
|
||||
bAlwaysDisplayLog = ReadInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog);
|
||||
// Debugger
|
||||
wInstrSize = ReadInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize);
|
||||
// Disassembler
|
||||
disassembler_mode = ReadInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode);
|
||||
disassembler_symb = ReadInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb);
|
||||
// Emulator
|
||||
bShowTitle = ReadInt(_T("Emulator"),_T("ShowTitle"),bShowTitle);
|
||||
bShowMenu = ReadInt(_T("Emulator"),_T("ShowMenu"),bShowMenu);
|
||||
bAlwaysOnTop = ReadInt(_T("Emulator"),_T("AlwaysOnTop"),bAlwaysOnTop);
|
||||
bActFollowsMouse = ReadInt(_T("Emulator"),_T("ActivationFollowsMouse"),bActFollowsMouse);
|
||||
bClientWinMove = ReadInt(_T("Emulator"),_T("ClientWinMove"),bClientWinMove);
|
||||
bSingleInstance = ReadInt(_T("Emulator"),_T("SingleInstance"),bSingleInstance);
|
||||
bRealSpeed = ReadInt(_T("Emulator"),_T("RealSpeed"),bRealSpeed);
|
||||
dwSXCycles = ReadInt(_T("Emulator"),_T("SXCycles"),dwSXCycles);
|
||||
dwGXCycles = ReadInt(_T("Emulator"),_T("GXCycles"),dwGXCycles);
|
||||
dwKeyMinDelay = ReadInt(_T("Emulator"),_T("KeyMinDelay"),dwKeyMinDelay);
|
||||
dwWakeupDelay = ReadInt(_T("Emulator"),_T("WakeupDelay"),dwWakeupDelay);
|
||||
bGrayscale = ReadInt(_T("Emulator"),_T("Grayscale"),bGrayscale);
|
||||
uWaveDevId = ReadInt(_T("Emulator"),_T("WaveDeviceId"),uWaveDevId);
|
||||
dwWaveVol = ReadInt(_T("Emulator"),_T("WaveVolume"),dwWaveVol);
|
||||
dwWaveTime = ReadInt(_T("Emulator"),_T("WaveTime"),dwWaveTime);
|
||||
bLocaleDecimalPoint = ReadInt(_T("Emulator"),_T("LocaleDecimalPoint"),bLocaleDecimalPoint);
|
||||
// LowBat
|
||||
bLowBatDisable = ReadInt(_T("LowBat"),_T("Disable"),bLowBatDisable);
|
||||
// Macro
|
||||
bMacroRealSpeed = ReadInt(_T("Macro"),_T("RealSpeed"),bMacroRealSpeed);
|
||||
nMacroTimeout = ReadInt(_T("Macro"),_T("ReplayTimeout"),nMacroTimeout);
|
||||
dwMacroMinDelay = ReadInt(_T("Macro"),_T("KeyMinDelay"),dwMacroMinDelay);
|
||||
// IrPrinter
|
||||
ReadString(_T("IrPrinter"),_T("Address"),szUdpServer,szUdpServer,ARRAYSIZEOF(szUdpServer));
|
||||
wUdpPort = ReadInt(_T("IrPrinter"),_T("Port"),wUdpPort);
|
||||
// Serial
|
||||
ReadString(_T("Serial"),_T("Wire"),_T(NO_SERIAL),szSerialWire,ARRAYSIZEOF(szSerialWire));
|
||||
ReadString(_T("Serial"),_T("Ir"),_T(NO_SERIAL),szSerialIr,ARRAYSIZEOF(szSerialIr));
|
||||
// ROM
|
||||
bRomWriteable = ReadInt(_T("ROM"),_T("Writeable"),bRomWriteable);
|
||||
bWP = ReadInt(_T("ROM"),_T("WP#"),bWP);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteSettings(VOID)
|
||||
{
|
||||
// Files
|
||||
WriteString(_T("Files"),_T("Emu48Directory"),szEmuDirectory);
|
||||
WriteInt(_T("Files"),_T("AutoSave"),bAutoSave);
|
||||
WriteInt(_T("Files"),_T("AutoSaveOnExit"),bAutoSaveOnExit);
|
||||
WriteInt(_T("Files"),_T("SaveDefaultConfirm"),bSaveDefConfirm);
|
||||
WriteInt(_T("Files"),_T("StartupBackup"),bStartupBackup);
|
||||
WriteInt(_T("Files"),_T("LoadObjectWarning"),bLoadObjectWarning);
|
||||
// Port2
|
||||
WriteInt(_T("Port2"),_T("IsShared"),bPort2IsShared);
|
||||
WriteString(_T("Port2"),_T("Filename"),szPort2Filename);
|
||||
// KML
|
||||
WriteInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog);
|
||||
// Debugger
|
||||
WriteInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize);
|
||||
// Disassembler
|
||||
WriteInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode);
|
||||
WriteInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb);
|
||||
// Emulator
|
||||
WriteInt(_T("Emulator"),_T("ShowTitle"),bShowTitle);
|
||||
WriteInt(_T("Emulator"),_T("ShowMenu"),bShowMenu);
|
||||
WriteInt(_T("Emulator"),_T("AlwaysOnTop"),bAlwaysOnTop);
|
||||
WriteInt(_T("Emulator"),_T("ActivationFollowsMouse"),bActFollowsMouse);
|
||||
WriteInt(_T("Emulator"),_T("ClientWinMove"),bClientWinMove);
|
||||
WriteInt(_T("Emulator"),_T("SingleInstance"),bSingleInstance);
|
||||
WriteInt(_T("Emulator"),_T("RealSpeed"),bRealSpeed);
|
||||
WriteInt(_T("Emulator"),_T("SXCycles"),dwSXCycles);
|
||||
WriteInt(_T("Emulator"),_T("GXCycles"),dwGXCycles);
|
||||
WriteInt(_T("Emulator"),_T("KeyMinDelay"),dwKeyMinDelay);
|
||||
WriteInt(_T("Emulator"),_T("WakeupDelay"),dwWakeupDelay);
|
||||
WriteInt(_T("Emulator"),_T("Grayscale"),bGrayscale);
|
||||
WriteInt(_T("Emulator"),_T("WaveDeviceId"),uWaveDevId);
|
||||
WriteInt(_T("Emulator"),_T("WaveVolume"),dwWaveVol);
|
||||
WriteInt(_T("Emulator"),_T("WaveTime"),dwWaveTime);
|
||||
WriteInt(_T("Emulator"),_T("LocaleDecimalPoint"),bLocaleDecimalPoint);
|
||||
// LowBat
|
||||
WriteInt(_T("LowBat"),_T("Disable"),bLowBatDisable);
|
||||
// Macro
|
||||
WriteInt(_T("Macro"),_T("RealSpeed"),bMacroRealSpeed);
|
||||
WriteInt(_T("Macro"),_T("ReplayTimeout"),nMacroTimeout);
|
||||
WriteInt(_T("Macro"),_T("KeyMinDelay"),dwMacroMinDelay);
|
||||
// IrPrinter
|
||||
WriteString(_T("IrPrinter"),_T("Address"),szUdpServer);
|
||||
WriteInt(_T("IrPrinter"),_T("Port"),wUdpPort);
|
||||
// Serial
|
||||
WriteString(_T("Serial"),_T("Wire"),szSerialWire);
|
||||
WriteString(_T("Serial"),_T("Ir"),szSerialIr);
|
||||
// ROM
|
||||
WriteInt(_T("ROM"),_T("Writeable"),bRomWriteable);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID ReadLastDocument(LPTSTR szFilename, DWORD nSize)
|
||||
{
|
||||
ReadString(_T("Files"),_T("LastDocument"),_T(""),szFilename,nSize);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteLastDocument(LPCTSTR szFilename)
|
||||
{
|
||||
WriteString(_T("Files"),_T("LastDocument"),szFilename);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID ReadSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpDefault, LPTSTR lpData, DWORD dwSize)
|
||||
{
|
||||
ReadString(lpszSection,lpszEntry,lpDefault,lpData,dwSize);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID WriteSettingsString(LPCTSTR lpszSection, LPCTSTR lpszEntry, LPTSTR lpData)
|
||||
{
|
||||
WriteString(lpszSection,lpszEntry,lpData);
|
||||
return;
|
||||
}
|
||||
|
||||
INT ReadSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nDefault)
|
||||
{
|
||||
return ReadInt(lpszSection,lpszEntry,nDefault);
|
||||
}
|
||||
|
||||
VOID WriteSettingsInt(LPCTSTR lpszSection, LPCTSTR lpszEntry, INT nValue)
|
||||
{
|
||||
WriteInt(lpszSection,lpszEntry,nValue);
|
||||
return;
|
||||
}
|
||||
|
||||
VOID DelSettingsKey(LPCTSTR lpszSection, LPCTSTR lpszEntry)
|
||||
{
|
||||
DelKey(lpszSection,lpszEntry);
|
||||
return;
|
||||
}
|
|
@ -1,102 +1,102 @@
|
|||
/*
|
||||
* snddef.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2015 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
#if _MSC_VER >= 1600 // valid for VS2010 and later
|
||||
|
||||
#include <DSound.h>
|
||||
#include <Dsconf.h>
|
||||
|
||||
#else // create the necessary definitions manually
|
||||
|
||||
//
|
||||
// IKsPropertySet
|
||||
//
|
||||
|
||||
#ifndef _IKsPropertySet_
|
||||
#define _IKsPropertySet_
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct IKsPropertySet;
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct IKsPropertySet *LPKSPROPERTYSET;
|
||||
|
||||
DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93);
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IKsPropertySet
|
||||
|
||||
DECLARE_INTERFACE_(IKsPropertySet, IUnknown)
|
||||
{
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE;
|
||||
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release) (THIS) PURE;
|
||||
|
||||
// IKsPropertySet methods
|
||||
STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
|
||||
LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE;
|
||||
STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
|
||||
LPVOID pPropertyData, ULONG ulDataLength) PURE;
|
||||
STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE;
|
||||
};
|
||||
|
||||
#endif // _IKsPropertySet_
|
||||
|
||||
// DirectSound Configuration Component GUID {11AB3EC0-25EC-11d1-A4D8-00C04FC28ACA}
|
||||
DEFINE_GUID(CLSID_DirectSoundPrivate, 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
|
||||
|
||||
// DirectSound Device Properties {84624F82-25EC-11d1-A4D8-00C04FC28ACA}
|
||||
DEFINE_GUID(DSPROPSETID_DirectSoundDevice, 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A = 1,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 = 2,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 = 3,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W = 4,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A = 5,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W = 6,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A = 7,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W = 8,
|
||||
} DSPROPERTY_DIRECTSOUNDDEVICE;
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
|
||||
#else // UNICODE
|
||||
#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
|
||||
#endif // UNICODE
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIRECTSOUNDDEVICE_TYPE_EMULATED,
|
||||
DIRECTSOUNDDEVICE_TYPE_VXD,
|
||||
DIRECTSOUNDDEVICE_TYPE_WDM
|
||||
} DIRECTSOUNDDEVICE_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIRECTSOUNDDEVICE_DATAFLOW_RENDER,
|
||||
DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
|
||||
} DIRECTSOUNDDEVICE_DATAFLOW;
|
||||
|
||||
typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA
|
||||
{
|
||||
DIRECTSOUNDDEVICE_TYPE Type; // Device type
|
||||
DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow
|
||||
GUID DeviceId; // DirectSound device id
|
||||
LPTSTR Description; // Device description
|
||||
LPTSTR Module; // Device driver module
|
||||
LPTSTR Interface; // Device interface
|
||||
ULONG WaveDeviceId; // Wave device id
|
||||
} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA;
|
||||
|
||||
#endif
|
||||
/*
|
||||
* snddef.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2015 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
#if _MSC_VER >= 1600 // valid for VS2010 and later
|
||||
|
||||
#include <DSound.h>
|
||||
#include <Dsconf.h>
|
||||
|
||||
#else // create the necessary definitions manually
|
||||
|
||||
//
|
||||
// IKsPropertySet
|
||||
//
|
||||
|
||||
#ifndef _IKsPropertySet_
|
||||
#define _IKsPropertySet_
|
||||
|
||||
#ifdef __cplusplus
|
||||
struct IKsPropertySet;
|
||||
#endif // __cplusplus
|
||||
|
||||
typedef struct IKsPropertySet *LPKSPROPERTYSET;
|
||||
|
||||
DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93);
|
||||
|
||||
#undef INTERFACE
|
||||
#define INTERFACE IKsPropertySet
|
||||
|
||||
DECLARE_INTERFACE_(IKsPropertySet, IUnknown)
|
||||
{
|
||||
// IUnknown methods
|
||||
STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID*) PURE;
|
||||
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
|
||||
STDMETHOD_(ULONG,Release) (THIS) PURE;
|
||||
|
||||
// IKsPropertySet methods
|
||||
STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
|
||||
LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE;
|
||||
STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength,
|
||||
LPVOID pPropertyData, ULONG ulDataLength) PURE;
|
||||
STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE;
|
||||
};
|
||||
|
||||
#endif // _IKsPropertySet_
|
||||
|
||||
// DirectSound Configuration Component GUID {11AB3EC0-25EC-11d1-A4D8-00C04FC28ACA}
|
||||
DEFINE_GUID(CLSID_DirectSoundPrivate, 0x11ab3ec0, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
|
||||
|
||||
// DirectSound Device Properties {84624F82-25EC-11d1-A4D8-00C04FC28ACA}
|
||||
DEFINE_GUID(DSPROPSETID_DirectSoundDevice, 0x84624f82, 0x25ec, 0x11d1, 0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_A = 1,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_1 = 2,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_1 = 3,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_WAVEDEVICEMAPPING_W = 4,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A = 5,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W = 6,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_A = 7,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_ENUMERATE_W = 8,
|
||||
} DSPROPERTY_DIRECTSOUNDDEVICE;
|
||||
|
||||
#ifdef UNICODE
|
||||
#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_W
|
||||
#else // UNICODE
|
||||
#define DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_A
|
||||
#endif // UNICODE
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIRECTSOUNDDEVICE_TYPE_EMULATED,
|
||||
DIRECTSOUNDDEVICE_TYPE_VXD,
|
||||
DIRECTSOUNDDEVICE_TYPE_WDM
|
||||
} DIRECTSOUNDDEVICE_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIRECTSOUNDDEVICE_DATAFLOW_RENDER,
|
||||
DIRECTSOUNDDEVICE_DATAFLOW_CAPTURE
|
||||
} DIRECTSOUNDDEVICE_DATAFLOW;
|
||||
|
||||
typedef struct _DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA
|
||||
{
|
||||
DIRECTSOUNDDEVICE_TYPE Type; // Device type
|
||||
DIRECTSOUNDDEVICE_DATAFLOW DataFlow; // Device dataflow
|
||||
GUID DeviceId; // DirectSound device id
|
||||
LPTSTR Description; // Device description
|
||||
LPTSTR Module; // Device driver module
|
||||
LPTSTR Interface; // Device interface
|
||||
ULONG WaveDeviceId; // Wave device id
|
||||
} DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA, *PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA;
|
||||
|
||||
#endif
|
|
@ -1,256 +1,256 @@
|
|||
/*
|
||||
* SndEnum.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2015 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "snddef.h"
|
||||
|
||||
typedef HRESULT (WINAPI *LPFNDLLGETCLASSOBJECT)(REFCLSID,REFIID,LPVOID *);
|
||||
static LPFNDLLGETCLASSOBJECT pfnDllGetClassObject = NULL;
|
||||
|
||||
//
|
||||
// create a IKsPropertySet interface
|
||||
//
|
||||
static __inline HRESULT DirectSoundPrivateCreate(LPKSPROPERTYSET *ppKsPropertySet)
|
||||
{
|
||||
LPCLASSFACTORY pClassFactory = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
// create a class factory object
|
||||
#if defined __cplusplus
|
||||
hr = pfnDllGetClassObject(CLSID_DirectSoundPrivate,IID_IClassFactory,(LPVOID *) &pClassFactory);
|
||||
#else
|
||||
hr = pfnDllGetClassObject(&CLSID_DirectSoundPrivate,&IID_IClassFactory,(LPVOID *) &pClassFactory);
|
||||
#endif
|
||||
|
||||
// create the DirectSoundPrivate object and query for an IKsPropertySet interface
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
#if defined __cplusplus
|
||||
hr = pClassFactory->CreateInstance(NULL,IID_IKsPropertySet,(LPVOID *) ppKsPropertySet);
|
||||
#else
|
||||
hr = pClassFactory->lpVtbl->CreateInstance(pClassFactory,NULL,&IID_IKsPropertySet,(LPVOID *) ppKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pClassFactory) // release the class factory object
|
||||
{
|
||||
#if defined __cplusplus
|
||||
pClassFactory->Release();
|
||||
#else
|
||||
pClassFactory->lpVtbl->Release(pClassFactory);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (FAILED(hr) && *ppKsPropertySet) // handle failure
|
||||
{
|
||||
#if defined __cplusplus
|
||||
(*ppKsPropertySet)->Release();
|
||||
#else
|
||||
(*ppKsPropertySet)->lpVtbl->Release(*ppKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
//
|
||||
// get the device information about a DirectSound GUID.
|
||||
//
|
||||
static BOOL GetInfoFromDSoundGUID(CONST GUID *lpGUID, UINT *puWaveDeviceID)
|
||||
{
|
||||
LPKSPROPERTYSET pKsPropertySet = NULL;
|
||||
HRESULT hr;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
hr = DirectSoundPrivateCreate(&pKsPropertySet);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ULONG ulBytesReturned = 0;
|
||||
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA sDirectSoundDeviceDescription;
|
||||
|
||||
ZeroMemory(&sDirectSoundDeviceDescription,sizeof(sDirectSoundDeviceDescription));
|
||||
sDirectSoundDeviceDescription.DeviceId = *lpGUID;
|
||||
|
||||
// get the size of the direct sound device description
|
||||
#if defined __cplusplus
|
||||
hr = pKsPropertySet->Get(
|
||||
DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
&sDirectSoundDeviceDescription,
|
||||
sizeof(sDirectSoundDeviceDescription),
|
||||
&ulBytesReturned
|
||||
);
|
||||
#else
|
||||
hr = pKsPropertySet->lpVtbl->Get(pKsPropertySet,
|
||||
&DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
&sDirectSoundDeviceDescription,
|
||||
sizeof(sDirectSoundDeviceDescription),
|
||||
&ulBytesReturned
|
||||
);
|
||||
#endif
|
||||
|
||||
if (SUCCEEDED(hr) && ulBytesReturned)
|
||||
{
|
||||
PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA psDirectSoundDeviceDescription = NULL;
|
||||
|
||||
// fetch the direct sound device description
|
||||
psDirectSoundDeviceDescription = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA) malloc(ulBytesReturned);
|
||||
if (psDirectSoundDeviceDescription != NULL)
|
||||
{
|
||||
// init structure with data from length request
|
||||
*psDirectSoundDeviceDescription = sDirectSoundDeviceDescription;
|
||||
|
||||
#if defined __cplusplus
|
||||
hr = pKsPropertySet->Get(
|
||||
DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
psDirectSoundDeviceDescription,
|
||||
ulBytesReturned,
|
||||
&ulBytesReturned
|
||||
);
|
||||
#else
|
||||
hr = pKsPropertySet->lpVtbl->Get(pKsPropertySet,
|
||||
&DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
psDirectSoundDeviceDescription,
|
||||
ulBytesReturned,
|
||||
&ulBytesReturned
|
||||
);
|
||||
#endif
|
||||
|
||||
if ((bSuccess = SUCCEEDED(hr)))
|
||||
{
|
||||
// the requested device ID
|
||||
*puWaveDeviceID = psDirectSoundDeviceDescription->WaveDeviceId;
|
||||
}
|
||||
free(psDirectSoundDeviceDescription);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined __cplusplus
|
||||
pKsPropertySet->Release();
|
||||
#else
|
||||
pKsPropertySet->lpVtbl->Release(pKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
//
|
||||
// callback function for DirectSoundEnumerate()
|
||||
//
|
||||
static BOOL CALLBACK DSEnumProc(LPGUID lpGUID,LPCTSTR lpszDesc,LPCTSTR lpszDrvName,LPVOID lpContext)
|
||||
{
|
||||
HWND hWnd = (HWND) lpContext; // window handle of the combo box
|
||||
|
||||
if (lpGUID != NULL) // NULL only for "Primary Sound Driver"
|
||||
{
|
||||
UINT uDevID;
|
||||
|
||||
if (GetInfoFromDSoundGUID(lpGUID,&uDevID))
|
||||
{
|
||||
WAVEOUTCAPS woc;
|
||||
|
||||
// has device the necessary capabilities?
|
||||
if ( waveOutGetDevCaps(uDevID,&woc,sizeof(woc)) == MMSYSERR_NOERROR
|
||||
&& (woc.dwFormats & WAVE_FORMAT_4M08) != 0)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
LONG i = (LONG) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) lpszDesc);
|
||||
SendMessage(hWnd,CB_SETITEMDATA,i,uDevID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
UNREFERENCED_PARAMETER(lpszDrvName);
|
||||
}
|
||||
|
||||
// set listfield for sound device combo box
|
||||
VOID SetSoundDeviceList(HWND hWnd,UINT uDeviceID)
|
||||
{
|
||||
typedef BOOL (CALLBACK *LPDSENUMCALLBACK)(LPGUID, LPCTSTR, LPCTSTR, LPVOID);
|
||||
typedef HRESULT (WINAPI *LPFN_SDE)(LPDSENUMCALLBACK lpDSEnumCallback,LPVOID lpContext);
|
||||
LPFN_SDE pfnDirectSoundEnumerate = NULL;
|
||||
|
||||
UINT uSelectDevice,uDevID,uDevNo;
|
||||
|
||||
HMODULE hDSound = LoadLibrary(_T("dsound.dll"));
|
||||
|
||||
if (hDSound != NULL) // direct sound dll found
|
||||
{
|
||||
#if defined _UNICODE
|
||||
pfnDirectSoundEnumerate = (LPFN_SDE) GetProcAddress(hDSound,"DirectSoundEnumerateW");
|
||||
#else
|
||||
pfnDirectSoundEnumerate = (LPFN_SDE) GetProcAddress(hDSound,"DirectSoundEnumerateA");
|
||||
#endif
|
||||
pfnDllGetClassObject = (LPFNDLLGETCLASSOBJECT) GetProcAddress(hDSound,"DllGetClassObject");
|
||||
}
|
||||
|
||||
SendMessage(hWnd,CB_RESETCONTENT,0,0);
|
||||
|
||||
// preset selector
|
||||
uSelectDevice = (UINT) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) _T("Standard Audio"));
|
||||
SendMessage(hWnd,CB_SETITEMDATA,uSelectDevice,WAVE_MAPPER);
|
||||
|
||||
// check for direct sound interface functions
|
||||
if (pfnDirectSoundEnumerate != NULL && pfnDllGetClassObject != NULL)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
if (SUCCEEDED(pfnDirectSoundEnumerate((LPDSENUMCALLBACK) DSEnumProc,hWnd)))
|
||||
{
|
||||
UINT i;
|
||||
|
||||
uDevNo = (UINT) SendMessage(hWnd,CB_GETCOUNT,0,0);
|
||||
for (i = 0; i < uDevNo; ++i)
|
||||
{
|
||||
// translate device ID to combo box position
|
||||
uDevID = (UINT) SendMessage(hWnd,CB_GETITEMDATA,i,0);
|
||||
|
||||
if (uDevID == uDeviceID) uSelectDevice = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // direct sound not available, detect over wave capabilities
|
||||
{
|
||||
WAVEOUTCAPS woc;
|
||||
|
||||
uDevNo = waveOutGetNumDevs();
|
||||
for (uDevID = 0; uDevID < uDevNo; ++uDevID)
|
||||
{
|
||||
if ( waveOutGetDevCaps(uDevID,&woc,sizeof(woc)) == MMSYSERR_NOERROR
|
||||
&& (woc.dwFormats & WAVE_FORMAT_4M08) != 0)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
LONG i = (LONG) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) woc.szPname);
|
||||
SendMessage(hWnd,CB_SETITEMDATA,i,uDevID);
|
||||
|
||||
if (uDevID == uDeviceID) uSelectDevice = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// activate last selected combo box item
|
||||
SendMessage(hWnd,CB_SETCURSEL,uSelectDevice,0L);
|
||||
|
||||
if (hDSound != NULL) // direct sound dll loaded
|
||||
{
|
||||
pfnDllGetClassObject = NULL;
|
||||
VERIFY(FreeLibrary(hDSound));
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* SndEnum.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2015 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "snddef.h"
|
||||
|
||||
typedef HRESULT (WINAPI *LPFNDLLGETCLASSOBJECT)(REFCLSID,REFIID,LPVOID *);
|
||||
static LPFNDLLGETCLASSOBJECT pfnDllGetClassObject = NULL;
|
||||
|
||||
//
|
||||
// create a IKsPropertySet interface
|
||||
//
|
||||
static __inline HRESULT DirectSoundPrivateCreate(LPKSPROPERTYSET *ppKsPropertySet)
|
||||
{
|
||||
LPCLASSFACTORY pClassFactory = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
// create a class factory object
|
||||
#if defined __cplusplus
|
||||
hr = pfnDllGetClassObject(CLSID_DirectSoundPrivate,IID_IClassFactory,(LPVOID *) &pClassFactory);
|
||||
#else
|
||||
hr = pfnDllGetClassObject(&CLSID_DirectSoundPrivate,&IID_IClassFactory,(LPVOID *) &pClassFactory);
|
||||
#endif
|
||||
|
||||
// create the DirectSoundPrivate object and query for an IKsPropertySet interface
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
#if defined __cplusplus
|
||||
hr = pClassFactory->CreateInstance(NULL,IID_IKsPropertySet,(LPVOID *) ppKsPropertySet);
|
||||
#else
|
||||
hr = pClassFactory->lpVtbl->CreateInstance(pClassFactory,NULL,&IID_IKsPropertySet,(LPVOID *) ppKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pClassFactory) // release the class factory object
|
||||
{
|
||||
#if defined __cplusplus
|
||||
pClassFactory->Release();
|
||||
#else
|
||||
pClassFactory->lpVtbl->Release(pClassFactory);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (FAILED(hr) && *ppKsPropertySet) // handle failure
|
||||
{
|
||||
#if defined __cplusplus
|
||||
(*ppKsPropertySet)->Release();
|
||||
#else
|
||||
(*ppKsPropertySet)->lpVtbl->Release(*ppKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
//
|
||||
// get the device information about a DirectSound GUID.
|
||||
//
|
||||
static BOOL GetInfoFromDSoundGUID(CONST GUID *lpGUID, UINT *puWaveDeviceID)
|
||||
{
|
||||
LPKSPROPERTYSET pKsPropertySet = NULL;
|
||||
HRESULT hr;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
hr = DirectSoundPrivateCreate(&pKsPropertySet);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ULONG ulBytesReturned = 0;
|
||||
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA sDirectSoundDeviceDescription;
|
||||
|
||||
ZeroMemory(&sDirectSoundDeviceDescription,sizeof(sDirectSoundDeviceDescription));
|
||||
sDirectSoundDeviceDescription.DeviceId = *lpGUID;
|
||||
|
||||
// get the size of the direct sound device description
|
||||
#if defined __cplusplus
|
||||
hr = pKsPropertySet->Get(
|
||||
DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
&sDirectSoundDeviceDescription,
|
||||
sizeof(sDirectSoundDeviceDescription),
|
||||
&ulBytesReturned
|
||||
);
|
||||
#else
|
||||
hr = pKsPropertySet->lpVtbl->Get(pKsPropertySet,
|
||||
&DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
&sDirectSoundDeviceDescription,
|
||||
sizeof(sDirectSoundDeviceDescription),
|
||||
&ulBytesReturned
|
||||
);
|
||||
#endif
|
||||
|
||||
if (SUCCEEDED(hr) && ulBytesReturned)
|
||||
{
|
||||
PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA psDirectSoundDeviceDescription = NULL;
|
||||
|
||||
// fetch the direct sound device description
|
||||
psDirectSoundDeviceDescription = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA) malloc(ulBytesReturned);
|
||||
if (psDirectSoundDeviceDescription != NULL)
|
||||
{
|
||||
// init structure with data from length request
|
||||
*psDirectSoundDeviceDescription = sDirectSoundDeviceDescription;
|
||||
|
||||
#if defined __cplusplus
|
||||
hr = pKsPropertySet->Get(
|
||||
DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
psDirectSoundDeviceDescription,
|
||||
ulBytesReturned,
|
||||
&ulBytesReturned
|
||||
);
|
||||
#else
|
||||
hr = pKsPropertySet->lpVtbl->Get(pKsPropertySet,
|
||||
&DSPROPSETID_DirectSoundDevice,
|
||||
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
|
||||
NULL,
|
||||
0,
|
||||
psDirectSoundDeviceDescription,
|
||||
ulBytesReturned,
|
||||
&ulBytesReturned
|
||||
);
|
||||
#endif
|
||||
|
||||
if ((bSuccess = SUCCEEDED(hr)))
|
||||
{
|
||||
// the requested device ID
|
||||
*puWaveDeviceID = psDirectSoundDeviceDescription->WaveDeviceId;
|
||||
}
|
||||
free(psDirectSoundDeviceDescription);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined __cplusplus
|
||||
pKsPropertySet->Release();
|
||||
#else
|
||||
pKsPropertySet->lpVtbl->Release(pKsPropertySet);
|
||||
#endif
|
||||
}
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
//
|
||||
// callback function for DirectSoundEnumerate()
|
||||
//
|
||||
static BOOL CALLBACK DSEnumProc(LPGUID lpGUID,LPCTSTR lpszDesc,LPCTSTR lpszDrvName,LPVOID lpContext)
|
||||
{
|
||||
HWND hWnd = (HWND) lpContext; // window handle of the combo box
|
||||
|
||||
if (lpGUID != NULL) // NULL only for "Primary Sound Driver"
|
||||
{
|
||||
UINT uDevID;
|
||||
|
||||
if (GetInfoFromDSoundGUID(lpGUID,&uDevID))
|
||||
{
|
||||
WAVEOUTCAPS woc;
|
||||
|
||||
// has device the necessary capabilities?
|
||||
if ( waveOutGetDevCaps(uDevID,&woc,sizeof(woc)) == MMSYSERR_NOERROR
|
||||
&& (woc.dwFormats & WAVE_FORMAT_4M08) != 0)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
LONG i = (LONG) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) lpszDesc);
|
||||
SendMessage(hWnd,CB_SETITEMDATA,i,uDevID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
UNREFERENCED_PARAMETER(lpszDrvName);
|
||||
}
|
||||
|
||||
// set listfield for sound device combo box
|
||||
VOID SetSoundDeviceList(HWND hWnd,UINT uDeviceID)
|
||||
{
|
||||
typedef BOOL (CALLBACK *LPDSENUMCALLBACK)(LPGUID, LPCTSTR, LPCTSTR, LPVOID);
|
||||
typedef HRESULT (WINAPI *LPFN_SDE)(LPDSENUMCALLBACK lpDSEnumCallback,LPVOID lpContext);
|
||||
LPFN_SDE pfnDirectSoundEnumerate = NULL;
|
||||
|
||||
UINT uSelectDevice,uDevID,uDevNo;
|
||||
|
||||
HMODULE hDSound = LoadLibrary(_T("dsound.dll"));
|
||||
|
||||
if (hDSound != NULL) // direct sound dll found
|
||||
{
|
||||
#if defined _UNICODE
|
||||
pfnDirectSoundEnumerate = (LPFN_SDE) GetProcAddress(hDSound,"DirectSoundEnumerateW");
|
||||
#else
|
||||
pfnDirectSoundEnumerate = (LPFN_SDE) GetProcAddress(hDSound,"DirectSoundEnumerateA");
|
||||
#endif
|
||||
pfnDllGetClassObject = (LPFNDLLGETCLASSOBJECT) GetProcAddress(hDSound,"DllGetClassObject");
|
||||
}
|
||||
|
||||
SendMessage(hWnd,CB_RESETCONTENT,0,0);
|
||||
|
||||
// preset selector
|
||||
uSelectDevice = (UINT) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) _T("Standard Audio"));
|
||||
SendMessage(hWnd,CB_SETITEMDATA,uSelectDevice,WAVE_MAPPER);
|
||||
|
||||
// check for direct sound interface functions
|
||||
if (pfnDirectSoundEnumerate != NULL && pfnDllGetClassObject != NULL)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
if (SUCCEEDED(pfnDirectSoundEnumerate((LPDSENUMCALLBACK) DSEnumProc,hWnd)))
|
||||
{
|
||||
UINT i;
|
||||
|
||||
uDevNo = (UINT) SendMessage(hWnd,CB_GETCOUNT,0,0);
|
||||
for (i = 0; i < uDevNo; ++i)
|
||||
{
|
||||
// translate device ID to combo box position
|
||||
uDevID = (UINT) SendMessage(hWnd,CB_GETITEMDATA,i,0);
|
||||
|
||||
if (uDevID == uDeviceID) uSelectDevice = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // direct sound not available, detect over wave capabilities
|
||||
{
|
||||
WAVEOUTCAPS woc;
|
||||
|
||||
uDevNo = waveOutGetNumDevs();
|
||||
for (uDevID = 0; uDevID < uDevNo; ++uDevID)
|
||||
{
|
||||
if ( waveOutGetDevCaps(uDevID,&woc,sizeof(woc)) == MMSYSERR_NOERROR
|
||||
&& (woc.dwFormats & WAVE_FORMAT_4M08) != 0)
|
||||
{
|
||||
// copy product name and wave device ID to combo box
|
||||
LONG i = (LONG) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) woc.szPname);
|
||||
SendMessage(hWnd,CB_SETITEMDATA,i,uDevID);
|
||||
|
||||
if (uDevID == uDeviceID) uSelectDevice = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// activate last selected combo box item
|
||||
SendMessage(hWnd,CB_SETCURSEL,uSelectDevice,0L);
|
||||
|
||||
if (hDSound != NULL) // direct sound dll loaded
|
||||
{
|
||||
pfnDllGetClassObject = NULL;
|
||||
VERIFY(FreeLibrary(hDSound));
|
||||
}
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,257 +1,257 @@
|
|||
/*
|
||||
* symbfile.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2008 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Saturn Object File Reading
|
||||
//#
|
||||
//################
|
||||
|
||||
#define RECORD_BLOCK 256 // block size
|
||||
#define OS_RESOLVED 0x8000 // resolved symbol
|
||||
#define OS_RELOCATABLE 0x4000 // relocatable symbol
|
||||
|
||||
#define SAT_ID "Saturn3" // saturn block header
|
||||
#define SYMB_ID "Symb" // symbol block header
|
||||
|
||||
#define HASHENTRIES 199 // size of hash table
|
||||
|
||||
typedef struct _REFDATA
|
||||
{
|
||||
LPTSTR lpszName; // symbol name
|
||||
DWORD dwAddr; // resolved address
|
||||
struct _REFDATA* pNext;
|
||||
} REFDATA, *PREFDATA;
|
||||
|
||||
static PREFDATA ppsBase[HASHENTRIES]; // base of symbol references (initialized with NULL)
|
||||
|
||||
static __inline DWORD GetHash(DWORD dwVal)
|
||||
{
|
||||
return dwVal % HASHENTRIES; // hash function
|
||||
}
|
||||
|
||||
static DWORD GetBigEndian(LPBYTE pbyData, INT nSize)
|
||||
{
|
||||
DWORD dwVal = 0;
|
||||
|
||||
while (nSize-- > 0)
|
||||
{
|
||||
dwVal <<= 8;
|
||||
dwVal += *pbyData++;
|
||||
}
|
||||
return dwVal;
|
||||
}
|
||||
|
||||
//
|
||||
// check if entry table is empty
|
||||
//
|
||||
BOOL RplTableEmpty(VOID)
|
||||
{
|
||||
DWORD i;
|
||||
|
||||
BOOL bEmpty = TRUE;
|
||||
|
||||
// check if hash table is empty
|
||||
for (i = 0; bEmpty && i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
bEmpty = (ppsBase[i] == NULL); // check if empty
|
||||
}
|
||||
return bEmpty;
|
||||
}
|
||||
|
||||
//
|
||||
// load entry table
|
||||
//
|
||||
BOOL RplLoadTable(LPCTSTR lpszFilename)
|
||||
{
|
||||
BYTE byPage[RECORD_BLOCK]; // record page size
|
||||
HANDLE hFile;
|
||||
DWORD dwFileLength,dwCodeLength,dwNoSymbols,dwNoReferences;
|
||||
DWORD dwFilePos,dwBytesRead,dwSymb,dwPageIndex,dwResolvedSymb;
|
||||
BOOL bSymbol,bSucc;
|
||||
|
||||
bSucc = FALSE;
|
||||
|
||||
hFile = CreateFile(lpszFilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dwResolvedSymb = 0; // no resolved symbols added
|
||||
bSymbol = TRUE; // next set is a symbol
|
||||
|
||||
// read first page
|
||||
ReadFile(hFile,byPage,sizeof(byPage),&dwBytesRead,NULL);
|
||||
if (dwBytesRead == sizeof(byPage) && memcmp(byPage,SAT_ID,7) == 0)
|
||||
{
|
||||
// file length in bytes
|
||||
dwFileLength = GetBigEndian(byPage+7,sizeof(WORD)) * sizeof(byPage);
|
||||
|
||||
// code area in nibbles
|
||||
dwCodeLength = GetBigEndian(byPage+9,sizeof(DWORD));
|
||||
|
||||
// no. of symbols & references
|
||||
dwNoSymbols = GetBigEndian(byPage+13,sizeof(WORD));
|
||||
|
||||
// no. of references
|
||||
dwNoReferences = GetBigEndian(byPage+15,sizeof(WORD));
|
||||
|
||||
// convert code area length into no. of pages
|
||||
dwPageIndex = (dwCodeLength + (2 * sizeof(byPage) - 1)) / (2 * sizeof(byPage));
|
||||
|
||||
// calculate no. of code pages
|
||||
dwFilePos = dwPageIndex * sizeof(byPage);
|
||||
|
||||
// jump to begin of symbols by skipping no. of code pages
|
||||
bSucc = SetFilePointer(hFile,dwFilePos,NULL,FILE_CURRENT) != INVALID_SET_FILE_POINTER;
|
||||
|
||||
dwFilePos += sizeof(byPage); // actual file position
|
||||
}
|
||||
|
||||
// read all symbol pages
|
||||
for (dwPageIndex = 256, dwSymb = 0; bSucc && dwSymb < dwNoSymbols; dwPageIndex += 42)
|
||||
{
|
||||
if (dwPageIndex >= 256) // read complete page
|
||||
{
|
||||
// read new symbol page
|
||||
ReadFile(hFile,byPage,sizeof(byPage),&dwBytesRead,NULL);
|
||||
dwFilePos += dwBytesRead; // update file position
|
||||
if ( dwFilePos > dwFileLength
|
||||
|| dwBytesRead != sizeof(byPage)
|
||||
|| memcmp(byPage,SYMB_ID,4) != 0)
|
||||
{
|
||||
bSucc = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
dwPageIndex = 4; // begin of new symbol
|
||||
}
|
||||
|
||||
if (bSymbol) // this is the 42 byte symbol set
|
||||
{
|
||||
WORD wSymbolType = (WORD) GetBigEndian(byPage+dwPageIndex+36,sizeof(WORD));
|
||||
|
||||
// check if it's a resolved or relocatable symbol
|
||||
bSymbol = (wSymbolType & OS_RESOLVED) != 0;
|
||||
|
||||
if (bSymbol) ++dwResolvedSymb; // added resolved symbol
|
||||
|
||||
if (wSymbolType == OS_RESOLVED) // resolved symbol type
|
||||
{
|
||||
TCHAR szSymbolName[36+1],*pcPtr;
|
||||
PREFDATA pData;
|
||||
DWORD dwHash;
|
||||
|
||||
#if defined _UNICODE
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,(LPCSTR)byPage+dwPageIndex,36,
|
||||
szSymbolName,ARRAYSIZEOF(szSymbolName));
|
||||
szSymbolName[36] = 0; // set EOS
|
||||
}
|
||||
#else
|
||||
{
|
||||
lstrcpyn(szSymbolName,(LPCSTR)byPage+dwPageIndex,ARRAYSIZEOF(szSymbolName));
|
||||
}
|
||||
#endif
|
||||
|
||||
// cut symbol name at first space character
|
||||
if ((pcPtr = _tcschr(szSymbolName,_T(' '))) != NULL)
|
||||
*pcPtr = 0; // set EOS
|
||||
|
||||
// allocate symbol memory
|
||||
VERIFY(pData = (PREFDATA) malloc(sizeof(*pData)));
|
||||
pData->lpszName = DuplicateString(szSymbolName);
|
||||
pData->dwAddr = GetBigEndian(byPage+dwPageIndex+38,sizeof(DWORD));
|
||||
|
||||
// add to hash table
|
||||
dwHash = GetHash(pData->dwAddr);
|
||||
pData->pNext = ppsBase[dwHash];
|
||||
ppsBase[dwHash] = pData;
|
||||
}
|
||||
|
||||
++dwSymb; // got symbol
|
||||
}
|
||||
else // 42 byte fill reference
|
||||
{
|
||||
bSymbol = TRUE; // nothing to do, next is a symbol set
|
||||
}
|
||||
}
|
||||
|
||||
bSucc = bSucc && (dwFilePos <= dwFileLength)
|
||||
&& (dwNoSymbols == (dwResolvedSymb + dwNoReferences));
|
||||
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
if (!bSucc) RplDeleteTable(); // delete current table
|
||||
return bSucc;
|
||||
}
|
||||
|
||||
//
|
||||
// delete entry table
|
||||
//
|
||||
VOID RplDeleteTable(VOID)
|
||||
{
|
||||
PREFDATA pData;
|
||||
DWORD i;
|
||||
|
||||
// clear hash entries
|
||||
for (i = 0; i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
while (ppsBase[i] != NULL) // walk through all datasets
|
||||
{
|
||||
pData = ppsBase[i]->pNext;
|
||||
free(ppsBase[i]->lpszName);
|
||||
free(ppsBase[i]);
|
||||
ppsBase[i] = pData;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// return name for given entry address
|
||||
//
|
||||
LPCTSTR RplGetName(DWORD dwAddr)
|
||||
{
|
||||
PREFDATA pData = ppsBase[GetHash(dwAddr)];
|
||||
|
||||
// walk through all datasets of hash entry
|
||||
for (; pData != NULL; pData = pData->pNext)
|
||||
{
|
||||
if (pData->dwAddr == dwAddr) // found address
|
||||
return pData->lpszName; // return symbol name
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// return entry address for given name
|
||||
//
|
||||
BOOL RplGetAddr(LPCTSTR lpszName, DWORD *pdwAddr)
|
||||
{
|
||||
PREFDATA pData;
|
||||
DWORD i;
|
||||
|
||||
// check for every dataset in hash table
|
||||
for (i = 0; i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
// walk through all datasets of hash entry
|
||||
for (pData = ppsBase[i]; pData != NULL; pData = pData->pNext)
|
||||
{
|
||||
// found symbol name
|
||||
if (lstrcmp(lpszName,pData->lpszName) == 0)
|
||||
{
|
||||
*pdwAddr = pData->dwAddr; // return address
|
||||
return FALSE; // found
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE; // not found
|
||||
}
|
||||
/*
|
||||
* symbfile.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2008 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
|
||||
//################
|
||||
//#
|
||||
//# Saturn Object File Reading
|
||||
//#
|
||||
//################
|
||||
|
||||
#define RECORD_BLOCK 256 // block size
|
||||
#define OS_RESOLVED 0x8000 // resolved symbol
|
||||
#define OS_RELOCATABLE 0x4000 // relocatable symbol
|
||||
|
||||
#define SAT_ID "Saturn3" // saturn block header
|
||||
#define SYMB_ID "Symb" // symbol block header
|
||||
|
||||
#define HASHENTRIES 199 // size of hash table
|
||||
|
||||
typedef struct _REFDATA
|
||||
{
|
||||
LPTSTR lpszName; // symbol name
|
||||
DWORD dwAddr; // resolved address
|
||||
struct _REFDATA* pNext;
|
||||
} REFDATA, *PREFDATA;
|
||||
|
||||
static PREFDATA ppsBase[HASHENTRIES]; // base of symbol references (initialized with NULL)
|
||||
|
||||
static __inline DWORD GetHash(DWORD dwVal)
|
||||
{
|
||||
return dwVal % HASHENTRIES; // hash function
|
||||
}
|
||||
|
||||
static DWORD GetBigEndian(LPBYTE pbyData, INT nSize)
|
||||
{
|
||||
DWORD dwVal = 0;
|
||||
|
||||
while (nSize-- > 0)
|
||||
{
|
||||
dwVal <<= 8;
|
||||
dwVal += *pbyData++;
|
||||
}
|
||||
return dwVal;
|
||||
}
|
||||
|
||||
//
|
||||
// check if entry table is empty
|
||||
//
|
||||
BOOL RplTableEmpty(VOID)
|
||||
{
|
||||
DWORD i;
|
||||
|
||||
BOOL bEmpty = TRUE;
|
||||
|
||||
// check if hash table is empty
|
||||
for (i = 0; bEmpty && i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
bEmpty = (ppsBase[i] == NULL); // check if empty
|
||||
}
|
||||
return bEmpty;
|
||||
}
|
||||
|
||||
//
|
||||
// load entry table
|
||||
//
|
||||
BOOL RplLoadTable(LPCTSTR lpszFilename)
|
||||
{
|
||||
BYTE byPage[RECORD_BLOCK]; // record page size
|
||||
HANDLE hFile;
|
||||
DWORD dwFileLength,dwCodeLength,dwNoSymbols,dwNoReferences;
|
||||
DWORD dwFilePos,dwBytesRead,dwSymb,dwPageIndex,dwResolvedSymb;
|
||||
BOOL bSymbol,bSucc;
|
||||
|
||||
bSucc = FALSE;
|
||||
|
||||
hFile = CreateFile(lpszFilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
dwResolvedSymb = 0; // no resolved symbols added
|
||||
bSymbol = TRUE; // next set is a symbol
|
||||
|
||||
// read first page
|
||||
ReadFile(hFile,byPage,sizeof(byPage),&dwBytesRead,NULL);
|
||||
if (dwBytesRead == sizeof(byPage) && memcmp(byPage,SAT_ID,7) == 0)
|
||||
{
|
||||
// file length in bytes
|
||||
dwFileLength = GetBigEndian(byPage+7,sizeof(WORD)) * sizeof(byPage);
|
||||
|
||||
// code area in nibbles
|
||||
dwCodeLength = GetBigEndian(byPage+9,sizeof(DWORD));
|
||||
|
||||
// no. of symbols & references
|
||||
dwNoSymbols = GetBigEndian(byPage+13,sizeof(WORD));
|
||||
|
||||
// no. of references
|
||||
dwNoReferences = GetBigEndian(byPage+15,sizeof(WORD));
|
||||
|
||||
// convert code area length into no. of pages
|
||||
dwPageIndex = (dwCodeLength + (2 * sizeof(byPage) - 1)) / (2 * sizeof(byPage));
|
||||
|
||||
// calculate no. of code pages
|
||||
dwFilePos = dwPageIndex * sizeof(byPage);
|
||||
|
||||
// jump to begin of symbols by skipping no. of code pages
|
||||
bSucc = SetFilePointer(hFile,dwFilePos,NULL,FILE_CURRENT) != INVALID_SET_FILE_POINTER;
|
||||
|
||||
dwFilePos += sizeof(byPage); // actual file position
|
||||
}
|
||||
|
||||
// read all symbol pages
|
||||
for (dwPageIndex = 256, dwSymb = 0; bSucc && dwSymb < dwNoSymbols; dwPageIndex += 42)
|
||||
{
|
||||
if (dwPageIndex >= 256) // read complete page
|
||||
{
|
||||
// read new symbol page
|
||||
ReadFile(hFile,byPage,sizeof(byPage),&dwBytesRead,NULL);
|
||||
dwFilePos += dwBytesRead; // update file position
|
||||
if ( dwFilePos > dwFileLength
|
||||
|| dwBytesRead != sizeof(byPage)
|
||||
|| memcmp(byPage,SYMB_ID,4) != 0)
|
||||
{
|
||||
bSucc = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
dwPageIndex = 4; // begin of new symbol
|
||||
}
|
||||
|
||||
if (bSymbol) // this is the 42 byte symbol set
|
||||
{
|
||||
WORD wSymbolType = (WORD) GetBigEndian(byPage+dwPageIndex+36,sizeof(WORD));
|
||||
|
||||
// check if it's a resolved or relocatable symbol
|
||||
bSymbol = (wSymbolType & OS_RESOLVED) != 0;
|
||||
|
||||
if (bSymbol) ++dwResolvedSymb; // added resolved symbol
|
||||
|
||||
if (wSymbolType == OS_RESOLVED) // resolved symbol type
|
||||
{
|
||||
TCHAR szSymbolName[36+1],*pcPtr;
|
||||
PREFDATA pData;
|
||||
DWORD dwHash;
|
||||
|
||||
#if defined _UNICODE
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,(LPCSTR)byPage+dwPageIndex,36,
|
||||
szSymbolName,ARRAYSIZEOF(szSymbolName));
|
||||
szSymbolName[36] = 0; // set EOS
|
||||
}
|
||||
#else
|
||||
{
|
||||
lstrcpyn(szSymbolName,(LPCSTR)byPage+dwPageIndex,ARRAYSIZEOF(szSymbolName));
|
||||
}
|
||||
#endif
|
||||
|
||||
// cut symbol name at first space character
|
||||
if ((pcPtr = _tcschr(szSymbolName,_T(' '))) != NULL)
|
||||
*pcPtr = 0; // set EOS
|
||||
|
||||
// allocate symbol memory
|
||||
VERIFY(pData = (PREFDATA) malloc(sizeof(*pData)));
|
||||
pData->lpszName = DuplicateString(szSymbolName);
|
||||
pData->dwAddr = GetBigEndian(byPage+dwPageIndex+38,sizeof(DWORD));
|
||||
|
||||
// add to hash table
|
||||
dwHash = GetHash(pData->dwAddr);
|
||||
pData->pNext = ppsBase[dwHash];
|
||||
ppsBase[dwHash] = pData;
|
||||
}
|
||||
|
||||
++dwSymb; // got symbol
|
||||
}
|
||||
else // 42 byte fill reference
|
||||
{
|
||||
bSymbol = TRUE; // nothing to do, next is a symbol set
|
||||
}
|
||||
}
|
||||
|
||||
bSucc = bSucc && (dwFilePos <= dwFileLength)
|
||||
&& (dwNoSymbols == (dwResolvedSymb + dwNoReferences));
|
||||
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
if (!bSucc) RplDeleteTable(); // delete current table
|
||||
return bSucc;
|
||||
}
|
||||
|
||||
//
|
||||
// delete entry table
|
||||
//
|
||||
VOID RplDeleteTable(VOID)
|
||||
{
|
||||
PREFDATA pData;
|
||||
DWORD i;
|
||||
|
||||
// clear hash entries
|
||||
for (i = 0; i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
while (ppsBase[i] != NULL) // walk through all datasets
|
||||
{
|
||||
pData = ppsBase[i]->pNext;
|
||||
free(ppsBase[i]->lpszName);
|
||||
free(ppsBase[i]);
|
||||
ppsBase[i] = pData;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// return name for given entry address
|
||||
//
|
||||
LPCTSTR RplGetName(DWORD dwAddr)
|
||||
{
|
||||
PREFDATA pData = ppsBase[GetHash(dwAddr)];
|
||||
|
||||
// walk through all datasets of hash entry
|
||||
for (; pData != NULL; pData = pData->pNext)
|
||||
{
|
||||
if (pData->dwAddr == dwAddr) // found address
|
||||
return pData->lpszName; // return symbol name
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// return entry address for given name
|
||||
//
|
||||
BOOL RplGetAddr(LPCTSTR lpszName, DWORD *pdwAddr)
|
||||
{
|
||||
PREFDATA pData;
|
||||
DWORD i;
|
||||
|
||||
// check for every dataset in hash table
|
||||
for (i = 0; i < ARRAYSIZEOF(ppsBase); ++i)
|
||||
{
|
||||
// walk through all datasets of hash entry
|
||||
for (pData = ppsBase[i]; pData != NULL; pData = pData->pNext)
|
||||
{
|
||||
// found symbol name
|
||||
if (lstrcmp(lpszName,pData->lpszName) == 0)
|
||||
{
|
||||
*pdwAddr = pData->dwAddr; // return address
|
||||
return FALSE; // found
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE; // not found
|
||||
}
|
|
@ -1,435 +1,429 @@
|
|||
/*
|
||||
* timer.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
#include "ops.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
#define AUTO_OFF 10 // Time in minutes for 'auto off'
|
||||
|
||||
// Ticks for 'auto off'
|
||||
#define OFF_TIME ((ULONGLONG) (AUTO_OFF * 60) << 13)
|
||||
|
||||
// memory address for clock and auto off
|
||||
// S(X) = 0x70052-0x70070, G(X) = 0x80058-0x80076, 49G = 0x80058-0x80076
|
||||
#define RPLTIME ((cCurrentRomType=='S')?0x52:0x58)
|
||||
|
||||
#define T1_FREQ 62 // Timer1 1/frequency in ms
|
||||
#define T2_FREQ 8192 // Timer2 frequency
|
||||
|
||||
static BOOL bStarted = FALSE;
|
||||
static BOOL bOutRange = FALSE; // flag if timer value out of range
|
||||
static UINT uT1TimerId = 0;
|
||||
static UINT uT2TimerId = 0;
|
||||
|
||||
static BOOL bNINT2T1 = FALSE; // state of NINT2 affected from timer1
|
||||
static BOOL bNINT2T2 = FALSE; // state of NINT2 affected from timer2
|
||||
|
||||
static BOOL bAccurateTimer; // flag if accurate timer is used
|
||||
static LARGE_INTEGER lT2Ref; // counter value at timer2 start
|
||||
static TIMECAPS tc; // timer information
|
||||
static UINT uT2MaxTicks; // max. timer2 ticks handled by one timer event
|
||||
|
||||
static DWORD dwT2Ref; // timer2 value at last timer2 access
|
||||
static DWORD dwT2Cyc; // cpu cycle counter at last timer2 access
|
||||
|
||||
static void CALLBACK TimeProc(UINT uEventId, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
|
||||
|
||||
static DWORD CalcT2(VOID) // calculate timer2 value
|
||||
{
|
||||
DWORD dwT2 = Chipset.t2; // get value from chipset
|
||||
if (bStarted) // timer2 running
|
||||
{
|
||||
LARGE_INTEGER lT2Act;
|
||||
DWORD dwT2Dif;
|
||||
|
||||
// timer should run a little bit faster (10%) than maschine in authentic speed mode
|
||||
DWORD dwCycPerTick = (9 * T2CYCLES) / 5;
|
||||
|
||||
QueryPerformanceCounter(&lT2Act); // actual time
|
||||
// calculate realtime timer2 ticks since reference point
|
||||
dwT2 -= (DWORD)
|
||||
(((lT2Act.QuadPart - lT2Ref.QuadPart) * T2_FREQ)
|
||||
/ lFreq.QuadPart);
|
||||
|
||||
dwT2Dif = dwT2Ref - dwT2; // timer2 ticks since last request
|
||||
|
||||
// checking if the MSB of dwT2Dif can be used as sign flag
|
||||
_ASSERT((DWORD) tc.wPeriodMax < ((1<<(sizeof(dwT2Dif)*8-1))/8192)*1000);
|
||||
|
||||
// 2nd timer call in a 32ms time frame or elapsed time is negative (Win2k bug)
|
||||
if (!Chipset.Shutdn && ((dwT2Dif > 0x01 && dwT2Dif <= 0x100) || (dwT2Dif & 0x80000000) != 0))
|
||||
{
|
||||
DWORD dwT2Ticks = ((DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwT2Cyc) / dwCycPerTick;
|
||||
|
||||
// estimated < real elapsed timer2 ticks or negative time
|
||||
if (dwT2Ticks < dwT2Dif || (dwT2Dif & 0x80000000) != 0)
|
||||
{
|
||||
// real time too long or got negative time elapsed
|
||||
dwT2 = dwT2Ref - dwT2Ticks; // estimated timer2 value from CPU cycles
|
||||
dwT2Cyc += dwT2Ticks * dwCycPerTick; // estimated CPU cycles for the timer2 ticks
|
||||
}
|
||||
else
|
||||
{
|
||||
// reached actual time -> new synchronizing
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// valid actual time -> new synchronizing
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
|
||||
// check if timer2 interrupt is active -> no timer2 value below 0xFFFFFFFF
|
||||
if ( Chipset.inte
|
||||
&& (dwT2 & 0x80000000) != 0
|
||||
&& (!Chipset.Shutdn || (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER2_CTRL]&INTR)
|
||||
)
|
||||
{
|
||||
dwT2 = 0xFFFFFFFF;
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
|
||||
dwT2Ref = dwT2; // new reference time
|
||||
}
|
||||
return dwT2;
|
||||
}
|
||||
|
||||
static VOID CheckT1(BYTE nT1)
|
||||
{
|
||||
// implementation of TSRQ
|
||||
bNINT2T1 = (Chipset.IORam[TIMER1_CTRL]&INTR) != 0 && (nT1&8) != 0;
|
||||
IOBit(SRQ1,TSRQ,bNINT2T1 || bNINT2T2);
|
||||
|
||||
if ((nT1&8) == 0) // timer1 MSB not set
|
||||
{
|
||||
Chipset.IORam[TIMER1_CTRL] &= ~SRQ; // clear SRQ bit
|
||||
return;
|
||||
}
|
||||
|
||||
_ASSERT((nT1&8) != 0); // timer1 MSB set
|
||||
|
||||
// timer MSB and INT or WAKE bit is set
|
||||
if ((Chipset.IORam[TIMER1_CTRL]&(WKE|INTR)) != 0)
|
||||
Chipset.IORam[TIMER1_CTRL] |= SRQ; // set SRQ
|
||||
// cpu not sleeping and T1 -> Interrupt
|
||||
if ( (!Chipset.Shutdn || (Chipset.IORam[TIMER1_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER1_CTRL]&INTR))
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
// cpu sleeping and T1 -> Wake Up
|
||||
if (Chipset.Shutdn && (Chipset.IORam[TIMER1_CTRL]&WKE))
|
||||
{
|
||||
Chipset.IORam[TIMER1_CTRL] &= ~WKE; // clear WKE bit
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID CheckT2(DWORD dwT2)
|
||||
{
|
||||
// implementation of TSRQ
|
||||
bNINT2T2 = (Chipset.IORam[TIMER2_CTRL]&INTR) != 0 && (dwT2&0x80000000) != 0;
|
||||
IOBit(SRQ1,TSRQ,bNINT2T1 || bNINT2T2);
|
||||
|
||||
if ((dwT2&0x80000000) == 0) // timer2 MSB not set
|
||||
{
|
||||
Chipset.IORam[TIMER2_CTRL] &= ~SRQ; // clear SRQ bit
|
||||
return;
|
||||
}
|
||||
|
||||
_ASSERT((dwT2&0x80000000) != 0); // timer2 MSB set
|
||||
|
||||
// timer MSB and INT or WAKE bit is set
|
||||
if ((Chipset.IORam[TIMER2_CTRL]&(WKE|INTR)) != 0)
|
||||
Chipset.IORam[TIMER2_CTRL] |= SRQ; // set SRQ
|
||||
// cpu not sleeping and T2 -> Interrupt
|
||||
if ( (!Chipset.Shutdn || (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER2_CTRL]&INTR))
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
// cpu sleeping and T2 -> Wake Up
|
||||
if (Chipset.Shutdn && (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
{
|
||||
Chipset.IORam[TIMER2_CTRL] &= ~WKE; // clear WKE bit
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID RescheduleT2(BOOL bRefPoint)
|
||||
{
|
||||
UINT uDelay;
|
||||
_ASSERT(uT2TimerId == 0); // timer2 must stopped
|
||||
if (bRefPoint) // save reference time
|
||||
{
|
||||
dwT2Ref = Chipset.t2; // timer2 value at last timer2 access
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF); // cpu cycle counter at last timer2 access
|
||||
QueryPerformanceCounter(&lT2Ref); // time of corresponding Chipset.t2 value
|
||||
uDelay = Chipset.t2; // timer value for delay
|
||||
}
|
||||
else // called without new refpoint, restart t2 with actual value
|
||||
{
|
||||
uDelay = CalcT2(); // actual timer value for delay
|
||||
}
|
||||
if ((bOutRange = uDelay > uT2MaxTicks)) // delay greater maximum delay
|
||||
uDelay = uT2MaxTicks; // wait maximum delay time
|
||||
uDelay = (uDelay * 125 + 1023) / 1024; // timer delay in ms (1000/8192 = 125/1024)
|
||||
uDelay = __max(tc.wPeriodMin,uDelay); // wait minimum delay of timer
|
||||
_ASSERT(uDelay <= tc.wPeriodMax); // inside maximum event delay
|
||||
// start timer2; schedule event, when Chipset.t2 will be zero
|
||||
VERIFY(uT2TimerId = timeSetEvent(uDelay,0,&TimeProc,2,TIME_ONESHOT));
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID AbortT2(VOID)
|
||||
{
|
||||
_ASSERT(uT2TimerId);
|
||||
timeKillEvent(uT2TimerId); // kill event
|
||||
uT2TimerId = 0; // then reset var
|
||||
return;
|
||||
}
|
||||
|
||||
static void CALLBACK TimeProc(UINT uEventId, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||
{
|
||||
if (uEventId == 0) return; // illegal EventId
|
||||
|
||||
if (uEventId == uT1TimerId) // called from timer1 event (default period 16 Hz)
|
||||
{
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
Chipset.t1 = (Chipset.t1-1)&0xF;// decrement timer value
|
||||
CheckT1(Chipset.t1); // test timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
return;
|
||||
}
|
||||
if (uEventId == uT2TimerId) // called from timer2 event, Chipset.t2 should be zero
|
||||
{
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
uT2TimerId = 0; // single shot timer timer2 stopped
|
||||
if (!bOutRange) // timer event elapsed
|
||||
{
|
||||
// timer2 overrun, test timer2 control bits else restart timer2
|
||||
Chipset.t2 = CalcT2(); // calculate new timer2 value
|
||||
CheckT2(Chipset.t2); // test timer2 control bits
|
||||
}
|
||||
RescheduleT2(!bOutRange); // restart timer2
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
UNREFERENCED_PARAMETER(uMsg);
|
||||
UNREFERENCED_PARAMETER(dwUser);
|
||||
UNREFERENCED_PARAMETER(dw1);
|
||||
UNREFERENCED_PARAMETER(dw2);
|
||||
}
|
||||
|
||||
VOID SetHP48Time(VOID) // set date and time
|
||||
{
|
||||
SYSTEMTIME ts;
|
||||
ULONGLONG ticks, time;
|
||||
DWORD dw;
|
||||
WORD crc, i;
|
||||
BYTE p[4];
|
||||
|
||||
_ASSERT(sizeof(ULONGLONG) == 8); // check size of datatype
|
||||
|
||||
GetLocalTime(&ts); // local time, _ftime() cause memory/resource leaks
|
||||
|
||||
// calculate days until 01.01.0000 (Erlang BIF localtime/0)
|
||||
dw = (DWORD) ts.wMonth;
|
||||
if (dw > 2)
|
||||
dw -= 3L;
|
||||
else
|
||||
{
|
||||
dw += 9L;
|
||||
--ts.wYear;
|
||||
}
|
||||
dw = (DWORD) ts.wDay + (153L * dw + 2L) / 5L;
|
||||
dw += (146097L * (((DWORD) ts.wYear) / 100L)) / 4L;
|
||||
dw += (1461L * (((DWORD) ts.wYear) % 100L)) / 4L;
|
||||
dw += (-719469L + 719528L); // days from year 0
|
||||
|
||||
ticks = (ULONGLONG) dw; // convert to 64 bit
|
||||
|
||||
// convert into seconds and add time
|
||||
ticks = ticks * 24L + (ULONGLONG) ts.wHour;
|
||||
ticks = ticks * 60L + (ULONGLONG) ts.wMinute;
|
||||
ticks = ticks * 60L + (ULONGLONG) ts.wSecond;
|
||||
|
||||
// create timerticks = (s + ms) * 8192
|
||||
ticks = (ticks << 13) | (((ULONGLONG) ts.wMilliseconds << 10) / 125);
|
||||
|
||||
ticks += Chipset.t2; // add actual timer2 value
|
||||
|
||||
time = ticks; // save for calc. timeout
|
||||
time += OFF_TIME; // add 10 min for auto off
|
||||
|
||||
dw = RPLTIME; // HP addresses for clock in port0
|
||||
|
||||
crc = 0x0; // reset crc value
|
||||
for (i = 0; i < 13; ++i, ++dw) // write date and time
|
||||
{
|
||||
*p = (BYTE) ticks & 0xf;
|
||||
crc = (crc >> 4) ^ (((crc ^ ((WORD) *p)) & 0xf) * 0x1081);
|
||||
Port0[dw] = *p; // always store in port0
|
||||
ticks >>= 4;
|
||||
}
|
||||
|
||||
Nunpack(p,crc,4); // write crc
|
||||
memcpy(Port0+dw,p,4); // always store in port0
|
||||
|
||||
dw += 4; // HP addresses for timeout
|
||||
|
||||
for (i = 0; i < 13; ++i, ++dw) // write time for auto off
|
||||
{
|
||||
Port0[dw] = (BYTE) time & 0xf; // always store in port0
|
||||
time >>= 4;
|
||||
}
|
||||
|
||||
Port0[dw] = 0xf; // always store in port0
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StartTimers(VOID)
|
||||
{
|
||||
if (bStarted) // timer running
|
||||
return; // -> quit
|
||||
if (Chipset.IORam[TIMER2_CTRL]&RUN) // start timer1 and timer2 ?
|
||||
{
|
||||
bStarted = TRUE; // flag timer running
|
||||
// initialisation of NINT2 lines
|
||||
bNINT2T1 = (Chipset.IORam[TIMER1_CTRL]&INTR) != 0 && (Chipset.t1 & 8) != 0;
|
||||
bNINT2T2 = (Chipset.IORam[TIMER2_CTRL]&INTR) != 0 && (Chipset.t2 & 0x80000000) != 0;
|
||||
timeGetDevCaps(&tc,sizeof(tc)); // get timer resolution
|
||||
|
||||
// max. timer2 ticks that can be handled by one timer event
|
||||
uT2MaxTicks = __min((0xFFFFFFFF / 1024),tc.wPeriodMax);
|
||||
uT2MaxTicks = __min((0xFFFFFFFF - 1023) / 125,uT2MaxTicks * 1024 / 125);
|
||||
|
||||
CheckT1(Chipset.t1); // check for timer1 interrupts
|
||||
CheckT2(Chipset.t2); // check for timer2 interrupts
|
||||
// set timer resolution to greatest possible one
|
||||
bAccurateTimer = (timeBeginPeriod(tc.wPeriodMin) == TIMERR_NOERROR);
|
||||
// set timer1 with given period
|
||||
VERIFY(uT1TimerId = timeSetEvent(T1_FREQ,0,&TimeProc,1,TIME_PERIODIC));
|
||||
RescheduleT2(TRUE); // start timer2
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StopTimers(VOID)
|
||||
{
|
||||
if (!bStarted) // timer stopped
|
||||
return; // -> quit
|
||||
if (uT1TimerId != 0) // timer1 running
|
||||
{
|
||||
// Critical Section handler may cause a dead lock
|
||||
timeKillEvent(uT1TimerId); // stop timer1
|
||||
uT1TimerId = 0; // set flag timer1 stopped
|
||||
}
|
||||
if (uT2TimerId != 0) // timer2 running
|
||||
{
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
Chipset.t2 = CalcT2(); // update chipset timer2 value
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
AbortT2(); // stop timer2 outside critical section
|
||||
}
|
||||
bStarted = FALSE;
|
||||
if (bAccurateTimer) // "Accurate timer" running
|
||||
{
|
||||
timeEndPeriod(tc.wPeriodMin); // finish service
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD ReadT2(VOID)
|
||||
{
|
||||
DWORD dwT2;
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
dwT2 = CalcT2(); // calculate timer2 value or if stopped last timer value
|
||||
CheckT2(dwT2); // update timer2 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return dwT2;
|
||||
}
|
||||
|
||||
VOID SetT2(DWORD dwValue)
|
||||
{
|
||||
// calling AbortT2() inside Critical Section handler may cause a dead lock
|
||||
if (uT2TimerId != 0) // timer2 running
|
||||
AbortT2(); // stop timer2
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
Chipset.t2 = dwValue; // set new value
|
||||
CheckT2(Chipset.t2); // test timer2 control bits
|
||||
if (bStarted) // timer running
|
||||
RescheduleT2(TRUE); // restart timer2
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE ReadT1(VOID)
|
||||
{
|
||||
BYTE nT1;
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
nT1 = Chipset.t1; // read timer1 value
|
||||
CheckT1(nT1); // update timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
return nT1;
|
||||
}
|
||||
|
||||
VOID SetT1(BYTE byValue)
|
||||
{
|
||||
BOOL bEqual;
|
||||
|
||||
_ASSERT(byValue < 0x10); // timer1 is only a 4bit counter
|
||||
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
bEqual = (Chipset.t1 == byValue); // check for same value
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
if (bEqual) return; // same value doesn't restart timer period
|
||||
|
||||
if (uT1TimerId != 0) // timer1 running
|
||||
{
|
||||
timeKillEvent(uT1TimerId); // stop timer1
|
||||
uT1TimerId = 0; // set flag timer1 stopped
|
||||
}
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
Chipset.t1 = byValue; // set new timer1 value
|
||||
CheckT1(Chipset.t1); // test timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
if (bStarted) // timer running
|
||||
{
|
||||
// restart timer1 to get full period of frequency
|
||||
VERIFY(uT1TimerId = timeSetEvent(T1_FREQ,0,&TimeProc,1,TIME_PERIODIC));
|
||||
}
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* timer.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
#include "ops.h"
|
||||
#include "io.h" // I/O definitions
|
||||
|
||||
#define AUTO_OFF 10 // Time in minutes for 'auto off'
|
||||
|
||||
// Ticks for 'auto off'
|
||||
#define OFF_TIME ((ULONGLONG) (AUTO_OFF * 60) << 13)
|
||||
|
||||
// memory address for clock and auto off
|
||||
// S(X) = 0x70052-0x70070, G(X) = 0x80058-0x80076, 49G = 0x80058-0x80076
|
||||
#define RPLTIME ((cCurrentRomType=='S')?0x52:0x58)
|
||||
|
||||
#define T1_FREQ 62 // Timer1 1/frequency in ms
|
||||
#define T2_FREQ 8192 // Timer2 frequency
|
||||
|
||||
static BOOL bStarted = FALSE;
|
||||
static BOOL bOutRange = FALSE; // flag if timer value out of range
|
||||
static UINT uT1TimerId = 0;
|
||||
static UINT uT2TimerId = 0;
|
||||
|
||||
static BOOL bNINT2T1 = FALSE; // state of NINT2 affected from timer1
|
||||
static BOOL bNINT2T2 = FALSE; // state of NINT2 affected from timer2
|
||||
|
||||
static BOOL bAccurateTimer; // flag if accurate timer is used
|
||||
static LARGE_INTEGER lT2Ref; // counter value at timer2 start
|
||||
static TIMECAPS tc; // timer information
|
||||
static UINT uT2MaxTicks; // max. timer2 ticks handled by one timer event
|
||||
|
||||
static DWORD dwT2Ref; // timer2 value at last timer2 access
|
||||
static DWORD dwT2Cyc; // cpu cycle counter at last timer2 access
|
||||
|
||||
static void CALLBACK TimeProc(UINT uEventId, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
|
||||
|
||||
static DWORD CalcT2(VOID) // calculate timer2 value
|
||||
{
|
||||
DWORD dwT2 = Chipset.t2; // get value from chipset
|
||||
if (bStarted) // timer2 running
|
||||
{
|
||||
LARGE_INTEGER lT2Act;
|
||||
DWORD dwT2Dif;
|
||||
|
||||
// timer should run a little bit faster (10%) than maschine in authentic speed mode
|
||||
DWORD dwCycPerTick = (9 * T2CYCLES) / 5;
|
||||
|
||||
QueryPerformanceCounter(&lT2Act); // actual time
|
||||
// calculate realtime timer2 ticks since reference point
|
||||
dwT2 -= (DWORD)
|
||||
(((lT2Act.QuadPart - lT2Ref.QuadPart) * T2_FREQ)
|
||||
/ lFreq.QuadPart);
|
||||
|
||||
dwT2Dif = dwT2Ref - dwT2; // timer2 ticks since last request
|
||||
|
||||
// checking if the MSB of dwT2Dif can be used as sign flag
|
||||
_ASSERT((DWORD) tc.wPeriodMax < ((1<<(sizeof(dwT2Dif)*8-1))/8192)*1000);
|
||||
|
||||
// 2nd timer call in a 32ms time frame or elapsed time is negative (Win2k bug)
|
||||
if (!Chipset.Shutdn && ((dwT2Dif > 0x01 && dwT2Dif <= 0x100) || (dwT2Dif & 0x80000000) != 0))
|
||||
{
|
||||
DWORD dwT2Ticks = ((DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwT2Cyc) / dwCycPerTick;
|
||||
|
||||
// estimated < real elapsed timer2 ticks or negative time
|
||||
if (dwT2Ticks < dwT2Dif || (dwT2Dif & 0x80000000) != 0)
|
||||
{
|
||||
// real time too long or got negative time elapsed
|
||||
dwT2 = dwT2Ref - dwT2Ticks; // estimated timer2 value from CPU cycles
|
||||
dwT2Cyc += dwT2Ticks * dwCycPerTick; // estimated CPU cycles for the timer2 ticks
|
||||
}
|
||||
else
|
||||
{
|
||||
// reached actual time -> new synchronizing
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// valid actual time -> new synchronizing
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
|
||||
// check if timer2 interrupt is active -> no timer2 value below 0xFFFFFFFF
|
||||
if ( Chipset.inte
|
||||
&& (dwT2 & 0x80000000) != 0
|
||||
&& (!Chipset.Shutdn || (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER2_CTRL]&INTR)
|
||||
)
|
||||
{
|
||||
dwT2 = 0xFFFFFFFF;
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF) - dwCycPerTick;
|
||||
}
|
||||
|
||||
dwT2Ref = dwT2; // new reference time
|
||||
}
|
||||
return dwT2;
|
||||
}
|
||||
|
||||
static VOID CheckT1(BYTE nT1)
|
||||
{
|
||||
// implementation of TSRQ
|
||||
bNINT2T1 = (Chipset.IORam[TIMER1_CTRL]&INTR) != 0 && (nT1&8) != 0;
|
||||
IOBit(SRQ1,TSRQ,bNINT2T1 || bNINT2T2);
|
||||
|
||||
if ((nT1&8) == 0) // timer1 MSB not set
|
||||
{
|
||||
Chipset.IORam[TIMER1_CTRL] &= ~SRQ; // clear SRQ bit
|
||||
return;
|
||||
}
|
||||
|
||||
_ASSERT((nT1&8) != 0); // timer1 MSB set
|
||||
|
||||
// timer MSB and INT or WAKE bit is set
|
||||
if ((Chipset.IORam[TIMER1_CTRL]&(WKE|INTR)) != 0)
|
||||
Chipset.IORam[TIMER1_CTRL] |= SRQ; // set SRQ
|
||||
// cpu not sleeping and T1 -> Interrupt
|
||||
if ( (!Chipset.Shutdn || (Chipset.IORam[TIMER1_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER1_CTRL]&INTR))
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
// cpu sleeping and T1 -> Wake Up
|
||||
if (Chipset.Shutdn && (Chipset.IORam[TIMER1_CTRL]&WKE))
|
||||
{
|
||||
Chipset.IORam[TIMER1_CTRL] &= ~WKE; // clear WKE bit
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID CheckT2(DWORD dwT2)
|
||||
{
|
||||
// implementation of TSRQ
|
||||
bNINT2T2 = (Chipset.IORam[TIMER2_CTRL]&INTR) != 0 && (dwT2&0x80000000) != 0;
|
||||
IOBit(SRQ1,TSRQ,bNINT2T1 || bNINT2T2);
|
||||
|
||||
if ((dwT2&0x80000000) == 0) // timer2 MSB not set
|
||||
{
|
||||
Chipset.IORam[TIMER2_CTRL] &= ~SRQ; // clear SRQ bit
|
||||
return;
|
||||
}
|
||||
|
||||
_ASSERT((dwT2&0x80000000) != 0); // timer2 MSB set
|
||||
|
||||
// timer MSB and INT or WAKE bit is set
|
||||
if ((Chipset.IORam[TIMER2_CTRL]&(WKE|INTR)) != 0)
|
||||
Chipset.IORam[TIMER2_CTRL] |= SRQ; // set SRQ
|
||||
// cpu not sleeping and T2 -> Interrupt
|
||||
if ( (!Chipset.Shutdn || (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
&& (Chipset.IORam[TIMER2_CTRL]&INTR))
|
||||
{
|
||||
Chipset.SoftInt = TRUE;
|
||||
bInterrupt = TRUE;
|
||||
}
|
||||
// cpu sleeping and T2 -> Wake Up
|
||||
if (Chipset.Shutdn && (Chipset.IORam[TIMER2_CTRL]&WKE))
|
||||
{
|
||||
Chipset.IORam[TIMER2_CTRL] &= ~WKE; // clear WKE bit
|
||||
Chipset.bShutdnWake = TRUE; // wake up from SHUTDN mode
|
||||
SetEvent(hEventShutdn); // wake up emulation thread
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID RescheduleT2(BOOL bRefPoint)
|
||||
{
|
||||
UINT uDelay;
|
||||
_ASSERT(uT2TimerId == 0); // timer2 must stopped
|
||||
if (bRefPoint) // save reference time
|
||||
{
|
||||
dwT2Ref = Chipset.t2; // timer2 value at last timer2 access
|
||||
dwT2Cyc = (DWORD) (Chipset.cycles & 0xFFFFFFFF); // cpu cycle counter at last timer2 access
|
||||
QueryPerformanceCounter(&lT2Ref); // time of corresponding Chipset.t2 value
|
||||
uDelay = Chipset.t2; // timer value for delay
|
||||
}
|
||||
else // called without new refpoint, restart t2 with actual value
|
||||
{
|
||||
uDelay = CalcT2(); // actual timer value for delay
|
||||
}
|
||||
if ((bOutRange = uDelay > uT2MaxTicks)) // delay greater maximum delay
|
||||
uDelay = uT2MaxTicks; // wait maximum delay time
|
||||
uDelay = (uDelay * 125 + 1023) / 1024; // timer delay in ms (1000/8192 = 125/1024)
|
||||
uDelay = __max(tc.wPeriodMin,uDelay); // wait minimum delay of timer
|
||||
_ASSERT(uDelay <= tc.wPeriodMax); // inside maximum event delay
|
||||
// start timer2; schedule event, when Chipset.t2 will be zero
|
||||
VERIFY(uT2TimerId = timeSetEvent(uDelay,0,&TimeProc,2,TIME_ONESHOT));
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID AbortT2(VOID)
|
||||
{
|
||||
_ASSERT(uT2TimerId);
|
||||
timeKillEvent(uT2TimerId); // kill event
|
||||
uT2TimerId = 0; // then reset var
|
||||
return;
|
||||
}
|
||||
|
||||
static void CALLBACK TimeProc(UINT uEventId, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||
{
|
||||
if (uEventId == 0) return; // illegal EventId
|
||||
|
||||
if (uEventId == uT1TimerId) // called from timer1 event (default period 16 Hz)
|
||||
{
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
Chipset.t1 = (Chipset.t1-1)&0xF;// decrement timer value
|
||||
CheckT1(Chipset.t1); // test timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
return;
|
||||
}
|
||||
if (uEventId == uT2TimerId) // called from timer2 event, Chipset.t2 should be zero
|
||||
{
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
uT2TimerId = 0; // single shot timer timer2 stopped
|
||||
if (!bOutRange) // timer event elapsed
|
||||
{
|
||||
// timer2 overrun, test timer2 control bits else restart timer2
|
||||
Chipset.t2 = CalcT2(); // calculate new timer2 value
|
||||
CheckT2(Chipset.t2); // test timer2 control bits
|
||||
}
|
||||
RescheduleT2(!bOutRange); // restart timer2
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
UNREFERENCED_PARAMETER(uMsg);
|
||||
UNREFERENCED_PARAMETER(dwUser);
|
||||
UNREFERENCED_PARAMETER(dw1);
|
||||
UNREFERENCED_PARAMETER(dw2);
|
||||
}
|
||||
|
||||
VOID SetHP48Time(VOID) // set date and time
|
||||
{
|
||||
SYSTEMTIME ts;
|
||||
ULONGLONG ticks, time;
|
||||
DWORD dw;
|
||||
WORD crc, i;
|
||||
LPBYTE pbyTime;
|
||||
|
||||
_ASSERT(sizeof(ULONGLONG) == 8); // check size of datatype
|
||||
|
||||
GetLocalTime(&ts); // local time, _ftime() cause memory/resource leaks
|
||||
|
||||
// calculate days until 01.01.0000 (Erlang BIF localtime/0)
|
||||
dw = (DWORD) ts.wMonth;
|
||||
if (dw > 2)
|
||||
dw -= 3L;
|
||||
else
|
||||
{
|
||||
dw += 9L;
|
||||
--ts.wYear;
|
||||
}
|
||||
dw = (DWORD) ts.wDay + (153L * dw + 2L) / 5L;
|
||||
dw += (146097L * (((DWORD) ts.wYear) / 100L)) / 4L;
|
||||
dw += (1461L * (((DWORD) ts.wYear) % 100L)) / 4L;
|
||||
dw += (-719469L + 719528L); // days from year 0
|
||||
|
||||
ticks = (ULONGLONG) dw; // convert to 64 bit
|
||||
|
||||
// convert into seconds and add time
|
||||
ticks = ticks * 24L + (ULONGLONG) ts.wHour;
|
||||
ticks = ticks * 60L + (ULONGLONG) ts.wMinute;
|
||||
ticks = ticks * 60L + (ULONGLONG) ts.wSecond;
|
||||
|
||||
// create timerticks = (s + ms) * 8192
|
||||
ticks = (ticks << 13) | (((ULONGLONG) ts.wMilliseconds << 10) / 125);
|
||||
|
||||
ticks += Chipset.t2; // add actual timer2 value
|
||||
|
||||
time = ticks; // save for calc. timeout
|
||||
time += OFF_TIME; // add 10 min for auto off
|
||||
|
||||
pbyTime = Port0 + RPLTIME; // HP addresses for clock in port0
|
||||
|
||||
crc = 0x0; // reset crc value
|
||||
for (i = 0; i < 13; ++i) // write date and time
|
||||
{
|
||||
*pbyTime = (BYTE) ticks & 0xf; // time
|
||||
crc = UpCRC(crc,*pbyTime);
|
||||
ticks >>= 4;
|
||||
|
||||
pbyTime[13+4] = (BYTE) time & 0xf; // auto off
|
||||
time >>= 4;
|
||||
++pbyTime;
|
||||
}
|
||||
|
||||
Nunpack(pbyTime,crc,4); // write crc
|
||||
|
||||
pbyTime[13+4] = 0xf;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StartTimers(VOID)
|
||||
{
|
||||
if (bStarted) // timer running
|
||||
return; // -> quit
|
||||
if (Chipset.IORam[TIMER2_CTRL]&RUN) // start timer1 and timer2 ?
|
||||
{
|
||||
bStarted = TRUE; // flag timer running
|
||||
// initialisation of NINT2 lines
|
||||
bNINT2T1 = (Chipset.IORam[TIMER1_CTRL]&INTR) != 0 && (Chipset.t1 & 8) != 0;
|
||||
bNINT2T2 = (Chipset.IORam[TIMER2_CTRL]&INTR) != 0 && (Chipset.t2 & 0x80000000) != 0;
|
||||
timeGetDevCaps(&tc,sizeof(tc)); // get timer resolution
|
||||
|
||||
// max. timer2 ticks that can be handled by one timer event
|
||||
uT2MaxTicks = __min((0xFFFFFFFF / 1024),tc.wPeriodMax);
|
||||
uT2MaxTicks = __min((0xFFFFFFFF - 1023) / 125,uT2MaxTicks * 1024 / 125);
|
||||
|
||||
CheckT1(Chipset.t1); // check for timer1 interrupts
|
||||
CheckT2(Chipset.t2); // check for timer2 interrupts
|
||||
// set timer resolution to greatest possible one
|
||||
bAccurateTimer = (timeBeginPeriod(tc.wPeriodMin) == TIMERR_NOERROR);
|
||||
// set timer1 with given period
|
||||
VERIFY(uT1TimerId = timeSetEvent(T1_FREQ,0,&TimeProc,1,TIME_PERIODIC));
|
||||
RescheduleT2(TRUE); // start timer2
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID StopTimers(VOID)
|
||||
{
|
||||
if (!bStarted) // timer stopped
|
||||
return; // -> quit
|
||||
if (uT1TimerId != 0) // timer1 running
|
||||
{
|
||||
// Critical Section handler may cause a dead lock
|
||||
timeKillEvent(uT1TimerId); // stop timer1
|
||||
uT1TimerId = 0; // set flag timer1 stopped
|
||||
}
|
||||
if (uT2TimerId != 0) // timer2 running
|
||||
{
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
Chipset.t2 = CalcT2(); // update chipset timer2 value
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
AbortT2(); // stop timer2 outside critical section
|
||||
}
|
||||
bStarted = FALSE;
|
||||
if (bAccurateTimer) // "Accurate timer" running
|
||||
{
|
||||
timeEndPeriod(tc.wPeriodMin); // finish service
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD ReadT2(VOID)
|
||||
{
|
||||
DWORD dwT2;
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
dwT2 = CalcT2(); // calculate timer2 value or if stopped last timer value
|
||||
CheckT2(dwT2); // update timer2 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return dwT2;
|
||||
}
|
||||
|
||||
VOID SetT2(DWORD dwValue)
|
||||
{
|
||||
// calling AbortT2() inside Critical Section handler may cause a dead lock
|
||||
if (uT2TimerId != 0) // timer2 running
|
||||
AbortT2(); // stop timer2
|
||||
EnterCriticalSection(&csT2Lock);
|
||||
{
|
||||
Chipset.t2 = dwValue; // set new value
|
||||
CheckT2(Chipset.t2); // test timer2 control bits
|
||||
if (bStarted) // timer running
|
||||
RescheduleT2(TRUE); // restart timer2
|
||||
}
|
||||
LeaveCriticalSection(&csT2Lock);
|
||||
return;
|
||||
}
|
||||
|
||||
BYTE ReadT1(VOID)
|
||||
{
|
||||
BYTE nT1;
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
nT1 = Chipset.t1; // read timer1 value
|
||||
CheckT1(nT1); // update timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
return nT1;
|
||||
}
|
||||
|
||||
VOID SetT1(BYTE byValue)
|
||||
{
|
||||
BOOL bEqual;
|
||||
|
||||
_ASSERT(byValue < 0x10); // timer1 is only a 4bit counter
|
||||
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
bEqual = (Chipset.t1 == byValue); // check for same value
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
if (bEqual) return; // same value doesn't restart timer period
|
||||
|
||||
if (uT1TimerId != 0) // timer1 running
|
||||
{
|
||||
timeKillEvent(uT1TimerId); // stop timer1
|
||||
uT1TimerId = 0; // set flag timer1 stopped
|
||||
}
|
||||
EnterCriticalSection(&csT1Lock);
|
||||
{
|
||||
Chipset.t1 = byValue; // set new timer1 value
|
||||
CheckT1(Chipset.t1); // test timer1 control bits
|
||||
}
|
||||
LeaveCriticalSection(&csT1Lock);
|
||||
if (bStarted) // timer running
|
||||
{
|
||||
// restart timer1 to get full period of frequency
|
||||
VERIFY(uT1TimerId = timeSetEvent(T1_FREQ,0,&TimeProc,1,TIME_PERIODIC));
|
||||
}
|
||||
return;
|
||||
}
|
|
@ -1,103 +1,103 @@
|
|||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
DWORD dwUnused0; // not used, was memory pointer Port0
|
||||
DWORD dwUnused1; // not used, was memory pointer Port1
|
||||
DWORD dwUnused2; // not used, was memory pointer Port2
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon; // not used
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
||||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
DWORD dwUnused0; // not used, was memory pointer Port0
|
||||
DWORD dwUnused1; // not used, was memory pointer Port1
|
||||
DWORD dwUnused2; // not used, was memory pointer Port2
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon; // not used
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
|
@ -1,78 +1,73 @@
|
|||
/*
|
||||
* udp.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2011 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "emu48.h"
|
||||
|
||||
TCHAR szUdpServer[1024] = _T("localhost");
|
||||
WORD wUdpPort = 5025; // scpi-raw
|
||||
|
||||
static SOCKADDR_IN sServer = { AF_INET, 0, { 255, 255, 255, 255 } };
|
||||
|
||||
VOID ResetUdp(VOID)
|
||||
{
|
||||
sServer.sin_addr.s_addr = INADDR_NONE; // invalidate saved UDP address
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL SendByteUdp(BYTE byData)
|
||||
{
|
||||
WSADATA wsd;
|
||||
SOCKET sClient;
|
||||
|
||||
BOOL bErr = TRUE;
|
||||
|
||||
VERIFY(WSAStartup(MAKEWORD(1,1),&wsd) == 0);
|
||||
|
||||
// IP address not specified
|
||||
if (sServer.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
LPSTR lpszIpAddr;
|
||||
|
||||
#if defined _UNICODE
|
||||
DWORD dwLength = lstrlen(szUdpServer) + 1;
|
||||
|
||||
if ((lpszIpAddr = (LPSTR) _alloca(dwLength)) == NULL)
|
||||
return TRUE; // server ip address not found
|
||||
|
||||
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
|
||||
szUdpServer, dwLength,
|
||||
lpszIpAddr, dwLength, NULL, NULL);
|
||||
#else
|
||||
lpszIpAddr = szUdpServer;
|
||||
#endif
|
||||
|
||||
// try to interpret string as IPv4 address
|
||||
sServer.sin_addr.s_addr = inet_addr(lpszIpAddr);
|
||||
|
||||
// not a valid ip address -> try to get ip address from name server
|
||||
if (sServer.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
PHOSTENT host = gethostbyname(lpszIpAddr);
|
||||
if (host == NULL)
|
||||
{
|
||||
return TRUE; // server ip address not found
|
||||
}
|
||||
|
||||
sServer.sin_addr.s_addr = ((PIN_ADDR) host->h_addr_list[0])->s_addr;
|
||||
}
|
||||
}
|
||||
|
||||
// create UDP socket
|
||||
if ((sClient = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET)
|
||||
{
|
||||
sServer.sin_port = htons(wUdpPort);
|
||||
|
||||
// transmit data byte
|
||||
bErr = sendto(sClient, (LPCCH) &byData, sizeof(byData), 0, (LPSOCKADDR) &sServer, sizeof(sServer)) == SOCKET_ERROR;
|
||||
closesocket(sClient);
|
||||
}
|
||||
|
||||
WSACleanup(); // cleanup network stack
|
||||
return bErr;
|
||||
}
|
||||
/*
|
||||
* udp.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 2011 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "Emu48.h"
|
||||
|
||||
TCHAR szUdpServer[1024] = _T("localhost");
|
||||
WORD wUdpPort = 5025; // scpi-raw
|
||||
|
||||
static SOCKADDR_IN sServer = { AF_INET, 0, { 255, 255, 255, 255 } };
|
||||
|
||||
VOID ResetUdp(VOID)
|
||||
{
|
||||
sServer.sin_addr.s_addr = INADDR_NONE; // invalidate saved UDP address
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL SendByteUdp(BYTE byData)
|
||||
{
|
||||
SOCKET sClient;
|
||||
|
||||
BOOL bErr = TRUE;
|
||||
|
||||
// IP address not specified
|
||||
if (sServer.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
LPSTR lpszIpAddr;
|
||||
|
||||
#if defined _UNICODE
|
||||
DWORD dwLength = lstrlen(szUdpServer) + 1;
|
||||
|
||||
if ((lpszIpAddr = (LPSTR) _alloca(dwLength)) == NULL)
|
||||
return TRUE; // server ip address not found
|
||||
|
||||
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
|
||||
szUdpServer, dwLength,
|
||||
lpszIpAddr, dwLength, NULL, NULL);
|
||||
#else
|
||||
lpszIpAddr = szUdpServer;
|
||||
#endif
|
||||
|
||||
// try to interpret string as IPv4 address
|
||||
sServer.sin_addr.s_addr = inet_addr(lpszIpAddr);
|
||||
|
||||
// not a valid ip address -> try to get ip address from name server
|
||||
if (sServer.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
PHOSTENT host = gethostbyname(lpszIpAddr);
|
||||
if (host == NULL)
|
||||
{
|
||||
return TRUE; // server ip address not found
|
||||
}
|
||||
|
||||
sServer.sin_addr.s_addr = ((PIN_ADDR) host->h_addr_list[0])->s_addr;
|
||||
}
|
||||
}
|
||||
|
||||
// create UDP socket
|
||||
if ((sClient = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET)
|
||||
{
|
||||
sServer.sin_port = htons(wUdpPort);
|
||||
|
||||
// transmit data byte
|
||||
bErr = sendto(sClient, (LPCCH) &byData, sizeof(byData), 0, (LPSOCKADDR) &sServer, sizeof(sServer)) == SOCKET_ERROR;
|
||||
closesocket(sClient);
|
||||
}
|
||||
return bErr;
|
||||
}
|
|
@ -1,778 +0,0 @@
|
|||
/*
|
||||
* fetch.c
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1999 Christoph Gießelink
|
||||
*
|
||||
*/
|
||||
#include "pch.h"
|
||||
#include "opcodes.h"
|
||||
|
||||
#define F 0xFF // F = function
|
||||
|
||||
typedef const struct
|
||||
{
|
||||
LPCVOID pLnk;
|
||||
const DWORD dwTyp;
|
||||
} JMPTAB, *PJMPTAB;
|
||||
|
||||
// jump tables
|
||||
static JMPTAB oF_[] =
|
||||
{
|
||||
(LPCVOID) oF0, F,
|
||||
(LPCVOID) oF1, F,
|
||||
(LPCVOID) oF2, F,
|
||||
(LPCVOID) oF3, F,
|
||||
(LPCVOID) oF4, F,
|
||||
(LPCVOID) oF5, F,
|
||||
(LPCVOID) oF6, F,
|
||||
(LPCVOID) oF7, F,
|
||||
(LPCVOID) oF8, F,
|
||||
(LPCVOID) oF9, F,
|
||||
(LPCVOID) oFA, F,
|
||||
(LPCVOID) oFB, F,
|
||||
(LPCVOID) oFC, F,
|
||||
(LPCVOID) oFD, F,
|
||||
(LPCVOID) oFE, F,
|
||||
(LPCVOID) oFF, F
|
||||
};
|
||||
|
||||
static JMPTAB oE_[] =
|
||||
{
|
||||
(LPCVOID) oE0, F,
|
||||
(LPCVOID) oE1, F,
|
||||
(LPCVOID) oE2, F,
|
||||
(LPCVOID) oE3, F,
|
||||
(LPCVOID) oE4, F,
|
||||
(LPCVOID) oE5, F,
|
||||
(LPCVOID) oE6, F,
|
||||
(LPCVOID) oE7, F,
|
||||
(LPCVOID) oE8, F,
|
||||
(LPCVOID) oE9, F,
|
||||
(LPCVOID) oEA, F,
|
||||
(LPCVOID) oEB, F,
|
||||
(LPCVOID) oEC, F,
|
||||
(LPCVOID) oED, F,
|
||||
(LPCVOID) oEE, F,
|
||||
(LPCVOID) oEF, F
|
||||
};
|
||||
|
||||
static JMPTAB oD_[] =
|
||||
{
|
||||
(LPCVOID) oD0, F,
|
||||
(LPCVOID) oD1, F,
|
||||
(LPCVOID) oD2, F,
|
||||
(LPCVOID) oD3, F,
|
||||
(LPCVOID) oD4, F,
|
||||
(LPCVOID) oD5, F,
|
||||
(LPCVOID) oD6, F,
|
||||
(LPCVOID) oD7, F,
|
||||
(LPCVOID) oD8, F,
|
||||
(LPCVOID) oD9, F,
|
||||
(LPCVOID) oDA, F,
|
||||
(LPCVOID) oDB, F,
|
||||
(LPCVOID) oDC, F,
|
||||
(LPCVOID) oDD, F,
|
||||
(LPCVOID) oDE, F,
|
||||
(LPCVOID) oDF, F
|
||||
};
|
||||
|
||||
static JMPTAB oC_[] =
|
||||
{
|
||||
(LPCVOID) oC0, F,
|
||||
(LPCVOID) oC1, F,
|
||||
(LPCVOID) oC2, F,
|
||||
(LPCVOID) oC3, F,
|
||||
(LPCVOID) oC4, F,
|
||||
(LPCVOID) oC5, F,
|
||||
(LPCVOID) oC6, F,
|
||||
(LPCVOID) oC7, F,
|
||||
(LPCVOID) oC8, F,
|
||||
(LPCVOID) oC9, F,
|
||||
(LPCVOID) oCA, F,
|
||||
(LPCVOID) oCB, F,
|
||||
(LPCVOID) oCC, F,
|
||||
(LPCVOID) oCD, F,
|
||||
(LPCVOID) oCE, F,
|
||||
(LPCVOID) oCF, F
|
||||
};
|
||||
|
||||
static JMPTAB oBb_[] =
|
||||
{
|
||||
(LPCVOID) oBb0, F,
|
||||
(LPCVOID) oBb1, F,
|
||||
(LPCVOID) oBb2, F,
|
||||
(LPCVOID) oBb3, F,
|
||||
(LPCVOID) oBb4, F,
|
||||
(LPCVOID) oBb5, F,
|
||||
(LPCVOID) oBb6, F,
|
||||
(LPCVOID) oBb7, F,
|
||||
(LPCVOID) oBb8, F,
|
||||
(LPCVOID) oBb9, F,
|
||||
(LPCVOID) oBbA, F,
|
||||
(LPCVOID) oBbB, F,
|
||||
(LPCVOID) oBbC, F,
|
||||
(LPCVOID) oBbD, F,
|
||||
(LPCVOID) oBbE, F,
|
||||
(LPCVOID) oBbF, F
|
||||
};
|
||||
|
||||
static JMPTAB oBa_[] =
|
||||
{
|
||||
(LPCVOID) oBa0, F,
|
||||
(LPCVOID) oBa1, F,
|
||||
(LPCVOID) oBa2, F,
|
||||
(LPCVOID) oBa3, F,
|
||||
(LPCVOID) oBa4, F,
|
||||
(LPCVOID) oBa5, F,
|
||||
(LPCVOID) oBa6, F,
|
||||
(LPCVOID) oBa7, F,
|
||||
(LPCVOID) oBa8, F,
|
||||
(LPCVOID) oBa9, F,
|
||||
(LPCVOID) oBaA, F,
|
||||
(LPCVOID) oBaB, F,
|
||||
(LPCVOID) oBaC, F,
|
||||
(LPCVOID) oBaD, F,
|
||||
(LPCVOID) oBaE, F,
|
||||
(LPCVOID) oBaF, F
|
||||
};
|
||||
|
||||
static JMPTAB oB_[] =
|
||||
{
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBa_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2,
|
||||
(LPCVOID) oBb_, 2
|
||||
};
|
||||
|
||||
static JMPTAB oAb_[] =
|
||||
{
|
||||
(LPCVOID) oAb0, F,
|
||||
(LPCVOID) oAb1, F,
|
||||
(LPCVOID) oAb2, F,
|
||||
(LPCVOID) oAb3, F,
|
||||
(LPCVOID) oAb4, F,
|
||||
(LPCVOID) oAb5, F,
|
||||
(LPCVOID) oAb6, F,
|
||||
(LPCVOID) oAb7, F,
|
||||
(LPCVOID) oAb8, F,
|
||||
(LPCVOID) oAb9, F,
|
||||
(LPCVOID) oAbA, F,
|
||||
(LPCVOID) oAbB, F,
|
||||
(LPCVOID) oAbC, F,
|
||||
(LPCVOID) oAbD, F,
|
||||
(LPCVOID) oAbE, F,
|
||||
(LPCVOID) oAbF, F
|
||||
};
|
||||
|
||||
static JMPTAB oAa_[] =
|
||||
{
|
||||
(LPCVOID) oAa0, F,
|
||||
(LPCVOID) oAa1, F,
|
||||
(LPCVOID) oAa2, F,
|
||||
(LPCVOID) oAa3, F,
|
||||
(LPCVOID) oAa4, F,
|
||||
(LPCVOID) oAa5, F,
|
||||
(LPCVOID) oAa6, F,
|
||||
(LPCVOID) oAa7, F,
|
||||
(LPCVOID) oAa8, F,
|
||||
(LPCVOID) oAa9, F,
|
||||
(LPCVOID) oAaA, F,
|
||||
(LPCVOID) oAaB, F,
|
||||
(LPCVOID) oAaC, F,
|
||||
(LPCVOID) oAaD, F,
|
||||
(LPCVOID) oAaE, F,
|
||||
(LPCVOID) oAaF, F
|
||||
};
|
||||
|
||||
static JMPTAB oA_[] =
|
||||
{
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAa_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2,
|
||||
(LPCVOID) oAb_, 2
|
||||
};
|
||||
|
||||
static JMPTAB o9b_[] =
|
||||
{
|
||||
(LPCVOID) o9b0, F,
|
||||
(LPCVOID) o9b1, F,
|
||||
(LPCVOID) o9b2, F,
|
||||
(LPCVOID) o9b3, F,
|
||||
(LPCVOID) o9b4, F,
|
||||
(LPCVOID) o9b5, F,
|
||||
(LPCVOID) o9b6, F,
|
||||
(LPCVOID) o9b7, F,
|
||||
(LPCVOID) o9b8, F,
|
||||
(LPCVOID) o9b9, F,
|
||||
(LPCVOID) o9bA, F,
|
||||
(LPCVOID) o9bB, F,
|
||||
(LPCVOID) o9bC, F,
|
||||
(LPCVOID) o9bD, F,
|
||||
(LPCVOID) o9bE, F,
|
||||
(LPCVOID) o9bF, F
|
||||
};
|
||||
|
||||
static JMPTAB o9a_[] =
|
||||
{
|
||||
(LPCVOID) o9a0, F,
|
||||
(LPCVOID) o9a1, F,
|
||||
(LPCVOID) o9a2, F,
|
||||
(LPCVOID) o9a3, F,
|
||||
(LPCVOID) o9a4, F,
|
||||
(LPCVOID) o9a5, F,
|
||||
(LPCVOID) o9a6, F,
|
||||
(LPCVOID) o9a7, F,
|
||||
(LPCVOID) o9a8, F,
|
||||
(LPCVOID) o9a9, F,
|
||||
(LPCVOID) o9aA, F,
|
||||
(LPCVOID) o9aB, F,
|
||||
(LPCVOID) o9aC, F,
|
||||
(LPCVOID) o9aD, F,
|
||||
(LPCVOID) o9aE, F,
|
||||
(LPCVOID) o9aF, F
|
||||
};
|
||||
|
||||
static JMPTAB o9_[] =
|
||||
{
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9a_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2,
|
||||
(LPCVOID) o9b_, 2
|
||||
};
|
||||
|
||||
static JMPTAB o8B_[] =
|
||||
{
|
||||
(LPCVOID) o8B0, F,
|
||||
(LPCVOID) o8B1, F,
|
||||
(LPCVOID) o8B2, F,
|
||||
(LPCVOID) o8B3, F,
|
||||
(LPCVOID) o8B4, F,
|
||||
(LPCVOID) o8B5, F,
|
||||
(LPCVOID) o8B6, F,
|
||||
(LPCVOID) o8B7, F,
|
||||
(LPCVOID) o8B8, F,
|
||||
(LPCVOID) o8B9, F,
|
||||
(LPCVOID) o8BA, F,
|
||||
(LPCVOID) o8BB, F,
|
||||
(LPCVOID) o8BC, F,
|
||||
(LPCVOID) o8BD, F,
|
||||
(LPCVOID) o8BE, F,
|
||||
(LPCVOID) o8BF, F
|
||||
};
|
||||
|
||||
static JMPTAB o8A_[] =
|
||||
{
|
||||
(LPCVOID) o8A0, F,
|
||||
(LPCVOID) o8A1, F,
|
||||
(LPCVOID) o8A2, F,
|
||||
(LPCVOID) o8A3, F,
|
||||
(LPCVOID) o8A4, F,
|
||||
(LPCVOID) o8A5, F,
|
||||
(LPCVOID) o8A6, F,
|
||||
(LPCVOID) o8A7, F,
|
||||
(LPCVOID) o8A8, F,
|
||||
(LPCVOID) o8A9, F,
|
||||
(LPCVOID) o8AA, F,
|
||||
(LPCVOID) o8AB, F,
|
||||
(LPCVOID) o8AC, F,
|
||||
(LPCVOID) o8AD, F,
|
||||
(LPCVOID) o8AE, F,
|
||||
(LPCVOID) o8AF, F
|
||||
};
|
||||
|
||||
static JMPTAB o81B_[] =
|
||||
{
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o81B2, F,
|
||||
(LPCVOID) o81B3, F,
|
||||
(LPCVOID) o81B4, F,
|
||||
(LPCVOID) o81B5, F,
|
||||
(LPCVOID) o81B6, F,
|
||||
(LPCVOID) o81B7, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F,
|
||||
(LPCVOID) o_invalid4, F
|
||||
};
|
||||
|
||||
static JMPTAB o81Af2_[] =
|
||||
{
|
||||
(LPCVOID) o81Af20, F,
|
||||
(LPCVOID) o81Af21, F,
|
||||
(LPCVOID) o81Af22, F,
|
||||
(LPCVOID) o81Af23, F,
|
||||
(LPCVOID) o81Af24, F,
|
||||
(LPCVOID) o81Af21, F,
|
||||
(LPCVOID) o81Af22, F,
|
||||
(LPCVOID) o81Af23, F,
|
||||
(LPCVOID) o81Af28, F,
|
||||
(LPCVOID) o81Af29, F,
|
||||
(LPCVOID) o81Af2A, F,
|
||||
(LPCVOID) o81Af2B, F,
|
||||
(LPCVOID) o81Af2C, F,
|
||||
(LPCVOID) o81Af29, F,
|
||||
(LPCVOID) o81Af2A, F,
|
||||
(LPCVOID) o81Af2B, F
|
||||
};
|
||||
|
||||
static JMPTAB o81Af1_[] =
|
||||
{
|
||||
(LPCVOID) o81Af10, F,
|
||||
(LPCVOID) o81Af11, F,
|
||||
(LPCVOID) o81Af12, F,
|
||||
(LPCVOID) o81Af13, F,
|
||||
(LPCVOID) o81Af14, F,
|
||||
(LPCVOID) o81Af11, F,
|
||||
(LPCVOID) o81Af12, F,
|
||||
(LPCVOID) o81Af13, F,
|
||||
(LPCVOID) o81Af18, F,
|
||||
(LPCVOID) o81Af19, F,
|
||||
(LPCVOID) o81Af1A, F,
|
||||
(LPCVOID) o81Af1B, F,
|
||||
(LPCVOID) o81Af1C, F,
|
||||
(LPCVOID) o81Af19, F,
|
||||
(LPCVOID) o81Af1A, F,
|
||||
(LPCVOID) o81Af1B, F
|
||||
};
|
||||
|
||||
static JMPTAB o81Af0_[] =
|
||||
{
|
||||
(LPCVOID) o81Af00, F,
|
||||
(LPCVOID) o81Af01, F,
|
||||
(LPCVOID) o81Af02, F,
|
||||
(LPCVOID) o81Af03, F,
|
||||
(LPCVOID) o81Af04, F,
|
||||
(LPCVOID) o81Af01, F,
|
||||
(LPCVOID) o81Af02, F,
|
||||
(LPCVOID) o81Af03, F,
|
||||
(LPCVOID) o81Af08, F,
|
||||
(LPCVOID) o81Af09, F,
|
||||
(LPCVOID) o81Af0A, F,
|
||||
(LPCVOID) o81Af0B, F,
|
||||
(LPCVOID) o81Af0C, F,
|
||||
(LPCVOID) o81Af09, F,
|
||||
(LPCVOID) o81Af0A, F,
|
||||
(LPCVOID) o81Af0B, F
|
||||
};
|
||||
|
||||
static JMPTAB o81A_[] =
|
||||
{
|
||||
(LPCVOID) o81Af0_, 5,
|
||||
(LPCVOID) o81Af1_, 5,
|
||||
(LPCVOID) o81Af2_, 5,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F
|
||||
};
|
||||
|
||||
static JMPTAB o819_[] =
|
||||
{
|
||||
(LPCVOID) o819f0, F,
|
||||
(LPCVOID) o819f1, F,
|
||||
(LPCVOID) o819f2, F,
|
||||
(LPCVOID) o819f3, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F
|
||||
};
|
||||
|
||||
static JMPTAB o818_[] =
|
||||
{
|
||||
(LPCVOID) o818f0x, F,
|
||||
(LPCVOID) o818f1x, F,
|
||||
(LPCVOID) o818f2x, F,
|
||||
(LPCVOID) o818f3x, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o818f8x, F,
|
||||
(LPCVOID) o818f9x, F,
|
||||
(LPCVOID) o818fAx, F,
|
||||
(LPCVOID) o818fBx, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F,
|
||||
(LPCVOID) o_invalid6, F
|
||||
};
|
||||
|
||||
static JMPTAB o81_[] =
|
||||
{
|
||||
(LPCVOID) o810, F,
|
||||
(LPCVOID) o811, F,
|
||||
(LPCVOID) o812, F,
|
||||
(LPCVOID) o813, F,
|
||||
(LPCVOID) o814, F,
|
||||
(LPCVOID) o815, F,
|
||||
(LPCVOID) o816, F,
|
||||
(LPCVOID) o817, F,
|
||||
(LPCVOID) o818_, 4,
|
||||
(LPCVOID) o819_, 4,
|
||||
(LPCVOID) o81A_, 4,
|
||||
(LPCVOID) o81B_, 3,
|
||||
(LPCVOID) o81C, F,
|
||||
(LPCVOID) o81D, F,
|
||||
(LPCVOID) o81E, F,
|
||||
(LPCVOID) o81F, F
|
||||
};
|
||||
|
||||
static JMPTAB o8081_[] =
|
||||
{
|
||||
(LPCVOID) o80810, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F,
|
||||
(LPCVOID) o_invalid5, F
|
||||
};
|
||||
|
||||
static JMPTAB o808_[] =
|
||||
{
|
||||
(LPCVOID) o8080, F,
|
||||
(LPCVOID) o8081_, 4,
|
||||
(LPCVOID) o8082X, F,
|
||||
(LPCVOID) o8083, F,
|
||||
(LPCVOID) o8084n, F,
|
||||
(LPCVOID) o8085n, F,
|
||||
(LPCVOID) o8086n, F,
|
||||
(LPCVOID) o8087n, F,
|
||||
(LPCVOID) o8088n, F,
|
||||
(LPCVOID) o8089n, F,
|
||||
(LPCVOID) o808An, F,
|
||||
(LPCVOID) o808Bn, F,
|
||||
(LPCVOID) o808C, F,
|
||||
(LPCVOID) o808D, F,
|
||||
(LPCVOID) o808E, F,
|
||||
(LPCVOID) o808F, F
|
||||
};
|
||||
|
||||
static JMPTAB o80_[] =
|
||||
{
|
||||
(LPCVOID) o800, F,
|
||||
(LPCVOID) o801, F,
|
||||
(LPCVOID) o802, F,
|
||||
(LPCVOID) o803, F,
|
||||
(LPCVOID) o804, F,
|
||||
(LPCVOID) o805, F,
|
||||
(LPCVOID) o806, F,
|
||||
(LPCVOID) o807, F,
|
||||
(LPCVOID) o808_, 3,
|
||||
(LPCVOID) o809, F,
|
||||
(LPCVOID) o80A, F,
|
||||
(LPCVOID) o80B, F,
|
||||
(LPCVOID) o80Cn, F,
|
||||
(LPCVOID) o80Dn, F,
|
||||
(LPCVOID) o80E, F,
|
||||
(LPCVOID) o80Fn, F
|
||||
};
|
||||
|
||||
static JMPTAB o8_[] =
|
||||
{
|
||||
(LPCVOID) o80_, 2,
|
||||
(LPCVOID) o81_, 2,
|
||||
(LPCVOID) o82n, F,
|
||||
(LPCVOID) o83n, F,
|
||||
(LPCVOID) o84n, F,
|
||||
(LPCVOID) o85n, F,
|
||||
(LPCVOID) o86n, F,
|
||||
(LPCVOID) o87n, F,
|
||||
(LPCVOID) o88n, F,
|
||||
(LPCVOID) o89n, F,
|
||||
(LPCVOID) o8A_, 2,
|
||||
(LPCVOID) o8B_, 2,
|
||||
(LPCVOID) o8Cd4, F,
|
||||
(LPCVOID) o8Dd5, F,
|
||||
(LPCVOID) o8Ed4, F,
|
||||
(LPCVOID) o8Fd5, F
|
||||
};
|
||||
|
||||
static JMPTAB o15_[] =
|
||||
{
|
||||
(LPCVOID) o150a, F,
|
||||
(LPCVOID) o151a, F,
|
||||
(LPCVOID) o152a, F,
|
||||
(LPCVOID) o153a, F,
|
||||
(LPCVOID) o154a, F,
|
||||
(LPCVOID) o155a, F,
|
||||
(LPCVOID) o156a, F,
|
||||
(LPCVOID) o157a, F,
|
||||
(LPCVOID) o158x, F,
|
||||
(LPCVOID) o159x, F,
|
||||
(LPCVOID) o15Ax, F,
|
||||
(LPCVOID) o15Bx, F,
|
||||
(LPCVOID) o15Cx, F,
|
||||
(LPCVOID) o15Dx, F,
|
||||
(LPCVOID) o15Ex, F,
|
||||
(LPCVOID) o15Fx, F
|
||||
};
|
||||
|
||||
static JMPTAB o14_[] =
|
||||
{
|
||||
(LPCVOID) o140, F,
|
||||
(LPCVOID) o141, F,
|
||||
(LPCVOID) o142, F,
|
||||
(LPCVOID) o143, F,
|
||||
(LPCVOID) o144, F,
|
||||
(LPCVOID) o145, F,
|
||||
(LPCVOID) o146, F,
|
||||
(LPCVOID) o147, F,
|
||||
(LPCVOID) o148, F,
|
||||
(LPCVOID) o149, F,
|
||||
(LPCVOID) o14A, F,
|
||||
(LPCVOID) o14B, F,
|
||||
(LPCVOID) o14C, F,
|
||||
(LPCVOID) o14D, F,
|
||||
(LPCVOID) o14E, F,
|
||||
(LPCVOID) o14F, F
|
||||
};
|
||||
|
||||
static JMPTAB o13_[] =
|
||||
{
|
||||
(LPCVOID) o130, F,
|
||||
(LPCVOID) o131, F,
|
||||
(LPCVOID) o132, F,
|
||||
(LPCVOID) o133, F,
|
||||
(LPCVOID) o134, F,
|
||||
(LPCVOID) o135, F,
|
||||
(LPCVOID) o136, F,
|
||||
(LPCVOID) o137, F,
|
||||
(LPCVOID) o138, F,
|
||||
(LPCVOID) o139, F,
|
||||
(LPCVOID) o13A, F,
|
||||
(LPCVOID) o13B, F,
|
||||
(LPCVOID) o13C, F,
|
||||
(LPCVOID) o13D, F,
|
||||
(LPCVOID) o13E, F,
|
||||
(LPCVOID) o13F, F
|
||||
};
|
||||
|
||||
static JMPTAB o12_[] =
|
||||
{
|
||||
(LPCVOID) o120, F,
|
||||
(LPCVOID) o121, F,
|
||||
(LPCVOID) o122, F,
|
||||
(LPCVOID) o123, F,
|
||||
(LPCVOID) o124, F,
|
||||
(LPCVOID) o121, F,
|
||||
(LPCVOID) o122, F,
|
||||
(LPCVOID) o123, F,
|
||||
(LPCVOID) o128, F,
|
||||
(LPCVOID) o129, F,
|
||||
(LPCVOID) o12A, F,
|
||||
(LPCVOID) o12B, F,
|
||||
(LPCVOID) o12C, F,
|
||||
(LPCVOID) o129, F,
|
||||
(LPCVOID) o12A, F,
|
||||
(LPCVOID) o12B, F
|
||||
};
|
||||
|
||||
static JMPTAB o11_[] =
|
||||
{
|
||||
(LPCVOID) o110, F,
|
||||
(LPCVOID) o111, F,
|
||||
(LPCVOID) o112, F,
|
||||
(LPCVOID) o113, F,
|
||||
(LPCVOID) o114, F,
|
||||
(LPCVOID) o111, F,
|
||||
(LPCVOID) o112, F,
|
||||
(LPCVOID) o113, F,
|
||||
(LPCVOID) o118, F,
|
||||
(LPCVOID) o119, F,
|
||||
(LPCVOID) o11A, F,
|
||||
(LPCVOID) o11B, F,
|
||||
(LPCVOID) o11C, F,
|
||||
(LPCVOID) o119, F,
|
||||
(LPCVOID) o11A, F,
|
||||
(LPCVOID) o11B, F
|
||||
};
|
||||
|
||||
static JMPTAB o10_[] =
|
||||
{
|
||||
(LPCVOID) o100, F,
|
||||
(LPCVOID) o101, F,
|
||||
(LPCVOID) o102, F,
|
||||
(LPCVOID) o103, F,
|
||||
(LPCVOID) o104, F,
|
||||
(LPCVOID) o101, F,
|
||||
(LPCVOID) o102, F,
|
||||
(LPCVOID) o103, F,
|
||||
(LPCVOID) o108, F,
|
||||
(LPCVOID) o109, F,
|
||||
(LPCVOID) o10A, F,
|
||||
(LPCVOID) o10B, F,
|
||||
(LPCVOID) o10C, F,
|
||||
(LPCVOID) o109, F,
|
||||
(LPCVOID) o10A, F,
|
||||
(LPCVOID) o10B, F
|
||||
};
|
||||
|
||||
static JMPTAB o1_[] =
|
||||
{
|
||||
(LPCVOID) o10_, 2,
|
||||
(LPCVOID) o11_, 2,
|
||||
(LPCVOID) o12_, 2,
|
||||
(LPCVOID) o13_, 2,
|
||||
(LPCVOID) o14_, 2,
|
||||
(LPCVOID) o15_, 2,
|
||||
(LPCVOID) o16x, F,
|
||||
(LPCVOID) o17x, F,
|
||||
(LPCVOID) o18x, F,
|
||||
(LPCVOID) o19d2, F,
|
||||
(LPCVOID) o1Ad4, F,
|
||||
(LPCVOID) o1Bd5, F,
|
||||
(LPCVOID) o1Cx, F,
|
||||
(LPCVOID) o1Dd2, F,
|
||||
(LPCVOID) o1Ed4, F,
|
||||
(LPCVOID) o1Fd5, F
|
||||
};
|
||||
|
||||
static JMPTAB o0E_[] =
|
||||
{
|
||||
(LPCVOID) o0Ef0, F,
|
||||
(LPCVOID) o0Ef1, F,
|
||||
(LPCVOID) o0Ef2, F,
|
||||
(LPCVOID) o0Ef3, F,
|
||||
(LPCVOID) o0Ef4, F,
|
||||
(LPCVOID) o0Ef5, F,
|
||||
(LPCVOID) o0Ef6, F,
|
||||
(LPCVOID) o0Ef7, F,
|
||||
(LPCVOID) o0Ef8, F,
|
||||
(LPCVOID) o0Ef9, F,
|
||||
(LPCVOID) o0EfA, F,
|
||||
(LPCVOID) o0EfB, F,
|
||||
(LPCVOID) o0EfC, F,
|
||||
(LPCVOID) o0EfD, F,
|
||||
(LPCVOID) o0EfE, F,
|
||||
(LPCVOID) o0EfF, F
|
||||
};
|
||||
|
||||
static JMPTAB o0_[] =
|
||||
{
|
||||
(LPCVOID) o00, F,
|
||||
(LPCVOID) o01, F,
|
||||
(LPCVOID) o02, F,
|
||||
(LPCVOID) o03, F,
|
||||
(LPCVOID) o04, F,
|
||||
(LPCVOID) o05, F,
|
||||
(LPCVOID) o06, F,
|
||||
(LPCVOID) o07, F,
|
||||
(LPCVOID) o08, F,
|
||||
(LPCVOID) o09, F,
|
||||
(LPCVOID) o0A, F,
|
||||
(LPCVOID) o0B, F,
|
||||
(LPCVOID) o0C, F,
|
||||
(LPCVOID) o0D, F,
|
||||
(LPCVOID) o0E_, 3,
|
||||
(LPCVOID) o0F, F
|
||||
};
|
||||
|
||||
static JMPTAB o_[] =
|
||||
{
|
||||
(LPCVOID) o0_, 1,
|
||||
(LPCVOID) o1_, 1,
|
||||
(LPCVOID) o2n, F,
|
||||
(LPCVOID) o3X, F,
|
||||
(LPCVOID) o4d2, F,
|
||||
(LPCVOID) o5d2, F,
|
||||
(LPCVOID) o6d3, F,
|
||||
(LPCVOID) o7d3, F,
|
||||
(LPCVOID) o8_, 1,
|
||||
(LPCVOID) o9_, 1,
|
||||
(LPCVOID) oA_, 1,
|
||||
(LPCVOID) oB_, 1,
|
||||
(LPCVOID) oC_, 1,
|
||||
(LPCVOID) oD_, 1,
|
||||
(LPCVOID) oE_, 1,
|
||||
(LPCVOID) oF_, 1
|
||||
};
|
||||
|
||||
// opcode dispatcher
|
||||
VOID EvalOpcode(LPBYTE I)
|
||||
{
|
||||
DWORD dwIndex = 0;
|
||||
PJMPTAB pJmpTab = o_;
|
||||
|
||||
do
|
||||
{
|
||||
_ASSERT(I[dwIndex] <= 0xf); // found packed data
|
||||
pJmpTab = &pJmpTab[I[dwIndex]]; // table entry by opcode
|
||||
dwIndex = pJmpTab->dwTyp; // next pointer type
|
||||
pJmpTab = (PJMPTAB) pJmpTab->pLnk; // next pointer to table/function
|
||||
}
|
||||
while (dwIndex != F); // reference to table? -> again
|
||||
|
||||
((VOID (*)(LPBYTE)) pJmpTab)(I); // call function
|
||||
return;
|
||||
}
|
|
@ -303,7 +303,7 @@ FONT 8, "MS Sans Serif"
|
|||
BEGIN
|
||||
ICON IDI_EMU48,IDC_STATIC,7,6,20,20,SS_REALSIZEIMAGE
|
||||
LTEXT "",IDC_VERSION,29,6,151,8,NOT WS_GROUP
|
||||
LTEXT "Copyright © 2023 Christoph Gießelink && Sébastien Carlier",
|
||||
LTEXT "Copyright © 2024 Christoph Gießelink && Sébastien Carlier",
|
||||
IDC_STATIC,29,18,181,8
|
||||
DEFPUSHBUTTON "OK",IDOK,215,12,39,14
|
||||
EDITTEXT IDC_LICENSE,7,33,247,112,ES_MULTILINE | ES_AUTOHSCROLL |
|
||||
|
@ -752,8 +752,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,6,6,0
|
||||
PRODUCTVERSION 1,6,6,0
|
||||
FILEVERSION 1,6,7,0
|
||||
PRODUCTVERSION 1,6,7,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -770,12 +770,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Christoph Gießelink & Sebastien Carlier\0"
|
||||
VALUE "FileDescription", "HP38/39/40/48/49 Emulator\0"
|
||||
VALUE "FileVersion", "1, 6, 6, 0\0"
|
||||
VALUE "FileVersion", "1, 6, 7, 0\0"
|
||||
VALUE "InternalName", "Emu48\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2023\0"
|
||||
VALUE "LegalCopyright", "Copyright © 2024\0"
|
||||
VALUE "OriginalFilename", "Emu48.exe\0"
|
||||
VALUE "ProductName", "Emu48\0"
|
||||
VALUE "ProductVersion", "1, 6, 6, 0\0"
|
||||
VALUE "ProductVersion", "1, 6, 7, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
//
|
||||
// PCH.H (MinGW version)
|
||||
//
|
||||
|
||||
#define _WIN32_IE 0x0200
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
#include <conio.h>
|
||||
// #include <crtdbg.h> // missing file
|
||||
|
||||
#if !defined IDC_HAND // Win2k specific definition
|
||||
#define IDC_HAND MAKEINTRESOURCE(32649)
|
||||
#endif
|
||||
|
||||
#define __unaligned
|
||||
|
||||
// normally defined in STDLIB.H
|
||||
#if !defined __max
|
||||
#define __max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#if !defined __min
|
||||
#define __min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// normally defined in missing CRTDBG.H
|
||||
#if !defined _ASSERT
|
||||
#define _ASSERT(a)
|
||||
#endif
|
||||
#define _CrtSetDbgFlag(f)
|
||||
|
||||
#if !defined VERIFY
|
||||
#if defined _DEBUG
|
||||
#define VERIFY(f) _ASSERT(f)
|
||||
#else // _DEBUG
|
||||
#define VERIFY(f) ((VOID)(f))
|
||||
#endif // _DEBUG
|
||||
#endif // VERIFY
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_CURRENT_VERSION
|
||||
#define PROCESS_POWER_THROTTLING_CURRENT_VERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
|
||||
#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x04
|
||||
#endif
|
||||
|
||||
enum { ProcessPowerThrottling = 4 };
|
||||
|
||||
typedef struct _PROCESS_POWER_THROTTLING_STATE {
|
||||
ULONG Version;
|
||||
ULONG ControlMask;
|
||||
ULONG StateMask;
|
||||
} PROCESS_POWER_THROTTLING_STATE, * PPROCESS_POWER_THROTTLING_STATE;
|
||||
//
|
||||
// PCH.H (MinGW version)
|
||||
//
|
||||
|
||||
#define _WIN32_IE 0x0200
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shellapi.h>
|
||||
#include <commctrl.h>
|
||||
#include <shlobj.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <direct.h>
|
||||
#include <conio.h>
|
||||
// #include <crtdbg.h> // missing file
|
||||
|
||||
#if !defined IDC_HAND // Win2k specific definition
|
||||
#define IDC_HAND MAKEINTRESOURCE(32649)
|
||||
#endif
|
||||
|
||||
#define __unaligned
|
||||
|
||||
// normally defined in STDLIB.H
|
||||
#if !defined __max
|
||||
#define __max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#if !defined __min
|
||||
#define __min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
// normally defined in missing CRTDBG.H
|
||||
#if !defined _ASSERT
|
||||
#define _ASSERT(a)
|
||||
#endif
|
||||
#define _CrtSetDbgFlag(f)
|
||||
|
||||
#if !defined VERIFY
|
||||
#if defined _DEBUG
|
||||
#define VERIFY(f) _ASSERT(f)
|
||||
#else // _DEBUG
|
||||
#define VERIFY(f) ((VOID)(f))
|
||||
#endif // _DEBUG
|
||||
#endif // VERIFY
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_CURRENT_VERSION
|
||||
#define PROCESS_POWER_THROTTLING_CURRENT_VERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
|
||||
#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x04
|
||||
#endif
|
||||
|
||||
enum { ProcessPowerThrottling = 4 };
|
||||
|
||||
typedef struct _PROCESS_POWER_THROTTLING_STATE {
|
||||
ULONG Version;
|
||||
ULONG ControlMask;
|
||||
ULONG StateMask;
|
||||
} PROCESS_POWER_THROTTLING_STATE, * PPROCESS_POWER_THROTTLING_STATE;
|
|
@ -67,4 +67,4 @@ Many thanks to Pedro A. Arranda Guti
|
|||
compatible.
|
||||
|
||||
|
||||
04/18/23 (c) by Christoph Gießelink
|
||||
09/23/24 (c) by Christoph Gießelink
|
||||
|
|
|
@ -1,266 +1,266 @@
|
|||
/*
|
||||
* MkShared, (c) 2006 Christoph Giesselink (c.giesselink@gmx.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include <crtdbg.h>
|
||||
#include "resource.h"
|
||||
|
||||
#if _MSC_VER >= 1400 // valid for VS2005 and later
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='x86' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='ia64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='amd64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='*' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _KB(n) (2*(n)*1024)
|
||||
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define DEFAULTFILE "SHARED.BIN"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATE_UNKOWN,
|
||||
STATE_GOOD,
|
||||
STATE_FAIL
|
||||
} CheckState;
|
||||
|
||||
static HBRUSH hBrushGreen;
|
||||
static HBRUSH hBrushRed;
|
||||
|
||||
static CheckState eState = STATE_UNKOWN;
|
||||
|
||||
static VOID SetInformation(HWND hWnd,LPCTSTR strSize,LPCTSTR strNoOfPorts,LPCTSTR strPorts)
|
||||
{
|
||||
SetDlgItemText(hWnd,IDC_FILE_SIZE,strSize);
|
||||
SetDlgItemText(hWnd,IDC_NO_OF_PORTS,strNoOfPorts);
|
||||
SetDlgItemText(hWnd,IDC_PORT_NO,strPorts);
|
||||
eState = STATE_UNKOWN;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T(""));
|
||||
InvalidateRect(GetDlgItem(hWnd,IDC_RESULT),NULL,TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
static BOOL WriteCardFile(LPCTSTR strFilename,INT nBlocks)
|
||||
{
|
||||
HANDLE hFile = CreateFile(strFilename,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
|
||||
LPBYTE pbyBuffer = (LPBYTE) calloc(1,_KB(1));
|
||||
|
||||
while (nBlocks--) WriteFile(hFile, pbyBuffer, _KB(1), &dwWritten, NULL);
|
||||
|
||||
free(pbyBuffer);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static WORD wSize;
|
||||
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
HCURSOR hCursor;
|
||||
|
||||
switch (iMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// filename
|
||||
SetDlgItemText(hWnd,IDC_FILENAME,_T(DEFAULTFILE));
|
||||
|
||||
// set to 32kb
|
||||
SendDlgItemMessage(hWnd,IDC_CARD32,BM_SETCHECK,1,0);
|
||||
PostMessage(hWnd,WM_COMMAND,IDC_CARD32,0);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_CARD32:
|
||||
wSize = 32;
|
||||
SetInformation(hWnd,_T("64kb"),_T("1"),_T("2"));
|
||||
return 0;
|
||||
case IDC_CARD128:
|
||||
wSize = 128;
|
||||
SetInformation(hWnd,_T("256kb"),_T("1"),_T("2"));
|
||||
return 0;
|
||||
case IDC_CARD256:
|
||||
wSize = 256;
|
||||
SetInformation(hWnd,_T("512kb"),_T("2"),_T("2,3"));
|
||||
return 0;
|
||||
case IDC_CARD512:
|
||||
wSize = 512;
|
||||
SetInformation(hWnd,_T("1mb"),_T("4"),_T("2 through 5"));
|
||||
return 0;
|
||||
case IDC_CARD1024:
|
||||
wSize = 1024;
|
||||
SetInformation(hWnd,_T("2mb"),_T("8"),_T("2 through 9"));
|
||||
return 0;
|
||||
case IDC_CARD2048:
|
||||
wSize = 2048;
|
||||
SetInformation(hWnd,_T("4mb"),_T("16"),_T("2 through 17"));
|
||||
return 0;
|
||||
case IDC_CARD4096:
|
||||
wSize = 4096;
|
||||
SetInformation(hWnd,_T("8mb"),_T("32"),_T("2 through 33"));
|
||||
return 0;
|
||||
case IDOK:
|
||||
GetDlgItemText(hWnd,IDC_FILENAME,szFilename,ARRAYSIZEOF(szFilename));
|
||||
hCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
|
||||
|
||||
// create file
|
||||
if (WriteCardFile(szFilename,wSize))
|
||||
{
|
||||
eState = STATE_FAIL;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T("Fail!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eState = STATE_GOOD;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T("Done!"));
|
||||
}
|
||||
InvalidateRect(GetDlgItem(hWnd,IDC_RESULT),NULL,TRUE);
|
||||
SetCursor(hCursor); // restore cursor
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
case WM_CTLCOLORSTATIC:
|
||||
if (GetDlgCtrlID((HWND) lParam) == IDC_RESULT)
|
||||
{
|
||||
switch (eState)
|
||||
{
|
||||
case STATE_GOOD:
|
||||
SetTextColor((HDC) wParam,(COLORREF) 0xFFFFFF); // white
|
||||
SetBkMode((HDC) wParam,TRANSPARENT);
|
||||
return (LRESULT) hBrushGreen;
|
||||
case STATE_FAIL:
|
||||
SetTextColor((HDC) wParam,(COLORREF) 0xFFFFFF); // white
|
||||
SetBkMode((HDC) wParam,TRANSPARENT);
|
||||
return (LRESULT) hBrushRed;
|
||||
}
|
||||
}
|
||||
break; // default handler for all other windows
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd,iMsg,wParam,lParam);
|
||||
}
|
||||
|
||||
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR lpszCmdLine,INT nCmdShow)
|
||||
{
|
||||
HWND hWnd;
|
||||
MSG msg;
|
||||
WNDCLASS wc;
|
||||
// RECT rc;
|
||||
HFONT hFont;
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
// create background brushes
|
||||
hBrushGreen = CreateSolidBrush(0x008000);
|
||||
hBrushRed = CreateSolidBrush(0x0000FF);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = DLGWINDOWEXTRA;
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MKSHARED));
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = _T("CMkShared");
|
||||
RegisterClass(&wc);
|
||||
|
||||
hWnd = CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),0,(DLGPROC) WndProc);
|
||||
_ASSERT(hWnd);
|
||||
|
||||
#if 0
|
||||
// center window
|
||||
GetWindowRect(hWnd, &rc);
|
||||
SetWindowPos(hWnd, HWND_TOP,
|
||||
((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
|
||||
((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
|
||||
0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
#endif
|
||||
|
||||
// initialization
|
||||
hFont = CreateFont(20,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
|
||||
OUT_DEVICE_PRECIS,CLIP_DEFAULT_PRECIS,
|
||||
PROOF_QUALITY,DEFAULT_PITCH|TMPF_TRUETYPE|FF_ROMAN,
|
||||
_T("Times New Roman"));
|
||||
_ASSERT(hFont);
|
||||
SendDlgItemMessage(hWnd,IDC_STATIC_TITLE,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));
|
||||
SendDlgItemMessage(hWnd,IDC_RESULT,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));
|
||||
|
||||
while(GetMessage(&msg,NULL,0,0))
|
||||
{
|
||||
if(!IsDialogMessage(hWnd,&msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteObject(hFont);
|
||||
DeleteObject(hBrushGreen);
|
||||
DeleteObject(hBrushRed);
|
||||
|
||||
return msg.wParam;
|
||||
UNREFERENCED_PARAMETER(hPrev);
|
||||
UNREFERENCED_PARAMETER(lpszCmdLine);
|
||||
UNREFERENCED_PARAMETER(nCmdShow);
|
||||
}
|
||||
/*
|
||||
* MkShared, (c) 2006 Christoph Giesselink (c.giesselink@gmx.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include <crtdbg.h>
|
||||
#include "resource.h"
|
||||
|
||||
#if _MSC_VER >= 1400 // valid for VS2005 and later
|
||||
#if defined _M_IX86
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='x86' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_IA64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='ia64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#elif defined _M_X64
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='amd64' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#else
|
||||
#pragma comment(linker,"/manifestdependency:\" \
|
||||
type='win32' \
|
||||
name='Microsoft.Windows.Common-Controls' \
|
||||
version='6.0.0.0' processorArchitecture='*' \
|
||||
publicKeyToken='6595b64144ccf1df' \
|
||||
language='*'\"")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _KB(n) (2*(n)*1024)
|
||||
|
||||
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define DEFAULTFILE "SHARED.BIN"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATE_UNKOWN,
|
||||
STATE_GOOD,
|
||||
STATE_FAIL
|
||||
} CheckState;
|
||||
|
||||
static HBRUSH hBrushGreen;
|
||||
static HBRUSH hBrushRed;
|
||||
|
||||
static CheckState eState = STATE_UNKOWN;
|
||||
|
||||
static VOID SetInformation(HWND hWnd,LPCTSTR strSize,LPCTSTR strNoOfPorts,LPCTSTR strPorts)
|
||||
{
|
||||
SetDlgItemText(hWnd,IDC_FILE_SIZE,strSize);
|
||||
SetDlgItemText(hWnd,IDC_NO_OF_PORTS,strNoOfPorts);
|
||||
SetDlgItemText(hWnd,IDC_PORT_NO,strPorts);
|
||||
eState = STATE_UNKOWN;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T(""));
|
||||
InvalidateRect(GetDlgItem(hWnd,IDC_RESULT),NULL,TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
static BOOL WriteCardFile(LPCTSTR strFilename,INT nBlocks)
|
||||
{
|
||||
HANDLE hFile = CreateFile(strFilename,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD dwWritten;
|
||||
|
||||
LPBYTE pbyBuffer = (LPBYTE) calloc(1,_KB(1));
|
||||
|
||||
while (nBlocks--) WriteFile(hFile, pbyBuffer, _KB(1), &dwWritten, NULL);
|
||||
|
||||
free(pbyBuffer);
|
||||
|
||||
CloseHandle(hFile);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static WORD wSize;
|
||||
|
||||
TCHAR szFilename[MAX_PATH];
|
||||
HCURSOR hCursor;
|
||||
|
||||
switch (iMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// filename
|
||||
SetDlgItemText(hWnd,IDC_FILENAME,_T(DEFAULTFILE));
|
||||
|
||||
// set to 32kb
|
||||
SendDlgItemMessage(hWnd,IDC_CARD32,BM_SETCHECK,1,0);
|
||||
PostMessage(hWnd,WM_COMMAND,IDC_CARD32,0);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_CARD32:
|
||||
wSize = 32;
|
||||
SetInformation(hWnd,_T("64kb"),_T("1"),_T("2"));
|
||||
return 0;
|
||||
case IDC_CARD128:
|
||||
wSize = 128;
|
||||
SetInformation(hWnd,_T("256kb"),_T("1"),_T("2"));
|
||||
return 0;
|
||||
case IDC_CARD256:
|
||||
wSize = 256;
|
||||
SetInformation(hWnd,_T("512kb"),_T("2"),_T("2,3"));
|
||||
return 0;
|
||||
case IDC_CARD512:
|
||||
wSize = 512;
|
||||
SetInformation(hWnd,_T("1mb"),_T("4"),_T("2 through 5"));
|
||||
return 0;
|
||||
case IDC_CARD1024:
|
||||
wSize = 1024;
|
||||
SetInformation(hWnd,_T("2mb"),_T("8"),_T("2 through 9"));
|
||||
return 0;
|
||||
case IDC_CARD2048:
|
||||
wSize = 2048;
|
||||
SetInformation(hWnd,_T("4mb"),_T("16"),_T("2 through 17"));
|
||||
return 0;
|
||||
case IDC_CARD4096:
|
||||
wSize = 4096;
|
||||
SetInformation(hWnd,_T("8mb"),_T("32"),_T("2 through 33"));
|
||||
return 0;
|
||||
case IDOK:
|
||||
GetDlgItemText(hWnd,IDC_FILENAME,szFilename,ARRAYSIZEOF(szFilename));
|
||||
hCursor = SetCursor(LoadCursor(NULL,IDC_WAIT));
|
||||
|
||||
// create file
|
||||
if (WriteCardFile(szFilename,wSize))
|
||||
{
|
||||
eState = STATE_FAIL;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T("Fail!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
eState = STATE_GOOD;
|
||||
SetDlgItemText(hWnd,IDC_RESULT,_T("Done!"));
|
||||
}
|
||||
InvalidateRect(GetDlgItem(hWnd,IDC_RESULT),NULL,TRUE);
|
||||
SetCursor(hCursor); // restore cursor
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
case WM_CTLCOLORSTATIC:
|
||||
if (GetDlgCtrlID((HWND) lParam) == IDC_RESULT)
|
||||
{
|
||||
switch (eState)
|
||||
{
|
||||
case STATE_GOOD:
|
||||
SetTextColor((HDC) wParam,(COLORREF) 0xFFFFFF); // white
|
||||
SetBkMode((HDC) wParam,TRANSPARENT);
|
||||
return (LRESULT) hBrushGreen;
|
||||
case STATE_FAIL:
|
||||
SetTextColor((HDC) wParam,(COLORREF) 0xFFFFFF); // white
|
||||
SetBkMode((HDC) wParam,TRANSPARENT);
|
||||
return (LRESULT) hBrushRed;
|
||||
}
|
||||
}
|
||||
break; // default handler for all other windows
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd,iMsg,wParam,lParam);
|
||||
}
|
||||
|
||||
INT WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR lpszCmdLine,INT nCmdShow)
|
||||
{
|
||||
HWND hWnd;
|
||||
MSG msg;
|
||||
WNDCLASS wc;
|
||||
// RECT rc;
|
||||
HFONT hFont;
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
// create background brushes
|
||||
hBrushGreen = CreateSolidBrush(0x008000);
|
||||
hBrushRed = CreateSolidBrush(0x0000FF);
|
||||
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = DLGWINDOWEXTRA;
|
||||
wc.hInstance = hInst;
|
||||
wc.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MKSHARED));
|
||||
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = _T("CMkShared");
|
||||
RegisterClass(&wc);
|
||||
|
||||
hWnd = CreateDialog(hInst,MAKEINTRESOURCE(IDD_MAIN),0,(DLGPROC) WndProc);
|
||||
_ASSERT(hWnd);
|
||||
|
||||
#if 0
|
||||
// center window
|
||||
GetWindowRect(hWnd, &rc);
|
||||
SetWindowPos(hWnd, HWND_TOP,
|
||||
((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
|
||||
((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
|
||||
0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
|
||||
#endif
|
||||
|
||||
// initialization
|
||||
hFont = CreateFont(20,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,
|
||||
OUT_DEVICE_PRECIS,CLIP_DEFAULT_PRECIS,
|
||||
PROOF_QUALITY,DEFAULT_PITCH|TMPF_TRUETYPE|FF_ROMAN,
|
||||
_T("Times New Roman"));
|
||||
_ASSERT(hFont);
|
||||
SendDlgItemMessage(hWnd,IDC_STATIC_TITLE,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));
|
||||
SendDlgItemMessage(hWnd,IDC_RESULT,WM_SETFONT,(WPARAM)hFont,MAKELPARAM(TRUE,0));
|
||||
|
||||
while(GetMessage(&msg,NULL,0,0))
|
||||
{
|
||||
if(!IsDialogMessage(hWnd,&msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
DeleteObject(hFont);
|
||||
DeleteObject(hBrushGreen);
|
||||
DeleteObject(hBrushRed);
|
||||
|
||||
return msg.wParam;
|
||||
UNREFERENCED_PARAMETER(hPrev);
|
||||
UNREFERENCED_PARAMETER(lpszCmdLine);
|
||||
UNREFERENCED_PARAMETER(nCmdShow);
|
||||
}
|
|
@ -1,32 +1,32 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by MKSHARED.RC
|
||||
//
|
||||
#define IDD_MAIN 100
|
||||
#define IDI_MKSHARED 101
|
||||
#define IDC_CARD32 1000
|
||||
#define IDC_CARD128 1001
|
||||
#define IDC_CARD256 1002
|
||||
#define IDC_CARD512 1003
|
||||
#define IDC_CARD1024 1004
|
||||
#define IDC_CARD2048 1005
|
||||
#define IDC_CARD4096 1006
|
||||
#define IDC_STATIC_TITLE 1007
|
||||
#define IDC_FILENAME 1008
|
||||
#define IDC_FILE_SIZE 1009
|
||||
#define IDC_NO_OF_PORTS 1010
|
||||
#define IDC_PORT_NO 1011
|
||||
#define IDC_RESULT 1012
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1013
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by MKSHARED.RC
|
||||
//
|
||||
#define IDD_MAIN 100
|
||||
#define IDI_MKSHARED 101
|
||||
#define IDC_CARD32 1000
|
||||
#define IDC_CARD128 1001
|
||||
#define IDC_CARD256 1002
|
||||
#define IDC_CARD512 1003
|
||||
#define IDC_CARD1024 1004
|
||||
#define IDC_CARD2048 1005
|
||||
#define IDC_CARD4096 1006
|
||||
#define IDC_STATIC_TITLE 1007
|
||||
#define IDC_FILENAME 1008
|
||||
#define IDC_FILE_SIZE 1009
|
||||
#define IDC_NO_OF_PORTS 1010
|
||||
#define IDC_PORT_NO 1011
|
||||
#define IDC_RESULT 1012
|
||||
#define IDC_STATIC -1
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1013
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -1,120 +1,120 @@
|
|||
/*
|
||||
* T48G, (c) 2000 Christoph Giesselink (cgiess@swol.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
|
||||
#define VERSION "1.0"
|
||||
|
||||
#define _KB(n) (n*1024*2) // KB emulator block
|
||||
|
||||
#define HP48SIG "Emu48 Document\xFE" // HP49 state file signature
|
||||
|
||||
VOID MakeTemplate(FILE *hFile,BYTE type,DWORD Port0Size,DWORD Port1Size)
|
||||
{
|
||||
CHIPSET Chipset;
|
||||
DWORD dwBytesWritten;
|
||||
UINT nVar;
|
||||
BYTE byZ;
|
||||
|
||||
// file signature
|
||||
WriteFile(hFile,HP48SIG,sizeof(HP48SIG),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(HP48SIG));
|
||||
|
||||
// KML filename length
|
||||
nVar = 0; // no name
|
||||
WriteFile(hFile,&nVar,sizeof(nVar),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(nVar));
|
||||
|
||||
// KML filename
|
||||
|
||||
// Chipset Size
|
||||
nVar = sizeof(Chipset); // length, no name
|
||||
WriteFile(hFile,&nVar,sizeof(nVar),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(nVar));
|
||||
|
||||
// Chipset
|
||||
ZeroMemory(&Chipset,sizeof(Chipset));
|
||||
Chipset.type = type;
|
||||
Chipset.Port0Size = Port0Size;
|
||||
Chipset.Port1Size = Port1Size;
|
||||
Chipset.Port2Size = 0;
|
||||
Chipset.cards_status = 0x0;
|
||||
|
||||
WriteFile(hFile,&Chipset,sizeof(Chipset),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(Chipset));
|
||||
|
||||
byZ = 0; // fill with zero nibble
|
||||
|
||||
// write port0 memory content
|
||||
for (nVar = 0; nVar < _KB(Chipset.Port0Size); ++nVar)
|
||||
{
|
||||
WriteFile(hFile,&byZ,1,&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == 1);
|
||||
}
|
||||
|
||||
// write port1 memory content
|
||||
for (nVar = 0; nVar < _KB(Chipset.Port1Size); ++nVar)
|
||||
{
|
||||
WriteFile(hFile,&byZ,1,&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFile;
|
||||
|
||||
BYTE type;
|
||||
DWORD Port0Size;
|
||||
DWORD Port1Size;
|
||||
|
||||
printf("HP48 State File Template for Emu48 V" VERSION "\n");
|
||||
if (argc != 5 || (*argv[2] != 'S' && *argv[2] != 'G'))
|
||||
{
|
||||
printf("\nUsage:\n\t%s <E48-File> <Model[S|G]> <Port0-Size> <Port1-Size>\n\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
type = *argv[2];
|
||||
Port0Size = atoi(argv[3]);
|
||||
Port1Size = atoi(argv[4]);
|
||||
|
||||
hFile = CreateFile(argv[1],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// write template
|
||||
MakeTemplate(hFile,type,Port0Size,Port1Size);
|
||||
puts("Generation successful.");
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Cannot open file %s.\n", argv[1]);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* T48G, (c) 2000 Christoph Giesselink (cgiess@swol.de)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include "types.h"
|
||||
|
||||
#define VERSION "1.0"
|
||||
|
||||
#define _KB(n) (n*1024*2) // KB emulator block
|
||||
|
||||
#define HP48SIG "Emu48 Document\xFE" // HP49 state file signature
|
||||
|
||||
VOID MakeTemplate(FILE *hFile,BYTE type,DWORD Port0Size,DWORD Port1Size)
|
||||
{
|
||||
CHIPSET Chipset;
|
||||
DWORD dwBytesWritten;
|
||||
UINT nVar;
|
||||
BYTE byZ;
|
||||
|
||||
// file signature
|
||||
WriteFile(hFile,HP48SIG,sizeof(HP48SIG),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(HP48SIG));
|
||||
|
||||
// KML filename length
|
||||
nVar = 0; // no name
|
||||
WriteFile(hFile,&nVar,sizeof(nVar),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(nVar));
|
||||
|
||||
// KML filename
|
||||
|
||||
// Chipset Size
|
||||
nVar = sizeof(Chipset); // length, no name
|
||||
WriteFile(hFile,&nVar,sizeof(nVar),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(nVar));
|
||||
|
||||
// Chipset
|
||||
ZeroMemory(&Chipset,sizeof(Chipset));
|
||||
Chipset.type = type;
|
||||
Chipset.Port0Size = Port0Size;
|
||||
Chipset.Port1Size = Port1Size;
|
||||
Chipset.Port2Size = 0;
|
||||
Chipset.cards_status = 0x0;
|
||||
|
||||
WriteFile(hFile,&Chipset,sizeof(Chipset),&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == sizeof(Chipset));
|
||||
|
||||
byZ = 0; // fill with zero nibble
|
||||
|
||||
// write port0 memory content
|
||||
for (nVar = 0; nVar < _KB(Chipset.Port0Size); ++nVar)
|
||||
{
|
||||
WriteFile(hFile,&byZ,1,&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == 1);
|
||||
}
|
||||
|
||||
// write port1 memory content
|
||||
for (nVar = 0; nVar < _KB(Chipset.Port1Size); ++nVar)
|
||||
{
|
||||
WriteFile(hFile,&byZ,1,&dwBytesWritten,NULL);
|
||||
assert(dwBytesWritten == 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
UINT main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hFile;
|
||||
|
||||
BYTE type;
|
||||
DWORD Port0Size;
|
||||
DWORD Port1Size;
|
||||
|
||||
printf("HP48 State File Template for Emu48 V" VERSION "\n");
|
||||
if (argc != 5 || (*argv[2] != 'S' && *argv[2] != 'G'))
|
||||
{
|
||||
printf("\nUsage:\n\t%s <E48-File> <Model[S|G]> <Port0-Size> <Port1-Size>\n\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
type = *argv[2];
|
||||
Port0Size = atoi(argv[3]);
|
||||
Port1Size = atoi(argv[4]);
|
||||
|
||||
hFile = CreateFile(argv[1],GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL);
|
||||
if (hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// write template
|
||||
MakeTemplate(hFile,type,Port0Size,Port1Size);
|
||||
puts("Generation successful.");
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Cannot open file %s.\n", argv[1]);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
|
@ -1,103 +1,103 @@
|
|||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
LPBYTE Port0;
|
||||
LPBYTE Port1;
|
||||
LPBYTE Port2;
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon;
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
||||
/*
|
||||
* types.h
|
||||
*
|
||||
* This file is part of Emu48
|
||||
*
|
||||
* Copyright (C) 1995 Sebastien Carlier
|
||||
*
|
||||
*/
|
||||
|
||||
// HST bits
|
||||
#define XM 1
|
||||
#define SB 2
|
||||
#define SR 4
|
||||
#define MP 8
|
||||
|
||||
#define SWORD SHORT // signed 16 Bit variable
|
||||
#define QWORD ULONGLONG // unsigned 64 Bit variable
|
||||
|
||||
#define CHIPSET Chipset_t
|
||||
typedef struct
|
||||
{
|
||||
SWORD nPosX; // position of window
|
||||
SWORD nPosY;
|
||||
BYTE type; // calculator type
|
||||
|
||||
DWORD Port0Size; // real size of module in KB
|
||||
DWORD Port1Size; // real size of module in KB
|
||||
DWORD Port2Size; // real size of module in KB (HP49G only)
|
||||
LPBYTE Port0;
|
||||
LPBYTE Port1;
|
||||
LPBYTE Port2;
|
||||
|
||||
DWORD pc;
|
||||
DWORD d0;
|
||||
DWORD d1;
|
||||
DWORD rstkp;
|
||||
DWORD rstk[8];
|
||||
BYTE A[16];
|
||||
BYTE B[16];
|
||||
BYTE C[16];
|
||||
BYTE D[16];
|
||||
BYTE R0[16];
|
||||
BYTE R1[16];
|
||||
BYTE R2[16];
|
||||
BYTE R3[16];
|
||||
BYTE R4[16];
|
||||
BYTE ST[4];
|
||||
BYTE HST;
|
||||
BYTE P;
|
||||
WORD out;
|
||||
WORD in;
|
||||
BOOL SoftInt;
|
||||
BOOL Shutdn;
|
||||
BOOL mode_dec;
|
||||
BOOL inte; // interrupt status flag (FALSE = int in service)
|
||||
BOOL intk; // 1 ms keyboard scan flag (TRUE = enable)
|
||||
BOOL intd; // keyboard interrupt pending (TRUE = int pending)
|
||||
BOOL carry;
|
||||
|
||||
WORD crc;
|
||||
WORD wPort2Crc; // fingerprint of port2
|
||||
WORD wRomCrc; // fingerprint of ROM
|
||||
#if defined _USRDLL // DLL version
|
||||
QWORD cycles; // oscillator cycles
|
||||
#else // EXE version
|
||||
DWORD cycles; // oscillator cycles
|
||||
DWORD cycles_reserved; // reserved for MSB of oscillator cycles
|
||||
#endif
|
||||
DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler
|
||||
|
||||
UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF
|
||||
UINT FlashRomState; // WSM state of flash memory (unused)
|
||||
BYTE cards_status;
|
||||
BYTE IORam[64]; // I/O hardware register
|
||||
UINT IOBase; // address of I/O modules page
|
||||
BOOL IOCfig; // I/O module configuration flag
|
||||
BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page
|
||||
BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB
|
||||
BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page
|
||||
BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag
|
||||
BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag
|
||||
|
||||
BYTE t1;
|
||||
DWORD t2;
|
||||
|
||||
BOOL bShutdnWake; // flag for wake up from SHUTDN mode
|
||||
|
||||
BYTE Keyboard_Row[9];
|
||||
WORD IR15X;
|
||||
UINT Keyboard_State; // not used
|
||||
|
||||
signed short loffset;
|
||||
signed int width;
|
||||
UINT boffset;
|
||||
UINT lcounter;
|
||||
UINT sync; // not used
|
||||
BYTE contrast;
|
||||
BOOL dispon;
|
||||
DWORD start1;
|
||||
DWORD start12;
|
||||
DWORD end1;
|
||||
DWORD start2, end2;
|
||||
} Chipset_t;
|
BIN
uninst.exe
BIN
uninst.exe
Binary file not shown.
Loading…
Reference in a new issue