PPPPUURRRRUU PURU!

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Kamjin
DC Developer
DC Developer
Posts: 216
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

PPPPUURRRRUU PURU!

Post by Kamjin »

Here we go..

1st. From what I've seen so far, not all rumbles are
equal.. actually they all behave diferently.

All the info I've gathered was done using a logic
analyzer, and then imitating the data until
I finally got a rumble

So far I have yet to find any understandable data
that comes from the unit aside from the generic parameters that
some have which usually are:
Vibration Motor: 1
FM: 4-30 or 45Hz
Power: 7

Note: that out of the 9 rumbles I have here
only 4 actually respond to an "extended dev info"
Some will actually get the command to rumble..
and rumble.. but report a failure??!

So to find a PURUPURU just query "dev info" (cmd 1).

Unfortunately My LA is only 2K.. so it was hard enough
catching a command to the puru.. I was never able
to catch the dreamcast reading from it..

So, at this point to get it to work right, someone
with the Katana dev kit is going to have to
follow some of the code to see how the data is
treated.. and if anyone who's got source to
a dreamcast emulator it would be nice if you could
sniff the access's to the puru to see how it can
tell the differences between them.
what it's reading from them, and how it treats the data..

before I go on.. to get a grip on the endian format
look at the source in the next post.

now values, and bits on one puru will cause another
to fail, there is very little "safe" room to program these
until someone figures out how the registers/parameters
work for real.. So don't create a random effect on
a EMS Puru.. it WILL fail on other models.. even what I'm
about to post will fail on 2/9 puru's I have here..

The puru's take data via Command 14 "Set condition"
One Frame, and One Data..

writing a data of 0x00000000 stops the puru imeadiatly.
in most cases you can simply keep writing effects
to the unit and it will switch to it right away.. with
one exception. the PSX to DC adapters they tend
to endlessly loop whatever you send them,
and don't change effects on the fly.. so
it's good practice to set the effects to run
longer, and then stop them with 0x00.


The data field:
0xAABBCCDD

AA= these appear to be the "Duration" on almost all
units.. I've found one exception, that requires an effect
to be on as well.. they appear to formated asA
Upper Nibble (Aa)
This is kind of like a multiplyer of the lower nibble,
but if you use this only, the slight pause is missing,
and from what I've counted is not quite 7 or 15 times
the lower nibble..

Lower Nibble (aA)
This will cause a repeat of whatever effect is going on.
if you have an effect of 3 pulses and set the
nibble to 1 you'll have 6pulses (3 a slight pause then 3)
Values that seem to work the best a 0-7, setting the
MSB will cause some units to ignore, or even stop the effect.

BB These one's totally baffle me. They
really don't behave the same across the different
puru's..

Upper Nibble (Bb)
On some units you HAVE to at least have a value
here in order for the effect to accept a duration,
while on other units they lower the intensity
of the rumble 0-7 appear to be okay values
when testing, the MSB here on some units
causes an Decay effect where the effect
starts out strong then fades out, determined
by the upper, and lower nibble, and the upper
C nibble.

Lower Nibble (bB)
This guy works with upper nibble C,
in a sense this behaves like the upper
half of the effects generator..
Values from 0-7 are intensity
and the MSB 8 creates a pulse effect.


CC These are pretty much the same across all
units.

Upper Nibble(Cc) This work with lower nibble
B to create the effect, it behaves exactly the
same as the B, 0-7 intensity, and the MSB
enables the pulse effect.

Lower Nibble(cC) appears to be the power saving
set any bit here, and most devices, will either
not respond to you command, or simply do nothing.



DD These are intersting..

Upper Nibble(Dd)
This is the motor select, I verified this on absolute
no-name HK psx to dc adapter.. which bit 0 and
bit 4 would control the left or right motor..
for now you set it to a 1, anthing else.. and
it don't work..

Lower Nibble(dD)
Special effects.. I've found 2 so far, but
once again.. the only one that works
across the board is bit 0 which causes
a sharp pulse effect.

So if you're going to add puru effects, you'll need
a few things 1. Many PuruPuru's initially I had
over 15 of them here to create a few effects that
worked on all the units, and behaved close enough
to each other.
2. Don't overdo the effects, in AAC when you thrust
it rumbles.. on most units it just tugs the weight,
but on a few it's annoying it actually spins the weight
a bit, and after 15 minutes.. you're annoyed..
3. Get used to feeding the puru, don't just use an
effect, thier durations vary from unit to unit..
feed it data , and stop it manually. you can also
create other effects this way as well like a heart beat,
etc..
4. Write a driver for KOS... I kept crashing the machine
trying to get data on the queue.. My proffesion is
Electronics... so I'm an assembly / straitC, lowlevel
programmer.. I usually write DIags, kernels, and drivers..
and I have a horrible time understanding someone else's :wink:
code!

