trunk/src/mess/video/a7800.c
| r22828 | r22829 | |
| 7 | 7 | TODO: |
| 8 | 8 | precise DMA cycle stealing |
| 9 | 9 | |
| 10 | 2013-05-08 huygens rewrite to emulate line ram buffers (mostly fixes Kung-Fu Master |
| 11 | Started DMA cycle stealing implementation |
| 12 | |
| 10 | 13 | 2003-06-23 ericball Kangaroo mode & 320 mode & other stuff |
| 11 | 14 | |
| 12 | 15 | 2002-05-14 kubecj vblank dma stop fix |
| r22828 | r22829 | |
| 34 | 37 | |
| 35 | 38 | #define DPPH 0x2c |
| 36 | 39 | #define DPPL 0x30 |
| 37 | | #define CTRL 0x3c |
| 38 | 40 | |
| 39 | | |
| 40 | | |
| 41 | | |
| 42 | | // 20030621 ericball define using logical operations |
| 43 | | #define inc_hpos() { hpos = (hpos + 1) & 0x1FF; } |
| 44 | | #define inc_hpos_by_2() { hpos = (hpos + 2) & 0x1FF; } |
| 45 | | |
| 46 | 41 | /*************************************************************************** |
| 47 | 42 | |
| 48 | 43 | Start the video hardware emulation. |
| r22828 | r22829 | |
| 50 | 45 | ***************************************************************************/ |
| 51 | 46 | void a7800_state::video_start() |
| 52 | 47 | { |
| 53 | | int i; |
| 54 | | |
| 55 | | for(i=0; i<8; i++) |
| 48 | int i,j; |
| 49 | for(i=0; i<32; i++) |
| 56 | 50 | { |
| 57 | | m_maria_palette[i][0]=0; |
| 58 | | m_maria_palette[i][1]=0; |
| 59 | | m_maria_palette[i][2]=0; |
| 60 | | m_maria_palette[i][3]=0; |
| 51 | m_maria_palette[i]=0; |
| 61 | 52 | } |
| 53 | |
| 54 | for(i=0; i<2; i++) |
| 55 | { |
| 56 | for(j=0; j<160; j++) |
| 57 | m_line_ram[i][j] = 0; |
| 58 | } |
| 59 | |
| 60 | m_active_buffer = 0; |
| 62 | 61 | |
| 63 | 62 | m_maria_write_mode=0; |
| 64 | 63 | m_maria_dmaon=0; |
| 65 | 64 | m_maria_vblank=0x80; |
| 66 | 65 | m_maria_dll=0; |
| 67 | | m_maria_dodma=0; |
| 68 | 66 | m_maria_wsync=0; |
| 69 | 67 | |
| 70 | 68 | m_maria_color_kill = 0; |
| r22828 | r22829 | |
| 82 | 80 | |
| 83 | 81 | ***************************************************************************/ |
| 84 | 82 | |
| 83 | int a7800_state::is_holey(unsigned int addr) |
| 84 | { |
| 85 | if (((m_maria_holey & 0x02) && ((addr & 0x9000) == 0x9000)) || ( (m_maria_holey & 0x01) && ((addr & 0x8800) == 0x8800))) |
| 86 | return 1; |
| 87 | else |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | int a7800_state::write_line_ram(int addr, UINT8 offset, int pal) |
| 92 | { |
| 93 | address_space& space = m_maincpu->space(AS_PROGRAM); |
| 94 | int data, c; |
| 95 | |
| 96 | data = READ_MEM(addr); |
| 97 | pal = pal << 2; |
| 98 | |
| 99 | if (m_maria_write_mode) |
| 100 | { |
| 101 | c = (pal & 0x10) | (data & 0x0C) | (data >> 6); // P2 D3 D2 D7 D6 |
| 102 | if (((c & 3) || m_maria_kangaroo) && (offset < 160)) |
| 103 | m_line_ram[m_active_buffer][offset] = c; |
| 104 | offset++; |
| 105 | c = (pal & 0x10) | ((data & 0x03) << 2) | ((data & 0x30) >> 4); // P2 D1 D0 D5 D4 |
| 106 | if (((c & 3) || m_maria_kangaroo) && (offset < 160)) |
| 107 | m_line_ram[m_active_buffer][offset] = c; |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | for (int i=0; i<4; i++, offset++) |
| 112 | { |
| 113 | c = pal | ((data >> (6 - 2*i)) & 0x03); |
| 114 | if (((c & 3) || m_maria_kangaroo) && (offset < 160)) |
| 115 | m_line_ram[m_active_buffer][offset] = c; |
| 116 | } |
| 117 | } |
| 118 | return m_maria_write_mode ? 2 : 4; |
| 119 | } |
| 120 | |
| 121 | |
| 85 | 122 | void a7800_state::maria_draw_scanline() |
| 86 | 123 | { |
| 87 | 124 | address_space& space = m_maincpu->space(AS_PROGRAM); |
| 88 | 125 | unsigned int graph_adr,data_addr; |
| 89 | | int width,hpos,pal,mode,ind; |
| 126 | int width,pal,ind; |
| 127 | UINT8 hpos; |
| 128 | int xpos; |
| 90 | 129 | unsigned int dl; |
| 91 | | int x, d, c, i; |
| 92 | | int ind_bytes; |
| 93 | | UINT16 *scanline; |
| 130 | int x, d, c, i, j, pixel_cell, cells; |
| 131 | int maria_cycles; |
| 94 | 132 | |
| 95 | | /* set up scanline */ |
| 96 | | scanline = &m_bitmap.pix16(m_screen->vpos()); |
| 97 | | for (i = 0; i < 320; i++) |
| 98 | | scanline[i] = m_maria_backcolor; |
| 133 | maria_cycles = 0; |
| 134 | cells = 0; |
| 99 | 135 | |
| 136 | /* clear active line ram buffer */ |
| 137 | for (i = 0; i < 160; i++) |
| 138 | m_line_ram[m_active_buffer][i] = 0; |
| 139 | |
| 100 | 140 | /* Process this DLL entry */ |
| 101 | 141 | dl = m_maria_dl; |
| 102 | 142 | |
| 143 | /* DMA */ |
| 103 | 144 | /* Step through DL's */ |
| 104 | 145 | while ((READ_MEM(dl + 1) & 0x5F) != 0) |
| 105 | 146 | { |
| r22828 | r22829 | |
| 108 | 149 | { |
| 109 | 150 | graph_adr = (READ_MEM(dl+2) << 8) | READ_MEM(dl); |
| 110 | 151 | width = ((READ_MEM(dl+3) ^ 0xff) & 0x1F) + 1; |
| 111 | | hpos = READ_MEM(dl+4)*2; |
| 152 | hpos = READ_MEM(dl+4); |
| 112 | 153 | pal = READ_MEM(dl+3) >> 5; |
| 113 | 154 | m_maria_write_mode = (READ_MEM(dl+1) & 0x80) >> 5; |
| 114 | 155 | ind = READ_MEM(dl+1) & 0x20; |
| 115 | 156 | dl+=5; |
| 157 | maria_cycles += 10; |
| 116 | 158 | } |
| 117 | 159 | /* Normal header */ |
| 118 | 160 | else |
| 119 | 161 | { |
| 120 | 162 | graph_adr = (READ_MEM(dl+2) << 8) | READ_MEM(dl); |
| 121 | 163 | width = ((READ_MEM(dl+1) ^ 0xff) & 0x1F) + 1; |
| 122 | | hpos = READ_MEM(dl+3)*2; |
| 164 | hpos = READ_MEM(dl+3); |
| 123 | 165 | pal = READ_MEM(dl+1) >> 5; |
| 124 | 166 | ind = 0x00; |
| 125 | 167 | dl+=4; |
| 168 | maria_cycles += 8; |
| 126 | 169 | } |
| 127 | 170 | |
| 128 | | mode = m_maria_rm | m_maria_write_mode; |
| 129 | | |
| 130 | 171 | /*logerror("%x DL: ADR=%x width=%x hpos=%x pal=%x mode=%x ind=%x\n",m_screen->vpos(),graph_adr,width,hpos,pal,mode,ind );*/ |
| 131 | 172 | |
| 132 | | for (x=0; x<width; x++) // 20030621 ericball get graphic data first, then switch (mode) |
| 173 | for (x=0; x<width; x++) |
| 133 | 174 | { |
| 134 | | ind_bytes = 1; |
| 135 | | |
| 136 | 175 | /* Do indirect mode */ |
| 137 | 176 | if (ind) |
| 138 | 177 | { |
| 139 | 178 | c = READ_MEM(graph_adr + x) & 0xFF; |
| 140 | | data_addr= (m_maria_charbase | c) + (m_maria_offset << 8); |
| 141 | | if( m_maria_cwidth ) |
| 142 | | ind_bytes = 2; |
| 179 | maria_cycles += 3; // 3 Maria cycles |
| 180 | data_addr = (m_maria_charbase | c) + (m_maria_offset << 8); |
| 181 | if (is_holey(data_addr)) |
| 182 | continue; |
| 183 | if( m_maria_cwidth ) // two data bytes per map byte |
| 184 | { |
| 185 | cells = write_line_ram(data_addr, hpos, pal); |
| 186 | hpos += cells; |
| 187 | cells = write_line_ram(data_addr+1, hpos, pal); |
| 188 | hpos += cells; |
| 189 | } |
| 190 | else |
| 191 | { |
| 192 | cells = write_line_ram(data_addr, hpos, pal); |
| 193 | hpos += cells; |
| 194 | } |
| 143 | 195 | } |
| 144 | | else |
| 196 | else // direct mode |
| 145 | 197 | { |
| 146 | 198 | data_addr = graph_adr + x + (m_maria_offset << 8); |
| 199 | if (is_holey(data_addr)) |
| 200 | continue; |
| 201 | cells = write_line_ram(data_addr, hpos, pal); |
| 202 | hpos += cells; |
| 147 | 203 | } |
| 204 | } |
| 205 | } |
| 148 | 206 | |
| 149 | | if ( (m_maria_holey & 0x02) && ((data_addr & 0x9000) == 0x9000)) |
| 150 | | continue; |
| 151 | | if ( (m_maria_holey & 0x01) && ((data_addr & 0x8800) == 0x8800)) |
| 152 | | continue; |
| 207 | /* render scanline */ |
| 208 | m_active_buffer = !m_active_buffer; // switch buffers |
| 209 | UINT16 *scanline; |
| 210 | scanline = &m_bitmap.pix16(m_screen->vpos()); |
| 211 | for (i = 0; i < 320; i++) |
| 212 | scanline[i] = m_maria_palette[0]; |
| 153 | 213 | |
| 154 | | while (ind_bytes > 0) |
| 155 | | { |
| 156 | | ind_bytes--; |
| 157 | | d = READ_MEM(data_addr++); |
| 214 | xpos = 0; |
| 215 | i=0; |
| 158 | 216 | |
| 159 | | switch (mode) |
| 217 | while ( i<160 ) |
| 218 | |
| 219 | switch (m_maria_rm | m_maria_write_mode) |
| 220 | { |
| 221 | case 0x00: /* 160A (160x2) */ |
| 222 | case 0x01: /* 160A (160x2) */ |
| 223 | for (j = 0; j<4; j++, xpos+=2) |
| 160 | 224 | { |
| 161 | | case 0x00: /* 160A (160x2) */ |
| 162 | | case 0x01: /* 160A (160x2) */ |
| 163 | | c = (d & 0xC0) >> 6; |
| 164 | | if (c || m_maria_kangaroo) |
| 165 | | { |
| 166 | | scanline[hpos + 0] = m_maria_palette[pal][c]; |
| 167 | | scanline[hpos + 1] = m_maria_palette[pal][c]; |
| 168 | | } |
| 169 | | inc_hpos_by_2(); |
| 225 | pixel_cell = m_line_ram[m_active_buffer][i+j]; |
| 226 | scanline[xpos] = m_maria_palette[pixel_cell]; |
| 227 | scanline[xpos+1] = m_maria_palette[pixel_cell]; |
| 228 | } |
| 229 | i += 4; |
| 230 | break; |
| 170 | 231 | |
| 171 | | c = (d & 0x30) >> 4; |
| 172 | | if (c || m_maria_kangaroo) |
| 173 | | { |
| 174 | | scanline[hpos + 0] = m_maria_palette[pal][c]; |
| 175 | | scanline[hpos + 1] = m_maria_palette[pal][c]; |
| 176 | | } |
| 177 | | inc_hpos_by_2(); |
| 232 | case 0x02: /* 320D used by Jinks! */ |
| 233 | for (j = 0; j<4; j++, xpos+=2) |
| 234 | { |
| 235 | pixel_cell = m_line_ram[m_active_buffer][i+j]; |
| 236 | d = (pixel_cell & 0x10) | (pixel_cell & 0x02) | ((pixel_cell >> 3) & 1); |
| 237 | scanline[xpos] = m_maria_palette[d]; |
| 178 | 238 | |
| 179 | | c = (d & 0x0C) >> 2; |
| 180 | | if (c || m_maria_kangaroo) |
| 181 | | { |
| 182 | | scanline[hpos + 0] = m_maria_palette[pal][c]; |
| 183 | | scanline[hpos + 1] = m_maria_palette[pal][c]; |
| 184 | | } |
| 185 | | inc_hpos_by_2(); |
| 239 | d = (pixel_cell & 0x10) | ((pixel_cell << 1) & 0x02) | ((pixel_cell >> 2) & 1); |
| 240 | scanline[xpos+1] = m_maria_palette[d]; |
| 241 | } |
| 242 | i += 4; |
| 243 | break; |
| 186 | 244 | |
| 187 | | c = (d & 0x03); |
| 188 | | if (c || m_maria_kangaroo) |
| 189 | | { |
| 190 | | scanline[hpos + 0] = m_maria_palette[pal][c]; |
| 191 | | scanline[hpos + 1] = m_maria_palette[pal][c]; |
| 192 | | } |
| 193 | | inc_hpos_by_2(); |
| 194 | | break; |
| 245 | case 0x03: /* MODE 320A */ |
| 246 | for (j = 0; j<4; j++, xpos+=2) |
| 247 | { |
| 248 | pixel_cell = m_line_ram[m_active_buffer][i+j]; |
| 249 | d = (pixel_cell & 0x1C) | (pixel_cell & 0x02); |
| 250 | scanline[xpos] = m_maria_palette[d]; |
| 195 | 251 | |
| 196 | | case 0x02: /* 320D used by Jinks! */ |
| 197 | | c = pal & 0x04; |
| 198 | | if ( d & 0xC0 || pal & 0x03 || m_maria_kangaroo ) |
| 199 | | { |
| 200 | | scanline[hpos + 0] = m_maria_palette[c][((d & 0x80) >> 6) | ((pal & 2) >> 1)]; |
| 201 | | scanline[hpos + 1] = m_maria_palette[c][((d & 0x40) >> 5) | ((pal & 1) >> 0)]; |
| 202 | | } |
| 203 | | inc_hpos_by_2(); |
| 252 | d = (pixel_cell & 0x1C) | ((pixel_cell << 1) & 0x02); |
| 253 | scanline[xpos+1] = m_maria_palette[d]; |
| 254 | } |
| 255 | i += 4; |
| 256 | break; |
| 204 | 257 | |
| 205 | | if ( d & 0x30 || pal & 0x03 || m_maria_kangaroo ) |
| 206 | | { |
| 207 | | scanline[hpos + 0] = m_maria_palette[c][((d & 0x20) >> 4) | ((pal & 2) >> 1)]; |
| 208 | | scanline[hpos + 1] = m_maria_palette[c][((d & 0x10) >> 3) | ((pal & 1) >> 0)]; |
| 209 | | } |
| 210 | | inc_hpos_by_2(); |
| 258 | case 0x04: /* 160B (160x4) */ |
| 259 | case 0x05: /* 160B (160x4) */ |
| 260 | for (j = 0; j<2; j++, xpos+=2) |
| 261 | { |
| 262 | d = m_line_ram[m_active_buffer][i+j]; |
| 263 | scanline[xpos] = m_maria_palette[d]; |
| 264 | scanline[xpos+1] = m_maria_palette[d]; |
| 265 | } |
| 266 | i += 2; |
| 267 | break; |
| 211 | 268 | |
| 212 | | if ( d & 0x0C || pal & 0x03 || m_maria_kangaroo ) |
| 213 | | { |
| 214 | | scanline[hpos + 0] = m_maria_palette[c][((d & 0x08) >> 2) | ((pal & 2) >> 1)]; |
| 215 | | scanline[hpos + 1] = m_maria_palette[c][((d & 0x04) >> 1) | ((pal & 1) >> 0)]; |
| 216 | | } |
| 217 | | inc_hpos_by_2(); |
| 269 | case 0x06: /* MODE 320B */ |
| 270 | for (j = 0; j<2; j++, xpos+=2) |
| 271 | { |
| 272 | pixel_cell = m_line_ram[m_active_buffer][i+j]; |
| 218 | 273 | |
| 219 | | if ( d & 0x03 || pal & 0x03 || m_maria_kangaroo ) |
| 220 | | { |
| 221 | | scanline[hpos + 0] = m_maria_palette[c][((d & 0x02) << 0) | ((pal & 2) >> 1)]; |
| 222 | | scanline[hpos + 1] = m_maria_palette[c][((d & 0x01) << 1) | ((pal & 1) >> 0)]; |
| 223 | | } |
| 224 | | inc_hpos_by_2(); |
| 274 | d = (pixel_cell & 0x10) | (pixel_cell & 0x02) | ((pixel_cell >> 3) & 1); |
| 275 | scanline[xpos] = m_maria_palette[d]; |
| 225 | 276 | |
| 226 | | break; |
| 277 | d = (pixel_cell & 0x10) | ((pixel_cell << 1) & 0x02) | ((pixel_cell >> 2) & 1); |
| 278 | scanline[xpos+1] = m_maria_palette[d]; |
| 279 | } |
| 280 | i += 2; |
| 281 | break; |
| 227 | 282 | |
| 228 | | case 0x03: /* MODE 320A */ |
| 229 | | if (d & 0xC0 || m_maria_kangaroo) |
| 230 | | { |
| 231 | | scanline[hpos + 0] = m_maria_palette[pal][(d & 0x80) >> 6]; |
| 232 | | scanline[hpos + 1] = m_maria_palette[pal][(d & 0x40) >> 5]; |
| 233 | | } |
| 234 | | inc_hpos_by_2(); |
| 283 | case 0x07: /* MODE 320C */ |
| 284 | for (j = 0; j<2; j++, xpos+=2) |
| 285 | { |
| 286 | pixel_cell = m_line_ram[m_active_buffer][i+j]; |
| 235 | 287 | |
| 236 | | if ( d & 0x30 || m_maria_kangaroo) |
| 237 | | { |
| 238 | | scanline[hpos + 0] = m_maria_palette[pal][(d & 0x20) >> 4]; |
| 239 | | scanline[hpos + 1] = m_maria_palette[pal][(d & 0x10) >> 3]; |
| 240 | | } |
| 241 | | inc_hpos_by_2(); |
| 288 | d = pixel_cell & 0x1E; |
| 289 | scanline[xpos] = m_maria_palette[d]; |
| 242 | 290 | |
| 243 | | if (d & 0x0C || m_maria_kangaroo) |
| 244 | | { |
| 245 | | scanline[hpos + 0] = m_maria_palette[pal][(d & 0x08) >> 2]; |
| 246 | | scanline[hpos + 1] = m_maria_palette[pal][(d & 0x04) >> 1]; |
| 247 | | } |
| 248 | | inc_hpos_by_2(); |
| 291 | d = (pixel_cell & 0x1C) | ((pixel_cell & 0x01) << 1); |
| 292 | scanline[xpos+1] = m_maria_palette[d]; |
| 293 | } |
| 294 | i += 2; |
| 295 | break; |
| 249 | 296 | |
| 250 | | if (d & 0x03 || m_maria_kangaroo) |
| 251 | | { |
| 252 | | scanline[hpos + 0] = m_maria_palette[pal][(d & 0x02)]; |
| 253 | | scanline[hpos + 1] = m_maria_palette[pal][(d & 0x01) << 1]; |
| 254 | | } |
| 255 | | inc_hpos_by_2(); |
| 256 | | break; |
| 297 | } /* endswitch (mode) */ |
| 257 | 298 | |
| 258 | | case 0x04: /* 160B (160x4) */ |
| 259 | | case 0x05: /* 160B (160x4) */ |
| 260 | | c = (d & 0xC0) >> 6; |
| 261 | | if (c || m_maria_kangaroo) |
| 262 | | { |
| 263 | | scanline[hpos + 0] = m_maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 264 | | scanline[hpos + 1] = m_maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][c]; |
| 265 | | } |
| 266 | | inc_hpos_by_2(); |
| 267 | | |
| 268 | | c = (d & 0x30) >> 4; |
| 269 | | if (c || m_maria_kangaroo) |
| 270 | | { |
| 271 | | scanline[hpos + 0] = m_maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 272 | | scanline[hpos + 1] = m_maria_palette[(pal & 0x04) | (d & 0x03)][c]; |
| 273 | | } |
| 274 | | inc_hpos_by_2(); |
| 275 | | break; |
| 276 | | |
| 277 | | case 0x06: /* MODE 320B */ |
| 278 | | if (d & 0xCC || m_maria_kangaroo) |
| 279 | | { |
| 280 | | scanline[hpos + 0] = m_maria_palette[pal][((d & 0x80) >> 6) | ((d & 0x08) >> 3)]; |
| 281 | | scanline[hpos + 1] = m_maria_palette[pal][((d & 0x40) >> 5) | ((d & 0x04) >> 2)]; |
| 282 | | } |
| 283 | | inc_hpos_by_2(); |
| 284 | | |
| 285 | | if ( d & 0x33 || m_maria_kangaroo) |
| 286 | | { |
| 287 | | scanline[hpos + 0] = m_maria_palette[pal][((d & 0x20) >> 4) | ((d & 0x02) >> 1)]; |
| 288 | | scanline[hpos + 1] = m_maria_palette[pal][((d & 0x10) >> 3) | (d & 0x01)]; |
| 289 | | } |
| 290 | | inc_hpos_by_2(); |
| 291 | | break; |
| 292 | | |
| 293 | | case 0x07: /* (320C mode) */ |
| 294 | | if (d & 0xC0 || m_maria_kangaroo) |
| 295 | | { |
| 296 | | scanline[hpos + 0] = m_maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x80) >> 6]; |
| 297 | | scanline[hpos + 1] = m_maria_palette[(pal & 0x04) | ((d & 0x0C) >> 2)][(d & 0x40) >> 5]; |
| 298 | | } |
| 299 | | inc_hpos_by_2(); |
| 300 | | |
| 301 | | if ( d & 0x30 || m_maria_kangaroo) |
| 302 | | { |
| 303 | | scanline[hpos + 0] = m_maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x20) >> 4]; |
| 304 | | scanline[hpos + 1] = m_maria_palette[(pal & 0x04) | (d & 0x03)][(d & 0x10) >> 3]; |
| 305 | | } |
| 306 | | inc_hpos_by_2(); |
| 307 | | break; |
| 308 | | |
| 309 | | } /* endswitch (mode) */ |
| 310 | | } /* endwhile (ind_bytes > 0)*/ |
| 311 | | } /* endfor (x=0; x<width; x++) */ |
| 312 | | } /* endwhile (READ_MEM(dl + 1) != 0) */ |
| 299 | m_maincpu->adjust_icount(-maria_cycles/4); // Maria clock rate is 4 times that of CPU |
| 313 | 300 | } |
| 314 | 301 | |
| 315 | 302 | |
| 303 | |
| 316 | 304 | TIMER_DEVICE_CALLBACK_MEMBER(a7800_state::a7800_interrupt) |
| 317 | 305 | { |
| 318 | | int frame_scanline; |
| 319 | | UINT8 *ROM = m_region_maincpu->base(); |
| 320 | | address_space& space = m_maincpu->space(AS_PROGRAM); |
| 321 | | int maria_scanline = m_screen->vpos(); |
| 322 | | |
| 323 | | /* why + 1? */ |
| 324 | | frame_scanline = maria_scanline % ( m_lines + 1 ); |
| 325 | | |
| 326 | | if( frame_scanline == 1 ) |
| 327 | | { |
| 328 | | /*logerror( "frame beg\n" );*/ |
| 329 | | } |
| 330 | | |
| 306 | machine().scheduler().timer_set(m_maincpu->cycles_to_attotime(7), timer_expired_delegate(FUNC(a7800_state::a7800_maria_startdma),this)); |
| 331 | 307 | if( m_maria_wsync ) |
| 332 | 308 | { |
| 333 | 309 | machine().scheduler().trigger( TRIGGER_HSYNC ); |
| 334 | 310 | m_maria_wsync = 0; |
| 335 | 311 | } |
| 312 | |
| 313 | int frame_scanline = m_screen->vpos() % ( m_lines + 1 ); |
| 314 | if (frame_scanline == 16) |
| 315 | m_maria_vblank = 0x00; |
| 336 | 316 | |
| 337 | | if( frame_scanline == 16 ) |
| 317 | if ( frame_scanline == ( m_lines - 4 ) ) |
| 338 | 318 | { |
| 339 | | /* end of vblank */ |
| 319 | m_maria_vblank = 0x80; |
| 320 | } |
| 321 | } |
| 340 | 322 | |
| 341 | | m_maria_vblank=0; |
| 342 | | if( m_maria_dmaon || m_maria_dodma ) |
| 343 | | { |
| 344 | | m_maria_dodma = 1; /* if dma allowed, start it */ |
| 345 | 323 | |
| 346 | | m_maria_dll = (ROM[DPPH] << 8) | ROM[DPPL]; |
| 347 | | m_maria_dl = (READ_MEM(m_maria_dll+1) << 8) | READ_MEM(m_maria_dll+2); |
| 348 | | m_maria_offset = READ_MEM(m_maria_dll) & 0x0f; |
| 349 | | m_maria_holey = (READ_MEM(m_maria_dll) & 0x60) >> 5; |
| 350 | | m_maria_dli = READ_MEM(m_maria_dll) & 0x80; |
| 351 | | /* logerror("DLL=%x\n",m_maria_dll); */ |
| 352 | | /* logerror("DLL: DL = %x dllctrl = %x\n",m_maria_dl,ROM[m_maria_dll]); */ |
| 353 | | } |
| 324 | TIMER_CALLBACK_MEMBER(a7800_state::a7800_maria_startdma) |
| 325 | { |
| 326 | int frame_scanline; |
| 327 | address_space& space = m_maincpu->space(AS_PROGRAM); |
| 328 | int maria_scanline = m_screen->vpos(); |
| 354 | 329 | |
| 355 | | /*logerror( "vblank end on line %d\n", frame_scanline );*/ |
| 356 | | } |
| 330 | frame_scanline = maria_scanline % ( m_lines + 1 ); |
| 357 | 331 | |
| 358 | | /* moved start of vblank up (to prevent dma/dli happen on line -4) |
| 359 | | this fix made PR Baseball happy |
| 360 | | Kung-Fu Master looks worse |
| 361 | | don't know about others yet */ |
| 362 | | if( frame_scanline == ( m_lines - 4 ) ) |
| 332 | if( (frame_scanline == 16) && m_maria_dmaon ) |
| 363 | 333 | { |
| 364 | | /* vblank starts 4 scanlines before end of screen */ |
| 334 | /* end of vblank */ |
| 365 | 335 | |
| 366 | | m_maria_vblank = 0x80; |
| 367 | | |
| 368 | | /* fixed 2002/05/14 kubecj |
| 369 | | when going vblank, dma must be stopped |
| 370 | | otherwise system tries to read past end of dll |
| 371 | | causing false dlis to occur, mainly causing wild |
| 372 | | screen flickering |
| 373 | | |
| 374 | | games fixed: |
| 375 | | Ace of Aces |
| 376 | | Mean 18 |
| 377 | | Ninja Golf (end of levels) |
| 378 | | Choplifter |
| 379 | | Impossible Mission |
| 380 | | Jinks |
| 381 | | */ |
| 382 | | |
| 383 | | m_maria_dodma = 0; |
| 384 | | /*logerror( "vblank on line %d\n\n", frame_scanline );*/ |
| 336 | m_maria_dll = m_maria_dpp; // currently only handle changes to dll during vblank |
| 337 | m_maria_dl = (READ_MEM(m_maria_dll+1) << 8) | READ_MEM(m_maria_dll+2); |
| 338 | m_maria_offset = READ_MEM(m_maria_dll) & 0x0f; |
| 339 | m_maria_holey = (READ_MEM(m_maria_dll) & 0x60) >> 5; |
| 340 | logerror("holey %d", m_maria_holey); |
| 341 | if ( READ_MEM(m_maria_dll) & 0x80 ) |
| 342 | m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 343 | m_maincpu->adjust_icount(-6); // 24 Maria cycles minimum (DMA startup + shutdown list-list fetch) |
| 344 | /* logerror("DLL=%x\n",m_maria_dll); */ |
| 345 | /* logerror("DLL: DL = %x dllctrl = %x\n",m_maria_dl,ROM[m_maria_dll]); */ |
| 385 | 346 | } |
| 386 | 347 | |
| 387 | 348 | |
| 388 | | if( ( frame_scanline > 15 ) && m_maria_dodma ) |
| 349 | if( ( frame_scanline > 15 ) && (frame_scanline < (m_lines - 4)) && m_maria_dmaon ) |
| 389 | 350 | { |
| 390 | | if (maria_scanline < ( m_lines - 4 ) ) |
| 391 | | maria_draw_scanline(); |
| 351 | maria_draw_scanline(); |
| 392 | 352 | |
| 393 | 353 | if( m_maria_offset == 0 ) |
| 394 | 354 | { |
| r22828 | r22829 | |
| 396 | 356 | m_maria_dl = (READ_MEM(m_maria_dll+1) << 8) | READ_MEM(m_maria_dll+2); |
| 397 | 357 | m_maria_offset = READ_MEM(m_maria_dll) & 0x0f; |
| 398 | 358 | m_maria_holey = (READ_MEM(m_maria_dll) & 0x60) >> 5; |
| 399 | | m_maria_dli = READ_MEM(m_maria_dll) & 0x80; |
| 359 | logerror("holey %d", m_maria_holey); |
| 360 | if ( READ_MEM(m_maria_dll) & 0x80 ) |
| 361 | m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 362 | m_maincpu->adjust_icount(-5); // 20 Maria cycles (DMA startup + shutdown) |
| 400 | 363 | } |
| 401 | 364 | else |
| 402 | 365 | { |
| 403 | 366 | m_maria_offset--; |
| 404 | 367 | } |
| 405 | 368 | } |
| 406 | | |
| 407 | | if( m_maria_dli ) |
| 408 | | { |
| 409 | | /*logerror( "dli on line %d [%02X] [%02X] [%02X]\n", frame_scanline, ROM[0x7E], ROM[0x7C], ROM[0x7D] );*/ |
| 410 | | } |
| 411 | | |
| 412 | | if( m_maria_dli ) |
| 413 | | { |
| 414 | | m_maria_dli = 0; |
| 415 | | m_maincpu->set_input_line(INPUT_LINE_NMI, PULSE_LINE); |
| 416 | | } |
| 417 | | |
| 418 | 369 | } |
| 419 | 370 | |
| 420 | 371 | /*************************************************************************** |
| r22828 | r22829 | |
| 434 | 385 | |
| 435 | 386 | READ8_MEMBER(a7800_state::a7800_MARIA_r) |
| 436 | 387 | { |
| 437 | | UINT8 *ROM = m_region_maincpu->base(); |
| 438 | 388 | switch (offset) |
| 439 | 389 | { |
| 440 | 390 | case 0x08: |
| r22828 | r22829 | |
| 442 | 392 | |
| 443 | 393 | default: |
| 444 | 394 | logerror("undefined MARIA read %x\n",offset); |
| 445 | | return ROM[0x20 + offset]; |
| 395 | return 0x00; // don't know if this should be 0x00 or 0xff |
| 446 | 396 | } |
| 447 | 397 | } |
| 448 | 398 | |
| 449 | 399 | WRITE8_MEMBER(a7800_state::a7800_MARIA_w) |
| 450 | 400 | { |
| 451 | | UINT8 *ROM = m_region_maincpu->base(); |
| 401 | int i; |
| 402 | |
| 403 | if ((offset & 3) != 0) |
| 404 | m_maria_palette[offset] = data; |
| 405 | |
| 452 | 406 | switch (offset) |
| 453 | 407 | { |
| 454 | 408 | case 0x00: |
| 455 | | m_maria_backcolor = data; |
| 456 | | // 20030621 ericball added m_maria_palette[pal][0] to make kanagroo mode easier |
| 457 | | m_maria_palette[0][0]=m_maria_backcolor; |
| 458 | | m_maria_palette[1][0]=m_maria_backcolor; |
| 459 | | m_maria_palette[2][0]=m_maria_backcolor; |
| 460 | | m_maria_palette[3][0]=m_maria_backcolor; |
| 461 | | m_maria_palette[4][0]=m_maria_backcolor; |
| 462 | | m_maria_palette[5][0]=m_maria_backcolor; |
| 463 | | m_maria_palette[6][0]=m_maria_backcolor; |
| 464 | | m_maria_palette[7][0]=m_maria_backcolor; |
| 409 | // 0x04 etc. necessary for 320 modes (pixels with color of 00 should display as background color) |
| 410 | for (i = 0; i<8; i++) |
| 411 | m_maria_palette[4*i] = data; |
| 465 | 412 | break; |
| 466 | | case 0x01: |
| 467 | | m_maria_palette[0][1] = data; |
| 468 | | break; |
| 469 | | case 0x02: |
| 470 | | m_maria_palette[0][2] = data; |
| 471 | | break; |
| 472 | | case 0x03: |
| 473 | | m_maria_palette[0][3] = data; |
| 474 | | break; |
| 475 | 413 | case 0x04: |
| 476 | 414 | m_maincpu->spin_until_trigger(TRIGGER_HSYNC); |
| 477 | 415 | m_maria_wsync=1; |
| 478 | 416 | break; |
| 479 | | |
| 480 | | case 0x05: |
| 481 | | m_maria_palette[1][1] = data; |
| 417 | case 0x0C: // DPPH |
| 418 | m_maria_dpp = (m_maria_dpp & 0x00ff) | (data << 8); |
| 482 | 419 | break; |
| 483 | | case 0x06: |
| 484 | | m_maria_palette[1][2] = data; |
| 420 | case 0x10: // DPPL |
| 421 | m_maria_dpp = (m_maria_dpp & 0xff00) | data; |
| 485 | 422 | break; |
| 486 | | case 0x07: |
| 487 | | m_maria_palette[1][3] = data; |
| 488 | | break; |
| 489 | | |
| 490 | | case 0x09: |
| 491 | | m_maria_palette[2][1] = data; |
| 492 | | break; |
| 493 | | case 0x0A: |
| 494 | | m_maria_palette[2][2] = data; |
| 495 | | break; |
| 496 | | case 0x0B: |
| 497 | | m_maria_palette[2][3] = data; |
| 498 | | break; |
| 499 | | |
| 500 | | case 0x0D: |
| 501 | | m_maria_palette[3][1] = data; |
| 502 | | break; |
| 503 | | case 0x0E: |
| 504 | | m_maria_palette[3][2] = data; |
| 505 | | break; |
| 506 | | case 0x0F: |
| 507 | | m_maria_palette[3][3] = data; |
| 508 | | break; |
| 509 | | |
| 510 | | case 0x11: |
| 511 | | m_maria_palette[4][1] = data; |
| 512 | | break; |
| 513 | | case 0x12: |
| 514 | | m_maria_palette[4][2] = data; |
| 515 | | break; |
| 516 | | case 0x13: |
| 517 | | m_maria_palette[4][3] = data; |
| 518 | | break; |
| 519 | 423 | case 0x14: |
| 520 | 424 | m_maria_charbase = (data << 8); |
| 521 | 425 | break; |
| 522 | | case 0x15: |
| 523 | | m_maria_palette[5][1] = data; |
| 524 | | break; |
| 525 | | case 0x16: |
| 526 | | m_maria_palette[5][2] = data; |
| 527 | | break; |
| 528 | | case 0x17: |
| 529 | | m_maria_palette[5][3] = data; |
| 530 | | break; |
| 531 | | |
| 532 | | case 0x19: |
| 533 | | m_maria_palette[6][1] = data; |
| 534 | | break; |
| 535 | | case 0x1A: |
| 536 | | m_maria_palette[6][2] = data; |
| 537 | | break; |
| 538 | | case 0x1B: |
| 539 | | m_maria_palette[6][3] = data; |
| 540 | | break; |
| 541 | | |
| 542 | 426 | case 0x1C: |
| 543 | 427 | /*logerror("MARIA CTRL=%x\n",data);*/ |
| 544 | 428 | m_maria_color_kill = data & 0x80; |
| 545 | | if ((data & 0x60) == 0x40) |
| 429 | switch ((data >> 5) & 3) |
| 430 | { |
| 431 | case 0x00: case 01: |
| 432 | logerror("dma test mode, do not use.\n"); |
| 433 | break; |
| 434 | case 0x02: |
| 546 | 435 | m_maria_dmaon = 1; |
| 547 | | else |
| 548 | | m_maria_dmaon = m_maria_dodma = 0; |
| 549 | | |
| 436 | break; |
| 437 | case 0x03: |
| 438 | m_maria_dmaon = 0; |
| 439 | break; |
| 440 | } |
| 550 | 441 | m_maria_cwidth = data & 0x10; |
| 551 | | m_maria_bcntl = data & 0x08; |
| 442 | m_maria_bcntl = data & 0x08; // Currently unimplemented as we don't display the border |
| 552 | 443 | m_maria_kangaroo = data & 0x04; |
| 553 | 444 | m_maria_rm = data & 0x03; |
| 554 | 445 | |
| r22828 | r22829 | |
| 561 | 452 | m_maria_rm );*/ |
| 562 | 453 | |
| 563 | 454 | break; |
| 564 | | case 0x1D: |
| 565 | | m_maria_palette[7][1] = data; |
| 566 | | break; |
| 567 | | case 0x1E: |
| 568 | | m_maria_palette[7][2] = data; |
| 569 | | break; |
| 570 | | case 0x1F: |
| 571 | | m_maria_palette[7][3] = data; |
| 572 | | break; |
| 573 | 455 | } |
| 574 | | ROM[ 0x20 + offset ] = data; |
| 575 | 456 | } |