home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / emulators / v9t9 / linux / sources / V9t9 / source / grom.c < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-19  |  1.7 KB  |  87 lines

  1. #include "v9t9_common.h"
  2. #include "memory.h"
  3. #include "grom.h"
  4.  
  5. //u8          gplrom[65536];
  6. static u16      gromaddr;
  7. static bool        gromaddrflag;    // not for real use, only for debugger
  8.  
  9. /*    GROM has a strange banking scheme where the upper portion
  10.     of the address does not change when incremented;
  11.     this acts like an 8K bank. */
  12. static u16
  13. grom_mmio_get_next_addr(u16 addr)
  14. {
  15.     return (((addr+1) & 0x1fff) | (gromaddr & 0xe000));
  16. }
  17.  
  18. u16
  19. grom_mmio_get_addr(void)
  20. {
  21.     return gromaddr;
  22. }
  23.  
  24. u8
  25. grom_mmio_get_addr_byte(void)
  26. {
  27.     return grom_mmio_get_next_addr(gromaddr) >> 8;
  28. }
  29.  
  30. void
  31. grom_mmio_set_addr(u16 addr)
  32. {
  33.     gromaddr = addr;
  34. }
  35.  
  36. bool 
  37. grom_mmio_addr_is_complete(void)
  38. {
  39.     return !gromaddrflag;
  40. }
  41.  
  42. void
  43. grom_mmio_write(u32 addr, u8 val)
  44. {
  45.     if (addr) {
  46.         gromaddr = (gromaddr << 8) | val;
  47.         gromaddrflag ^= 1;
  48.         logger(LOG_CPU | LOG_INFO | L_2, "GROMSETADDR: %04X\n", gromaddr);
  49.     } else {
  50.         gromaddrflag = 0;
  51.         domain_write_byte(md_graphics, gromaddr, val);
  52.         gromaddr = grom_mmio_get_next_addr(gromaddr);
  53.     }
  54. }
  55.  
  56. s8 grom_mmio_read(u32 addr)
  57. {
  58.     register u8 ret;
  59.     register u32 temp;
  60.  
  61.     if (addr) {
  62.         temp = grom_mmio_get_next_addr(gromaddr);
  63.         ret = grom_mmio_get_addr_byte();
  64.         gromaddr = temp << 8;
  65.         gromaddrflag ^= 1;
  66.         logger(LOG_CPU | LOG_INFO | L_2, "GROMREADADDR: %02X / %04X\n", ret,
  67.                gromaddr);
  68.         return ret;
  69.     } else {
  70.         gromaddrflag = 0;
  71.         ret = domain_read_byte(md_graphics, gromaddr);
  72.         logger(LOG_CPU | LOG_INFO | L_2, "GROMADDR: %04X\n", gromaddr);
  73.         gromaddr = grom_mmio_get_next_addr(gromaddr);
  74.         return ret;
  75.     }
  76. }
  77.  
  78. /*    Initially set up this memory as empty.  We expect ROMs to be
  79.     loaded by the config file.  */
  80.  
  81. void
  82. gpl_memory_init(void)
  83. {
  84. //    memory_insert_new_entry(MEMENT_GRAPHICS, 0x0000, 0x10000, 
  85. //                           "Graphics ROM", 0L, &zero_memory_handler);
  86. }
  87.