and lastly next post has some source to see it rumble
include <kos.h> to compile under KOS, or stick your
own starup code, either in line or linked, and it should
run on it's own..

and here are some effect that run on all units..

0x2617a010
0x2615F010 (+0x1000 to bring to smooth)
Car Idle (VW beetle) effect duration
Performance 6sec
topway 7sec
4Mb Rumble 2sec
Vibration Pack 2sec
Most units 2sec

0x31071011
0x31071011 (+0x1000 to bring to smooth)
Car Idle (69 Mustang )
Performance 4sec
topway 8sec
4Mb Rumble 4sec
Vibration Pack 3sec
Most units 4secs

0x3339f010
Eathquake(Vibtrate, and fade out)
Performance 5sec
topway 6sec
4Mb Rumble 2sec (no fadeout)
Vibration Pack 6sec

0x011a7010
Basic Thud (simple .5s jolt)

0x05281011
Helicopter

0x00072010
Ship's Thrust (as in AAC)
it's also a single jolt
but lower in freq, just repeat
it over and over.
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

Code: Select all

#include <math.h>

unsigned char dmabuffer[2128];

void *maple_docmd(int port, int unit, int cmd, int len, void *data)
{
  unsigned long *sbuf, *rbuf;
  int dst, src;

  src = port << 6;
  if(unit==0){
       dst=0x0020; //main perf
       }else{
      dst=0x0001; //mov 1
      dst=(dst<<(unit-1)); //sub+shl
      }
  dst=((port<<6)+dst);
  //aligned and set to UC
  rbuf = (unsigned long *) ((((unsigned long)dmabuffer+0x20)& 0xffffffe0)|0xa0000000);
  sbuf = (unsigned long *) (((unsigned char *)rbuf) + 1024);
   while((*(volatile unsigned long *)(0xa05f6c18)) & 1);//DMA Busy?
  *(volatile unsigned long *)(0xa05f6c04) = ((unsigned long)sbuf) & 0xfffffff;
  *sbuf++ = len + (port * 0x10000) + 0x80000000;
  *sbuf++ = ((unsigned long)rbuf) & 0xfffffff;
  *sbuf++ = (cmd & 0xff) + (dst * 0x100) + (src *0x10000) + (len * 0x1000000);
   if(len > 0) {
    unsigned long *param = data;
    int i;
    for(i=0; i<len; i++)
      *sbuf++ = *param++;
  }
  *(volatile unsigned long *)(0xa05f6c18) = 1;//do dma..
   while((*(volatile unsigned long *)(0xa05f6c18)) & 1);
   return rbuf;
}//end maple_docmd



 void delay(int t){ //spin sleep was causing problems..
      float x = 1;
      while(t-->0)x=cos(x);
}//end delay


void main(void)
{

  unsigned long effects[7]={0x00072010,0x011a7010,0x31071011,0x3339f010,0x2617a010,0x05281011,0x00};
  unsigned int i,params[2];
  char *res;



  //maple init

  *(volatile unsigned long *)(0xa05f6c8c)= 0x6155404f; //where did this number come from..
  *(volatile unsigned long *)(0xa05f6c10) = 0;
  *(volatile unsigned long *)(0xa05f6c80) = 0xc3500000;
  *(volatile unsigned long *)(0xa05f6c14) = 1;


//play the effects 
for(i=0;i<7;i++){

          params[1]=effects[i];
          printf("%d, %x\n",i,params[1]);
          params[0]=0x00010000; //purupuru
          do res = maple_docmd(0, 2, 14, 2, params);
          while(*res == -4);
          delay(5000000);




}//end for
}//end main

[/code]
speud
DCEmu Uncool Newbie
DCEmu Uncool Newbie
Posts: 1459
Joined: Sat Dec 27, 2003 10:40 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by speud »

thats great !
thx for sharing :)
http://blueswirl.fr.st - DC Online Tools and Downloads

thx to Wack0 for the avatar ;)
GPF
DC Developer
DC Developer
Posts: 529
Joined: Wed Oct 17, 2001 7:44 pm
Location: Texas
Has thanked: 0
Been thanked: 0
Contact:

Post by GPF »

have you taken a look at the linuxdc's Purupuru driver ? Maybe it can answer some questions or point you in the right direction.

http://cvs.sourceforge.net/viewcvs.py/l ... iew=markup

Troy
Vorrtexx
Insane DCEmu
Insane DCEmu
Posts: 138
Joined: Sun Apr 06, 2003 5:29 am
Has thanked: 0
Been thanked: 0
Contact:

Post by Vorrtexx »

Thanks for the info Kamjin
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

