EmuNation-SC rev 940.5 Read Me

This is a version of EmuNation-sc. Needs the vc++ 2005sp1 runtime. vc++2008 is NOT backwardly compatable.

To convert from regular emunation:
	1. Install VC++ 2005 sp1 runtime, link included in zip file.
	2. Open Emunation.ini in this zip.  Cut and Paste the [sc] section to the bottom of your emunation.ini. 
	3. Copy the three EEP0x-102.bin files in the zip nagra folder to your nagra directory.
	4. Copy emunation.dll to the right plugins directory for your application.
	5. Run TV app and wait for mecm downloads (if needed), could take 30-40 minutes.

Vista users take note:
The ini file under Vista may not be in the program app plugin directory, but is in \users\{yourusername}\appdata\local\virtualstore\program files\{dvbprogramename}\plugins.  This may be true if your dvb app is in \Program Files! You may need to go into folder options and tell it to show hidden files and folders.

Latest Change:
================================================================
rev 940.5 3/4/09

Fix N3 EMM handling for cardclient. Make sure you change emm_pid_hex from 00F9 to 00EE 
in [901] section of ini file.
I think gbox works, someone test it and let me know.


File locations:
---------------
*** ProgDVB & MyTheatre & MediaPortal TV Server (TV3) ***
  {root} 
    pthreadVC2.dll   {VC++ support file}

  {root}\Plugins 
    EmuNation.dll
    EmuNation.ini
    Softcam.key      {see sample for required keys}
    FFDecsa_32_INT.dll {Required for MyTheatre 4.0}

  {root}\Plugins\Nagra    
    Rom102.bin       {ROM 102 bin file - 98304 bytes}
    EEP01_102.bin {Dish rev10B - 18432 bytes)
    EEP08_102.bin {Bev rev147 - 18432 bytes)
    EEP09_102.bin {Bev rev147 - 18432 bytes)

*** DvbDream ***
  {root}
    pthreadVC2.dll {VC++ support file}

  {root}\Plugins\Pip00
    EmuNation.dll
    EmuNation.ini
    Softcam.key {see sample for required keys}

  {root}\Plugins\Pip00\Nagra 
    Rom102.bin {ROM 102 bin file - 98304 bytes}
    EEP01_102.bin {Dish rev10B - 18432 bytes)
    EEP08_102.bin {Bev rev147 - 18432 bytes)
    EEP09_102.bin {Bev rev147 - 18432 bytes)

*** TSReader ***
  {root}
    FFDecsa_64_MMX.dll
    pthreadVC2.dll   {VC++ support file}

  {root}\MDPlugins
    EmuNation.dll
    EmuNation.ini
    Softcam.key      {see sample for required keys}

  {root}\MDPlugins\Nagra    
    Rom102.bin       {ROM 102 bin file - 98304 bytes}
    EEP01_102.bin {Dish rev10B - 18432 bytes)
    EEP08_102.bin {Dish rev147 - 18432 bytes)
    EEP09_102.bin {Bev rev147 - 18432 bytes)

Please make sure the names are EXACTLY as they are shown above for your provider! 
The ROM102.bin has an md5sum ('md5sum ROM102.bin') of: f05c2feeec184c6c5f3f327a90712b09 

Additionally for Mediaportal TV Server you must install and register Agarwals MDAPI filter.
You can find the filter, as well as instructions on how to install it, on DVBN

To run multiple programs (MT and TSR for example), or multiple PIP instances (Dream for example):
  - Place all the emunation files (except emunation.dll and emunation.ini) and the 
    nagra subfolder in a folder somewhere
  - Place the pthreadVC2.dll file where it needs to be for your application(s) (see above).
  - Put the EmuNation.dll and EmuNation.ini files in the (MD)plugins directory as shown above.
  - Modify each EmuNation.ini file so that the S_K_location= entry points to the 
    folder that you created in the first bullet.
  - The MECM files, softcam file etc. will now all be shared among all of your applications.

