Developers Blog
===============

This file is mainly an R&D document containing developers findings. The aim is
 to have it as much accurate as possible. Each item has to contain a number(ID),
 the name of developer, revisions history and a short description.
Also, this document will serve as a pinboard - will contain coding rules,
 explanations on implementation of different parts of the emulator, suggestions,
 questions and ideas.


==============================================================================
==============================================================================
==============================================================================

[ ID ] 4
[name] Florin
[desc] PS2 info dumping project
[hist] 2006-05-08 initial version

The emulator needs some information from a Playstation2 console.
We used to require the 'bios' software. In order to get better results
 more and more information was needed. So here are some guidelines
 on what we need and what we don't need from the console.
Also, a new dumper and handling of these infos in the emu are in work.

a. The so-called 'bios', is actualy rom0 found in consoles, devkits,
   test-kits and PSX at address 0xBFC00000 on both EE and IOP.
   [!] Note that on 75xxx the EE side bios mismatch zone fields,
       so it is recomended to make a IOP side dump.
b. Rom1 and Erom contain DvdPlayer related software and are located
   starting with 0xBE000000 on PS2s from 18000 and up. Over various
   versions, the size of rom1 and size and position of erom changed.
   They used to be dumped separately, the new dumper will simplify this,
   there'll only one file containing both rom1 and erom (2M or 4M).
   [!] Note that on 70xxx and 75xxx (PStwo's) the dumping of erom from EE
       is not possible, the correct dump is done only from IOP!
   [!] rom1 and erom are identical for same generation for all zones.
   In order to be able to run the dvdplayer code in the emulator, it needs
   to be pre-decrypted. EROMDRV and DVDELF will have some 'decrypt' patches.
c. NVM (Non Volatile Memory) is 1K of code and provide valuable info about
   console model and region. 10000 and 15000 don't contain the model name.
   PStwo's contain the zone codes making possible to have a single version
   of the rom for all zones.
d. Rom2 is found only in Chinese PS2s (50009, 70009...) and contains
   a font file: GB18030. It is located at 0xBE400000. It was (w/o
   justification) assumed that it is as big as rom1. There is no need to
   dump it on any other console than chinese. The size is to be calculated
   from the filesystem (as rom0 and rom1, it has romfs).
e. BBA (BroadBand Adapter) info is not needed to be dumped. At least not
   for the emulator itself, maybe for the DEV9 plugin. Anyway, it's just
   a MAC address that can be made up.
f. The current dumper is reading CDVD Mecha version. This will be replaced
   by a more complete information file that will contain the following info:
   from [EE]
	CPU revision - revision code from COP0->PRId register
		easier read from (u16)GetCop0(15)
		high byte is 0x2E for EE
		low byte is: high nibble major, low nibble minor of revision
	FPU revision - revision code from COP1->control register 0
		same description as for cpu PRId
	VUs revision - hum, i'm not aware of any revision for them :(
	VUs memory   - local and micro memory sizes are not detected
	GS  revision - upper halfword in CSR register
		high byte is ID = 0x55
		low bytes is major.minor (per nibbles)
	GS mem       - is 4M
	IPU revision - hum, i'm not aware of any revision for IPU :(
	Caches       - instruction and data cache sizes are read from
		COP0->Config register
		easier read from GetCop0(16).
	MEM          - total RAM available
		easier read with Syscall +127 - GetMemorySize()
		the values are: 32M for console and test-kits,
		128M for devkits and 64M for PSX
		the size is not roughly detected. As devkits have multiple
		boot modes (128M or 64M).
   from [IOP]
	CPU revision - revision code from COP0->PRId register
		high byte seems to be 0
		low byte is major.minor (per nibbles)
		initial japs have major=1,
		most of the consoles have major=2,
		75xxx have a new IOP processor with major=3
	Caches       - are known to be 4K-I$; 1K-D$
		0xFFFE0130 is CACHE_CONFIG register...
	MEM          - total RAM available
		easier to read with QueryMemSize()
		the values are: 2M for consoles and test-kits,
		8M for devkits and PSX
		again, the size is incorrectly read :)
	SPU mem      - 2M (any method of detection?)
	CDVD mecha   - version of CDVD controller
		Scmd 0x03 with subcode 0x00 (outsize=4)
		the first byte is the MG-encryption code
		second is major, third is minor, fourth is [2b completed]
	     meka    - i don't know; not supported on early consoles
		Scmd 0x03 with subcode 0x90 (outsize=1+1)
	DEV9 revision- type of DEV9 device: 0x2x for PCMCIA, 0x3x for EXPBAY
		*(vu16*)BF80146E
	USB OHCI rev - Hc_revision of the OHCI controller
		*(vu32*)0xBF801600
	ILINK rev/id - I'm not sure of this one, on ps2's that don't have
		firewire anymore, the value is 0xFF; on 10000 is random
		*(vu32*)0xBF808480 and *(vu32*)0xBF808500 (looks like mirror)

