trunk/src/mess/drivers/vboy.c
r17435 | r17436 | |
81 | 81 | public: |
82 | 82 | vboy_state(const machine_config &mconfig, device_type type, const char *tag) |
83 | 83 | : driver_device(mconfig, type, tag), |
84 | | m_maincpu(*this, "maincpu"), |
85 | | m_l_frame_0(*this,"l_frame_0"), |
86 | | m_l_frame_1(*this,"l_frame_1"), |
87 | | m_r_frame_0(*this,"r_frame_0"), |
88 | | m_r_frame_1(*this,"r_frame_1") { } |
| 84 | m_maincpu(*this, "maincpu") |
| 85 | { } |
89 | 86 | |
90 | 87 | required_device<cpu_device> m_maincpu; |
91 | 88 | |
r17435 | r17436 | |
103 | 100 | DECLARE_READ16_MEMBER(vboy_font3_r); |
104 | 101 | DECLARE_WRITE16_MEMBER(vboy_bgmap_w); |
105 | 102 | DECLARE_READ16_MEMBER(vboy_bgmap_r); |
| 103 | DECLARE_READ8_MEMBER(vboy_lfb0_r); |
| 104 | DECLARE_READ8_MEMBER(vboy_lfb1_r); |
| 105 | DECLARE_READ8_MEMBER(vboy_rfb0_r); |
| 106 | DECLARE_READ8_MEMBER(vboy_rfb1_r); |
| 107 | DECLARE_WRITE8_MEMBER(vboy_lfb0_w); |
| 108 | DECLARE_WRITE8_MEMBER(vboy_lfb1_w); |
| 109 | DECLARE_WRITE8_MEMBER(vboy_rfb0_w); |
| 110 | DECLARE_WRITE8_MEMBER(vboy_rfb1_w); |
106 | 111 | UINT16 *m_font; |
107 | 112 | UINT16 *m_bgmap; |
108 | | required_shared_ptr<UINT32> m_l_frame_0; |
109 | | required_shared_ptr<UINT32> m_l_frame_1; |
110 | | required_shared_ptr<UINT32> m_r_frame_0; |
111 | | required_shared_ptr<UINT32> m_r_frame_1; |
| 113 | UINT8 *m_l_frame_0; |
| 114 | UINT8 *m_l_frame_1; |
| 115 | UINT8 *m_r_frame_0; |
| 116 | UINT8 *m_r_frame_1; |
112 | 117 | UINT16 *m_world; |
113 | 118 | UINT16 *m_columntab1; |
114 | 119 | UINT16 *m_columntab2; |
r17435 | r17436 | |
123 | 128 | UINT8 m_drawfb; |
124 | 129 | UINT8 m_row_num; |
125 | 130 | attotime m_input_latch_time; |
126 | | |
127 | 131 | void m_timer_tick(UINT8 setting); |
128 | 132 | void m_scanline_tick(int scanline, UINT8 screen_type); |
129 | 133 | void m_set_irq(UINT16 irq_vector); |
r17435 | r17436 | |
152 | 156 | state->m_bg_map = auto_alloc_array_clear(machine, int, 0x1000*0x1000); |
153 | 157 | state->m_ovr_map = auto_alloc_array_clear(machine, int, 8*8); |
154 | 158 | |
| 159 | // Allocate memory for framebuffers |
| 160 | state->m_l_frame_0 = auto_alloc_array_clear(machine, UINT8, 0x6000); |
| 161 | state->m_l_frame_1 = auto_alloc_array_clear(machine, UINT8, 0x6000); |
| 162 | state->m_r_frame_0 = auto_alloc_array_clear(machine, UINT8, 0x6000); |
| 163 | state->m_r_frame_1 = auto_alloc_array_clear(machine, UINT8, 0x6000); |
| 164 | |
155 | 165 | state->m_font = auto_alloc_array_clear(machine, UINT16, 2048 * 8); |
156 | 166 | state->m_bgmap = auto_alloc_array(machine, UINT16, 0x20000 >> 1); |
157 | 167 | state->m_objects = state->m_bgmap + (0x1e000 >> 1); |
r17435 | r17436 | |
484 | 494 | for(int i=31; i>=0; i--) |
485 | 495 | if (state->display_world(i, bitmap, false, cur_spt)) break; |
486 | 496 | |
| 497 | if(0) |
| 498 | { |
| 499 | int x,y; |
| 500 | |
| 501 | for(y=0;y<224;y++) |
| 502 | { |
| 503 | for(x=0;x<384;x++) |
| 504 | { |
| 505 | UINT8 pen; |
| 506 | UINT8 pix; |
| 507 | int yi; |
| 508 | |
| 509 | pen = state->m_l_frame_1[(x*0x40)+(y >> 2)]; |
| 510 | yi = ((y & 0x3)*2); |
| 511 | pix = (pen >> yi) & 3; |
| 512 | |
| 513 | bitmap.pix16(y, x) = screen.machine().pens[pix & 3]; |
| 514 | } |
| 515 | } |
| 516 | } |
| 517 | |
487 | 518 | return 0; |
488 | 519 | } |
489 | 520 | |
r17435 | r17436 | |
798 | 829 | logerror("Error writing INTPND\n"); |
799 | 830 | break; |
800 | 831 | case 0x02: //INTENB |
801 | | if(data & 0x2000) |
802 | | printf("SBHIT active\n"); |
803 | 832 | m_vip_regs.INTENB = data; |
804 | 833 | m_set_irq(0); |
805 | 834 | //printf("%04x ENB\n",data); |
r17435 | r17436 | |
1002 | 1031 | return m_bgmap[offset]; |
1003 | 1032 | } |
1004 | 1033 | |
| 1034 | READ8_MEMBER( vboy_state::vboy_lfb0_r ) { return m_l_frame_0[offset]; } |
| 1035 | READ8_MEMBER( vboy_state::vboy_lfb1_r ) { return m_l_frame_1[offset]; } |
| 1036 | READ8_MEMBER( vboy_state::vboy_rfb0_r ) { return m_r_frame_0[offset]; } |
| 1037 | READ8_MEMBER( vboy_state::vboy_rfb1_r ) { return m_r_frame_1[offset]; } |
| 1038 | WRITE8_MEMBER( vboy_state::vboy_lfb0_w ) { m_l_frame_0[offset] = data; } |
| 1039 | WRITE8_MEMBER( vboy_state::vboy_lfb1_w ) { m_l_frame_1[offset] = data; } |
| 1040 | WRITE8_MEMBER( vboy_state::vboy_rfb0_w ) { m_r_frame_0[offset] = data; } |
| 1041 | WRITE8_MEMBER( vboy_state::vboy_rfb1_w ) { m_r_frame_1[offset] = data; } |
| 1042 | |
| 1043 | |
1005 | 1044 | static ADDRESS_MAP_START( vboy_mem, AS_PROGRAM, 32, vboy_state ) |
1006 | 1045 | ADDRESS_MAP_GLOBAL_MASK(0x07ffffff) |
1007 | | AM_RANGE( 0x00000000, 0x00005fff ) AM_RAM AM_SHARE("l_frame_0") // L frame buffer 0 |
| 1046 | AM_RANGE( 0x00000000, 0x00005fff ) AM_READWRITE8(vboy_lfb0_r,vboy_lfb0_w,0xffffffff) // L frame buffer 0 |
1008 | 1047 | AM_RANGE( 0x00006000, 0x00007fff ) AM_READWRITE16(vboy_font0_r, vboy_font0_w, 0xffffffff) // Font 0-511 |
1009 | | AM_RANGE( 0x00008000, 0x0000dfff ) AM_RAM AM_SHARE("l_frame_1") // L frame buffer 1 |
| 1048 | AM_RANGE( 0x00008000, 0x0000dfff ) AM_READWRITE8(vboy_lfb1_r,vboy_lfb1_w,0xffffffff) // L frame buffer 1 |
1010 | 1049 | AM_RANGE( 0x0000e000, 0x0000ffff ) AM_READWRITE16(vboy_font1_r, vboy_font1_w, 0xffffffff) // Font 512-1023 |
1011 | | AM_RANGE( 0x00010000, 0x00015fff ) AM_RAM AM_SHARE("r_frame_0") // R frame buffer 0 |
| 1050 | AM_RANGE( 0x00010000, 0x00015fff ) AM_READWRITE8(vboy_rfb0_r,vboy_rfb0_w,0xffffffff) // R frame buffer 0 |
1012 | 1051 | AM_RANGE( 0x00016000, 0x00017fff ) AM_READWRITE16(vboy_font2_r, vboy_font2_w, 0xffffffff) // Font 1024-1535 |
1013 | | AM_RANGE( 0x00018000, 0x0001dfff ) AM_RAM AM_SHARE("r_frame_1") // R frame buffer 1 |
| 1052 | AM_RANGE( 0x00018000, 0x0001dfff ) AM_READWRITE8(vboy_rfb1_r,vboy_rfb1_w,0xffffffff) // R frame buffer 1 |
1014 | 1053 | AM_RANGE( 0x0001e000, 0x0001ffff ) AM_READWRITE16(vboy_font3_r, vboy_font3_w, 0xffffffff) // Font 1536-2047 |
1015 | 1054 | |
1016 | 1055 | AM_RANGE( 0x00020000, 0x0003ffff ) AM_READWRITE16(vboy_bgmap_r,vboy_bgmap_w, 0xffffffff) // VIPC memory |
r17435 | r17436 | |
1201 | 1240 | m_set_irq(0x0004); // RFBEND |
1202 | 1241 | } |
1203 | 1242 | |
1204 | | if(scanline == 248) |
| 1243 | if(m_row_num == ((m_vip_regs.XPCTRL & 0x1f00) >> 8)) |
1205 | 1244 | { |
1206 | | //m_set_irq(0x2000); // SBHIT |
| 1245 | m_set_irq(0x2000); // SBHIT |
1207 | 1246 | } |
1208 | 1247 | |
1209 | 1248 | } |