forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variables randomly changing

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Sun Jun 27, 2004 7:03 pm    Post subject: Variables randomly changing Reply with quote

I'm trying to add a jpg viewer to PS2MNU-K and the only way I can keep from having to reduce the pictures to having 256 be their longest side is to break the graphic up into multiple small textures, in this case 64x64. buf_32b is the raw bitmap data. x and y are u32s.

Code:

#define BLOCK_SIZE 64
            int block_x=0, block_y=0;
            u32 block[BLOCK_SIZE*BLOCK_SIZE];
            u32 memoff;
            for (block_y=0;block_y<(info.height/BLOCK_SIZE)-1;block_y++)
            {
               for (block_x=0;block_x<(info.width/BLOCK_SIZE)-1;block_x++)
             {
               for(y=BLOCK_SIZE*block_y;y<BLOCK_SIZE*block_y+BLOCK_SIZE;y++)
                   for(x=BLOCK_SIZE*block_x;x<BLOCK_SIZE*block_x+BLOCK_SIZE;x++)
                    {
                      block[x-(BLOCK_SIZE*block_x)+((y-(BLOCK_SIZE*block_y))*BLOCK_SIZE)]= buf_32b[x+(info.width*y)];
                      dbgprintf("X: %03u, Y: %03u SX: %03u, SY: %03u MO: %u\n",x-(BLOCK_SIZE*block_x),(y-(BLOCK_SIZE*block_y)),x,y,x-(BLOCK_SIZE*block_x)+((y-(BLOCK_SIZE*block_y))*BLOCK_SIZE));
                     }
              memoff=(block_y*BLOCK_SIZE*(((info.width/BLOCK_SIZE)-1)*BLOCK_SIZE))+(block_x*BLOCK_SIZE*BLOCK_SIZE);
              itoLoadTexture(block,memoff , BLOCK_SIZE, ITO_RGBA32, 0, 0, BLOCK_SIZE, BLOCK_SIZE);
              dbgprintf("%d\n", memoff);       
             }
            }


The following is an excerpt from that first dbgprintf command. The variables worked fine up to this point, and from here on, they're screwy. Since it's a for loop and nothing should be acting on those variables, I can't see why they're suddenly changing. In case you got lost in the code, SX and SY are the values of the x and y variables used in the for loop.

Code:

X: 032, Y: 003 SX: 032, SY: 003 MO: 224
X: 033, Y: 003 SX: 033, SY: 003 MO: 225
X: 034, Y: 003 SX: 034, SY: 003 MO: 226
X: 035, Y: 003 SX: 035, SY: 003 MO: 227
X: 036, Y: 003 SX: 036, SY: 003 MO: 228
X: 037, Y: 003 SX: 037, SY: 003 MO: 229
X: 041, Y: 003 SX: 041, SY: 003 MO: 233
X: 052, Y: 003 SX: 052, SY: 003 MO: 244
X: 002, Y: 004 SX: 002, SY: 004 MO: 258
X: 009, Y: 004 SX: 009, SY: 004 MO: 265
X: 017, Y: 004 SX: 017, SY: 004 MO: 273
X: 023, Y: 004 SX: 023, SY: 004 MO: 279
X: 030, Y: 004 SX: 030, SY: 004 MO: 286
X: 038, Y: 004 SX: 038, SY: 004 MO: 294
X: 043, Y: 004 SX: 043, SY: 004 MO: 299
X: 051, Y: 004 SX: 051, SY: 004 MO: 307
X: 063, Y: 004 SX: 063, SY: 004 MO: 319
X: 007, Y: 005 SX: 007, SY: 005 MO: 327
X: 012, Y: 005 SX: 012, SY: 005 MO: 332
X: 018, Y: 005 SX: 018, SY: 005 MO: 338
X: 024, Y: 005 SX: 024, SY: 005 MO: 344
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ldesnogu



Joined: 17 Apr 2004
Posts: 95

PostPosted: Mon Jun 28, 2004 10:46 pm    Post subject: Reply with quote

Your code looks OK...
Try to allocate "block" with malloc and see if that changes the behavior (if so, this *may* be a compiler bug).

Also play with the compiler flags (e.g. no optimization enabled).
Back to top
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Tue Jun 29, 2004 1:28 am    Post subject: Reply with quote