Sharing is good! finally get some rumble in homebrew!!
But hopefully someone can either do the purupuru driver
for KOS, or at least help get the data on the queue..
right now I'm avoiding vblanks, killing the IRQ, and
making sure DMA in not on before I write to avoid
a head but with KOS.. but I'd like to get it in there the
right way.

GPF, He's got a simmilar idea as to what I've been playing
with by streaming "playing" the rumble, feeding it starts
and stops to produce effects. kinda like a "dual shock"
just he's got one problem from what I can see his code will
only work on the 4mb rumble, and the EMS rumble,
he's writing 0x0000FFFF to the unit, that will cause
almost all to fail.. That's roughly where I started before
I hooked up the logic analyzer to get some values back..


So people are looking at the thread.. so once again any
help on getting a driver for KOS, decoding more of the
puru would be much appreciated, by everyone!!
User avatar
SinisterTengu
DC Developer
DC Developer
Posts: 382
Joined: Wed Oct 17, 2001 7:44 pm
Location: Arlington, WA
Has thanked: 0
Been thanked: 0

Post by SinisterTengu »

The linuxdc rumble driver is actually kinda useless..it was just a bug in the Naki rumble pack that allowed it to rumble. I think the Naki rumble pack would just rumble as long as any data was sent to it or something like that..it wouldn't work with any other pack besides that.

Anyways, the parameter structure that the Katana uses consists of unit, flag, power, frequency, inc (interval..?), and three reserved. All of these were uint8's. One of the test programs called inc the interval, but I couldn't really figure out what it did..the flag gets set to either continuous (1 << 0), exhalation (1 << 3), or convergence (1 << 7). Also, I dunno what unit does because if I set it to anything other than 1, no rumble occurred. There is no way to know what the Katana does with this structure really unless you disassembled the libs, and I have no idea how to do that.

I'll give any more info I can tomorrow night, but I have a calculus test to study for right now :(
Image
Image
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

I doubt dan would want any thing learned from the offical dev kit included in kos..
If so we could of had rumbled support since day one.. You dont have to do the real katana kit includes the docs and how that works in detal.. if you have the real kit you would have the printed docs not just the ones from the cd..

Any way if we used bits from that it would be easy to get working. Bu the way Kamjin did it is the proper way.

I dont think it's really right to use the katana kit to do that or we could just use it and not kos..

just my thoughts on it..
Dreamcast forever!!!
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

I see where Ian is going on this... I'd have to agree..
If we hack apart sega's work.. it would become "unlegit"
as I've gone so far it's been in the dark, find the first parameter
to rumble the unit, then play with the registers there
after..

Sinister, Thanks for the info,
you don't have to go any further, that was the main info I wanted
out of the dev kit, just to see if I'm barking up the right tree..
good luck on the test!

That tells me I've got the labels on the registers close
enough
Interval is "special effects" but only the first one works
across the board.. I've seen the cases where other
bit works, and the 1<<7 was for the 2nd motor..

it appears most of the clone rumbles were made by just hacking as well..
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

So let's change the direction of this thread..Hopefully incur
more feedback...

So what do we need..
1. A KOS driver, or at least function to send commands..

So rumble under KOS.. Here's what I tried

maple_frame_init
Lock the frame
fill a maple_frame struct..
unlock
maple_queue_frame <- I crashed here
maple_queue_remove

I played with the locking, and my data format a bit then gave up..

Anyone got a clue, what I missed?
User avatar
SinisterTengu
DC Developer
DC Developer
Posts: 382
Joined: Wed Oct 17, 2001 7:44 pm
Location: Arlington, WA
Has thanked: 0
Been thanked: 0

Post by SinisterTengu »

The code you have looks like its modelled after libronin's way of doing maple stuff. Why don't you try making your functions a bit more like KOS's kernel\arch\dreamcast\hardware\maple\vmu.c or any of the other devices in there.
Image
Image
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

You got my brain going there.. that's one thing I wasn't
doing.. my code wasn't inside the VBlank interupt..
like the other stuff in maple..
gonna try to see how he loads the drivers, maybe it
was as simple as putting the code into a driver,
or hooking it into his int. routines..
User avatar
SinisterTengu
DC Developer
DC Developer
Posts: 382
Joined: Wed Oct 17, 2001 7:44 pm
Location: Arlington, WA
Has thanked: 0
Been thanked: 0

Post by SinisterTengu »

wow, I was just able to successfully get a short rumble out using KOS by sending that effects[0] through a makeshift purupuru_rumble function modelled after the vmu_draw_lcd function. It barely lasted a second on my Performance rumble/memory card thing. I should probably get an official pack for more testing, maybe I'll check around and see if any stores around here carry them tomorrow.