Tested with the following:
-------------------------
Alt-DVB
DVB Dream
MediaPortal TVServer with Agarwals MDAPI Filter (DVB-S only)
MyTheatre
ProgDVB
RitzDVB
TSReader

History:
================================================================
================================================================
rev 940.4 2/27/09
Fix for map2e, probably some other changes i have forgotten about, lol.

rev 940.3 2/7/09
Fix for DVBPlus to take advantage of info passed by app, 
fix for dvbPlus emm processing when using cardclients.
Renamed st19com ini entry to SmartCartPort and moved to [EmuNation] to stay
in sync with regular emunation. Set to nonexistent port if not using smartcard.

rev 940.2 2/3/09
Loop condition when using a motor and cardclients found and fixed.
Smartcard startup message changed to be less confusing for those not using it.
EMM Processing startup bug fixed.
Map 23 bug fixed.

rev 940.1 1/22/09
Fix for dn latest.
Fix for crash on exit if dll not active, thanks anon.
Other minor lil changes here and there.

rev 940.0 1/18/09

Bug Fixes. Improved thread locking, thanks to anon.
EMM added to radegast.
EMM bug fix, PMT bug fix, minor changes to cardclient console messages.
Caid improvements, fix for dvbdream and mediaportal.
The encypted to fta channel change bug may finally be fixed. A few more
memory leaks fixed.

rev 939.9 1/14/09

New File Mapping system, thanks to anon.
Bugfixes courtesy of other patrons of the arts.
A few memory leaks plugged.

rev 939.8  1/11/09

fix for dn latest
emm processing for newcamd, use this on your own server or with server owner's permission ONLY!!
a few other lil fixes and things

rev 939.7 1/8/09

Dirty fix DvbDream when connected to Bev via newcamd.
Fix for DN latest

rev 939.6 1/3/09

Fixed a lil error I introduced into map3e while fixing map46. 
Configurable priorities, see 938.7 below, fixed to now work with multiple system ids. 
Providers.conf never worked right and support has been dropped.
Radegast and newcamd cardclients fixed. Sample .conf file added.
New [SC] ini entry CCDump turns on/off raw data dumps to console for cardclient and smartcard.
ST19Com and ST19Echo settings activated in ini.  Set ST19Com to nonexistant port if the smartcard interface is not in use.  You can ignore the Com port opening error if not in use.

Be sure you have a Nagra3=-15 or something, as there are n3 stubs that show as a valid protocol (wishful thinking). N3 ca-ids are valid for cardclient n3 cardsharing, if supported by your server.  Be careful of unintended consequences, on gc irdeto is sometimes a valid protocol, but i bet you don't have valid keys. Check your ini against the distribution file. All priorities are negative numbers. -3 is higher than -5. No number may be less -20 nor higher than -1.

You can change between smartcard, cardclient and native code on the fly by inserting/removing card and retuning the channel, if priorities are set appropriately.  You can not change priorities on the fly.

Finally, before you say cardclient doesn't work, check your firewall settings.

rev 939.5 12/14/08

Fix for Map 46.

rev 939.4 12/9/08

Rename the dll is back, any name will do. ini file must be the same as dll. See notes from 938.5 and 938.7. Works with TSR too.
Added map timing tracker, console map display will show timings added to the tracker, announce timing changes. Tracker resets on channel change.

rev 939.3 
Added map 3d (no release package was made).

rev 939.2 11/11/08

Fix for freezing on map3c.
Fix for emm processing on startup in DVBPlus.

rev 939.1
Added set computer time and date from the sat stream.  Never have a recording start at the wrong time again. New ini file entry needed under [Menu Options] SetClock=1 to set the clock on first channel tune. Menu item, under 'options', turns function on/off and menu item to set clock now.

