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 

Memory-resident programs

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



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Sat Jul 10, 2004 7:32 am    Post subject: Memory-resident programs Reply with quote

I'm working on writing a memory resident program for the PS2, to run behind a game. I've gotten it to work in PCSX2 and print out the syscalls that other demos. It does this by overwriting parts of the syscall interrupt handler. I've only been able to test in an emulator so far, still waiting for my equipment to arrive so I can test it on the hardware, but does anyone know a reason why it shouldn't work on the hardware?
Back to top
View user's profile Send private message Visit poster's website AIM Address
apache37



Joined: 04 Jun 2004
Posts: 76

PostPosted: Sat Jul 10, 2004 1:39 pm    Post subject: Reply with quote

What does the memory resident program do?
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Jul 10, 2004 8:24 pm    Post subject: Reply with quote

Which brings up another topic...and discussion.

Has anyone investigated the utility of PCSX2 for ps2dev development ?
Too many times I would prefer to do some development completely
on my laptop.

Of course, there are the always present legal concerns. However, since
at this point its ability to play actual games seems to be near impossible,
but I have seen reports of homebrew demos working fine, one might not
need to be concerned about indirectly contributing to warez efforts merely
by being a "consumer" of this tool.

If PCSX2 could actually play commercial games, I think the line might be
more clear, that this would have the same status of modchips, that is to
say, completely muddled and a major grey area, as opposed to a minor
grey area ?

What do people think ?

Gorim
Back to top
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sat Jul 10, 2004 8:42 pm    Post subject: Reply with quote

I think this would be more or less the same that the first battles between SONY and Bleem!. Having a full emulator for a platform like the PSX has prooved to be not that much illegal, if it is not coded using the official documentations.

Bleem! was the only PSX emulator to be threatened by SONY, and many other free emulators were out a bit after, without beeing problematic. Now, PCSX2 seems to be not even considered by SONY at all.

Apart of that, I quite do not care :)
_________________
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
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Sun Jul 11, 2004 1:58 am    Post subject: Reply with quote

Right now it prints something each time a syscall is made (except for... whichever one is called in the printf itself so it doesn't recurse). I only need to find if the principle of memory-residence will work, not the specific program.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Herben



Joined: 25 Jan 2004
Posts: 107

PostPosted: Sun Jul 11, 2004 9:21 am    Post subject: Reply with quote

Doing something like a syscall logger wouldn't be difficult on it's own, but the printf might be problematic. Simply adding your own syscall exception handler to the exception table would work for the actual syscall logging, but you'll need a way to keep your printf() stuff working. That's not a problem if you use EE SIO as it doesn't require any drivers/etc on the IOP, but using Naplink/ps2link means that you need to make sure those modules get loaded every time the IOP is rebooted. Certainly not impossible but problematic when you consider things such as USBD/DEV9/etc conflicts with some games. EE SIO is the way to go. :)
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sun Jul 11, 2004 11:41 am    Post subject: Reply with quote

pixel wrote:
Bleem! was the only PSX emulator to be threatened by SONY, and many other free emulators were out a bit after, without beeing problematic.


Not quite - VGS from Connectix was sued by Sony in court. The case lasted quite some time. Other PSX emulators haven't been targetted for two reasons - they aren't commercial like Bleem! and VGS were, and they are developed in countries which don't care about enforcing copyright or patent laws.
Back to top
View user's profile Send private message AIM Address
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Jul 11, 2004 12:05 pm    Post subject: Reply with quote

Ah yeah, I always mess up between Bleem! and VGS.
_________________
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
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jul 11, 2004 4:39 pm    Post subject: Reply with quote

Quote:
they aren't commercial like Bleem! and VGS were, and they are developed in countries which don't care about enforcing copyright or patent laws.


Which countries are these now ?
Back to top
View user's profile Send private message
pixel



Joined: 30 Jan 2004
Posts: 791

PostPosted: Sun Jul 11, 2004 10:11 pm    Post subject: Reply with quote

I know linuzapp is bresilian, but I don't know if bresil is such a country.

Otherwise, I know that .cx (Christmas Island) is.
_________________
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
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sun Jul 11, 2004 10:39 pm    Post subject: Reply with quote

linuz is argentinian but still ;)

And Christmas Island is a den of piracy, been like that since the the 1720s :P
Back to top
View user's profile Send private message
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Tue Jul 13, 2004 1:31 am    Post subject: Reply with quote

Herben wrote:
EE SIO is the way to go. :)


Is there any way to get access to the EE SIO without building mrbrown's serial cable?
What I'm trying to do now is get scr_printf in the exception handler and see if I can just take over the screen when I need to write something. Is there a character set in ROM or RAM that I could use instead of including font.c?

Another question:
can I be reasonably sure that the exception table will be in the same place between BIOS revisions?
Back to top
View user's profile Send private message Visit poster's website AIM Address
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Tue Jul 13, 2004 3:09 am    Post subject: Reply with quote

