sonik-br / GunconUSB

Use Guncon 2 and 3 on Windows
GNU General Public License v2.0
23 stars 2 forks source link

GunCon 2 x offset #1

Open pcnimdock opened 2 years ago

pcnimdock commented 2 years ago
Hi, I'm trying to do an guncon2 plugin for pcsx2 and I note that when the game start, the game send a control out frame. game controlOut
point blanck collection 0, 0, 0, 0, 0, 1,
virtua cop 0x14, 0, 0, 0, 0, 1,
timecrisis 3 0, 0, 0, 0, 0, 1,
timecrisis 2 0, 0, 0, 0, 0, 1
crisis zone 0, 0, 0, 0, 0, 1
vamire knigth 0x14, 0, 0, 0, 0, 1
ninja assault 0, 0, 0, 0, 0, 1
gun figther 0, 0, 0, 0, 0, 1
endgame 0, 0, 0, 0, 0, 1
dinostalker 0, 0, 0, 0, 0, 1
In calibration screen when I shot at center, the game correct y axis, but x axis doesn't, but the game send a new ControlOut (or set report) frame. I get for virtua cop, a set of data on the first shot. I think the first 2 numbers is a int value for change x offset. pointing to x guncon frame decimal number
center 424 0x16 0x00 0x00 0x00 0x01 22
left center 403 0xf0 0xff ... -15
rigth center 441 0x36 0x00... 54
rigth center 464 0x5e 0x00... 136

If you have a guncon2, could you test if changing this number produce any linear change on pointing? Thanks

sonik-br commented 2 years ago

Hi, Nice find!

My pc is currently not connected to a CRT but I will try to configure it again.

The 0, 0, 0, 0, 0, 1 command is to disable the "progressive screen" mode https://github.com/sonik-br/GunconUSB/blob/main/src/Guncon2Console/Guncon2.cs#L26

I will have to verify this first byte. It makes sense to be an offset correction indeed. When I was making an GC1 to GC2 adapter for use on a real PS2, I found that virtua cop have a big offset difference.

BTW do you know that a plugin already exists for PCSX2? And it does have per game hard coded offset settings.

pcnimdock commented 2 years ago

Yes, I know the nuvee plugin and I am using it like base for translate to USBqemu-Wheel, this last it's working on linux. The problem with nuvee is that I need to push the game in the combobox in configuration and if this number is really a offset number, i can delete this step. Also I created a bridge with wiimote and a ESP32 to real ps2, and I want ignore the combobox step.

sonik-br commented 2 years ago

Amazing! This combobox step is why I don't use the emulator with guncon games. Can't promise but I will do my best to put my setup working today and test those commands.

sonik-br commented 2 years ago

Btw if you find out how to make the gc2 work in real progressive mode (ie: game outputting at 480p to a 480p screen) it will be amazing! It's he holy grail for real guncon2 gaming on a vga crt display.

pcnimdock commented 2 years ago

For nuvee plugin https://github.com/mirror/nuvee/blob/b710557c5812f6fae6d015827cfc88b194ee9ccb/nuvee_ps2_usb%20-%20guncon2%2C%20keyboard%2C%20mouse/ps2_lightgun_list.txt

"- At calibration screen, hold trigger offscreen + press SELECT

change screen: 480i, 480p, 100 Hz ('Progressive Scan' is 480p)"

I 'm gonna to read the code if there are any hack for this.

pcnimdock commented 2 years ago

Ok, in the code https://github.com/mirror/nuvee/blob/b710557c5812f6fae6d015827cfc88b194ee9ccb/nuvee_ps2_usb%20-%20guncon2%2C%20keyboard%2C%20mouse/src/guncon2.cpp //--------------------------------------------

define PROGRESSIVE_SCAN 0x0100

// buttons (default) pad_out[0] = 0xffff & ~PROGRESSIVE_SCAN;

// usually tv scan flag (mode $0100 = interlace) pad_out[0] |= DEVICE.vars[ GUNCON2_PARAM_MODE ]; //---------------------------

pad_out[0] is an unsigned int where is located the buttons states

Also, in the code show a diference with x and y data //--------------------- if( DEVICE.vars[ GUNCON2_PARAM_MODE ] & PROGRESSIVE_SCAN ) { // interlace mode data_x -= (s16) ( DEVICE.vars[ GUNCON2_PARAM_X ] ) / 2; data_y -= (s16) ( DEVICE.vars[ GUNCON2_PARAM_Y ] ) / 2; }