after further examination, I'm thinking maybe it's just a lag in the dbgprintf statement and it dropping lines. The blocks seem to be copying properly now that I look close at the image. They don't look like they would if those numbers were correct. However, when displayed, some repeat and look like one of those sliding block puzzles. If anyone sees anything wrong with the loadtexture code, the memoff variable computation in particular, let me know.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ldesnogu



Joined: 17 Apr 2004
Posts: 95

PostPosted: Tue Jun 29, 2004 1:36 am    Post subject: Reply with quote

You miss some blocks in your block loops :
Code:
            for (block_y=0;block_y<(info.height/BLOCK_SIZE)-1;block_y++)

You should either change < with <= or remove the -1.

Not sure it has anything to do with your problem.
Back to top
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Tue Jun 29, 2004 1:47 am    Post subject: Reply with quote

yeah, I intentionally cut off the edges so that I could get it to work before having to worry about them. The problem turned out to be that I forgot to account for the pixel bit depth. Actually, I didn't forget but I though the itoLoadTexture function would account for it. It didn't. So now I have JPG's coming up with their edges missing but they're coming up and that's what's important.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Jun 29, 2004 12:51 pm    Post subject: Reply with quote

You were probably right about the printf's dropping the lines. I had trouble on another system with the same thing. printf should flush the buffer on line feeds, but in the case of this other system, it wasn't. Flushing the buffer on line feeds is not documented behavior, but EVERY system (with a couple exceptions) does it, so most folks rely on that behavior.
Back to top
View user's profile Send private message AIM Address
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Tue Jun 29, 2004 6:45 pm    Post subject: Reply with quote

linux doesn't on stdout ;-)

But it does on stderr. Try this piece of code under linux:

Code:
for (i = 0; i < 100; i++) {
    fprintf(stdout, "From stdout: %i\n", i);
    fprintf(stderr, "From stderr: %i\n", i);
}


And then run it using >& somefile.log


Anyway, I don't think this is the problem here...
_________________
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Back to top
View user's profile Send private message
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Tue Jun 29, 2004 10:09 pm    Post subject: Reply with quote

Well, it's unimportant now. I have the jpg viewer all done, with zoom and scroll, and Next Picture, and Prev Picture and slideshow. :-)
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Wed Jun 30, 2004 7:17 pm    Post subject: Reply with quote

noticed "your" release of ps2menu-k, are you aware of that the license is not bundled with the zip ? just in case you did not know, that is illegal ( as stated by the license ), and the hoster of the zip can be hold responsible.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
ooPo
Site Admin


Joined: 17 Jan 2004
Posts: 2032
Location: Canada

PostPosted: Wed Jun 30, 2004 11:37 pm    Post subject: Reply with quote

Sending source changes to either cvs or one of the 'official' ps2menu authors would also be a nice thing to do. Perhaps they'll even let you join the team.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Thu Jul 01, 2004 5:30 pm    Post subject: Reply with quote

So how about it Kaylakaze ?

You have been a member of the PS2DEV community for only 2 months,
already ranked #10 in number of posts to the forums, and making updates
to PS2DEV code. Obviously you are interested in the community here.

Everyone can benefit from making your code mods legit. Its up to you
if you want to maintain your own independant fork of the code, but you
are less likely to run afoul of licensing issues such as "forgetting" to
include the required license statements in your code fork. Its just easier
all around, and more beneficial for all, to contribute back.

We are always happy to have new people interested to contribute to
legal homebrew development.

Gorim
Back to top
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Thu Jul 01, 2004 9:58 pm    Post subject: Reply with quote

I don't mind sharing back. I just didn't know how to go about doing it. If someone wants to go through my mess of code, fine with me :-) Just tell me what you want done to make it a "legal" product.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Thu Jul 01, 2004 10:18 pm    Post subject: Reply with quote

I already pointed out that the LICENSE file from the original ps2menu is missing, now since ps2men-k is based on ps2menu you are violating the license by not including the copyright notice. just read the original license file and it should all get clear.

Second ( mind you this is not a legal problem ) censoring the original readme is just childish, and you could just remove it, its evidently not there to uphold any legal issue, but just to point out that "ownz" do not like ps2dev.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Thu Jul 01, 2004 10:30 pm    Post subject: Reply with quote

I leave the original 'cause I don't feel like rewriting the info in it. It's censored because if it wasn't, I'd be banned from the site. I'd rather not have to do that. As for the license, I ignore license files for good reason: they're BS. And then if someone modifies released code of mine, is it a mod of mine or a mod of thiers? and then if their's is modified. How many license files end up being included? Just the first, even though more code is modified than the original? And what if ALL the code had to be restructured to support added functionality? Is it still the original software or a similar product? It's a theoretical question. I personally don't care about adding the license file.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Thu Jul 01, 2004 11:05 pm    Post subject: Reply with quote