N.B. Your computer is keeping its clock in UTC, formerly known as GMT.  Windows calculates local time from UTC. Depending on your time zone, its 'tomorrow' around 7:00 or 8:00 in the evening. Console display of time set is in UTC, so don't be surprised by it being 'tomorrow' before it seems to be so, in your local time.

N.B. Vista users, program app must "Run As Administrator" for time set to work.  If you have not already been running as admin you MAY need to copy the contents of \users\{yourusername}\appdata\local\virtualstore\program files\dvbprogramname\ including its subdirectories to \program files\{dvbprogramname} to maintain your settings.

If you don't want to futz with this just SetClock=0 in your ini and the whole thing will be ignored.


rev 939.0 10/29/08
Fix for bev bad key packets.

rev 938.9 10/27/08
More better fix for changing channels encrypted->fta. Better killing off old ecm and emm filters.

rev 938.8
Fix my fix for changing channels from encrypted to unencrypted. It broke apps other than the one the fix was intended for.

rev 938.7
Bugfix changing channels from encrypted to unencrypted. Fix race condition affecting certain apps killing off filters on channel change. Configurable priorities for different protocols, all numbers are negative, -3 is higher priority than -5. See new entries in sample .ini file. Set for your most common protocol to have highest priority and channel changes will be faster as it wont have to test other protocols to find the right one. Making this work has broken the ability to find ini files named other than emunation.ini.  I'll have to figure out  how to fix it. Until I do the .INI file MUST be named emunation.ini.

rev 938.6
Fix method of calculating provider id in ecm because bev is using caid 1801 again, ignore 1802 for GC.
Rewrite nagra files to make compatible with linux. Source files now can be used in either system.
Fix a lil problem in MyTheatre usage. Found some spelling errors in console messages.
Added FFDecsa_32_INT.dll to distro package, required for beta MyTheatre 4.0 releases.

rev 938.5

Improved map 3e.
Added map 3c and 3b.
Improved brute force. Faster channel changes.
Found some console messages that were in EMU that should be in MAP. Added some EMM messages.
Eliminated menu item conflicts with EmuNation. Added ability to rename the .dll to whatever you want.
Removed  EMM % line from the console.

If you do rename it you MUST rename .ini to follow.  i.e. if you rename emunation.dll to sc.dll you MUST rename emunation.ini to sc.ini. This does NOT work with TSReader, leave it emunation.ini.

Added console menu and ini entry under [sc] to allow/disallow duplicate messages to repeat in the console.
Dupes=0 means no dupes allowed and the message "last message repeated 99 times" will appear for identical messages repeating.  Dupes=1 allows dupes.  Use this in conjunction with "hide bad messages" under menu options. If there is only one map in the stream, you may want to see it repeat, or if bad messages are off, you may want to see all the "MECM code packets" repeat in nagra.emm.  Hide bad messages off and allow dupes produces a lot of messages.

rev 938.4
Better fix for Map25 and other timings.

rev 938.3
Fix for map25.
Merge irdeto2 changes from sc repository.
Add western position to channel lock display in console.
Add message and beep to console on active key change.

rev 938.2
EMM-S implemented, just in time for football season. Softcam.key template for EMM-S added to sample file included.  There are no public numbers for EMM-S, you'll have to find/get your own if/when bev starts using EMM-S again.

rev 938.1
Merge Irdeto changes from sc repository.
Add Irdeto2 support from sc repository. See file "irdeto softcam example.txt" for softcam format.

rev 938.0
Added beeps to MECM writes, one set per chunk. "MECM Write in progress" message.
Added "Found ignored CA type" message.
Corrected some spelling errors in messages. Brought more messages into sc's method of messaging.

rev 937.0
Changed the EMM % line in the console to switch on/off with EMM console display switch. 
Excluded nagra.map messages from the "last message repeated x times" so that when there is just one map call in the stream, you will always see the message.  
Better fix for TSReader startup problem. 
Too rapid a channel change caused picture delay, fixed, faster channel changes too. 
Console window now resizable.

