src/mess/video/wswan.c
| r4212 | r4213 | |
| 16 | 16 | |
| 17 | 17 | INLINE void wswan_plot_pixel(int x, int y, int pen) { |
| 18 | 18 | y += 5*8; |
| 19 | | if ( vdp.display_vertical ) { |
| 19 | if ( wswan_vdp.display_vertical ) { |
| 20 | 20 | *BITMAP_ADDR16(tmpbitmap, 28*8 - 1 - x, y) = pen; |
| 21 | 21 | } else { |
| 22 | 22 | *BITMAP_ADDR16(tmpbitmap, y, x) = pen; |
| r4212 | r4213 | |
| 25 | 25 | |
| 26 | 26 | INLINE void wswan_fillbitmap( int pen, rectangle *rec ) { |
| 27 | 27 | /* Fill empty area above line 0 when filling line 0 */ |
| 28 | | if ( vdp.current_line != 0 ) { |
| 28 | if ( wswan_vdp.current_line != 0 ) { |
| 29 | 29 | rec->min_y = rec->min_y + 5*8; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /* Fill empty area below line 143 when filling line 143 */ |
| 33 | | if ( vdp.current_line != 143 ) { |
| 33 | if ( wswan_vdp.current_line != 143 ) { |
| 34 | 34 | rec->max_y = rec->max_y + 5*8; |
| 35 | 35 | } else { |
| 36 | 36 | rec->max_y = 28*8; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | | if ( vdp.display_vertical ) { |
| 39 | if ( wswan_vdp.display_vertical ) { |
| 40 | 40 | rectangle rec2; |
| 41 | 41 | rec2.min_y = 28*8 - 1 - rec->max_x; |
| 42 | 42 | rec2.max_y = 28*8 - 1 - rec->min_x; |
| r4212 | r4213 | |
| 51 | 51 | static void wswan_setup_palettes(void) { |
| 52 | 52 | int i,j; |
| 53 | 53 | |
| 54 | | if ( vdp.color_mode ) { |
| 54 | if ( wswan_vdp.color_mode ) { |
| 55 | 55 | for( i = 0; i < 16; i++ ) { |
| 56 | 56 | for( j = 0; j < 16; j++ ) { |
| 57 | | pal[i][j] = ( ( vdp.palette_vram[ ( i << 5 ) + j*2 + 1 ] << 8 ) | vdp.palette_vram[ ( i << 5 ) + j*2 ] ) & 0x0FFF; |
| 57 | pal[i][j] = ( ( wswan_vdp.palette_vram[ ( i << 5 ) + j*2 + 1 ] << 8 ) | wswan_vdp.palette_vram[ ( i << 5 ) + j*2 ] ) & 0x0FFF; |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } else { |
| r4212 | r4213 | |
| 72 | 72 | UINT8 start_column; |
| 73 | 73 | int column; |
| 74 | 74 | |
| 75 | | map_addr = vdp.layer_bg_address + ( ( ( vdp.current_line + vdp.layer_bg_scroll_y ) & 0xF8 ) << 3 ); |
| 76 | | start_column = ( vdp.layer_bg_scroll_x >> 3 ); |
| 75 | map_addr = wswan_vdp.layer_bg_address + ( ( ( wswan_vdp.current_line + wswan_vdp.layer_bg_scroll_y ) & 0xF8 ) << 3 ); |
| 76 | start_column = ( wswan_vdp.layer_bg_scroll_x >> 3 ); |
| 77 | 77 | for( column = 0; column < 29; column++ ) { |
| 78 | 78 | int tile_data, tile_number, tile_palette, tile_line, tile_address; |
| 79 | 79 | UINT32 plane0=0, plane1=0, plane2=0, plane3=0; |
| 80 | 80 | int x, x_offset; |
| 81 | 81 | |
| 82 | | tile_data = ( vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 83 | | | vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 82 | tile_data = ( wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 83 | | wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 84 | 84 | tile_number = tile_data & 0x01FF; |
| 85 | 85 | tile_palette = ( tile_data >> 9 ) & 0x0F; |
| 86 | 86 | |
| 87 | | tile_line = ( vdp.current_line + vdp.layer_bg_scroll_y ) & 0x07; |
| 87 | tile_line = ( wswan_vdp.current_line + wswan_vdp.layer_bg_scroll_y ) & 0x07; |
| 88 | 88 | if ( tile_data & 0x8000 ) { |
| 89 | 89 | tile_line = 7 - tile_line; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | | if ( vdp.colors_16 ) { |
| 92 | if ( wswan_vdp.colors_16 ) { |
| 93 | 93 | tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); |
| 94 | | if ( vdp.tile_packed ) { |
| 95 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 24 ) | ( vdp.vram[ tile_address + 1 ] << 16 ) | ( vdp.vram[ tile_address + 2 ] << 8 ) | vdp.vram[ tile_address + 3 ]; |
| 94 | if ( wswan_vdp.tile_packed ) { |
| 95 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 24 ) | ( wswan_vdp.vram[ tile_address + 1 ] << 16 ) | ( wswan_vdp.vram[ tile_address + 2 ] << 8 ) | wswan_vdp.vram[ tile_address + 3 ]; |
| 96 | 96 | } else { |
| 97 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 98 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 99 | | plane2 = vdp.vram[ tile_address + 2 ] << 2; |
| 100 | | plane3 = vdp.vram[ tile_address + 3 ] << 3; |
| 97 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 98 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 99 | plane2 = wswan_vdp.vram[ tile_address + 2 ] << 2; |
| 100 | plane3 = wswan_vdp.vram[ tile_address + 3 ] << 3; |
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | 103 | tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); |
| 104 | | if ( vdp.tile_packed ) { |
| 105 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 8 ) | vdp.vram[ tile_address + 1 ]; |
| 104 | if ( wswan_vdp.tile_packed ) { |
| 105 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 8 ) | wswan_vdp.vram[ tile_address + 1 ]; |
| 106 | 106 | } else { |
| 107 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 108 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 107 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 108 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 109 | 109 | plane2 = 0; |
| 110 | 110 | plane3 = 0; |
| 111 | 111 | } |
| r4212 | r4213 | |
| 113 | 113 | |
| 114 | 114 | for( x = 0; x < 8; x++ ) { |
| 115 | 115 | int col; |
| 116 | | if ( vdp.tile_packed ) { |
| 117 | | if ( vdp.colors_16 ) { |
| 116 | if ( wswan_vdp.tile_packed ) { |
| 117 | if ( wswan_vdp.colors_16 ) { |
| 118 | 118 | col = plane0 & 0x0F; |
| 119 | 119 | plane0 = plane0 >> 4; |
| 120 | 120 | } else { |
| r4212 | r4213 | |
| 129 | 129 | plane0 = plane0 >> 1; |
| 130 | 130 | } |
| 131 | 131 | if ( tile_data & 0x4000 ) { |
| 132 | | x_offset = x + ( column << 3 ) - ( vdp.layer_bg_scroll_x & 0x07 ); |
| 132 | x_offset = x + ( column << 3 ) - ( wswan_vdp.layer_bg_scroll_x & 0x07 ); |
| 133 | 133 | } else { |
| 134 | | x_offset = 7 - x + ( column << 3 ) - ( vdp.layer_bg_scroll_x & 0x07 ); |
| 134 | x_offset = 7 - x + ( column << 3 ) - ( wswan_vdp.layer_bg_scroll_x & 0x07 ); |
| 135 | 135 | } |
| 136 | 136 | if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { |
| 137 | | if ( vdp.colors_16 ) { |
| 137 | if ( wswan_vdp.colors_16 ) { |
| 138 | 138 | if ( col ) { |
| 139 | | if ( vdp.color_mode ) { |
| 140 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 139 | if ( wswan_vdp.color_mode ) { |
| 140 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 141 | 141 | } else { |
| 142 | 142 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 143 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 143 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } else { |
| 147 | 147 | if ( col || !(tile_palette & 4 ) ) { |
| 148 | | if ( vdp.color_mode ) { |
| 149 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 148 | if ( wswan_vdp.color_mode ) { |
| 149 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 150 | 150 | } else { |
| 151 | | wswan_plot_pixel( x_offset, vdp.current_line, vdp.main_palette[pal[tile_palette][col]] ); |
| 151 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, wswan_vdp.main_palette[pal[tile_palette][col]] ); |
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | } |
| r4212 | r4213 | |
| 161 | 161 | UINT16 map_addr; |
| 162 | 162 | UINT8 start_column; |
| 163 | 163 | int column; |
| 164 | | map_addr = vdp.layer_fg_address + ( ( ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 165 | | start_column = ( vdp.layer_fg_scroll_x >> 3 ); |
| 164 | map_addr = wswan_vdp.layer_fg_address + ( ( ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 165 | start_column = ( wswan_vdp.layer_fg_scroll_x >> 3 ); |
| 166 | 166 | for( column = 0; column < 29; column++ ) { |
| 167 | 167 | UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; |
| 168 | 168 | int x, x_offset, tile_line, tile_address; |
| 169 | | int tile_data = ( vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 170 | | | vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 169 | int tile_data = ( wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 170 | | wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 171 | 171 | int tile_number = tile_data & 0x01FF; |
| 172 | 172 | int tile_palette = ( tile_data >> 9 ) & 0x0F; |
| 173 | 173 | |
| 174 | | tile_line = ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0x07; |
| 174 | tile_line = ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0x07; |
| 175 | 175 | if ( tile_data & 0x8000 ) { |
| 176 | 176 | tile_line = 7 - tile_line; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | | if ( vdp.colors_16 ) { |
| 179 | if ( wswan_vdp.colors_16 ) { |
| 180 | 180 | tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); |
| 181 | | if ( vdp.tile_packed ) { |
| 182 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 24 ) | ( vdp.vram[ tile_address + 1 ] << 16 ) | ( vdp.vram[ tile_address + 2 ] << 8 ) | vdp.vram[ tile_address + 3 ]; |
| 181 | if ( wswan_vdp.tile_packed ) { |
| 182 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 24 ) | ( wswan_vdp.vram[ tile_address + 1 ] << 16 ) | ( wswan_vdp.vram[ tile_address + 2 ] << 8 ) | wswan_vdp.vram[ tile_address + 3 ]; |
| 183 | 183 | } else { |
| 184 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 185 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 186 | | plane2 = vdp.vram[ tile_address + 2 ] << 2; |
| 187 | | plane3 = vdp.vram[ tile_address + 3 ] << 3; |
| 184 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 185 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 186 | plane2 = wswan_vdp.vram[ tile_address + 2 ] << 2; |
| 187 | plane3 = wswan_vdp.vram[ tile_address + 3 ] << 3; |
| 188 | 188 | } |
| 189 | 189 | } else { |
| 190 | 190 | tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); |
| 191 | | if ( vdp.tile_packed ) { |
| 192 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 8 ) | vdp.vram[ tile_address + 1 ]; |
| 191 | if ( wswan_vdp.tile_packed ) { |
| 192 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 8 ) | wswan_vdp.vram[ tile_address + 1 ]; |
| 193 | 193 | } else { |
| 194 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 195 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 194 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 195 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 196 | 196 | plane2 = 0; |
| 197 | 197 | plane3 = 0; |
| 198 | 198 | } |
| r4212 | r4213 | |
| 200 | 200 | |
| 201 | 201 | for( x = 0; x < 8; x++ ) { |
| 202 | 202 | int col; |
| 203 | | if ( vdp.tile_packed ) { |
| 204 | | if ( vdp.colors_16 ) { |
| 203 | if ( wswan_vdp.tile_packed ) { |
| 204 | if ( wswan_vdp.colors_16 ) { |
| 205 | 205 | col = plane0 & 0x0F; |
| 206 | 206 | plane0 = plane0 >> 4; |
| 207 | 207 | } else { |
| r4212 | r4213 | |
| 216 | 216 | plane0 = plane0 >> 1; |
| 217 | 217 | } |
| 218 | 218 | if ( tile_data & 0x4000 ) { |
| 219 | | x_offset = x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 219 | x_offset = x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 220 | 220 | } else { |
| 221 | | x_offset = 7 - x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 221 | x_offset = 7 - x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 222 | 222 | } |
| 223 | 223 | if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { |
| 224 | | if ( vdp.colors_16 ) { |
| 224 | if ( wswan_vdp.colors_16 ) { |
| 225 | 225 | if ( col ) { |
| 226 | | // if ( vdp.color_mode ) { |
| 227 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 226 | // if ( wswan_vdp.color_mode ) { |
| 227 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 228 | 228 | // } else { |
| 229 | 229 | // /* Hmmmm, what should we do here... Is this correct?? */ |
| 230 | | // wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 230 | // wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 231 | 231 | // } |
| 232 | 232 | } |
| 233 | 233 | } else { |
| 234 | 234 | if ( col || !(tile_palette & 4 ) ) { |
| 235 | | if ( vdp.color_mode ) { |
| 236 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 235 | if ( wswan_vdp.color_mode ) { |
| 236 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 237 | 237 | } else { |
| 238 | | wswan_plot_pixel( x_offset, vdp.current_line, vdp.main_palette[pal[tile_palette][col]] ); |
| 238 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, wswan_vdp.main_palette[pal[tile_palette][col]] ); |
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | } |
| r4212 | r4213 | |
| 248 | 248 | UINT16 map_addr; |
| 249 | 249 | UINT8 start_column; |
| 250 | 250 | int column; |
| 251 | | map_addr = vdp.layer_fg_address + ( ( ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 252 | | start_column = ( vdp.layer_fg_scroll_x >> 3 ); |
| 251 | map_addr = wswan_vdp.layer_fg_address + ( ( ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 252 | start_column = ( wswan_vdp.layer_fg_scroll_x >> 3 ); |
| 253 | 253 | for( column = 0; column < 29; column++ ) { |
| 254 | 254 | UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; |
| 255 | 255 | int x, x_offset, tile_line, tile_address; |
| 256 | | int tile_data = ( vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 257 | | | vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 256 | int tile_data = ( wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 257 | | wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 258 | 258 | int tile_number = tile_data & 0x01FF; |
| 259 | 259 | int tile_palette = ( tile_data >> 9 ) & 0x0F; |
| 260 | 260 | |
| 261 | | tile_line = ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0x07; |
| 261 | tile_line = ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0x07; |
| 262 | 262 | if ( tile_data & 0x8000 ) { |
| 263 | 263 | tile_line = 7 - tile_line; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | | if ( vdp.colors_16 ) { |
| 266 | if ( wswan_vdp.colors_16 ) { |
| 267 | 267 | tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); |
| 268 | | if ( vdp.tile_packed ) { |
| 269 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 24 ) | ( vdp.vram[ tile_address + 1 ] << 16 ) | ( vdp.vram[ tile_address + 2 ] << 8 ) | vdp.vram[ tile_address + 3 ]; |
| 268 | if ( wswan_vdp.tile_packed ) { |
| 269 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 24 ) | ( wswan_vdp.vram[ tile_address + 1 ] << 16 ) | ( wswan_vdp.vram[ tile_address + 2 ] << 8 ) | wswan_vdp.vram[ tile_address + 3 ]; |
| 270 | 270 | } else { |
| 271 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 272 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 273 | | plane2 = vdp.vram[ tile_address + 2 ] << 2; |
| 274 | | plane3 = vdp.vram[ tile_address + 3 ] << 3; |
| 271 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 272 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 273 | plane2 = wswan_vdp.vram[ tile_address + 2 ] << 2; |
| 274 | plane3 = wswan_vdp.vram[ tile_address + 3 ] << 3; |
| 275 | 275 | } |
| 276 | 276 | } else { |
| 277 | 277 | tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); |
| 278 | | if ( vdp.tile_packed ) { |
| 279 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 8 ) | vdp.vram[ tile_address + 1 ]; |
| 278 | if ( wswan_vdp.tile_packed ) { |
| 279 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 8 ) | wswan_vdp.vram[ tile_address + 1 ]; |
| 280 | 280 | } else { |
| 281 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 282 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 281 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 282 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 283 | 283 | plane2 = 0; |
| 284 | 284 | plane3 = 0; |
| 285 | 285 | } |
| r4212 | r4213 | |
| 287 | 287 | |
| 288 | 288 | for( x = 0; x < 8; x++ ) { |
| 289 | 289 | int col; |
| 290 | | if ( vdp.tile_packed ) { |
| 291 | | if ( vdp.colors_16 ) { |
| 290 | if ( wswan_vdp.tile_packed ) { |
| 291 | if ( wswan_vdp.colors_16 ) { |
| 292 | 292 | col = plane0 & 0x0F; |
| 293 | 293 | plane0 = plane0 >> 4; |
| 294 | 294 | } else { |
| r4212 | r4213 | |
| 303 | 303 | plane0 = plane0 >> 1; |
| 304 | 304 | } |
| 305 | 305 | if ( tile_data & 0x4000 ) { |
| 306 | | x_offset = x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 306 | x_offset = x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 307 | 307 | } else { |
| 308 | | x_offset = 7 - x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 308 | x_offset = 7 - x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 309 | 309 | } |
| 310 | | if ( x_offset >= 0 && x_offset >= vdp.window_fg_left && x_offset < vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) { |
| 311 | | if ( vdp.colors_16 ) { |
| 310 | if ( x_offset >= 0 && x_offset >= wswan_vdp.window_fg_left && x_offset < wswan_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) { |
| 311 | if ( wswan_vdp.colors_16 ) { |
| 312 | 312 | if ( col ) { |
| 313 | | if ( vdp.color_mode ) { |
| 314 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 313 | if ( wswan_vdp.color_mode ) { |
| 314 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 315 | 315 | } else { |
| 316 | 316 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 317 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 317 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | } else { |
| 321 | 321 | if ( col || !(tile_palette & 4 ) ) { |
| 322 | | if ( vdp.color_mode ) { |
| 323 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 322 | if ( wswan_vdp.color_mode ) { |
| 323 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 324 | 324 | } else { |
| 325 | | wswan_plot_pixel( x_offset, vdp.current_line, vdp.main_palette[pal[tile_palette][col]] ); |
| 325 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, wswan_vdp.main_palette[pal[tile_palette][col]] ); |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | } |
| r4212 | r4213 | |
| 335 | 335 | UINT16 map_addr; |
| 336 | 336 | UINT8 start_column; |
| 337 | 337 | int column; |
| 338 | | map_addr = vdp.layer_fg_address + ( ( ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 339 | | start_column = ( vdp.layer_fg_scroll_x >> 3 ); |
| 338 | map_addr = wswan_vdp.layer_fg_address + ( ( ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0xF8 ) << 3 ); |
| 339 | start_column = ( wswan_vdp.layer_fg_scroll_x >> 3 ); |
| 340 | 340 | for( column = 0; column < 29; column++ ) { |
| 341 | 341 | UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; |
| 342 | 342 | int x, x_offset, tile_line, tile_address; |
| 343 | | int tile_data = ( vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 344 | | | vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 343 | int tile_data = ( wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) + 1 ] << 8 ) |
| 344 | | wswan_vdp.vram[ map_addr + ( ( ( start_column + column ) & 0x1F ) << 1 ) ]; |
| 345 | 345 | int tile_number = tile_data & 0x01FF; |
| 346 | 346 | int tile_palette = ( tile_data >> 9 ) & 0x0F; |
| 347 | 347 | |
| 348 | | tile_line = ( vdp.current_line + vdp.layer_fg_scroll_y ) & 0x07; |
| 348 | tile_line = ( wswan_vdp.current_line + wswan_vdp.layer_fg_scroll_y ) & 0x07; |
| 349 | 349 | if ( tile_data & 0x8000 ) { |
| 350 | 350 | tile_line = 7 - tile_line; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | | if ( vdp.colors_16 ) { |
| 353 | if ( wswan_vdp.colors_16 ) { |
| 354 | 354 | tile_address = ( ( tile_data & 0x2000 ) ? 0x8000 : 0x4000 ) + ( tile_number * 32 ) + ( tile_line << 2 ); |
| 355 | | if ( vdp.tile_packed ) { |
| 356 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 24 ) | ( vdp.vram[ tile_address + 1 ] << 16 ) | ( vdp.vram[ tile_address + 2 ] << 8 ) | vdp.vram[ tile_address + 3 ]; |
| 355 | if ( wswan_vdp.tile_packed ) { |
| 356 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 24 ) | ( wswan_vdp.vram[ tile_address + 1 ] << 16 ) | ( wswan_vdp.vram[ tile_address + 2 ] << 8 ) | wswan_vdp.vram[ tile_address + 3 ]; |
| 357 | 357 | } else { |
| 358 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 359 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 360 | | plane2 = vdp.vram[ tile_address + 2 ] << 2; |
| 361 | | plane3 = vdp.vram[ tile_address + 3 ] << 3; |
| 358 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 359 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 360 | plane2 = wswan_vdp.vram[ tile_address + 2 ] << 2; |
| 361 | plane3 = wswan_vdp.vram[ tile_address + 3 ] << 3; |
| 362 | 362 | } |
| 363 | 363 | } else { |
| 364 | 364 | tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); |
| 365 | | if ( vdp.tile_packed ) { |
| 366 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 8 ) | vdp.vram[ tile_address + 1 ]; |
| 365 | if ( wswan_vdp.tile_packed ) { |
| 366 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 8 ) | wswan_vdp.vram[ tile_address + 1 ]; |
| 367 | 367 | } else { |
| 368 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 369 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 368 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 369 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 370 | 370 | plane2 = 0; |
| 371 | 371 | plane3 = 0; |
| 372 | 372 | } |
| r4212 | r4213 | |
| 374 | 374 | |
| 375 | 375 | for( x = 0; x < 8; x++ ) { |
| 376 | 376 | int col; |
| 377 | | if ( vdp.tile_packed ) { |
| 378 | | if ( vdp.colors_16 ) { |
| 377 | if ( wswan_vdp.tile_packed ) { |
| 378 | if ( wswan_vdp.colors_16 ) { |
| 379 | 379 | col = plane0 & 0x0F; |
| 380 | 380 | plane0 = plane0 >> 4; |
| 381 | 381 | } else { |
| r4212 | r4213 | |
| 390 | 390 | plane0 = plane0 >> 1; |
| 391 | 391 | } |
| 392 | 392 | if ( tile_data & 0x4000 ) { |
| 393 | | x_offset = x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 393 | x_offset = x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 394 | 394 | } else { |
| 395 | | x_offset = 7 - x + ( column << 3 ) - ( vdp.layer_fg_scroll_x & 0x07 ); |
| 395 | x_offset = 7 - x + ( column << 3 ) - ( wswan_vdp.layer_fg_scroll_x & 0x07 ); |
| 396 | 396 | } |
| 397 | | if ( ( x_offset >= 0 && x_offset < vdp.window_fg_left ) || ( x_offset >= vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) ) { |
| 398 | | if ( vdp.colors_16 ) { |
| 397 | if ( ( x_offset >= 0 && x_offset < wswan_vdp.window_fg_left ) || ( x_offset >= wswan_vdp.window_fg_right && x_offset < WSWAN_X_PIXELS ) ) { |
| 398 | if ( wswan_vdp.colors_16 ) { |
| 399 | 399 | if ( col ) { |
| 400 | | if ( vdp.color_mode ) { |
| 401 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 400 | if ( wswan_vdp.color_mode ) { |
| 401 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 402 | 402 | } else { |
| 403 | 403 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 404 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 404 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | } else { |
| 408 | 408 | if ( col || !(tile_palette & 4 ) ) { |
| 409 | | if ( vdp.color_mode ) { |
| 410 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 409 | if ( wswan_vdp.color_mode ) { |
| 410 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 411 | 411 | } else { |
| 412 | | wswan_plot_pixel( x_offset, vdp.current_line, vdp.main_palette[pal[tile_palette][col]] ); |
| 412 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, wswan_vdp.main_palette[pal[tile_palette][col]] ); |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
| r4212 | r4213 | |
| 420 | 420 | |
| 421 | 421 | static void wswan_handle_sprites( int mask ) { |
| 422 | 422 | int i; |
| 423 | | if ( vdp.sprite_count == 0 ) |
| 423 | if ( wswan_vdp.sprite_count == 0 ) |
| 424 | 424 | return; |
| 425 | | for( i = vdp.sprite_first + vdp.sprite_count - 1; i >= vdp.sprite_first; i-- ) { |
| 425 | for( i = wswan_vdp.sprite_first + wswan_vdp.sprite_count - 1; i >= wswan_vdp.sprite_first; i-- ) { |
| 426 | 426 | UINT8 x, y; |
| 427 | 427 | UINT16 tile_data; |
| 428 | 428 | int tile_line; |
| 429 | 429 | |
| 430 | | tile_data = ( vdp.vram[ vdp.sprite_table_address + i * 4 + 1 ] << 8 ) |
| 431 | | | vdp.vram[ vdp.sprite_table_address + i * 4 ]; |
| 432 | | y = vdp.vram[ vdp.sprite_table_address + i * 4 + 2 ]; |
| 433 | | x = vdp.vram[ vdp.sprite_table_address + i * 4 + 3 ]; |
| 434 | | tile_line = vdp.current_line - y; |
| 430 | tile_data = ( wswan_vdp.vram[ wswan_vdp.sprite_table_address + i * 4 + 1 ] << 8 ) |
| 431 | | wswan_vdp.vram[ wswan_vdp.sprite_table_address + i * 4 ]; |
| 432 | y = wswan_vdp.vram[ wswan_vdp.sprite_table_address + i * 4 + 2 ]; |
| 433 | x = wswan_vdp.vram[ wswan_vdp.sprite_table_address + i * 4 + 3 ]; |
| 434 | tile_line = wswan_vdp.current_line - y; |
| 435 | 435 | tile_line = tile_line & 0xFF; |
| 436 | 436 | if ( ( tile_line >= 0 ) && ( tile_line < 8 ) && ( ( tile_data & mask ) == mask ) ) { |
| 437 | 437 | UINT32 plane0 = 0, plane1 = 0, plane2 = 0, plane3 = 0; |
| r4212 | r4213 | |
| 443 | 443 | tile_line = 7 - tile_line; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | | if ( vdp.colors_16 ) { |
| 446 | if ( wswan_vdp.colors_16 ) { |
| 447 | 447 | tile_address = 0x4000 + ( tile_number * 32 ) + ( tile_line << 2 ); |
| 448 | | if ( vdp.tile_packed ) { |
| 449 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 24 ) | ( vdp.vram[ tile_address + 1 ] << 16 ) | ( vdp.vram[ tile_address + 2 ] << 8 ) | vdp.vram[ tile_address + 3 ]; |
| 448 | if ( wswan_vdp.tile_packed ) { |
| 449 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 24 ) | ( wswan_vdp.vram[ tile_address + 1 ] << 16 ) | ( wswan_vdp.vram[ tile_address + 2 ] << 8 ) | wswan_vdp.vram[ tile_address + 3 ]; |
| 450 | 450 | } else { |
| 451 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 452 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 453 | | plane2 = vdp.vram[ tile_address + 2 ] << 2; |
| 454 | | plane3 = vdp.vram[ tile_address + 3 ] << 3; |
| 451 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 452 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 453 | plane2 = wswan_vdp.vram[ tile_address + 2 ] << 2; |
| 454 | plane3 = wswan_vdp.vram[ tile_address + 3 ] << 3; |
| 455 | 455 | } |
| 456 | 456 | } else { |
| 457 | 457 | tile_address = 0x2000 + ( tile_number * 16 ) + ( tile_line << 1 ); |
| 458 | | if ( vdp.tile_packed ) { |
| 459 | | plane0 = ( vdp.vram[ tile_address + 0 ] << 8 ) | vdp.vram[ tile_address + 1 ]; |
| 458 | if ( wswan_vdp.tile_packed ) { |
| 459 | plane0 = ( wswan_vdp.vram[ tile_address + 0 ] << 8 ) | wswan_vdp.vram[ tile_address + 1 ]; |
| 460 | 460 | } else { |
| 461 | | plane0 = vdp.vram[ tile_address + 0 ]; |
| 462 | | plane1 = vdp.vram[ tile_address + 1 ] << 1; |
| 461 | plane0 = wswan_vdp.vram[ tile_address + 0 ]; |
| 462 | plane1 = wswan_vdp.vram[ tile_address + 1 ] << 1; |
| 463 | 463 | plane2 = 0; |
| 464 | 464 | plane3 = 0; |
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | | if ( vdp.window_sprites_enable ) { |
| 468 | if ( wswan_vdp.window_sprites_enable ) { |
| 469 | 469 | if ( tile_data & 0x1000 ) { |
| 470 | | if ( vdp.current_line >= vdp.window_sprites_top && vdp.current_line <= vdp.window_sprites_bottom ) { |
| 470 | if ( wswan_vdp.current_line >= wswan_vdp.window_sprites_top && wswan_vdp.current_line <= wswan_vdp.window_sprites_bottom ) { |
| 471 | 471 | check_clip = 1; |
| 472 | 472 | } |
| 473 | 473 | } else { |
| 474 | | if ( vdp.current_line < vdp.window_sprites_top || vdp.current_line > vdp.window_sprites_bottom ) { |
| 474 | if ( wswan_vdp.current_line < wswan_vdp.window_sprites_top || wswan_vdp.current_line > wswan_vdp.window_sprites_bottom ) { |
| 475 | 475 | continue; |
| 476 | 476 | } |
| 477 | 477 | } |
| r4212 | r4213 | |
| 479 | 479 | |
| 480 | 480 | for ( j = 0; j < 8; j++ ) { |
| 481 | 481 | int col; |
| 482 | | if ( vdp.tile_packed ) { |
| 483 | | if ( vdp.colors_16 ) { |
| 482 | if ( wswan_vdp.tile_packed ) { |
| 483 | if ( wswan_vdp.colors_16 ) { |
| 484 | 484 | col = plane0 & 0x0F; |
| 485 | 485 | plane0 = plane0 >> 4; |
| 486 | 486 | } else { |
| r4212 | r4213 | |
| 500 | 500 | x_offset = x + 7 - j; |
| 501 | 501 | } |
| 502 | 502 | x_offset = x_offset & 0xFF; |
| 503 | | if ( vdp.window_sprites_enable ) { |
| 503 | if ( wswan_vdp.window_sprites_enable ) { |
| 504 | 504 | if ( tile_data & 0x1000 && check_clip ) { |
| 505 | | if ( x_offset >= vdp.window_sprites_left && x_offset <= vdp.window_sprites_right ) { |
| 505 | if ( x_offset >= wswan_vdp.window_sprites_left && x_offset <= wswan_vdp.window_sprites_right ) { |
| 506 | 506 | continue; |
| 507 | 507 | } |
| 508 | 508 | } else { |
| 509 | | if ( x_offset < vdp.window_sprites_left || x_offset > vdp.window_sprites_right ) { |
| 509 | if ( x_offset < wswan_vdp.window_sprites_left || x_offset > wswan_vdp.window_sprites_right ) { |
| 510 | 510 | // continue; |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | if ( x_offset >= 0 && x_offset < WSWAN_X_PIXELS ) { |
| 515 | | if ( vdp.colors_16 ) { |
| 515 | if ( wswan_vdp.colors_16 ) { |
| 516 | 516 | if ( col ) { |
| 517 | | if ( vdp.color_mode ) { |
| 518 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 517 | if ( wswan_vdp.color_mode ) { |
| 518 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 519 | 519 | } else { |
| 520 | 520 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 521 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 521 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | } else { |
| 525 | 525 | if ( col || !(tile_palette & 4 ) ) { |
| 526 | | if ( vdp.color_mode ) { |
| 527 | | wswan_plot_pixel( x_offset, vdp.current_line, pal[tile_palette][col] ); |
| 526 | if ( wswan_vdp.color_mode ) { |
| 527 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, pal[tile_palette][col] ); |
| 528 | 528 | } else { |
| 529 | | wswan_plot_pixel( x_offset, vdp.current_line, vdp.main_palette[pal[tile_palette][col]] ); |
| 529 | wswan_plot_pixel( x_offset, wswan_vdp.current_line, wswan_vdp.main_palette[pal[tile_palette][col]] ); |
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | } |
| r4212 | r4213 | |
| 544 | 544 | |
| 545 | 545 | rec.min_x = 0; |
| 546 | 546 | rec.max_x = WSWAN_X_PIXELS; |
| 547 | | rec.min_y = rec.max_y = vdp.current_line; |
| 547 | rec.min_y = rec.max_y = wswan_vdp.current_line; |
| 548 | 548 | if ( ws_portram[0x14] ) { |
| 549 | 549 | /* Not sure if these background color checks and settings are correct */ |
| 550 | | if ( vdp.color_mode && vdp.colors_16 ) { |
| 550 | if ( wswan_vdp.color_mode && wswan_vdp.colors_16 ) { |
| 551 | 551 | wswan_fillbitmap( pal[ws_portram[0x01]>>4][ws_portram[0x01]&0x0F], &rec ); |
| 552 | 552 | } else { |
| 553 | | wswan_fillbitmap( vdp.main_palette[ws_portram[0x01]&0x07], &rec ); |
| 553 | wswan_fillbitmap( wswan_vdp.main_palette[ws_portram[0x01]&0x07], &rec ); |
| 554 | 554 | } |
| 555 | 555 | } else { |
| 556 | 556 | wswan_fillbitmap( 0, &rec ); |
| r4212 | r4213 | |
| 560 | 560 | /* |
| 561 | 561 | * Draw background layer |
| 562 | 562 | */ |
| 563 | | if ( vdp.layer_bg_enable ) { |
| 563 | if ( wswan_vdp.layer_bg_enable ) { |
| 564 | 564 | wswan_draw_background(); |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /* |
| 568 | 568 | * Draw sprites between background and foreground layers |
| 569 | 569 | */ |
| 570 | | if ( vdp.sprites_enable ) { |
| 570 | if ( wswan_vdp.sprites_enable ) { |
| 571 | 571 | wswan_handle_sprites( 0 ); |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /* |
| 575 | 575 | * Draw foreground layer, taking window settings into account |
| 576 | 576 | */ |
| 577 | | if ( vdp.layer_fg_enable ) { |
| 578 | | switch( vdp.window_fg_mode ) { |
| 577 | if ( wswan_vdp.layer_fg_enable ) { |
| 578 | switch( wswan_vdp.window_fg_mode ) { |
| 579 | 579 | case 0: /* FG inside & outside window area */ |
| 580 | 580 | wswan_draw_foreground_0(); |
| 581 | 581 | break; |
| r4212 | r4213 | |
| 583 | 583 | logerror( "Unknown foreground mode 1 set\n" ); |
| 584 | 584 | break; |
| 585 | 585 | case 2: /* FG only inside window area */ |
| 586 | | if ( vdp.current_line >= vdp.window_fg_top && vdp.current_line <= vdp.window_fg_bottom ) { |
| 586 | if ( wswan_vdp.current_line >= wswan_vdp.window_fg_top && wswan_vdp.current_line <= wswan_vdp.window_fg_bottom ) { |
| 587 | 587 | wswan_draw_foreground_2(); |
| 588 | 588 | } |
| 589 | 589 | break; |
| 590 | 590 | case 3: /* FG only outside window area */ |
| 591 | | if ( vdp.current_line < vdp.window_fg_top || vdp.current_line > vdp.window_fg_bottom ) { |
| 591 | if ( wswan_vdp.current_line < wswan_vdp.window_fg_top || wswan_vdp.current_line > wswan_vdp.window_fg_bottom ) { |
| 592 | 592 | wswan_draw_foreground_0(); |
| 593 | 593 | } else { |
| 594 | 594 | wswan_draw_foreground_3(); |
| r4212 | r4213 | |
| 600 | 600 | /* |
| 601 | 601 | * Draw sprites in front of foreground layer |
| 602 | 602 | */ |
| 603 | | if ( vdp.sprites_enable ) { |
| 603 | if ( wswan_vdp.sprites_enable ) { |
| 604 | 604 | wswan_handle_sprites( 0x2000 ); |
| 605 | 605 | } |
| 606 | 606 | } |
src/mess/video/x68k.c
| r4212 | r4213 | |
| 29 | 29 | #include "includes/x68k.h" |
| 30 | 30 | #include "machine/68901mfp.h" |
| 31 | 31 | |
| 32 | | UINT16* gvram; // Graphic VRAM |
| 33 | | UINT16* tvram; // Text VRAM |
| 32 | UINT16* x68k_gvram; // Graphic VRAM |
| 33 | UINT16* x68k_tvram; // Text VRAM |
| 34 | 34 | UINT16* x68k_spriteram; // sprite/background RAM |
| 35 | 35 | UINT16* x68k_spritereg; // sprite/background registers |
| 36 | 36 | |
| r4212 | r4213 | |
| 111 | 111 | for(line=0;line<8;line++) |
| 112 | 112 | { |
| 113 | 113 | // update RAM in each plane |
| 114 | | memcpy(tvram+dest_ram,tvram+src_ram,128); |
| 115 | | memcpy(tvram+dest_ram+0x10000,tvram+src_ram+0x10000,128); |
| 116 | | memcpy(tvram+dest_ram+0x20000,tvram+src_ram+0x20000,128); |
| 117 | | memcpy(tvram+dest_ram+0x30000,tvram+src_ram+0x30000,128); |
| 114 | memcpy(x68k_tvram+dest_ram,x68k_tvram+src_ram,128); |
| 115 | memcpy(x68k_tvram+dest_ram+0x10000,x68k_tvram+src_ram+0x10000,128); |
| 116 | memcpy(x68k_tvram+dest_ram+0x20000,x68k_tvram+src_ram+0x20000,128); |
| 117 | memcpy(x68k_tvram+dest_ram+0x30000,x68k_tvram+src_ram+0x30000,128); |
| 118 | 118 | |
| 119 | 119 | // redraw scanline |
| 120 | 120 | for(x=0;x<64;x++) |
| r4212 | r4213 | |
| 129 | 129 | static TIMER_CALLBACK(x68k_crtc_operation_end) |
| 130 | 130 | { |
| 131 | 131 | int bit = param; |
| 132 | | sys.crtc.operation &= ~bit; |
| 132 | x68k_sys.crtc.operation &= ~bit; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | static void x68k_crtc_refresh_mode(running_machine *machine) |
| r4212 | r4213 | |
| 140 | 140 | int length; |
| 141 | 141 | |
| 142 | 142 | // Calculate data from register values |
| 143 | | sys.crtc.vmultiple = 1; |
| 144 | | if((sys.crtc.reg[20] & 0x10) != 0 && (sys.crtc.reg[20] & 0x0c) == 0) |
| 145 | | sys.crtc.vmultiple = 2; // 31.5kHz + 256 lines = doublescan |
| 146 | | sys.crtc.htotal = (sys.crtc.reg[0] + 1) * 8; |
| 147 | | sys.crtc.vtotal = (sys.crtc.reg[4] + 1) / sys.crtc.vmultiple; // default is 567 (568 scanlines) |
| 148 | | sys.crtc.hbegin = (sys.crtc.reg[2] * 8) + 1; |
| 149 | | sys.crtc.hend = (sys.crtc.reg[3] * 8); |
| 150 | | sys.crtc.vbegin = (sys.crtc.reg[6]) / sys.crtc.vmultiple; |
| 151 | | sys.crtc.vend = (sys.crtc.reg[7] - 1) / sys.crtc.vmultiple; |
| 152 | | sys.crtc.hsync_end = (sys.crtc.reg[1]) * 8; |
| 153 | | sys.crtc.vsync_end = (sys.crtc.reg[5]) / sys.crtc.vmultiple; |
| 154 | | sys.crtc.hsyncadjust = sys.crtc.reg[8]; |
| 143 | x68k_sys.crtc.vmultiple = 1; |
| 144 | if((x68k_sys.crtc.reg[20] & 0x10) != 0 && (x68k_sys.crtc.reg[20] & 0x0c) == 0) |
| 145 | x68k_sys.crtc.vmultiple = 2; // 31.5kHz + 256 lines = doublescan |
| 146 | x68k_sys.crtc.htotal = (x68k_sys.crtc.reg[0] + 1) * 8; |
| 147 | x68k_sys.crtc.vtotal = (x68k_sys.crtc.reg[4] + 1) / x68k_sys.crtc.vmultiple; // default is 567 (568 scanlines) |
| 148 | x68k_sys.crtc.hbegin = (x68k_sys.crtc.reg[2] * 8) + 1; |
| 149 | x68k_sys.crtc.hend = (x68k_sys.crtc.reg[3] * 8); |
| 150 | x68k_sys.crtc.vbegin = (x68k_sys.crtc.reg[6]) / x68k_sys.crtc.vmultiple; |
| 151 | x68k_sys.crtc.vend = (x68k_sys.crtc.reg[7] - 1) / x68k_sys.crtc.vmultiple; |
| 152 | x68k_sys.crtc.hsync_end = (x68k_sys.crtc.reg[1]) * 8; |
| 153 | x68k_sys.crtc.vsync_end = (x68k_sys.crtc.reg[5]) / x68k_sys.crtc.vmultiple; |
| 154 | x68k_sys.crtc.hsyncadjust = x68k_sys.crtc.reg[8]; |
| 155 | 155 | scr.min_x = scr.min_y = 0; |
| 156 | | scr.max_x = sys.crtc.htotal - 8; |
| 157 | | scr.max_y = sys.crtc.vtotal; |
| 158 | | if(scr.max_y <= sys.crtc.vend) |
| 159 | | scr.max_y = sys.crtc.vend + 2; |
| 160 | | if(scr.max_x <= sys.crtc.hend) |
| 161 | | scr.max_x = sys.crtc.hend + 2; |
| 162 | | visiblescr.min_x = sys.crtc.hbegin; |
| 163 | | visiblescr.max_x = sys.crtc.hend; |
| 164 | | visiblescr.min_y = sys.crtc.vbegin; |
| 165 | | visiblescr.max_y = sys.crtc.vend; |
| 156 | scr.max_x = x68k_sys.crtc.htotal - 8; |
| 157 | scr.max_y = x68k_sys.crtc.vtotal; |
| 158 | if(scr.max_y <= x68k_sys.crtc.vend) |
| 159 | scr.max_y = x68k_sys.crtc.vend + 2; |
| 160 | if(scr.max_x <= x68k_sys.crtc.hend) |
| 161 | scr.max_x = x68k_sys.crtc.hend + 2; |
| 162 | visiblescr.min_x = x68k_sys.crtc.hbegin; |
| 163 | visiblescr.max_x = x68k_sys.crtc.hend; |
| 164 | visiblescr.min_y = x68k_sys.crtc.vbegin; |
| 165 | visiblescr.max_y = x68k_sys.crtc.vend; |
| 166 | 166 | |
| 167 | 167 | // expand visible area to the size indicated by CRTC reg 20 |
| 168 | | length = sys.crtc.hend - sys.crtc.hbegin; |
| 169 | | if (length < sys.crtc.width) |
| 168 | length = x68k_sys.crtc.hend - x68k_sys.crtc.hbegin; |
| 169 | if (length < x68k_sys.crtc.width) |
| 170 | 170 | { |
| 171 | | visiblescr.min_x = sys.crtc.hbegin - ((sys.crtc.width - length)/2); |
| 172 | | visiblescr.max_x = sys.crtc.hend + ((sys.crtc.width - length)/2); |
| 171 | visiblescr.min_x = x68k_sys.crtc.hbegin - ((x68k_sys.crtc.width - length)/2); |
| 172 | visiblescr.max_x = x68k_sys.crtc.hend + ((x68k_sys.crtc.width - length)/2); |
| 173 | 173 | } |
| 174 | | length = sys.crtc.vend - sys.crtc.vbegin; |
| 175 | | if (length < sys.crtc.height) |
| 174 | length = x68k_sys.crtc.vend - x68k_sys.crtc.vbegin; |
| 175 | if (length < x68k_sys.crtc.height) |
| 176 | 176 | { |
| 177 | | visiblescr.min_y = sys.crtc.vbegin - ((sys.crtc.height - length)/2); |
| 178 | | visiblescr.max_y = sys.crtc.vend + ((sys.crtc.height - length)/2); |
| 177 | visiblescr.min_y = x68k_sys.crtc.vbegin - ((x68k_sys.crtc.height - length)/2); |
| 178 | visiblescr.max_y = x68k_sys.crtc.vend + ((x68k_sys.crtc.height - length)/2); |
| 179 | 179 | } |
| 180 | 180 | // bounds check |
| 181 | 181 | if(visiblescr.min_x < 0) |
| r4212 | r4213 | |
| 187 | 187 | if(visiblescr.max_y >= scr.max_y - 1) |
| 188 | 188 | visiblescr.max_y = scr.max_y - 2; |
| 189 | 189 | |
| 190 | | logerror("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i\n",sys.crtc.reg[0],sys.crtc.reg[1],sys.crtc.reg[2],sys.crtc.reg[3], |
| 191 | | sys.crtc.reg[4],sys.crtc.reg[5],sys.crtc.reg[6],sys.crtc.reg[7],sys.crtc.reg[8],sys.crtc.reg[9]); |
| 190 | logerror("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i\n",x68k_sys.crtc.reg[0],x68k_sys.crtc.reg[1],x68k_sys.crtc.reg[2],x68k_sys.crtc.reg[3], |
| 191 | x68k_sys.crtc.reg[4],x68k_sys.crtc.reg[5],x68k_sys.crtc.reg[6],x68k_sys.crtc.reg[7],x68k_sys.crtc.reg[8],x68k_sys.crtc.reg[9]); |
| 192 | 192 | logerror("video_screen_configure(machine->primary_screen,%i,%i,[%i,%i,%i,%i],55.45)\n",scr.max_x,scr.max_y,visiblescr.min_x,visiblescr.min_y,visiblescr.max_x,visiblescr.max_y); |
| 193 | 193 | video_screen_configure(machine->primary_screen,scr.max_x,scr.max_y,&visiblescr,HZ_TO_ATTOSECONDS(55.45)); |
| 194 | 194 | } |
| r4212 | r4213 | |
| 198 | 198 | int state = param; |
| 199 | 199 | attotime hsync_time; |
| 200 | 200 | |
| 201 | | sys.crtc.hblank = state; |
| 202 | | if(sys.crtc.vmultiple == 2) // 256-line (doublescan) |
| 201 | x68k_sys.crtc.hblank = state; |
| 202 | if(x68k_sys.crtc.vmultiple == 2) // 256-line (doublescan) |
| 203 | 203 | { |
| 204 | 204 | static int oddscanline; |
| 205 | 205 | if(state == 1) |
| r4212 | r4213 | |
| 207 | 207 | if(oddscanline == 1) |
| 208 | 208 | { |
| 209 | 209 | int scan = video_screen_get_vpos(machine->primary_screen); |
| 210 | | if(scan > sys.crtc.vend) |
| 211 | | scan = sys.crtc.vbegin; |
| 212 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,(sys.crtc.htotal + sys.crtc.hend) / 2); |
| 213 | | timer_adjust_oneshot(scanline_timer, hsync_time, 0); |
| 210 | if(scan > x68k_sys.crtc.vend) |
| 211 | scan = x68k_sys.crtc.vbegin; |
| 212 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,(x68k_sys.crtc.htotal + x68k_sys.crtc.hend) / 2); |
| 213 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 0); |
| 214 | 214 | if(scan != 0) |
| 215 | 215 | { |
| 216 | 216 | if((input_port_read(machine, "options") & 0x04)) |
| r4212 | r4213 | |
| 222 | 222 | else |
| 223 | 223 | { |
| 224 | 224 | int scan = video_screen_get_vpos(machine->primary_screen); |
| 225 | | if(scan > sys.crtc.vend) |
| 226 | | scan = sys.crtc.vbegin; |
| 227 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,sys.crtc.hend / 2); |
| 228 | | timer_adjust_oneshot(scanline_timer, hsync_time, 0); |
| 225 | if(scan > x68k_sys.crtc.vend) |
| 226 | scan = x68k_sys.crtc.vbegin; |
| 227 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,x68k_sys.crtc.hend / 2); |
| 228 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 0); |
| 229 | 229 | if(scan != 0) |
| 230 | 230 | { |
| 231 | 231 | if((input_port_read(machine, "options") & 0x04)) |
| r4212 | r4213 | |
| 240 | 240 | if(oddscanline == 1) |
| 241 | 241 | { |
| 242 | 242 | int scan = video_screen_get_vpos(machine->primary_screen); |
| 243 | | if(scan > sys.crtc.vend) |
| 244 | | scan = sys.crtc.vbegin; |
| 243 | if(scan > x68k_sys.crtc.vend) |
| 244 | scan = x68k_sys.crtc.vbegin; |
| 245 | 245 | else |
| 246 | 246 | scan++; |
| 247 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,sys.crtc.hbegin / 2); |
| 248 | | timer_adjust_oneshot(scanline_timer, hsync_time, 1); |
| 247 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,x68k_sys.crtc.hbegin / 2); |
| 248 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 1); |
| 249 | 249 | oddscanline = 0; |
| 250 | 250 | } |
| 251 | 251 | else |
| 252 | 252 | { |
| 253 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,video_screen_get_vpos(machine->primary_screen),(sys.crtc.htotal + sys.crtc.hbegin) / 2); |
| 254 | | timer_adjust_oneshot(scanline_timer, hsync_time, 1); |
| 253 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,video_screen_get_vpos(machine->primary_screen),(x68k_sys.crtc.htotal + x68k_sys.crtc.hbegin) / 2); |
| 254 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 1); |
| 255 | 255 | oddscanline = 1; |
| 256 | 256 | } |
| 257 | 257 | } |
| r4212 | r4213 | |
| 261 | 261 | if(state == 1) |
| 262 | 262 | { |
| 263 | 263 | int scan = video_screen_get_vpos(machine->primary_screen); |
| 264 | | if(scan > sys.crtc.vend) |
| 264 | if(scan > x68k_sys.crtc.vend) |
| 265 | 265 | scan = 0; |
| 266 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,sys.crtc.hend); |
| 267 | | timer_adjust_oneshot(scanline_timer, hsync_time, 0); |
| 266 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,scan,x68k_sys.crtc.hend); |
| 267 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 0); |
| 268 | 268 | if(scan != 0) |
| 269 | 269 | { |
| 270 | 270 | if((input_port_read(machine, "options") & 0x04)) |
| r4212 | r4213 | |
| 275 | 275 | } |
| 276 | 276 | if(state == 0) |
| 277 | 277 | { |
| 278 | | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,video_screen_get_vpos(machine->primary_screen)+1,sys.crtc.hbegin); |
| 279 | | timer_adjust_oneshot(scanline_timer, hsync_time, 1); |
| 280 | | // if(!(sys.mfp.gpio & 0x40)) // if GPIP6 is active, clear it |
| 281 | | // sys.mfp.gpio |= 0x40; |
| 278 | hsync_time = video_screen_get_time_until_pos(machine->primary_screen,video_screen_get_vpos(machine->primary_screen)+1,x68k_sys.crtc.hbegin); |
| 279 | timer_adjust_oneshot(x68k_scanline_timer, hsync_time, 1); |
| 280 | // if(!(x68k_sys.mfp.gpio & 0x40)) // if GPIP6 is active, clear it |
| 281 | // x68k_sys.mfp.gpio |= 0x40; |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | static TIMER_CALLBACK(x68k_crtc_raster_end) |
| 287 | 287 | { |
| 288 | | sys.mfp.gpio |= 0x40; |
| 288 | x68k_sys.mfp.gpio |= 0x40; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | TIMER_CALLBACK(x68k_crtc_raster_irq) |
| r4212 | r4213 | |
| 294 | 294 | attotime irq_time; |
| 295 | 295 | attotime end_time; |
| 296 | 296 | |
| 297 | | if(scan <= sys.crtc.vtotal) |
| 297 | if(scan <= x68k_sys.crtc.vtotal) |
| 298 | 298 | { |
| 299 | | sys.mfp.gpio &= ~0x40; // GPIP6 |
| 299 | x68k_sys.mfp.gpio &= ~0x40; // GPIP6 |
| 300 | 300 | video_screen_update_partial(machine->primary_screen,scan); |
| 301 | 301 | irq_time = video_screen_get_time_until_pos(machine->primary_screen,scan,2); |
| 302 | 302 | // end of HBlank period clears GPIP6 also? |
| 303 | | end_time = video_screen_get_time_until_pos(machine->primary_screen,scan,sys.crtc.hbegin); |
| 304 | | timer_adjust_oneshot(raster_irq, irq_time, scan); |
| 303 | end_time = video_screen_get_time_until_pos(machine->primary_screen,scan,x68k_sys.crtc.hbegin); |
| 304 | timer_adjust_oneshot(x68k_raster_irq, irq_time, scan); |
| 305 | 305 | timer_set(machine, end_time,NULL,0,x68k_crtc_raster_end); |
| 306 | 306 | logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,video_screen_get_vpos(machine->primary_screen)); |
| 307 | 307 | } |
| r4212 | r4213 | |
| 316 | 316 | |
| 317 | 317 | if(val == 1) // VBlank on |
| 318 | 318 | { |
| 319 | | sys.crtc.vblank = 1; |
| 320 | | vblank_line = sys.crtc.vbegin; |
| 319 | x68k_sys.crtc.vblank = 1; |
| 320 | vblank_line = x68k_sys.crtc.vbegin; |
| 321 | 321 | irq_time = video_screen_get_time_until_pos(machine->primary_screen,vblank_line,2); |
| 322 | | timer_adjust_oneshot(vblank_irq, irq_time, 0); |
| 322 | timer_adjust_oneshot(x68k_vblank_irq, irq_time, 0); |
| 323 | 323 | logerror("CRTC: VBlank on\n"); |
| 324 | 324 | } |
| 325 | 325 | if(val == 0) // VBlank off |
| 326 | 326 | { |
| 327 | | sys.crtc.vblank = 0; |
| 328 | | vblank_line = sys.crtc.vend; |
| 329 | | if(vblank_line > sys.crtc.vtotal) |
| 330 | | vblank_line = sys.crtc.vtotal; |
| 327 | x68k_sys.crtc.vblank = 0; |
| 328 | vblank_line = x68k_sys.crtc.vend; |
| 329 | if(vblank_line > x68k_sys.crtc.vtotal) |
| 330 | vblank_line = x68k_sys.crtc.vtotal; |
| 331 | 331 | irq_time = video_screen_get_time_until_pos(machine->primary_screen,vblank_line,2); |
| 332 | | timer_adjust_oneshot(vblank_irq, irq_time, 1); |
| 332 | timer_adjust_oneshot(x68k_vblank_irq, irq_time, 1); |
| 333 | 333 | logerror("CRTC: VBlank off\n"); |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | if (x68k_mfp != NULL) |
| 337 | | mc68901_tai_w(x68k_mfp, !sys.crtc.vblank); |
| 337 | mc68901_tai_w(x68k_mfp, !x68k_sys.crtc.vblank); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | |
| r4212 | r4213 | |
| 387 | 387 | */ |
| 388 | 388 | WRITE16_HANDLER( x68k_crtc_w ) |
| 389 | 389 | { |
| 390 | | COMBINE_DATA(sys.crtc.reg+offset); |
| 390 | COMBINE_DATA(x68k_sys.crtc.reg+offset); |
| 391 | 391 | switch(offset) |
| 392 | 392 | { |
| 393 | 393 | case 0: |
| r4212 | r4213 | |
| 404 | 404 | case 9: // CRTC raster IRQ (GPIP6) |
| 405 | 405 | { |
| 406 | 406 | attotime irq_time; |
| 407 | | irq_time = video_screen_get_time_until_pos(space->machine->primary_screen,(data) / sys.crtc.vmultiple,2); |
| 407 | irq_time = video_screen_get_time_until_pos(space->machine->primary_screen,(data) / x68k_sys.crtc.vmultiple,2); |
| 408 | 408 | |
| 409 | 409 | if(attotime_to_double(irq_time) > 0) |
| 410 | | timer_adjust_oneshot(raster_irq, irq_time, (data) / sys.crtc.vmultiple); |
| 410 | timer_adjust_oneshot(x68k_raster_irq, irq_time, (data) / x68k_sys.crtc.vmultiple); |
| 411 | 411 | } |
| 412 | 412 | logerror("CRTC: Write to raster IRQ register - %i\n",data); |
| 413 | 413 | break; |
| r4212 | r4213 | |
| 417 | 417 | switch(data & 0x0c) |
| 418 | 418 | { |
| 419 | 419 | case 0x00: |
| 420 | | sys.crtc.height = 256; |
| 420 | x68k_sys.crtc.height = 256; |
| 421 | 421 | break; |
| 422 | 422 | case 0x08: |
| 423 | 423 | case 0x0c: // TODO: 1024 vertical, if horizontal freq = 31kHz |
| 424 | | sys.crtc.height = 512; |
| 424 | x68k_sys.crtc.height = 512; |
| 425 | 425 | break; |
| 426 | 426 | case 0x04: |
| 427 | | sys.crtc.height = 512; |
| 427 | x68k_sys.crtc.height = 512; |
| 428 | 428 | break; |
| 429 | 429 | } |
| 430 | 430 | switch(data & 0x03) |
| 431 | 431 | { |
| 432 | 432 | case 0x00: |
| 433 | | sys.crtc.width = 256; |
| 433 | x68k_sys.crtc.width = 256; |
| 434 | 434 | break; |
| 435 | 435 | case 0x01: |
| 436 | | sys.crtc.width = 512; |
| 436 | x68k_sys.crtc.width = 512; |
| 437 | 437 | break; |
| 438 | 438 | case 0x02: |
| 439 | 439 | case 0x03: // 0x03 = 50MHz clock mode (XVI only) |
| 440 | | sys.crtc.width = 768; |
| 440 | x68k_sys.crtc.width = 768; |
| 441 | 441 | break; |
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | if(ACCESSING_BITS_8_15) |
| 445 | 445 | { |
| 446 | | sys.crtc.interlace = 0; |
| 446 | x68k_sys.crtc.interlace = 0; |
| 447 | 447 | if(data & 0x0400) |
| 448 | | sys.crtc.interlace = 1; |
| 448 | x68k_sys.crtc.interlace = 1; |
| 449 | 449 | } |
| 450 | 450 | x68k_crtc_refresh_mode(space->machine); |
| 451 | 451 | break; |
| 452 | 452 | case 576: // operation register |
| 453 | | sys.crtc.operation = data; |
| 453 | x68k_sys.crtc.operation = data; |
| 454 | 454 | if(data & 0x08) // text screen raster copy |
| 455 | 455 | { |
| 456 | | x68k_crtc_text_copy((sys.crtc.reg[22] & 0xff00) >> 8,(sys.crtc.reg[22] & 0x00ff)); |
| 456 | x68k_crtc_text_copy((x68k_sys.crtc.reg[22] & 0xff00) >> 8,(x68k_sys.crtc.reg[22] & 0x00ff)); |
| 457 | 457 | timer_set(space->machine, ATTOTIME_IN_MSEC(1), NULL, 0x02,x68k_crtc_operation_end); // time taken to do operation is a complete guess. |
| 458 | 458 | } |
| 459 | 459 | if(data & 0x02) // high-speed graphic screen clear |
| r4212 | r4213 | |
| 461 | 461 | rectangle rect = {0,0,0,0}; |
| 462 | 462 | rect.max_x = 512; |
| 463 | 463 | rect.max_y = 512; |
| 464 | | if(sys.crtc.reg[21] & 0x01) |
| 464 | if(x68k_sys.crtc.reg[21] & 0x01) |
| 465 | 465 | { |
| 466 | 466 | bitmap_fill(x68k_gfx_0_bitmap_16,&rect,0); |
| 467 | 467 | bitmap_fill(x68k_gfx_0_bitmap_256,&rect,0); |
| 468 | 468 | bitmap_fill(x68k_gfx_0_bitmap_65536,&rect,0); |
| 469 | 469 | bitmap_fill(x68k_gfx_big_bitmap,&rect,0); |
| 470 | | memset(gvram,0,0x40000); |
| 470 | memset(x68k_gvram,0,0x40000); |
| 471 | 471 | } |
| 472 | | if(sys.crtc.reg[21] & 0x02) |
| 472 | if(x68k_sys.crtc.reg[21] & 0x02) |
| 473 | 473 | { |
| 474 | 474 | bitmap_fill(x68k_gfx_1_bitmap_16,&rect,0); |
| 475 | 475 | bitmap_fill(x68k_gfx_1_bitmap_256,&rect,0); |
| 476 | | memset(gvram+0x40000,0,0x40000); |
| 476 | memset(x68k_gvram+0x40000,0,0x40000); |
| 477 | 477 | } |
| 478 | | if(sys.crtc.reg[21] & 0x04) |
| 478 | if(x68k_sys.crtc.reg[21] & 0x04) |
| 479 | 479 | { |
| 480 | 480 | bitmap_fill(x68k_gfx_2_bitmap_16,&rect,0); |
| 481 | | memset(gvram+0x80000,0,0x40000); |
| 481 | memset(x68k_gvram+0x80000,0,0x40000); |
| 482 | 482 | } |
| 483 | | if(sys.crtc.reg[21] & 0x08) |
| 483 | if(x68k_sys.crtc.reg[21] & 0x08) |
| 484 | 484 | { |
| 485 | 485 | bitmap_fill(x68k_gfx_3_bitmap_16,&rect,0); |
| 486 | | memset(gvram+0xc0000,0,0x40000); |
| 486 | memset(x68k_gvram+0xc0000,0,0x40000); |
| 487 | 487 | } |
| 488 | 488 | timer_set(space->machine, ATTOTIME_IN_MSEC(10), NULL, 0x02,x68k_crtc_operation_end); // time taken to do operation is a complete guess. |
| 489 | | // popmessage("CRTC: High-speed gfx screen clear [0x%02x]",sys.crtc.reg[21] & 0x0f); |
| 489 | // popmessage("CRTC: High-speed gfx screen clear [0x%02x]",x68k_sys.crtc.reg[21] & 0x0f); |
| 490 | 490 | } |
| 491 | 491 | break; |
| 492 | 492 | } |
| r4212 | r4213 | |
| 503 | 503 | }*/ |
| 504 | 504 | if(offset < 24) |
| 505 | 505 | { |
| 506 | | // logerror("CRTC: [%08x] Read %04x from CRTC register %i\n",activecpu_get_pc(),sys.crtc.reg[offset],offset); |
| 506 | // logerror("CRTC: [%08x] Read %04x from CRTC register %i\n",activecpu_get_pc(),x68k_sys.crtc.reg[offset],offset); |
| 507 | 507 | switch(offset) |
| 508 | 508 | { |
| 509 | 509 | case 9: |
| r4212 | r4213 | |
| 512 | 512 | case 11: |
| 513 | 513 | case 12: // Graphic layer 0 scroll |
| 514 | 514 | case 13: |
| 515 | | return sys.crtc.reg[offset] & 0x3ff; |
| 515 | return x68k_sys.crtc.reg[offset] & 0x3ff; |
| 516 | 516 | case 14: // Graphic layer 1 scroll |
| 517 | 517 | case 15: |
| 518 | 518 | case 16: // Graphic layer 2 scroll |
| 519 | 519 | case 17: |
| 520 | 520 | case 18: // Graphic layer 3 scroll |
| 521 | 521 | case 19: |
| 522 | | return sys.crtc.reg[offset] & 0x1ff; |
| 522 | return x68k_sys.crtc.reg[offset] & 0x1ff; |
| 523 | 523 | default: |
| 524 | | return sys.crtc.reg[offset]; |
| 524 | return x68k_sys.crtc.reg[offset]; |
| 525 | 525 | } |
| 526 | 526 | } |
| 527 | 527 | if(offset == 576) // operation port, operation bits are set to 0 when operation is complete |
| 528 | | return sys.crtc.operation; |
| 528 | return x68k_sys.crtc.operation; |
| 529 | 529 | // logerror("CRTC: [%08x] Read from unknown CRTC register %i\n",activecpu_get_pc(),offset); |
| 530 | 530 | return 0xffff; |
| 531 | 531 | } |
| r4212 | r4213 | |
| 537 | 537 | // if(offset % 2 == 0) |
| 538 | 538 | // bit += 8; |
| 539 | 539 | // offset = offset/2; |
| 540 | | if(tvram[offset] & (1 << bit)) |
| 540 | if(x68k_tvram[offset] & (1 << bit)) |
| 541 | 541 | ret |= 0x01; |
| 542 | | if(tvram[offset+0x10000] & (1 << bit)) |
| 542 | if(x68k_tvram[offset+0x10000] & (1 << bit)) |
| 543 | 543 | ret |= 0x02; |
| 544 | | if(tvram[offset+0x20000] & (1 << bit)) |
| 544 | if(x68k_tvram[offset+0x20000] & (1 << bit)) |
| 545 | 545 | ret |= 0x04; |
| 546 | | if(tvram[offset+0x30000] & (1 << bit)) |
| 546 | if(x68k_tvram[offset+0x30000] & (1 << bit)) |
| 547 | 547 | ret |= 0x08; |
| 548 | 548 | |
| 549 | 549 | return ret; |
| r4212 | r4213 | |
| 561 | 561 | for(l=0;l<16;l++) |
| 562 | 562 | { |
| 563 | 563 | // apply text layer access mask |
| 564 | | if(sys.crtc.reg[21] & 0x0200) |
| 564 | if(x68k_sys.crtc.reg[21] & 0x0200) |
| 565 | 565 | { |
| 566 | | if((sys.crtc.reg[23] & (1<<l)) == 0) |
| 566 | if((x68k_sys.crtc.reg[23] & (1<<l)) == 0) |
| 567 | 567 | x68k_plot_pixel(x68k_text_bitmap,x+(15-l),y,0x100+x68k_get_text_pixel(offset,l)); |
| 568 | 568 | } |
| 569 | 569 | else |
| r4212 | r4213 | |
| 588 | 588 | Page 1 - 0xc00000-0xc7ffff Page 2 - 0xc80000-0xcfffff |
| 589 | 589 | Page 3 - 0xd00000-0xd7ffff Page 4 - 0xd80000-0xdfffff |
| 590 | 590 | */ |
| 591 | | COMBINE_DATA(gvram+offset); |
| 591 | COMBINE_DATA(x68k_gvram+offset); |
| 592 | 592 | |
| 593 | 593 | pageoffset = offset & 0xfffff; |
| 594 | 594 | xloc = pageoffset % 1024; |
| r4212 | r4213 | |
| 601 | 601 | |
| 602 | 602 | if(offset < 0x40000) // first page, all colour depths |
| 603 | 603 | { |
| 604 | | x68k_plot_pixel(x68k_gfx_0_bitmap_65536,xloc,yloc,(gvram[offset] >> 1) + 512); |
| 604 | x68k_plot_pixel(x68k_gfx_0_bitmap_65536,xloc,yloc,(x68k_gvram[offset] >> 1) + 512); |
| 605 | 605 | x68k_plot_pixel(x68k_gfx_0_bitmap_256,xloc,yloc,data & 0x00ff); |
| 606 | 606 | x68k_plot_pixel(x68k_gfx_0_bitmap_16,xloc,yloc,data & 0x000f); |
| 607 | 607 | } |
| r4212 | r4213 | |
| 624 | 624 | { |
| 625 | 625 | UINT16 text_mask; |
| 626 | 626 | |
| 627 | | text_mask = ~(sys.crtc.reg[23]) & mem_mask; |
| 627 | text_mask = ~(x68k_sys.crtc.reg[23]) & mem_mask; |
| 628 | 628 | |
| 629 | | if(!(sys.crtc.reg[21] & 0x0200)) // text access mask enable |
| 629 | if(!(x68k_sys.crtc.reg[21] & 0x0200)) // text access mask enable |
| 630 | 630 | text_mask = 0xffff & mem_mask; |
| 631 | 631 | |
| 632 | 632 | mem_mask = text_mask; |
| 633 | 633 | |
| 634 | | if(sys.crtc.reg[21] & 0x0100) |
| 634 | if(x68k_sys.crtc.reg[21] & 0x0100) |
| 635 | 635 | { // simultaneous T-VRAM plane access (I think ;)) |
| 636 | 636 | int plane,wr; |
| 637 | 637 | offset = offset & 0x00ffff; |
| 638 | | wr = (sys.crtc.reg[21] & 0x00f0) >> 4; |
| 638 | wr = (x68k_sys.crtc.reg[21] & 0x00f0) >> 4; |
| 639 | 639 | for(plane=0;plane<4;plane++) |
| 640 | 640 | { |
| 641 | 641 | if(wr & (1 << plane)) |
| 642 | 642 | { |
| 643 | | COMBINE_DATA(tvram+offset+(0x10000*plane)); |
| 643 | COMBINE_DATA(x68k_tvram+offset+(0x10000*plane)); |
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | x68k_render_video_word(offset); |
| 647 | 647 | } |
| 648 | 648 | else |
| 649 | 649 | { |
| 650 | | COMBINE_DATA(tvram+offset); |
| 650 | COMBINE_DATA(x68k_tvram+offset); |
| 651 | 651 | x68k_render_video_word(offset); |
| 652 | 652 | } |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | READ16_HANDLER( x68k_gvram_r ) |
| 656 | 656 | { |
| 657 | | return gvram[offset]; |
| 657 | return x68k_gvram[offset]; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | READ16_HANDLER( x68k_tvram_r ) |
| 661 | 661 | { |
| 662 | | return tvram[offset]; |
| 662 | return x68k_tvram[offset]; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | WRITE16_HANDLER( x68k_spritereg_w ) |
| r4212 | r4213 | |
| 668 | 668 | switch(offset) |
| 669 | 669 | { |
| 670 | 670 | case 0x400: |
| 671 | | tilemap_set_scrollx(x68k_bg0_8,0,(data - sys.crtc.hbegin) & 0x3ff); |
| 672 | | tilemap_set_scrollx(x68k_bg0_16,0,(data - sys.crtc.hbegin) & 0x3ff); |
| 671 | tilemap_set_scrollx(x68k_bg0_8,0,(data - x68k_sys.crtc.hbegin) & 0x3ff); |
| 672 | tilemap_set_scrollx(x68k_bg0_16,0,(data - x68k_sys.crtc.hbegin) & 0x3ff); |
| 673 | 673 | break; |
| 674 | 674 | case 0x401: |
| 675 | | tilemap_set_scrolly(x68k_bg0_8,0,(data - sys.crtc.vbegin) & 0x3ff); |
| 676 | | tilemap_set_scrolly(x68k_bg0_16,0,(data - sys.crtc.vbegin) & 0x3ff); |
| 675 | tilemap_set_scrolly(x68k_bg0_8,0,(data - x68k_sys.crtc.vbegin) & 0x3ff); |
| 676 | tilemap_set_scrolly(x68k_bg0_16,0,(data - x68k_sys.crtc.vbegin) & 0x3ff); |
| 677 | 677 | break; |
| 678 | 678 | case 0x402: |
| 679 | | tilemap_set_scrollx(x68k_bg1_8,0,(data - sys.crtc.hbegin) & 0x3ff); |
| 680 | | tilemap_set_scrollx(x68k_bg1_16,0,(data - sys.crtc.hbegin) & 0x3ff); |
| 679 | tilemap_set_scrollx(x68k_bg1_8,0,(data - x68k_sys.crtc.hbegin) & 0x3ff); |
| 680 | tilemap_set_scrollx(x68k_bg1_16,0,(data - x68k_sys.crtc.hbegin) & 0x3ff); |
| 681 | 681 | break; |
| 682 | 682 | case 0x403: |
| 683 | | tilemap_set_scrolly(x68k_bg1_8,0,(data - sys.crtc.vbegin) & 0x3ff); |
| 684 | | tilemap_set_scrolly(x68k_bg1_16,0,(data - sys.crtc.vbegin) & 0x3ff); |
| 683 | tilemap_set_scrolly(x68k_bg1_8,0,(data - x68k_sys.crtc.vbegin) & 0x3ff); |
| 684 | tilemap_set_scrolly(x68k_bg1_16,0,(data - x68k_sys.crtc.vbegin) & 0x3ff); |
| 685 | 685 | break; |
| 686 | 686 | case 0x405: // BG H-DISP (like CRTC reg 2) |
| 687 | 687 | if(data != 0x00ff) |
| 688 | 688 | { |
| 689 | | sys.crtc.bg_visible_width = (sys.crtc.reg[3] - ((data & 0x003f) - 4)) * 8; |
| 690 | | sys.crtc.bg_hshift = (sys.crtc.width - sys.crtc.bg_visible_width) / 2; |
| 689 | x68k_sys.crtc.bg_visible_width = (x68k_sys.crtc.reg[3] - ((data & 0x003f) - 4)) * 8; |
| 690 | x68k_sys.crtc.bg_hshift = (x68k_sys.crtc.width - x68k_sys.crtc.bg_visible_width) / 2; |
| 691 | 691 | } |
| 692 | 692 | else |
| 693 | | sys.crtc.bg_hshift = sys.crtc.hshift; |
| 693 | x68k_sys.crtc.bg_hshift = x68k_sys.crtc.hshift; |
| 694 | 694 | break; |
| 695 | 695 | case 0x406: // BG V-DISP (like CRTC reg 6) |
| 696 | | sys.crtc.bg_vshift = sys.crtc.vshift; |
| 696 | x68k_sys.crtc.bg_vshift = x68k_sys.crtc.vshift; |
| 697 | 697 | break; |
| 698 | 698 | } |
| 699 | 699 | } |
| r4212 | r4213 | |
| 708 | 708 | WRITE16_HANDLER( x68k_spriteram_w ) |
| 709 | 709 | { |
| 710 | 710 | COMBINE_DATA(x68k_spriteram+offset); |
| 711 | | sys.video.tile8_dirty[offset / 16] = 1; |
| 712 | | sys.video.tile16_dirty[offset / 64] = 1; |
| 711 | x68k_sys.video.tile8_dirty[offset / 16] = 1; |
| 712 | x68k_sys.video.tile16_dirty[offset / 64] = 1; |
| 713 | 713 | if(offset < 0x2000) |
| 714 | 714 | { |
| 715 | 715 | tilemap_mark_all_tiles_dirty(x68k_bg1_8); |
| r4212 | r4213 | |
| 743 | 743 | |
| 744 | 744 | for(priority=3;priority>=0;priority--) |
| 745 | 745 | { |
| 746 | | if(sys.crtc.reg[20] & 0x0400) // 1024x1024 "real" screen size - use 1024x1024 16-colour gfx layer |
| 746 | if(x68k_sys.crtc.reg[20] & 0x0400) // 1024x1024 "real" screen size - use 1024x1024 16-colour gfx layer |
| 747 | 747 | { |
| 748 | 748 | // 16 colour gfx screen |
| 749 | | rect.min_x=sys.crtc.hshift; |
| 750 | | rect.min_y=sys.crtc.vshift; |
| 751 | | rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 752 | | rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 753 | | if(sys.video.reg[2] & 0x0010 && priority == sys.video.gfxlayer_pri[0]) |
| 749 | rect.min_x=x68k_sys.crtc.hshift; |
| 750 | rect.min_y=x68k_sys.crtc.vshift; |
| 751 | rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 752 | rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 753 | if(x68k_sys.video.reg[2] & 0x0010 && priority == x68k_sys.video.gfxlayer_pri[0]) |
| 754 | 754 | { |
| 755 | | xscr = sys.crtc.hbegin-(sys.crtc.reg[12]); |
| 756 | | yscr = sys.crtc.vbegin-(sys.crtc.reg[13]); |
| 755 | xscr = x68k_sys.crtc.hbegin-(x68k_sys.crtc.reg[12]); |
| 756 | yscr = x68k_sys.crtc.vbegin-(x68k_sys.crtc.reg[13]); |
| 757 | 757 | copyscrollbitmap_trans(bitmap, x68k_gfx_big_bitmap, 1, &xscr, 1, &yscr ,&cliprect,0); |
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | else // 512x512 "real" screen size |
| 761 | 761 | { |
| 762 | | switch(sys.video.reg[0] & 0x03) |
| 762 | switch(x68k_sys.video.reg[0] & 0x03) |
| 763 | 763 | { |
| 764 | 764 | case 0x03: |
| 765 | 765 | // 65,536 colour gfx screen |
| 766 | | if(sys.video.reg[2] & 0x0001 && priority == sys.video.gfxlayer_pri[0]) |
| 766 | if(x68k_sys.video.reg[2] & 0x0001 && priority == x68k_sys.video.gfxlayer_pri[0]) |
| 767 | 767 | { |
| 768 | | rect.min_x=sys.crtc.hshift; |
| 769 | | rect.min_y=sys.crtc.vshift; |
| 770 | | rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 771 | | rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 772 | | xscr = sys.crtc.hbegin-(sys.crtc.reg[12] & 0x1ff); |
| 773 | | yscr = sys.crtc.vbegin-(sys.crtc.reg[13] & 0x1ff); |
| 768 | rect.min_x=x68k_sys.crtc.hshift; |
| 769 | rect.min_y=x68k_sys.crtc.vshift; |
| 770 | rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 771 | rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 772 | xscr = x68k_sys.crtc.hbegin-(x68k_sys.crtc.reg[12] & 0x1ff); |
| 773 | yscr = x68k_sys.crtc.vbegin-(x68k_sys.crtc.reg[13] & 0x1ff); |
| 774 | 774 | copyscrollbitmap_trans(bitmap, x68k_gfx_0_bitmap_65536, 1, &xscr, 1, &yscr,&cliprect,0); |
| 775 | 775 | } |
| 776 | 776 | break; |
| 777 | 777 | case 0x01: |
| 778 | 778 | // 256 colour gfx screen |
| 779 | | rect.min_x=sys.crtc.hshift; |
| 780 | | rect.min_y=sys.crtc.vshift; |
| 781 | | rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 782 | | rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 783 | | gpage = sys.video.gfxlayer_pri[priority]; |
| 784 | | if(sys.video.reg[2] & (1 << priority)) |
| 779 | rect.min_x=x68k_sys.crtc.hshift; |
| 780 | rect.min_y=x68k_sys.crtc.vshift; |
| 781 | rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 782 | rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 783 | gpage = x68k_sys.video.gfxlayer_pri[priority]; |
| 784 | if(x68k_sys.video.reg[2] & (1 << priority)) |
| 785 | 785 | { |
| 786 | 786 | if(gpage == 0 || gpage == 2) // so that we aren't drawing the same pages twice |
| 787 | 787 | { |
| 788 | | xscr = sys.crtc.hbegin-(sys.crtc.reg[12 + (gpage*2)] & 0x1ff); |
| 789 | | yscr = sys.crtc.vbegin-(sys.crtc.reg[13 + (gpage*2)] & 0x1ff); |
| 788 | xscr = x68k_sys.crtc.hbegin-(x68k_sys.crtc.reg[12 + (gpage*2)] & 0x1ff); |
| 789 | yscr = x68k_sys.crtc.vbegin-(x68k_sys.crtc.reg[13 + (gpage*2)] & 0x1ff); |
| 790 | 790 | copyscrollbitmap_trans(bitmap, x68k_get_gfx_page(gpage,GFX256), 1, &xscr, 1, &yscr, &cliprect,0); |
| 791 | 791 | } |
| 792 | 792 | } |
| 793 | 793 | break; |
| 794 | 794 | case 0x00: |
| 795 | 795 | // 16 colour gfx screen |
| 796 | | rect.min_x=sys.crtc.hshift; |
| 797 | | rect.min_y=sys.crtc.vshift; |
| 798 | | rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 799 | | rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 800 | | gpage = sys.video.gfxlayer_pri[priority]; |
| 801 | | if(sys.video.reg[2] & (1 << priority)) |
| 796 | rect.min_x=x68k_sys.crtc.hshift; |
| 797 | rect.min_y=x68k_sys.crtc.vshift; |
| 798 | rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 799 | rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 800 | gpage = x68k_sys.video.gfxlayer_pri[priority]; |
| 801 | if(x68k_sys.video.reg[2] & (1 << priority)) |
| 802 | 802 | { |
| 803 | | xscr = sys.crtc.hbegin-(sys.crtc.reg[12+(gpage*2)] & 0x1ff); |
| 804 | | yscr = sys.crtc.vbegin-(sys.crtc.reg[13+(gpage*2)] & 0x1ff); |
| 803 | xscr = x68k_sys.crtc.hbegin-(x68k_sys.crtc.reg[12+(gpage*2)] & 0x1ff); |
| 804 | yscr = x68k_sys.crtc.vbegin-(x68k_sys.crtc.reg[13+(gpage*2)] & 0x1ff); |
| 805 | 805 | copyscrollbitmap_trans(bitmap, x68k_get_gfx_page(gpage,GFX16), 1, &xscr, 1, &yscr ,&cliprect,0); |
| 806 | 806 | } |
| 807 | 807 | break; |
| r4212 | r4213 | |
| 860 | 860 | int sx = (x68k_spritereg[ptr+0] & 0x3ff) - 16; |
| 861 | 861 | int sy = (x68k_spritereg[ptr+1] & 0x3ff) - 16; |
| 862 | 862 | |
| 863 | | rect.min_x=sys.crtc.hshift; |
| 864 | | rect.min_y=sys.crtc.vshift; |
| 865 | | rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 866 | | rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 863 | rect.min_x=x68k_sys.crtc.hshift; |
| 864 | rect.min_y=x68k_sys.crtc.vshift; |
| 865 | rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 866 | rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 867 | 867 | |
| 868 | 868 | sx += sprite_shift; |
| 869 | 869 | |
| 870 | | drawgfx(bitmap,machine->gfx[1],code,colour+0x10,xflip,yflip,sys.crtc.hbegin+sx,sys.crtc.vbegin+sy,&cliprect,TRANSPARENCY_PEN,0x00); |
| 870 | drawgfx(bitmap,machine->gfx[1],code,colour+0x10,xflip,yflip,x68k_sys.crtc.hbegin+sx,x68k_sys.crtc.vbegin+sy,&cliprect,TRANSPARENCY_PEN,0x00); |
| 871 | 871 | } |
| 872 | 872 | } |
| 873 | 873 | } |
| r4212 | r4213 | |
| 985 | 985 | tilemap_set_transparent_pen(x68k_bg0_16,0); |
| 986 | 986 | tilemap_set_transparent_pen(x68k_bg1_16,0); |
| 987 | 987 | |
| 988 | | // timer_adjust_periodic(scanline_timer, attotime_zero, 0, ATTOTIME_IN_HZ(55.45)/568); |
| 988 | // timer_adjust_periodic(x68k_scanline_timer, attotime_zero, 0, ATTOTIME_IN_HZ(55.45)/568); |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | VIDEO_UPDATE( x68000 ) |
| r4212 | r4213 | |
| 1008 | 1008 | x68k_bg0 = x68k_bg0_16; |
| 1009 | 1009 | x68k_bg1 = x68k_bg1_16; |
| 1010 | 1010 | } |
| 1011 | | // rect.max_x=sys.crtc.width; |
| 1012 | | // rect.max_y=sys.crtc.height; |
| 1011 | // rect.max_x=x68k_sys.crtc.width; |
| 1012 | // rect.max_y=x68k_sys.crtc.height; |
| 1013 | 1013 | bitmap_fill(bitmap,cliprect,0); |
| 1014 | 1014 | |
| 1015 | | rect.min_x=sys.crtc.hbegin; |
| 1016 | | rect.min_y=sys.crtc.vbegin; |
| 1017 | | // rect.max_x=rect.min_x + sys.crtc.visible_width-1; |
| 1018 | | // rect.max_y=rect.min_y + sys.crtc.visible_height-1; |
| 1019 | | rect.max_x=sys.crtc.hend + 1; |
| 1020 | | rect.max_y=sys.crtc.vend + 1; |
| 1015 | rect.min_x=x68k_sys.crtc.hbegin; |
| 1016 | rect.min_y=x68k_sys.crtc.vbegin; |
| 1017 | // rect.max_x=rect.min_x + x68k_sys.crtc.visible_width-1; |
| 1018 | // rect.max_y=rect.min_y + x68k_sys.crtc.visible_height-1; |
| 1019 | rect.max_x=x68k_sys.crtc.hend + 1; |
| 1020 | rect.max_y=x68k_sys.crtc.vend + 1; |
| 1021 | 1021 | |
| 1022 | 1022 | if(rect.min_y < cliprect->min_y) |
| 1023 | 1023 | rect.min_y = cliprect->min_y; |
| r4212 | r4213 | |
| 1028 | 1028 | rom = memory_region(screen->machine, "user1"); |
| 1029 | 1029 | for(x=0;x<256;x++) |
| 1030 | 1030 | { |
| 1031 | | if(sys.video.tile16_dirty[x] != 0) |
| 1031 | if(x68k_sys.video.tile16_dirty[x] != 0) |
| 1032 | 1032 | { |
| 1033 | 1033 | gfx_element_mark_dirty(screen->machine->gfx[1], x); |
| 1034 | | sys.video.tile16_dirty[x] = 0; |
| 1034 | x68k_sys.video.tile16_dirty[x] = 0; |
| 1035 | 1035 | } |
| 1036 | | if(sys.video.tile8_dirty[x] != 0) |
| 1036 | if(x68k_sys.video.tile8_dirty[x] != 0) |
| 1037 | 1037 | { |
| 1038 | 1038 | gfx_element_mark_dirty(screen->machine->gfx[0], x); |
| 1039 | | sys.video.tile8_dirty[x] = 0; |
| 1039 | x68k_sys.video.tile8_dirty[x] = 0; |
| 1040 | 1040 | } |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | for(priority=3;priority>=0;priority--) |
| 1044 | 1044 | { |
| 1045 | 1045 | // Graphics screen(s) |
| 1046 | | if(priority == sys.video.gfx_pri) |
| 1046 | if(priority == x68k_sys.video.gfx_pri) |
| 1047 | 1047 | x68k_draw_gfx(bitmap,rect); |
| 1048 | 1048 | |
| 1049 | 1049 | // Sprite / BG Tiles |
| 1050 | | if(priority == sys.video.sprite_pri /*&& (x68k_spritereg[0x404] & 0x0200)*/ && (sys.video.reg[2] & 0x0040)) |
| 1050 | if(priority == x68k_sys.video.sprite_pri /*&& (x68k_spritereg[0x404] & 0x0200)*/ && (x68k_sys.video.reg[2] & 0x0040)) |
| 1051 | 1051 | { |
| 1052 | 1052 | x68k_draw_sprites(screen->machine, bitmap,1,rect); |
| 1053 | 1053 | if((x68k_spritereg[0x404] & 0x0008)) |
| 1054 | 1054 | { |
| 1055 | 1055 | if((x68k_spritereg[0x404] & 0x0030) == 0x10) // BG1 TXSEL |
| 1056 | 1056 | { |
| 1057 | | tilemap_set_scrollx(x68k_bg0,0,(x68k_spritereg[0x402] - sys.crtc.hbegin) & 0x3ff); |
| 1058 | | tilemap_set_scrolly(x68k_bg0,0,(x68k_spritereg[0x403] - sys.crtc.vbegin) & 0x3ff); |
| 1057 | tilemap_set_scrollx(x68k_bg0,0,(x68k_spritereg[0x402] - x68k_sys.crtc.hbegin) & 0x3ff); |
| 1058 | tilemap_set_scrolly(x68k_bg0,0,(x68k_spritereg[0x403] - x68k_sys.crtc.vbegin) & 0x3ff); |
| 1059 | 1059 | tilemap_draw(bitmap,&rect,x68k_bg0,0,0); |
| 1060 | 1060 | } |
| 1061 | 1061 | else |
| 1062 | 1062 | { |
| 1063 | | tilemap_set_scrollx(x68k_bg1,0,(x68k_spritereg[0x402] - sys.crtc.hbegin) & 0x3ff); |
| 1064 | | tilemap_set_scrolly(x68k_bg1,0,(x68k_spritereg[0x403] - sys.crtc.vbegin) & 0x3ff); |
| 1063 | tilemap_set_scrollx(x68k_bg1,0,(x68k_spritereg[0x402] - x68k_sys.crtc.hbegin) & 0x3ff); |
| 1064 | tilemap_set_scrolly(x68k_bg1,0,(x68k_spritereg[0x403] - x68k_sys.crtc.vbegin) & 0x3ff); |
| 1065 | 1065 | tilemap_draw(bitmap,&rect,x68k_bg1,0,0); |
| 1066 | 1066 | } |
| 1067 | 1067 | } |
| r4212 | r4213 | |
| 1070 | 1070 | { |
| 1071 | 1071 | if((x68k_spritereg[0x404] & 0x0006) == 0x02) // BG0 TXSEL |
| 1072 | 1072 | { |
| 1073 | | tilemap_set_scrollx(x68k_bg0,0,(x68k_spritereg[0x400] - sys.crtc.hbegin) & 0x3ff); |
| 1074 | | tilemap_set_scrolly(x68k_bg0,0,(x68k_spritereg[0x401] - sys.crtc.vbegin) & 0x3ff); |
| 1073 | tilemap_set_scrollx(x68k_bg0,0,(x68k_spritereg[0x400] - x68k_sys.crtc.hbegin) & 0x3ff); |
| 1074 | tilemap_set_scrolly(x68k_bg0,0,(x68k_spritereg[0x401] - x68k_sys.crtc.vbegin) & 0x3ff); |
| 1075 | 1075 | tilemap_draw(bitmap,&rect,x68k_bg0,0,0); |
| 1076 | 1076 | } |
| 1077 | 1077 | else |
| 1078 | 1078 | { |
| 1079 | | tilemap_set_scrollx(x68k_bg1,0,(x68k_spritereg[0x400] - sys.crtc.hbegin) & 0x3ff); |
| 1080 | | tilemap_set_scrolly(x68k_bg1,0,(x68k_spritereg[0x401] - sys.crtc.vbegin) & 0x3ff); |
| 1079 | tilemap_set_scrollx(x68k_bg1,0,(x68k_spritereg[0x400] - x68k_sys.crtc.hbegin) & 0x3ff); |
| 1080 | tilemap_set_scrolly(x68k_bg1,0,(x68k_spritereg[0x401] - x68k_sys.crtc.vbegin) & 0x3ff); |
| 1081 | 1081 | tilemap_draw(bitmap,&rect,x68k_bg1,0,0); |
| 1082 | 1082 | } |
| 1083 | 1083 | } |
| r4212 | r4213 | |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | // Text screen |
| 1088 | | if(sys.video.reg[2] & 0x0020 && priority == sys.video.text_pri) |
| 1088 | if(x68k_sys.video.reg[2] & 0x0020 && priority == x68k_sys.video.text_pri) |
| 1089 | 1089 | { |
| 1090 | | xscr = sys.crtc.hbegin-(sys.crtc.reg[10] & 0x3ff); |
| 1091 | | yscr = sys.crtc.vbegin-(sys.crtc.reg[11] & 0x3ff); |
| 1090 | xscr = x68k_sys.crtc.hbegin-(x68k_sys.crtc.reg[10] & 0x3ff); |
| 1091 | yscr = x68k_sys.crtc.vbegin-(x68k_sys.crtc.reg[11] & 0x3ff); |
| 1092 | 1092 | #ifdef MAME_DEBUG |
| 1093 | 1093 | if(!input_code_pressed(KEYCODE_Q)) |
| 1094 | 1094 | #endif |
| r4212 | r4213 | |
| 1099 | 1099 | #ifdef MAME_DEBUG |
| 1100 | 1100 | if(input_code_pressed(KEYCODE_I)) |
| 1101 | 1101 | { |
| 1102 | | sys.mfp.isra = 0; |
| 1103 | | sys.mfp.isrb = 0; |
| 1102 | x68k_sys.mfp.isra = 0; |
| 1103 | x68k_sys.mfp.isrb = 0; |
| 1104 | 1104 | // mfp_trigger_irq(MFP_IRQ_GPIP6); |
| 1105 | 1105 | // cpu_set_input_line_and_vector(machine->cpu[0],6,ASSERT_LINE,0x43); |
| 1106 | 1106 | } |
| r4212 | r4213 | |
| 1118 | 1118 | #endif |
| 1119 | 1119 | |
| 1120 | 1120 | #ifdef MAME_DEBUG |
| 1121 | | // popmessage("Layer priorities [%04x] - Txt: %i Spr: %i Gfx: %i Layer Pri0-3: %i %i %i %i",sys.video.reg[1],sys.video.text_pri,sys.video.sprite_pri, |
| 1122 | | // sys.video.gfx_pri,sys.video.gfxlayer_pri[0],sys.video.gfxlayer_pri[1],sys.video.gfxlayer_pri[2],sys.video.gfxlayer_pri[3]); |
| 1123 | | // popmessage("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i",sys.crtc.reg[0],sys.crtc.reg[1],sys.crtc.reg[2],sys.crtc.reg[3], |
| 1124 | | // sys.crtc.reg[4],sys.crtc.reg[5],sys.crtc.reg[6],sys.crtc.reg[7],sys.crtc.reg[8],sys.crtc.reg[9]); |
| 1125 | | // popmessage("Visible resolution = %ix%i (%s) Screen size = %ix%i",sys.crtc.visible_width,sys.crtc.visible_height,sys.crtc.interlace ? "Interlaced" : "Non-interlaced",sys.crtc.video_width,sys.crtc.video_height); |
| 1121 | // popmessage("Layer priorities [%04x] - Txt: %i Spr: %i Gfx: %i Layer Pri0-3: %i %i %i %i",x68k_sys.video.reg[1],x68k_sys.video.text_pri,x68k_sys.video.sprite_pri, |
| 1122 | // x68k_sys.video.gfx_pri,x68k_sys.video.gfxlayer_pri[0],x68k_sys.video.gfxlayer_pri[1],x68k_sys.video.gfxlayer_pri[2],x68k_sys.video.gfxlayer_pri[3]); |
| 1123 | // popmessage("CRTC regs - %i %i %i %i - %i %i %i %i - %i - %i",x68k_sys.crtc.reg[0],x68k_sys.crtc.reg[1],x68k_sys.crtc.reg[2],x68k_sys.crtc.reg[3], |
| 1124 | // x68k_sys.crtc.reg[4],x68k_sys.crtc.reg[5],x68k_sys.crtc.reg[6],x68k_sys.crtc.reg[7],x68k_sys.crtc.reg[8],x68k_sys.crtc.reg[9]); |
| 1125 | // popmessage("Visible resolution = %ix%i (%s) Screen size = %ix%i",x68k_sys.crtc.visible_width,x68k_sys.crtc.visible_height,x68k_sys.crtc.interlace ? "Interlaced" : "Non-interlaced",x68k_sys.crtc.video_width,x68k_sys.crtc.video_height); |
| 1126 | 1126 | // popmessage("VBlank : x68k_scanline = %i",x68k_scanline); |
| 1127 | | // popmessage("CRTC/BG compare H-TOTAL %i/%i H-DISP %i/%i V-DISP %i/%i BG Res %02x",sys.crtc.reg[0],x68k_spritereg[0x405],sys.crtc.reg[2],x68k_spritereg[0x406], |
| 1128 | | // sys.crtc.reg[6],x68k_spritereg[0x407],x68k_spritereg[0x408]); |
| 1129 | | // popmessage("IER %02x %02x IPR %02x %02x ISR %02x %02x IMR %02x %02x", sys.mfp.iera,sys.mfp.ierb,sys.mfp.ipra,sys.mfp.iprb, |
| 1130 | | // sys.mfp.isra,sys.mfp.isrb,sys.mfp.imra,sys.mfp.imrb); |
| 1127 | // popmessage("CRTC/BG compare H-TOTAL %i/%i H-DISP %i/%i V-DISP %i/%i BG Res %02x",x68k_sys.crtc.reg[0],x68k_spritereg[0x405],x68k_sys.crtc.reg[2],x68k_spritereg[0x406], |
| 1128 | // x68k_sys.crtc.reg[6],x68k_spritereg[0x407],x68k_spritereg[0x408]); |
| 1129 | // popmessage("IER %02x %02x IPR %02x %02x ISR %02x %02x IMR %02x %02x", x68k_sys.mfp.iera,x68k_sys.mfp.ierb,x68k_sys.mfp.ipra,x68k_sys.mfp.iprb, |
| 1130 | // x68k_sys.mfp.isra,x68k_sys.mfp.isrb,x68k_sys.mfp.imra,x68k_sys.mfp.imrb); |
| 1131 | 1131 | // popmessage("BG Scroll - BG0 X %i Y %i BG1 X %i Y %i",x68k_spriteram[0x400],x68k_spriteram[0x401],x68k_spriteram[0x402],x68k_spriteram[0x403]); |
| 1132 | | // popmessage("Keyboard buffer position = %i",sys.keyboard.headpos); |
| 1133 | | // popmessage("IERA = 0x%02x, IERB = 0x%02x",sys.mfp.iera,sys.mfp.ierb); |
| 1134 | | // popmessage("IPRA = 0x%02x, IPRB = 0x%02x",sys.mfp.ipra,sys.mfp.iprb); |
| 1132 | // popmessage("Keyboard buffer position = %i",x68k_sys.keyboard.headpos); |
| 1133 | // popmessage("IERA = 0x%02x, IERB = 0x%02x",x68k_sys.mfp.iera,x68k_sys.mfp.ierb); |
| 1134 | // popmessage("IPRA = 0x%02x, IPRB = 0x%02x",x68k_sys.mfp.ipra,x68k_sys.mfp.iprb); |
| 1135 | 1135 | // popmessage("uPD72065 status = %02x",nec765_status_r(machine, 0)); |
| 1136 | | // popmessage("Layer enable - 0x%02x",sys.video.reg[2] & 0xff); |
| 1136 | // popmessage("Layer enable - 0x%02x",x68k_sys.video.reg[2] & 0xff); |
| 1137 | 1137 | // popmessage("Graphic layer scroll - %i, %i - %i, %i - %i, %i - %i, %i", |
| 1138 | | // sys.crtc.reg[12],sys.crtc.reg[13],sys.crtc.reg[14],sys.crtc.reg[15],sys.crtc.reg[16],sys.crtc.reg[17],sys.crtc.reg[18],sys.crtc.reg[19]); |
| 1139 | | // popmessage("Video Controller registers - %04x - %04x - %04x",sys.video.reg[0],sys.video.reg[1],sys.video.reg[2]); |
| 1140 | | // popmessage("IOC IRQ status - %02x",sys.ioc.irqstatus); |
| 1138 | // x68k_sys.crtc.reg[12],x68k_sys.crtc.reg[13],x68k_sys.crtc.reg[14],x68k_sys.crtc.reg[15],x68k_sys.crtc.reg[16],x68k_sys.crtc.reg[17],x68k_sys.crtc.reg[18],x68k_sys.crtc.reg[19]); |
| 1139 | // popmessage("Video Controller registers - %04x - %04x - %04x",x68k_sys.video.reg[0],x68k_sys.video.reg[1],x68k_sys.video.reg[2]); |
| 1140 | // popmessage("IOC IRQ status - %02x",x68k_sys.ioc.irqstatus); |
| 1141 | 1141 | // popmessage("RAM: mouse data - %02x %02x %02x %02x",mess_ram[0x931],mess_ram[0x930],mess_ram[0x933],mess_ram[0x932]); |
| 1142 | 1142 | #endif |
| 1143 | 1143 | return 0; |
src/mess/video/electron.c
| r4212 | r4213 | |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | INLINE UINT8 read_vram( UINT16 addr ) { |
| 56 | | return ula.vram[ addr % ula.screen_size ]; |
| 56 | return electron_ula.vram[ addr % electron_ula.screen_size ]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | INLINE void electron_plot_pixel(bitmap_t *bitmap, int x, int y, UINT32 color) |
| r4212 | r4213 | |
| 71 | 71 | r.min_y = r.max_y = scanline; |
| 72 | 72 | |
| 73 | 73 | /* set up palette */ |
| 74 | | switch( ula.screen_mode ) { |
| 74 | switch( electron_ula.screen_mode ) { |
| 75 | 75 | case 0: case 3: case 4: case 6: case 7: /* 2 colour mode */ |
| 76 | | pal[0] = ula.current_pal[0]; |
| 77 | | pal[1] = ula.current_pal[8]; |
| 76 | pal[0] = electron_ula.current_pal[0]; |
| 77 | pal[1] = electron_ula.current_pal[8]; |
| 78 | 78 | break; |
| 79 | 79 | case 1: case 5: /* 4 colour mode */ |
| 80 | | pal[0] = ula.current_pal[0]; |
| 81 | | pal[1] = ula.current_pal[2]; |
| 82 | | pal[2] = ula.current_pal[8]; |
| 83 | | pal[3] = ula.current_pal[10]; |
| 80 | pal[0] = electron_ula.current_pal[0]; |
| 81 | pal[1] = electron_ula.current_pal[2]; |
| 82 | pal[2] = electron_ula.current_pal[8]; |
| 83 | pal[3] = electron_ula.current_pal[10]; |
| 84 | 84 | break; |
| 85 | 85 | case 2: /* 16 colour mode */ |
| 86 | 86 | for( i = 0; i < 16; i++ ) { |
| 87 | | pal[i] = ula.current_pal[i]; |
| 87 | pal[i] = electron_ula.current_pal[i]; |
| 88 | 88 | } |
| 89 | 89 | break; |
| 90 | 90 | } |
| 91 | 91 | /* draw line */ |
| 92 | | switch( ula.screen_mode ) { |
| 92 | switch( electron_ula.screen_mode ) { |
| 93 | 93 | case 0: |
| 94 | 94 | for( i = 0; i < 80; i++ ) { |
| 95 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 95 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 96 | 96 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)& 1] ); |
| 97 | 97 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)& 1] ); |
| 98 | 98 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)& 1] ); |
| r4212 | r4213 | |
| 102 | 102 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)& 1] ); |
| 103 | 103 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)& 1] ); |
| 104 | 104 | } |
| 105 | | ula.screen_addr += 1; |
| 105 | electron_ula.screen_addr += 1; |
| 106 | 106 | if ( ( scanline & 0x07 ) == 7 ) { |
| 107 | | ula.screen_addr += ( 0x280 - 8 ); |
| 107 | electron_ula.screen_addr += ( 0x280 - 8 ); |
| 108 | 108 | } |
| 109 | 109 | break; |
| 110 | 110 | case 1: |
| 111 | 111 | x = 0; |
| 112 | 112 | for( i = 0; i < 80; i++ ) { |
| 113 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 113 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 114 | 114 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>3]] ); |
| 115 | 115 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>3]] ); |
| 116 | 116 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>2]] ); |
| r4212 | r4213 | |
| 120 | 120 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>0]] ); |
| 121 | 121 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>0]] ); |
| 122 | 122 | } |
| 123 | | ula.screen_addr += 1; |
| 123 | electron_ula.screen_addr += 1; |
| 124 | 124 | if ( ( scanline & 0x07 ) == 7 ) { |
| 125 | | ula.screen_addr += ( 0x280 - 8 ); |
| 125 | electron_ula.screen_addr += ( 0x280 - 8 ); |
| 126 | 126 | } |
| 127 | 127 | break; |
| 128 | 128 | case 2: |
| 129 | 129 | for( i = 0; i < 80; i++ ) { |
| 130 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 130 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 131 | 131 | electron_plot_pixel( bitmap, x++, scanline, pal[map16[pattern>>1]] ); |
| 132 | 132 | electron_plot_pixel( bitmap, x++, scanline, pal[map16[pattern>>1]] ); |
| 133 | 133 | electron_plot_pixel( bitmap, x++, scanline, pal[map16[pattern>>1]] ); |
| r4212 | r4213 | |
| 137 | 137 | electron_plot_pixel( bitmap, x++, scanline, pal[map16[pattern>>0]] ); |
| 138 | 138 | electron_plot_pixel( bitmap, x++, scanline, pal[map16[pattern>>0]] ); |
| 139 | 139 | } |
| 140 | | ula.screen_addr += 1; |
| 140 | electron_ula.screen_addr += 1; |
| 141 | 141 | if ( ( scanline & 0x07 ) == 7 ) { |
| 142 | | ula.screen_addr += ( 0x280 - 8 ); |
| 142 | electron_ula.screen_addr += ( 0x280 - 8 ); |
| 143 | 143 | } |
| 144 | 144 | break; |
| 145 | 145 | case 3: |
| r4212 | r4213 | |
| 149 | 149 | { |
| 150 | 150 | for( i = 0; i < 80; i++ ) |
| 151 | 151 | { |
| 152 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 152 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 153 | 153 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); |
| 154 | 154 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); |
| 155 | 155 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>5)&1] ); |
| r4212 | r4213 | |
| 159 | 159 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>1)&1] ); |
| 160 | 160 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); |
| 161 | 161 | } |
| 162 | | ula.screen_addr += 1; |
| 162 | electron_ula.screen_addr += 1; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | | if ( scanline % 10 == 9 ) ula.screen_addr += ( 0x280 - 8 ); |
| 165 | if ( scanline % 10 == 9 ) electron_ula.screen_addr += ( 0x280 - 8 ); |
| 166 | 166 | break; |
| 167 | 167 | case 4: |
| 168 | 168 | case 7: |
| 169 | 169 | for( i = 0; i < 40; i++ ) { |
| 170 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 170 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 171 | 171 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); |
| 172 | 172 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); |
| 173 | 173 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); |
| r4212 | r4213 | |
| 185 | 185 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); |
| 186 | 186 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); |
| 187 | 187 | } |
| 188 | | ula.screen_addr += 1; |
| 188 | electron_ula.screen_addr += 1; |
| 189 | 189 | if ( ( scanline & 0x07 ) == 7 ) { |
| 190 | | ula.screen_addr += ( 0x140 - 8 ); |
| 190 | electron_ula.screen_addr += ( 0x140 - 8 ); |
| 191 | 191 | } |
| 192 | 192 | break; |
| 193 | 193 | case 5: |
| 194 | 194 | for( i = 0; i < 40; i++ ) { |
| 195 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 195 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 196 | 196 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>3]] ); |
| 197 | 197 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>3]] ); |
| 198 | 198 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>3]] ); |
| r4212 | r4213 | |
| 210 | 210 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>0]] ); |
| 211 | 211 | electron_plot_pixel( bitmap, x++, scanline, pal[map4[pattern>>0]] ); |
| 212 | 212 | } |
| 213 | | ula.screen_addr += 1; |
| 213 | electron_ula.screen_addr += 1; |
| 214 | 214 | if ( ( scanline & 0x07 ) == 7 ) { |
| 215 | | ula.screen_addr += ( 0x140 - 8 ); |
| 215 | electron_ula.screen_addr += ( 0x140 - 8 ); |
| 216 | 216 | } |
| 217 | 217 | break; |
| 218 | 218 | case 6: |
| r4212 | r4213 | |
| 220 | 220 | bitmap_fill( bitmap, &r , 7); |
| 221 | 221 | } else { |
| 222 | 222 | for( i = 0; i < 40; i++ ) { |
| 223 | | UINT8 pattern = read_vram( ula.screen_addr + i * 8 ); |
| 223 | UINT8 pattern = read_vram( electron_ula.screen_addr + i * 8 ); |
| 224 | 224 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); |
| 225 | 225 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>7)&1] ); |
| 226 | 226 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>6)&1] ); |
| r4212 | r4213 | |
| 238 | 238 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); |
| 239 | 239 | electron_plot_pixel( bitmap, x++, scanline, pal[(pattern>>0)&1] ); |
| 240 | 240 | } |
| 241 | | ula.screen_addr += 1; |
| 241 | electron_ula.screen_addr += 1; |
| 242 | 242 | if ( ( scanline % 10 ) == 7 ) { |
| 243 | | ula.screen_addr += ( 0x140 - 8 ); |
| 243 | electron_ula.screen_addr += ( 0x140 - 8 ); |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | break; |
| r4212 | r4213 | |
| 260 | 260 | electron_interrupt_handler( machine, INT_SET, INT_DISPLAY_END ); |
| 261 | 261 | break; |
| 262 | 262 | case 255: |
| 263 | | ula.screen_addr = ula.screen_start - ula.screen_base; |
| 263 | electron_ula.screen_addr = electron_ula.screen_start - electron_ula.screen_base; |
| 264 | 264 | break; |
| 265 | 265 | } |
| 266 | 266 | } |
src/mess/machine/electron.c
| r4212 | r4213 | |
| 12 | 12 | #include "sound/beep.h" |
| 13 | 13 | #include "devices/cassette.h" |
| 14 | 14 | |
| 15 | | ULA ula; |
| 15 | ULA electron_ula; |
| 16 | 16 | static emu_timer *electron_tape_timer; |
| 17 | 17 | |
| 18 | 18 | static const device_config *cassette_device_image( running_machine *machine ) { |
| r4212 | r4213 | |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | static void electron_tape_start( void ) { |
| 23 | | if ( ula.tape_running ) { |
| 23 | if ( electron_ula.tape_running ) { |
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | | ula.tape_steps = 0; |
| 27 | | ula.tape_value = 0x80808080; |
| 28 | | ula.high_tone_set = 0; |
| 29 | | ula.bit_count = 0; |
| 30 | | ula.tape_running = 1; |
| 26 | electron_ula.tape_steps = 0; |
| 27 | electron_ula.tape_value = 0x80808080; |
| 28 | electron_ula.high_tone_set = 0; |
| 29 | electron_ula.bit_count = 0; |
| 30 | electron_ula.tape_running = 1; |
| 31 | 31 | timer_adjust_periodic(electron_tape_timer, attotime_zero, 0, ATTOTIME_IN_HZ(4800)); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | static void electron_tape_stop( void ) { |
| 35 | | ula.tape_running = 0; |
| 35 | electron_ula.tape_running = 0; |
| 36 | 36 | timer_reset( electron_tape_timer, attotime_never ); |
| 37 | 37 | } |
| 38 | 38 | |
| r4212 | r4213 | |
| 41 | 41 | |
| 42 | 42 | static TIMER_CALLBACK(electron_tape_timer_handler) |
| 43 | 43 | { |
| 44 | | if ( ula.cassette_motor_mode ) { |
| 44 | if ( electron_ula.cassette_motor_mode ) { |
| 45 | 45 | double tap_val; |
| 46 | 46 | tap_val = cassette_input( cassette_device_image( machine ) ); |
| 47 | 47 | if ( tap_val < -0.5 ) { |
| 48 | | ula.tape_value = ( ula.tape_value << 8 ) | TAPE_LOW; |
| 49 | | ula.tape_steps++; |
| 48 | electron_ula.tape_value = ( electron_ula.tape_value << 8 ) | TAPE_LOW; |
| 49 | electron_ula.tape_steps++; |
| 50 | 50 | } else if ( tap_val > 0.5 ) { |
| 51 | | ula.tape_value = ( ula.tape_value << 8 ) | TAPE_HIGH; |
| 52 | | ula.tape_steps++; |
| 51 | electron_ula.tape_value = ( electron_ula.tape_value << 8 ) | TAPE_HIGH; |
| 52 | electron_ula.tape_steps++; |
| 53 | 53 | } else { |
| 54 | | ula.tape_steps = 0; |
| 55 | | ula.bit_count = 0; |
| 56 | | ula.high_tone_set = 0; |
| 57 | | ula.tape_value = 0x80808080; |
| 54 | electron_ula.tape_steps = 0; |
| 55 | electron_ula.bit_count = 0; |
| 56 | electron_ula.high_tone_set = 0; |
| 57 | electron_ula.tape_value = 0x80808080; |
| 58 | 58 | } |
| 59 | | if ( ula.tape_steps > 2 && ( ula.tape_value == 0x0000FFFF || ula.tape_value == 0x00FF00FF ) ) { |
| 60 | | ula.tape_steps = 0; |
| 61 | | switch( ula.bit_count ) { |
| 59 | if ( electron_ula.tape_steps > 2 && ( electron_ula.tape_value == 0x0000FFFF || electron_ula.tape_value == 0x00FF00FF ) ) { |
| 60 | electron_ula.tape_steps = 0; |
| 61 | switch( electron_ula.bit_count ) { |
| 62 | 62 | case 0: /* start bit */ |
| 63 | | ula.start_bit = ( ( ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); |
| 64 | | //logerror( "++ Read start bit: %d\n", ula.start_bit ); |
| 65 | | if ( ula.start_bit ) { |
| 66 | | if ( ula.high_tone_set ) { |
| 67 | | ula.bit_count--; |
| 63 | electron_ula.start_bit = ( ( electron_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); |
| 64 | //logerror( "++ Read start bit: %d\n", electron_ula.start_bit ); |
| 65 | if ( electron_ula.start_bit ) { |
| 66 | if ( electron_ula.high_tone_set ) { |
| 67 | electron_ula.bit_count--; |
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | | ula.high_tone_set = 0; |
| 70 | electron_ula.high_tone_set = 0; |
| 71 | 71 | } |
| 72 | 72 | break; |
| 73 | 73 | case 1: case 2: case 3: case 4: |
| 74 | 74 | case 5: case 6: case 7: case 8: |
| 75 | | //logerror( "++ Read regular bit: %d\n", ula.tape_value == 0x0000FFFF ? 0 : 1 ); |
| 76 | | ula.tape_byte = ( ula.tape_byte >> 1 ) | ( ula.tape_value == 0x0000FFFF ? 0 : 0x80 ); |
| 75 | //logerror( "++ Read regular bit: %d\n", electron_ula.tape_value == 0x0000FFFF ? 0 : 1 ); |
| 76 | electron_ula.tape_byte = ( electron_ula.tape_byte >> 1 ) | ( electron_ula.tape_value == 0x0000FFFF ? 0 : 0x80 ); |
| 77 | 77 | break; |
| 78 | 78 | case 9: /* stop bit */ |
| 79 | | ula.stop_bit = ( ( ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); |
| 80 | | //logerror( "++ Read stop bit: %d\n", ula.stop_bit ); |
| 81 | | if ( ula.start_bit && ula.stop_bit && ula.tape_byte == 0xFF && ! ula.high_tone_set ) { |
| 79 | electron_ula.stop_bit = ( ( electron_ula.tape_value == 0x0000FFFF ) ? 0 : 1 ); |
| 80 | //logerror( "++ Read stop bit: %d\n", electron_ula.stop_bit ); |
| 81 | if ( electron_ula.start_bit && electron_ula.stop_bit && electron_ula.tape_byte == 0xFF && ! electron_ula.high_tone_set ) { |
| 82 | 82 | electron_interrupt_handler( machine, INT_SET, INT_HIGH_TONE ); |
| 83 | | ula.high_tone_set = 1; |
| 84 | | } else if ( ! ula.start_bit && ula.stop_bit ) { |
| 85 | | //logerror( "-- Byte read from tape: %02x\n", ula.tape_byte ); |
| 83 | electron_ula.high_tone_set = 1; |
| 84 | } else if ( ! electron_ula.start_bit && electron_ula.stop_bit ) { |
| 85 | //logerror( "-- Byte read from tape: %02x\n", electron_ula.tape_byte ); |
| 86 | 86 | electron_interrupt_handler( machine, INT_SET, INT_RECEIVE_FULL ); |
| 87 | 87 | } else { |
| 88 | | logerror( "Invalid start/stop bit combination detected: %d,%d\n", ula.start_bit, ula.stop_bit ); |
| 88 | logerror( "Invalid start/stop bit combination detected: %d,%d\n", electron_ula.start_bit, electron_ula.stop_bit ); |
| 89 | 89 | } |
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | | ula.bit_count = ( ula.bit_count + 1 ) % 10; |
| 92 | electron_ula.bit_count = ( electron_ula.bit_count + 1 ) % 10; |
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | } |
| r4212 | r4213 | |
| 131 | 131 | UINT8 data = ((UINT8 *)memory_region(space->machine, "user1"))[0x43E00 + offset]; |
| 132 | 132 | switch ( offset & 0x0f ) { |
| 133 | 133 | case 0x00: /* Interrupt status */ |
| 134 | | data = ula.interrupt_status; |
| 135 | | ula.interrupt_status &= ~0x02; |
| 134 | data = electron_ula.interrupt_status; |
| 135 | electron_ula.interrupt_status &= ~0x02; |
| 136 | 136 | break; |
| 137 | 137 | case 0x01: /* Unknown */ |
| 138 | 138 | break; |
| 139 | 139 | case 0x04: /* Casette data shift register */ |
| 140 | 140 | electron_interrupt_handler( space->machine, INT_CLEAR, INT_RECEIVE_FULL ); |
| 141 | | data = ula.tape_byte; |
| 141 | data = electron_ula.tape_byte; |
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | logerror( "ULA: read offset %02x: %02x\n", offset, data ); |
| r4212 | r4213 | |
| 153 | 153 | logerror( "ULA: write offset %02x <- %02x\n", offset & 0x0f, data ); |
| 154 | 154 | switch( offset & 0x0f ) { |
| 155 | 155 | case 0x00: /* Interrupt control */ |
| 156 | | ula.interrupt_control = data; |
| 156 | electron_ula.interrupt_control = data; |
| 157 | 157 | break; |
| 158 | 158 | case 0x01: /* Unknown */ |
| 159 | 159 | break; |
| 160 | 160 | case 0x02: /* Screen start address #1 */ |
| 161 | | ula.screen_start = ( ula.screen_start & 0x7e00 ) | ( ( data & 0xe0 ) << 1 ); |
| 162 | | logerror( "screen_start changed to %04x\n", ula.screen_start ); |
| 161 | electron_ula.screen_start = ( electron_ula.screen_start & 0x7e00 ) | ( ( data & 0xe0 ) << 1 ); |
| 162 | logerror( "screen_start changed to %04x\n", electron_ula.screen_start ); |
| 163 | 163 | break; |
| 164 | 164 | case 0x03: /* Screen start addres #2 */ |
| 165 | | ula.screen_start = ( ula.screen_start & 0x1c0 ) | ( ( data & 0x3f ) << 9 ); |
| 166 | | logerror( "screen_start changed to %04x\n", ula.screen_start ); |
| 165 | electron_ula.screen_start = ( electron_ula.screen_start & 0x1c0 ) | ( ( data & 0x3f ) << 9 ); |
| 166 | logerror( "screen_start changed to %04x\n", electron_ula.screen_start ); |
| 167 | 167 | break; |
| 168 | 168 | case 0x04: /* Cassette data shift register */ |
| 169 | 169 | break; |
| r4212 | r4213 | |
| 174 | 174 | * Rompages 10 and 11 both select the Basic ROM. |
| 175 | 175 | * Rompages 8 and 9 both select the keyboard. |
| 176 | 176 | */ |
| 177 | | if ( ( ( ula.rompage & 0x0C ) != 0x08 ) || ( data & 0x08 ) ) { |
| 178 | | ula.rompage = data & 0x0f; |
| 179 | | if ( ula.rompage == 8 || ula.rompage == 9 ) { |
| 180 | | ula.rompage = 8; |
| 177 | if ( ( ( electron_ula.rompage & 0x0C ) != 0x08 ) || ( data & 0x08 ) ) { |
| 178 | electron_ula.rompage = data & 0x0f; |
| 179 | if ( electron_ula.rompage == 8 || electron_ula.rompage == 9 ) { |
| 180 | electron_ula.rompage = 8; |
| 181 | 181 | memory_install_read8_handler( space, 0x8000, 0xbfff, 0, 0, electron_read_keyboard ); |
| 182 | 182 | } else { |
| 183 | 183 | memory_install_read8_handler( space, 0x8000, 0xbfff, 0, 0, SMH_BANK2 ); |
| 184 | 184 | } |
| 185 | | memory_set_bank(space->machine, 2, ula.rompage); |
| 185 | memory_set_bank(space->machine, 2, electron_ula.rompage); |
| 186 | 186 | } |
| 187 | 187 | if ( data & 0x10 ) { |
| 188 | 188 | electron_interrupt_handler( space->machine, INT_CLEAR, INT_DISPLAY_END ); |
| r4212 | r4213 | |
| 197 | 197 | } |
| 198 | 198 | break; |
| 199 | 199 | case 0x06: /* Counter divider */ |
| 200 | | if ( ula.communication_mode == 0x01) { |
| 200 | if ( electron_ula.communication_mode == 0x01) { |
| 201 | 201 | beep_set_frequency( 0, 1000000 / ( 16 * ( data + 1 ) ) ); |
| 202 | 202 | } |
| 203 | 203 | break; |
| 204 | 204 | case 0x07: /* Misc. */ |
| 205 | | ula.communication_mode = ( data >> 1 ) & 0x03; |
| 206 | | switch( ula.communication_mode ) { |
| 205 | electron_ula.communication_mode = ( data >> 1 ) & 0x03; |
| 206 | switch( electron_ula.communication_mode ) { |
| 207 | 207 | case 0x00: /* cassette input */ |
| 208 | 208 | beep_set_state( 0, 0 ); |
| 209 | 209 | electron_tape_start(); |
| r4212 | r4213 | |
| 221 | 221 | electron_tape_stop(); |
| 222 | 222 | break; |
| 223 | 223 | } |
| 224 | | ula.screen_mode = ( data >> 3 ) & 0x07; |
| 225 | | ula.screen_base = electron_screen_base[ ula.screen_mode ]; |
| 226 | | ula.screen_size = 0x8000 - ula.screen_base; |
| 227 | | ula.vram = memory_get_read_ptr( space, ula.screen_base ); |
| 228 | | logerror( "ULA: screen mode set to %d\n", ula.screen_mode ); |
| 229 | | ula.cassette_motor_mode = ( data >> 6 ) & 0x01; |
| 230 | | cassette_change_state( cassette_device_image( space->machine ), ula.cassette_motor_mode ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MOTOR_DISABLED ); |
| 231 | | ula.capslock_mode = ( data >> 7 ) & 0x01; |
| 224 | electron_ula.screen_mode = ( data >> 3 ) & 0x07; |
| 225 | electron_ula.screen_base = electron_screen_base[ electron_ula.screen_mode ]; |
| 226 | electron_ula.screen_size = 0x8000 - electron_ula.screen_base; |
| 227 | electron_ula.vram = memory_get_read_ptr( space, electron_ula.screen_base ); |
| 228 | logerror( "ULA: screen mode set to %d\n", electron_ula.screen_mode ); |
| 229 | electron_ula.cassette_motor_mode = ( data >> 6 ) & 0x01; |
| 230 | cassette_change_state( cassette_device_image( space->machine ), electron_ula.cassette_motor_mode ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MOTOR_DISABLED ); |
| 231 | electron_ula.capslock_mode = ( data >> 7 ) & 0x01; |
| 232 | 232 | break; |
| 233 | 233 | case 0x08: case 0x0A: case 0x0C: case 0x0E: |
| 234 | 234 | // video_update |
| 235 | | ula.current_pal[i+10] = (ula.current_pal[i+10] & 0x01) | (((data & 0x80) >> 5) | ((data & 0x08) >> 1)); |
| 236 | | ula.current_pal[i+8] = (ula.current_pal[i+8] & 0x01) | (((data & 0x40) >> 4) | ((data & 0x04) >> 1)); |
| 237 | | ula.current_pal[i+2] = (ula.current_pal[i+2] & 0x03) | ((data & 0x20) >> 3); |
| 238 | | ula.current_pal[i] = (ula.current_pal[i] & 0x03) | ((data & 0x10) >> 2); |
| 235 | electron_ula.current_pal[i+10] = (electron_ula.current_pal[i+10] & 0x01) | (((data & 0x80) >> 5) | ((data & 0x08) >> 1)); |
| 236 | electron_ula.current_pal[i+8] = (electron_ula.current_pal[i+8] & 0x01) | (((data & 0x40) >> 4) | ((data & 0x04) >> 1)); |
| 237 | electron_ula.current_pal[i+2] = (electron_ula.current_pal[i+2] & 0x03) | ((data & 0x20) >> 3); |
| 238 | electron_ula.current_pal[i] = (electron_ula.current_pal[i] & 0x03) | ((data & 0x10) >> 2); |
| 239 | 239 | break; |
| 240 | 240 | case 0x09: case 0x0B: case 0x0D: case 0x0F: |
| 241 | 241 | // video_update |
| 242 | | ula.current_pal[i+10] = (ula.current_pal[i+10] & 0x06) | ((data & 0x08) >> 3); |
| 243 | | ula.current_pal[i+8] = (ula.current_pal[i+8] & 0x06) | ((data & 0x04) >> 2); |
| 244 | | ula.current_pal[i+2] = (ula.current_pal[i+2] & 0x04) | (((data & 0x20) >> 4) | ((data & 0x02) >> 1)); |
| 245 | | ula.current_pal[i] = (ula.current_pal[i] & 0x04) | (((data & 0x10) >> 3) | ((data & 0x01))); |
| 242 | electron_ula.current_pal[i+10] = (electron_ula.current_pal[i+10] & 0x06) | ((data & 0x08) >> 3); |
| 243 | electron_ula.current_pal[i+8] = (electron_ula.current_pal[i+8] & 0x06) | ((data & 0x04) >> 2); |
| 244 | electron_ula.current_pal[i+2] = (electron_ula.current_pal[i+2] & 0x04) | (((data & 0x20) >> 4) | ((data & 0x02) >> 1)); |
| 245 | electron_ula.current_pal[i] = (electron_ula.current_pal[i] & 0x04) | (((data & 0x10) >> 3) | ((data & 0x01))); |
| 246 | 246 | break; |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | void electron_interrupt_handler(running_machine *machine, int mode, int interrupt) { |
| 251 | 251 | if ( mode == INT_SET ) { |
| 252 | | ula.interrupt_status |= interrupt; |
| 252 | electron_ula.interrupt_status |= interrupt; |
| 253 | 253 | } else { |
| 254 | | ula.interrupt_status &= ~interrupt; |
| 254 | electron_ula.interrupt_status &= ~interrupt; |
| 255 | 255 | } |
| 256 | | if ( ula.interrupt_status & ula.interrupt_control & ~0x83 ) { |
| 257 | | ula.interrupt_status |= 0x01; |
| 256 | if ( electron_ula.interrupt_status & electron_ula.interrupt_control & ~0x83 ) { |
| 257 | electron_ula.interrupt_status |= 0x01; |
| 258 | 258 | cpu_set_input_line(machine->cpu[0], 0, ASSERT_LINE ); |
| 259 | 259 | } else { |
| 260 | | ula.interrupt_status &= ~0x01; |
| 260 | electron_ula.interrupt_status &= ~0x01; |
| 261 | 261 | cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE ); |
| 262 | 262 | } |
| 263 | 263 | } |
| r4212 | r4213 | |
| 276 | 276 | { |
| 277 | 277 | memory_set_bank(machine, 2, 0); |
| 278 | 278 | |
| 279 | | ula.communication_mode = 0x04; |
| 280 | | ula.screen_mode = 0; |
| 281 | | ula.cassette_motor_mode = 0; |
| 282 | | ula.capslock_mode = 0; |
| 283 | | ula.screen_mode = 0; |
| 284 | | ula.screen_start = 0x3000; |
| 285 | | ula.screen_base = 0x3000; |
| 286 | | ula.screen_size = 0x8000 - 0x3000; |
| 287 | | ula.screen_addr = 0; |
| 288 | | ula.tape_running = 0; |
| 289 | | ula.vram = memory_get_read_ptr( cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ), ula.screen_base ); |
| 279 | electron_ula.communication_mode = 0x04; |
| 280 | electron_ula.screen_mode = 0; |
| 281 | electron_ula.cassette_motor_mode = 0; |
| 282 | electron_ula.capslock_mode = 0; |
| 283 | electron_ula.screen_mode = 0; |
| 284 | electron_ula.screen_start = 0x3000; |
| 285 | electron_ula.screen_base = 0x3000; |
| 286 | electron_ula.screen_size = 0x8000 - 0x3000; |
| 287 | electron_ula.screen_addr = 0; |
| 288 | electron_ula.tape_running = 0; |
| 289 | electron_ula.vram = memory_get_read_ptr( cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ), electron_ula.screen_base ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | MACHINE_START( electron ) |
| 293 | 293 | { |
| 294 | 294 | memory_configure_bank(machine, 2, 0, 16, memory_region(machine, "user1"), 0x4000); |
| 295 | 295 | |
| 296 | | ula.interrupt_status = 0x82; |
| 297 | | ula.interrupt_control = 0x00; |
| 296 | electron_ula.interrupt_status = 0x82; |
| 297 | electron_ula.interrupt_control = 0x00; |
| 298 | 298 | timer_set(machine, attotime_zero, NULL, 0, setup_beep ); |
| 299 | 299 | electron_tape_timer = timer_alloc(machine, electron_tape_timer_handler, NULL ); |
| 300 | 300 | add_reset_callback(machine, electron_reset); |
src/mess/machine/wswan.c
| r4212 | r4213 | |
| 64 | 64 | static UINT32 ROMBanks; |
| 65 | 65 | static UINT8 internal_eeprom[INTERNAL_EEPROM_SIZE]; |
| 66 | 66 | static UINT8 system_type; |
| 67 | | struct VDP vdp; |
| 67 | struct VDP wswan_vdp; |
| 68 | 68 | static struct EEPROM eeprom; |
| 69 | 69 | static struct RTC rtc; |
| 70 | 70 | static struct SoundDMA sound_dma; |
| r4212 | r4213 | |
| 233 | 233 | memcpy( ws_portram, ws_portram_init, 256 ); |
| 234 | 234 | |
| 235 | 235 | /* Initialize VDP */ |
| 236 | | memset( &vdp, 0, sizeof( vdp ) ); |
| 236 | memset( &wswan_vdp, 0, sizeof( wswan_vdp ) ); |
| 237 | 237 | |
| 238 | | vdp.vram = memory_get_read_ptr( space, 0 ); |
| 239 | | vdp.palette_vram = memory_get_read_ptr( space, ( system_type == WSC ) ? 0xFE00 : 0 ); |
| 240 | | vdp.current_line = 145; /* Randomly chosen, beginning of VBlank period to give cart some time to boot up */ |
| 241 | | vdp.new_display_vertical = ROMMap[ROMBanks-1][0xfffc] & 0x01; |
| 242 | | vdp.display_vertical = ~vdp.new_display_vertical; |
| 243 | | vdp.color_mode = 0; |
| 244 | | vdp.colors_16 = 0; |
| 245 | | vdp.tile_packed = 0; |
| 246 | | vdp.timer = timer_alloc( machine, wswan_scanline_interrupt, &vdp ); |
| 247 | | timer_adjust_periodic( vdp.timer, ticks_to_attotime( 256, 3072000 ), 0, ticks_to_attotime( 256, 3072000 ) ); |
| 238 | wswan_vdp.vram = memory_get_read_ptr( space, 0 ); |
| 239 | wswan_vdp.palette_vram = memory_get_read_ptr( space, ( system_type == WSC ) ? 0xFE00 : 0 ); |
| 240 | wswan_vdp.current_line = 145; /* Randomly chosen, beginning of VBlank period to give cart some time to boot up */ |
| 241 | wswan_vdp.new_display_vertical = ROMMap[ROMBanks-1][0xfffc] & 0x01; |
| 242 | wswan_vdp.display_vertical = ~wswan_vdp.new_display_vertical; |
| 243 | wswan_vdp.color_mode = 0; |
| 244 | wswan_vdp.colors_16 = 0; |
| 245 | wswan_vdp.tile_packed = 0; |
| 246 | wswan_vdp.timer = timer_alloc( machine, wswan_scanline_interrupt, &wswan_vdp ); |
| 247 | timer_adjust_periodic( wswan_vdp.timer, ticks_to_attotime( 256, 3072000 ), 0, ticks_to_attotime( 256, 3072000 ) ); |
| 248 | 248 | |
| 249 | 249 | /* Initialize sound DMA */ |
| 250 | 250 | memset( &sound_dma, 0, sizeof( sound_dma ) ); |
| r4212 | r4213 | |
| 314 | 314 | switch( offset ) |
| 315 | 315 | { |
| 316 | 316 | case 0x02: /* Current line */ |
| 317 | | value = vdp.current_line; |
| 317 | value = wswan_vdp.current_line; |
| 318 | 318 | break; |
| 319 | 319 | case 0x4A: /* Sound DMA source address (low) */ |
| 320 | 320 | value = sound_dma.source & 0xFF; |
| r4212 | r4213 | |
| 344 | 344 | } |
| 345 | 345 | break; |
| 346 | 346 | case 0xA8: |
| 347 | | value = vdp.timer_hblank_count & 0xFF; |
| 347 | value = wswan_vdp.timer_hblank_count & 0xFF; |
| 348 | 348 | break; |
| 349 | 349 | case 0xA9: |
| 350 | | value = vdp.timer_hblank_count >> 8; |
| 350 | value = wswan_vdp.timer_hblank_count >> 8; |
| 351 | 351 | break; |
| 352 | 352 | case 0xAA: |
| 353 | | value = vdp.timer_vblank_count & 0xFF; |
| 353 | value = wswan_vdp.timer_vblank_count & 0xFF; |
| 354 | 354 | break; |
| 355 | 355 | case 0xAB: |
| 356 | | value = vdp.timer_vblank_count >> 8; |
| 356 | value = wswan_vdp.timer_vblank_count >> 8; |
| 357 | 357 | break; |
| 358 | 358 | case 0xCB: /* RTC data */ |
| 359 | 359 | if ( ws_portram[0xca] == 0x95 && ( rtc.index < 7 ) ) { |
| r4212 | r4213 | |
| 390 | 390 | 11 - Foreground layer is displayed outside foreground window area |
| 391 | 391 | Bit 6-7 - Unknown |
| 392 | 392 | */ |
| 393 | | vdp.layer_bg_enable = data & 0x1; |
| 394 | | vdp.layer_fg_enable = (data & 0x2) >> 1; |
| 395 | | vdp.sprites_enable = (data & 0x4) >> 2; |
| 396 | | vdp.window_sprites_enable = (data & 0x8) >> 3; |
| 397 | | vdp.window_fg_mode = (data & 0x30) >> 4; |
| 393 | wswan_vdp.layer_bg_enable = data & 0x1; |
| 394 | wswan_vdp.layer_fg_enable = (data & 0x2) >> 1; |
| 395 | wswan_vdp.sprites_enable = (data & 0x4) >> 2; |
| 396 | wswan_vdp.window_sprites_enable = (data & 0x8) >> 3; |
| 397 | wswan_vdp.window_fg_mode = (data & 0x30) >> 4; |
| 398 | 398 | break; |
| 399 | 399 | case 0x01: /* Background colour |
| 400 | 400 | In 16 colour mode: |
| r4212 | r4213 | |
| 408 | 408 | case 0x02: /* Current scanline |
| 409 | 409 | Bit 0-7 - Current scanline (Most likely read-only) |
| 410 | 410 | */ |
| 411 | | logerror( "Write to current scanline! Current value: %d Data to write: %d\n", vdp.current_line, data ); |
| 411 | logerror( "Write to current scanline! Current value: %d Data to write: %d\n", wswan_vdp.current_line, data ); |
| 412 | 412 | /* Returning so we don't overwrite the value here, not that it |
| 413 | 413 | * really matters */ |
| 414 | 414 | return; |
| 415 | 415 | case 0x03: /* Line compare |
| 416 | 416 | Bit 0-7 - Line compare |
| 417 | 417 | */ |
| 418 | | vdp.line_compare = data; |
| 418 | wswan_vdp.line_compare = data; |
| 419 | 419 | break; |
| 420 | 420 | case 0x04: /* Sprite table base address |
| 421 | 421 | Bit 0-5 - Determine sprite table base address 0 0xxxxxx0 00000000 |
| 422 | 422 | Bit 6-7 - Unknown |
| 423 | 423 | */ |
| 424 | | vdp.sprite_table_address = ( data & 0x3F ) << 9; |
| 424 | wswan_vdp.sprite_table_address = ( data & 0x3F ) << 9; |
| 425 | 425 | break; |
| 426 | 426 | case 0x05: /* Number of sprite to start drawing with |
| 427 | 427 | Bit 0-7 - First sprite number |
| 428 | 428 | */ |
| 429 | | vdp.sprite_first = data; |
| 429 | wswan_vdp.sprite_first = data; |
| 430 | 430 | break; |
| 431 | 431 | case 0x06: /* Number of sprites to draw |
| 432 | 432 | Bit 0-7 - Number of sprites to draw |
| 433 | 433 | */ |
| 434 | | vdp.sprite_count = data; |
| 434 | wswan_vdp.sprite_count = data; |
| 435 | 435 | break; |
| 436 | 436 | case 0x07: /* Background/Foreground table base addresses |
| 437 | 437 | Bit 0-2 - Determine background table base address 00xxx000 00000000 |
| r4212 | r4213 | |
| 439 | 439 | Bit 4-6 - Determine foreground table base address 00xxx000 00000000 |
| 440 | 440 | Bit 7 - Unknown |
| 441 | 441 | */ |
| 442 | | vdp.layer_bg_address = (data & 0x7) << 11; |
| 443 | | vdp.layer_fg_address = (data & 0x70) << 7; |
| 442 | wswan_vdp.layer_bg_address = (data & 0x7) << 11; |
| 443 | wswan_vdp.layer_fg_address = (data & 0x70) << 7; |
| 444 | 444 | break; |
| 445 | 445 | case 0x08: /* Left coordinate of foreground window |
| 446 | 446 | Bit 0-7 - Left coordinate of foreground window area |
| 447 | 447 | */ |
| 448 | | vdp.window_fg_left = data; |
| 448 | wswan_vdp.window_fg_left = data; |
| 449 | 449 | break; |
| 450 | 450 | case 0x09: /* Top coordinate of foreground window |
| 451 | 451 | Bit 0-7 - Top coordinatte of foreground window area |
| 452 | 452 | */ |
| 453 | | vdp.window_fg_top = data; |
| 453 | wswan_vdp.window_fg_top = data; |
| 454 | 454 | break; |
| 455 | 455 | case 0x0A: /* Right coordinate of foreground window |
| 456 | 456 | Bit 0-7 - Right coordinate of foreground window area |
| 457 | 457 | */ |
| 458 | | vdp.window_fg_right = data; |
| 458 | wswan_vdp.window_fg_right = data; |
| 459 | 459 | break; |
| 460 | 460 | case 0x0B: /* Bottom coordinate of foreground window |
| 461 | 461 | Bit 0-7 - Bottom coordinate of foreground window area |
| 462 | 462 | */ |
| 463 | | vdp.window_fg_bottom = data; |
| 463 | wswan_vdp.window_fg_bottom = data; |
| 464 | 464 | break; |
| 465 | 465 | case 0x0C: /* Left coordinate of sprite window |
| 466 | 466 | Bit 0-7 - Left coordinate of sprite window area |
| 467 | 467 | */ |
| 468 | | vdp.window_sprites_left = data; |
| 468 | wswan_vdp.window_sprites_left = data; |
| 469 | 469 | break; |
| 470 | 470 | case 0x0D: /* Top coordinate of sprite window |
| 471 | 471 | Bit 0-7 - Top coordinate of sprite window area |
| 472 | 472 | */ |
| 473 | | vdp.window_sprites_top = data; |
| 473 | wswan_vdp.window_sprites_top = data; |
| 474 | 474 | break; |
| 475 | 475 | case 0x0E: /* Right coordinate of sprite window |
| 476 | 476 | Bit 0-7 - Right coordinate of sprite window area |
| 477 | 477 | */ |
| 478 | | vdp.window_sprites_right = data; |
| 478 | wswan_vdp.window_sprites_right = data; |
| 479 | 479 | break; |
| 480 | 480 | case 0x0F: /* Bottom coordinate of sprite window |
| 481 | 481 | Bit 0-7 - Bottom coordiante of sprite window area |
| 482 | 482 | */ |
| 483 | | vdp.window_sprites_bottom = data; |
| 483 | wswan_vdp.window_sprites_bottom = data; |
| 484 | 484 | break; |
| 485 | 485 | case 0x10: /* Background layer X scroll |
| 486 | 486 | Bit 0-7 - Background layer X scroll |
| 487 | 487 | */ |
| 488 | | vdp.layer_bg_scroll_x = data; |
| 488 | wswan_vdp.layer_bg_scroll_x = data; |
| 489 | 489 | break; |
| 490 | 490 | case 0x11: /* Background layer Y scroll |
| 491 | 491 | Bit 0-7 - Background layer Y scroll |
| 492 | 492 | */ |
| 493 | | vdp.layer_bg_scroll_y = data; |
| 493 | wswan_vdp.layer_bg_scroll_y = data; |
| 494 | 494 | break; |
| 495 | 495 | case 0x12: /* Foreground layer X scroll |
| 496 | 496 | Bit 0-7 - Foreground layer X scroll |
| 497 | 497 | */ |
| 498 | | vdp.layer_fg_scroll_x = data; |
| 498 | wswan_vdp.layer_fg_scroll_x = data; |
| 499 | 499 | break; |
| 500 | 500 | case 0x13: /* Foreground layer Y scroll |
| 501 | 501 | Bit 0-7 - Foreground layer Y scroll |
| 502 | 502 | */ |
| 503 | | vdp.layer_fg_scroll_y = data; |
| 503 | wswan_vdp.layer_fg_scroll_y = data; |
| 504 | 504 | break; |
| 505 | 505 | case 0x14: /* LCD control |
| 506 | 506 | Bit 0 - LCD enable |
| 507 | 507 | Bit 1-7 - Unknown |
| 508 | 508 | */ |
| 509 | | vdp.lcd_enable = data & 0x1; |
| 509 | wswan_vdp.lcd_enable = data & 0x1; |
| 510 | 510 | break; |
| 511 | 511 | case 0x15: /* LCD icons |
| 512 | 512 | Bit 0 - LCD sleep icon enable |
| r4212 | r4213 | |
| 517 | 517 | Bit 5 - Dot 3 icon enable |
| 518 | 518 | Bit 6-7 - Unknown |
| 519 | 519 | */ |
| 520 | | vdp.icons = data; /* ummmmm */ |
| 520 | wswan_vdp.icons = data; /* ummmmm */ |
| 521 | 521 | break; |
| 522 | 522 | case 0x1c: /* Palette colors 0 and 1 |
| 523 | 523 | Bit 0-3 - Gray tone setting for main palette index 0 |
| r4212 | r4213 | |
| 526 | 526 | if ( system_type == WSC ) { |
| 527 | 527 | int i = 15 - ( data & 0x0F ); |
| 528 | 528 | int j = 15 - ( ( data & 0xF0 ) >> 4 ); |
| 529 | | vdp.main_palette[0] = ( i << 8 ) | ( i << 4 ) | i; |
| 530 | | vdp.main_palette[1] = ( j << 8 ) | ( j << 4 ) | j; |
| 529 | wswan_vdp.main_palette[0] = ( i << 8 ) | ( i << 4 ) | i; |
| 530 | wswan_vdp.main_palette[1] = ( j << 8 ) | ( j << 4 ) | j; |
| 531 | 531 | } else { |
| 532 | | vdp.main_palette[0] = data & 0x0F; |
| 533 | | vdp.main_palette[1] = ( data & 0xF0 ) >> 4; |
| 532 | wswan_vdp.main_palette[0] = data & 0x0F; |
| 533 | wswan_vdp.main_palette[1] = ( data & 0xF0 ) >> 4; |
| 534 | 534 | } |
| 535 | 535 | break; |
| 536 | 536 | case 0x1d: /* Palette colors 2 and 3 |
| r4212 | r4213 | |
| 540 | 540 | if ( system_type == WSC ) { |
| 541 | 541 | int i = 15 - ( data & 0x0F ); |
| 542 | 542 | int j = 15 - ( ( data & 0xF0 ) >> 4 ); |
| 543 | | vdp.main_palette[2] = ( i << 8 ) | ( i << 4 ) | i; |
| 544 | | vdp.main_palette[3] = ( j << 8 ) | ( j << 4 ) | j; |
| 543 | wswan_vdp.main_palette[2] = ( i << 8 ) | ( i << 4 ) | i; |
| 544 | wswan_vdp.main_palette[3] = ( j << 8 ) | ( j << 4 ) | j; |
| 545 | 545 | } else { |
| 546 | | vdp.main_palette[2] = data & 0x0F; |
| 547 | | vdp.main_palette[3] = ( data & 0xF0 ) >> 4; |
| 546 | wswan_vdp.main_palette[2] = data & 0x0F; |
| 547 | wswan_vdp.main_palette[3] = ( data & 0xF0 ) >> 4; |
| 548 | 548 | } |
| 549 | 549 | break; |
| 550 | 550 | case 0x1e: /* Palette colors 4 and 5 |
| r4212 | r4213 | |
| 554 | 554 | if ( system_type == WSC ) { |
| 555 | 555 | int i = 15 - ( data & 0x0F ); |
| 556 | 556 | int j = 15 - ( ( data & 0xF0 ) >> 4 ); |
| 557 | | vdp.main_palette[4] = ( i << 8 ) | ( i << 4 ) | i; |
| 558 | | vdp.main_palette[5] = ( j << 8 ) | ( j << 4 ) | j; |
| 557 | wswan_vdp.main_palette[4] = ( i << 8 ) | ( i << 4 ) | i; |
| 558 | wswan_vdp.main_palette[5] = ( j << 8 ) | ( j << 4 ) | j; |
| 559 | 559 | } else { |
| 560 | | vdp.main_palette[4] = data & 0x0F; |
| 561 | | vdp.main_palette[5] = ( data & 0xF0 ) >> 4; |
| 560 | wswan_vdp.main_palette[4] = data & 0x0F; |
| 561 | wswan_vdp.main_palette[5] = ( data & 0xF0 ) >> 4; |
| 562 | 562 | } |
| 563 | 563 | break; |
| 564 | 564 | case 0x1f: /* Palette colors 6 and 7 |
| r4212 | r4213 | |
| 568 | 568 | if ( system_type == WSC ) { |
| 569 | 569 | int i = 15 - ( data & 0x0F ); |
| 570 | 570 | int j = 15 - ( ( data & 0xF0 ) >> 4 ); |
| 571 | | vdp.main_palette[6] = ( i << 8 ) | ( i << 4 ) | i; |
| 572 | | vdp.main_palette[7] = ( j << 8 ) | ( j << 4 ) | j; |
| 571 | wswan_vdp.main_palette[6] = ( i << 8 ) | ( i << 4 ) | i; |
| 572 | wswan_vdp.main_palette[7] = ( j << 8 ) | ( j << 4 ) | j; |
| 573 | 573 | } else { |
| 574 | | vdp.main_palette[6] = data & 0x0F; |
| 575 | | vdp.main_palette[7] = ( data & 0xF0 ) >> 4; |
| 574 | wswan_vdp.main_palette[6] = data & 0x0F; |
| 575 | wswan_vdp.main_palette[7] = ( data & 0xF0 ) >> 4; |
| 576 | 576 | } |
| 577 | 577 | break; |
| 578 | 578 | case 0x20: /* tile/sprite palette settings |
| r4212 | r4213 | |
| 749 | 749 | * 000 - not packed, 4 color, use 2000, monochrome - Regular WS monochrome |
| 750 | 750 | */ |
| 751 | 751 | if ( system_type == WSC ) { |
| 752 | | vdp.color_mode = data & 0x80; |
| 753 | | vdp.colors_16 = data & 0x40; |
| 754 | | vdp.tile_packed = data & 0x20; |
| 752 | wswan_vdp.color_mode = data & 0x80; |
| 753 | wswan_vdp.colors_16 = data & 0x40; |
| 754 | wswan_vdp.tile_packed = data & 0x20; |
| 755 | 755 | } |
| 756 | 756 | break; |
| 757 | 757 | case 0x80: /* Audio 1 freq (lo) |
| r4212 | r4213 | |
| 856 | 856 | Bit 3 - VBlank Timer mode: 0 = one shot, 1 = auto reset |
| 857 | 857 | Bit 4-7 - Unknown |
| 858 | 858 | */ |
| 859 | | vdp.timer_hblank_enable = data & 0x1; |
| 860 | | vdp.timer_hblank_mode = (data & 0x2) >> 1; |
| 861 | | vdp.timer_vblank_enable = (data & 0x4) >> 2; |
| 862 | | vdp.timer_vblank_mode = (data & 0x8) >> 3; |
| 859 | wswan_vdp.timer_hblank_enable = data & 0x1; |
| 860 | wswan_vdp.timer_hblank_mode = (data & 0x2) >> 1; |
| 861 | wswan_vdp.timer_vblank_enable = (data & 0x4) >> 2; |
| 862 | wswan_vdp.timer_vblank_mode = (data & 0x8) >> 3; |
| 863 | 863 | break; |
| 864 | 864 | case 0xa4: /* HBlank timer frequency (low) - reload value |
| 865 | 865 | Bit 0-7 - HBlank timer reload value bit 0-7 |
| 866 | 866 | */ |
| 867 | | vdp.timer_hblank_reload &= 0xff00; |
| 868 | | vdp.timer_hblank_reload += data; |
| 869 | | vdp.timer_hblank_count = vdp.timer_hblank_reload; |
| 867 | wswan_vdp.timer_hblank_reload &= 0xff00; |
| 868 | wswan_vdp.timer_hblank_reload += data; |
| 869 | wswan_vdp.timer_hblank_count = wswan_vdp.timer_hblank_reload; |
| 870 | 870 | break; |
| 871 | 871 | case 0xa5: /* HBlank timer frequency (high) - reload value |
| 872 | 872 | Bit 8-15 - HBlank timer reload value bit 8-15 |
| 873 | 873 | */ |
| 874 | | vdp.timer_hblank_reload &= 0xff; |
| 875 | | vdp.timer_hblank_reload += data << 8; |
| 876 | | vdp.timer_hblank_count = vdp.timer_hblank_reload; |
| 874 | wswan_vdp.timer_hblank_reload &= 0xff; |
| 875 | wswan_vdp.timer_hblank_reload += data << 8; |
| 876 | wswan_vdp.timer_hblank_count = wswan_vdp.timer_hblank_reload; |
| 877 | 877 | break; |
| 878 | 878 | case 0xa6: /* VBlank timer frequency (low) - reload value |
| 879 | 879 | Bit 0-7 - VBlank timer reload value bit 0-7 |
| 880 | 880 | */ |
| 881 | | vdp.timer_vblank_reload &= 0xff00; |
| 882 | | vdp.timer_vblank_reload += data; |
| 883 | | vdp.timer_vblank_count = vdp.timer_vblank_reload; |
| 881 | wswan_vdp.timer_vblank_reload &= 0xff00; |
| 882 | wswan_vdp.timer_vblank_reload += data; |
| 883 | wswan_vdp.timer_vblank_count = wswan_vdp.timer_vblank_reload; |
| 884 | 884 | break; |
| 885 | 885 | case 0xa7: /* VBlank timer frequency (high) - reload value |
| 886 | 886 | Bit 0-7 - VBlank timer reload value bit 8-15 |
| 887 | 887 | */ |
| 888 | | vdp.timer_vblank_reload &= 0xff; |
| 889 | | vdp.timer_vblank_reload += data << 8; |
| 890 | | vdp.timer_vblank_count = vdp.timer_vblank_reload; |
| 888 | wswan_vdp.timer_vblank_reload &= 0xff; |
| 889 | wswan_vdp.timer_vblank_reload += data << 8; |
| 890 | wswan_vdp.timer_vblank_count = wswan_vdp.timer_vblank_reload; |
| 891 | 891 | break; |
| 892 | 892 | case 0xa8: /* HBlank counter (low) |
| 893 | 893 | Bit 0-7 - HBlank counter bit 0-7 |
| r4212 | r4213 | |
| 1364 | 1364 | |
| 1365 | 1365 | static TIMER_CALLBACK(wswan_scanline_interrupt) |
| 1366 | 1366 | { |
| 1367 | | if( vdp.current_line < 144 ) { |
| 1367 | if( wswan_vdp.current_line < 144 ) { |
| 1368 | 1368 | wswan_refresh_scanline(); |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | /* Decrement 12kHz (HBlank) counter */ |
| 1372 | | if ( vdp.timer_hblank_enable && vdp.timer_hblank_reload != 0 ) { |
| 1373 | | vdp.timer_hblank_count--; |
| 1374 | | logerror( "timer_hblank_count: %X\n", vdp.timer_hblank_count ); |
| 1375 | | if ( vdp.timer_hblank_count == 0 ) { |
| 1376 | | if ( vdp.timer_hblank_mode ) { |
| 1377 | | vdp.timer_hblank_count = vdp.timer_hblank_reload; |
| 1372 | if ( wswan_vdp.timer_hblank_enable && wswan_vdp.timer_hblank_reload != 0 ) { |
| 1373 | wswan_vdp.timer_hblank_count--; |
| 1374 | logerror( "timer_hblank_count: %X\n", wswan_vdp.timer_hblank_count ); |
| 1375 | if ( wswan_vdp.timer_hblank_count == 0 ) { |
| 1376 | if ( wswan_vdp.timer_hblank_mode ) { |
| 1377 | wswan_vdp.timer_hblank_count = wswan_vdp.timer_hblank_reload; |
| 1378 | 1378 | } else { |
| 1379 | | vdp.timer_hblank_reload = 0; |
| 1379 | wswan_vdp.timer_hblank_reload = 0; |
| 1380 | 1380 | } |
| 1381 | 1381 | logerror( "trigerring hbltmr interrupt\n" ); |
| 1382 | 1382 | wswan_set_irq_line( machine, WSWAN_IFLAG_HBLTMR ); |
| r4212 | r4213 | |
| 1395 | 1395 | } |
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | | // vdp.current_line = (vdp.current_line + 1) % 159; |
| 1398 | // wswan_vdp.current_line = (wswan_vdp.current_line + 1) % 159; |
| 1399 | 1399 | |
| 1400 | | if( vdp.current_line == 144 ) { |
| 1400 | if( wswan_vdp.current_line == 144 ) { |
| 1401 | 1401 | wswan_set_irq_line( machine, WSWAN_IFLAG_VBL ); |
| 1402 | 1402 | /* Decrement 75Hz (VBlank) counter */ |
| 1403 | | if ( vdp.timer_vblank_enable && vdp.timer_vblank_reload != 0 ) { |
| 1404 | | vdp.timer_vblank_count--; |
| 1405 | | logerror( "timer_vblank_count: %X\n", vdp.timer_vblank_count ); |
| 1406 | | if ( vdp.timer_vblank_count == 0 ) { |
| 1407 | | if ( vdp.timer_vblank_mode ) { |
| 1408 | | vdp.timer_vblank_count = vdp.timer_vblank_reload; |
| 1403 | if ( wswan_vdp.timer_vblank_enable && wswan_vdp.timer_vblank_reload != 0 ) { |
| 1404 | wswan_vdp.timer_vblank_count--; |
| 1405 | logerror( "timer_vblank_count: %X\n", wswan_vdp.timer_vblank_count ); |
| 1406 | if ( wswan_vdp.timer_vblank_count == 0 ) { |
| 1407 | if ( wswan_vdp.timer_vblank_mode ) { |
| 1408 | wswan_vdp.timer_vblank_count = wswan_vdp.timer_vblank_reload; |
| 1409 | 1409 | } else { |
| 1410 | | vdp.timer_vblank_reload = 0; |
| 1410 | wswan_vdp.timer_vblank_reload = 0; |
| 1411 | 1411 | } |
| 1412 | 1412 | logerror( "triggering vbltmr interrupt\n" ); |
| 1413 | 1413 | wswan_set_irq_line( machine, WSWAN_IFLAG_VBLTMR ); |
| r4212 | r4213 | |
| 1415 | 1415 | } |
| 1416 | 1416 | } |
| 1417 | 1417 | |
| 1418 | | // vdp.current_line = (vdp.current_line + 1) % 159; |
| 1418 | // wswan_vdp.current_line = (wswan_vdp.current_line + 1) % 159; |
| 1419 | 1419 | |
| 1420 | | if ( vdp.current_line == vdp.line_compare ) { |
| 1420 | if ( wswan_vdp.current_line == wswan_vdp.line_compare ) { |
| 1421 | 1421 | wswan_set_irq_line( machine, WSWAN_IFLAG_LCMP ); |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | | vdp.current_line = (vdp.current_line + 1) % 159; |
| 1424 | wswan_vdp.current_line = (wswan_vdp.current_line + 1) % 159; |
| 1425 | 1425 | |
| 1426 | | if ( vdp.current_line == 0 ) { |
| 1427 | | if ( vdp.display_vertical != vdp.new_display_vertical ) { |
| 1428 | | vdp.display_vertical = vdp.new_display_vertical; |
| 1429 | | if ( vdp.display_vertical ) { |
| 1426 | if ( wswan_vdp.current_line == 0 ) { |
| 1427 | if ( wswan_vdp.display_vertical != wswan_vdp.new_display_vertical ) { |
| 1428 | wswan_vdp.display_vertical = wswan_vdp.new_display_vertical; |
| 1429 | if ( wswan_vdp.display_vertical ) { |
| 1430 | 1430 | video_screen_set_visarea( machine->primary_screen, 5*8, 5*8 + WSWAN_Y_PIXELS - 1, 0, WSWAN_X_PIXELS - 1 ); |
| 1431 | 1431 | } else { |
| 1432 | 1432 | video_screen_set_visarea( machine->primary_screen, 0, WSWAN_X_PIXELS - 1, 5*8, 5*8 + WSWAN_Y_PIXELS - 1 ); |
src/mess/drivers/z88.c
| r4212 | r4213 | |
| 18 | 18 | #include "includes/z88.h" |
| 19 | 19 | #include "sound/speaker.h" |
| 20 | 20 | |
| 21 | | struct blink_hw blink; |
| 21 | struct blink_hw z88_blink; |
| 22 | 22 | |
| 23 | 23 | static void blink_reset(void) |
| 24 | 24 | { |
| 25 | | memset(&blink, 0, sizeof(struct blink_hw)); |
| 25 | memset(&z88_blink, 0, sizeof(struct blink_hw)); |
| 26 | 26 | |
| 27 | 27 | /* rams is cleared on reset */ |
| 28 | | blink.com &=~(1<<2); |
| 29 | | blink.sbf = 0; |
| 30 | | blink.z88_state = Z88_AWAKE; |
| 28 | z88_blink.com &=~(1<<2); |
| 29 | z88_blink.sbf = 0; |
| 30 | z88_blink.z88_state = Z88_AWAKE; |
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| r4212 | r4213 | |
| 35 | 35 | static void z88_interrupt_refresh(running_machine *machine) |
| 36 | 36 | { |
| 37 | 37 | /* ints enabled? */ |
| 38 | | if ((blink.ints & INT_GINT)!=0) |
| 38 | if ((z88_blink.ints & INT_GINT)!=0) |
| 39 | 39 | { |
| 40 | 40 | /* yes */ |
| 41 | 41 | |
| 42 | 42 | /* other ints - except timer */ |
| 43 | 43 | if ( |
| 44 | | (((blink.ints & blink.sta) & 0x0fc)!=0) || |
| 45 | | (((blink.ints>>1) & blink.sta & STA_TIME)!=0) |
| 44 | (((z88_blink.ints & z88_blink.sta) & 0x0fc)!=0) || |
| 45 | (((z88_blink.ints>>1) & z88_blink.sta & STA_TIME)!=0) |
| 46 | 46 | ) |
| 47 | 47 | { |
| 48 | 48 | logerror("set int\n"); |
| r4212 | r4213 | |
| 57 | 57 | |
| 58 | 58 | static void z88_update_rtc_interrupt(void) |
| 59 | 59 | { |
| 60 | | blink.sta &=~STA_TIME; |
| 60 | z88_blink.sta &=~STA_TIME; |
| 61 | 61 | |
| 62 | 62 | /* time interrupt enabled? */ |
| 63 | | if (blink.ints & INT_TIME) |
| 63 | if (z88_blink.ints & INT_TIME) |
| 64 | 64 | { |
| 65 | 65 | /* yes */ |
| 66 | 66 | |
| 67 | 67 | /* any ints occured? */ |
| 68 | | if ((blink.tsta & 0x07)!=0) |
| 68 | if ((z88_blink.tsta & 0x07)!=0) |
| 69 | 69 | { |
| 70 | 70 | /* yes, set time int */ |
| 71 | | blink.sta |= STA_TIME; |
| 71 | z88_blink.sta |= STA_TIME; |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
| r4212 | r4213 | |
| 81 | 81 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" }; |
| 82 | 82 | |
| 83 | 83 | /* is z88 in snooze state? */ |
| 84 | | if (blink.z88_state == Z88_SNOOZE) |
| 84 | if (z88_blink.z88_state == Z88_SNOOZE) |
| 85 | 85 | { |
| 86 | 86 | int i; |
| 87 | 87 | unsigned char data = 0x0ff; |
| r4212 | r4213 | |
| 98 | 98 | logerror("Z88 wake up from snooze!\n"); |
| 99 | 99 | |
| 100 | 100 | /* wake up z88 */ |
| 101 | | blink.z88_state = Z88_AWAKE; |
| 101 | z88_blink.z88_state = Z88_AWAKE; |
| 102 | 102 | /* column has gone low in snooze/coma */ |
| 103 | | blink.sta |= STA_KEY; |
| 103 | z88_blink.sta |= STA_KEY; |
| 104 | 104 | |
| 105 | 105 | cpuexec_trigger(machine, Z88_SNOOZE_TRIGGER); |
| 106 | 106 | |
| r4212 | r4213 | |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | /* hold clock at reset? - in this mode it doesn't update */ |
| 114 | | if ((blink.com & (1<<4))==0) |
| 114 | if ((z88_blink.com & (1<<4))==0) |
| 115 | 115 | { |
| 116 | 116 | /* update 5 millisecond counter */ |
| 117 | | blink.tim[0]++; |
| 117 | z88_blink.tim[0]++; |
| 118 | 118 | |
| 119 | 119 | /* tick */ |
| 120 | | if ((blink.tim[0]%10)==0) |
| 120 | if ((z88_blink.tim[0]%10)==0) |
| 121 | 121 | { |
| 122 | 122 | /* set tick int has occured */ |
| 123 | | blink.tsta |= RTC_TICK_INT; |
| 123 | z88_blink.tsta |= RTC_TICK_INT; |
| 124 | 124 | refresh_ints = 1; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | | if (blink.tim[0]==200) |
| 127 | if (z88_blink.tim[0]==200) |
| 128 | 128 | { |
| 129 | | blink.tim[0] = 0; |
| 129 | z88_blink.tim[0] = 0; |
| 130 | 130 | |
| 131 | 131 | /* set seconds int has occured */ |
| 132 | | blink.tsta |= RTC_SEC_INT; |
| 132 | z88_blink.tsta |= RTC_SEC_INT; |
| 133 | 133 | refresh_ints = 1; |
| 134 | 134 | |
| 135 | | blink.tim[1]++; |
| 135 | z88_blink.tim[1]++; |
| 136 | 136 | |
| 137 | | if (blink.tim[1]==60) |
| 137 | if (z88_blink.tim[1]==60) |
| 138 | 138 | { |
| 139 | 139 | /* set minutes int has occured */ |
| 140 | | blink.tsta |=RTC_MIN_INT; |
| 140 | z88_blink.tsta |=RTC_MIN_INT; |
| 141 | 141 | refresh_ints = 1; |
| 142 | 142 | |
| 143 | | blink.tim[1]=0; |
| 143 | z88_blink.tim[1]=0; |
| 144 | 144 | |
| 145 | | blink.tim[2]++; |
| 145 | z88_blink.tim[2]++; |
| 146 | 146 | |
| 147 | | if (blink.tim[2]==256) |
| 147 | if (z88_blink.tim[2]==256) |
| 148 | 148 | { |
| 149 | | blink.tim[2] = 0; |
| 149 | z88_blink.tim[2] = 0; |
| 150 | 150 | |
| 151 | | blink.tim[3]++; |
| 151 | z88_blink.tim[3]++; |
| 152 | 152 | |
| 153 | | if (blink.tim[3]==256) |
| 153 | if (z88_blink.tim[3]==256) |
| 154 | 154 | { |
| 155 | | blink.tim[3] = 0; |
| 155 | z88_blink.tim[3] = 0; |
| 156 | 156 | |
| 157 | | blink.tim[4]++; |
| 157 | z88_blink.tim[4]++; |
| 158 | 158 | |
| 159 | | if (blink.tim[4]==32) |
| 159 | if (z88_blink.tim[4]==32) |
| 160 | 160 | { |
| 161 | | blink.tim[4] = 0; |
| 161 | z88_blink.tim[4] = 0; |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | } |
| r4212 | r4213 | |
| 228 | 228 | assert(bank <= 3); |
| 229 | 229 | |
| 230 | 230 | /* ram? */ |
| 231 | | if (blink.mem[bank]>=0x020) |
| 231 | if (z88_blink.mem[bank]>=0x020) |
| 232 | 232 | { |
| 233 | | block = blink.mem[bank]-0x020; |
| 233 | block = z88_blink.mem[bank]-0x020; |
| 234 | 234 | |
| 235 | 235 | if (block >= 128) |
| 236 | 236 | { |
| r4212 | r4213 | |
| 244 | 244 | } |
| 245 | 245 | else |
| 246 | 246 | { |
| 247 | | block = blink.mem[bank] & 0x07; |
| 247 | block = z88_blink.mem[bank] & 0x07; |
| 248 | 248 | |
| 249 | 249 | /* in rom area, but rom not present */ |
| 250 | 250 | if (block>=8) |
| r4212 | r4213 | |
| 267 | 267 | /* override setting for lower 8k of bank 0 */ |
| 268 | 268 | |
| 269 | 269 | /* enable rom? */ |
| 270 | | if ((blink.com & (1<<2))==0) |
| 270 | if ((z88_blink.com & (1<<2))==0) |
| 271 | 271 | { |
| 272 | 272 | /* yes */ |
| 273 | 273 | read_addr = memory_region(machine, "main") + 0x010000; |
| r4212 | r4213 | |
| 319 | 319 | |
| 320 | 320 | case 0x00: |
| 321 | 321 | { |
| 322 | | /**/ blink.pb[0] = addr_written; |
| 323 | | blink.lores0 = ((addr_written & 0x01f)<<9) | ((addr_written & 0x01fe0)<<9); // blink_pb_offset(-1, addr_written, 9); |
| 324 | | logerror("lores0 %08x\n",blink.lores0); |
| 322 | /**/ z88_blink.pb[0] = addr_written; |
| 323 | z88_blink.lores0 = ((addr_written & 0x01f)<<9) | ((addr_written & 0x01fe0)<<9); // blink_pb_offset(-1, addr_written, 9); |
| 324 | logerror("lores0 %08x\n",z88_blink.lores0); |
| 325 | 325 | } |
| 326 | 326 | break; |
| 327 | 327 | |
| 328 | 328 | case 0x01: |
| 329 | 329 | { |
| 330 | | blink.pb[1] = addr_written; |
| 331 | | blink.lores1 = ((addr_written & 0x01f)<<12) | ((addr_written & 0x01fe0)<<12); //blink_pb_offset(-1, addr_written, 12); |
| 332 | | logerror("lores1 %08x\n",blink.lores1); |
| 330 | z88_blink.pb[1] = addr_written; |
| 331 | z88_blink.lores1 = ((addr_written & 0x01f)<<12) | ((addr_written & 0x01fe0)<<12); //blink_pb_offset(-1, addr_written, 12); |
| 332 | logerror("lores1 %08x\n",z88_blink.lores1); |
| 333 | 333 | } |
| 334 | 334 | break; |
| 335 | 335 | |
| 336 | 336 | case 0x02: |
| 337 | 337 | { |
| 338 | | blink.pb[2] = addr_written; |
| 339 | | /**/ blink.hires0 = ((addr_written & 0x01f)<<13) | ((addr_written & 0x01fe0)<<13); //blink_pb_offset(-1, addr_written, 13); |
| 340 | | logerror("hires0 %08x\n", blink.hires0); |
| 338 | z88_blink.pb[2] = addr_written; |
| 339 | /**/ z88_blink.hires0 = ((addr_written & 0x01f)<<13) | ((addr_written & 0x01fe0)<<13); //blink_pb_offset(-1, addr_written, 13); |
| 340 | logerror("hires0 %08x\n", z88_blink.hires0); |
| 341 | 341 | } |
| 342 | 342 | break; |
| 343 | 343 | |
| 344 | 344 | |
| 345 | 345 | case 0x03: |
| 346 | 346 | { |
| 347 | | blink.pb[3] = addr_written; |
| 348 | | blink.hires1 = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); //blink_pb_offset(-1, addr_written, 11); |
| 347 | z88_blink.pb[3] = addr_written; |
| 348 | z88_blink.hires1 = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); //blink_pb_offset(-1, addr_written, 11); |
| 349 | 349 | |
| 350 | | logerror("hires1 %08x\n", blink.hires1); |
| 350 | logerror("hires1 %08x\n", z88_blink.hires1); |
| 351 | 351 | } |
| 352 | 352 | break; |
| 353 | 353 | |
| 354 | 354 | case 0x04: |
| 355 | 355 | { |
| 356 | | blink.sbr = addr_written; |
| 356 | z88_blink.sbr = addr_written; |
| 357 | 357 | |
| 358 | | blink.sbf = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); |
| 359 | | logerror("%08x\n", blink.sbf); |
| 358 | z88_blink.sbf = ((addr_written & 0x01f)<<11) | ((addr_written & 0x01fe0)<<11); |
| 359 | logerror("%08x\n", z88_blink.sbf); |
| 360 | 360 | |
| 361 | 361 | } |
| 362 | 362 | break; |
| r4212 | r4213 | |
| 370 | 370 | /* segment register write */ |
| 371 | 371 | static WRITE8_HANDLER(blink_srx_w) |
| 372 | 372 | { |
| 373 | | blink.mem[offset] = data; |
| 373 | z88_blink.mem[offset] = data; |
| 374 | 374 | |
| 375 | 375 | z88_refresh_memory_bank(space->machine, offset); |
| 376 | 376 | } |
| r4212 | r4213 | |
| 409 | 409 | logerror("tack w: %02x\n", data); |
| 410 | 410 | |
| 411 | 411 | /* set acknowledge */ |
| 412 | | blink.tack = data & 0x07; |
| 412 | z88_blink.tack = data & 0x07; |
| 413 | 413 | /* clear ints that have occured */ |
| 414 | | blink.tsta &= ~blink.tack; |
| 414 | z88_blink.tsta &= ~z88_blink.tack; |
| 415 | 415 | |
| 416 | 416 | /* refresh ints */ |
| 417 | 417 | z88_update_rtc_interrupt(); |
| r4212 | r4213 | |
| 425 | 425 | logerror("tmk w: %02x\n", data); |
| 426 | 426 | |
| 427 | 427 | /* set new int mask */ |
| 428 | | blink.tmk = data & 0x07; |
| 428 | z88_blink.tmk = data & 0x07; |
| 429 | 429 | |
| 430 | 430 | /* refresh ints */ |
| 431 | 431 | z88_update_rtc_interrupt(); |
| r4212 | r4213 | |
| 439 | 439 | |
| 440 | 440 | logerror("com w: %02x\n", data); |
| 441 | 441 | |
| 442 | | changed_bits = blink.com^data; |
| 443 | | blink.com = data; |
| 442 | changed_bits = z88_blink.com^data; |
| 443 | z88_blink.com = data; |
| 444 | 444 | |
| 445 | 445 | /* reset clock? */ |
| 446 | 446 | if ((data & (1<<4))!=0) |
| 447 | 447 | { |
| 448 | | blink.tim[0] = (blink.tim[1] = (blink.tim[2] = (blink.tim[3] = (blink.tim[4] = 0)))); |
| 448 | z88_blink.tim[0] = (z88_blink.tim[1] = (z88_blink.tim[2] = (z88_blink.tim[3] = (z88_blink.tim[4] = 0)))); |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /* SBIT controls speaker direct? */ |
| r4212 | r4213 | |
| 479 | 479 | /* set int enables */ |
| 480 | 480 | logerror("int w: %02x\n", data); |
| 481 | 481 | |
| 482 | | blink.ints = data; |
| 482 | z88_blink.ints = data; |
| 483 | 483 | z88_update_rtc_interrupt(); |
| 484 | 484 | z88_interrupt_refresh(space->machine); |
| 485 | 485 | } |
| r4212 | r4213 | |
| 491 | 491 | logerror("ack w: %02x\n", data); |
| 492 | 492 | |
| 493 | 493 | /* acknowledge ints */ |
| 494 | | blink.ack = data & ((1<<6) | (1<<5) | (1<<3) | (1<<2)); |
| 494 | z88_blink.ack = data & ((1<<6) | (1<<5) | (1<<3) | (1<<2)); |
| 495 | 495 | |
| 496 | | blink.ints &= ~blink.ack; |
| 496 | z88_blink.ints &= ~z88_blink.ack; |
| 497 | 497 | z88_update_rtc_interrupt(); |
| 498 | 498 | z88_interrupt_refresh(space->machine); |
| 499 | 499 | } |
| r4212 | r4213 | |
| 523 | 523 | switch (port) |
| 524 | 524 | { |
| 525 | 525 | case 0x0b1: |
| 526 | | blink.sta &=~(1<<1); |
| 527 | | logerror("sta r: %02x\n",blink.sta); |
| 528 | | return blink.sta; |
| 526 | z88_blink.sta &=~(1<<1); |
| 527 | logerror("sta r: %02x\n",z88_blink.sta); |
| 528 | return z88_blink.sta; |
| 529 | 529 | |
| 530 | 530 | |
| 531 | 531 | case 0x0b2: |
| r4212 | r4213 | |
| 537 | 537 | lines = offset>>8; |
| 538 | 538 | |
| 539 | 539 | /* if set, reading the keyboard will put z88 into snooze */ |
| 540 | | if ((blink.ints & INT_KWAIT)!=0) |
| 540 | if ((z88_blink.ints & INT_KWAIT)!=0) |
| 541 | 541 | { |
| 542 | | blink.z88_state = Z88_SNOOZE; |
| 542 | z88_blink.z88_state = Z88_SNOOZE; |
| 543 | 543 | /* spin cycles until rtc timer */ |
| 544 | 544 | cpu_spinuntil_trigger( space->machine->cpu[0], Z88_SNOOZE_TRIGGER); |
| 545 | 545 | |
| r4212 | r4213 | |
| 578 | 578 | |
| 579 | 579 | /* read real time clock status */ |
| 580 | 580 | case 0x0b5: |
| 581 | | blink.tsta &=~0x07; |
| 582 | | logerror("tsta r: %02x\n",blink.tsta); |
| 583 | | return blink.tsta; |
| 581 | z88_blink.tsta &=~0x07; |
| 582 | logerror("tsta r: %02x\n",z88_blink.tsta); |
| 583 | return z88_blink.tsta; |
| 584 | 584 | |
| 585 | 585 | /* read real time clock counters */ |
| 586 | 586 | case 0x0d0: |
| 587 | | logerror("tim0 r: %02x\n", blink.tim[0]); |
| 588 | | return blink.tim[0] & 0x0ff; |
| 587 | logerror("tim0 r: %02x\n", z88_blink.tim[0]); |
| 588 | return z88_blink.tim[0] & 0x0ff; |
| 589 | 589 | case 0x0d1: |
| 590 | | logerror("tim1 r: %02x\n", blink.tim[1]); |
| 591 | | return blink.tim[1] & 0x03f; |
| 590 | logerror("tim1 r: %02x\n", z88_blink.tim[1]); |
| 591 | return z88_blink.tim[1] & 0x03f; |
| 592 | 592 | case 0x0d2: |
| 593 | | logerror("tim2 r: %02x\n", blink.tim[2]); |
| 594 | | return blink.tim[2] & 0x0ff; |
| 593 | logerror("tim2 r: %02x\n", z88_blink.tim[2]); |
| 594 | return z88_blink.tim[2] & 0x0ff; |
| 595 | 595 | case 0x0d3: |
| 596 | | logerror("tim3 r: %02x\n", blink.tim[3]); |
| 597 | | return blink.tim[3] & 0x0ff; |
| 596 | logerror("tim3 r: %02x\n", z88_blink.tim[3]); |
| 597 | return z88_blink.tim[3] & 0x0ff; |
| 598 | 598 | case 0x0d4: |
| 599 | | logerror("tim4 r: %02x\n", blink.tim[4]); |
| 600 | | return blink.tim[4] & 0x01f; |
| 599 | logerror("tim4 r: %02x\n", z88_blink.tim[4]); |
| 600 | return z88_blink.tim[4] & 0x01f; |
| 601 | 601 | |
| 602 | 602 | default: |
| 603 | 603 | break; |
src/mess/drivers/x68k.c
| r4212 | r4213 | |
| 134 | 134 | #include "includes/x68k.h" |
| 135 | 135 | #include "x68000.lh" |
| 136 | 136 | |
| 137 | | struct x68k_system sys; |
| 137 | struct x68k_system x68k_sys; |
| 138 | 138 | |
| 139 | 139 | static UINT16* sram; // SRAM |
| 140 | 140 | static UINT8 ppi_port[3]; |
| r4212 | r4213 | |
| 148 | 148 | static emu_timer* kb_timer; |
| 149 | 149 | //emu_timer* mfp_timer[4]; |
| 150 | 150 | //emu_timer* mfp_irq; |
| 151 | | emu_timer* scanline_timer; |
| 152 | | emu_timer* raster_irq; |
| 153 | | emu_timer* vblank_irq; |
| 151 | emu_timer* x68k_scanline_timer; |
| 152 | emu_timer* x68k_raster_irq; |
| 153 | emu_timer* x68k_vblank_irq; |
| 154 | 154 | static emu_timer* mouse_timer; // to set off the mouse interrupts via the SCC |
| 155 | 155 | static emu_timer* led_timer; // to make disk drive control LEDs blink |
| 156 | 156 | |
| r4212 | r4213 | |
| 180 | 180 | |
| 181 | 181 | static void mfp_init() |
| 182 | 182 | { |
| 183 | | sys.mfp.tadr = sys.mfp.tbdr = sys.mfp.tcdr = sys.mfp.tddr = 0xff; |
| 183 | x68k_sys.mfp.tadr = x68k_sys.mfp.tbdr = x68k_sys.mfp.tcdr = x68k_sys.mfp.tddr = 0xff; |
| 184 | 184 | |
| 185 | | sys.mfp.irqline = 6; // MFP is connected to 68000 IRQ line 6 |
| 186 | | sys.mfp.current_irq = -1; // No current interrupt |
| 185 | x68k_sys.mfp.irqline = 6; // MFP is connected to 68000 IRQ line 6 |
| 186 | x68k_sys.mfp.current_irq = -1; // No current interrupt |
| 187 | 187 | |
| 188 | 188 | /* mfp_timer[0] = timer_alloc(machine, mfp_timer_a_callback, NULL); |
| 189 | 189 | mfp_timer[1] = timer_alloc(machine, mfp_timer_b_callback, NULL); |
| r4212 | r4213 | |
| 199 | 199 | { |
| 200 | 200 | int x; |
| 201 | 201 | |
| 202 | | if((sys.ioc.irqstatus & 0xc0) != 0) |
| 202 | if((x68k_sys.ioc.irqstatus & 0xc0) != 0) |
| 203 | 203 | return; |
| 204 | 204 | |
| 205 | 205 | // check for pending IRQs, in priority order |
| 206 | | if(sys.mfp.ipra != 0) |
| 206 | if(x68k_sys.mfp.ipra != 0) |
| 207 | 207 | { |
| 208 | 208 | for(x=7;x>=0;x--) |
| 209 | 209 | { |
| 210 | | if((sys.mfp.ipra & (1 << x)) && (sys.mfp.imra & (1 << x))) |
| 210 | if((x68k_sys.mfp.ipra & (1 << x)) && (x68k_sys.mfp.imra & (1 << x))) |
| 211 | 211 | { |
| 212 | | current_irq_line = sys.mfp.irqline; |
| 213 | | sys.mfp.current_irq = x + 8; |
| 212 | current_irq_line = x68k_sys.mfp.irqline; |
| 213 | x68k_sys.mfp.current_irq = x + 8; |
| 214 | 214 | // assert IRQ line |
| 215 | | // if(sys.mfp.iera & (1 << x)) |
| 215 | // if(x68k_sys.mfp.iera & (1 << x)) |
| 216 | 216 | { |
| 217 | | current_vector[6] = (sys.mfp.vr & 0xf0) | (x+8); |
| 218 | | cpu_set_input_line_and_vector(machine->cpu[0],sys.mfp.irqline,ASSERT_LINE,(sys.mfp.vr & 0xf0) | (x + 8)); |
| 219 | | // logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(sys.mfp.vr & 0xf0) | (x+8),sys.mfp.irqline); |
| 217 | current_vector[6] = (x68k_sys.mfp.vr & 0xf0) | (x+8); |
| 218 | cpu_set_input_line_and_vector(machine->cpu[0],x68k_sys.mfp.irqline,ASSERT_LINE,(x68k_sys.mfp.vr & 0xf0) | (x + 8)); |
| 219 | // logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(x68k_sys.mfp.vr & 0xf0) | (x+8),x68k_sys.mfp.irqline); |
| 220 | 220 | return; // one at a time only |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | | if(sys.mfp.iprb != 0) |
| 225 | if(x68k_sys.mfp.iprb != 0) |
| 226 | 226 | { |
| 227 | 227 | for(x=7;x>=0;x--) |
| 228 | 228 | { |
| 229 | | if((sys.mfp.iprb & (1 << x)) && (sys.mfp.imrb & (1 << x))) |
| 229 | if((x68k_sys.mfp.iprb & (1 << x)) && (x68k_sys.mfp.imrb & (1 << x))) |
| 230 | 230 | { |
| 231 | | current_irq_line = sys.mfp.irqline; |
| 232 | | sys.mfp.current_irq = x; |
| 231 | current_irq_line = x68k_sys.mfp.irqline; |
| 232 | x68k_sys.mfp.current_irq = x; |
| 233 | 233 | // assert IRQ line |
| 234 | | // if(sys.mfp.ierb & (1 << x)) |
| 234 | // if(x68k_sys.mfp.ierb & (1 << x)) |
| 235 | 235 | { |
| 236 | | current_vector[6] = (sys.mfp.vr & 0xf0) | x; |
| 237 | | cpu_set_input_line_and_vector(machine->cpu[0],sys.mfp.irqline,ASSERT_LINE,(sys.mfp.vr & 0xf0) | x); |
| 238 | | // logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(sys.mfp.vr & 0xf0) | x,sys.mfp.irqline); |
| 236 | current_vector[6] = (x68k_sys.mfp.vr & 0xf0) | x; |
| 237 | cpu_set_input_line_and_vector(machine->cpu[0],x68k_sys.mfp.irqline,ASSERT_LINE,(x68k_sys.mfp.vr & 0xf0) | x); |
| 238 | // logerror("MFP: Sent IRQ vector 0x%02x (IRQ line %i)\n",(x68k_sys.mfp.vr & 0xf0) | x,x68k_sys.mfp.irqline); |
| 239 | 239 | return; // one at a time only |
| 240 | 240 | } |
| 241 | 241 | } |
| r4212 | r4213 | |
| 248 | 248 | // check if interrupt is enabled |
| 249 | 249 | if(irq > 7) |
| 250 | 250 | { |
| 251 | | if(!(sys.mfp.iera & (1 << (irq-8)))) |
| 251 | if(!(x68k_sys.mfp.iera & (1 << (irq-8)))) |
| 252 | 252 | return; // not enabled, no action taken |
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | { |
| 256 | | if(!(sys.mfp.ierb & (1 << irq))) |
| 256 | if(!(x68k_sys.mfp.ierb & (1 << irq))) |
| 257 | 257 | return; // not enabled, no action taken |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // set requested IRQ as pending |
| 261 | 261 | if(irq > 7) |
| 262 | | sys.mfp.ipra |= (1 << (irq-8)); |
| 262 | x68k_sys.mfp.ipra |= (1 << (irq-8)); |
| 263 | 263 | else |
| 264 | | sys.mfp.iprb |= (1 << irq); |
| 264 | x68k_sys.mfp.iprb |= (1 << irq); |
| 265 | 265 | |
| 266 | 266 | // check for IRQs to be called |
| 267 | 267 | // mfp_update_irq(0); |
| r4212 | r4213 | |
| 270 | 270 | |
| 271 | 271 | TIMER_CALLBACK(mfp_timer_a_callback) |
| 272 | 272 | { |
| 273 | | sys.mfp.timer[0].counter--; |
| 274 | | if(sys.mfp.timer[0].counter == 0) |
| 273 | x68k_sys.mfp.timer[0].counter--; |
| 274 | if(x68k_sys.mfp.timer[0].counter == 0) |
| 275 | 275 | { |
| 276 | | sys.mfp.timer[0].counter = sys.mfp.tadr; |
| 276 | x68k_sys.mfp.timer[0].counter = x68k_sys.mfp.tadr; |
| 277 | 277 | mfp_trigger_irq(MFP_IRQ_TIMERA); |
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | TIMER_CALLBACK(mfp_timer_b_callback) |
| 282 | 282 | { |
| 283 | | sys.mfp.timer[1].counter--; |
| 284 | | if(sys.mfp.timer[1].counter == 0) |
| 283 | x68k_sys.mfp.timer[1].counter--; |
| 284 | if(x68k_sys.mfp.timer[1].counter == 0) |
| 285 | 285 | { |
| 286 | | sys.mfp.timer[1].counter = sys.mfp.tbdr; |
| 286 | x68k_sys.mfp.timer[1].counter = x68k_sys.mfp.tbdr; |
| 287 | 287 | mfp_trigger_irq(MFP_IRQ_TIMERB); |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | TIMER_CALLBACK(mfp_timer_c_callback) |
| 292 | 292 | { |
| 293 | | sys.mfp.timer[2].counter--; |
| 294 | | if(sys.mfp.timer[2].counter == 0) |
| 293 | x68k_sys.mfp.timer[2].counter--; |
| 294 | if(x68k_sys.mfp.timer[2].counter == 0) |
| 295 | 295 | { |
| 296 | | sys.mfp.timer[2].counter = sys.mfp.tcdr; |
| 296 | x68k_sys.mfp.timer[2].counter = x68k_sys.mfp.tcdr; |
| 297 | 297 | mfp_trigger_irq(MFP_IRQ_TIMERC); |
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | TIMER_CALLBACK(mfp_timer_d_callback) |
| 302 | 302 | { |
| 303 | | sys.mfp.timer[3].counter--; |
| 304 | | if(sys.mfp.timer[3].counter == 0) |
| 303 | x68k_sys.mfp.timer[3].counter--; |
| 304 | if(x68k_sys.mfp.timer[3].counter == 0) |
| 305 | 305 | { |
| 306 | | sys.mfp.timer[3].counter = sys.mfp.tddr; |
| 306 | x68k_sys.mfp.timer[3].counter = x68k_sys.mfp.tddr; |
| 307 | 307 | mfp_trigger_irq(MFP_IRQ_TIMERD); |
| 308 | 308 | } |
| 309 | 309 | } |
| r4212 | r4213 | |
| 334 | 334 | if(led_state == 1) |
| 335 | 335 | { |
| 336 | 336 | for(drive=0;drive<4;drive++) |
| 337 | | output_set_indexed_value("ctrl_drv",drive,sys.fdc.led_ctrl[drive] ? 0 : 1); |
| 337 | output_set_indexed_value("ctrl_drv",drive,x68k_sys.fdc.led_ctrl[drive] ? 0 : 1); |
| 338 | 338 | } |
| 339 | 339 | else |
| 340 | 340 | { |
| r4212 | r4213 | |
| 410 | 410 | |
| 411 | 411 | if((data & 0xf8) == 0x48) // Keyboard enable |
| 412 | 412 | { |
| 413 | | sys.keyboard.enabled = data & 0x01; |
| 414 | | logerror("KB: Keyboard enable bit = %i\n",sys.keyboard.enabled); |
| 413 | x68k_sys.keyboard.enabled = data & 0x01; |
| 414 | logerror("KB: Keyboard enable bit = %i\n",x68k_sys.keyboard.enabled); |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | if((data & 0xf0) == 0x60) // Key delay time |
| 418 | 418 | { |
| 419 | | sys.keyboard.delay = data & 0x0f; |
| 419 | x68k_sys.keyboard.delay = data & 0x0f; |
| 420 | 420 | logerror("KB: Keypress delay time is now %ims\n",(data & 0x0f)*100+200); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | if((data & 0xf0) == 0x70) // Key repeat rate |
| 424 | 424 | { |
| 425 | | sys.keyboard.repeat = data & 0x0f; |
| 425 | x68k_sys.keyboard.repeat = data & 0x0f; |
| 426 | 426 | logerror("KB: Keypress repeat rate is now %ims\n",((data & 0x0f)^2)*5+30); |
| 427 | 427 | } |
| 428 | 428 | |
| r4212 | r4213 | |
| 431 | 431 | int x68k_keyboard_pop_scancode(void) |
| 432 | 432 | { |
| 433 | 433 | int ret; |
| 434 | | if(sys.keyboard.keynum == 0) // no scancodes in USART buffer |
| 434 | if(x68k_sys.keyboard.keynum == 0) // no scancodes in USART buffer |
| 435 | 435 | return 0x00; |
| 436 | 436 | |
| 437 | | sys.keyboard.keynum--; |
| 438 | | ret = sys.keyboard.buffer[sys.keyboard.tailpos++]; |
| 439 | | if(sys.keyboard.tailpos > 15) |
| 440 | | sys.keyboard.tailpos = 0; |
| 437 | x68k_sys.keyboard.keynum--; |
| 438 | ret = x68k_sys.keyboard.buffer[x68k_sys.keyboard.tailpos++]; |
| 439 | if(x68k_sys.keyboard.tailpos > 15) |
| 440 | x68k_sys.keyboard.tailpos = 0; |
| 441 | 441 | |
| 442 | 442 | logerror("MFP: Keyboard buffer pop 0x%02x\n",ret); |
| 443 | 443 | return ret; |
| r4212 | r4213 | |
| 445 | 445 | |
| 446 | 446 | static void x68k_keyboard_push_scancode(running_machine* machine,unsigned char code) |
| 447 | 447 | { |
| 448 | | sys.keyboard.keynum++; |
| 449 | | if(sys.keyboard.keynum >= 1) |
| 448 | x68k_sys.keyboard.keynum++; |
| 449 | if(x68k_sys.keyboard.keynum >= 1) |
| 450 | 450 | { // keyboard buffer full |
| 451 | | if(sys.keyboard.enabled != 0) |
| 451 | if(x68k_sys.keyboard.enabled != 0) |
| 452 | 452 | { |
| 453 | | sys.mfp.rsr |= 0x80; // Buffer full |
| 453 | x68k_sys.mfp.rsr |= 0x80; // Buffer full |
| 454 | 454 | // mfp_trigger_irq(MFP_IRQ_RX_FULL); |
| 455 | 455 | if(input_port_read(machine,"options") & 0x01) |
| 456 | 456 | { |
| r4212 | r4213 | |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | | sys.keyboard.buffer[sys.keyboard.headpos++] = code; |
| 464 | | if(sys.keyboard.headpos > 15) |
| 463 | x68k_sys.keyboard.buffer[x68k_sys.keyboard.headpos++] = code; |
| 464 | if(x68k_sys.keyboard.headpos > 15) |
| 465 | 465 | { |
| 466 | | sys.keyboard.headpos = 0; |
| 466 | x68k_sys.keyboard.headpos = 0; |
| 467 | 467 | // mfp_trigger_irq(MFP_IRQ_RX_ERROR); |
| 468 | 468 | current_vector[6] = 0x4b; |
| 469 | 469 | // cpu_set_input_line_and_vector(machine->cpu[0],6,ASSERT_LINE,0x4b); |
| r4212 | r4213 | |
| 478 | 478 | for(x=0;x<0x80;x++) |
| 479 | 479 | { |
| 480 | 480 | // adjust delay/repeat timers |
| 481 | | if(sys.keyboard.keytime[x] > 0) |
| 481 | if(x68k_sys.keyboard.keytime[x] > 0) |
| 482 | 482 | { |
| 483 | | sys.keyboard.keytime[x] -= 5; |
| 483 | x68k_sys.keyboard.keytime[x] -= 5; |
| 484 | 484 | } |
| 485 | 485 | if(!(input_port_read(machine, keynames[x / 32]) & (1 << (x % 32)))) |
| 486 | 486 | { |
| 487 | | if(sys.keyboard.keyon[x] != 0) |
| 487 | if(x68k_sys.keyboard.keyon[x] != 0) |
| 488 | 488 | { |
| 489 | 489 | x68k_keyboard_push_scancode(machine,0x80 + x); |
| 490 | | sys.keyboard.keytime[x] = 0; |
| 491 | | sys.keyboard.keyon[x] = 0; |
| 492 | | sys.keyboard.last_pressed = 0; |
| 490 | x68k_sys.keyboard.keytime[x] = 0; |
| 491 | x68k_sys.keyboard.keyon[x] = 0; |
| 492 | x68k_sys.keyboard.last_pressed = 0; |
| 493 | 493 | logerror("KB: Released key 0x%02x\n",x); |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | // check to see if a key is being held |
| 497 | | if(sys.keyboard.keyon[x] != 0 && sys.keyboard.keytime[x] == 0 && sys.keyboard.last_pressed == x) |
| 497 | if(x68k_sys.keyboard.keyon[x] != 0 && x68k_sys.keyboard.keytime[x] == 0 && x68k_sys.keyboard.last_pressed == x) |
| 498 | 498 | { |
| 499 | | if(input_port_read(machine, keynames[sys.keyboard.last_pressed / 32]) & (1 << (sys.keyboard.last_pressed % 32))) |
| 499 | if(input_port_read(machine, keynames[x68k_sys.keyboard.last_pressed / 32]) & (1 << (x68k_sys.keyboard.last_pressed % 32))) |
| 500 | 500 | { |
| 501 | | x68k_keyboard_push_scancode(machine,sys.keyboard.last_pressed); |
| 502 | | sys.keyboard.keytime[sys.keyboard.last_pressed] = (sys.keyboard.repeat^2)*5+30; |
| 503 | | logerror("KB: Holding key 0x%02x\n",sys.keyboard.last_pressed); |
| 501 | x68k_keyboard_push_scancode(machine,x68k_sys.keyboard.last_pressed); |
| 502 | x68k_sys.keyboard.keytime[x68k_sys.keyboard.last_pressed] = (x68k_sys.keyboard.repeat^2)*5+30; |
| 503 | logerror("KB: Holding key 0x%02x\n",x68k_sys.keyboard.last_pressed); |
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | if((input_port_read(machine, keynames[x / 32]) & (1 << (x % 32)))) |
| 507 | 507 | { |
| 508 | | if(sys.keyboard.keyon[x] == 0) |
| 508 | if(x68k_sys.keyboard.keyon[x] == 0) |
| 509 | 509 | { |
| 510 | 510 | x68k_keyboard_push_scancode(machine,x); |
| 511 | | sys.keyboard.keytime[x] = sys.keyboard.delay * 100 + 200; |
| 512 | | sys.keyboard.keyon[x] = 1; |
| 513 | | sys.keyboard.last_pressed = x; |
| 511 | x68k_sys.keyboard.keytime[x] = x68k_sys.keyboard.delay * 100 + 200; |
| 512 | x68k_sys.keyboard.keyon[x] = 1; |
| 513 | x68k_sys.keyboard.last_pressed = x; |
| 514 | 514 | logerror("KB: Pushed key 0x%02x\n",x); |
| 515 | 515 | } |
| 516 | 516 | } |
| r4212 | r4213 | |
| 521 | 521 | #ifdef UNUSED_FUNCTION |
| 522 | 522 | void mfp_recv_data(int data) |
| 523 | 523 | { |
| 524 | | sys.mfp.rsr |= 0x80; // Buffer full |
| 525 | | sys.mfp.tsr |= 0x80; |
| 526 | | sys.mfp.usart.recv_buffer = 0x00; // TODO: set up keyboard data |
| 527 | | sys.mfp.vector = current_vector[6] = (sys.mfp.vr & 0xf0) | 0x0c; |
| 524 | x68k_sys.mfp.rsr |= 0x80; // Buffer full |
| 525 | x68k_sys.mfp.tsr |= 0x80; |
| 526 | x68k_sys.mfp.usart.recv_buffer = 0x00; // TODO: set up keyboard data |
| 527 | x68k_sys.mfp.vector = current_vector[6] = (x68k_sys.mfp.vr & 0xf0) | 0x0c; |
| 528 | 528 | // mfp_trigger_irq(MFP_IRQ_RX_FULL); |
| 529 | 529 | // logerror("MFP: Receive buffer full IRQ sent\n"); |
| 530 | 530 | } |
| r4212 | r4213 | |
| 542 | 542 | if(!(scc_get_reg_b(scc,5) & 0x02)) |
| 543 | 543 | return 0xff; |
| 544 | 544 | |
| 545 | | switch(sys.mouse.inputtype) |
| 545 | switch(x68k_sys.mouse.inputtype) |
| 546 | 546 | { |
| 547 | 547 | case 0: |
| 548 | 548 | ipt = input_port_read(machine, "mouse1"); |
| 549 | 549 | break; |
| 550 | 550 | case 1: |
| 551 | 551 | val = input_port_read(machine, "mouse2"); |
| 552 | | ipt = val - sys.mouse.last_mouse_x; |
| 553 | | sys.mouse.last_mouse_x = val; |
| 552 | ipt = val - x68k_sys.mouse.last_mouse_x; |
| 553 | x68k_sys.mouse.last_mouse_x = val; |
| 554 | 554 | break; |
| 555 | 555 | case 2: |
| 556 | 556 | val = input_port_read(machine, "mouse3"); |
| 557 | | ipt = val - sys.mouse.last_mouse_y; |
| 558 | | sys.mouse.last_mouse_y = val; |
| 557 | ipt = val - x68k_sys.mouse.last_mouse_y; |
| 558 | x68k_sys.mouse.last_mouse_y = val; |
| 559 | 559 | break; |
| 560 | 560 | } |
| 561 | | sys.mouse.inputtype++; |
| 562 | | if(sys.mouse.inputtype > 2) |
| 561 | x68k_sys.mouse.inputtype++; |
| 562 | if(x68k_sys.mouse.inputtype > 2) |
| 563 | 563 | { |
| 564 | 564 | int val = scc_get_reg_b(scc, 0); |
| 565 | | sys.mouse.inputtype = 0; |
| 566 | | sys.mouse.bufferempty = 1; |
| 565 | x68k_sys.mouse.inputtype = 0; |
| 566 | x68k_sys.mouse.bufferempty = 1; |
| 567 | 567 | val &= ~0x01; |
| 568 | 568 | scc_set_reg_b(scc, 0, val); |
| 569 | 569 | logerror("SCC: mouse buffer empty\n"); |
| r4212 | r4213 | |
| 612 | 612 | if(scc_get_reg_b(scc, 5) & 0x02) // Request to Send |
| 613 | 613 | { |
| 614 | 614 | int val = scc_get_reg_b(scc, 0); |
| 615 | | sys.mouse.bufferempty = 0; |
| 615 | x68k_sys.mouse.bufferempty = 0; |
| 616 | 616 | val |= 0x01; |
| 617 | 617 | scc_set_reg_b(scc, 0,val); |
| 618 | 618 | } |
| r4212 | r4213 | |
| 634 | 634 | static TIMER_CALLBACK(x68k_scc_ack) |
| 635 | 635 | { |
| 636 | 636 | const device_config *scc = devtag_get_device(machine, SCC8530, "scc"); |
| 637 | | if(sys.mouse.bufferempty != 0) // nothing to do if the mouse data buffer is empty |
| 637 | if(x68k_sys.mouse.bufferempty != 0) // nothing to do if the mouse data buffer is empty |
| 638 | 638 | return; |
| 639 | 639 | |
| 640 | | // if((sys.ioc.irqstatus & 0xc0) != 0) |
| 640 | // if((x68k_sys.ioc.irqstatus & 0xc0) != 0) |
| 641 | 641 | // return; |
| 642 | 642 | |
| 643 | 643 | // hard-code the IRQ vector for now, until the SCC code is more complete |
| r4212 | r4213 | |
| 647 | 647 | { |
| 648 | 648 | if(scc_get_reg_b(scc, 5) & 0x02) // RTS signal |
| 649 | 649 | { |
| 650 | | sys.mouse.irqactive = 1; |
| 650 | x68k_sys.mouse.irqactive = 1; |
| 651 | 651 | current_vector[5] = 0x54; |
| 652 | 652 | current_irq_line = 5; |
| 653 | 653 | cpu_set_input_line_and_vector(machine->cpu[0],5,ASSERT_LINE,0x54); |
| r4212 | r4213 | |
| 661 | 661 | const device_config *dev = devtag_get_device(machine, HD63450, "hd63450"); |
| 662 | 662 | UINT32 rate = 0; |
| 663 | 663 | |
| 664 | | switch(sys.adpcm.rate & 0x0c) |
| 664 | switch(x68k_sys.adpcm.rate & 0x0c) |
| 665 | 665 | { |
| 666 | 666 | case 0x00: |
| 667 | 667 | rate = 7812/2; |
| r4212 | r4213 | |
| 676 | 676 | logerror("PPI: Invalid ADPCM sample rate set.\n"); |
| 677 | 677 | rate = 15625/2; |
| 678 | 678 | } |
| 679 | | if(sys.adpcm.clock != 0) |
| 679 | if(x68k_sys.adpcm.clock != 0) |
| 680 | 680 | rate = rate/2; |
| 681 | 681 | hd63450_set_timer(dev,3,ATTOTIME_IN_HZ(rate)); |
| 682 | 682 | } |
| r4212 | r4213 | |
| 686 | 686 | static READ8_DEVICE_HANDLER( ppi_port_a_r ) |
| 687 | 687 | { |
| 688 | 688 | // Joystick 1 |
| 689 | | if(sys.joy.joy1_enable == 0) |
| 689 | if(x68k_sys.joy.joy1_enable == 0) |
| 690 | 690 | return input_port_read(device->machine, "joy1"); |
| 691 | 691 | else |
| 692 | 692 | return 0xff; |
| r4212 | r4213 | |
| 695 | 695 | static READ8_DEVICE_HANDLER( ppi_port_b_r ) |
| 696 | 696 | { |
| 697 | 697 | // Joystick 2 |
| 698 | | if(sys.joy.joy2_enable == 0) |
| 698 | if(x68k_sys.joy.joy2_enable == 0) |
| 699 | 699 | return input_port_read(device->machine, "joy2"); |
| 700 | 700 | else |
| 701 | 701 | return 0xff; |
| r4212 | r4213 | |
| 719 | 719 | // ADPCM / Joystick control |
| 720 | 720 | |
| 721 | 721 | ppi_port[2] = data; |
| 722 | | sys.adpcm.pan = data & 0x03; |
| 723 | | sys.adpcm.rate = data & 0x0c; |
| 722 | x68k_sys.adpcm.pan = data & 0x03; |
| 723 | x68k_sys.adpcm.rate = data & 0x0c; |
| 724 | 724 | x68k_set_adpcm(device->machine); |
| 725 | 725 | okim6258_set_divider(0, (data >> 2) & 3); |
| 726 | 726 | |
| 727 | | sys.joy.joy1_enable = data & 0x10; |
| 728 | | sys.joy.joy2_enable = data & 0x20; |
| 729 | | sys.joy.ioc6 = data & 0x40; |
| 730 | | sys.joy.ioc7 = data & 0x80; |
| 727 | x68k_sys.joy.joy1_enable = data & 0x10; |
| 728 | x68k_sys.joy.joy2_enable = data & 0x20; |
| 729 | x68k_sys.joy.ioc6 = data & 0x40; |
| 730 | x68k_sys.joy.ioc7 = data & 0x80; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
| r4212 | r4213 | |
| 748 | 748 | { |
| 749 | 749 | if(x & (1 << drive)) |
| 750 | 750 | { |
| 751 | | sys.fdc.led_ctrl[drive] = data & 0x80; // blinking drive LED if no disk inserted |
| 752 | | sys.fdc.led_eject[drive] = data & 0x40; // eject button LED (on when set to 0) |
| 751 | x68k_sys.fdc.led_ctrl[drive] = data & 0x80; // blinking drive LED if no disk inserted |
| 752 | x68k_sys.fdc.led_eject[drive] = data & 0x40; // eject button LED (on when set to 0) |
| 753 | 753 | output_set_indexed_value("eject_drv",drive,(data & 0x40) ? 1 : 0); |
| 754 | 754 | if(data & 0x20) // ejects disk |
| 755 | 755 | { |
| r4212 | r4213 | |
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | } |
| 761 | | sys.fdc.selected_drive = data & 0x0f; |
| 761 | x68k_sys.fdc.selected_drive = data & 0x0f; |
| 762 | 762 | logerror("FDC: signal control set to %02x\n",data); |
| 763 | 763 | break; |
| 764 | 764 | case 0x03: |
| 765 | | sys.fdc.media_density[data & 0x03] = data & 0x10; |
| 766 | | sys.fdc.motor[data & 0x03] = data & 0x80; |
| 765 | x68k_sys.fdc.media_density[data & 0x03] = data & 0x10; |
| 766 | x68k_sys.fdc.motor[data & 0x03] = data & 0x80; |
| 767 | 767 | floppy_drive_set_motor_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, data & 0x03), (data & 0x80)); |
| 768 | 768 | if(data & 0x80) |
| 769 | 769 | { |
| r4212 | r4213 | |
| 821 | 821 | ret = 0x00; |
| 822 | 822 | for(x=0;x<4;x++) |
| 823 | 823 | { |
| 824 | | if(sys.fdc.selected_drive & (1 << x)) |
| 824 | if(x68k_sys.fdc.selected_drive & (1 << x)) |
| 825 | 825 | { |
| 826 | 826 | ret = 0x00; |
| 827 | | if(sys.fdc.disk_inserted[x] != 0) |
| 827 | if(x68k_sys.fdc.disk_inserted[x] != 0) |
| 828 | 828 | { |
| 829 | 829 | ret |= 0x80; |
| 830 | 830 | } |
| r4212 | r4213 | |
| 845 | 845 | |
| 846 | 846 | static NEC765_INTERRUPT( fdc_irq ) |
| 847 | 847 | { |
| 848 | | if((sys.ioc.irqstatus & 0x04) && state == ASSERT_LINE) |
| 848 | if((x68k_sys.ioc.irqstatus & 0x04) && state == ASSERT_LINE) |
| 849 | 849 | { |
| 850 | | current_vector[1] = sys.ioc.fdcvector; |
| 851 | | sys.ioc.irqstatus |= 0x80; |
| 850 | current_vector[1] = x68k_sys.ioc.fdcvector; |
| 851 | x68k_sys.ioc.irqstatus |= 0x80; |
| 852 | 852 | current_irq_line = 1; |
| 853 | 853 | logerror("FDC: IRQ triggered\n"); |
| 854 | 854 | cpu_set_input_line_and_vector(device->machine->cpu[0],1,ASSERT_LINE,current_vector[1]); |
| r4212 | r4213 | |
| 860 | 860 | int data = -1; |
| 861 | 861 | device_config *fdc = (device_config*)devtag_get_device(machine, NEC72065, "nec72065"); |
| 862 | 862 | |
| 863 | | if(sys.fdc.drq_state != 0) |
| 863 | if(x68k_sys.fdc.drq_state != 0) |
| 864 | 864 | data = nec765_dack_r(fdc, 0); |
| 865 | 865 | // logerror("FDC: DACK reading\n"); |
| 866 | 866 | return data; |
| r4212 | r4213 | |
| 874 | 874 | |
| 875 | 875 | static NEC765_DMA_REQUEST ( fdc_drq ) |
| 876 | 876 | { |
| 877 | | sys.fdc.drq_state = state; |
| 877 | x68k_sys.fdc.drq_state = state; |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | static WRITE16_HANDLER( x68k_fm_w ) |
| r4212 | r4213 | |
| 907 | 907 | // CT1 - ADPCM clock - 0 = 8MHz, 1 = 4MHz |
| 908 | 908 | // CT2 - 1 = Set ready state of FDC |
| 909 | 909 | nec765_set_ready_state(fdc,data & 0x01); |
| 910 | | sys.adpcm.clock = data & 0x02; |
| 910 | x68k_sys.adpcm.clock = data & 0x02; |
| 911 | 911 | x68k_set_adpcm(space->machine); |
| 912 | 912 | okim6258_set_clock(0, data & 0x02 ? 4000000 : 8000000); |
| 913 | 913 | } |
| r4212 | r4213 | |
| 933 | 933 | switch(offset) |
| 934 | 934 | { |
| 935 | 935 | case 0x00: |
| 936 | | sys.ioc.irqstatus = data & 0x0f; |
| 936 | x68k_sys.ioc.irqstatus = data & 0x0f; |
| 937 | 937 | logerror("I/O: Status register write %02x\n",data); |
| 938 | 938 | break; |
| 939 | 939 | case 0x01: |
| 940 | 940 | switch(data & 0x03) |
| 941 | 941 | { |
| 942 | 942 | case 0x00: |
| 943 | | sys.ioc.fdcvector = data & 0xfc; |
| 943 | x68k_sys.ioc.fdcvector = data & 0xfc; |
| 944 | 944 | logerror("IOC: FDC IRQ vector = 0x%02x\n",data & 0xfc); |
| 945 | 945 | break; |
| 946 | 946 | case 0x01: |
| 947 | | sys.ioc.fddvector = data & 0xfc; |
| 947 | x68k_sys.ioc.fddvector = data & 0xfc; |
| 948 | 948 | logerror("IOC: FDD IRQ vector = 0x%02x\n",data & 0xfc); |
| 949 | 949 | break; |
| 950 | 950 | case 0x02: |
| 951 | | sys.ioc.hdcvector = data & 0xfc; |
| 951 | x68k_sys.ioc.hdcvector = data & 0xfc; |
| 952 | 952 | logerror("IOC: HDD IRQ vector = 0x%02x\n",data & 0xfc); |
| 953 | 953 | break; |
| 954 | 954 | case 0x03: |
| 955 | | sys.ioc.prnvector = data & 0xfc; |
| 955 | x68k_sys.ioc.prnvector = data & 0xfc; |
| 956 | 956 | logerror("IOC: Printer IRQ vector = 0x%02x\n",data & 0xfc); |
| 957 | 957 | break; |
| 958 | 958 | } |
| r4212 | r4213 | |
| 966 | 966 | { |
| 967 | 967 | case 0x00: |
| 968 | 968 | logerror("I/O: Status register read\n"); |
| 969 | | return (sys.ioc.irqstatus & 0xdf) | 0x20; |
| 969 | return (x68k_sys.ioc.irqstatus & 0xdf) | 0x20; |
| 970 | 970 | default: |
| 971 | 971 | return 0x00; |
| 972 | 972 | } |
| r4212 | r4213 | |
| 997 | 997 | switch(offset) |
| 998 | 998 | { |
| 999 | 999 | case 0x00: |
| 1000 | | sys.sysport.contrast = data & 0x0f; // often used for screen fades / blanking |
| 1000 | x68k_sys.sysport.contrast = data & 0x0f; // often used for screen fades / blanking |
| 1001 | 1001 | // TODO: implement a decent, not slow, brightness control |
| 1002 | 1002 | break; |
| 1003 | 1003 | case 0x01: |
| 1004 | | sys.sysport.monitor = data & 0x08; |
| 1004 | x68k_sys.sysport.monitor = data & 0x08; |
| 1005 | 1005 | break; |
| 1006 | 1006 | case 0x03: |
| 1007 | | sys.sysport.keyctrl = data & 0x08; // bit 3 = enable keyboard data transmission |
| 1007 | x68k_sys.sysport.keyctrl = data & 0x08; // bit 3 = enable keyboard data transmission |
| 1008 | 1008 | break; |
| 1009 | 1009 | case 0x06: |
| 1010 | | sys.sysport.sram_writeprotect = data; |
| 1010 | x68k_sys.sysport.sram_writeprotect = data; |
| 1011 | 1011 | break; |
| 1012 | 1012 | default: |
| 1013 | 1013 | // logerror("SYS: [%08x] Wrote %04x to invalid or unimplemented system port %04x\n",cpu_get_pc(space->cpu),data,offset); |
| r4212 | r4213 | |
| 1021 | 1021 | switch(offset) |
| 1022 | 1022 | { |
| 1023 | 1023 | case 0x00: // monitor contrast setting (bits3-0) |
| 1024 | | return sys.sysport.contrast; |
| 1024 | return x68k_sys.sysport.contrast; |
| 1025 | 1025 | case 0x01: // monitor control (bit3) / 3D Scope (bits1,0) |
| 1026 | | ret |= sys.sysport.monitor; |
| 1026 | ret |= x68k_sys.sysport.monitor; |
| 1027 | 1027 | return ret; |
| 1028 | 1028 | case 0x03: // bit 3 = key control (is 1 if keyboard is connected) |
| 1029 | 1029 | return 0x08; |
| r4212 | r4213 | |
| 1052 | 1052 | { |
| 1053 | 1053 | /* case 0x00: // GPIP - General purpose I/O register (read-only) |
| 1054 | 1054 | ret = 0x23; |
| 1055 | | if(video_screen_get_vpos(machine->primary_screen) == sys.crtc.reg[9]) |
| 1055 | if(video_screen_get_vpos(machine->primary_screen) == x68k_sys.crtc.reg[9]) |
| 1056 | 1056 | ret |= 0x40; |
| 1057 | | if(sys.crtc.vblank == 0) |
| 1057 | if(x68k_sys.crtc.vblank == 0) |
| 1058 | 1058 | ret |= 0x10; // Vsync signal (low if in vertical retrace) |
| 1059 | | // if(sys.mfp.isrb & 0x08) |
| 1059 | // if(x68k_sys.mfp.isrb & 0x08) |
| 1060 | 1060 | // ret |= 0x08; // FM IRQ signal |
| 1061 | | if(video_screen_get_hpos(machine->primary_screen) > sys.crtc.width - 32) |
| 1061 | if(video_screen_get_hpos(machine->primary_screen) > x68k_sys.crtc.width - 32) |
| 1062 | 1062 | ret |= 0x80; // Hsync signal |
| 1063 | 1063 | // logerror("MFP: [%08x] Reading offset %i (ret=%02x)\n",cpu_get_pc(space->cpu),offset,ret); |
| 1064 | 1064 | return ret; // bit 5 is always 1 |
| 1065 | 1065 | case 3: |
| 1066 | | return sys.mfp.iera; |
| 1066 | return x68k_sys.mfp.iera; |
| 1067 | 1067 | case 4: |
| 1068 | | return sys.mfp.ierb; |
| 1068 | return x68k_sys.mfp.ierb; |
| 1069 | 1069 | case 5: |
| 1070 | | return sys.mfp.ipra; |
| 1070 | return x68k_sys.mfp.ipra; |
| 1071 | 1071 | case 6: |
| 1072 | | return sys.mfp.iprb; |
| 1072 | return x68k_sys.mfp.iprb; |
| 1073 | 1073 | case 7: |
| 1074 | | if(sys.mfp.eoi_mode == 0) // forced low in auto EOI mode |
| 1074 | if(x68k_sys.mfp.eoi_mode == 0) // forced low in auto EOI mode |
| 1075 | 1075 | return 0; |
| 1076 | 1076 | else |
| 1077 | | return sys.mfp.isra; |
| 1077 | return x68k_sys.mfp.isra; |
| 1078 | 1078 | case 8: |
| 1079 | | if(sys.mfp.eoi_mode == 0) // forced low in auto EOI mode |
| 1079 | if(x68k_sys.mfp.eoi_mode == 0) // forced low in auto EOI mode |
| 1080 | 1080 | return 0; |
| 1081 | 1081 | else |
| 1082 | | return sys.mfp.isrb; |
| 1082 | return x68k_sys.mfp.isrb; |
| 1083 | 1083 | case 9: |
| 1084 | | return sys.mfp.imra; |
| 1084 | return x68k_sys.mfp.imra; |
| 1085 | 1085 | case 10: |
| 1086 | | return sys.mfp.imrb; |
| 1086 | return x68k_sys.mfp.imrb; |
| 1087 | 1087 | case 15: // TADR |
| 1088 | | return sys.mfp.timer[0].counter; // Timer data registers return their main counter values |
| 1088 | return x68k_sys.mfp.timer[0].counter; // Timer data registers return their main counter values |
| 1089 | 1089 | case 16: // TBDR |
| 1090 | | return sys.mfp.timer[1].counter; |
| 1090 | return x68k_sys.mfp.timer[1].counter; |
| 1091 | 1091 | case 17: // TCDR |
| 1092 | | return sys.mfp.timer[2].counter; |
| 1092 | return x68k_sys.mfp.timer[2].counter; |
| 1093 | 1093 | case 18: // TDDR |
| 1094 | | return sys.mfp.timer[3].counter;*/ |
| 1094 | return x68k_sys.mfp.timer[3].counter;*/ |
| 1095 | 1095 | case 21: // RSR |
| 1096 | | return sys.mfp.rsr; |
| 1096 | return x68k_sys.mfp.rsr; |
| 1097 | 1097 | case 22: // TSR |
| 1098 | | return sys.mfp.tsr | 0x80; // buffer is typically empty? |
| 1098 | return x68k_sys.mfp.tsr | 0x80; // buffer is typically empty? |
| 1099 | 1099 | case 23: |
| 1100 | 1100 | return x68k_keyboard_pop_scancode(); |
| 1101 | 1101 | default: |
| r4212 | r4213 | |
| 1132 | 1132 | // All bits are inputs generally, so no action taken. |
| 1133 | 1133 | break; |
| 1134 | 1134 | case 1: // AER |
| 1135 | | sys.mfp.aer = data; |
| 1135 | x68k_sys.mfp.aer = data; |
| 1136 | 1136 | break; |
| 1137 | 1137 | case 2: // DDR |
| 1138 | | sys.mfp.ddr = data; // usually all bits are 0 (input) |
| 1138 | x68k_sys.mfp.ddr = data; // usually all bits are 0 (input) |
| 1139 | 1139 | break; |
| 1140 | 1140 | case 3: // IERA |
| 1141 | | sys.mfp.iera = data; |
| 1141 | x68k_sys.mfp.iera = data; |
| 1142 | 1142 | break; |
| 1143 | 1143 | case 4: // IERB |
| 1144 | | sys.mfp.ierb = data; |
| 1144 | x68k_sys.mfp.ierb = data; |
| 1145 | 1145 | break; |
| 1146 | 1146 | case 5: // IPRA |
| 1147 | | sys.mfp.ipra = data; |
| 1147 | x68k_sys.mfp.ipra = data; |
| 1148 | 1148 | break; |
| 1149 | 1149 | case 6: // IPRB |
| 1150 | | sys.mfp.iprb = data; |
| 1150 | x68k_sys.mfp.iprb = data; |
| 1151 | 1151 | break; |
| 1152 | 1152 | case 7: |
| 1153 | | sys.mfp.isra = data; |
| 1153 | x68k_sys.mfp.isra = data; |
| 1154 | 1154 | break; |
| 1155 | 1155 | case 8: |
| 1156 | | sys.mfp.isrb = data; |
| 1156 | x68k_sys.mfp.isrb = data; |
| 1157 | 1157 | break; |
| 1158 | 1158 | case 9: |
| 1159 | | sys.mfp.imra = data; |
| 1159 | x68k_sys.mfp.imra = data; |
| 1160 | 1160 | // mfp_update_irq(0); |
| 1161 | 1161 | // logerror("MFP: IRQ Mask A write: %02x\n",data); |
| 1162 | 1162 | break; |
| 1163 | 1163 | case 10: |
| 1164 | | sys.mfp.imrb = data; |
| 1164 | x68k_sys.mfp.imrb = data; |
| 1165 | 1165 | // mfp_update_irq(0); |
| 1166 | 1166 | // logerror("MFP: IRQ Mask B write: %02x\n",data); |
| 1167 | 1167 | break; |
| 1168 | 1168 | case 11: // VR |
| 1169 | | sys.mfp.vr = 0x40;//data; // High 4 bits = high 4 bits of IRQ vector |
| 1170 | | sys.mfp.eoi_mode = data & 0x08; // 0 = Auto, 1 = Software End-of-interrupt |
| 1171 | | if(sys.mfp.eoi_mode == 0) // In-service registers are cleared if this bit is cleared. |
| 1169 | x68k_sys.mfp.vr = 0x40;//data; // High 4 bits = high 4 bits of IRQ vector |
| 1170 | x68k_sys.mfp.eoi_mode = data & 0x08; // 0 = Auto, 1 = Software End-of-interrupt |
| 1171 | if(x68k_sys.mfp.eoi_mode == 0) // In-service registers are cleared if this bit is cleared. |
| 1172 | 1172 | { |
| 1173 | | sys.mfp.isra = 0; |
| 1174 | | sys.mfp.isrb = 0; |
| 1173 | x68k_sys.mfp.isra = 0; |
| 1174 | x68k_sys.mfp.isrb = 0; |
| 1175 | 1175 | } |
| 1176 | 1176 | break; |
| 1177 | 1177 | case 12: // TACR |
| 1178 | | sys.mfp.tacr = data; |
| 1178 | x68k_sys.mfp.tacr = data; |
| 1179 | 1179 | mfp_set_timer(0,data & 0x0f); |
| 1180 | 1180 | break; |
| 1181 | 1181 | case 13: // TBCR |
| 1182 | | sys.mfp.tbcr = data; |
| 1182 | x68k_sys.mfp.tbcr = data; |
| 1183 | 1183 | mfp_set_timer(1,data & 0x0f); |
| 1184 | 1184 | break; |
| 1185 | 1185 | case 14: // TCDCR |
| 1186 | | sys.mfp.tcdcr = data; |
| 1186 | x68k_sys.mfp.tcdcr = data; |
| 1187 | 1187 | mfp_set_timer(2,(data & 0x70)>>4); |
| 1188 | 1188 | mfp_set_timer(3,data & 0x07); |
| 1189 | 1189 | break; |
| 1190 | 1190 | case 15: // TADR |
| 1191 | | sys.mfp.tadr = data; |
| 1192 | | sys.mfp.timer[0].counter = data; |
| 1191 | x68k_sys.mfp.tadr = data; |
| 1192 | x68k_sys.mfp.timer[0].counter = data; |
| 1193 | 1193 | break; |
| 1194 | 1194 | case 16: // TBDR |
| 1195 | | sys.mfp.tbdr = data; |
| 1196 | | sys.mfp.timer[1].counter = data; |
| 1195 | x68k_sys.mfp.tbdr = data; |
| 1196 | x68k_sys.mfp.timer[1].counter = data; |
| 1197 | 1197 | break; |
| 1198 | 1198 | case 17: // TCDR |
| 1199 | | sys.mfp.tcdr = data; |
| 1200 | | sys.mfp.timer[2].counter = data; |
| 1199 | x68k_sys.mfp.tcdr = data; |
| 1200 | x68k_sys.mfp.timer[2].counter = data; |
| 1201 | 1201 | break; |
| 1202 | 1202 | case 18: // TDDR |
| 1203 | | sys.mfp.tddr = data; |
| 1204 | | sys.mfp.timer[3].counter = data; |
| 1203 | x68k_sys.mfp.tddr = data; |
| 1204 | x68k_sys.mfp.timer[3].counter = data; |
| 1205 | 1205 | break; |
| 1206 | 1206 | case 20: |
| 1207 | | sys.mfp.ucr = data; |
| 1207 | x68k_sys.mfp.ucr = data; |
| 1208 | 1208 | break;*/ |
| 1209 | 1209 | case 21: |
| 1210 | 1210 | if(data & 0x01) |
| 1211 | | sys.mfp.usart.recv_enable = 1; |
| 1211 | x68k_sys.mfp.usart.recv_enable = 1; |
| 1212 | 1212 | else |
| 1213 | | sys.mfp.usart.recv_enable = 0; |
| 1213 | x68k_sys.mfp.usart.recv_enable = 0; |
| 1214 | 1214 | break; |
| 1215 | 1215 | case 22: |
| 1216 | 1216 | if(data & 0x01) |
| 1217 | | sys.mfp.usart.send_enable = 1; |
| 1217 | x68k_sys.mfp.usart.send_enable = 1; |
| 1218 | 1218 | else |
| 1219 | | sys.mfp.usart.send_enable = 0; |
| 1219 | x68k_sys.mfp.usart.send_enable = 0; |
| 1220 | 1220 | break; |
| 1221 | 1221 | case 23: |
| 1222 | | if(sys.mfp.usart.send_enable != 0) |
| 1222 | if(x68k_sys.mfp.usart.send_enable != 0) |
| 1223 | 1223 | { |
| 1224 | 1224 | // Keyboard control command. |
| 1225 | | sys.mfp.usart.send_buffer = data; |
| 1225 | x68k_sys.mfp.usart.send_buffer = data; |
| 1226 | 1226 | x68k_keyboard_ctrl_w(data); |
| 1227 | 1227 | // logerror("MFP: [%08x] USART Sent data %04x\n",cpu_get_pc(space->cpu),data); |
| 1228 | 1228 | } |
| r4212 | r4213 | |
| 1256 | 1256 | |
| 1257 | 1257 | static void x68k_rtc_alarm_irq(int state) |
| 1258 | 1258 | { |
| 1259 | | if(sys.mfp.aer & 0x01) |
| 1259 | if(x68k_sys.mfp.aer & 0x01) |
| 1260 | 1260 | { |
| 1261 | 1261 | if(state == 1) |
| 1262 | | sys.mfp.gpio |= 0x01; |
| 1262 | x68k_sys.mfp.gpio |= 0x01; |
| 1263 | 1263 | //mfp_trigger_irq(MFP_IRQ_GPIP0); // RTC ALARM |
| 1264 | 1264 | } |
| 1265 | 1265 | else |
| 1266 | 1266 | { |
| 1267 | 1267 | if(state == 0) |
| 1268 | | sys.mfp.gpio &= ~0x01; |
| 1268 | x68k_sys.mfp.gpio &= ~0x01; |
| 1269 | 1269 | //mfp_trigger_irq(MFP_IRQ_GPIP0); // RTC ALARM |
| 1270 | 1270 | } |
| 1271 | 1271 | } |
| r4212 | r4213 | |
| 1273 | 1273 | |
| 1274 | 1274 | static WRITE16_HANDLER( x68k_sram_w ) |
| 1275 | 1275 | { |
| 1276 | | if(sys.sysport.sram_writeprotect == 0x31) |
| 1276 | if(x68k_sys.sysport.sram_writeprotect == 0x31) |
| 1277 | 1277 | { |
| 1278 | 1278 | COMBINE_DATA(generic_nvram16+offset); |
| 1279 | 1279 | } |
| r4212 | r4213 | |
| 1300 | 1300 | int val; |
| 1301 | 1301 | if(offset < 0x100) // Graphic layer palette |
| 1302 | 1302 | { |
| 1303 | | COMBINE_DATA(sys.video.gfx_pal+offset); |
| 1304 | | val = sys.video.gfx_pal[offset]; |
| 1303 | COMBINE_DATA(x68k_sys.video.gfx_pal+offset); |
| 1304 | val = x68k_sys.video.gfx_pal[offset]; |
| 1305 | 1305 | palette_set_color_rgb(space->machine,offset,(val & 0x07c0) >> 3,(val & 0xf800) >> 8,(val & 0x003e) << 2); |
| 1306 | 1306 | return; |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | if(offset >= 0x100 && offset < 0x200) // Text / Sprites / Tilemap palette |
| 1310 | 1310 | { |
| 1311 | | COMBINE_DATA(sys.video.text_pal+(offset-0x100)); |
| 1312 | | val = sys.video.text_pal[offset-0x100]; |
| 1311 | COMBINE_DATA(x68k_sys.video.text_pal+(offset-0x100)); |
| 1312 | val = x68k_sys.video.text_pal[offset-0x100]; |
| 1313 | 1313 | palette_set_color_rgb(space->machine,offset,(val & 0x07c0) >> 3,(val & 0xf800) >> 8,(val & 0x003e) << 2); |
| 1314 | 1314 | return; |
| 1315 | 1315 | } |
| r4212 | r4213 | |
| 1317 | 1317 | switch(offset) |
| 1318 | 1318 | { |
| 1319 | 1319 | case 0x200: |
| 1320 | | COMBINE_DATA(sys.video.reg); |
| 1320 | COMBINE_DATA(x68k_sys.video.reg); |
| 1321 | 1321 | break; |
| 1322 | 1322 | case 0x280: // priority levels |
| 1323 | | COMBINE_DATA(sys.video.reg+1); |
| 1323 | COMBINE_DATA(x68k_sys.video.reg+1); |
| 1324 | 1324 | if(ACCESSING_BITS_0_7) |
| 1325 | 1325 | { |
| 1326 | | sys.video.gfxlayer_pri[0] = data & 0x0003; |
| 1327 | | sys.video.gfxlayer_pri[1] = (data & 0x000c) >> 2; |
| 1328 | | sys.video.gfxlayer_pri[2] = (data & 0x0030) >> 4; |
| 1329 | | sys.video.gfxlayer_pri[3] = (data & 0x00c0) >> 6; |
| 1326 | x68k_sys.video.gfxlayer_pri[0] = data & 0x0003; |
| 1327 | x68k_sys.video.gfxlayer_pri[1] = (data & 0x000c) >> 2; |
| 1328 | x68k_sys.video.gfxlayer_pri[2] = (data & 0x0030) >> 4; |
| 1329 | x68k_sys.video.gfxlayer_pri[3] = (data & 0x00c0) >> 6; |
| 1330 | 1330 | } |
| 1331 | 1331 | if(ACCESSING_BITS_8_15) |
| 1332 | 1332 | { |
| 1333 | | sys.video.gfx_pri = (data & 0x0300) >> 8; |
| 1334 | | sys.video.text_pri = (data & 0x0c00) >> 10; |
| 1335 | | sys.video.sprite_pri = (data & 0x3000) >> 12; |
| 1336 | | if(sys.video.gfx_pri == 3) |
| 1337 | | sys.video.gfx_pri--; |
| 1338 | | if(sys.video.text_pri == 3) |
| 1339 | | sys.video.text_pri--; |
| 1340 | | if(sys.video.sprite_pri == 3) |
| 1341 | | sys.video.sprite_pri--; |
| 1333 | x68k_sys.video.gfx_pri = (data & 0x0300) >> 8; |
| 1334 | x68k_sys.video.text_pri = (data & 0x0c00) >> 10; |
| 1335 | x68k_sys.video.sprite_pri = (data & 0x3000) >> 12; |
| 1336 | if(x68k_sys.video.gfx_pri == 3) |
| 1337 | x68k_sys.video.gfx_pri--; |
| 1338 | if(x68k_sys.video.text_pri == 3) |
| 1339 | x68k_sys.video.text_pri--; |
| 1340 | if(x68k_sys.video.sprite_pri == 3) |
| 1341 | x68k_sys.video.sprite_pri--; |
| 1342 | 1342 | } |
| 1343 | 1343 | break; |
| 1344 | 1344 | case 0x300: |
| 1345 | | COMBINE_DATA(sys.video.reg+2); |
| 1345 | COMBINE_DATA(x68k_sys.video.reg+2); |
| 1346 | 1346 | break; |
| 1347 | 1347 | default: |
| 1348 | 1348 | logerror("VC: Invalid video controller write (offset = 0x%04x, data = %04x)\n",offset,data); |
| r4212 | r4213 | |
| 1352 | 1352 | static READ16_HANDLER( x68k_vid_r ) |
| 1353 | 1353 | { |
| 1354 | 1354 | if(offset < 0x100) |
| 1355 | | return sys.video.gfx_pal[offset]; |
| 1355 | return x68k_sys.video.gfx_pal[offset]; |
| 1356 | 1356 | |
| 1357 | 1357 | if(offset >= 0x100 && offset < 0x200) |
| 1358 | | return sys.video.text_pal[offset-0x100]; |
| 1358 | return x68k_sys.video.text_pal[offset-0x100]; |
| 1359 | 1359 | |
| 1360 | 1360 | switch(offset) |
| 1361 | 1361 | { |
| 1362 | 1362 | case 0x200: |
| 1363 | | return sys.video.reg[0]; |
| 1363 | return x68k_sys.video.reg[0]; |
| 1364 | 1364 | case 0x280: |
| 1365 | | return sys.video.reg[1]; |
| 1365 | return x68k_sys.video.reg[1]; |
| 1366 | 1366 | case 0x300: |
| 1367 | | return sys.video.reg[2]; |
| 1367 | return x68k_sys.video.reg[2]; |
| 1368 | 1368 | default: |
| 1369 | 1369 | logerror("VC: Invalid video controller read (offset = 0x%04x)\n",offset); |
| 1370 | 1370 | } |
| r4212 | r4213 | |
| 1514 | 1514 | { |
| 1515 | 1515 | if(irq == CLEAR_LINE) |
| 1516 | 1516 | { |
| 1517 | | sys.mfp.gpio |= 0x08; |
| 1517 | x68k_sys.mfp.gpio |= 0x08; |
| 1518 | 1518 | } |
| 1519 | 1519 | else |
| 1520 | 1520 | { |
| 1521 | | sys.mfp.gpio &= ~0x08; |
| 1521 | x68k_sys.mfp.gpio &= ~0x08; |
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | static MC68901_GPIO_READ( mfp_gpio_r ) |
| 1526 | 1526 | { |
| 1527 | | UINT8 data = sys.mfp.gpio; |
| 1527 | UINT8 data = x68k_sys.mfp.gpio; |
| 1528 | 1528 | |
| 1529 | | data &= ~(sys.crtc.hblank << 7); |
| 1530 | | data &= ~(sys.crtc.vblank << 4); |
| 1529 | data &= ~(x68k_sys.crtc.hblank << 7); |
| 1530 | data &= ~(x68k_sys.crtc.vblank << 4); |
| 1531 | 1531 | data |= 0x23; // GPIP5 is unused, always 1 |
| 1532 | 1532 | |
| 1533 | | // mc68901_tai_w(mfp, sys.crtc.vblank); |
| 1533 | // mc68901_tai_w(mfp, x68k_sys.crtc.vblank); |
| 1534 | 1534 | |
| 1535 | 1535 | return data; |
| 1536 | 1536 | } |
| r4212 | r4213 | |
| 1540 | 1540 | static int prev; |
| 1541 | 1541 | if(prev == CLEAR_LINE && level == CLEAR_LINE) // eliminate unnecessary calls to set the IRQ line for speed reasons |
| 1542 | 1542 | return; |
| 1543 | | // if((sys.ioc.irqstatus & 0xc0) != 0) // if the FDC is busy, then we don't want to miss that IRQ |
| 1543 | // if((x68k_sys.ioc.irqstatus & 0xc0) != 0) // if the FDC is busy, then we don't want to miss that IRQ |
| 1544 | 1544 | // return; |
| 1545 | 1545 | cpu_set_input_line(device->machine->cpu[0], 6, level); |
| 1546 | 1546 | current_vector[6] = 0; |
| r4212 | r4213 | |
| 1549 | 1549 | |
| 1550 | 1550 | static INTERRUPT_GEN( x68k_vsync_irq ) |
| 1551 | 1551 | { |
| 1552 | | // if(sys.mfp.ierb & 0x40) |
| 1552 | // if(x68k_sys.mfp.ierb & 0x40) |
| 1553 | 1553 | // { |
| 1554 | | // sys.mfp.isrb |= 0x40; |
| 1555 | | // current_vector[6] = (sys.mfp.vr & 0xf0) | 0x06; // GPIP4 (V-DISP) |
| 1554 | // x68k_sys.mfp.isrb |= 0x40; |
| 1555 | // current_vector[6] = (x68k_sys.mfp.vr & 0xf0) | 0x06; // GPIP4 (V-DISP) |
| 1556 | 1556 | // current_irq_line = 6; |
| 1557 | 1557 | // mfp_timer_a_callback(0); // Timer A is usually always in event count mode, and is tied to V-DISP |
| 1558 | 1558 | // mfp_trigger_irq(MFP_IRQ_GPIP4); |
| 1559 | 1559 | // } |
| 1560 | | // if(sys.crtc.height == 256) |
| 1561 | | // video_screen_update_partial(machine->primary_screen,256);//sys.crtc.reg[4]/2); |
| 1560 | // if(x68k_sys.crtc.height == 256) |
| 1561 | // video_screen_update_partial(machine->primary_screen,256);//x68k_sys.crtc.reg[4]/2); |
| 1562 | 1562 | // else |
| 1563 | | // video_screen_update_partial(machine->primary_screen,512);//sys.crtc.reg[4]); |
| 1563 | // video_screen_update_partial(machine->primary_screen,512);//x68k_sys.crtc.reg[4]); |
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | static IRQ_CALLBACK(x68k_int_ack) |
| r4212 | r4213 | |
| 1569 | 1569 | |
| 1570 | 1570 | if(irqline == 6) // MFP |
| 1571 | 1571 | { |
| 1572 | | sys.mfp.current_irq = -1; |
| 1572 | x68k_sys.mfp.current_irq = -1; |
| 1573 | 1573 | if(current_vector[6] != 0x4b && current_vector[6] != 0x4c) |
| 1574 | 1574 | current_vector[6] = mc68901_get_vector(x68k_mfp); |
| 1575 | 1575 | else |
| r4212 | r4213 | |
| 1581 | 1581 | cpu_set_input_line_and_vector(device->machine->cpu[0],irqline,CLEAR_LINE,current_vector[irqline]); |
| 1582 | 1582 | if(irqline == 1) // IOSC |
| 1583 | 1583 | { |
| 1584 | | sys.ioc.irqstatus &= ~0xf0; |
| 1584 | x68k_sys.ioc.irqstatus &= ~0xf0; |
| 1585 | 1585 | } |
| 1586 | 1586 | if(irqline == 5) // SCC |
| 1587 | 1587 | { |
| 1588 | | sys.mouse.irqactive = 0; |
| 1588 | x68k_sys.mouse.irqactive = 0; |
| 1589 | 1589 | } |
| 1590 | 1590 | |
| 1591 | 1591 | logerror("SYS: IRQ acknowledged (vector=0x%02x, line = %i)\n",current_vector[irqline],irqline); |
| r4212 | r4213 | |
| 1595 | 1595 | static ADDRESS_MAP_START(x68k_map, ADDRESS_SPACE_PROGRAM, 16) |
| 1596 | 1596 | // AM_RANGE(0x000000, 0xbfffff) AM_RAMBANK(1) |
| 1597 | 1597 | AM_RANGE(0xbffffc, 0xbfffff) AM_READWRITE(x68k_rom0_r, x68k_rom0_w) |
| 1598 | | // AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE(x68k_gvram_r, x68k_gvram_w) AM_BASE(&gvram) |
| 1599 | | // AM_RANGE(0xe00000, 0xe7ffff) AM_READWRITE(x68k_tvram_r, x68k_tvram_w) AM_BASE(&tvram) |
| 1598 | // AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE(x68k_gvram_r, x68k_gvram_w) AM_BASE(&x68k_gvram) |
| 1599 | // AM_RANGE(0xe00000, 0xe7ffff) AM_READWRITE(x68k_tvram_r, x68k_tvram_w) AM_BASE(&x68k_tvram) |
| 1600 | 1600 | AM_RANGE(0xc00000, 0xdfffff) AM_RAMBANK(2) |
| 1601 | 1601 | AM_RANGE(0xe00000, 0xe7ffff) AM_RAMBANK(3) |
| 1602 | 1602 | AM_RANGE(0xe80000, 0xe81fff) AM_READWRITE(x68k_crtc_r, x68k_crtc_w) |
| r4212 | r4213 | |
| 1620 | 1620 | AM_RANGE(0xeb0000, 0xeb7fff) AM_READWRITE(x68k_spritereg_r, x68k_spritereg_w) |
| 1621 | 1621 | AM_RANGE(0xeb8000, 0xebffff) AM_READWRITE(x68k_spriteram_r, x68k_spriteram_w) |
| 1622 | 1622 | AM_RANGE(0xec0000, 0xecffff) AM_NOP // User I/O |
| 1623 | | // AM_RANGE(0xed0000, 0xed3fff) AM_READWRITE(x68k_sram_r, x68k_sram_w) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size) |
| 1623 | // AM_RANGE(0xed0000, 0xed3fff) AM_READWRITE(sram_r, sram_w) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size) |
| 1624 | 1624 | AM_RANGE(0xed0000, 0xed3fff) AM_RAMBANK(4) AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size) |
| 1625 | 1625 | AM_RANGE(0xed4000, 0xefffff) AM_NOP |
| 1626 | 1626 | AM_RANGE(0xf00000, 0xffffff) AM_ROM |
| r4212 | r4213 | |
| 1927 | 1927 | dimdsk_set_geometry(image); |
| 1928 | 1928 | else |
| 1929 | 1929 | basicdsk_set_geometry(image, 77, 2, 8, 1024, 0x01, 0, FALSE); |
| 1930 | | if(sys.ioc.irqstatus & 0x02) |
| 1930 | if(x68k_sys.ioc.irqstatus & 0x02) |
| 1931 | 1931 | { |
| 1932 | 1932 | current_vector[1] = 0x61; |
| 1933 | | sys.ioc.irqstatus |= 0x40; |
| 1933 | x68k_sys.ioc.irqstatus |= 0x40; |
| 1934 | 1934 | current_irq_line = 1; |
| 1935 | 1935 | cpu_set_input_line_and_vector(image->machine->cpu[0],1,ASSERT_LINE,current_vector[1]); // Disk insert/eject interrupt |
| 1936 | 1936 | logerror("IOC: Disk image inserted\n"); |
| 1937 | 1937 | } |
| 1938 | | sys.fdc.disk_inserted[image_index_in_device(image)] = 1; |
| 1938 | x68k_sys.fdc.disk_inserted[image_index_in_device(image)] = 1; |
| 1939 | 1939 | return INIT_PASS; |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| r4212 | r4213 | |
| 1944 | 1944 | |
| 1945 | 1945 | static DEVICE_IMAGE_UNLOAD( x68k_floppy ) |
| 1946 | 1946 | { |
| 1947 | | if(sys.ioc.irqstatus & 0x02) |
| 1947 | if(x68k_sys.ioc.irqstatus & 0x02) |
| 1948 | 1948 | { |
| 1949 | 1949 | current_vector[1] = 0x61; |
| 1950 | | sys.ioc.irqstatus |= 0x40; |
| 1950 | x68k_sys.ioc.irqstatus |= 0x40; |
| 1951 | 1951 | current_irq_line = 1; |
| 1952 | 1952 | cpu_set_input_line_and_vector(image->machine->cpu[0],1,ASSERT_LINE,current_vector[1]); // Disk insert/eject interrupt |
| 1953 | 1953 | } |
| 1954 | | sys.fdc.disk_inserted[image_index_in_device(image)] = 0; |
| 1954 | x68k_sys.fdc.disk_inserted[image_index_in_device(image)] = 0; |
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | static void x68k_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| r4212 | r4213 | |
| 1999 | 1999 | memcpy(mess_ram,romdata,8); |
| 2000 | 2000 | |
| 2001 | 2001 | // init keyboard |
| 2002 | | sys.keyboard.delay = 500; // 3*100+200 |
| 2003 | | sys.keyboard.repeat = 110; // 4^2*5+30 |
| 2002 | x68k_sys.keyboard.delay = 500; // 3*100+200 |
| 2003 | x68k_sys.keyboard.repeat = 110; // 4^2*5+30 |
| 2004 | 2004 | |
| 2005 | 2005 | // check for disks |
| 2006 | 2006 | for(drive=0;drive<4;drive++) |
| 2007 | 2007 | { |
| 2008 | 2008 | if(image_exists(image_from_devtype_and_index(machine, IO_FLOPPY,drive))) |
| 2009 | | sys.fdc.disk_inserted[drive] = 1; |
| 2009 | x68k_sys.fdc.disk_inserted[drive] = 1; |
| 2010 | 2010 | else |
| 2011 | | sys.fdc.disk_inserted[drive] = 0; |
| 2011 | x68k_sys.fdc.disk_inserted[drive] = 0; |
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | 2014 | // initialise CRTC, set registers to defaults for the standard text mode (768x512) |
| 2015 | | sys.crtc.reg[0] = 137; // Horizontal total (in characters) |
| 2016 | | sys.crtc.reg[1] = 14; // Horizontal sync end |
| 2017 | | sys.crtc.reg[2] = 28; // Horizontal start |
| 2018 | | sys.crtc.reg[3] = 124; // Horizontal end |
| 2019 | | sys.crtc.reg[4] = 567; // Vertical total |
| 2020 | | sys.crtc.reg[5] = 5; // Vertical sync end |
| 2021 | | sys.crtc.reg[6] = 40; // Vertical start |
| 2022 | | sys.crtc.reg[7] = 552; // Vertical end |
| 2023 | | sys.crtc.reg[8] = 27; // Horizontal adjust |
| 2015 | x68k_sys.crtc.reg[0] = 137; // Horizontal total (in characters) |
| 2016 | x68k_sys.crtc.reg[1] = 14; // Horizontal sync end |
| 2017 | x68k_sys.crtc.reg[2] = 28; // Horizontal start |
| 2018 | x68k_sys.crtc.reg[3] = 124; // Horizontal end |
| 2019 | x68k_sys.crtc.reg[4] = 567; // Vertical total |
| 2020 | x68k_sys.crtc.reg[5] = 5; // Vertical sync end |
| 2021 | x68k_sys.crtc.reg[6] = 40; // Vertical start |
| 2022 | x68k_sys.crtc.reg[7] = 552; // Vertical end |
| 2023 | x68k_sys.crtc.reg[8] = 27; // Horizontal adjust |
| 2024 | 2024 | |
| 2025 | 2025 | mfp_init(); |
| 2026 | 2026 | |
| 2027 | | x68k_scanline = video_screen_get_vpos(machine->primary_screen);// = sys.crtc.reg[6]; // Vertical start |
| 2027 | x68k_scanline = video_screen_get_vpos(machine->primary_screen);// = x68k_sys.crtc.reg[6]; // Vertical start |
| 2028 | 2028 | |
| 2029 | 2029 | // start VBlank timer |
| 2030 | | sys.crtc.vblank = 1; |
| 2031 | | irq_time = video_screen_get_time_until_pos(machine->primary_screen,sys.crtc.reg[6],2); |
| 2032 | | timer_adjust_oneshot(vblank_irq, irq_time, 0); |
| 2030 | x68k_sys.crtc.vblank = 1; |
| 2031 | irq_time = video_screen_get_time_until_pos(machine->primary_screen,x68k_sys.crtc.reg[6],2); |
| 2032 | timer_adjust_oneshot(x68k_vblank_irq, irq_time, 0); |
| 2033 | 2033 | |
| 2034 | 2034 | // start HBlank timer |
| 2035 | | timer_adjust_oneshot(scanline_timer, video_screen_get_scan_period(machine->primary_screen), 1); |
| 2035 | timer_adjust_oneshot(x68k_scanline_timer, video_screen_get_scan_period(machine->primary_screen), 1); |
| 2036 | 2036 | |
| 2037 | | sys.mfp.gpio = 0xfb; |
| 2037 | x68k_sys.mfp.gpio = 0xfb; |
| 2038 | 2038 | |
| 2039 | 2039 | // reset output values |
| 2040 | 2040 | output_set_value("key_led_kana",1); |
| r4212 | r4213 | |
| 2065 | 2065 | memory_set_bankptr(machine, 1,mess_ram); |
| 2066 | 2066 | memory_install_read16_handler(space,0xc00000,0xdfffff,0x1fffff,0,(read16_space_func)x68k_gvram_r); |
| 2067 | 2067 | memory_install_write16_handler(space,0xc00000,0xdfffff,0x1fffff,0,(write16_space_func)x68k_gvram_w); |
| 2068 | | memory_set_bankptr(machine, 2,gvram); // so that code in VRAM is executable - needed for Terra Cresta |
| 2068 | memory_set_bankptr(machine, 2,x68k_gvram); // so that code in VRAM is executable - needed for Terra Cresta |
| 2069 | 2069 | memory_install_read16_handler(space,0xe00000,0xe7ffff,0x07ffff,0,(read16_space_func)x68k_tvram_r); |
| 2070 | 2070 | memory_install_write16_handler(space,0xe00000,0xe7ffff,0x07ffff,0,(write16_space_func)x68k_tvram_w); |
| 2071 | | memory_set_bankptr(machine, 3,tvram); // so that code in VRAM is executable - needed for Terra Cresta |
| 2071 | memory_set_bankptr(machine, 3,x68k_tvram); // so that code in VRAM is executable - needed for Terra Cresta |
| 2072 | 2072 | memory_install_read16_handler(space,0xed0000,0xed3fff,0x003fff,0,(read16_space_func)x68k_sram_r); |
| 2073 | 2073 | memory_install_write16_handler(space,0xed0000,0xed3fff,0x003fff,0,(write16_space_func)x68k_sram_w); |
| 2074 | 2074 | memory_set_bankptr(machine, 4,generic_nvram16); // so that code in SRAM is executable, there is an option for booting from SRAM |
| r4212 | r4213 | |
| 2078 | 2078 | |
| 2079 | 2079 | // start mouse timer |
| 2080 | 2080 | timer_adjust_periodic(mouse_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(1)); // a guess for now |
| 2081 | | sys.mouse.inputtype = 0; |
| 2081 | x68k_sys.mouse.inputtype = 0; |
| 2082 | 2082 | |
| 2083 | 2083 | // start LED timer |
| 2084 | 2084 | timer_adjust_periodic(led_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(400)); |
| r4212 | r4213 | |
| 2088 | 2088 | { |
| 2089 | 2089 | unsigned char* rom = memory_region(machine, "main"); |
| 2090 | 2090 | unsigned char* user2 = memory_region(machine, "user2"); |
| 2091 | | gvram = auto_malloc(0x200000); |
| 2092 | | memset(gvram,0,0x200000); |
| 2093 | | tvram = auto_malloc(0x080000); |
| 2094 | | memset(tvram,0,0x80000); |
| 2091 | x68k_gvram = auto_malloc(0x200000); |
| 2092 | memset(x68k_gvram,0,0x200000); |
| 2093 | x68k_tvram = auto_malloc(0x080000); |
| 2094 | memset(x68k_tvram,0,0x80000); |
| 2095 | 2095 | sram = auto_malloc(0x4000); |
| 2096 | 2096 | memset(sram,0,0x4000); |
| 2097 | 2097 | |
| r4212 | r4213 | |
| 2108 | 2108 | // copy last half of BIOS to a user region, to use for inital startup |
| 2109 | 2109 | memcpy(user2,(rom+0xff0000),0x10000); |
| 2110 | 2110 | |
| 2111 | | memset(&sys,0,sizeof(sys)); |
| 2111 | memset(&x68k_sys,0,sizeof(x68k_sys)); |
| 2112 | 2112 | |
| 2113 | 2113 | mfp_init(); |
| 2114 | 2114 | |
| 2115 | 2115 | cpu_set_irq_callback(machine->cpu[0], x68k_int_ack); |
| 2116 | 2116 | |
| 2117 | 2117 | // init keyboard |
| 2118 | | sys.keyboard.delay = 500; // 3*100+200 |
| 2119 | | sys.keyboard.repeat = 110; // 4^2*5+30 |
| 2118 | x68k_sys.keyboard.delay = 500; // 3*100+200 |
| 2119 | x68k_sys.keyboard.repeat = 110; // 4^2*5+30 |
| 2120 | 2120 | kb_timer = timer_alloc(machine, x68k_keyboard_poll,NULL); |
| 2121 | | scanline_timer = timer_alloc(machine, x68k_hsync,NULL); |
| 2122 | | raster_irq = timer_alloc(machine, x68k_crtc_raster_irq,NULL); |
| 2123 | | vblank_irq = timer_alloc(machine, x68k_crtc_vblank_irq,NULL); |
| 2121 | x68k_scanline_timer = timer_alloc(machine, x68k_hsync,NULL); |
| 2122 | x68k_raster_irq = timer_alloc(machine, x68k_crtc_raster_irq,NULL); |
| 2123 | x68k_vblank_irq = timer_alloc(machine, x68k_crtc_vblank_irq,NULL); |
| 2124 | 2124 | mouse_timer = timer_alloc(machine, x68k_scc_ack,NULL); |
| 2125 | 2125 | led_timer = timer_alloc(machine, x68k_led_callback,NULL); |
| 2126 | 2126 | } |
src/mess/drivers/bbc.c
| r4212 | r4213 | |
| 92 | 92 | static ADDRESS_MAP_START(bbca_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 93 | 93 | ADDRESS_MAP_UNMAP_LOW /* Hardware marked with a 1 is not present in a Model A */ |
| 94 | 94 | |
| 95 | | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(SMH_BANK1 , memorya1_w ) /* 0000-3fff Regular Ram */ |
| 96 | | AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK3 , memorya1_w ) /* 4000-7fff Repeat of the Regular Ram */ |
| 95 | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(SMH_BANK1 , bbc_memorya1_w ) /* 0000-3fff Regular Ram */ |
| 96 | AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK3 , bbc_memorya1_w ) /* 4000-7fff Repeat of the Regular Ram */ |
| 97 | 97 | |
| 98 | 98 | AM_RANGE(0x8000, 0xbfff) AM_READWRITE(SMH_BANK4 , SMH_ROM ) /* 8000-bfff Paged ROM */ |
| 99 | 99 | |
| r4212 | r4213 | |
| 106 | 106 | AM_RANGE(0xfe08, 0xfe0f) AM_READWRITE(BBC_6850_r , BBC_6850_w ) /* fe08-fe0f 6850 ACIA Serial Controller */ |
| 107 | 107 | AM_RANGE(0xfe10, 0xfe17) AM_READWRITE(return8_FE , BBC_SerialULA_w ) /* fe10-fe17 Serial ULA Serial system chip */ |
| 108 | 108 | AM_RANGE(0xfe18, 0xfe1f) AM_NOP /* fe18-fe1f INTOFF/STATID 1 ECONET Interrupt Off / ID No. */ |
| 109 | | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE ( videoULA_w ) /* R: fe20-fe2f INTON 1 ECONET Interrupt On */ |
| 109 | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE ( bbc_videoULA_w ) /* R: fe20-fe2f INTON 1 ECONET Interrupt On */ |
| 110 | 110 | /* W: fe20-fe2f Video ULA Video system chip */ |
| 111 | | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , page_selecta_w ) /* R: fe30-fe3f NC Not Connected */ |
| 111 | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , bbc_page_selecta_w ) /* R: fe30-fe3f NC Not Connected */ |
| 112 | 112 | /* W: fe30-fe3f 84LS161 Paged ROM selector */ |
| 113 | 113 | AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE(VIA6522, "via6522_0", via_r, via_w) /* fe40-fe5f 6522 VIA SYSTEM VIA */ |
| 114 | 114 | AM_RANGE(0xfe60, 0xfe7f) AM_NOP /* fe60-fe7f 6522 VIA 1 USER VIA */ |
| r4212 | r4213 | |
| 124 | 124 | static ADDRESS_MAP_START(bbcb_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 125 | 125 | ADDRESS_MAP_UNMAP_LOW |
| 126 | 126 | |
| 127 | | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(SMH_BANK1 , memorya1_w ) /* 0000-3fff Regular Ram */ |
| 128 | | AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK3 , memoryb3_w ) /* 4000-7fff Repeat of the Regular Ram */ |
| 127 | AM_RANGE(0x0000, 0x3fff) AM_READWRITE(SMH_BANK1 , bbc_memorya1_w ) /* 0000-3fff Regular Ram */ |
| 128 | AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK3 , bbc_memoryb3_w ) /* 4000-7fff Repeat of the Regular Ram */ |
| 129 | 129 | |
| 130 | 130 | |
| 131 | | AM_RANGE(0x8000, 0xbfff) AM_READWRITE(SMH_BANK4 , memoryb4_w ) /* 8000-bfff Paged ROM */ |
| 131 | AM_RANGE(0x8000, 0xbfff) AM_READWRITE(SMH_BANK4 , bbc_memoryb4_w ) /* 8000-bfff Paged ROM */ |
| 132 | 132 | |
| 133 | 133 | AM_RANGE(0xc000, 0xfbff) AM_READWRITE(SMH_BANK7 , SMH_ROM ) /* c000-fbff OS ROM */ |
| 134 | 134 | |
| r4212 | r4213 | |
| 139 | 139 | AM_RANGE(0xfe08, 0xfe0f) AM_READWRITE(BBC_6850_r , BBC_6850_w ) /* fe08-fe0f 6850 ACIA Serial Controller */ |
| 140 | 140 | AM_RANGE(0xfe10, 0xfe17) AM_READWRITE(return8_FE , BBC_SerialULA_w ) /* fe10-fe17 Serial ULA Serial system chip */ |
| 141 | 141 | AM_RANGE(0xfe18, 0xfe1f) AM_NOP /* fe18-fe1f INTOFF/STATID ECONET Interrupt Off / ID No. */ |
| 142 | | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE ( videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 142 | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE ( bbc_videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 143 | 143 | /* W: fe20-fe2f Video ULA Video system chip */ |
| 144 | | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , page_selectb_w ) /* R: fe30-fe3f NC Not Connected */ |
| 144 | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , bbc_page_selectb_w ) /* R: fe30-fe3f NC Not Connected */ |
| 145 | 145 | /* W: fe30-fe3f 84LS161 Paged ROM selector */ |
| 146 | 146 | AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE(VIA6522, "via6522_0", via_r, via_w) /* fe40-fe5f 6522 VIA SYSTEM VIA */ |
| 147 | 147 | AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE(VIA6522, "via6522_1", via_r, via_w) /* fe60-fe7f 6522 VIA USER VIA */ |
| r4212 | r4213 | |
| 157 | 157 | static ADDRESS_MAP_START(bbcbp_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 158 | 158 | ADDRESS_MAP_UNMAP_LOW |
| 159 | 159 | |
| 160 | | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , memorybp1_w ) /* 0000-2fff Regular Ram */ |
| 160 | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , bbc_memorybp1_w ) /* 0000-2fff Regular Ram */ |
| 161 | 161 | |
| 162 | | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , memorybp2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 162 | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , bbc_memorybp2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 163 | 163 | |
| 164 | | AM_RANGE(0x8000, 0xafff) AM_READWRITE(SMH_BANK4 , memorybp4_w ) /* 8000-afff Paged ROM or 12K of RAM */ |
| 164 | AM_RANGE(0x8000, 0xafff) AM_READWRITE(SMH_BANK4 , bbc_memorybp4_w ) /* 8000-afff Paged ROM or 12K of RAM */ |
| 165 | 165 | AM_RANGE(0xb000, 0xbfff) AM_READWRITE(SMH_BANK6 , SMH_ROM ) /* b000-bfff Rest of paged ROM area */ |
| 166 | 166 | |
| 167 | 167 | AM_RANGE(0xc000, 0xfbff) AM_READWRITE(SMH_BANK7 , SMH_ROM ) /* c000-fbff OS ROM */ |
| r4212 | r4213 | |
| 173 | 173 | AM_RANGE(0xfe08, 0xfe0f) AM_READWRITE(BBC_6850_r , BBC_6850_w ) /* fe08-fe0f 6850 ACIA Serial Controller */ |
| 174 | 174 | AM_RANGE(0xfe10, 0xfe17) AM_READWRITE(return8_FE , BBC_SerialULA_w ) /* fe10-fe17 Serial ULA Serial system chip */ |
| 175 | 175 | AM_RANGE(0xfe18, 0xfe1f) AM_NOP /* fe18-fe1f INTOFF/STATID ECONET Interrupt Off / ID No. */ |
| 176 | | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE (videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 176 | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE (bbc_videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 177 | 177 | /* W: fe20-fe2f Video ULA Video system chip */ |
| 178 | | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , page_selectbp_w ) /* R: fe30-fe3f NC Not Connected */ |
| 178 | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , bbc_page_selectbp_w ) /* R: fe30-fe3f NC Not Connected */ |
| 179 | 179 | /* W: fe30-fe3f 84LS161 Paged ROM selector */ |
| 180 | 180 | AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE(VIA6522, "via6522_0", via_r, via_w) /* fe40-fe5f 6522 VIA SYSTEM VIA */ |
| 181 | 181 | AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE(VIA6522, "via6522_1", via_r, via_w) /* fe60-fe7f 6522 VIA USER VIA */ |
| r4212 | r4213 | |
| 192 | 192 | static ADDRESS_MAP_START(bbcbp128_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 193 | 193 | ADDRESS_MAP_UNMAP_LOW |
| 194 | 194 | |
| 195 | | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , memorybp1_w ) /* 0000-2fff Regular Ram */ |
| 195 | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , bbc_memorybp1_w ) /* 0000-2fff Regular Ram */ |
| 196 | 196 | |
| 197 | | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , memorybp2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 197 | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , bbc_memorybp2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 198 | 198 | |
| 199 | | AM_RANGE(0x8000, 0xafff) AM_READWRITE(SMH_BANK4 , memorybp4_128_w ) /* 8000-afff Paged ROM or 12K of RAM */ |
| 200 | | AM_RANGE(0xb000, 0xbfff) AM_READWRITE(SMH_BANK6 , memorybp6_128_w ) /* b000-bfff Rest of paged ROM area */ |
| 199 | AM_RANGE(0x8000, 0xafff) AM_READWRITE(SMH_BANK4 , bbc_memorybp4_128_w ) /* 8000-afff Paged ROM or 12K of RAM */ |
| 200 | AM_RANGE(0xb000, 0xbfff) AM_READWRITE(SMH_BANK6 , bbc_memorybp6_128_w ) /* b000-bfff Rest of paged ROM area */ |
| 201 | 201 | |
| 202 | 202 | AM_RANGE(0xc000, 0xfbff) AM_READWRITE(SMH_BANK7 , SMH_ROM ) /* c000-fbff OS ROM */ |
| 203 | 203 | |
| r4212 | r4213 | |
| 209 | 209 | AM_RANGE(0xfe10, 0xfe17) AM_READWRITE(return8_FE , BBC_SerialULA_w ) /* fe10-fe17 Serial ULA Serial system chip */ |
| 210 | 210 | AM_RANGE(0xfe10, 0xfe17) AM_NOP /* fe10-fe17 Serial ULA Serial system chip */ |
| 211 | 211 | AM_RANGE(0xfe18, 0xfe1f) AM_NOP /* fe18-fe1f INTOFF/STATID ECONET Interrupt Off / ID No. */ |
| 212 | | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE (videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 212 | AM_RANGE(0xfe20, 0xfe2f) AM_WRITE (bbc_videoULA_w ) /* R: fe20-fe2f INTON ECONET Interrupt On */ |
| 213 | 213 | /* W: fe20-fe2f Video ULA Video system chip */ |
| 214 | | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , page_selectbp_w ) /* R: fe30-fe3f NC Not Connected */ |
| 214 | AM_RANGE(0xfe30, 0xfe3f) AM_READWRITE(return8_FE , bbc_page_selectbp_w ) /* R: fe30-fe3f NC Not Connected */ |
| 215 | 215 | /* W: fe30-fe3f 84LS161 Paged ROM selector */ |
| 216 | 216 | AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE(VIA6522, "via6522_0", via_r, via_w) /* fe40-fe5f 6522 VIA SYSTEM VIA */ |
| 217 | 217 | AM_RANGE(0xfe60, 0xfe7f) AM_DEVREADWRITE(VIA6522, "via6522_1", via_r, via_w) /* fe60-fe7f 6522 VIA USER VIA */ |
| r4212 | r4213 | |
| 251 | 251 | |
| 252 | 252 | static ADDRESS_MAP_START(bbcm_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 253 | 253 | |
| 254 | | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , memorybm1_w ) /* 0000-2fff Regular Ram */ |
| 254 | AM_RANGE(0x0000, 0x2fff) AM_READWRITE(SMH_BANK1 , bbc_memorybm1_w ) /* 0000-2fff Regular Ram */ |
| 255 | 255 | |
| 256 | | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , memorybm2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 256 | AM_RANGE(0x3000, 0x7fff) AM_READWRITE(SMH_BANK2 , bbc_memorybm2_w ) /* 3000-7fff Video/Shadow Ram */ |
| 257 | 257 | |
| 258 | | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(SMH_BANK4 , memorybm4_w ) /* 8000-8fff Paged ROM/RAM or 4K of RAM ANDY */ |
| 259 | | AM_RANGE(0x9000, 0xbfff) AM_READWRITE(SMH_BANK5 , memorybm5_w ) /* 9000-bfff Rest of paged ROM/RAM area */ |
| 258 | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(SMH_BANK4 , bbc_memorybm4_w ) /* 8000-8fff Paged ROM/RAM or 4K of RAM ANDY */ |
| 259 | AM_RANGE(0x9000, 0xbfff) AM_READWRITE(SMH_BANK5 , bbc_memorybm5_w ) /* 9000-bfff Rest of paged ROM/RAM area */ |
| 260 | 260 | |
| 261 | | AM_RANGE(0xc000, 0xdfff) AM_READWRITE(SMH_BANK7 , memorybm7_w ) /* c000-dfff OS ROM or 8K of RAM HAZEL */ |
| 261 | AM_RANGE(0xc000, 0xdfff) AM_READWRITE(SMH_BANK7 , bbc_memorybm7_w ) /* c000-dfff OS ROM or 8K of RAM HAZEL */ |
| 262 | 262 | AM_RANGE(0xe000, 0xfbff) AM_ROM AM_REGION("user1", 0x42000) /* e000-fbff OS ROM */ |
| 263 | 263 | |
| 264 | 264 | AM_RANGE(0xfc00, 0xfeff) AM_READWRITE(SMH_BANK8 , bbcm_w ) /* this is now processed directly because it can be ROM or hardware */ |
| r4212 | r4213 | |
| 272 | 272 | AM_RANGE(0xfe08, 0xfe0f) AM_READWRITE(BBC_6850_r , BBC_6850_w ) fe08-fe0f 6850 ACIA Serial Controller |
| 273 | 273 | AM_RANGE(0xfe10, 0xfe17) AM_NOP fe10-fe17 Serial ULA Serial system chip |
| 274 | 274 | AM_RANGE(0xfe18, 0xfe1f) M_DEVREADWRITE(UPD7002, "uPD7002",uPD7002_r, uPD7002_w ) fec0-fedf uPD7002 Analogue to digital converter |
| 275 | | AM_RANGE(0xfe20, 0xfe23) AM_READWRITE(return8_FE , videoULA_w ) fe20-fe23 Video ULA Video system chip |
| 275 | AM_RANGE(0xfe20, 0xfe23) AM_READWRITE(return8_FE , bbc_videoULA_w ) fe20-fe23 Video ULA Video system chip |
| 276 | 276 | AM_RANGE(0xfe24, 0xfe27) AM_READWRITE(bbcm_wd1770l_read , bbcm_wd1770l_write) fe24-fe27 1770 Latch 1770 Control Latch |
| 277 | 277 | AM_RANGE(0xfe28, 0xfe2f) AM_READWRITE(bbcm_wd1770_read , bbcm_wd1770_write ) fe28-fe2f 1770 FDC Floppy disc controller |
| 278 | | AM_RANGE(0xfe30, 0xfe33) AM_READWRITE(return8_FE , page_selectbp_w ) fe30-fe33 84LS161 Paged ROM selector |
| 278 | AM_RANGE(0xfe30, 0xfe33) AM_READWRITE(return8_FE , bbc_page_selectbp_w ) fe30-fe33 84LS161 Paged ROM selector |
| 279 | 279 | AM_RANGE(0xfe34, 0xfe37) AM_READWRITE(bbcm_ACCCON_read , bbcm_ACCCON_write ) fe34-fe37 ACCCON ACCCON select Latch |
| 280 | 280 | AM_RANGE(0xfe38, 0xfe3f) AM_READ (return8_FE ) fe38-fe3f NC |
| 281 | 281 | AM_RANGE(0xfe40, 0xfe5f) AM_DEVREADWRITE(VIA6522, "via6522_0", via_r, via_w) fe40-fe5f 6522 VIA SYSTEM VIA |