Author Topic: Aticore  (Read 1889 times)

djtreble

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • http://
Aticore
« on: December 27, 2004, 04:30:37 am »
Traveling the world for a year with my Z, I fill the gaps by slowly turning the assembly into c code. Currently in Sydney. It'll take me ages, I'm on file 3 of 26, it's a mess and needs cleaning up bit by bit.

Anyone else want to help me?! Anyone care? Would anyone like to set me up some cvs for it?

Here's a highlight from file 2 to wet your whistle!

Code: [Select]
void SwitchToNon2DMode(char in1, unsigned char in2)
{
    unsigned char* clpgDrvState = (unsigned char*)lpgDrvState;
    //short* slpgDrvState = (short*)lpgDrvState;
    dp_gui_master_cntl_u *dpGuiMasterCntl = (dp_gui_master_cntl_u *)&lpgDrvState[0x68/sizeof(unsigned int)];
    
    //if(clpgDrvState[0x6b] & 0x80)
    if(dpGuiMasterCntl->f.gmc_dp_op == DP_PIX_ORDER_LSB2MSB)
    {
  if(in1 == 0)
  {
      return;
  }
    }
    else
    {
  if(in1 == 1)
  {
      return;
  }
    }
    
    lpgDrvState[mmPLL_REF_FB_DIV / sizeof(unsigned int)] = 0x0;
    
    if(in1 != 0)
    {
  //clpgDrvState[0x6b] |= 0x80;
  dpGuiMasterCntl->f.gmc_dp_op = DP_OP_ARITHMETIC;
  
  //unk_432B10 = (clpgDrvState[0x69] >> 4) & 0x7;
  unk_432B10 = dpGuiMasterCntl->f.gmc_src_datatype;
  
  //unk_432B14 = (unsigned char)(slpgDrvState[0x6A / sizeof(short)] >> 1);
  unk_432B14 = dpGuiMasterCntl->f.gmc_rop3;
  
  PM4_SubmitPacket0(0, mmDEBUG1,1,&clpgDrvState[mmCP_ME_RAM_DATAH]);
  
  ResetGUIEngine();
    }
    else
    {
  
  PM4_SubmitPacket0(0, mmDEBUG1,1,&clpgDrvState[mmCP_ME_RAM_DATAH]);
  
  //clpgDrvState[0x6b] &= 0x7F;
  dpGuiMasterCntl->f.gmc_dp_op = DP_OP_ROP;
  
  //clpgDrvState[0x69] = (clpgDrvState[0x69] & ~0x70) | ((unk_432B10 & 7) << 4);
  dpGuiMasterCntl->f.gmc_src_datatype = unk_432B10;
    
  //unsigned char lr = slpgDrvState[0x6A / sizeof(short)] = (((slpgDrvState[0x6A / sizeof(short)] & ~0x1FC) & ~0x2) | unk_432B14 << 1);
  dpGuiMasterCntl->f.gmc_rop3 = unk_432B14;
  
  //unsigned char r12 = (clpgDrvState[0x69] >> 4) & 0x7;
  
  //unsigned char r4 = clpgDrvState[0x69] << 7;
  
  dp_datatype_u dpDatatype;
  
  //unsigned int r2 = ((clpgDrvState[0x68] >> 4 ) << 8 ) | (clpgDrvState[0x69] & 0xf) | (r12 << 13) | (r12 << 16) | (r4 << 30);  
  
  dpDatatype.f.dp_brush_datatype = dpGuiMasterCntl->f.gmc_brush_datatype;
  dpDatatype.f.dp_dst_datatype = dpGuiMasterCntl->f.gmc_dst_datatype;
  dpDatatype.f.dp_src2_datatype = dpGuiMasterCntl->f.gmc_src_datatype;
  dpDatatype.f.dp_src_datatype = dpGuiMasterCntl->f.gmc_src_datatype;
  dpDatatype.f.dp_byte_pix_order = dpGuiMasterCntl->f.gmc_dp_op;
  
  dp_mix_u dpMix;
  
  //unsigned int foo = ((((((0 & ~0x700 | (((clpgDrvState[0x6B] >> 1) & 0x7 ) << 8)) & ~0x2800) | 0x1000) & ~0xff0000) | lr << 16 ) & ~0x1000000 ) | ((clpgDrvState[0x6B] >> 7) << 24);
  
  dpMix.f.dp_src_source = dpGuiMasterCntl->f.gmc_dp_src_source;
  dpMix.f.dp_src2_source = DP_SRC_MEM_RECTANGULAR; //(dpMix.f.dp_src2_source & ~5) | 2; //strange
  dpMix.f.dp_rop3 = dpGuiMasterCntl->f.gmc_rop3;
  dpMix.f.dp_op = dpGuiMasterCntl->f.gmc_dp_op;
  
  PM4_SubmitPacket1(0,mmDP_DATATYPE,dpDatatype.val,mmDP_MIX,dpMix.val);
    }
    
    if(clpgDrvState[0xA2] != 0)
    {
  while( AtiCore_WaitComplete(0x64) == 0)
  {
  }
  
  //debug1_u debug1;
  unsigned int debug1;
  
  ReadRegDirect(0,mmDEBUG1,4,&debug1);
  
  if(in1 != 0)
  {
      debug1 |= 0x4000;
      
      if(dpGuiMasterCntl->f.gmc_src_datatype == DP_SRC_COLOR_SAME_AS_DST)
      {
    debug1 |= 1<<16;
      }
      
      if(in2 != 0)
      {
    debug1 |= 1<<17;
      }
      else
      {
    debug1 |= in2<<17;
      }
  }
  else
  {
      debug1 &= ~0x7000;
  }
  
  WriteRegDirect(0,mmDEBUG1,4,&debug1);
  
  lpgDrvState[mmCP_ME_RAM_DATAH] = debug1;
    }
    else
    {
  PM4_SubmitPacket0(0, mmDEBUG1,1,&clpgDrvState[mmCP_ME_RAM_DATAH]);
    }
    
    lpgDrvState[mmCP_ME_RAM_DATAL] &= ~0x1;
}

ScottYelich

  • Hero Member
  • *****
  • Posts: 992
    • View Profile
    • http://www.zaurususergroup.com/modules.php?opmodload&namephpWiki&filei
Aticore
« Reply #1 on: December 27, 2004, 09:32:36 am »
c is basically macro assembly anyway...

and that code looks pretty close to assembly, anyway.

What do you hope to achieve?

Scott

djtreble

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • http://
Aticore
« Reply #2 on: December 27, 2004, 11:49:29 pm »
Quote
and that code looks pretty close to assembly

Ha ha, you cheeky thing, it took ages to work out which bitfield it was doing what to   loads of the really messy stuff is comented out.

Ultimately I want better graphics drivers, I want a better understanding of the chip and I'd really like hardware mpeg. I want hardware blits (if they are faster). I want a (flat shaded) poly rasterer that at least uses some of the hardware for gl.

That's a long way off, just wondered if anyone else was interested.
« Last Edit: December 27, 2004, 11:50:21 pm by djtreble »