rev 936.0
Fix for latest from DN.  Fix for startup in TSReader.

rev 935.5 
Restore Map57 brute force, thanks to many for the help.
Minor adjustment tp frequency calculation to prevent problems with dual tuner dp setups in the future. 
Merge Leslie's sc changes to rom10/nagra1 and constcw.

rev 935.4
Fix dn action

rev 935.3
Fix my error preventing MyTheatre menus from working correctly.

rev 935.2
Correction for the latest DN action. 

rev 935.1

Added menu switch and ini file setting to be able to turn PMT processing on and off.  Use this with ProcessEMM to speed up channel changes. Remember that if you turn off EMM processing you will not roll keys.
New ini setting under:
[Menu Options]
ProcessPMT=0/1
If you don't add it, it will add itself the first time you use the menu switch.

Remember that the ini file under Vista may not be in the program app plugin directory, but is in \users\{yourusername}\appdata\local\virtualstore\program files\dvbprogramename\plugins.  This will be true if your dvb app is in \Program Files!
Most programs will pass PMT to the plugin without the need for the plugin doing it.  See how it works with your DVB viewer app.  The default is off.

A bit more consolidation of the console display. A bit more use of info passed from the app for figuring out which sat and tp you are watching.  This will lead to better CAID processing.

Fixed a bug where in the monitor, the provider and provider id did not show up until the channel was changed.

rev 935.0
cleaned up some console display. Modified map control system.  nagra2-4101, 0501 and 1101 re-included. 
Fix identification of older versions of ProgDVB which fixes crash when tuning to certain FTA channels.  Thanks to Skywise@UICN for helping to find this one.

rev 934.4
show disasm80 option fixed

rev 934.3
Fixed mecm file writing I had broken in last version.  Added Nagra4101 and 0501 back into compile, I have no idea if they work. Show disassembly still broke, but not crashing the program anymore.

rev 934.2
broke 907 key processing, fixed.

rev 934.1
Seems I got the interrupt system working. Moved the menu item for console controls up a level to make them easier to get to.

rev 934.0
This is an experimental private release of mfong's interruptable map system into emunation-sc. Also, with the demise of the public emunation-sc respository the version numbering basis has ceased to exist, so I am going to continue the same numbering, but it no longer references back to anything and represents major and minor revisions of my own code.

rev 933.4
fix what i'd broke in map 31

rev 933.3
map3e fix

rev 933.2
map21 fix

rev 933.1
map3a and various timing fixes, finally. Thanks to certain patrons of the fine arts.

rev 930.4
Fix Map31, changed console window to read Emunation-SC, an unsupported map call was part of the console emu display, not part of the console map display, so I changed it to display on the map switch.

rev 930.3
merge various fixes from various sources to improve various map handling.  Serial port changes on the way to making st19 work with emun-sc.  It's not there yet, but if you have st19, emun-sc will be talking on com3. I think the problem is in emun-sc's serial routines still, but its close. Masochists should feel free to play.

rev 930.2
Fix map30

rev 930.1
merge from repository, some changes to math, otherwise just to stay in sync. No changes to other files.

rev 918.2
map 2A thanks to all

rev918.1
map30 implemented, thanks to those engaged in the discussion in the linux forum on dvbn.

I decided that following C0dem0nkey's number system is confusing to newbies.  These files do not derive from C0dem0nkey's, they derive from SLJ's repository so henceforth I'll use SLJ's latest public rev number plus a sub number representing the level of my changes from whats public.

3.0.3.5f
Various MAP and timing updates from mfong

3.0.3.5e
Replaced quick hack of sc's crc routine with port of mfong's timer and crc routines.
Before you say it doesn't work make sure you have pointed s_k_location where it belongs.

3.0.3.5d
Well, that didn't last long!
Fix sc's CRC routine

