logo
 drop

Main

Community

Submissions

Help

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - BRPXQZME

Pages: 1 ... 26 27 28 29 30 [31] 32 33 34 35 36 ... 63
601
ROM Hacking Discussion / Re: bad coding in roms
« on: November 27, 2012, 06:48:59 am »
My MIPS assembly is a bit rusty, but that's indirect addressing, isn't it? Meaning it would be

v0 <- 0xffff
address r0+0000=000000000 <- v0

I don't know what the N64 has at address 0, but it really doesn't seem like r0 itself.
Close. In MIPS, immediate values for arithmetic are sign-extended 16-bit numbers, so (as posted) the code does

v0 := -1
M[0] := v0

602
General Discussion / Re: Video Time
« on: November 27, 2012, 03:54:49 am »

603
ROM Hacking Discussion / Re: bad coding in roms
« on: November 26, 2012, 11:29:31 pm »
I don’t see anything being dumped into R0 in that code....

604
I know some people name their variables stuff like zxcv at first, then they search and replace the verbose version.

605
Programming / Re: Organized Battle System.
« on: November 26, 2012, 05:44:22 pm »
Nobody is denying it’s a start, but Henke here is just tellin’ it like it is; this code has serious outstanding issues that really aren’t outside your reach to address.

606
Well, you have to keep in mind that one of the things it was born out of was non-OOP languages (in fact, it came from a language with only one data type) and big multi-person projects. Nowadays OOP makes it a lot easier to figure out where to look if you don’t understand what the heck that variable is supposed to be and who was smoking what.

The reasoning Mr. Spolsky gives in that article I linked makes a lot more sense than just prefixing with types. Type checking really should be left to the compiler.

607
ROM Hacking Discussion / Re: bad coding in roms
« on: November 26, 2012, 04:49:38 pm »
e: almost forgot the best part.

...
amg

well, I guess it still takes care of what they wanted it to accomplish, but still

wow

608
As for adding the datatype before the variable name, for some names, it's probably obvious and in some ways can be the convention itself. Some people are also better at naming things than others. I feel that I can come back a year later, read my code, and understand that, yeah, $strTitle is supposed to be a string that holds a title to something.
This sort of “Hungarian notation” for types is more or less pointless in a strongly+statically typed language like C, though I do not deny the efficacy of Apps Hungarian in certain situations. I suspect many coders would have a visceral reaction to a variable name like $strTitle in that that shouldn’t have to be something so important to the variable that it needs to be in the name, but then again those coders don’t PHP.

609
This has been around for like 3 years or so. Deuce did not have nice things to say about it at the time, and... some... of his points were valid, even. The whole “this is my project” thing, well, yeah I’ve got an ego, too, but at least I try to clean up after it, friends ::)

Okay sure, it could be a matter of finding someone who is willing to translate it and doesn’t mind certain technical issues this particular code presents. But it is not a trivial amount of text we’re talking here by any means.

610
Programming / Re: Organized Battle System.
« on: November 22, 2012, 11:49:41 pm »
It doesn’t make any sense at all. Two calls to rand() is like rolling a die twice; plus, rand()%4 will always be greater or equal than 0, and rand()%4 will always be less than or equal to 8 so you might as well omit the conditional ;)

611
Programming / Re: Organized Battle System.
« on: November 22, 2012, 09:49:31 pm »
On these forums, double posting or editing will mark the thread new, but without bumping it.

612
Programming / Re: Organized Battle System.
« on: November 22, 2012, 09:12:45 pm »
srand() seeds the RNG with the single argument. It gives it a starting point for faking random numbers. They’re not actually random, but for most purposes it’s really close enough. On a conceptual level, you give the RNG a “seed” number. For every call to rand(), you do crazy stuff to that seed until it looks like a random number and spit it out; that random number is the new seed. Actual implementation may vary. You probably don’t want to call srand() with the same value every time unless you are testing something, as on the same system, it will always give the same sequence from rand().

time(0) returns time in seconds since midnight 1 January 1970 (as long as the system clock is set accurately). This isn’t good enough a seed for security but for most games it is, since very few people would bother to stack randomness in their favor by setting the system clock. This way, you get a different sequence of random numbers depending on what time the srand() function was called.

613
Programming / Re: Organized Battle System.
« on: November 22, 2012, 08:30:26 pm »
This is how a typical program should use srand():

<start program>
srand(time(0));
<rest of program with rand()s in it; never calls srand again>
<end program>

Every call to rand() will return a random number this way.

614
Programming / Re: Organized Battle System.
« on: November 22, 2012, 08:14:10 pm »
Code: [Select]
[20:13:02] brp@eva:~$ cat test.c
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    srand(150);
    printf("%d ", rand());
    srand(150);
    printf("%d ", rand());
    srand(150);
    printf("%d\n", rand());
    srand(150);
    printf("%d ", rand());
    printf("%d ", rand());
    printf("%d\n", rand());
}
[20:13:09] brp@eva:~$ cc -o test test.c
[20:13:13] brp@eva:~$ ./test
2521050 2521050 2521050
2521050 1569098057 731858839
[20:13:15] brp@eva:~$
Please. Only seed once!

615
But the pseudocode doesn’t say that, which I think is a good demonstration of why it is not necessarily the best way to write a similar loop ;)

616
I pasted the exact snippet I was referring to. I don’t know PHP, but if you did this in C, the loop would never end no matter how much you messed with the string, on virtue of never changing the thing you check.

Then again, if you did this in C you would just check the first character being equal to 0.

617
Code: [Select]

$strText = "Hello World!";
$intTextLength = strlen($strText);

...

while ($intTextLength != 0)
{
    //do something that would make $strText's length shrink until 0
}
This would be an infinite loop, wouldn’t it? Operations in a condition check are A-OK as long as they make paradigmatic sense and aren’t terribly expensive.

I’m also okay with one-letter variables being used for obvious and transient purposes. Saves typing time, confuses nobody.

618
ROM Hacking Discussion / Re: bad coding in roms
« on: November 16, 2012, 07:18:26 pm »
Not all compilers optimize (though this is getting much rarer than it was 20 years ago). And not all compilers that optimize do it well! :laugh:

Cruft left over from debug code can also leave puzzling artifacts, particularly if the developer was not that assembly-minded (or just didn’t care... I mean, sometimes it’s really just a few instructions on a processor that does millions a second and doesn’t mess up caching or anything).

In that case for PSG2, it’s possible that the return value wasn’t the point of that particular call to the function. It isn’t unusual to call a function that returns something when all you wanted was the function’s effect. But again, it could just be partially-dummied debug code. Only way to tell is to look and see what it does.

619
Programming / Re: Organized Battle System.
« on: November 16, 2012, 07:03:08 pm »
Time is a popular choice but there are other seed sources you can consider, because sometimes you don’t want the player to have any (reasonably easy) influence over the seed.

I don’t know what you mean by “reestablish”, but srand() just seeds the generator, and rand() keeps getting new numbers from the generator. Pretty much just set it and forget it.

620
ROM Hacking Discussion / Re: Final Fantasy IV NES Easy Type project.
« on: November 14, 2012, 03:52:25 am »
He did mention it in the title ;P

SE doesn’t really C&D fan projects left and right. I’m actually rather appalled that people in this community seem so eager to mention it. It most certainly IS a “speak of the devil” kind of thing.

Pages: 1 ... 26 27 28 29 30 [31] 32 33 34 35 36 ... 63