Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
Acmlm's Board - I2 Archive - - Posts by Dish
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
User Post
Dish

Spiny
Level: 38

Posts: 221/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-01-05 10:49 PM, in AHH Shit! Link
Originally posted by Sonicandtails
Meh. My stepdads a cracker and he doesent care.


BWAHAHHAHAHHAHAHHHAHHA
hhahahhahahhahha


hahahhaha

oh man.. I SOOooooo read that the wrong way at first XD
Dish

Spiny
Level: 38

Posts: 222/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-04-05 11:12 PM, in Scrollbar Colors Link
I second that motion. Having extra scrollbars is rediculous... they just make the page harder to navigate and your post harder to read. I don't even bother reading posts when I have to move from the main page scrollbar to the posters "special" scrollbar.. .I'll just skip their post (or read what's visible and skip the rest)


A good layout should fit the post... the post should NOT have to be comprimised to fit the layout. The layout works for the post, not the other way around. Fixed layouts are bad. Scrollbar layouts are bad.
Dish

Spiny
Level: 38

Posts: 223/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-05-05 11:43 PM, in Who wants to make an NES emu with me? Link
Well I got it somewhat ready:

Source
Binary

The Binary is a demo exe which has a very shoddy UI slapped together for the purpose of testing the emu. There's still some bugs I haven't fully worked out (DQ4 doesn't like to run), and my timing isn't quite perfect (Rad Racer messes up sometimes), so I'll have to touch up / rewrite the PPU. But for the most part, it's good... it just needs a little more work. I figured it's better to get something out here so that anyone interested can actually work with something that is test-able.

Be sure to read the readme(s) if you download. Lemme know if you're still interested / may be interested in the future ^^

HH (or anyone else): if you need this DLL-ifiied, I can do that for you... although I'm not sure if the function pointer thing I have going for the joypad input is very VB-friendly. I can do an alternate method if you need one.

Feedback welcome/appreciated.
Dish

Spiny
Level: 38

Posts: 224/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-06-05 01:31 PM, in Thinking of getting serious with C. Link
I use Visual Studio for pretty much everything. But MingW is a good compiler, gcc is good too.

As for IDE... VS is good. There's an addon called Visual Assist which is great. But if you want something more lightweight (and free), TextPad might work.

VS has a resource builder... and a good one at that. I don't know of any alternatives =/ although I'm sure there are some.



Also, any references to string-related code that might be useful is greatly appreciated, as I always seem to have trouble with string manipulation


Strings are nothing but arrays. When you can think of a string as being synonymous with being an array... you can understand strings. Only difference is arrays tend to be fixed length (or have their length specified in a seperate var), wheras the end of a string is signaled with a null terminator.

There are several string functions which aid in string manipulation:

strcpy --- copy the contents of one string to another
strcat --- append one string to the end of another
strcmp --- compare two strings
strcmpi --- ditto (case insensitive)
strlen --- finds the length of a string
sprintf -- string formatting!

There's also search functions too, but I dont know them offhand.


How does the whole */& thing work? Like *foo = address of foo, &foo = copy of foo's contents, or something like that, isn't it?


You have it backwards.

'&' is the Address-of operator... it gives you the address of (pointer to) the following var.
'*' is the Indirection operator... it gives you what the following pointer is pointing to. '*' is also used when declaring pointers:

int* foo; // makes an int pointer
int var; // makes an int
foo = &var; // set foo to point to var
*foo = 5; // sets what foo is pointing to (in this case: var) to 5 (this is like saying "var = 5;")

Another really cool concept with pointers is that an array without its brakets gives you a pointer... and brakets double as an indirection operator. For example:

Saying *foo is exactly the same as saying foo[0]. foo[1] is the same as *(foo + 1). Etc.

Since arrays without brakets are pointers, you don't need to use & when you want to get a pointer to an array:

int* foo;
int ar[5];
foo = ar; // foo will point to ar
foo[3] = 0; //same as saying ar[3] = 0


Kudos on making the switch! There's really no reason at all to use VB ever... as you'll see when you get more comfortable with C. ;D


(edited by Disch on 01-06-05 04:32 AM)
(edited by Disch on 01-06-05 04:38 AM)
Dish

Spiny
Level: 38

Posts: 225/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-06-05 08:52 PM, in Thinking of getting serious with C. Link
Originally posted by HyperHacker
Woah, there it is. Neat! Now how do I actually use these resources?


In VS, you #include the resource header file in any file that needs access to one or more resources... then use the resource ID's as needed. The .rc file also needs to be included in the build of the project.

I'd imagine it's the same/similar for other compilers, but I really couldn't say. I completely lack experience when it comes to anything but VS

Many WINAPI functions take a resource ID in the form of a string.. but resources get IDs which are ints, which can make it kind of weird to use. For this, there's a MAKEINTRESOURCE macro which converts a resource ID to a resource string for these functions.

For example... the DialogBox() function (which pops up a modal dialog) takes the resource string as the 2nd parameter. If your dialog id is, say, IDD_MAINDIALOG, it would look something like this:

DialogBox( hInstance, MAKEINTRESOURCE( IDD_MAINDIALOG ), hParentWnd, MyDialogProcedure );


So, just to clarify... int* foo just makes foo a pointer, meaning you can't actually store a value in it, just point it to one? (This has always been one of the bigger problems I had with C. If I can get it all memorized, I imagine things will go a lot easier. )


Yes. You could technically typecast the pointer to treat it as a normal int or whatever... but I'm just getting technical. Basically, you're right... a pointer does not hold a var, it just points to a var (or the start of an array of vars).

And yeah... pointers are hard to get used to, but once you understand them they're soooooooooo great.


@ Euclid: you're giving the right idea... but you're technically inaccurate, so I'm going to point out corrections (don't want to give HH misleading pointer info)

Originally posted by Euclid

int* foo;

foo points to NULL


foo will NOT point to NULL until you tell it to:

int* foo = NULL; (or) int* foo = 0;

uninitialized pointers are just like uninitialized vars. Their contents are undefined and they'll be filled with garbage RAM... effectively making foo point to random memory when unset.



char blah[10]; //array of char
int* foo = &blah; // make foo point to address of blah in memory.



No, blah is an array, so you don't need the '&' operator in this case. Remeber that an array without its brakets already is a pointer.

char* foo = blah; // will set foo to point to blah.. no '&' needed.
or:
char* foo = &blah[0]; // this would work too... but your example wouldn't

'&blah' will try to get a pointer to the pointer, which will probably make the compiler yell at you.

Also note your different types... int is typically 4-byte... char is 1-byte. When working with pointers you typically want to point to a var of whatever type yout pointer is. When changing types you typically need to / should typecast:

char blah[10];
int* foo = blah;

this may generate compiler errors since blah is char and foo is an int pointer. To remedy this in my above exmples I changed foo to a char pointer. However if you want blah to be a char array and still want foo to be an int array... typecasting would be recommended (or even necessary depending on your compiler):

char blah[10];
int* foo = (int*)blah;

that will work without problems.



foo++;

foo will now point to blah[1];



If foo is a char pointer. Yes. If foo was an int pointer, it would actually point to blah[4] (due to ints being 4 times the size of chars). When you add to a pointer, it adds by the element size... not by bytes.

char blah[10];
int* foo = (int*)blah;
char* bar = blah;

-- at this point, both foo and bar point to blah

foo += 1;
bar += 4;

-- at this point, both foo and bar point to blah[4]. (foo == bar) will come up true
Dish

Spiny
Level: 38

Posts: 226/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-08-05 12:38 PM, in FCEUXD question Link
The '~' key.

I really wish you could reassign it you a joypad button. Fastforward is almost useless unless you can reach it from your playing hand(s). '~' is in the middle of nowhere... even when you're using the keyboard
Dish

Spiny
Level: 38

Posts: 227/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-10-05 02:47 AM, in Thinking of getting serious with C. Link
Originally posted by HyperHacker
Now if only the window would actually close. (Of course given that I didn't provide any message handler, I'm surprised it works at all. I was just expecting it to compile and crash right away, at least that would mean I did it right.)


Yeah you'll need a message handler =P.

Typcially, when the dialog is to be closed, a WM_COMMAND message is send to the message handler, with BN_CLICKED as the high word of the wparam, and IDCANCEL as the low word (this will catch not only the escape button being pushed, but the 'X' in the corner, and also a press of a Cancel button if you have one on your dialog). To actually close the dialog, you need to call EndDialog(), which takes 2 params... 1st being the HWND of the dialog to close, and the second being its exit value (this is what DialogBox() will return with)

so something like:


INT_PTR CALLBACK MyCallbackProc( HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
 switch(msg)
 {
 case WM_COMMAND:
  if( (LOWORD(wparam) == IDCANCEL) && (HIWORD(wparam) == BN_CLICKED) )
  {
   EndDialog( wnd, 0 );
   return 1;
  }
  break;
 }
 return 0;
}



Now, the question is how do I make it send messages for controls? Like I have a button on the dialog, but the message handler isn't getting anything from it.


Most controls signal the main window through the WM_COMMAND message (like my example above). With WM_COMMAND, the high word of the wparam is the action being performed by the control (typically just BN_CLICKED for pushbuttons... but can be other things for other controls -- like for example, list boxes have a wide variety, like LBN_SELCHANGE, LBN_DBLCLK, and others). The low word of the wparam is the ID to the control (whatever ID you gave it in the resource editor... like IDC_BUTTON or whatever)... and if memory serves, the lparam is the HWND to the control.
Dish

Spiny
Level: 38

Posts: 228/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-10-05 07:30 AM, in Thinking of getting serious with C. Link
Originally posted by HyperHacker
Cool, though the control method seems complicated.


Not really.. it's just weird that it all get channeled through the same function (instead of each message getting its own routine -- which is how I assume VB does it (MFC does something similar)). I guess it takes some getting used to.



Now of course another problem - I renamed a control, and it refuses to acknowledge the new name! I re-compiled the script resource, checked that the new name was declared in the header (and removed the old one which was still there for some reason) but it just won't accept it (keeps saying it isn't defined). I had to use the actual resource ID instead. What's up with that?