3.0.3.5c
I took SLJ's suggestion and created an [SC] section of the ini file. The new controls belong there and are renamed to Show* instead of Log*. Be sure to look at the .ini included here and either c&p or whatever. Better to make the new section now than to keep adding things and make a bigger mess to clean up later.  


[SC]
ShowEMM=0		;Console Messaging of EMM MEssages (0=off/1=on)
ShowECM=0		;Console Messaging of ECM Messages (0=off/1=on)	
ShowRAWEMM=0		;Console Messaging of Raw EMM Messages (0=off/1=on)
ShowRAWECM=0		;Console Messaging of Raw ECM Messages (0=off/1=on)
ShowMAP=1		;Console Messaging of MAP Calls (0=off/1=on)
ShowEMU=0		;Console Messaging of EMU Details (0=off/1=on)
ShowKEY=1		;Console Messaging of Key reads/writes (0=off/1=on)
ShowDISASM80=0		;Console Messaging of Disassembly (0=off/1=on)
ShowCPUStats=0		;Console Messaging of 6805 CPU Stats (0=off/1=on)
ShowCrypto=0		;Console Messaging of Decryp Messaging (0=off/1=on)


New menu control for console show options that lets you change the console display options on the fly.  Two more options added: CPUStats and Crypto.  Log Console to file is also now functional. Options follow the display options. The EMM 100.00%: 360447 etc. etc. line does not print to file.  CPUStats is broken and, upon analysis, does not look like it will supply any useful information, so I'll probably kill it off next time around.

Incorporated latest repository updates.

3.0.3.5b
Incorporated an mfong bugfix slj pushed out to the public repository.  Fixed a bug I introduced which prevented 907 keys from being picked up.

3.0.3.5  map 32 fix

sc has a bit different console logging from emunation, and as folks playing with source know in main.ccp you can control the type of messages provided.  There are 8 of them.  I have added them to .ini file control so peeps playing with compiled versions can also adjust the messaging in the console. Thanks to chuck35@dvbn for the idea.

I know slj wants these to follow sc build numbers, but i am doing a few things he is not and don't have access to his latest to know what this is equivelent to. 

The files included aren't really needed, except that they are up-to-date as of the moment of release.
 
3.0.3.4c - same as b except has the emm update from emunation 2.x as below. I forgot to put it in earlier.

3.0.3.4b - SLJ adopted some of the changes I had made, so this version is closer to his version of the code.  I have added the code to make the monitor window work.

Finally, sc saves and monitors keys differently than regular emunation, when running mutliple programs using a shared softcam.key file simulataneously (i.e. over a network) the other instances ought to pick up that the file has changed and go to the new key.


3.0.3.4a - numbered to track regular emunation. Updated for latest code change.
I have numbered it as 3.0.3.4a only because it works on all providers as does the current version of regular Emunation. It has no relation to the current release of Emunation and is based solely on the most recent public release of Emunation-sc source code.

What I have done here is:

S_K_Location in the ini file is used to point ALL file access to a location, not just the softcam.  For example, if S_K_Location=c:\dvbdream\plugins\pip00  then other programs can use the files in that location, all you need in the other program's plugin folder is the .dll and the .ini pointing back to the common directory. Similarly, in DvbDream there is no need for 19 copies of the nagra folder in all the various pip folders.  The advantage is not only not having to copy all them files, more better is no need to keep all them other binary files updated with each new mecm, etc.

Restored functionality to the monitor screen

Restored beep on new key

Although aux works, it has no function right now without map57 in the stream.

Needs vc++ 2005sp1 runtime

I have included my nagra folder because, if you have been using regular emunation, the mecm are written to seperate files.  sc uses the eep files, so you won't have to wait for updates.

********
I have updated the version number to track CodeMonkey's release of the same file version concept.

Ported over and added the improved EMM processing from 3.0.2.x emunation.

Most importantly: i missed the lil spinner in the Monitor window for emm processing, so i fixed that.

YMMV