Previous 199869 Revisions Next

r24688 Friday 2nd August, 2013 at 23:53:42 UTC by David Haywood
reworking it so we can start to use the parser in the actual protection routine (nw)
[src/mame/includes]pgm.h
[src/mame/machine]pgmprot_igs027a_type1.c

trunk/src/mame/machine/pgmprot_igs027a_type1.c
r24687r24688
18631863   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x400000, 0x400005, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_r),this), write16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_w),this));
18641864}
18651865
1866DRIVER_INIT_MEMBER(pgm_arm_type1_state,puzzli2)
1867{
1868   pgm_basic_init();
1869   pgm_puzzli2_decrypt(machine());
1870   arm_sim_handler = &pgm_arm_type1_state::command_handler_puzzli2;
1871   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x500000, 0x500005, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_r),this), write16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_w),this));
1872   m_maincpu->space(AS_PROGRAM).install_read_handler(0x4f0000, 0x4f003f, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_protram_r),this));
1873   m_irq4_disabled = 1; // // doesn't like this irq??
18741866
1875//#define PUZZLI2_LEVEL_STRUCTURE_LOG
1876#ifdef PUZZLI2_LEVEL_STRUCTURE_LOG
1877   UINT8 *src2 = (UINT8 *) (machine().root_device().memregion("maincpu")->base());
1878   UINT8 new_puzzli2_level_decode[256];
18791867
1880   for (int i=0;i<256;i++)
1881      new_puzzli2_level_decode[i] = puzzli2_level_decode[i];
18821868
1883   int offset;
1884   int limit;
1885   UINT8 coverage[256]; // coverage is how much of the table we've managed to verify using known facts about the table structure
1886   for (int i=0;i<256;i++)
1887      coverage[i] = 0;
1888
1889   if (!strcmp(machine().system().name,"puzzli2"))
1869int pgm_arm_type1_state::puzzli2_take_leveldata_value(UINT8 datvalue)
1870{
1871   if (stage==-1)
18901872   {
1891      offset = 0x17ab66;
1892       limit = 476;
1873      printf("%02x <- table offset\n", datvalue);
1874      tableoffs = datvalue;
1875      tableoffs2 = 0;
1876      stage = 0;
18931877   }
18941878   else
18951879   {
1896       offset = 0x16c3ca;
1897       limit = 500;
1898   }
1880   
1881      UINT8 rawvalue = datvalue;
1882      UINT8 tableloc = (tableoffs+tableoffs2)&0xff;
1883      rawvalue ^= puzzli2_level_decode[tableloc];
18991884
1885      tableoffs2++;
1886      tableoffs2&=0xf;
19001887
1901   for (int i=0;i<limit;i++)
1902   {
1903      UINT32 val1 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0);
1904      offset += 4;
1905      UINT32 val2 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0);
1888      if (stage==0)
1889      {
1890         stage = 1;
19061891
1907      int stage = 0;
1892         // this seems to be the first thing returned back when reading the level structure always seems to be 0x8 or 0x7, makes sense, levels would be too difficult otherwise ;-) (actually puzzli2 seems to have one specifying 5 unless it's a decrypt table error?!)
1893         depth = (rawvalue & 0xf0);
1894         numbercolumns = (rawvalue & 0x0f);
1895         numbercolumns++;
19081896
1909      printf("(%d) data range %08x %08x\n", i, val1, val2);
1897         printf("%02x <- Sizes (level depth %01x) (number of columns %01x)", rawvalue, depth>>4, numbercolumns);
19101898
1911      int tableoffs = 0;
1912      int tableoffs2 = 0;
1913      int entries_left = 0;
1914      int currentcolumn = 0;
1915      int num_entries = 0;
1916      int full_entry = 0;
1917      int prev_tablloc = 0;
1918      int x  =  0;
1919      int numbercolumns = 0;
1920      int depth;
19211899
1922      for (x=val1; x<val2;x++)
1923      {
1924   
1925         if (x==val1)
1926         {
1927             printf("%02x <- table offset\n", src2[x^1]);
1928             tableoffs = src2[x^1];
1929             tableoffs2 = 0;
1930         }
1931         else
1932         {
1933   
1934            UINT8 rawvalue = src2[x^1];
1935            UINT8 tableloc = (tableoffs+tableoffs2)&0xff;
1936            rawvalue ^= puzzli2_level_decode[tableloc];
1900         if ((depth != 0x80) && (depth != 0x70) && (depth != 0x50))
1901            fatalerror("depth isn't 0x5, 0x7 or 0x8");
19371902
1938            tableoffs2++;
1939            tableoffs2&=0xf;
19401903
1941            if (stage==0)
1942            {
1943               stage = 1;
19441904
1945               // this seems to be the first thing returned back when reading the level structure always seems to be 0x8 or 0x7, makes sense, levels would be too difficult otherwise ;-) (actually puzzli2 seems to have one specifying 5 unless it's a decrypt table error?!)
1946               depth = (rawvalue & 0xf0);
1947               numbercolumns = (rawvalue & 0x0f);
1948               numbercolumns++;
1905         // it seems to use this to specify the number of columns, ie how many data structures follow, so that the ARM knows when to send back the 'finished' flag.
1906         // it also gets returned at the end with said flag
1907         if ((numbercolumns != 0x6) && (numbercolumns != 0x7) && (numbercolumns != 0x8))
1908            fatalerror("number of columns specified isn't 6,7, or 8");
19491909
1950               printf("%02x <- Sizes (level depth %01x) (number of columns %01x)", rawvalue, depth>>4, numbercolumns);
1910         printf("\n");
19511911
1912      }
1913      else if (stage==1)
1914      {
1915         printf("%02x <- Number of Entries for this Column (column is %d) (xor table location is %02x) ", rawvalue, currentcolumn, tableloc);
1916         stage = 2;
1917         entries_left = (rawvalue >> 4);
1918         full_entry = rawvalue;
1919         prev_tablloc = tableloc;
19521920
1953               if ((depth != 0x80) && (depth != 0x70) && (depth != 0x50))
1954                  fatalerror("depth isn't 0x5, 0x7 or 0x8");
1921         num_entries = entries_left;
19551922
1923         if (num_entries == 0x00)
1924         {
1925            printf("0 entries for this column?"); // seems a valid condition based on the data
1926         }
19561927
19571928
1958               // it seems to use this to specify the number of columns, ie how many data structures follow, so that the ARM knows when to send back the 'finished' flag.
1959               // it also gets returned at the end with said flag
1960               if ((numbercolumns != 0x6) && (numbercolumns != 0x7) && (numbercolumns != 0x8))
1961                  fatalerror("number of columns specified isn't 6,7, or 8");
19621929
1963               printf("\n");
1930         printf("\n");
19641931
1932               
1933      }
1934      else if (stage==2)
1935      {   
1936         printf("%02x <- Mask value equal to number of entries (xor table location is %02x)", rawvalue, tableloc);
1937         stage = 3;
1938
1939         //
1940         if (entries_left == 0)
1941         {
1942            // for 0 entries skip back to state 1 instead of 3, because there is nothing following
1943            stage = 1;
1944            currentcolumn++;
1945
1946            coverage[tableloc] = 1;
1947            if (rawvalue!=0)
1948            {
1949               printf(" invalid mask after 00 length?");
1950               // attempt to correct the table
1951               //new_puzzli2_level_decode[tableloc] = new_puzzli2_level_decode[tableloc] ^ rawvalue;
1952
19651953            }
1966            else if (stage==1)
1954            coverage[prev_tablloc] = 1;
1955            if (full_entry!=0)
19671956            {
1968               printf("%02x <- Number of Entries for this Column (column is %d) (xor table location is %02x) ", rawvalue, currentcolumn, tableloc);
1969               stage = 2;
1970               entries_left = (rawvalue >> 4);
1971               full_entry = rawvalue;
1972               prev_tablloc = tableloc;
1957               printf(" previous value wasn't 0x00");
1958            }
19731959
1974               num_entries = entries_left;
1960            if (currentcolumn==numbercolumns)
1961            {
1962               return 1;
1963            }
1964   
1965         }
1966         else
1967         {
1968            if (num_entries> 0xa)
1969            {
1970               printf(" more than 10 entries?");
1971            }
1972            else
1973            {
1974               coverage[tableloc] = 1;
19751975
1976               if (num_entries == 0x00)
1976               int desired_mask = 0;
1977
1978               if (num_entries==0x00) desired_mask = 0x00;
1979               if (num_entries==0x01) desired_mask = 0x01;
1980               if (num_entries==0x02) desired_mask = 0x03;
1981               if (num_entries==0x03) desired_mask = 0x07;
1982               if (num_entries==0x04) desired_mask = 0x0f;
1983               if (num_entries==0x05) desired_mask = 0x1f;
1984               if (num_entries==0x06) desired_mask = 0x3f;
1985               if (num_entries==0x07) desired_mask = 0x7f;
1986               if (num_entries==0x08) desired_mask = 0xff;
1987               if (num_entries==0x09) desired_mask = 0xff;
1988               if (num_entries==0x0a) desired_mask = 0xff;
1989
1990               if (rawvalue!=desired_mask)
19771991               {
1978                  printf("0 entries for this column?"); // seems a valid condition based on the data
1992                  printf(" possible wrong mask?");
19791993               }
19801994
19811995
1982
1983               printf("\n");
1984
1985               
19861996            }
1987            else if (stage==2)
1988            {   
1989               printf("%02x <- Mask value equal to number of entries (xor table location is %02x)", rawvalue, tableloc);
1990               stage = 3;
19911997
1992               //
1993               if (entries_left == 0)
1994               {
1995                  // for 0 entries skip back to state 1 instead of 3, because there is nothing following
1996                  stage = 1;
1997                  currentcolumn++;
1998         }
19981999
1999                  coverage[tableloc] = 1;
2000                  if (rawvalue!=0)
2001                  {
2002                     printf(" invalid mask after 00 length?");
2003                     // attempt to correct the table
2004                     //new_puzzli2_level_decode[tableloc] = new_puzzli2_level_decode[tableloc] ^ rawvalue;
2000         printf("\n");
20052001
2006                  }
2007                  coverage[prev_tablloc] = 1;
2008                  if (full_entry!=0)
2009                  {
2010                     printf(" previous value wasn't 0x00");
2011                  }
2002      }
2003      else if (stage==3)
2004      {
2005         // some of these might be due to bad decrypt values in the table
2006         if (rawvalue==0x00)      printf("%02x <- fish type 0\n", rawvalue);
2007         else if (rawvalue==0x01) printf("%02x <- fish type 1\n", rawvalue);
2008         else if (rawvalue==0x02) printf("%02x <- fish type 2\n", rawvalue);
2009         else if (rawvalue==0x03) printf("%02x <- fish type 3\n", rawvalue);
2010         else if (rawvalue==0x04) printf("%02x <- fish type 4\n", rawvalue);
2011         else if (rawvalue==0x05) printf("%02x <- fish type 5\n", rawvalue);
2012         else if (rawvalue==0x06) printf("%02x <- fish type 6\n", rawvalue);
2013         else if (rawvalue==0x07) printf("%02x <- fish type 7\n", rawvalue);
20122014   
2013               }
2014               else
2015               {
2016                  if (num_entries> 0xa)
2017                  {
2018                     printf(" more than 10 entries?");
2019                  }
2020                  else
2021                  {
2022                     coverage[tableloc] = 1;
2015         else if (rawvalue==0x08) printf("%02x <- ?? 08\n", rawvalue);
20232016
2024                     int desired_mask = 0;
2017         else if (rawvalue==0x0b) printf("%02x <- ?? 0b\n", rawvalue);
2018         else if (rawvalue==0x0c) printf("%02x <- ?? 0c\n", rawvalue);
2019         else if (rawvalue==0x0d) printf("%02x <- ?? 0d\n", rawvalue);
2020         else if (rawvalue==0x0e) printf("%02x <- ?? 0e\n", rawvalue);
2021         else if (rawvalue==0x0f) printf("%02x <- ?? 0f\n", rawvalue);
2022         else if (rawvalue==0x10) printf("%02x <- ?? 10\n", rawvalue);
2023         else if (rawvalue==0x11) printf("%02x <- ?? 11\n", rawvalue);
2024         else if (rawvalue==0x12) printf("%02x <- ?? 12\n", rawvalue);
2025         else if (rawvalue==0x13) printf("%02x <- ?? 13\n", rawvalue);
2026         else if (rawvalue==0x14) printf("%02x <- ?? 14\n", rawvalue);
2027         else if (rawvalue==0x15) printf("%02x <- ?? 15\n", rawvalue);
2028         else if (rawvalue==0x16) printf("%02x <- ?? 16\n", rawvalue);
2029         else if (rawvalue==0x17) printf("%02x <- ?? 17\n", rawvalue);
2030         else if (rawvalue==0x18) printf("%02x <- ?? 18\n", rawvalue);
2031         else if (rawvalue==0x19) printf("%02x <- ?? 19\n", rawvalue);
20252032
2026                     if (num_entries==0x00) desired_mask = 0x00;
2027                     if (num_entries==0x01) desired_mask = 0x01;
2028                     if (num_entries==0x02) desired_mask = 0x03;
2029                     if (num_entries==0x03) desired_mask = 0x07;
2030                     if (num_entries==0x04) desired_mask = 0x0f;
2031                     if (num_entries==0x05) desired_mask = 0x1f;
2032                     if (num_entries==0x06) desired_mask = 0x3f;
2033                     if (num_entries==0x07) desired_mask = 0x7f;
2034                     if (num_entries==0x08) desired_mask = 0xff;
2035                     if (num_entries==0x09) desired_mask = 0xff;
2036                     if (num_entries==0x0a) desired_mask = 0xff;
2033         else if (rawvalue==0x1e) printf("%02x <- ?? 1e\n", rawvalue);
20372034
2038                     if (rawvalue!=desired_mask)
2039                     {
2040                        printf(" possible wrong mask?");
2041                     }
2035         else if (rawvalue==0x21) printf("%02x <- ?? 21\n", rawvalue); // puzzli2
2036         else if (rawvalue==0x22) printf("%02x <- ?? 22\n", rawvalue);
2037         else if (rawvalue==0x23) printf("%02x <- ?? 23\n", rawvalue);
2038         else if (rawvalue==0x24) printf("%02x <- ?? 24\n", rawvalue);
2039         else if (rawvalue==0x25) printf("%02x <- ?? 25\n", rawvalue);
2040         else if (rawvalue==0x26) printf("%02x <- ?? 26\n", rawvalue);
2041         else if (rawvalue==0x27) printf("%02x <- ?? 27\n", rawvalue);
2042         else if (rawvalue==0x28) printf("%02x <- ?? 28\n", rawvalue);
2043         else if (rawvalue==0x29) printf("%02x <- ?? 29\n", rawvalue);
2044         else if (rawvalue==0x2a) printf("%02x <- ?? 2a\n", rawvalue);
20422045
2046         else if (rawvalue==0x32) printf("%02x <- ?? 32\n", rawvalue); // puzzli2
2047         else if (rawvalue==0x33) printf("%02x <- ?? 33\n", rawvalue); // puzzli2
2048         else if (rawvalue==0x35) printf("%02x <- ?? 35\n", rawvalue);
2049         else if (rawvalue==0x38) printf("%02x <- ?? 38\n", rawvalue); // puzzli2
20432050
2044                  }
2051         else if (rawvalue==0x41) printf("%02x <- ?? 41\n", rawvalue); // puzzli2
2052         else if (rawvalue==0x43) printf("%02x <- ?? 43\n", rawvalue); // puzzli2
20452053
2046               }
2054         else if (rawvalue==0xd0) printf("%02x <- ?? d0\n", rawvalue);
20472055
2048               printf("\n");
2056         else if (rawvalue==0xe0) printf("%02x <- ?? e0\n", rawvalue);
2057         else if (rawvalue==0xe1) printf("%02x <- ?? e1\n", rawvalue);
2058         else if (rawvalue==0xe2) printf("%02x <- ?? e2\n", rawvalue);
2059         else if (rawvalue==0xe3) printf("%02x <- ?? e3\n", rawvalue);
2060         else if (rawvalue==0xe4) printf("%02x <- ?? e3\n", rawvalue);
20492061
2062
2063         else                     printf("%02x <- unknown object\n", rawvalue);
2064
2065         entries_left--;
2066         if (entries_left == 0)
2067         {
2068            stage = 1;
2069            currentcolumn++;
2070
2071            if (currentcolumn==numbercolumns)
2072            {
2073               return 1;
20502074            }
2051            else if (stage==3)
2052            {
2053               // some of these might be due to bad decrypt values in the table
2054               if (rawvalue==0x00)      printf("%02x <- fish type 0\n", rawvalue);
2055               else if (rawvalue==0x01) printf("%02x <- fish type 1\n", rawvalue);
2056               else if (rawvalue==0x02) printf("%02x <- fish type 2\n", rawvalue);
2057               else if (rawvalue==0x03) printf("%02x <- fish type 3\n", rawvalue);
2058               else if (rawvalue==0x04) printf("%02x <- fish type 4\n", rawvalue);
2059               else if (rawvalue==0x05) printf("%02x <- fish type 5\n", rawvalue);
2060               else if (rawvalue==0x06) printf("%02x <- fish type 6\n", rawvalue);
2061               else if (rawvalue==0x07) printf("%02x <- fish type 7\n", rawvalue);
2075
2076         }
2077      }
2078           
2079   }
2080
2081   return 0;
2082}
20622083   
2063               else if (rawvalue==0x08) printf("%02x <- ?? 08\n", rawvalue);
20642084
2065               else if (rawvalue==0x0b) printf("%02x <- ?? 0b\n", rawvalue);
2066               else if (rawvalue==0x0c) printf("%02x <- ?? 0c\n", rawvalue);
2067               else if (rawvalue==0x0d) printf("%02x <- ?? 0d\n", rawvalue);
2068               else if (rawvalue==0x0e) printf("%02x <- ?? 0e\n", rawvalue);
2069               else if (rawvalue==0x0f) printf("%02x <- ?? 0f\n", rawvalue);
2070               else if (rawvalue==0x10) printf("%02x <- ?? 10\n", rawvalue);
2071               else if (rawvalue==0x11) printf("%02x <- ?? 11\n", rawvalue);
2072               else if (rawvalue==0x12) printf("%02x <- ?? 12\n", rawvalue);
2073               else if (rawvalue==0x13) printf("%02x <- ?? 13\n", rawvalue);
2074               else if (rawvalue==0x14) printf("%02x <- ?? 14\n", rawvalue);
2075               else if (rawvalue==0x15) printf("%02x <- ?? 15\n", rawvalue);
2076               else if (rawvalue==0x16) printf("%02x <- ?? 16\n", rawvalue);
2077               else if (rawvalue==0x17) printf("%02x <- ?? 17\n", rawvalue);
2078               else if (rawvalue==0x18) printf("%02x <- ?? 18\n", rawvalue);
2079               else if (rawvalue==0x19) printf("%02x <- ?? 19\n", rawvalue);
20802085
2081               else if (rawvalue==0x1e) printf("%02x <- ?? 1e\n", rawvalue);
2086DRIVER_INIT_MEMBER(pgm_arm_type1_state,puzzli2)
2087{
2088   pgm_basic_init();
2089   pgm_puzzli2_decrypt(machine());
2090   arm_sim_handler = &pgm_arm_type1_state::command_handler_puzzli2;
2091   m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0x500000, 0x500005, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_r),this), write16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_w),this));
2092   m_maincpu->space(AS_PROGRAM).install_read_handler(0x4f0000, 0x4f003f, read16_delegate(FUNC(pgm_arm_type1_state::pgm_arm7_type1_sim_protram_r),this));
2093   m_irq4_disabled = 1; // // doesn't like this irq??
20822094
2083               else if (rawvalue==0x21) printf("%02x <- ?? 21\n", rawvalue); // puzzli2
2084               else if (rawvalue==0x22) printf("%02x <- ?? 22\n", rawvalue);
2085               else if (rawvalue==0x23) printf("%02x <- ?? 23\n", rawvalue);
2086               else if (rawvalue==0x24) printf("%02x <- ?? 24\n", rawvalue);
2087               else if (rawvalue==0x25) printf("%02x <- ?? 25\n", rawvalue);
2088               else if (rawvalue==0x26) printf("%02x <- ?? 26\n", rawvalue);
2089               else if (rawvalue==0x27) printf("%02x <- ?? 27\n", rawvalue);
2090               else if (rawvalue==0x28) printf("%02x <- ?? 28\n", rawvalue);
2091               else if (rawvalue==0x29) printf("%02x <- ?? 29\n", rawvalue);
2092               else if (rawvalue==0x2a) printf("%02x <- ?? 2a\n", rawvalue);
2095//#define PUZZLI2_LEVEL_STRUCTURE_LOG
2096#ifdef PUZZLI2_LEVEL_STRUCTURE_LOG
2097   UINT8 *src2 = (UINT8 *) (machine().root_device().memregion("maincpu")->base());
2098//   UINT8 new_puzzli2_level_decode[256];
20932099
2094               else if (rawvalue==0x32) printf("%02x <- ?? 32\n", rawvalue); // puzzli2
2095               else if (rawvalue==0x33) printf("%02x <- ?? 33\n", rawvalue); // puzzli2
2096               else if (rawvalue==0x35) printf("%02x <- ?? 35\n", rawvalue);
2097               else if (rawvalue==0x38) printf("%02x <- ?? 38\n", rawvalue); // puzzli2
2100//   for (int i=0;i<256;i++)
2101//      new_puzzli2_level_decode[i] = puzzli2_level_decode[i];
20982102
2099               else if (rawvalue==0x41) printf("%02x <- ?? 41\n", rawvalue); // puzzli2
2100               else if (rawvalue==0x43) printf("%02x <- ?? 43\n", rawvalue); // puzzli2
2103   int offset;
2104   int limit;
2105   for (int i=0;i<256;i++)
2106      coverage[i] = 0;
21012107
2102               else if (rawvalue==0xd0) printf("%02x <- ?? d0\n", rawvalue);
2108   if (!strcmp(machine().system().name,"puzzli2"))
2109   {
2110      offset = 0x17ab66;
2111       limit = 476;
2112   }
2113   else
2114   {
2115       offset = 0x16c3ca;
2116       limit = 500;
2117   }
21032118
2104               else if (rawvalue==0xe0) printf("%02x <- ?? e0\n", rawvalue);
2105               else if (rawvalue==0xe1) printf("%02x <- ?? e1\n", rawvalue);
2106               else if (rawvalue==0xe2) printf("%02x <- ?? e2\n", rawvalue);
2107               else if (rawvalue==0xe3) printf("%02x <- ?? e3\n", rawvalue);
2108               else if (rawvalue==0xe4) printf("%02x <- ?? e3\n", rawvalue);
21092119
21102120
2111               else                     printf("%02x <- unknown object\n", rawvalue);
21122121
2113               entries_left--;
2114               if (entries_left == 0)
2115               {
2116                  stage = 1;
2117                  currentcolumn++;
2118               }
2122   for (int i=0;i<limit;i++)
2123   {
2124      UINT32 val1 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0);
2125      offset += 4;
2126      UINT32 val2 = (src2[offset+1]<<24) | (src2[offset+0] << 16) | (src2[offset+3]<<8) | (src2[offset+2] << 0);
2127
2128
2129      printf("(%d) data range %08x %08x\n", i, val1, val2);
2130
2131      int x = 0;
2132
2133      tableoffs = 0;
2134      tableoffs2 = 0;
2135      entries_left = 0;
2136      currentcolumn = 0;
2137      num_entries = 0;
2138      full_entry = 0;
2139      prev_tablloc = 0;
2140      numbercolumns = 0;
2141      depth = 0;
2142      stage = -1;
2143
2144      for (x=val1; x<val2;x++)
2145      {
2146         int end = puzzli2_take_leveldata_value(src2[x^1]);
2147
2148         if (end)
2149         {
2150            printf("--- ended at %08x (val 2 was %08x)\n",x ,val2);
2151
2152            if ( (val2-x) > 2 )
2153            {
2154               fatalerror("ended even earlier than padding byte\n");
21192155            }
2120           
2156            else if ( (val2-x) == 2)
2157            {
2158               printf("ended with padding byte\n");
2159            }
2160            else if ( (val2-x) == 1)
2161            {
2162               printf("ended normally\n");
2163            }
2164            else // can't happen
2165            {
2166               fatalerror("ended after marker?!\n");
2167            }
2168
2169            x = val2;
21212170         }
2122      }
21232171
2124      if (entries_left!=0)
2125      {
2126         printf("last column didn't terminate (sometimes this is ok, streams are padded to a word)\n");
2127         UINT8 lastbyte = src2[(x-1)^1];
2128         printf("last (pre-decrypted) byte in stream was %02x if this is 00 we're probably ok\n", lastbyte);
21292172      }
21302173
21312174      printf("total number of valid columns was %02x\n", currentcolumn);
r24687r24688
21372180         fatalerror("mismatch in number of columns vs specified amount\n");
21382181
21392182      printf("\n");
2183     
21402184
21412185   }
2186   /*
21422187   int c=0;
21432188   for (int i=0;i<256;i++)
21442189   {
r24687r24688
21652210         c = 0;
21662211      }
21672212   }
2213   */
21682214
21692215#endif
21702216
trunk/src/mame/includes/pgm.h
r24687r24688
254254   DECLARE_WRITE16_MEMBER( pgm_arm7_type1_sim_w );
255255   DECLARE_READ16_MEMBER( pgm_arm7_type1_sim_protram_r );
256256   DECLARE_READ16_MEMBER( pstars_arm7_type1_sim_protram_r );
257
258   /* puzzli2 protection internal state stuff */
259   int stage;
260   int tableoffs;
261   int tableoffs2;
262   int entries_left;
263   int currentcolumn;
264   int num_entries;
265   int full_entry;
266   int prev_tablloc;
267   int numbercolumns;
268   int depth;
269   UINT8 coverage[256]; // coverage is how much of the table we've managed to verify using known facts about the table structure
270
271
272   int puzzli2_take_leveldata_value(UINT8 datvalue);
257273};
258274
259275/* for machine/pgmprot2.c type games */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team