you may feel what you want about license files, that does not change the fact that you have based your work on someone elses, and that work was covered by a license, and in that license it is clearly stated that you have to leave the copyright statement intact, otherwise YOU violate the license and are thereby not granted the permission to use the source.

Now this is quite simple, either you adhere to the license to the source that you base your work on OR you do your own thing from scratch. Thats how it works, and then and only then are you in your fully right to either not include a license or include one protect your source/credit etc.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
Neovanglist
Site Admin


Joined: 22 May 2004
Posts: 72
Location: Copenhagen, Denmark

PostPosted: Thu Jul 01, 2004 11:11 pm    Post subject: Reply with quote

Preserving the original license is not just a matter of legality, it's a matter of respect. If you didn't want ps2dev in the files, then you shouldn't have used a ps2dev project. Either way, it's not your codebase, it's t0mb0la and adams, and you do _not_ have the right to modify the license irregardless of your personal situation. It would make a lot more sense for you to submit your improvements to ps2menu as a unified diff to one of the ps2dev commiters. Or, talk to Oobles to get cvs access for yourself. Also, ps2menu is a somewhat dead project. t0mb0la is now working on Altimit, which is a much improved menu using a completely new codebase. You can check it out from ps2dev anonymous cvs.

Regards,
Chris (Neovanglist) Gilbert
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu Jul 01, 2004 11:13 pm    Post subject: Reply with quote

KaylaKaze wrote:
I leave the orinal 'caus eI don't feel like rewriting the info in it. It's censored because if it wasn't, I'd be banned from the site. I'd rather not have to do that.

Personally, I wouldn't want to be part of any site that would ban me for being a decent person instead of following their childish ways.

Quote:
As for the license, I ignore license files for good reason: they're BS.

Thats a very bad reason to ignore licenses. And no, they are not BS. Ignoring the copyrights of the original author because you think your changes are more important is BS.
Yeah, licenses can be a bit messy. The license for ps2menu is pretty clear and open. If you wanted to be anal about it you could probably go through and clearly label what is your code and what is the original code, or you could do like everyone else here does; add your changes in, add your name to the copyrights, and just follow the same license.
If you really have a problem with the license, then don't use the damn source. Start your own project from scratch. That sound like a lot of work? Guess what the original authors of that software had to do?

I guess there is two ways of looking at it... You can be a decent person, respect copyrights, and get banned from a site that wants you to act childish, or you can be childish, disgregard the hardwork of others, and get banned from a community that has spent quite a bit of time answering your questions and helping you with your problems.

Maybe it's just me, but that seems like an easy decision.


And btw contributing is easy and there is a couple ways to do it. You can ask for cvs access, either by poking a regular (which are very easy to spot here), posting on the forums, or asking in irc. You can also just post here or poke one of the regulars and provide the source to your changes and we'll do what we can to get it taken care of. Easy eh?
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Thu Jul 01, 2004 11:24 pm    Post subject: Reply with quote

Then why doesn't ps2menu include the licenses for libito, ps2lib, ps2dev, libhdd, etc. ?

Like I said, I don't have a problem with the license thing in and of itself. I'm just trying to find where the BS ends.

And I know PS2Menu is a dead project. That's why I'm working with it and not Altimit. I know I'd personally be pissed about sharing code of something I was working on and having somone else stepping all over my toes.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu Jul 01, 2004 11:30 pm    Post subject: Reply with quote

KaylaKaze wrote:
Then why doesn't ps2menu include the licenses for libito, ps2lib, ps2dev, libhdd, etc. ?

libito, ps2lib, libhdd are seperately distributed libraries, there is no reason for the ps2menu source to contain their licenses.

Last I checked none of those required the license to be shown a run time eithe, although I suppose I could be wrong, and in that case we'd rectify the mistake.

BTW, if you think licenses are crap then you should take a look around. PS2DEV tends to use the AFL, which is about the simplest and most open license there is.
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu Jul 01, 2004 11:33 pm    Post subject: Reply with quote

KaylaKaze wrote:
And I know PS2Menu is a dead project. That's why I'm working with it and not Altimit. I know I'd personally be pissed about sharing code of something I was working on and having somone else stepping all over my toes.

