src/mess/drivers/mz2500.c
| r8929 | r8930 | |
| 124 | 124 | |
| 125 | 125 | count = 0x70000; |
| 126 | 126 | |
| 127 | | if(tv_mode != 1) |
| 128 | | popmessage("%02x",tv_mode); |
| 127 | // if(tv_mode != 1) |
| 128 | // popmessage("%02x %02x %02x",tv_mode,text_reg[1],text_reg[2]); |
| 129 | 129 | |
| 130 | 130 | for (y=0;y<25;y++) |
| 131 | 131 | { |
| r8929 | r8930 | |
| 230 | 230 | #endif |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | static void draw_cg16_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) |
| 234 | { |
| 235 | static UINT32 count; |
| 236 | UINT8 *vram = memory_region(machine, "maincpu"); |
| 237 | UINT8 pen,pen_bit[4]; |
| 238 | int x,y,xi; |
| 239 | |
| 240 | count = 0x40000; |
| 241 | |
| 242 | for(y=0;y<200;y++) |
| 243 | { |
| 244 | for(x=0;x<320;x+=8) |
| 245 | { |
| 246 | for(xi=0;xi<8;xi++) |
| 247 | { |
| 248 | pen_bit[0] = (vram[count+0x0000]>>(xi)) & 1 ? 1 : 0; |
| 249 | pen_bit[1] = (vram[count+0x4000]>>(xi)) & 1 ? 2 : 0; |
| 250 | pen_bit[2] = (vram[count+0x8000]>>(xi)) & 1 ? 4 : 0; |
| 251 | pen_bit[3] = (vram[count+0xc000]>>(xi)) & 1 ? 0 : 8; //FIXME: this should be swapped |
| 252 | |
| 253 | pen = pen_bit[0]|pen_bit[1]|pen_bit[2]|pen_bit[3]; |
| 254 | |
| 255 | if(pen != 8) |
| 256 | *BITMAP_ADDR16(bitmap, y, x+xi) = machine->pens[pen+0x200]; |
| 257 | } |
| 258 | count++; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | |
| 233 | 263 | static void draw_cg256_screen(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) |
| 234 | 264 | { |
| 235 | 265 | static UINT32 count; |
| r8929 | r8930 | |
| 258 | 288 | static VIDEO_UPDATE( mz2500 ) |
| 259 | 289 | { |
| 260 | 290 | if(pal_select) |
| 291 | { |
| 261 | 292 | draw_tv_screen(screen->machine,bitmap,cliprect); |
| 293 | draw_cg16_screen(screen->machine,bitmap,cliprect); |
| 294 | } |
| 262 | 295 | else //4096 mode colors |
| 263 | 296 | { |
| 264 | 297 | // ... |
| r8929 | r8930 | |
| 649 | 682 | |
| 650 | 683 | static WRITE8_HANDLER( mz2500_crtc_data_w ) |
| 651 | 684 | { |
| 652 | | |
| 653 | 685 | crtc_reg[crtc_reg_index & 0x1f] = data; |
| 654 | 686 | |
| 655 | 687 | if((crtc_reg_index & 0x1f) == 0x08) //accessing VS LO reg clears VS HI reg |
| r8929 | r8930 | |
| 658 | 690 | if((crtc_reg_index & 0x1f) == 0x0a) //accessing VE LO reg clears VE HI reg |
| 659 | 691 | crtc_reg[0x0b] = 0; |
| 660 | 692 | |
| 693 | if((crtc_reg_index & 0x1f) == 0x05) //clear bitmap buffer |
| 694 | { |
| 695 | UINT32 i; |
| 696 | UINT8 *vram = memory_region(space->machine, "maincpu"); |
| 697 | |
| 698 | /* TODO: this isn't yet 100% accurate */ |
| 699 | if(crtc_reg[0x05] & 1) |
| 700 | { |
| 701 | for(i=0;i<0x4000;i++) |
| 702 | vram[i+0x40000] = 0x00; //clear B |
| 703 | } |
| 704 | if(crtc_reg[0x05] & 2) |
| 705 | { |
| 706 | for(i=0;i<0x4000;i++) |
| 707 | vram[i+0x44000] = 0x00; //clear R |
| 708 | } |
| 709 | if(crtc_reg[0x05] & 4) |
| 710 | { |
| 711 | for(i=0;i<0x4000;i++) |
| 712 | vram[i+0x48000] = 0x00; //clear G |
| 713 | } |
| 714 | if(crtc_reg[0x05] & 8) |
| 715 | { |
| 716 | for(i=0;i<0x4000;i++) |
| 717 | vram[i+0x4c000] = 0x00; //clear I |
| 718 | } |
| 719 | } |
| 720 | |
| 661 | 721 | if(crtc_reg_index & 0x80) //enable auto-inc |
| 662 | 722 | crtc_reg_index = (crtc_reg_index & 0xfc) | ((crtc_reg_index + 1) & 0x03); |
| 663 | 723 | |
| r8929 | r8930 | |
| 701 | 761 | pit8253_gate1_w(pit8253, 1); |
| 702 | 762 | } |
| 703 | 763 | |
| 764 | static UINT8 joy_mode; |
| 765 | |
| 766 | static READ8_HANDLER( mz2500_joystick_r ) |
| 767 | { |
| 768 | static UINT8 res,dir_en,in_r; |
| 769 | |
| 770 | res = 0xff; |
| 771 | in_r = ~input_port_read(space->machine,"JOY"); |
| 772 | |
| 773 | if(joy_mode & 0x40) |
| 774 | { |
| 775 | if(!(joy_mode & 0x04)) res &= ~0x20; |
| 776 | if(!(joy_mode & 0x08)) res &= ~0x10; |
| 777 | dir_en = (joy_mode & 0x20) ? 0 : 1; |
| 778 | } |
| 779 | else |
| 780 | { |
| 781 | if(!(joy_mode & 0x01)) res &= ~0x20; |
| 782 | if(!(joy_mode & 0x02)) res &= ~0x10; |
| 783 | dir_en = (joy_mode & 0x10) ? 0 : 1; |
| 784 | } |
| 785 | |
| 786 | if(dir_en) |
| 787 | res &= (~((in_r) & 0x0f)); |
| 788 | |
| 789 | res &= (~((in_r) & 0x30)); |
| 790 | |
| 791 | return res; |
| 792 | } |
| 793 | |
| 794 | static WRITE8_HANDLER( mz2500_joystick_w ) |
| 795 | { |
| 796 | joy_mode = data; |
| 797 | } |
| 798 | |
| 704 | 799 | static ADDRESS_MAP_START(mz2500_io, ADDRESS_SPACE_IO, 8) |
| 705 | 800 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 706 | 801 | // AM_RANGE(0x60, 0x63) AM_WRITE(w3100a_w) |
| r8929 | r8930 | |
| 732 | 827 | AM_RANGE(0xe4, 0xe7) AM_DEVREADWRITE("pit", pit8253_r, pit8253_w) |
| 733 | 828 | AM_RANGE(0xe8, 0xe9) AM_DEVREADWRITE("z80pio_1", z80pio_c_r, z80pio_c_w) |
| 734 | 829 | AM_RANGE(0xea, 0xeb) AM_DEVREADWRITE("z80pio_1", z80pio_d_r, z80pio_d_w) |
| 735 | | // AM_RANGE(0xef, 0xef) AM_READWRITE(joystick_r,joystick_w) |
| 830 | AM_RANGE(0xef, 0xef) AM_READWRITE(mz2500_joystick_r,mz2500_joystick_w) |
| 736 | 831 | AM_RANGE(0xf0, 0xf3) AM_WRITE(timer_w) |
| 737 | 832 | AM_RANGE(0xf4, 0xf7) AM_READ(mz2500_crtc_hvblank_r) AM_WRITE(mz2500_tv_crtc_w) |
| 738 | 833 | // AM_RANGE(0xf8, 0xf9) AM_READWRITE(extrom_r,extrom_w) |
| r8929 | r8930 | |
| 1078 | 1173 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) |
| 1079 | 1174 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1080 | 1175 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 1176 | |
| 1177 | PORT_START("JOY") |
| 1178 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY |
| 1179 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY |
| 1180 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY |
| 1181 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY |
| 1182 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 1183 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) |
| 1184 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1185 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1081 | 1186 | INPUT_PORTS_END |
| 1082 | 1187 | |
| 1083 | 1188 | static void mz2500_reset(UINT8 type) |