640x512 PAL mode

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
bionicman
Posts: 7
Joined: Mon Jun 14, 2004 5:05 am

640x512 PAL mode

Post by bionicman »

Hi,
I've just started my home brew PS2 hacking -- first of all thanks to all of you who provided invaluable information that helped me get going.
I managed to run my code using independence exploit and Xploder.
Too bad naplink doesn't seem to recognize my cable, but I've got a
network adaptor and I'm gonna try using it for development.

I'm developing a simple demo and I'm struggling with basic video mode
setting. I'm trying to setup a basic 640x512 PAL mode, and here's what
I've got so far:

I'm using SetGsCrt syscall to set the mode (interlaced=1, mode=3, frame_field=0). Then I stuff some magic numbers into DISPLAY2.
I'm using standard double buffering technique, polling for vsync
using CSR register.

It all kinda works, but the are a couple of things I'm trying to nail down:

- the image flickers as if I was running 10-15 Hz refresh rate. What am I
doing wrong? Certainly there is a bit of flickering when I play games in
this video mode, but not as bad as my demo.

- The screen is shifted a bit to the left and there is uninitialized crap
at the bottom of the screen. This probably has to do with how to initialize
DISPLAY2 register, but I've tried following the tutorials and using
the PS2 Linux code (ps2gs.c) to compute them -- it's always a bit off.
What are the definite guidelines on how to set this up?

- Anyone knows how can I avoid vsync polling and setup interrupt handler
for this?

Thanks, any help appreciated!
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

dunno where you got mode = 3 from, I give SetGsCrt 1 for pal.
Personally I set display to 0x1FF9FF01840290 wich centers it pretty nicely on my tft's, tv's and projector.

personally I use polling for VR so far, as one should keep things within a frame ;)

otherwise just register a vrhandler, something like this ( im sure there are some sources out there, pillgen or somesuch that sets up a vrhandler ).

# disable interrupts
di
# install handler
ori a0, zero, 0x2
la a1, vrFunction
move a2, zero
ori v1, zero, 0x10
syscall
nop

# save handler id
la a0, vrId
sw v0, 0(a0)
# enable it
ori a0, zero, 2
ori v1, zero, 0x14
syscall
nop
# enable interrupts
ei
Kung VU
bionicman
Posts: 7
Joined: Mon Jun 14, 2004 5:05 am

Post by bionicman »

Thanks for your reply.
BTW, I'm pretty sure it's 3 for PAL when calling SetGsCrt.

0x02 // NTSC
0x03 // PAL
0x50 // HDTV 480p
0x1A // VGA 640x480
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

About the flicker - 640x512 PAL is interlaced. You have a 50 Hz field rate, and a 25 Hz frame rate. If your routine to wait for the vertical blank was assuming a 50 Hz field rate when the bit monitored was giving you a 25 Hz frame rate, it's possible you're actually winding up with a 12.5 Hz synchronizing routine. Another possibility is that your routine takes longer than one frame, so then waiting on the frame end gives you a two frame delay, also giving a 12.5 Hz synchronization.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

C source for setting up a vr handler (taken from BP Demo Harness stuff, and probably from somewhere else before ;P)

int vb_id;

int vblank_handler(int cause)
{
/* Do sommit, i.e. Signal a sema */
asm("sync.l ; ei");

return 0;
}

void enable_vblank()
{
DI();
vb_id = AddIntcHandler(2, vblank_handler, 0);
EnableIntc(2);
EI();
}

void disable_vblank()
{
DisableIntc(2);
RemoveIntcHandler(2, vb_id);
}
bionicman
Posts: 7
Joined: Mon Jun 14, 2004 5:05 am

Post by bionicman »

Excellent, thank you! I also found ito lib to be a great source for learning
- cleanly written and commented.

As for the flickering: good points J.F., although now I'm thinking I was imagining things being used to high refresh rates on the monitor :)

Alright! I've got the basics nailed down, it's time to do some 3D! :)
It'd be cool to see an absolutely basic 3D demo, .e.g rotating cube
or something, that uses VU units properly etc. I'm going through the docs
now, If I ever make something useful I'll try to publish it for everyone.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

bionicman wrote:As for the flickering: good points J.F., although now I'm thinking I was imagining things being used to high refresh rates on the monitor :)
Yes, after using 75 to 100Hz for a year or two, going back to even 50Hz would seem bad, much less 25Hz. I can't stand 60Hz anymore. :D
Post Reply