t0m has been quite open about accepting help with altimit. I'd go as far as to say he has openly requested help, but I can't think of anytime he has screamed at the top of his lungs "OH DEAR GOD SOMEONE HELP ME!" ;)
_________________
Shoot Pixels Not People!
Makeshift Development
Back to top
View user's profile Send private message Visit poster's website
Neovanglist
Site Admin


Joined: 22 May 2004
Posts: 72
Location: Copenhagen, Denmark

PostPosted: Thu Jul 01, 2004 11:45 pm    Post subject: Reply with quote

KaylaKaze, please take into consideration the community as a whole. Nothing we do here is really for personal benefit outside of learning. We work where it would be most advantageous to the community. For example, I don't work on gsKit because I want to learn about the GS, I work on gsKit because the ps2sdk needed a GS library.

The way this relates to you, is what would benefit the community more? Spending your time working on an obsolete codebase, or contributing to a new codebase with far more potential? Altimit is the way of the future as far as open-source ps2 explorers go, (unless someone else starts a new one) and it really needs help. It's already pretty established, but it needs a few trimmings and additions before it can become usable.

We don't want to shoo you away from the community, we are trying to bring you into it. However, there are certain guidelines and ethical rules involved with being in any open development community that must be respected and followed. We would love to have you join us, and get cvs commit access. By all means, commit your improvements to ps2menu for all to use. Talk to t0mb0la and add yourself to the AUTHORS or README file with his permissions if you are concerned about credit for your work.

Just keep in mind, this is about the advancement of the community as a whole, not personal fame or gain.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
KaylaKaze



Joined: 05 May 2004
Posts: 75
Location: NC, USA

PostPosted: Thu Jul 01, 2004 11:56 pm    Post subject: Reply with quote

If it's wanted, I'll be more than happy to, if nothing else, add the MC database code to altimit, and the jpg viewer if necessary, and the FTP code if we ever get it working. But also, altimit is a lot more complex than ps2menu. the mods I did to PS2Menu were the first things I had done at all involving ps2 development. I originally got the code to see how the ps2 coding structure was done and I said "hey, this is simple enough I can work with it." I know more now so hopefully I can be of some use with Altimit (assuming I can get it compiled)

Quote:
Just keep in mind, this is about the advancement of the community as a whole, not personal fame or gain.


I agree completely. That's why the whole bitching about the license thing is driving me nuts and confusing me.
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Neovanglist
Site Admin


Joined: 22 May 2004
Posts: 72
Location: Copenhagen, Denmark

PostPosted: Fri Jul 02, 2004 12:04 am    Post subject: Reply with quote

Sounds great, glad to have you on our side!

The best way for you to communicate with us is to join #ps2dev on the EFNet IRC network. Just PM me once on EFNet (Nickname: NeoV) and I'll get you an invite to the channel.

Regards,
Chris (Neovanglist) Gilbert
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Guest






PostPosted: Fri Jul 02, 2004 1:38 am    Post subject: Reply with quote

KaylaKaze wrote:

I agree completely. That's why the whole bitching about the license thing is driving me nuts and confusing me.


You might understand it better if you think of it from a different perspective.
Members of this community created the code you are using, and they chose
to put a certain license to govern its usage on the code, which is their right.
Now, actually the license is not restrictive, its probably the least restrictive
out there. Since they took the time to write it, its rather upsetting and
hurting when someone casually comes along and violates it. Mostly
because one of the main things the license governs is preserving the
original authorship of the code. The license is so unrestrictive, that it
pretty much only wants to guarantee that the original author gets
credit. That is the only compensation being asked for use of the code.

To cast aside the license, is to deny the author credit, and in a sense
is a stealing of credit. Think back to high-school english class where
the instructor harped on citing references/footnotes for much material
in your research papers, that failing to do so was plagiarism. Similar
concept here, except that this license goes further to say that you can
use the code any way you want, even sell it, so long as you continue
to give credit to the author and maintain the original license.


Now you might be approaching the license from a different perspective,
without understanding the purpose of the license. This license is not like
what you read with shrink-wrapped softwares like Microsoft et al where
you have to read a long EULA that promises your arm and assorted body
parts if you violate the license. This is nothing of the kind.

But thankfully you are agreeable to putting the license back. If you haven't
read it yet, perhaps you should, you would realize that not only is it
not a big deal, but its the license that helps ensure people can continue
to legally use the software created here in a very free and open manner.

Gorim
Back to top
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group