trunk/src/mess/drivers/pet.c
| r21319 | r21320 | |
| 198 | 198 | { |
| 199 | 199 | if (m_speaker) |
| 200 | 200 | { |
| 201 | | speaker_level_w(m_speaker, !(m_via_cb2 || m_pia1_pa7)); |
| 201 | speaker_level_w(m_speaker, !(m_via_cb2 || m_pia1_pa7)); |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| r21319 | r21320 | |
| 216 | 216 | switch (sel) |
| 217 | 217 | { |
| 218 | 218 | case SEL0: case SEL1: case SEL2: case SEL3: case SEL4: case SEL5: case SEL6: case SEL7: |
| 219 | | if (offset < m_ram->size()) |
| 220 | | { |
| 221 | | data = m_ram->pointer()[offset]; |
| 222 | | } |
| 223 | | break; |
| 219 | if (offset < m_ram->size()) |
| 220 | { |
| 221 | data = m_ram->pointer()[offset]; |
| 222 | } |
| 223 | break; |
| 224 | 224 | |
| 225 | 225 | case SEL8: |
| 226 | | data = m_video_ram[offset & (m_video_ram_size - 1)]; |
| 227 | | break; |
| 226 | data = m_video_ram[offset & (m_video_ram_size - 1)]; |
| 227 | break; |
| 228 | 228 | |
| 229 | 229 | case SEL9: case SELA: case SELB: case SELC: case SELD: case SELF: |
| 230 | | if (norom) |
| 231 | | { |
| 232 | | data = m_rom->base()[offset - 0x9000]; |
| 233 | | } |
| 234 | | break; |
| 230 | if (norom) |
| 231 | { |
| 232 | data = m_rom->base()[offset - 0x9000]; |
| 233 | } |
| 234 | break; |
| 235 | 235 | |
| 236 | 236 | case SELE: |
| 237 | | if (BIT(offset, 11)) |
| 238 | | { |
| 239 | | if (BIT(offset, 4)) |
| 237 | if (BIT(offset, 11)) |
| 240 | 238 | { |
| 241 | | data = m_pia1->read(space, offset & 0x03); |
| 239 | if (BIT(offset, 4)) |
| 240 | { |
| 241 | data = m_pia1->read(space, offset & 0x03); |
| 242 | } |
| 243 | if (BIT(offset, 5)) |
| 244 | { |
| 245 | data = m_pia2->read(space, offset & 0x03); |
| 246 | } |
| 247 | if (BIT(offset, 6)) |
| 248 | { |
| 249 | data = m_via->read(space, offset & 0x0f); |
| 250 | } |
| 251 | if (m_crtc && BIT(offset, 7) && BIT(offset, 0)) |
| 252 | { |
| 253 | data = m_crtc->register_r(space, 0); |
| 254 | } |
| 242 | 255 | } |
| 243 | | if (BIT(offset, 5)) |
| 256 | else if (norom) |
| 244 | 257 | { |
| 245 | | data = m_pia2->read(space, offset & 0x03); |
| 258 | data = m_rom->base()[offset - 0x9000]; |
| 246 | 259 | } |
| 247 | | if (BIT(offset, 6)) |
| 248 | | { |
| 249 | | data = m_via->read(space, offset & 0x0f); |
| 250 | | } |
| 251 | | if (m_crtc && BIT(offset, 7) && BIT(offset, 0)) |
| 252 | | { |
| 253 | | data = m_crtc->register_r(space, 0); |
| 254 | | } |
| 260 | break; |
| 255 | 261 | } |
| 256 | | else if (norom) |
| 257 | | { |
| 258 | | data = m_rom->base()[offset - 0x9000]; |
| 259 | | } |
| 260 | | break; |
| 261 | | } |
| 262 | 262 | |
| 263 | 263 | return m_exp->read(space, offset, data, sel); |
| 264 | 264 | } |
| r21319 | r21320 | |
| 271 | 271 | WRITE8_MEMBER( pet_state::write ) |
| 272 | 272 | { |
| 273 | 273 | int sel = offset >> 12; |
| 274 | int norom = m_exp->norom_r(space, offset, sel); |
| 274 | 275 | |
| 275 | 276 | switch (sel) |
| 276 | 277 | { |
| 277 | 278 | case SEL0: case SEL1: case SEL2: case SEL3: case SEL4: case SEL5: case SEL6: case SEL7: |
| 278 | | if (offset < m_ram->size()) |
| 279 | | { |
| 280 | | m_ram->pointer()[offset] = data; |
| 281 | | } |
| 282 | | break; |
| 279 | if (offset < m_ram->size()) |
| 280 | { |
| 281 | m_ram->pointer()[offset] = data; |
| 282 | } |
| 283 | break; |
| 283 | 284 | |
| 284 | 285 | case SEL8: |
| 285 | | m_video_ram[offset & (m_video_ram_size - 1)] = data; |
| 286 | | break; |
| 286 | m_video_ram[offset & (m_video_ram_size - 1)] = data; |
| 287 | break; |
| 287 | 288 | |
| 288 | 289 | case SELE: |
| 289 | | if (BIT(offset, 11)) |
| 290 | | { |
| 291 | | if (BIT(offset, 4)) |
| 290 | if (BIT(offset, 11)) |
| 292 | 291 | { |
| 293 | | m_pia1->write(space, offset & 0x03, data); |
| 292 | if (BIT(offset, 4)) |
| 293 | { |
| 294 | m_pia1->write(space, offset & 0x03, data); |
| 295 | } |
| 296 | if (BIT(offset, 5)) |
| 297 | { |
| 298 | m_pia2->write(space, offset & 0x03, data); |
| 299 | } |
| 300 | if (BIT(offset, 6)) |
| 301 | { |
| 302 | m_via->write(space, offset & 0x0f, data); |
| 303 | } |
| 304 | if (m_crtc && BIT(offset, 7)) |
| 305 | { |
| 306 | if (BIT(offset, 0)) |
| 307 | { |
| 308 | m_crtc->register_w(space, 0, data); |
| 309 | } |
| 310 | else |
| 311 | { |
| 312 | m_crtc->address_w(space, 0, data); |
| 313 | } |
| 314 | } |
| 294 | 315 | } |
| 295 | | if (BIT(offset, 5)) |
| 296 | | { |
| 297 | | m_pia2->write(space, offset & 0x03, data); |
| 298 | | } |
| 299 | | if (BIT(offset, 6)) |
| 300 | | { |
| 301 | | m_via->write(space, offset & 0x0f, data); |
| 302 | | } |
| 303 | | if (m_crtc && BIT(offset, 7)) |
| 304 | | { |
| 305 | | if (BIT(offset, 0)) |
| 306 | | { |
| 307 | | m_crtc->register_w(space, 0, data); |
| 308 | | } |
| 309 | | else |
| 310 | | { |
| 311 | | m_crtc->address_w(space, 0, data); |
| 312 | | } |
| 313 | | } |
| 316 | break; |
| 314 | 317 | } |
| 315 | | break; |
| 316 | | } |
| 317 | 318 | |
| 318 | 319 | m_exp->write(space, offset, data, sel); |
| 319 | 320 | } |
| r21319 | r21320 | |
| 918 | 919 | { |
| 919 | 920 | for (int y = 0; y < 200; y++) |
| 920 | 921 | { |
| 921 | | for (int sx = 0; sx < 40; sx++) |
| 922 | | { |
| 923 | | int sy = y / 8; |
| 924 | | offs_t video_addr = (sy * 40) + sx; |
| 925 | | UINT8 lsd = m_video_ram[video_addr]; |
| 922 | for (int sx = 0; sx < 40; sx++) |
| 923 | { |
| 924 | int sy = y / 8; |
| 925 | offs_t video_addr = (sy * 40) + sx; |
| 926 | UINT8 lsd = m_video_ram[video_addr]; |
| 926 | 927 | |
| 927 | | int ra = y & 0x07; |
| 928 | | offs_t char_addr = (m_graphic << 10) | ((lsd & 0x7f) << 3) | ra; |
| 929 | | UINT8 data = m_char_rom->base()[char_addr]; |
| 928 | int ra = y & 0x07; |
| 929 | offs_t char_addr = (m_graphic << 10) | ((lsd & 0x7f) << 3) | ra; |
| 930 | UINT8 data = m_char_rom->base()[char_addr]; |
| 930 | 931 | |
| 931 | | for (int x = 0; x < 8; x++, data <<= 1) |
| 932 | | { |
| 933 | | int color = (BIT(data, 7) ^ BIT(lsd, 7)) && m_blanktv; |
| 934 | | bitmap.pix32(y, (sx * 8) + x) = RGB_MONOCHROME_GREEN[color]; |
| 932 | for (int x = 0; x < 8; x++, data <<= 1) |
| 933 | { |
| 934 | int color = (BIT(data, 7) ^ BIT(lsd, 7)) && m_blanktv; |
| 935 | bitmap.pix32(y, (sx * 8) + x) = RGB_MONOCHROME_GREEN[color]; |
| 936 | } |
| 935 | 937 | } |
| 936 | 938 | } |
| 937 | | } |
| 938 | 939 | |
| 939 | 940 | return 0; |
| 940 | 941 | } |
| r21319 | r21320 | |
| 952 | 953 | |
| 953 | 954 | for (int column = 0; column < x_count; column++) |
| 954 | 955 | { |
| 955 | | UINT8 lsd = 0, data = 0; |
| 956 | | UINT8 rra = ra & 0x07; |
| 957 | | int no_row = !(BIT(ra, 3) || BIT(ra, 4)); |
| 958 | | int invert = BIT(ma, 12); |
| 959 | | int chr_option = BIT(ma, 13); |
| 956 | UINT8 lsd = 0, data = 0; |
| 957 | UINT8 rra = ra & 0x07; |
| 958 | int no_row = !(BIT(ra, 3) || BIT(ra, 4)); |
| 959 | int invert = BIT(ma, 12); |
| 960 | int chr_option = BIT(ma, 13); |
| 960 | 961 | |
| 961 | | // even character |
| 962 | // even character |
| 962 | 963 | |
| 963 | | lsd = state->m_video_ram[((ma + column) << 1) & 0x7ff]; |
| 964 | lsd = state->m_video_ram[((ma + column) << 1) & 0x7ff]; |
| 964 | 965 | |
| 965 | | offs_t char_addr = (chr_option << 11) | (state->m_graphic << 10) | ((lsd & 0x7f) << 3) | rra; |
| 966 | | data = state->m_char_rom->base()[char_addr & char_rom_mask]; |
| 966 | offs_t char_addr = (chr_option << 11) | (state->m_graphic << 10) | ((lsd & 0x7f) << 3) | rra; |
| 967 | data = state->m_char_rom->base()[char_addr & char_rom_mask]; |
| 967 | 968 | |
| 968 | | for (int bit = 0; bit < 8; bit++, data <<= 1) |
| 969 | | { |
| 970 | | int video = !((BIT(data, 7) ^ BIT(lsd, 7)) && no_row) ^ invert; |
| 971 | | bitmap.pix32(y, x++) = RGB_MONOCHROME_GREEN[video]; |
| 972 | | } |
| 969 | for (int bit = 0; bit < 8; bit++, data <<= 1) |
| 970 | { |
| 971 | int video = !((BIT(data, 7) ^ BIT(lsd, 7)) && no_row) ^ invert; |
| 972 | bitmap.pix32(y, x++) = RGB_MONOCHROME_GREEN[video]; |
| 973 | } |
| 973 | 974 | |
| 974 | | // odd character |
| 975 | // odd character |
| 975 | 976 | |
| 976 | | lsd = state->m_video_ram[(((ma + column) << 1) + 1) & 0x7ff]; |
| 977 | lsd = state->m_video_ram[(((ma + column) << 1) + 1) & 0x7ff]; |
| 977 | 978 | |
| 978 | | char_addr = (chr_option << 11) | (state->m_graphic << 10) | ((lsd & 0x7f) << 3) | rra; |
| 979 | | data = state->m_char_rom->base()[char_addr & char_rom_mask]; |
| 979 | char_addr = (chr_option << 11) | (state->m_graphic << 10) | ((lsd & 0x7f) << 3) | rra; |
| 980 | data = state->m_char_rom->base()[char_addr & char_rom_mask]; |
| 980 | 981 | |
| 981 | | for (int bit = 0; bit < 8; bit++, data <<= 1) |
| 982 | | { |
| 983 | | int video = !((BIT(data, 7) ^ BIT(lsd, 7)) && no_row) ^ invert; |
| 984 | | bitmap.pix32(y, x++) = RGB_MONOCHROME_GREEN[video]; |
| 982 | for (int bit = 0; bit < 8; bit++, data <<= 1) |
| 983 | { |
| 984 | int video = !((BIT(data, 7) ^ BIT(lsd, 7)) && no_row) ^ invert; |
| 985 | bitmap.pix32(y, x++) = RGB_MONOCHROME_GREEN[video]; |
| 986 | } |
| 985 | 987 | } |
| 986 | | } |
| 987 | 988 | } |
| 988 | 989 | |
| 989 | 990 | static MC6845_INTERFACE( crtc_intf ) |
| r21319 | r21320 | |
| 1021 | 1022 | |
| 1022 | 1023 | for (offs_t offset = 0; offset < m_ram->size(); offset++) |
| 1023 | 1024 | { |
| 1024 | | m_ram->pointer()[offset] = data; |
| 1025 | | if (!(offset % 64)) data ^= 0xff; |
| 1025 | m_ram->pointer()[offset] = data; |
| 1026 | if (!(offset % 64)) data ^= 0xff; |
| 1026 | 1027 | } |
| 1027 | 1028 | |
| 1028 | 1029 | data = 0xff; |
| 1029 | 1030 | |
| 1030 | 1031 | for (offs_t offset = 0; offset < m_video_ram_size; offset++) |
| 1031 | 1032 | { |
| 1032 | | m_video_ram[offset] = data; |
| 1033 | | if (!(offset % 64)) data ^= 0xff; |
| 1033 | m_video_ram[offset] = data; |
| 1034 | if (!(offset % 64)) data ^= 0xff; |
| 1034 | 1035 | } |
| 1035 | 1036 | |
| 1036 | 1037 | // state saving |