src/mame/video/stvvdp1.c
| r11640 | r11641 | |
| 2 | 2 | |
| 3 | 3 | STV - VDP1 |
| 4 | 4 | |
| 5 | | crude drawing code to support some of the basic vdp1 features |
| 6 | | based on what hanagumi columns needs |
| 7 | | -- to be expanded |
| 8 | | |
| 9 | 5 | the vdp1 draws to the FRAMEBUFFER which is mapped in memory |
| 10 | 6 | |
| 11 | 7 | Framebuffer todo: |
| r11640 | r11641 | |
| 13 | 9 | - add proper framebuffer erase |
| 14 | 10 | - 8 bpp support - now we always draw as 16 bpp, but this is not a problem since |
| 15 | 11 | VDP2 interprets framebuffer as 8 bpp in these cases |
| 12 | - make this to be inp record/playback safe |
| 13 | |
| 16 | 14 | */ |
| 17 | 15 | |
| 18 | 16 | |
| 19 | 17 | #include "emu.h" |
| 20 | | #include "sound/scsp.h" |
| 21 | 18 | #include "includes/stv.h" |
| 22 | 19 | |
| 23 | | static int vdp1_sprite_log = 0; |
| 20 | #define VDP1_LOG 0 |
| 24 | 21 | |
| 25 | | UINT32 *stv_vdp1_vram; |
| 26 | | static UINT32 *stv_vdp1_regs; |
| 27 | | UINT8* stv_vdp1_gfx_decode; |
| 28 | | |
| 29 | | static UINT16 *stv_framebuffer[2]; |
| 30 | | static UINT16 **stv_framebuffer_draw_lines; |
| 31 | | UINT16 **stv_framebuffer_display_lines; |
| 32 | | static int stv_framebuffer_width; |
| 33 | | static int stv_framebuffer_height; |
| 34 | | int stv_framebuffer_mode; |
| 35 | | int stv_framebuffer_double_interlace; |
| 36 | | static int stv_vdp1_fbcr_accessed; |
| 37 | | static int stv_vdp1_current_display_framebuffer; |
| 38 | | static int stv_vdp1_current_draw_framebuffer; |
| 39 | | static int stv_vdp1_clear_framebuffer_on_next_frame; |
| 40 | | static rectangle stv_vdp1_system_cliprect; |
| 41 | | static rectangle stv_vdp1_user_cliprect; |
| 42 | | |
| 43 | | static int stvvdp1_local_x; |
| 44 | | static int stvvdp1_local_y; |
| 45 | | |
| 46 | 22 | struct stv_vdp1_poly_scanline |
| 47 | 23 | { |
| 48 | 24 | INT32 x[2]; |
| r11640 | r11641 | |
| 115 | 91 | 1 1024x256 |
| 116 | 92 | 0 512x256 |
| 117 | 93 | */ |
| 118 | | #define STV_VDP1_TVMR ((stv_vdp1_regs[0x000/4] >> 16)&0x0000ffff) |
| 94 | #define STV_VDP1_TVMR ((state->m_vdp1_regs[0x000/4] >> 16)&0x0000ffff) |
| 119 | 95 | #define STV_VDP1_VBE ((STV_VDP1_TVMR & 0x0008) >> 3) |
| 120 | 96 | #define STV_VDP1_TVM ((STV_VDP1_TVMR & 0x0007) >> 0) |
| 121 | 97 | |
| r11640 | r11641 | |
| 128 | 104 | ---- ---- ---- --x- | Frame Buffer Change Trigger (FCM) |
| 129 | 105 | ---- ---- ---- ---x | Frame Buffer Change Mode (FCT) |
| 130 | 106 | */ |
| 131 | | #define STV_VDP1_FBCR ((stv_vdp1_regs[0x000/4] >> 0)&0x0000ffff) |
| 107 | #define STV_VDP1_FBCR ((state->m_vdp1_regs[0x000/4] >> 0)&0x0000ffff) |
| 132 | 108 | #define STV_VDP1_EOS ((STV_VDP1_FBCR & 0x0010) >> 4) |
| 133 | 109 | #define STV_VDP1_DIE ((STV_VDP1_FBCR & 0x0008) >> 3) |
| 134 | 110 | #define STV_VDP1_DIL ((STV_VDP1_FBCR & 0x0004) >> 2) |
| r11640 | r11641 | |
| 146 | 122 | 1 VDP1 draw by request |
| 147 | 123 | 0 VDP1 Idle (no access) |
| 148 | 124 | */ |
| 149 | | #define STV_VDP1_PTMR ((stv_vdp1_regs[0x004/4] >> 16)&0x0000ffff) |
| 125 | #define STV_VDP1_PTMR ((state->m_vdp1_regs[0x004/4] >> 16)&0x0000ffff) |
| 150 | 126 | #define STV_VDP1_PTM ((STV_VDP1_PTMR & 0x0003) >> 0) |
| 151 | | #define SET_PTM_FROM_1_TO_0 if(STV_VDP1_PTM & 1) stv_vdp1_regs[0x004/4]^=0x00010000 |
| 127 | #define PTM_0 state->m_vdp1_regs[0x004/4]&=~0x00010000 |
| 152 | 128 | /*Erase/Write Upper-Left register*/ |
| 153 | 129 | /* |
| 154 | 130 | x--- ---- ---- ---- | UNUSED |
| r11640 | r11641 | |
| 156 | 132 | ---- ---x xxxx xxxx | Y1 register |
| 157 | 133 | |
| 158 | 134 | */ |
| 159 | | #define STV_VDP1_EWLR ((stv_vdp1_regs[0x008/4] >> 16)&0x0000ffff) |
| 135 | #define STV_VDP1_EWLR ((state->m_vdp1_regs[0x008/4] >> 16)&0x0000ffff) |
| 160 | 136 | #define STV_VDP1_EWLR_X1 ((STV_VDP1_EWLR & 0x7e00) >> 9) |
| 161 | 137 | #define STV_VDP1_EWLR_Y1 ((STV_VDP1_EWLR & 0x01ff) >> 0) |
| 162 | 138 | /*Erase/Write Lower-Right register*/ |
| r11640 | r11641 | |
| 165 | 141 | ---- ---x xxxx xxxx | Y3 register |
| 166 | 142 | |
| 167 | 143 | */ |
| 168 | | #define STV_VDP1_EWRR ((stv_vdp1_regs[0x008/4] >> 0)&0x0000ffff) |
| 144 | #define STV_VDP1_EWRR ((state->m_vdp1_regs[0x008/4] >> 0)&0x0000ffff) |
| 169 | 145 | #define STV_VDP1_EWRR_X3 ((STV_VDP1_EWRR & 0xfe00) >> 9) |
| 170 | 146 | #define STV_VDP1_EWRR_Y3 ((STV_VDP1_EWRR & 0x01ff) >> 0) |
| 171 | 147 | /*Transfer End Status Register*/ |
| r11640 | r11641 | |
| 175 | 151 | ---- ---- ---- ---x | BEF |
| 176 | 152 | |
| 177 | 153 | */ |
| 178 | | #define STV_VDP1_EDSR ((stv_vdp1_regs[0x010/4] >> 16)&0x0000ffff) |
| 154 | #define STV_VDP1_EDSR ((state->m_vdp1_regs[0x010/4] >> 16)&0x0000ffff) |
| 179 | 155 | #define STV_VDP1_CEF (STV_VDP1_EDSR & 2) |
| 180 | 156 | #define STV_VDP1_BEF (STV_VDP1_EDSR & 1) |
| 181 | | #define SET_CEF_FROM_1_TO_0 if(STV_VDP1_CEF) stv_vdp1_regs[0x010/4]^=0x00020000 |
| 182 | | #define SET_CEF_FROM_0_TO_1 if(!(STV_VDP1_CEF)) stv_vdp1_regs[0x010/4]^=0x00020000 |
| 157 | #define CEF_1 state->m_vdp1_regs[0x010/4]|=0x00020000 |
| 158 | #define CEF_0 state->m_vdp1_regs[0x010/4]&=~0x00020000 |
| 183 | 159 | /**/ |
| 184 | 160 | |
| 185 | 161 | |
| 186 | 162 | |
| 187 | 163 | static void stv_vdp1_process_list(running_machine &machine); |
| 188 | 164 | |
| 189 | | READ32_HANDLER( stv_vdp1_regs_r ) |
| 165 | READ32_HANDLER( saturn_vdp1_regs_r ) |
| 190 | 166 | { |
| 191 | | // static int x; |
| 167 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 192 | 168 | |
| 193 | | // x ^= 0x00020000; |
| 169 | //logerror ("cpu %s (PC=%08X) VDP1: Read from Registers, Offset %04x\n", space->device().tag(), cpu_get_pc(&space->device()), offset); |
| 194 | 170 | |
| 195 | | logerror ("cpu %s (PC=%08X) VDP1: Read from Registers, Offset %04x\n", space->device().tag(), cpu_get_pc(&space->device()), offset); |
| 196 | | // if (offset == 0x04) return x; |
| 197 | | |
| 198 | | return stv_vdp1_regs[offset]; |
| 171 | return state->m_vdp1_regs[offset]; |
| 199 | 172 | } |
| 200 | 173 | |
| 201 | | static void stv_clear_framebuffer( int which_framebuffer ) |
| 174 | static void stv_clear_framebuffer( running_machine &machine, int which_framebuffer ) |
| 202 | 175 | { |
| 203 | | if ( vdp1_sprite_log ) logerror( "Clearing %d framebuffer\n", stv_vdp1_current_draw_framebuffer ); |
| 204 | | memset( stv_framebuffer[ which_framebuffer ], 0, 1024 * 256 * sizeof(UINT16) * 2 ); |
| 176 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 177 | |
| 178 | if ( VDP1_LOG ) logerror( "Clearing %d framebuffer\n", state->m_vdp1.framebuffer_current_draw ); |
| 179 | memset( state->m_vdp1.framebuffer[ which_framebuffer ], 0, 1024 * 256 * sizeof(UINT16) * 2 ); |
| 205 | 180 | } |
| 206 | 181 | |
| 207 | 182 | |
| 208 | | static void stv_prepare_framebuffers( void ) |
| 183 | static void stv_prepare_framebuffers( running_machine &machine ) |
| 209 | 184 | { |
| 185 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 210 | 186 | int i,rowsize; |
| 211 | 187 | |
| 212 | | rowsize = stv_framebuffer_width; |
| 213 | | if ( stv_vdp1_current_draw_framebuffer == 0 ) |
| 188 | rowsize = state->m_vdp1.framebuffer_width; |
| 189 | if ( state->m_vdp1.framebuffer_current_draw == 0 ) |
| 214 | 190 | { |
| 215 | | for ( i = 0; i < stv_framebuffer_height; i++ ) |
| 191 | for ( i = 0; i < state->m_vdp1.framebuffer_height; i++ ) |
| 216 | 192 | { |
| 217 | | stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][ i * rowsize ]; |
| 218 | | stv_framebuffer_display_lines[i] = &stv_framebuffer[1][ i * rowsize ]; |
| 193 | state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][ i * rowsize ]; |
| 194 | state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][ i * rowsize ]; |
| 219 | 195 | } |
| 220 | 196 | for ( ; i < 512; i++ ) |
| 221 | 197 | { |
| 222 | | stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][0]; |
| 223 | | stv_framebuffer_display_lines[i] = &stv_framebuffer[1][0]; |
| 198 | state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][0]; |
| 199 | state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][0]; |
| 224 | 200 | } |
| 225 | 201 | |
| 226 | 202 | } |
| 227 | 203 | else |
| 228 | 204 | { |
| 229 | | for ( i = 0; i < stv_framebuffer_height; i++ ) |
| 205 | for ( i = 0; i < state->m_vdp1.framebuffer_height; i++ ) |
| 230 | 206 | { |
| 231 | | stv_framebuffer_draw_lines[i] = &stv_framebuffer[1][ i * rowsize ]; |
| 232 | | stv_framebuffer_display_lines[i] = &stv_framebuffer[0][ i * rowsize ]; |
| 207 | state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[1][ i * rowsize ]; |
| 208 | state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[0][ i * rowsize ]; |
| 233 | 209 | } |
| 234 | 210 | for ( ; i < 512; i++ ) |
| 235 | 211 | { |
| 236 | | stv_framebuffer_draw_lines[i] = &stv_framebuffer[1][0]; |
| 237 | | stv_framebuffer_display_lines[i] = &stv_framebuffer[0][0]; |
| 212 | state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[1][0]; |
| 213 | state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[0][0]; |
| 238 | 214 | } |
| 239 | 215 | |
| 240 | 216 | } |
| 241 | 217 | |
| 242 | 218 | for ( ; i < 512; i++ ) |
| 243 | 219 | { |
| 244 | | stv_framebuffer_draw_lines[i] = &stv_framebuffer[0][0]; |
| 245 | | stv_framebuffer_display_lines[i] = &stv_framebuffer[1][0]; |
| 220 | state->m_vdp1.framebuffer_draw_lines[i] = &state->m_vdp1.framebuffer[0][0]; |
| 221 | state->m_vdp1.framebuffer_display_lines[i] = &state->m_vdp1.framebuffer[1][0]; |
| 246 | 222 | } |
| 247 | 223 | |
| 248 | 224 | } |
| 249 | 225 | |
| 250 | | static void stv_vdp1_change_framebuffers( void ) |
| 226 | static void stv_vdp1_change_framebuffers( running_machine &machine ) |
| 251 | 227 | { |
| 252 | | stv_vdp1_current_display_framebuffer ^= 1; |
| 253 | | stv_vdp1_current_draw_framebuffer ^= 1; |
| 254 | | if ( vdp1_sprite_log ) logerror( "Changing framebuffers: %d - draw, %d - display\n", stv_vdp1_current_draw_framebuffer, stv_vdp1_current_display_framebuffer ); |
| 255 | | stv_prepare_framebuffers(); |
| 228 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 229 | state->m_vdp1.framebuffer_current_display ^= 1; |
| 230 | state->m_vdp1.framebuffer_current_draw ^= 1; |
| 231 | if ( VDP1_LOG ) logerror( "Changing framebuffers: %d - draw, %d - display\n", state->m_vdp1.framebuffer_current_draw, state->m_vdp1.framebuffer_current_display ); |
| 232 | stv_prepare_framebuffers(machine); |
| 256 | 233 | } |
| 257 | 234 | |
| 258 | | static void stv_set_framebuffer_config( void ) |
| 235 | static void stv_set_framebuffer_config( running_machine &machine ) |
| 259 | 236 | { |
| 260 | | if ( stv_framebuffer_mode == STV_VDP1_TVM && |
| 261 | | stv_framebuffer_double_interlace == STV_VDP1_DIE ) return; |
| 237 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 238 | if ( state->m_vdp1.framebuffer_mode == STV_VDP1_TVM && |
| 239 | state->m_vdp1.framebuffer_double_interlace == STV_VDP1_DIE ) return; |
| 262 | 240 | |
| 263 | | if ( vdp1_sprite_log ) logerror( "Setting framebuffer config\n" ); |
| 264 | | stv_framebuffer_mode = STV_VDP1_TVM; |
| 265 | | stv_framebuffer_double_interlace = STV_VDP1_DIE; |
| 266 | | switch( stv_framebuffer_mode ) |
| 241 | if ( VDP1_LOG ) logerror( "Setting framebuffer config\n" ); |
| 242 | state->m_vdp1.framebuffer_mode = STV_VDP1_TVM; |
| 243 | state->m_vdp1.framebuffer_double_interlace = STV_VDP1_DIE; |
| 244 | switch( state->m_vdp1.framebuffer_mode ) |
| 267 | 245 | { |
| 268 | | case 0: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break; |
| 269 | | case 1: stv_framebuffer_width = 1024; stv_framebuffer_height = 256; break; |
| 270 | | case 2: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break; |
| 271 | | case 3: stv_framebuffer_width = 512; stv_framebuffer_height = 512; break; |
| 272 | | case 4: stv_framebuffer_width = 512; stv_framebuffer_height = 256; break; |
| 273 | | default: logerror( "Invalid framebuffer config %x\n", STV_VDP1_TVM ); stv_framebuffer_width = 512; stv_framebuffer_height = 256; break; |
| 246 | case 0: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break; |
| 247 | case 1: state->m_vdp1.framebuffer_width = 1024; state->m_vdp1.framebuffer_height = 256; break; |
| 248 | case 2: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break; |
| 249 | case 3: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 512; break; |
| 250 | case 4: state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break; |
| 251 | default: logerror( "Invalid framebuffer config %x\n", STV_VDP1_TVM ); state->m_vdp1.framebuffer_width = 512; state->m_vdp1.framebuffer_height = 256; break; |
| 274 | 252 | } |
| 275 | | if ( STV_VDP1_DIE ) stv_framebuffer_height *= 2; /* double interlace */ |
| 253 | if ( STV_VDP1_DIE ) state->m_vdp1.framebuffer_height *= 2; /* double interlace */ |
| 276 | 254 | |
| 277 | | stv_vdp1_current_draw_framebuffer = 0; |
| 278 | | stv_vdp1_current_display_framebuffer = 1; |
| 279 | | stv_prepare_framebuffers(); |
| 255 | state->m_vdp1.framebuffer_current_draw = 0; |
| 256 | state->m_vdp1.framebuffer_current_display = 1; |
| 257 | stv_prepare_framebuffers(machine); |
| 280 | 258 | } |
| 281 | 259 | |
| 282 | | WRITE32_HANDLER( stv_vdp1_regs_w ) |
| 260 | WRITE32_HANDLER( saturn_vdp1_regs_w ) |
| 283 | 261 | { |
| 284 | | COMBINE_DATA(&stv_vdp1_regs[offset]); |
| 262 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 263 | COMBINE_DATA(&state->m_vdp1_regs[offset]); |
| 285 | 264 | if ( offset == 0 ) |
| 286 | 265 | { |
| 287 | | stv_set_framebuffer_config(); |
| 266 | stv_set_framebuffer_config(space->machine()); |
| 288 | 267 | if ( ACCESSING_BITS_0_15 ) |
| 289 | 268 | { |
| 290 | | if ( vdp1_sprite_log ) logerror( "VDP1: Access to register FBCR = %1X\n", STV_VDP1_FBCR ); |
| 291 | | stv_vdp1_fbcr_accessed = 1; |
| 269 | if ( VDP1_LOG ) logerror( "VDP1: Access to register FBCR = %1X\n", STV_VDP1_FBCR ); |
| 270 | state->m_vdp1.fbcr_accessed = 1; |
| 292 | 271 | } |
| 293 | 272 | else |
| 294 | 273 | { |
| 295 | | if ( vdp1_sprite_log ) logerror( "VDP1: Access to register TVMR = %1X\n", STV_VDP1_TVMR ); |
| 274 | if ( VDP1_LOG ) logerror( "VDP1: Access to register TVMR = %1X\n", STV_VDP1_TVMR ); |
| 296 | 275 | if ( STV_VDP1_VBE && stv_get_vblank(space->machine()) ) |
| 297 | 276 | { |
| 298 | | stv_vdp1_clear_framebuffer_on_next_frame = 1; |
| 277 | state->m_vdp1.framebuffer_clear_on_next_frame = 1; |
| 299 | 278 | } |
| 300 | 279 | |
| 301 | 280 | /* needed by pblbeach, it doesn't clear local coordinates in its sprite list...*/ |
| 302 | 281 | //if ( !strcmp(space->machine().system().name, "pblbeach") ) |
| 303 | 282 | //{ |
| 304 | | // stvvdp1_local_x = stvvdp1_local_y = 0; |
| 283 | // state->m_vdp1.local_x = state->m_vdp1.local_y = 0; |
| 305 | 284 | //} |
| 306 | 285 | } |
| 307 | 286 | } |
| r11640 | r11641 | |
| 311 | 290 | { |
| 312 | 291 | if ( STV_VDP1_PTMR == 1 ) |
| 313 | 292 | { |
| 314 | | if ( vdp1_sprite_log ) logerror( "VDP1: Access to register PTMR = %1X\n", STV_VDP1_PTMR ); |
| 293 | if ( VDP1_LOG ) logerror( "VDP1: Access to register PTMR = %1X\n", STV_VDP1_PTMR ); |
| 315 | 294 | stv_vdp1_process_list( space->machine() ); |
| 316 | 295 | } |
| 317 | 296 | } |
| 318 | 297 | else if ( ACCESSING_BITS_0_15 ) |
| 319 | 298 | { |
| 320 | | if ( vdp1_sprite_log ) logerror( "VDP1: Erase data set %08X\n", data ); |
| 299 | if ( VDP1_LOG ) logerror( "VDP1: Erase data set %08X\n", data ); |
| 321 | 300 | } |
| 322 | 301 | } |
| 323 | 302 | else if ( offset == 2 ) |
| 324 | 303 | { |
| 325 | 304 | if ( ACCESSING_BITS_16_31 ) |
| 326 | 305 | { |
| 327 | | if ( vdp1_sprite_log ) logerror( "VDP1: Erase upper-left coord set: %08X\n", data ); |
| 306 | if ( VDP1_LOG ) logerror( "VDP1: Erase upper-left coord set: %08X\n", data ); |
| 328 | 307 | } |
| 329 | 308 | else if ( ACCESSING_BITS_0_15 ) |
| 330 | 309 | { |
| 331 | | if ( vdp1_sprite_log ) logerror( "VDP1: Erase lower-right coord set: %08X\n", data ); |
| 310 | if ( VDP1_LOG ) logerror( "VDP1: Erase lower-right coord set: %08X\n", data ); |
| 332 | 311 | } |
| 333 | 312 | } |
| 334 | 313 | |
| 335 | 314 | } |
| 336 | 315 | |
| 337 | | READ32_HANDLER ( stv_vdp1_vram_r ) |
| 316 | READ32_HANDLER ( saturn_vdp1_vram_r ) |
| 338 | 317 | { |
| 339 | | return stv_vdp1_vram[offset]; |
| 318 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 319 | return state->m_vdp1_vram[offset]; |
| 340 | 320 | } |
| 341 | 321 | |
| 342 | 322 | |
| 343 | | WRITE32_HANDLER ( stv_vdp1_vram_w ) |
| 323 | WRITE32_HANDLER ( saturn_vdp1_vram_w ) |
| 344 | 324 | { |
| 345 | | UINT8 *vdp1 = stv_vdp1_gfx_decode; |
| 325 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 326 | UINT8 *vdp1 = state->m_vdp1.gfx_decode; |
| 346 | 327 | |
| 347 | | COMBINE_DATA (&stv_vdp1_vram[offset]); |
| 328 | COMBINE_DATA (&state->m_vdp1_vram[offset]); |
| 348 | 329 | |
| 349 | 330 | // if (((offset * 4) > 0xdf) && ((offset * 4) < 0x140)) |
| 350 | 331 | // { |
| 351 | 332 | // logerror("cpu %s (PC=%08X): VRAM dword write to %08X = %08X & %08X\n", space->device().tag(), cpu_get_pc(&space->device()), offset*4, data, mem_mask); |
| 352 | 333 | // } |
| 353 | 334 | |
| 354 | | data = stv_vdp1_vram[offset]; |
| 335 | data = state->m_vdp1_vram[offset]; |
| 355 | 336 | /* put in gfx region for easy decoding */ |
| 356 | 337 | vdp1[offset*4+0] = (data & 0xff000000) >> 24; |
| 357 | 338 | vdp1[offset*4+1] = (data & 0x00ff0000) >> 16; |
| r11640 | r11641 | |
| 359 | 340 | vdp1[offset*4+3] = (data & 0x000000ff) >> 0; |
| 360 | 341 | } |
| 361 | 342 | |
| 362 | | WRITE32_HANDLER ( stv_vdp1_framebuffer0_w ) |
| 343 | WRITE32_HANDLER ( saturn_vdp1_framebuffer0_w ) |
| 363 | 344 | { |
| 345 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 364 | 346 | //popmessage ("STV VDP1 Framebuffer 0 WRITE offset %08x data %08x",offset, data); |
| 365 | | if ( STV_VDP1_TVM & 0 ) |
| 347 | if ( STV_VDP1_TVM & 1 ) |
| 366 | 348 | { |
| 367 | 349 | /* 8-bit mode */ |
| 368 | 350 | } |
| r11640 | r11641 | |
| 371 | 353 | /* 16-bit mode */ |
| 372 | 354 | if ( ACCESSING_BITS_16_31 ) |
| 373 | 355 | { |
| 374 | | stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2] = (data >> 16) & 0xffff; |
| 356 | state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2] = (data >> 16) & 0xffff; |
| 375 | 357 | } |
| 376 | 358 | if ( ACCESSING_BITS_0_15 ) |
| 377 | 359 | { |
| 378 | | stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2+1] = data & 0xffff; |
| 360 | state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2+1] = data & 0xffff; |
| 379 | 361 | } |
| 380 | 362 | } |
| 381 | 363 | } |
| 382 | 364 | |
| 383 | | READ32_HANDLER ( stv_vdp1_framebuffer0_r ) |
| 365 | READ32_HANDLER ( saturn_vdp1_framebuffer0_r ) |
| 384 | 366 | { |
| 367 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 385 | 368 | UINT32 result = 0; |
| 386 | 369 | //popmessage ("STV VDP1 Framebuffer 0 READ offset %08x",offset); |
| 387 | | if ( STV_VDP1_TVM & 0 ) |
| 370 | if ( STV_VDP1_TVM & 1 ) |
| 388 | 371 | { |
| 389 | 372 | /* 8-bit mode */ |
| 390 | 373 | } |
| r11640 | r11641 | |
| 393 | 376 | /* 16-bit mode */ |
| 394 | 377 | if ( ACCESSING_BITS_16_31 ) |
| 395 | 378 | { |
| 396 | | result |= (stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2] << 16); |
| 379 | result |= (state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2] << 16); |
| 397 | 380 | } |
| 398 | 381 | if ( ACCESSING_BITS_0_15 ) |
| 399 | 382 | { |
| 400 | | result |= stv_framebuffer[stv_vdp1_current_draw_framebuffer][offset*2+1]; |
| 383 | result |= (state->m_vdp1.framebuffer[state->m_vdp1.framebuffer_current_draw][offset*2+1]); |
| 401 | 384 | } |
| 402 | 385 | |
| 403 | 386 | } |
| r11640 | r11641 | |
| 406 | 389 | } |
| 407 | 390 | |
| 408 | 391 | #ifdef UNUSED_FUNCTION |
| 409 | | WRITE32_HANDLER ( stv_vdp1_framebuffer1_w ) |
| 392 | WRITE32_HANDLER ( saturn_vdp1_framebuffer1_w ) |
| 410 | 393 | { |
| 411 | 394 | //popmessage ("STV VDP1 Framebuffer 1 WRITE offset %08x data %08x",offset, data); |
| 412 | 395 | } |
| 413 | 396 | |
| 414 | | READ32_HANDLER ( stv_vdp1_framebuffer1_r ) |
| 397 | READ32_HANDLER ( saturn_vdp1_framebuffer1_r ) |
| 415 | 398 | { |
| 416 | 399 | //popmessage ("STV VDP1 Framebuffer 1 READ offset %08x",offset); |
| 417 | 400 | return 0xffff; |
| r11640 | r11641 | |
| 513 | 496 | memset( &stv_gouraud_shading, 0, sizeof( stv_gouraud_shading ) ); |
| 514 | 497 | } |
| 515 | 498 | |
| 516 | | static UINT8 stv_read_gouraud_table(void) |
| 499 | static UINT8 stv_read_gouraud_table(running_machine &machine) |
| 517 | 500 | { |
| 501 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 518 | 502 | int gaddr; |
| 519 | 503 | |
| 520 | 504 | if ( (stv2_current_sprite.CMDPMOD & 0x7) == 4 ) |
| 521 | 505 | { |
| 522 | 506 | gaddr = stv2_current_sprite.CMDGRDA * 8; |
| 523 | | stv_gouraud_shading.GA = (stv_vdp1_vram[gaddr/4] >> 16) & 0xffff; |
| 524 | | stv_gouraud_shading.GB = (stv_vdp1_vram[gaddr/4] >> 0) & 0xffff; |
| 525 | | stv_gouraud_shading.GC = (stv_vdp1_vram[gaddr/4 + 1] >> 16) & 0xffff; |
| 526 | | stv_gouraud_shading.GD = (stv_vdp1_vram[gaddr/4 + 1] >> 0) & 0xffff; |
| 507 | stv_gouraud_shading.GA = (state->m_vdp1_vram[gaddr/4] >> 16) & 0xffff; |
| 508 | stv_gouraud_shading.GB = (state->m_vdp1_vram[gaddr/4] >> 0) & 0xffff; |
| 509 | stv_gouraud_shading.GC = (state->m_vdp1_vram[gaddr/4 + 1] >> 16) & 0xffff; |
| 510 | stv_gouraud_shading.GD = (state->m_vdp1_vram[gaddr/4 + 1] >> 0) & 0xffff; |
| 527 | 511 | return 1; |
| 528 | 512 | } |
| 529 | 513 | else |
| r11640 | r11641 | |
| 674 | 658 | *ng2 = g2; |
| 675 | 659 | } |
| 676 | 660 | |
| 677 | | static void stv_vdp1_setup_shading(const struct spoint* q, const rectangle *cliprect) |
| 661 | static void stv_vdp1_setup_shading(running_machine &machine,const struct spoint* q, const rectangle *cliprect) |
| 678 | 662 | { |
| 679 | 663 | INT32 x1, x2, delta, cury, limy; |
| 680 | 664 | INT32 r1, g1, b1, r2, g2, b2; |
| r11640 | r11641 | |
| 684 | 668 | struct shaded_point p[8]; |
| 685 | 669 | UINT16 gd[4]; |
| 686 | 670 | |
| 687 | | if ( stv_read_gouraud_table() == 0 ) return; |
| 671 | if ( stv_read_gouraud_table(machine) == 0 ) return; |
| 688 | 672 | |
| 689 | 673 | gd[0] = stv_gouraud_shading.GA; |
| 690 | 674 | gd[1] = stv_gouraud_shading.GB; |
| r11640 | r11641 | |
| 858 | 842 | |
| 859 | 843 | static void drawpixel_poly(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 860 | 844 | { |
| 861 | | stv_framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR; |
| 845 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 846 | state->m_vdp1.framebuffer_draw_lines[y][x] = stv2_current_sprite.CMDCOLR; |
| 862 | 847 | } |
| 863 | 848 | |
| 864 | 849 | static void drawpixel_8bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 865 | 850 | { |
| 851 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 866 | 852 | UINT16 pix; |
| 867 | 853 | |
| 868 | 854 | pix = gfxdata[patterndata+offsetcnt]; |
| 869 | 855 | if ( pix & 0xff ) |
| 870 | 856 | { |
| 871 | | stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 857 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 872 | 858 | } |
| 873 | 859 | } |
| 874 | 860 | |
| 875 | 861 | static void drawpixel_4bpp_notrans(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 876 | 862 | { |
| 863 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 877 | 864 | UINT16 pix; |
| 878 | 865 | |
| 879 | 866 | pix = gfxdata[patterndata+offsetcnt/2]; |
| 880 | 867 | pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ; |
| 881 | | stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 868 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 882 | 869 | } |
| 883 | 870 | |
| 884 | 871 | static void drawpixel_4bpp_trans(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 885 | 872 | { |
| 873 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 886 | 874 | UINT16 pix; |
| 887 | 875 | |
| 888 | 876 | pix = gfxdata[patterndata+offsetcnt/2]; |
| 889 | 877 | pix = offsetcnt&1 ? (pix & 0x0f):((pix & 0xf0)>>4) ; |
| 890 | 878 | if ( pix ) |
| 891 | | stv_framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 879 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix | sprite_colorbank; |
| 892 | 880 | } |
| 893 | 881 | |
| 894 | 882 | static void drawpixel_generic(running_machine &machine, int x, int y, int patterndata, int offsetcnt) |
| 895 | 883 | { |
| 884 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 896 | 885 | int pix,mode,transmask, spd = stv2_current_sprite.CMDPMOD & 0x40; |
| 897 | 886 | int mesh = stv2_current_sprite.CMDPMOD & 0x100; |
| 898 | 887 | int pix2; |
| r11640 | r11641 | |
| 933 | 922 | pix2 = gfxdata[patterndata+offsetcnt/2]; |
| 934 | 923 | pix2 = offsetcnt&1 ? (pix2 & 0x0f):((pix2 & 0xf0)>>4); |
| 935 | 924 | pix = pix2&1 ? |
| 936 | | ((((stv_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0): |
| 937 | | ((((stv_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16); |
| 925 | ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0x0000ffff) >> 0): |
| 926 | ((((state->m_vdp1_vram[(((stv2_current_sprite.CMDCOLR&0xffff)*8)>>2)+((pix2&0xfffe)/2)])) & 0xffff0000) >> 16); |
| 938 | 927 | |
| 939 | 928 | mode = 5; |
| 940 | 929 | transmask = 0xffff; |
| r11640 | r11641 | |
| 996 | 985 | { |
| 997 | 986 | if ( (pix & transmask) || spd ) |
| 998 | 987 | { |
| 999 | | stv_framebuffer_draw_lines[y][x] = pix; |
| 988 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| 1000 | 989 | } |
| 1001 | 990 | } |
| 1002 | 991 | else |
| r11640 | r11641 | |
| 1006 | 995 | switch( stv2_current_sprite.CMDPMOD & 0x7 ) |
| 1007 | 996 | { |
| 1008 | 997 | case 0: /* replace */ |
| 1009 | | stv_framebuffer_draw_lines[y][x] = pix; |
| 998 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| 1010 | 999 | break; |
| 1011 | 1000 | case 1: /* shadow */ |
| 1012 | | if ( stv_framebuffer_draw_lines[y][x] & 0x8000 ) |
| 1001 | if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 ) |
| 1013 | 1002 | { |
| 1014 | | stv_framebuffer_draw_lines[y][x] = ((stv_framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000; |
| 1003 | state->m_vdp1.framebuffer_draw_lines[y][x] = ((state->m_vdp1.framebuffer_draw_lines[y][x] & ~0x8421) >> 1) | 0x8000; |
| 1015 | 1004 | } |
| 1016 | 1005 | break; |
| 1017 | 1006 | case 2: /* half luminance */ |
| 1018 | | stv_framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000; |
| 1007 | state->m_vdp1.framebuffer_draw_lines[y][x] = ((pix & ~0x8421) >> 1) | 0x8000; |
| 1019 | 1008 | break; |
| 1020 | 1009 | case 3: /* half transparent */ |
| 1021 | | if ( stv_framebuffer_draw_lines[y][x] & 0x8000 ) |
| 1010 | if ( state->m_vdp1.framebuffer_draw_lines[y][x] & 0x8000 ) |
| 1022 | 1011 | { |
| 1023 | | stv_framebuffer_draw_lines[y][x] = alpha_blend_r16( stv_framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000; |
| 1012 | state->m_vdp1.framebuffer_draw_lines[y][x] = alpha_blend_r16( state->m_vdp1.framebuffer_draw_lines[y][x], pix, 0x80 ) | 0x8000; |
| 1024 | 1013 | } |
| 1025 | 1014 | else |
| 1026 | 1015 | { |
| 1027 | | stv_framebuffer_draw_lines[y][x] = pix; |
| 1016 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| 1028 | 1017 | } |
| 1029 | 1018 | break; |
| 1030 | 1019 | case 4: /* Gouraud shading */ |
| 1031 | | stv_framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix ); |
| 1020 | state->m_vdp1.framebuffer_draw_lines[y][x] = stv_vdp1_apply_gouraud_shading( x, y, pix ); |
| 1032 | 1021 | break; |
| 1033 | 1022 | default: |
| 1034 | | stv_framebuffer_draw_lines[y][x] = pix; |
| 1023 | state->m_vdp1.framebuffer_draw_lines[y][x] = pix; |
| 1035 | 1024 | break; |
| 1036 | 1025 | } |
| 1037 | 1026 | } |
| r11640 | r11641 | |
| 1039 | 1028 | } |
| 1040 | 1029 | |
| 1041 | 1030 | |
| 1042 | | static void stv_vdp1_set_drawpixel(void) |
| 1031 | static void stv_vdp1_set_drawpixel(running_machine &machine) |
| 1043 | 1032 | { |
| 1033 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 1044 | 1034 | int sprite_type = stv2_current_sprite.CMDCTRL & 0x000f; |
| 1045 | 1035 | int sprite_mode = stv2_current_sprite.CMDPMOD&0x0038; |
| 1046 | 1036 | int spd = stv2_current_sprite.CMDPMOD & 0x40; |
| 1047 | 1037 | int mesh = stv2_current_sprite.CMDPMOD & 0x100; |
| 1048 | 1038 | int ecd = stv2_current_sprite.CMDPMOD & 0x80; |
| 1049 | 1039 | |
| 1050 | | gfxdata = stv_vdp1_gfx_decode; |
| 1040 | gfxdata = state->m_vdp1.gfx_decode; |
| 1051 | 1041 | |
| 1052 | 1042 | if ( mesh || !ecd || ((stv2_current_sprite.CMDPMOD & 0x7) != 0) ) |
| 1053 | 1043 | { |
| r11640 | r11641 | |
| 1372 | 1362 | vdp1_fill_line(machine, cliprect, patterndata, xsize, cury, x1, x2, u1, u2, v1, v2); |
| 1373 | 1363 | } |
| 1374 | 1364 | |
| 1375 | | static int x2s(int v) |
| 1365 | static int x2s(running_machine &machine,int v) |
| 1376 | 1366 | { |
| 1377 | | return (INT32)(INT16)v + stvvdp1_local_x; |
| 1367 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 1368 | |
| 1369 | return (INT32)(INT16)v + state->m_vdp1.local_x; |
| 1378 | 1370 | } |
| 1379 | 1371 | |
| 1380 | | static int y2s(int v) |
| 1372 | static int y2s(running_machine &machine, int v) |
| 1381 | 1373 | { |
| 1382 | | return (INT32)(INT16)v + stvvdp1_local_y; |
| 1374 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 1375 | |
| 1376 | return (INT32)(INT16)v + state->m_vdp1.local_y; |
| 1383 | 1377 | } |
| 1384 | 1378 | |
| 1385 | 1379 | static void stv_vdp1_draw_line(running_machine &machine, const rectangle *cliprect) |
| 1386 | 1380 | { |
| 1387 | 1381 | struct spoint q[4]; |
| 1388 | 1382 | |
| 1389 | | q[0].x = x2s(stv2_current_sprite.CMDXA); |
| 1390 | | q[0].y = y2s(stv2_current_sprite.CMDYA); |
| 1391 | | q[1].x = x2s(stv2_current_sprite.CMDXB); |
| 1392 | | q[1].y = y2s(stv2_current_sprite.CMDYB); |
| 1393 | | q[2].x = x2s(stv2_current_sprite.CMDXA); |
| 1394 | | q[2].y = y2s(stv2_current_sprite.CMDYA); |
| 1395 | | q[3].x = x2s(stv2_current_sprite.CMDXB); |
| 1396 | | q[3].y = y2s(stv2_current_sprite.CMDYB); |
| 1383 | q[0].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1384 | q[0].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1385 | q[1].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1386 | q[1].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1387 | q[2].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1388 | q[2].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1389 | q[3].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1390 | q[3].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1397 | 1391 | |
| 1398 | 1392 | q[0].u = q[3].u = q[1].u = q[2].u = 0; |
| 1399 | 1393 | q[0].v = q[1].v = q[2].v = q[3].v = 0; |
| r11640 | r11641 | |
| 1405 | 1399 | { |
| 1406 | 1400 | struct spoint q[4]; |
| 1407 | 1401 | |
| 1408 | | q[0].x = x2s(stv2_current_sprite.CMDXA); |
| 1409 | | q[0].y = y2s(stv2_current_sprite.CMDYA); |
| 1410 | | q[1].x = x2s(stv2_current_sprite.CMDXB); |
| 1411 | | q[1].y = y2s(stv2_current_sprite.CMDYB); |
| 1412 | | q[2].x = x2s(stv2_current_sprite.CMDXA); |
| 1413 | | q[2].y = y2s(stv2_current_sprite.CMDYA); |
| 1414 | | q[3].x = x2s(stv2_current_sprite.CMDXB); |
| 1415 | | q[3].y = y2s(stv2_current_sprite.CMDYB); |
| 1402 | q[0].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1403 | q[0].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1404 | q[1].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1405 | q[1].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1406 | q[2].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1407 | q[2].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1408 | q[3].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1409 | q[3].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1416 | 1410 | |
| 1417 | 1411 | q[0].u = q[3].u = q[1].u = q[2].u = 0; |
| 1418 | 1412 | q[0].v = q[1].v = q[2].v = q[3].v = 0; |
| 1419 | 1413 | |
| 1420 | 1414 | vdp1_fill_quad(machine, cliprect, 0, 1, q); |
| 1421 | 1415 | |
| 1422 | | q[0].x = x2s(stv2_current_sprite.CMDXB); |
| 1423 | | q[0].y = y2s(stv2_current_sprite.CMDYB); |
| 1424 | | q[1].x = x2s(stv2_current_sprite.CMDXC); |
| 1425 | | q[1].y = y2s(stv2_current_sprite.CMDYC); |
| 1426 | | q[2].x = x2s(stv2_current_sprite.CMDXB); |
| 1427 | | q[2].y = y2s(stv2_current_sprite.CMDYB); |
| 1428 | | q[3].x = x2s(stv2_current_sprite.CMDXC); |
| 1429 | | q[3].y = y2s(stv2_current_sprite.CMDYC); |
| 1416 | q[0].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1417 | q[0].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1418 | q[1].x = x2s(machine, stv2_current_sprite.CMDXC); |
| 1419 | q[1].y = y2s(machine, stv2_current_sprite.CMDYC); |
| 1420 | q[2].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1421 | q[2].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1422 | q[3].x = x2s(machine, stv2_current_sprite.CMDXC); |
| 1423 | q[3].y = y2s(machine, stv2_current_sprite.CMDYC); |
| 1430 | 1424 | |
| 1431 | 1425 | q[0].u = q[3].u = q[1].u = q[2].u = 0; |
| 1432 | 1426 | q[0].v = q[1].v = q[2].v = q[3].v = 0; |
| 1433 | 1427 | |
| 1434 | 1428 | vdp1_fill_quad(machine, cliprect, 0, 1, q); |
| 1435 | 1429 | |
| 1436 | | q[0].x = x2s(stv2_current_sprite.CMDXC); |
| 1437 | | q[0].y = y2s(stv2_current_sprite.CMDYC); |
| 1438 | | q[1].x = x2s(stv2_current_sprite.CMDXD); |
| 1439 | | q[1].y = y2s(stv2_current_sprite.CMDYD); |
| 1440 | | q[2].x = x2s(stv2_current_sprite.CMDXC); |
| 1441 | | q[2].y = y2s(stv2_current_sprite.CMDYC); |
| 1442 | | q[3].x = x2s(stv2_current_sprite.CMDXD); |
| 1443 | | q[3].y = y2s(stv2_current_sprite.CMDYD); |
| 1430 | q[0].x = x2s(machine, stv2_current_sprite.CMDXC); |
| 1431 | q[0].y = y2s(machine, stv2_current_sprite.CMDYC); |
| 1432 | q[1].x = x2s(machine, stv2_current_sprite.CMDXD); |
| 1433 | q[1].y = y2s(machine, stv2_current_sprite.CMDYD); |
| 1434 | q[2].x = x2s(machine, stv2_current_sprite.CMDXC); |
| 1435 | q[2].y = y2s(machine, stv2_current_sprite.CMDYC); |
| 1436 | q[3].x = x2s(machine, stv2_current_sprite.CMDXD); |
| 1437 | q[3].y = y2s(machine, stv2_current_sprite.CMDYD); |
| 1444 | 1438 | |
| 1445 | 1439 | q[0].u = q[3].u = q[1].u = q[2].u = 0; |
| 1446 | 1440 | q[0].v = q[1].v = q[2].v = q[3].v = 0; |
| 1447 | 1441 | |
| 1448 | 1442 | vdp1_fill_quad(machine, cliprect, 0, 1, q); |
| 1449 | 1443 | |
| 1450 | | q[0].x = x2s(stv2_current_sprite.CMDXD); |
| 1451 | | q[0].y = y2s(stv2_current_sprite.CMDYD); |
| 1452 | | q[1].x = x2s(stv2_current_sprite.CMDXA); |
| 1453 | | q[1].y = y2s(stv2_current_sprite.CMDYA); |
| 1454 | | q[2].x = x2s(stv2_current_sprite.CMDXD); |
| 1455 | | q[2].y = y2s(stv2_current_sprite.CMDYD); |
| 1456 | | q[3].x = x2s(stv2_current_sprite.CMDXA); |
| 1457 | | q[3].y = y2s(stv2_current_sprite.CMDYA); |
| 1444 | q[0].x = x2s(machine, stv2_current_sprite.CMDXD); |
| 1445 | q[0].y = y2s(machine, stv2_current_sprite.CMDYD); |
| 1446 | q[1].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1447 | q[1].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1448 | q[2].x = x2s(machine, stv2_current_sprite.CMDXD); |
| 1449 | q[2].y = y2s(machine, stv2_current_sprite.CMDYD); |
| 1450 | q[3].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1451 | q[3].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1458 | 1452 | |
| 1459 | 1453 | q[0].u = q[3].u = q[1].u = q[2].u = 0; |
| 1460 | 1454 | q[0].v = q[1].v = q[2].v = q[3].v = 0; |
| 1461 | 1455 | |
| 1462 | | stv_vdp1_setup_shading(q, cliprect); |
| 1456 | stv_vdp1_setup_shading(machine, q, cliprect); |
| 1463 | 1457 | vdp1_fill_quad(machine, cliprect, 0, 1, q); |
| 1464 | 1458 | |
| 1465 | 1459 | } |
| r11640 | r11641 | |
| 1494 | 1488 | } |
| 1495 | 1489 | |
| 1496 | 1490 | |
| 1497 | | q[0].x = x2s(stv2_current_sprite.CMDXA); |
| 1498 | | q[0].y = y2s(stv2_current_sprite.CMDYA); |
| 1499 | | q[1].x = x2s(stv2_current_sprite.CMDXB); |
| 1500 | | q[1].y = y2s(stv2_current_sprite.CMDYB); |
| 1501 | | q[2].x = x2s(stv2_current_sprite.CMDXC); |
| 1502 | | q[2].y = y2s(stv2_current_sprite.CMDYC); |
| 1503 | | q[3].x = x2s(stv2_current_sprite.CMDXD); |
| 1504 | | q[3].y = y2s(stv2_current_sprite.CMDYD); |
| 1491 | q[0].x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1492 | q[0].y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1493 | q[1].x = x2s(machine, stv2_current_sprite.CMDXB); |
| 1494 | q[1].y = y2s(machine, stv2_current_sprite.CMDYB); |
| 1495 | q[2].x = x2s(machine, stv2_current_sprite.CMDXC); |
| 1496 | q[2].y = y2s(machine, stv2_current_sprite.CMDYC); |
| 1497 | q[3].x = x2s(machine, stv2_current_sprite.CMDXD); |
| 1498 | q[3].y = y2s(machine, stv2_current_sprite.CMDYD); |
| 1505 | 1499 | |
| 1506 | 1500 | if(direction & 1) { // xflip |
| 1507 | 1501 | q[0].u = q[3].u = xsize-1; |
| r11640 | r11641 | |
| 1518 | 1512 | q[2].v = q[3].v = ysize-1; |
| 1519 | 1513 | } |
| 1520 | 1514 | |
| 1521 | | stv_vdp1_setup_shading(q, cliprect); |
| 1515 | stv_vdp1_setup_shading(machine, q, cliprect); |
| 1522 | 1516 | vdp1_fill_quad(machine, cliprect, patterndata, xsize, q); |
| 1523 | 1517 | } |
| 1524 | 1518 | |
| r11640 | r11641 | |
| 1620 | 1614 | |
| 1621 | 1615 | if (zoompoint) |
| 1622 | 1616 | { |
| 1623 | | q[0].x = x2s(x); |
| 1624 | | q[0].y = y2s(y); |
| 1625 | | q[1].x = x2s(x)+screen_width; |
| 1626 | | q[1].y = y2s(y); |
| 1627 | | q[2].x = x2s(x)+screen_width; |
| 1628 | | q[2].y = y2s(y)+screen_height; |
| 1629 | | q[3].x = x2s(x); |
| 1630 | | q[3].y = y2s(y)+screen_height; |
| 1617 | q[0].x = x2s(machine, x); |
| 1618 | q[0].y = y2s(machine, y); |
| 1619 | q[1].x = x2s(machine, x)+screen_width; |
| 1620 | q[1].y = y2s(machine, y); |
| 1621 | q[2].x = x2s(machine, x)+screen_width; |
| 1622 | q[2].y = y2s(machine, y)+screen_height; |
| 1623 | q[3].x = x2s(machine, x); |
| 1624 | q[3].y = y2s(machine, y)+screen_height; |
| 1631 | 1625 | |
| 1632 | 1626 | if ( screen_height_negative ) |
| 1633 | 1627 | { |
| r11640 | r11641 | |
| 1639 | 1633 | } |
| 1640 | 1634 | else |
| 1641 | 1635 | { |
| 1642 | | q[0].x = x2s(x); |
| 1643 | | q[0].y = y2s(y); |
| 1644 | | q[1].x = x2s(x2); |
| 1645 | | q[1].y = y2s(y); |
| 1646 | | q[2].x = x2s(x2); |
| 1647 | | q[2].y = y2s(y2); |
| 1648 | | q[3].x = x2s(x); |
| 1649 | | q[3].y = y2s(y2); |
| 1636 | q[0].x = x2s(machine, x); |
| 1637 | q[0].y = y2s(machine, y); |
| 1638 | q[1].x = x2s(machine, x2); |
| 1639 | q[1].y = y2s(machine, y); |
| 1640 | q[2].x = x2s(machine, x2); |
| 1641 | q[2].y = y2s(machine, y2); |
| 1642 | q[3].x = x2s(machine, x); |
| 1643 | q[3].y = y2s(machine, y2); |
| 1650 | 1644 | } |
| 1651 | 1645 | |
| 1652 | 1646 | |
| r11640 | r11641 | |
| 1665 | 1659 | q[2].v = q[3].v = ysize-1; |
| 1666 | 1660 | } |
| 1667 | 1661 | |
| 1668 | | stv_vdp1_setup_shading(q, cliprect); |
| 1662 | stv_vdp1_setup_shading(machine, q, cliprect); |
| 1669 | 1663 | vdp1_fill_quad(machine, cliprect, patterndata, xsize, q); |
| 1670 | 1664 | } |
| 1671 | 1665 | |
| r11640 | r11641 | |
| 1673 | 1667 | static void stv_vpd1_draw_normal_sprite(running_machine &machine, const rectangle *cliprect, int sprite_type) |
| 1674 | 1668 | { |
| 1675 | 1669 | //UINT16 *destline; |
| 1676 | | |
| 1670 | //saturn_state *state = machine.driver_data<saturn_state>(); |
| 1677 | 1671 | int y, ysize, drawypos; |
| 1678 | 1672 | int x, xsize, drawxpos; |
| 1679 | 1673 | int direction; |
| r11640 | r11641 | |
| 1684 | 1678 | |
| 1685 | 1679 | |
| 1686 | 1680 | |
| 1687 | | shading = stv_read_gouraud_table(); |
| 1681 | shading = stv_read_gouraud_table(machine); |
| 1688 | 1682 | |
| 1689 | | x = x2s(stv2_current_sprite.CMDXA); |
| 1690 | | y = y2s(stv2_current_sprite.CMDYA); |
| 1683 | x = x2s(machine, stv2_current_sprite.CMDXA); |
| 1684 | y = y2s(machine, stv2_current_sprite.CMDYA); |
| 1691 | 1685 | |
| 1692 | 1686 | direction = (stv2_current_sprite.CMDCTRL & 0x0030)>>4; |
| 1693 | 1687 | |
| r11640 | r11641 | |
| 1699 | 1693 | patterndata = (stv2_current_sprite.CMDSRCA) & 0xffff; |
| 1700 | 1694 | patterndata = patterndata * 0x8; |
| 1701 | 1695 | |
| 1702 | | if (vdp1_sprite_log) logerror ("Drawing Normal Sprite x %04x y %04x xsize %04x ysize %04x patterndata %06x\n",x,y,xsize,ysize,patterndata); |
| 1696 | if (VDP1_LOG) logerror ("Drawing Normal Sprite x %04x y %04x xsize %04x ysize %04x patterndata %06x\n",x,y,xsize,ysize,patterndata); |
| 1703 | 1697 | |
| 1704 | 1698 | if ( x > cliprect->max_x ) return; |
| 1705 | 1699 | if ( y > cliprect->max_y ) return; |
| 1706 | 1700 | |
| 1707 | | shading = stv_read_gouraud_table(); |
| 1701 | shading = stv_read_gouraud_table(machine); |
| 1708 | 1702 | if ( shading ) |
| 1709 | 1703 | { |
| 1710 | 1704 | struct spoint q[4]; |
| r11640 | r11641 | |
| 1713 | 1707 | q[2].x = x + xsize; q[2].y = y + ysize; |
| 1714 | 1708 | q[3].x = x; q[3].y = y + ysize; |
| 1715 | 1709 | |
| 1716 | | stv_vdp1_setup_shading( q, cliprect ); |
| 1710 | stv_vdp1_setup_shading( machine, q, cliprect ); |
| 1717 | 1711 | } |
| 1718 | 1712 | |
| 1719 | 1713 | u = 0; |
| r11640 | r11641 | |
| 1745 | 1739 | maxdrawxpos = MIN(x+xsize-1,cliprect->max_x); |
| 1746 | 1740 | for (drawypos = y; drawypos <= maxdrawypos; drawypos++ ) |
| 1747 | 1741 | { |
| 1748 | | //destline = stv_framebuffer_draw_lines[drawypos]; |
| 1742 | //destline = state->m_vdp1.framebuffer_draw_lines[drawypos]; |
| 1749 | 1743 | su = u; |
| 1750 | 1744 | for (drawxpos = x; drawxpos <= maxdrawxpos; drawxpos++ ) |
| 1751 | 1745 | { |
| r11640 | r11641 | |
| 1758 | 1752 | |
| 1759 | 1753 | static void stv_vdp1_process_list(running_machine &machine) |
| 1760 | 1754 | { |
| 1755 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 1761 | 1756 | int position; |
| 1762 | 1757 | int spritecount; |
| 1763 | 1758 | int vdp1_nest; |
| r11640 | r11641 | |
| 1766 | 1761 | spritecount = 0; |
| 1767 | 1762 | position = 0; |
| 1768 | 1763 | |
| 1769 | | if (vdp1_sprite_log) logerror ("Sprite List Process START\n"); |
| 1764 | if (VDP1_LOG) logerror ("Sprite List Process START\n"); |
| 1770 | 1765 | |
| 1771 | 1766 | vdp1_nest = -1; |
| 1772 | 1767 | |
| 1773 | 1768 | stv_clear_gouraud_shading(); |
| 1774 | 1769 | |
| 1775 | 1770 | /*Set CEF bit to 0*/ |
| 1776 | | SET_CEF_FROM_1_TO_0; |
| 1771 | CEF_0; |
| 1777 | 1772 | |
| 1778 | 1773 | while (spritecount<10000) // if its drawn this many sprites something is probably wrong or sega were crazy ;-) |
| 1779 | 1774 | { |
| r11640 | r11641 | |
| 1783 | 1778 | |
| 1784 | 1779 | // if (position >= ((0x80000/0x20)/4)) // safety check |
| 1785 | 1780 | // { |
| 1786 | | // if (vdp1_sprite_log) logerror ("Sprite List Position Too High!\n"); |
| 1781 | // if (VDP1_LOG) logerror ("Sprite List Position Too High!\n"); |
| 1787 | 1782 | // position = 0; |
| 1788 | 1783 | // } |
| 1789 | 1784 | |
| 1790 | | stv2_current_sprite.CMDCTRL = (stv_vdp1_vram[position * (0x20/4)+0] & 0xffff0000) >> 16; |
| 1785 | stv2_current_sprite.CMDCTRL = (state->m_vdp1_vram[position * (0x20/4)+0] & 0xffff0000) >> 16; |
| 1791 | 1786 | |
| 1792 | 1787 | if (stv2_current_sprite.CMDCTRL == 0x8000) |
| 1793 | 1788 | { |
| 1794 | | if (vdp1_sprite_log) logerror ("List Terminator (0x8000) Encountered, Sprite List Process END\n"); |
| 1789 | if (VDP1_LOG) logerror ("List Terminator (0x8000) Encountered, Sprite List Process END\n"); |
| 1795 | 1790 | goto end; // end of list |
| 1796 | 1791 | } |
| 1797 | 1792 | |
| 1798 | | stv2_current_sprite.CMDLINK = (stv_vdp1_vram[position * (0x20/4)+0] & 0x0000ffff) >> 0; |
| 1799 | | stv2_current_sprite.CMDPMOD = (stv_vdp1_vram[position * (0x20/4)+1] & 0xffff0000) >> 16; |
| 1800 | | stv2_current_sprite.CMDCOLR = (stv_vdp1_vram[position * (0x20/4)+1] & 0x0000ffff) >> 0; |
| 1801 | | stv2_current_sprite.CMDSRCA = (stv_vdp1_vram[position * (0x20/4)+2] & 0xffff0000) >> 16; |
| 1802 | | stv2_current_sprite.CMDSIZE = (stv_vdp1_vram[position * (0x20/4)+2] & 0x0000ffff) >> 0; |
| 1803 | | stv2_current_sprite.CMDXA = (stv_vdp1_vram[position * (0x20/4)+3] & 0xffff0000) >> 16; |
| 1804 | | stv2_current_sprite.CMDYA = (stv_vdp1_vram[position * (0x20/4)+3] & 0x0000ffff) >> 0; |
| 1805 | | stv2_current_sprite.CMDXB = (stv_vdp1_vram[position * (0x20/4)+4] & 0xffff0000) >> 16; |
| 1806 | | stv2_current_sprite.CMDYB = (stv_vdp1_vram[position * (0x20/4)+4] & 0x0000ffff) >> 0; |
| 1807 | | stv2_current_sprite.CMDXC = (stv_vdp1_vram[position * (0x20/4)+5] & 0xffff0000) >> 16; |
| 1808 | | stv2_current_sprite.CMDYC = (stv_vdp1_vram[position * (0x20/4)+5] & 0x0000ffff) >> 0; |
| 1809 | | stv2_current_sprite.CMDXD = (stv_vdp1_vram[position * (0x20/4)+6] & 0xffff0000) >> 16; |
| 1810 | | stv2_current_sprite.CMDYD = (stv_vdp1_vram[position * (0x20/4)+6] & 0x0000ffff) >> 0; |
| 1811 | | stv2_current_sprite.CMDGRDA = (stv_vdp1_vram[position * (0x20/4)+7] & 0xffff0000) >> 16; |
| 1812 | | // stv2_current_sprite.UNUSED = (stv_vdp1_vram[position * (0x20/4)+7] & 0x0000ffff) >> 0; |
| 1793 | stv2_current_sprite.CMDLINK = (state->m_vdp1_vram[position * (0x20/4)+0] & 0x0000ffff) >> 0; |
| 1794 | stv2_current_sprite.CMDPMOD = (state->m_vdp1_vram[position * (0x20/4)+1] & 0xffff0000) >> 16; |
| 1795 | stv2_current_sprite.CMDCOLR = (state->m_vdp1_vram[position * (0x20/4)+1] & 0x0000ffff) >> 0; |
| 1796 | stv2_current_sprite.CMDSRCA = (state->m_vdp1_vram[position * (0x20/4)+2] & 0xffff0000) >> 16; |
| 1797 | stv2_current_sprite.CMDSIZE = (state->m_vdp1_vram[position * (0x20/4)+2] & 0x0000ffff) >> 0; |
| 1798 | stv2_current_sprite.CMDXA = (state->m_vdp1_vram[position * (0x20/4)+3] & 0xffff0000) >> 16; |
| 1799 | stv2_current_sprite.CMDYA = (state->m_vdp1_vram[position * (0x20/4)+3] & 0x0000ffff) >> 0; |
| 1800 | stv2_current_sprite.CMDXB = (state->m_vdp1_vram[position * (0x20/4)+4] & 0xffff0000) >> 16; |
| 1801 | stv2_current_sprite.CMDYB = (state->m_vdp1_vram[position * (0x20/4)+4] & 0x0000ffff) >> 0; |
| 1802 | stv2_current_sprite.CMDXC = (state->m_vdp1_vram[position * (0x20/4)+5] & 0xffff0000) >> 16; |
| 1803 | stv2_current_sprite.CMDYC = (state->m_vdp1_vram[position * (0x20/4)+5] & 0x0000ffff) >> 0; |
| 1804 | stv2_current_sprite.CMDXD = (state->m_vdp1_vram[position * (0x20/4)+6] & 0xffff0000) >> 16; |
| 1805 | stv2_current_sprite.CMDYD = (state->m_vdp1_vram[position * (0x20/4)+6] & 0x0000ffff) >> 0; |
| 1806 | stv2_current_sprite.CMDGRDA = (state->m_vdp1_vram[position * (0x20/4)+7] & 0xffff0000) >> 16; |
| 1807 | // stv2_current_sprite.UNUSED = (state->m_vdp1_vram[position * (0x20/4)+7] & 0x0000ffff) >> 0; |
| 1813 | 1808 | |
| 1814 | 1809 | /* proecess jump / skip commands, set position for next sprite */ |
| 1815 | 1810 | switch (stv2_current_sprite.CMDCTRL & 0x7000) |
| 1816 | 1811 | { |
| 1817 | 1812 | case 0x0000: // jump next |
| 1818 | | if (vdp1_sprite_log) logerror ("Sprite List Process + Next (Normal)\n"); |
| 1813 | if (VDP1_LOG) logerror ("Sprite List Process + Next (Normal)\n"); |
| 1819 | 1814 | position++; |
| 1820 | 1815 | break; |
| 1821 | 1816 | case 0x1000: // jump assign |
| 1822 | | if (vdp1_sprite_log) logerror ("Sprite List Process + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2)); |
| 1817 | if (VDP1_LOG) logerror ("Sprite List Process + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2)); |
| 1823 | 1818 | position= (stv2_current_sprite.CMDLINK>>2); |
| 1824 | 1819 | break; |
| 1825 | 1820 | case 0x2000: // jump call |
| 1826 | 1821 | if (vdp1_nest == -1) |
| 1827 | 1822 | { |
| 1828 | | if (vdp1_sprite_log) logerror ("Sprite List Process + Call Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2)); |
| 1823 | if (VDP1_LOG) logerror ("Sprite List Process + Call Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2)); |
| 1829 | 1824 | vdp1_nest = position+1; |
| 1830 | 1825 | position = (stv2_current_sprite.CMDLINK>>2); |
| 1831 | 1826 | } |
| 1832 | 1827 | else |
| 1833 | 1828 | { |
| 1834 | | if (vdp1_sprite_log) logerror ("Sprite List Nested Call, ignoring\n"); |
| 1829 | if (VDP1_LOG) logerror ("Sprite List Nested Call, ignoring\n"); |
| 1835 | 1830 | position++; |
| 1836 | 1831 | } |
| 1837 | 1832 | break; |
| 1838 | 1833 | case 0x3000: |
| 1839 | 1834 | if (vdp1_nest != -1) |
| 1840 | 1835 | { |
| 1841 | | if (vdp1_sprite_log) logerror ("Sprite List Process + Return\n"); |
| 1836 | if (VDP1_LOG) logerror ("Sprite List Process + Return\n"); |
| 1842 | 1837 | position = vdp1_nest; |
| 1843 | 1838 | vdp1_nest = -1; |
| 1844 | 1839 | } |
| 1845 | 1840 | else |
| 1846 | 1841 | { |
| 1847 | | if (vdp1_sprite_log) logerror ("Attempted return from no subroutine, aborting\n"); |
| 1842 | if (VDP1_LOG) logerror ("Attempted return from no subroutine, aborting\n"); |
| 1848 | 1843 | position++; |
| 1849 | 1844 | goto end; // end of list |
| 1850 | 1845 | } |
| r11640 | r11641 | |
| 1854 | 1849 | position++; |
| 1855 | 1850 | break; |
| 1856 | 1851 | case 0x5000: |
| 1857 | | if (vdp1_sprite_log) logerror ("Sprite List Skip + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2)); |
| 1852 | if (VDP1_LOG) logerror ("Sprite List Skip + Jump Old %06x New %06x\n", position, (stv2_current_sprite.CMDLINK>>2)); |
| 1858 | 1853 | draw_this_sprite = 0; |
| 1859 | 1854 | position= (stv2_current_sprite.CMDLINK>>2); |
| 1860 | 1855 | |
| r11640 | r11641 | |
| 1863 | 1858 | draw_this_sprite = 0; |
| 1864 | 1859 | if (vdp1_nest == -1) |
| 1865 | 1860 | { |
| 1866 | | if (vdp1_sprite_log) logerror ("Sprite List Skip + Call To Subroutine Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2)); |
| 1861 | if (VDP1_LOG) logerror ("Sprite List Skip + Call To Subroutine Old %06x New %06x\n",position, (stv2_current_sprite.CMDLINK>>2)); |
| 1867 | 1862 | |
| 1868 | 1863 | vdp1_nest = position+1; |
| 1869 | 1864 | position = (stv2_current_sprite.CMDLINK>>2); |
| 1870 | 1865 | } |
| 1871 | 1866 | else |
| 1872 | 1867 | { |
| 1873 | | if (vdp1_sprite_log) logerror ("Sprite List Nested Call, ignoring\n"); |
| 1868 | if (VDP1_LOG) logerror ("Sprite List Nested Call, ignoring\n"); |
| 1874 | 1869 | position++; |
| 1875 | 1870 | } |
| 1876 | 1871 | break; |
| r11640 | r11641 | |
| 1878 | 1873 | draw_this_sprite = 0; |
| 1879 | 1874 | if (vdp1_nest != -1) |
| 1880 | 1875 | { |
| 1881 | | if (vdp1_sprite_log) logerror ("Sprite List Skip + Return from Subroutine\n"); |
| 1876 | if (VDP1_LOG) logerror ("Sprite List Skip + Return from Subroutine\n"); |
| 1882 | 1877 | |
| 1883 | 1878 | position = vdp1_nest; |
| 1884 | 1879 | vdp1_nest = -1; |
| 1885 | 1880 | } |
| 1886 | 1881 | else |
| 1887 | 1882 | { |
| 1888 | | if (vdp1_sprite_log) logerror ("Attempted return from no subroutine, aborting\n"); |
| 1883 | if (VDP1_LOG) logerror ("Attempted return from no subroutine, aborting\n"); |
| 1889 | 1884 | position++; |
| 1890 | 1885 | goto end; // end of list |
| 1891 | 1886 | } |
| r11640 | r11641 | |
| 1897 | 1892 | { |
| 1898 | 1893 | if ( stv2_current_sprite.CMDPMOD & 0x0400 ) |
| 1899 | 1894 | { |
| 1900 | | cliprect = &stv_vdp1_user_cliprect; |
| 1895 | cliprect = &state->m_vdp1.user_cliprect; |
| 1901 | 1896 | } |
| 1902 | 1897 | else |
| 1903 | 1898 | { |
| 1904 | | cliprect = &stv_vdp1_system_cliprect; |
| 1899 | cliprect = &state->m_vdp1.system_cliprect; |
| 1905 | 1900 | } |
| 1906 | 1901 | |
| 1907 | | stv_vdp1_set_drawpixel(); |
| 1902 | stv_vdp1_set_drawpixel(machine); |
| 1908 | 1903 | |
| 1909 | 1904 | switch (stv2_current_sprite.CMDCTRL & 0x000f) |
| 1910 | 1905 | { |
| 1911 | 1906 | case 0x0000: |
| 1912 | | if (vdp1_sprite_log) logerror ("Sprite List Normal Sprite\n"); |
| 1907 | if (VDP1_LOG) logerror ("Sprite List Normal Sprite\n"); |
| 1913 | 1908 | stv2_current_sprite.ispoly = 0; |
| 1914 | 1909 | stv_vpd1_draw_normal_sprite(machine, cliprect, 0); |
| 1915 | 1910 | break; |
| 1916 | 1911 | |
| 1917 | 1912 | case 0x0001: |
| 1918 | | if (vdp1_sprite_log) logerror ("Sprite List Scaled Sprite\n"); |
| 1913 | if (VDP1_LOG) logerror ("Sprite List Scaled Sprite\n"); |
| 1919 | 1914 | stv2_current_sprite.ispoly = 0; |
| 1920 | 1915 | stv_vpd1_draw_scaled_sprite(machine, cliprect); |
| 1921 | 1916 | break; |
| 1922 | 1917 | |
| 1923 | 1918 | case 0x0002: |
| 1924 | | if (vdp1_sprite_log) logerror ("Sprite List Distorted Sprite\n"); |
| 1919 | if (VDP1_LOG) logerror ("Sprite List Distorted Sprite\n"); |
| 1925 | 1920 | stv2_current_sprite.ispoly = 0; |
| 1926 | 1921 | stv_vpd1_draw_distorted_sprite(machine, cliprect); |
| 1927 | 1922 | break; |
| 1928 | 1923 | |
| 1929 | 1924 | case 0x0004: |
| 1930 | | if (vdp1_sprite_log) logerror ("Sprite List Polygon\n"); |
| 1925 | if (VDP1_LOG) logerror ("Sprite List Polygon\n"); |
| 1931 | 1926 | stv2_current_sprite.ispoly = 1; |
| 1932 | 1927 | stv_vpd1_draw_distorted_sprite(machine, cliprect); |
| 1933 | 1928 | break; |
| 1934 | 1929 | |
| 1935 | 1930 | case 0x0005: |
| 1936 | | if (vdp1_sprite_log) logerror ("Sprite List Polyline\n"); |
| 1931 | if (VDP1_LOG) logerror ("Sprite List Polyline\n"); |
| 1937 | 1932 | stv2_current_sprite.ispoly = 1; |
| 1938 | 1933 | stv_vdp1_draw_poly_line(machine, cliprect); |
| 1939 | 1934 | break; |
| 1940 | 1935 | |
| 1941 | 1936 | case 0x0006: |
| 1942 | | if (vdp1_sprite_log) logerror ("Sprite List Line\n"); |
| 1937 | if (VDP1_LOG) logerror ("Sprite List Line\n"); |
| 1943 | 1938 | stv2_current_sprite.ispoly = 1; |
| 1944 | 1939 | stv_vdp1_draw_line(machine, cliprect); |
| 1945 | 1940 | break; |
| 1946 | 1941 | |
| 1947 | 1942 | case 0x0008: |
| 1948 | | if (vdp1_sprite_log) logerror ("Sprite List Set Command for User Clipping (%d,%d),(%d,%d)\n", stv2_current_sprite.CMDXA, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 1949 | | stv_vdp1_user_cliprect.min_x = stv2_current_sprite.CMDXA; |
| 1950 | | stv_vdp1_user_cliprect.min_y = stv2_current_sprite.CMDYA; |
| 1951 | | stv_vdp1_user_cliprect.max_x = stv2_current_sprite.CMDXC; |
| 1952 | | stv_vdp1_user_cliprect.max_y = stv2_current_sprite.CMDYC; |
| 1943 | if (VDP1_LOG) logerror ("Sprite List Set Command for User Clipping (%d,%d),(%d,%d)\n", stv2_current_sprite.CMDXA, stv2_current_sprite.CMDYA, stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 1944 | state->m_vdp1.user_cliprect.min_x = stv2_current_sprite.CMDXA; |
| 1945 | state->m_vdp1.user_cliprect.min_y = stv2_current_sprite.CMDYA; |
| 1946 | state->m_vdp1.user_cliprect.max_x = stv2_current_sprite.CMDXC; |
| 1947 | state->m_vdp1.user_cliprect.max_y = stv2_current_sprite.CMDYC; |
| 1953 | 1948 | break; |
| 1954 | 1949 | |
| 1955 | 1950 | case 0x0009: |
| 1956 | | if (vdp1_sprite_log) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 1957 | | stv_vdp1_system_cliprect.min_x = 0; |
| 1958 | | stv_vdp1_system_cliprect.min_y = 0; |
| 1959 | | stv_vdp1_system_cliprect.max_x = stv2_current_sprite.CMDXC; |
| 1960 | | stv_vdp1_system_cliprect.max_y = stv2_current_sprite.CMDYC; |
| 1951 | if (VDP1_LOG) logerror ("Sprite List Set Command for System Clipping (0,0),(%d,%d)\n", stv2_current_sprite.CMDXC, stv2_current_sprite.CMDYC); |
| 1952 | state->m_vdp1.system_cliprect.min_x = 0; |
| 1953 | state->m_vdp1.system_cliprect.min_y = 0; |
| 1954 | state->m_vdp1.system_cliprect.max_x = stv2_current_sprite.CMDXC; |
| 1955 | state->m_vdp1.system_cliprect.max_y = stv2_current_sprite.CMDYC; |
| 1961 | 1956 | break; |
| 1962 | 1957 | |
| 1963 | 1958 | case 0x000a: |
| 1964 | | if (vdp1_sprite_log) logerror ("Sprite List Local Co-Ordinate Set\n"); |
| 1965 | | stvvdp1_local_x = (INT16)stv2_current_sprite.CMDXA; |
| 1966 | | stvvdp1_local_y = (INT16)stv2_current_sprite.CMDYA; |
| 1959 | if (VDP1_LOG) logerror ("Sprite List Local Co-Ordinate Set\n"); |
| 1960 | state->m_vdp1.local_x = (INT16)stv2_current_sprite.CMDXA; |
| 1961 | state->m_vdp1.local_y = (INT16)stv2_current_sprite.CMDYA; |
| 1967 | 1962 | break; |
| 1968 | 1963 | |
| 1969 | 1964 | default: |
| 1970 | | if (vdp1_sprite_log) logerror ("Sprite List Illegal!\n"); |
| 1965 | if (VDP1_LOG) logerror ("Sprite List Illegal!\n"); |
| 1971 | 1966 | break; |
| 1972 | 1967 | |
| 1973 | 1968 | |
| r11640 | r11641 | |
| 1983 | 1978 | |
| 1984 | 1979 | end: |
| 1985 | 1980 | /*set CEF to 1*/ |
| 1986 | | SET_CEF_FROM_0_TO_1; |
| 1981 | CEF_1; |
| 1987 | 1982 | |
| 1988 | 1983 | /* not here! this is done every frame drawn even if the cpu isn't running eg in the debugger */ |
| 1989 | 1984 | // if(!(stv_scu[40] & 0x2000)) /*Sprite draw end irq*/ |
| 1990 | 1985 | // cputag_set_input_line_and_vector(machine, "maincpu", 2, HOLD_LINE , 0x4d); |
| 1991 | 1986 | |
| 1992 | | if (vdp1_sprite_log) logerror ("End of list processing!\n"); |
| 1987 | if (VDP1_LOG) logerror ("End of list processing!\n"); |
| 1993 | 1988 | } |
| 1994 | 1989 | |
| 1995 | 1990 | void video_update_vdp1(running_machine &machine) |
| 1996 | 1991 | { |
| 1992 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 1997 | 1993 | int framebufer_changed = 0; |
| 1998 | 1994 | |
| 1999 | 1995 | // int enable; |
| 2000 | | // if (input_code_pressed (machine, KEYCODE_R)) vdp1_sprite_log = 1; |
| 2001 | | // if (input_code_pressed (machine, KEYCODE_T)) vdp1_sprite_log = 0; |
| 1996 | // if (input_code_pressed (machine, KEYCODE_R)) VDP1_LOG = 1; |
| 1997 | // if (input_code_pressed (machine, KEYCODE_T)) VDP1_LOG = 0; |
| 2002 | 1998 | |
| 2003 | | // if (input_code_pressed (machine, KEYCODE_Y)) vdp1_sprite_log = 0; |
| 1999 | // if (input_code_pressed (machine, KEYCODE_Y)) VDP1_LOG = 0; |
| 2004 | 2000 | // { |
| 2005 | 2001 | // FILE *fp; |
| 2006 | 2002 | // |
| r11640 | r11641 | |
| 2011 | 2007 | // fclose(fp); |
| 2012 | 2008 | // } |
| 2013 | 2009 | // } |
| 2014 | | if (vdp1_sprite_log) logerror("video_update_vdp1 called\n"); |
| 2015 | | if (vdp1_sprite_log) logerror( "FBCR = %0x, accessed = %d\n", STV_VDP1_FBCR, stv_vdp1_fbcr_accessed ); |
| 2010 | if (VDP1_LOG) logerror("video_update_vdp1 called\n"); |
| 2011 | if (VDP1_LOG) logerror( "FBCR = %0x, accessed = %d\n", STV_VDP1_FBCR, state->m_vdp1.fbcr_accessed ); |
| 2016 | 2012 | |
| 2017 | | if ( stv_vdp1_clear_framebuffer_on_next_frame ) |
| 2013 | if ( state->m_vdp1.framebuffer_clear_on_next_frame ) |
| 2018 | 2014 | { |
| 2019 | 2015 | if ( ((STV_VDP1_FBCR & 0x3) == 3) && |
| 2020 | | stv_vdp1_fbcr_accessed ) |
| 2016 | state->m_vdp1.fbcr_accessed ) |
| 2021 | 2017 | { |
| 2022 | | stv_clear_framebuffer(stv_vdp1_current_display_framebuffer); |
| 2023 | | stv_vdp1_clear_framebuffer_on_next_frame = 0; |
| 2018 | stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_display); |
| 2019 | state->m_vdp1.framebuffer_clear_on_next_frame = 0; |
| 2024 | 2020 | } |
| 2025 | 2021 | } |
| 2026 | 2022 | |
| 2027 | 2023 | switch( STV_VDP1_FBCR & 0x3 ) |
| 2028 | 2024 | { |
| 2029 | 2025 | case 0: /* Automatic mode */ |
| 2030 | | stv_vdp1_change_framebuffers(); |
| 2031 | | stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer); |
| 2026 | stv_vdp1_change_framebuffers(machine); |
| 2027 | stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw); |
| 2032 | 2028 | framebufer_changed = 1; |
| 2033 | 2029 | break; |
| 2034 | 2030 | case 1: /* Setting prohibited */ |
| 2035 | 2031 | break; |
| 2036 | 2032 | case 2: /* Manual mode - erase */ |
| 2037 | | if ( stv_vdp1_fbcr_accessed ) |
| 2033 | if ( state->m_vdp1.fbcr_accessed ) |
| 2038 | 2034 | { |
| 2039 | | stv_vdp1_clear_framebuffer_on_next_frame = 1; |
| 2035 | state->m_vdp1.framebuffer_clear_on_next_frame = 1; |
| 2040 | 2036 | } |
| 2041 | 2037 | break; |
| 2042 | 2038 | case 3: /* Manual mode - change */ |
| 2043 | | if ( stv_vdp1_fbcr_accessed ) |
| 2039 | if ( state->m_vdp1.fbcr_accessed ) |
| 2044 | 2040 | { |
| 2045 | | stv_vdp1_change_framebuffers(); |
| 2041 | stv_vdp1_change_framebuffers(machine); |
| 2046 | 2042 | if ( STV_VDP1_VBE ) |
| 2047 | 2043 | { |
| 2048 | | stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer); |
| 2044 | stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw); |
| 2049 | 2045 | } |
| 2050 | 2046 | framebufer_changed = 1; |
| 2051 | 2047 | } |
| 2052 | 2048 | break; |
| 2053 | 2049 | } |
| 2054 | | stv_vdp1_fbcr_accessed = 0; |
| 2050 | state->m_vdp1.fbcr_accessed = 0; |
| 2055 | 2051 | |
| 2056 | | if (vdp1_sprite_log) logerror( "PTM = %0x, TVM = %x\n", STV_VDP1_PTM, STV_VDP1_TVM ); |
| 2052 | if (VDP1_LOG) logerror( "PTM = %0x, TVM = %x\n", STV_VDP1_PTM, STV_VDP1_TVM ); |
| 2057 | 2053 | switch(STV_VDP1_PTM & 3) |
| 2058 | 2054 | { |
| 2059 | 2055 | case 0:/*Idle Mode*/ |
| r11640 | r11641 | |
| 2073 | 2069 | |
| 2074 | 2070 | static void stv_vdp1_state_save_postload(running_machine &machine) |
| 2075 | 2071 | { |
| 2076 | | UINT8 *vdp1 = stv_vdp1_gfx_decode; |
| 2072 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2073 | UINT8 *vdp1 = state->m_vdp1.gfx_decode; |
| 2077 | 2074 | int offset; |
| 2078 | 2075 | UINT32 data; |
| 2079 | 2076 | |
| 2080 | | stv_framebuffer_mode = -1; |
| 2081 | | stv_framebuffer_double_interlace = -1; |
| 2077 | state->m_vdp1.framebuffer_mode = -1; |
| 2078 | state->m_vdp1.framebuffer_double_interlace = -1; |
| 2082 | 2079 | |
| 2083 | | stv_set_framebuffer_config(); |
| 2080 | stv_set_framebuffer_config(machine); |
| 2084 | 2081 | |
| 2085 | 2082 | for (offset = 0; offset < 0x80000/4; offset++ ) |
| 2086 | 2083 | { |
| 2087 | | data = stv_vdp1_vram[offset]; |
| 2084 | data = state->m_vdp1_vram[offset]; |
| 2088 | 2085 | /* put in gfx region for easy decoding */ |
| 2089 | 2086 | vdp1[offset*4+0] = (data & 0xff000000) >> 24; |
| 2090 | 2087 | vdp1[offset*4+1] = (data & 0x00ff0000) >> 16; |
| r11640 | r11641 | |
| 2095 | 2092 | |
| 2096 | 2093 | int stv_vdp1_start ( running_machine &machine ) |
| 2097 | 2094 | { |
| 2098 | | stv_vdp1_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 ); |
| 2099 | | stv_vdp1_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); |
| 2100 | | stv_vdp1_gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 ); |
| 2095 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2096 | state->m_vdp1_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 ); |
| 2097 | state->m_vdp1_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); |
| 2098 | state->m_vdp1.gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 ); |
| 2101 | 2099 | |
| 2102 | 2100 | stv_vdp1_shading_data = auto_alloc(machine, struct stv_vdp1_poly_scanline_data); |
| 2103 | 2101 | |
| 2104 | | stv_framebuffer[0] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); /* *2 is for double interlace */ |
| 2105 | | stv_framebuffer[1] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); |
| 2102 | state->m_vdp1.framebuffer[0] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); /* *2 is for double interlace */ |
| 2103 | state->m_vdp1.framebuffer[1] = auto_alloc_array(machine, UINT16, 1024 * 256 * 2 ); |
| 2106 | 2104 | |
| 2107 | | stv_framebuffer_display_lines = auto_alloc_array(machine, UINT16 *, 512); |
| 2108 | | stv_framebuffer_draw_lines = auto_alloc_array(machine, UINT16 *, 512); |
| 2105 | state->m_vdp1.framebuffer_display_lines = auto_alloc_array(machine, UINT16 *, 512); |
| 2106 | state->m_vdp1.framebuffer_draw_lines = auto_alloc_array(machine, UINT16 *, 512); |
| 2109 | 2107 | |
| 2110 | | stv_framebuffer_width = stv_framebuffer_height = 0; |
| 2111 | | stv_framebuffer_mode = -1; |
| 2112 | | stv_framebuffer_double_interlace = -1; |
| 2113 | | stv_vdp1_fbcr_accessed = 0; |
| 2114 | | stv_vdp1_current_display_framebuffer = 0; |
| 2115 | | stv_vdp1_current_draw_framebuffer = 1; |
| 2116 | | stv_clear_framebuffer(stv_vdp1_current_draw_framebuffer); |
| 2117 | | stv_vdp1_clear_framebuffer_on_next_frame = 0; |
| 2108 | state->m_vdp1.framebuffer_width = state->m_vdp1.framebuffer_height = 0; |
| 2109 | state->m_vdp1.framebuffer_mode = -1; |
| 2110 | state->m_vdp1.framebuffer_double_interlace = -1; |
| 2111 | state->m_vdp1.fbcr_accessed = 0; |
| 2112 | state->m_vdp1.framebuffer_current_display = 0; |
| 2113 | state->m_vdp1.framebuffer_current_draw = 1; |
| 2114 | stv_clear_framebuffer(machine, state->m_vdp1.framebuffer_current_draw); |
| 2115 | state->m_vdp1.framebuffer_clear_on_next_frame = 0; |
| 2118 | 2116 | |
| 2119 | | stv_vdp1_system_cliprect.min_x = stv_vdp1_system_cliprect.max_x = 0; |
| 2120 | | stv_vdp1_system_cliprect.min_y = stv_vdp1_system_cliprect.max_y = 0; |
| 2121 | | stv_vdp1_user_cliprect.min_x = stv_vdp1_user_cliprect.max_x = 0; |
| 2122 | | stv_vdp1_user_cliprect.min_y = stv_vdp1_user_cliprect.max_y = 0; |
| 2117 | state->m_vdp1.system_cliprect.min_x = state->m_vdp1.system_cliprect.max_x = 0; |
| 2118 | state->m_vdp1.system_cliprect.min_y = state->m_vdp1.system_cliprect.max_y = 0; |
| 2119 | state->m_vdp1.user_cliprect.min_x = state->m_vdp1.user_cliprect.max_x = 0; |
| 2120 | state->m_vdp1.user_cliprect.min_y = state->m_vdp1.user_cliprect.max_y = 0; |
| 2123 | 2121 | |
| 2124 | 2122 | // save state |
| 2125 | | state_save_register_global_pointer(machine, stv_vdp1_regs, 0x040000/4); |
| 2126 | | state_save_register_global_pointer(machine, stv_vdp1_vram, 0x100000/4); |
| 2127 | | state_save_register_global(machine, stv_vdp1_fbcr_accessed); |
| 2128 | | state_save_register_global(machine, stv_vdp1_current_display_framebuffer); |
| 2129 | | state_save_register_global(machine, stv_vdp1_current_draw_framebuffer); |
| 2130 | | state_save_register_global(machine, stv_vdp1_clear_framebuffer_on_next_frame); |
| 2131 | | state_save_register_global(machine, stvvdp1_local_x); |
| 2132 | | state_save_register_global(machine, stvvdp1_local_y); |
| 2123 | state_save_register_global_pointer(machine, state->m_vdp1_regs, 0x040000/4); |
| 2124 | state_save_register_global_pointer(machine, state->m_vdp1_vram, 0x100000/4); |
| 2125 | state_save_register_global(machine, state->m_vdp1.fbcr_accessed); |
| 2126 | state_save_register_global(machine, state->m_vdp1.framebuffer_current_display); |
| 2127 | state_save_register_global(machine, state->m_vdp1.framebuffer_current_draw); |
| 2128 | state_save_register_global(machine, state->m_vdp1.framebuffer_clear_on_next_frame); |
| 2129 | state_save_register_global(machine, state->m_vdp1.local_x); |
| 2130 | state_save_register_global(machine, state->m_vdp1.local_y); |
| 2133 | 2131 | machine.save().register_postload(save_prepost_delegate(FUNC(stv_vdp1_state_save_postload), &machine)); |
| 2134 | 2132 | return 0; |
| 2135 | 2133 | } |
src/mame/video/stvvdp2.c
| r11640 | r11641 | |
| 105 | 105 | #include "profiler.h" |
| 106 | 106 | #include "includes/stv.h" |
| 107 | 107 | |
| 108 | | UINT32* stv_vdp2_regs; |
| 109 | | UINT32* stv_vdp2_vram; |
| 110 | | |
| 111 | | static UINT8* stv_vdp2_gfx_decode; |
| 112 | | |
| 113 | | static int stv_vdp2_render_rbg0; |
| 114 | | int stv_hblank,stv_vblank; |
| 115 | | static int stv_odd; |
| 116 | | static int horz_res,vert_res; |
| 117 | | |
| 118 | | UINT32* stv_vdp2_cram; |
| 119 | | |
| 120 | | static void stv_vdp2_dynamic_res_change(running_machine &machine); |
| 121 | 108 | static UINT8 get_hblank(running_machine &machine); |
| 122 | 109 | static int get_vblank_duration(running_machine &machine); |
| 123 | 110 | static int get_hblank_duration(running_machine &machine); |
| 124 | 111 | static UINT8 get_odd_bit(running_machine &machine); |
| 125 | 112 | |
| 126 | 113 | static void refresh_palette_data(running_machine &machine); |
| 127 | | static int stv_vdp2_window_process(int x,int y); |
| 128 | | static int stv_vdp2_apply_window_on_layer(rectangle *cliprect); |
| 129 | | static void stv_vdp2_get_window0_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y); |
| 114 | static int stv_vdp2_window_process(running_machine &machine,int x,int y); |
| 115 | static int stv_vdp2_apply_window_on_layer(running_machine &machine,rectangle *cliprect); |
| 116 | static void stv_vdp2_get_window0_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y); |
| 130 | 117 | static void stv_vdp2_check_tilemap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect); |
| 131 | | static bitmap_t *stv_vdp2_roz_bitmap[2]; |
| 132 | 118 | |
| 133 | 119 | enum |
| 134 | 120 | { |
| r11640 | r11641 | |
| 195 | 181 | | LSMD1 | LSMD0 | VRESO1 | VRESO0 | -- | HRESO2 | HRESO1 | HRESO0 | |
| 196 | 182 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 197 | 183 | |
| 198 | | #define STV_VDP2_TVMD ((stv_vdp2_regs[0x000/4] >> 16)&0x0000ffff) |
| 184 | #define STV_VDP2_TVMD ((state->m_vdp2_regs[0x000/4] >> 16)&0x0000ffff) |
| 199 | 185 | |
| 200 | 186 | #define STV_VDP2_DISP ((STV_VDP2_TVMD & 0x8000) >> 15) |
| 201 | 187 | #define STV_VDP2_BDCLMD ((STV_VDP2_TVMD & 0x0100) >> 8) |
| r11640 | r11641 | |
| 224 | 210 | | -- | -- | -- | -- | VER3 | VER2 | VER1 | VER0 | |
| 225 | 211 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 226 | 212 | |
| 227 | | #define STV_VDP2_VRSIZE ((stv_vdp2_regs[0x004/4] >> 0)&0x0000ffff) |
| 213 | #define STV_VDP2_VRSIZE ((state->m_vdp2_regs[0x004/4] >> 0)&0x0000ffff) |
| 228 | 214 | |
| 229 | 215 | #define STV_VDP2_VRAMSZ ((STV_VDP2_VRSIZE & 0x8000) >> 15) |
| 230 | 216 | |
| r11640 | r11641 | |
| 235 | 221 | | HCT7 | HCT6 | HCT5 | HCT4 | HCT3 | HCT2 | HCT1 | HCT0 | |
| 236 | 222 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 237 | 223 | |
| 238 | | #define STV_VDP2_HCNT ((stv_vdp2_regs[0x008/4] >> 16)&0x000003ff) |
| 224 | #define STV_VDP2_HCNT ((state->m_vdp2_regs[0x008/4] >> 16)&0x000003ff) |
| 239 | 225 | |
| 240 | 226 | /* 18000A - r/o - VCNT - V-Counter |
| 241 | 227 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 244 | 230 | | VCT7 | VCT6 | VCT5 | VCT4 | VCT3 | VCT2 | VCT1 | VCT0 | |
| 245 | 231 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 246 | 232 | |
| 247 | | #define STV_VDP2_VCNT ((stv_vdp2_regs[0x008/4] >> 0)&0x000003ff) |
| 233 | #define STV_VDP2_VCNT ((state->m_vdp2_regs[0x008/4] >> 0)&0x000003ff) |
| 248 | 234 | |
| 249 | 235 | /* 18000C - RESERVED |
| 250 | 236 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 260 | 246 | | RDBSB11 | RDBSB10 | RDBSB01 | RDBSB00 | RDBSA11 | RDBSA10 | RDBSA01 | RDBSA00 | |
| 261 | 247 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 262 | 248 | |
| 263 | | #define STV_VDP2_RAMCTL ((stv_vdp2_regs[0x00c/4] >> 0)&0x0000ffff) |
| 249 | #define STV_VDP2_RAMCTL ((state->m_vdp2_regs[0x00c/4] >> 0)&0x0000ffff) |
| 264 | 250 | |
| 265 | 251 | #define STV_VDP2_CRKTE ((STV_VDP2_RAMCTL & 0x8000) >> 15) |
| 266 | 252 | #define STV_VDP2_CRMD ((STV_VDP2_RAMCTL & 0x3000) >> 12) |
| r11640 | r11641 | |
| 277 | 263 | | VCP2A03 | VCP2A02 | VCP2A01 | VCP2A00 | VCP3A03 | VCP3A02 | VCP3A01 | VCP3A00 | |
| 278 | 264 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 279 | 265 | |
| 280 | | #define STV_VDP2_CYCA0L ((stv_vdp2_regs[0x010/4] >> 16)&0x0000ffff) |
| 266 | #define STV_VDP2_CYCA0L ((state->m_vdp2_regs[0x010/4] >> 16)&0x0000ffff) |
| 281 | 267 | |
| 282 | 268 | /* 180012 - r/w - -CYCA0U - VRAM CYCLE PATTERN (BANK A0) |
| 283 | 269 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 286 | 272 | | VCP6A03 | VCP6A02 | VCP6A01 | VCP6A00 | VCP7A03 | VCP7A02 | VCP7A01 | VCP7A00 | |
| 287 | 273 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 288 | 274 | |
| 289 | | #define STV_VDP2_CYCA0U ((stv_vdp2_regs[0x10/4] >> 0)&0x0000ffff) |
| 275 | #define STV_VDP2_CYCA0U ((state->m_vdp2_regs[0x10/4] >> 0)&0x0000ffff) |
| 290 | 276 | |
| 291 | 277 | /* 180014 - r/w - -CYCA1L - VRAM CYCLE PATTERN (BANK A1) |
| 292 | 278 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 295 | 281 | | VCP2A13 | VCP2A12 | VCP2A11 | VCP2A10 | VCP3A13 | VCP3A12 | VCP3A11 | VCP3A10 | |
| 296 | 282 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 297 | 283 | |
| 298 | | #define STV_VDP2_CYCA1L ((stv_vdp2_regs[0x014/4] >> 16)&0x0000ffff) |
| 284 | #define STV_VDP2_CYCA1L ((state->m_vdp2_regs[0x014/4] >> 16)&0x0000ffff) |
| 299 | 285 | |
| 300 | 286 | /* 180016 - r/w - -CYCA1U - VRAM CYCLE PATTERN (BANK A1) |
| 301 | 287 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 304 | 290 | | VCP6A13 | VCP6A12 | VCP6A11 | VCP6A10 | VCP7A13 | VCP7A12 | VCP7A11 | VCP7A10 | |
| 305 | 291 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 306 | 292 | |
| 307 | | #define STV_VDP2_CYCA1U ((stv_vdp2_regs[0x14/4] >> 0)&0x0000ffff) |
| 293 | #define STV_VDP2_CYCA1U ((state->m_vdp2_regs[0x14/4] >> 0)&0x0000ffff) |
| 308 | 294 | |
| 309 | 295 | /* 180018 - r/w - -CYCB0L - VRAM CYCLE PATTERN (BANK B0) |
| 310 | 296 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 313 | 299 | | VCP2B03 | VCP2B02 | VCP2B01 | VCP2B00 | VCP3B03 | VCP3B02 | VCP3B01 | VCP3B00 | |
| 314 | 300 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 315 | 301 | |
| 316 | | #define STV_VDP2_CYCA2L ((stv_vdp2_regs[0x018/4] >> 16)&0x0000ffff) |
| 302 | #define STV_VDP2_CYCA2L ((state->m_vdp2_regs[0x018/4] >> 16)&0x0000ffff) |
| 317 | 303 | |
| 318 | 304 | /* 18001A - r/w - -CYCB0U - VRAM CYCLE PATTERN (BANK B0) |
| 319 | 305 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 322 | 308 | | VCP6B03 | VCP6B02 | VCP6B01 | VCP6B00 | VCP7B03 | VCP7B02 | VCP7B01 | VCP7B00 | |
| 323 | 309 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 324 | 310 | |
| 325 | | #define STV_VDP2_CYCA2U ((stv_vdp2_regs[0x18/4] >> 0)&0x0000ffff) |
| 311 | #define STV_VDP2_CYCA2U ((state->m_vdp2_regs[0x18/4] >> 0)&0x0000ffff) |
| 326 | 312 | |
| 327 | 313 | /* 18001C - r/w - -CYCB1L - VRAM CYCLE PATTERN (BANK B1) |
| 328 | 314 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 331 | 317 | | VCP2B13 | VCP2B12 | VCP2B11 | VCP2B10 | VCP3B13 | VCP3B12 | VCP3B11 | VCP3B10 | |
| 332 | 318 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 333 | 319 | |
| 334 | | #define STV_VDP2_CYCA3L ((stv_vdp2_regs[0x01c/4] >> 16)&0x0000ffff) |
| 320 | #define STV_VDP2_CYCA3L ((state->m_vdp2_regs[0x01c/4] >> 16)&0x0000ffff) |
| 335 | 321 | |
| 336 | 322 | /* 18001E - r/w - -CYCB1U - VRAM CYCLE PATTERN (BANK B1) |
| 337 | 323 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 340 | 326 | | VCP6B13 | VCP6B12 | VCP6B11 | VCP6B10 | VCP7B13 | VCP7B12 | VCP7B11 | VCP7B10 | |
| 341 | 327 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 342 | 328 | |
| 343 | | #define STV_VDP2_CYCA3U ((stv_vdp2_regs[0x1c/4] >> 0)&0x0000ffff) |
| 329 | #define STV_VDP2_CYCA3U ((state->m_vdp2_regs[0x1c/4] >> 0)&0x0000ffff) |
| 344 | 330 | |
| 345 | 331 | /* 180020 - r/w - BGON - SCREEN DISPLAY ENABLE |
| 346 | 332 | |
| r11640 | r11641 | |
| 352 | 338 | | -- | -- | R1ON | R0ON | N3ON | N2ON | N1ON | N0ON | |
| 353 | 339 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 354 | 340 | |
| 355 | | #define STV_VDP2_BGON ((stv_vdp2_regs[0x020/4] >> 16)&0x0000ffff) |
| 341 | #define STV_VDP2_BGON ((state->m_vdp2_regs[0x020/4] >> 16)&0x0000ffff) |
| 356 | 342 | |
| 357 | 343 | // NxOn - Layer Enable Register |
| 358 | 344 | #define STV_VDP2_xxON ((STV_VDP2_BGON & 0x001f) >> 0) /* to see if anything is enabled */ |
| r11640 | r11641 | |
| 379 | 365 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 380 | 366 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 381 | 367 | |
| 382 | | #define STV_VDP2_MZCTL ((stv_vdp2_regs[0x020/4] >> 0)&0x0000ffff) |
| 368 | #define STV_VDP2_MZCTL ((state->m_vdp2_regs[0x020/4] >> 0)&0x0000ffff) |
| 383 | 369 | |
| 384 | 370 | #define STV_VDP2_R0MZE ((STV_VDP2_MZCTL & 0x0010) >> 4) |
| 385 | 371 | #define STV_VDP2_N3MZE ((STV_VDP2_MZCTL & 0x0008) >> 3) |
| r11640 | r11641 | |
| 398 | 384 | | -- | N0CHCN2 | N0CHCN1 | N0CHCN0 | N0BMSZ1 | N0BMSZ0 | N0BMEN | N0CHSZ | |
| 399 | 385 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 400 | 386 | |
| 401 | | #define STV_VDP2_CHCTLA ((stv_vdp2_regs[0x028/4] >> 16)&0x0000ffff) |
| 387 | #define STV_VDP2_CHCTLA ((state->m_vdp2_regs[0x028/4] >> 16)&0x0000ffff) |
| 402 | 388 | |
| 403 | 389 | /* -------------------------- NBG0 Character Control Registers -------------------------- */ |
| 404 | 390 | |
| r11640 | r11641 | |
| 464 | 450 | | -- | -- | N3CHCN | N3CHSZ | -- | -- | N2CHCN | N2CHSZ | |
| 465 | 451 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 466 | 452 | |
| 467 | | #define STV_VDP2_CHCTLB ((stv_vdp2_regs[0x028/4] >> 0)&0x0000ffff) |
| 453 | #define STV_VDP2_CHCTLB ((state->m_vdp2_regs[0x028/4] >> 0)&0x0000ffff) |
| 468 | 454 | |
| 469 | 455 | /* -------------------------- RBG0 Character Control Registers -------------------------- */ |
| 470 | 456 | |
| r11640 | r11641 | |
| 509 | 495 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 510 | 496 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 511 | 497 | |
| 512 | | #define STV_VDP2_BMPNA ((stv_vdp2_regs[0x02c/4] >> 16)&0x0000ffff) |
| 498 | #define STV_VDP2_BMPNA ((state->m_vdp2_regs[0x02c/4] >> 16)&0x0000ffff) |
| 513 | 499 | |
| 514 | 500 | #define STV_VDP2_N1BMP ((STV_VDP2_BMPNA & 0x0700) >> 8) |
| 515 | 501 | #define STV_VDP2_N0BMP ((STV_VDP2_BMPNA & 0x0007) >> 0) |
| r11640 | r11641 | |
| 521 | 507 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 522 | 508 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 523 | 509 | |
| 524 | | #define STV_VDP2_BMPNB ((stv_vdp2_regs[0x02c/4] >> 0)&0x0000ffff) |
| 510 | #define STV_VDP2_BMPNB ((state->m_vdp2_regs[0x02c/4] >> 0)&0x0000ffff) |
| 525 | 511 | |
| 526 | 512 | #define STV_VDP2_R0BMP ((STV_VDP2_BMPNB & 0x0007) >> 0) |
| 527 | 513 | |
| r11640 | r11641 | |
| 532 | 518 | | N0SPLT6 | N0SPLT5 | N0SPLT4 | N0SPCN4 | N0SPCN3 | N0SPCN2 | N0SPCN1 | N0SPCN0 | |
| 533 | 519 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 534 | 520 | |
| 535 | | #define STV_VDP2_PNCN0 ((stv_vdp2_regs[0x030/4] >> 16)&0x0000ffff) |
| 521 | #define STV_VDP2_PNCN0 ((state->m_vdp2_regs[0x030/4] >> 16)&0x0000ffff) |
| 536 | 522 | |
| 537 | 523 | /* Pattern Data Size |
| 538 | 524 | 0 = 2 bytes |
| r11640 | r11641 | |
| 563 | 549 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 564 | 550 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 565 | 551 | |
| 566 | | #define STV_VDP2_PNCN1 ((stv_vdp2_regs[0x030/4] >> 0)&0x0000ffff) |
| 552 | #define STV_VDP2_PNCN1 ((state->m_vdp2_regs[0x030/4] >> 0)&0x0000ffff) |
| 567 | 553 | |
| 568 | 554 | /* Pattern Data Size |
| 569 | 555 | 0 = 2 bytes |
| r11640 | r11641 | |
| 595 | 581 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 596 | 582 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 597 | 583 | |
| 598 | | #define STV_VDP2_PNCN2 ((stv_vdp2_regs[0x034/4] >> 16)&0x0000ffff) |
| 584 | #define STV_VDP2_PNCN2 ((state->m_vdp2_regs[0x034/4] >> 16)&0x0000ffff) |
| 599 | 585 | |
| 600 | 586 | /* Pattern Data Size |
| 601 | 587 | 0 = 2 bytes |
| r11640 | r11641 | |
| 627 | 613 | | N3SPLT6 | N3SPLT5 | N3SPLT4 | N3SPCN4 | N3SPCN3 | N3SPCN2 | N3SPCN1 | N3SPCN0 | |
| 628 | 614 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 629 | 615 | |
| 630 | | #define STV_VDP2_PNCN3 ((stv_vdp2_regs[0x034/4] >> 0)&0x0000ffff) |
| 616 | #define STV_VDP2_PNCN3 ((state->m_vdp2_regs[0x034/4] >> 0)&0x0000ffff) |
| 631 | 617 | |
| 632 | 618 | /* Pattern Data Size |
| 633 | 619 | 0 = 2 bytes |
| r11640 | r11641 | |
| 659 | 645 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 660 | 646 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 661 | 647 | |
| 662 | | #define STV_VDP2_PNCR ((stv_vdp2_regs[0x038/4] >> 16)&0x0000ffff) |
| 648 | #define STV_VDP2_PNCR ((state->m_vdp2_regs[0x038/4] >> 16)&0x0000ffff) |
| 663 | 649 | |
| 664 | 650 | /* Pattern Data Size |
| 665 | 651 | 0 = 2 bytes |
| r11640 | r11641 | |
| 690 | 676 | | N3PLSZ1 | N3PLSZ0 | -- | -- | N1PLSZ1 | N1PLSZ0 | N0PLSZ1 | N0PLSZ0 | |
| 691 | 677 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 692 | 678 | |
| 693 | | #define STV_VDP2_PLSZ ((stv_vdp2_regs[0x038/4] >> 0)&0x0000ffff) |
| 679 | #define STV_VDP2_PLSZ ((state->m_vdp2_regs[0x038/4] >> 0)&0x0000ffff) |
| 694 | 680 | |
| 695 | 681 | /* NBG0 Plane Size |
| 696 | 682 | 00 1H Page x 1V Page |
| r11640 | r11641 | |
| 713 | 699 | | -- | N1MP8 | N1MP7 | N1MP6 | -- | N0MP8 | N0MP7 | N0MP6 | |
| 714 | 700 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 715 | 701 | |
| 716 | | #define STV_VDP2_MPOFN_ ((stv_vdp2_regs[0x03c/4] >> 16)&0x0000ffff) |
| 702 | #define STV_VDP2_MPOFN_ ((state->m_vdp2_regs[0x03c/4] >> 16)&0x0000ffff) |
| 717 | 703 | |
| 718 | 704 | /* Higher 3 bits of the map offset for each layer */ |
| 719 | 705 | #define STV_VDP2_N0MP_ ((STV_VDP2_MPOFN_ & 0x0007) >> 0) |
| r11640 | r11641 | |
| 731 | 717 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 732 | 718 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 733 | 719 | |
| 734 | | #define STV_VDP2_MPOFR_ ((stv_vdp2_regs[0x03c/4] >> 0)&0x0000ffff) |
| 720 | #define STV_VDP2_MPOFR_ ((state->m_vdp2_regs[0x03c/4] >> 0)&0x0000ffff) |
| 735 | 721 | |
| 736 | 722 | #define STV_VDP2_RAMP_ ((STV_VDP2_MPOFR_ & 0x0007) >> 0) |
| 737 | 723 | #define STV_VDP2_RBMP_ ((STV_VDP2_MPOFR_ & 0x0070) >> 4) |
| r11640 | r11641 | |
| 743 | 729 | | -- | -- | N0MPA5 | N0MPA4 | N0MPA3 | N0MPA2 | N0MPA1 | N0MPA0 | |
| 744 | 730 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 745 | 731 | |
| 746 | | #define STV_VDP2_MPABN0 ((stv_vdp2_regs[0x040/4] >> 16)&0x0000ffff) |
| 732 | #define STV_VDP2_MPABN0 ((state->m_vdp2_regs[0x040/4] >> 16)&0x0000ffff) |
| 747 | 733 | |
| 748 | 734 | /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG0 */ |
| 749 | 735 | #define STV_VDP2_N0MPB ((STV_VDP2_MPABN0 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 759 | 745 | | -- | -- | N0MPC5 | N0MPC4 | N0MPC3 | N0MPC2 | N0MPC1 | N0MPC0 | |
| 760 | 746 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 761 | 747 | |
| 762 | | #define STV_VDP2_MPCDN0 ((stv_vdp2_regs[0x040/4] >> 0)&0x0000ffff) |
| 748 | #define STV_VDP2_MPCDN0 ((state->m_vdp2_regs[0x040/4] >> 0)&0x0000ffff) |
| 763 | 749 | |
| 764 | 750 | /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG0 */ |
| 765 | 751 | #define STV_VDP2_N0MPD ((STV_VDP2_MPCDN0 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 775 | 761 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 776 | 762 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 777 | 763 | |
| 778 | | #define STV_VDP2_MPABN1 ((stv_vdp2_regs[0x044/4] >> 16)&0x0000ffff) |
| 764 | #define STV_VDP2_MPABN1 ((state->m_vdp2_regs[0x044/4] >> 16)&0x0000ffff) |
| 779 | 765 | |
| 780 | 766 | /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG1 */ |
| 781 | 767 | #define STV_VDP2_N1MPB ((STV_VDP2_MPABN1 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 790 | 776 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 791 | 777 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 792 | 778 | |
| 793 | | #define STV_VDP2_MPCDN1 ((stv_vdp2_regs[0x044/4] >> 0)&0x0000ffff) |
| 779 | #define STV_VDP2_MPCDN1 ((state->m_vdp2_regs[0x044/4] >> 0)&0x0000ffff) |
| 794 | 780 | |
| 795 | 781 | /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG0 */ |
| 796 | 782 | #define STV_VDP2_N1MPD ((STV_VDP2_MPCDN1 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 806 | 792 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 807 | 793 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 808 | 794 | |
| 809 | | #define STV_VDP2_MPABN2 ((stv_vdp2_regs[0x048/4] >> 16)&0x0000ffff) |
| 795 | #define STV_VDP2_MPABN2 ((state->m_vdp2_regs[0x048/4] >> 16)&0x0000ffff) |
| 810 | 796 | |
| 811 | 797 | /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG2 */ |
| 812 | 798 | #define STV_VDP2_N2MPB ((STV_VDP2_MPABN2 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 821 | 807 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 822 | 808 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 823 | 809 | |
| 824 | | #define STV_VDP2_MPCDN2 ((stv_vdp2_regs[0x048/4] >> 0)&0x0000ffff) |
| 810 | #define STV_VDP2_MPCDN2 ((state->m_vdp2_regs[0x048/4] >> 0)&0x0000ffff) |
| 825 | 811 | |
| 826 | 812 | /* N0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap NBG2 */ |
| 827 | 813 | #define STV_VDP2_N2MPD ((STV_VDP2_MPCDN2 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 836 | 822 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 837 | 823 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 838 | 824 | |
| 839 | | #define STV_VDP2_MPABN3 ((stv_vdp2_regs[0x04c/4] >> 16)&0x0000ffff) |
| 825 | #define STV_VDP2_MPABN3 ((state->m_vdp2_regs[0x04c/4] >> 16)&0x0000ffff) |
| 840 | 826 | |
| 841 | 827 | /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG1 */ |
| 842 | 828 | #define STV_VDP2_N3MPB ((STV_VDP2_MPABN3 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 852 | 838 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 853 | 839 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 854 | 840 | |
| 855 | | #define STV_VDP2_MPCDN3 ((stv_vdp2_regs[0x04c/4] >> 0)&0x0000ffff) |
| 841 | #define STV_VDP2_MPCDN3 ((state->m_vdp2_regs[0x04c/4] >> 0)&0x0000ffff) |
| 856 | 842 | |
| 857 | 843 | /* N0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap NBG0 */ |
| 858 | 844 | #define STV_VDP2_N3MPD ((STV_VDP2_MPCDN3 & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 867 | 853 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 868 | 854 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 869 | 855 | |
| 870 | | #define STV_VDP2_MPABRA ((stv_vdp2_regs[0x050/4] >> 16)&0x0000ffff) |
| 856 | #define STV_VDP2_MPABRA ((state->m_vdp2_regs[0x050/4] >> 16)&0x0000ffff) |
| 871 | 857 | |
| 872 | 858 | /* R0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap RBG0 */ |
| 873 | 859 | #define STV_VDP2_RAMPB ((STV_VDP2_MPABRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 883 | 869 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 884 | 870 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 885 | 871 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 886 | | #define STV_VDP2_MPCDRA ((stv_vdp2_regs[0x050/4] >> 0)&0x0000ffff) |
| 872 | #define STV_VDP2_MPCDRA ((state->m_vdp2_regs[0x050/4] >> 0)&0x0000ffff) |
| 887 | 873 | |
| 888 | 874 | /* R0MPB5 = lower 6 bits of Map Address of Plane D of Tilemap RBG0 */ |
| 889 | 875 | #define STV_VDP2_RAMPD ((STV_VDP2_MPCDRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 897 | 883 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 898 | 884 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 899 | 885 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 900 | | #define STV_VDP2_MPEFRA ((stv_vdp2_regs[0x054/4] >> 16)&0x0000ffff) |
| 886 | #define STV_VDP2_MPEFRA ((state->m_vdp2_regs[0x054/4] >> 16)&0x0000ffff) |
| 901 | 887 | |
| 902 | 888 | /* R0MPB5 = lower 6 bits of Map Address of Plane F of Tilemap RBG0 */ |
| 903 | 889 | #define STV_VDP2_RAMPF ((STV_VDP2_MPEFRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 911 | 897 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 912 | 898 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 913 | 899 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 914 | | #define STV_VDP2_MPGHRA ((stv_vdp2_regs[0x054/4] >> 0)&0x0000ffff) |
| 900 | #define STV_VDP2_MPGHRA ((state->m_vdp2_regs[0x054/4] >> 0)&0x0000ffff) |
| 915 | 901 | |
| 916 | 902 | /* R0MPB5 = lower 6 bits of Map Address of Plane H of Tilemap RBG0 */ |
| 917 | 903 | #define STV_VDP2_RAMPH ((STV_VDP2_MPGHRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 925 | 911 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 926 | 912 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 927 | 913 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 928 | | #define STV_VDP2_MPIJRA ((stv_vdp2_regs[0x058/4] >> 16)&0x0000ffff) |
| 914 | #define STV_VDP2_MPIJRA ((state->m_vdp2_regs[0x058/4] >> 16)&0x0000ffff) |
| 929 | 915 | |
| 930 | 916 | /* R0MPB5 = lower 6 bits of Map Address of Plane J of Tilemap RBG0 */ |
| 931 | 917 | #define STV_VDP2_RAMPJ ((STV_VDP2_MPIJRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 939 | 925 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 940 | 926 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 941 | 927 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 942 | | #define STV_VDP2_MPKLRA ((stv_vdp2_regs[0x058/4] >> 0)&0x0000ffff) |
| 928 | #define STV_VDP2_MPKLRA ((state->m_vdp2_regs[0x058/4] >> 0)&0x0000ffff) |
| 943 | 929 | |
| 944 | 930 | /* R0MPB5 = lower 6 bits of Map Address of Plane L of Tilemap RBG0 */ |
| 945 | 931 | #define STV_VDP2_RAMPL ((STV_VDP2_MPKLRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 953 | 939 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 954 | 940 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 955 | 941 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 956 | | #define STV_VDP2_MPMNRA ((stv_vdp2_regs[0x05c/4] >> 16)&0x0000ffff) |
| 942 | #define STV_VDP2_MPMNRA ((state->m_vdp2_regs[0x05c/4] >> 16)&0x0000ffff) |
| 957 | 943 | |
| 958 | 944 | /* R0MPB5 = lower 6 bits of Map Address of Plane N of Tilemap RBG0 */ |
| 959 | 945 | #define STV_VDP2_RAMPN ((STV_VDP2_MPMNRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 967 | 953 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 968 | 954 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 969 | 955 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 970 | | #define STV_VDP2_MPOPRA ((stv_vdp2_regs[0x05c/4] >> 0)&0x0000ffff) |
| 956 | #define STV_VDP2_MPOPRA ((state->m_vdp2_regs[0x05c/4] >> 0)&0x0000ffff) |
| 971 | 957 | |
| 972 | 958 | /* R0MPB5 = lower 6 bits of Map Address of Plane P of Tilemap RBG0 */ |
| 973 | 959 | #define STV_VDP2_RAMPP ((STV_VDP2_MPOPRA & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 982 | 968 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 983 | 969 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 984 | 970 | |
| 985 | | #define STV_VDP2_MPABRB ((stv_vdp2_regs[0x060/4] >> 16)&0x0000ffff) |
| 971 | #define STV_VDP2_MPABRB ((state->m_vdp2_regs[0x060/4] >> 16)&0x0000ffff) |
| 986 | 972 | |
| 987 | 973 | /* R0MPB5 = lower 6 bits of Map Address of Plane B of Tilemap RBG0 */ |
| 988 | 974 | #define STV_VDP2_RBMPB ((STV_VDP2_MPABRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 998 | 984 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 999 | 985 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1000 | 986 | |
| 1001 | | #define STV_VDP2_MPCDRB ((stv_vdp2_regs[0x060/4] >> 0)&0x0000ffff) |
| 987 | #define STV_VDP2_MPCDRB ((state->m_vdp2_regs[0x060/4] >> 0)&0x0000ffff) |
| 1002 | 988 | |
| 1003 | 989 | /* R0MPD5 = lower 6 bits of Map Address of Plane D of Tilemap RBG0 */ |
| 1004 | 990 | #define STV_VDP2_RBMPD ((STV_VDP2_MPCDRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1013 | 999 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1014 | 1000 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1015 | 1001 | |
| 1016 | | #define STV_VDP2_MPEFRB ((stv_vdp2_regs[0x064/4] >> 16)&0x0000ffff) |
| 1002 | #define STV_VDP2_MPEFRB ((state->m_vdp2_regs[0x064/4] >> 16)&0x0000ffff) |
| 1017 | 1003 | |
| 1018 | 1004 | /* R0MPF5 = lower 6 bits of Map Address of Plane F of Tilemap RBG0 */ |
| 1019 | 1005 | #define STV_VDP2_RBMPF ((STV_VDP2_MPEFRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1028 | 1014 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1029 | 1015 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1030 | 1016 | |
| 1031 | | #define STV_VDP2_MPGHRB ((stv_vdp2_regs[0x064/4] >> 0)&0x0000ffff) |
| 1017 | #define STV_VDP2_MPGHRB ((state->m_vdp2_regs[0x064/4] >> 0)&0x0000ffff) |
| 1032 | 1018 | |
| 1033 | 1019 | /* R0MPH5 = lower 6 bits of Map Address of Plane H of Tilemap RBG0 */ |
| 1034 | 1020 | #define STV_VDP2_RBMPH ((STV_VDP2_MPGHRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1043 | 1029 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1044 | 1030 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1045 | 1031 | |
| 1046 | | #define STV_VDP2_MPIJRB ((stv_vdp2_regs[0x068/4] >> 16)&0x0000ffff) |
| 1032 | #define STV_VDP2_MPIJRB ((state->m_vdp2_regs[0x068/4] >> 16)&0x0000ffff) |
| 1047 | 1033 | |
| 1048 | 1034 | /* R0MPJ5 = lower 6 bits of Map Address of Plane J of Tilemap RBG0 */ |
| 1049 | 1035 | #define STV_VDP2_RBMPJ ((STV_VDP2_MPIJRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1058 | 1044 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1059 | 1045 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1060 | 1046 | |
| 1061 | | #define STV_VDP2_MPKLRB ((stv_vdp2_regs[0x068/4] >> 0)&0x0000ffff) |
| 1047 | #define STV_VDP2_MPKLRB ((state->m_vdp2_regs[0x068/4] >> 0)&0x0000ffff) |
| 1062 | 1048 | |
| 1063 | 1049 | /* R0MPL5 = lower 6 bits of Map Address of Plane L of Tilemap RBG0 */ |
| 1064 | 1050 | #define STV_VDP2_RBMPL ((STV_VDP2_MPKLRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1073 | 1059 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1074 | 1060 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1075 | 1061 | |
| 1076 | | #define STV_VDP2_MPMNRB ((stv_vdp2_regs[0x06c/4] >> 16)&0x0000ffff) |
| 1062 | #define STV_VDP2_MPMNRB ((state->m_vdp2_regs[0x06c/4] >> 16)&0x0000ffff) |
| 1077 | 1063 | |
| 1078 | 1064 | /* R0MPN5 = lower 6 bits of Map Address of Plane N of Tilemap RBG0 */ |
| 1079 | 1065 | #define STV_VDP2_RBMPN ((STV_VDP2_MPMNRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1088 | 1074 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1089 | 1075 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1090 | 1076 | |
| 1091 | | #define STV_VDP2_MPOPRB ((stv_vdp2_regs[0x06c/4] >> 0)&0x0000ffff) |
| 1077 | #define STV_VDP2_MPOPRB ((state->m_vdp2_regs[0x06c/4] >> 0)&0x0000ffff) |
| 1092 | 1078 | |
| 1093 | 1079 | /* R0MPP5 = lower 6 bits of Map Address of Plane P of Tilemap RBG0 */ |
| 1094 | 1080 | #define STV_VDP2_RBMPP ((STV_VDP2_MPOPRB & 0x3f00) >> 8) |
| r11640 | r11641 | |
| 1103 | 1089 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1104 | 1090 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1105 | 1091 | |
| 1106 | | #define STV_VDP2_SCXIN0 ((stv_vdp2_regs[0x070/4] >> 16)&0x0000ffff) |
| 1092 | #define STV_VDP2_SCXIN0 ((state->m_vdp2_regs[0x070/4] >> 16)&0x0000ffff) |
| 1107 | 1093 | |
| 1108 | 1094 | |
| 1109 | 1095 | /* 180072 - Screen Scroll (NBG0, Horizontal Fractional Part) |
| r11640 | r11641 | |
| 1119 | 1105 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 1120 | 1106 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1121 | 1107 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1122 | | #define STV_VDP2_SCYIN0 ((stv_vdp2_regs[0x074/4] >> 16)&0x0000ffff) |
| 1108 | #define STV_VDP2_SCYIN0 ((state->m_vdp2_regs[0x074/4] >> 16)&0x0000ffff) |
| 1123 | 1109 | |
| 1124 | 1110 | |
| 1125 | 1111 | /* 180076 - Screen Scroll (NBG0, Vertical Fractional Part) |
| r11640 | r11641 | |
| 1136 | 1122 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1137 | 1123 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1138 | 1124 | |
| 1139 | | #define STV_VDP2_ZMXIN0 ((stv_vdp2_regs[0x078/4] >> 16)&0x0000ffff) |
| 1140 | | #define STV_VDP2_ZMXN0 (stv_vdp2_regs[0x078/4] & 0x007ff00) |
| 1125 | #define STV_VDP2_ZMXIN0 ((state->m_vdp2_regs[0x078/4] >> 16)&0x0000ffff) |
| 1126 | #define STV_VDP2_ZMXN0 (state->m_vdp2_regs[0x078/4] & 0x007ff00) |
| 1141 | 1127 | |
| 1142 | 1128 | #define STV_VDP2_N0ZMXI ((STV_VDP2_ZMXIN0 & 0x0007) >> 0) |
| 1143 | 1129 | |
| r11640 | r11641 | |
| 1148 | 1134 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1149 | 1135 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1150 | 1136 | |
| 1151 | | #define STV_VDP2_ZMXDN0 ((stv_vdp2_regs[0x078/4] >> 0)&0x0000ffff) |
| 1137 | #define STV_VDP2_ZMXDN0 ((state->m_vdp2_regs[0x078/4] >> 0)&0x0000ffff) |
| 1152 | 1138 | |
| 1153 | 1139 | #define STV_VDP2_N0ZMXD ((STV_VDP2_ZMXDN0 >> 8)& 0xff) |
| 1154 | 1140 | |
| r11640 | r11641 | |
| 1159 | 1145 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1160 | 1146 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1161 | 1147 | |
| 1162 | | #define STV_VDP2_ZMYIN0 ((stv_vdp2_regs[0x07c/4] >> 16)&0x0000ffff) |
| 1163 | | #define STV_VDP2_ZMYN0 (stv_vdp2_regs[0x07c/4] & 0x007ff00) |
| 1148 | #define STV_VDP2_ZMYIN0 ((state->m_vdp2_regs[0x07c/4] >> 16)&0x0000ffff) |
| 1149 | #define STV_VDP2_ZMYN0 (state->m_vdp2_regs[0x07c/4] & 0x007ff00) |
| 1164 | 1150 | |
| 1165 | 1151 | #define STV_VDP2_N0ZMYI ((STV_VDP2_ZMYIN0 & 0x0007) >> 0) |
| 1166 | 1152 | |
| r11640 | r11641 | |
| 1171 | 1157 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1172 | 1158 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1173 | 1159 | |
| 1174 | | #define STV_VDP2_ZMYDN0 ((stv_vdp2_regs[0x07c/4] >> 0)&0x0000ffff) |
| 1160 | #define STV_VDP2_ZMYDN0 ((state->m_vdp2_regs[0x07c/4] >> 0)&0x0000ffff) |
| 1175 | 1161 | |
| 1176 | 1162 | #define STV_VDP2_N0ZMYD ((STV_VDP2_ZMYDN0 >> 8)& 0xff) |
| 1177 | 1163 | |
| r11640 | r11641 | |
| 1182 | 1168 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1183 | 1169 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1184 | 1170 | |
| 1185 | | #define STV_VDP2_SCXIN1 ((stv_vdp2_regs[0x080/4] >> 16)&0x0000ffff) |
| 1171 | #define STV_VDP2_SCXIN1 ((state->m_vdp2_regs[0x080/4] >> 16)&0x0000ffff) |
| 1186 | 1172 | |
| 1187 | 1173 | /* 180082 - Screen Scroll (NBG1, Horizontal Fractional Part) |
| 1188 | 1174 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1198 | 1184 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1199 | 1185 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1200 | 1186 | |
| 1201 | | #define STV_VDP2_SCYIN1 ((stv_vdp2_regs[0x084/4] >> 16)&0x0000ffff) |
| 1187 | #define STV_VDP2_SCYIN1 ((state->m_vdp2_regs[0x084/4] >> 16)&0x0000ffff) |
| 1202 | 1188 | |
| 1203 | 1189 | /* 180086 - Screen Scroll (NBG1, Vertical Fractional Part) |
| 1204 | 1190 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1214 | 1200 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1215 | 1201 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1216 | 1202 | |
| 1217 | | #define STV_VDP2_ZMXIN1 ((stv_vdp2_regs[0x088/4] >> 16)&0x0000ffff) |
| 1218 | | #define STV_VDP2_ZMXN1 (stv_vdp2_regs[0x088/4] & 0x007ff00) |
| 1203 | #define STV_VDP2_ZMXIN1 ((state->m_vdp2_regs[0x088/4] >> 16)&0x0000ffff) |
| 1204 | #define STV_VDP2_ZMXN1 (state->m_vdp2_regs[0x088/4] & 0x007ff00) |
| 1219 | 1205 | |
| 1220 | 1206 | #define STV_VDP2_N1ZMXI ((STV_VDP2_ZMXIN1 & 0x0007) >> 0) |
| 1221 | 1207 | |
| r11640 | r11641 | |
| 1226 | 1212 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1227 | 1213 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1228 | 1214 | |
| 1229 | | #define STV_VDP2_ZMXDN1 ((stv_vdp2_regs[0x088/4] >> 0)&0x0000ffff) |
| 1215 | #define STV_VDP2_ZMXDN1 ((state->m_vdp2_regs[0x088/4] >> 0)&0x0000ffff) |
| 1230 | 1216 | |
| 1231 | 1217 | #define STV_VDP2_N1ZMXD ((STV_VDP2_ZMXDN1 >> 8)& 0xff) |
| 1232 | 1218 | |
| r11640 | r11641 | |
| 1237 | 1223 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1238 | 1224 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1239 | 1225 | |
| 1240 | | #define STV_VDP2_ZMYIN1 ((stv_vdp2_regs[0x08c/4] >> 16)&0x0000ffff) |
| 1241 | | #define STV_VDP2_ZMYN1 (stv_vdp2_regs[0x08c/4] & 0x007ff00) |
| 1226 | #define STV_VDP2_ZMYIN1 ((state->m_vdp2_regs[0x08c/4] >> 16)&0x0000ffff) |
| 1227 | #define STV_VDP2_ZMYN1 (state->m_vdp2_regs[0x08c/4] & 0x007ff00) |
| 1242 | 1228 | |
| 1243 | 1229 | #define STV_VDP2_N1ZMYI ((STV_VDP2_ZMYIN1 & 0x0007) >> 0) |
| 1244 | 1230 | |
| r11640 | r11641 | |
| 1249 | 1235 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1250 | 1236 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1251 | 1237 | |
| 1252 | | #define STV_VDP2_ZMYDN1 ((stv_vdp2_regs[0x08c/4] >> 0)&0x0000ffff) |
| 1238 | #define STV_VDP2_ZMYDN1 ((state->m_vdp2_regs[0x08c/4] >> 0)&0x0000ffff) |
| 1253 | 1239 | |
| 1254 | 1240 | #define STV_VDP2_N1ZMYD ((STV_VDP2_ZMYDN1 >> 8)& 0xff) |
| 1255 | 1241 | |
| r11640 | r11641 | |
| 1260 | 1246 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1261 | 1247 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1262 | 1248 | |
| 1263 | | #define STV_VDP2_SCXN2 ((stv_vdp2_regs[0x090/4] >> 16)&0x0000ffff) |
| 1249 | #define STV_VDP2_SCXN2 ((state->m_vdp2_regs[0x090/4] >> 16)&0x0000ffff) |
| 1264 | 1250 | |
| 1265 | 1251 | /* 180092 - SCYN2 - Screen Scroll (NBG2, Vertical) |
| 1266 | 1252 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1269 | 1255 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1270 | 1256 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1271 | 1257 | |
| 1272 | | #define STV_VDP2_SCYN2 ((stv_vdp2_regs[0x090/4] >> 0)&0x0000ffff) |
| 1258 | #define STV_VDP2_SCYN2 ((state->m_vdp2_regs[0x090/4] >> 0)&0x0000ffff) |
| 1273 | 1259 | |
| 1274 | 1260 | /* 180094 - SCXN3 - Screen Scroll (NBG3, Horizontal) |
| 1275 | 1261 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1278 | 1264 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1279 | 1265 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1280 | 1266 | |
| 1281 | | #define STV_VDP2_SCXN3 ((stv_vdp2_regs[0x094/4] >> 16)&0x0000ffff) |
| 1267 | #define STV_VDP2_SCXN3 ((state->m_vdp2_regs[0x094/4] >> 16)&0x0000ffff) |
| 1282 | 1268 | |
| 1283 | 1269 | /* 180096 - SCYN3 - Screen Scroll (NBG3, Vertical) |
| 1284 | 1270 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1287 | 1273 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1288 | 1274 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1289 | 1275 | |
| 1290 | | #define STV_VDP2_SCYN3 ((stv_vdp2_regs[0x094/4] >> 0)&0x0000ffff) |
| 1276 | #define STV_VDP2_SCYN3 ((state->m_vdp2_regs[0x094/4] >> 0)&0x0000ffff) |
| 1291 | 1277 | |
| 1292 | 1278 | /* 180098 - Reduction Enable |
| 1293 | 1279 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1296 | 1282 | | -- | -- | -- | -- | -- | -- | N0ZMQT | N0ZMHF | |
| 1297 | 1283 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1298 | 1284 | |
| 1299 | | #define STV_VDP2_ZMCTL ((stv_vdp2_regs[0x098/4] >> 16)&0x0000ffff) |
| 1285 | #define STV_VDP2_ZMCTL ((state->m_vdp2_regs[0x098/4] >> 16)&0x0000ffff) |
| 1300 | 1286 | |
| 1301 | 1287 | #define STV_VDP2_N1ZMQT ((STV_VDP2_ZMCTL & 0x0200) >> 9) |
| 1302 | 1288 | #define STV_VDP2_N1ZMHF ((STV_VDP2_ZMCTL & 0x0100) >> 8) |
| r11640 | r11641 | |
| 1310 | 1296 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1311 | 1297 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1312 | 1298 | |
| 1313 | | #define STV_VDP2_SCRCTL ((stv_vdp2_regs[0x098/4] >> 0)&0x0000ffff) |
| 1299 | #define STV_VDP2_SCRCTL ((state->m_vdp2_regs[0x098/4] >> 0)&0x0000ffff) |
| 1314 | 1300 | |
| 1315 | 1301 | #define STV_VDP2_N1LSS ((STV_VDP2_SCRCTL & 0x3000) >> 12) |
| 1316 | 1302 | #define STV_VDP2_N1LZMX ((STV_VDP2_SCRCTL & 0x0800) >> 11) |
| r11640 | r11641 | |
| 1345 | 1331 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1346 | 1332 | |
| 1347 | 1333 | /*bit 2 unused when VRAM = 4 Mbits*/ |
| 1348 | | #define STV_VDP2_LSTA0U ((stv_vdp2_regs[0x0a0/4] >> 16)&0x00000003) |
| 1334 | #define STV_VDP2_LSTA0U ((state->m_vdp2_regs[0x0a0/4] >> 16)&0x00000003) |
| 1349 | 1335 | |
| 1350 | 1336 | /* 1800a2 - LSTA0L - Line Scroll Table Address (NBG0) |
| 1351 | 1337 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1354 | 1340 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1355 | 1341 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1356 | 1342 | |
| 1357 | | #define STV_VDP2_LSTA0L ((stv_vdp2_regs[0x0a0/4] >> 0)&0x0000fffe) |
| 1343 | #define STV_VDP2_LSTA0L ((state->m_vdp2_regs[0x0a0/4] >> 0)&0x0000fffe) |
| 1358 | 1344 | |
| 1359 | 1345 | /* 1800a4 - LSTA1U - Line Scroll Table Address (NBG1) |
| 1360 | 1346 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1364 | 1350 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1365 | 1351 | |
| 1366 | 1352 | /*bit 2 unused when VRAM = 4 Mbits*/ |
| 1367 | | #define STV_VDP2_LSTA1U ((stv_vdp2_regs[0x0a4/4] >> 16)&0x00000003) |
| 1353 | #define STV_VDP2_LSTA1U ((state->m_vdp2_regs[0x0a4/4] >> 16)&0x00000003) |
| 1368 | 1354 | |
| 1369 | 1355 | /* 1800a6 - LSTA1L - Line Scroll Table Address (NBG1) |
| 1370 | 1356 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1373 | 1359 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1374 | 1360 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1375 | 1361 | |
| 1376 | | #define STV_VDP2_LSTA1L ((stv_vdp2_regs[0x0a4/4] >> 0)&0x0000fffe) |
| 1362 | #define STV_VDP2_LSTA1L ((state->m_vdp2_regs[0x0a4/4] >> 0)&0x0000fffe) |
| 1377 | 1363 | |
| 1378 | 1364 | /* 1800a8 - LCTAU - Line Colour Screen Table Address |
| 1379 | 1365 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1382 | 1368 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1383 | 1369 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1384 | 1370 | |
| 1385 | | #define STV_VDP2_LCTAU ((stv_vdp2_regs[0x0a8/4] >> 16) & 0xffff) |
| 1371 | #define STV_VDP2_LCTAU ((state->m_vdp2_regs[0x0a8/4] >> 16) & 0xffff) |
| 1386 | 1372 | #define STV_VDP2_LCCLMD ((STV_VDP2_LCTAU & 0x8000) >> 15) |
| 1387 | 1373 | |
| 1388 | 1374 | /* 1800aa - LCTAL - Line Colour Screen Table Address |
| r11640 | r11641 | |
| 1391 | 1377 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 1392 | 1378 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1393 | 1379 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1394 | | #define STV_VDP2_LCTAL ((stv_vdp2_regs[0x0a8/4] >> 0) & 0xffff) |
| 1380 | #define STV_VDP2_LCTAL ((state->m_vdp2_regs[0x0a8/4] >> 0) & 0xffff) |
| 1395 | 1381 | |
| 1396 | | #define STV_VDP2_LCTA (stv_vdp2_regs[0x0a8/4] & 0x0003ffff) |
| 1382 | #define STV_VDP2_LCTA (state->m_vdp2_regs[0x0a8/4] & 0x0003ffff) |
| 1397 | 1383 | |
| 1398 | 1384 | /* 1800ac - Back Screen Table Address |
| 1399 | 1385 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1409 | 1395 | | BKTA7 | BKTA7 | BKTA6 | BKTA5 | BKTA4 | BKTA3 | BKTA2 | BKTA0 | |
| 1410 | 1396 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1411 | 1397 | |
| 1412 | | #define STV_VDP2_BKTA_UL (stv_vdp2_regs[0x0ac/4]) |
| 1398 | #define STV_VDP2_BKTA_UL (state->m_vdp2_regs[0x0ac/4]) |
| 1413 | 1399 | |
| 1414 | 1400 | #define STV_VDP2_BKCLMD ((STV_VDP2_BKTA_UL & 0x80000000) >> 31) |
| 1415 | 1401 | #define STV_VDP2_BKTA ((STV_VDP2_BKTA_UL & 0x0003ffff) >> 0) |
| r11640 | r11641 | |
| 1423 | 1409 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1424 | 1410 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1425 | 1411 | |
| 1426 | | #define STV_VDP2_RPMD ((stv_vdp2_regs[0x0b0/4] >> 16) & 0x00000003) |
| 1412 | #define STV_VDP2_RPMD ((state->m_vdp2_regs[0x0b0/4] >> 16) & 0x00000003) |
| 1427 | 1413 | |
| 1428 | 1414 | /* 1800b2 - RPRCTL - Rotation Parameter Read Control |
| 1429 | 1415 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1432 | 1418 | | -- | -- | -- | -- | -- | RAKASTRE | RAYSTRE | RBXSTRE | |
| 1433 | 1419 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1434 | 1420 | |
| 1435 | | #define STV_VDP2_RPRCTL ((stv_vdp2_regs[0x0b0/4] >> 0)&0x0000ffff) |
| 1421 | #define STV_VDP2_RPRCTL ((state->m_vdp2_regs[0x0b0/4] >> 0)&0x0000ffff) |
| 1436 | 1422 | #define STV_VDP2_RBKASTRE ((STV_VDP2_RPRCTL & 0x0400) >> 10) |
| 1437 | 1423 | #define STV_VDP2_RBYSTRE ((STV_VDP2_RPRCTL & 0x0200) >> 9) |
| 1438 | 1424 | #define STV_VDP2_RBXSTRE ((STV_VDP2_RPRCTL & 0x0100) >> 8) |
| r11640 | r11641 | |
| 1447 | 1433 | | -- | -- | -- | RAKLCE | RAKMD1 | RAKMD0 | RAKDBS | RAKTE | |
| 1448 | 1434 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1449 | 1435 | |
| 1450 | | #define STV_VDP2_KTCTL ((stv_vdp2_regs[0x0b4/4] >> 16) & 0x0000ffff) |
| 1436 | #define STV_VDP2_KTCTL ((state->m_vdp2_regs[0x0b4/4] >> 16) & 0x0000ffff) |
| 1451 | 1437 | #define STV_VDP2_RBKLCE ((STV_VDP2_KTCTL & 0x1000) >> 12) |
| 1452 | 1438 | #define STV_VDP2_RBKMD ((STV_VDP2_KTCTL & 0x0c00) >> 10) |
| 1453 | 1439 | #define STV_VDP2_RBKDBS ((STV_VDP2_KTCTL & 0x0200) >> 9) |
| r11640 | r11641 | |
| 1464 | 1450 | | -- | -- | -- | -- | -- | RAKTAOS2 | RAKTAOS1 | RAKTAOS0 | |
| 1465 | 1451 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1466 | 1452 | |
| 1467 | | #define STV_VDP2_KTAOF ((stv_vdp2_regs[0x0b4/4] >> 0) & 0x0000ffff) |
| 1453 | #define STV_VDP2_KTAOF ((state->m_vdp2_regs[0x0b4/4] >> 0) & 0x0000ffff) |
| 1468 | 1454 | #define STV_VDP2_RBKTAOS ((STV_VDP2_KTAOF & 0x0700) >> 8) |
| 1469 | 1455 | #define STV_VDP2_RAKTAOS ((STV_VDP2_KTAOF & 0x0007) >> 0) |
| 1470 | 1456 | |
| r11640 | r11641 | |
| 1475 | 1461 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1476 | 1462 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1477 | 1463 | |
| 1478 | | #define STV_VDP2_OVPNRA ((stv_vdp2_regs[0x0b8/4] >> 16) & 0x0000ffff) |
| 1464 | #define STV_VDP2_OVPNRA ((state->m_vdp2_regs[0x0b8/4] >> 16) & 0x0000ffff) |
| 1479 | 1465 | |
| 1480 | 1466 | /* 1800ba - Screen Over Pattern Name (Rotation Parameter B) |
| 1481 | 1467 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1484 | 1470 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1485 | 1471 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1486 | 1472 | |
| 1487 | | #define STV_VDP2_OVPNRB ((stv_vdp2_regs[0x0b8/4] >> 0) & 0x0000ffff) |
| 1473 | #define STV_VDP2_OVPNRB ((state->m_vdp2_regs[0x0b8/4] >> 0) & 0x0000ffff) |
| 1488 | 1474 | |
| 1489 | 1475 | /* 1800bc - RPTAU - Rotation Parameter Table Address (Rotation Parameter A,B) |
| 1490 | 1476 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1492 | 1478 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 1493 | 1479 | | -- | -- | -- | -- | -- | RPTA18 | RPTA17 | RPTA16 | |
| 1494 | 1480 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1495 | | #define STV_VDP2_RPTAU ((stv_vdp2_regs[0x0bc/4] >> 16) & 0x00000007) |
| 1481 | #define STV_VDP2_RPTAU ((state->m_vdp2_regs[0x0bc/4] >> 16) & 0x00000007) |
| 1496 | 1482 | |
| 1497 | 1483 | /* 1800be - RPTAL - Rotation Parameter Table Address (Rotation Parameter A,B) |
| 1498 | 1484 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1501 | 1487 | | RPTA7 | RPTA6 | RPTA5 | RPTA4 | RPTA3 | RPTA2 | RPTA1 | -- | |
| 1502 | 1488 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1503 | 1489 | |
| 1504 | | #define STV_VDP2_RPTAL ((stv_vdp2_regs[0x0bc/4] >> 0) & 0x0000fffe) |
| 1490 | #define STV_VDP2_RPTAL ((state->m_vdp2_regs[0x0bc/4] >> 0) & 0x0000fffe) |
| 1505 | 1491 | |
| 1506 | 1492 | /* 1800c0 - Window Position (W0, Horizontal Start Point) |
| 1507 | 1493 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1510 | 1496 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1511 | 1497 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1512 | 1498 | |
| 1513 | | #define STV_VDP2_WPSX0 ((stv_vdp2_regs[0x0c0/4] >> 16)&0x0000ffff) |
| 1499 | #define STV_VDP2_WPSX0 ((state->m_vdp2_regs[0x0c0/4] >> 16)&0x0000ffff) |
| 1514 | 1500 | |
| 1515 | 1501 | #define STV_VDP2_W0SX ((STV_VDP2_WPSX0 & 0x03ff) >> 0) |
| 1516 | 1502 | |
| r11640 | r11641 | |
| 1521 | 1507 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1522 | 1508 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1523 | 1509 | |
| 1524 | | #define STV_VDP2_WPSY0 ((stv_vdp2_regs[0x0c0/4] >> 0)&0x0000ffff) |
| 1510 | #define STV_VDP2_WPSY0 ((state->m_vdp2_regs[0x0c0/4] >> 0)&0x0000ffff) |
| 1525 | 1511 | |
| 1526 | 1512 | #define STV_VDP2_W0SY ((STV_VDP2_WPSY0 & 0x03ff) >> 0) |
| 1527 | 1513 | |
| r11640 | r11641 | |
| 1532 | 1518 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1533 | 1519 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1534 | 1520 | |
| 1535 | | #define STV_VDP2_WPEX0 ((stv_vdp2_regs[0x0c4/4] >> 16)&0x0000ffff) |
| 1521 | #define STV_VDP2_WPEX0 ((state->m_vdp2_regs[0x0c4/4] >> 16)&0x0000ffff) |
| 1536 | 1522 | |
| 1537 | 1523 | #define STV_VDP2_W0EX ((STV_VDP2_WPEX0 & 0x03ff) >> 0) |
| 1538 | 1524 | |
| r11640 | r11641 | |
| 1543 | 1529 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1544 | 1530 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1545 | 1531 | |
| 1546 | | #define STV_VDP2_WPEY0 ((stv_vdp2_regs[0x0c4/4] >> 0)&0x0000ffff) |
| 1532 | #define STV_VDP2_WPEY0 ((state->m_vdp2_regs[0x0c4/4] >> 0)&0x0000ffff) |
| 1547 | 1533 | |
| 1548 | 1534 | #define STV_VDP2_W0EY ((STV_VDP2_WPEY0 & 0x03ff) >> 0) |
| 1549 | 1535 | |
| r11640 | r11641 | |
| 1554 | 1540 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1555 | 1541 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1556 | 1542 | |
| 1557 | | #define STV_VDP2_WPSX1 ((stv_vdp2_regs[0x0c8/4] >> 16)&0x0000ffff) |
| 1543 | #define STV_VDP2_WPSX1 ((state->m_vdp2_regs[0x0c8/4] >> 16)&0x0000ffff) |
| 1558 | 1544 | |
| 1559 | 1545 | #define STV_VDP2_W1SX ((STV_VDP2_WPSX1 & 0x03ff) >> 0) |
| 1560 | 1546 | |
| r11640 | r11641 | |
| 1565 | 1551 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1566 | 1552 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1567 | 1553 | |
| 1568 | | #define STV_VDP2_WPSY1 ((stv_vdp2_regs[0x0c8/4] >> 0)&0x0000ffff) |
| 1554 | #define STV_VDP2_WPSY1 ((state->m_vdp2_regs[0x0c8/4] >> 0)&0x0000ffff) |
| 1569 | 1555 | |
| 1570 | 1556 | #define STV_VDP2_W1SY ((STV_VDP2_WPSY1 & 0x03ff) >> 0) |
| 1571 | 1557 | |
| r11640 | r11641 | |
| 1576 | 1562 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1577 | 1563 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1578 | 1564 | |
| 1579 | | #define STV_VDP2_WPEX1 ((stv_vdp2_regs[0x0cc/4] >> 16)&0x0000ffff) |
| 1565 | #define STV_VDP2_WPEX1 ((state->m_vdp2_regs[0x0cc/4] >> 16)&0x0000ffff) |
| 1580 | 1566 | |
| 1581 | 1567 | #define STV_VDP2_W1EX ((STV_VDP2_WPEX1 & 0x03ff) >> 0) |
| 1582 | 1568 | |
| r11640 | r11641 | |
| 1587 | 1573 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1588 | 1574 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1589 | 1575 | |
| 1590 | | #define STV_VDP2_WPEY1 ((stv_vdp2_regs[0x0cc/4] >> 0)&0x0000ffff) |
| 1576 | #define STV_VDP2_WPEY1 ((state->m_vdp2_regs[0x0cc/4] >> 0)&0x0000ffff) |
| 1591 | 1577 | |
| 1592 | 1578 | #define STV_VDP2_W1EY ((STV_VDP2_WPEY1 & 0x03ff) >> 0) |
| 1593 | 1579 | |
| r11640 | r11641 | |
| 1598 | 1584 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1599 | 1585 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1600 | 1586 | |
| 1601 | | #define STV_VDP2_WCTLA ((stv_vdp2_regs[0x0d0/4] >> 16)&0x0000ffff) |
| 1587 | #define STV_VDP2_WCTLA ((state->m_vdp2_regs[0x0d0/4] >> 16)&0x0000ffff) |
| 1602 | 1588 | #define STV_VDP2_N1LOG ((STV_VDP2_WCTLA & 0x8000) >> 15) |
| 1603 | 1589 | #define STV_VDP2_N1SWE ((STV_VDP2_WCTLA & 0x2000) >> 13) |
| 1604 | 1590 | #define STV_VDP2_N1SWA ((STV_VDP2_WCTLA & 0x1000) >> 12) |
| r11640 | r11641 | |
| 1621 | 1607 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1622 | 1608 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1623 | 1609 | |
| 1624 | | #define STV_VDP2_WCTLB ((stv_vdp2_regs[0x0d0/4] >> 0)&0x0000ffff) |
| 1610 | #define STV_VDP2_WCTLB ((state->m_vdp2_regs[0x0d0/4] >> 0)&0x0000ffff) |
| 1625 | 1611 | #define STV_VDP2_N3LOG ((STV_VDP2_WCTLB & 0x8000) >> 15) |
| 1626 | 1612 | #define STV_VDP2_N3SWE ((STV_VDP2_WCTLB & 0x2000) >> 13) |
| 1627 | 1613 | #define STV_VDP2_N3SWA ((STV_VDP2_WCTLB & 0x1000) >> 12) |
| r11640 | r11641 | |
| 1644 | 1630 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1645 | 1631 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1646 | 1632 | |
| 1647 | | #define STV_VDP2_WCTLC ((stv_vdp2_regs[0x0d4/4] >> 16)&0x0000ffff) |
| 1633 | #define STV_VDP2_WCTLC ((state->m_vdp2_regs[0x0d4/4] >> 16)&0x0000ffff) |
| 1648 | 1634 | #define STV_VDP2_SPLOG ((STV_VDP2_WCTLC & 0x8000) >> 15) |
| 1649 | 1635 | #define STV_VDP2_SPSWE ((STV_VDP2_WCTLC & 0x2000) >> 13) |
| 1650 | 1636 | #define STV_VDP2_SPSWA ((STV_VDP2_WCTLC & 0x1000) >> 12) |
| r11640 | r11641 | |
| 1702 | 1688 | | -- | -- | SPCLMD | SPWINEN | SPTYPE3 | SPTYPE2 | SPTYPE1 | SPTYPE0 | |
| 1703 | 1689 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1704 | 1690 | |
| 1705 | | #define STV_VDP2_SPCTL ((stv_vdp2_regs[0xe0/4] >> 16)&0x0000ffff) |
| 1691 | #define STV_VDP2_SPCTL ((state->m_vdp2_regs[0xe0/4] >> 16)&0x0000ffff) |
| 1706 | 1692 | #define STV_VDP2_SPCCCS ((STV_VDP2_SPCTL & 0x3000) >> 12) |
| 1707 | 1693 | #define STV_VDP2_SPCCN ((STV_VDP2_SPCTL & 0x700) >> 8) |
| 1708 | 1694 | #define STV_VDP2_SPCLMD ((STV_VDP2_SPCTL & 0x20) >> 5) |
| r11640 | r11641 | |
| 1716 | 1702 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1717 | 1703 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1718 | 1704 | |
| 1719 | | #define STV_VDP2_SDCTL ((stv_vdp2_regs[0x0e0/4] >> 0) & 0x0000ffff) |
| 1705 | #define STV_VDP2_SDCTL ((state->m_vdp2_regs[0x0e0/4] >> 0) & 0x0000ffff) |
| 1720 | 1706 | |
| 1721 | 1707 | /* 1800e4 - CRAOFA - Colour Ram Address Offset (NBG0 - NBG3) |
| 1722 | 1708 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 1725 | 1711 | | -- | N1CAOS2 | N1CAOS1 | N1CAOS0 | -- | N0CAOS2 | N0CAOS1 | N0CAOS0 | |
| 1726 | 1712 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1727 | 1713 | |
| 1728 | | #define STV_VDP2_CRAOFA ((stv_vdp2_regs[0x0e4/4] >> 16)&0x0000ffff) |
| 1714 | #define STV_VDP2_CRAOFA ((state->m_vdp2_regs[0x0e4/4] >> 16)&0x0000ffff) |
| 1729 | 1715 | |
| 1730 | 1716 | /* NxCAOS = */ |
| 1731 | 1717 | #define STV_VDP2_N0CAOS ((STV_VDP2_CRAOFA & 0x0007) >> 0) |
| r11640 | r11641 | |
| 1740 | 1726 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 1741 | 1727 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1742 | 1728 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1743 | | #define STV_VDP2_CRAOFB ((stv_vdp2_regs[0x0e4/4] >> 0)&0x0000ffff) |
| 1729 | #define STV_VDP2_CRAOFB ((state->m_vdp2_regs[0x0e4/4] >> 0)&0x0000ffff) |
| 1744 | 1730 | #define STV_VDP2_R0CAOS ((STV_VDP2_CRAOFB & 0x0007) >> 0) |
| 1745 | 1731 | #define STV_VDP2_SPCAOS ((STV_VDP2_CRAOFB & 0x0070) >> 4) |
| 1746 | 1732 | |
| r11640 | r11641 | |
| 1751 | 1737 | | -- | -- | SPLCEN | R0LCEN | N3LCEN | N2LCEN | N1LCEN | N0LCEN | |
| 1752 | 1738 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1753 | 1739 | |
| 1754 | | #define STV_VDP2_LNCLEN ((stv_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff) |
| 1740 | #define STV_VDP2_LNCLEN ((state->m_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff) |
| 1755 | 1741 | #define STV_VDP2_SPLCEN ((STV_VDP2_LNCLEN & 0x0020) >> 5) |
| 1756 | 1742 | #define STV_VDP2_R0LCEN ((STV_VDP2_LNCLEN & 0x0010) >> 4) |
| 1757 | 1743 | #define STV_VDP2_N3LCEN ((STV_VDP2_LNCLEN & 0x0008) >> 3) |
| r11640 | r11641 | |
| 1773 | 1759 | | -- | SPCCEN | LCCCEN | R0CCEN | N3CCEN | N2CCEN | N1CCEN | N0CCEN | |
| 1774 | 1760 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1775 | 1761 | |
| 1776 | | #define STV_VDP2_CCCR ((stv_vdp2_regs[0xec/4]>>16)&0x0000ffff) |
| 1762 | #define STV_VDP2_CCCR ((state->m_vdp2_regs[0xec/4]>>16)&0x0000ffff) |
| 1777 | 1763 | #define STV_VDP2_CCMD ((STV_VDP2_CCCR & 0x100) >> 8) |
| 1778 | 1764 | #define STV_VDP2_SPCCEN ((STV_VDP2_CCCR & 0x40) >> 6) |
| 1779 | 1765 | #define STV_VDP2_LCCCEN ((STV_VDP2_CCCR & 0x20) >> 5) |
| r11640 | r11641 | |
| 1798 | 1784 | | -- | -- | -- | -- | -- | S0PRIN2 | S0PRIN1 | S0PRIN0 | |
| 1799 | 1785 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1800 | 1786 | |
| 1801 | | #define STV_VDP2_PRISA ((stv_vdp2_regs[0xf0/4] >> 16) & 0x0000ffff) |
| 1787 | #define STV_VDP2_PRISA ((state->m_vdp2_regs[0xf0/4] >> 16) & 0x0000ffff) |
| 1802 | 1788 | #define STV_VDP2_S1PRIN ((STV_VDP2_PRISA & 0x0700) >> 8) |
| 1803 | 1789 | #define STV_VDP2_S0PRIN ((STV_VDP2_PRISA & 0x0007) >> 0) |
| 1804 | 1790 | |
| r11640 | r11641 | |
| 1809 | 1795 | | -- | -- | -- | -- | -- | S2PRIN2 | S2PRIN1 | S2PRIN0 | |
| 1810 | 1796 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1811 | 1797 | |
| 1812 | | #define STV_VDP2_PRISB ((stv_vdp2_regs[0xf0/4] >> 0) & 0x0000ffff) |
| 1798 | #define STV_VDP2_PRISB ((state->m_vdp2_regs[0xf0/4] >> 0) & 0x0000ffff) |
| 1813 | 1799 | #define STV_VDP2_S3PRIN ((STV_VDP2_PRISB & 0x0700) >> 8) |
| 1814 | 1800 | #define STV_VDP2_S2PRIN ((STV_VDP2_PRISB & 0x0007) >> 0) |
| 1815 | 1801 | |
| r11640 | r11641 | |
| 1820 | 1806 | | -- | -- | -- | -- | -- | S4PRIN2 | S4PRIN1 | S4PRIN0 | |
| 1821 | 1807 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1822 | 1808 | |
| 1823 | | #define STV_VDP2_PRISC ((stv_vdp2_regs[0xf4/4] >> 16) & 0x0000ffff) |
| 1809 | #define STV_VDP2_PRISC ((state->m_vdp2_regs[0xf4/4] >> 16) & 0x0000ffff) |
| 1824 | 1810 | #define STV_VDP2_S5PRIN ((STV_VDP2_PRISC & 0x0700) >> 8) |
| 1825 | 1811 | #define STV_VDP2_S4PRIN ((STV_VDP2_PRISC & 0x0007) >> 0) |
| 1826 | 1812 | |
| r11640 | r11641 | |
| 1831 | 1817 | | -- | -- | -- | -- | -- | S6PRIN2 | S6PRIN1 | S6PRIN0 | |
| 1832 | 1818 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1833 | 1819 | |
| 1834 | | #define STV_VDP2_PRISD ((stv_vdp2_regs[0xf4/4] >> 0) & 0x0000ffff) |
| 1820 | #define STV_VDP2_PRISD ((state->m_vdp2_regs[0xf4/4] >> 0) & 0x0000ffff) |
| 1835 | 1821 | #define STV_VDP2_S7PRIN ((STV_VDP2_PRISD & 0x0700) >> 8) |
| 1836 | 1822 | #define STV_VDP2_S6PRIN ((STV_VDP2_PRISD & 0x0007) >> 0) |
| 1837 | 1823 | |
| r11640 | r11641 | |
| 1843 | 1829 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1844 | 1830 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1845 | 1831 | |
| 1846 | | #define STV_VDP2_PRINA ((stv_vdp2_regs[0x0f8/4] >> 16)&0x0000ffff) |
| 1832 | #define STV_VDP2_PRINA ((state->m_vdp2_regs[0x0f8/4] >> 16)&0x0000ffff) |
| 1847 | 1833 | |
| 1848 | 1834 | #define STV_VDP2_N1PRIN ((STV_VDP2_PRINA & 0x0700) >> 8) |
| 1849 | 1835 | #define STV_VDP2_N0PRIN ((STV_VDP2_PRINA & 0x0007) >> 0) |
| r11640 | r11641 | |
| 1855 | 1841 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1856 | 1842 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1857 | 1843 | |
| 1858 | | #define STV_VDP2_PRINB ((stv_vdp2_regs[0x0f8/4] >> 0)&0x0000ffff) |
| 1844 | #define STV_VDP2_PRINB ((state->m_vdp2_regs[0x0f8/4] >> 0)&0x0000ffff) |
| 1859 | 1845 | |
| 1860 | 1846 | #define STV_VDP2_N3PRIN ((STV_VDP2_PRINB & 0x0700) >> 8) |
| 1861 | 1847 | #define STV_VDP2_N2PRIN ((STV_VDP2_PRINB & 0x0007) >> 0) |
| r11640 | r11641 | |
| 1866 | 1852 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 1867 | 1853 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1868 | 1854 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1869 | | #define STV_VDP2_PRIR ((stv_vdp2_regs[0x0fc/4] >> 16)&0x0000ffff) |
| 1855 | #define STV_VDP2_PRIR ((state->m_vdp2_regs[0x0fc/4] >> 16)&0x0000ffff) |
| 1870 | 1856 | |
| 1871 | 1857 | #define STV_VDP2_R0PRIN ((STV_VDP2_PRIR & 0x0007) >> 0) |
| 1872 | 1858 | |
| r11640 | r11641 | |
| 1884 | 1870 | | -- | -- | -- | S0CCRT4 | S0CCRT3 | S0CCRT2 | S0CCRT1 | S0CCRT0 | |
| 1885 | 1871 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1886 | 1872 | |
| 1887 | | #define STV_VDP2_CCRSA ((stv_vdp2_regs[0x100/4] >> 16) & 0x0000ffff) |
| 1873 | #define STV_VDP2_CCRSA ((state->m_vdp2_regs[0x100/4] >> 16) & 0x0000ffff) |
| 1888 | 1874 | #define STV_VDP2_S1CCRT ((STV_VDP2_CCRSA & 0x1f00) >> 8) |
| 1889 | 1875 | #define STV_VDP2_S0CCRT ((STV_VDP2_CCRSA & 0x001f) >> 0) |
| 1890 | 1876 | |
| r11640 | r11641 | |
| 1895 | 1881 | | -- | -- | -- | S2CCRT4 | S2CCRT3 | S2CCRT2 | S2CCRT1 | S2CCRT0 | |
| 1896 | 1882 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1897 | 1883 | |
| 1898 | | #define STV_VDP2_CCRSB ((stv_vdp2_regs[0x100/4] >> 0) & 0x0000ffff) |
| 1884 | #define STV_VDP2_CCRSB ((state->m_vdp2_regs[0x100/4] >> 0) & 0x0000ffff) |
| 1899 | 1885 | #define STV_VDP2_S3CCRT ((STV_VDP2_CCRSB & 0x1f00) >> 8) |
| 1900 | 1886 | #define STV_VDP2_S2CCRT ((STV_VDP2_CCRSB & 0x001f) >> 0) |
| 1901 | 1887 | |
| r11640 | r11641 | |
| 1906 | 1892 | | -- | -- | -- | S4CCRT4 | S4CCRT3 | S4CCRT2 | S4CCRT1 | S4CCRT0 | |
| 1907 | 1893 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1908 | 1894 | |
| 1909 | | #define STV_VDP2_CCRSC ((stv_vdp2_regs[0x104/4 ]>> 16) & 0x0000ffff) |
| 1895 | #define STV_VDP2_CCRSC ((state->m_vdp2_regs[0x104/4 ]>> 16) & 0x0000ffff) |
| 1910 | 1896 | #define STV_VDP2_S5CCRT ((STV_VDP2_CCRSC & 0x1f00) >> 8) |
| 1911 | 1897 | #define STV_VDP2_S4CCRT ((STV_VDP2_CCRSC & 0x001f) >> 0) |
| 1912 | 1898 | |
| r11640 | r11641 | |
| 1917 | 1903 | | -- | -- | -- | S6CCRT4 | S6CCRT3 | S6CCRT2 | S6CCRT1 | S6CCRT0 | |
| 1918 | 1904 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1919 | 1905 | |
| 1920 | | #define STV_VDP2_CCRSD ((stv_vdp2_regs[0x104/4 ]>> 0) & 0x0000ffff) |
| 1906 | #define STV_VDP2_CCRSD ((state->m_vdp2_regs[0x104/4 ]>> 0) & 0x0000ffff) |
| 1921 | 1907 | #define STV_VDP2_S7CCRT ((STV_VDP2_CCRSD & 0x1f00) >> 8) |
| 1922 | 1908 | #define STV_VDP2_S6CCRT ((STV_VDP2_CCRSD & 0x001f) >> 0) |
| 1923 | 1909 | |
| r11640 | r11641 | |
| 1928 | 1914 | | -- | -- | -- | N0CCRT4 | N0CCRT3 | N0CCRT2 | N0CCRT1 | N0CCRT0 | |
| 1929 | 1915 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1930 | 1916 | |
| 1931 | | #define STV_VDP2_CCRNA ((stv_vdp2_regs[0x108/4] >> 16)&0x0000ffff) |
| 1917 | #define STV_VDP2_CCRNA ((state->m_vdp2_regs[0x108/4] >> 16)&0x0000ffff) |
| 1932 | 1918 | #define STV_VDP2_N1CCRT ((STV_VDP2_CCRNA & 0x1f00) >> 8) |
| 1933 | 1919 | #define STV_VDP2_N0CCRT (STV_VDP2_CCRNA & 0x1f) |
| 1934 | 1920 | |
| r11640 | r11641 | |
| 1939 | 1925 | | -- | -- | -- | N2CCRT4 | N2CCRT3 | N2CCRT2 | N2CCRT1 | N2CCRT0 | |
| 1940 | 1926 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1941 | 1927 | |
| 1942 | | #define STV_VDP2_CCRNB ((stv_vdp2_regs[0x108/4] >> 0)&0x0000ffff) |
| 1928 | #define STV_VDP2_CCRNB ((state->m_vdp2_regs[0x108/4] >> 0)&0x0000ffff) |
| 1943 | 1929 | #define STV_VDP2_N3CCRT ((STV_VDP2_CCRNB & 0x1f00) >> 8) |
| 1944 | 1930 | #define STV_VDP2_N2CCRT (STV_VDP2_CCRNB & 0x1f) |
| 1945 | 1931 | |
| r11640 | r11641 | |
| 1950 | 1936 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1951 | 1937 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1952 | 1938 | |
| 1953 | | #define STV_VDP2_CCRR ((stv_vdp2_regs[0x10c/4] >> 16)&0x0000ffff) |
| 1939 | #define STV_VDP2_CCRR ((state->m_vdp2_regs[0x10c/4] >> 16)&0x0000ffff) |
| 1954 | 1940 | #define STV_VDP2_R0CCRT (STV_VDP2_CCRR & 0x1f) |
| 1955 | 1941 | |
| 1956 | 1942 | /* 18010e - Colour Calculation Ratio (Line Colour Screen, Back Colour Screen) |
| r11640 | r11641 | |
| 1967 | 1953 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1968 | 1954 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1969 | 1955 | |
| 1970 | | #define STV_VDP2_CLOFEN ((stv_vdp2_regs[0x110/4] >> 16)&0x0000ffff) |
| 1956 | #define STV_VDP2_CLOFEN ((state->m_vdp2_regs[0x110/4] >> 16)&0x0000ffff) |
| 1971 | 1957 | #define STV_VDP2_N0COEN ((STV_VDP2_CLOFEN & 0x01) >> 0) |
| 1972 | 1958 | #define STV_VDP2_N1COEN ((STV_VDP2_CLOFEN & 0x02) >> 1) |
| 1973 | 1959 | #define STV_VDP2_N2COEN ((STV_VDP2_CLOFEN & 0x04) >> 2) |
| r11640 | r11641 | |
| 1983 | 1969 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 1984 | 1970 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 1985 | 1971 | |
| 1986 | | #define STV_VDP2_CLOFSL ((stv_vdp2_regs[0x110/4] >> 0)&0x0000ffff) |
| 1972 | #define STV_VDP2_CLOFSL ((state->m_vdp2_regs[0x110/4] >> 0)&0x0000ffff) |
| 1987 | 1973 | #define STV_VDP2_N0COSL ((STV_VDP2_CLOFSL & 0x01) >> 0) |
| 1988 | 1974 | #define STV_VDP2_N1COSL ((STV_VDP2_CLOFSL & 0x02) >> 1) |
| 1989 | 1975 | #define STV_VDP2_N2COSL ((STV_VDP2_CLOFSL & 0x04) >> 2) |
| r11640 | r11641 | |
| 1999 | 1985 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2000 | 1986 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2001 | 1987 | |
| 2002 | | #define STV_VDP2_COAR ((stv_vdp2_regs[0x114/4] >> 16)&0x0000ffff) |
| 1988 | #define STV_VDP2_COAR ((state->m_vdp2_regs[0x114/4] >> 16)&0x0000ffff) |
| 2003 | 1989 | |
| 2004 | 1990 | /* 180116 - Colour Offset A (Green) |
| 2005 | 1991 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 2007 | 1993 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 2008 | 1994 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2009 | 1995 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2010 | | #define STV_VDP2_COAG ((stv_vdp2_regs[0x114/4] >> 0)&0x0000ffff) |
| 1996 | #define STV_VDP2_COAG ((state->m_vdp2_regs[0x114/4] >> 0)&0x0000ffff) |
| 2011 | 1997 | |
| 2012 | 1998 | /* 180118 - Colour Offset A (Blue) |
| 2013 | 1999 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 2016 | 2002 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2017 | 2003 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2018 | 2004 | |
| 2019 | | #define STV_VDP2_COAB ((stv_vdp2_regs[0x118/4] >> 16)&0x0000ffff) |
| 2005 | #define STV_VDP2_COAB ((state->m_vdp2_regs[0x118/4] >> 16)&0x0000ffff) |
| 2020 | 2006 | |
| 2021 | 2007 | /* 18011a - Colour Offset B (Red) |
| 2022 | 2008 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 2024 | 2010 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 2025 | 2011 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2026 | 2012 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2027 | | #define STV_VDP2_COBR ((stv_vdp2_regs[0x118/4] >> 0)&0x0000ffff) |
| 2013 | #define STV_VDP2_COBR ((state->m_vdp2_regs[0x118/4] >> 0)&0x0000ffff) |
| 2028 | 2014 | |
| 2029 | 2015 | /* 18011b - Colour Offset B (Green) |
| 2030 | 2016 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 2032 | 2018 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 2033 | 2019 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2034 | 2020 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2035 | | #define STV_VDP2_COBG ((stv_vdp2_regs[0x11c/4] >> 16)&0x0000ffff) |
| 2021 | #define STV_VDP2_COBG ((state->m_vdp2_regs[0x11c/4] >> 16)&0x0000ffff) |
| 2036 | 2022 | |
| 2037 | 2023 | /* 18011c - Colour Offset B (Blue) |
| 2038 | 2024 | bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\ |
| r11640 | r11641 | |
| 2040 | 2026 | |----07----|----06----|----05----|----04----|----03----|----02----|----01----|----00----| |
| 2041 | 2027 | | -- | -- | -- | -- | -- | -- | -- | -- | |
| 2042 | 2028 | \----------|----------|----------|----------|----------|----------|----------|---------*/ |
| 2043 | | #define STV_VDP2_COBB ((stv_vdp2_regs[0x11c/4] >> 0)&0x0000ffff) |
| 2029 | #define STV_VDP2_COBB ((state->m_vdp2_regs[0x11c/4] >> 0)&0x0000ffff) |
| 2044 | 2030 | |
| 2045 | 2031 | /*For Debug purposes only*/ |
| 2046 | 2032 | static struct stv_vdp2_debugging |
| r11640 | r11641 | |
| 2164 | 2150 | |
| 2165 | 2151 | static void stv_vdp2_fill_rotation_parameter_table( running_machine &machine, UINT8 rot_parameter ) |
| 2166 | 2152 | { |
| 2153 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2167 | 2154 | UINT32 address = 0; |
| 2168 | 2155 | |
| 2169 | 2156 | address = (((STV_VDP2_RPTAU << 16) | STV_VDP2_RPTAL) << 1); |
| r11640 | r11641 | |
| 2176 | 2163 | address |= 0x00000080; |
| 2177 | 2164 | } |
| 2178 | 2165 | |
| 2179 | | stv_current_rotation_parameter_table.xst = (stv_vdp2_vram[address/4] & 0x1fffffc0) | ((stv_vdp2_vram[address/4] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2180 | | stv_current_rotation_parameter_table.yst = (stv_vdp2_vram[address/4 + 1] & 0x1fffffc0) | ((stv_vdp2_vram[address/4 + 1] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2181 | | stv_current_rotation_parameter_table.zst = (stv_vdp2_vram[address/4 + 2] & 0x1fffffc0) | ((stv_vdp2_vram[address/4 + 2] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2182 | | stv_current_rotation_parameter_table.dxst = (stv_vdp2_vram[address/4 + 3] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 3] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2183 | | stv_current_rotation_parameter_table.dyst = (stv_vdp2_vram[address/4 + 4] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 4] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2184 | | stv_current_rotation_parameter_table.dx = (stv_vdp2_vram[address/4 + 5] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 5] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2185 | | stv_current_rotation_parameter_table.dy = (stv_vdp2_vram[address/4 + 6] & 0x0007ffc0) | ((stv_vdp2_vram[address/4 + 6] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2186 | | stv_current_rotation_parameter_table.A = (stv_vdp2_vram[address/4 + 7] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 7] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2187 | | stv_current_rotation_parameter_table.B = (stv_vdp2_vram[address/4 + 8] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 8] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2188 | | stv_current_rotation_parameter_table.C = (stv_vdp2_vram[address/4 + 9] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 9] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2189 | | stv_current_rotation_parameter_table.D = (stv_vdp2_vram[address/4 + 10] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 10] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2190 | | stv_current_rotation_parameter_table.E = (stv_vdp2_vram[address/4 + 11] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 11] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2191 | | stv_current_rotation_parameter_table.F = (stv_vdp2_vram[address/4 + 12] & 0x000fffc0) | ((stv_vdp2_vram[address/4 + 12] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2192 | | stv_current_rotation_parameter_table.px = (stv_vdp2_vram[address/4 + 13] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 13] & 0x30000000) ? 0xc0000000 : 0x00000000 ); |
| 2193 | | stv_current_rotation_parameter_table.py = (stv_vdp2_vram[address/4 + 13] & 0x00003fff) << 16; |
| 2166 | stv_current_rotation_parameter_table.xst = (state->m_vdp2_vram[address/4] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2167 | stv_current_rotation_parameter_table.yst = (state->m_vdp2_vram[address/4 + 1] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4 + 1] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2168 | stv_current_rotation_parameter_table.zst = (state->m_vdp2_vram[address/4 + 2] & 0x1fffffc0) | ((state->m_vdp2_vram[address/4 + 2] & 0x10000000) ? 0xe0000000 : 0x00000000 ); |
| 2169 | stv_current_rotation_parameter_table.dxst = (state->m_vdp2_vram[address/4 + 3] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 3] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2170 | stv_current_rotation_parameter_table.dyst = (state->m_vdp2_vram[address/4 + 4] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 4] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2171 | stv_current_rotation_parameter_table.dx = (state->m_vdp2_vram[address/4 + 5] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 5] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2172 | stv_current_rotation_parameter_table.dy = (state->m_vdp2_vram[address/4 + 6] & 0x0007ffc0) | ((state->m_vdp2_vram[address/4 + 6] & 0x00040000) ? 0xfff80000 : 0x00000000 ); |
| 2173 | stv_current_rotation_parameter_table.A = (state->m_vdp2_vram[address/4 + 7] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 7] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2174 | stv_current_rotation_parameter_table.B = (state->m_vdp2_vram[address/4 + 8] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 8] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2175 | stv_current_rotation_parameter_table.C = (state->m_vdp2_vram[address/4 + 9] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 9] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2176 | stv_current_rotation_parameter_table.D = (state->m_vdp2_vram[address/4 + 10] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 10] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2177 | stv_current_rotation_parameter_table.E = (state->m_vdp2_vram[address/4 + 11] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 11] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2178 | stv_current_rotation_parameter_table.F = (state->m_vdp2_vram[address/4 + 12] & 0x000fffc0) | ((state->m_vdp2_vram[address/4 + 12] & 0x00080000) ? 0xfff00000 : 0x00000000 ); |
| 2179 | stv_current_rotation_parameter_table.px = (state->m_vdp2_vram[address/4 + 13] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 13] & 0x30000000) ? 0xc0000000 : 0x00000000 ); |
| 2180 | stv_current_rotation_parameter_table.py = (state->m_vdp2_vram[address/4 + 13] & 0x00003fff) << 16; |
| 2194 | 2181 | if ( stv_current_rotation_parameter_table.py & 0x20000000 ) stv_current_rotation_parameter_table.py |= 0xc0000000; |
| 2195 | | stv_current_rotation_parameter_table.pz = (stv_vdp2_vram[address/4 + 14] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 14] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2196 | | stv_current_rotation_parameter_table.cx = (stv_vdp2_vram[address/4 + 15] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 15] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2197 | | stv_current_rotation_parameter_table.cy = (stv_vdp2_vram[address/4 + 15] & 0x00003fff) << 16; |
| 2182 | stv_current_rotation_parameter_table.pz = (state->m_vdp2_vram[address/4 + 14] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 14] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2183 | stv_current_rotation_parameter_table.cx = (state->m_vdp2_vram[address/4 + 15] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 15] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2184 | stv_current_rotation_parameter_table.cy = (state->m_vdp2_vram[address/4 + 15] & 0x00003fff) << 16; |
| 2198 | 2185 | if ( stv_current_rotation_parameter_table.cy & 0x20000000 ) stv_current_rotation_parameter_table.cy |= 0xc0000000; |
| 2199 | | stv_current_rotation_parameter_table.cz = (stv_vdp2_vram[address/4 + 16] & 0x3fff0000) | ((stv_vdp2_vram[address/4 + 16] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2200 | | stv_current_rotation_parameter_table.mx = (stv_vdp2_vram[address/4 + 17] & 0x3fffffc0) | ((stv_vdp2_vram[address/4 + 17] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2201 | | stv_current_rotation_parameter_table.my = (stv_vdp2_vram[address/4 + 18] & 0x3fffffc0) | ((stv_vdp2_vram[address/4 + 18] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2202 | | stv_current_rotation_parameter_table.kx = (stv_vdp2_vram[address/4 + 19] & 0x00ffffff) | ((stv_vdp2_vram[address/4 + 19] & 0x00800000) ? 0xff000000 : 0x00000000 ); |
| 2203 | | stv_current_rotation_parameter_table.ky = (stv_vdp2_vram[address/4 + 20] & 0x00ffffff) | ((stv_vdp2_vram[address/4 + 20] & 0x00800000) ? 0xff000000 : 0x00000000 ); |
| 2204 | | stv_current_rotation_parameter_table.kast = (stv_vdp2_vram[address/4 + 21] & 0xffffffc0); |
| 2205 | | stv_current_rotation_parameter_table.dkast= (stv_vdp2_vram[address/4 + 22] & 0x03ffffc0) | ((stv_vdp2_vram[address/4 + 22] & 0x02000000) ? 0xfc000000 : 0x00000000 ); |
| 2206 | | stv_current_rotation_parameter_table.dkax = (stv_vdp2_vram[address/4 + 23] & 0x03ffffc0) | ((stv_vdp2_vram[address/4 + 23] & 0x02000000) ? 0xfc000000 : 0x00000000 ); |
| 2186 | stv_current_rotation_parameter_table.cz = (state->m_vdp2_vram[address/4 + 16] & 0x3fff0000) | ((state->m_vdp2_vram[address/4 + 16] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2187 | stv_current_rotation_parameter_table.mx = (state->m_vdp2_vram[address/4 + 17] & 0x3fffffc0) | ((state->m_vdp2_vram[address/4 + 17] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2188 | stv_current_rotation_parameter_table.my = (state->m_vdp2_vram[address/4 + 18] & 0x3fffffc0) | ((state->m_vdp2_vram[address/4 + 18] & 0x20000000) ? 0xc0000000 : 0x00000000 ); |
| 2189 | stv_current_rotation_parameter_table.kx = (state->m_vdp2_vram[address/4 + 19] & 0x00ffffff) | ((state->m_vdp2_vram[address/4 + 19] & 0x00800000) ? 0xff000000 : 0x00000000 ); |
| 2190 | stv_current_rotation_parameter_table.ky = (state->m_vdp2_vram[address/4 + 20] & 0x00ffffff) | ((state->m_vdp2_vram[address/4 + 20] & 0x00800000) ? 0xff000000 : 0x00000000 ); |
| 2191 | stv_current_rotation_parameter_table.kast = (state->m_vdp2_vram[address/4 + 21] & 0xffffffc0); |
| 2192 | stv_current_rotation_parameter_table.dkast= (state->m_vdp2_vram[address/4 + 22] & 0x03ffffc0) | ((state->m_vdp2_vram[address/4 + 22] & 0x02000000) ? 0xfc000000 : 0x00000000 ); |
| 2193 | stv_current_rotation_parameter_table.dkax = (state->m_vdp2_vram[address/4 + 23] & 0x03ffffc0) | ((state->m_vdp2_vram[address/4 + 23] & 0x02000000) ? 0xfc000000 : 0x00000000 ); |
| 2207 | 2194 | |
| 2208 | 2195 | #define RP stv_current_rotation_parameter_table |
| 2209 | 2196 | |
| r11640 | r11641 | |
| 2288 | 2275 | return 1; |
| 2289 | 2276 | } |
| 2290 | 2277 | |
| 2291 | | static void stv_vdp2_check_fade_control_for_layer(void) |
| 2278 | static void stv_vdp2_check_fade_control_for_layer(running_machine &machine) |
| 2292 | 2279 | { |
| 2280 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2293 | 2281 | if ( stv2_current_tilemap.fade_control & 1 ) |
| 2294 | 2282 | { |
| 2295 | 2283 | if ( stv2_current_tilemap.fade_control & 2 ) |
| r11640 | r11641 | |
| 2323 | 2311 | #define STV_VDP2_CP_NBG3_CPDR 0x7 |
| 2324 | 2312 | |
| 2325 | 2313 | static UINT8 stv_vdp2_check_vram_cycle_pattern_registers( |
| 2314 | running_machine &machine, |
| 2326 | 2315 | UINT8 access_command_pnmdr, |
| 2327 | 2316 | UINT8 access_command_cpdr, |
| 2328 | 2317 | UINT8 bitmap_enable ) |
| 2329 | 2318 | { |
| 2319 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2330 | 2320 | int i; |
| 2331 | 2321 | UINT8 access_command_ok = 0; |
| 2332 | 2322 | UINT16 cp_regs[8]; |
| r11640 | r11641 | |
| 2661 | 2651 | |
| 2662 | 2652 | } |
| 2663 | 2653 | |
| 2664 | | static void stv_vdp2_compute_color_offset_RGB555( int *r, int *g, int *b, int cor ) |
| 2654 | static void stv_vdp2_compute_color_offset_RGB555( running_machine &machine,int *r, int *g, int *b, int cor ) |
| 2665 | 2655 | { |
| 2656 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2666 | 2657 | *r <<= 3; |
| 2667 | 2658 | *g <<= 3; |
| 2668 | 2659 | *b <<= 3; |
| r11640 | r11641 | |
| 2690 | 2681 | |
| 2691 | 2682 | } |
| 2692 | 2683 | |
| 2693 | | static void stv_vdp2_compute_color_offset_RGB555_UINT16(UINT16 *rgb, int cor) |
| 2684 | static void stv_vdp2_compute_color_offset_RGB555_UINT16(running_machine &machine,UINT16 *rgb, int cor) |
| 2694 | 2685 | { |
| 2686 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2695 | 2687 | int _r = (*rgb & 0x7c00) >> (10-3); |
| 2696 | 2688 | int _g = (*rgb & 0x03e0) >> (5-3); |
| 2697 | 2689 | int _b = (*rgb & 0x001f) << 3; |
| r11640 | r11641 | |
| 2720 | 2712 | *rgb = (_r << 10) | (_g << 5) | _b; |
| 2721 | 2713 | } |
| 2722 | 2714 | |
| 2723 | | static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, const rectangle *clip, UINT32 code, int flipx, int flipy, |
| 2715 | static void stv_vdp2_drawgfx_rgb555( bitmap_t *dest_bmp, const rectangle *clip, running_machine &machine, UINT32 code, int flipx, int flipy, |
| 2724 | 2716 | int sx, int sy, int transparency, int alpha) |
| 2725 | 2717 | { |
| 2718 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2726 | 2719 | rectangle myclip; |
| 2727 | 2720 | UINT8* gfxdata; |
| 2728 | 2721 | int t_pen; |
| 2729 | 2722 | int sprite_screen_width, sprite_screen_height; |
| 2730 | 2723 | |
| 2731 | | gfxdata = stv_vdp2_gfx_decode + code * 0x20; |
| 2724 | gfxdata = state->m_vdp2.gfx_decode + code * 0x20; |
| 2732 | 2725 | sprite_screen_width = sprite_screen_height = 8; |
| 2733 | 2726 | |
| 2734 | 2727 | /* KW 991012 -- Added code to force clip to bitmap boundary */ |
| r11640 | r11641 | |
| 2826 | 2819 | g = (data & 0x03e0) >> 5; |
| 2827 | 2820 | r = (data & 0x001f); |
| 2828 | 2821 | if(stv2_current_tilemap.fade_control & 1) |
| 2829 | | stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2822 | stv_vdp2_compute_color_offset_RGB555(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 2830 | 2823 | |
| 2831 | 2824 | if ( transparency == STV_TRANSPARENCY_ALPHA ) |
| 2832 | 2825 | dest[x] = alpha_blend_r16( dest[x], b | g << 5 | r << 10, alpha ); |
| r11640 | r11641 | |
| 2847 | 2840 | |
| 2848 | 2841 | static void stv_vdp2_draw_basic_bitmap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 2849 | 2842 | { |
| 2843 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 2844 | |
| 2850 | 2845 | // if(LOG_VDP2) logerror ("bitmap enable %02x size %08x depth %08x\n", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth); |
| 2851 | 2846 | // popmessage ("bitmap enable %02x size %08x depth %08x number %02x", stv2_current_tilemap.layer_name, stv2_current_tilemap.bitmap_size, stv2_current_tilemap.colour_depth,stv2_current_tilemap.bitmap_palette_number); |
| 2852 | 2847 | //popmessage("%04x",STV_VDP2_SCRCTL); |
| r11640 | r11641 | |
| 2855 | 2850 | int ysize = 0/*, ysizemask = 0*/; |
| 2856 | 2851 | int xlinesize = 0/*, xpixelsize = 0*/; |
| 2857 | 2852 | int xcnt,ycnt; |
| 2858 | | UINT8* gfxdata = stv_vdp2_gfx_decode; |
| 2853 | UINT8* gfxdata = state->m_vdp2.gfx_decode; |
| 2859 | 2854 | static UINT16 *destline; |
| 2860 | 2855 | UINT16 pal_color_offset = 0; |
| 2861 | 2856 | UINT8* gfxdatalow, *gfxdatahigh; |
| r11640 | r11641 | |
| 2924 | 2919 | { |
| 2925 | 2920 | for (xcnt = 0; xcnt <xsize;xcnt+=2) |
| 2926 | 2921 | { |
| 2927 | | tw = stv_vdp2_window_process(xcnt+1,ycnt); |
| 2922 | tw = stv_vdp2_window_process(machine,xcnt+1,ycnt); |
| 2928 | 2923 | if(tw == 0) |
| 2929 | 2924 | { |
| 2930 | 2925 | t_pen = (((gfxdata[0] & 0x0f) >> 0) != 0) ? (1) : (0); |
| r11640 | r11641 | |
| 2940 | 2935 | } |
| 2941 | 2936 | } |
| 2942 | 2937 | } |
| 2943 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 2938 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 2944 | 2939 | if(tw == 0) |
| 2945 | 2940 | { |
| 2946 | 2941 | t_pen = (((gfxdata[0] & 0xf0) >> 4) != 0) ? (1) : (0); |
| r11640 | r11641 | |
| 2974 | 2969 | { |
| 2975 | 2970 | int xs = xcnt & xsizemask; |
| 2976 | 2971 | |
| 2977 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 2972 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 2978 | 2973 | if(tw == 0) |
| 2979 | 2974 | { |
| 2980 | 2975 | //60aee2c = $0013 at @605d838 |
| r11640 | r11641 | |
| 3021 | 3016 | for (xcnt = cliprect->min_x; xcnt <= cliprect->max_x; xx+=stv2_current_tilemap.incx, xcnt++) |
| 3022 | 3017 | { |
| 3023 | 3018 | xs = xx >> 16; |
| 3024 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 3019 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 3025 | 3020 | if(tw == 0) |
| 3026 | 3021 | { |
| 3027 | 3022 | t_pen = ((gfxdata[xs] & 0xff) != 0) ? 1 : 0; |
| r11640 | r11641 | |
| 3049 | 3044 | { |
| 3050 | 3045 | for (xcnt = 0; xcnt <xsize;xcnt++) |
| 3051 | 3046 | { |
| 3052 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 3047 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 3053 | 3048 | if(tw == 0) |
| 3054 | 3049 | { |
| 3055 | 3050 | t_pen = ((((gfxdata[0] & 0x07) * 0x100) | (gfxdata[1] & 0xff)) != 0) ? (1) : (0); |
| r11640 | r11641 | |
| 3099 | 3094 | g = ((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5); |
| 3100 | 3095 | r = ((gfxdata[2*xs+1] & 0x1f)); |
| 3101 | 3096 | if(stv2_current_tilemap.fade_control & 1) |
| 3102 | | stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3103 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 3097 | stv_vdp2_compute_color_offset_RGB555(machine,&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3098 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 3104 | 3099 | if(tw == 0) |
| 3105 | 3100 | { |
| 3106 | 3101 | if (((xcnt + 0) < screen_x) && (ycnt < screen_y)) |
| r11640 | r11641 | |
| 3142 | 3137 | g = ((gfxdata[2*xs] & 0x03) << 3) | ((gfxdata[2*xs+1] & 0xe0) >> 5); |
| 3143 | 3138 | r = ((gfxdata[2*xs+1] & 0x1f)); |
| 3144 | 3139 | if(stv2_current_tilemap.fade_control & 1) |
| 3145 | | stv_vdp2_compute_color_offset_RGB555(&r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3146 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 3140 | stv_vdp2_compute_color_offset_RGB555(machine, &r,&g,&b,stv2_current_tilemap.fade_control & 2); |
| 3141 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 3147 | 3142 | if(tw == 0) |
| 3148 | 3143 | { |
| 3149 | 3144 | if(t_pen) |
| r11640 | r11641 | |
| 3191 | 3186 | g = (gfxdata[2] & 0xf8) >> 3; |
| 3192 | 3187 | r = (gfxdata[3] & 0xf8) >> 3; |
| 3193 | 3188 | |
| 3194 | | tw = stv_vdp2_window_process(xcnt,ycnt); |
| 3189 | tw = stv_vdp2_window_process(machine,xcnt,ycnt); |
| 3195 | 3190 | if(tw == 0) |
| 3196 | 3191 | { |
| 3197 | 3192 | if(t_pen) |
| r11640 | r11641 | |
| 3377 | 3372 | |
| 3378 | 3373 | static void stv_vdp2_draw_basic_tilemap(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 3379 | 3374 | { |
| 3375 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 3380 | 3376 | /* hopefully this is easier to follow than it is efficient .. */ |
| 3381 | 3377 | |
| 3382 | 3378 | /* I call character patterns tiles .. even if they represent up to 4 tiles */ |
| r11640 | r11641 | |
| 3656 | 3652 | if (stv2_current_tilemap.pattern_data_size ==1) |
| 3657 | 3653 | { |
| 3658 | 3654 | |
| 3659 | | data = stv_vdp2_vram[newbase + offs/2]; |
| 3655 | data = state->m_vdp2_vram[newbase + offs/2]; |
| 3660 | 3656 | data = (offs&1) ? (data & 0x0000ffff) : ((data & 0xffff0000) >> 16); |
| 3661 | 3657 | |
| 3662 | 3658 | /* Supplement Mode 12 bits, no flip */ |
| r11640 | r11641 | |
| 3682 | 3678 | else |
| 3683 | 3679 | { |
| 3684 | 3680 | |
| 3685 | | data = stv_vdp2_vram[newbase + offs]; |
| 3681 | data = state->m_vdp2_vram[newbase + offs]; |
| 3686 | 3682 | tilecode = (data & 0x00007fff); |
| 3687 | 3683 | pal = (data & 0x007f0000)>>16; |
| 3688 | 3684 | // specialc = (data & 0x10000000)>>28; |
| r11640 | r11641 | |
| 3753 | 3749 | if ( stv2_current_tilemap.colour_depth == 3 ) |
| 3754 | 3750 | { |
| 3755 | 3751 | /* normal */ |
| 3756 | | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3757 | | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3758 | | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3759 | | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3752 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(0+(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos, drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3753 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(1-(flipyx&1)+(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3754 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(2+(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3755 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode+(3-(flipyx&1)-(flipyx&2))*4,flipyx&1,flipyx&2,drawxpos+8,drawypos+8,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3760 | 3756 | |
| 3761 | 3757 | } |
| 3762 | 3758 | else if (stv2_current_tilemap.transparency == STV_TRANSPARENCY_ALPHA) |
| r11640 | r11641 | |
| 3782 | 3778 | { |
| 3783 | 3779 | if ( stv2_current_tilemap.colour_depth == 3 ) |
| 3784 | 3780 | { |
| 3785 | | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3781 | stv_vdp2_drawgfx_rgb555(bitmap,cliprect,machine,tilecode,flipyx&1,flipyx&2,drawxpos,drawypos,stv2_current_tilemap.transparency,stv2_current_tilemap.alpha); |
| 3786 | 3782 | } |
| 3787 | 3783 | else |
| 3788 | 3784 | { |
| r11640 | r11641 | |
| 3844 | 3840 | |
| 3845 | 3841 | #define STV_VDP2_READ_VERTICAL_LINESCROLL( _val, _address ) \ |
| 3846 | 3842 | { \ |
| 3847 | | _val = stv_vdp2_vram[ _address ]; \ |
| 3843 | _val = state->m_vdp2_vram[ _address ]; \ |
| 3848 | 3844 | _val &= 0x07ffff00; \ |
| 3849 | 3845 | if ( _val & 0x04000000 ) _val |= 0xf8000000; \ |
| 3850 | 3846 | } |
| r11640 | r11641 | |
| 3852 | 3848 | |
| 3853 | 3849 | static void stv_vdp2_check_tilemap_with_linescroll(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 3854 | 3850 | { |
| 3851 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 3855 | 3852 | rectangle mycliprect; |
| 3856 | 3853 | int cur_line = cliprect->min_y; |
| 3857 | 3854 | int address; |
| r11640 | r11641 | |
| 3903 | 3900 | } |
| 3904 | 3901 | else |
| 3905 | 3902 | { |
| 3906 | | prev_scroll_values[i] = stv_vdp2_vram[ (address / 4) + i ]; |
| 3903 | prev_scroll_values[i] = state->m_vdp2_vram[ (address / 4) + i ]; |
| 3907 | 3904 | } |
| 3908 | 3905 | } |
| 3909 | 3906 | |
| r11640 | r11641 | |
| 3928 | 3925 | } |
| 3929 | 3926 | else |
| 3930 | 3927 | { |
| 3931 | | scroll_values[i] = stv_vdp2_vram[ (address / 4) + i ]; |
| 3928 | scroll_values[i] = state->m_vdp2_vram[ (address / 4) + i ]; |
| 3932 | 3929 | } |
| 3933 | 3930 | } |
| 3934 | 3931 | |
| r11640 | r11641 | |
| 3985 | 3982 | { |
| 3986 | 3983 | /* the idea is here we check the tilemap capabilities / whats enabled and call an appropriate tilemap drawing routine, or |
| 3987 | 3984 | at the very list throw up a few errors if the tilemaps want to do something we don't support yet */ |
| 3985 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 3988 | 3986 | |
| 3989 | 3987 | int window_applied = 0; |
| 3990 | 3988 | rectangle mycliprect; |
| r11640 | r11641 | |
| 4001 | 3999 | return; |
| 4002 | 4000 | } |
| 4003 | 4001 | |
| 4004 | | window_applied = stv_vdp2_apply_window_on_layer(&mycliprect); |
| 4002 | window_applied = stv_vdp2_apply_window_on_layer(machine,&mycliprect); |
| 4005 | 4003 | |
| 4006 | 4004 | if (stv2_current_tilemap.bitmap_enable) // this layer is a bitmap |
| 4007 | 4005 | { |
| r11640 | r11641 | |
| 4030 | 4028 | } |
| 4031 | 4029 | |
| 4032 | 4030 | static void stv_vdp2_copy_roz_bitmap(bitmap_t *bitmap, |
| 4031 | running_machine &machine, |
| 4033 | 4032 | bitmap_t *roz_bitmap, |
| 4034 | 4033 | const rectangle *cliprect, |
| 4035 | 4034 | int iRP, |
| r11640 | r11641 | |
| 4038 | 4037 | int planerenderedsizex, |
| 4039 | 4038 | int planerenderedsizey) |
| 4040 | 4039 | { |
| 4040 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4041 | 4041 | INT32 xsp, ysp, xp, yp, dx, dy, x, y, xs, ys, dxs, dys; |
| 4042 | 4042 | INT32 vcnt, hcnt; |
| 4043 | 4043 | INT32 kx, ky; |
| r11640 | r11641 | |
| 4121 | 4121 | { |
| 4122 | 4122 | if ( STV_VDP2_CRKTE == 0 ) |
| 4123 | 4123 | { |
| 4124 | | coeff_table_base = stv_vdp2_vram; |
| 4124 | coeff_table_base = state->m_vdp2_vram; |
| 4125 | 4125 | } |
| 4126 | 4126 | else |
| 4127 | 4127 | { |
| 4128 | | coeff_table_base = stv_vdp2_cram; |
| 4128 | coeff_table_base = state->m_vdp2_cram; |
| 4129 | 4129 | } |
| 4130 | 4130 | if ( coeff_table_size == 0 ) |
| 4131 | 4131 | { |
| r11640 | r11641 | |
| 4283 | 4283 | if ( x & clipxmask || y & clipymask ) continue; |
| 4284 | 4284 | pix = *BITMAP_ADDR16(roz_bitmap, y & planerenderedsizey, x & planerenderedsizex); |
| 4285 | 4285 | if(stv2_current_tilemap.fade_control & 1) |
| 4286 | | stv_vdp2_compute_color_offset_RGB555_UINT16(&pix,stv2_current_tilemap.fade_control & 2); |
| 4286 | stv_vdp2_compute_color_offset_RGB555_UINT16(machine,&pix,stv2_current_tilemap.fade_control & 2); |
| 4287 | 4287 | switch( stv2_current_tilemap.transparency ) |
| 4288 | 4288 | { |
| 4289 | 4289 | case STV_TRANSPARENCY_PEN: |
| r11640 | r11641 | |
| 4375 | 4375 | |
| 4376 | 4376 | pix = *BITMAP_ADDR16(roz_bitmap, y & planerenderedsizey, x & planerenderedsizex); |
| 4377 | 4377 | if(stv2_current_tilemap.fade_control & 1) |
| 4378 | | stv_vdp2_compute_color_offset_RGB555_UINT16(&pix,stv2_current_tilemap.fade_control & 2); |
| 4378 | stv_vdp2_compute_color_offset_RGB555_UINT16(machine,&pix,stv2_current_tilemap.fade_control & 2); |
| 4379 | 4379 | switch( stv2_current_tilemap.transparency ) |
| 4380 | 4380 | { |
| 4381 | 4381 | case STV_TRANSPARENCY_PEN: |
| r11640 | r11641 | |
| 4398 | 4398 | |
| 4399 | 4399 | static void stv_vdp2_draw_NBG0(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4400 | 4400 | { |
| 4401 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4402 | |
| 4401 | 4403 | /* |
| 4402 | 4404 | Colours : 16, 256, 2048, 32768, 16770000 |
| 4403 | 4405 | Char Size : 1x1 cells, 2x2 cells |
| r11640 | r11641 | |
| 4467 | 4469 | stv2_current_tilemap.plane_size = STV_VDP2_N0PLSZ; |
| 4468 | 4470 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N0CAOS; |
| 4469 | 4471 | stv2_current_tilemap.fade_control = (STV_VDP2_N0COEN * 1) | (STV_VDP2_N0COSL * 2); |
| 4470 | | stv_vdp2_check_fade_control_for_layer(); |
| 4471 | | stv2_current_tilemap.window_control = (STV_VDP2_N0LOG * 0x01) | |
| 4472 | | (STV_VDP2_N0W0E * 0x02) | |
| 4473 | | (STV_VDP2_N0W1E * 0x04) | |
| 4474 | | (STV_VDP2_N0SWE * 0x08) | |
| 4475 | | (STV_VDP2_N0W0A * 0x10) | |
| 4476 | | (STV_VDP2_N0W1A * 0x20) | |
| 4477 | | (STV_VDP2_N0SWA * 0x40); |
| 4472 | stv_vdp2_check_fade_control_for_layer(machine); |
| 4473 | stv2_current_tilemap.window_control = (STV_VDP2_N0LOG << 0) | |
| 4474 | (STV_VDP2_N0W0E << 1) | |
| 4475 | (STV_VDP2_N0W1E << 2) | |
| 4476 | (STV_VDP2_N0SWE << 3) | |
| 4477 | (STV_VDP2_N0W0A << 4) | |
| 4478 | (STV_VDP2_N0W1A << 5) | |
| 4479 | (STV_VDP2_N0SWA << 6); |
| 4478 | 4480 | |
| 4479 | 4481 | stv2_current_tilemap.layer_name=0; |
| 4480 | 4482 | |
| 4481 | 4483 | if ( stv2_current_tilemap.enabled ) |
| 4482 | 4484 | { |
| 4483 | | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG0_PNMDR, STV_VDP2_CP_NBG0_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4485 | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG0_PNMDR, STV_VDP2_CP_NBG0_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4484 | 4486 | } |
| 4485 | 4487 | |
| 4486 | 4488 | stv_vdp2_check_tilemap(machine, bitmap, cliprect); |
| r11640 | r11641 | |
| 4488 | 4490 | |
| 4489 | 4491 | static void stv_vdp2_draw_NBG1(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4490 | 4492 | { |
| 4493 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4494 | |
| 4491 | 4495 | /* |
| 4492 | 4496 | Colours : 16, 256, 2048, 32768 |
| 4493 | 4497 | Char Size : 1x1 cells, 2x2 cells |
| r11640 | r11641 | |
| 4557 | 4561 | stv2_current_tilemap.plane_size = STV_VDP2_N1PLSZ; |
| 4558 | 4562 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N1CAOS; |
| 4559 | 4563 | stv2_current_tilemap.fade_control = (STV_VDP2_N1COEN * 1) | (STV_VDP2_N1COSL * 2); |
| 4560 | | stv_vdp2_check_fade_control_for_layer(); |
| 4561 | | stv2_current_tilemap.window_control = (STV_VDP2_N1LOG * 0x01) | |
| 4562 | | (STV_VDP2_N1W0E * 0x02) | |
| 4563 | | (STV_VDP2_N1W1E * 0x04) | |
| 4564 | | (STV_VDP2_N1SWE * 0x08) | |
| 4565 | | (STV_VDP2_N1W0A * 0x10) | |
| 4566 | | (STV_VDP2_N1W1A * 0x20) | |
| 4567 | | (STV_VDP2_N1SWA * 0x40); |
| 4564 | stv_vdp2_check_fade_control_for_layer(machine); |
| 4565 | stv2_current_tilemap.window_control = (STV_VDP2_N1LOG << 0) | |
| 4566 | (STV_VDP2_N1W0E << 1) | |
| 4567 | (STV_VDP2_N1W1E << 2) | |
| 4568 | (STV_VDP2_N1SWE << 3) | |
| 4569 | (STV_VDP2_N1W0A << 4) | |
| 4570 | (STV_VDP2_N1W1A << 5) | |
| 4571 | (STV_VDP2_N1SWA << 6); |
| 4568 | 4572 | |
| 4569 | 4573 | stv2_current_tilemap.layer_name=1; |
| 4570 | 4574 | |
| 4571 | 4575 | if ( stv2_current_tilemap.enabled ) |
| 4572 | 4576 | { |
| 4573 | | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG1_PNMDR, STV_VDP2_CP_NBG1_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4577 | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG1_PNMDR, STV_VDP2_CP_NBG1_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4574 | 4578 | } |
| 4575 | 4579 | |
| 4576 | 4580 | stv_vdp2_check_tilemap(machine, bitmap, cliprect); |
| r11640 | r11641 | |
| 4578 | 4582 | |
| 4579 | 4583 | static void stv_vdp2_draw_NBG2(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4580 | 4584 | { |
| 4585 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4586 | |
| 4581 | 4587 | /* |
| 4582 | 4588 | NBG2 is the first of the 2 more basic tilemaps, it has exactly the same capabilities as NBG3 |
| 4583 | 4589 | |
| r11640 | r11641 | |
| 4655 | 4661 | |
| 4656 | 4662 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N2CAOS; |
| 4657 | 4663 | stv2_current_tilemap.fade_control = (STV_VDP2_N2COEN * 1) | (STV_VDP2_N2COSL * 2); |
| 4658 | | stv_vdp2_check_fade_control_for_layer(); |
| 4659 | | stv2_current_tilemap.window_control = (STV_VDP2_N2LOG * 0x01) | |
| 4660 | | (STV_VDP2_N2W0E * 0x02) | |
| 4661 | | (STV_VDP2_N2W1E * 0x04) | |
| 4662 | | (STV_VDP2_N2SWE * 0x08) | |
| 4663 | | (STV_VDP2_N2W0A * 0x10) | |
| 4664 | | (STV_VDP2_N2W1A * 0x20) | |
| 4665 | | (STV_VDP2_N2SWA * 0x40); |
| 4664 | stv_vdp2_check_fade_control_for_layer(machine); |
| 4665 | stv2_current_tilemap.window_control = (STV_VDP2_N2LOG << 0) | |
| 4666 | (STV_VDP2_N2W0E << 1) | |
| 4667 | (STV_VDP2_N2W1E << 2) | |
| 4668 | (STV_VDP2_N2SWE << 3) | |
| 4669 | (STV_VDP2_N2W0A << 4) | |
| 4670 | (STV_VDP2_N2W1A << 5) | |
| 4671 | (STV_VDP2_N2SWA << 6); |
| 4666 | 4672 | |
| 4667 | 4673 | stv2_current_tilemap.layer_name=2; |
| 4668 | 4674 | |
| r11640 | r11641 | |
| 4670 | 4676 | |
| 4671 | 4677 | if ( stv2_current_tilemap.enabled ) |
| 4672 | 4678 | { |
| 4673 | | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG2_PNMDR, STV_VDP2_CP_NBG2_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4679 | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG2_PNMDR, STV_VDP2_CP_NBG2_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4674 | 4680 | } |
| 4675 | 4681 | |
| 4676 | 4682 | stv_vdp2_check_tilemap(machine, bitmap, cliprect); |
| r11640 | r11641 | |
| 4678 | 4684 | |
| 4679 | 4685 | static void stv_vdp2_draw_NBG3(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4680 | 4686 | { |
| 4687 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4681 | 4688 | /* |
| 4682 | 4689 | NBG3 is the second of the 2 more basic tilemaps, it has exactly the same capabilities as NBG2 |
| 4683 | 4690 | |
| r11640 | r11641 | |
| 4755 | 4762 | |
| 4756 | 4763 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_N3CAOS; |
| 4757 | 4764 | stv2_current_tilemap.fade_control = (STV_VDP2_N3COEN * 1) | (STV_VDP2_N3COSL * 2); |
| 4758 | | stv_vdp2_check_fade_control_for_layer(); |
| 4759 | | stv2_current_tilemap.window_control = (STV_VDP2_N3LOG * 0x01) | |
| 4760 | | (STV_VDP2_N3W0E * 0x02) | |
| 4761 | | (STV_VDP2_N3W1E * 0x04) | |
| 4762 | | (STV_VDP2_N3SWE * 0x08) | |
| 4763 | | (STV_VDP2_N3W0A * 0x10) | |
| 4764 | | (STV_VDP2_N3W1A * 0x20) | |
| 4765 | | (STV_VDP2_N3SWA * 0x40); |
| 4765 | stv_vdp2_check_fade_control_for_layer(machine); |
| 4766 | stv2_current_tilemap.window_control = (STV_VDP2_N3LOG << 0) | |
| 4767 | (STV_VDP2_N3W0E << 1) | |
| 4768 | (STV_VDP2_N3W1E << 2) | |
| 4769 | (STV_VDP2_N3SWE << 3) | |
| 4770 | (STV_VDP2_N3W0A << 4) | |
| 4771 | (STV_VDP2_N3W1A << 5) | |
| 4772 | (STV_VDP2_N3SWA << 6); |
| 4766 | 4773 | |
| 4767 | 4774 | stv2_current_tilemap.layer_name=3; |
| 4768 | 4775 | |
| r11640 | r11641 | |
| 4770 | 4777 | |
| 4771 | 4778 | if ( stv2_current_tilemap.enabled ) |
| 4772 | 4779 | { |
| 4773 | | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( STV_VDP2_CP_NBG3_PNMDR, STV_VDP2_CP_NBG3_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4780 | stv2_current_tilemap.enabled = stv_vdp2_check_vram_cycle_pattern_registers( machine, STV_VDP2_CP_NBG3_PNMDR, STV_VDP2_CP_NBG3_CPDR, stv2_current_tilemap.bitmap_enable ); |
| 4774 | 4781 | } |
| 4775 | 4782 | |
| 4776 | 4783 | stv_vdp2_check_tilemap(machine, bitmap, cliprect); |
| r11640 | r11641 | |
| 4779 | 4786 | |
| 4780 | 4787 | static void stv_vdp2_draw_rotation_screen(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int iRP) |
| 4781 | 4788 | { |
| 4789 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4782 | 4790 | rectangle roz_clip_rect, mycliprect; |
| 4783 | 4791 | int planesizex = 0, planesizey = 0; |
| 4784 | 4792 | int planerenderedsizex, planerenderedsizey; |
| r11640 | r11641 | |
| 4881 | 4889 | } |
| 4882 | 4890 | else |
| 4883 | 4891 | { |
| 4884 | | if ( stv_vdp2_roz_bitmap[iRP-1] == NULL ) |
| 4885 | | stv_vdp2_roz_bitmap[iRP-1] = auto_alloc(machine, bitmap_t(4096, 4096, machine.primary_screen->format())); |
| 4892 | if ( state->m_vdp2.roz_bitmap[iRP-1] == NULL ) |
| 4893 | state->m_vdp2.roz_bitmap[iRP-1] = auto_alloc(machine, bitmap_t(4096, 4096, machine.primary_screen->format())); |
| 4886 | 4894 | |
| 4887 | 4895 | roz_clip_rect.min_x = roz_clip_rect.min_y = 0; |
| 4888 | 4896 | if ( (iRP == 1 && STV_VDP2_RAOVR == 3) || |
| r11640 | r11641 | |
| 4919 | 4927 | if ( (stv_rbg_cache_data.is_cache_dirty & iRP) || |
| 4920 | 4928 | memcmp(&stv_rbg_cache_data.layer_data[iRP-1],&stv2_current_tilemap,sizeof(stv2_current_tilemap)) != 0 ) |
| 4921 | 4929 | { |
| 4922 | | bitmap_fill( stv_vdp2_roz_bitmap[iRP-1], &roz_clip_rect , get_black_pen(machine)); |
| 4923 | | stv_vdp2_check_tilemap(machine, stv_vdp2_roz_bitmap[iRP-1], &roz_clip_rect); |
| 4930 | bitmap_fill( state->m_vdp2.roz_bitmap[iRP-1], &roz_clip_rect , get_black_pen(machine)); |
| 4931 | stv_vdp2_check_tilemap(machine, state->m_vdp2.roz_bitmap[iRP-1], &roz_clip_rect); |
| 4924 | 4932 | // prepare cache data |
| 4925 | 4933 | stv_rbg_cache_data.watch_vdp2_vram_writes |= iRP; |
| 4926 | 4934 | stv_rbg_cache_data.is_cache_dirty &= ~iRP; |
| r11640 | r11641 | |
| 4949 | 4957 | if ( window_control ) |
| 4950 | 4958 | { |
| 4951 | 4959 | stv2_current_tilemap.window_control = window_control; |
| 4952 | | stv_vdp2_apply_window_on_layer(&mycliprect); |
| 4960 | stv_vdp2_apply_window_on_layer(machine,&mycliprect); |
| 4953 | 4961 | } |
| 4954 | 4962 | |
| 4955 | 4963 | stv2_current_tilemap.fade_control = fade_control; |
| 4956 | 4964 | |
| 4957 | 4965 | g_profiler.start(PROFILER_USER2); |
| 4958 | | stv_vdp2_copy_roz_bitmap(bitmap, stv_vdp2_roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey ); |
| 4966 | stv_vdp2_copy_roz_bitmap(bitmap, machine, state->m_vdp2.roz_bitmap[iRP-1], &mycliprect, iRP, planesizex, planesizey, planerenderedsizex, planerenderedsizey ); |
| 4959 | 4967 | g_profiler.stop(); |
| 4960 | 4968 | } |
| 4961 | 4969 | |
| r11640 | r11641 | |
| 4963 | 4971 | |
| 4964 | 4972 | static void stv_vdp2_draw_RBG0(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 4965 | 4973 | { |
| 4974 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 4966 | 4975 | /* |
| 4967 | 4976 | Colours : 16, 256, 2048, 32768, 16770000 |
| 4968 | 4977 | Char Size : 1x1 cells, 2x2 cells |
| r11640 | r11641 | |
| 5015 | 5024 | |
| 5016 | 5025 | stv2_current_tilemap.colour_ram_address_offset = STV_VDP2_R0CAOS; |
| 5017 | 5026 | stv2_current_tilemap.fade_control = (STV_VDP2_R0COEN * 1) | (STV_VDP2_R0COSL * 2); |
| 5018 | | stv_vdp2_check_fade_control_for_layer(); |
| 5019 | | stv2_current_tilemap.window_control = (STV_VDP2_R0LOG * 0x01) | |
| 5020 | | (STV_VDP2_R0W0E * 0x02) | |
| 5021 | | (STV_VDP2_R0W1E * 0x04) | |
| 5022 | | (STV_VDP2_R0SWE * 0x08) | |
| 5023 | | (STV_VDP2_R0W0A * 0x10) | |
| 5024 | | (STV_VDP2_R0W1A * 0x20) | |
| 5025 | | (STV_VDP2_R0SWA * 0x40); |
| 5027 | stv_vdp2_check_fade_control_for_layer(machine); |
| 5028 | stv2_current_tilemap.window_control = (STV_VDP2_R0LOG << 0) | |
| 5029 | (STV_VDP2_R0W0E << 1) | |
| 5030 | (STV_VDP2_R0W1E << 2) | |
| 5031 | (STV_VDP2_R0SWE << 3) | |
| 5032 | (STV_VDP2_R0W0A << 4) | |
| 5033 | (STV_VDP2_R0W1A << 5) | |
| 5034 | (STV_VDP2_R0SWA << 6); |
| 5026 | 5035 | |
| 5027 | 5036 | stv2_current_tilemap.scrollx = 0; |
| 5028 | 5037 | stv2_current_tilemap.scrolly = 0; |
| r11640 | r11641 | |
| 5038 | 5047 | /*Use 0x80 as a normal/rotate switch*/ |
| 5039 | 5048 | stv2_current_tilemap.layer_name=0x80; |
| 5040 | 5049 | |
| 5041 | | if ( !stv_vdp2_render_rbg0 ) return; |
| 5042 | 5050 | if ( !stv2_current_tilemap.enabled ) return; |
| 5043 | 5051 | |
| 5044 | 5052 | switch(STV_VDP2_RPMD) |
| r11640 | r11641 | |
| 5063 | 5071 | |
| 5064 | 5072 | static void stv_vdp2_draw_back(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect) |
| 5065 | 5073 | { |
| 5074 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5066 | 5075 | int xcnt,ycnt; |
| 5067 | | UINT8* gfxdata = stv_vdp2_gfx_decode; |
| 5076 | UINT8* gfxdata = state->m_vdp2.gfx_decode; |
| 5068 | 5077 | static UINT16 *destline; |
| 5069 | 5078 | int r,b,g; |
| 5070 | 5079 | UINT16 data; |
| r11640 | r11641 | |
| 5104 | 5113 | } |
| 5105 | 5114 | |
| 5106 | 5115 | |
| 5107 | | WRITE32_HANDLER ( stv_vdp2_vram_w ) |
| 5116 | WRITE32_HANDLER ( saturn_vdp2_vram_w ) |
| 5108 | 5117 | { |
| 5109 | | UINT8 *stv_vdp2_vram_decode = stv_vdp2_gfx_decode; |
| 5118 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5119 | UINT8* gfxdata = state->m_vdp2.gfx_decode; |
| 5110 | 5120 | |
| 5111 | | COMBINE_DATA(&stv_vdp2_vram[offset]); |
| 5121 | COMBINE_DATA(&state->m_vdp2_vram[offset]); |
| 5112 | 5122 | |
| 5113 | | data = stv_vdp2_vram[offset]; |
| 5123 | data = state->m_vdp2_vram[offset]; |
| 5114 | 5124 | /* put in gfx region for easy decoding */ |
| 5115 | | stv_vdp2_vram_decode[offset*4+0] = (data & 0xff000000) >> 24; |
| 5116 | | stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16; |
| 5117 | | stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8; |
| 5118 | | stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0; |
| 5125 | gfxdata[offset*4+0] = (data & 0xff000000) >> 24; |
| 5126 | gfxdata[offset*4+1] = (data & 0x00ff0000) >> 16; |
| 5127 | gfxdata[offset*4+2] = (data & 0x0000ff00) >> 8; |
| 5128 | gfxdata[offset*4+3] = (data & 0x000000ff) >> 0; |
| 5119 | 5129 | |
| 5120 | 5130 | gfx_element_mark_dirty(space->machine().gfx[0], offset/8); |
| 5121 | 5131 | gfx_element_mark_dirty(space->machine().gfx[1], offset/8); |
| r11640 | r11641 | |
| 5160 | 5170 | |
| 5161 | 5171 | } |
| 5162 | 5172 | |
| 5163 | | READ32_HANDLER ( stv_vdp2_vram_r ) |
| 5173 | READ32_HANDLER ( saturn_vdp2_regs_r ) |
| 5164 | 5174 | { |
| 5165 | | return stv_vdp2_vram[offset]; |
| 5175 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5176 | // if (offset!=1) if(LOG_VDP2) logerror ("VDP2: Read from Registers, Offset %04x\n",offset); |
| 5177 | |
| 5178 | switch(offset) |
| 5179 | { |
| 5180 | case 0x4/4: |
| 5181 | { |
| 5182 | int stv_hblank,stv_vblank,stv_odd; |
| 5183 | /*Screen Status Register*/ |
| 5184 | stv_vblank = stv_get_vblank(space->machine()); |
| 5185 | stv_hblank = get_hblank(space->machine()); |
| 5186 | stv_odd = get_odd_bit(space->machine()); |
| 5187 | |
| 5188 | /*VBLANK HBLANK ODD PAL */ |
| 5189 | state->m_vdp2_regs[offset] = (stv_vblank<<19) | (stv_hblank<<18) | (stv_odd << 17) | (0 << 16); |
| 5190 | break; |
| 5191 | } |
| 5192 | case 0x8/4: |
| 5193 | /*H/V Counter Register*/ |
| 5194 | { |
| 5195 | static UINT16 h_count,v_count; |
| 5196 | /* TODO: handle various h/v settings. */ |
| 5197 | h_count = space->machine().primary_screen->hpos() & 0x3ff; |
| 5198 | v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); |
| 5199 | state->m_vdp2_regs[offset] = (h_count<<16)|(v_count); |
| 5200 | if(LOG_VDP2) logerror("CPU %s PC(%08x) = VDP2: H/V counter read : %08x\n", space->device().tag(), cpu_get_pc(&space->device()),state->m_vdp2_regs[offset]); |
| 5201 | break; |
| 5202 | } |
| 5203 | } |
| 5204 | return state->m_vdp2_regs[offset]; |
| 5166 | 5205 | } |
| 5167 | 5206 | |
| 5168 | | WRITE32_HANDLER ( stv_vdp2_cram_w ) |
| 5207 | READ32_HANDLER ( saturn_vdp2_cram_r ) |
| 5169 | 5208 | { |
| 5209 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5210 | |
| 5211 | return state->m_vdp2_cram[offset]; |
| 5212 | } |
| 5213 | |
| 5214 | |
| 5215 | READ32_HANDLER ( saturn_vdp2_vram_r ) |
| 5216 | { |
| 5217 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5218 | |
| 5219 | return state->m_vdp2_vram[offset]; |
| 5220 | } |
| 5221 | |
| 5222 | WRITE32_HANDLER ( saturn_vdp2_cram_w ) |
| 5223 | { |
| 5224 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5170 | 5225 | int r,g,b; |
| 5171 | | COMBINE_DATA(&stv_vdp2_cram[offset]); |
| 5226 | COMBINE_DATA(&state->m_vdp2_cram[offset]); |
| 5172 | 5227 | |
| 5173 | 5228 | // popmessage("%01x\n",STV_VDP2_CRMD); |
| 5174 | 5229 | |
| r11640 | r11641 | |
| 5178 | 5233 | case 2: |
| 5179 | 5234 | case 3: |
| 5180 | 5235 | { |
| 5181 | | b = ((stv_vdp2_cram[offset] & 0x00ff0000) >> 16); |
| 5182 | | g = ((stv_vdp2_cram[offset] & 0x0000ff00) >> 8); |
| 5183 | | r = ((stv_vdp2_cram[offset] & 0x000000ff) >> 0); |
| 5236 | b = ((state->m_vdp2_cram[offset] & 0x00ff0000) >> 16); |
| 5237 | g = ((state->m_vdp2_cram[offset] & 0x0000ff00) >> 8); |
| 5238 | r = ((state->m_vdp2_cram[offset] & 0x000000ff) >> 0); |
| 5184 | 5239 | palette_set_color(space->machine(),offset,MAKE_RGB(r,g,b)); |
| 5185 | 5240 | } |
| 5186 | 5241 | break; |
| 5187 | 5242 | /*Mode 0*/ |
| 5188 | 5243 | case 0: |
| 5189 | | { |
| 5190 | | offset &= 0x3ff; |
| 5191 | | |
| 5192 | | b = ((stv_vdp2_cram[offset] & 0x00007c00) >> 10); |
| 5193 | | g = ((stv_vdp2_cram[offset] & 0x000003e0) >> 5); |
| 5194 | | r = ((stv_vdp2_cram[offset] & 0x0000001f) >> 0); |
| 5195 | | palette_set_color_rgb(space->machine(),(offset*2)+1,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5196 | | b = ((stv_vdp2_cram[offset] & 0x7c000000) >> 26); |
| 5197 | | g = ((stv_vdp2_cram[offset] & 0x03e00000) >> 21); |
| 5198 | | r = ((stv_vdp2_cram[offset] & 0x001f0000) >> 16); |
| 5199 | | palette_set_color_rgb(space->machine(),offset*2,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5200 | | } |
| 5201 | | break; |
| 5202 | | /*Mode 1*/ |
| 5203 | 5244 | case 1: |
| 5204 | 5245 | { |
| 5205 | | offset &= 0x7ff; |
| 5246 | offset &= (0x3ff | ((offset & 1) << 10)); |
| 5206 | 5247 | |
| 5207 | | b = ((stv_vdp2_cram[offset] & 0x00007c00) >> 10); |
| 5208 | | g = ((stv_vdp2_cram[offset] & 0x000003e0) >> 5); |
| 5209 | | r = ((stv_vdp2_cram[offset] & 0x0000001f) >> 0); |
| 5248 | b = ((state->m_vdp2_cram[offset] & 0x00007c00) >> 10); |
| 5249 | g = ((state->m_vdp2_cram[offset] & 0x000003e0) >> 5); |
| 5250 | r = ((state->m_vdp2_cram[offset] & 0x0000001f) >> 0); |
| 5210 | 5251 | palette_set_color_rgb(space->machine(),(offset*2)+1,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5211 | | b = ((stv_vdp2_cram[offset] & 0x7c000000) >> 26); |
| 5212 | | g = ((stv_vdp2_cram[offset] & 0x03e00000) >> 21); |
| 5213 | | r = ((stv_vdp2_cram[offset] & 0x001f0000) >> 16); |
| 5252 | b = ((state->m_vdp2_cram[offset] & 0x7c000000) >> 26); |
| 5253 | g = ((state->m_vdp2_cram[offset] & 0x03e00000) >> 21); |
| 5254 | r = ((state->m_vdp2_cram[offset] & 0x001f0000) >> 16); |
| 5214 | 5255 | palette_set_color_rgb(space->machine(),offset*2,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5215 | 5256 | } |
| 5216 | 5257 | break; |
| r11640 | r11641 | |
| 5219 | 5260 | |
| 5220 | 5261 | static void refresh_palette_data(running_machine &machine) |
| 5221 | 5262 | { |
| 5263 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5222 | 5264 | int r,g,b; |
| 5223 | 5265 | int c_i; |
| 5224 | 5266 | |
| r11640 | r11641 | |
| 5230 | 5272 | case 2: |
| 5231 | 5273 | case 3: |
| 5232 | 5274 | { |
| 5233 | | b = ((stv_vdp2_cram[c_i] & 0x00ff0000) >> 16); |
| 5234 | | g = ((stv_vdp2_cram[c_i] & 0x0000ff00) >> 8); |
| 5235 | | r = ((stv_vdp2_cram[c_i] & 0x000000ff) >> 0); |
| 5275 | b = ((state->m_vdp2_cram[c_i] & 0x00ff0000) >> 16); |
| 5276 | g = ((state->m_vdp2_cram[c_i] & 0x0000ff00) >> 8); |
| 5277 | r = ((state->m_vdp2_cram[c_i] & 0x000000ff) >> 0); |
| 5236 | 5278 | palette_set_color(machine,c_i,MAKE_RGB(r,g,b)); |
| 5237 | 5279 | } |
| 5238 | 5280 | break; |
| 5239 | 5281 | /*Mode 0*/ |
| 5240 | 5282 | case 0: |
| 5283 | case 1: |
| 5241 | 5284 | { |
| 5242 | 5285 | //c_i &= 0x3ff; |
| 5243 | 5286 | |
| 5244 | | b = ((stv_vdp2_cram[c_i] & 0x00007c00) >> 10); |
| 5245 | | g = ((stv_vdp2_cram[c_i] & 0x000003e0) >> 5); |
| 5246 | | r = ((stv_vdp2_cram[c_i] & 0x0000001f) >> 0); |
| 5287 | b = ((state->m_vdp2_cram[c_i] & 0x00007c00) >> 10); |
| 5288 | g = ((state->m_vdp2_cram[c_i] & 0x000003e0) >> 5); |
| 5289 | r = ((state->m_vdp2_cram[c_i] & 0x0000001f) >> 0); |
| 5247 | 5290 | palette_set_color_rgb(machine,(c_i*2)+1,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5248 | | b = ((stv_vdp2_cram[c_i] & 0x7c000000) >> 26); |
| 5249 | | g = ((stv_vdp2_cram[c_i] & 0x03e00000) >> 21); |
| 5250 | | r = ((stv_vdp2_cram[c_i] & 0x001f0000) >> 16); |
| 5291 | b = ((state->m_vdp2_cram[c_i] & 0x7c000000) >> 26); |
| 5292 | g = ((state->m_vdp2_cram[c_i] & 0x03e00000) >> 21); |
| 5293 | r = ((state->m_vdp2_cram[c_i] & 0x001f0000) >> 16); |
| 5251 | 5294 | palette_set_color_rgb(machine,c_i*2,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5252 | 5295 | } |
| 5253 | 5296 | break; |
| 5254 | | /*Mode 1*/ |
| 5255 | | case 1: |
| 5256 | | { |
| 5257 | | //c_i &= 0x7ff; |
| 5258 | | |
| 5259 | | b = ((stv_vdp2_cram[c_i] & 0x00007c00) >> 10); |
| 5260 | | g = ((stv_vdp2_cram[c_i] & 0x000003e0) >> 5); |
| 5261 | | r = ((stv_vdp2_cram[c_i] & 0x0000001f) >> 0); |
| 5262 | | palette_set_color_rgb(machine,(c_i*2)+1,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5263 | | b = ((stv_vdp2_cram[c_i] & 0x7c000000) >> 26); |
| 5264 | | g = ((stv_vdp2_cram[c_i] & 0x03e00000) >> 21); |
| 5265 | | r = ((stv_vdp2_cram[c_i] & 0x001f0000) >> 16); |
| 5266 | | palette_set_color_rgb(machine,c_i*2,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5267 | | } |
| 5268 | | break; |
| 5269 | 5297 | } |
| 5270 | 5298 | } |
| 5271 | 5299 | } |
| 5272 | 5300 | |
| 5273 | | READ32_HANDLER ( stv_vdp2_cram_r ) |
| 5301 | WRITE32_HANDLER ( saturn_vdp2_regs_w ) |
| 5274 | 5302 | { |
| 5275 | | return stv_vdp2_cram[offset]; |
| 5276 | | } |
| 5277 | | |
| 5278 | | WRITE32_HANDLER ( stv_vdp2_regs_w ) |
| 5279 | | { |
| 5303 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 5280 | 5304 | static UINT8 old_crmd; |
| 5281 | 5305 | static UINT16 old_tvmd; |
| 5282 | | COMBINE_DATA(&stv_vdp2_regs[offset]); |
| 5306 | COMBINE_DATA(&state->m_vdp2_regs[offset]); |
| 5283 | 5307 | |
| 5284 | 5308 | if(old_crmd != STV_VDP2_CRMD) |
| 5285 | 5309 | { |
| r11640 | r11641 | |
| 5309 | 5333 | /* the following is a complete guess-work */ |
| 5310 | 5334 | static int get_hblank_duration(running_machine &machine) |
| 5311 | 5335 | { |
| 5336 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5312 | 5337 | switch( STV_VDP2_HRES & 3 ) |
| 5313 | 5338 | { |
| 5314 | 5339 | case 0: return 80; //400-320 |
| r11640 | r11641 | |
| 5335 | 5360 | /*some vblank lines measurements (according to Charles MacDonald)*/ |
| 5336 | 5361 | static int get_vblank_duration(running_machine &machine) |
| 5337 | 5362 | { |
| 5363 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5364 | |
| 5338 | 5365 | if(STV_VDP2_HRES & 4) |
| 5339 | | { |
| 5340 | | switch(STV_VDP2_HRES & 1) |
| 5341 | | { |
| 5342 | | case 0: return 45; //31kHz Monitor |
| 5343 | | case 1: return 82; //Hi-Vision Monitor |
| 5344 | | } |
| 5345 | | } |
| 5366 | return (STV_VDP2_HRES & 1) ? 480+82 : 480+45; //Hi-Vision / 31kHz Monitor |
| 5346 | 5367 | |
| 5347 | | switch(STV_VDP2_VRES & 3) |
| 5348 | | { |
| 5349 | | case 0: return 40; //264-224 |
| 5350 | | case 1: return 24; //264-240 |
| 5351 | | case 2: return 8; //264-256 |
| 5352 | | case 3: return 8; //264-256 |
| 5353 | | } |
| 5368 | if((STV_VDP2_LSMD & 3) == 3) |
| 5369 | return 264*2; |
| 5354 | 5370 | |
| 5355 | | return 0; |
| 5371 | return 264; |
| 5356 | 5372 | } |
| 5357 | 5373 | |
| 5358 | 5374 | static UINT8 get_odd_bit(running_machine &machine) |
| 5359 | 5375 | { |
| 5376 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5360 | 5377 | static int cur_v; |
| 5361 | 5378 | cur_v = machine.primary_screen->vpos(); |
| 5362 | 5379 | |
| r11640 | r11641 | |
| 5369 | 5386 | return 0; |
| 5370 | 5387 | } |
| 5371 | 5388 | |
| 5372 | | READ32_HANDLER ( stv_vdp2_regs_r ) |
| 5373 | | { |
| 5374 | | // if (offset!=1) if(LOG_VDP2) logerror ("VDP2: Read from Registers, Offset %04x\n",offset); |
| 5375 | | |
| 5376 | | switch(offset) |
| 5377 | | { |
| 5378 | | case 0x4/4: |
| 5379 | | { |
| 5380 | | /*Screen Status Register*/ |
| 5381 | | stv_vblank = stv_get_vblank(space->machine()); |
| 5382 | | stv_hblank = get_hblank(space->machine()); |
| 5383 | | stv_odd = get_odd_bit(space->machine()); |
| 5384 | | |
| 5385 | | /*VBLANK HBLANK ODD PAL */ |
| 5386 | | stv_vdp2_regs[offset] = (stv_vblank<<19) | (stv_hblank<<18) | (stv_odd << 17) | (0 << 16); |
| 5387 | | break; |
| 5388 | | } |
| 5389 | | case 0x8/4: |
| 5390 | | /*H/V Counter Register*/ |
| 5391 | | { |
| 5392 | | static UINT16 h_count,v_count; |
| 5393 | | /* TODO: handle various h/v settings. */ |
| 5394 | | h_count = space->machine().primary_screen->hpos() & 0x3ff; |
| 5395 | | v_count = space->machine().primary_screen->vpos() & (STV_VDP2_LSMD == 3 ? 0x7ff : 0x3ff); |
| 5396 | | stv_vdp2_regs[offset] = (h_count<<16)|(v_count); |
| 5397 | | if(LOG_VDP2) logerror("CPU %s PC(%08x) = VDP2: H/V counter read : %08x\n", space->device().tag(), cpu_get_pc(&space->device()),stv_vdp2_regs[offset]); |
| 5398 | | break; |
| 5399 | | } |
| 5400 | | } |
| 5401 | | return stv_vdp2_regs[offset]; |
| 5402 | | } |
| 5403 | | |
| 5404 | 5389 | static void stv_vdp2_state_save_postload(running_machine &machine) |
| 5405 | 5390 | { |
| 5406 | | UINT8 *stv_vdp2_vram_decode = stv_vdp2_gfx_decode; |
| 5391 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5392 | UINT8 *gfxdata = state->m_vdp2.gfx_decode; |
| 5407 | 5393 | int offset; |
| 5408 | 5394 | UINT32 data; |
| 5409 | 5395 | |
| 5410 | 5396 | for ( offset = 0; offset < 0x100000/4; offset++ ) |
| 5411 | 5397 | { |
| 5412 | | data = stv_vdp2_vram[offset]; |
| 5398 | data = state->m_vdp2_vram[offset]; |
| 5413 | 5399 | /* put in gfx region for easy decoding */ |
| 5414 | | stv_vdp2_vram_decode[offset*4+0] = (data & 0xff000000) >> 24; |
| 5415 | | stv_vdp2_vram_decode[offset*4+1] = (data & 0x00ff0000) >> 16; |
| 5416 | | stv_vdp2_vram_decode[offset*4+2] = (data & 0x0000ff00) >> 8; |
| 5417 | | stv_vdp2_vram_decode[offset*4+3] = (data & 0x000000ff) >> 0; |
| 5400 | gfxdata[offset*4+0] = (data & 0xff000000) >> 24; |
| 5401 | gfxdata[offset*4+1] = (data & 0x00ff0000) >> 16; |
| 5402 | gfxdata[offset*4+2] = (data & 0x0000ff00) >> 8; |
| 5403 | gfxdata[offset*4+3] = (data & 0x000000ff) >> 0; |
| 5418 | 5404 | |
| 5419 | 5405 | gfx_element_mark_dirty(machine.gfx[0], offset/8); |
| 5420 | 5406 | gfx_element_mark_dirty(machine.gfx[1], offset/8); |
| r11640 | r11641 | |
| 5439 | 5425 | |
| 5440 | 5426 | static void stv_vdp2_exit (running_machine &machine) |
| 5441 | 5427 | { |
| 5442 | | stv_vdp2_roz_bitmap[0] = stv_vdp2_roz_bitmap[1] = NULL; |
| 5428 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5429 | state->m_vdp2.roz_bitmap[0] = state->m_vdp2.roz_bitmap[1] = NULL; |
| 5443 | 5430 | } |
| 5444 | 5431 | |
| 5445 | 5432 | static int stv_vdp2_start (running_machine &machine) |
| 5446 | 5433 | { |
| 5434 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5447 | 5435 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stv_vdp2_exit), &machine)); |
| 5448 | 5436 | |
| 5449 | | stv_vdp2_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 ); |
| 5450 | | stv_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart. |
| 5451 | | stv_vdp2_cram = auto_alloc_array_clear(machine, UINT32, 0x080000/4 ); |
| 5452 | | stv_vdp2_gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 ); |
| 5437 | state->m_vdp2_regs = auto_alloc_array_clear(machine, UINT32, 0x040000/4 ); |
| 5438 | state->m_vdp2_vram = auto_alloc_array_clear(machine, UINT32, 0x100000/4 ); // actually we only need half of it since we don't emulate extra 4mbit ram cart. |
| 5439 | state->m_vdp2_cram = auto_alloc_array_clear(machine, UINT32, 0x080000/4 ); |
| 5440 | state->m_vdp2.gfx_decode = auto_alloc_array(machine, UINT8, 0x100000 ); |
| 5453 | 5441 | |
| 5454 | | stv_vdp2_render_rbg0 = 1; |
| 5455 | 5442 | // machine.gfx[0]->color_granularity=4; |
| 5456 | 5443 | // machine.gfx[1]->color_granularity=4; |
| 5457 | 5444 | |
| r11640 | r11641 | |
| 5459 | 5446 | stv_rbg_cache_data.is_cache_dirty = 3; |
| 5460 | 5447 | memset( &stv_vdp2_layer_data_placement, 0, sizeof(stv_vdp2_layer_data_placement)); |
| 5461 | 5448 | |
| 5462 | | state_save_register_global_pointer(machine, stv_vdp2_regs, 0x040000/4); |
| 5463 | | state_save_register_global_pointer(machine, stv_vdp2_vram, 0x100000/4); |
| 5464 | | state_save_register_global_pointer(machine, stv_vdp2_cram, 0x080000/4); |
| 5449 | state_save_register_global_pointer(machine, state->m_vdp2_regs, 0x040000/4); |
| 5450 | state_save_register_global_pointer(machine, state->m_vdp2_vram, 0x100000/4); |
| 5451 | state_save_register_global_pointer(machine, state->m_vdp2_cram, 0x080000/4); |
| 5465 | 5452 | machine.save().register_postload(save_prepost_delegate(FUNC(stv_vdp2_state_save_postload), &machine)); |
| 5466 | 5453 | |
| 5467 | 5454 | return 0; |
| r11640 | r11641 | |
| 5470 | 5457 | /* maybe we should move this to video/stv.c */ |
| 5471 | 5458 | VIDEO_START( stv_vdp2 ) |
| 5472 | 5459 | { |
| 5473 | | stv_vdp2_roz_bitmap[0] = stv_vdp2_roz_bitmap[1] = NULL; |
| 5460 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5461 | state->m_vdp2.roz_bitmap[0] = state->m_vdp2.roz_bitmap[1] = NULL; |
| 5474 | 5462 | stv_vdp2_start(machine); |
| 5475 | 5463 | stv_vdp1_start(machine); |
| 5476 | 5464 | debug.l_en = 0xff; |
| 5477 | 5465 | debug.error = 0xffffffff; |
| 5478 | 5466 | debug.roz = 0; |
| 5479 | | gfx_element_set_source(machine.gfx[0], stv_vdp2_gfx_decode); |
| 5480 | | gfx_element_set_source(machine.gfx[1], stv_vdp2_gfx_decode); |
| 5481 | | gfx_element_set_source(machine.gfx[2], stv_vdp2_gfx_decode); |
| 5482 | | gfx_element_set_source(machine.gfx[3], stv_vdp2_gfx_decode); |
| 5483 | | gfx_element_set_source(machine.gfx[4], stv_vdp1_gfx_decode); |
| 5484 | | gfx_element_set_source(machine.gfx[5], stv_vdp1_gfx_decode); |
| 5485 | | gfx_element_set_source(machine.gfx[6], stv_vdp1_gfx_decode); |
| 5486 | | gfx_element_set_source(machine.gfx[7], stv_vdp1_gfx_decode); |
| 5467 | gfx_element_set_source(machine.gfx[0], state->m_vdp2.gfx_decode); |
| 5468 | gfx_element_set_source(machine.gfx[1], state->m_vdp2.gfx_decode); |
| 5469 | gfx_element_set_source(machine.gfx[2], state->m_vdp2.gfx_decode); |
| 5470 | gfx_element_set_source(machine.gfx[3], state->m_vdp2.gfx_decode); |
| 5471 | gfx_element_set_source(machine.gfx[4], state->m_vdp1.gfx_decode); |
| 5472 | gfx_element_set_source(machine.gfx[5], state->m_vdp1.gfx_decode); |
| 5473 | gfx_element_set_source(machine.gfx[6], state->m_vdp1.gfx_decode); |
| 5474 | gfx_element_set_source(machine.gfx[7], state->m_vdp1.gfx_decode); |
| 5487 | 5475 | } |
| 5488 | 5476 | |
| 5489 | | static void stv_vdp2_dynamic_res_change(running_machine &machine) |
| 5477 | void stv_vdp2_dynamic_res_change(running_machine &machine) |
| 5490 | 5478 | { |
| 5491 | | static UINT8 old_vres = 0,old_hres = 0; |
| 5479 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5480 | int horz_res,vert_res; |
| 5492 | 5481 | |
| 5493 | 5482 | switch( STV_VDP2_VRES & 3 ) |
| 5494 | 5483 | { |
| r11640 | r11641 | |
| 5517 | 5506 | case 6: horz_res = 640; vert_res = 480; break; |
| 5518 | 5507 | case 7: horz_res = 704; vert_res = 480; break; |
| 5519 | 5508 | } |
| 5520 | | // horz_res+=1; |
| 5521 | | // vert_res*=2; |
| 5522 | | if(old_vres != vert_res || old_hres != horz_res) |
| 5509 | |
| 5523 | 5510 | { |
| 5524 | 5511 | int vblank_period,hblank_period; |
| 5525 | 5512 | rectangle visarea = machine.primary_screen->visible_area(); |
| r11640 | r11641 | |
| 5530 | 5517 | |
| 5531 | 5518 | vblank_period = get_vblank_duration(machine); |
| 5532 | 5519 | hblank_period = get_hblank_duration(machine); |
| 5533 | | // popmessage("%d",vblank_period); |
| 5534 | | // hblank_period = get_hblank_duration(machine.primary_screen); |
| 5535 | | machine.primary_screen->configure((horz_res+hblank_period), (vert_res+vblank_period), visarea, machine.primary_screen->frame_period().attoseconds ); |
| 5536 | 5520 | |
| 5537 | | old_vres = vert_res; |
| 5538 | | old_hres = horz_res; |
| 5521 | //printf("%d %d %d %d\n",horz_res,vert_res,horz_res+hblank_period,vblank_period); |
| 5522 | |
| 5523 | machine.primary_screen->configure((horz_res+hblank_period), (vblank_period), visarea, machine.primary_screen->frame_period().attoseconds ); |
| 5539 | 5524 | } |
| 5540 | 5525 | // machine.primary_screen->set_visible_area(0*8, horz_res-1,0*8, vert_res-1); |
| 5541 | 5526 | //if(LOG_VDP2) popmessage("%04d %04d",horz_res-1,vert-1); |
| r11640 | r11641 | |
| 5545 | 5530 | /*TODO: Optimize this...*/ |
| 5546 | 5531 | static void stv_vdp2_fade_effects(running_machine &machine) |
| 5547 | 5532 | { |
| 5533 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5548 | 5534 | /* |
| 5549 | 5535 | Note:We have to use temporary storages because palette_get_color must use |
| 5550 | 5536 | variables setted with unsigned int8 |
| r11640 | r11641 | |
| 5624 | 5610 | (0 = OR,1 = AND) |
| 5625 | 5611 | ******************************************************************************************/ |
| 5626 | 5612 | |
| 5627 | | static void stv_vdp2_get_window0_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y) |
| 5613 | static void stv_vdp2_get_window0_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y) |
| 5628 | 5614 | { |
| 5615 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5616 | |
| 5629 | 5617 | /*W0*/ |
| 5630 | 5618 | switch(STV_VDP2_LSMD & 3) |
| 5631 | 5619 | { |
| r11640 | r11641 | |
| 5669 | 5657 | } |
| 5670 | 5658 | } |
| 5671 | 5659 | |
| 5672 | | static void stv_vdp2_get_window1_coordinates(UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y) |
| 5660 | static void stv_vdp2_get_window1_coordinates(running_machine &machine,UINT16 *s_x, UINT16 *e_x, UINT16 *s_y, UINT16 *e_y) |
| 5673 | 5661 | { |
| 5662 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5663 | |
| 5674 | 5664 | /*W1*/ |
| 5675 | 5665 | switch(STV_VDP2_LSMD & 3) |
| 5676 | 5666 | { |
| r11640 | r11641 | |
| 5715 | 5705 | |
| 5716 | 5706 | } |
| 5717 | 5707 | |
| 5718 | | static int stv_vdp2_window_process(int x,int y) |
| 5708 | static int stv_vdp2_window_process(running_machine &machine,int x,int y) |
| 5719 | 5709 | { |
| 5720 | 5710 | UINT16 s_x=0,e_x=0,s_y=0,e_y=0; |
| 5721 | 5711 | |
| 5722 | 5712 | if ((stv2_current_tilemap.window_control & 6) == 0) |
| 5723 | 5713 | return 0; |
| 5724 | 5714 | |
| 5725 | | stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y); |
| 5715 | stv_vdp2_get_window0_coordinates(machine,&s_x, &e_x, &s_y, &e_y); |
| 5726 | 5716 | |
| 5727 | 5717 | if(stv2_current_tilemap.window_control & 2) |
| 5728 | 5718 | { |
| r11640 | r11641 | |
| 5752 | 5742 | } |
| 5753 | 5743 | } |
| 5754 | 5744 | |
| 5755 | | stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y); |
| 5745 | stv_vdp2_get_window1_coordinates(machine,&s_x, &e_x, &s_y, &e_y); |
| 5756 | 5746 | |
| 5757 | 5747 | if(stv2_current_tilemap.window_control & 4) |
| 5758 | 5748 | { |
| r11640 | r11641 | |
| 5785 | 5775 | // return 1; |
| 5786 | 5776 | } |
| 5787 | 5777 | |
| 5788 | | static int stv_vdp2_apply_window_on_layer(rectangle *cliprect) |
| 5778 | static int stv_vdp2_apply_window_on_layer(running_machine &machine,rectangle *cliprect) |
| 5789 | 5779 | { |
| 5780 | //saturn_state *state = machine.driver_data<saturn_state>(); |
| 5790 | 5781 | UINT16 s_x=0,e_x=0,s_y=0,e_y=0; |
| 5791 | 5782 | |
| 5792 | 5783 | if ( stv2_current_tilemap.window_control == 0x12 ) |
| 5793 | 5784 | { |
| 5794 | 5785 | /* w0, transparent outside supported */ |
| 5795 | | stv_vdp2_get_window0_coordinates(&s_x, &e_x, &s_y, &e_y); |
| 5786 | stv_vdp2_get_window0_coordinates(machine,&s_x, &e_x, &s_y, &e_y); |
| 5796 | 5787 | |
| 5797 | 5788 | if ( s_x > cliprect->min_x ) cliprect->min_x = s_x; |
| 5798 | 5789 | if ( e_x < cliprect->max_x ) cliprect->max_x = e_x; |
| r11640 | r11641 | |
| 5804 | 5795 | else if ( stv2_current_tilemap.window_control == 0x24 ) |
| 5805 | 5796 | { |
| 5806 | 5797 | /* w1, transparent outside supported */ |
| 5807 | | stv_vdp2_get_window1_coordinates(&s_x, &e_x, &s_y, &e_y); |
| 5798 | stv_vdp2_get_window1_coordinates(machine,&s_x, &e_x, &s_y, &e_y); |
| 5808 | 5799 | |
| 5809 | 5800 | if ( s_x > cliprect->min_x ) cliprect->min_x = s_x; |
| 5810 | 5801 | if ( e_x < cliprect->max_x ) cliprect->max_x = e_x; |
| r11640 | r11641 | |
| 5824 | 5815 | static int stv_sprite_priorities_usage_valid; |
| 5825 | 5816 | static UINT8 stv_sprite_priorities_in_fb_line[512][8]; |
| 5826 | 5817 | |
| 5818 | #define STV_VDP1_TVMR ((state->m_vdp1_regs[0x000/4] >> 16)&0x0000ffff) |
| 5819 | #define STV_VDP1_TVM ((STV_VDP1_TVMR & 0x0007) >> 0) |
| 5827 | 5820 | |
| 5828 | 5821 | static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 pri) |
| 5829 | 5822 | { |
| 5823 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 5830 | 5824 | int x,y,r,g,b; |
| 5831 | 5825 | int i; |
| 5832 | 5826 | UINT16 pix; |
| r11640 | r11641 | |
| 5917 | 5911 | } |
| 5918 | 5912 | |
| 5919 | 5913 | /* framebuffer interlace */ |
| 5920 | | if ( (STV_VDP2_LSMD == 2 || STV_VDP2_LSMD == 3) && stv_framebuffer_double_interlace == 0 ) |
| 5914 | if ( (STV_VDP2_LSMD == 2 || STV_VDP2_LSMD == 3) && state->m_vdp1.framebuffer_double_interlace == 0 ) |
| 5921 | 5915 | interlace_framebuffer = 1; |
| 5922 | 5916 | else |
| 5923 | 5917 | interlace_framebuffer = 0; |
| 5924 | 5918 | |
| 5925 | 5919 | /*Guess:Some games needs that the horizontal sprite size to be doubled |
| 5926 | 5920 | (TODO: understand the proper settings,it might not work like this)*/ |
| 5927 | | if(STV_VDP2_LSMD == 3 && /*((STV_VDP2_HRES & 3) != 3) &&*/ (!(stv_framebuffer_mode & 1))) |
| 5921 | if(STV_VDP1_TVM == 0 && STV_VDP2_HRES & 2) // astrass & findlove |
| 5928 | 5922 | double_x = 1; |
| 5929 | 5923 | else |
| 5930 | 5924 | double_x = 0; |
| r11640 | r11641 | |
| 5941 | 5935 | mycliprect.max_x = cliprect->max_x; |
| 5942 | 5936 | mycliprect.min_y = cliprect->min_y; |
| 5943 | 5937 | mycliprect.max_y = cliprect->max_y; |
| 5944 | | stv_vdp2_apply_window_on_layer(&mycliprect); |
| 5938 | stv_vdp2_apply_window_on_layer(machine,&mycliprect); |
| 5945 | 5939 | |
| 5946 | 5940 | if (interlace_framebuffer == 0 && double_x == 0 ) |
| 5947 | 5941 | { |
| r11640 | r11641 | |
| 5953 | 5947 | if (stv_sprite_priorities_in_fb_line[y][pri] == 0) |
| 5954 | 5948 | continue; |
| 5955 | 5949 | |
| 5956 | | framebuffer_line = stv_framebuffer_display_lines[y]; |
| 5950 | framebuffer_line = state->m_vdp1.framebuffer_display_lines[y]; |
| 5957 | 5951 | bitmap_line = BITMAP_ADDR16(bitmap, y, 0); |
| 5958 | 5952 | |
| 5959 | 5953 | for ( x = mycliprect.min_x; x <= mycliprect.max_x; x++ ) |
| r11640 | r11641 | |
| 5972 | 5966 | r = (pix & 0x1f); |
| 5973 | 5967 | if ( color_offset_pal ) |
| 5974 | 5968 | { |
| 5975 | | stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL ); |
| 5969 | stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL ); |
| 5976 | 5970 | } |
| 5977 | 5971 | bitmap_line[x] = b | g << 5 | r << 10; |
| 5978 | 5972 | } |
| r11640 | r11641 | |
| 6025 | 6019 | if (stv_sprite_priorities_in_fb_line[y][pri] == 0) |
| 6026 | 6020 | continue; |
| 6027 | 6021 | |
| 6028 | | framebuffer_line = stv_framebuffer_display_lines[y]; |
| 6022 | framebuffer_line = state->m_vdp1.framebuffer_display_lines[y]; |
| 6029 | 6023 | bitmap_line = BITMAP_ADDR16(bitmap, y, 0); |
| 6030 | 6024 | |
| 6031 | 6025 | for ( x = mycliprect.min_x; x <= mycliprect.max_x; x++ ) |
| r11640 | r11641 | |
| 6045 | 6039 | r = (pix & 0x1f); |
| 6046 | 6040 | if ( color_offset_pal ) |
| 6047 | 6041 | { |
| 6048 | | stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL ); |
| 6042 | stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL ); |
| 6049 | 6043 | } |
| 6050 | 6044 | ccr = sprite_ccr[0]; |
| 6051 | 6045 | if ( STV_VDP2_CCMD ) |
| r11640 | r11641 | |
| 6127 | 6121 | if (stv_sprite_priorities_in_fb_line[y][pri] == 0) |
| 6128 | 6122 | continue; |
| 6129 | 6123 | |
| 6130 | | framebuffer_line = stv_framebuffer_display_lines[y]; |
| 6124 | framebuffer_line = state->m_vdp1.framebuffer_display_lines[y]; |
| 6131 | 6125 | if ( interlace_framebuffer == 0 ) |
| 6132 | 6126 | { |
| 6133 | 6127 | bitmap_line = BITMAP_ADDR16(bitmap, y, 0); |
| r11640 | r11641 | |
| 6154 | 6148 | r = (pix & 0x1f); |
| 6155 | 6149 | if ( color_offset_pal ) |
| 6156 | 6150 | { |
| 6157 | | stv_vdp2_compute_color_offset_RGB555( &r, &g, &b, STV_VDP2_SPCOSL ); |
| 6151 | stv_vdp2_compute_color_offset_RGB555( machine, &r, &g, &b, STV_VDP2_SPCOSL ); |
| 6158 | 6152 | } |
| 6159 | 6153 | if ( alpha_enabled == 0 ) |
| 6160 | 6154 | { |
| r11640 | r11641 | |
| 6311 | 6305 | |
| 6312 | 6306 | SCREEN_UPDATE( stv_vdp2 ) |
| 6313 | 6307 | { |
| 6308 | saturn_state *state = screen->machine().driver_data<saturn_state>(); |
| 6314 | 6309 | static UINT8 pri; |
| 6315 | 6310 | video_update_vdp1(screen->machine()); |
| 6316 | 6311 | |
src/mame/drivers/saturn.c
| r11640 | r11641 | |
| 1 | | /* |
| 2 | | Sega Saturn & Sega ST-V (Sega Titan Video) |
| 1 | /************************************************************************************************** |
| 3 | 2 | |
| 4 | | Driver by David Haywood,Angelo Salese,Olivier Galibert & Mariusz Wojcieszek |
| 5 | | SCSP driver provided by R.Belmont,based on ElSemi's SCSP sound chip emulator |
| 6 | | CD Block driver provided by ANY,based on sthief original emulator |
| 7 | | Many thanks to Guru,Fabien & Runik for the help given. |
| 3 | Sega Saturn & Sega ST-V (Sega Titan Video) HW (c) 1994 Sega |
| 8 | 4 | |
| 5 | Driver by David Haywood, Angelo Salese, Olivier Galibert & Mariusz Wojcieszek |
| 6 | SCSP driver provided by R.Belmont, based on ElSemi's SCSP sound chip emulator |
| 7 | CD Block driver provided by ANY, based on sthief original emulator |
| 8 | Many thanks to Guru, Fabien & Runik for the help given. |
| 9 | |
| 10 | =================================================================================================== |
| 11 | |
| 12 | Notes: |
| 13 | -To enter into an Advanced Test Mode,keep pressed the Test Button (F2) on the start-up. |
| 14 | -Memo: Some tests done on the original & working PCB,to be implemented: |
| 15 | -The AD-Stick returns 0x00 or a similar value. |
| 16 | -The Ports E,F & G must return 0xff |
| 17 | -The regular BIOS tests (Memory Test) changes his background color at some point to |
| 18 | several gradients of red,green and blue.Current implementation remains black.I dunno |
| 19 | if this is a framebuffer write or a funky transparency issue (i.e TRANSPARENT_NONE |
| 20 | should instead show the back layer). |
| 21 | -RBG0 rotating can be checked on the "Advanced Test" menu thru the VDP1/VDP2 check. |
| 22 | It rotates clockwise IIRC.Also the ST-V logo when the game is in Multi mode rotates too. |
| 23 | -The MIDI communication check fails even on a ST-V board,somebody needs to check if there |
| 24 | is a MIDI port on the real PCB... |
| 25 | |
| 26 | TODO: |
| 27 | (Main issues) |
| 28 | - decap the SH-1, used for CD block (needed especially for Sega Saturn) |
| 29 | - IRQs: some games have some issues with timing accurate IRQs,check/fix all of them. |
| 30 | - The Cart-Dev mode hangs even with the -dev bios,I would like to see what it does on the real HW. |
| 31 | - IC13 games on the bios dev doesn't even load the cartridge / crashes the emulation at start-up, |
| 32 | rom rearrange needed? |
| 33 | - finish the DSP core. |
| 34 | - Add the RS232c interface (serial port),needed by fhboxers. |
| 35 | - (PCB owners) check if the clocks documented in the manuals are really right for ST-V. |
| 36 | - We need to check every game if can be completed or there are any hanging/crash/protection |
| 37 | issues on them. |
| 38 | - Clean-ups and split the various chips(SCU,SMPC) into their respective files (in progress). |
| 39 | - Video emulation bugs: check stvvdp2.c file. |
| 40 | - Reimplement the idle skip if possible. |
| 41 | - clean up the I/Os, by using per-game specific mapped ports and rewrite it by using 16-bit trampolines |
| 42 | - Properly emulate the protection chips, used by several games (check stvprot.c for more info) |
| 43 | |
| 44 | (per-game issues) |
| 45 | - stress: accesses the Sound Memory Expansion Area (0x05a00000-0x05afffff), unknown purpose; |
| 46 | - smleague / finlarch: it randomly hangs / crashes,it works if you use a ridiculous MCFG_INTERLEAVE number,might need strict |
| 47 | SH-2 synching. |
| 48 | - suikoenb/shanhigw + others: why do we get 2 credits on startup? Cause might be by a communication with the M68k |
| 49 | - bakubaku: sound part is largely incomplete,caused by a tight loop at location PC=1048 of the sound cpu part. |
| 50 | - myfairld: Apparently this game gives a black screen (either test mode and in-game mode),but let it wait for about |
| 51 | 10 seconds and the game will load everything. This is because of a hellishly slow m68k sub-routine located at 54c2. |
| 52 | Likely to not be a bug but an in-game design issue. |
| 53 | - myfairld: Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact |
| 54 | joystick panel is mapped with input_port(10) instead of input_port(2),so for now use |
| 55 | the mahjong panel instead. |
| 56 | - danchih: hanafuda panel doesn't work. |
| 57 | - findlove: controls doesn't work? Playing with the debugger at location $6063720 it makes it get furter,but controls |
| 58 | still doesn't work,missing irq? |
| 59 | - batmanfr: Missing sound,caused by an extra ADSP chip which is on the cart.The CPU is a |
| 60 | ADSP-2181,and it's the same used by NBA Jam Extreme (ZN game). |
| 61 | - vfremix: when you play Akira, there is a problem with third match: game doesn't upload all textures |
| 62 | and tiles and doesn't enable display, although gameplay is normal - wait a while to get back |
| 63 | to title screen after losing a match |
| 64 | |
| 65 | =================================================================================================== |
| 66 | |
| 9 | 67 | Hardware overview: |
| 10 | 68 | ------------------ |
| 11 | 69 | -two SH-2 CPUs,in a master/slave configuration.The master cpu is used to |
| r11640 | r11641 | |
| 37 | 95 | -shadow effects; |
| 38 | 96 | -global rgb brightness control,separate for every plane; |
| 39 | 97 | |
| 40 | | Memory map: |
| 41 | | ----------- |
| 98 | ****************************************************************************************************/ |
| 42 | 99 | |
| 43 | | 0x00000000, 0x0007ffff BIOS ROM |
| 44 | | 0x00080000, 0x000fffff Unused |
| 45 | | 0x00100000, 0x0010007f SMPC |
| 46 | | 0x00100080, 0x0017ffff Unused |
| 47 | | 0x00180000, 0x0018ffff Back Up Ram |
| 48 | | 0x00190000, 0x001fffff Unused |
| 49 | | 0x00200000, 0x002fffff Work Ram-L |
| 50 | | 0x00300000, 0x00ffffff Unused |
| 51 | | 0x01000000, 0x01000003 MINIT |
| 52 | | 0x01000004, 0x017fffff Unused |
| 53 | | 0x01800000, 0x01800003 SINIT |
| 54 | | 0x01800004, 0x01ffffff Unused |
| 55 | | 0x02000000, 0x03ffffff A-BUS CS0 |
| 56 | | 0x04000000, 0x04ffffff A-BUS CS1 |
| 57 | | 0x05000000, 0x057fffff A-BUS DUMMY |
| 58 | | 0x05800000, 0x058fffff A-BUS CS2 |
| 59 | | 0x05900000, 0x059fffff Unused |
| 60 | | 0x05a00000, 0x05b00ee3 Sound Region |
| 61 | | 0x05b00ee4, 0x05bfffff Unused |
| 62 | | 0x05c00000, 0x05cbffff VDP 1 |
| 63 | | 0x05cc0000, 0x05cfffff Unused |
| 64 | | 0x05d00000, 0x05d00017 VDP 1 regs |
| 65 | | 0x05d00018, 0x05dfffff Unused |
| 66 | | 0x05e00000, 0x05e7ffff VDP2 |
| 67 | | 0x05e80000, 0x05efffff VDP2 Extra RAM,accessible thru the VRAMSZ register |
| 68 | | 0x05f00000, 0x05f00fff VDP2 Color RAM |
| 69 | | 0x05f01000, 0x05f7ffff Unused |
| 70 | | 0x05f80000 0x05f8011f VDP2 regs |
| 71 | | 0x05f80120, 0x05fdffff Unused |
| 72 | | 0x05fe0000, 0x05fe00cf SCU regs |
| 73 | | 0x05fe00d0, 0x05ffffff Unused |
| 74 | | 0x06000000, 0x060fffff Work Ram-H |
| 75 | | 0x06100000, 0x07ffffff Unused |
| 76 | | |
| 77 | | *the unused locations aren't known if they are really unused or not,needs verification,most |
| 78 | | of them seem just mirrors of the previous valid memory allocated. |
| 79 | | |
| 80 | | ToDo / Notes: |
| 81 | | ------------- |
| 82 | | |
| 83 | | -To enter into an Advanced Test Mode,keep pressed the Test Button (F2) on the start-up. |
| 84 | | |
| 85 | | (Main issues) |
| 86 | | -IRQs: some games have some issues with timing accurate IRQs,check/fix all of them. |
| 87 | | -Clean-ups and split the various chips(SCU,SMPC)into their respective files. |
| 88 | | -CD block:complete it. |
| 89 | | -The Cart-Dev mode hangs even with the -dev bios,I would like to see what it does on the real HW. |
| 90 | | -IC13 games on the bios dev doesn't even load the cartridge / crashes the emulation at start-up, |
| 91 | | rom rearrange needed? |
| 92 | | -finish the DSP core. |
| 93 | | -Add the RS232c interface (serial port),needed by fhboxers. |
| 94 | | -(PCB owners) check if the clocks documented in the manuals are really right for ST-V. |
| 95 | | -SCSP to master irq: see if there is a sound cpu mask bit. |
| 96 | | -Does the device_set_clock really works?Investigate. |
| 97 | | -We need to check every game if can be completed or there are any hanging/crash/protection |
| 98 | | issues on them. |
| 99 | | -Memo: Some tests done on the original & working PCB,to be implemented: |
| 100 | | -The AD-Stick returns 0x00 or a similar value. |
| 101 | | -The Ports E,F & G must return 0xff |
| 102 | | -The regular BIOS tests (Memory Test) changes his background color at some point to |
| 103 | | several gradients of red,green and blue.Current implementation remains black.I dunno |
| 104 | | if this is a framebuffer write or a funky transparency issue (i.e TRANSPARENT_NONE |
| 105 | | should instead show the back layer). |
| 106 | | -RBG0 rotating can be checked on the "Advanced Test" menu thru the VDP1/VDP2 check. |
| 107 | | It rotates clockwise IIRC.Also the ST-V logo when the game is in Multi mode rotates too. |
| 108 | | -The MIDI communication check fails even on a ST-V board,somebody needs to check if there |
| 109 | | is a MIDI port on the real PCB... |
| 110 | | -All games except shienryu: add default eeprom if necessary (1P/3P games for example). |
| 111 | | -Video emulation bugs: check stvvdp2.c file. |
| 112 | | |
| 113 | | (per-game issues) |
| 114 | | -stress: accesses the Sound Memory Expansion Area (0x05a00000-0x05afffff), unknown purpose; |
| 115 | | -smleague / finlarch: it randomly hangs / crashes,it works if you use a ridiculous MCFG_INTERLEAVE number,might need strict |
| 116 | | SH-2 synching. |
| 117 | | -various: find idle skip if possible. |
| 118 | | -suikoenb/shanhigw + others: why do we get 2 credits on startup? Cause might be by a communication with the M68k |
| 119 | | -colmns97/puyosun/mausuke/cotton2/cottonbm: interrupt issues? we can't check the SCU mask |
| 120 | | on SMPC or controls fail |
| 121 | | -mausuke/bakubaku/grdforce: need to sort out transparency on the colour mapped sprites |
| 122 | | -bakubaku: sound part is largely incomplete,caused by a tight loop at location PC=1048 of the sound cpu part. |
| 123 | | -myfairld: Apparently this game gives a black screen (either test mode and in-game mode),but let it wait for about |
| 124 | | 10 seconds and the game will load everything.This is because of a hellishly slow m68k sub-routine located at 54c2. |
| 125 | | Likely to not be a bug but an in-game design issue. |
| 126 | | -myfairld: Micronet programmers had the "great" idea to *not* use the ST-V input standards,infact |
| 127 | | joystick panel is mapped with input_port(10) instead of input_port(2),so for now use |
| 128 | | the mahjong panel instead. |
| 129 | | -danchih: hanafuda panel doesn't work. |
| 130 | | -decathlt: Is currently using a strange protection DMA abus control,and it uses some sort of RLE |
| 131 | | compression/encryption that serves as a gfxdecode. |
| 132 | | -findlove: controls doesn't work? Playing with the debugger at location $6063720 it makes it get furter,but controls |
| 133 | | still doesn't work,missing irq? |
| 134 | | -batmanfr: Missing sound,caused by an extra ADSP chip which is on the cart.The CPU is a |
| 135 | | ADSP-2181,and it's the same used by NBA Jam Extreme (ZN game). |
| 136 | | -vfremix: when you play Akira, there is a problem with third match: game doesn't upload all textures |
| 137 | | and tiles and doesn't enable display, although gameplay is normal - wait a while to get back |
| 138 | | to title screen after losing a match |
| 139 | | -sokyugrt: gameplay seems to be not smooth, timing? |
| 140 | | -seabass: crashes in stvcd.c - there is no CD and we report than we have one, and game tries |
| 141 | | to read something, however it doesn't do it after nvram is deleted? |
| 142 | | -Protection issues: |
| 143 | | \-ffreveng: boot vectors; |
| 144 | | \-decathlt: in-game graphics; |
| 145 | | \-elandore: human / dragons textures; |
| 146 | | \-twcup98: tecmo logo / sprite movements; |
| 147 | | \-astrass: text layer (kludged for now); |
| 148 | | |
| 149 | | |
| 150 | | */ |
| 151 | | |
| 152 | 100 | #include "emu.h" |
| 153 | 101 | #include "cpu/m68000/m68000.h" |
| 154 | 102 | #include "machine/eeprom.h" |
| r11640 | r11641 | |
| 163 | 111 | #include "coreutil.h" |
| 164 | 112 | |
| 165 | 113 | |
| 166 | | |
| 114 | /* TODO: do this in a verboselog style */ |
| 167 | 115 | #define LOG_CDB 0 |
| 168 | 116 | #define LOG_SMPC 0 |
| 169 | 117 | #define LOG_SCU 0 |
| r11640 | r11641 | |
| 181 | 129 | |
| 182 | 130 | //static void stv_dump_ram(void); |
| 183 | 131 | |
| 184 | | static UINT32* ioga; |
| 185 | | static UINT16* scsp_regs; |
| 186 | | static int saturn_region; |
| 187 | | |
| 188 | 132 | /*VDP2 stuff*/ |
| 189 | 133 | /*SMPC stuff*/ |
| 190 | 134 | /*SCU stuff*/ |
| r11640 | r11641 | |
| 213 | 157 | static void scu_dma_indirect(address_space *space, UINT8 dma_ch); /*DMA level 0 indirect transfer function*/ |
| 214 | 158 | |
| 215 | 159 | |
| 216 | | int minit_boost,sinit_boost; |
| 217 | | attotime minit_boost_timeslice, sinit_boost_timeslice; |
| 218 | 160 | |
| 219 | 161 | //static int scanline; |
| 220 | 162 | |
| 221 | | static emu_timer *stv_rtc_timer; |
| 222 | | |
| 223 | | |
| 224 | 163 | /*A-Bus IRQ checks,where they could be located these?*/ |
| 225 | 164 | #define ABUSIRQ(_irq_,_vector_) \ |
| 226 | 165 | { cputag_set_input_line_and_vector(device->machine(), "maincpu", _irq_, HOLD_LINE , _vector_); } |
| r11640 | r11641 | |
| 401 | 340 | 7e |
| 402 | 341 | 7f -w EXLE2/1 |
| 403 | 342 | */ |
| 404 | | static UINT8 IOSEL1; |
| 405 | | static UINT8 IOSEL2; |
| 406 | | static UINT8 EXLE1; |
| 407 | | static UINT8 EXLE2; |
| 408 | | static UINT8 PDR1; |
| 409 | | static UINT8 PDR2; |
| 410 | | static int intback_stage = 0, smpcSR, pmode; |
| 411 | | static UINT8 SMEM[4]; |
| 412 | 343 | |
| 413 | | #define SH2_DIRECT_MODE_PORT_1 IOSEL1 = 1 |
| 414 | | #define SH2_DIRECT_MODE_PORT_2 IOSEL2 = 1 |
| 415 | | #define SMPC_CONTROL_MODE_PORT_1 IOSEL1 = 0 |
| 416 | | #define SMPC_CONTROL_MODE_PORT_2 IOSEL2 = 0 |
| 417 | | |
| 418 | | |
| 419 | | |
| 420 | | static void system_reset(address_space *space) |
| 421 | | { |
| 422 | | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 423 | | |
| 424 | | /*Only backup ram and SMPC ram are retained after that this command is issued.*/ |
| 425 | | memset(state->m_scu_regs ,0x00,0x000100); |
| 426 | | memset(scsp_regs ,0x00,0x001000); |
| 427 | | memset(state->m_sound_ram ,0x00,0x080000); |
| 428 | | memset(state->m_workram_h,0x00,0x100000); |
| 429 | | memset(state->m_workram_l,0x00,0x100000); |
| 430 | | memset(stv_vdp2_regs,0x00,0x040000); |
| 431 | | memset(stv_vdp2_vram,0x00,0x100000); |
| 432 | | memset(stv_vdp2_cram,0x00,0x080000); |
| 433 | | //vdp1 |
| 434 | | //A-Bus |
| 435 | | /*Order is surely wrong but whatever...*/ |
| 436 | | } |
| 437 | | |
| 438 | 344 | static READ8_HANDLER( stv_SMPC_r8 ) |
| 439 | 345 | { |
| 440 | 346 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| r11640 | r11641 | |
| 454 | 360 | // if (offset == 0x33) //country code |
| 455 | 361 | // return_data = input_port_read(machine, "FAKE"); |
| 456 | 362 | |
| 457 | | if (cpu_get_pc(&space->device())==0x060020E6) return_data = 0x10;//??? |
| 458 | | |
| 459 | 363 | //if(LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, return_data); |
| 460 | 364 | |
| 461 | 365 | |
| r11640 | r11641 | |
| 486 | 390 | machine.scheduler().timer_set(attotime::zero, FUNC(stv_bankswitch_state), gameno); |
| 487 | 391 | } |
| 488 | 392 | |
| 393 | static void smpc_master_on(running_machine &machine) |
| 394 | { |
| 395 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 396 | |
| 397 | device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, CLEAR_LINE); |
| 398 | } |
| 399 | |
| 400 | static void smpc_slave_enable(running_machine &machine,UINT8 cmd) |
| 401 | { |
| 402 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 403 | |
| 404 | device_set_input_line(state->m_slave, INPUT_LINE_RESET, cmd ? ASSERT_LINE : CLEAR_LINE); |
| 405 | } |
| 406 | |
| 407 | static void smpc_sound_enable(running_machine &machine,UINT8 cmd) |
| 408 | { |
| 409 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 410 | |
| 411 | device_set_input_line(state->m_audiocpu, INPUT_LINE_RESET, cmd ? ASSERT_LINE : CLEAR_LINE); |
| 412 | state->m_en_68k = cmd ^ 1; |
| 413 | } |
| 414 | |
| 415 | static void smpc_system_reset(running_machine &machine) |
| 416 | { |
| 417 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 418 | |
| 419 | /*Only backup ram and SMPC ram are retained after that this command is issued.*/ |
| 420 | memset(state->m_scu_regs ,0x00,0x000100); |
| 421 | memset(state->m_scsp_regs,0x00,0x001000); |
| 422 | memset(state->m_sound_ram,0x00,0x080000); |
| 423 | memset(state->m_workram_h,0x00,0x100000); |
| 424 | memset(state->m_workram_l,0x00,0x100000); |
| 425 | memset(state->m_vdp2_regs,0x00,0x040000); |
| 426 | memset(state->m_vdp2_vram,0x00,0x100000); |
| 427 | memset(state->m_vdp2_cram,0x00,0x080000); |
| 428 | memset(state->m_vdp1_vram,0x00,0x100000); |
| 429 | //A-Bus |
| 430 | |
| 431 | device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, PULSE_LINE); |
| 432 | } |
| 433 | |
| 434 | static void smpc_change_clock(running_machine &machine, UINT8 cmd) |
| 435 | { |
| 436 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 437 | UINT32 xtal; |
| 438 | |
| 439 | xtal = cmd ? MASTER_CLOCK_320 : MASTER_CLOCK_352; |
| 440 | |
| 441 | machine.device("maincpu")->set_unscaled_clock(xtal/2); |
| 442 | machine.device("slave")->set_unscaled_clock(xtal/2); |
| 443 | machine.device("audiocpu")->set_unscaled_clock(xtal/5); |
| 444 | |
| 445 | state->m_vdp2.pixel_clock = cmd; |
| 446 | stv_vdp2_dynamic_res_change(machine); |
| 447 | |
| 448 | device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 449 | } |
| 450 | |
| 451 | static void smpc_intbackhelper(running_machine &machine) |
| 452 | { |
| 453 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 454 | int pad; |
| 455 | static const char *const padnames[] = { "JOY1", "JOY2" }; |
| 456 | |
| 457 | if (state->m_smpc.intback_stage == 1) |
| 458 | { |
| 459 | state->m_smpc.intback_stage++; |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | pad = input_port_read(machine, padnames[state->m_smpc.intback_stage-2]); |
| 464 | |
| 465 | // if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2); |
| 466 | state->m_smpc_ram[33] = 0xf1; // no tap, direct connect |
| 467 | state->m_smpc_ram[35] = 0x02; // saturn pad |
| 468 | state->m_smpc_ram[37] = pad>>8; |
| 469 | state->m_smpc_ram[39] = pad & 0xff; |
| 470 | |
| 471 | if (state->m_smpc.intback_stage == 3) |
| 472 | { |
| 473 | state->m_smpc.smpcSR = (0x80 | state->m_smpc.pmode); // pad 2, no more data, echo back pad mode set by intback |
| 474 | } |
| 475 | else |
| 476 | { |
| 477 | state->m_smpc.smpcSR = (0xe0 | state->m_smpc.pmode); // pad 1, more data, echo back pad mode set by intback |
| 478 | } |
| 479 | |
| 480 | state->m_smpc.intback_stage++; |
| 481 | } |
| 482 | |
| 483 | /* sys_type 1 == STV, 0 == SATURN */ |
| 484 | static void smpc_intback(running_machine &machine, UINT8 sys_type,system_time systime) |
| 485 | { |
| 486 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 487 | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 488 | |
| 489 | if(sys_type == 0) |
| 490 | { |
| 491 | state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100); |
| 492 | state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100); |
| 493 | state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1); |
| 494 | state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday); |
| 495 | state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour); |
| 496 | state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute); |
| 497 | state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second); |
| 498 | } |
| 499 | |
| 500 | state->m_smpc_ram[0x31]=0x00; //? |
| 501 | |
| 502 | //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE"); |
| 503 | |
| 504 | state->m_smpc_ram[0x35]=0x00; |
| 505 | state->m_smpc_ram[0x37]=0x00; |
| 506 | |
| 507 | state->m_smpc_ram[0x39]=sys_type ? 0xff : state->m_smpc.SMEM[0]; |
| 508 | state->m_smpc_ram[0x3b]=sys_type ? 0xff : state->m_smpc.SMEM[1]; |
| 509 | state->m_smpc_ram[0x3d]=sys_type ? 0xff : state->m_smpc.SMEM[2]; |
| 510 | state->m_smpc_ram[0x3f]=sys_type ? 0xff : state->m_smpc.SMEM[3]; |
| 511 | |
| 512 | state->m_smpc_ram[0x41]=0xff; |
| 513 | state->m_smpc_ram[0x43]=0xff; |
| 514 | state->m_smpc_ram[0x45]=0xff; |
| 515 | state->m_smpc_ram[0x47]=0xff; |
| 516 | state->m_smpc_ram[0x49]=0xff; |
| 517 | state->m_smpc_ram[0x4b]=0xff; |
| 518 | state->m_smpc_ram[0x4d]=0xff; |
| 519 | state->m_smpc_ram[0x4f]=0xff; |
| 520 | state->m_smpc_ram[0x51]=0xff; |
| 521 | state->m_smpc_ram[0x53]=0xff; |
| 522 | state->m_smpc_ram[0x55]=0xff; |
| 523 | state->m_smpc_ram[0x57]=0xff; |
| 524 | state->m_smpc_ram[0x59]=0xff; |
| 525 | state->m_smpc_ram[0x5b]=0xff; |
| 526 | state->m_smpc_ram[0x5d]=0xff; |
| 527 | |
| 528 | if(sys_type == 0) |
| 529 | { |
| 530 | state->m_smpc.smpcSR = 0x60; // peripheral data ready, no reset, etc. |
| 531 | state->m_smpc.pmode = state->m_smpc_ram[1]>>4; |
| 532 | |
| 533 | state->m_smpc.intback_stage = 1; |
| 534 | |
| 535 | smpc_intbackhelper(machine); |
| 536 | } |
| 537 | |
| 538 | // /*This is for RTC,cartridge code and similar stuff...*/ |
| 539 | //if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 540 | device_set_input_line_and_vector(state->m_maincpu, 8, (stv_irq.smpc) ? HOLD_LINE : CLEAR_LINE, 0x47); |
| 541 | } |
| 542 | |
| 543 | static void smpc_rtc_write(running_machine &machine) |
| 544 | { |
| 545 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 546 | state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d]; |
| 547 | state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b]; |
| 548 | state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09]; |
| 549 | state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07]; |
| 550 | state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05]; |
| 551 | state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03]; |
| 552 | state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01]; |
| 553 | } |
| 554 | |
| 555 | static void smpc_memory_setting(running_machine &machine) |
| 556 | { |
| 557 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 558 | state->m_smpc.SMEM[0] = state->m_smpc_ram[1]; |
| 559 | state->m_smpc.SMEM[1] = state->m_smpc_ram[3]; |
| 560 | state->m_smpc.SMEM[2] = state->m_smpc_ram[5]; |
| 561 | state->m_smpc.SMEM[3] = state->m_smpc_ram[7]; |
| 562 | } |
| 563 | |
| 564 | static void smpc_nmi_req(running_machine &machine) |
| 565 | { |
| 566 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 567 | |
| 568 | /*NMI is unconditionally requested?*/ |
| 569 | device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE); |
| 570 | } |
| 571 | |
| 572 | static void smpc_nmi_set(running_machine &machine,UINT8 cmd) |
| 573 | { |
| 574 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 575 | |
| 576 | state->m_NMI_reset = cmd ^ 1; |
| 577 | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 578 | } |
| 579 | |
| 489 | 580 | static WRITE8_HANDLER( stv_SMPC_w8 ) |
| 490 | 581 | { |
| 491 | 582 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| r11640 | r11641 | |
| 497 | 588 | |
| 498 | 589 | if(offset == 0x75) |
| 499 | 590 | { |
| 591 | /* |
| 592 | -xx- ---- PDR1 |
| 593 | ---x ---- EEPROM write bit |
| 594 | ---- x--- EEPROM CLOCK line |
| 595 | ---- -x-- EEPROM CS line |
| 596 | ---- --xx A-Bus bank bits |
| 597 | */ |
| 500 | 598 | eeprom_device *eeprom = space->machine().device<eeprom_device>("eeprom"); |
| 501 | 599 | eeprom->set_clock_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE); |
| 502 | 600 | eeprom->write_bit(data & 0x10); |
| r11640 | r11641 | |
| 505 | 603 | |
| 506 | 604 | stv_select_game(space->machine(), state->m_stv_multi_bank); |
| 507 | 605 | |
| 508 | | // if (data & 0x01) |
| 509 | | // if(LOG_SMPC) logerror("bit 0 active\n"); |
| 510 | | // if (data & 0x02) |
| 511 | | // if(LOG_SMPC) logerror("bit 1 active\n"); |
| 512 | | // if (data & 0x10) |
| 513 | | //if(LOG_SMPC) logerror("bit 4 active\n");//LOT |
| 514 | | //if(LOG_SMPC) logerror("SMPC: ram [0x75] = %02x\n",state->m_smpc_ram[0x75]); |
| 515 | | PDR1 = (data & 0x60); |
| 606 | state->m_smpc.PDR1 = (data & 0x60); |
| 516 | 607 | } |
| 517 | 608 | |
| 518 | 609 | if(offset == 0x77) |
| 519 | 610 | { |
| 520 | 611 | /* |
| 521 | | ACTIVE LOW |
| 522 | | bit 4(0x10) - Enable Sound System |
| 612 | -xx- ---- PDR2 |
| 613 | ---x ---- Enable Sound System (ACTIVE LOW) |
| 523 | 614 | */ |
| 524 | 615 | //popmessage("PDR2 = %02x",state->m_smpc_ram[0x77]); |
| 525 | 616 | |
| r11640 | r11641 | |
| 528 | 619 | state->m_en_68k = ((state->m_smpc_ram[0x77] & 0x10) >> 4) ^ 1; |
| 529 | 620 | |
| 530 | 621 | //if(LOG_SMPC) logerror("SMPC: ram [0x77] = %02x\n",state->m_smpc_ram[0x77]); |
| 531 | | PDR2 = (data & 0x60); |
| 622 | state->m_smpc.PDR2 = (data & 0x60); |
| 532 | 623 | } |
| 533 | 624 | |
| 534 | 625 | if(offset == 0x7d) |
| 535 | 626 | { |
| 536 | | if(state->m_smpc_ram[0x7d] & 1) |
| 537 | | SH2_DIRECT_MODE_PORT_1; |
| 538 | | else |
| 539 | | SMPC_CONTROL_MODE_PORT_1; |
| 540 | | |
| 541 | | if(state->m_smpc_ram[0x7d] & 2) |
| 542 | | SH2_DIRECT_MODE_PORT_2; |
| 543 | | else |
| 544 | | SMPC_CONTROL_MODE_PORT_2; |
| 627 | /* |
| 628 | ---- --x- IOSEL2 direct (1) / control mode (0) port select |
| 629 | ---- ---x IOSEL1 direct (1) / control mode (0) port select |
| 630 | */ |
| 631 | state->m_smpc.IOSEL1 = (state->m_smpc_ram[0x7d] & 1) >> 0; |
| 632 | state->m_smpc.IOSEL2 = (state->m_smpc_ram[0x7d] & 2) >> 1; |
| 545 | 633 | } |
| 546 | 634 | |
| 547 | | /*TODO: probably this is wrong...*/ |
| 548 | 635 | if(offset == 0x7f) |
| 549 | 636 | { |
| 550 | 637 | //enable PAD irq & VDP2 external latch for port 1/2 |
| 551 | | EXLE1 = state->m_smpc_ram[0x7f] & 1 ? 1 : 0; |
| 552 | | EXLE2 = state->m_smpc_ram[0x7f] & 2 ? 1 : 0; |
| 553 | | if(EXLE1 || EXLE2) |
| 638 | state->m_smpc.EXLE1 = (state->m_smpc_ram[0x7f] & 1) >> 0; |
| 639 | state->m_smpc.EXLE2 = (state->m_smpc_ram[0x7f] & 2) >> 1; |
| 640 | if(state->m_smpc.EXLE1 || state->m_smpc.EXLE2) |
| 554 | 641 | { |
| 555 | 642 | //if(LOG_SMPC) logerror ("Interrupt: PAD irq at scanline %04x, Vector 0x48 Level 0x08\n",scanline); |
| 556 | | cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48); |
| 643 | //cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48); |
| 557 | 644 | } |
| 558 | 645 | } |
| 559 | 646 | |
| 560 | | if (offset == 0x1f) |
| 647 | if (offset == 0x1f) // COMREG |
| 561 | 648 | { |
| 562 | 649 | switch (data) |
| 563 | 650 | { |
| 564 | 651 | case 0x00: |
| 565 | 652 | if(LOG_SMPC) logerror ("SMPC: Master ON\n"); |
| 566 | | state->m_smpc_ram[0x5f]=0x00; |
| 653 | smpc_master_on(space->machine()); |
| 567 | 654 | break; |
| 568 | 655 | //in theory 0x01 is for Master OFF,but obviously is not used. |
| 569 | 656 | case 0x02: |
| 570 | | if(LOG_SMPC) logerror ("SMPC: Slave ON\n"); |
| 571 | | state->m_smpc_ram[0x5f]=0x02; |
| 572 | | cputag_set_input_line(space->machine(), "slave", INPUT_LINE_RESET, CLEAR_LINE); |
| 573 | | break; |
| 574 | 657 | case 0x03: |
| 575 | | if(LOG_SMPC) logerror ("SMPC: Slave OFF\n"); |
| 576 | | state->m_smpc_ram[0x5f]=0x03; |
| 577 | | space->machine().scheduler().trigger(1000); |
| 578 | | cputag_set_input_line(space->machine(), "slave", INPUT_LINE_RESET, ASSERT_LINE); |
| 658 | if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 659 | smpc_slave_enable(space->machine(),(data & 1)); |
| 579 | 660 | break; |
| 580 | 661 | case 0x06: |
| 581 | | if(LOG_SMPC) logerror ("SMPC: Sound ON\n"); |
| 582 | | /* wrong? */ |
| 583 | | state->m_smpc_ram[0x5f]=0x06; |
| 584 | | cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, CLEAR_LINE); |
| 585 | | break; |
| 586 | 662 | case 0x07: |
| 587 | | if(LOG_SMPC) logerror ("SMPC: Sound OFF\n"); |
| 588 | | state->m_smpc_ram[0x5f]=0x07; |
| 663 | if(LOG_SMPC) logerror ("SMPC: Sound %s, ignored\n",(data & 1) ? "off" : "on"); |
| 589 | 664 | break; |
| 590 | 665 | /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/ |
| 591 | 666 | //case 0x08: |
| 592 | 667 | //case 0x09: |
| 593 | 668 | case 0x0d: |
| 594 | 669 | if(LOG_SMPC) logerror ("SMPC: System Reset\n"); |
| 595 | | state->m_smpc_ram[0x5f]=0x0d; |
| 596 | | cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE); |
| 597 | | system_reset(space); |
| 670 | smpc_system_reset(space->machine()); |
| 598 | 671 | break; |
| 599 | 672 | case 0x0e: |
| 600 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to 352\n"); |
| 601 | | state->m_smpc_ram[0x5f]=0x0e; |
| 602 | | space->machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_352/2); |
| 603 | | space->machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_352/2); |
| 604 | | space->machine().device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_352/5); |
| 605 | | cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 606 | | break; |
| 607 | 673 | case 0x0f: |
| 608 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to 320\n"); |
| 609 | | state->m_smpc_ram[0x5f]=0x0f; |
| 610 | | space->machine().device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2); |
| 611 | | space->machine().device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2); |
| 612 | | space->machine().device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_320/5); |
| 613 | | cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 674 | if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 675 | smpc_change_clock(space->machine(),data & 1); |
| 614 | 676 | break; |
| 615 | 677 | /*"Interrupt Back"*/ |
| 616 | 678 | case 0x10: |
| 617 | 679 | if(LOG_SMPC) logerror ("SMPC: Status Acquire\n"); |
| 618 | | state->m_smpc_ram[0x5f]=0x10; |
| 619 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 620 | | //state->m_smpc_ram[0x23] = DectoBCD(systime.local_time.year /100); |
| 621 | | //state->m_smpc_ram[0x25] = DectoBCD(systime.local_time.year %100); |
| 622 | | //state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month+1); |
| 623 | | //state->m_smpc_ram[0x29] = DectoBCD(systime.local_time.mday); |
| 624 | | //state->m_smpc_ram[0x2b] = DectoBCD(systime.local_time.hour); |
| 625 | | //state->m_smpc_ram[0x2d] = DectoBCD(systime.local_time.minute); |
| 626 | | //state->m_smpc_ram[0x2f] = DectoBCD(systime.local_time.second); |
| 627 | | |
| 628 | | state->m_smpc_ram[0x31]=0x00; //? |
| 629 | | |
| 630 | | //state->m_smpc_ram[0x33]=input_port_read(space->machine(), "FAKE"); |
| 631 | | |
| 632 | | state->m_smpc_ram[0x35]=0x00; |
| 633 | | state->m_smpc_ram[0x37]=0x00; |
| 634 | | |
| 635 | | state->m_smpc_ram[0x39]=0xff; |
| 636 | | state->m_smpc_ram[0x3b]=0xff; |
| 637 | | state->m_smpc_ram[0x3d]=0xff; |
| 638 | | state->m_smpc_ram[0x3f]=0xff; |
| 639 | | state->m_smpc_ram[0x41]=0xff; |
| 640 | | state->m_smpc_ram[0x43]=0xff; |
| 641 | | state->m_smpc_ram[0x45]=0xff; |
| 642 | | state->m_smpc_ram[0x47]=0xff; |
| 643 | | state->m_smpc_ram[0x49]=0xff; |
| 644 | | state->m_smpc_ram[0x4b]=0xff; |
| 645 | | state->m_smpc_ram[0x4d]=0xff; |
| 646 | | state->m_smpc_ram[0x4f]=0xff; |
| 647 | | state->m_smpc_ram[0x51]=0xff; |
| 648 | | state->m_smpc_ram[0x53]=0xff; |
| 649 | | state->m_smpc_ram[0x55]=0xff; |
| 650 | | state->m_smpc_ram[0x57]=0xff; |
| 651 | | state->m_smpc_ram[0x59]=0xff; |
| 652 | | state->m_smpc_ram[0x5b]=0xff; |
| 653 | | state->m_smpc_ram[0x5d]=0xff; |
| 654 | | |
| 655 | | // /*This is for RTC,cartridge code and similar stuff...*/ |
| 656 | | /*System Manager(SMPC) irq*/ |
| 657 | | { |
| 658 | | //if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 659 | | cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.smpc) ? HOLD_LINE : CLEAR_LINE, 0x47); |
| 660 | | } |
| 661 | | break; |
| 680 | smpc_intback(space->machine(),1,systime); |
| 681 | break; |
| 662 | 682 | /* RTC write*/ |
| 663 | 683 | case 0x16: |
| 664 | 684 | if(LOG_SMPC) logerror("SMPC: RTC write\n"); |
| 665 | | state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d]; |
| 666 | | state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b]; |
| 667 | | state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09]; |
| 668 | | state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07]; |
| 669 | | state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05]; |
| 670 | | state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03]; |
| 671 | | state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01]; |
| 672 | | state->m_smpc_ram[0x5f]=0x16; |
| 673 | | break; |
| 685 | smpc_rtc_write(space->machine()); |
| 686 | break; |
| 674 | 687 | /* SMPC memory setting*/ |
| 675 | 688 | case 0x17: |
| 676 | 689 | if(LOG_SMPC) logerror ("SMPC: memory setting\n"); |
| 677 | | state->m_smpc_ram[0x5f]=0x17; |
| 678 | | break; |
| 690 | //smpc_memory_setting(space->machine()); |
| 691 | break; |
| 679 | 692 | case 0x18: |
| 680 | 693 | if(LOG_SMPC) logerror ("SMPC: NMI request\n"); |
| 681 | | state->m_smpc_ram[0x5f]=0x18; |
| 682 | | /*NMI is unconditionally requested?*/ |
| 683 | | cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 694 | smpc_nmi_req(space->machine()); |
| 684 | 695 | break; |
| 685 | 696 | case 0x19: |
| 686 | | if(LOG_SMPC) logerror ("SMPC: NMI Enable\n"); |
| 687 | | state->m_smpc_ram[0x5f]=0x19; |
| 688 | | state->m_NMI_reset = 0; |
| 689 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 690 | | break; |
| 691 | 697 | case 0x1a: |
| 692 | | if(LOG_SMPC) logerror ("SMPC: NMI Disable\n"); |
| 693 | | state->m_smpc_ram[0x5f]=0x1a; |
| 694 | | state->m_NMI_reset = 1; |
| 695 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 698 | if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 699 | smpc_nmi_set(space->machine(),data & 1); |
| 696 | 700 | break; |
| 697 | 701 | default: |
| 698 | | if(LOG_SMPC) logerror ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data); |
| 702 | printf ("cpu '%s' (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data); |
| 699 | 703 | } |
| 700 | 704 | |
| 701 | 705 | // we've processed the command, clear status flag |
| 706 | state->m_smpc_ram[0x5f] = data; //read-back command |
| 702 | 707 | state->m_smpc_ram[0x63] = 0x00; |
| 703 | 708 | /*TODO:emulate the timing of each command...*/ |
| 704 | 709 | } |
| 705 | 710 | } |
| 706 | 711 | |
| 707 | | |
| 708 | | static void smpc_intbackhelper(running_machine &machine) |
| 709 | | { |
| 710 | | saturn_state *state = machine.driver_data<saturn_state>(); |
| 711 | | int pad; |
| 712 | | static const char *const padnames[] = { "JOY1", "JOY2" }; |
| 713 | | |
| 714 | | if (intback_stage == 1) |
| 715 | | { |
| 716 | | intback_stage++; |
| 717 | | return; |
| 718 | | } |
| 719 | | |
| 720 | | pad = input_port_read(machine, padnames[intback_stage-2]); |
| 721 | | |
| 722 | | // if (LOG_SMPC) logerror("SMPC: providing PAD data for intback, pad %d\n", intback_stage-2); |
| 723 | | state->m_smpc_ram[33] = 0xf1; // no tap, direct connect |
| 724 | | state->m_smpc_ram[35] = 0x02; // saturn pad |
| 725 | | state->m_smpc_ram[37] = pad>>8; |
| 726 | | state->m_smpc_ram[39] = pad & 0xff; |
| 727 | | |
| 728 | | if (intback_stage == 3) |
| 729 | | { |
| 730 | | smpcSR = (0x80 | pmode); // pad 2, no more data, echo back pad mode set by intback |
| 731 | | } |
| 732 | | else |
| 733 | | { |
| 734 | | smpcSR = (0xe0 | pmode); // pad 1, more data, echo back pad mode set by intback |
| 735 | | } |
| 736 | | |
| 737 | | intback_stage++; |
| 738 | | } |
| 739 | | |
| 740 | 712 | static READ8_HANDLER( saturn_SMPC_r8 ) |
| 741 | 713 | { |
| 742 | 714 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| r11640 | r11641 | |
| 745 | 717 | return_data = state->m_smpc_ram[offset]; |
| 746 | 718 | |
| 747 | 719 | if ((offset == 0x61)) |
| 748 | | return_data = smpcSR; |
| 720 | return_data = state->m_smpc.smpcSR; |
| 749 | 721 | |
| 750 | 722 | if (offset == 0x75)//PDR1 read |
| 751 | 723 | { |
| 752 | | if (IOSEL1) |
| 724 | if (state->m_smpc.IOSEL1) |
| 753 | 725 | { |
| 754 | 726 | int hshake; |
| 755 | 727 | |
| 756 | | hshake = (PDR1>>5) & 3; |
| 728 | hshake = (state->m_smpc.PDR1>>5) & 3; |
| 757 | 729 | |
| 758 | 730 | if (LOG_SMPC) logerror("SMPC: SH-2 direct mode, returning data for phase %d\n", hshake); |
| 759 | 731 | |
| r11640 | r11641 | |
| 787 | 759 | return_data = 0xff; // | EEPROM_read_bit()); |
| 788 | 760 | } |
| 789 | 761 | |
| 790 | | if (offset == 0x33) return_data = saturn_region; |
| 762 | if (offset == 0x33) return_data = state->saturn_region; |
| 791 | 763 | |
| 792 | 764 | if (LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x (%d) Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, offset>>1, return_data); |
| 793 | 765 | |
| r11640 | r11641 | |
| 811 | 783 | |
| 812 | 784 | last = state->m_smpc_ram[offset]; |
| 813 | 785 | |
| 814 | | if ((intback_stage > 0) && (offset == 1) && (((data ^ 0x80)&0x80) == (last&0x80))) |
| 786 | if ((state->m_smpc.intback_stage > 0) && (offset == 1) && (((data ^ 0x80)&0x80) == (last&0x80))) |
| 815 | 787 | { |
| 816 | | if (LOG_SMPC) logerror("SMPC: CONTINUE request, stage %d\n", intback_stage); |
| 817 | | if (intback_stage != 3) |
| 788 | if (LOG_SMPC) logerror("SMPC: CONTINUE request, stage %d\n", state->m_smpc.intback_stage); |
| 789 | if (state->m_smpc.intback_stage != 3) |
| 818 | 790 | { |
| 819 | | intback_stage = 2; |
| 791 | state->m_smpc.intback_stage = 2; |
| 820 | 792 | } |
| 821 | 793 | smpc_intbackhelper(machine); |
| 822 | 794 | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47); |
| r11640 | r11641 | |
| 825 | 797 | if ((offset == 1) && (data & 0x40)) |
| 826 | 798 | { |
| 827 | 799 | if (LOG_SMPC) logerror("SMPC: BREAK request\n"); |
| 828 | | intback_stage = 0; |
| 800 | state->m_smpc.intback_stage = 0; |
| 829 | 801 | } |
| 830 | 802 | |
| 831 | 803 | state->m_smpc_ram[offset] = data; |
| 832 | 804 | |
| 833 | 805 | if (offset == 0x75) // PDR1 |
| 834 | 806 | { |
| 835 | | PDR1 = (data & state->m_smpc_ram[0x79]); |
| 807 | state->m_smpc.PDR1 = (data & state->m_smpc_ram[0x79]); |
| 836 | 808 | } |
| 837 | 809 | |
| 838 | 810 | if (offset == 0x77) // PDR2 |
| 839 | 811 | { |
| 840 | | PDR2 = (data & state->m_smpc_ram[0x7b]); |
| 812 | state->m_smpc.PDR2 = (data & state->m_smpc_ram[0x7b]); |
| 841 | 813 | } |
| 842 | 814 | |
| 843 | 815 | if(offset == 0x7d) |
| 844 | 816 | { |
| 845 | | if(state->m_smpc_ram[0x7d] & 1) |
| 846 | | SH2_DIRECT_MODE_PORT_1; |
| 847 | | else |
| 848 | | SMPC_CONTROL_MODE_PORT_1; |
| 849 | | |
| 850 | | if(state->m_smpc_ram[0x7d] & 2) |
| 851 | | SH2_DIRECT_MODE_PORT_2; |
| 852 | | else |
| 853 | | SMPC_CONTROL_MODE_PORT_2; |
| 817 | state->m_smpc.IOSEL1 = state->m_smpc_ram[0x7d] & 1; |
| 818 | state->m_smpc.IOSEL2 = (state->m_smpc_ram[0x7d] & 2) >> 1; |
| 854 | 819 | } |
| 855 | 820 | |
| 856 | 821 | if(offset == 0x7f) |
| 857 | 822 | { |
| 858 | 823 | //enable PAD irq & VDP2 external latch for port 1/2 |
| 859 | | EXLE1 = state->m_smpc_ram[0x7f] & 1 ? 1 : 0; |
| 860 | | EXLE2 = state->m_smpc_ram[0x7f] & 2 ? 1 : 0; |
| 861 | | if(EXLE1 || EXLE2) |
| 862 | | if(!(state->m_scu_regs[40] & 0x0100)) /*Pad irq*/ |
| 863 | | { |
| 864 | | if(LOG_SMPC) logerror ("Interrupt: PAD irq, Vector 0x48 Level 0x08\n"); |
| 865 | | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x48); |
| 866 | | } |
| 824 | state->m_smpc.EXLE1 = (state->m_smpc_ram[0x7f] & 1) >> 0; |
| 825 | state->m_smpc.EXLE2 = (state->m_smpc_ram[0x7f] & 2) >> 1; |
| 826 | //if(state->m_smpc.EXLE1 || state->m_smpc.EXLE2) |
| 827 | // cputag_set_input_line_and_vector(space->machine(), "maincpu", 8, (stv_irq.pad) ? HOLD_LINE : CLEAR_LINE, 0x48); |
| 867 | 828 | } |
| 868 | 829 | |
| 869 | 830 | if (offset == 0x1f) |
| r11640 | r11641 | |
| 872 | 833 | { |
| 873 | 834 | case 0x00: |
| 874 | 835 | if(LOG_SMPC) logerror ("SMPC: Master ON\n"); |
| 875 | | state->m_smpc_ram[0x5f]=0x00; |
| 836 | smpc_master_on(space->machine()); |
| 876 | 837 | break; |
| 877 | | //in theory 0x01 is for Master OFF,but obviously is not used. |
| 838 | //in theory 0x01 is for Master OFF |
| 878 | 839 | case 0x02: |
| 879 | | if(LOG_SMPC) logerror ("SMPC: Slave ON\n"); |
| 880 | | state->m_smpc_ram[0x5f]=0x02; |
| 881 | | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, CLEAR_LINE); |
| 882 | | break; |
| 883 | 840 | case 0x03: |
| 884 | | if(LOG_SMPC) logerror ("SMPC: Slave OFF\n"); |
| 885 | | state->m_smpc_ram[0x5f]=0x03; |
| 886 | | machine.scheduler().trigger(1000); |
| 887 | | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE); |
| 841 | if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 842 | smpc_slave_enable(space->machine(),data & 1); |
| 888 | 843 | break; |
| 889 | 844 | case 0x06: |
| 890 | | if(LOG_SMPC) logerror ("SMPC: Sound ON\n"); |
| 891 | | /* wrong? */ |
| 892 | | state->m_smpc_ram[0x5f]=0x06; |
| 893 | | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, CLEAR_LINE); |
| 894 | | state->m_en_68k = 1; |
| 895 | | break; |
| 896 | 845 | case 0x07: |
| 897 | | if(LOG_SMPC) logerror ("SMPC: Sound OFF\n"); |
| 898 | | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); |
| 899 | | state->m_en_68k = 0; |
| 900 | | state->m_smpc_ram[0x5f]=0x07; |
| 846 | if(LOG_SMPC) logerror ("SMPC: Sound %s\n",(data & 1) ? "off" : "on"); |
| 847 | smpc_sound_enable(space->machine(),data & 1); |
| 901 | 848 | break; |
| 902 | 849 | /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/ |
| 903 | 850 | //case 0x08: |
| 904 | 851 | //case 0x09: |
| 905 | 852 | case 0x0d: |
| 906 | 853 | if(LOG_SMPC) logerror ("SMPC: System Reset\n"); |
| 907 | | state->m_smpc_ram[0x5f]=0x0d; |
| 908 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE); |
| 909 | | system_reset(space); |
| 854 | smpc_system_reset(space->machine()); |
| 910 | 855 | break; |
| 911 | 856 | case 0x0e: |
| 912 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to 352\n"); |
| 913 | | state->m_smpc_ram[0x5f]=0x0e; |
| 914 | | machine.device("maincpu")->set_unscaled_clock(MASTER_CLOCK_352/2); |
| 915 | | machine.device("slave")->set_unscaled_clock(MASTER_CLOCK_352/2); |
| 916 | | machine.device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_352/5); |
| 917 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 918 | | break; |
| 919 | 857 | case 0x0f: |
| 920 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to 320\n"); |
| 921 | | state->m_smpc_ram[0x5f]=0x0f; |
| 922 | | machine.device("maincpu")->set_unscaled_clock(MASTER_CLOCK_320/2); |
| 923 | | machine.device("slave")->set_unscaled_clock(MASTER_CLOCK_320/2); |
| 924 | | machine.device("audiocpu")->set_unscaled_clock(MASTER_CLOCK_320/5); |
| 925 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 858 | if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 859 | smpc_change_clock(space->machine(),data & 1); |
| 926 | 860 | break; |
| 927 | 861 | /*"Interrupt Back"*/ |
| 928 | 862 | case 0x10: |
| 929 | | if(LOG_SMPC) logerror ("SMPC: Status Acquire (IntBack)\n"); |
| 930 | | state->m_smpc_ram[0x5f]=0x10; |
| 931 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 932 | | state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100); |
| 933 | | state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100); |
| 934 | | state->m_smpc_ram[0x27] = (systime.local_time.weekday << 4) | (systime.local_time.month + 1); |
| 935 | | state->m_smpc_ram[0x29] = dec_2_bcd(systime.local_time.mday); |
| 936 | | state->m_smpc_ram[0x2b] = dec_2_bcd(systime.local_time.hour); |
| 937 | | state->m_smpc_ram[0x2d] = dec_2_bcd(systime.local_time.minute); |
| 938 | | state->m_smpc_ram[0x2f] = dec_2_bcd(systime.local_time.second); |
| 939 | | |
| 940 | | state->m_smpc_ram[0x31]=0x00; //? |
| 941 | | |
| 942 | | |
| 943 | | state->m_smpc_ram[0x35]=0x00; |
| 944 | | state->m_smpc_ram[0x37]=0x00; |
| 945 | | |
| 946 | | state->m_smpc_ram[0x39] = SMEM[0]; |
| 947 | | state->m_smpc_ram[0x3b] = SMEM[1]; |
| 948 | | state->m_smpc_ram[0x3d] = SMEM[2]; |
| 949 | | state->m_smpc_ram[0x3f] = SMEM[3]; |
| 950 | | |
| 951 | | state->m_smpc_ram[0x41]=0xff; |
| 952 | | state->m_smpc_ram[0x43]=0xff; |
| 953 | | state->m_smpc_ram[0x45]=0xff; |
| 954 | | state->m_smpc_ram[0x47]=0xff; |
| 955 | | state->m_smpc_ram[0x49]=0xff; |
| 956 | | state->m_smpc_ram[0x4b]=0xff; |
| 957 | | state->m_smpc_ram[0x4d]=0xff; |
| 958 | | state->m_smpc_ram[0x4f]=0xff; |
| 959 | | state->m_smpc_ram[0x51]=0xff; |
| 960 | | state->m_smpc_ram[0x53]=0xff; |
| 961 | | state->m_smpc_ram[0x55]=0xff; |
| 962 | | state->m_smpc_ram[0x57]=0xff; |
| 963 | | state->m_smpc_ram[0x59]=0xff; |
| 964 | | state->m_smpc_ram[0x5b]=0xff; |
| 965 | | state->m_smpc_ram[0x5d]=0xff; |
| 966 | | |
| 967 | | smpcSR = 0x60; // peripheral data ready, no reset, etc. |
| 968 | | pmode = state->m_smpc_ram[1]>>4; |
| 969 | | |
| 970 | | intback_stage = 1; |
| 971 | | |
| 972 | | // /*This is for RTC,cartridge code and similar stuff...*/ |
| 973 | | // if(!(state->m_scu_regs[40] & 0x0080)) /*System Manager(SMPC) irq*/ /* we can't check this .. breaks controls .. probably issues elsewhere? */ |
| 974 | | { |
| 975 | | // if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 976 | | smpc_intbackhelper(machine); |
| 977 | | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47); |
| 978 | | } |
| 979 | | break; |
| 863 | if(LOG_SMPC) logerror ("SMPC: Status Acquire (IntBack)\n"); |
| 864 | smpc_intback(space->machine(),0,systime); |
| 865 | break; |
| 980 | 866 | /* RTC write*/ |
| 981 | 867 | case 0x16: |
| 982 | 868 | if(LOG_SMPC) logerror("SMPC: RTC write\n"); |
| 983 | | state->m_smpc_ram[0x2f] = state->m_smpc_ram[0x0d]; |
| 984 | | state->m_smpc_ram[0x2d] = state->m_smpc_ram[0x0b]; |
| 985 | | state->m_smpc_ram[0x2b] = state->m_smpc_ram[0x09]; |
| 986 | | state->m_smpc_ram[0x29] = state->m_smpc_ram[0x07]; |
| 987 | | state->m_smpc_ram[0x27] = state->m_smpc_ram[0x05]; |
| 988 | | state->m_smpc_ram[0x25] = state->m_smpc_ram[0x03]; |
| 989 | | state->m_smpc_ram[0x23] = state->m_smpc_ram[0x01]; |
| 990 | | state->m_smpc_ram[0x5f]=0x16; |
| 991 | | break; |
| 869 | smpc_rtc_write(space->machine()); |
| 870 | break; |
| 992 | 871 | /* SMPC memory setting*/ |
| 993 | 872 | case 0x17: |
| 994 | 873 | if(LOG_SMPC) logerror ("SMPC: memory setting\n"); |
| 995 | | SMEM[0] = state->m_smpc_ram[1]; |
| 996 | | SMEM[1] = state->m_smpc_ram[3]; |
| 997 | | SMEM[2] = state->m_smpc_ram[5]; |
| 998 | | SMEM[3] = state->m_smpc_ram[7]; |
| 999 | | |
| 1000 | | state->m_smpc_ram[0x5f]=0x17; |
| 1001 | | break; |
| 874 | smpc_memory_setting(space->machine()); |
| 875 | break; |
| 1002 | 876 | case 0x18: |
| 1003 | 877 | if(LOG_SMPC) logerror ("SMPC: NMI request\n"); |
| 1004 | | state->m_smpc_ram[0x5f]=0x18; |
| 1005 | | /*NMI is unconditionally requested?*/ |
| 1006 | | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 878 | smpc_nmi_req(space->machine()); |
| 1007 | 879 | break; |
| 1008 | 880 | case 0x19: |
| 1009 | | if(LOG_SMPC) logerror ("SMPC: NMI Enable\n"); |
| 1010 | | state->m_smpc_ram[0x5f]=0x19; |
| 1011 | | state->m_NMI_reset = 0; |
| 1012 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 1013 | | break; |
| 1014 | 881 | case 0x1a: |
| 1015 | | if(LOG_SMPC) logerror ("SMPC: NMI Disable\n"); |
| 1016 | | state->m_smpc_ram[0x5f]=0x1a; |
| 1017 | | state->m_NMI_reset = 1; |
| 1018 | | state->m_smpc_ram[0x21] = (0x80) | ((state->m_NMI_reset & 1) << 6); |
| 1019 | | |
| 882 | if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 883 | smpc_nmi_set(space->machine(),data & 1); |
| 1020 | 884 | break; |
| 1021 | 885 | default: |
| 1022 | | if(LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data); |
| 886 | printf ("cpu %s (PC=%08X) SMPC: undocumented Command %02x\n", space->device().tag(), cpu_get_pc(&space->device()), data); |
| 1023 | 887 | } |
| 1024 | 888 | |
| 1025 | 889 | // we've processed the command, clear status flag |
| 890 | state->m_smpc_ram[0x5f] = data; //read-back for last command issued |
| 1026 | 891 | state->m_smpc_ram[0x63] = 0x00; |
| 1027 | 892 | /*TODO:emulate the timing of each command...*/ |
| 1028 | 893 | } |
| r11640 | r11641 | |
| 1068 | 933 | |
| 1069 | 934 | static READ32_HANDLER ( stv_io_r32 ) |
| 1070 | 935 | { |
| 936 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1071 | 937 | // if(LOG_IOGA) logerror("(PC=%08X): I/O r %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, mem_mask); |
| 1072 | 938 | // popmessage("SEL: %02x MUX: %02x OFF: %02x",port_sel,mux_data,offset*4); |
| 1073 | 939 | |
| r11640 | r11641 | |
| 1120 | 986 | } |
| 1121 | 987 | case 0x04/4: |
| 1122 | 988 | if ( strcmp(space->machine().system().name,"critcrsh") == 0 ) |
| 1123 | | return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (ioga[1]); |
| 989 | return ((input_port_read(space->machine(), "SYSTEM") << 16) & ((input_port_read(space->machine(), "P1") & 1) ? 0xffef0000 : 0xffff0000)) | (state->m_ioga[1]); |
| 1124 | 990 | else |
| 1125 | | return (input_port_read(space->machine(), "SYSTEM") << 16) | (ioga[1]); |
| 991 | return (input_port_read(space->machine(), "SYSTEM") << 16) | (state->m_ioga[1]); |
| 1126 | 992 | |
| 1127 | 993 | case 0x08/4: |
| 1128 | 994 | switch(port_sel) |
| 1129 | 995 | { |
| 1130 | 996 | case 0x77: return (input_port_read(space->machine(), "UNUSED") << 16) | (input_port_read(space->machine(), "EXTRA")); |
| 1131 | 997 | case 0x67: return 0xffffffff;/**/ |
| 1132 | | case 0x20: return 0xffff0000 | (ioga[2] & 0xffff); |
| 1133 | | case 0x10: return ((ioga[2] & 0xffff) << 16) | 0xffff; |
| 998 | case 0x20: return 0xffff0000 | (state->m_ioga[2] & 0xffff); |
| 999 | case 0x10: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff; |
| 1134 | 1000 | case 0x60: return 0xffffffff;/**/ |
| 1135 | 1001 | default: |
| 1136 | 1002 | return 0xffffffff; |
| r11640 | r11641 | |
| 1138 | 1004 | case 0x0c/4: |
| 1139 | 1005 | switch(port_sel) |
| 1140 | 1006 | { |
| 1141 | | case 0x60: return ((ioga[2] & 0xffff) << 16) | 0xffff; |
| 1007 | case 0x60: return ((state->m_ioga[2] & 0xffff) << 16) | 0xffff; |
| 1142 | 1008 | default: |
| 1143 | 1009 | //popmessage("offs: 3 %02x",port_sel); |
| 1144 | 1010 | return 0xffffffff; |
| r11640 | r11641 | |
| 1149 | 1015 | { |
| 1150 | 1016 | case 0x77: |
| 1151 | 1017 | { |
| 1152 | | //popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16)); |
| 1153 | | logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16)); |
| 1018 | //popmessage("(PC=%06x) offs 5 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16)); |
| 1019 | logerror("(PC=%06x) offs 5 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16)); |
| 1154 | 1020 | |
| 1155 | | //stv_m_workram_h[0x8e830/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3; |
| 1156 | | //stv_m_workram_h[0x8e834/4] = ((ioga[5] & 0xff0000) >> 16) ^ 0x3; |
| 1157 | | return (ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data |
| 1021 | //stv_m_workram_h[0x8e830/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3; |
| 1022 | //stv_m_workram_h[0x8e834/4] = ((state->m_ioga[5] & 0xff0000) >> 16) ^ 0x3; |
| 1023 | return (state->m_ioga[5] & 0xff0000) >> 16;//stv_m_workram_h[0x8e830/4];//sound board data |
| 1158 | 1024 | } |
| 1159 | 1025 | default: return 0xffffffff; |
| 1160 | 1026 | } |
| 1161 | 1027 | case 0x18/4: |
| 1162 | 1028 | switch(port_sel) |
| 1163 | 1029 | { |
| 1164 | | case 0x60: return ioga[5]; |
| 1030 | case 0x60: return state->m_ioga[5]; |
| 1165 | 1031 | case 0x77: |
| 1166 | 1032 | { |
| 1167 | | //popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16)); |
| 1168 | | logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((ioga[5] & 0xff0000) >> 16)); |
| 1033 | //popmessage("(PC=%06x) offs 6 %04x %02x",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16)); |
| 1034 | logerror("(PC=%06x) offs 6 %04x %02x\n",cpu_get_pc(&space->device()),port_sel,((state->m_ioga[5] & 0xff0000) >> 16)); |
| 1169 | 1035 | return 0;//sound board status,non-zero = processing |
| 1170 | 1036 | } |
| 1171 | 1037 | default: |
| r11640 | r11641 | |
| 1178 | 1044 | port_i++; |
| 1179 | 1045 | return port_ad[port_i & 7]; |
| 1180 | 1046 | default: |
| 1181 | | return ioga[offset]; |
| 1047 | return state->m_ioga[offset]; |
| 1182 | 1048 | } |
| 1183 | 1049 | } |
| 1184 | 1050 | |
| 1185 | 1051 | static WRITE32_HANDLER ( stv_io_w32 ) |
| 1186 | 1052 | { |
| 1053 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1187 | 1054 | // if(LOG_IOGA) logerror("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask); |
| 1188 | 1055 | |
| 1189 | 1056 | // printf("(PC=%08X): I/O w %08X = %08X & %08X\n", cpu_get_pc(&space->device()), offset*4, data, mem_mask); |
| r11640 | r11641 | |
| 1194 | 1061 | if(ACCESSING_BITS_0_7) |
| 1195 | 1062 | { |
| 1196 | 1063 | /*Why does the BIOS tests these as ACTIVE HIGH? A program bug?*/ |
| 1197 | | ioga[1] = (data) & 0xff; |
| 1064 | state->m_ioga[1] = (data) & 0xff; |
| 1198 | 1065 | coin_counter_w(space->machine(), 0,~data & 0x01); |
| 1199 | 1066 | coin_counter_w(space->machine(), 1,~data & 0x02); |
| 1200 | 1067 | coin_lockout_w(space->machine(), 0,~data & 0x04); |
| r11640 | r11641 | |
| 1207 | 1074 | case 0x08/4: |
| 1208 | 1075 | if(ACCESSING_BITS_16_23) |
| 1209 | 1076 | { |
| 1210 | | ioga[2] = data >> 16; |
| 1211 | | mux_data = ioga[2]; |
| 1077 | state->m_ioga[2] = data >> 16; |
| 1078 | mux_data = state->m_ioga[2]; |
| 1212 | 1079 | } |
| 1213 | 1080 | else if(ACCESSING_BITS_0_7) |
| 1214 | | ioga[2] = data; |
| 1081 | state->m_ioga[2] = data; |
| 1215 | 1082 | break; |
| 1216 | 1083 | case 0x0c/4: |
| 1217 | 1084 | if(ACCESSING_BITS_16_23) |
| 1218 | | ioga[3] = data; |
| 1085 | state->m_ioga[3] = data; |
| 1219 | 1086 | break; |
| 1220 | 1087 | case 0x10/4: |
| 1221 | 1088 | if(ACCESSING_BITS_16_23) |
| r11640 | r11641 | |
| 1223 | 1090 | break; |
| 1224 | 1091 | case 0x14/4: |
| 1225 | 1092 | if(ACCESSING_BITS_16_23) |
| 1226 | | ioga[5] = data; |
| 1093 | state->m_ioga[5] = data; |
| 1227 | 1094 | break; |
| 1228 | 1095 | //case 0x18/4: |
| 1229 | 1096 | case 0x1c/4: |
| 1230 | 1097 | //technical bowling tests here |
| 1231 | 1098 | if(ACCESSING_BITS_16_23) |
| 1232 | | ioga[7] = data; |
| 1099 | state->m_ioga[7] = data; |
| 1233 | 1100 | break; |
| 1234 | 1101 | |
| 1235 | 1102 | } |
| r11640 | r11641 | |
| 1335 | 1202 | |
| 1336 | 1203 | #define DMA_STATUS (state->m_scu_regs[31]) |
| 1337 | 1204 | /*These macros sets the various DMA status flags.*/ |
| 1338 | | #define D0MV_1 DMA_STATUS|=0x10 |
| 1339 | | #define D1MV_1 DMA_STATUS|=0x100 |
| 1340 | | #define D2MV_1 DMA_STATUS|=0x1000 |
| 1341 | | #define D0MV_0 DMA_STATUS&=~0x10 |
| 1342 | | #define D1MV_0 DMA_STATUS&=~0x100 |
| 1343 | | #define D2MV_0 DMA_STATUS&=~0x1000 |
| 1205 | #define DnMV_1(_ch_) DMA_STATUS|=(0x10 << 4 * _ch_) |
| 1206 | #define DnMV_0(_ch_) DMA_STATUS&=~(0x10 << 4 * _ch_) |
| 1344 | 1207 | |
| 1345 | 1208 | static UINT32 scu_add_tmp; |
| 1346 | 1209 | |
| 1347 | 1210 | /*For area checking*/ |
| 1348 | | #define ABUS(_lv_) ((state->m_scu_src[_lv_] & 0x07ffffff) >= 0x02000000) && ((state->m_scu_src[_lv_] & 0x07ffffff) <= 0x04ffffff) |
| 1211 | #define ABUS(_lv_) ((state->m_scu.src[_lv_] & 0x07ffffff) >= 0x02000000) && ((state->m_scu.src[_lv_] & 0x07ffffff) <= 0x04ffffff) |
| 1349 | 1212 | #define BBUS(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05a00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05ffffff) |
| 1350 | 1213 | #define VDP1_REGS(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05d00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05dfffff) |
| 1351 | 1214 | #define VDP2(_lv_) ((scu_##_lv_ & 0x07ffffff) >= 0x05e00000) && ((scu_##_lv_ & 0x07ffffff) <= 0x05fdffff) |
| r11640 | r11641 | |
| 1418 | 1281 | switch(offset) |
| 1419 | 1282 | { |
| 1420 | 1283 | /*LV 0 DMA*/ |
| 1421 | | case 0: case 8: case 16: state->m_scu_src[DMA_CH] = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break; |
| 1422 | | case 1: case 9: case 17: state->m_scu_dst[DMA_CH] = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break; |
| 1423 | | case 2: case 10: case 18: state->m_scu_size[DMA_CH] = ((state->m_scu_regs[offset] & ((offset == 2) ? 0x000fffff : 0x1fff)) >> 0); break; |
| 1284 | case 0: case 8: case 16: state->m_scu.src[DMA_CH] = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break; |
| 1285 | case 1: case 9: case 17: state->m_scu.dst[DMA_CH] = ((state->m_scu_regs[offset] & 0x07ffffff) >> 0); break; |
| 1286 | case 2: case 10: case 18: state->m_scu.size[DMA_CH] = ((state->m_scu_regs[offset] & ((offset == 2) ? 0x000fffff : 0x1fff)) >> 0); break; |
| 1424 | 1287 | case 3: case 11: case 19: |
| 1425 | 1288 | /*Read address add value for DMA lv 0*/ |
| 1426 | | state->m_scu_src_add[DMA_CH] = (state->m_scu_regs[offset] & 0x100) ? 4 : 1; |
| 1289 | state->m_scu.src_add[DMA_CH] = (state->m_scu_regs[offset] & 0x100) ? 4 : 1; |
| 1427 | 1290 | |
| 1428 | 1291 | /*Write address add value for DMA lv 0*/ |
| 1429 | | state->m_scu_dst_add[DMA_CH] = 2 << (state->m_scu_regs[offset] & 7); |
| 1292 | state->m_scu.dst_add[DMA_CH] = 2 << (state->m_scu_regs[offset] & 7); |
| 1430 | 1293 | break; |
| 1431 | 1294 | case 4: case 12: case 20: |
| 1432 | 1295 | /* |
| r11640 | r11641 | |
| 1441 | 1304 | if(state->m_scu_regs[offset] & 1 && ((state->m_scu_regs[offset+1] & 7) == 7) && state->m_scu_regs[offset] & 0x100) |
| 1442 | 1305 | { |
| 1443 | 1306 | if(DIRECT_MODE(DMA_CH)) { scu_dma_direct(space,DMA_CH); } |
| 1444 | | else { scu_dma_indirect(space,DMA_CH); } |
| 1307 | else { scu_dma_indirect(space,DMA_CH); } |
| 1445 | 1308 | |
| 1446 | 1309 | state->m_scu_regs[offset]&=~1;//disable starting bit. |
| 1447 | 1310 | } |
| r11640 | r11641 | |
| 1450 | 1313 | if(INDIRECT_MODE(DMA_CH)) |
| 1451 | 1314 | { |
| 1452 | 1315 | if(LOG_SCU) logerror("Indirect Mode DMA lv %d set\n",DMA_CH); |
| 1453 | | if(!DWUP(DMA_CH)) state->m_scu_index[DMA_CH] = state->m_scu_dst[DMA_CH]; |
| 1316 | if(!DWUP(DMA_CH)) state->m_scu.index[DMA_CH] = state->m_scu.dst[DMA_CH]; |
| 1454 | 1317 | } |
| 1455 | 1318 | |
| 1456 | 1319 | /*Start factor enable bits,bit 2,bit 1 and bit 0*/ |
| r11640 | r11641 | |
| 1564 | 1427 | |
| 1565 | 1428 | cputag_set_input_line_and_vector(machine, "maincpu", 5, (stv_irq.dma_end[0]) ? HOLD_LINE : CLEAR_LINE, 0x4b); |
| 1566 | 1429 | |
| 1567 | | D0MV_0; |
| 1430 | DnMV_0(0); |
| 1568 | 1431 | } |
| 1569 | 1432 | |
| 1570 | 1433 | /*Lv 1 DMA end irq*/ |
| r11640 | r11641 | |
| 1574 | 1437 | |
| 1575 | 1438 | cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[1]) ? HOLD_LINE : CLEAR_LINE, 0x4a); |
| 1576 | 1439 | |
| 1577 | | D1MV_0; |
| 1440 | DnMV_0(1); |
| 1578 | 1441 | } |
| 1579 | 1442 | |
| 1580 | 1443 | /*Lv 2 DMA end irq*/ |
| r11640 | r11641 | |
| 1584 | 1447 | |
| 1585 | 1448 | cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[2]) ? HOLD_LINE : CLEAR_LINE, 0x49); |
| 1586 | 1449 | |
| 1587 | | D2MV_0; |
| 1450 | DnMV_0(2); |
| 1588 | 1451 | } |
| 1589 | 1452 | |
| 1590 | 1453 | static void scu_dma_direct(address_space *space, UINT8 dma_ch) |
| 1591 | 1454 | { |
| 1592 | 1455 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1593 | 1456 | static UINT32 tmp_src,tmp_dst,tmp_size; |
| 1594 | | if(LOG_SCU) logerror("DMA lv 0 transfer START\n" |
| 1595 | | "Start %08x End %08x Size %04x\n",state->m_scu_src[0],state->m_scu_dst[0],state->m_scu_size[0]); |
| 1596 | | if(LOG_SCU) logerror("Start Add %04x Destination Add %04x\n",state->m_scu_src_add[0],state->m_scu_dst_add[0]); |
| 1597 | 1457 | |
| 1598 | | D0MV_1; |
| 1458 | if(LOG_SCU) printf("DMA lv %d transfer START\n" |
| 1459 | "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu.src[dma_ch],state->m_scu.dst[dma_ch],state->m_scu.size[dma_ch]); |
| 1460 | if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",state->m_scu.src_add[dma_ch],state->m_scu.dst_add[dma_ch]); |
| 1599 | 1461 | |
| 1462 | DnMV_1(dma_ch); |
| 1463 | |
| 1600 | 1464 | /* max size */ |
| 1601 | | if(state->m_scu_size[dma_ch] == 0) { state->m_scu_size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; } |
| 1465 | if(state->m_scu.size[dma_ch] == 0) { state->m_scu.size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; } |
| 1602 | 1466 | |
| 1603 | 1467 | /*set here the boundaries checks*/ |
| 1604 | 1468 | /*...*/ |
| 1605 | 1469 | |
| 1606 | | if((state->m_scu_dst_add[dma_ch] != state->m_scu_src_add[dma_ch]) && (ABUS(dma_ch))) |
| 1470 | if((state->m_scu.dst_add[dma_ch] != state->m_scu.src_add[dma_ch]) && (ABUS(dma_ch))) |
| 1607 | 1471 | { |
| 1608 | 1472 | logerror("A-Bus invalid transfer,sets to default\n"); |
| 1609 | | scu_add_tmp = (state->m_scu_dst_add[dma_ch]*0x100) | (state->m_scu_src_add[dma_ch]); |
| 1610 | | state->m_scu_dst_add[dma_ch] = state->m_scu_src_add[dma_ch] = 4; |
| 1473 | scu_add_tmp = (state->m_scu.dst_add[dma_ch]*0x100) | (state->m_scu.src_add[dma_ch]); |
| 1474 | state->m_scu.dst_add[dma_ch] = state->m_scu.src_add[dma_ch] = 4; |
| 1611 | 1475 | scu_add_tmp |= 0x80000000; |
| 1612 | 1476 | } |
| 1613 | 1477 | |
| r11640 | r11641 | |
| 1637 | 1501 | if(VDP1_REGS(dst_0)) |
| 1638 | 1502 | { |
| 1639 | 1503 | logerror("VDP1 register access,must be in word units\n"); |
| 1640 | | scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]); |
| 1641 | | state->m_scu_dst_add[0] = state->m_scu_src_add[0] = 2; |
| 1504 | scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]); |
| 1505 | state->m_scu.dst_add[0] = state->m_scu.src_add[0] = 2; |
| 1642 | 1506 | scu_add_tmp |= 0x80000000; |
| 1643 | 1507 | } |
| 1644 | 1508 | if(DRUP(0)) |
| 1645 | 1509 | { |
| 1646 | 1510 | logerror("Data read update = 1,read address add value must be 1 too\n"); |
| 1647 | | scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]); |
| 1648 | | state->m_scu_src_add[0] = 4; |
| 1511 | scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]); |
| 1512 | state->m_scu.src_add[0] = 4; |
| 1649 | 1513 | scu_add_tmp |= 0x80000000; |
| 1650 | 1514 | } |
| 1651 | 1515 | |
| 1652 | | if (WORK_RAM_H(dst_0) && (state->m_scu_dst_add[0] != 4)) |
| 1516 | if (WORK_RAM_H(dst_0) && (state->m_scu.dst_add[0] != 4)) |
| 1653 | 1517 | { |
| 1654 | | scu_add_tmp = (state->m_scu_dst_add[0]*0x100) | (state->m_scu_src_add[0]); |
| 1655 | | state->m_scu_dst_add[0] = 4; |
| 1518 | scu_add_tmp = (state->m_scu.dst_add[0]*0x100) | (state->m_scu.src_add[0]); |
| 1519 | state->m_scu.dst_add[0] = 4; |
| 1656 | 1520 | scu_add_tmp |= 0x80000000; |
| 1657 | 1521 | } |
| 1658 | 1522 | #endif |
| 1659 | 1523 | |
| 1660 | | tmp_size = state->m_scu_size[dma_ch]; |
| 1661 | | if(!(DRUP(dma_ch))) tmp_src = state->m_scu_src[dma_ch]; |
| 1662 | | if(!(DWUP(dma_ch))) tmp_dst = state->m_scu_dst[dma_ch]; |
| 1524 | tmp_size = state->m_scu.size[dma_ch]; |
| 1525 | if(!(DRUP(dma_ch))) tmp_src = state->m_scu.src[dma_ch]; |
| 1526 | if(!(DWUP(dma_ch))) tmp_dst = state->m_scu.dst[dma_ch]; |
| 1663 | 1527 | |
| 1664 | | for (; state->m_scu_size[dma_ch] > 0; state->m_scu_size[dma_ch]-=state->m_scu_dst_add[dma_ch]) |
| 1528 | for (; state->m_scu.size[dma_ch] > 0; state->m_scu.size[dma_ch]-=state->m_scu.dst_add[dma_ch]) |
| 1665 | 1529 | { |
| 1666 | | if(state->m_scu_dst_add[dma_ch] == 2) |
| 1667 | | space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch])); |
| 1668 | | else if(state->m_scu_dst_add[dma_ch] == 8) |
| 1530 | if(state->m_scu.dst_add[dma_ch] == 2) |
| 1531 | space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch])); |
| 1532 | else if(state->m_scu.dst_add[dma_ch] == 8) |
| 1669 | 1533 | { |
| 1670 | | space->write_word(state->m_scu_dst[dma_ch], space->read_word(state->m_scu_src[dma_ch] )); |
| 1671 | | space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch] )); |
| 1672 | | space->write_word(state->m_scu_dst[dma_ch]+4,space->read_word(state->m_scu_src[dma_ch]+2)); |
| 1673 | | space->write_word(state->m_scu_dst[dma_ch]+6,space->read_word(state->m_scu_src[dma_ch]+2)); |
| 1534 | space->write_word(state->m_scu.dst[dma_ch], space->read_word(state->m_scu.src[dma_ch] )); |
| 1535 | space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch] )); |
| 1536 | space->write_word(state->m_scu.dst[dma_ch]+4,space->read_word(state->m_scu.src[dma_ch]+2)); |
| 1537 | space->write_word(state->m_scu.dst[dma_ch]+6,space->read_word(state->m_scu.src[dma_ch]+2)); |
| 1674 | 1538 | } |
| 1675 | 1539 | else |
| 1676 | 1540 | { |
| 1677 | | space->write_word(state->m_scu_dst[dma_ch], space->read_word(state->m_scu_src[dma_ch] )); |
| 1678 | | space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch]+2)); |
| 1541 | space->write_word(state->m_scu.dst[dma_ch], space->read_word(state->m_scu.src[dma_ch] )); |
| 1542 | space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch]+2)); |
| 1679 | 1543 | } |
| 1680 | 1544 | |
| 1681 | | state->m_scu_dst[dma_ch]+=state->m_scu_dst_add[dma_ch]; |
| 1682 | | state->m_scu_src[dma_ch]+=state->m_scu_src_add[dma_ch]; |
| 1545 | state->m_scu.dst[dma_ch]+=state->m_scu.dst_add[dma_ch]; |
| 1546 | state->m_scu.src[dma_ch]+=state->m_scu.src_add[dma_ch]; |
| 1683 | 1547 | } |
| 1684 | 1548 | |
| 1685 | | state->m_scu_size[dma_ch] = tmp_size; |
| 1686 | | if(!(DRUP(dma_ch))) state->m_scu_src[dma_ch] = tmp_src; |
| 1687 | | if(!(DWUP(dma_ch))) state->m_scu_dst[dma_ch] = tmp_dst; |
| 1549 | state->m_scu.size[dma_ch] = tmp_size; |
| 1550 | if(!(DRUP(dma_ch))) state->m_scu.src[dma_ch] = tmp_src; |
| 1551 | if(!(DWUP(dma_ch))) state->m_scu.dst[dma_ch] = tmp_dst; |
| 1688 | 1552 | |
| 1553 | if(dma_ch != 2) |
| 1689 | 1554 | if(LOG_SCU) logerror("DMA transfer END\n"); |
| 1690 | 1555 | |
| 1691 | 1556 | /*TODO: timing of this, clean up */ |
| r11640 | r11641 | |
| 1698 | 1563 | |
| 1699 | 1564 | if(scu_add_tmp & 0x80000000) |
| 1700 | 1565 | { |
| 1701 | | state->m_scu_dst_add[dma_ch] = (scu_add_tmp & 0xff00) >> 8; |
| 1702 | | state->m_scu_src_add[dma_ch] = (scu_add_tmp & 0x00ff) >> 0; |
| 1566 | state->m_scu.dst_add[dma_ch] = (scu_add_tmp & 0xff00) >> 8; |
| 1567 | state->m_scu.src_add[dma_ch] = (scu_add_tmp & 0x00ff) >> 0; |
| 1703 | 1568 | scu_add_tmp^=0x80000000; |
| 1704 | 1569 | } |
| 1705 | 1570 | } |
| r11640 | r11641 | |
| 1713 | 1578 | /*temporary storage for the transfer data*/ |
| 1714 | 1579 | UINT32 tmp_src; |
| 1715 | 1580 | |
| 1716 | | D0MV_1; |
| 1581 | DnMV_1(dma_ch); |
| 1717 | 1582 | |
| 1718 | | if(state->m_scu_index[dma_ch] == 0) { state->m_scu_index[dma_ch] = state->m_scu_dst[0]; } |
| 1583 | if(state->m_scu.index[dma_ch] == 0) { state->m_scu.index[dma_ch] = state->m_scu.dst[0]; } |
| 1719 | 1584 | |
| 1720 | 1585 | do{ |
| 1721 | | tmp_src = state->m_scu_index[dma_ch]; |
| 1586 | tmp_src = state->m_scu.index[dma_ch]; |
| 1722 | 1587 | |
| 1723 | | state->m_scu_size[dma_ch] = space->read_dword(state->m_scu_index[dma_ch]); |
| 1724 | | state->m_scu_src[dma_ch] = space->read_dword(state->m_scu_index[dma_ch]+8); |
| 1725 | | state->m_scu_dst[dma_ch] = space->read_dword(state->m_scu_index[dma_ch]+4); |
| 1588 | state->m_scu.size[dma_ch] = space->read_dword(state->m_scu.index[dma_ch]); |
| 1589 | state->m_scu.src[dma_ch] = space->read_dword(state->m_scu.index[dma_ch]+8); |
| 1590 | state->m_scu.dst[dma_ch] = space->read_dword(state->m_scu.index[dma_ch]+4); |
| 1726 | 1591 | |
| 1727 | 1592 | /*Indirect Mode end factor*/ |
| 1728 | | if(state->m_scu_src[dma_ch] & 0x80000000) |
| 1593 | if(state->m_scu.src[dma_ch] & 0x80000000) |
| 1729 | 1594 | job_done = 1; |
| 1730 | 1595 | |
| 1731 | 1596 | #if 0 |
| r11640 | r11641 | |
| 1736 | 1601 | } |
| 1737 | 1602 | #endif |
| 1738 | 1603 | |
| 1739 | | if(LOG_SCU) logerror("DMA lv %d indirect mode transfer START\n" |
| 1740 | | "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu_src[dma_ch],state->m_scu_dst[dma_ch],state->m_scu_size[dma_ch]); |
| 1741 | | if(LOG_SCU) logerror("Start Add %04x Destination Add %04x\n",state->m_scu_src_add[dma_ch],state->m_scu_dst_add[dma_ch]); |
| 1604 | if(LOG_SCU) printf("DMA lv %d indirect mode transfer START\n" |
| 1605 | "Start %08x End %08x Size %04x\n",dma_ch,state->m_scu.src[dma_ch],state->m_scu.dst[dma_ch],state->m_scu.size[dma_ch]); |
| 1606 | if(LOG_SCU) printf("Start Add %04x Destination Add %04x\n",state->m_scu.src_add[dma_ch],state->m_scu.dst_add[dma_ch]); |
| 1742 | 1607 | |
| 1743 | 1608 | //guess,but I believe it's right. |
| 1744 | | state->m_scu_src[dma_ch] &=0x07ffffff; |
| 1745 | | state->m_scu_dst[dma_ch] &=0x07ffffff; |
| 1746 | | state->m_scu_size[dma_ch] &= ((dma_ch == 0) ? 0xfffff : 0x1fff); |
| 1609 | state->m_scu.src[dma_ch] &=0x07ffffff; |
| 1610 | state->m_scu.dst[dma_ch] &=0x07ffffff; |
| 1611 | state->m_scu.size[dma_ch] &= ((dma_ch == 0) ? 0xfffff : 0x1fff); |
| 1747 | 1612 | |
| 1748 | | if(state->m_scu_size[dma_ch] == 0) { state->m_scu_size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; } |
| 1613 | if(state->m_scu.size[dma_ch] == 0) { state->m_scu.size[dma_ch] = (dma_ch == 0) ? 0x00100000 : 0x2000; } |
| 1749 | 1614 | |
| 1750 | | for (; state->m_scu_size[dma_ch] > 0; state->m_scu_size[dma_ch]-=state->m_scu_dst_add[dma_ch]) |
| 1615 | for (; state->m_scu.size[dma_ch] > 0; state->m_scu.size[dma_ch]-=state->m_scu.dst_add[dma_ch]) |
| 1751 | 1616 | { |
| 1752 | | if(state->m_scu_dst_add[dma_ch] == 2) |
| 1753 | | space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch])); |
| 1617 | if(state->m_scu.dst_add[dma_ch] == 2) |
| 1618 | space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch])); |
| 1754 | 1619 | else |
| 1755 | 1620 | { |
| 1756 | 1621 | /* some games, eg columns97 are a bit weird, I'm not sure this is correct |
| r11640 | r11641 | |
| 1758 | 1623 | can't access 2 byte boundaries, and the end of the sprite list never gets marked, |
| 1759 | 1624 | the length of the transfer is also set to a 2 byte boundary, maybe the add values |
| 1760 | 1625 | should be different, I don't know */ |
| 1761 | | space->write_word(state->m_scu_dst[dma_ch],space->read_word(state->m_scu_src[dma_ch])); |
| 1762 | | space->write_word(state->m_scu_dst[dma_ch]+2,space->read_word(state->m_scu_src[dma_ch]+2)); |
| 1626 | space->write_word(state->m_scu.dst[dma_ch],space->read_word(state->m_scu.src[dma_ch])); |
| 1627 | space->write_word(state->m_scu.dst[dma_ch]+2,space->read_word(state->m_scu.src[dma_ch]+2)); |
| 1763 | 1628 | } |
| 1764 | | state->m_scu_dst[dma_ch]+=state->m_scu_dst_add[dma_ch]; |
| 1765 | | state->m_scu_src[dma_ch]+=state->m_scu_src_add[dma_ch]; |
| 1629 | state->m_scu.dst[dma_ch]+=state->m_scu.dst_add[dma_ch]; |
| 1630 | state->m_scu.src[dma_ch]+=state->m_scu.src_add[dma_ch]; |
| 1766 | 1631 | } |
| 1767 | 1632 | |
| 1768 | | //if(DRUP(0)) space->write_dword(tmp_src+8,state->m_scu_src[0]|job_done ? 0x80000000 : 0); |
| 1769 | | //if(DWUP(0)) space->write_dword(tmp_src+4,state->m_scu_dst[0]); |
| 1633 | //if(DRUP(0)) space->write_dword(tmp_src+8,state->m_scu.src[0]|job_done ? 0x80000000 : 0); |
| 1634 | //if(DWUP(0)) space->write_dword(tmp_src+4,state->m_scu.dst[0]); |
| 1770 | 1635 | |
| 1771 | | state->m_scu_index[dma_ch] = tmp_src+0xc; |
| 1636 | state->m_scu.index[dma_ch] = tmp_src+0xc; |
| 1772 | 1637 | |
| 1773 | 1638 | }while(job_done == 0); |
| 1774 | 1639 | |
| 1775 | 1640 | /*TODO: timing of this, clean up */ |
| 1776 | 1641 | switch(dma_ch) |
| 1777 | 1642 | { |
| 1778 | | case 0: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv0_ended)); break; |
| 1779 | | case 1: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv1_ended)); break; |
| 1780 | | case 2: space->machine().scheduler().timer_set(attotime::from_usec(300), FUNC(dma_lv2_ended)); break; |
| 1643 | case 0: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv0_ended)); break; |
| 1644 | case 1: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv1_ended)); break; |
| 1645 | case 2: space->machine().scheduler().timer_set(attotime::from_usec(3000), FUNC(dma_lv2_ended)); break; |
| 1781 | 1646 | } |
| 1782 | 1647 | } |
| 1783 | 1648 | |
| r11640 | r11641 | |
| 1805 | 1670 | /* communication,SLAVE CPU acquires data from the MASTER CPU and triggers an irq. */ |
| 1806 | 1671 | static WRITE32_HANDLER( minit_w ) |
| 1807 | 1672 | { |
| 1808 | | logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data); |
| 1809 | | space->machine().scheduler().boost_interleave(minit_boost_timeslice, attotime::from_usec(minit_boost)); |
| 1673 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1674 | |
| 1675 | //logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data); |
| 1676 | space->machine().scheduler().boost_interleave(state->m_minit_boost_timeslice, attotime::from_usec(state->m_minit_boost)); |
| 1810 | 1677 | space->machine().scheduler().trigger(1000); |
| 1811 | | sh2_set_frt_input(space->machine().device("slave"), PULSE_LINE); |
| 1678 | sh2_set_frt_input(state->m_slave, PULSE_LINE); |
| 1812 | 1679 | } |
| 1813 | 1680 | |
| 1814 | 1681 | static WRITE32_HANDLER( sinit_w ) |
| 1815 | 1682 | { |
| 1816 | | logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data); |
| 1817 | | space->machine().scheduler().boost_interleave(sinit_boost_timeslice, attotime::from_usec(sinit_boost)); |
| 1818 | | sh2_set_frt_input(space->machine().device("maincpu"), PULSE_LINE); |
| 1683 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1684 | |
| 1685 | //logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space->device().tag(), cpu_get_pc(&space->device()),data); |
| 1686 | space->machine().scheduler().boost_interleave(state->m_sinit_boost_timeslice, attotime::from_usec(state->m_sinit_boost)); |
| 1687 | sh2_set_frt_input(state->m_maincpu, PULSE_LINE); |
| 1819 | 1688 | } |
| 1820 | 1689 | |
| 1821 | | static READ32_HANDLER(saturn_m_backupram_r) |
| 1690 | static READ32_HANDLER(saturn_backupram_r) |
| 1822 | 1691 | { |
| 1823 | 1692 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1824 | 1693 | |
| 1825 | 1694 | return state->m_backupram[offset] & 0x00ff00ff; // yes, it makes sure the "holes" are there. |
| 1826 | 1695 | } |
| 1827 | 1696 | |
| 1828 | | static WRITE32_HANDLER(saturn_m_backupram_w) |
| 1697 | static WRITE32_HANDLER(saturn_backupram_w) |
| 1829 | 1698 | { |
| 1830 | 1699 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| 1831 | 1700 | |
| r11640 | r11641 | |
| 1867 | 1736 | static ADDRESS_MAP_START( saturn_mem, AS_PROGRAM, 32 ) |
| 1868 | 1737 | AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_SHARE("share6") // bios |
| 1869 | 1738 | AM_RANGE(0x00100000, 0x0010007f) AM_READWRITE8(saturn_SMPC_r8, saturn_SMPC_w8,0xffffffff) |
| 1870 | | AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_m_backupram_r, saturn_m_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram) |
| 1739 | AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_backupram_r, saturn_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram) |
| 1871 | 1740 | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_MIRROR(0x100000) AM_SHARE("share2") AM_BASE_MEMBER(saturn_state,m_workram_l) |
| 1872 | 1741 | AM_RANGE(0x01000000, 0x01000003) AM_MIRROR(0x7ffffc) AM_WRITE(minit_w) |
| 1873 | 1742 | AM_RANGE(0x01800000, 0x01800003) AM_MIRROR(0x7ffffc) AM_WRITE(sinit_w) |
| r11640 | r11641 | |
| 1877 | 1746 | AM_RANGE(0x05a00000, 0x05a7ffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff) |
| 1878 | 1747 | AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16("scsp", scsp_r, scsp_w, 0xffffffff) |
| 1879 | 1748 | /* VDP1 */ |
| 1880 | | /*0x05c00000-0x05c7ffff VRAM*/ |
| 1881 | | /*0x05c80000-0x05c9ffff Frame Buffer 0*/ |
| 1882 | | /*0x05ca0000-0x05cbffff Frame Buffer 1*/ |
| 1883 | | /*0x05d00000-0x05d7ffff VDP1 Regs */ |
| 1884 | | AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(stv_vdp1_vram_r, stv_vdp1_vram_w) |
| 1885 | | AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(stv_vdp1_framebuffer0_r, stv_vdp1_framebuffer0_w) |
| 1886 | | AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(stv_vdp1_regs_r, stv_vdp1_regs_w) |
| 1887 | | AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(stv_vdp2_vram_r, stv_vdp2_vram_w) |
| 1888 | | AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(stv_vdp2_cram_r, stv_vdp2_cram_w) |
| 1889 | | AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(stv_vdp2_regs_r, stv_vdp2_regs_w) |
| 1749 | AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(saturn_vdp1_vram_r, saturn_vdp1_vram_w) |
| 1750 | AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(saturn_vdp1_framebuffer0_r, saturn_vdp1_framebuffer0_w) |
| 1751 | AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(saturn_vdp1_regs_r, saturn_vdp1_regs_w) |
| 1752 | AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(saturn_vdp2_vram_r, saturn_vdp2_vram_w) |
| 1753 | AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(saturn_vdp2_cram_r, saturn_vdp2_cram_w) |
| 1754 | AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(saturn_vdp2_regs_r, saturn_vdp2_regs_w) |
| 1890 | 1755 | AM_RANGE(0x05fe0000, 0x05fe00cf) AM_READWRITE(saturn_scu_r, saturn_scu_w) |
| 1891 | 1756 | AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_MIRROR(0x01f00000) AM_SHARE("share3") AM_BASE_MEMBER(saturn_state,m_workram_h) |
| 1892 | 1757 | AM_RANGE(0x20000000, 0x2007ffff) AM_ROM AM_SHARE("share6") // bios mirror |
| r11640 | r11641 | |
| 1896 | 1761 | static ADDRESS_MAP_START( stv_mem, AS_PROGRAM, 32 ) |
| 1897 | 1762 | AM_RANGE(0x00000000, 0x0007ffff) AM_ROM AM_SHARE("share6") // bios |
| 1898 | 1763 | AM_RANGE(0x00100000, 0x0010007f) AM_READWRITE8(stv_SMPC_r8, stv_SMPC_w8,0xffffffff) |
| 1899 | | AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_m_backupram_r,saturn_m_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram) |
| 1764 | AM_RANGE(0x00180000, 0x0018ffff) AM_READWRITE(saturn_backupram_r,saturn_backupram_w) AM_SHARE("share1") AM_BASE_MEMBER(saturn_state,m_backupram) |
| 1900 | 1765 | AM_RANGE(0x00200000, 0x002fffff) AM_RAM AM_MIRROR(0x100000) AM_SHARE("share2") AM_BASE_MEMBER(saturn_state,m_workram_l) |
| 1901 | | AM_RANGE(0x00400000, 0x0040001f) AM_READWRITE(stv_io_r32, stv_io_w32) AM_BASE(&ioga) AM_SHARE("share4") AM_MIRROR(0x20) |
| 1766 | AM_RANGE(0x00400000, 0x0040001f) AM_READWRITE(stv_io_r32, stv_io_w32) AM_BASE_MEMBER(saturn_state,m_ioga) AM_SHARE("share4") AM_MIRROR(0x20) |
| 1902 | 1767 | AM_RANGE(0x01000000, 0x01000003) AM_MIRROR(0x7ffffc) AM_WRITE(minit_w) |
| 1903 | 1768 | AM_RANGE(0x01800000, 0x01800003) AM_MIRROR(0x7ffffc) AM_WRITE(sinit_w) |
| 1904 | 1769 | AM_RANGE(0x02000000, 0x04ffffff) AM_ROM AM_SHARE("share7") AM_REGION("abus", 0) // cartridge |
| r11640 | r11641 | |
| 1907 | 1772 | AM_RANGE(0x05a00000, 0x05afffff) AM_READWRITE16(saturn_soundram_r, saturn_soundram_w,0xffffffff) |
| 1908 | 1773 | AM_RANGE(0x05b00000, 0x05b00fff) AM_DEVREADWRITE16("scsp", scsp_r, scsp_w, 0xffffffff) |
| 1909 | 1774 | /* VDP1 */ |
| 1910 | | AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(stv_vdp1_vram_r, stv_vdp1_vram_w) |
| 1911 | | AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(stv_vdp1_framebuffer0_r, stv_vdp1_framebuffer0_w) |
| 1912 | | AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(stv_vdp1_regs_r, stv_vdp1_regs_w) |
| 1913 | | AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(stv_vdp2_vram_r, stv_vdp2_vram_w) |
| 1914 | | AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(stv_vdp2_cram_r, stv_vdp2_cram_w) |
| 1915 | | AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(stv_vdp2_regs_r, stv_vdp2_regs_w) |
| 1775 | AM_RANGE(0x05c00000, 0x05c7ffff) AM_READWRITE(saturn_vdp1_vram_r, saturn_vdp1_vram_w) |
| 1776 | AM_RANGE(0x05c80000, 0x05cbffff) AM_READWRITE(saturn_vdp1_framebuffer0_r, saturn_vdp1_framebuffer0_w) |
| 1777 | AM_RANGE(0x05d00000, 0x05d0001f) AM_READWRITE(saturn_vdp1_regs_r, saturn_vdp1_regs_w) |
| 1778 | AM_RANGE(0x05e00000, 0x05efffff) AM_READWRITE(saturn_vdp2_vram_r, saturn_vdp2_vram_w) |
| 1779 | AM_RANGE(0x05f00000, 0x05f7ffff) AM_READWRITE(saturn_vdp2_cram_r, saturn_vdp2_cram_w) |
| 1780 | AM_RANGE(0x05f80000, 0x05fbffff) AM_READWRITE(saturn_vdp2_regs_r, saturn_vdp2_regs_w) |
| 1916 | 1781 | AM_RANGE(0x05fe0000, 0x05fe00cf) AM_READWRITE(saturn_scu_r, saturn_scu_w) |
| 1917 | 1782 | AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_MIRROR(0x01f00000) AM_SHARE("share3") AM_BASE_MEMBER(saturn_state,m_workram_h) |
| 1918 | 1783 | AM_RANGE(0x20000000, 0x2007ffff) AM_ROM AM_SHARE("share6") // bios mirror |
| r11640 | r11641 | |
| 2300 | 2165 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 2301 | 2166 | INPUT_PORTS_END |
| 2302 | 2167 | |
| 2168 | #ifdef UNUSED_FUNCTION |
| 2303 | 2169 | static WRITE32_HANDLER ( w60ffc44_write ) |
| 2304 | 2170 | { |
| 2305 | 2171 | saturn_state *state = space->machine().driver_data<saturn_state>(); |
| r11640 | r11641 | |
| 2319 | 2185 | logerror("cpu %s (PC=%08X): 60ffc48_write write = %08X & %08X\n", space->device().tag(), cpu_get_pc(&space->device()), data, mem_mask); |
| 2320 | 2186 | //minit_w(offset,data,mem_mask); |
| 2321 | 2187 | } |
| 2188 | #endif |
| 2322 | 2189 | |
| 2323 | 2190 | #ifdef UNUSED_FUNCTION |
| 2324 | 2191 | static void print_game_info(void); |
| r11640 | r11641 | |
| 2332 | 2199 | machine.base_datetime(systime); |
| 2333 | 2200 | |
| 2334 | 2201 | /* amount of time to boost interleave for on MINIT / SINIT, needed for communication to work */ |
| 2335 | | minit_boost = 400; |
| 2336 | | sinit_boost = 400; |
| 2337 | | minit_boost_timeslice = attotime::zero; |
| 2338 | | sinit_boost_timeslice = attotime::zero; |
| 2202 | state->m_minit_boost = 400; |
| 2203 | state->m_sinit_boost = 400; |
| 2204 | state->m_minit_boost_timeslice = attotime::zero; |
| 2205 | state->m_sinit_boost_timeslice = attotime::zero; |
| 2339 | 2206 | |
| 2340 | 2207 | state->m_smpc_ram = auto_alloc_array(machine, UINT8, 0x80); |
| 2341 | 2208 | state->m_scu_regs = auto_alloc_array(machine, UINT32, 0x100/4); |
| 2342 | | scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2); |
| 2209 | state->m_scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2); |
| 2343 | 2210 | |
| 2344 | 2211 | install_stvbios_speedups(machine); |
| 2345 | 2212 | |
| r11640 | r11641 | |
| 2350 | 2217 | sh2drc_set_options(machine.device("slave"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| 2351 | 2218 | |
| 2352 | 2219 | /* debug .. watch the command buffer rsgun, cottonbm etc. appear to use to communicate between cpus */ |
| 2353 | | machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) ); |
| 2354 | | machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) ); |
| 2355 | | machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) ); |
| 2356 | | machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) ); |
| 2220 | //machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) ); |
| 2221 | //machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) ); |
| 2222 | //machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc44, 0x60ffc47, FUNC(w60ffc44_write) ); |
| 2223 | //machine.device("slave")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0x60ffc48, 0x60ffc4b, FUNC(w60ffc48_write) ); |
| 2357 | 2224 | |
| 2358 | 2225 | state->m_smpc_ram[0x31] = 0x00; //CTG1=0 CTG0=0 (correct??) |
| 2359 | 2226 | // state->m_smpc_ram[0x33] = input_port_read(machine, "FAKE"); |
| r11640 | r11641 | |
| 2531 | 2398 | state->m_smpc_ram[0x2f]++; |
| 2532 | 2399 | |
| 2533 | 2400 | /* seconds from 9 -> 10*/ |
| 2534 | | if((state->m_smpc_ram[0x2f] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2f]+=0x10; state->m_smpc_ram[0x2f]&=0xf0; } |
| 2401 | if((state->m_smpc_ram[0x2f] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2f]+=0x10; state->m_smpc_ram[0x2f]&=0xf0; } |
| 2535 | 2402 | /* seconds from 59 -> 0 */ |
| 2536 | | if((state->m_smpc_ram[0x2f] & 0xf0) >= 0x60) { state->m_smpc_ram[0x2d]++; state->m_smpc_ram[0x2f] = 0; } |
| 2403 | if((state->m_smpc_ram[0x2f] & 0xf0) >= 0x60) { state->m_smpc_ram[0x2d]++; state->m_smpc_ram[0x2f] = 0; } |
| 2537 | 2404 | /* minutes from 9 -> 10 */ |
| 2538 | | if((state->m_smpc_ram[0x2d] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2d]+=0x10; state->m_smpc_ram[0x2d]&=0xf0; } |
| 2405 | if((state->m_smpc_ram[0x2d] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2d]+=0x10; state->m_smpc_ram[0x2d]&=0xf0; } |
| 2539 | 2406 | /* minutes from 59 -> 0 */ |
| 2540 | | if((state->m_smpc_ram[0x2d] & 0xf0) >= 0x60) { state->m_smpc_ram[0x2b]++; state->m_smpc_ram[0x2d] = 0; } |
| 2407 | if((state->m_smpc_ram[0x2d] & 0xf0) >= 0x60) { state->m_smpc_ram[0x2b]++; state->m_smpc_ram[0x2d] = 0; } |
| 2541 | 2408 | /* hours from 9 -> 10 */ |
| 2542 | | if((state->m_smpc_ram[0x2b] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2b]+=0x10; state->m_smpc_ram[0x2b]&=0xf0; } |
| 2409 | if((state->m_smpc_ram[0x2b] & 0x0f) >= 0x0a) { state->m_smpc_ram[0x2b]+=0x10; state->m_smpc_ram[0x2b]&=0xf0; } |
| 2543 | 2410 | /* hours from 23 -> 0 */ |
| 2544 | 2411 | if((state->m_smpc_ram[0x2b] & 0xff) >= 0x24) { state->m_smpc_ram[0x29]++; state->m_smpc_ram[0x27]+=0x10; state->m_smpc_ram[0x2b] = 0; } |
| 2545 | 2412 | /* week day name sunday -> monday */ |
| r11640 | r11641 | |
| 2597 | 2464 | // save states |
| 2598 | 2465 | state_save_register_global_pointer(machine, state->m_smpc_ram, 0x80); |
| 2599 | 2466 | state_save_register_global_pointer(machine, state->m_scu_regs, 0x100/4); |
| 2600 | | state_save_register_global_pointer(machine, scsp_regs, 0x1000/2); |
| 2601 | | // state_save_register_global(machine, stv_vblank); |
| 2602 | | // state_save_register_global(machine, stv_hblank); |
| 2467 | state_save_register_global_pointer(machine, state->m_scsp_regs, 0x1000/2); |
| 2603 | 2468 | state_save_register_global(machine, state->m_NMI_reset); |
| 2604 | 2469 | state_save_register_global(machine, state->m_en_68k); |
| 2605 | 2470 | state_save_register_global(machine, timer_0); |
| 2606 | 2471 | state_save_register_global(machine, timer_1); |
| 2607 | 2472 | // state_save_register_global(machine, scanline); |
| 2608 | | state_save_register_global(machine, IOSEL1); |
| 2609 | | state_save_register_global(machine, IOSEL2); |
| 2610 | | state_save_register_global(machine, EXLE1); |
| 2611 | | state_save_register_global(machine, EXLE2); |
| 2612 | | state_save_register_global(machine, PDR1); |
| 2613 | | state_save_register_global(machine, PDR2); |
| 2473 | state_save_register_global(machine, state->m_smpc.IOSEL1); |
| 2474 | state_save_register_global(machine, state->m_smpc.IOSEL2); |
| 2475 | state_save_register_global(machine, state->m_smpc.EXLE1); |
| 2476 | state_save_register_global(machine, state->m_smpc.EXLE2); |
| 2477 | state_save_register_global(machine, state->m_smpc.PDR1); |
| 2478 | state_save_register_global(machine, state->m_smpc.PDR2); |
| 2614 | 2479 | state_save_register_global(machine, port_sel); |
| 2615 | 2480 | state_save_register_global(machine, mux_data); |
| 2616 | 2481 | state_save_register_global(machine, scsp_last_line); |
| r11640 | r11641 | |
| 2627 | 2492 | state->m_smpc_ram[0x2d] = DectoBCD(systime.local_time.minute); |
| 2628 | 2493 | state->m_smpc_ram[0x2f] = DectoBCD(systime.local_time.second); |
| 2629 | 2494 | |
| 2630 | | stv_rtc_timer = machine.scheduler().timer_alloc(FUNC(stv_rtc_increment)); |
| 2495 | state->m_stv_rtc_timer = machine.scheduler().timer_alloc(FUNC(stv_rtc_increment)); |
| 2631 | 2496 | } |
| 2632 | 2497 | |
| 2633 | 2498 | |
| r11640 | r11641 | |
| 2639 | 2504 | // save states |
| 2640 | 2505 | state_save_register_global_pointer(machine, state->m_smpc_ram, 0x80); |
| 2641 | 2506 | state_save_register_global_pointer(machine, state->m_scu_regs, 0x100/4); |
| 2642 | | state_save_register_global_pointer(machine, scsp_regs, 0x1000/2); |
| 2643 | | state_save_register_global(machine, stv_vblank); |
| 2644 | | state_save_register_global(machine, stv_hblank); |
| 2507 | state_save_register_global_pointer(machine, state->m_scsp_regs, 0x1000/2); |
| 2645 | 2508 | state_save_register_global(machine, state->m_NMI_reset); |
| 2646 | 2509 | state_save_register_global(machine, state->m_en_68k); |
| 2647 | 2510 | state_save_register_global(machine, timer_0); |
| 2648 | 2511 | state_save_register_global(machine, timer_1); |
| 2649 | | state_save_register_global(machine, IOSEL1); |
| 2650 | | state_save_register_global(machine, IOSEL2); |
| 2651 | | state_save_register_global(machine, EXLE1); |
| 2652 | | state_save_register_global(machine, EXLE2); |
| 2653 | | state_save_register_global(machine, PDR1); |
| 2654 | | state_save_register_global(machine, PDR2); |
| 2512 | state_save_register_global(machine, state->m_smpc.IOSEL1); |
| 2513 | state_save_register_global(machine, state->m_smpc.IOSEL2); |
| 2514 | state_save_register_global(machine, state->m_smpc.EXLE1); |
| 2515 | state_save_register_global(machine, state->m_smpc.EXLE2); |
| 2516 | state_save_register_global(machine, state->m_smpc.PDR1); |
| 2517 | state_save_register_global(machine, state->m_smpc.PDR2); |
| 2655 | 2518 | // state_save_register_global(machine, port_sel); |
| 2656 | 2519 | // state_save_register_global(machine, mux_data); |
| 2657 | 2520 | state_save_register_global(machine, scsp_last_line); |
| 2658 | | state_save_register_global(machine, intback_stage); |
| 2659 | | state_save_register_global(machine, pmode); |
| 2660 | | state_save_register_global(machine, smpcSR); |
| 2661 | | state_save_register_global_array(machine, SMEM); |
| 2521 | state_save_register_global(machine, state->m_smpc.intback_stage); |
| 2522 | state_save_register_global(machine, state->m_smpc.pmode); |
| 2523 | state_save_register_global(machine, state->m_smpc.smpcSR); |
| 2524 | state_save_register_global_array(machine, state->m_smpc.SMEM); |
| 2662 | 2525 | |
| 2663 | 2526 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(stvcd_exit), &machine)); |
| 2664 | 2527 | } |
| r11640 | r11641 | |
| 2857 | 2720 | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE); |
| 2858 | 2721 | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); |
| 2859 | 2722 | |
| 2860 | | smpcSR = 0x40; // this bit is always on according to docs |
| 2723 | state->m_smpc.smpcSR = 0x40; // this bit is always on according to docs |
| 2861 | 2724 | |
| 2862 | 2725 | timer_0 = 0; |
| 2863 | 2726 | timer_1 = 0; |
| r11640 | r11641 | |
| 2915 | 2778 | vblank_out_timer->adjust(machine.primary_screen->time_until_pos(0)); |
| 2916 | 2779 | scan_timer->adjust(machine.primary_screen->time_until_pos(224, 352)); |
| 2917 | 2780 | |
| 2918 | | stv_rtc_timer->adjust(attotime::zero, 0, attotime::from_seconds(1)); |
| 2781 | state->m_stv_rtc_timer->adjust(attotime::zero, 0, attotime::from_seconds(1)); |
| 2919 | 2782 | state->m_prev_bankswitch = 0xff; |
| 2920 | 2783 | } |
| 2921 | 2784 | |
| r11640 | r11641 | |
| 3036 | 2899 | |
| 3037 | 2900 | static DEVICE_IMAGE_LOAD( stv_cart ) |
| 3038 | 2901 | { |
| 3039 | | // saturn_state *state = image.device().machine().driver_data<saturn_state>(); |
| 2902 | // saturn_state *state = image.device().machine().driver_data<saturn_state>(); |
| 3040 | 2903 | const struct stv_cart_region *stv_cart = &stv_cart_table[0], *this_cart; |
| 3041 | | //const char *pcb_name; |
| 2904 | //const char *pcb_name; |
| 3042 | 2905 | |
| 3043 | 2906 | /* First, determine where this cart has to be loaded */ |
| 3044 | 2907 | while (stv_cart->tag) |
| r11640 | r11641 | |
| 3078 | 2941 | } |
| 3079 | 2942 | |
| 3080 | 2943 | //if ((pcb_name = image.get_feature("pcb_type")) == NULL) |
| 3081 | | // return IMAGE_INIT_FAIL; |
| 2944 | // return IMAGE_INIT_FAIL; |
| 3082 | 2945 | |
| 3083 | 2946 | return IMAGE_INIT_PASS; |
| 3084 | 2947 | } |
| r11640 | r11641 | |
| 3108 | 2971 | saturn_state *state = machine.driver_data<saturn_state>(); |
| 3109 | 2972 | system_time systime; |
| 3110 | 2973 | |
| 3111 | | saturn_region = rgn; |
| 2974 | state->saturn_region = rgn; |
| 3112 | 2975 | |
| 3113 | 2976 | // set compatible options |
| 3114 | 2977 | sh2drc_set_options(machine.device("maincpu"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| r11640 | r11641 | |
| 3118 | 2981 | machine.current_datetime(systime); |
| 3119 | 2982 | |
| 3120 | 2983 | /* amount of time to boost interleave for on MINIT / SINIT, needed for communication to work */ |
| 3121 | | minit_boost = 400; |
| 3122 | | sinit_boost = 400; |
| 3123 | | minit_boost_timeslice = attotime::zero; |
| 3124 | | sinit_boost_timeslice = attotime::zero; |
| 2984 | state->m_minit_boost = 400; |
| 2985 | state->m_sinit_boost = 400; |
| 2986 | state->m_minit_boost_timeslice = attotime::zero; |
| 2987 | state->m_sinit_boost_timeslice = attotime::zero; |
| 3125 | 2988 | |
| 3126 | 2989 | state->m_smpc_ram = auto_alloc_array(machine, UINT8, 0x80); |
| 3127 | 2990 | state->m_scu_regs = auto_alloc_array(machine, UINT32, 0x100/4); |
| 3128 | | scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2); |
| 2991 | state->m_scsp_regs = auto_alloc_array(machine, UINT16, 0x1000/2); |
| 3129 | 2992 | |
| 3130 | 2993 | state->m_smpc_ram[0x23] = dec_2_bcd(systime.local_time.year / 100); |
| 3131 | 2994 | state->m_smpc_ram[0x25] = dec_2_bcd(systime.local_time.year % 100); |
| r11640 | r11641 | |
| 3281 | 3144 | ROM_REGION32_BE( 0x3000000, "game2", ROMREGION_ERASE00 ) |
| 3282 | 3145 | |
| 3283 | 3146 | ROM_REGION32_BE( 0x3000000, "game3", ROMREGION_ERASE00 ) |
| 3147 | |
| 3148 | ROM_REGION16_BE( 0x80, "eeprom", 0 ) // preconfigured to multi cart mode |
| 3149 | ROM_LOAD( "stvbios.nv", 0x0000, 0x0080, CRC(15432ae2) SHA1(7d9364d546f3d3f839ec36be148076f8d26a65a6) ) |
| 3284 | 3150 | ROM_END |
| 3285 | 3151 | |
| 3286 | 3152 | /* |
| r11640 | r11641 | |
| 3306 | 3172 | 0x2800000 - 0x2bfffff IC11 |
| 3307 | 3173 | 0x2c00000 - 0x2ffffff IC12 |
| 3308 | 3174 | |
| 3309 | | Update:Issue fixed,see stvhacks.c for more details (TODO: Clean-up that) |
| 3310 | 3175 | */ |
| 3311 | 3176 | |
| 3312 | 3177 | |
| r11640 | r11641 | |
| 4402 | 4267 | GAME( 1995, sandor, stvbios, stv, stv, sandor, ROT0, "Sega", "Puzzle & Action: Sando-R (J 951114 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4403 | 4268 | GAME( 1997, thunt, sandor, stv, stv, thunt, ROT0, "Sega", "Puzzle & Action: Treasure Hunt (JUET 970901 V2.00E)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4404 | 4269 | GAME( 1997, thuntk, sandor, stv, stv, sandor, ROT0, "Sega / Deniam", "Puzzle & Action: BoMulEul Chajara (JUET 970125 V2.00K)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4270 | GAME( 1995, smleague, stvbios, stv, stv, smleague, ROT0, "Sega", "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4271 | GAME( 1995, finlarch, smleague,stv, stv, finlarch, ROT0, "Sega", "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4405 | 4272 | GAME( 1996, sokyugrt, stvbios, stv, stv, sokyugrt, ROT0, "Raizing / Eighting", "Soukyugurentai / Terra Diver (JUET 960821 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4406 | 4273 | GAME( 1995, suikoenb, stvbios, stv, stv, suikoenb, ROT0, "Data East", "Suikoenbu / Outlaws of the Lost Dynasty (JUETL 950314 V2.001)", GAME_IMPERFECT_SOUND ) |
| 4407 | 4274 | GAME( 1996, vfkids, stvbios, stv, stv, stv, ROT0, "Sega", "Virtua Fighter Kids (JUET 960319 V0.000)", GAME_IMPERFECT_SOUND ) |
| r11640 | r11641 | |
| 4411 | 4278 | /* Almost */ |
| 4412 | 4279 | GAME( 1997, vmahjong, stvbios, stv, stvmp, stv, ROT0, "Micronet", "Virtual Mahjong (J 961214 V1.000)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4413 | 4280 | GAME( 1998, twcup98, stvbios, stv, stv, twcup98, ROT0, "Tecmo", "Tecmo World Cup '98 (JUET 980410 V1.000)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS|GAME_NOT_WORKING ) // player movement |
| 4414 | | GAME( 1995, smleague, stvbios, stv, stv, smleague, ROT0, "Sega", "Super Major League (U 960108 V1.000)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4415 | | GAME( 1995, finlarch, smleague,stv, stv, finlarch, ROT0, "Sega", "Final Arch (J 950714 V1.001)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4416 | 4281 | GAME( 1998, elandore, stvbios, stv, stv, elandore, ROT0, "Sai-Mate", "Touryuu Densetsu Elan-Doree / Elan Doree - Legend of Dragoon (JUET 980922 V1.006)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 4417 | 4282 | |
| 4418 | 4283 | /* Unemulated printer device */ |
src/osd/windows/winmain.c
| r11640 | r11641 | |
| 327 | 327 | { WINOPTION_FILTER ";d3dfilter;flt", "1", OPTION_BOOLEAN, "enable bilinear filtering on screen output" }, |
| 328 | 328 | |
| 329 | 329 | // post-processing options |
| 330 | | { NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, |
| 331 | | { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" }, |
| 332 | | { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" }, |
| 333 | | { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" }, |
| 330 | { NULL, NULL, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, |
| 331 | { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enable HLSL post-processing (PS3.0 required)" }, |
| 332 | { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" }, |
| 333 | { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)", "0.0", OPTION_FLOAT, "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" }, |
| 334 | 334 | { WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)", "aperture.png", OPTION_STRING, "shadow mask texture name" }, |
| 335 | | { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww", "640", OPTION_INTEGER, "shadow mask width, in phosphor dots" }, |
| 335 | { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww", "640", OPTION_INTEGER, "shadow mask width, in phosphor dots" }, |
| 336 | 336 | { WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh", "480", OPTION_INTEGER, "shadow mask height, in phosphor dots" }, |
| 337 | 337 | { WINOPTION_SHADOW_MASK_USIZE";fs_shadwu(0.0-1.0)", "0.1875", OPTION_FLOAT, "shadow mask texture size in U direction" }, |
| 338 | 338 | { WINOPTION_SHADOW_MASK_VSIZE";fs_shadwv(0.0-1.0)", "0.1875", OPTION_FLOAT, "shadow mask texture size in V direction" }, |
| 339 | | { WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative X direction, multiple" }, |
| 340 | | { WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative Y direction, multiple" }, |
| 341 | | { WINOPTION_CURVATURE";fs_curv(0.0-4.0)", "0.0", OPTION_FLOAT, "screen curvature amount" }, |
| 342 | | { WINOPTION_SCREEN_SCALE_TOP";fs_scalex(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, top" }, |
| 343 | | { WINOPTION_SCREEN_SCALE_BOTTOM";fs_scaley(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, bottom" }, |
| 339 | { WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative X direction, multiple" }, |
| 340 | { WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)", "1.0", OPTION_FLOAT, "oversample amount in screen-relative Y direction, multiple" }, |
| 341 | { WINOPTION_CURVATURE";fs_curv(0.0-4.0)", "0.0", OPTION_FLOAT, "screen curvature amount" }, |
| 342 | { WINOPTION_SCREEN_SCALE_TOP";fs_scalex(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, top" }, |
| 343 | { WINOPTION_SCREEN_SCALE_BOTTOM";fs_scaley(0.0-2.0)", "1.0", OPTION_FLOAT, "screen scale, bottom" }, |
| 344 | 344 | /* Beam-related values below this line*/ |
| 345 | | { WINOPTION_PINCUSHION";fs_pin(0.0-4.0)", "0.0", OPTION_FLOAT, "pincushion amount" }, |
| 346 | | { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" }, |
| 347 | | { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" }, |
| 348 | | { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" }, |
| 349 | | { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.6", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" }, |
| 350 | | { WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" }, |
| 351 | | { WINOPTION_DEFOCUS_X";fs_focusx(0.0-16.0)", "0.0", OPTION_FLOAT, "overall defocus scaling value in screen-relative X direction" }, |
| 352 | | { WINOPTION_DEFOCUS_Y";fs_focusy(0.0-16.0)", "0.0", OPTION_FLOAT, "overall defocus scaling value in screen-relative Y direction" }, |
| 353 | | { WINOPTION_RED_CONVERGE_X";fs_redcvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "red convergence in screen-relative X direction" }, |
| 354 | | { WINOPTION_RED_CONVERGE_Y";fs_redcvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "red convergence in screen-relative Y direction" }, |
| 355 | | { WINOPTION_GREEN_CONVERGE_X";fs_grncvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "green convergence in screen-relative X direction" }, |
| 356 | | { WINOPTION_GREEN_CONVERGE_Y";fs_grncvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "green convergence in screen-relative Y direction" }, |
| 357 | | { WINOPTION_BLUE_CONVERGE_X";fs_blucvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "blue convergence in screen-relative X direction" }, |
| 358 | | { WINOPTION_BLUE_CONVERGE_Y";fs_blucvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "blue convergence in screen-relative Y direction" }, |
| 359 | | { WINOPTION_RED_RADIAL_CONVERGE_X";fs_redrcvx(-16 - 16)", "0.0", OPTION_FLOAT, "red radial convergence in screen-relative X direction" }, |
| 360 | | { WINOPTION_RED_RADIAL_CONVERGE_Y";fs_redrcvy(-16 - 16)", "0.0", OPTION_FLOAT, "red radial convergence in screen-relative Y direction" }, |
| 361 | | { WINOPTION_GREEN_RADIAL_CONVERGE_X";fs_grnrcvx(-16 - 16)", "0.0", OPTION_FLOAT, "green radial convergence in screen-relative X direction" }, |
| 362 | | { WINOPTION_GREEN_RADIAL_CONVERGE_Y";fs_grnrcvy(-16 - 16)", "0.0", OPTION_FLOAT, "green radial convergence in screen-relative Y direction" }, |
| 363 | | { WINOPTION_BLUE_RADIAL_CONVERGE_X";fs_blurcvx(-16 - 16)", "0.0", OPTION_FLOAT, "blue radial convergence in screen-relative X direction" }, |
| 364 | | { WINOPTION_BLUE_RADIAL_CONVERGE_Y";fs_blurcvy(-16 - 16)", "0.0", OPTION_FLOAT, "blue radial convergence in screen-relative Y direction" }, |
| 345 | { WINOPTION_PINCUSHION";fs_pin(0.0-4.0)", "0.0", OPTION_FLOAT, "pincushion amount" }, |
| 346 | { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)", "0.0", OPTION_FLOAT, "overall alpha scaling value for scanlines" }, |
| 347 | { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)", "1.0", OPTION_FLOAT, "overall height scaling value for scanlines" }, |
| 348 | { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)", "1.0", OPTION_FLOAT, "overall brightness scaling value for scanlines (multiplicative)" }, |
| 349 | { WINOPTION_SCANLINE_BRIGHT_OFFSET";fs_scanbo(0.0-1.0)", "0.6", OPTION_FLOAT, "overall brightness offset value for scanlines (additive)" }, |
| 350 | { WINOPTION_SCANLINE_OFFSET";fs_scanjt(0.0-4.0)", "0.0", OPTION_FLOAT, "overall interlace jitter scaling value for scanlines" }, |
| 351 | { WINOPTION_DEFOCUS_X";fs_focusx(0.0-16.0)", "0.0", OPTION_FLOAT, "overall defocus scaling value in screen-relative X direction" }, |
| 352 | { WINOPTION_DEFOCUS_Y";fs_focusy(0.0-16.0)", "0.0", OPTION_FLOAT, "overall defocus scaling value in screen-relative Y direction" }, |
| 353 | { WINOPTION_RED_CONVERGE_X";fs_redcvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "red convergence in screen-relative X direction" }, |
| 354 | { WINOPTION_RED_CONVERGE_Y";fs_redcvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "red convergence in screen-relative Y direction" }, |
| 355 | { WINOPTION_GREEN_CONVERGE_X";fs_grncvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "green convergence in screen-relative X direction" }, |
| 356 | { WINOPTION_GREEN_CONVERGE_Y";fs_grncvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "green convergence in screen-relative Y direction" }, |
| 357 | { WINOPTION_BLUE_CONVERGE_X";fs_blucvx(-1.0-1.0)", "0.0", OPTION_FLOAT, "blue convergence in screen-relative X direction" }, |
| 358 | { WINOPTION_BLUE_CONVERGE_Y";fs_blucvy(-1.0-1.0)", "0.0", OPTION_FLOAT, "blue convergence in screen-relative Y direction" }, |
| 359 | { WINOPTION_RED_RADIAL_CONVERGE_X";fs_redrcvx(-16 - 16)", "0.0", OPTION_FLOAT, "red radial convergence in screen-relative X direction" }, |
| 360 | { WINOPTION_RED_RADIAL_CONVERGE_Y";fs_redrcvy(-16 - 16)", "0.0", OPTION_FLOAT, "red radial convergence in screen-relative Y direction" }, |
| 361 | { WINOPTION_GREEN_RADIAL_CONVERGE_X";fs_grnrcvx(-16 - 16)", "0.0", OPTION_FLOAT, "green radial convergence in screen-relative X direction" }, |
| 362 | { WINOPTION_GREEN_RADIAL_CONVERGE_Y";fs_grnrcvy(-16 - 16)", "0.0", OPTION_FLOAT, "green radial convergence in screen-relative Y direction" }, |
| 363 | { WINOPTION_BLUE_RADIAL_CONVERGE_X";fs_blurcvx(-16 - 16)", "0.0", OPTION_FLOAT, "blue radial convergence in screen-relative X direction" }, |
| 364 | { WINOPTION_BLUE_RADIAL_CONVERGE_Y";fs_blurcvy(-16 - 16)", "0.0", OPTION_FLOAT, "blue radial convergence in screen-relative Y direction" }, |
| 365 | 365 | /* RGB colorspace convolution below this line */ |
| 366 | | { WINOPTION_RED_MATRIX_R";fs_matrr(-2.0-2.0)", "1.0", OPTION_FLOAT, "red output signal generated by red input signal" }, |
| 367 | | { WINOPTION_RED_MATRIX_G";fs_matrg(-2.0-2.0)", "0.0", OPTION_FLOAT, "red output signal generated by green input signal" }, |
| 368 | | { WINOPTION_RED_MATRIX_B";fs_matrb(-2.0-2.0)", "0.0", OPTION_FLOAT, "red output signal generated by blue input signal" }, |
| 369 | | { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by red input signal" }, |
| 370 | | { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)", "1.0", OPTION_FLOAT, "green output signal generated by green input signal" }, |
| 371 | | { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by blue input signal" }, |
| 372 | | { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by red input signal" }, |
| 373 | | { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by green input signal" }, |
| 374 | | { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)", "1.0", OPTION_FLOAT, "blue output signal generated by blue input signal" }, |
| 375 | | { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by red input signal" }, |
| 376 | | { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)", "1.0", OPTION_FLOAT, "green output signal generated by green input signal" }, |
| 377 | | { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by blue input signal" }, |
| 378 | | { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by red input signal" }, |
| 379 | | { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by green input signal" }, |
| 380 | | { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)", "1.0", OPTION_FLOAT, "blue output signal generated by blue input signal" }, |
| 366 | { WINOPTION_RED_MATRIX_R";fs_matrr(-2.0-2.0)", "1.0", OPTION_FLOAT, "red output signal generated by red input signal" }, |
| 367 | { WINOPTION_RED_MATRIX_G";fs_matrg(-2.0-2.0)", "0.0", OPTION_FLOAT, "red output signal generated by green input signal" }, |
| 368 | { WINOPTION_RED_MATRIX_B";fs_matrb(-2.0-2.0)", "0.0", OPTION_FLOAT, "red output signal generated by blue input signal" }, |
| 369 | { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by red input signal" }, |
| 370 | { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)", "1.0", OPTION_FLOAT, "green output signal generated by green input signal" }, |
| 371 | { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by blue input signal" }, |
| 372 | { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by red input signal" }, |
| 373 | { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by green input signal" }, |
| 374 | { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)", "1.0", OPTION_FLOAT, "blue output signal generated by blue input signal" }, |
| 375 | { WINOPTION_GREEN_MATRIX_R";fs_matgr(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by red input signal" }, |
| 376 | { WINOPTION_GREEN_MATRIX_G";fs_matgg(-2.0-2.0)", "1.0", OPTION_FLOAT, "green output signal generated by green input signal" }, |
| 377 | { WINOPTION_GREEN_MATRIX_B";fs_matgb(-2.0-2.0)", "0.0", OPTION_FLOAT, "green output signal generated by blue input signal" }, |
| 378 | { WINOPTION_BLUE_MATRIX_R";fs_matbr(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by red input signal" }, |
| 379 | { WINOPTION_BLUE_MATRIX_G";fs_matbg(-2.0-2.0)", "0.0", OPTION_FLOAT, "blue output signal generated by green input signal" }, |
| 380 | { WINOPTION_BLUE_MATRIX_B";fs_matbb(-2.0-2.0)", "1.0", OPTION_FLOAT, "blue output signal generated by blue input signal" }, |
| 381 | 381 | { WINOPTION_SATURATION";fs_sat(0.0-4.0)", "1.0", OPTION_FLOAT, "saturation scaling value" }, |
| 382 | 382 | { WINOPTION_RED_OFFSET";fs_redoff(-1.0-1.0)", "0.0", OPTION_FLOAT, "red signal offset value (additive)" }, |
| 383 | 383 | { WINOPTION_GREEN_OFFSET";fs_grnoff(-1.0-1.0)", "0.0", OPTION_FLOAT, "green signal offset value (additive)" }, |
| r11640 | r11641 | |
| 385 | 385 | { WINOPTION_RED_SCALE";fs_redmul(0.0-2.0)", "1.0", OPTION_FLOAT, "red signal scaling value (multiplicative)" }, |
| 386 | 386 | { WINOPTION_GREEN_SCALE";fs_grnmul(0.0-2.0)", "1.0", OPTION_FLOAT, "green signal scaling value (multiplicative)" }, |
| 387 | 387 | { WINOPTION_BLUE_SCALE";fs_blumul(0.0-2.0)", "1.0", OPTION_FLOAT, "blue signal scaling value (multiplicative)" }, |
| 388 | | { WINOPTION_RED_POWER";fs_redpow(0.01-32.0)", "1.0", OPTION_FLOAT, "red signal power value (exponential)" }, |
| 389 | | { WINOPTION_GREEN_POWER";fs_grnpow(0.01-32.0)", "1.0", OPTION_FLOAT, "green signal power value (exponential)" }, |
| 390 | | { WINOPTION_BLUE_POWER";fs_blupow(0.01-32.0)", "1.0", OPTION_FLOAT, "blue signal power value (exponential)" }, |
| 388 | { WINOPTION_RED_POWER";fs_redpow(0.01-32.0)", "1.0", OPTION_FLOAT, "red signal power value (exponential)" }, |
| 389 | { WINOPTION_GREEN_POWER";fs_grnpow(0.01-32.0)", "1.0", OPTION_FLOAT, "green signal power value (exponential)" }, |
| 390 | { WINOPTION_BLUE_POWER";fs_blupow(0.01-32.0)", "1.0", OPTION_FLOAT, "blue signal power value (exponential)" }, |
| 391 | 391 | { WINOPTION_RED_FLOOR";fs_redfl(0.0-1.0)", "0.0", OPTION_FLOAT, "red signal floor level" }, |
| 392 | 392 | { WINOPTION_GREEN_FLOOR";fs_grnfl(0.0-1.0)", "0.0", OPTION_FLOAT, "green signal floor level" }, |
| 393 | 393 | { WINOPTION_BLUE_FLOOR";fs_blufl(0.0-1.0)", "0.0", OPTION_FLOAT, "blue signal floor level" }, |
| r11640 | r11641 | |
| 395 | 395 | { WINOPTION_GREEN_PHOSPHOR";fs_grnpho(0.0-1.0)", "0.0", OPTION_FLOAT, "green phosphorescence decay rate (0.0 is instant, 1.0 is forever)" }, |
| 396 | 396 | { WINOPTION_BLUE_PHOSPHOR";fs_grnpho(0.0-1.0)", "0.0", OPTION_FLOAT, "blue phosphorescence decay rate (0.0 is instant, 1.0 is forever)" }, |
| 397 | 397 | /* NTSC simulation below this line */ |
| 398 | | { WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable YIQ-space HLSL post-processing" }, |
| 398 | { WINOPTION_YIQ_ENABLE";yiq", "0", OPTION_BOOLEAN, "enable YIQ-space HLSL post-processing" }, |
| 399 | 399 | { WINOPTION_YIQ_WVALUE";yiqw", "4.1187867", OPTION_FLOAT, "W value for YIQ signal processing" }, |
| 400 | | { WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for YIQ signal processing" }, |
| 400 | { WINOPTION_YIQ_AVALUE";yiqa", "0.5", OPTION_FLOAT, "A value for YIQ signal processing" }, |
| 401 | 401 | { WINOPTION_YIQ_BVALUE";yiqb", "0.5", OPTION_FLOAT, "B value for YIQ signal processing" }, |
| 402 | | { WINOPTION_YIQ_FSCVALUE";yiqfsc", "1.5", OPTION_FLOAT, "Fsc value for YIQ signal processing" }, |
| 403 | | { WINOPTION_YIQ_FSCSCALE";yiqfscs", "1.0", OPTION_FLOAT, "Incoming Fsc scaling value for YIQ signal processing" }, |
| 402 | { WINOPTION_YIQ_FSCVALUE";yiqfsc", "1.5", OPTION_FLOAT, "Fsc value for YIQ signal processing" }, |
| 403 | { WINOPTION_YIQ_FSCSCALE";yiqfscs", "1.0", OPTION_FLOAT, "Incoming Fsc scaling value for YIQ signal processing" }, |
| 404 | 404 | { WINOPTION_YIQ_PHASE_COUNT";yiqp", "2", OPTION_INTEGER, "Phase Count value for YIQ signal processing" }, |
| 405 | 405 | |
| 406 | 406 | // per-window options |
| r11640 | r11641 | |
| 449 | 449 | { NULL } |
| 450 | 450 | }; |
| 451 | 451 | |
| 452 | | |
| 453 | | |
| 454 | 452 | //************************************************************************** |
| 455 | 453 | // MAIN ENTRY POINT |
| 456 | 454 | //************************************************************************** |