mirror of
https://github.com/SourMesen/VisualNes.git
synced 2024-06-01 02:48:05 -04:00
Fixed overflow bug for area calculations (fix by bgourlie)
This commit is contained in:
parent
714c06e821
commit
6a429a413b
|
@ -158,8 +158,8 @@ bool getNodeValue() {
|
|||
return true;
|
||||
}
|
||||
|
||||
int hi_area = 0;
|
||||
int lo_area = 0;
|
||||
int64_t hi_area = 0;
|
||||
int64_t lo_area = 0;
|
||||
for(uint16_t nn : group) {
|
||||
node &n = nodes[nn];
|
||||
if(n.pullup) return true;
|
||||
|
|
|
@ -27,7 +27,7 @@ struct node
|
|||
bool pulldown = false;
|
||||
bool floating = true;
|
||||
|
||||
int area = 0;
|
||||
int64_t area = 0;
|
||||
uint16_t num = EMPTYNODE;
|
||||
vector<uint16_t> gates;
|
||||
vector<vector<uint16_t>> segs;
|
||||
|
|
|
@ -24,6 +24,7 @@ THE SOFTWARE.
|
|||
#include "datastructures.h"
|
||||
#include "wires.h"
|
||||
#include "datadefs.h"
|
||||
#include <iostream>
|
||||
|
||||
vector<node> nodes;
|
||||
vector<transistor> transistors;
|
||||
|
@ -38,7 +39,7 @@ void setupNodes()
|
|||
for(size_t i = 0, len = segdefs.size(); i < len; i++) {
|
||||
maxID = std::max(maxID, segdefs[i][0]);
|
||||
}
|
||||
nodes.insert(nodes.end(), maxID + 1, node());
|
||||
nodes.insert(nodes.end(), (size_t)maxID + 1, node());
|
||||
|
||||
for(size_t i = 0, len = segdefs.size(); i < len; i++) {
|
||||
std::vector<int> &seg = segdefs[i];
|
||||
|
@ -54,9 +55,9 @@ void setupNodes()
|
|||
if(w == ngnd) continue;
|
||||
if(w == npwr) continue;
|
||||
|
||||
int area = seg[seg.size() - 2] * seg[4] - seg[3] * seg[seg.size() - 1];
|
||||
int64_t area = (int64_t)seg[seg.size() - 2] * (int64_t)seg[4] - (int64_t)seg[3] * (int64_t)seg[seg.size() - 1];
|
||||
for(size_t j = 3; j + 4 < seg.size(); j += 2) {
|
||||
area += seg[j] * seg[j + 3] - seg[j + 2] * seg[j - 1];
|
||||
area += (int64_t)seg[j] * (int64_t)seg[j + 3] - (int64_t)seg[j + 2] * (int64_t)seg[j - 1];
|
||||
}
|
||||
if(area < 0) {
|
||||
area = -area;
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace GUI
|
|||
public bool state = false;
|
||||
public List<transistor> gates = new List<transistor>();
|
||||
public List<transistor> c1c2s = new List<transistor>();
|
||||
public int area = 0;
|
||||
public Int64 area = 0;
|
||||
public bool floating = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue