From f7669a3fcc87d4f6040257c3dd8708c263331458 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Fri, 25 May 2018 10:13:59 +0530
Subject: Added all LDmicro filles to be ported
---
ldmicro/includes/advanceddialog.h | 142 ++++
ldmicro/includes/componentlist.h | 71 ++
ldmicro/includes/components/componentfunctions.h | 63 ++
ldmicro/includes/components/componentimages.h | 53 ++
ldmicro/includes/components/components.h | 51 ++
ldmicro/includes/components/componentstructs.h | 62 ++
ldmicro/includes/intcode.h | 83 +++
ldmicro/includes/ldmicro.h | 781 ++++++++++++++++++++
ldmicro/includes/mcutable.h | 862 +++++++++++++++++++++++
ldmicro/includes/naminglist.h | 16 +
ldmicro/includes/simulate.h | 8 +
11 files changed, 2192 insertions(+)
create mode 100644 ldmicro/includes/advanceddialog.h
create mode 100644 ldmicro/includes/componentlist.h
create mode 100644 ldmicro/includes/components/componentfunctions.h
create mode 100644 ldmicro/includes/components/componentimages.h
create mode 100644 ldmicro/includes/components/components.h
create mode 100644 ldmicro/includes/components/componentstructs.h
create mode 100644 ldmicro/includes/intcode.h
create mode 100644 ldmicro/includes/ldmicro.h
create mode 100644 ldmicro/includes/mcutable.h
create mode 100644 ldmicro/includes/naminglist.h
create mode 100644 ldmicro/includes/simulate.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/advanceddialog.h b/ldmicro/includes/advanceddialog.h
new file mode 100644
index 0000000..5e4808f
--- /dev/null
+++ b/ldmicro/includes/advanceddialog.h
@@ -0,0 +1,142 @@
+#ifndef _ADVANCED_DIALOG_H
+#define _ADVANCED_DIALOG_H
+
+#define MAX_PIN_NAME 128
+
+/*Advanced Dialog Menus*/
+#define MNU_ADV_NEW 0x01
+#define MNU_ADV_OPEN 0x02
+#define MNU_ADV_SAVE 0x03
+#define MNU_ADV_SAVE_AS 0x04
+#define MNU_ADV_EXIT 0x05
+
+#define MNU_ADV_UNDO 0x10
+#define MNU_ADV_REDO 0x11
+#define MNU_ADV_CUT 0x12
+#define MNU_ADV_COPY 0x13
+#define MNU_ADV_PASTE 0x14
+#define MNU_ADV_DEL 0x15
+
+#define MNU_ADV_SIMULATION_MODE 0x20
+#define MNU_ADV_START_SIMULATION 0x21
+#define MNU_ADV_STOP_SIMULATION 0x22
+#define MNU_ADV_SINGLE_CYCLE 0x23
+
+#define MNU_ADV_MANUAL 0x30
+#define MNU_ADV_ABOUT 0x31
+
+#define MAX_NAME_LENGTH 128
+#define MAX_SCREEN_ITEMS 512
+#define MAX_PINS 4000
+#define MCU_PIN_FLAG 4000
+#define MAX_MCU_PINS 128
+#define TIMER_ADV_SIMULATE 101
+
+
+typedef struct ImageStructTag {
+ int selectedState;
+ HIMAGELIST Images;
+ int ComponentId;
+} ImageStruct;
+
+typedef struct ImageLocationTag{
+ int Id;
+ ImageStruct* Image;
+ int Index;
+ int x;
+ int y;
+ void* Properties;
+ void* PinId;
+ void* PinName;
+}ImageLocation;
+
+typedef struct PinInfoTag{
+ double Volt;
+ double OperatingVolt;
+ void** ImageId;
+ int* Index;
+ int* ImageType; //To compare with imagelocation array
+ int LinkCount; //No of valid entries in array
+ double ProgVolt;
+ void* ProgComponent;
+}PinInfo;
+
+typedef struct PinMcuTag{
+ UINT PinId;
+ UINT state;
+ int type;
+ BOOL InternalPullup;
+}PinMcu;
+
+typedef struct PinNameTag{
+ UINT PinId; //Need to generate unique pinid every time user saves a name
+ TCHAR Name[MAX_NAME_LENGTH];
+ PinInfo PinData;
+}PinName;
+
+typedef struct PinComponentTag{
+ UINT PinId;
+ void** ComponentAddress;
+ int Count;
+ void* Next;
+}PinComponent;
+
+extern HANDLE ImageHeap;
+extern HFONT AdvNiceFont;
+extern HFONT AdvFixedFont;
+extern UINT NameCount;
+extern ImageLocation ImageStack[MAX_SCREEN_ITEMS];
+// extern PinInfo PinData[MAX_PINS];
+extern PinMcu McuPin[MAX_MCU_PINS];
+extern PinName NameId[MAX_PINS];
+extern HWND AdvancedDialog;
+extern PinComponent ComponentPin;
+
+/*Advanced Dialog Functions*/
+void MakeAdvancedDialogControls(void);
+void AdvancedDialogResized(void);
+void MakeAdvancedWindowMenus(void);
+void ProcessEvent(int x, int y, int Event);
+void AdvancedWindowClosing(void);
+void ToggleAdvancedSimulationMode(void);
+void SimulateOneAdvCycle(BOOL ForceRefresh);
+int IsMCUPin(int PinId);
+// void CreateVoltRequest(int PinId, int Index, double VoltReq);
+
+// Heap Functions
+void* AllocImageHeap(size_t n);
+void* ReallocImageHeap(LPVOID lpMem, size_t n);
+void FreeImageHeap(void *p);
+
+// Component Functions
+
+void InitComponents(void);
+
+double GetGlobalVoltage(int PinId, void* ComponentAddress);
+double RefreshVolt(int PinId, int Index, UINT Id, void* ComponentAddress, double volt);
+double RefreshProcessorStat(int PinId, UINT Id);
+
+
+int RegisterPinName(LPCTSTR Name);
+int SetPinImage(int PinId,void* ImageId,int ImageType, int Index);
+int FlushPinNames(void); //Clear Pins which are deleted from MainWindow
+int DeRegisterPinName(LPCTSTR Name, void* ImageId);
+int DeletePinImage(LPCTSTR Name, void* ImageId, int Index);
+int DeletePinName(UINT Index);
+void SetMcu(int PinId, int Type);
+void RefreshNamingList(void);
+void PopulateNamingList(void);
+
+double RequestVoltChange(int PinId, int Index, void *ComponentAddress, double volt);
+
+int DeleteComponentPin(int PinId, void* ComponentAddress);
+int AddComponentPin(int PinId, void* ComponentAddress);
+// int RegisterPinState(int Index, double Volt);
+
+//NamingList functions
+void ToggleInternalPullup(int PinId);
+
+
+extern BOOL SimulationStarted;
+
+#endif
diff --git a/ldmicro/includes/componentlist.h b/ldmicro/includes/componentlist.h
new file mode 100644
index 0000000..20c095b
--- /dev/null
+++ b/ldmicro/includes/componentlist.h
@@ -0,0 +1,71 @@
+//-----------------------------------------------------------------------------
+// Copyright 2007 Jonathan Westhues
+//
+// This file is part of LDmicro.
+//
+// LDmicro 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 3 of the License, or
+// (at your option) any later version.
+//
+// LDmicro 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 LDmicro. If not, see .
+//------
+//
+// Constants, structures, declarations etc. for the PIC ladder logic compiler
+// Jonathan Westhues, Oct 2004
+//-----------------------------------------------------------------------------
+
+#ifndef __COMPONENTLIST_H
+#define __COMPONENTLIST_H
+
+#define MAX_COMPONENTS 999
+#define MAX_IMAGES 10
+
+#define COMPONENT_WIDTH 100
+#define COMPONENT_HEIGHT 100
+
+extern HDC HdcMem;
+extern HWND ComponentList;
+extern HBITMAP test;
+extern HIMAGELIST ComponentDiagrams;
+extern HWND AdvancedWorkspace;
+extern BOOL Dragging;
+extern int ImagesDrawn;
+extern int DragX;
+extern int DragY;
+extern UINT UniquePinId;
+extern UINT UniqueImgId;
+
+
+/*map Imagemap; //To relate image with it's drawing area(Index,Images,x,y,maptype)
+map Switchmap; //Add MCU pin later //(Index(same as Imagemap), Selected, Default Connected,Latch Action)
+map Relaymap; //Add MCU pin later //(Index(same as Imagemap), Selected)
+
+extern Imagemap test;*/
+
+void ComponentListProc(NMHDR *h);
+void ComponentListInitiate(void);
+
+void InitializeImageList(HIMAGELIST *il);
+
+int BeginComponentDrag(int x, int y);
+int ComponentDrag(int x, int y);
+int EndComponentDrag(int x, int y);
+
+// Componentimages.cpp functions
+//Function Definitions
+
+void InitializeComponentImage(int Component, HIMAGELIST *il);
+IStream * CreateStreamOnResource(LPCTSTR lpName, LPCTSTR lpType);
+IWICBitmapSource * LoadBitmapFromStream(IStream * ipImageStream);
+HBITMAP CreateHBITMAP(IWICBitmapSource * ipBitmap);
+HBITMAP LoadComponentImage(int resource);
+
+
+#endif
\ No newline at end of file
diff --git a/ldmicro/includes/components/componentfunctions.h b/ldmicro/includes/components/componentfunctions.h
new file mode 100644
index 0000000..916bf00
--- /dev/null
+++ b/ldmicro/includes/components/componentfunctions.h
@@ -0,0 +1,63 @@
+#ifndef _COMPONENT_FUNCTIONS
+#define _COMPONENT_FUNCTIONS
+
+//Few Prerequisites
+extern HFONT MyNiceFont;
+extern HFONT MyFixedFont;
+extern HWND OkButton;
+extern HWND CancelButton;
+extern HINSTANCE* ComponentInstance;
+
+extern BOOL DlgDone;
+extern BOOL DlgCancel;
+extern HWND ComponentDialog;
+
+// Common Functions
+
+void FontNice(HWND h);
+void FontFixed(HWND h);
+HWND* CreateDialogWindow(LPCTSTR title, int x, int y, int width, int height, int style);
+void ShowDialogWindow(void);
+BOOL ProcessDialogWindow(void);
+
+/*Initialization Functions*/
+int InitSwitch(void* ComponentAddress);
+int InitRelay(void* ComponentAddress);
+int InitSpdt(void* ComponentAddress);
+int InitDpst(void* ComponentAddress);
+int InitDpdt(void* ComponentAddress);
+
+/*Event Handlers*/
+void HandleSwitchEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleRelayEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleSpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleDpstEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+void HandleDpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
+ void* ImageLocation, UINT ImageId, HWND* h);
+
+/*Request Handlers*/
+double SwitchVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double RelayVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double SpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double DpstVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+double DpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
+ double Volt, int Source, void* ImageLocation);
+
+/*Program Reference Functions*/
+void SetSwitchIds(int*, void*);
+void SetRelayIds(int*, void*);
+void SetSpdtIds(int*, void*);
+void SetDpstIds(int*, void*);
+void SetDpdtIds(int*, void*);
+
+// Relay Functions
+
+#endif
diff --git a/ldmicro/includes/components/componentimages.h b/ldmicro/includes/components/componentimages.h
new file mode 100644
index 0000000..27ef6ce
--- /dev/null
+++ b/ldmicro/includes/components/componentimages.h
@@ -0,0 +1,53 @@
+#ifndef __COMPONENTIMAGES_H
+#define __COMPONENTIMAGES_H
+
+#define SWITCH_CONNECTED 8000
+#define SWITCH_DISCONNECTED 8001
+#define RELAY_NC 8002
+#define RELAY_NO 8003
+#define SPDT_1 8004
+#define SPDT_2 8005
+#define DPST_1 8006
+#define DPST_2 8007
+#define DPDT_1 8008
+#define DPDT_2 8009
+
+
+
+#ifndef RC_INVOKED //Used to hide code from resource file(Guess)
+
+#define TOTAL_COMPONENTS 5
+#define COMPONENT_NAME_MAX_LENGTH 50
+
+// Try to keep ComponentID's between 6000 - 6999
+
+#define COMPONENT_SWITCH 6000
+#define COMPONENT_RELAY 6001
+#define COMPONENT_SPDT 6002
+#define COMPONENT_DPST 6003
+#define COMPONENT_DPDT 6004
+
+
+#define MAX_PIN_COUNT 10
+
+typedef struct ComponentDataTag{
+ int Index;
+ int ComponentId;
+ TCHAR ComponentName[COMPONENT_NAME_MAX_LENGTH];
+ int PinCount;
+ LPCTSTR PinNames[MAX_PIN_COUNT]; //Valid Number of images from below property
+}ComponentData;
+
+void RefreshImages();
+void SetImage(int Component, void *il);
+
+static ComponentData rgCompData[TOTAL_COMPONENTS] = {
+ {0, COMPONENT_SWITCH, TEXT("Switch"), 2, {"Input:", "Output:"}},
+ {1, COMPONENT_RELAY, TEXT("Relay"), 5, {"Coil1:", "Coil2:", "NO:", "COM:", "NC:"}},
+ {2, COMPONENT_SPDT, TEXT("SPDT"), 3, {"Input:", "Output1:", "Output2:"}},
+ {3, COMPONENT_DPST, TEXT("DPST"), 4, {"Input1:", "Input2:", "Output1:", "Output2:"}},
+ {4, COMPONENT_DPDT, TEXT("DPDT"), 6, {"Input1:", "Input2:", "Output11:", "Output12:", "Output21:", "Output22:"}}
+};
+
+#endif
+#endif
diff --git a/ldmicro/includes/components/components.h b/ldmicro/includes/components/components.h
new file mode 100644
index 0000000..810c2d2
--- /dev/null
+++ b/ldmicro/includes/components/components.h
@@ -0,0 +1,51 @@
+#ifndef _COMPONENTS_H
+#define _COMPONENTS_H
+
+#define EVENT_VALUE_CHANGED 0
+#define EVENT_MOUSE_CLICK 1
+#define EVENT_MOUSE_DOWN 2
+#define EVENT_MOUSE_UP 3
+#define EVENT_MOUSE_RDOWN 4
+#define EVENT_MOUSE_RUP 5
+#define EVENT_MOUSE_DBLCLICK 6
+#define EVENT_MOUSE_RCLICK 7
+
+
+
+#define SOURCE_PROGRAM_MAIN 1
+#define SOURCE_PROGRAM_NEW 2
+#define SOURCE_EVENT_MAIN 3
+#define SOURCE_EVENT_NEW 4
+#define SOURCE_FORCE_MAIN 5
+#define SOURCE_REQUEST_MAIN 6
+
+/*#define EVENT_KEY_DOWN 6
+#define EVENT_KEY_RELEASE 7
+#define EVENT_KEY_PRESS 8*/
+#define V_DIALOG_WIDTH 96
+#define V_DIALOG_HEIGHT 115
+#define H_DIALOG_WIDTH 179
+#define H_DIALOG_HEIGHT 85
+
+//Window styles for dialog box
+#define STYLE_HORIZONTAL 1
+#define STYLE_VERTICAL 2
+
+#define GND 0
+#define VOLT_5 5
+#define V_OPEN 4196
+
+int NotifyComponent(void *ComponentAddress, void* PinName, int ComponentId, int Event,
+ BOOL SimulationStarted, HWND* h, int Index, UINT ImageId, void* ImageLocation);
+int InitializeComponentProperties(void *ComponentAddress, int ComponentId);
+double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, int Index,
+ double Volt, int Source, void* ImageLocation);
+
+double VoltRequest(int PinId, void* ComponentAddress);
+// void RequestData(void* ComponentAddress);
+// double GlobalVoltChange(int PinId, void *ComponentAddress, double volt);
+double VoltChange(int PinId, int Index, void* ComponentAddress, double Volt);
+size_t GetStructSize(int ComponentId);
+size_t GetNameSize(int ComponentId);
+
+#endif
diff --git a/ldmicro/includes/components/componentstructs.h b/ldmicro/includes/components/componentstructs.h
new file mode 100644
index 0000000..76dadda
--- /dev/null
+++ b/ldmicro/includes/components/componentstructs.h
@@ -0,0 +1,62 @@
+#ifndef _COMPONENT_STRUCTS
+#define _COMPONENT_STRUCTS
+
+typedef struct SwitchStructTag
+{
+ int id;
+ int Image;
+ BOOL Latched; //Temporary/Latched Action
+ BOOL NOpen; //Initial Open/Closed position
+ BOOL Open;
+ char Name[15];
+ double Volt[2];
+ int PinId[2];
+}SwitchStruct;
+
+typedef struct RelayStructTag
+{
+ int id;
+ int Image;
+ BOOL NC; //Whether relay is operated
+ double MinOperatingVolt; //Operating voltage
+ double MaxOperatingVolt;
+ double CoilVolt1; //Voltage at input pin
+ double CoilVolt2; //Voltage at input pin
+ double COMVolt; //Voltage at COM pin
+ double NOVolt; //Voltage at NO pin
+ double NCVolt; //Voltage at NC pin
+ int PinId[5];
+
+}RelayStruct;
+
+typedef struct SpdtStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NO1; //Whether Output 1 is connected
+ double Volt[3]; //Voltage at Input, Output1, Output2 respectively
+ int PinId[3];
+}SpdtStruct;
+
+typedef struct DpstStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NO; //Whether the inputs and outputs are disconnected (Open)
+ double Volt[4]; // Voltage at Input1, Input2, Output1, Output2 respectively
+ int PinId[4];
+}DpstStruct;
+
+typedef struct DpdtStructTag
+{
+ int id;
+ int image;
+ BOOL latched; //Whether the swetch is in latch mode or not
+ BOOL NS1; //Whether the inputs and outputs are connected in state 1
+ double Volt[6]; // Voltage at Input1, Input2, Output11, Output12, Output21, Output22 respectively
+ int PinId[6];
+}DpdtStruct;
+
+#endif
diff --git a/ldmicro/includes/intcode.h b/ldmicro/includes/intcode.h
new file mode 100644
index 0000000..f265a8d
--- /dev/null
+++ b/ldmicro/includes/intcode.h
@@ -0,0 +1,83 @@
+//-----------------------------------------------------------------------------
+// Copyright 2007 Jonathan Westhues
+//
+// This file is part of LDmicro.
+//
+// LDmicro 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 3 of the License, or
+// (at your option) any later version.
+//
+// LDmicro 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 LDmicro. If not, see .
+//------
+//
+// Description of the intermediate code that we generate. The routines in
+// intcode.cpp generate this intermediate code from the program source. Then
+// either we simulate the intermediate code with the routines in simulate.cpp
+// or we convert it to PIC or AVR instructions so that it can run on a
+// real device.
+// Jonathan Westhues, Nov 2004
+//-----------------------------------------------------------------------------
+
+#ifndef __INTCODE_H
+#define __INTCODE_H
+
+#define INT_SET_BIT 1
+#define INT_CLEAR_BIT 2
+#define INT_COPY_BIT_TO_BIT 3
+#define INT_SET_VARIABLE_TO_LITERAL 4
+#define INT_SET_VARIABLE_TO_VARIABLE 5
+#define INT_INCREMENT_VARIABLE 6
+#define INT_SET_VARIABLE_ADD 7
+#define INT_SET_VARIABLE_SUBTRACT 8
+#define INT_SET_VARIABLE_MULTIPLY 9
+#define INT_SET_VARIABLE_DIVIDE 10
+
+#define INT_READ_ADC 11
+#define INT_SET_PWM 12
+#define INT_UART_SEND 13
+#define INT_UART_RECV 14
+#define INT_EEPROM_BUSY_CHECK 15
+#define INT_EEPROM_READ 16
+#define INT_EEPROM_WRITE 17
+
+#define INT_IF_GROUP(x) (((x) >= 50) && ((x) < 60))
+#define INT_IF_BIT_SET 50
+#define INT_IF_BIT_CLEAR 51
+#define INT_IF_VARIABLE_LES_LITERAL 52
+#define INT_IF_VARIABLE_EQUALS_VARIABLE 53
+#define INT_IF_VARIABLE_GRT_VARIABLE 54
+
+#define INT_ELSE 60
+#define INT_END_IF 61
+
+#define INT_SIMULATE_NODE_STATE 80
+
+#define INT_COMMENT 100
+
+// Only used for the interpretable code.
+#define INT_END_OF_PROGRAM 255
+
+#if !defined(INTCODE_H_CONSTANTS_ONLY)
+ typedef struct IntOpTag {
+ int op;
+ char name1[MAX_NAME_LEN];
+ char name2[MAX_NAME_LEN];
+ char name3[MAX_NAME_LEN];
+ SWORD literal;
+ BOOL *poweredAfter;
+ } IntOp;
+
+ #define MAX_INT_OPS (1024*16)
+ extern IntOp IntCode[MAX_INT_OPS];
+ extern int IntCodeLen;
+#endif
+
+
+#endif
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
new file mode 100644
index 0000000..2c6f720
--- /dev/null
+++ b/ldmicro/includes/ldmicro.h
@@ -0,0 +1,781 @@
+//-----------------------------------------------------------------------------
+// Copyright 2007 Jonathan Westhues
+//
+// This file is part of LDmicro.
+//
+// LDmicro 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 3 of the License, or
+// (at your option) any later version.
+//
+// LDmicro 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 LDmicro. If not, see .
+//------
+//
+// Constants, structures, declarations etc. for the PIC ladder logic compiler
+// Jonathan Westhues, Oct 2004
+//-----------------------------------------------------------------------------
+
+#ifndef __LDMICRO_H
+#define __LDMICRO_H
+
+#include
+typedef signed short SWORD;
+typedef signed long SDWORD;
+
+//-----------------------------------------------
+// `Configuration options.'
+
+// The library that I use to do registry stuff.
+#define FREEZE_SUBKEY "LDMicro"
+
+// Size of the font that we will use to draw the ladder diagrams, in pixels
+#define FONT_WIDTH 7
+#define FONT_HEIGHT 13
+
+
+//-----------------------------------------------
+// Constants for the GUI. We have drop-down menus, a listview for the I/Os,
+// etc.
+
+// Menu IDs
+
+#define MNU_NEW 0x01
+#define MNU_OPEN 0x02
+#define MNU_SAVE 0x03
+#define MNU_SAVE_AS 0x04
+#define MNU_EXPORT 0x05
+#define MNU_EXIT 0x06
+
+#define MNU_UNDO 0x10
+#define MNU_REDO 0x11
+#define MNU_PUSH_RUNG_UP 0x12
+#define MNU_PUSH_RUNG_DOWN 0x13
+#define MNU_INSERT_RUNG_BEFORE 0x14
+#define MNU_INSERT_RUNG_AFTER 0x15
+#define MNU_DELETE_ELEMENT 0x16
+#define MNU_DELETE_RUNG 0x17
+
+#define MNU_INSERT_COMMENT 0x20
+#define MNU_INSERT_CONTACTS 0x21
+#define MNU_INSERT_COIL 0x22
+#define MNU_INSERT_TON 0x23
+#define MNU_INSERT_TOF 0x24
+#define MNU_INSERT_RTO 0x25
+#define MNU_INSERT_RES 0x26
+#define MNU_INSERT_OSR 0x27
+#define MNU_INSERT_OSF 0x28
+#define MNU_INSERT_CTU 0x29
+#define MNU_INSERT_CTD 0x2a
+#define MNU_INSERT_CTC 0x2b
+#define MNU_INSERT_ADD 0x2c
+#define MNU_INSERT_SUB 0x2d
+#define MNU_INSERT_MUL 0x2e
+#define MNU_INSERT_DIV 0x2f
+#define MNU_INSERT_MOV 0x30
+#define MNU_INSERT_READ_ADC 0x31
+#define MNU_INSERT_SET_PWM 0x32
+#define MNU_INSERT_UART_SEND 0x33
+#define MNU_INSERT_UART_RECV 0x34
+#define MNU_INSERT_EQU 0x35
+#define MNU_INSERT_NEQ 0x36
+#define MNU_INSERT_GRT 0x37
+#define MNU_INSERT_GEQ 0x38
+#define MNU_INSERT_LES 0x39
+#define MNU_INSERT_LEQ 0x3a
+#define MNU_INSERT_OPEN 0x3b
+#define MNU_INSERT_SHORT 0x3c
+#define MNU_INSERT_MASTER_RLY 0x3d
+#define MNU_INSERT_SHIFT_REG 0x3e
+#define MNU_INSERT_LUT 0x3f
+#define MNU_INSERT_FMTD_STR 0x40
+#define MNU_INSERT_PERSIST 0x41
+#define MNU_MAKE_NORMAL 0x42
+#define MNU_NEGATE 0x43
+#define MNU_MAKE_SET_ONLY 0x44
+#define MNU_MAKE_RESET_ONLY 0x45
+#define MNU_INSERT_PWL 0x46
+
+#define MNU_MCU_SETTINGS 0x50
+#define MNU_PROCESSOR_0 0xa0
+
+#define MNU_SIMULATION_MODE 0x60
+#define MNU_START_SIMULATION 0x61
+#define MNU_STOP_SIMULATION 0x62
+#define MNU_SINGLE_CYCLE 0x63
+
+#define MNU_COMPILE 0x70
+#define MNU_COMPILE_AS 0x71
+
+#define MNU_MANUAL 0x80
+#define MNU_ABOUT 0x81
+
+#define MNU_ADV_SIMULATION 0x82
+
+// Columns within the I/O etc. listview.
+#define LV_IO_NAME 0x00
+#define LV_IO_TYPE 0x01
+#define LV_IO_STATE 0x02
+#define LV_IO_PIN 0x03
+#define LV_IO_PORT 0x04
+
+// Timer IDs associated with the main window.
+#define TIMER_BLINK_CURSOR 1
+#define TIMER_SIMULATE 2
+
+//-----------------------------------------------
+// Data structures for the actual ladder logic. A rung on the ladder
+// is a series subcircuit. A series subcircuit contains elements or
+// parallel subcircuits. A parallel subcircuit contains elements or series
+// subcircuits. An element is a set of contacts (possibly negated) or a coil.
+
+#define MAX_ELEMENTS_IN_SUBCKT 16
+
+#define ELEM_PLACEHOLDER 0x01
+#define ELEM_SERIES_SUBCKT 0x02
+#define ELEM_PARALLEL_SUBCKT 0x03
+#define ELEM_PADDING 0x04
+#define ELEM_COMMENT 0x05
+
+#define ELEM_CONTACTS 0x10
+#define ELEM_COIL 0x11
+#define ELEM_TON 0x12
+#define ELEM_TOF 0x13
+#define ELEM_RTO 0x14
+#define ELEM_RES 0x15
+#define ELEM_ONE_SHOT_RISING 0x16
+#define ELEM_ONE_SHOT_FALLING 0x17
+#define ELEM_MOVE 0x18
+#define ELEM_ADD 0x19
+#define ELEM_SUB 0x1a
+#define ELEM_MUL 0x1b
+#define ELEM_DIV 0x1c
+#define ELEM_EQU 0x1d
+#define ELEM_NEQ 0x1e
+#define ELEM_GRT 0x1f
+#define ELEM_GEQ 0x20
+#define ELEM_LES 0x21
+#define ELEM_LEQ 0x22
+#define ELEM_CTU 0x23
+#define ELEM_CTD 0x24
+#define ELEM_CTC 0x25
+#define ELEM_SHORT 0x26
+#define ELEM_OPEN 0x27
+#define ELEM_READ_ADC 0x28
+#define ELEM_SET_PWM 0x29
+#define ELEM_UART_RECV 0x2a
+#define ELEM_UART_SEND 0x2b
+#define ELEM_MASTER_RELAY 0x2c
+#define ELEM_SHIFT_REGISTER 0x2d
+#define ELEM_LOOK_UP_TABLE 0x2e
+#define ELEM_FORMATTED_STRING 0x2f
+#define ELEM_PERSIST 0x30
+#define ELEM_PIECEWISE_LINEAR 0x31
+
+#define CASE_LEAF \
+ case ELEM_PLACEHOLDER: \
+ case ELEM_COMMENT: \
+ case ELEM_COIL: \
+ case ELEM_CONTACTS: \
+ case ELEM_TON: \
+ case ELEM_TOF: \
+ case ELEM_RTO: \
+ case ELEM_CTD: \
+ case ELEM_CTU: \
+ case ELEM_CTC: \
+ case ELEM_RES: \
+ case ELEM_ONE_SHOT_RISING: \
+ case ELEM_ONE_SHOT_FALLING: \
+ case ELEM_EQU: \
+ case ELEM_NEQ: \
+ case ELEM_GRT: \
+ case ELEM_GEQ: \
+ case ELEM_LES: \
+ case ELEM_LEQ: \
+ case ELEM_ADD: \
+ case ELEM_SUB: \
+ case ELEM_MUL: \
+ case ELEM_DIV: \
+ case ELEM_MOVE: \
+ case ELEM_SHORT: \
+ case ELEM_OPEN: \
+ case ELEM_READ_ADC: \
+ case ELEM_SET_PWM: \
+ case ELEM_UART_SEND: \
+ case ELEM_UART_RECV: \
+ case ELEM_MASTER_RELAY: \
+ case ELEM_SHIFT_REGISTER: \
+ case ELEM_LOOK_UP_TABLE: \
+ case ELEM_PIECEWISE_LINEAR: \
+ case ELEM_FORMATTED_STRING: \
+ case ELEM_PERSIST:
+
+#define MAX_NAME_LEN 128
+#define MAX_COMMENT_LEN 384
+#define MAX_LOOK_UP_TABLE_LEN 60
+
+typedef struct ElemSubckParallelTag ElemSubcktParallel;
+
+typedef struct ElemCommentTag {
+ char str[MAX_COMMENT_LEN];
+} ElemComment;
+
+typedef struct ElemContactsTag {
+ char name[MAX_NAME_LEN];
+ BOOL negated;
+} ElemContacts;
+
+typedef struct ElemCoilTag {
+ char name[MAX_NAME_LEN];
+ BOOL negated;
+ BOOL setOnly;
+ BOOL resetOnly;
+} ElemCoil;
+
+typedef struct ElemTimeTag {
+ char name[MAX_NAME_LEN];
+ int delay;
+} ElemTimer;
+
+typedef struct ElemResetTag {
+ char name[MAX_NAME_LEN];
+} ElemReset;
+
+typedef struct ElemMoveTag {
+ char src[MAX_NAME_LEN];
+ char dest[MAX_NAME_LEN];
+} ElemMove;
+
+typedef struct ElemMathTag {
+ char op1[MAX_NAME_LEN];
+ char op2[MAX_NAME_LEN];
+ char dest[MAX_NAME_LEN];
+} ElemMath;
+
+typedef struct ElemCmpTag {
+ char op1[MAX_NAME_LEN];
+ char op2[MAX_NAME_LEN];
+} ElemCmp;
+
+typedef struct ElemCounterTag {
+ char name[MAX_NAME_LEN];
+ int max;
+} ElemCounter;
+
+typedef struct ElemReadAdcTag {
+ char name[MAX_NAME_LEN];
+} ElemReadAdc;
+
+typedef struct ElemSetPwmTag {
+ char name[MAX_NAME_LEN];
+ int targetFreq;
+} ElemSetPwm;
+
+typedef struct ElemUartTag {
+ char name[MAX_NAME_LEN];
+} ElemUart;
+
+typedef struct ElemShiftRegisterTag {
+ char name[MAX_NAME_LEN];
+ int stages;
+} ElemShiftRegister;
+
+typedef struct ElemLookUpTableTag {
+ char dest[MAX_NAME_LEN];
+ char index[MAX_NAME_LEN];
+ int count;
+ BOOL editAsString;
+ SWORD vals[MAX_LOOK_UP_TABLE_LEN];
+} ElemLookUpTable;
+
+typedef struct ElemPiecewiseLinearTag {
+ char dest[MAX_NAME_LEN];
+ char index[MAX_NAME_LEN];
+ int count;
+ SWORD vals[MAX_LOOK_UP_TABLE_LEN];
+} ElemPiecewiseLinear;
+
+typedef struct ElemFormattedStringTag {
+ char var[MAX_NAME_LEN];
+ char string[MAX_LOOK_UP_TABLE_LEN];
+} ElemFormattedString;
+
+typedef struct ElemPerisistTag {
+ char var[MAX_NAME_LEN];
+} ElemPersist;
+
+#define SELECTED_NONE 0
+#define SELECTED_ABOVE 1
+#define SELECTED_BELOW 2
+#define SELECTED_RIGHT 3
+#define SELECTED_LEFT 4
+typedef struct ElemLeafTag {
+ int selectedState;
+ BOOL poweredAfter;
+ union {
+ ElemComment comment;
+ ElemContacts contacts;
+ ElemCoil coil;
+ ElemTimer timer;
+ ElemReset reset;
+ ElemMove move;
+ ElemMath math;
+ ElemCmp cmp;
+ ElemCounter counter;
+ ElemReadAdc readAdc;
+ ElemSetPwmTag setPwm;
+ ElemUart uart;
+ ElemShiftRegister shiftRegister;
+ ElemFormattedString fmtdStr;
+ ElemLookUpTable lookUpTable;
+ ElemPiecewiseLinear piecewiseLinear;
+ ElemPersist persist;
+ } d;
+} ElemLeaf;
+
+typedef struct ElemSubcktSeriesTag {
+ struct {
+ int which;
+ union {
+ void *any;
+ ElemSubcktParallel *parallel;
+ ElemLeaf *leaf;
+ } d;
+ } contents[MAX_ELEMENTS_IN_SUBCKT];
+ int count;
+} ElemSubcktSeries;
+
+typedef struct ElemSubckParallelTag {
+ struct {
+ int which;
+ union {
+ void *any;
+ ElemSubcktSeries *series;
+ ElemLeaf *leaf;
+ } d;
+ } contents[MAX_ELEMENTS_IN_SUBCKT];
+ int count;
+} ElemSubcktParallel;
+
+typedef struct McuIoInfoTag McuIoInfo;
+
+typedef struct PlcProgramSingleIoTag {
+ char name[MAX_NAME_LEN];
+#define IO_TYPE_PENDING 0
+
+#define IO_TYPE_DIG_INPUT 1
+#define IO_TYPE_DIG_OUTPUT 2
+#define IO_TYPE_READ_ADC 3
+#define IO_TYPE_UART_TX 4
+#define IO_TYPE_UART_RX 5
+#define IO_TYPE_PWM_OUTPUT 6
+#define IO_TYPE_INTERNAL_RELAY 7
+#define IO_TYPE_TON 8
+#define IO_TYPE_TOF 9
+#define IO_TYPE_RTO 10
+#define IO_TYPE_COUNTER 11
+#define IO_TYPE_GENERAL 12
+ int type;
+#define NO_PIN_ASSIGNED 0
+ int pin;
+} PlcProgramSingleIo;
+
+#define MAX_IO 512
+typedef struct PlcProgramTag {
+ struct {
+ PlcProgramSingleIo assignment[MAX_IO];
+ int count;
+ } io;
+ McuIoInfo *mcu;
+ int cycleTime;
+ int mcuClock;
+ int baudRate;
+
+#define MAX_RUNGS 99
+ ElemSubcktSeries *rungs[MAX_RUNGS];
+ BOOL rungPowered[MAX_RUNGS];
+ int numRungs;
+} PlcProgram;
+
+//-----------------------------------------------
+// For actually drawing the ladder logic on screen; constants that determine
+// how the boxes are laid out in the window, need to know that lots of
+// places for figuring out if a mouse click is in a box etc.
+
+// dimensions, in characters, of the area reserved for 1 leaf element
+#define POS_WIDTH 17
+#define POS_HEIGHT 3
+
+// offset from the top left of the window at which we start drawing, in pixels
+#define X_PADDING 35
+#define Y_PADDING 14
+
+typedef struct PlcCursorTag {
+ int left;
+ int top;
+ int width;
+ int height;
+} PlcCursor;
+
+//-----------------------------------------------
+// The syntax highlighting style colours; a structure for the palette.
+
+typedef struct SyntaxHighlightingColoursTag {
+ COLORREF bg; // background
+ COLORREF def; // default foreground
+ COLORREF selected; // selected element
+ COLORREF op; // `op code' (like OSR, OSF, ADD, ...)
+ COLORREF punct; // punctuation, like square or curly braces
+ COLORREF lit; // a literal number
+ COLORREF name; // the name of an item
+ COLORREF rungNum; // rung numbers
+ COLORREF comment; // user-written comment text
+
+ COLORREF bus; // the `bus' at the right and left of screen
+
+ COLORREF simBg; // background, simulation mode
+ COLORREF simRungNum; // rung number, simulation mode
+ COLORREF simOff; // de-energized element, simulation mode
+ COLORREF simOn; // energzied element, simulation mode
+ COLORREF simBusLeft; // the `bus,' can be different colours for
+ COLORREF simBusRight; // right and left of the screen
+} SyntaxHighlightingColours;
+extern SyntaxHighlightingColours HighlightColours;
+
+//-----------------------------------------------
+// Processor definitions. These tables tell us where to find the I/Os on
+// a processor, what bit in what register goes with what pin, etc. There
+// is one master SupportedMcus table, which contains entries for each
+// supported microcontroller.
+
+typedef struct McuIoPinInfoTag {
+ char port;
+ int bit;
+ int pin;
+} McuIoPinInfo;
+
+typedef struct McuAdcPinInfoTag {
+ int pin;
+ BYTE muxRegValue;
+} McuAdcPinInfo;
+
+#define ISA_AVR 0x00
+#define ISA_PIC16 0x01
+#define ISA_ANSIC 0x02
+#define ISA_INTERPRETED 0x03
+#define ISA_ARDUINO 0x04
+
+#define MAX_IO_PORTS 10
+#define MAX_RAM_SECTIONS 5
+
+typedef struct McuIoInfoTag {
+ char *mcuName;
+ char portPrefix;
+ DWORD inputRegs[MAX_IO_PORTS]; // a is 0, j is 9
+ DWORD outputRegs[MAX_IO_PORTS];
+ DWORD dirRegs[MAX_IO_PORTS];
+ DWORD flashWords;
+ struct {
+ DWORD start;
+ int len;
+ } ram[MAX_RAM_SECTIONS];
+ McuIoPinInfo *pinInfo;
+ int pinCount;
+ McuAdcPinInfo *adcInfo;
+ int adcCount;
+ int adcMax;
+ struct {
+ int rxPin;
+ int txPin;
+ } uartNeeds;
+ int pwmNeedsPin;
+ int whichIsa;
+ BOOL avrUseIjmp;
+ DWORD configurationWord;
+} McuIoInfo;
+
+#define NUM_SUPPORTED_MCUS 16
+
+
+//-----------------------------------------------
+// Function prototypes
+
+// ldmicro.cpp
+void ProgramChanged(void);
+void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
+ BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther,
+ BOOL canPushRungDown, BOOL canPushRungUp, BOOL canInsertComment);
+void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled);
+void RefreshScrollbars(void);
+extern HINSTANCE Instance;
+extern HWND MainWindow;
+extern HDC Hdc;
+extern PlcProgram Prog;
+extern char CurrentSaveFile[MAX_PATH];
+extern char CurrentCompileFile[MAX_PATH];
+extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
+// memory debugging, because I often get careless; ok() will check that the
+// heap used for all the program storage is not yet corrupt, and oops() if
+// it is
+void CheckHeap(char *file, int line);
+#define ok() CheckHeap(__FILE__, __LINE__)
+
+// maincontrols.cpp
+void MakeMainWindowControls(void);
+HMENU MakeMainWindowMenus(void);
+void VscrollProc(WPARAM wParam);
+void HscrollProc(WPARAM wParam);
+void GenerateIoListDontLoseSelection(void);
+void RefreshControlsToSettings(void);
+void MainWindowResized(void);
+void ToggleSimulationMode(void);
+void StopSimulation(void);
+void StartSimulation(void);
+void UpdateMainWindowTitleBar(void);
+extern int ScrollWidth;
+extern int ScrollHeight;
+extern BOOL NeedHoriz;
+extern HWND IoList;
+extern int IoListTop;
+extern int IoListHeight;
+
+// draw.cpp
+int ProgCountWidestRow(void);
+int CountHeightOfElement(int which, void *elem);
+BOOL DrawElement(int which, void *elem, int *cx, int *cy, BOOL poweredBefore);
+void DrawEndRung(int cx, int cy);
+extern int ColsAvailable;
+extern BOOL SelectionActive;
+extern BOOL ThisHighlighted;
+
+// draw_outputdev.cpp
+extern void (*DrawChars)(int, int, char *);
+void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time);
+void PaintWindow(void);
+void ExportDrawingAsText(char *file);
+void InitForDrawing(void);
+void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert);
+int ScreenRowsAvailable(void);
+int ScreenColsAvailable(void);
+extern HFONT FixedWidthFont;
+extern HFONT FixedWidthFontBold;
+extern int SelectedGxAfterNextPaint;
+extern int SelectedGyAfterNextPaint;
+extern BOOL ScrollSelectedIntoViewAfterNextPaint;
+extern int ScrollXOffset;
+extern int ScrollYOffset;
+extern int ScrollXOffsetMax;
+extern int ScrollYOffsetMax;
+
+// schematic.cpp
+void SelectElement(int gx, int gy, int state);
+void MoveCursorKeyboard(int keyCode);
+void MoveCursorMouseClick(int x, int y);
+BOOL MoveCursorTopLeft(void);
+void EditElementMouseDoubleclick(int x, int y);
+void EditSelectedElement(void);
+void MakeResetOnlySelected(void);
+void MakeSetOnlySelected(void);
+void MakeNormalSelected(void);
+void NegateSelected(void);
+void ForgetFromGrid(void *p);
+void ForgetEverything(void);
+void WhatCanWeDoFromCursorAndTopology(void);
+BOOL FindSelected(int *gx, int *gy);
+void MoveCursorNear(int gx, int gy);
+
+#define DISPLAY_MATRIX_X_SIZE 16
+#define DISPLAY_MATRIX_Y_SIZE 512
+extern ElemLeaf *DisplayMatrix[DISPLAY_MATRIX_X_SIZE][DISPLAY_MATRIX_Y_SIZE];
+extern int DisplayMatrixWhich[DISPLAY_MATRIX_X_SIZE][DISPLAY_MATRIX_Y_SIZE];
+extern ElemLeaf DisplayMatrixFiller;
+#define PADDING_IN_DISPLAY_MATRIX (&DisplayMatrixFiller)
+#define VALID_LEAF(x) ((x) != NULL && (x) != PADDING_IN_DISPLAY_MATRIX)
+extern ElemLeaf *Selected;
+extern int SelectedWhich;
+
+extern PlcCursor Cursor;
+extern BOOL CanInsertEnd;
+extern BOOL CanInsertOther;
+extern BOOL CanInsertComment;
+
+// circuit.cpp
+void AddTimer(int which);
+void AddCoil(void);
+void AddContact(void);
+void AddEmpty(int which);
+void AddMove(void);
+void AddMath(int which);
+void AddCmp(int which);
+void AddReset(void);
+void AddCounter(int which);
+void AddReadAdc(void);
+void AddSetPwm(void);
+void AddUart(int which);
+void AddPersist(void);
+void AddComment(char *text);
+void AddShiftRegister(void);
+void AddMasterRelay(void);
+void AddLookUpTable(void);
+void AddPiecewiseLinear(void);
+void AddFormattedString(void);
+void DeleteSelectedFromProgram(void);
+void DeleteSelectedRung(void);
+void InsertRung(BOOL afterCursor);
+int RungContainingSelected(void);
+BOOL ItemIsLastInCircuit(ElemLeaf *item);
+BOOL UartFunctionUsed(void);
+BOOL PwmFunctionUsed(void);
+void PushRungUp(void);
+void PushRungDown(void);
+void NewProgram(void);
+ElemLeaf *AllocLeaf(void);
+ElemSubcktSeries *AllocSubcktSeries(void);
+ElemSubcktParallel *AllocSubcktParallel(void);
+void FreeCircuit(int which, void *any);
+void FreeEntireProgram(void);
+void UndoUndo(void);
+void UndoRedo(void);
+void UndoRemember(void);
+void UndoFlush(void);
+BOOL CanUndo(void);
+
+// loadsave.cpp
+BOOL LoadProjectFromFile(char *filename);
+BOOL SaveProjectToFile(char *filename);
+
+// iolist.cpp
+int GenerateIoList(int prevSel);
+void SaveIoListToFile(FILE *f);
+BOOL LoadIoListFromFile(FILE *f);
+void ShowIoDialog(int item);
+void IoListProc(NMHDR *h);
+void ShowAnalogSliderPopup(char *name);
+
+// commentdialog.cpp
+void ShowCommentDialog(char *comment);
+// contactsdialog.cpp
+void ShowContactsDialog(BOOL *negated, char *name);
+// coildialog.cpp
+void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name);
+
+//advanceddialog.cpp
+void ShowAdvancedDialog(void);
+void MakeAdvancedDialogClass(void);
+void MakeAdvancedWorkspaceClass(void);
+void TranslateState(char *name, BOOL state);
+void MCUPinState(char *name, BOOL state);
+void StartAdvSimulation(void);
+void StopAdvSimulation(void);
+extern BOOL AdvancedWindowOpen;
+
+//naminglist.cpp
+void MakeSmplDialogClass(void);
+
+// simpledialog.cpp
+void ShowTimerDialog(int which, int *delay, char *name);
+void ShowCounterDialog(int which, int *count, char *name);
+void ShowMoveDialog(char *dest, char *src);
+void ShowReadAdcDialog(char *name);
+void ShowSetPwmDialog(char *name, int *targetFreq);
+void ShowPersistDialog(char *var);
+void ShowUartDialog(int which, char *name);
+void ShowCmpDialog(int which, char *op1, char *op2);
+void ShowMathDialog(int which, char *dest, char *op1, char *op2);
+void ShowShiftRegisterDialog(char *name, int *stages);
+void ShowFormattedStringDialog(char *var, char *string);
+void ShowLookUpTableDialog(ElemLeaf *l);
+void ShowPiecewiseLinearDialog(ElemLeaf *l);
+void ShowResetDialog(char *name);
+// confdialog.cpp
+void ShowConfDialog(void);
+// helpdialog.cpp
+void ShowHelpDialog(BOOL about);
+
+// miscutil.cpp
+#define oops() { \
+ dbp("bad at %d %s\n", __LINE__, __FILE__); \
+ Error("Internal error at line %d file '%s'\n", __LINE__, __FILE__); \
+ exit(1); \
+ }
+void dbp(char *str, ...);
+void Error(char *str, ...);
+void *CheckMalloc(size_t n);
+void CheckFree(void *p);
+extern HANDLE MainHeap;
+void StartIhex(FILE *f);
+void WriteIhex(FILE *f, BYTE b);
+void FinishIhex(FILE *f);
+char *IoTypeToString(int ioType);
+void PinNumberForIo(char *dest, PlcProgramSingleIo *io);
+HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName,
+ DWORD style, int x, int y, int width, int height, HWND parent,
+ HMENU menu, HINSTANCE instance, void *param);
+
+void MakeComponentListClass(void);
+void MakeNamingListClass(void);
+void MakeDialogBoxClass(void);
+void NiceFont(HWND h);
+void FixedFont(HWND h);
+void CompileSuccessfulMessage(char *str);
+extern BOOL RunningInBatchMode;
+extern HFONT MyNiceFont;
+extern HFONT MyFixedFont;
+extern HWND OkButton;
+extern HWND CancelButton;
+extern BOOL DialogDone;
+extern BOOL DialogCancel;
+
+// lang.cpp
+char *_(char *in);
+
+// simulate.cpp
+void SimulateOneCycle(BOOL forceRefresh);
+void CALLBACK PlcCycleTimer(HWND hwnd, UINT msg, UINT_PTR id, DWORD time);
+void StartSimulationTimer(void);
+void ClearSimulationData(void);
+void DescribeForIoList(char *name, char *out);
+void SimulationToggleContact(char *name);
+void SimulationSetContact(char* name);
+void SimulationResetContact(char* name);
+void SetAdcShadow(char *name, SWORD val);
+SWORD GetAdcShadow(char *name);
+void DestroyUartSimulationWindow(void);
+void ShowUartSimulationWindow(void);
+extern BOOL InSimulationMode;
+extern BOOL SimulateRedrawAfterNextCycle;
+
+// compilecommon.cpp
+void AllocStart(void);
+DWORD AllocOctetRam(void);
+void AllocBitRam(DWORD *addr, int *bit);
+void MemForVariable(char *name, DWORD *addrl, DWORD *addrh);
+BYTE MuxForAdcVariable(char *name);
+void MemForSingleBit(char *name, BOOL forRead, DWORD *addr, int *bit);
+void MemCheckForErrorsPostCompile(void);
+void BuildDirectionRegisters(BYTE *isInput, BYTE *isOutput);
+void ComplainAboutBaudRateError(int divisor, double actual, double err);
+void ComplainAboutBaudRateOverflow(void);
+#define CompileError() longjmp(CompileErrorBuf, 1)
+extern jmp_buf CompileErrorBuf;
+
+// intcode.cpp
+void IntDumpListing(char *outFile);
+BOOL GenerateIntermediateCode(void);
+// pic16.cpp
+void CompilePic16(char *outFile);
+// avr.cpp
+void CompileAvr(char *outFile);
+// ansic.cpp
+void CompileAnsiC(char *outFile);
+// interpreted.c
+void CompileInterpreted(char *outFile);
+//Arduino.cpp
+void CompileArduino(char *outFile);
+
+#endif
diff --git a/ldmicro/includes/mcutable.h b/ldmicro/includes/mcutable.h
new file mode 100644
index 0000000..14964ad
--- /dev/null
+++ b/ldmicro/includes/mcutable.h
@@ -0,0 +1,862 @@
+//-----------------------------------------------------------------------------
+// Copyright 2007 Jonathan Westhues
+//
+// This file is part of LDmicro.
+//
+// LDmicro 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 3 of the License, or
+// (at your option) any later version.
+//
+// LDmicro 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 LDmicro. If not, see .
+//------
+//
+// The table of supported MCUs, used to determine where the IOs are, what
+// instruction set, what init code, etc.
+// Jonathan Westhues, Oct 2004
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// ATmega128 or ATmega64
+
+McuIoPinInfo AvrAtmega128_64TQFPIoPinInfo[] = {
+ { 'E', 0, 2 },
+ { 'E', 1, 3 },
+ { 'E', 2, 4 },
+ { 'E', 3, 5 },
+ { 'E', 4, 6 },
+ { 'E', 5, 7 },
+ { 'E', 6, 8 },
+ { 'E', 7, 9 },
+
+ { 'B', 0, 10 },
+ { 'B', 1, 11 },
+ { 'B', 2, 12 },
+ { 'B', 3, 13 },
+ { 'B', 4, 14 },
+ { 'B', 5, 15 },
+ { 'B', 6, 16 },
+ { 'B', 7, 17 },
+
+ { 'G', 3, 18 },
+ { 'G', 4, 19 },
+
+ { 'D', 0, 25 },
+ { 'D', 1, 26 },
+ { 'D', 2, 27 },
+ { 'D', 3, 28 },
+ { 'D', 4, 29 },
+ { 'D', 5, 30 },
+ { 'D', 6, 31 },
+ { 'D', 7, 32 },
+
+ { 'G', 0, 33 },
+ { 'G', 1, 34 },
+
+ { 'C', 0, 35 },
+ { 'C', 1, 36 },
+ { 'C', 2, 37 },
+ { 'C', 3, 38 },
+ { 'C', 4, 39 },
+ { 'C', 5, 40 },
+ { 'C', 6, 41 },
+ { 'C', 7, 42 },
+
+ { 'G', 2, 43 },
+
+ { 'A', 7, 44 },
+ { 'A', 6, 45 },
+ { 'A', 5, 46 },
+ { 'A', 4, 47 },
+ { 'A', 3, 48 },
+ { 'A', 2, 49 },
+ { 'A', 1, 50 },
+ { 'A', 0, 51 },
+
+ { 'F', 7, 54 },
+ { 'F', 6, 55 },
+ { 'F', 5, 56 },
+ { 'F', 4, 57 },
+ { 'F', 3, 58 },
+ { 'F', 2, 59 },
+ { 'F', 1, 60 },
+ { 'F', 0, 61 },
+};
+
+McuAdcPinInfo AvrAtmega128_64TQFPAdcPinInfo[] = {
+ { 61, 0x00 },
+ { 60, 0x01 },
+ { 59, 0x02 },
+ { 58, 0x03 },
+ { 57, 0x04 },
+ { 56, 0x05 },
+ { 55, 0x06 },
+ { 54, 0x07 },
+};
+
+
+//-----------------------------------------------------------------------------
+// ATmega162
+
+McuIoPinInfo AvrAtmega162IoPinInfo[] = {
+ { 'B', 0, 1 },
+ { 'B', 1, 2 },
+ { 'B', 2, 3 },
+ { 'B', 3, 4 },
+ { 'B', 4, 5 },
+ { 'B', 5, 6 },
+ { 'B', 6, 7 },
+ { 'B', 7, 8 },
+ { 'D', 0, 10 },
+ { 'D', 1, 11 },
+ { 'D', 2, 12 },
+ { 'D', 3, 13 },
+ { 'D', 4, 14 },
+ { 'D', 5, 15 },
+ { 'D', 6, 16 },
+ { 'D', 7, 17 },
+ { 'C', 0, 21 },
+ { 'C', 1, 22 },
+ { 'C', 2, 23 },
+ { 'C', 3, 24 },
+ { 'C', 4, 25 },
+ { 'C', 5, 26 },
+ { 'C', 6, 27 },
+ { 'C', 7, 28 },
+ { 'E', 2, 29 },
+ { 'E', 1, 30 },
+ { 'E', 0, 31 },
+ { 'A', 7, 32 },
+ { 'A', 6, 33 },
+ { 'A', 5, 34 },
+ { 'A', 4, 35 },
+ { 'A', 3, 36 },
+ { 'A', 2, 37 },
+ { 'A', 1, 38 },
+ { 'A', 0, 39 },
+};
+
+
+//-----------------------------------------------------------------------------
+// ATmega16 or ATmega32
+
+McuIoPinInfo AvrAtmega16or32IoPinInfo[] = {
+ { 'B', 0, 1 },
+ { 'B', 1, 2 },
+ { 'B', 2, 3 },
+ { 'B', 3, 4 },
+ { 'B', 4, 5 },
+ { 'B', 5, 6 },
+ { 'B', 6, 7 },
+ { 'B', 7, 8 },
+ { 'D', 0, 14 },
+ { 'D', 1, 15 },
+ { 'D', 2, 16 },
+ { 'D', 3, 17 },
+ { 'D', 4, 18 },
+ { 'D', 5, 19 },
+ { 'D', 6, 20 },
+ { 'D', 7, 21 },
+ { 'C', 0, 22 },
+ { 'C', 1, 23 },
+ { 'C', 2, 24 },
+ { 'C', 3, 25 },
+ { 'C', 4, 26 },
+ { 'C', 5, 27 },
+ { 'C', 6, 28 },
+ { 'C', 7, 29 },
+ { 'A', 7, 33 },
+ { 'A', 6, 34 },
+ { 'A', 5, 35 },
+ { 'A', 4, 36 },
+ { 'A', 3, 37 },
+ { 'A', 2, 38 },
+ { 'A', 1, 39 },
+ { 'A', 0, 40 },
+};
+
+McuAdcPinInfo AvrAtmega16or32AdcPinInfo[] = {
+ { 40, 0x00 },
+ { 39, 0x01 },
+ { 38, 0x02 },
+ { 37, 0x03 },
+ { 36, 0x04 },
+ { 35, 0x05 },
+ { 34, 0x06 },
+ { 33, 0x07 },
+};
+
+
+//-----------------------------------------------------------------------------
+// ATmega328_28PDIP Arduino
+
+McuIoPinInfo AvrAtmega328_28PDIPIoPinInfo[] = {
+ { 'C', 6, 1 },
+ { 'D', 0, 2 },
+ { 'D', 1, 3 },
+ { 'D', 2, 4 },
+ { 'D', 3, 5 },
+ { 'D', 4, 6 },
+ { 'B', 6, 9 },
+ { 'B', 7, 10 },
+ { 'D', 5, 11 },
+ { 'D', 6, 12 },
+ { 'D', 7, 13 },
+ { 'B', 0, 14 },
+ { 'B', 1, 15 },
+ { 'B', 2, 16 },
+ { 'B', 3, 17 },
+ { 'B', 4, 18 },
+ { 'B', 5, 19 },
+ { 'C', 0, 23 },
+ { 'C', 1, 24 },
+ { 'C', 2, 25 },
+ { 'C', 3, 26 },
+ { 'C', 4, 27 },
+ { 'C', 5, 28 },
+};
+
+McuAdcPinInfo AvrAtmega328_28PDIPAdcPinInfo[] = {
+ { 23, 0x00 },
+ { 24, 0x01 },
+ { 25, 0x02 },
+ { 26, 0x03 },
+ { 27, 0x04 },
+};
+
+
+//-----------------------------------------------------------------------------
+// ATmega8
+
+McuIoPinInfo AvrAtmega8IoPinInfo[] = {
+ { 'D', 0, 2 },
+ { 'D', 1, 3 },
+ { 'D', 2, 4 },
+ { 'D', 3, 5 },
+ { 'D', 4, 6 },
+ { 'D', 5, 11 },
+ { 'D', 6, 12 },
+ { 'D', 7, 13 },
+ { 'B', 0, 14 },
+ { 'B', 1, 15 },
+ { 'B', 2, 16 },
+ { 'B', 3, 17 },
+ { 'B', 4, 18 },
+ { 'B', 5, 19 },
+ { 'C', 0, 23 },
+ { 'C', 1, 24 },
+ { 'C', 2, 25 },
+ { 'C', 3, 26 },
+ { 'C', 4, 27 },
+ { 'C', 5, 28 },
+};
+
+McuAdcPinInfo AvrAtmega8AdcPinInfo[] = {
+ { 23, 0x00 }, // ADC0
+ { 24, 0x01 },
+ { 25, 0x02 },
+ { 26, 0x03 },
+ { 27, 0x04 },
+ { 28, 0x05 }, // ADC5
+};
+
+
+//-----------------------------------------------------------------------------
+// A variety of 18-pin PICs that share the same digital IO assignment.
+
+McuIoPinInfo Pic18PinIoInfo[] = {
+ { 'A', 2, 1 },
+ { 'A', 3, 2 },
+ { 'A', 4, 3 },
+ { 'A', 5, 4 },
+ { 'B', 0, 6 },
+ { 'B', 1, 7 },
+ { 'B', 2, 8 },
+ { 'B', 3, 9 },
+ { 'B', 4, 10 },
+ { 'B', 5, 11 },
+ { 'B', 6, 12 },
+ { 'B', 7, 13 },
+ { 'A', 6, 15 },
+ { 'A', 7, 16 },
+ { 'A', 0, 17 },
+ { 'A', 1, 18 },
+};
+
+McuAdcPinInfo Pic16f819AdcPinInfo[] = {
+ { 1, 0x02 },
+ { 2, 0x03 },
+ { 3, 0x04 },
+ { 17, 0x00 },
+ { 18, 0x01 },
+};
+
+McuAdcPinInfo Pic16f88AdcPinInfo[] = {
+ { 1, 0x02 },
+ { 2, 0x03 },
+ { 3, 0x04 },
+ { 12, 0x05 },
+ { 13, 0x06 },
+ { 17, 0x00 },
+ { 18, 0x01 },
+};
+
+
+//-----------------------------------------------------------------------------
+// PIC16F877
+
+McuIoPinInfo Pic16f877IoPinInfo[] = {
+ { 'A', 0, 2 },
+ { 'A', 1, 3 },
+ { 'A', 2, 4 },
+ { 'A', 3, 5 },
+ { 'A', 4, 6 },
+ { 'A', 5, 7 },
+ { 'E', 0, 8 },
+ { 'E', 1, 9 },
+ { 'E', 2, 10 },
+ { 'C', 0, 15 },
+ { 'C', 1, 16 },
+ { 'C', 2, 17 },
+ { 'C', 3, 18 },
+ { 'D', 0, 19 },
+ { 'D', 1, 20 },
+ { 'D', 2, 21 },
+ { 'D', 3, 22 },
+ { 'C', 4, 23 },
+ { 'C', 5, 24 },
+ { 'C', 6, 25 },
+ { 'C', 7, 26 },
+ { 'D', 4, 27 },
+ { 'D', 5, 28 },
+ { 'D', 6, 29 },
+ { 'D', 7, 30 },
+ { 'B', 0, 33 },
+ { 'B', 1, 34 },
+ { 'B', 2, 35 },
+ { 'B', 3, 36 },
+ { 'B', 4, 37 },
+ { 'B', 5, 38 },
+ { 'B', 6, 39 },
+ { 'B', 7, 40 },
+};
+
+McuAdcPinInfo Pic16f877AdcPinInfo[] = {
+ { 2, 0x00 },
+ { 3, 0x01 },
+ { 4, 0x02 },
+ { 5, 0x03 },
+ { 7, 0x04 },
+ { 8, 0x05 },
+ { 9, 0x06 },
+ { 10, 0x07 },
+};
+
+
+//-----------------------------------------------------------------------------
+// PIC16F876
+
+McuIoPinInfo Pic16f876IoPinInfo[] = {
+ { 'A', 0, 2 },
+ { 'A', 1, 3 },
+ { 'A', 2, 4 },
+ { 'A', 3, 5 },
+ { 'A', 4, 6 },
+ { 'A', 5, 7 },
+ { 'C', 0, 11 },
+ { 'C', 1, 12 },
+ { 'C', 2, 13 },
+ { 'C', 3, 14 },
+ { 'C', 4, 15 },
+ { 'C', 5, 16 },
+ { 'C', 6, 17 },
+ { 'C', 7, 18 },
+ { 'B', 0, 21 },
+ { 'B', 1, 22 },
+ { 'B', 2, 23 },
+ { 'B', 3, 24 },
+ { 'B', 4, 25 },
+ { 'B', 5, 26 },
+ { 'B', 6, 27 },
+ { 'B', 7, 28 },
+};
+
+McuAdcPinInfo Pic16f876AdcPinInfo[] = {
+ { 2, 0x00 },
+ { 3, 0x01 },
+ { 4, 0x02 },
+ { 5, 0x03 },
+ { 7, 0x04 }
+};
+
+
+//-----------------------------------------------------------------------------
+// PIC16F887
+
+McuIoPinInfo Pic16f887IoPinInfo[] = {
+ { 'A', 0, 2 },
+ { 'A', 1, 3 },
+ { 'A', 2, 4 },
+ { 'A', 3, 5 },
+ { 'A', 4, 6 },
+ { 'A', 5, 7 },
+ { 'E', 0, 8 },
+ { 'E', 1, 9 },
+ { 'E', 2, 10 },
+ { 'C', 0, 15 },
+ { 'C', 1, 16 },
+ { 'C', 2, 17 },
+ { 'C', 3, 18 },
+ { 'D', 0, 19 },
+ { 'D', 1, 20 },
+ { 'D', 2, 21 },
+ { 'D', 3, 22 },
+ { 'C', 4, 23 },
+ { 'C', 5, 24 },
+ { 'C', 6, 25 },
+ { 'C', 7, 26 },
+ { 'D', 4, 27 },
+ { 'D', 5, 28 },
+ { 'D', 6, 29 },
+ { 'D', 7, 30 },
+ { 'B', 0, 33 },
+ { 'B', 1, 34 },
+ { 'B', 2, 35 },
+ { 'B', 3, 36 },
+ { 'B', 4, 37 },
+ { 'B', 5, 38 },
+ { 'B', 6, 39 },
+ { 'B', 7, 40 },
+};
+
+McuAdcPinInfo Pic16f887AdcPinInfo[] = {
+ { 2, 0x00 },
+ { 3, 0x01 },
+ { 4, 0x02 },
+ { 5, 0x03 },
+ { 7, 0x04 },
+ { 8, 0x05 },
+ { 9, 0x06 },
+ { 10, 0x07 },
+ { 33, 0x0c },
+ { 34, 0x0a },
+ { 35, 0x08 },
+ { 36, 0x09 },
+ { 37, 0x0b },
+ { 38, 0x0d },
+};
+
+
+//-----------------------------------------------------------------------------
+// PIC16F886
+
+McuIoPinInfo Pic16f886IoPinInfo[] = {
+ { 'A', 0, 2 },
+ { 'A', 1, 3 },
+ { 'A', 2, 4 },
+ { 'A', 3, 5 },
+ { 'A', 4, 6 },
+ { 'A', 5, 7 },
+ { 'C', 0, 11 },
+ { 'C', 1, 12 },
+ { 'C', 2, 13 },
+ { 'C', 3, 14 },
+ { 'C', 4, 15 },
+ { 'C', 5, 16 },
+ { 'C', 6, 17 },
+ { 'C', 7, 18 },
+ { 'B', 0, 21 },
+ { 'B', 1, 22 },
+ { 'B', 2, 23 },
+ { 'B', 3, 24 },
+ { 'B', 4, 25 },
+ { 'B', 5, 26 },
+ { 'B', 6, 27 },
+ { 'B', 7, 28 },
+};
+
+McuAdcPinInfo Pic16f886AdcPinInfo[] = {
+ { 2, 0x00 },
+ { 3, 0x01 },
+ { 4, 0x02 },
+ { 5, 0x03 },
+ { 7, 0x04 },
+ { 21, 0x0c },
+ { 22, 0x0a },
+ { 23, 0x08 },
+ { 24, 0x09 },
+ { 25, 0x0b },
+ { 26, 0x0d },
+};
+
+
+#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
+
+McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS] = {
+ {
+ "Atmel AVR ATmega128 64-TQFP",
+ 'P',
+ { 0x39, 0x36, 0x33, 0x30, 0x21, 0x20, 0x63 }, // PINx
+ { 0x3b, 0x38, 0x35, 0x32, 0x23, 0x62, 0x65 }, // PORTx
+ { 0x3a, 0x37, 0x34, 0x31, 0x22, 0x61, 0x64 }, // DDRx
+ 64*1024,
+ { { 0x100, 4096 } },
+ AvrAtmega128_64TQFPIoPinInfo,
+ arraylen(AvrAtmega128_64TQFPIoPinInfo),
+ AvrAtmega128_64TQFPAdcPinInfo,
+ arraylen(AvrAtmega128_64TQFPAdcPinInfo),
+ 1023,
+ { 27, 28 },
+ 17,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega64 64-TQFP",
+ 'P',
+ { 0x39, 0x36, 0x33, 0x30, 0x21, 0x20, 0x63 }, // PINx
+ { 0x3b, 0x38, 0x35, 0x32, 0x23, 0x62, 0x65 }, // PORTx
+ { 0x3a, 0x37, 0x34, 0x31, 0x22, 0x61, 0x64 }, // DDRx
+ 32*1024,
+ { { 0x100, 4096 } },
+ AvrAtmega128_64TQFPIoPinInfo,
+ arraylen(AvrAtmega128_64TQFPIoPinInfo),
+ AvrAtmega128_64TQFPAdcPinInfo,
+ arraylen(AvrAtmega128_64TQFPAdcPinInfo),
+ 1023,
+ { 27, 28 },
+ 17,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega162 40-PDIP",
+ 'P',
+ { 0x39, 0x36, 0x33, 0x30, 0x25 }, // PINx
+ { 0x3b, 0x38, 0x35, 0x32, 0x27 }, // PORTx
+ { 0x3a, 0x37, 0x34, 0x31, 0x26 }, // DDRx
+ 8*1024,
+ { { 0x100, 1024 } },
+ AvrAtmega162IoPinInfo,
+ arraylen(AvrAtmega162IoPinInfo),
+ NULL,
+ 0,
+ 0,
+ { 0, 0 },
+ 0,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega32 40-PDIP",
+ 'P',
+ { 0x39, 0x36, 0x33, 0x30 }, // PINx
+ { 0x3b, 0x38, 0x35, 0x32 }, // PORTx
+ { 0x3a, 0x37, 0x34, 0x31 }, // DDRx
+ 16*1024,
+ { { 0x60, 2048 } },
+ AvrAtmega16or32IoPinInfo,
+ arraylen(AvrAtmega16or32IoPinInfo),
+ AvrAtmega16or32AdcPinInfo,
+ arraylen(AvrAtmega16or32AdcPinInfo),
+ 1023,
+ { 14, 15 },
+ 0,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega16 40-PDIP",
+ 'P',
+ { 0x39, 0x36, 0x33, 0x30 }, // PINx
+ { 0x3b, 0x38, 0x35, 0x32 }, // PORTx
+ { 0x3a, 0x37, 0x34, 0x31 }, // DDRx
+ 8*1024,
+ { { 0x60, 1024 } },
+ AvrAtmega16or32IoPinInfo,
+ arraylen(AvrAtmega16or32IoPinInfo),
+ AvrAtmega16or32AdcPinInfo,
+ arraylen(AvrAtmega16or32AdcPinInfo),
+ 1023,
+ { 14, 15 },
+ 21,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega8 28-PDIP",
+ 'P',
+ { 0xff, 0x36, 0x33, 0x30 }, // PINx (but there is no xxxA)
+ { 0xff, 0x38, 0x35, 0x32 }, // PORTx
+ { 0xff, 0x37, 0x34, 0x31 }, // DDRx
+ 4*1024,
+ { { 0x60, 1024 } },
+ AvrAtmega8IoPinInfo,
+ arraylen(AvrAtmega8IoPinInfo),
+ AvrAtmega8AdcPinInfo,
+ arraylen(AvrAtmega8AdcPinInfo),
+ 1023,
+ { 2, 3 },
+ 17,
+ ISA_AVR,
+ TRUE,
+ 0
+ },
+ {
+ "Atmel AVR ATmega328 28-PDIP",
+ 'P',
+ { 0xff, 0x23, 0x26, 0x29 }, // PINx (but there is no xxxA)
+ { 0xff, 0x25, 0x28, 0x2B }, // PORTx
+ { 0xff, 0x24, 0x27, 0x2A }, // DDRx
+ 16*1024,
+ { { 0x100, 1024 } },
+ AvrAtmega328_28PDIPIoPinInfo,
+ arraylen(AvrAtmega328_28PDIPIoPinInfo),
+ AvrAtmega328_28PDIPAdcPinInfo,
+ arraylen(AvrAtmega328_28PDIPAdcPinInfo),
+ 1023,
+ { 2, 3 },
+ 17,
+ ISA_ARDUINO,
+ TRUE,
+ 0
+ },
+ {
+ "Microchip PIC16F628 18-PDIP or 18-SOIC",
+ 'R',
+ { 0x05, 0x06 }, // PORTx
+ { 0x05, 0x06 }, // PORTx
+ { 0x85, 0x86 }, // TRISx
+ 2048,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 48 } },
+ Pic18PinIoInfo,
+ arraylen(Pic18PinIoInfo),
+ NULL,
+ 0,
+ 0,
+ { 7, 8 },
+ 0,
+ ISA_PIC16,
+ FALSE,
+ // code protection off, data code protection off, LVP disabled,
+ // BOD reset enabled, RA5/nMCLR is RA5, PWRT enabled, WDT disabled,
+ // HS oscillator
+ 0x3f62
+ },
+ {
+ "Microchip PIC16F88 18-PDIP or 18-SOIC",
+ 'R',
+ { 0x05, 0x06 }, // PORTx
+ { 0x05, 0x06 }, // PORTx
+ { 0x85, 0x86 }, // TRISx
+ 4096,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 48 } },
+ Pic18PinIoInfo,
+ arraylen(Pic18PinIoInfo),
+ Pic16f88AdcPinInfo,
+ arraylen(Pic16f88AdcPinInfo),
+ 1023,
+ { 8, 11 },
+ 0,
+ ISA_PIC16,
+ FALSE,
+ (1 << 13) | // CP off
+ (1 << 12) | // CCP on RB2 (doesn't matter)
+ (1 << 11) | // ICD disabled
+ (3 << 9) | // flash write protection off
+ (1 << 8) | // code protection off
+ (0 << 7) | // LVP disabled
+ (1 << 6) | // BOR enabled
+ (0 << 5) | // RA5/nMCLR is RA5
+ (0 << 4) | // for osc sel, later
+ (0 << 3) | // PWRT enabled
+ (0 << 2) | // WDT disabled
+ (2 << 0), // HS oscillator
+ },
+ {
+ "Microchip PIC16F819 18-PDIP or 18-SOIC",
+ 'R',
+ { 0x05, 0x06 }, // PORTx
+ { 0x05, 0x06 }, // PORTx
+ { 0x85, 0x86 }, // TRISx
+ 2048,
+ { { 0x20, 96 } },
+ Pic18PinIoInfo,
+ arraylen(Pic18PinIoInfo),
+ Pic16f819AdcPinInfo,
+ arraylen(Pic16f819AdcPinInfo),
+ 1023,
+ { 0, 0 },
+ 0,
+ ISA_PIC16,
+ FALSE,
+ (1 << 13) | // code protect off
+ (1 << 12) | // CCP1 on RB2 (doesn't matter, can't use)
+ (1 << 11) | // disable debugger
+ (3 << 9) | // flash protection off
+ (1 << 8) | // data protect off
+ (0 << 7) | // LVP disabled
+ (1 << 6) | // BOR enabled
+ (0 << 5) | // nMCLR/RA5 is RA5
+ (0 << 3) | // PWRTE enabled
+ (0 << 2) | // WDT disabled
+ (2 << 0), // HS oscillator
+ },
+ {
+ "Microchip PIC16F877 40-PDIP",
+ 'R',
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
+ 8*1024,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x110, 96 }, { 0x190, 96 } },
+ Pic16f877IoPinInfo,
+ arraylen(Pic16f877IoPinInfo),
+ Pic16f877AdcPinInfo,
+ arraylen(Pic16f877AdcPinInfo),
+ 1023,
+ { 26, 25 },
+ 16,
+ ISA_PIC16,
+ FALSE,
+ // code protection off, debug off, flash write off, EE code protection
+ // off, LVP disabled, BOD enabled, CP off, PWRT enabled, WDT disabled,
+ // HS oscillator
+ 0x3f72
+ },
+ {
+ "Microchip PIC16F876 28-PDIP or 28-SOIC",
+ 'R',
+ { 0x05, 0x06, 0x07 }, // PORTx
+ { 0x05, 0x06, 0x07 }, // PORTx
+ { 0x85, 0x86, 0x87 }, // TRISx
+ 8*1024,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x110, 96 }, { 0x190, 96 } },
+ Pic16f876IoPinInfo,
+ arraylen(Pic16f876IoPinInfo),
+ Pic16f876AdcPinInfo,
+ arraylen(Pic16f876AdcPinInfo),
+ 1023,
+ { 18, 17 },
+ 12,
+ ISA_PIC16,
+ FALSE,
+ // code protection off, debug off, flash write off, EE code protection
+ // off, LVP disabled, BOD enabled, CP off, PWRT enabled, WDT disabled,
+ // HS oscillator
+ 0x3f72
+ },
+ {
+ "Microchip PIC16F887 40-PDIP",
+ 'R',
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
+ 8*1024,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 80 }, { 0x1a0, 80 } },
+ Pic16f887IoPinInfo,
+ arraylen(Pic16f887IoPinInfo),
+ Pic16f887AdcPinInfo,
+ arraylen(Pic16f887AdcPinInfo),
+ 1023,
+ { 26, 25 },
+ 16,
+ ISA_PIC16,
+ FALSE,
+ (3 << (9+16)) | // flash write protection off
+ (0 << (8+16)) | // BOR at 2.1 V
+ (1 << 13) | // ICD disabled
+ (0 << 12) | // LVP disabled
+ (0 << 11) | // fail-safe clock monitor disabled
+ (0 << 10) | // internal/external switchover disabled
+ (3 << 8) | // brown-out detect enabled
+ (1 << 7) | // data code protection disabled
+ (1 << 6) | // code protection disabled
+ (1 << 5) | // nMCLR enabled
+ (0 << 4) | // PWRTE enabled
+ (0 << 3) | // WDTE disabled
+ (2 << 0) // HS oscillator
+
+ },
+ {
+ "Microchip PIC16F886 28-PDIP or 28-SOIC",
+ 'R',
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
+ { 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
+ 8*1024,
+ { { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 80 }, { 0x1a0, 80 } },
+ Pic16f886IoPinInfo,
+ arraylen(Pic16f886IoPinInfo),
+ Pic16f886AdcPinInfo,
+ arraylen(Pic16f886AdcPinInfo),
+ 1023,
+ { 18, 17 },
+ 12,
+ ISA_PIC16,
+ FALSE,
+ (3 << (9+16)) | // flash write protection off
+ (0 << (8+16)) | // BOR at 2.1 V
+ (1 << 13) | // ICD disabled
+ (0 << 12) | // LVP disabled
+ (0 << 11) | // fail-safe clock monitor disabled
+ (0 << 10) | // internal/external switchover disabled
+ (3 << 8) | // brown-out detect enabled
+ (1 << 7) | // data code protection disabled
+ (1 << 6) | // code protection disabled
+ (1 << 5) | // nMCLR enabled
+ (0 << 4) | // PWRTE enabled
+ (0 << 3) | // WDTE disabled
+ (2 << 0) // HS oscillator
+ },
+ {
+ "ANSI C Code",
+ 'x',
+ { 0x00 },
+ { 0x00 },
+ { 0x00 },
+ 0,
+ { { 0x00, 0 } },
+ NULL,
+ 0,
+ NULL,
+ 0,
+ 0,
+ { 0, 0 },
+ 0,
+ ISA_ANSIC,
+ FALSE,
+ 0x00
+ },
+ {
+ "Interpretable Byte Code",
+ 'x',
+ { 0x00 },
+ { 0x00 },
+ { 0x00 },
+ 0,
+ { { 0x00, 0 } },
+ NULL,
+ 0,
+ NULL,
+ 0,
+ 0,
+ { 0, 0 },
+ 0,
+ ISA_INTERPRETED,
+ FALSE,
+ 0x00
+ }
+};
+
diff --git a/ldmicro/includes/naminglist.h b/ldmicro/includes/naminglist.h
new file mode 100644
index 0000000..43a7a76
--- /dev/null
+++ b/ldmicro/includes/naminglist.h
@@ -0,0 +1,16 @@
+#ifndef _NAMING_LIST
+#define _NAMING_LIST
+
+extern HWND NamingList;
+
+// void NamingListProc(NMHDR *h);
+
+int NameList_AddName(LPCTSTR Name, int Index);
+double NameList_RegisterVolt(LPCTSTR Name, double volt); //Forcefully set voltage will not be accessible outside the cpp file
+double NameList_SetVolt(int Index, double volt); //Set voltage if current voltage>specified voltage
+double NameList_DeRegisterVolt(LPCTSTR Name); //Send a message to rest of the components to set new voltage
+void NamingListProc(NMHDR *h);
+
+
+// void ConfigureNamingList(int type,int PinOnProcessor, MCUPort);
+#endif
diff --git a/ldmicro/includes/simulate.h b/ldmicro/includes/simulate.h
new file mode 100644
index 0000000..7b26ba3
--- /dev/null
+++ b/ldmicro/includes/simulate.h
@@ -0,0 +1,8 @@
+/*This file is created with an intention to share simulation functions
+with advanced simulation dialog window*/
+#ifndef _SIMULATE_H
+#define _SIMULATE_H
+
+static void SetSingleBit(char *name, BOOL state);
+static BOOL SingleBitOn(char *name);
+#endif
--
cgit
From 68a6eb8058af7d6a14727da77eb7dda7a363c9cd Mon Sep 17 00:00:00 2001
From: Rr42
Date: Fri, 25 May 2018 10:29:07 +0530
Subject: Edited Cmake to test linuxUI
---
ldmicro/includes/linuxUI/linuxUI.h | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 ldmicro/includes/linuxUI/linuxUI.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
new file mode 100644
index 0000000..e69de29
--
cgit
From dcbd1d4e87abd5a90f903296a42a1464c007cc67 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Fri, 25 May 2018 18:12:31 +0530
Subject: Added linuxUI (analog to windows.h)
---
ldmicro/includes/ldmicroVC.h | 3 +++
ldmicro/includes/ldmicroVC.h.in | 3 +++
ldmicro/includes/linuxUI/linuxUI.h | 50 ++++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
create mode 100644 ldmicro/includes/ldmicroVC.h
create mode 100644 ldmicro/includes/ldmicroVC.h.in
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicroVC.h b/ldmicro/includes/ldmicroVC.h
new file mode 100644
index 0000000..400bc42
--- /dev/null
+++ b/ldmicro/includes/ldmicroVC.h
@@ -0,0 +1,3 @@
+/// version control
+#define LDMicro_VERSION_MAJOR 1
+#define LDMicro_VERSION_MINOR 0
diff --git a/ldmicro/includes/ldmicroVC.h.in b/ldmicro/includes/ldmicroVC.h.in
new file mode 100644
index 0000000..46c0e4a
--- /dev/null
+++ b/ldmicro/includes/ldmicroVC.h.in
@@ -0,0 +1,3 @@
+/// version control
+#define LDMicro_VERSION_MAJOR @LDMicro_VERSION_MAJOR@
+#define LDMicro_VERSION_MINOR @LDMicro_VERSION_MINOR@
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index e69de29..e084e73 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -0,0 +1,50 @@
+/// includes
+#include
+#include
+#include
+#include
+
+/// version control
+#define LDMicro_VERSION_MAJOR 1
+#define LDMicro_VERSION_MINOR 0
+
+/// common windows referances for linux
+/// definitions
+#define MAX_PATH PATH_MAX
+/// CALLBACK or __stdcall os defined empty
+#define CALLBACK
+
+/// typedefs
+//typedef int64_t __int64;
+typedef bool BOOL;
+typedef GdkRGBA COLORREF;
+typedef unsigned char BYTE;
+typedef unsigned int DWORD;
+typedef void* PVOID;
+typedef PVOID HANDLE;
+typedef HANDLE HINSTANCE;
+typedef HANDLE HWND;
+typedef HANDLE HDC;
+typedef HANDLE HMENU;
+
+/*
+/// Check if system is x64 or x86 using GCC
+#if __GNUC__
+#if __x86_64__ || __ppc64__
+/// system is x64
+typedef unsigned __int64 UINT_PTR;
+#else
+/// system is x86
+typedef unsigned int UINT_PTR;
+#endif
+#endif
+*/
+
+/// Check if system is x64 or x86
+#if defined(__UNIX64)
+typedef uint64_t UINT_PTR;
+#else
+typedef unsigned int UINT_PTR;
+#endif
+
+typedef UINT_PTR WPARAM;
\ No newline at end of file
--
cgit
From b689a165db83226ea6735dea22a47bac2f4f41ab Mon Sep 17 00:00:00 2001
From: Rr42
Date: Fri, 25 May 2018 18:53:00 +0530
Subject: Dropped support for windows cross compilation
---
ldmicro/includes/linuxUI/linuxUI.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index e084e73..02691b5 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -20,8 +20,10 @@ typedef bool BOOL;
typedef GdkRGBA COLORREF;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
+
+/// all handles will hold a GtkWindow* type
typedef void* PVOID;
-typedef PVOID HANDLE;
+typedef GtkWindow* HANDLE;
typedef HANDLE HINSTANCE;
typedef HANDLE HWND;
typedef HANDLE HDC;
@@ -47,4 +49,10 @@ typedef uint64_t UINT_PTR;
typedef unsigned int UINT_PTR;
#endif
-typedef UINT_PTR WPARAM;
\ No newline at end of file
+typedef UINT_PTR WPARAM;
+typedef unsigned int UINT;
+
+/// common windows referances for linux - end
+
+/// functions
+BOOL isFocus(HWND);
\ No newline at end of file
--
cgit
From a2e0c92b2f4edfd067f8671dab18c92835143528 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Sun, 27 May 2018 18:09:03 +0530
Subject: Added RGB convertion for GTK
---
ldmicro/includes/linuxUI/linuxUI.h | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index 02691b5..bfbf3bc 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -17,18 +17,19 @@
/// typedefs
//typedef int64_t __int64;
typedef bool BOOL;
-typedef GdkRGBA COLORREF;
typedef unsigned char BYTE;
typedef unsigned int DWORD;
/// all handles will hold a GtkWindow* type
typedef void* PVOID;
-typedef GtkWindow* HANDLE;
+typedef GtkWidget* HANDLE;
typedef HANDLE HINSTANCE;
typedef HANDLE HWND;
typedef HANDLE HDC;
typedef HANDLE HMENU;
+typedef GtkApplication* HAPP;
+
/*
/// Check if system is x64 or x86 using GCC
#if __GNUC__
@@ -52,7 +53,27 @@ typedef unsigned int UINT_PTR;
typedef UINT_PTR WPARAM;
typedef unsigned int UINT;
+/// custom classes
+class COLORREF : public GdkRGBA{
+ public:
+ COLORREF()
+ {
+ this->red = 0.0;
+ this->green = 0.0;
+ this->blue = 0.0;
+ this->alpha = 1.0;
+ }
+ COLORREF(int r, int g, int b)
+ {
+ this->red = r/255.0;
+ this->green = g/255.0;
+ this->blue = b/255.0;
+ this->alpha = 1.0;
+ }
+};
+
/// common windows referances for linux - end
/// functions
-BOOL isFocus(HWND);
\ No newline at end of file
+BOOL isFocus(HWND);
+COLORREF RGB(int, int, int);
\ No newline at end of file
--
cgit
From 4be201f18c265a0bd66b2500ccdb383e91a436bd Mon Sep 17 00:00:00 2001
From: Rr42
Date: Sun, 27 May 2018 19:21:59 +0530
Subject: Updated freeze library to add an entry to register file
---
ldmicro/includes/linuxUI/linuxUI.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index bfbf3bc..803f915 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -1,3 +1,6 @@
+#ifndef __LINUX_UI__
+#define __LINUX_UI__
+
/// includes
#include
#include
@@ -76,4 +79,6 @@ class COLORREF : public GdkRGBA{
/// functions
BOOL isFocus(HWND);
-COLORREF RGB(int, int, int);
\ No newline at end of file
+COLORREF RGB(int, int, int);
+
+#endif
\ No newline at end of file
--
cgit
From c71814905e187916d81ad250fa0bbcc13c2e8098 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Mon, 28 May 2018 10:54:41 +0530
Subject: Seprated windows definitions and UI elements from linuxUI library
---
ldmicro/includes/linuxUI/linuxLD.h | 58 +++++++++++++++++++++++++++++++++
ldmicro/includes/linuxUI/linuxUI.h | 67 +-------------------------------------
2 files changed, 59 insertions(+), 66 deletions(-)
create mode 100644 ldmicro/includes/linuxUI/linuxLD.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/includes/linuxUI/linuxLD.h
new file mode 100644
index 0000000..77352e4
--- /dev/null
+++ b/ldmicro/includes/linuxUI/linuxLD.h
@@ -0,0 +1,58 @@
+#ifndef __LINUX_LD__
+#define __LINUX_LD__
+
+#include "linuxUI/linuxUI.h"
+
+/// common windows referances for linux
+
+/// definitions
+#define MAX_PATH PATH_MAX
+/// CALLBACK or __stdcall os defined empty
+#define CALLBACK
+
+/// typedefs
+//typedef int64_t __int64;
+typedef bool BOOL;
+typedef unsigned char BYTE;
+typedef unsigned int DWORD;
+
+/// all handles will hold a GtkWindow* type
+typedef void* PVOID;
+typedef GtkWidget* HANDLE;
+typedef HANDLE HINSTANCE;
+typedef HANDLE HWND;
+typedef HANDLE HDC;
+typedef HANDLE HMENU;
+
+typedef GtkApplication* HAPP;
+
+/// Check if system is x64 or x86
+#if defined(__UNIX64)
+typedef uint64_t UINT_PTR;
+#else
+typedef unsigned int UINT_PTR;
+#endif
+
+typedef UINT_PTR WPARAM;
+typedef unsigned int UINT;
+
+/// custom classes
+class COLORREF : public GdkRGBA{
+ public:
+ COLORREF()
+ {
+ this->red = 0.0;
+ this->green = 0.0;
+ this->blue = 0.0;
+ this->alpha = 1.0;
+ }
+ COLORREF(int r, int g, int b)
+ {
+ this->red = r/255.0;
+ this->green = g/255.0;
+ this->blue = b/255.0;
+ this->alpha = 1.0;
+ }
+};
+
+#endif
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
index 803f915..01b7af2 100644
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ b/ldmicro/includes/linuxUI/linuxUI.h
@@ -6,77 +6,12 @@
#include
#include
#include
+#include "linuxUI/linuxLD.h"
/// version control
#define LDMicro_VERSION_MAJOR 1
#define LDMicro_VERSION_MINOR 0
-/// common windows referances for linux
-/// definitions
-#define MAX_PATH PATH_MAX
-/// CALLBACK or __stdcall os defined empty
-#define CALLBACK
-
-/// typedefs
-//typedef int64_t __int64;
-typedef bool BOOL;
-typedef unsigned char BYTE;
-typedef unsigned int DWORD;
-
-/// all handles will hold a GtkWindow* type
-typedef void* PVOID;
-typedef GtkWidget* HANDLE;
-typedef HANDLE HINSTANCE;
-typedef HANDLE HWND;
-typedef HANDLE HDC;
-typedef HANDLE HMENU;
-
-typedef GtkApplication* HAPP;
-
-/*
-/// Check if system is x64 or x86 using GCC
-#if __GNUC__
-#if __x86_64__ || __ppc64__
-/// system is x64
-typedef unsigned __int64 UINT_PTR;
-#else
-/// system is x86
-typedef unsigned int UINT_PTR;
-#endif
-#endif
-*/
-
-/// Check if system is x64 or x86
-#if defined(__UNIX64)
-typedef uint64_t UINT_PTR;
-#else
-typedef unsigned int UINT_PTR;
-#endif
-
-typedef UINT_PTR WPARAM;
-typedef unsigned int UINT;
-
-/// custom classes
-class COLORREF : public GdkRGBA{
- public:
- COLORREF()
- {
- this->red = 0.0;
- this->green = 0.0;
- this->blue = 0.0;
- this->alpha = 1.0;
- }
- COLORREF(int r, int g, int b)
- {
- this->red = r/255.0;
- this->green = g/255.0;
- this->blue = b/255.0;
- this->alpha = 1.0;
- }
-};
-
-/// common windows referances for linux - end
-
/// functions
BOOL isFocus(HWND);
COLORREF RGB(int, int, int);
--
cgit
From 0c0b7b26031283bb1ba7e71064cbee7d215557cd Mon Sep 17 00:00:00 2001
From: Rr42
Date: Mon, 28 May 2018 12:30:38 +0530
Subject: Updated handle types
---
ldmicro/includes/linuxUI/linuxLD.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/includes/linuxUI/linuxLD.h
index 77352e4..53194e1 100644
--- a/ldmicro/includes/linuxUI/linuxLD.h
+++ b/ldmicro/includes/linuxUI/linuxLD.h
@@ -20,10 +20,12 @@ typedef unsigned int DWORD;
typedef void* PVOID;
typedef GtkWidget* HANDLE;
typedef HANDLE HINSTANCE;
-typedef HANDLE HWND;
+typedef HANDLE HWID;
typedef HANDLE HDC;
typedef HANDLE HMENU;
+typedef GtkWindow* HWND;
+
typedef GtkApplication* HAPP;
/// Check if system is x64 or x86
--
cgit
From 5c01aef5fd87870b63511f17bd50405a0df08a3b Mon Sep 17 00:00:00 2001
From: Rr42
Date: Tue, 29 May 2018 10:46:19 +0530
Subject: Freeze library updated and renamed to freezeLD (working)
---
ldmicro/includes/linuxUI/linuxLD.h | 60 --------------------------------------
ldmicro/includes/linuxUI/linuxUI.h | 19 ------------
2 files changed, 79 deletions(-)
delete mode 100644 ldmicro/includes/linuxUI/linuxLD.h
delete mode 100644 ldmicro/includes/linuxUI/linuxUI.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/linuxUI/linuxLD.h b/ldmicro/includes/linuxUI/linuxLD.h
deleted file mode 100644
index 53194e1..0000000
--- a/ldmicro/includes/linuxUI/linuxLD.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef __LINUX_LD__
-#define __LINUX_LD__
-
-#include "linuxUI/linuxUI.h"
-
-/// common windows referances for linux
-
-/// definitions
-#define MAX_PATH PATH_MAX
-/// CALLBACK or __stdcall os defined empty
-#define CALLBACK
-
-/// typedefs
-//typedef int64_t __int64;
-typedef bool BOOL;
-typedef unsigned char BYTE;
-typedef unsigned int DWORD;
-
-/// all handles will hold a GtkWindow* type
-typedef void* PVOID;
-typedef GtkWidget* HANDLE;
-typedef HANDLE HINSTANCE;
-typedef HANDLE HWID;
-typedef HANDLE HDC;
-typedef HANDLE HMENU;
-
-typedef GtkWindow* HWND;
-
-typedef GtkApplication* HAPP;
-
-/// Check if system is x64 or x86
-#if defined(__UNIX64)
-typedef uint64_t UINT_PTR;
-#else
-typedef unsigned int UINT_PTR;
-#endif
-
-typedef UINT_PTR WPARAM;
-typedef unsigned int UINT;
-
-/// custom classes
-class COLORREF : public GdkRGBA{
- public:
- COLORREF()
- {
- this->red = 0.0;
- this->green = 0.0;
- this->blue = 0.0;
- this->alpha = 1.0;
- }
- COLORREF(int r, int g, int b)
- {
- this->red = r/255.0;
- this->green = g/255.0;
- this->blue = b/255.0;
- this->alpha = 1.0;
- }
-};
-
-#endif
diff --git a/ldmicro/includes/linuxUI/linuxUI.h b/ldmicro/includes/linuxUI/linuxUI.h
deleted file mode 100644
index 01b7af2..0000000
--- a/ldmicro/includes/linuxUI/linuxUI.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __LINUX_UI__
-#define __LINUX_UI__
-
-/// includes
-#include
-#include
-#include
-#include
-#include "linuxUI/linuxLD.h"
-
-/// version control
-#define LDMicro_VERSION_MAJOR 1
-#define LDMicro_VERSION_MINOR 0
-
-/// functions
-BOOL isFocus(HWND);
-COLORREF RGB(int, int, int);
-
-#endif
\ No newline at end of file
--
cgit
From eb8f6932fe45f550bc2b77c1b3e578884ed60d91 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Wed, 30 May 2018 12:11:46 +0530
Subject: Added message box functionality
---
ldmicro/includes/ldmicro.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 2c6f720..579d3a7 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -31,8 +31,8 @@ typedef signed long SDWORD;
//-----------------------------------------------
// `Configuration options.'
-// The library that I use to do registry stuff.
-#define FREEZE_SUBKEY "LDMicro"
+// The library that I use to do registry stuff. decleared in freezeLD.h due to build issues
+// #define FREEZE_SUBKEY "LDMicro"
// Size of the font that we will use to draw the ladder diagrams, in pixels
#define FONT_WIDTH 7
@@ -501,7 +501,7 @@ typedef struct McuIoInfoTag {
#define NUM_SUPPORTED_MCUS 16
-
+/*
//-----------------------------------------------
// Function prototypes
@@ -777,5 +777,5 @@ void CompileAnsiC(char *outFile);
void CompileInterpreted(char *outFile);
//Arduino.cpp
void CompileArduino(char *outFile);
-
+*/
#endif
--
cgit
From 39d3eeb5fc8c969f8eed03e0c1fc818453cca6df Mon Sep 17 00:00:00 2001
From: NatsuDrag9
Date: Thu, 31 May 2018 11:43:09 +0530
Subject: Ported the function updating titlebar.
---
ldmicro/includes/ldmicro.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 579d3a7..50299ee 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -747,7 +747,7 @@ void SetAdcShadow(char *name, SWORD val);
SWORD GetAdcShadow(char *name);
void DestroyUartSimulationWindow(void);
void ShowUartSimulationWindow(void);
-extern BOOL InSimulationMode;
+extern BOOL InSimulationMode;
extern BOOL SimulateRedrawAfterNextCycle;
// compilecommon.cpp
--
cgit
From 0e41f9a700e928970f79b20d8d6a0f9993b16df6 Mon Sep 17 00:00:00 2001
From: NatsuDrag9
Date: Thu, 31 May 2018 12:35:36 +0530
Subject: Rearranged variables
---
ldmicro/includes/ldmicro.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 50299ee..df8c02e 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -515,9 +515,9 @@ void RefreshScrollbars(void);
extern HINSTANCE Instance;
extern HWND MainWindow;
extern HDC Hdc;
-extern PlcProgram Prog;
+extern PlcProgram Prog;*/
extern char CurrentSaveFile[MAX_PATH];
-extern char CurrentCompileFile[MAX_PATH];
+/*extern char CurrentCompileFile[MAX_PATH];
extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
// memory debugging, because I often get careless; ok() will check that the
// heap used for all the program storage is not yet corrupt, and oops() if
@@ -746,9 +746,9 @@ void SimulationResetContact(char* name);
void SetAdcShadow(char *name, SWORD val);
SWORD GetAdcShadow(char *name);
void DestroyUartSimulationWindow(void);
-void ShowUartSimulationWindow(void);
+void ShowUartSimulationWindow(void);*/
extern BOOL InSimulationMode;
-extern BOOL SimulateRedrawAfterNextCycle;
+/*extern BOOL SimulateRedrawAfterNextCycle;
// compilecommon.cpp
void AllocStart(void);
--
cgit
From 3cf43f746d445fdce77af21718881f45fe78d06b Mon Sep 17 00:00:00 2001
From: NatsuDrag9
Date: Thu, 31 May 2018 13:19:50 +0530
Subject: Updated the completed functions.
---
ldmicro/includes/ldmicro.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index df8c02e..e35e346 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -512,13 +512,15 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
BOOL canPushRungDown, BOOL canPushRungUp, BOOL canInsertComment);
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled);
void RefreshScrollbars(void);
-extern HINSTANCE Instance;
-extern HWND MainWindow;
+extern HINSTANCE Instance;*/
+extern HWID MainWindow;
+/*
extern HDC Hdc;
extern PlcProgram Prog;*/
extern char CurrentSaveFile[MAX_PATH];
-/*extern char CurrentCompileFile[MAX_PATH];
+// extern char CurrentCompileFile[MAX_PATH];
extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
+/*
// memory debugging, because I often get careless; ok() will check that the
// heap used for all the program storage is not yet corrupt, and oops() if
// it is
--
cgit
From 1f483baf37359032ca3224a5d07853aaf725def4 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Mon, 4 Jun 2018 15:25:44 +0530
Subject: Commented all GUI code for core test
---
ldmicro/includes/advanceddialog.h | 284 +++++++++++++++++++-------------------
ldmicro/includes/ldmicro.h | 22 +--
ldmicro/includes/windows.h | 40 ++++++
3 files changed, 193 insertions(+), 153 deletions(-)
create mode 100644 ldmicro/includes/windows.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/advanceddialog.h b/ldmicro/includes/advanceddialog.h
index 5e4808f..5adadbc 100644
--- a/ldmicro/includes/advanceddialog.h
+++ b/ldmicro/includes/advanceddialog.h
@@ -1,142 +1,142 @@
-#ifndef _ADVANCED_DIALOG_H
-#define _ADVANCED_DIALOG_H
-
-#define MAX_PIN_NAME 128
-
-/*Advanced Dialog Menus*/
-#define MNU_ADV_NEW 0x01
-#define MNU_ADV_OPEN 0x02
-#define MNU_ADV_SAVE 0x03
-#define MNU_ADV_SAVE_AS 0x04
-#define MNU_ADV_EXIT 0x05
-
-#define MNU_ADV_UNDO 0x10
-#define MNU_ADV_REDO 0x11
-#define MNU_ADV_CUT 0x12
-#define MNU_ADV_COPY 0x13
-#define MNU_ADV_PASTE 0x14
-#define MNU_ADV_DEL 0x15
-
-#define MNU_ADV_SIMULATION_MODE 0x20
-#define MNU_ADV_START_SIMULATION 0x21
-#define MNU_ADV_STOP_SIMULATION 0x22
-#define MNU_ADV_SINGLE_CYCLE 0x23
-
-#define MNU_ADV_MANUAL 0x30
-#define MNU_ADV_ABOUT 0x31
-
-#define MAX_NAME_LENGTH 128
-#define MAX_SCREEN_ITEMS 512
-#define MAX_PINS 4000
-#define MCU_PIN_FLAG 4000
-#define MAX_MCU_PINS 128
-#define TIMER_ADV_SIMULATE 101
-
-
-typedef struct ImageStructTag {
- int selectedState;
- HIMAGELIST Images;
- int ComponentId;
-} ImageStruct;
-
-typedef struct ImageLocationTag{
- int Id;
- ImageStruct* Image;
- int Index;
- int x;
- int y;
- void* Properties;
- void* PinId;
- void* PinName;
-}ImageLocation;
-
-typedef struct PinInfoTag{
- double Volt;
- double OperatingVolt;
- void** ImageId;
- int* Index;
- int* ImageType; //To compare with imagelocation array
- int LinkCount; //No of valid entries in array
- double ProgVolt;
- void* ProgComponent;
-}PinInfo;
-
-typedef struct PinMcuTag{
- UINT PinId;
- UINT state;
- int type;
- BOOL InternalPullup;
-}PinMcu;
-
-typedef struct PinNameTag{
- UINT PinId; //Need to generate unique pinid every time user saves a name
- TCHAR Name[MAX_NAME_LENGTH];
- PinInfo PinData;
-}PinName;
-
-typedef struct PinComponentTag{
- UINT PinId;
- void** ComponentAddress;
- int Count;
- void* Next;
-}PinComponent;
-
-extern HANDLE ImageHeap;
-extern HFONT AdvNiceFont;
-extern HFONT AdvFixedFont;
-extern UINT NameCount;
-extern ImageLocation ImageStack[MAX_SCREEN_ITEMS];
-// extern PinInfo PinData[MAX_PINS];
-extern PinMcu McuPin[MAX_MCU_PINS];
-extern PinName NameId[MAX_PINS];
-extern HWND AdvancedDialog;
-extern PinComponent ComponentPin;
-
-/*Advanced Dialog Functions*/
-void MakeAdvancedDialogControls(void);
-void AdvancedDialogResized(void);
-void MakeAdvancedWindowMenus(void);
-void ProcessEvent(int x, int y, int Event);
-void AdvancedWindowClosing(void);
-void ToggleAdvancedSimulationMode(void);
-void SimulateOneAdvCycle(BOOL ForceRefresh);
-int IsMCUPin(int PinId);
-// void CreateVoltRequest(int PinId, int Index, double VoltReq);
-
-// Heap Functions
-void* AllocImageHeap(size_t n);
-void* ReallocImageHeap(LPVOID lpMem, size_t n);
-void FreeImageHeap(void *p);
-
-// Component Functions
-
-void InitComponents(void);
-
-double GetGlobalVoltage(int PinId, void* ComponentAddress);
-double RefreshVolt(int PinId, int Index, UINT Id, void* ComponentAddress, double volt);
-double RefreshProcessorStat(int PinId, UINT Id);
-
-
-int RegisterPinName(LPCTSTR Name);
-int SetPinImage(int PinId,void* ImageId,int ImageType, int Index);
-int FlushPinNames(void); //Clear Pins which are deleted from MainWindow
-int DeRegisterPinName(LPCTSTR Name, void* ImageId);
-int DeletePinImage(LPCTSTR Name, void* ImageId, int Index);
-int DeletePinName(UINT Index);
-void SetMcu(int PinId, int Type);
-void RefreshNamingList(void);
-void PopulateNamingList(void);
-
-double RequestVoltChange(int PinId, int Index, void *ComponentAddress, double volt);
-
-int DeleteComponentPin(int PinId, void* ComponentAddress);
-int AddComponentPin(int PinId, void* ComponentAddress);
-// int RegisterPinState(int Index, double Volt);
-
-//NamingList functions
-void ToggleInternalPullup(int PinId);
-
-
-extern BOOL SimulationStarted;
-
-#endif
+// #ifndef _ADVANCED_DIALOG_H
+// #define _ADVANCED_DIALOG_H
+
+// #define MAX_PIN_NAME 128
+
+// /*Advanced Dialog Menus*/
+// #define MNU_ADV_NEW 0x01
+// #define MNU_ADV_OPEN 0x02
+// #define MNU_ADV_SAVE 0x03
+// #define MNU_ADV_SAVE_AS 0x04
+// #define MNU_ADV_EXIT 0x05
+
+// #define MNU_ADV_UNDO 0x10
+// #define MNU_ADV_REDO 0x11
+// #define MNU_ADV_CUT 0x12
+// #define MNU_ADV_COPY 0x13
+// #define MNU_ADV_PASTE 0x14
+// #define MNU_ADV_DEL 0x15
+
+// #define MNU_ADV_SIMULATION_MODE 0x20
+// #define MNU_ADV_START_SIMULATION 0x21
+// #define MNU_ADV_STOP_SIMULATION 0x22
+// #define MNU_ADV_SINGLE_CYCLE 0x23
+
+// #define MNU_ADV_MANUAL 0x30
+// #define MNU_ADV_ABOUT 0x31
+
+// #define MAX_NAME_LENGTH 128
+// #define MAX_SCREEN_ITEMS 512
+// #define MAX_PINS 4000
+// #define MCU_PIN_FLAG 4000
+// #define MAX_MCU_PINS 128
+// #define TIMER_ADV_SIMULATE 101
+
+
+// typedef struct ImageStructTag {
+// int selectedState;
+// HIMAGELIST Images;
+// int ComponentId;
+// } ImageStruct;
+
+// typedef struct ImageLocationTag{
+// int Id;
+// ImageStruct* Image;
+// int Index;
+// int x;
+// int y;
+// void* Properties;
+// void* PinId;
+// void* PinName;
+// }ImageLocation;
+
+// typedef struct PinInfoTag{
+// double Volt;
+// double OperatingVolt;
+// void** ImageId;
+// int* Index;
+// int* ImageType; //To compare with imagelocation array
+// int LinkCount; //No of valid entries in array
+// double ProgVolt;
+// void* ProgComponent;
+// }PinInfo;
+
+// typedef struct PinMcuTag{
+// UINT PinId;
+// UINT state;
+// int type;
+// BOOL InternalPullup;
+// }PinMcu;
+
+// typedef struct PinNameTag{
+// UINT PinId; //Need to generate unique pinid every time user saves a name
+// TCHAR Name[MAX_NAME_LENGTH];
+// PinInfo PinData;
+// }PinName;
+
+// typedef struct PinComponentTag{
+// UINT PinId;
+// void** ComponentAddress;
+// int Count;
+// void* Next;
+// }PinComponent;
+
+// extern HANDLE ImageHeap;
+// extern HFONT AdvNiceFont;
+// extern HFONT AdvFixedFont;
+// extern UINT NameCount;
+// extern ImageLocation ImageStack[MAX_SCREEN_ITEMS];
+// // extern PinInfo PinData[MAX_PINS];
+// extern PinMcu McuPin[MAX_MCU_PINS];
+// extern PinName NameId[MAX_PINS];
+// extern HWND AdvancedDialog;
+// extern PinComponent ComponentPin;
+
+// /*Advanced Dialog Functions*/
+// void MakeAdvancedDialogControls(void);
+// void AdvancedDialogResized(void);
+// void MakeAdvancedWindowMenus(void);
+// void ProcessEvent(int x, int y, int Event);
+// void AdvancedWindowClosing(void);
+// void ToggleAdvancedSimulationMode(void);
+// void SimulateOneAdvCycle(BOOL ForceRefresh);
+// int IsMCUPin(int PinId);
+// // void CreateVoltRequest(int PinId, int Index, double VoltReq);
+
+// // Heap Functions
+// void* AllocImageHeap(size_t n);
+// void* ReallocImageHeap(LPVOID lpMem, size_t n);
+// void FreeImageHeap(void *p);
+
+// // Component Functions
+
+// void InitComponents(void);
+
+// double GetGlobalVoltage(int PinId, void* ComponentAddress);
+// double RefreshVolt(int PinId, int Index, UINT Id, void* ComponentAddress, double volt);
+// double RefreshProcessorStat(int PinId, UINT Id);
+
+
+// int RegisterPinName(LPCTSTR Name);
+// int SetPinImage(int PinId,void* ImageId,int ImageType, int Index);
+// int FlushPinNames(void); //Clear Pins which are deleted from MainWindow
+// int DeRegisterPinName(LPCTSTR Name, void* ImageId);
+// int DeletePinImage(LPCTSTR Name, void* ImageId, int Index);
+// int DeletePinName(UINT Index);
+// void SetMcu(int PinId, int Type);
+// void RefreshNamingList(void);
+// void PopulateNamingList(void);
+
+// double RequestVoltChange(int PinId, int Index, void *ComponentAddress, double volt);
+
+// int DeleteComponentPin(int PinId, void* ComponentAddress);
+// int AddComponentPin(int PinId, void* ComponentAddress);
+// // int RegisterPinState(int Index, double Volt);
+
+// //NamingList functions
+// void ToggleInternalPullup(int PinId);
+
+
+// extern BOOL SimulationStarted;
+
+// #endif
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index 579d3a7..f7a3d9b 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -501,7 +501,6 @@ typedef struct McuIoInfoTag {
#define NUM_SUPPORTED_MCUS 16
-/*
//-----------------------------------------------
// Function prototypes
@@ -513,7 +512,7 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled);
void RefreshScrollbars(void);
extern HINSTANCE Instance;
-extern HWND MainWindow;
+extern HWID MainWindow;
extern HDC Hdc;
extern PlcProgram Prog;
extern char CurrentSaveFile[MAX_PATH];
@@ -554,14 +553,14 @@ extern BOOL SelectionActive;
extern BOOL ThisHighlighted;
// draw_outputdev.cpp
-extern void (*DrawChars)(int, int, char *);
-void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time);
-void PaintWindow(void);
-void ExportDrawingAsText(char *file);
-void InitForDrawing(void);
-void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert);
-int ScreenRowsAvailable(void);
-int ScreenColsAvailable(void);
+// extern void (*DrawChars)(int, int, char *);
+// void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time);
+// void PaintWindow(void);
+// void ExportDrawingAsText(char *file);
+// void InitForDrawing(void);
+// void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert);
+// int ScreenRowsAvailable(void);
+// int ScreenColsAvailable(void);
extern HFONT FixedWidthFont;
extern HFONT FixedWidthFontBold;
extern int SelectedGxAfterNextPaint;
@@ -703,6 +702,7 @@ void ShowHelpDialog(BOOL about);
Error("Internal error at line %d file '%s'\n", __LINE__, __FILE__); \
exit(1); \
}
+
void dbp(char *str, ...);
void Error(char *str, ...);
void *CheckMalloc(size_t n);
@@ -777,5 +777,5 @@ void CompileAnsiC(char *outFile);
void CompileInterpreted(char *outFile);
//Arduino.cpp
void CompileArduino(char *outFile);
-*/
+
#endif
diff --git a/ldmicro/includes/windows.h b/ldmicro/includes/windows.h
new file mode 100644
index 0000000..2e0621d
--- /dev/null
+++ b/ldmicro/includes/windows.h
@@ -0,0 +1,40 @@
+#ifndef __windows_h_
+#define __windoew_h_
+#include "linuxUI.h"
+#include
+typedef void* HFONT;
+typedef void* HMODULE;
+typedef void* HHOOK;
+typedef void* HBRUSH;
+typedef void* HFONT;
+
+#if defined(__UNIX64)
+ typedef __int64_t LONG_PTR;
+#else
+ typedef long LONG_PTR;
+#endif
+
+typedef UINT_PTR WPARAM;
+typedef LONG_PTR LPARAM;
+typedef LONG_PTR LRESULT;
+
+typedef struct tagSCROLLINFO {
+ UINT cbSize;
+ UINT fMask;
+ int nMin;
+ int nMax;
+ UINT nPage;
+ int nPos;
+ int nTrackPos;
+} SCROLLINFO, *LPCSCROLLINFO;
+
+typedef struct tagNMHDR {
+ HWND hwndFrom;
+ UINT_PTR idFrom;
+ UINT code;
+} NMHDR;
+
+void OutputDebugString(char*);
+double GetTickCount(void);
+
+#endif
\ No newline at end of file
--
cgit
From 67b618853b13595749ef89c620de4bc8e967cd02 Mon Sep 17 00:00:00 2001
From: NatsuDrag9
Date: Wed, 6 Jun 2018 10:03:16 +0530
Subject: Ported functions
---
ldmicro/includes/ldmicro.h | 157 +++++++++++++++++++++++----------------------
1 file changed, 79 insertions(+), 78 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index e35e346..e434b82 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -28,6 +28,8 @@
typedef signed short SWORD;
typedef signed long SDWORD;
+// #include "linuxUI.h"
+
//-----------------------------------------------
// `Configuration options.'
@@ -38,84 +40,87 @@ typedef signed long SDWORD;
#define FONT_WIDTH 7
#define FONT_HEIGHT 13
+// Timer IDs associated with the main window.
+#define TIMER_BLINK_CURSOR 1
+#define TIMER_SIMULATE 2
//-----------------------------------------------
// Constants for the GUI. We have drop-down menus, a listview for the I/Os,
// etc.
// Menu IDs
+extern HMENU MNU_NEW;
+extern HMENU MNU_OPEN;
+extern HMENU MNU_SAVE;
+extern HMENU MNU_SAVE_AS;
+extern HMENU MNU_EXPORT;
+extern HMENU MNU_EXIT;
+
+extern HMENU MNU_UNDO;
+extern HMENU MNU_REDO;
+extern HMENU MNU_PUSH_RUNG_UP;
+extern HMENU MNU_PUSH_RUNG_DOWN;
+extern HMENU MNU_INSERT_RUNG_BEFORE;
+extern HMENU MNU_INSERT_RUNG_AFTER;
+extern HMENU MNU_DELETE_ELEMENT;
+extern HMENU MNU_DELETE_RUNG;
+
+extern HMENU MNU_INSERT_COMMENT;
+extern HMENU MNU_INSERT_CONTACTS;
+extern HMENU MNU_INSERT_COIL;
+extern HMENU MNU_INSERT_TON;
+extern HMENU MNU_INSERT_TOF;
+extern HMENU MNU_INSERT_RTO;
+extern HMENU MNU_INSERT_RES;
+extern HMENU MNU_INSERT_OSR;
+extern HMENU MNU_INSERT_OSF;
+extern HMENU MNU_INSERT_CTU;
+extern HMENU MNU_INSERT_CTD;
+extern HMENU MNU_INSERT_CTC;
+extern HMENU MNU_INSERT_ADD;
+extern HMENU MNU_INSERT_SUB;
+extern HMENU MNU_INSERT_MUL;
+extern HMENU MNU_INSERT_DIV;
+extern HMENU MNU_INSERT_MOV;
+extern HMENU MNU_INSERT_READ_ADC;
+extern HMENU MNU_INSERT_SET_PWM;
+extern HMENU MNU_INSERT_UART_SEND;
+extern HMENU MNU_INSERT_UART_RECV;
+extern HMENU MNU_INSERT_EQU;
+extern HMENU MNU_INSERT_NEQ;
+extern HMENU MNU_INSERT_GRT;
+extern HMENU MNU_INSERT_GEQ;
+extern HMENU MNU_INSERT_LES;
+extern HMENU MNU_INSERT_LEQ;
+extern HMENU MNU_INSERT_OPEN;
+extern HMENU MNU_INSERT_SHORT;
+extern HMENU MNU_INSERT_MASTER_RLY;
+extern HMENU MNU_INSERT_SHIFT_REG;
+extern HMENU MNU_INSERT_LUT;
+extern HMENU MNU_INSERT_FMTD_STR;
+extern HMENU MNU_INSERT_PERSIST;
+extern HMENU MNU_MAKE_NORMAL;
+extern HMENU MNU_NEGATE;
+extern HMENU MNU_MAKE_SET_ONLY;
+extern HMENU MNU_MAKE_RESET_ONLY;
+extern HMENU MNU_INSERT_PWL;
+
+extern HMENU MNU_MCU_SETTINGS;
+extern HMENU MNU_PROCESSOR_0;
+
+extern HMENU MNU_SIMULATION_MODE;
+extern HMENU MNU_START_SIMULATION;
+extern HMENU MNU_STOP_SIMULATION;
+extern HMENU MNU_SINGLE_CYCLE;
+
+extern HMENU MNU_COMPILE;
+extern HMENU MNU_COMPILE_AS;
+
+extern HMENU MNU_MANUAL;
+extern HMENU MNU_ABOUT;
+
+extern HMENU MNU_ADV_SIMULATION;
-#define MNU_NEW 0x01
-#define MNU_OPEN 0x02
-#define MNU_SAVE 0x03
-#define MNU_SAVE_AS 0x04
-#define MNU_EXPORT 0x05
-#define MNU_EXIT 0x06
-
-#define MNU_UNDO 0x10
-#define MNU_REDO 0x11
-#define MNU_PUSH_RUNG_UP 0x12
-#define MNU_PUSH_RUNG_DOWN 0x13
-#define MNU_INSERT_RUNG_BEFORE 0x14
-#define MNU_INSERT_RUNG_AFTER 0x15
-#define MNU_DELETE_ELEMENT 0x16
-#define MNU_DELETE_RUNG 0x17
-
-#define MNU_INSERT_COMMENT 0x20
-#define MNU_INSERT_CONTACTS 0x21
-#define MNU_INSERT_COIL 0x22
-#define MNU_INSERT_TON 0x23
-#define MNU_INSERT_TOF 0x24
-#define MNU_INSERT_RTO 0x25
-#define MNU_INSERT_RES 0x26
-#define MNU_INSERT_OSR 0x27
-#define MNU_INSERT_OSF 0x28
-#define MNU_INSERT_CTU 0x29
-#define MNU_INSERT_CTD 0x2a
-#define MNU_INSERT_CTC 0x2b
-#define MNU_INSERT_ADD 0x2c
-#define MNU_INSERT_SUB 0x2d
-#define MNU_INSERT_MUL 0x2e
-#define MNU_INSERT_DIV 0x2f
-#define MNU_INSERT_MOV 0x30
-#define MNU_INSERT_READ_ADC 0x31
-#define MNU_INSERT_SET_PWM 0x32
-#define MNU_INSERT_UART_SEND 0x33
-#define MNU_INSERT_UART_RECV 0x34
-#define MNU_INSERT_EQU 0x35
-#define MNU_INSERT_NEQ 0x36
-#define MNU_INSERT_GRT 0x37
-#define MNU_INSERT_GEQ 0x38
-#define MNU_INSERT_LES 0x39
-#define MNU_INSERT_LEQ 0x3a
-#define MNU_INSERT_OPEN 0x3b
-#define MNU_INSERT_SHORT 0x3c
-#define MNU_INSERT_MASTER_RLY 0x3d
-#define MNU_INSERT_SHIFT_REG 0x3e
-#define MNU_INSERT_LUT 0x3f
-#define MNU_INSERT_FMTD_STR 0x40
-#define MNU_INSERT_PERSIST 0x41
-#define MNU_MAKE_NORMAL 0x42
-#define MNU_NEGATE 0x43
-#define MNU_MAKE_SET_ONLY 0x44
-#define MNU_MAKE_RESET_ONLY 0x45
-#define MNU_INSERT_PWL 0x46
-
-#define MNU_MCU_SETTINGS 0x50
-#define MNU_PROCESSOR_0 0xa0
-
-#define MNU_SIMULATION_MODE 0x60
-#define MNU_START_SIMULATION 0x61
-#define MNU_STOP_SIMULATION 0x62
-#define MNU_SINGLE_CYCLE 0x63
-
-#define MNU_COMPILE 0x70
-#define MNU_COMPILE_AS 0x71
-
-#define MNU_MANUAL 0x80
-#define MNU_ABOUT 0x81
-
-#define MNU_ADV_SIMULATION 0x82
// Columns within the I/O etc. listview.
#define LV_IO_NAME 0x00
@@ -123,11 +128,6 @@ typedef signed long SDWORD;
#define LV_IO_STATE 0x02
#define LV_IO_PIN 0x03
#define LV_IO_PORT 0x04
-
-// Timer IDs associated with the main window.
-#define TIMER_BLINK_CURSOR 1
-#define TIMER_SIMULATE 2
-
//-----------------------------------------------
// Data structures for the actual ladder logic. A rung on the ladder
// is a series subcircuit. A series subcircuit contains elements or
@@ -507,16 +507,17 @@ typedef struct McuIoInfoTag {
// ldmicro.cpp
void ProgramChanged(void);
+*/
void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly,
BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther,
BOOL canPushRungDown, BOOL canPushRungUp, BOOL canInsertComment);
+/*
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled);
void RefreshScrollbars(void);
extern HINSTANCE Instance;*/
extern HWID MainWindow;
-/*
extern HDC Hdc;
-extern PlcProgram Prog;*/
+extern PlcProgram Prog;
extern char CurrentSaveFile[MAX_PATH];
// extern char CurrentCompileFile[MAX_PATH];
extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
--
cgit
From 2ef55474f6c1622b19bbd9dfa0d132bb433e08b9 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Wed, 6 Jun 2018 12:12:49 +0530
Subject: Removed unnecessary files and headers.
---
ldmicro/includes/windows.h | 40 ----------------------------------------
1 file changed, 40 deletions(-)
delete mode 100644 ldmicro/includes/windows.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/windows.h b/ldmicro/includes/windows.h
deleted file mode 100644
index 2e0621d..0000000
--- a/ldmicro/includes/windows.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __windows_h_
-#define __windoew_h_
-#include "linuxUI.h"
-#include
-typedef void* HFONT;
-typedef void* HMODULE;
-typedef void* HHOOK;
-typedef void* HBRUSH;
-typedef void* HFONT;
-
-#if defined(__UNIX64)
- typedef __int64_t LONG_PTR;
-#else
- typedef long LONG_PTR;
-#endif
-
-typedef UINT_PTR WPARAM;
-typedef LONG_PTR LPARAM;
-typedef LONG_PTR LRESULT;
-
-typedef struct tagSCROLLINFO {
- UINT cbSize;
- UINT fMask;
- int nMin;
- int nMax;
- UINT nPage;
- int nPos;
- int nTrackPos;
-} SCROLLINFO, *LPCSCROLLINFO;
-
-typedef struct tagNMHDR {
- HWND hwndFrom;
- UINT_PTR idFrom;
- UINT code;
-} NMHDR;
-
-void OutputDebugString(char*);
-double GetTickCount(void);
-
-#endif
\ No newline at end of file
--
cgit
From 3333e7072ed134e381fa084f46d916c549cfc815 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Wed, 6 Jun 2018 13:25:11 +0530
Subject: Removed AdvancedSimulation files
---
ldmicro/includes/advanceddialog.h | 142 -----------------------
ldmicro/includes/componentlist.h | 71 ------------
ldmicro/includes/components/componentfunctions.h | 63 ----------
ldmicro/includes/components/componentimages.h | 53 ---------
ldmicro/includes/components/components.h | 51 --------
ldmicro/includes/components/componentstructs.h | 62 ----------
ldmicro/includes/simulate.h | 8 --
7 files changed, 450 deletions(-)
delete mode 100644 ldmicro/includes/advanceddialog.h
delete mode 100644 ldmicro/includes/componentlist.h
delete mode 100644 ldmicro/includes/components/componentfunctions.h
delete mode 100644 ldmicro/includes/components/componentimages.h
delete mode 100644 ldmicro/includes/components/components.h
delete mode 100644 ldmicro/includes/components/componentstructs.h
delete mode 100644 ldmicro/includes/simulate.h
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/advanceddialog.h b/ldmicro/includes/advanceddialog.h
deleted file mode 100644
index 5adadbc..0000000
--- a/ldmicro/includes/advanceddialog.h
+++ /dev/null
@@ -1,142 +0,0 @@
-// #ifndef _ADVANCED_DIALOG_H
-// #define _ADVANCED_DIALOG_H
-
-// #define MAX_PIN_NAME 128
-
-// /*Advanced Dialog Menus*/
-// #define MNU_ADV_NEW 0x01
-// #define MNU_ADV_OPEN 0x02
-// #define MNU_ADV_SAVE 0x03
-// #define MNU_ADV_SAVE_AS 0x04
-// #define MNU_ADV_EXIT 0x05
-
-// #define MNU_ADV_UNDO 0x10
-// #define MNU_ADV_REDO 0x11
-// #define MNU_ADV_CUT 0x12
-// #define MNU_ADV_COPY 0x13
-// #define MNU_ADV_PASTE 0x14
-// #define MNU_ADV_DEL 0x15
-
-// #define MNU_ADV_SIMULATION_MODE 0x20
-// #define MNU_ADV_START_SIMULATION 0x21
-// #define MNU_ADV_STOP_SIMULATION 0x22
-// #define MNU_ADV_SINGLE_CYCLE 0x23
-
-// #define MNU_ADV_MANUAL 0x30
-// #define MNU_ADV_ABOUT 0x31
-
-// #define MAX_NAME_LENGTH 128
-// #define MAX_SCREEN_ITEMS 512
-// #define MAX_PINS 4000
-// #define MCU_PIN_FLAG 4000
-// #define MAX_MCU_PINS 128
-// #define TIMER_ADV_SIMULATE 101
-
-
-// typedef struct ImageStructTag {
-// int selectedState;
-// HIMAGELIST Images;
-// int ComponentId;
-// } ImageStruct;
-
-// typedef struct ImageLocationTag{
-// int Id;
-// ImageStruct* Image;
-// int Index;
-// int x;
-// int y;
-// void* Properties;
-// void* PinId;
-// void* PinName;
-// }ImageLocation;
-
-// typedef struct PinInfoTag{
-// double Volt;
-// double OperatingVolt;
-// void** ImageId;
-// int* Index;
-// int* ImageType; //To compare with imagelocation array
-// int LinkCount; //No of valid entries in array
-// double ProgVolt;
-// void* ProgComponent;
-// }PinInfo;
-
-// typedef struct PinMcuTag{
-// UINT PinId;
-// UINT state;
-// int type;
-// BOOL InternalPullup;
-// }PinMcu;
-
-// typedef struct PinNameTag{
-// UINT PinId; //Need to generate unique pinid every time user saves a name
-// TCHAR Name[MAX_NAME_LENGTH];
-// PinInfo PinData;
-// }PinName;
-
-// typedef struct PinComponentTag{
-// UINT PinId;
-// void** ComponentAddress;
-// int Count;
-// void* Next;
-// }PinComponent;
-
-// extern HANDLE ImageHeap;
-// extern HFONT AdvNiceFont;
-// extern HFONT AdvFixedFont;
-// extern UINT NameCount;
-// extern ImageLocation ImageStack[MAX_SCREEN_ITEMS];
-// // extern PinInfo PinData[MAX_PINS];
-// extern PinMcu McuPin[MAX_MCU_PINS];
-// extern PinName NameId[MAX_PINS];
-// extern HWND AdvancedDialog;
-// extern PinComponent ComponentPin;
-
-// /*Advanced Dialog Functions*/
-// void MakeAdvancedDialogControls(void);
-// void AdvancedDialogResized(void);
-// void MakeAdvancedWindowMenus(void);
-// void ProcessEvent(int x, int y, int Event);
-// void AdvancedWindowClosing(void);
-// void ToggleAdvancedSimulationMode(void);
-// void SimulateOneAdvCycle(BOOL ForceRefresh);
-// int IsMCUPin(int PinId);
-// // void CreateVoltRequest(int PinId, int Index, double VoltReq);
-
-// // Heap Functions
-// void* AllocImageHeap(size_t n);
-// void* ReallocImageHeap(LPVOID lpMem, size_t n);
-// void FreeImageHeap(void *p);
-
-// // Component Functions
-
-// void InitComponents(void);
-
-// double GetGlobalVoltage(int PinId, void* ComponentAddress);
-// double RefreshVolt(int PinId, int Index, UINT Id, void* ComponentAddress, double volt);
-// double RefreshProcessorStat(int PinId, UINT Id);
-
-
-// int RegisterPinName(LPCTSTR Name);
-// int SetPinImage(int PinId,void* ImageId,int ImageType, int Index);
-// int FlushPinNames(void); //Clear Pins which are deleted from MainWindow
-// int DeRegisterPinName(LPCTSTR Name, void* ImageId);
-// int DeletePinImage(LPCTSTR Name, void* ImageId, int Index);
-// int DeletePinName(UINT Index);
-// void SetMcu(int PinId, int Type);
-// void RefreshNamingList(void);
-// void PopulateNamingList(void);
-
-// double RequestVoltChange(int PinId, int Index, void *ComponentAddress, double volt);
-
-// int DeleteComponentPin(int PinId, void* ComponentAddress);
-// int AddComponentPin(int PinId, void* ComponentAddress);
-// // int RegisterPinState(int Index, double Volt);
-
-// //NamingList functions
-// void ToggleInternalPullup(int PinId);
-
-
-// extern BOOL SimulationStarted;
-
-// #endif
diff --git a/ldmicro/includes/componentlist.h b/ldmicro/includes/componentlist.h
deleted file mode 100644
index 20c095b..0000000
--- a/ldmicro/includes/componentlist.h
+++ /dev/null
@@ -1,71 +0,0 @@
-//-----------------------------------------------------------------------------
-// Copyright 2007 Jonathan Westhues
-//
-// This file is part of LDmicro.
-//
-// LDmicro 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 3 of the License, or
-// (at your option) any later version.
-//
-// LDmicro 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 LDmicro. If not, see .
-//------
-//
-// Constants, structures, declarations etc. for the PIC ladder logic compiler
-// Jonathan Westhues, Oct 2004
-//-----------------------------------------------------------------------------
-
-#ifndef __COMPONENTLIST_H
-#define __COMPONENTLIST_H
-
-#define MAX_COMPONENTS 999
-#define MAX_IMAGES 10
-
-#define COMPONENT_WIDTH 100
-#define COMPONENT_HEIGHT 100
-
-extern HDC HdcMem;
-extern HWND ComponentList;
-extern HBITMAP test;
-extern HIMAGELIST ComponentDiagrams;
-extern HWND AdvancedWorkspace;
-extern BOOL Dragging;
-extern int ImagesDrawn;
-extern int DragX;
-extern int DragY;
-extern UINT UniquePinId;
-extern UINT UniqueImgId;
-
-
-/*map Imagemap; //To relate image with it's drawing area(Index,Images,x,y,maptype)
-map Switchmap; //Add MCU pin later //(Index(same as Imagemap), Selected, Default Connected,Latch Action)
-map Relaymap; //Add MCU pin later //(Index(same as Imagemap), Selected)
-
-extern Imagemap test;*/
-
-void ComponentListProc(NMHDR *h);
-void ComponentListInitiate(void);
-
-void InitializeImageList(HIMAGELIST *il);
-
-int BeginComponentDrag(int x, int y);
-int ComponentDrag(int x, int y);
-int EndComponentDrag(int x, int y);
-
-// Componentimages.cpp functions
-//Function Definitions
-
-void InitializeComponentImage(int Component, HIMAGELIST *il);
-IStream * CreateStreamOnResource(LPCTSTR lpName, LPCTSTR lpType);
-IWICBitmapSource * LoadBitmapFromStream(IStream * ipImageStream);
-HBITMAP CreateHBITMAP(IWICBitmapSource * ipBitmap);
-HBITMAP LoadComponentImage(int resource);
-
-
-#endif
\ No newline at end of file
diff --git a/ldmicro/includes/components/componentfunctions.h b/ldmicro/includes/components/componentfunctions.h
deleted file mode 100644
index 916bf00..0000000
--- a/ldmicro/includes/components/componentfunctions.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef _COMPONENT_FUNCTIONS
-#define _COMPONENT_FUNCTIONS
-
-//Few Prerequisites
-extern HFONT MyNiceFont;
-extern HFONT MyFixedFont;
-extern HWND OkButton;
-extern HWND CancelButton;
-extern HINSTANCE* ComponentInstance;
-
-extern BOOL DlgDone;
-extern BOOL DlgCancel;
-extern HWND ComponentDialog;
-
-// Common Functions
-
-void FontNice(HWND h);
-void FontFixed(HWND h);
-HWND* CreateDialogWindow(LPCTSTR title, int x, int y, int width, int height, int style);
-void ShowDialogWindow(void);
-BOOL ProcessDialogWindow(void);
-
-/*Initialization Functions*/
-int InitSwitch(void* ComponentAddress);
-int InitRelay(void* ComponentAddress);
-int InitSpdt(void* ComponentAddress);
-int InitDpst(void* ComponentAddress);
-int InitDpdt(void* ComponentAddress);
-
-/*Event Handlers*/
-void HandleSwitchEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
- void* ImageLocation, UINT ImageId, HWND* h);
-void HandleRelayEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
- void* ImageLocation, UINT ImageId, HWND* h);
-void HandleSpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
- void* ImageLocation, UINT ImageId, HWND* h);
-void HandleDpstEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
- void* ImageLocation, UINT ImageId, HWND* h);
-void HandleDpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted,
- void* ImageLocation, UINT ImageId, HWND* h);
-
-/*Request Handlers*/
-double SwitchVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
- double Volt, int Source, void* ImageLocation);
-double RelayVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
- double Volt, int Source, void* ImageLocation);
-double SpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
- double Volt, int Source, void* ImageLocation);
-double DpstVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
- double Volt, int Source, void* ImageLocation);
-double DpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index,
- double Volt, int Source, void* ImageLocation);
-
-/*Program Reference Functions*/
-void SetSwitchIds(int*, void*);
-void SetRelayIds(int*, void*);
-void SetSpdtIds(int*, void*);
-void SetDpstIds(int*, void*);
-void SetDpdtIds(int*, void*);
-
-// Relay Functions
-
-#endif
diff --git a/ldmicro/includes/components/componentimages.h b/ldmicro/includes/components/componentimages.h
deleted file mode 100644
index 27ef6ce..0000000
--- a/ldmicro/includes/components/componentimages.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef __COMPONENTIMAGES_H
-#define __COMPONENTIMAGES_H
-
-#define SWITCH_CONNECTED 8000
-#define SWITCH_DISCONNECTED 8001
-#define RELAY_NC 8002
-#define RELAY_NO 8003
-#define SPDT_1 8004
-#define SPDT_2 8005
-#define DPST_1 8006
-#define DPST_2 8007
-#define DPDT_1 8008
-#define DPDT_2 8009
-
-
-
-#ifndef RC_INVOKED //Used to hide code from resource file(Guess)
-
-#define TOTAL_COMPONENTS 5
-#define COMPONENT_NAME_MAX_LENGTH 50
-
-// Try to keep ComponentID's between 6000 - 6999
-
-#define COMPONENT_SWITCH 6000
-#define COMPONENT_RELAY 6001
-#define COMPONENT_SPDT 6002
-#define COMPONENT_DPST 6003
-#define COMPONENT_DPDT 6004
-
-
-#define MAX_PIN_COUNT 10
-
-typedef struct ComponentDataTag{
- int Index;
- int ComponentId;
- TCHAR ComponentName[COMPONENT_NAME_MAX_LENGTH];
- int PinCount;
- LPCTSTR PinNames[MAX_PIN_COUNT]; //Valid Number of images from below property
-}ComponentData;
-
-void RefreshImages();
-void SetImage(int Component, void *il);
-
-static ComponentData rgCompData[TOTAL_COMPONENTS] = {
- {0, COMPONENT_SWITCH, TEXT("Switch"), 2, {"Input:", "Output:"}},
- {1, COMPONENT_RELAY, TEXT("Relay"), 5, {"Coil1:", "Coil2:", "NO:", "COM:", "NC:"}},
- {2, COMPONENT_SPDT, TEXT("SPDT"), 3, {"Input:", "Output1:", "Output2:"}},
- {3, COMPONENT_DPST, TEXT("DPST"), 4, {"Input1:", "Input2:", "Output1:", "Output2:"}},
- {4, COMPONENT_DPDT, TEXT("DPDT"), 6, {"Input1:", "Input2:", "Output11:", "Output12:", "Output21:", "Output22:"}}
-};
-
-#endif
-#endif
diff --git a/ldmicro/includes/components/components.h b/ldmicro/includes/components/components.h
deleted file mode 100644
index 810c2d2..0000000
--- a/ldmicro/includes/components/components.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _COMPONENTS_H
-#define _COMPONENTS_H
-
-#define EVENT_VALUE_CHANGED 0
-#define EVENT_MOUSE_CLICK 1
-#define EVENT_MOUSE_DOWN 2
-#define EVENT_MOUSE_UP 3
-#define EVENT_MOUSE_RDOWN 4
-#define EVENT_MOUSE_RUP 5
-#define EVENT_MOUSE_DBLCLICK 6
-#define EVENT_MOUSE_RCLICK 7
-
-
-
-#define SOURCE_PROGRAM_MAIN 1
-#define SOURCE_PROGRAM_NEW 2
-#define SOURCE_EVENT_MAIN 3
-#define SOURCE_EVENT_NEW 4
-#define SOURCE_FORCE_MAIN 5
-#define SOURCE_REQUEST_MAIN 6
-
-/*#define EVENT_KEY_DOWN 6
-#define EVENT_KEY_RELEASE 7
-#define EVENT_KEY_PRESS 8*/
-#define V_DIALOG_WIDTH 96
-#define V_DIALOG_HEIGHT 115
-#define H_DIALOG_WIDTH 179
-#define H_DIALOG_HEIGHT 85
-
-//Window styles for dialog box
-#define STYLE_HORIZONTAL 1
-#define STYLE_VERTICAL 2
-
-#define GND 0
-#define VOLT_5 5
-#define V_OPEN 4196
-
-int NotifyComponent(void *ComponentAddress, void* PinName, int ComponentId, int Event,
- BOOL SimulationStarted, HWND* h, int Index, UINT ImageId, void* ImageLocation);
-int InitializeComponentProperties(void *ComponentAddress, int ComponentId);
-double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, int Index,
- double Volt, int Source, void* ImageLocation);
-
-double VoltRequest(int PinId, void* ComponentAddress);
-// void RequestData(void* ComponentAddress);
-// double GlobalVoltChange(int PinId, void *ComponentAddress, double volt);
-double VoltChange(int PinId, int Index, void* ComponentAddress, double Volt);
-size_t GetStructSize(int ComponentId);
-size_t GetNameSize(int ComponentId);
-
-#endif
diff --git a/ldmicro/includes/components/componentstructs.h b/ldmicro/includes/components/componentstructs.h
deleted file mode 100644
index 76dadda..0000000
--- a/ldmicro/includes/components/componentstructs.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef _COMPONENT_STRUCTS
-#define _COMPONENT_STRUCTS
-
-typedef struct SwitchStructTag
-{
- int id;
- int Image;
- BOOL Latched; //Temporary/Latched Action
- BOOL NOpen; //Initial Open/Closed position
- BOOL Open;
- char Name[15];
- double Volt[2];
- int PinId[2];
-}SwitchStruct;
-
-typedef struct RelayStructTag
-{
- int id;
- int Image;
- BOOL NC; //Whether relay is operated
- double MinOperatingVolt; //Operating voltage
- double MaxOperatingVolt;
- double CoilVolt1; //Voltage at input pin
- double CoilVolt2; //Voltage at input pin
- double COMVolt; //Voltage at COM pin
- double NOVolt; //Voltage at NO pin
- double NCVolt; //Voltage at NC pin
- int PinId[5];
-
-}RelayStruct;
-
-typedef struct SpdtStructTag
-{
- int id;
- int image;
- BOOL latched; //Whether the swetch is in latch mode or not
- BOOL NO1; //Whether Output 1 is connected
- double Volt[3]; //Voltage at Input, Output1, Output2 respectively
- int PinId[3];
-}SpdtStruct;
-
-typedef struct DpstStructTag
-{
- int id;
- int image;
- BOOL latched; //Whether the swetch is in latch mode or not
- BOOL NO; //Whether the inputs and outputs are disconnected (Open)
- double Volt[4]; // Voltage at Input1, Input2, Output1, Output2 respectively
- int PinId[4];
-}DpstStruct;
-
-typedef struct DpdtStructTag
-{
- int id;
- int image;
- BOOL latched; //Whether the swetch is in latch mode or not
- BOOL NS1; //Whether the inputs and outputs are connected in state 1
- double Volt[6]; // Voltage at Input1, Input2, Output11, Output12, Output21, Output22 respectively
- int PinId[6];
-}DpdtStruct;
-
-#endif
diff --git a/ldmicro/includes/simulate.h b/ldmicro/includes/simulate.h
deleted file mode 100644
index 7b26ba3..0000000
--- a/ldmicro/includes/simulate.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*This file is created with an intention to share simulation functions
-with advanced simulation dialog window*/
-#ifndef _SIMULATE_H
-#define _SIMULATE_H
-
-static void SetSingleBit(char *name, BOOL state);
-static BOOL SingleBitOn(char *name);
-#endif
--
cgit
From 0a7ef8991842872aa1cbc828619fc71a1216f748 Mon Sep 17 00:00:00 2001
From: Rr42
Date: Wed, 6 Jun 2018 14:49:01 +0530
Subject: removed code with bugs
---
ldmicro/includes/ldmicro.h | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
(limited to 'ldmicro/includes')
diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h
index e6edddc..caa154d 100644
--- a/ldmicro/includes/ldmicro.h
+++ b/ldmicro/includes/ldmicro.h
@@ -518,9 +518,9 @@ extern HWID MainWindow;
extern HDC Hdc;
extern PlcProgram Prog;
extern char CurrentSaveFile[MAX_PATH];
-// extern char CurrentCompileFile[MAX_PATH];
+extern char CurrentCompileFile[MAX_PATH];
extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS];
-/*
+
// memory debugging, because I often get careless; ok() will check that the
// heap used for all the program storage is not yet corrupt, and oops() if
// it is
@@ -666,16 +666,6 @@ void ShowContactsDialog(BOOL *negated, char *name);
// coildialog.cpp
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name);
-//advanceddialog.cpp
-void ShowAdvancedDialog(void);
-void MakeAdvancedDialogClass(void);
-void MakeAdvancedWorkspaceClass(void);
-void TranslateState(char *name, BOOL state);
-void MCUPinState(char *name, BOOL state);
-void StartAdvSimulation(void);
-void StopAdvSimulation(void);
-extern BOOL AdvancedWindowOpen;
-
//naminglist.cpp
void MakeSmplDialogClass(void);
@@ -749,9 +739,9 @@ void SimulationResetContact(char* name);
void SetAdcShadow(char *name, SWORD val);
SWORD GetAdcShadow(char *name);
void DestroyUartSimulationWindow(void);
-void ShowUartSimulationWindow(void);*/
+void ShowUartSimulationWindow(void);
extern BOOL InSimulationMode;
-/*extern BOOL SimulateRedrawAfterNextCycle;
+extern BOOL SimulateRedrawAfterNextCycle;
// compilecommon.cpp
void AllocStart(void);
--
cgit