check out adresd bios font unpacker, its on ps2dev.org somewhere.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Tue Jul 13, 2004 4:10 am    Post subject: Reply with quote

hcs wrote:

Another question:
can I be reasonably sure that the exception table will be in the same place between BIOS revisions?


The V_COMMON exception handler is always at the same address. If you're referring to the kernel's syscall handler table, the easiest way to find it's origin is to add a dummy syscall, scan kernel memory for it's address, and subtract the number of the syscall * 4 (since the address is 4 bytes). That's the only reliable way to get the start of the syscall table as it is different in almost every kernel revision.
Back to top
View user's profile Send private message
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Tue Jul 13, 2004 4:23 am    Post subject: Reply with quote

Alright, that's what I was hoping to avoid doing with the syscall table, but if I must I must.

Tolerate another question if you will:
I mentioned using scr_printf, is there a reason why I couldn't write this so that it overlays whatever graphics are already on the screen? Of course I'd have to do it every frame . . .
Back to top
View user's profile Send private message Visit poster's website AIM Address
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Tue Jul 13, 2004 6:04 am    Post subject: Reply with quote

well unless you know the framebuffer locations for each frame, turn of zdepth test, write text to some "safe" area in vmem, and draw a sprite primitive with the uploaded text texture.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Tue Jul 13, 2004 6:39 am    Post subject: Reply with quote

I'm not sure I understand what you're saying, will it be necessary to do all of this or is this how I could get around drawing each frame? What I thought I could do was replicate the debug printf and somehow have that called once per frame. There I only need space for a single character. I've got this working, though not behind any real program yet.
On the subject of the framebuffer, this wasn't something I noticed anywhere in the scr_printf sources. Is this assumed or set by default?
Back to top
View user's profile Send private message Visit poster's website AIM Address
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Tue Jul 13, 2004 6:39 pm    Post subject: Reply with quote

scr_printf just writes to the beginning of vram.
if you double buffer like any sane person you will have 2 different vram locations,
using scr_printf only every second frame will show the scr_printf output.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Wed Jul 14, 2004 12:59 am    Post subject: Reply with quote

Does scr_printf just write to the beginning of vram because of how it initializes the GS, or is there something specific in the command to draw each character that forces it there?

[edit]
Never mind, I see it now.
Couldn't I read the current framebuffer address and write my characters directly there?
Back to top
View user's profile Send private message Visit poster's website AIM Address
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Wed Jul 14, 2004 2:57 am    Post subject: Reply with quote

sure aslong as you know where the frame buffer is you can write data to it and expect it to be shown.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Wed Jul 14, 2004 4:07 am    Post subject: Reply with quote

Should I be able to read from GS_DISPFB1 and GS_DISPFB2? Although changing the framebuffer pointer produces the expected effect in PCSX2 I only ever read zero from those registers. Is this a hardware artifact or an emulator bug?
Back to top
View user's profile Send private message Visit poster's website AIM Address
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jul 14, 2004 5:56 am    Post subject: Reply with quote

Those registers are write-only.
Back to top
View user's profile Send private message
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Wed Jul 14, 2004 6:05 am    Post subject: Reply with quote

That will make it more difficult... drat you for crushing my dreams!
Is there any other way I could get the framebuffer address out of the hardware?
Back to top
View user's profile Send private message Visit poster's website AIM Address
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Wed Jul 14, 2004 6:28 am    Post subject: Reply with quote

no. back to drawing sprites with ztest off.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Wed Jul 14, 2004 6:28 am    Post subject: Reply with quote

The only zany idea I could think of, which I have no idea if it would work, is adding entries to or modifying the MMU TLB entries to "trap" accesses to GS priveledged registers. There really is no reliable way to get access to those registers once they've been written to.
Back to top
View user's profile Send private message
blackdroid



Joined: 17 Jan 2004
Posts: 564
Location: Sweden

PostPosted: Wed Jul 14, 2004 6:58 am    Post subject: Reply with quote

no. back to drawing sprites with ztest off.
_________________
Kung VU
Back to top
View user's profile Send private message Visit poster's website
hcs



Joined: 30 Jun 2004
Posts: 18
Location: New Jersey, USA

PostPosted: Wed Jul 14, 2004 7:48 am    Post subject: Reply with quote

So as I currently understand it I should be able to blit the text to vmem and then draw sprites, which will go to the framebuffer currently being drawn. I presume disabling z test was to prevent it from being under something already on screen. Could setting the z value very high be another solution, with the added benefit that things drawn after the text wouldn't overlap it?

Is there any way I could get text on screen without having to find a safe place in vmem to render a texture to? Something that just popped to mind is using the line primities to draw text (or as a last resort drawing one pixel at a time with points), but is there any other way to get a texture to the currently drawing buffer? If not the other two possibilities should be fine.

Thanks for answering all these newbie questions . . .
Back to top
View user's profile Send private message Visit poster's website AIM Address
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