g. The dumper will sign the dumped content, so John Doe cannot play easily
   with the bios data ;) The emu works correctly with good data/food.

h. I'm thinking of a method to check for modified content (dumps made with a
   chipped console). Probably, it will be done in the emu and presented as a
   warrning.


==============================================================================
==============================================================================
==============================================================================

[ ID ] 3
[name] auMatt
[desc] PS2 NVM Data not 100%
[hist] 2006-05-07 initial version

             v0-v8   v9-    Bits   Bytes 
͹
͹
PS1 Disc Spd  0x300  0x2c0               
PS1 Texture   0x300  0x2c0               
Video Output  0x300  0x2c0               
SPDIF         0x310  0x2c0    0          
A/R           0x310  0x2c0  1 & 2        
Language      0x311  0x2c1   All         
TimeZone      0x312  0x2c2               
Summer Time   0x312  0x2c2    3          
Time Format   0x312  0x2c2    5          
DateNotation  0x312  0x2c2  6 & 7        
TimeZone      0x313  0x2c3   All         
TimeZone      0x315  0x2c5   All         
Model Number  0x1a0  0x1b0           16  
Console ID    0x1c8  0x1f0           8   
ILink ID      0x1c0  0x1e0           8   
Date Stamp    0x180                  16  
Date Stamp    0x1e0                  16  
Date Stamp    0x1f0                  16  
Rem. Control         0x2c4    5          
Checksum      0x31f  0x2cf   All         

Checksum is calculated by the previous 15 bytes added together, then ANDed with 0xFF
Serial Number of Console can be obtained from bytes 7,6 & 5 of the Console ID in dec.


==============================================================================
==============================================================================
==============================================================================

[ ID ] 2
[name] Florin
[desc] PS2 bios versioning
[hist] 2006-04-30 initial version

MG zone - the MagicGate decryption zone. You can find the code as one of the bits
	  in the byte at offset +1C in MagicGate encrypted files
PS1 drv - the letter for PS1VERx files in PStwo rom0
ROMVER  - has the following format VVvvZTYYYYMMDD in 14 bytes
	  VV, vv are the version of the bios in BCD
	  Z is zone code, see below
	  T is type of the console: C - consumer console, D - devkit/test console
	  YYYYMMDD is date of the bios
	- BxDATA-SYSTEM, BxEXEC-SYSTEM, BxEXEC-DVDPLAYER uses Z code in place of 'x'
	  I: default, Japan; A: Usa, Asia; E: Europe, Oceania, Russia; C: China
VERSTR  - the code from that file in rom0
OSDVER  - VVvvZlng is the format of the file for scph5xxxx. in PStwo the last 4 letters
	  are read from NVM, offset +180 7 chars (ROMVER:1|OSDVER:4|VERSTR:1|DVDID:1)
mecha   - version read from CDVD SCmd 0x03:0x00

The following table is far from complete...

         Japan  USA  AusNz   UK  EuropeKorea   HK  TaiwanRussiaChina Mexic 
