Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 20:31:04 UTC, Johan wrote: (snip) Awesome, I just might try to get LDC working with this... On a different note, I'd really like a critique on a decision I made. Creating the bindings for libctru and citro3d was really tedious, partly because I made the decision to change every named enum from stuff like... enum GPU_TEXTURE_WRAP_PARAM { GPU_CLAMP_TO_EDGE = 0x0, ///< Clamps to edge. GPU_CLAMP_TO_BORDER = 0x1, ///< Clamps to border. GPU_REPEAT = 0x2, ///< Repeats texture. GPU_MIRRORED_REPEAT = 0x3, ///< Repeats with mirrored texture. } ...to... enum GPUTextureWrapParam { clamp_to_edge = 0x0, ///< Clamps to edge. clamp_to_border = 0x1, ///< Clamps to border. repeat = 0x2, ///< Repeats texture. mirrored_repeat = 0x3 ///< Repeats with mirrored texture. } ...in order to fit the D naming style, since the semantics for the enum was changing anyway. But of course, every struct must keep its old name... Is this alright? Should I add aliases for every struct for a better naming style, or maybe go back on my decision before, or...?
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 18:25:42 UTC, TheGag96 wrote: On Sunday, 20 October 2019 at 09:36:17 UTC, Johan Engelen wrote: Did you try with LDC? Just a wild guess but perhaps this triple will work: `-mtriple=armv6k-unknown-eabi`. -Johan I haven't yet, but I've been told also by someone else to try! It would certainly be nice to have a true -betterC going with this. Does LDC have equivalent flags for what devkitARM wants passed into GCC, like: -march=armv6k -mtriple=armv6k-unknown-eabi I am not sure about the "eabi". -mtune=mpcore This is not strictly needed. (It's an optimization parameter) Maybe "-mcpu=mpcore" sets the optimizer to optimize for that cpu. -mfloat-abi=hard -float-abi=hard -mtp=soft Don't know if we expose this option, but LDC by default seem to do the same as GCC's -mtp=soft: https://d.godbolt.org/z/bmcRdI -mword-relocations Don't know! -fomit-frame-pointer This is more of a non-debug option, so not strictly needed. LDC's option is -frame-pointer=none (for newer LDC), or --disable-fp-elim=false (older and newer LDC). -ffunction-sections -function-sections LDC is a cross compiler by nature, but you'll have to build the runtime libraries yourself. But LDC contains an easy tool for just that! Read: https://wiki.dlang.org/Building_LDC_runtime_libraries cheers, Johan
Re: D code running on the Nintendo 3DS
On Sun, 20 Oct 2019 at 20:40, TheGag96 via Digitalmars-d-announce wrote: > > Darn... Are there any plans at some point in the future to add a > real -betterC sort of flag? It would be really really nice to be > able to compile something like... > > import std.bitmanip : bitfields; > > struct Stuff { >mixin(bitfields!( > uint, "x",2, > int, "y",3, > uint, "z",2, > bool, "flag", 1)); > } > > extern(C) void main() { >Stuff x; > } > > ...just as in DMD or LDC. Saying that, if you can distil that into a test case with no dependencies (no imports) and gdc emits something that neither ldc or dmd does, then I should probably be notified about that in a bug report, as a newer version of the D language frontend won't necessarily fix it. -- Iain
Re: D code running on the Nintendo 3DS
On Sun, 20 Oct 2019 at 20:40, TheGag96 via Digitalmars-d-announce wrote: > > On Sunday, 20 October 2019 at 15:27:35 UTC, Iain Buclaw wrote: > > Great stuff! Though I don't think you'll find much improvement > > in gdc 10 regarding switching off D features. Backported > > patches to make gdc on parity with dmd as of April 2019 was > > done prior to the gdc 9 release. I'm not aware of much more > > being done regarding that other than some extern(C) library > > functions being converted into templates, and the C main > > function being moved to a common location in D runtime (C main > > is not "compiled into" gdc unlike previous versions of dmd). > > Darn... Are there any plans at some point in the future to add a > real -betterC sort of flag? It would be really really nice to be > able to compile something like... > > import std.bitmanip : bitfields; > > struct Stuff { >mixin(bitfields!( > uint, "x",2, > int, "y",3, > uint, "z",2, > bool, "flag", 1)); > } > > extern(C) void main() { >Stuff x; > } > > ...just as in DMD or LDC. I called the option switch -fno-druntime, because -betterC was at the time of invention (and still is) a terrible name for a switch. Originally, for a long time, it just meant -fno-mduleinfo, but then -fno-exceptions and -fno-rtti got added which warranted giving it a name that turned off all three (well, four including D asserts, that is not exposed as an option as far as I recall). If the above works for you in the latest dmd, that's probably because the library has improved, not the compiler. (You need to write code in a way that doesn't depend on D runtime, not just expect the compiler to do everything for you. :-) -- Iain
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 17:40:04 UTC, Meta wrote: Awesome work. I used to hack around on my original NDS and thought about maybe trying to get D working on it, but didn't have sufficient time or motivation. I'll definitely play around with this. Last year I was able to get some C very simple code running on the DS, hacked into Pokemon Platinum... I imagine it could be done with -betterC, I guess! Following this tutorial might do a good chunk of the work to setting it up. You'd just need to copy similar stuff I did in 3ds_rules and my (horrific) Makefile in nds_rules. You could get by converting an example DS hello world and declaring any functions/structs needed in your main file as a start.
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 15:27:35 UTC, Iain Buclaw wrote: Great stuff! Though I don't think you'll find much improvement in gdc 10 regarding switching off D features. Backported patches to make gdc on parity with dmd as of April 2019 was done prior to the gdc 9 release. I'm not aware of much more being done regarding that other than some extern(C) library functions being converted into templates, and the C main function being moved to a common location in D runtime (C main is not "compiled into" gdc unlike previous versions of dmd). Darn... Are there any plans at some point in the future to add a real -betterC sort of flag? It would be really really nice to be able to compile something like... import std.bitmanip : bitfields; struct Stuff { mixin(bitfields!( uint, "x",2, int, "y",3, uint, "z",2, bool, "flag", 1)); } extern(C) void main() { Stuff x; } ...just as in DMD or LDC.
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 09:36:17 UTC, Johan Engelen wrote: Did you try with LDC? Just a wild guess but perhaps this triple will work: `-mtriple=armv6k-unknown-eabi`. -Johan I haven't yet, but I've been told also by someone else to try! It would certainly be nice to have a true -betterC going with this. Does LDC have equivalent flags for what devkitARM wants passed into GCC, like: -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -mword-relocations -fomit-frame-pointer -ffunction-sections ?
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 06:06:48 UTC, TheGag96 wrote: Hi, all. I wanted to get into the world of 3DS homebrew, but I really didn't feel like coding in C or C++. So, through an effort of sheer will, I somehow got a hello world example written in D up and running, along with bindings for most of libctru and citro3d. https://github.com/TheGag96/3ds-hello-dlang Included are instructions on how to set this up (although it's pretty hacky). I imagine one could easily start writing Switch homebrew in D by following most of these steps as well. Once GCC 10 comes out with an updated GDC, it might become a pretty attractive alternative to C/++ for such projects if some work is put into bindings and stuff. Hope someone finds this interesting! Awesome work. I used to hack around on my original NDS and thought about maybe trying to get D working on it, but didn't have sufficient time or motivation. I'll definitely play around with this.
Re: D at 20: Hits and Misses, and what I learned along the way Oct 19
On Friday, 18 October 2019 at 01:37:01 UTC, Walter Bright wrote: Slides: https://digitalmars.com/articles/hits.pdf Tangent time. In regards to floating point: Unable to convince people that more precision is worthwhile I'm actually waiting for quad floats to have hardware support. Registers are already wide enough, just nothing internally or in terms of instruction set for them yet. But yeah. The reality is that the hardware I operate on uses 32-bit floats almost exclusively on the CPU (the sole exception I can think of is the main simulation timer, you don't want that as a 32-bit float). GPUs and shaders use 16-bit half floats extensively these days. But 64-bit is a rarity because operations take 40% more execution time on average with my own tests and we can forsake the accuracy for execution time. This might change in a 4K TV world. Haven't really done too much with them yet (despite Quantum Break supporting 4K, but I didn't really notice anything glitchy that I could associate with floating point imprecision). Still. 64- and 128-bit floats are quite useful for offline calculations. Make your data as accurate as possible, then let the runtime code use the fastest execution path it can.
Re: D code running on the Nintendo 3DS
On Sun, 20 Oct 2019 at 17:27, Iain Buclaw wrote: > > On Sun, 20 Oct 2019 at 08:10, TheGag96 via Digitalmars-d-announce > wrote: > > > > Hi, all. I wanted to get into the world of 3DS homebrew, but I > > really didn't feel like coding in C or C++. So, through an effort > > of sheer will, I somehow got a hello world example written in D > > up and running, along with bindings for most of libctru and > > citro3d. > > > > https://github.com/TheGag96/3ds-hello-dlang > > > > Included are instructions on how to set this up (although it's > > pretty hacky). I imagine one could easily start writing Switch > > homebrew in D by following most of these steps as well. Once GCC > > 10 comes out with an updated GDC, it might become a pretty > > attractive alternative to C/++ for such projects if some work is > > put into bindings and stuff. > > > > Hope someone finds this interesting! > > Great stuff! Though I don't think you'll find much improvement in gdc > 10 regarding switching off D features. Backported patches to make gdc > on parity with dmd as of April 2019 was done prior to the gdc 9 > release. I'm not aware of much more being done regarding that other > than some extern(C) library functions being converted into templates, > and the C main function being moved to a common location in D runtime > (C main is not "compiled into" gdc unlike previous versions of dmd). > For citation on betterC, this is the dmd-cxx PR: https://github.com/dlang/dmd/pull/9678 And the commit done to gcc trunk: https://github.com/gcc-mirror/gcc/commit/7ad41fff7142a495d030e55aa93ae4959b804494 -- Iain
Re: D code running on the Nintendo 3DS
On Sun, 20 Oct 2019 at 08:10, TheGag96 via Digitalmars-d-announce wrote: > > Hi, all. I wanted to get into the world of 3DS homebrew, but I > really didn't feel like coding in C or C++. So, through an effort > of sheer will, I somehow got a hello world example written in D > up and running, along with bindings for most of libctru and > citro3d. > > https://github.com/TheGag96/3ds-hello-dlang > > Included are instructions on how to set this up (although it's > pretty hacky). I imagine one could easily start writing Switch > homebrew in D by following most of these steps as well. Once GCC > 10 comes out with an updated GDC, it might become a pretty > attractive alternative to C/++ for such projects if some work is > put into bindings and stuff. > > Hope someone finds this interesting! Great stuff! Though I don't think you'll find much improvement in gdc 10 regarding switching off D features. Backported patches to make gdc on parity with dmd as of April 2019 was done prior to the gdc 9 release. I'm not aware of much more being done regarding that other than some extern(C) library functions being converted into templates, and the C main function being moved to a common location in D runtime (C main is not "compiled into" gdc unlike previous versions of dmd). -- Iain
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 06:06:48 UTC, TheGag96 wrote: Hi, all. I wanted to get into the world of 3DS homebrew, but I really didn't feel like coding in C or C++. So, through an effort of sheer will, I somehow got a hello world example written in D up and running, along with bindings for most of libctru and citro3d. https://github.com/TheGag96/3ds-hello-dlang Included are instructions on how to set this up (although it's pretty hacky). I imagine one could easily start writing Switch homebrew in D by following most of these steps as well. Once GCC 10 comes out with an updated GDC, it might become a pretty attractive alternative to C/++ for such projects if some work is put into bindings and stuff. Hope someone finds this interesting! I'm really gonna give it a try. Really nice, nice work.
DIP 1021--Argument Ownership and Function Calls--Formal Assessment
DIP 1021, "Argument Ownership and Function Calls", has been formally accepted with minor revision. It was updated to make clear that the proposal is one piece of a bigger plan. https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1021.md
Re: D code running on the Nintendo 3DS
On Sunday, 20 October 2019 at 06:06:48 UTC, TheGag96 wrote: Hi, all. I wanted to get into the world of 3DS homebrew, but I really didn't feel like coding in C or C++. So, through an effort of sheer will, I somehow got a hello world example written in D up and running, along with bindings for most of libctru and citro3d. https://github.com/TheGag96/3ds-hello-dlang Included are instructions on how to set this up (although it's pretty hacky). I imagine one could easily start writing Switch homebrew in D by following most of these steps as well. Once GCC 10 comes out with an updated GDC, it might become a pretty attractive alternative to C/++ for such projects if some work is put into bindings and stuff. Hope someone finds this interesting! Definitely :-) Did you try with LDC? Just a wild guess but perhaps this triple will work: `-mtriple=armv6k-unknown-eabi`. -Johan
D code running on the Nintendo 3DS
Hi, all. I wanted to get into the world of 3DS homebrew, but I really didn't feel like coding in C or C++. So, through an effort of sheer will, I somehow got a hello world example written in D up and running, along with bindings for most of libctru and citro3d. https://github.com/TheGag96/3ds-hello-dlang Included are instructions on how to set this up (although it's pretty hacky). I imagine one could easily start writing Switch homebrew in D by following most of these steps as well. Once GCC 10 comes out with an updated GDC, it might become a pretty attractive alternative to C/++ for such projects if some work is put into bindings and stuff. Hope someone finds this interesting!