src/mess/video/vic4567.c
| r3879 | r3880 | |
| 46 | 46 | vic3.palette_dirty=1; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | | void vic4567_init (running_machine *machine, int pal, int (*dma_read) (int), |
| 50 | | int (*dma_read_color) (int), void (*irq) (int), |
| 49 | void vic4567_init(running_machine *machine, int pal, int (*dma_read)(running_machine *, int), |
| 50 | int (*dma_read_color)(running_machine *, int), void (*irq) (int), |
| 51 | 51 | void (*param_port_changed)(int)) |
| 52 | 52 | { |
| 53 | 53 | memset(&vic2, 0, sizeof(vic2)); |
| r3879 | r3880 | |
| 259 | 259 | |
| 260 | 260 | for (xoff = vic2.x_begin + XPOS; xoff < x_end2 + XPOS; xoff += 8, offs++) |
| 261 | 261 | { |
| 262 | | ch = vic2.dma_read (vic2.videoaddr + offs); |
| 263 | | attr = vic2.dma_read_color (vic2.videoaddr + offs); |
| 262 | ch = vic2.dma_read(machine, vic2.videoaddr + offs); |
| 263 | attr = vic2.dma_read_color(machine, vic2.videoaddr + offs); |
| 264 | 264 | if (HIRESON) |
| 265 | 265 | { |
| 266 | 266 | vic2.bitmapmulti[1] = vic2.c64_bitmap[1] = ch >> 4; |
| r3879 | r3880 | |
| 268 | 268 | if (MULTICOLORON) |
| 269 | 269 | { |
| 270 | 270 | vic2.bitmapmulti[3] = attr; |
| 271 | | vic2_draw_bitmap_multi (ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 271 | vic2_draw_bitmap_multi(machine, ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 272 | 272 | } |
| 273 | 273 | else |
| 274 | 274 | { |
| 275 | | vic2_draw_bitmap (ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 275 | vic2_draw_bitmap(machine, ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | else if (ECMON) |
| r3879 | r3880 | |
| 280 | 280 | ecm = ch >> 6; |
| 281 | 281 | vic2.ecmcolor[0] = vic2.colors[ecm]; |
| 282 | 282 | vic2.ecmcolor[1] = attr; |
| 283 | | vic2_draw_character (ybegin, yend, ch & ~0xC0, yoff, xoff, vic2.ecmcolor, start_x, end_x); |
| 283 | vic2_draw_character(machine, ybegin, yend, ch & ~0xC0, yoff, xoff, vic2.ecmcolor, start_x, end_x); |
| 284 | 284 | } |
| 285 | 285 | else if (MULTICOLORON && (attr & 8)) |
| 286 | 286 | { |
| 287 | 287 | vic2.multi[3] = attr & 7; |
| 288 | | vic2_draw_character_multi (ybegin, yend, ch, yoff, xoff, start_x, end_x); |
| 288 | vic2_draw_character_multi(machine, ybegin, yend, ch, yoff, xoff, start_x, end_x); |
| 289 | 289 | } |
| 290 | 290 | else |
| 291 | 291 | { |
| 292 | 292 | vic2.mono[1] = attr; |
| 293 | | vic2_draw_character (ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x); |
| 293 | vic2_draw_character(machine, ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x); |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | /* sprite priority, sprite overwrites lowerprior pixels */ |
src/mess/video/vic6567.c
| r3879 | r3880 | |
| 195 | 195 | int vic3; |
| 196 | 196 | int on; /* rastering of the screen */ |
| 197 | 197 | |
| 198 | | int (*dma_read) (int); |
| 199 | | int (*dma_read_color) (int); |
| 198 | int (*dma_read)(running_machine *, int); |
| 199 | int (*dma_read_color)(running_machine *, int); |
| 200 | 200 | void (*interrupt) (int); |
| 201 | 201 | void (*port_changed)(int); |
| 202 | 202 | |
| r3879 | r3880 | |
| 264 | 264 | static void vic2_drawlines (running_machine *machine, int first, int last, int start_x, int end_x); |
| 265 | 265 | |
| 266 | 266 | void vic6567_init (int chip_vic2e, int pal, |
| 267 | | int (*dma_read) (int), int (*dma_read_color) (int), |
| 267 | int (*dma_read) (running_machine *, int), int (*dma_read_color) (running_machine *, int), |
| 268 | 268 | void (*irq) (int)) |
| 269 | 269 | { |
| 270 | 270 | memset(&vic2, 0, sizeof(vic2)); |
| r3879 | r3880 | |
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | | static void vic2_draw_character (int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color, int start_x, int end_x) |
| 798 | static void vic2_draw_character (running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff, UINT16 *color, int start_x, int end_x) |
| 799 | 799 | { |
| 800 | 800 | int y, code; |
| 801 | 801 | |
| 802 | 802 | for (y = ybegin; y <= yend; y++) |
| 803 | 803 | { |
| 804 | | code = vic2.dma_read (vic2.chargenaddr + ch * 8 + y); |
| 804 | code = vic2.dma_read(machine, vic2.chargenaddr + ch * 8 + y); |
| 805 | 805 | vic2.screen[y + yoff][xoff >> 3] = code; |
| 806 | 806 | if ((xoff + 0 > start_x) && (xoff + 0 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 0) = color[code >> 7]; |
| 807 | 807 | if ((xoff + 1 > start_x) && (xoff + 0 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 1) = color[(code >> 6) & 1]; |
| r3879 | r3880 | |
| 814 | 814 | } |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | | static void vic2_draw_character_multi (int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x ) |
| 817 | static void vic2_draw_character_multi(running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x ) |
| 818 | 818 | { |
| 819 | 819 | int y, code; |
| 820 | 820 | |
| 821 | 821 | for (y = ybegin; y <= yend; y++) |
| 822 | 822 | { |
| 823 | | code = vic2.dma_read (vic2.chargenaddr + ch * 8 + y); |
| 823 | code = vic2.dma_read(machine, vic2.chargenaddr + ch * 8 + y); |
| 824 | 824 | vic2.screen[y + yoff][xoff >> 3] = vic2.foreground[code]; |
| 825 | 825 | if ((xoff + 0 > start_x) && (xoff + 0 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 0) = vic2.multi[code >> 6]; |
| 826 | 826 | if ((xoff + 1 > start_x) && (xoff + 1 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 1) = vic2.multi[code >> 6]; |
| r3879 | r3880 | |
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | | static void vic2_draw_bitmap (int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x) |
| 836 | static void vic2_draw_bitmap(running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x) |
| 837 | 837 | { |
| 838 | 838 | int y, code; |
| 839 | 839 | |
| 840 | 840 | for (y = ybegin; y <= yend; y++) |
| 841 | 841 | { |
| 842 | | code = vic2.dma_read ((vic2.chargenaddr&0x2000) + ch * 8 + y); |
| 842 | code = vic2.dma_read(machine, (vic2.chargenaddr&0x2000) + ch * 8 + y); |
| 843 | 843 | vic2.screen[y + yoff][xoff >> 3] = code; |
| 844 | 844 | if ((xoff + 0 > start_x) && (xoff + 0 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 0) = vic2.c64_bitmap[code >> 7]; |
| 845 | 845 | if ((xoff + 1 > start_x) && (xoff + 1 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 1) = vic2.c64_bitmap[(code >> 6) & 1]; |
| r3879 | r3880 | |
| 852 | 852 | } |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | | static void vic2_draw_bitmap_multi (int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x) |
| 855 | static void vic2_draw_bitmap_multi(running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff, int start_x, int end_x) |
| 856 | 856 | { |
| 857 | 857 | int y, code; |
| 858 | 858 | |
| 859 | 859 | for (y = ybegin; y <= yend; y++) |
| 860 | 860 | { |
| 861 | | code = vic2.dma_read ((vic2.chargenaddr&0x2000) + ch * 8 + y); |
| 861 | code = vic2.dma_read(machine, (vic2.chargenaddr&0x2000) + ch * 8 + y); |
| 862 | 862 | vic2.screen[y + yoff][xoff >> 3] = vic2.foreground[code]; |
| 863 | 863 | if ((xoff + 0 > start_x) && (xoff + 0 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 0) = vic2.bitmapmulti[code >> 6]; |
| 864 | 864 | if ((xoff + 1 > start_x) && (xoff + 1 < end_x)) *BITMAP_ADDR16(vic2.bitmap, y + yoff + FIRSTLINE, xoff + 1) = vic2.bitmapmulti[code >> 6]; |
| r3879 | r3880 | |
| 959 | 959 | int value, value2, value3 = 0, bg, color[2]; |
| 960 | 960 | |
| 961 | 961 | xbegin = SPRITE_X_POS (nr); |
| 962 | | addr = vic2.dma_read (SPRITE_ADDR (nr)) << 6; |
| 962 | addr = vic2.dma_read(machine, SPRITE_ADDR (nr)) << 6; |
| 963 | 963 | vic2.spritemulti[2] = SPRITE_COLOR (nr); |
| 964 | 964 | prior = SPRITE_PRIORITY (nr); |
| 965 | 965 | collision = SPRITE_BG_COLLISION (nr); |
| r3879 | r3880 | |
| 973 | 973 | vic2.sprites[nr].paintedline[y] = 1; |
| 974 | 974 | for (i = 0; i < 3; i++) |
| 975 | 975 | { |
| 976 | | value = vic2.expandx_multi[bg = vic2.dma_read (addr + vic2.sprites[nr].line * 3 + i)]; |
| 976 | value = vic2.expandx_multi[bg = vic2.dma_read(machine, addr + vic2.sprites[nr].line * 3 + i)]; |
| 977 | 977 | value2 = vic2.expandx[vic2.multi_collision[bg]]; |
| 978 | 978 | vic2.sprites[nr].bitmap[y][i*2] = value2 >> 8; |
| 979 | 979 | vic2.sprites[nr].bitmap[y][i*2+1] = value2 & 0xff; |
| r3879 | r3880 | |
| 1024 | 1024 | vic2.sprites[nr].paintedline[y] = 1; |
| 1025 | 1025 | for (i = 0; i < 3; i++) |
| 1026 | 1026 | { |
| 1027 | | value = vic2.dma_read (addr + vic2.sprites[nr].line * 3 + i); |
| 1027 | value = vic2.dma_read(machine, addr + vic2.sprites[nr].line * 3 + i); |
| 1028 | 1028 | vic2.sprites[nr].bitmap[y][i] = |
| 1029 | 1029 | value2 = vic2.multi_collision[value]; |
| 1030 | 1030 | vic2_sprite_collision(machine, nr, y, xbegin + i * 8, value2); |
| r3879 | r3880 | |
| 1072 | 1072 | int value, value3 = 0; |
| 1073 | 1073 | |
| 1074 | 1074 | xbegin = SPRITE_X_POS (nr); |
| 1075 | | addr = vic2.dma_read (SPRITE_ADDR (nr)) << 6; |
| 1075 | addr = vic2.dma_read(machine, SPRITE_ADDR (nr)) << 6; |
| 1076 | 1076 | color = SPRITE_COLOR (nr); |
| 1077 | 1077 | prior = SPRITE_PRIORITY (nr); |
| 1078 | 1078 | collision = SPRITE_BG_COLLISION (nr); |
| r3879 | r3880 | |
| 1084 | 1084 | vic2.sprites[nr].paintedline[y] = 1; |
| 1085 | 1085 | for (i = 0; i < 3; i++) |
| 1086 | 1086 | { |
| 1087 | | value = vic2.expandx[vic2.dma_read (addr + vic2.sprites[nr].line * 3 + i)]; |
| 1087 | value = vic2.expandx[vic2.dma_read(machine, addr + vic2.sprites[nr].line * 3 + i)]; |
| 1088 | 1088 | vic2.sprites[nr].bitmap[y][i*2] = value>>8; |
| 1089 | 1089 | vic2.sprites[nr].bitmap[y][i*2+1] = value&0xff; |
| 1090 | 1090 | vic2_sprite_collision(machine, nr, y, xbegin + i * 16, value >> 8); |
| r3879 | r3880 | |
| 1126 | 1126 | vic2.sprites[nr].paintedline[y] = 1; |
| 1127 | 1127 | for (i = 0; i < 3; i++) |
| 1128 | 1128 | { |
| 1129 | | value = vic2.dma_read (addr + vic2.sprites[nr].line * 3 + i); |
| 1129 | value = vic2.dma_read(machine, addr + vic2.sprites[nr].line * 3 + i); |
| 1130 | 1130 | vic2.sprites[nr].bitmap[y][i] = value; |
| 1131 | 1131 | vic2_sprite_collision(machine, nr, y, xbegin + i * 8, value); |
| 1132 | 1132 | if (prior || !collision) |
| r3879 | r3880 | |
| 1253 | 1253 | vic2.shift[line] = HORIZONTALPOS; |
| 1254 | 1254 | for (xoff = vic2.x_begin + XPOS; xoff < vic2.x_end + XPOS; xoff += 8, offs++) |
| 1255 | 1255 | { |
| 1256 | | ch = vic2.dma_read (vic2.videoaddr + offs); |
| 1256 | ch = vic2.dma_read(machine, vic2.videoaddr + offs); |
| 1257 | 1257 | #if 0 |
| 1258 | | attr = vic2.dma_read_color (vic2.videoaddr + offs); |
| 1258 | attr = vic2.dma_read_color(machine, vic2.videoaddr + offs); |
| 1259 | 1259 | #else |
| 1260 | 1260 | /* temporaery until vic3 finished */ |
| 1261 | | attr = vic2.dma_read_color ((vic2.videoaddr + offs)&0x3ff)&0x0f; |
| 1261 | attr = vic2.dma_read_color(machine, (vic2.videoaddr + offs)&0x3ff)&0x0f; |
| 1262 | 1262 | #endif |
| 1263 | 1263 | if (HIRESON) |
| 1264 | 1264 | { |
| r3879 | r3880 | |
| 1267 | 1267 | if (MULTICOLORON) |
| 1268 | 1268 | { |
| 1269 | 1269 | vic2.bitmapmulti[3] = attr; |
| 1270 | | vic2_draw_bitmap_multi (ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 1270 | vic2_draw_bitmap_multi(machine, ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 1271 | 1271 | } |
| 1272 | 1272 | else |
| 1273 | 1273 | { |
| 1274 | | vic2_draw_bitmap (ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 1274 | vic2_draw_bitmap(machine, ybegin, yend, offs, yoff, xoff, start_x, end_x); |
| 1275 | 1275 | } |
| 1276 | 1276 | } |
| 1277 | 1277 | else if (ECMON) |
| r3879 | r3880 | |
| 1279 | 1279 | ecm = ch >> 6; |
| 1280 | 1280 | vic2.ecmcolor[0] = vic2.colors[ecm]; |
| 1281 | 1281 | vic2.ecmcolor[1] = attr; |
| 1282 | | vic2_draw_character (ybegin, yend, ch & ~0xC0, yoff, xoff, vic2.ecmcolor, start_x, end_x); |
| 1282 | vic2_draw_character(machine, ybegin, yend, ch & ~0xC0, yoff, xoff, vic2.ecmcolor, start_x, end_x); |
| 1283 | 1283 | } |
| 1284 | 1284 | else if (MULTICOLORON && (attr & 8)) |
| 1285 | 1285 | { |
| 1286 | 1286 | vic2.multi[3] = attr & 7; |
| 1287 | | vic2_draw_character_multi (ybegin, yend, ch, yoff, xoff, start_x, end_x); |
| 1287 | vic2_draw_character_multi(machine, ybegin, yend, ch, yoff, xoff, start_x, end_x); |
| 1288 | 1288 | } |
| 1289 | 1289 | else |
| 1290 | 1290 | { |
| 1291 | 1291 | vic2.mono[1] = attr; |
| 1292 | | vic2_draw_character (ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x); |
| 1292 | vic2_draw_character(machine, ybegin, yend, ch, yoff, xoff, vic2.mono, start_x, end_x); |
| 1293 | 1293 | } |
| 1294 | 1294 | } |
| 1295 | 1295 | |
src/mess/machine/cbmb.c
| r3879 | r3880 | |
| 3 | 3 | |
| 4 | 4 | peter.trauner@jk.uni-linz.ac.at |
| 5 | 5 | ***************************************************************************/ |
| 6 | | #include <ctype.h> |
| 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | 8 | #include "cpu/m6502/m6509.h" |
| 9 | 9 | #include "sound/sid6581.h" |
| 10 | 10 | #include "machine/6526cia.h" |
| 11 | | #include "deprecat.h" |
| 12 | 11 | |
| 13 | 12 | #include "includes/cbm.h" |
| 14 | 13 | #include "machine/tpi6525.h" |
| r3879 | r3880 | |
| 73 | 72 | i1 self pb0 |
| 74 | 73 | i0 tod (50 or 60 hertz frequency) |
| 75 | 74 | */ |
| 76 | | static int cbmb_tpi0_port_a_r(void) |
| 75 | static int cbmb_tpi0_port_a_r(running_machine *machine) |
| 77 | 76 | { |
| 78 | | running_machine *machine = Machine; |
| 79 | 77 | int data = 0; |
| 78 | |
| 80 | 79 | if (cbm_ieee_nrfd_r(machine)) data |= 0x80; |
| 81 | 80 | if (cbm_ieee_ndac_r(machine)) data |= 0x40; |
| 82 | 81 | if (cbm_ieee_eoi_r(machine)) data |= 0x20; |
| 83 | 82 | if (cbm_ieee_dav_r(machine)) data |= 0x10; |
| 84 | 83 | if (cbm_ieee_atn_r(machine)) data |= 0x08; |
| 85 | 84 | /* if (cbm_ieee_ren_r(machine)) data |= 0x04; */ |
| 85 | |
| 86 | 86 | return data; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | | static void cbmb_tpi0_port_a_w(int data) |
| 89 | static void cbmb_tpi0_port_a_w(running_machine *machine, int data) |
| 90 | 90 | { |
| 91 | 91 | cbm_ieee_nrfd_w(0, data & 0x80); |
| 92 | 92 | cbm_ieee_ndac_w(0, data & 0x40); |
| r3879 | r3880 | |
| 109 | 109 | port c6 ? |
| 110 | 110 | port c5 .. c0 keyboard line select |
| 111 | 111 | port a7..a0 b7..b0 keyboard input */ |
| 112 | | static void cbmb_keyboard_line_select_a(int line) |
| 112 | static void cbmb_keyboard_line_select_a(running_machine *machine, int line) |
| 113 | 113 | { |
| 114 | 114 | cbmb_keyline_a=line; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | | static void cbmb_keyboard_line_select_b(int line) |
| 117 | static void cbmb_keyboard_line_select_b(running_machine *machine, int line) |
| 118 | 118 | { |
| 119 | 119 | cbmb_keyline_b=line; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | | static void cbmb_keyboard_line_select_c(int line) |
| 122 | static void cbmb_keyboard_line_select_c(running_machine *machine, int line) |
| 123 | 123 | { |
| 124 | 124 | cbmb_keyline_c=line; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | | static int cbmb_keyboard_line_a(void) |
| 127 | static int cbmb_keyboard_line_a(running_machine *machine) |
| 128 | 128 | { |
| 129 | 129 | int data = 0; |
| 130 | 130 | |
| 131 | 131 | if (!(cbmb_keyline_c & 0x01)) |
| 132 | | data |= input_port_read(Machine, "ROW0"); |
| 132 | data |= input_port_read(machine, "ROW0"); |
| 133 | 133 | |
| 134 | 134 | if (!(cbmb_keyline_c & 0x02)) |
| 135 | | data |= input_port_read(Machine, "ROW2"); |
| 135 | data |= input_port_read(machine, "ROW2"); |
| 136 | 136 | |
| 137 | 137 | if (!(cbmb_keyline_c & 0x04)) |
| 138 | | data |= input_port_read(Machine, "ROW4"); |
| 138 | data |= input_port_read(machine, "ROW4"); |
| 139 | 139 | |
| 140 | 140 | if (!(cbmb_keyline_c & 0x08)) |
| 141 | | data |= input_port_read(Machine, "ROW6"); |
| 141 | data |= input_port_read(machine, "ROW6"); |
| 142 | 142 | |
| 143 | 143 | if (!(cbmb_keyline_c & 0x10)) |
| 144 | | data |= input_port_read(Machine, "ROW8"); |
| 144 | data |= input_port_read(machine, "ROW8"); |
| 145 | 145 | |
| 146 | 146 | if (!(cbmb_keyline_c & 0x20)) |
| 147 | | data |= input_port_read(Machine, "ROW10"); |
| 147 | data |= input_port_read(machine, "ROW10"); |
| 148 | 148 | |
| 149 | 149 | return data ^0xff; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | | static int cbmb_keyboard_line_b(void) |
| 152 | static int cbmb_keyboard_line_b(running_machine *machine) |
| 153 | 153 | { |
| 154 | 154 | int data = 0; |
| 155 | 155 | |
| 156 | 156 | if (!(cbmb_keyline_c & 0x01)) |
| 157 | | data |= input_port_read(Machine, "ROW1"); |
| 157 | data |= input_port_read(machine, "ROW1"); |
| 158 | 158 | |
| 159 | 159 | if (!(cbmb_keyline_c & 0x02)) |
| 160 | | data |= input_port_read(Machine, "ROW3"); |
| 160 | data |= input_port_read(machine, "ROW3"); |
| 161 | 161 | |
| 162 | 162 | if (!(cbmb_keyline_c & 0x04)) |
| 163 | | data |= input_port_read(Machine, "ROW5"); |
| 163 | data |= input_port_read(machine, "ROW5"); |
| 164 | 164 | |
| 165 | 165 | if (!(cbmb_keyline_c & 0x08)) |
| 166 | | data |= input_port_read(Machine, "ROW7"); |
| 166 | data |= input_port_read(machine, "ROW7"); |
| 167 | 167 | |
| 168 | 168 | if (!(cbmb_keyline_c & 0x10)) |
| 169 | | data |= input_port_read(Machine, "ROW9") | ((input_port_read(Machine, "SPECIAL") & 0x04) ? 1 : 0 ); |
| 169 | data |= input_port_read(machine, "ROW9") | ((input_port_read(machine, "SPECIAL") & 0x04) ? 1 : 0 ); |
| 170 | 170 | |
| 171 | 171 | if (!(cbmb_keyline_c & 0x20)) |
| 172 | | data |= input_port_read(Machine, "ROW11"); |
| 172 | data |= input_port_read(machine, "ROW11"); |
| 173 | 173 | |
| 174 | 174 | return data ^0xff; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | | static int cbmb_keyboard_line_c(void) |
| 177 | static int cbmb_keyboard_line_c(running_machine *machine) |
| 178 | 178 | { |
| 179 | 179 | int data = 0; |
| 180 | 180 | |
| 181 | | if ((input_port_read(Machine, "ROW0") & ~cbmb_keyline_a) || |
| 182 | | (input_port_read(Machine, "ROW1") & ~cbmb_keyline_b)) |
| 181 | if ((input_port_read(machine, "ROW0") & ~cbmb_keyline_a) || |
| 182 | (input_port_read(machine, "ROW1") & ~cbmb_keyline_b)) |
| 183 | 183 | data |= 0x01; |
| 184 | 184 | |
| 185 | | if ((input_port_read(Machine, "ROW2") & ~cbmb_keyline_a) || |
| 186 | | (input_port_read(Machine, "ROW3") & ~cbmb_keyline_b)) |
| 185 | if ((input_port_read(machine, "ROW2") & ~cbmb_keyline_a) || |
| 186 | (input_port_read(machine, "ROW3") & ~cbmb_keyline_b)) |
| 187 | 187 | data |= 0x02; |
| 188 | 188 | |
| 189 | | if ((input_port_read(Machine, "ROW4") & ~cbmb_keyline_a) || |
| 190 | | (input_port_read(Machine, "ROW5") & ~cbmb_keyline_b)) |
| 189 | if ((input_port_read(machine, "ROW4") & ~cbmb_keyline_a) || |
| 190 | (input_port_read(machine, "ROW5") & ~cbmb_keyline_b)) |
| 191 | 191 | data |= 0x04; |
| 192 | 192 | |
| 193 | | if ((input_port_read(Machine, "ROW6") & ~cbmb_keyline_a) || |
| 194 | | (input_port_read(Machine, "ROW7") & ~cbmb_keyline_b)) |
| 193 | if ((input_port_read(machine, "ROW6") & ~cbmb_keyline_a) || |
| 194 | (input_port_read(machine, "ROW7") & ~cbmb_keyline_b)) |
| 195 | 195 | data |= 0x08; |
| 196 | 196 | |
| 197 | | if ((input_port_read(Machine, "ROW8") & ~cbmb_keyline_a) || |
| 198 | | ((input_port_read(Machine, "ROW9") | ((input_port_read(Machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~cbmb_keyline_b)) |
| 197 | if ((input_port_read(machine, "ROW8") & ~cbmb_keyline_a) || |
| 198 | ((input_port_read(machine, "ROW9") | ((input_port_read(machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~cbmb_keyline_b)) |
| 199 | 199 | data |= 0x10; |
| 200 | 200 | |
| 201 | | if ((input_port_read(Machine, "ROW10") & ~cbmb_keyline_a) || |
| 202 | | (input_port_read(Machine, "ROW11") & ~cbmb_keyline_b)) |
| 201 | if ((input_port_read(machine, "ROW10") & ~cbmb_keyline_a) || |
| 202 | (input_port_read(machine, "ROW11") & ~cbmb_keyline_b)) |
| 203 | 203 | data |= 0x20; |
| 204 | 204 | |
| 205 | 205 | if (!p500) |
| r3879 | r3880 | |
| 213 | 213 | return data ^0xff; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | | static void cbmb_irq (running_machine *machine, int level) |
| 216 | static void cbmb_irq(running_machine *machine, int level) |
| 217 | 217 | { |
| 218 | 218 | static int old_level = 0; |
| 219 | 219 | |
| r3879 | r3880 | |
| 265 | 265 | cbmb_colorram[offset] = data | 0xf0; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | | static int cbmb_dma_read(int offset) |
| 268 | static int cbmb_dma_read(running_machine *machine, int offset) |
| 269 | 269 | { |
| 270 | 270 | if (offset >= 0x1000) |
| 271 | 271 | return cbmb_videoram[offset & 0x3ff]; |
| r3879 | r3880 | |
| 273 | 273 | return cbmb_chargen[offset & 0xfff]; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | | static int cbmb_dma_read_color(int offset) |
| 276 | static int cbmb_dma_read_color(running_machine *machine, int offset) |
| 277 | 277 | { |
| 278 | 278 | return cbmb_colorram[offset & 0x3ff]; |
| 279 | 279 | } |
src/mess/machine/c128.c
| r3879 | r3880 | |
| 14 | 14 | #include "cpu/m6502/m6502.h" |
| 15 | 15 | #include "sound/sid6581.h" |
| 16 | 16 | #include "machine/6526cia.h" |
| 17 | | #include "deprecat.h" |
| 18 | 17 | |
| 19 | 18 | #include "includes/cbmserb.h" |
| 20 | 19 | #include "includes/vc1541.h" |
| r3879 | r3880 | |
| 26 | 25 | |
| 27 | 26 | #include "devices/cassette.h" |
| 28 | 27 | |
| 29 | | #include "deprecat.h" |
| 30 | 28 | |
| 31 | | |
| 32 | 29 | #define VERBOSE_LEVEL 0 |
| 33 | 30 | #define DBG_LOG(N,M,A) \ |
| 34 | 31 | do { \ |
| r3879 | r3880 | |
| 184 | 181 | return 0xff; |
| 185 | 182 | } |
| 186 | 183 | |
| 187 | | void c128_bankswitch_64 (running_machine *machine, int reset) |
| 184 | void c128_bankswitch_64(running_machine *machine, int reset) |
| 188 | 185 | { |
| 189 | 186 | static int old, exrom, game; |
| 190 | 187 | int data, loram, hiram, charen; |
| r3879 | r3880 | |
| 306 | 303 | |
| 307 | 304 | /* typical z80 configuration |
| 308 | 305 | 0x3f 0x3f 0x7f 0x3e 0x7e 0xb0 0x0b 0x00 0x00 0x01 0x00 */ |
| 309 | | static void c128_bankswitch_z80 (running_machine *machine) |
| 306 | static void c128_bankswitch_z80(running_machine *machine) |
| 310 | 307 | { |
| 311 | 308 | c128_ram = c64_memory + MMU_RAM_ADDR; |
| 312 | 309 | c128_va1617 = MMU_VIC_ADDR; |
| r3879 | r3880 | |
| 781 | 778 | * a15 and a14 portlines |
| 782 | 779 | * 0x1000-0x1fff, 0x9000-0x9fff char rom |
| 783 | 780 | */ |
| 784 | | static int c128_dma_read(int offset) |
| 781 | static int c128_dma_read(running_machine *machine, int offset) |
| 785 | 782 | { |
| 786 | | UINT8 c64_port6510 = (UINT8) cpu_get_info_int(Machine->cpu[0], CPUINFO_INT_M6510_PORT); |
| 783 | UINT8 c64_port6510 = (UINT8) cpu_get_info_int(machine->cpu[0], CPUINFO_INT_M6510_PORT); |
| 787 | 784 | |
| 788 | 785 | /* main memory configuration to include */ |
| 789 | 786 | if (c64mode) |
| r3879 | r3880 | |
| 804 | 801 | return c128_vicaddr[offset]; |
| 805 | 802 | } |
| 806 | 803 | |
| 807 | | static int c128_dma_read_color (int offset) |
| 804 | static int c128_dma_read_color(running_machine *machine, int offset) |
| 808 | 805 | { |
| 809 | | UINT8 c64_port6510 = (UINT8) cpu_get_info_int(Machine->cpu[0], CPUINFO_INT_M6510_PORT); |
| 806 | UINT8 c64_port6510 = (UINT8) cpu_get_info_int(machine->cpu[0], CPUINFO_INT_M6510_PORT); |
| 810 | 807 | |
| 811 | 808 | if (c64mode) |
| 812 | 809 | return c64_colorram[offset & 0x3ff] & 0xf; |
| r3879 | r3880 | |
| 822 | 819 | |
| 823 | 820 | static emu_timer *datasette_timer; |
| 824 | 821 | |
| 825 | | static void c128_m6510_port_write(UINT8 direction, UINT8 data) |
| 822 | static void c128_m6510_port_write(const device_config *device, UINT8 direction, UINT8 data) |
| 826 | 823 | { |
| 827 | | running_machine *machine = Machine; |
| 828 | | |
| 829 | 824 | /* if line is marked as input then keep current value */ |
| 830 | 825 | data = (c64_port_data & ~direction) | (data & direction); |
| 831 | 826 | |
| r3879 | r3880 | |
| 845 | 840 | { |
| 846 | 841 | if (direction & 0x08) |
| 847 | 842 | { |
| 848 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), (data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); |
| 843 | cassette_output(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ), (data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); |
| 849 | 844 | } |
| 850 | 845 | |
| 851 | 846 | if (direction & 0x20) |
| 852 | 847 | { |
| 853 | 848 | if(!(data & 0x20)) |
| 854 | 849 | { |
| 855 | | cassette_change_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 850 | cassette_change_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 856 | 851 | timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100)); |
| 857 | 852 | } |
| 858 | 853 | else |
| 859 | 854 | { |
| 860 | | cassette_change_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR); |
| 855 | cassette_change_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR); |
| 861 | 856 | timer_reset(datasette_timer, attotime_never); |
| 862 | 857 | } |
| 863 | 858 | } |
| 864 | 859 | } |
| 865 | 860 | |
| 866 | | c128_bankswitch_64(machine, 0); |
| 861 | c128_bankswitch_64(device->machine, 0); |
| 867 | 862 | |
| 868 | | c64_memory[0x000] = memory_read_byte( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0 ); |
| 869 | | c64_memory[0x001] = memory_read_byte( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 1 ); |
| 863 | c64_memory[0x000] = memory_read_byte( cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 0 ); |
| 864 | c64_memory[0x001] = memory_read_byte( cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 1 ); |
| 870 | 865 | } |
| 871 | 866 | |
| 872 | | static UINT8 c128_m6510_port_read(UINT8 direction) |
| 867 | static UINT8 c128_m6510_port_read(const device_config *device, UINT8 direction) |
| 873 | 868 | { |
| 874 | | running_machine *machine = Machine; |
| 875 | 869 | UINT8 data = c64_port_data; |
| 876 | 870 | |
| 877 | | if ((cassette_get_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 871 | if ((cassette_get_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" )) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 878 | 872 | data &= ~0x10; |
| 879 | 873 | else |
| 880 | 874 | data |= 0x10; |
| 881 | 875 | |
| 882 | | if (input_port_read(machine, "SPECIAL") & 0x20) /* Check Caps Lock */ |
| 876 | if (input_port_read(device->machine, "SPECIAL") & 0x20) /* Check Caps Lock */ |
| 883 | 877 | { |
| 884 | 878 | data &= ~0x40; |
| 885 | 879 | } else { |
src/mess/machine/tpi6525.c
| r3879 | r3880 | |
| 71 | 71 | highest interrupt can be found in air register |
| 72 | 72 | read clears highest interrupt |
| 73 | 73 | */ |
| 74 | | #include <ctype.h> |
| 75 | | #include "driver.h" |
| 76 | 74 | |
| 75 | #include "driver.h" |
| 77 | 76 | #include "tpi6525.h" |
| 78 | 77 | |
| 79 | 78 | |
| r3879 | r3880 | |
| 201 | 200 | } |
| 202 | 201 | } |
| 203 | 202 | |
| 204 | | static int tpi6525_port_a_r(TPI6525 *This, int offset) |
| 203 | static int tpi6525_port_a_r(running_machine *machine, TPI6525 *This, int offset) |
| 205 | 204 | { |
| 206 | 205 | int data=This->a.in; |
| 207 | 206 | |
| 208 | | if (This->a.read) data=This->a.read(); |
| 207 | if (This->a.read) data=This->a.read(machine); |
| 209 | 208 | data=(data&~This->a.ddr)|(This->a.ddr&This->a.port); |
| 210 | 209 | |
| 211 | 210 | return data; |
| 212 | 211 | } |
| 213 | 212 | |
| 214 | | static void tpi6525_port_a_w(TPI6525 *This, int offset, int data) |
| 213 | static void tpi6525_port_a_w(running_machine *machine, TPI6525 *This, int offset, int data) |
| 215 | 214 | { |
| 216 | 215 | This->a.in=data; |
| 217 | 216 | } |
| 218 | 217 | |
| 219 | | static int tpi6525_port_b_r(TPI6525 *This, int offset) |
| 218 | static int tpi6525_port_b_r(running_machine *machine, TPI6525 *This, int offset) |
| 220 | 219 | { |
| 221 | 220 | int data=This->b.in; |
| 222 | 221 | |
| 223 | | if (This->b.read) data=This->b.read(); |
| 222 | if (This->b.read) data=This->b.read(machine); |
| 224 | 223 | data=(data&~This->b.ddr)|(This->b.ddr&This->b.port); |
| 225 | 224 | |
| 226 | 225 | return data; |
| 227 | 226 | } |
| 228 | 227 | |
| 229 | | static void tpi6525_port_b_w(TPI6525 *This, int offset, int data) |
| 228 | static void tpi6525_port_b_w(running_machine *machine, TPI6525 *This, int offset, int data) |
| 230 | 229 | { |
| 231 | 230 | This->b.in=data; |
| 232 | 231 | } |
| 233 | 232 | |
| 234 | | static int tpi6525_port_c_r(TPI6525 *This, int offset) |
| 233 | static int tpi6525_port_c_r(running_machine *machine, TPI6525 *This, int offset) |
| 235 | 234 | { |
| 236 | 235 | int data=This->c.in; |
| 237 | 236 | |
| 238 | | if (This->c.read) data&=This->c.read(); |
| 237 | if (This->c.read) data&=This->c.read(machine); |
| 239 | 238 | data=(data&~This->c.ddr)|(This->c.ddr&This->c.port); |
| 240 | 239 | |
| 241 | 240 | return data; |
| 242 | 241 | } |
| 243 | 242 | |
| 244 | | static void tpi6525_port_c_w(TPI6525 *This, int offset, int data) |
| 243 | static void tpi6525_port_c_w(running_machine *machine, TPI6525 *This, int offset, int data) |
| 245 | 244 | { |
| 246 | 245 | This->c.in=data; |
| 247 | 246 | } |
| r3879 | r3880 | |
| 252 | 251 | switch (offset&7) { |
| 253 | 252 | case 0: |
| 254 | 253 | data=This->a.in; |
| 255 | | if (This->a.read) data&=This->a.read(); |
| 254 | if (This->a.read) data&=This->a.read(machine); |
| 256 | 255 | data=(data&~This->a.ddr)|(This->a.ddr&This->a.port); |
| 257 | 256 | break; |
| 258 | 257 | case 1: |
| 259 | 258 | data=This->b.in; |
| 260 | | if (This->b.read) data&=This->b.read(); |
| 259 | if (This->b.read) data&=This->b.read(machine); |
| 261 | 260 | data=(data&~This->b.ddr)|(This->b.ddr&This->b.port); |
| 262 | 261 | break; |
| 263 | 262 | case 2: |
| r3879 | r3880 | |
| 273 | 272 | if (This->cb.level) data|=0x80; |
| 274 | 273 | } else { |
| 275 | 274 | data=This->c.in; |
| 276 | | if (This->c.read) data&=This->c.read(); |
| 275 | if (This->c.read) data&=This->c.read(machine); |
| 277 | 276 | data=(data&~This->c.ddr)|(This->c.ddr&This->c.port); |
| 278 | 277 | } |
| 279 | 278 | DBG_LOG (2, "tpi6525", |
| r3879 | r3880 | |
| 330 | 329 | case 0: |
| 331 | 330 | This->a.port=data; |
| 332 | 331 | if (This->a.output) { |
| 333 | | This->a.output(This->a.port&This->a.ddr); |
| 332 | This->a.output(machine, This->a.port&This->a.ddr); |
| 334 | 333 | } |
| 335 | 334 | break; |
| 336 | 335 | case 1: |
| 337 | 336 | This->b.port=data; |
| 338 | 337 | if (This->b.output) { |
| 339 | | This->b.output(This->b.port&This->b.ddr); |
| 338 | This->b.output(machine, This->b.port&This->b.ddr); |
| 340 | 339 | } |
| 341 | 340 | break; |
| 342 | 341 | case 2: |
| 343 | 342 | This->c.port=data; |
| 344 | 343 | if (!INTERRUPT_MODE&&This->c.output) { |
| 345 | | This->c.output(This->c.port&This->c.ddr); |
| 344 | This->c.output(machine, This->c.port&This->c.ddr); |
| 346 | 345 | } |
| 347 | 346 | break; |
| 348 | 347 | case 3: |
| 349 | 348 | This->a.ddr=data; |
| 350 | 349 | if (This->a.output) { |
| 351 | | This->a.output(This->a.port&This->a.ddr); |
| 350 | This->a.output(machine, This->a.port&This->a.ddr); |
| 352 | 351 | } |
| 353 | 352 | break; |
| 354 | 353 | case 4: |
| 355 | 354 | This->b.ddr=data; |
| 356 | 355 | if (This->b.output) { |
| 357 | | This->b.output(This->b.port&This->b.ddr); |
| 356 | This->b.output(machine, This->b.port&This->b.ddr); |
| 358 | 357 | } |
| 359 | 358 | break; |
| 360 | 359 | case 5: |
| 361 | 360 | This->c.ddr=data; |
| 362 | 361 | if (!INTERRUPT_MODE&&This->c.output) { |
| 363 | | This->c.output(This->c.port&This->c.ddr); |
| 362 | This->c.output(machine, This->c.port&This->c.ddr); |
| 364 | 363 | } |
| 365 | 364 | break; |
| 366 | 365 | case 6: |
| r3879 | r3880 | |
| 457 | 456 | tpi6525_irq4_level(machine, tpi6525+1, level); |
| 458 | 457 | } |
| 459 | 458 | |
| 460 | | READ8_HANDLER ( tpi6525_0_port_r ) |
| 459 | READ8_HANDLER ( tpi6525_0_port_r ) |
| 461 | 460 | { |
| 462 | 461 | return tpi6525_port_r(space->machine, tpi6525, offset); |
| 463 | 462 | } |
| 464 | 463 | |
| 465 | | READ8_HANDLER ( tpi6525_1_port_r ) |
| 464 | READ8_HANDLER ( tpi6525_1_port_r ) |
| 466 | 465 | { |
| 467 | 466 | return tpi6525_port_r(space->machine, tpi6525+1, offset); |
| 468 | 467 | } |
| 469 | 468 | |
| 470 | | READ8_HANDLER ( tpi6525_2_port_r ) |
| 469 | READ8_HANDLER ( tpi6525_2_port_r ) |
| 471 | 470 | { |
| 472 | 471 | return tpi6525_port_r(space->machine, tpi6525+2, offset); |
| 473 | 472 | } |
| 474 | 473 | |
| 475 | | READ8_HANDLER ( tpi6525_3_port_r ) |
| 474 | READ8_HANDLER ( tpi6525_3_port_r ) |
| 476 | 475 | { |
| 477 | 476 | return tpi6525_port_r(space->machine, tpi6525+3, offset); |
| 478 | 477 | } |
| r3879 | r3880 | |
| 497 | 496 | tpi6525_port_w(space->machine, tpi6525+3, offset, data); |
| 498 | 497 | } |
| 499 | 498 | |
| 500 | | READ8_HANDLER ( tpi6525_0_port_a_r ) |
| 499 | READ8_HANDLER ( tpi6525_0_port_a_r ) |
| 501 | 500 | { |
| 502 | | return tpi6525_port_a_r(tpi6525, offset); |
| 501 | return tpi6525_port_a_r(space->machine, tpi6525, offset); |
| 503 | 502 | } |
| 504 | 503 | |
| 505 | | READ8_HANDLER ( tpi6525_1_port_a_r ) |
| 504 | READ8_HANDLER ( tpi6525_1_port_a_r ) |
| 506 | 505 | { |
| 507 | | return tpi6525_port_a_r(tpi6525+1, offset); |
| 506 | return tpi6525_port_a_r(space->machine, tpi6525+1, offset); |
| 508 | 507 | } |
| 509 | 508 | |
| 510 | | READ8_HANDLER ( tpi6525_2_port_a_r ) |
| 509 | READ8_HANDLER ( tpi6525_2_port_a_r ) |
| 511 | 510 | { |
| 512 | | return tpi6525_port_a_r(tpi6525+2, offset); |
| 511 | return tpi6525_port_a_r(space->machine, tpi6525+2, offset); |
| 513 | 512 | } |
| 514 | 513 | |
| 515 | | READ8_HANDLER ( tpi6525_3_port_a_r ) |
| 514 | READ8_HANDLER ( tpi6525_3_port_a_r ) |
| 516 | 515 | { |
| 517 | | return tpi6525_port_a_r(tpi6525+3, offset); |
| 516 | return tpi6525_port_a_r(space->machine, tpi6525+3, offset); |
| 518 | 517 | } |
| 519 | 518 | |
| 520 | 519 | WRITE8_HANDLER ( tpi6525_0_port_a_w ) |
| 521 | 520 | { |
| 522 | | tpi6525_port_a_w(tpi6525, offset, data); |
| 521 | tpi6525_port_a_w(space->machine, tpi6525, offset, data); |
| 523 | 522 | } |
| 524 | 523 | |
| 525 | 524 | WRITE8_HANDLER ( tpi6525_1_port_a_w ) |
| 526 | 525 | { |
| 527 | | tpi6525_port_a_w(tpi6525+1, offset, data); |
| 526 | tpi6525_port_a_w(space->machine, tpi6525+1, offset, data); |
| 528 | 527 | } |
| 529 | 528 | |
| 530 | 529 | WRITE8_HANDLER ( tpi6525_2_port_a_w ) |
| 531 | 530 | { |
| 532 | | tpi6525_port_a_w(tpi6525+2, offset, data); |
| 531 | tpi6525_port_a_w(space->machine, tpi6525+2, offset, data); |
| 533 | 532 | } |
| 534 | 533 | |
| 535 | 534 | WRITE8_HANDLER ( tpi6525_3_port_a_w ) |
| 536 | 535 | { |
| 537 | | tpi6525_port_a_w(tpi6525+3, offset, data); |
| 536 | tpi6525_port_a_w(space->machine, tpi6525+3, offset, data); |
| 538 | 537 | } |
| 539 | 538 | |
| 540 | | READ8_HANDLER ( tpi6525_0_port_b_r ) |
| 539 | READ8_HANDLER ( tpi6525_0_port_b_r ) |
| 541 | 540 | { |
| 542 | | return tpi6525_port_b_r(tpi6525, offset); |
| 541 | return tpi6525_port_b_r(space->machine, tpi6525, offset); |
| 543 | 542 | } |
| 544 | 543 | |
| 545 | | READ8_HANDLER ( tpi6525_1_port_b_r ) |
| 544 | READ8_HANDLER ( tpi6525_1_port_b_r ) |
| 546 | 545 | { |
| 547 | | return tpi6525_port_b_r(tpi6525+1, offset); |
| 546 | return tpi6525_port_b_r(space->machine, tpi6525+1, offset); |
| 548 | 547 | } |
| 549 | 548 | |
| 550 | | READ8_HANDLER ( tpi6525_2_port_b_r ) |
| 549 | READ8_HANDLER ( tpi6525_2_port_b_r ) |
| 551 | 550 | { |
| 552 | | return tpi6525_port_b_r(tpi6525+2, offset); |
| 551 | return tpi6525_port_b_r(space->machine, tpi6525+2, offset); |
| 553 | 552 | } |
| 554 | 553 | |
| 555 | | READ8_HANDLER ( tpi6525_3_port_b_r ) |
| 554 | READ8_HANDLER ( tpi6525_3_port_b_r ) |
| 556 | 555 | { |
| 557 | | return tpi6525_port_b_r(tpi6525+3, offset); |
| 556 | return tpi6525_port_b_r(space->machine, tpi6525+3, offset); |
| 558 | 557 | } |
| 559 | 558 | |
| 560 | 559 | WRITE8_HANDLER ( tpi6525_0_port_b_w ) |
| 561 | 560 | { |
| 562 | | tpi6525_port_b_w(tpi6525, offset, data); |
| 561 | tpi6525_port_b_w(space->machine, tpi6525, offset, data); |
| 563 | 562 | } |
| 564 | 563 | |
| 565 | 564 | WRITE8_HANDLER ( tpi6525_1_port_b_w ) |
| 566 | 565 | { |
| 567 | | tpi6525_port_b_w(tpi6525+1, offset, data); |
| 566 | tpi6525_port_b_w(space->machine, tpi6525+1, offset, data); |
| 568 | 567 | } |
| 569 | 568 | |
| 570 | 569 | WRITE8_HANDLER ( tpi6525_2_port_b_w ) |
| 571 | 570 | { |
| 572 | | tpi6525_port_b_w(tpi6525+2, offset, data); |
| 571 | tpi6525_port_b_w(space->machine, tpi6525+2, offset, data); |
| 573 | 572 | } |
| 574 | 573 | |
| 575 | 574 | WRITE8_HANDLER ( tpi6525_3_port_b_w ) |
| 576 | 575 | { |
| 577 | | tpi6525_port_b_w(tpi6525+3, offset, data); |
| 576 | tpi6525_port_b_w(space->machine, tpi6525+3, offset, data); |
| 578 | 577 | } |
| 579 | 578 | |
| 580 | | READ8_HANDLER ( tpi6525_0_port_c_r ) |
| 579 | READ8_HANDLER ( tpi6525_0_port_c_r ) |
| 581 | 580 | { |
| 582 | | return tpi6525_port_c_r(tpi6525, offset); |
| 581 | return tpi6525_port_c_r(space->machine, tpi6525, offset); |
| 583 | 582 | } |
| 584 | 583 | |
| 585 | | READ8_HANDLER ( tpi6525_1_port_c_r ) |
| 584 | READ8_HANDLER ( tpi6525_1_port_c_r ) |
| 586 | 585 | { |
| 587 | | return tpi6525_port_c_r(tpi6525+1, offset); |
| 586 | return tpi6525_port_c_r(space->machine, tpi6525+1, offset); |
| 588 | 587 | } |
| 589 | 588 | |
| 590 | | READ8_HANDLER ( tpi6525_2_port_c_r ) |
| 589 | READ8_HANDLER ( tpi6525_2_port_c_r ) |
| 591 | 590 | { |
| 592 | | return tpi6525_port_c_r(tpi6525+2, offset); |
| 591 | return tpi6525_port_c_r(space->machine, tpi6525+2, offset); |
| 593 | 592 | } |
| 594 | 593 | |
| 595 | | READ8_HANDLER ( tpi6525_3_port_c_r ) |
| 594 | READ8_HANDLER ( tpi6525_3_port_c_r ) |
| 596 | 595 | { |
| 597 | | return tpi6525_port_c_r(tpi6525+3, offset); |
| 596 | return tpi6525_port_c_r(space->machine, tpi6525+3, offset); |
| 598 | 597 | } |
| 599 | 598 | |
| 600 | 599 | WRITE8_HANDLER ( tpi6525_0_port_c_w ) |
| 601 | 600 | { |
| 602 | | tpi6525_port_c_w(tpi6525, offset, data); |
| 601 | tpi6525_port_c_w(space->machine, tpi6525, offset, data); |
| 603 | 602 | } |
| 604 | 603 | |
| 605 | 604 | WRITE8_HANDLER ( tpi6525_1_port_c_w ) |
| 606 | 605 | { |
| 607 | | tpi6525_port_c_w(tpi6525+1, offset, data); |
| 606 | tpi6525_port_c_w(space->machine, tpi6525+1, offset, data); |
| 608 | 607 | } |
| 609 | 608 | |
| 610 | 609 | WRITE8_HANDLER ( tpi6525_2_port_c_w ) |
| 611 | 610 | { |
| 612 | | tpi6525_port_c_w(tpi6525+2, offset, data); |
| 611 | tpi6525_port_c_w(space->machine, tpi6525+2, offset, data); |
| 613 | 612 | } |
| 614 | 613 | |
| 615 | 614 | WRITE8_HANDLER ( tpi6525_3_port_c_w ) |
| 616 | 615 | { |
| 617 | | tpi6525_port_c_w(tpi6525+3, offset, data); |
| 616 | tpi6525_port_c_w(space->machine, tpi6525+3, offset, data); |
| 618 | 617 | } |
| 619 | | |
src/mess/machine/c64.c
| r3879 | r3880 | |
| 784 | 784 | |
| 785 | 785 | static emu_timer *datasette_timer; |
| 786 | 786 | |
| 787 | | void c64_m6510_port_write(UINT8 direction, UINT8 data) |
| 787 | void c64_m6510_port_write(const device_config *device, UINT8 direction, UINT8 data) |
| 788 | 788 | { |
| 789 | | running_machine *machine = Machine; |
| 790 | | |
| 791 | 789 | /* if line is marked as input then keep current value */ |
| 792 | 790 | data = (c64_port_data & ~direction) | (data & direction); |
| 793 | 791 | |
| r3879 | r3880 | |
| 807 | 805 | { |
| 808 | 806 | if (direction & 0x08) |
| 809 | 807 | { |
| 810 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), (data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); |
| 808 | cassette_output(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ), (data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1)); |
| 811 | 809 | } |
| 812 | 810 | |
| 813 | 811 | if (direction & 0x20) |
| 814 | 812 | { |
| 815 | 813 | if(!(data & 0x20)) |
| 816 | 814 | { |
| 817 | | cassette_change_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 815 | cassette_change_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 818 | 816 | timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100)); |
| 819 | 817 | } |
| 820 | 818 | else |
| 821 | 819 | { |
| 822 | | cassette_change_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 820 | cassette_change_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" ), CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 823 | 821 | timer_reset(datasette_timer, attotime_never); |
| 824 | 822 | } |
| 825 | 823 | } |
| 826 | 824 | } |
| 827 | 825 | |
| 828 | | if (is_c65(machine)) |
| 826 | if (is_c65(device->machine)) |
| 829 | 827 | { |
| 830 | 828 | // NPW 8-Feb-2004 - Don't know why I have to do this |
| 831 | 829 | //c65_bankswitch(machine); |
| 832 | 830 | } |
| 833 | 831 | |
| 834 | 832 | else if (!ultimax) |
| 835 | | c64_bankswitch(machine, 0); |
| 833 | c64_bankswitch(device->machine, 0); |
| 836 | 834 | |
| 837 | | c64_memory[0x000] = memory_read_byte( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0 ); |
| 838 | | c64_memory[0x001] = memory_read_byte( cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 1 ); |
| 835 | c64_memory[0x000] = memory_read_byte( cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 0 ); |
| 836 | c64_memory[0x001] = memory_read_byte( cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 1 ); |
| 839 | 837 | } |
| 840 | 838 | |
| 841 | | UINT8 c64_m6510_port_read(UINT8 direction) |
| 839 | UINT8 c64_m6510_port_read(const device_config *device, UINT8 direction) |
| 842 | 840 | { |
| 843 | | running_machine *machine = Machine; |
| 844 | 841 | UINT8 data = c64_port_data; |
| 845 | 842 | |
| 846 | 843 | if (c64_tape_on) |
| 847 | 844 | { |
| 848 | | if ((cassette_get_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 845 | if ((cassette_get_state(device_list_find_by_tag(device->machine->config->devicelist, CASSETTE, "cassette" )) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| 849 | 846 | data &= ~0x10; |
| 850 | 847 | else |
| 851 | 848 | data |= 0x10; |
| 852 | 849 | } |
| 853 | 850 | |
| 854 | | if (is_c65(machine)) |
| 851 | if (is_c65(device->machine)) |
| 855 | 852 | { |
| 856 | | if (input_port_read(machine, "SPECIAL") & 0x20) /* Check Caps Lock */ |
| 853 | if (input_port_read(device->machine, "SPECIAL") & 0x20) /* Check Caps Lock */ |
| 857 | 854 | data &= ~0x40; |
| 858 | 855 | |
| 859 | 856 | else |
| r3879 | r3880 | |
| 980 | 977 | * a15 and a14 portlines |
| 981 | 978 | * 0x1000-0x1fff, 0x9000-0x9fff char rom |
| 982 | 979 | */ |
| 983 | | static int c64_dma_read( int offset ) |
| 980 | static int c64_dma_read(running_machine *machine, int offset) |
| 984 | 981 | { |
| 985 | 982 | if (!c64_game && c64_exrom) |
| 986 | 983 | { |
| r3879 | r3880 | |
| 996 | 993 | return c64_vicaddr[offset]; |
| 997 | 994 | } |
| 998 | 995 | |
| 999 | | static int c64_dma_read_ultimax( int offset ) |
| 996 | static int c64_dma_read_ultimax(running_machine *machine, int offset ) |
| 1000 | 997 | { |
| 1001 | 998 | if (offset < 0x3000) |
| 1002 | 999 | return c64_memory[offset]; |
| r3879 | r3880 | |
| 1004 | 1001 | return c64_romh[offset & 0x1fff]; |
| 1005 | 1002 | } |
| 1006 | 1003 | |
| 1007 | | static int c64_dma_read_color( int offset ) |
| 1004 | static int c64_dma_read_color(running_machine *machine, int offset) |
| 1008 | 1005 | { |
| 1009 | 1006 | return c64_colorram[offset & 0x3ff] & 0xf; |
| 1010 | 1007 | } |