͹
͹
MG zone   0/J   1/U   3/O   2/E   2/E   4/A   4/A   4/A   5/R   6/C   7/M  
PS1 drv    J     A     E     E     E     H     H     H     E     C     A   
ROMVER   0 J   1 A   2 E   2 E   2 E   1 H   1 H   1 H   2 E   3 C   1 A   
VERSTR     J     A     E     E     E     J     J     J     E     J     A   
OSDVER   0 Jjpn1 Aeng2 Eeng2 Eeng2 Eeng5 Kkor6 Htch6 Htch4 Rrus3 Csch Aspa?
Ķ
v0   scph10000 Ķ
    mecha0.12.0Ķ
      ver0100JCĶ
     date000117Ķ
     scph15000 Ķ
    mecha0.18.0Ķ
      ver0101JCĶ
     date000217Ķ
     scph18000 Ķ
    mecha0.22.0Ķ
      ver0120JCĶ
     date001027Ķ
͹
v1   scph30000 30001 Ķ
v2       30000 30001 Ķ
v3       30000 30001 30002 30003 30004 Ķ
͹
v4   scph30000 30001 30002 30003 30004 Ķ
    mecha                              Ķ
      ver                  0120EC      Ķ
     date                  000902      Ķ
         35000 35001 35002 35003 35004 35005 Ķ
͹
v5       30000 30001 30002 30003 30004 30005             Ķ
     scph30000R30001R30002R30003R30004R30005R30006R30007RĶ
    mecha0.32.0            2.32.0                        Ķ
      ver0160JC            0160EC0160EC                  Ķ
     date011004            011004011004                  Ķ
v6                                                       Ķ
͹
v7   scph37000 Ķ
         39000 39001 39002 39003 39004 39005 39006 39007 39008 Ķ
    mecha      1.36.0                                          Ķ
      ver      0160AC                                          Ķ
     date      020207                                          Ķ
         Ĵ39001NĴ39010N
Ķ
v8   scph39000 Ĵ39006 Ķ
    mecha0.38.0                                                            
      ver0160JC                                                            
     date020426                                                            
͹
v9   scph50000 50001 50002 50003 50004 50005N50006 50007 50008 50009 Ķ
         Ĵ50001NĴ50010N
         55000 Ĵ55005N55006 55007 Ķ
Ķ
v10  scph      50001 50002 50003 50004       50006 50007       50009 50010 
    mecha                                    4.54.04.??.0      6.??.0      
      ver                        0190EC      0190HC0190HC      0190CC      
     date                        030623      030623030623      030623      
v11                              50004                                     Mexic  USA
ͻ
v12  scph70000 Ĵ70002 70003 70004 70005 70006 70007 70008 70009 Ĵ70011 70012 
    mecha      Ĵ3.62.02.62.02.??.0      4.64.0      5.??.0      Ĵ      1.60.0
      ver0200JCĴ0200EC0200EC0200EC      0200HC      0200EC      Ĵ      0200AC
     date040614Ĵ040614040614040614      040614      040614      Ĵ      040614
v13  scph      70001 70002 70003 70004                                     ͼ
͹
v14  scph75000 75001 75002 75003 75004 75005 75006 75007 75008 Ĵ75010 
    mecha      1.66.03.66.0                                    Ĵ      
      ver      0220AC0220EC                                    Ĵ      
     date      050620050620                                    Ĵ      
Ľ


==============================================================================
==============================================================================
==============================================================================

[ ID ] 1
[name] Florin
[desc] CVS management rules
[hist] 2006-04-30 initial version

Please do not commit on CVS temporary files or those made by development tools
 (IDEs). Eg: *.suo/aps/opt/plg/ncb/exp
Keep it clean and before commiting a new module see the previous structure and
 naming rules. If unsure about how to do any opperation please ASK. please ASK!
There's no rush ;)
Also, I'm considering switching to SVN, as CVS seems to be *abandoned* by
 sourceforge.net
Any change to sources has to be commited to the public CVS. The risk of
 stealing is faced by any open-source developer - the difference is the
 quality! The original will always stand up ;)
Try not to break the source by your patches. Although linux and 64-bit versions
 are not maintained atm, your changes should be done with all versions in mind.
Happy coding :)