else {
    // progressive mode
    data_x -= (s16) ( DEVICE.vars[ GUNCON2_PARAM_X ] );
    data_y -= (s16) ( DEVICE.vars[ GUNCON2_PARAM_Y ] );
}

//--------------------- I guess it was useful

Edit: May be, pushing 0 in last byte in ControlOut frame, it will force to progressive

sonik-br commented 2 years ago

This "progressive" mode is for console outputting 480i to a sony tv that internally does 480i > 480p.

This way the input on the GC2 is 480i but it will read 480p on the tv. It defaults to this and it what causes the "rolling x" problem when used on a pc. Older GC2 drivers had this problem until beardypig found the correct command to disable this mode.

It's still unknown if the gc2 does indeed support a real 480p input.

sonik-br commented 2 years ago

Guncon2 connected and ready top test. Some findings...

The first byte is indeed the horizontal offset

Pointing to an fixed part of the screen (in decimal values)

Command on the left and actual reading on the right, 00 | 315 20 | 300 32 | 300 60 | 280 94 | 265

The third byte changes the vertical offset 00 | 36 20 | 16

Changing the command forces it to output a negative offset. Still need to figure out how to change it to a positive offset. And a very long offset crashes the guncon2 when pointing at the edges of the screen. Had to disconnect the usb and reconnect again to make it work.

pcnimdock commented 2 years ago

WOo! thanks! For a negative comand you need to write 0xFF in the second byte. Examples: 5 -> 0x05 0x00 = {5,0...} 0 -> 0x00 0x00 = {0,0.. } -5 -> 0xFB 0xFF = {251,255...} With windows calculator, in programmer mode, you can show it

-20 -> EC FF -32 -> E0 FF -60 -> C4 FF -94 |-> A2 FF

sonik-br commented 2 years ago

Cool! Those findings will be handy if I ever make the GC1 to CG2 adapter :)

Need me to test anything more with a real gc2?

Also, beardypig said the GC2 have "Normal/High-Density" and "Progressive/Interlaced" But it was not documented :(

Normal/High-Density mode is indicated by bit 8 of the buttons data and bit ?? indicates Progressive/Interlaced.

pcnimdock commented 2 years ago

In the nuvee plugin, for "Time Crisis - Crisis Zone" and "Vampire Night (U)", have a resolution of 768x768 pixels, may be I can show if there are any extra configuration

sonik-br commented 2 years ago

Can you try to put Vampire Night in progressive mode and see if it sends any command?

pcnimdock commented 2 years ago

I'm trying now :D

pcnimdock commented 2 years ago

Ok, my findings: At begin,I'm forcing to my emulated guncon to set progressive. When Vampire Night (U) begin, it sends to guncon: SET_REPORT length: 6 14, 0, 0, 0, 0, 1,

Because mode is 1, I put my guncon is setted to interlianced.

When is showed the calibration screen, the game puts: SET_REPORT length: 6 a, 0, 0, 0, 0, 0,

Because mode is 0, I put guncon to progressive. At now in the screen show High Density 2 point calibration.

I probe same on Virtua Cop, but now I have problems with y axis. It's needed more inventigation for me. Conclusions: You can query to your guncon2 set to progressive, but it's the guncon2 who accepts this state putting '0' at 0b0001000 in the second byte. gsdx_20220604184052 gsdx_20220604184435

sonik-br commented 2 years ago

Game is outputting in 480i or 480p? (I think the emulator can show this info. If it's rendering/outputting in 480p, how to enable this?

pcnimdock commented 2 years ago

480i pcsx2

sonik-br commented 2 years ago

Would be cool if we could get any guncon2 game to render at 480p :) This link says that Vampire Night supports 480p mode. https://en.everybodywiki.com/List_of_PlayStation_2_games_with_alternative_display_modes

pcnimdock commented 2 years ago

I'm looking for how to do in pcsx2 but i don't find anything. I think that the unique form to do it is connect a playstation 2 in a progressive CRT.

sonik-br commented 1 year ago

Hi @pcnimdock !

I did some testing with your guncon2 plugin and it's working quite good on windows! You did an amazing job!

I would like to ask for a feature. Can you add "offscreen" mode using the MAME pattern? MAME defined that lightgun is offscreen when X = MAX and Y = MAX... ie: left bottom of the screen.

pcnimdock commented 1 year ago

I think for pcsx2/ps2 an offscreen shot is when x=0 y=0 (from nuvee plugin). At now, the offscreen feature is not implemented. I will change this soon