diff options
| author | 2008-11-23 07:12:37 +0000 | |
|---|---|---|
| committer | 2008-11-23 07:12:37 +0000 | |
| commit | 2f200eac6cee5780b09d08c7e440cf80ec46f055 (patch) | |
| tree | acfee780c6488e8b991e1f50d0efb9f6a01eb551 /src | |
| parent | 61347380f2aedd41852174cd383c7d10413982a7 (diff) | |
More driver conversions, including snes and seicop, which were two big ones.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mame/includes/snes.h | 4 | ||||
| -rw-r--r-- | src/mame/machine/seicop.c | 264 | ||||
| -rw-r--r-- | src/mame/machine/snes.c | 125 | ||||
| -rw-r--r-- | src/mame/machine/taitosj.c | 10 | ||||
| -rw-r--r-- | src/mame/machine/tatsumi.c | 22 | ||||
| -rw-r--r-- | src/mame/machine/toaplan1.c | 14 | ||||
| -rw-r--r-- | src/mame/machine/twincobr.c | 30 | ||||
| -rw-r--r-- | src/mame/video/astrocde.c | 14 | ||||
| -rw-r--r-- | src/mame/video/attckufo.c | 7 | ||||
| -rw-r--r-- | src/mame/video/combatsc.c | 3 |
10 files changed, 262 insertions, 231 deletions
diff --git a/src/mame/includes/snes.h b/src/mame/includes/snes.h index 821658f9915..4260201df1a 100644 --- a/src/mame/includes/snes.h +++ b/src/mame/includes/snes.h @@ -401,9 +401,9 @@ extern WRITE8_HANDLER( snes_w_bank7 ); extern UINT8 has_addon_chip; -extern void snes_gdma( UINT8 channels ); +extern void snes_gdma( const address_space *space, UINT8 channels ); extern void snes_hdma_init(void); -extern void snes_hdma(void); +extern void snes_hdma(const address_space *space); /* (PPU) Video related */ extern UINT8 *snes_vram; /* Video RAM (Should be 16-bit, but it's easier this way) */ diff --git a/src/mame/machine/seicop.c b/src/mame/machine/seicop.c index c683e1b4232..fcf4724a04e 100644 --- a/src/mame/machine/seicop.c +++ b/src/mame/machine/seicop.c @@ -204,16 +204,16 @@ static UINT32 protection_bcd_jsr(UINT16 prot_data) /* -the second value should be end of calculation (in other words,check everything between the two values) */ #define PLAYER 0 #define ENEMY 1 -static void protection_move_jsr(UINT32 work_ram,UINT8 k) +static void protection_move_jsr(const address_space *space,UINT32 work_ram,UINT8 k) { static UINT32 move_data,x_data,y_data; /*Read the movement data to execute*/ - move_data = ((program_read_word(work_ram+0x34)<<16) & 0xffff0000) | - (program_read_word(work_ram+0x36) & 0xffff); + move_data = ((memory_read_word(space, work_ram+0x34)<<16) & 0xffff0000) | + (memory_read_word(space, work_ram+0x36) & 0xffff); /*Read the x/y axis of the sprite to change*/ - x_data = (program_read_word(work_ram+0x8)); - y_data = (program_read_word(work_ram+0x4)); + x_data = (memory_read_word(space, work_ram+0x8)); + y_data = (memory_read_word(space, work_ram+0x4)); /*it's bit sensitive AFAIK*/ /*move_data hi-word on player $17 = walk floor @@ -255,22 +255,22 @@ static void protection_move_jsr(UINT32 work_ram,UINT8 k) break; } /*Write the new values to the sprite x/y data*/ - program_write_word(work_ram+0x8,x_data); - program_write_word(work_ram+0x4,y_data); + memory_write_word(space, work_ram+0x8,x_data); + memory_write_word(space, work_ram+0x4,y_data); } static UINT16 hit_check; -static void protection_hit_jsr(UINT32 work_ram1,UINT32 work_ram2) +static void protection_hit_jsr(const address_space *space,UINT32 work_ram1,UINT32 work_ram2) { int x1,y1,x2,y2/*,hit1,hit2*/; - x1 = (program_read_word(work_ram1+0x8)); - y1 = (program_read_word(work_ram1+0x4)); - //hit1 = (program_read_word(work_ram1-));//this sprite is attacking - x2 = (program_read_word(work_ram2+0x8)); - y2 = (program_read_word(work_ram2+0x4)); - //hit2 = (program_read_word()); + x1 = (memory_read_word(space, work_ram1+0x8)); + y1 = (memory_read_word(space, work_ram1+0x4)); + //hit1 = (memory_read_word(space, work_ram1-));//this sprite is attacking + x2 = (memory_read_word(space, work_ram2+0x8)); + y2 = (memory_read_word(space, work_ram2+0x4)); + //hit2 = (memory_read_word(space)); popmessage("%08x:x=%04x y=%04x %08x:x=%04x y=%04x",work_ram1,x1,y1,work_ram2,x2,y2); @@ -284,46 +284,46 @@ static void protection_hit_jsr(UINT32 work_ram1,UINT32 work_ram2) } /*directional movement protection*/ -static void moveprot_jsr(void) +static void moveprot_jsr(const address_space *space) { static INT16 x_axis,y_axis; static UINT16 move_data,distance,move_type; - move_data = program_read_word(cop_register[0]+0x36); - x_axis = program_read_word(cop_register[0]+0x08); - y_axis = program_read_word(cop_register[0]+0x04); + move_data = memory_read_word(space, cop_register[0]+0x36); + x_axis = memory_read_word(space, cop_register[0]+0x08); + y_axis = memory_read_word(space, cop_register[0]+0x04); distance = (move_data & 0xf); move_type = (move_data & 0xf0)>>4; switch(move_type) { case 0x0f://right - program_write_word(cop_register[0]+0x08,x_axis+distance); - //program_write_word(0x110004,); + memory_write_word(space, cop_register[0]+0x08,x_axis+distance); + //memory_write_word(space, 0x110004,); break; case 0x0b://up - program_write_word(cop_register[0]+0x04,y_axis-distance); + memory_write_word(space, cop_register[0]+0x04,y_axis-distance); break; case 0x07://left - program_write_word(cop_register[0]+0x08,x_axis-distance); + memory_write_word(space, cop_register[0]+0x08,x_axis-distance); break; case 0x03://down - program_write_word(cop_register[0]+0x04,y_axis+distance); + memory_write_word(space, cop_register[0]+0x04,y_axis+distance); break; case 0x0d://up-right - program_write_word(cop_register[0]+0x08,x_axis+distance); - program_write_word(cop_register[0]+0x04,y_axis-distance); + memory_write_word(space, cop_register[0]+0x08,x_axis+distance); + memory_write_word(space, cop_register[0]+0x04,y_axis-distance); break; case 0x09://up-left - program_write_word(cop_register[0]+0x04,y_axis-distance); - program_write_word(cop_register[0]+0x08,x_axis-distance); + memory_write_word(space, cop_register[0]+0x04,y_axis-distance); + memory_write_word(space, cop_register[0]+0x08,x_axis-distance); break; case 0x01://down-right - program_write_word(cop_register[0]+0x04,y_axis+distance); - program_write_word(cop_register[0]+0x08,x_axis+distance); + memory_write_word(space, cop_register[0]+0x04,y_axis+distance); + memory_write_word(space, cop_register[0]+0x08,x_axis+distance); break; case 0x05://down-left - program_write_word(cop_register[0]+0x04,y_axis+distance); - program_write_word(cop_register[0]+0x08,x_axis-distance); + memory_write_word(space, cop_register[0]+0x04,y_axis+distance); + memory_write_word(space, cop_register[0]+0x08,x_axis-distance); break; default: logerror("Warning: \"0x205\" command called with move_type parameter = %02x\n",move_type); @@ -331,11 +331,11 @@ static void moveprot_jsr(void) //down-right //down-left } - //program_write_word(0x110008,x_axis+tmp); - //program_write_word(0x110004,y_axis+tmp); + //memory_write_word(space, 0x110008,x_axis+tmp); + //memory_write_word(space, 0x110004,y_axis+tmp); - //program_write_word(0x110008,x_axis); - //program_write_word(0x110004,y_axis); + //memory_write_word(space, 0x110008,x_axis); + //memory_write_word(space, 0x110004,y_axis); } /* @@ -350,13 +350,13 @@ static void moveprot_jsr(void) */ /*sprite "look" protection*/ -static void move2prot_jsr(void) +static void move2prot_jsr(const address_space *space) { static INT16 x_pl,y_pl,x_en,y_en,res; - x_pl = program_read_word(cop_register[1]+0x8); - y_pl = program_read_word(cop_register[1]+0x4); - x_en = program_read_word(cop_register[0]+0x8); - y_en = program_read_word(cop_register[0]+0x4); + x_pl = memory_read_word(space, cop_register[1]+0x8); + y_pl = memory_read_word(space, cop_register[1]+0x4); + x_en = memory_read_word(space, cop_register[0]+0x8); + y_en = memory_read_word(space, cop_register[0]+0x4); res = 0; if(x_en > x_pl) @@ -368,37 +368,37 @@ static void move2prot_jsr(void) //if(y_en > y_pl) // res|=0x40; - program_write_word(cop_register[0]+0x36,res); + memory_write_word(space, cop_register[0]+0x36,res); } #ifdef UNUSED_FUNCTION /*"To point" movement protection*/ -static void move3x_prot_jsr(void) +static void move3x_prot_jsr(const address_space *space) { static INT16 x_pl,x_en,x_dis; - x_pl = program_read_word(cop_register[1]+0x8); - x_en = program_read_word(cop_register[0]+0x8); - x_dis = ((program_read_word(cop_register[0]+0x34) & 0xf0) >> 4); + x_pl = memory_read_word(space, cop_register[1]+0x8); + x_en = memory_read_word(space, cop_register[0]+0x8); + x_dis = ((memory_read_word(space, cop_register[0]+0x34) & 0xf0) >> 4); if(x_en > x_pl) x_dis^=0xffff; - program_write_word(cop_register[0]+0x36,-0x40);/*enable command*/ - program_write_word(cop_register[0]+0x14,x_dis); + memory_write_word(space, cop_register[0]+0x36,-0x40);/*enable command*/ + memory_write_word(space, cop_register[0]+0x14,x_dis); } -static void move3y_prot_jsr(void) +static void move3y_prot_jsr(const address_space *space) { static INT16 y_pl,y_en,y_dis; - y_pl = program_read_word(cop_register[1]+0x4); - y_en = program_read_word(cop_register[0]+0x4); - y_dis = (program_read_word(cop_register[0]+0x34) & 0xf); + y_pl = memory_read_word(space, cop_register[1]+0x4); + y_en = memory_read_word(space, cop_register[0]+0x4); + y_dis = (memory_read_word(space, cop_register[0]+0x34) & 0xf); if(y_en > y_pl) y_dis^=0xffff; - program_write_word(cop_register[0]+0x36,-0x80);/*enable command*/ - program_write_word(cop_register[0]+0x10,y_dis); + memory_write_word(space, cop_register[0]+0x36,-0x80);/*enable command*/ + memory_write_word(space, cop_register[0]+0x10,y_dis); } #endif @@ -503,7 +503,7 @@ x/y check [2] static UINT16 s_i; -static void dma_transfer(void) +static void dma_transfer(const address_space *space) { static UINT16 rel_xy; static UINT16 abs_x,abs_y; @@ -512,20 +512,20 @@ static void dma_transfer(void) //for(s_i = dma_size;s_i > 0;s_i--) { /*Sprite Color*/ - param = program_read_word(0x100400) & 0x3f; + param = memory_read_word(space, 0x100400) & 0x3f; /*Write the entire parameters [offs+0]*/ - program_write_word(cop_register[5]+4,program_read_word(dma_src) + param); + memory_write_word(space, cop_register[5]+4,memory_read_word(space, dma_src) + param); /*Sprite Priority (guess)*/ - //param = ((program_read_word(0x100400) & 0x40) ? 0x4000 : 0); + //param = ((memory_read_word(space, 0x100400) & 0x40) ? 0x4000 : 0); /*Write the sprite number [offs+1]*/ - program_write_word(cop_register[5]+6,program_read_word(dma_src+2)); + memory_write_word(space, cop_register[5]+6,memory_read_word(space, dma_src+2)); /*Sprite Relative x/y coords*/ - rel_xy = program_read_word(dma_src+4); /*???*/ + rel_xy = memory_read_word(space, dma_src+4); /*???*/ /*temporary hardwired,it should point to 0x4c0/0x4a0*/ - abs_x = (program_read_word(0x110008) - program_read_word(0x10048e)); - abs_y = (program_read_word(0x110004) - program_read_word(0x10048c)); - program_write_word(cop_register[5]+8,((rel_xy & 0x7f) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)) & 0x1ff); - program_write_word(cop_register[5]+10,(((rel_xy & 0x7f00) >> 8) + (abs_y) + (0x10) - ((rel_xy & 0x8000) ? 0x80 : 0)) & 0x1ff); + abs_x = (memory_read_word(space, 0x110008) - memory_read_word(space, 0x10048e)); + abs_y = (memory_read_word(space, 0x110004) - memory_read_word(space, 0x10048c)); + memory_write_word(space, cop_register[5]+8,((rel_xy & 0x7f) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)) & 0x1ff); + memory_write_word(space, cop_register[5]+10,(((rel_xy & 0x7f00) >> 8) + (abs_y) + (0x10) - ((rel_xy & 0x8000) ? 0x80 : 0)) & 0x1ff); cop_register[5]+=8; dma_src+=6; } @@ -533,7 +533,7 @@ static void dma_transfer(void) /* - switch(program_read_word(cop_register[2])) + switch(memory_read_word(space, cop_register[2])) { case 0xb4: xparam = 0x0c/2; break; case 0xb8: xparam = 0x10/2; break; @@ -560,23 +560,23 @@ static UINT16 check_calc(UINT16 param) return num; } -static UINT16 hit_check_jsr(void) +static UINT16 hit_check_jsr(const address_space *space) { static INT16 xsrc,xdst,ysrc,ydst,xparam,yparam; - xsrc = (program_read_word(0x110008)); - ysrc = (program_read_word(0x110004)); - xdst = (program_read_word(0x110048)); - ydst = (program_read_word(0x110044)); + xsrc = (memory_read_word(space, 0x110008)); + ysrc = (memory_read_word(space, 0x110004)); + xdst = (memory_read_word(space, 0x110048)); + ydst = (memory_read_word(space, 0x110044)); /*Here we check the destination sprite width*/ /*0x4a4/0x4c4*/ - xparam = check_calc(program_read_word(cop_register[2])); + xparam = check_calc(memory_read_word(space, cop_register[2])); /*Here we check the destination sprite height*/ /*0x4a6/0x4c6*/ - yparam = check_calc(program_read_word(cop_register[3])); + yparam = check_calc(memory_read_word(space, cop_register[3])); if(!xparam || !yparam) - popmessage("SRC:%04x %04x DST:%04x %04x V:%08x %08x",xsrc,ysrc,xdst,ydst,program_read_word(cop_register[2]),program_read_word(cop_register[3])); + popmessage("SRC:%04x %04x DST:%04x %04x V:%08x %08x",xsrc,ysrc,xdst,ydst,memory_read_word(space, cop_register[2]),memory_read_word(space, cop_register[3])); if(xdst >= (xsrc-xparam) && ydst >= (ysrc-yparam) && xdst <= (xsrc+xparam) && ydst <= (ysrc+yparam)) return 0;//sprites collide @@ -596,17 +596,17 @@ static UINT16 hit_check_jsr(void) /*Heated Barrel*/ /*command 0x8100 will check for the direction of the sprite*/ /*command 0x8900 will check the "point" movement*/ -static void cop2_move3_prot(void) +static void cop2_move3_prot(const address_space *space) { static INT16 x_pl,x_en; static INT16 y_pl,y_en; static INT16 x_dis,y_dis; static INT16 dir,dis; - x_pl = program_read_word(cop_register[1]+0x8); - x_en = program_read_word(cop_register[0]+0x8); - dis = ((program_read_word(cop_register[0]+0x34) & 0xf0) >> 4); - y_pl = program_read_word(cop_register[1]+0x4); - y_en = program_read_word(cop_register[0]+0x4); + x_pl = memory_read_word(space, cop_register[1]+0x8); + x_en = memory_read_word(space, cop_register[0]+0x8); + dis = ((memory_read_word(space, cop_register[0]+0x34) & 0xf0) >> 4); + y_pl = memory_read_word(space, cop_register[1]+0x4); + y_en = memory_read_word(space, cop_register[0]+0x4); /* xxxx ---- select the direction of the enemy sprite @@ -645,7 +645,7 @@ static void cop2_move3_prot(void) dir = DOWN; } - program_write_word(cop_register[0]+0x36,dir); + memory_write_word(space, cop_register[0]+0x36,dir); /*TODO*/ x_dis = (x_pl-x_en); @@ -669,12 +669,12 @@ static void cop2_move3_prot(void) //if(x_en > x_pl) // x_dis^=0xffff; - program_write_word(cop_register[0]+0x10,y_dis); - program_write_word(cop_register[0]+0x14,x_dis); + memory_write_word(space, cop_register[0]+0x10,y_dis); + memory_write_word(space, cop_register[0]+0x14,x_dis); } /**/ -static UINT16 cop2_hit_prot(void) +static UINT16 cop2_hit_prot(const address_space *space) { static INT16 xsrc,xdst; static INT16 ysrc,ydst; @@ -682,13 +682,13 @@ static UINT16 cop2_hit_prot(void) static INT16 param1,param2; static INT16 val; - param1 = program_read_word(cop_register[2]); - param2 = program_read_word(cop_register[3]); + param1 = memory_read_word(space, cop_register[2]); + param2 = memory_read_word(space, cop_register[3]); - xsrc = program_read_word(cop_register[0]+0x8) + program_read_word(cop_register[0]+0x14); - ysrc = program_read_word(cop_register[0]+0x4) + program_read_word(cop_register[0]+0x10); - xdst = program_read_word(cop_register[1]+0x8) + program_read_word(cop_register[1]+0x14); - ydst = program_read_word(cop_register[1]+0x4) + program_read_word(cop_register[1]+0x10); + xsrc = memory_read_word(space, cop_register[0]+0x8) + memory_read_word(space, cop_register[0]+0x14); + ysrc = memory_read_word(space, cop_register[0]+0x4) + memory_read_word(space, cop_register[0]+0x10); + xdst = memory_read_word(space, cop_register[1]+0x8) + memory_read_word(space, cop_register[1]+0x14); + ydst = memory_read_word(space, cop_register[1]+0x4) + memory_read_word(space, cop_register[1]+0x10); // xp = (param1 & 0x00f0) >> 4; // yp = (param1 & 0x0f00) >> 8; @@ -713,14 +713,14 @@ static UINT16 cop2_hit_prot(void) return 3; } -static void cop2_move2_prot(void) +static void cop2_move2_prot(const address_space *space) { static INT16 xsrc,ysrc; static INT16 param2; - xsrc = program_read_word(cop_register[0]+0x14); - ysrc = program_read_word(cop_register[0]+0x10); - param2 = program_read_word(cop_register[3]); + xsrc = memory_read_word(space, cop_register[0]+0x14); + ysrc = memory_read_word(space, cop_register[0]+0x10); + param2 = memory_read_word(space, cop_register[3]); switch(param2) { @@ -734,8 +734,8 @@ static void cop2_move2_prot(void) case 0x18: ysrc++; xsrc++; break; //down-right } - program_write_word(cop_register[0]+0x14,xsrc); - program_write_word(cop_register[0]+0x10,ysrc); + memory_write_word(space, cop_register[0]+0x14,xsrc); + memory_write_word(space, cop_register[0]+0x10,ysrc); } @@ -946,14 +946,14 @@ INLINE void cop_ram_w(cop_state *cop, UINT16 offset, UINT16 data) INLINE UINT32 r32(offs_t address) { - return (program_read_word(address + 0) << 0) | - (program_read_word(address + 2) << 16); + return (memory_read_word(space, address + 0) << 0) | + (memory_read_word(space, address + 2) << 16); } INLINE void w32(offs_t address, UINT32 data) { - program_write_word(address + 0, data >> 0); - program_write_word(address + 2, data >> 16); + memory_write_word(space, address + 0, data >> 0); + memory_write_word(space, address + 2, data >> 16); } @@ -1025,7 +1025,7 @@ WRITE16_HANDLER( raiden2_cop2_w ) int count = (cop_ram_r(cop, 0x47a) + 1) << 5; COP_LOG(("%05X:COP RAM clear from %05X to %05X\n", cpu_get_pc(space->cpu), addr, addr + count)); while (count--) - program_write_byte(addr++, 0); + memory_write_byte(space, addr++, 0); } else { @@ -1274,7 +1274,7 @@ static WRITE16_HANDLER( generic_cop_w ) for (i=address;i<address+length;i+=2) { - program_write_word(i, 0x0000); + memory_write_word(space, i, 0x0000); } } break; @@ -1350,12 +1350,12 @@ WRITE16_HANDLER( heatbrl_mcu_w ) break; case 0x8900: { - cop2_move3_prot(); + cop2_move3_prot(space); break; } case 0x205: { - cop2_move2_prot(); + cop2_move2_prot(space); break; } case 0xa100: @@ -1366,7 +1366,7 @@ WRITE16_HANDLER( heatbrl_mcu_w ) break; case 0xb880: { - xy_check = cop2_hit_prot(); + xy_check = cop2_hit_prot(space); break; } default: @@ -1460,30 +1460,30 @@ WRITE16_HANDLER( cupsoc_mcu_w ) case 0x8100: { UINT32 src = cop_register[0]; - program_write_word(src+0x36,0xffc0); + memory_write_word(space, src+0x36,0xffc0); break; } case 0x8900: { UINT32 src = cop_register[0]; - program_write_word(src+0x36,0xff80); + memory_write_word(space, src+0x36,0xff80); break; } /*Right*/ case 0x0205: { UINT32 src = cop_register[0]; - INT16 y = program_read_word(src+0x4); - INT16 x = program_read_word(src+0x8); - INT16 y_rel = program_read_word(src+0x10); - INT16 x_rel = program_read_word(src+0x14); - program_write_word(src+0x4,(y+y_rel)); - program_write_word(src+0x8,(x+x_rel)); + INT16 y = memory_read_word(space, src+0x4); + INT16 x = memory_read_word(space, src+0x8); + INT16 y_rel = memory_read_word(space, src+0x10); + INT16 x_rel = memory_read_word(space, src+0x14); + memory_write_word(space, src+0x4,(y+y_rel)); + memory_write_word(space, src+0x8,(x+x_rel)); /*logerror("%08x %08x %08x %08x %08x\n",cop_register[0], - program_read_word(cop_reg[0]+0x4), - program_read_word(cop_reg[0]+0x8), - program_read_word(cop_reg[0]+0x10), - program_read_word(cop_reg[0]+0x14));*/ + memory_read_word(space, cop_reg[0]+0x4), + memory_read_word(space, cop_reg[0]+0x8), + memory_read_word(space, cop_reg[0]+0x10), + memory_read_word(space, cop_reg[0]+0x14));*/ break; } /*???*/ @@ -1491,10 +1491,10 @@ WRITE16_HANDLER( cupsoc_mcu_w ) { //UINT32 dst = cop_register[0]; //UINT32 dst = cop_register[1]; - //program_write_word(dst, mame_rand(space->machine)/*program_read_word(src)*/); - //program_write_word(dst+2,mame_rand(space->machine)/*program_read_word(src+2)*/); - //program_write_word(dst+4,mame_rand(space->machine)/*program_read_word(src+4)*/); - //program_write_word(dst+6,mame_rand(space->machine)/*program_read_word(src+6)*/); + //memory_write_word(space, dst, mame_rand(space->machine)/*memory_read_word(space, src)*/); + //memory_write_word(space, dst+2,mame_rand(space->machine)/*memory_read_word(space, src+2)*/); + //memory_write_word(space, dst+4,mame_rand(space->machine)/*memory_read_word(space, src+4)*/); + //memory_write_word(space, dst+6,mame_rand(space->machine)/*memory_read_word(space, src+6)*/); //logerror("%04x\n",cop_register[0]); break; } @@ -1737,8 +1737,8 @@ WRITE16_HANDLER( sdgndmrb_mcu_w ) dma_src+=4; //cop_register[5]+=4; s_i = dma_size; - //cop_register[5]+=((program_read_word(0x110000) & 0x000f) * 8); - //program_write_word(0x1004c8,cop_register[5] & 0xffff); + //cop_register[5]+=((memory_read_word(space, 0x110000) & 0x000f) * 8); + //memory_write_word(space, 0x1004c8,cop_register[5] & 0xffff); //dma_status = 1; break; } @@ -1748,30 +1748,30 @@ WRITE16_HANDLER( sdgndmrb_mcu_w ) break; case 0xb900: { - xy_check = hit_check_jsr(); + xy_check = hit_check_jsr(space); break; } /*bullet movement protection,conflicts with [3],will be worked out*/ case 0x8100: { - //move3x_prot_jsr(); + //move3x_prot_jsr(space); break; } case 0x8900: { - //move3y_prot_jsr(); + //move3y_prot_jsr(space); break; } case 0x0205:/*do the job [3]*/ { - moveprot_jsr(); + moveprot_jsr(space); break; } case 0x138e:/*do the job [4]*/ break; case 0x3bb0: { - move2prot_jsr(); + move2prot_jsr(space); break; } default: @@ -1784,7 +1784,7 @@ WRITE16_HANDLER( sdgndmrb_mcu_w ) { if(cop_mcu_ram[offset] == 0xc480) { - dma_transfer(); + dma_transfer(space); s_i--; if(s_i == 0) dma_status = 1; @@ -1934,16 +1934,16 @@ WRITE16_HANDLER( legionna_mcu_w ) { static UINT16 xy_data[2]; static UINT8 k; - xy_data[0] = program_read_word(cop_register[2]); - xy_data[1] = program_read_word(cop_register[3]); + xy_data[0] = memory_read_word(space, cop_register[2]); + xy_data[1] = memory_read_word(space, cop_register[3]); k = (cop_mcu_ram[offset] == 0x0205) ? ENEMY : PLAYER; - protection_move_jsr(cop_register[0],k); - //protection_move_jsr(cop_register[1]); //??? + protection_move_jsr(space,cop_register[0],k); + //protection_move_jsr(space,cop_register[1]); //??? //popmessage("%08x %08x %04x %04x",cop_register[0],cop_register[1],xy_data[0],xy_data[1]); } else if(cop_mcu_ram[offset] == 0x3bb0 || cop_mcu_ram[offset] == 0x138e) { - protection_hit_jsr(cop_register[0],cop_register[1]); + protection_hit_jsr(space,cop_register[0],cop_register[1]); } break; } diff --git a/src/mame/machine/snes.c b/src/mame/machine/snes.c index 3e9ddf57c97..0e42b420719 100644 --- a/src/mame/machine/snes.c +++ b/src/mame/machine/snes.c @@ -107,7 +107,8 @@ static TIMER_CALLBACK( snes_hirq_tick_callback ) static TIMER_CALLBACK( snes_scanline_tick ) { // make sure we're in the 65816's context since we're messing with the OAM and stuff - cpu_push_context(machine->cpu[0]); + const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(space->cpu); /* Increase current line - we want to latch on this line during it, not after it */ snes_ppu.beam.current_vert = video_screen_get_vpos(machine->primary_screen); @@ -160,8 +161,8 @@ static TIMER_CALLBACK( snes_scanline_tick ) { if(!(snes_ram[INIDISP]&0x80)) { - program_write_byte(OAMADDL, snes_ppu.oam.saved_address_low ); /* Reset oam address */ - program_write_byte(OAMADDH, snes_ppu.oam.saved_address_high ); + memory_write_byte(space, OAMADDL, snes_ppu.oam.saved_address_low ); /* Reset oam address */ + memory_write_byte(space, OAMADDH, snes_ppu.oam.saved_address_high ); } snes_ram[HVBJOY] |= 0x81; /* Set vblank bit to on & indicate controllers being read */ snes_ram[RDNMI] |= 0x80; /* Set NMI occured bit */ @@ -241,6 +242,7 @@ static TIMER_CALLBACK( snes_scanline_tick ) /* This is called at the start of hblank *before* the scanline indicated in current_vert! */ static TIMER_CALLBACK( snes_hblank_tick ) { + const address_space *cpu0space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); int nextscan; snes_ppu.beam.current_vert = video_screen_get_vpos(machine->primary_screen); @@ -249,7 +251,7 @@ static TIMER_CALLBACK( snes_hblank_tick ) timer_adjust_oneshot(snes_hblank_timer, attotime_never, 0); // we must guarantee the 65816's context for HDMA to work - cpu_push_context(machine->cpu[0]); + cpu_push_context(cpu0space->cpu); /* draw a scanline */ if (snes_ppu.beam.current_vert <= snes_ppu.beam.last_visible_line) @@ -258,7 +260,7 @@ static TIMER_CALLBACK( snes_hblank_tick ) { /* Do HDMA */ if( snes_ram[HDMAEN] ) - snes_hdma(); + snes_hdma(cpu0space); video_screen_update_partial(machine->primary_screen, snes_ppu.beam.current_vert-1); } @@ -463,7 +465,7 @@ READ8_HANDLER( snes_r_io ) { UINT32 addr = ((snes_ram[WMADDH] & 0x1) << 16) | (snes_ram[WMADDM] << 8) | snes_ram[WMADDL]; - value = program_read_byte(0x7e0000 + addr++); + value = memory_read_byte(space, 0x7e0000 + addr++); addr &= 0x1ffff; snes_ram[WMADDH] = (addr >> 16) & 0x1; snes_ram[WMADDM] = (addr >> 8) & 0xff; @@ -969,7 +971,7 @@ WRITE8_HANDLER( snes_w_io ) case WMDATA: /* Data to write to WRAM */ { UINT32 addr = ((snes_ram[WMADDH] & 0x1) << 16) | (snes_ram[WMADDM] << 8) | snes_ram[WMADDL]; - program_write_byte(0x7e0000 + addr++, data ); + memory_write_byte(space, 0x7e0000 + addr++, data ); addr &= 0x1ffff; snes_ram[WMADDH] = (addr >> 16) & 0x1; snes_ram[WMADDM] = (addr >> 8) & 0xff; @@ -1035,7 +1037,7 @@ WRITE8_HANDLER( snes_w_io ) case VTIMEH: /* V-Count timer settings (high) */ break; case MDMAEN: /* GDMA channel designation and trigger */ - snes_gdma( data ); + snes_gdma( space, data ); data = 0; /* Once DMA is done we need to reset all bits to 0 */ break; case HDMAEN: /* HDMA channel designation */ @@ -1176,7 +1178,7 @@ READ8_HANDLER( snes_r_bank1 ) UINT16 address = offset & 0xffff; if (address < 0x2000) /* Mirror of Low RAM */ - value = program_read_byte(0x7e0000 + address); + value = memory_read_byte(space, 0x7e0000 + address); else if (address < 0x6000) /* I/O */ value = snes_r_io(space, address); else if (address < 0x8000) @@ -1207,7 +1209,7 @@ READ8_HANDLER( snes_r_bank2 ) UINT16 address = offset & 0xffff; if (address < 0x2000) /* Mirror of Low RAM */ - value = program_read_byte(0x7e0000 + address); + value = memory_read_byte(space, 0x7e0000 + address); else if (address < 0x6000) /* I/O */ value = snes_r_io(space, address); else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ @@ -1308,11 +1310,11 @@ READ8_HANDLER( snes_r_bank6 ) if (address < 0x8000) { if (snes_cart.mode != SNES_MODE_25) - value = program_read_byte(offset); + value = memory_read_byte(space, offset); else /* Mode 25 has SRAM not mirrored from lower banks */ { if (address < 0x6000) - value = program_read_byte(offset); + value = memory_read_byte(space, offset); else if ((offset >= 0x300000) && (snes_cart.sram > 0)) { int mask = ((snes_cart.sram * 1024) - 1); /* Limit SRAM size to what's actually present */ @@ -1342,7 +1344,7 @@ READ8_HANDLER( snes_r_bank7 ) if (snes_cart.mode & 5) /* Mode 20 & 22 */ { if (address < 0x8000) - value = program_read_byte(0x400000 + offset); + value = memory_read_byte(space, 0x400000 + offset); else value = snes_ram[0xc00000 + offset]; } @@ -1359,7 +1361,7 @@ WRITE8_HANDLER( snes_w_bank1 ) UINT16 address = offset & 0xffff; if (address < 0x2000) /* Mirror of Low RAM */ - program_write_byte(0x7e0000 + address, data); + memory_write_byte(space, 0x7e0000 + address, data); else if (address < 0x6000) /* I/O */ snes_w_io(space, address, data); else if (address < 0x8000) @@ -1387,7 +1389,7 @@ WRITE8_HANDLER( snes_w_bank2 ) UINT16 address = offset & 0xffff; if (address < 0x2000) /* Mirror of Low RAM */ - program_write_byte(0x7e0000 + address, data); + memory_write_byte(space, 0x7e0000 + address, data); else if (address < 0x6000) /* I/O */ snes_w_io(space, address, data); else if (address < 0x8000) /* SRAM for mode_21, Reserved othewise */ @@ -1526,6 +1528,7 @@ WRITE8_HANDLER( snes_w_bank7 ) static void snes_init_ram(running_machine *machine) { + const address_space *cpu0space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); int i; /* Init DSP1 */ @@ -1542,10 +1545,10 @@ static void snes_init_ram(running_machine *machine) /* Init work RAM - 0x55 isn't exactly right but it's close */ /* make sure it happens to the 65816 (CPU 0) */ - cpu_push_context(machine->cpu[0]); + cpu_push_context(cpu0space->cpu); for (i = 0; i < (128*1024); i++) { - program_write_byte(0x7e0000 + i, 0x55); + memory_write_byte(cpu0space, 0x7e0000 + i, 0x55); } cpu_pop_context(); @@ -1807,7 +1810,7 @@ DRIVER_INIT( snes_hirom ) *************************************/ -void snes_hdma() +void snes_hdma(const address_space *space) { UINT8 mask = 1, dma = 0, i, contmode; UINT16 bbus; @@ -1824,7 +1827,7 @@ void snes_hdma() abus = (snes_ram[SNES_DMA_BASE + dma + 4] << 16) + (snes_ram[SNES_DMA_BASE + dma + 9] << 8) + snes_ram[SNES_DMA_BASE + dma + 8]; /* Get the number of lines */ - snes_ram[SNES_DMA_BASE + dma + 0xa] = program_read_byte(abus); + snes_ram[SNES_DMA_BASE + dma + 0xa] = memory_read_byte(space, abus); if( !snes_ram[SNES_DMA_BASE + dma + 0xa] ) { /* No more lines so clear HDMA */ @@ -1836,8 +1839,8 @@ void snes_hdma() snes_ram[SNES_DMA_BASE + dma + 9] = (abus >> 8) & 0xff; if( snes_ram[SNES_DMA_BASE + dma] & 0x40 ) { - snes_ram[SNES_DMA_BASE + dma + 5] = program_read_byte(abus++); - snes_ram[SNES_DMA_BASE + dma + 6] = program_read_byte(abus++); + snes_ram[SNES_DMA_BASE + dma + 5] = memory_read_byte(space, abus++); + snes_ram[SNES_DMA_BASE + dma + 6] = memory_read_byte(space, abus++); snes_ram[SNES_DMA_BASE + dma + 8] = abus & 0xff; snes_ram[SNES_DMA_BASE + dma + 9] = (abus >> 8) & 0xff; } @@ -1860,40 +1863,40 @@ void snes_hdma() { case 0: /* 1 address */ { - program_write_byte(bbus, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); } break; case 5: /* 4 bytes to 2 addresses (l,h,l,h) */ { - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); } break; case 1: /* 2 addresses (l,h) */ { - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); } break; case 2: /* Write twice (l,l) */ case 6: { - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); } break; case 3: /* 2 addresses/Write twice (l,l,h,h) */ case 7: { - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); } break; case 4: /* 4 addresses (l,h,l,h) */ { - program_write_byte(bbus, program_read_byte(abus++)); - program_write_byte(bbus + 1, program_read_byte(abus++)); - program_write_byte(bbus + 2, program_read_byte(abus++)); - program_write_byte(bbus + 3, program_read_byte(abus++)); + memory_write_byte(space, bbus, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 2, memory_read_byte(space, abus++)); + memory_write_byte(space, bbus + 3, memory_read_byte(space, abus++)); } break; default: #ifdef MAME_DEBUG @@ -1934,7 +1937,7 @@ void snes_hdma() } } -void snes_gdma( UINT8 channels ) +void snes_gdma( const address_space *space, UINT8 channels ) { UINT8 mask = 1, dma = 0, i; INT8 increment; @@ -1981,9 +1984,9 @@ void snes_gdma( UINT8 channels ) while( length-- ) { if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus) ); else /* CPU->PPU */ - program_write_byte(bbus, program_read_byte(abus) ); + memory_write_byte(space, bbus, memory_read_byte(space, abus) ); abus += increment; } } break; @@ -1993,16 +1996,16 @@ void snes_gdma( UINT8 channels ) while( length-- ) { if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus) ); else /* CPU->PPU */ - program_write_byte(bbus, program_read_byte(abus) ); + memory_write_byte(space, bbus, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 1) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 1) ); else /* CPU->PPU */ - program_write_byte(bbus + 1, program_read_byte(abus) ); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus) ); abus += increment; } } break; @@ -2012,30 +2015,30 @@ void snes_gdma( UINT8 channels ) while( length-- ) { if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus) ); else /* CPU->PPU */ - program_write_byte(bbus, program_read_byte(abus) ); + memory_write_byte(space, bbus, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus) ); else /* CPU->PPU */ - program_write_byte(bbus, program_read_byte(abus) ); + memory_write_byte(space, bbus, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 1) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 1) ); else /* CPU->PPU */ - program_write_byte(bbus + 1, program_read_byte(abus) ); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 1) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 1) ); else /* CPU->PPU */ - program_write_byte(bbus + 1, program_read_byte(abus) ); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus) ); abus += increment; } } break; @@ -2044,30 +2047,30 @@ void snes_gdma( UINT8 channels ) while( length-- ) { if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus) ); else /* CPU->PPU */ - program_write_byte(bbus, program_read_byte(abus) ); + memory_write_byte(space, bbus, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 1) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 1) ); else /* CPU->PPU */ - program_write_byte(bbus + 1, program_read_byte(abus) ); + memory_write_byte(space, bbus + 1, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 2) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 2) ); else /* CPU->PPU */ - program_write_byte(bbus + 2, program_read_byte(abus) ); + memory_write_byte(space, bbus + 2, memory_read_byte(space, abus) ); abus += increment; if( !(length--) ) break; if( snes_ram[SNES_DMA_BASE + dma] & 0x80 ) /* PPU->CPU */ - program_write_byte(abus, program_read_byte(bbus + 3) ); + memory_write_byte(space, abus, memory_read_byte(space, bbus + 3) ); else /* CPU->PPU */ - program_write_byte(bbus + 3, program_read_byte(abus) ); + memory_write_byte(space, bbus + 3, memory_read_byte(space, abus) ); abus += increment; } } break; diff --git a/src/mame/machine/taitosj.c b/src/mame/machine/taitosj.c index 8a6040e92be..e7f7ffad0f5 100644 --- a/src/mame/machine/taitosj.c +++ b/src/mame/machine/taitosj.c @@ -216,10 +216,11 @@ WRITE8_HANDLER( taitosj_68705_portB_w ) } if (~data & 0x10) { + const address_space *cpu0space = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); LOG(("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu),portA_out,address)); - cpu_push_context(space->machine->cpu[0]); - program_write_byte(address, portA_out); + cpu_push_context(cpu0space->cpu); + memory_write_byte(cpu0space, address, portA_out); cpu_pop_context(); /* increase low 8 bits of latched address for burst writes */ @@ -227,8 +228,9 @@ WRITE8_HANDLER( taitosj_68705_portB_w ) } if (~data & 0x20) { - cpu_push_context(space->machine->cpu[0]); - portA_in = program_read_byte(address); + const address_space *cpu0space = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(cpu0space->cpu); + portA_in = memory_read_byte(cpu0space, address); cpu_pop_context(); LOG(("%04x: 68705 read %02x from address %04x\n",cpu_get_pc(space->cpu),portA_in,address)); } diff --git a/src/mame/machine/tatsumi.c b/src/mame/machine/tatsumi.c index 28e74821164..b09b6c10a86 100644 --- a/src/mame/machine/tatsumi.c +++ b/src/mame/machine/tatsumi.c @@ -86,6 +86,7 @@ WRITE16_HANDLER( apache3_irq_ack_w ) READ16_HANDLER( apache3_v30_v20_r ) { + const address_space *targetspace = cpu_get_address_space(space->machine->cpu[2], ADDRESS_SPACE_PROGRAM); UINT8 value; /* Each V20 byte maps to a V30 word */ @@ -98,22 +99,24 @@ READ16_HANDLER( apache3_v30_v20_r ) else logerror("%08x: unmapped read z80 rom %08x\n",cpu_get_pc(space->cpu),offset); - cpu_push_context(space->machine->cpu[2]); - value = program_read_byte(offset); + cpu_push_context(targetspace->cpu); + value = memory_read_byte(targetspace, offset); cpu_pop_context(); return value | 0xff00; } WRITE16_HANDLER( apache3_v30_v20_w ) { + const address_space *targetspace = cpu_get_address_space(space->machine->cpu[2], ADDRESS_SPACE_PROGRAM); + if ((tatsumi_control_word&0xe0)!=0x80) logerror("%08x: write unmapped v30 rom %08x\n",cpu_get_pc(space->cpu),offset); /* Only 8 bits of the V30 data bus are connected - ignore writes to the other half */ if (ACCESSING_BITS_0_7) { - cpu_push_context(space->machine->cpu[2]); - program_write_byte(offset, data&0xff); + cpu_push_context(targetspace->cpu); + memory_write_byte(targetspace, offset, data&0xff); cpu_pop_context(); } } @@ -154,28 +157,31 @@ WRITE16_HANDLER( apache3_a0000_w ) READ16_HANDLER( roundup_v30_z80_r ) { + const address_space *targetspace = cpu_get_address_space(space->machine->cpu[2], ADDRESS_SPACE_PROGRAM); UINT8 value; /* Each Z80 byte maps to a V30 word */ if (tatsumi_control_word&0x20) offset+=0x8000; /* Upper half */ - cpu_push_context(space->machine->cpu[2]); - value = program_read_byte(offset); + cpu_push_context(targetspace->cpu); + value = memory_read_byte(targetspace, offset); cpu_pop_context(); return value | 0xff00; } WRITE16_HANDLER( roundup_v30_z80_w ) { + const address_space *targetspace = cpu_get_address_space(space->machine->cpu[2], ADDRESS_SPACE_PROGRAM); + /* Only 8 bits of the V30 data bus are connected - ignore writes to the other half */ if (ACCESSING_BITS_0_7) { if (tatsumi_control_word&0x20) offset+=0x8000; /* Upper half of Z80 address space */ - cpu_push_context(space->machine->cpu[2]); - program_write_byte(offset, data&0xff); + cpu_push_context(targetspace->cpu); + memory_write_byte(targetspace, offset, data&0xff); cpu_pop_context(); } } diff --git a/src/mame/machine/toaplan1.c b/src/mame/machine/toaplan1.c index b9f7136dfa2..d2b14fbaff1 100644 --- a/src/mame/machine/toaplan1.c +++ b/src/mame/machine/toaplan1.c @@ -61,9 +61,14 @@ READ16_HANDLER( demonwld_dsp_r ) { /* DSP can read data from main CPU RAM via DSP IO port 1 */ + const address_space *mainspace; UINT16 input_data = 0; switch (main_ram_seg) { - case 0xc00000: cpu_push_context(space->machine->cpu[0]); input_data = program_read_word(main_ram_seg + dsp_addr_w); cpu_pop_context(); break; + case 0xc00000: mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + input_data = memory_read_word(mainspace, main_ram_seg + dsp_addr_w); + cpu_pop_context(); + break; default: logerror("DSP PC:%04x Warning !!! IO reading from %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); } logerror("DSP PC:%04x IO read %04x at %08x (port 1)\n",cpu_get_previouspc(space->cpu),input_data,main_ram_seg + dsp_addr_w); @@ -72,12 +77,15 @@ READ16_HANDLER( demonwld_dsp_r ) WRITE16_HANDLER( demonwld_dsp_w ) { + const address_space *mainspace; + /* Data written to main CPU RAM via DSP IO port 1 */ dsp_execute = 0; switch (main_ram_seg) { case 0xc00000: if ((dsp_addr_w < 3) && (data == 0)) dsp_execute = 1; - cpu_push_context(space->machine->cpu[0]); - program_write_word(main_ram_seg + dsp_addr_w, data); + mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + memory_write_word(mainspace, main_ram_seg + dsp_addr_w, data); cpu_pop_context(); break; default: logerror("DSP PC:%04x Warning !!! IO writing to %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); } diff --git a/src/mame/machine/twincobr.c b/src/mame/machine/twincobr.c index c94d7d567b5..c37dbc7e967 100644 --- a/src/mame/machine/twincobr.c +++ b/src/mame/machine/twincobr.c @@ -67,12 +67,14 @@ READ16_HANDLER( twincobr_dsp_r ) { /* DSP can read data from main CPU RAM via DSP IO port 1 */ + const address_space *mainspace; UINT16 input_data = 0; switch (main_ram_seg) { case 0x30000: case 0x40000: - case 0x50000: cpu_push_context(space->machine->cpu[0]); - input_data = program_read_word(main_ram_seg + dsp_addr_w); + case 0x50000: mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + input_data = memory_read_word(mainspace, main_ram_seg + dsp_addr_w); cpu_pop_context(); break; default: logerror("DSP PC:%04x Warning !!! IO reading from %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); break; } @@ -82,13 +84,16 @@ READ16_HANDLER( twincobr_dsp_r ) WRITE16_HANDLER( twincobr_dsp_w ) { + const address_space *mainspace; + /* Data written to main CPU RAM via DSP IO port 1 */ dsp_execute = 0; switch (main_ram_seg) { case 0x30000: if ((dsp_addr_w < 3) && (data == 0)) dsp_execute = 1; case 0x40000: - case 0x50000: cpu_push_context(space->machine->cpu[0]); - program_write_word(main_ram_seg + dsp_addr_w, data); + case 0x50000: mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + memory_write_word(mainspace, main_ram_seg + dsp_addr_w, data); cpu_pop_context(); break; default: logerror("DSP PC:%04x Warning !!! IO writing to %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); break; } @@ -114,13 +119,15 @@ READ16_HANDLER( wardner_dsp_r ) { /* DSP can read data from main CPU RAM via DSP IO port 1 */ + const address_space *mainspace; UINT16 input_data = 0; switch (main_ram_seg) { case 0x7000: case 0x8000: - case 0xa000: cpu_push_context(space->machine->cpu[0]); - input_data = program_read_byte(main_ram_seg + (dsp_addr_w + 0)) - | (program_read_byte(main_ram_seg + (dsp_addr_w + 1)) << 8); + case 0xa000: mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + input_data = memory_read_byte(mainspace, main_ram_seg + (dsp_addr_w + 0)) + | (memory_read_byte(mainspace, main_ram_seg + (dsp_addr_w + 1)) << 8); cpu_pop_context(); break; default: logerror("DSP PC:%04x Warning !!! IO reading from %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); break; } @@ -130,14 +137,17 @@ READ16_HANDLER( wardner_dsp_r ) WRITE16_HANDLER( wardner_dsp_w ) { + const address_space *mainspace; + /* Data written to main CPU RAM via DSP IO port 1 */ dsp_execute = 0; switch (main_ram_seg) { case 0x7000: if ((dsp_addr_w < 3) && (data == 0)) dsp_execute = 1; case 0x8000: - case 0xa000: cpu_push_context(space->machine->cpu[0]); - program_write_byte(main_ram_seg + (dsp_addr_w + 0), (data & 0xff)); - program_write_byte(main_ram_seg + (dsp_addr_w + 1), ((data >> 8) & 0xff)); + case 0xa000: mainspace = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); + cpu_push_context(mainspace->cpu); + memory_write_byte(mainspace, main_ram_seg + (dsp_addr_w + 0), (data & 0xff)); + memory_write_byte(mainspace, main_ram_seg + (dsp_addr_w + 1), ((data >> 8) & 0xff)); cpu_pop_context(); break; default: logerror("DSP PC:%04x Warning !!! IO writing to %08x (port 1)\n",cpu_get_previouspc(space->cpu),main_ram_seg + dsp_addr_w); break; } diff --git a/src/mame/video/astrocde.c b/src/mame/video/astrocde.c index 19c047fb26a..4bbef180bfd 100644 --- a/src/mame/video/astrocde.c +++ b/src/mame/video/astrocde.c @@ -727,7 +727,7 @@ WRITE8_HANDLER( astrocade_funcgen_w ) /* OR/XOR */ if (funcgen_control & 0x30) { - UINT8 olddata = program_read_byte(0x4000 + offset); + UINT8 olddata = memory_read_byte(space, 0x4000 + offset); /* compute any intercepts */ funcgen_intercept &= 0x0f; @@ -748,7 +748,7 @@ WRITE8_HANDLER( astrocade_funcgen_w ) } /* write the result */ - program_write_byte(0x4000 + offset, data); + memory_write_byte(space, 0x4000 + offset, data); } @@ -788,7 +788,7 @@ INLINE void increment_dest(UINT8 curwidth) } -static void execute_blit(running_machine *machine) +static void execute_blit(const address_space *space) { /* pattern_source = counter set U7/U16/U25/U34 @@ -842,7 +842,7 @@ static void execute_blit(running_machine *machine) if (curwidth == 0 && (pattern_mode & 0x08) != 0) busdata = 0; else - busdata = program_read_byte(busaddr); + busdata = memory_read_byte(space, busaddr); /* increment the appropriate address */ if ((pattern_mode & 0x01) == 0) @@ -854,7 +854,7 @@ static void execute_blit(running_machine *machine) /* address is selected between source/dest based on mode.d0 */ busaddr = ((pattern_mode & 0x01) != 0) ? pattern_source : pattern_dest; - program_write_byte(busaddr, busdata); + memory_write_byte(space, busaddr, busdata); /* increment the appropriate address */ if ((pattern_mode & 0x01) == 0) @@ -880,7 +880,7 @@ static void execute_blit(running_machine *machine) } while (pattern_height-- != 0); /* count cycles we ran the bus */ - cpu_adjust_icount(machine->activecpu, -cycles); + cpu_adjust_icount(space->cpu, -cycles); } @@ -915,7 +915,7 @@ WRITE8_HANDLER( astrocade_pattern_board_w ) case 6: /* height of blit and initiator */ pattern_height = data; - execute_blit(space->machine); + execute_blit(cpu_get_address_space(space->cpu, ADDRESS_SPACE_PROGRAM)); break; } } diff --git a/src/mame/video/attckufo.c b/src/mame/video/attckufo.c index 26439ed7dc8..258628246e8 100644 --- a/src/mame/video/attckufo.c +++ b/src/mame/video/attckufo.c @@ -137,6 +137,7 @@ INTERRUPT_GEN( attckufo_raster_interrupt ) VIDEO_UPDATE( attckufo ) { + const address_space *space = cpu_get_address_space(screen->machine->cpu[0], ADDRESS_SPACE_PROGRAM); int x, y, yy; for (y = cliprect->min_y & ~7; y <= cliprect->max_y; y += 8) @@ -148,13 +149,13 @@ VIDEO_UPDATE( attckufo ) for (x = cliprect->min_x & ~7; x <= cliprect->max_x; x += 8) { - UINT8 ch = program_read_byte(offs + x/8); - UINT8 attr = program_read_byte(offs + x/8 + 0x400) & 0xf; + UINT8 ch = memory_read_byte(space, offs + x/8); + UINT8 attr = memory_read_byte(space, offs + x/8 + 0x400) & 0xf; UINT16 *dest = destrow; for (yy = ymin; yy <= ymax; yy++) { - UINT8 code = program_read_byte(chargenaddr + ch * 8 + yy); + UINT8 code = memory_read_byte(space, chargenaddr + ch * 8 + yy); dest[x + 0] = (code & 0x80) ? attr : 0; dest[x + 1] = (code & 0x40) ? attr : 0; dest[x + 2] = (code & 0x20) ? attr : 0; diff --git a/src/mame/video/combatsc.c b/src/mame/video/combatsc.c index a9de8083de3..8df42c9450a 100644 --- a/src/mame/video/combatsc.c +++ b/src/mame/video/combatsc.c @@ -600,9 +600,10 @@ byte #4: static void bootleg_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit ) { + const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); const gfx_element *gfx = machine->gfx[circuit+2]; - int limit = ( circuit) ? (program_read_byte(0xc2)*256 + program_read_byte(0xc3)) : (program_read_byte(0xc0)*256 + program_read_byte(0xc1)); + int limit = ( circuit) ? (memory_read_byte(space, 0xc2)*256 + memory_read_byte(space, 0xc3)) : (memory_read_byte(space, 0xc0)*256 + memory_read_byte(space, 0xc1)); const UINT8 *finish; source+=0x1000; |
