Re: Advent of Code 2018 megathread
Day 9 https://adventofcode.com/2018/day/9 was so much fun to solve ! I also really enjoyed day 3 https://adventofcode.com/2018/day/3 and day 6 https://adventofcode.com/2018/day/6 Do you guys have a favorite so far?
Re: Extract sprite data from old DOS game resource file?
Even if you get the sprites they might be all jumbled up like this: [http://www.gamasutra.com/db_area/images/news/253377/fig03.png](http://www.gamasutra.com/db_area/images/news/253377/fig03.png) Older games tent to reuse/recolor spires. Even when you get spires it might be really hard to put together again.
OOP macro - problems with import
Hello, i really like OOP macro from [https://github.com/jyapayne/nim-extensions](https://github.com/jyapayne/nim-extensions). There are so far two problems * Cant figure out how should i define class as exported however this is kinda solvable by changing oop.nim code to export all * Second is worse, probably due to some namespace magic importing class from other module doesnt work Example: #test_class.nim import oop class MyClass: var value: int method init*(value: int){.base.}= self.value = value method print{.base.}= echo self.value Run #main.nim from test_class import MyClass var m : MyClass; m = new MyClass(value:111) m.print() Run Compiler reports **main.nim(5, 16) Error: the field 'value' is not accessible.** What am i missing? Thanks alot.
Re: Nim vs D
FWIW I had a look at D multiple times and learned to fervently dislike it. My personal summary is that D is but yet another better C/C++ attempt with funny gadgets added and an utter lack of consistence in concept and design. To even put Nim and D next to each other is ridiculous.
Re: Extract sprite data from old DOS game resource file?
> What's also possible, is that multiple pixels are stored in one byte. I don't > know the exact specs, though it might be possible that if a sprite can only > have four colors, each pixel is a palette color index stored in two bits > therefore a byte holds four pixels and the palette selector for each sprite > is stored somewhere else. Yeah, I thought so. I was hoping there were some standard thing one could try to see if data was packed in some slightly standard way. Oh well. > I would recommend just taking a bunch of screen shots and cutting out the > sprites in image editor. In the end, if I don't find anything else, I'll probably go this route. Thanks guys.
Re: Nim vs D
" **I believe we are the language with the best static introspection in the world** " — [AA](https://en.wikipedia.org/wiki/Andrei_Alexandrescu) @ [Dconf 2018 in Munich](http://dconf.org/2018/index.html), three minutes into "[Ask Us Anything](https://www.youtube.com/watch?v=3XOfUcv6sjk=5=PLIldXzSkPUXXtAvzS0RDCi3Cm0t5h4B-a=175s)"... _OH SNAP!_ Metaprogrammingnerdkrieg... ;-)
How does --gc:stack work?
I'm curious as to know how exactly does --gc:stack work? I looked over the documentation but couldn't find much details. Is it similar to C++ constructors/destructors? Does GC still run in the background?
Re: Cast string to tuple?
Note that casting to a ref is dangerous, as ref's interfere with the Garbage-Collector. I guess when you really need a cast, you may want to cast to ptr instead of ref -- ptr is Nim's untraced pointer, similar to C's pointers.
Re: Cast string to tuple?
I understand my mistake. t = cast[ref Raw_Frame](addr c) Run should be t = cast[ref Raw_Frame](addr c[0]) Run
Cast string to tuple?
Hi, I just discovered Nim and already doing little toy projects with it to get used to it. Love it. I am playing with networking. But reading from raw sockets, I need to cast the string to a tuple which represent the headers fields. That would enable me to select any field of the ethernet/ip/udp frame more easily. I have: type Raw_Frame = tuple mac_dest: array[6,char] mac_src: array[6,char] var t : ref Raw_Frame var data_coming_from_socket : string = "123456789123" #Imagine that the string comes from recv t = cast[ref Raw_Frame](addr c) echo("hi ", t.mac_dest,t.mac_src) Run nim I want t.mac_dest = ['1','2','3','4','5','6'] and t.mac_src = ['7','8','9','1','2','3'] as an array of char Then, different types will follow but I wanted my question to remain concise. Ultimately, I would cast the string to a tuple (I don't want objects, too much overhead) In C, you just cast your array of uint8 to a structure pointer and call it a day. Sure Nim does that too. I understood that string is actually a pointer but not too sure. If you have a better idea as to how to do it the Nim way, please help! Thanks,
Re: Extract sprite data from old DOS game resource file?
I'm not very familiar with MS-DOS games, but I have a bit of knowledge about NES games. It might be possible that the data you're looking for is compressed. Something like RLE with small modifications wasn't uncommon on the NES, especially for storing level data. What's also possible, is that multiple pixels are stored in one byte. I don't know the exact specs, though it might be possible that if a sprite can only have four colors, each pixel is a palette color index stored in two bits therefore a byte holds four pixels and the palette selector for each sprite is stored somewhere else. The last option would be to run the game in an emulator with a disassembler attached and just search for writes to the video memory, which is probably the least pleasant way.
Re: Advent of Code 2018 megathread
Thank you, that means a lot :)
Re: Extract sprite data from old DOS game resource file?
Getting sprites out old dos game can be hard. You will not find standard images formats like png, jpg or dds. It can be stored in extremely convoluted way. One game I ripped the sprites from (Panzer General) used a strange pen method where it stored all images as move pen left, right, draw color X... like G-Code for CNC machine. I would recommend just taking a bunch of screen shots and cutting out the sprites in image editor. You can also just use whole map as a single image like: [https://faqs.neoseeker.com/Games/PC/zeliard_milagro.png](https://faqs.neoseeker.com/Games/PC/zeliard_milagro.png) No need to mess with spires/level data.
Extract sprite data from old DOS game resource file?
Hi guys, I have a couple resource files from an old MS-DOS game called `Zeliard`. The files have a `.sar` extension, if that is of any help. I would like to find out how the sprite information is stored in these files, but I have no knowledge of how it is `packed`. Some data for the game text is stored in plain ascii and there are some references to other files inside it in plain ascii, like KING.GRP, ... The whole file is about 330kB, so I tried storing each byte as a single color value (0..255) and block storing the data in 8x8, 16x16 and 32x32 chunks and then storing the chunks in a single image file, to see if anything would visually stand out as being a sprite, but no luck (well at least I can't see anything useful). Any ideas on where to start? Thanks, Matic
Re: How do you pass code blocks to when compiles?
> My intention was to check to see if a proc hello exists in the current scope > that doesn't conflict with the proc I'm about to create. A simple test call to the proc would do (`when compiles(hello()): ...`). But then, the compiler would issue an error anyway if there's a conflict with an existing proc, so why bother checking that in custom compile-time code?
Re: Advent of Code 2018 megathread
> I'm still learning Nim (...) Not a programmer by trade and it might show. I really like your solutions so far! And if you didn't explicitly tell, I wouldn't ever have guessed that you're just learning Nim nor that you're not a programmer.
Re: Advent of Code 2018 megathread
Here is my repository: [https://github.com/filipux/adventofcode2018](https://github.com/filipux/adventofcode2018)