cell_map.c 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Convert "cell arrange" address to normal address.
  3. * (C) notaz, 2008
  4. *
  5. * This work is licensed under the terms of MAME license.
  6. * See COPYING file in the top-level directory.
  7. */
  8. // 64 x32 x16 x8 x4 x4
  9. static unsigned int cell_map(int celln)
  10. {
  11. int col, row;
  12. switch ((celln >> 12) & 7) { // 0-0x8000
  13. case 0: // x32 cells
  14. case 1:
  15. case 2:
  16. case 3:
  17. col = celln >> 8;
  18. row = celln & 0xff;
  19. break;
  20. case 4: // x16
  21. case 5:
  22. col = celln >> 7;
  23. row = celln & 0x7f;
  24. row |= 0x10000 >> 8;
  25. break;
  26. case 6: // x8
  27. col = celln >> 6;
  28. row = celln & 0x3f;
  29. row |= 0x18000 >> 8;
  30. break;
  31. case 7: // x4
  32. col = celln >> 5;
  33. row = celln & 0x1f;
  34. row |= (celln & 0x7800) >> 6;
  35. break;
  36. default: // never happens, only here to make compiler happy
  37. col = row = 0;
  38. break;
  39. }
  40. return (col & 0x3f) + row*64;
  41. }