I'll try prettying up the code a bit and give you what I have if you haven't figured it out yourself already. I was having problems correctly detecting a puru for some reason, I'll be messing with it for a while more before I sleep tonight. I don't have any classes tomorrow, so I can try some more tomorrow too.
Image
Image
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

Who is going to do the first Sex related dc homebrew game for gurls ? Would save all the gurls using metal gear solid demo disk ps1 version. )()(

Dangous toys edtion?
Last edited by Ian Micheal on Fri Apr 09, 2004 4:56 am, edited 2 times in total.
Dreamcast forever!!!
Viktor
DC Developer
DC Developer
Posts: 30
Joined: Sun Nov 04, 2001 4:47 am
Location: Stockholm, Sweden
Has thanked: 0
Been thanked: 1 time
Contact:

Post by Viktor »

Great work!
Because of this I have now orderd a "Dreamcast Vibration Pack" from Play-Asia for $10 (including shiping to Sweden!) :)

Tetris with Vibration support, a super hit :lol:

/Viktor
OneThirty8
Damn Dirty Ape
Damn Dirty Ape
Posts: 5031
Joined: Thu Nov 07, 2002 11:11 pm
Location: Saugerties, NY
Has thanked: 0
Been thanked: 0

Post by OneThirty8 »

Ian Micheal wrote:Who is going to do the first Sex related dc homebrew game for gurls ? Would save all the gurls using metal gear solid demo disk ps1 version. )()(

Dangous toys edtion?
Ian, you're a sick, sick man. Although I must admit I had the same thought myself.
User avatar
SinisterTengu
DC Developer
DC Developer
Posts: 382
Joined: Wed Oct 17, 2001 7:44 pm
Location: Arlington, WA
Has thanked: 0
Been thanked: 0

Post by SinisterTengu »

Purupuru Demo by SinisterTengu (April 9, 2004)

Ok, I realize this is kinda sloppy coding, but it was like 3:00AM while I was writing this ;)

Anyways, the rumble.bin included is not scrambled, so you can upload as is through dcload, or scramble it and burn it to a CD.

If you want to compile the code yourself, replace the purupuru.c in kos's kernel/arch/dreamcast/hardware/maple/ dir, and purupuru.h in kernel/arch/dreamcast/hardware/include/dc/maple/ dir with the ones provided. Then you will need to go to KOS's include dir and edit kos.h to also include <dc/maple/purupuru.h>.

The params used in the example are the ones Kamjin provided, and function like this for my rumble pack:

0 - very short half second rumble
1 - even shorter rumble
2 - several harder bursts for 3-4 seconds
3 - hard continuous rumbling for several seconds
4 - medium continuous rumbling for several seconds
5 - soft continuous rumbling for several seconds
6 - does nothing for me

Please note I am using a 3rd party Performance brand Rumble/memory card for my testing, so you may experience different results for yours. Feel free to post your experiences.

This driver is in no way complete, it only allows for a couple rumble effects. I am going to try and do some more tests and see what else I can do.

Download
Image
Image
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

OneThirty8 wrote:
Ian Micheal wrote:Who is going to do the first Sex related dc homebrew game for gurls ? Would save all the gurls using metal gear solid demo disk ps1 version. )()(

Dangous toys edtion?
Ian, you're a sick, sick man. Although I must admit I had the same thought myself.
Well Would you beleive ive had requests for a rumble pack for gurls type game.. I said only when it works in kos.. Looks like i will have to do it lol

Really metal gear solid 1 demo on ps1 is a gurls best freind ive been told lol..


I think with this new code i can replace that lol
Dreamcast forever!!!
Kamjin
DC Developer
DC Developer
Posts: 216
Joined: Wed Dec 17, 2003 5:27 am
Has thanked: 0
Been thanked: 0

Post by Kamjin »

HAHHHHA... :guffaw: BUhahhh!!!.. I've snorted coffee... that's was such a
good one and caught me by surprise :hatty: My hat's off Ian.. that
one made my day.. I've got some good titles for the game..
but.. well.. the thread will be locked..


Sinister.. good work I didn't have a chace to try myself.. gonna check
the code..
and yup 6 has to be repeated over and over.. it gives.. a low grumble..

ugh... now I can't keep from laughing.. low grumble... IAN!!!!
User avatar
SinisterTengu
DC Developer
DC Developer
Posts: 382
Joined: Wed Oct 17, 2001 7:44 pm
Location: Arlington, WA
Has thanked: 0
Been thanked: 0

Post by SinisterTengu »

Heh, I didn't realize it before, but what you were calling 6, I was calling 5 (because I included 0). I said 6 did nothing, and actually it shouldn't because its 0x00! heh, I wasn't even paying attention to that. Sorry about the confusion.
Image
Image
Post Reply