Skip to content

Commit 36daa84

Browse files
committed
e
1 parent 226c545 commit 36daa84

File tree

10 files changed

+276
-116
lines changed

10 files changed

+276
-116
lines changed

source/Main.hx

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -103,57 +103,57 @@ class Main extends Sprite
103103
}
104104
trace("Finished testing forceCast.");
105105

106-
var r:Random<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
107-
trace("Random Test: " + r);
106+
// var r:Random<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
107+
// trace("Random Test: " + r);
108108

109-
trace("Random Test 2: " + new Random<Int>([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
109+
// trace("Random Test 2: " + new Random<Int>([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
110110

111-
var r2:Random<Int> = [for (i in 1...11) i];
112-
trace("Random Test 3: " + r2);
111+
// var r2:Random<Int> = [for (i in 1...11) i];
112+
// trace("Random Test 3: " + r2);
113113

114114

115-
var temp:Temp<Int> = 23932;
115+
// var temp:Temp<Int> = 23932;
116116

117-
trace("Temp Test 2: " + temp);
117+
// trace("Temp Test 2: " + temp);
118118

119-
var temp2:Temp<{value:Int, otherValue:Int}> = {
120-
value: 123,
121-
otherValue: 456
122-
};
119+
// var temp2:Temp<{value:Int, otherValue:Int}> = {
120+
// value: 123,
121+
// otherValue: 456
122+
// };
123123

124-
var nonTemp:{value:Int, otherValue:Int} = {
125-
value: 123,
126-
otherValue: 456
127-
};
124+
// var nonTemp:{value:Int, otherValue:Int} = {
125+
// value: 123,
126+
// otherValue: 456
127+
// };
128128

129-
var temp2Address = cpp.Native.addressOf(game);
130-
trace("Star test 1: " + temp2Address);
131-
var randofdsde:Temp<Int> = 123;
132-
trace("Temp Test 3: " + randofdsde);
129+
// var temp2Address = cpp.Native.addressOf(game);
130+
// trace("Star test 1: " + temp2Address);
131+
// var randofdsde:Temp<Int> = 123;
132+
// trace("Temp Test 3: " + randofdsde);
133133

134134

135135

136-
var eeee:Int = 123;
136+
// var eeee:Int = 123;
137137

138-
var p = cpp.Pointer.addressOf(eeee)[0];
139-
trace("Pointer Test: " + p);
138+
// var p = cpp.Pointer.addressOf(eeee)[0];
139+
// trace("Pointer Test: " + p);
140140

141-
var funnyDouble = new HaxePointer<Dynamic>(game);
142-
trace("Funny Double Test: " + funnyDouble);
143-
trace("Funny Double Test: " + new HaxePointer<Dynamic>(game));
141+
// var funnyDouble = new HaxePointer<Dynamic>(game);
142+
// trace("Funny Double Test: " + funnyDouble);
143+
// trace("Funny Double Test: " + new HaxePointer<Dynamic>(game));
144144

145-
(new Fields(temp2).printFields());
146-
(new Fields(nonTemp).printFields());
145+
// (new Fields(temp2).printFields());
146+
// (new Fields(nonTemp).printFields());
147147

148-
trace("TestAcc: " + new FieldAccTest({}).eeeee);
149-
trace("TestAcc2: " );
150-
var testAcc2 = new FieldAccTest({eeeee: 123}).eeeee = 456;
148+
// trace("TestAcc: " + new FieldAccTest({}).eeeee);
149+
// trace("TestAcc2: " );
150+
// var testAcc2 = new FieldAccTest({eeeee: 123}).eeeee = 456;
151151

152-
var collaped:Collapsed<Int> = [[1], [2], [3], [4], [5]];
152+
// var collaped:Collapsed<Int> = [[1], [2], [3], [4], [5]];
153153

154-
trace("Collaped Test: " + collaped);
154+
// trace("Collaped Test: " + collaped);
155155

156-
var gaming:GlobalPointer<Dynamic> = game;
156+
// var gaming:GlobalPointer<Dynamic> = game;
157157

158158
// gaming.startFullscreen = true;
159159

@@ -263,11 +263,13 @@ class Main extends Sprite
263263

264264
trace("gamedddifsdsf".realSizeOf());
265265

266-
var testArray = new yutautil.CollectionUtils.KeyIndexedArray();
267-
testArray.set("test", 1);
268-
trace(testArray.get("test"));
269-
trace(testArray.get("test2"));
270-
trace(testArray["test"]);
266+
// var testArray = new yutautil.CollectionUtils.KeyIndexedArray();
267+
// testArray.set("test", 1);
268+
// trace(testArray.get("test"));
269+
// trace(testArray.get("test2"));
270+
// trace(testArray["test"]);
271+
272+
trace("PC System Memory: " + backend.util.NativeAPI.getPhysicallyInstalledSystemMemory() + " GB");
271273

272274

273275
// 'You can\'t put variable expressions in COMMENTS, silly!'.NativeComment(true);

source/backend/util/NativeAPI.hx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ class NativeAPI {
101101
#end
102102
}
103103

104+
public static function getPhysicallyInstalledSystemMemory(mb:Bool = false):Float {
105+
#if windows
106+
return mb
107+
? Std.parseFloat(Std.string(Windows.getPhysicallyInstalledSystemMemory(mb)))
108+
: Std.parseFloat(Std.string(Windows.getPhysicallyInstalledSystemMemory(mb)).substr(0, 2) + "." + Std.string(Windows.getPhysicallyInstalledSystemMemory(mb)).substr(2));
109+
#else
110+
return 0; // Not supported on other platforms... yet.
111+
#end
112+
}
113+
104114
/**
105115
* Sets the console colors
106116
*/

source/backend/window/os/Windows.hx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum abstract MessageBoxReturnValue(Int) from Int to Int {
6262
#include "combaseapi.h"
6363
#include <iostream>
6464
#include <Windows.h>
65+
#include <psapi.h>
6566
#include <cstdio>
6667
#include <tchar.h>
6768
#include <dwmapi.h>
@@ -235,7 +236,19 @@ class Windows {
235236
MessageBox(GetActiveWindow(), message, caption, icon | MB_SETFOREGROUND);
236237
')
237238
public static function showMessageBox(caption:String, message:String, icon:MessageBoxIcon = MSG_WARNING) {
239+
}
240+
238241

242+
@:functionCode('
243+
ULONGLONG totalRAM_MB;
244+
GetPhysicallyInstalledSystemMemory(&totalRAM_MB);
245+
246+
double ram = mb ? (double)totalRAM_MB : (double)totalRAM_MB / 1024.0;
247+
ram = round(ram * 100.0) / 100.0;
248+
return ram;
249+
')
250+
public static function getPhysicallyInstalledSystemMemory(mb:Bool):Float {
251+
return 0; // Not supported on other platforms... yet.
239252
}
240253

241254
@:functionCode('

source/states/LoadingState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ class LoadingState extends MusicBeatState
520520
var moddedImages:Array<String> = Paths.crawlDirectory('$curDirct/images', 'png');
521521
var moddedSounds:Array<String> = Paths.crawlDirectory('$curDirct/sounds', 'png');
522522
var moddedMusic:Array<String> = Paths.crawlDirectory('$curDirct/music', 'png');
523-
prepare(moddedImages, moddedSounds, moddedMusic);
523+
// prepare(moddedImages, moddedSounds, moddedMusic);
524524
trace('IMAGE LOADING LIST: $moddedImages\nSOUND LOADING LIST: $moddedSounds\nMUSIC LOADING LIST: $moddedMusic');
525525
}
526526
}

source/states/TitleState.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class TitleState extends MusicBeatState
9999

100100
curWacky = FlxG.random.getObject(getIntroTextShit());
101101

102+
trace(cpp.vm.Gc.trace(FlxSprite));
103+
102104
if(!initialized)
103105
{
104106
if(FlxG.save.data != null && FlxG.save.data.fullscreen)

source/yutautil/RuntimeClass.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ abstract RuntimeClass(RuntimeClassStructure) {
268268
// Haxe does not expose the constructor directly, but we can create a wrapper.
269269
var constructor:Null<haxe.Constraints.Function> = switch (Type.getClassFields(cls).indexOf("new") != -1) {
270270
case true:
271-
// Get new directly, so that the arguments apply to the class constructor.
272-
cls.new;
271+
// Use Reflect to get the constructor function dynamically.
272+
cast Reflect.field(cls, "new");
273273
case false:
274274
null;
275275
};

source/yutautil/TypeUtils.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ typedef ExceptionDetails = {
10911091
pos:Null<haxe.PosInfos>
10921092
};
10931093

1094-
abstract DetailedException(ExceptionDetails) from String from haxe.Exception to haxe.Exception to String {
1094+
abstract DetailedException(ExceptionDetails) {
10951095
public inline function new(value:Dynamic, ?pos:haxe.PosInfos) {
10961096
this = DetailedException.buildDetailsObject(value, pos);
10971097
}
@@ -1147,7 +1147,7 @@ abstract DetailedException(ExceptionDetails) from String from haxe.Exception to
11471147
static function generateErrorCode(message:String, pos:Null<haxe.PosInfos>):String {
11481148
var base = message + (pos != null ? pos.fileName + pos.lineNumber : "");
11491149
var hash = 0;
1150-
for (i in 0...base.length) hash = (hash * 31 + base.charCodeAt(i)) & 0x7FFFFFFF;
1150+
for (i in 0...base.length) hash = (hash * 31 + base.charCodeAt(i)) % 0x7FFFFFFF;
11511151
return "E" + StringTools.hex(hash, 8).toUpperCase();
11521152
}
11531153

source/yutautil/YNum.hx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ class YNumber {
7171

7272
private function carryOverflow() {
7373
// Handle float part carry
74-
for (i in floatPart.length - 1...0) {
74+
var i = floatPart.length - 1;
75+
while (i >= 0) {
7576
if (floatPart[i] >= 10) {
7677
var carry = Math.floor(floatPart[i] / 10);
7778
floatPart[i] %= 10;
@@ -83,21 +84,26 @@ class YNumber {
8384
floatPart[i - 1] += carry;
8485
}
8586
}
87+
i--;
8688
}
8789

8890
// Handle integer part carry
89-
for (i in intPart.length - 1...0) {
91+
i = intPart.length - 1;
92+
while (i >= 0) {
9093
if (intPart[i] >= 10) {
9194
var carry = Math.floor(intPart[i] / 10);
9295
intPart[i] %= 10;
9396

9497
if (i == 0) {
9598
// Add new digit at the beginning
9699
intPart.unshift(carry);
100+
// Break to avoid infinite loop after unshift
101+
break;
97102
} else {
98103
intPart[i - 1] += carry;
99104
}
100105
}
106+
i--;
101107
}
102108
}
103109

0 commit comments

Comments
 (0)