Previous 15994 Revisions Next

r8777 Sunday 15th August, 2010 at 04:14:52 UTC by Robbbert
[GAMECOM] wip
[src/emu/cpu/sm8500]sm8500.c
[src/mess/machine]gamecom.c

src/emu/cpu/sm8500/sm8500.c
r8776r8777
77  this cpu, and made educated guesses on the number of cycles for each instruction.
88
99  Code by Wilbert Pol
10
11
12There is some internal ram for the main cpu registers. They are offset by an index value.
13The address is (PS0 & 0xF8) + register number. It is not known what happens when PS0 >= F8.
14The assumption is that F8 to 107 is used, but it might wrap around instead.
15The registers also mirror out to main RAM, appearing at 0000 to 000F regardless of where
16they are internally.
17
1018*/
1119
1220#include "emu.h"
r8776r8777
4553   legacy_cpu_device *device;
4654   const address_space *program;
4755   UINT16 oldpc;
56   UINT8 register_ram[0x108];
4857};
4958
5059INLINE sm8500_state *get_safe_token(running_device *device)
r8776r8777
6574   if (cpustate->SYS&0x40) cpustate->SP |= data;
6675}
6776
68static UINT8 sm85cpu_mem_readbyte( sm8500_state *cpustate, UINT32 offset ) {
69   if (offset < 0x10) offset+= cpustate->PS0 & 0xf8;
70   return memory_read_byte( cpustate->program, offset );
77static UINT8 sm85cpu_mem_readbyte( sm8500_state *cpustate, UINT32 offset )
78{
79   offset &= 0xffff;
80   return (offset < 0x10) ? cpustate->register_ram[offset + (cpustate->PS0 & 0xF8)]
81      : memory_read_byte( cpustate->program, offset );
7182}
7283
73static void sm85cpu_mem_writebyte( sm8500_state *cpustate, UINT32 offset, UINT8 data ) {
74   if (offset < 0x10) offset+= cpustate->PS0 & 0xf8;
84static void sm85cpu_mem_writebyte( sm8500_state *cpustate, UINT32 offset, UINT8 data )
85{
86   UINT8 i;
87   offset &= 0xffff;
88   if (offset < 0x10)
89      cpustate->register_ram[offset + (cpustate->PS0 & 0xF8)] = data;
90
7591   memory_write_byte( cpustate->program, offset, data );
92
7693   switch (offset)
7794   {
7895      case 0x10: cpustate->IE0 = data; break;
r8776r8777
83100      case 0x1a: cpustate->CKC = data; break;
84101      case 0x1c:
85102      case 0x1d: sm8500_get_sp(cpustate); break;
86      case 0x1e: cpustate->PS0 = data; break;
103      case 0x1e: cpustate->PS0 = data;
104            for (i = 0; i < 16; i++)   // refresh register contents in debugger
105               memory_write_byte(cpustate->program, i, sm85cpu_mem_readbyte(cpustate, i)); break;
87106      case 0x1f: cpustate->PS1 = data; break;
88107   }
89108}
r8776r8777
91110
92111INLINE UINT16 sm85cpu_mem_readword( sm8500_state *cpustate, UINT32 address )
93112{
94   UINT16 value = (UINT16) sm85cpu_mem_readbyte( cpustate, address ) << 8;
95   value |= sm85cpu_mem_readbyte( cpustate, ( address + 1 ) & 0xffff );
96   return value;
113   return (sm85cpu_mem_readbyte( cpustate, address ) << 8) | (sm85cpu_mem_readbyte( cpustate, address+1 ));
97114}
98115
99116INLINE void sm85cpu_mem_writeword( sm8500_state *cpustate, UINT32 address, UINT16 value )
100117{
101118   sm85cpu_mem_writebyte( cpustate, address, value >> 8 );
102   sm85cpu_mem_writebyte( cpustate, ( address + 1 ) & 0xffff, value & 0xff );
119   sm85cpu_mem_writebyte( cpustate, ++address, value );
103120}
104121
105122static CPU_INIT( sm8500 )
r8776r8777
272289         }
273290         if (cpustate->SYS&0x40) memory_write_byte(cpustate->program,0x1c,cpustate->SP>>8);
274291         memory_write_byte(cpustate->program,0x1d,cpustate->SP&0xFF);
275         memory_write_byte(cpustate->program,0x1e,cpustate->PS0);
292         sm85cpu_mem_writebyte(cpustate,0x1e,cpustate->PS0);   // need to update debugger
276293         memory_write_byte(cpustate->program,0x1f,cpustate->PS1);
277294      } else {
278295         mycycles = 4;
src/mess/machine/gamecom.c
r8776r8777
6666static GAMECOM_TIMER gamecom_timer[2];
6767static gamecom_sound_t gamecom_sound;
6868
69//static const int gamecom_timer_limit[8] = { 2/2, 1024/2, 2048/2, 4096/2, 8192/2, 16384/2, 32768/2, 65536/2 };
7069static const int gamecom_timer_limit[8] = { 2, 1024, 2048, 4096, 8192, 16384, 32768, 65536 };
7170
72
7371static void gamecom_dma_init(running_machine *machine);
7472
7573static TIMER_CALLBACK(gamecom_clock_timer_callback)
r8776r8777
499497   case 0x04:
500498      /* Extend RAM->VRAM */
501499      gamecom_dma.source_width = 64;
502      gamecom_dma.source_bank = (UINT8*)memory_get_read_ptr(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xE000 );
500      gamecom_dma.source_bank = &gamecom_vram[0x4000];
503501      gamecom_dma.dest_bank = &gamecom_vram[(RAM[SM8521_DMVP] & 0x02) ? 0x2000 : 0x0000];
504502      break;
505503   case 0x06:
506504      /* VRAM->Extend RAM */
507505      gamecom_dma.source_bank = &gamecom_vram[(RAM[SM8521_DMVP] & 0x01) ? 0x2000 : 0x0000];
508506      gamecom_dma.dest_width = 64;
509      gamecom_dma.dest_bank = (UINT8*)memory_get_read_ptr(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xE000 );
507      gamecom_dma.dest_bank = &gamecom_vram[0x4000];
510508      break;
511509   }
512510   gamecom_dma.source_current = gamecom_dma.source_width * gamecom_dma.source_y;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team