Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header restructure and warnings elimination #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion L83.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "zx81s.h"
#include "basictypes.h"

zx81vars L83vars[] = {
1,"VERSN ",0,
Expand Down
19 changes: 19 additions & 0 deletions basictypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

extern HWND g_hWnd;
extern HWND g_hwndStartAddr;
extern HWND g_hwndColumns;

extern char* hexdump(BYTE* inputstring, size_t ccin, size_t* lpccout, char* szFileName);

typedef struct zx81vars
{
BYTE bytes;
char name[10];
WORD addr;
}zx81vars;

struct charcodes {
int number;
char text[11];
};
6 changes: 2 additions & 4 deletions download.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "stdafx.h"

DWORD retFileSize3(HANDLE h_File);
int FileExistCheckEx(HWND hWnd,WCHAR* szFileName);
DWORD DownloadFileToBufferSafe(WCHAR* szFileName,char* szBuffer, DWORD* dwBufferSize);
#include "download.h"

DWORD DownloadFileToBufferSafe(WCHAR* szFileName,char* szBuffer, DWORD* dwBufferSize)
{ // szFileName: file name to open, return contents in szBuffer
Expand All @@ -12,7 +10,7 @@ DWORD DownloadFileToBufferSafe(WCHAR* szFileName,char* szBuffer, DWORD* dwBuffer
SetLastError(ERROR_SUCCESS); // for reading 0 bytes
//check to make sure file already exists
DWORD dwExists = GetFileAttributes(szFileName);
if(dwExists == 0xFFFFFFFF)
if(dwExists == INVALID_FILE_ATTRIBUTES)
{
_stprintf_s(myErrString,TEXT("ERROR_FILE_NOT_FOUND:\n\n%s"),szFileName);
SetLastError(ERROR_FILE_NOT_FOUND);
Expand Down
5 changes: 5 additions & 0 deletions download.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

extern DWORD DownloadFileToBufferSafe(WCHAR* szFileName, char* szBuffer, DWORD* dwBufferSize);
extern DWORD retFileSize3(HANDLE h_File);
extern int FileExistCheckEx(HWND hWnd, WCHAR* szFileName);
29 changes: 17 additions & 12 deletions zx81s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
#include "zx81s.h"
#include "L83.h"

#define HEADERSIZE_HEXDUMP 135

#define PROGRAM 16509 //407D
#define offset 16393 //4009
#define program 16509 - offset //116

//host app will supply these GUI items
extern HWND hWndExportName; // text window for status updates
char* zxhexdumpX(BYTE* bs, int cbbs, char* spacer, int columns, WORD address, BOOL bShowStatus);
BYTE GetSysByte(WORD _offset, BYTE* p_stream);
int FileExistCheckEx(HWND hWnd,WCHAR* szFileName);

char (*code2ascii)[11];
Expand Down Expand Up @@ -45,7 +53,7 @@ BOOL convertToWide2(size_t* lenW, WCHAR* szWide,char* szANSI)
}
void GetFileNameOut(char* szFileName,char* outname,WCHAR* wOutname)
{
char FilePath[MAX_PATH]; *FilePath=0;
char FilePath[MAX_PATH] = { 0 };
if(szFileName)
{
char* p = strrchr(szFileName,'\\');
Expand Down Expand Up @@ -99,7 +107,7 @@ int DetectVersion(BYTE* bytestream)
}
}
else {
char s[4]; *s = 0;
char s[4] = { 0 };
sprintf_s(s, "%d", versn);
MessageBoxA(g_hWnd, s, "Version", MB_OK | MB_ICONEXCLAMATION);
}
Expand Down Expand Up @@ -251,7 +259,6 @@ void doHexDump(char* zxrem,size_t cczxrem,BYTE* in,int ccin,int columns, WORD ad
delete ss;

strcat_s(zxrem, cczxrem, hexdump);
delete hexdump;
}
BOOL IsZXstandard(BYTE byte)
{
Expand All @@ -263,16 +270,16 @@ char* zxhexdumpX(BYTE* bs, int cbbs, char* spacer, int columns, WORD address, BO
{
size_t cczxhexdump = 20 + optionSizeHD(cbbs);
char* szHexDump = new char[cczxhexdump]; *szHexDump = 0;
char chex[10]; *chex = 0;
char hx_line[4 * (8 + 7 + 16 + 4)]; *hx_line = 0;
char chex[10] = { 0 };
char hx_line[4 * (8 + 7 + 16 + 4)] = { 0 };
char a[36 + 2]; //36col
char ts[36 + 2];//36col
char hx[3];
BYTE d;
int addcounter = 0;
while (addcounter < cbbs)
{
WCHAR sz[67];
WCHAR sz[67] = { 0 };
if (bShowStatus)
{
_stprintf_s(sz, L"Hex Dump: %d bytes of %d", addcounter, cbbs);
Expand Down Expand Up @@ -313,9 +320,7 @@ char* zxhexdumpX(BYTE* bs, int cbbs, char* spacer, int columns, WORD address, BO
//'get char from ASCII Char Set
if (((d > 31) && (d < 0x7f)) || (d >= 0xA0))
{
char as[2];
as[0] = d;
as[1] = 0;
char as[2] = { (char)d, 0 };
strcat_s(a, as);
}
else
Expand Down Expand Up @@ -404,9 +409,9 @@ void doDBZXdisplayfile(char* s, size_t ccs, BYTE* in, int ccin, int columns, int
{
char sl[] = "L4023:";
size_t slcc = strlen(sl)+1;
char zxs[11]; *zxs = 0;
char zxs[11] = { 0 };
size_t zxscc = 11;
int d;
int d = 0;
int z = 1;
for (int b = 0; b < rows; b++)
{
Expand Down Expand Up @@ -469,7 +474,7 @@ char* ShowAlternateDisplayFiles(char* is, int ccis)
strcat_s(s, ccs, "\r\n");
char ss[] = " // 439B 76 possible display file found\r\n";
int ccss = strlen(ss) + 1;
sprintf_s(ss, ccss, "%s%04X 76 possible display file found\r\n", mcIndent, f + offset);
sprintf_s(ss, ccss, "%s%04X 76 possible display file found\r\n", mcIndent[1], f + offset);
strcat_s(s, ccs, ss);

int myrows = 24;
Expand Down
36 changes: 5 additions & 31 deletions zx81s.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
#pragma once

#define HEADERSIZE_HEXDUMP 135

#define PROGRAM 16509 //407D
#define offset 16393 //4009
#define program 16509 - offset //116

HWND g_hWnd;
extern HWND g_hwndStartAddr;
extern HWND g_hwndColumns;


char* zxhexdumpX(BYTE* bs, int cbbs, char* spacer, int columns , WORD address, BOOL bShowStatus);
char* hexdump (BYTE* inputstring,size_t ccin, size_t* lpccout,char* szFileName);
BYTE GetSysByte(WORD _offset, BYTE* p_stream);
#include "basictypes.h"

char mcIndent[][10] = {
" // ",
" "};

typedef struct zx81vars
{
BYTE bytes;
char name[10];
WORD addr;
}zx81vars;
" " };

zx81vars zxvars[] = {
1,"VERSN ",0,
Expand Down Expand Up @@ -61,7 +40,7 @@ zx81vars zxvars[] = {
1,"CDFLAG ",0,
33,"PRBUFF ",16444,
25,"MEMBOT ",16477,
5,"MEM_5 ",16502,
5,"MEM_5 ",16502,
2,"UNUSED2 ",16507,
255,0,0
};
Expand Down Expand Up @@ -322,12 +301,7 @@ char zx2ascii[][11] = {
"UNPLOT ",
"CLEAR ",
"RETURN ",
"COPY "};

struct charcodes {
int number;
char text[11];
};
"COPY " };

charcodes ZX81charcodes[]{
0, "",
Expand Down Expand Up @@ -585,4 +559,4 @@ charcodes ZX81charcodes[]{
2, "ZX_UNPLOT",
2, "ZX_CLEAR",
2, "ZX_RETURN",
2, "ZX_COPY"};
2, "ZX_COPY" };
45 changes: 22 additions & 23 deletions zxdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
*/

#include "stdafx.h"
#include "zxdump.h"
#include <tchar.h>
#include <stdio.h>
#include <assert.h>
Expand All @@ -33,6 +32,10 @@
#include <shlwapi.h>
#pragma comment(lib, "Shlwapi.lib")

#include "zxdump.h"
#include "basictypes.h"
#include "download.h"

#define darkmode_
#ifdef darkmode_
#include <dwmapi.h>
Expand All @@ -46,9 +49,8 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define ADDRESS_BASE L"4009"
WORD address_start = OFFSET;

extern BOOL validatePfile(BYTE* inputstring,size_t ccin,char* outstring, size_t ccout);
extern DWORD retFileSize3(HANDLE h_File);
extern int DetectVersion(BYTE* bytestream);
BOOL validatePfile(BYTE* inputstring,size_t ccin,char* outstring, size_t ccout);
int DetectVersion(BYTE* bytestream);

void convert(BYTE* inputstring, size_t ccin, HWND hWnd, char* szFileName);
BOOL GetFileName(WCHAR* szFileName);
Expand Down Expand Up @@ -77,6 +79,7 @@ COLORREF clrLabelBkGnd;
HWND hWndOpen;
HWND hwndTipGo;
HWND hwndTipCols;
HWND g_hWnd;
HWND g_WndStatus;
HWND g_hwndStartAddr;
HWND g_hwndColumns;
Expand Down Expand Up @@ -125,7 +128,6 @@ void OnOpen();
DWORD WINAPI ThreadProcess(LPVOID lpParameter);
int FileExistCheck(WCHAR* szFileName);
void OpenMyFile(WCHAR* szFileName);
DWORD DownloadFileToBufferSafe(WCHAR* szFileName,char* szBuffer, DWORD* dwBufferSize);
void OnExportOpen();
void OnResetAddress();
BOOL GetSaveName(WCHAR* szFileName, WCHAR* lpstrTitle, WCHAR* lpstrDefExt, int Flags, int nFilterIndex);
Expand Down Expand Up @@ -156,7 +158,7 @@ void args()
{
LPWSTR *szArgList;
int argCount;
WCHAR szArg[MAX_PATH]; *szArg= 0;
WCHAR szArg[MAX_PATH] = { 0 };
//UpdateWindow(hWnd);

szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
Expand All @@ -169,10 +171,10 @@ void args()
if(*szArg != 0)
OpenMyFile(szArg);
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
Expand Down Expand Up @@ -243,7 +245,7 @@ void ResetFields()
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
WNDCLASSEX wcex = { 0 };

wcex.cbSize = sizeof(WNDCLASSEX);

Expand Down Expand Up @@ -339,8 +341,7 @@ char* getBS(WCHAR* szFileName,int* cb)
int n = DownloadFileToBufferSafe(szFileName,bs1,&dwFS_low);
if (n == 0)
{
delete bs1;
bs1 = 0;
bs1 = NULL;
}
*cb = n;
return bs1;
Expand Down Expand Up @@ -767,7 +768,7 @@ BOOL convertToStr(WCHAR* szWide, char* szANSI)
BOOL GetSaveName(WCHAR* szFileName, WCHAR* lpstrTitle, WCHAR* lpstrDefExt, int Flags, int nFilterIndex)
{
OPENFILENAME ofn; // common dialog box structure
WCHAR szFile[MAX_PATH];
WCHAR szFile[MAX_PATH] = { 0 };

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
Expand Down Expand Up @@ -796,7 +797,7 @@ BOOL GetSaveName(WCHAR* szFileName, WCHAR* lpstrTitle, WCHAR* lpstrDefExt, int F
BOOL GetFileName(WCHAR* szFileName)
{
OPENFILENAME ofn; // common dialog box structure
WCHAR szFile[MAX_PATH];
WCHAR szFile[MAX_PATH] = { 0 };

// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
Expand Down Expand Up @@ -905,9 +906,9 @@ void OnOpen()
}
void OnProcess()
{
DWORD selStart;
DWORD selEnd;
LRESULT result = SendMessage(g_WndStatus, EM_GETSEL, (WPARAM) & selStart, (LPARAM) & selEnd);
DWORD selStart = 0;
DWORD selEnd = 0;
LRESULT result = SendMessage(g_WndStatus, EM_GETSEL, (WPARAM) &selStart, (LPARAM) &selEnd);
DWORD dwThreadID = 0;
CreateThread(NULL,0,ThreadProcess,0,0,&dwThreadID);
}
Expand All @@ -921,7 +922,7 @@ void OnExportOpen()
}
void OnButtonExport()
{
WCHAR szFileName[MAX_PATH]; *szFileName = 0;
WCHAR szFileName[MAX_PATH] = { 0 };
WCHAR szFilePath[MAX_PATH];
GetWindowText(hWndExportName, szFilePath, MAX_PATH);
if (*szFilePath == 0)
Expand All @@ -936,7 +937,7 @@ void OnButtonExport()

GetSaveName(szFileName, L"Save file As", L"txt", OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT, 1);

WCHAR wOutname[MAX_PATH];
WCHAR wOutname[MAX_PATH] = { 0 };
wcscpy_s(wOutname, szFileName);

int i = GetWindowTextLength(g_WndStatus);
Expand Down Expand Up @@ -974,7 +975,7 @@ int FilePathExistQz(IN OUT _TCHAR* szPath, const size_t sizePath, HWND hWnd)
d = GetFileAttributes (szPath);
if( d == -1 )
{
LPVOID lpMsgBuf;
LPVOID lpMsgBuf = 0;

d = GetLastError();
FormatMessage(
Expand Down Expand Up @@ -1081,7 +1082,6 @@ void ScanForDisplayFiles()
size_t cctemp = 120; // size of SYSTEM VARS + 4
char* working = new char[cctemp]; *working = 0;
BOOL b = validatePfile((BYTE*)inputstring, dwFS_low, working, cctemp);
delete working;
if (b)
{
VERSN = DetectVersion((BYTE*)inputstring);
Expand All @@ -1094,7 +1094,6 @@ void ScanForDisplayFiles()
SetWindowTextA(g_WndStatus, inputstring);
}
}
delete inputstring;
}
void validatePlus()
{
Expand Down
Binary file modified zxdump.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions zxdump.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@
<ClCompile Include="zx81s.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="basictypes.h" />
<ClInclude Include="download.h" />
<ClInclude Include="zxdump.h" />
<ClInclude Include="L83.h" />
<ClInclude Include="Resource.h" />
Expand Down