Umm... you always have to use the resource ID... that's what it's there for. I must be misunderstand what you're saying




Also how do I change controls' properties? Do I have to send them messages and such?


For some things... yes. Like for stuff specific to the control, you'd have to send the control the appropriate message (like for setting a checkbox's check state, or adding strings to a listbox... stuff like that). But there's also a bunch of functions which will apply to almost any window (and remember that all controls are windows).

So stuff like:

SetWindowText() -- will change the display text (like the caption of a pushbutton, or the contents of an edit box)

EnableWindow() - will enable/disable a control

ShowWindow() - will show/hide a control
Dish

Spiny
Level: 38

Posts: 229/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-11-05 03:19 AM, in Thinking of getting serious with C. Link
Originally posted by sloat
Don't forget about SetDlgItemText, SetDlgItemInt, and SendDlgItemMessage. They come in quite handy for dialogs, especially if you're lazy.


Haha... I actually never knew about those before. They look like they're just macros though... like SetDlgItemText() just calls both GetDlgItem() and SetWindowText()


[speaking of CreateDialog dialogs]You have to have a message pump for those dialogs to work,



No you don't... they operate (more or less) the same way... only CreateDialog returns immedaitly rather than waiting for the dialog to close... and you exit with DestroyWindow (rather than EndDialog... like you mentioned). Other than that, it's driven the same way... you just supply a DLGPROC callback function when you call CreateDialog() and it feeds messages to it for you... no need to actually run your own pump.

