From db25c9f050a690bbec032ef3f93e244c7ec2dbee Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期五, 26 五月 2023 09:30:59 +0800
Subject: [PATCH] PLCFunction fix2

---
 Src/PLCfunctions.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Src/PLCfunctions.c b/Src/PLCfunctions.c
index f6acac0..3e699a0 100644
--- a/Src/PLCfunctions.c
+++ b/Src/PLCfunctions.c
@@ -342,7 +342,7 @@
 int InitPLC()
 {
 	PLCMem.nScanCount=0;
-	for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
+	for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
 	for (int i=0;i<16;i++)	{
 		KMem.WR[i]=0;
 	}
@@ -355,7 +355,7 @@
 int StartPLC()
 {
 	PLCMem.nScanCount = 0;
-	for (int i=0;i<1024;i++){PLCMem.ProgTrace[i]=0;}
+	for (int i=0;i<256;i++){PLCMem.ProgTrace[i]=0;}
 	for (int i=0;i<16;i++)	{
 		KMem.WR[i]=0;
 	}
@@ -369,6 +369,8 @@
 int StopPLC()
 {
 	PLCMem.bPLCRunning=0;
+	for (int i=0;i<KLDataWXCount;i++) KMem.WY[i]=0;
+	for (int i=0;i<KLDataWLCount;i++) KMem.WLY[i]=0;
 	return 0;
 }
 
@@ -765,9 +767,11 @@
 		default:
 			break;
 		}
-
-		lastScanInputVal =  PLCMem.ProgTrace[CurPos]; //GetBitValue(KMem.WDFs);
-		PLCMem.ProgTrace[CurPos] = KMem.CurVAL;
+		lastScanInputVal =  GetBitValue( PLCMem.ProgTrace[CurPos>>4],CurPos&0xf); //GetBitValue(KMem.WDFs);
+		SetBitValue( &PLCMem.ProgTrace[CurPos>>4],CurPos&0xf, KMem.CurVAL);
+		
+//		lastScanInputVal =  PLCMem.ProgTrace[CurPos]; //GetBitValue(KMem.WDFs);
+//		PLCMem.ProgTrace[CurPos] = KMem.CurVAL;
 		CurPos += nNextPos;
 	}
 	PLCMem.nScanCount++;

--
Gitblit v1.9.1