src/mess/machine/gamepock.c
| r3677 | r3678 | |
| 15 | 15 | static UINT8 gamepock_port_b; |
| 16 | 16 | static HD44102CH hd44102ch[3]; |
| 17 | 17 | |
| 18 | | static void hd44102ch_w( int which, int c_d, UINT8 data ) { |
| 19 | | if ( c_d ) { |
| 18 | static void hd44102ch_w( int which, int c_d, UINT8 data ) |
| 19 | { |
| 20 | if ( c_d ) |
| 21 | { |
| 20 | 22 | UINT8 y; |
| 21 | 23 | /* Data */ |
| 22 | 24 | hd44102ch[which].ram[ hd44102ch[which].address ] = data; |
| 23 | 25 | |
| 24 | 26 | /* Increment/decrement Y counter */ |
| 25 | 27 | y = ( hd44102ch[which].address & 0x3F ) + hd44102ch[which].y_inc; |
| 26 | | if ( y == 0xFF ) { |
| 28 | if ( y == 0xFF ) |
| 29 | { |
| 27 | 30 | y = 49; |
| 28 | 31 | } |
| 29 | | if ( y == 50 ) { |
| 32 | if ( y == 50 ) |
| 33 | { |
| 30 | 34 | y = 0; |
| 31 | 35 | } |
| 32 | 36 | hd44102ch[which].address = ( hd44102ch[which].address & 0xC0 ) | y; |
| 33 | | } else { |
| 37 | } |
| 38 | else |
| 39 | { |
| 34 | 40 | /* Command */ |
| 35 | | switch ( data ) { |
| 41 | switch ( data ) |
| 42 | { |
| 36 | 43 | case 0x38: /* Display off */ |
| 37 | 44 | hd44102ch[which].enabled = 0; |
| 38 | 45 | break; |
| r3677 | r3678 | |
| 52 | 59 | hd44102ch[which].start_page = data & 0xC0; |
| 53 | 60 | break; |
| 54 | 61 | default: |
| 55 | | if ( ( data & 0x3F ) < 50 ) { |
| 62 | if ( ( data & 0x3F ) < 50 ) |
| 63 | { |
| 56 | 64 | hd44102ch[which].address = data; |
| 57 | 65 | } |
| 58 | 66 | break; |
| r3677 | r3678 | |
| 60 | 68 | } |
| 61 | 69 | } |
| 62 | 70 | |
| 63 | | static void hd44102ch_init( int which ) { |
| 71 | static void hd44102ch_init( int which ) |
| 72 | { |
| 64 | 73 | memset( &hd44102ch[which], 0, sizeof( HD44102CH ) ); |
| 65 | 74 | hd44102ch[which].y_inc = 0x01; |
| 66 | 75 | } |
| 67 | 76 | |
| 68 | | static void gamepock_lcd_update(void) { |
| 77 | static void gamepock_lcd_update(void) |
| 78 | { |
| 69 | 79 | /* Check whether HD44102CH #1 is enabled */ |
| 70 | | if ( gamepock_port_a & 0x08 ) { |
| 80 | if ( gamepock_port_a & 0x08 ) |
| 81 | { |
| 71 | 82 | hd44102ch_w( 0, gamepock_port_a & 0x04, gamepock_port_b ); |
| 72 | 83 | } |
| 73 | 84 | |
| 74 | 85 | /* Check whether HD44102CH #2 is enabled */ |
| 75 | | if ( gamepock_port_a & 0x10 ) { |
| 86 | if ( gamepock_port_a & 0x10 ) |
| 87 | { |
| 76 | 88 | hd44102ch_w( 1, gamepock_port_a & 0x04, gamepock_port_b ); |
| 77 | 89 | } |
| 78 | 90 | |
| 79 | 91 | /* Check whether HD44102CH #3 is enabled */ |
| 80 | | if ( gamepock_port_a & 0x20 ) { |
| 92 | if ( gamepock_port_a & 0x20 ) |
| 93 | { |
| 81 | 94 | hd44102ch_w( 2, gamepock_port_a & 0x04, gamepock_port_b ); |
| 82 | 95 | } |
| 83 | 96 | } |
| 84 | 97 | |
| 85 | | WRITE8_HANDLER( gamepock_port_a_w ) { |
| 98 | WRITE8_HANDLER( gamepock_port_a_w ) |
| 99 | { |
| 86 | 100 | UINT8 old_port_a = gamepock_port_a; |
| 87 | 101 | |
| 88 | 102 | gamepock_port_a = data; |
| 89 | 103 | |
| 90 | | if ( ! ( old_port_a & 0x02 ) && ( gamepock_port_a & 0x02 ) ) { |
| 104 | if ( ! ( old_port_a & 0x02 ) && ( gamepock_port_a & 0x02 ) ) |
| 105 | { |
| 91 | 106 | gamepock_lcd_update(); |
| 92 | 107 | } |
| 93 | 108 | } |
| 94 | 109 | |
| 95 | | WRITE8_HANDLER( gamepock_port_b_w ) { |
| 110 | WRITE8_HANDLER( gamepock_port_b_w ) |
| 111 | { |
| 96 | 112 | gamepock_port_b = data; |
| 97 | 113 | } |
| 98 | 114 | |
| 99 | | READ8_HANDLER( gamepock_port_b_r ) { |
| 115 | READ8_HANDLER( gamepock_port_b_r ) |
| 116 | { |
| 100 | 117 | logerror("gamepock_port_b_r: not implemented\n"); |
| 101 | 118 | return 0xFF; |
| 102 | 119 | } |
| 103 | 120 | |
| 104 | | READ8_HANDLER( gamepock_port_c_r ) { |
| 121 | READ8_HANDLER( gamepock_port_c_r ) |
| 122 | { |
| 105 | 123 | UINT8 data = 0xFF; |
| 106 | 124 | |
| 107 | 125 | if ( gamepock_port_a & 0x80 ) |
| 108 | 126 | { |
| 109 | | data &= input_port_read(machine, "IN0"); |
| 127 | data &= input_port_read(space->machine, "IN0"); |
| 110 | 128 | } |
| 111 | 129 | |
| 112 | 130 | if ( gamepock_port_a & 0x40 ) |
| 113 | 131 | { |
| 114 | | data &= input_port_read(machine, "IN1"); |
| 132 | data &= input_port_read(space->machine, "IN1"); |
| 115 | 133 | } |
| 116 | 134 | |
| 117 | 135 | return data; |
| 118 | 136 | } |
| 119 | 137 | |
| 120 | | MACHINE_RESET( gamepock ) { |
| 138 | MACHINE_RESET( gamepock ) |
| 139 | { |
| 121 | 140 | hd44102ch_init( 0 ); |
| 122 | 141 | hd44102ch_init( 1 ); |
| 123 | 142 | hd44102ch_init( 2 ); |
| 124 | 143 | } |
| 125 | 144 | |
| 126 | | VIDEO_UPDATE( gamepock ) { |
| 145 | VIDEO_UPDATE( gamepock ) |
| 146 | { |
| 127 | 147 | UINT8 ad; |
| 128 | 148 | int i,j; |
| 129 | 149 | |
| 130 | 150 | /* Handle HD44102CH #0 */ |
| 131 | 151 | ad = hd44102ch[0].start_page; |
| 132 | | for ( i = 0; i < 4; i++ ) { |
| 133 | | for ( j = 0; j < 50; j++ ) { |
| 152 | for ( i = 0; i < 4; i++ ) |
| 153 | { |
| 154 | for ( j = 0; j < 50; j++ ) |
| 155 | { |
| 134 | 156 | *BITMAP_ADDR16(bitmap, i * 8 + 0, 49 - j ) = ( hd44102ch[0].ram[ad+j] & 0x01 ) ? 0 : 1; |
| 135 | 157 | *BITMAP_ADDR16(bitmap, i * 8 + 1, 49 - j ) = ( hd44102ch[0].ram[ad+j] & 0x02 ) ? 0 : 1; |
| 136 | 158 | *BITMAP_ADDR16(bitmap, i * 8 + 2, 49 - j ) = ( hd44102ch[0].ram[ad+j] & 0x04 ) ? 0 : 1; |
| r3677 | r3678 | |
| 145 | 167 | |
| 146 | 168 | /* Handle HD44102CH #1 */ |
| 147 | 169 | ad = hd44102ch[1].start_page; |
| 148 | | for ( i = 4; i < 8; i++ ) { |
| 149 | | for ( j = 0; j < 50; j++ ) { |
| 170 | for ( i = 4; i < 8; i++ ) |
| 171 | { |
| 172 | for ( j = 0; j < 50; j++ ) |
| 173 | { |
| 150 | 174 | *BITMAP_ADDR16(bitmap, i * 8 + 0, j ) = ( hd44102ch[1].ram[ad+j] & 0x01 ) ? 0 : 1; |
| 151 | 175 | *BITMAP_ADDR16(bitmap, i * 8 + 1, j ) = ( hd44102ch[1].ram[ad+j] & 0x02 ) ? 0 : 1; |
| 152 | 176 | *BITMAP_ADDR16(bitmap, i * 8 + 2, j ) = ( hd44102ch[1].ram[ad+j] & 0x04 ) ? 0 : 1; |
| r3677 | r3678 | |
| 161 | 185 | |
| 162 | 186 | /* Handle HD44102CH #2 */ |
| 163 | 187 | ad = hd44102ch[2].start_page; |
| 164 | | for ( i = 0; i < 4; i++ ) { |
| 165 | | for ( j = 0; j < 25; j++ ) { |
| 188 | for ( i = 0; i < 4; i++ ) |
| 189 | { |
| 190 | for ( j = 0; j < 25; j++ ) |
| 191 | { |
| 166 | 192 | *BITMAP_ADDR16(bitmap, i * 8 + 0, 50 + j ) = ( hd44102ch[2].ram[ad+j] & 0x01 ) ? 0 : 1; |
| 167 | 193 | *BITMAP_ADDR16(bitmap, i * 8 + 1, 50 + j ) = ( hd44102ch[2].ram[ad+j] & 0x02 ) ? 0 : 1; |
| 168 | 194 | *BITMAP_ADDR16(bitmap, i * 8 + 2, 50 + j ) = ( hd44102ch[2].ram[ad+j] & 0x04 ) ? 0 : 1; |
| r3677 | r3678 | |
| 172 | 198 | *BITMAP_ADDR16(bitmap, i * 8 + 6, 50 + j ) = ( hd44102ch[2].ram[ad+j] & 0x40 ) ? 0 : 1; |
| 173 | 199 | *BITMAP_ADDR16(bitmap, i * 8 + 7, 50 + j ) = ( hd44102ch[2].ram[ad+j] & 0x80 ) ? 0 : 1; |
| 174 | 200 | } |
| 175 | | for ( j = 25; j < 50; j++ ) { |
| 201 | for ( j = 25; j < 50; j++ ) |
| 202 | { |
| 176 | 203 | *BITMAP_ADDR16(bitmap, 32 + i * 8 + 0, 25 + j ) = ( hd44102ch[2].ram[ad+j] & 0x01 ) ? 0 : 1; |
| 177 | 204 | *BITMAP_ADDR16(bitmap, 32 + i * 8 + 1, 25 + j ) = ( hd44102ch[2].ram[ad+j] & 0x02 ) ? 0 : 1; |
| 178 | 205 | *BITMAP_ADDR16(bitmap, 32 + i * 8 + 2, 25 + j ) = ( hd44102ch[2].ram[ad+j] & 0x04 ) ? 0 : 1; |
| r3677 | r3678 | |
| 189 | 216 | } |
| 190 | 217 | |
| 191 | 218 | /* This is called whenever the T0 pin switches state */ |
| 192 | | int gamepock_io_callback( int ioline, int state ) { |
| 193 | | if ( ioline == UPD7810_TO ) { |
| 219 | int gamepock_io_callback( int ioline, int state ) |
| 220 | { |
| 221 | if ( ioline == UPD7810_TO ) |
| 222 | { |
| 194 | 223 | speaker_level_w(0, state & 1 ); |
| 195 | 224 | } |
| 196 | 225 | return 0; |
src/mess/drivers/gmaster.c
| r3677 | r3678 | |
| 31 | 31 | { |
| 32 | 32 | UINT8 data=0; |
| 33 | 33 | if (gmaster.ports[2]&1) { |
| 34 | | data=memory_region(machine, "main")[0x4000+offset]; |
| 35 | | logerror("%.4x external memory %.4x read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset,data); |
| 34 | data=memory_region(space->machine, "main")[0x4000+offset]; |
| 35 | logerror("%.4x external memory %.4x read %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000+offset,data); |
| 36 | 36 | } else { |
| 37 | 37 | switch (offset) { |
| 38 | 38 | case 1: |
| 39 | 39 | data=gmaster_video.pixels[gmaster_video.y][gmaster_video.x]; |
| 40 | | logerror("%.4x lcd x:%.2x y:%.2x %.4x read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), gmaster_video.x, gmaster_video.y, 0x4000+offset,data); |
| 40 | logerror("%.4x lcd x:%.2x y:%.2x %.4x read %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), gmaster_video.x, gmaster_video.y, 0x4000+offset,data); |
| 41 | 41 | if (!(gmaster_video.mode)&&gmaster_video.delayed) gmaster_video.x++; |
| 42 | 42 | gmaster_video.delayed=TRUE; |
| 43 | 43 | break; |
| 44 | 44 | default: |
| 45 | | logerror("%.4x memory %.4x read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset,data); |
| 45 | logerror("%.4x memory %.4x read %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000+offset,data); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | return data; |
| r3677 | r3678 | |
| 53 | 53 | static WRITE8_HANDLER( gmaster_io_w ) |
| 54 | 54 | { |
| 55 | 55 | if (gmaster.ports[2]&1) { |
| 56 | | memory_region(machine, "main")[0x4000+offset]=data; |
| 57 | | logerror("%.4x external memory %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 56 | memory_region(space->machine, "main")[0x4000+offset]=data; |
| 57 | logerror("%.4x external memory %.4x written %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000+offset, data); |
| 58 | 58 | } else { |
| 59 | 59 | switch (offset) { |
| 60 | 60 | case 0: |
| 61 | 61 | gmaster_video.delayed=FALSE; |
| 62 | | logerror("%.4x lcd %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 62 | logerror("%.4x lcd %.4x written %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000+offset, data); |
| 63 | 63 | // e2 af a4 a0 a9 falling block init for both halves |
| 64 | 64 | if ((data&0xfc)==0xb8) { |
| 65 | 65 | gmaster_video.index=0; |
| r3677 | r3678 | |
| 78 | 78 | if (gmaster_video.x<ARRAY_LENGTH(gmaster_video.pixels[0])) // continental galaxy flutlicht |
| 79 | 79 | gmaster_video.pixels[gmaster_video.y][gmaster_video.x]=data; |
| 80 | 80 | logerror("%.4x lcd x:%.2x y:%.2x %.4x written %.2x\n", |
| 81 | | (int)activecpu_get_reg(CPUINFO_INT_PC), gmaster_video.x, gmaster_video.y, 0x4000+offset, data); |
| 81 | (int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), gmaster_video.x, gmaster_video.y, 0x4000+offset, data); |
| 82 | 82 | gmaster_video.x++; |
| 83 | 83 | /* 02 b8 1a |
| 84 | 84 | 02 bb 1a |
| r3677 | r3678 | |
| 96 | 96 | */ |
| 97 | 97 | break; |
| 98 | 98 | default: |
| 99 | | logerror("%.4x memory %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 99 | logerror("%.4x memory %.4x written %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000+offset, data); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
| r3677 | r3678 | |
| 107 | 107 | UINT8 data=0xff; |
| 108 | 108 | switch (offset) { |
| 109 | 109 | case UPD7810_PORTA: |
| 110 | | data=input_port_read(machine, "JOY"); |
| 110 | data=input_port_read(space->machine, "JOY"); |
| 111 | 111 | break; |
| 112 | 112 | default: |
| 113 | | logerror("%.4x port %d read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC),offset,data); |
| 113 | logerror("%.4x port %d read %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC),offset,data); |
| 114 | 114 | } |
| 115 | 115 | return data; |
| 116 | 116 | } |
| r3677 | r3678 | |
| 118 | 118 | static WRITE8_HANDLER( gmaster_port_w ) |
| 119 | 119 | { |
| 120 | 120 | gmaster.ports[offset]=data; |
| 121 | | logerror("%.4x port %d written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), offset, data); |
| 121 | logerror("%.4x port %d written %.2x\n",(int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), offset, data); |
| 122 | 122 | switch (offset) { |
| 123 | 123 | case UPD7810_PORTC: |
| 124 | 124 | gmaster_video.y=BLITTER_Y; |
| r3677 | r3678 | |
| 203 | 203 | |
| 204 | 204 | static INTERRUPT_GEN( gmaster_interrupt ) |
| 205 | 205 | { |
| 206 | | cpu_set_input_line(machine->cpu[0], UPD7810_INTFE1, PULSE_LINE); |
| 206 | cpu_set_input_line(device->machine->cpu[0], UPD7810_INTFE1, PULSE_LINE); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | static UPD7810_CONFIG config={ |