That's my experience anyway. I don't even see where you'd need to call IsDialogMessage or where you'd even put your pump.
Dish

Spiny
Level: 38

Posts: 230/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-11-05 10:16 PM, in Thinking of getting serious with C. Link
As for your first problem... only thing I can think of, is resource.h isn't being saved before you compile.

As for your memory allocation question:

The C way is usually done with malloc() and free() functions. You #include <malloc.h>, and create your array with malloc like so:

int* myarray;
myarray = (int*)malloc( howmany * sizeof(int) );

'howmany' would be however many ints you want to make memory for. If there isn't enough memory, malloc will return NULL, so you might want to check for that.

Be sure to clean up whe you're done... or you'll have memory leaks in the program. You un-allocate the blocks with free():

free( myarray );


The C++ way is pretty much the same... but instead you use new[] and delete[]:

int* myarray;
myarray = new int[ howmany ];

delete[] myarray;

(afaik, doesn't require any #includes, which I find to be strange, actually)


Never mix malloc with delete.... or new with free. If you allocate something with malloc, use free. If you allocate something with new... use delete. The only real difference between the two is that new[] will call an object's Constructor (if it has one), and delete[] will call the object's destructor (if it has one) -- making it more useful for C++ classes and stuff like that. Whereas malloc/free will not call any constructors/destructors.
Dish

Spiny
Level: 38

Posts: 231/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-14-05 04:01 AM, in Megaman Vengeance? Link
Originally posted by Ok Impala!
Megaman Vengeance was officially canceled when Vagla left. So, you can forget about it. It was a great project though....


I remember hearing that Seph was still working on it even after Vagla quit (this was before the leak though). I don't know if he still is working on it... though.
Dish

Spiny
Level: 38

Posts: 232/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-15-05 12:36 PM, in Megaman Vengeance? Link
Originally posted by macbee
Hi! A Brazilian page made a recent (12/19/2004) interview with Vagla about his MegaMan game.


I don't think it's prudent to call it "his" game... since the brunt of the actual work is (or at least was) being done by Seph3. Vagla is part of the project fo sho... but there would be no project without Seph.
Dish

Spiny
Level: 38

Posts: 233/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-19-05 12:22 AM, in Thinking of getting serious with C. Link
.o files are object files. You still need to run the linker to make an executable.

.cpp --> [compiler] --> .o --> [linker] --> .exe
Dish

Spiny
Level: 38

Posts: 234/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-19-05 10:33 AM, in Thinking of getting serious with C. Link
'true', 'false', 'TRUE', and 'FALSE' are like the stupidest keywords ever.

Why the hell are 0 and 1 so inconvienient to type? =P I mean really... they're easier to type.. .and it's not like they're confusing.
Dish

Spiny
Level: 38

Posts: 235/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-20-05 06:32 AM, in Object Oriented Programming Link
I find OOP to me of a concept than an actual programming style. You can (and most if not all people do) program with somewhat of an OOP style in C and other procedural language (yes even you Para ;P). Even games on old consoles (NES) use OOP techniques and they're primarily written in assembly. So I find the whole concept of an "OOP Language" to be really, really stupid... since pretty much any language can do OOP.

Whether you do classes with member functions in C++... or structs with accompanying functions in C... they do the same thing. Virtual functions in C++... or a function pointer inside the struct in C. Inheritance in C++... or putting a common "parent" struct inside another struct in C. Templates in C++.... or carefully placed #defines in C. There's nothing new that C++ adds to C... everything --- and I mean everything can be done in C... C++ just offers different ways of doing it (and since C++ also includes all of C... all the "new" methods are optional).

I prefer to use OOP where appropriate... which is most of the time. However some things just don't need it... and languages that FORCE you to do things in an OOP style I find to be pretty silly (Java). Because of this... I consider myself to be a C/C++ hybrid coder. Object Oriented Programming is good... but it shouldn't be the only way. Rather it should be an idea you adapt into your coding style. Because let's face it... code that isn't at all object oriented blows unless it's a very... very small program.
Dish

Spiny
Level: 38

Posts: 236/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-20-05 07:12 AM, in Object Oriented Programming Link
Originally posted by Retro-Kasumi
But the difference is with C++ is that it supports OO natively, right?


I guess you could say that. I mean the logic behind classes in C++ was definatly driven by OOP ideas.

But like I said... there's nothing C++ can do that C can't (and vice versa)... it just uses different techniques for things. So when you say the language "supports" something... it doesn't support anything that C doesn't besides different syntax. Most of the C++ additions to C were just re-words of pre-existing C methods. The big paragraph in my post lays out the big ones:

- C++'s virtual functions are nothing but function pointers
- C++'s inheritance is nothing but putting the "parent" struct inside the "child" struct (for all practical purposes, classes and structs are identical in C++):

class CChildClass : public CParentClass
{
//class stuff here
};

that's the C++ version... the C version differs only slightly:

typedef struct CChildClass
{
CParentClass parentobject;
//rest of struct here
};

They're both fundamentally exactly the same. But only one is branded as "OOP" by courses (even though they're both OOP -- I mean syntax aside, they're completely identical).

OOP might be a little easier in C++... but it's not very hard at all to do in C. It's not a language thing at all... programming in a so called procedural language doesn't mean your code can't be OOP... and programming in a so called OOP language doesn't mean your code won't be procedural (like you said... you were doing procedural coding in Java). Hence my point of why calling X language an OOP language is stupid. It's not the language that makes it OOP... it's the style with which it's coded.
Dish

Spiny
Level: 38

Posts: 237/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-20-05 07:31 AM, in Thinking of getting serious with C. Link
I'm not sure if creating a window in one thread and running the message pump in another thread is a good idea. I don't even see why you'd need a seperate thread at all (you could just check for messages periodically in your main thread... like say every frame or something).

But that aside... if hVideoWindow is a valid window handle... PeekMessage WILL return true (unless that thread thing is a problem). Are you sure it's not returning true? I'm not exactly sure how printf() fits in here... since this isn't a console program (where are you expecting it to print to?)

As for other potential problems... sometimes when vars are only used within a small area of code (like your StopWindowUpdateThread var in this example), the processor will keep the value in a register and not write it back to RAM. Basically... this will cause problems when you rely on your second thread to react to a change made to the var from your first thread. To avoid this... declare vars that MUST be "thread safe" as volatile:

volatile int StopWindowUpdateThread;

When you write to it in 1 thread... the second thread will be sure to pick up the changes on the next read. However this removes the occasional optimization which will make slower code... so only use volatile where needed (and try to keep the number of inter-thread variables to a minimum)

But like I said... multithreading is not recommended unless necessary.


- edit -

bah... way to make my post useless XD


(edited by Disch on 01-19-05 10:31 PM)
Dish

Spiny
Level: 38

Posts: 238/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-20-05 08:38 AM, in Thinking of getting serious with C. Link
Originally posted by HyperHacker
Too slow. If I checked every frame it slowed down the emulation drastically, and if I checked every second or so the window became very unresponsive.


Not really. The time you spend processing windows messages is next to nothing. Besides... the CPU divies up processing time as needed for every running thread. You're still telling it to do the same amount of work.... making it divie up its attention to 2 seperate threads doesn't somehow make the processor run faster... if anything it makes it slower (more threads = more CPU split time).

The basic idea is:

Process all pending messages... Do a frame... and sleep if time allows (if you don't spend time sleeping, your program will gobble 100% of the CPU's time). For a demonstration:


----

while( runprogram )
{

while( PeekMessage( wnd, &msg, 0,0, PM_REMOVE ) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

if( emulationpaused )
{
Sleep(10); // if emulation isn't running for some reason, don't hog CPU time... sleep
continue; // and go back to pump
}

DoAnEmulationFrame();

// check time here, if it's too early to do another emulation frame, Sleep for a while

}

----

that runs suprisingly fast... hardly any CPU time will be spent on the PeekMessage loop. And if your time checking code is good... it can be smooth. The Demo NES Emu I made a while back does something like this. You can check the winmain cpp file in the source of said emu (or whatever the file is named) for a demonstration. That emu is very quick on my machine (typically no more than 0-1% CPU time)

Running multiple threads won't speed anything up... they may actually slow things down a bit. Not to mention they severly complicate things and cause lots of weird quirks (like your prior window problem).
Dish

Spiny
Level: 38

Posts: 239/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-20-05 09:23 AM, in Visual Studio Question Link
I'm sure there are. C/C++ have evolved a lot over the years... some older C code won't even compile on modern compilers.

Get a book that's up to date.
Dish

Spiny
Level: 38

Posts: 240/596
EXP: 355646
For next: 14801

Since: 03-15-04
From: Disch

Since last post: 18 days
Last activity: 18 days
Posted on 01-22-05 04:39 AM, in Your ROM-hacking WishLists! Link
Originally posted by HyperHacker

-A Super Mario Land 2 level editor. This had the potential to be one of the best Mario games, but was plagued by really annoying stupid features being for a shitty, handheld system.


Fixed. Hahaha... I'm just being a wiseass. But really... GB has too shitty of a res... its games are really... really hindered because of it. I mean Mario takes up 1/10th of the screen in that game.... the screen is so small it has to scroll up when you do a normal short jump.


Better yet, a project I might even try to do sometime: A universal music inserter/extractor/editor. This IS possible


This concept if fundamentally flawed. A universal music edtior is no more possible than a universal level editor. Different music routines use different spaces in RAM... different -amounts- of RAM... different sound channels... some take more space... some take less. On top of that... there's no way for a program to magically find music data... since music data can look like anything. That's like wanting it to find level data -- it just can't be done through automation (or at least... not without full emulation and one hell of a logic sequence -- and even then it'd be iffy).


And even if you somehow manage to make a program find and convert the music data to a common format -- you'd essentially have to reprogram the music engine in the ROM to play the new format. Again... finding the music playback code and rewriting it is not a job best suited for a machine. Add space issues, sound effect conflicts, and a slew of other problems and you might see what I'm talking about.


(edited by Disch on 01-21-05 07:39 PM)
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Acmlm's Board - I2 Archive - - Posts by Dish


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.014 seconds.