src/mess/drivers/gmaster.c
| r0 | r1867 | |
| 1 | /****************************************************************************** |
| 2 | PeT mess@utanet.at march 2002 |
| 3 | ******************************************************************************/ |
| 4 | |
| 5 | #include "driver.h" |
| 6 | #include "deprecat.h" |
| 7 | #include "mslegacy.h" |
| 8 | //#include "vidhrdw/generic.h" |
| 9 | #include "cpu/upd7810/upd7810.h" |
| 10 | #include "devices/cartslot.h" |
| 11 | |
| 12 | #include "includes/gmaster.h" |
| 13 | |
| 14 | |
| 15 | static struct { |
| 16 | UINT8 data[8]; |
| 17 | int index; |
| 18 | int x, y; |
| 19 | /*bool*/int mode; // true read does not increase address |
| 20 | /*bool*/int delayed; |
| 21 | UINT8 pixels[8][64/*>=62 sure*/]; |
| 22 | } gmaster_video; |
| 23 | |
| 24 | typedef struct { |
| 25 | UINT8 ports[5]; |
| 26 | } GMASTER; |
| 27 | static GMASTER gmaster; |
| 28 | |
| 29 | static READ8_HANDLER( gmaster_io_r ) |
| 30 | { |
| 31 | UINT8 data=0; |
| 32 | if (gmaster.ports[2]&1) { |
| 33 | data=memory_region(REGION_CPU1)[0x4000+offset]; |
| 34 | logerror("%.4x external memory %.4x read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset,data); |
| 35 | } else { |
| 36 | switch (offset) { |
| 37 | case 1: |
| 38 | data=gmaster_video.pixels[gmaster_video.y][gmaster_video.x]; |
| 39 | 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 | if (!(gmaster_video.mode)&&gmaster_video.delayed) gmaster_video.x++; |
| 41 | gmaster_video.delayed=TRUE; |
| 42 | break; |
| 43 | default: |
| 44 | logerror("%.4x memory %.4x read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset,data); |
| 45 | } |
| 46 | } |
| 47 | return data; |
| 48 | } |
| 49 | |
| 50 | #define BLITTER_Y ((gmaster.ports[2]&4)|(gmaster_video.data[0]&3)) |
| 51 | |
| 52 | static WRITE8_HANDLER( gmaster_io_w ) |
| 53 | { |
| 54 | if (gmaster.ports[2]&1) { |
| 55 | memory_region(REGION_CPU1)[0x4000+offset]=data; |
| 56 | logerror("%.4x external memory %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 57 | } else { |
| 58 | switch (offset) { |
| 59 | case 0: |
| 60 | gmaster_video.delayed=FALSE; |
| 61 | logerror("%.4x lcd %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 62 | // e2 af a4 a0 a9 falling block init for both halves |
| 63 | if ((data&0xfc)==0xb8) { |
| 64 | gmaster_video.index=0; |
| 65 | gmaster_video.data[gmaster_video.index]=data; |
| 66 | gmaster_video.y=BLITTER_Y; |
| 67 | } else if ((data&0xc0)==0) { |
| 68 | gmaster_video.x=data; |
| 69 | } else if ((data&0xf0)==0xe0) { |
| 70 | gmaster_video.mode=(data&0xe)?FALSE:TRUE; |
| 71 | } |
| 72 | gmaster_video.data[gmaster_video.index]=data; |
| 73 | gmaster_video.index=(gmaster_video.index+1)&7; |
| 74 | break; |
| 75 | case 1: |
| 76 | gmaster_video.delayed=FALSE; |
| 77 | if (gmaster_video.x<ARRAY_LENGTH(gmaster_video.pixels[0])) // continental galaxy flutlicht |
| 78 | gmaster_video.pixels[gmaster_video.y][gmaster_video.x]=data; |
| 79 | logerror("%.4x lcd x:%.2x y:%.2x %.4x written %.2x\n", |
| 80 | (int)activecpu_get_reg(CPUINFO_INT_PC), gmaster_video.x, gmaster_video.y, 0x4000+offset, data); |
| 81 | gmaster_video.x++; |
| 82 | /* 02 b8 1a |
| 83 | 02 bb 1a |
| 84 | 02 bb 22 |
| 85 | 04 b8 12 |
| 86 | 04 b8 1a |
| 87 | 04 b8 22 |
| 88 | 04 b9 12 |
| 89 | 04 b9 1a |
| 90 | 04 b9 22 |
| 91 | 02 bb 12 |
| 92 | 4000 e0 |
| 93 | rr w rr w rr w rr w rr w rr w rr w rr w |
| 94 | 4000 ee |
| 95 | */ |
| 96 | break; |
| 97 | default: |
| 98 | logerror("%.4x memory %.4x written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), 0x4000+offset, data); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | static READ8_HANDLER( gmaster_port_r ) |
| 104 | { |
| 105 | // UINT8 data=gmaster.ports[offset]; |
| 106 | UINT8 data=0xff; |
| 107 | switch (offset) { |
| 108 | case UPD7810_PORTA: |
| 109 | data=readinputport(0); |
| 110 | break; |
| 111 | default: |
| 112 | logerror("%.4x port %d read %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC),offset,data); |
| 113 | } |
| 114 | return data; |
| 115 | } |
| 116 | |
| 117 | static WRITE8_HANDLER( gmaster_port_w ) |
| 118 | { |
| 119 | gmaster.ports[offset]=data; |
| 120 | logerror("%.4x port %d written %.2x\n",(int)activecpu_get_reg(CPUINFO_INT_PC), offset, data); |
| 121 | switch (offset) { |
| 122 | case UPD7810_PORTC: |
| 123 | gmaster_video.y=BLITTER_Y; |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | static ADDRESS_MAP_START( gmaster_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 129 | AM_RANGE(0x0000, 0x3fff) AM_ROM |
| 130 | AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w) |
| 131 | AM_RANGE(0x8000, 0xfeff) AM_ROM |
| 132 | AM_RANGE(0xff00, 0xffff) AM_RAM |
| 133 | ADDRESS_MAP_END |
| 134 | |
| 135 | static ADDRESS_MAP_START(gmaster_io, ADDRESS_SPACE_IO, 8) |
| 136 | AM_RANGE(UPD7810_PORTA, UPD7810_PORTF) AM_READWRITE(gmaster_port_r, gmaster_port_w ) |
| 137 | ADDRESS_MAP_END |
| 138 | |
| 139 | static INPUT_PORTS_START( gmaster ) |
| 140 | PORT_START |
| 141 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) |
| 142 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) |
| 143 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) |
| 144 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) |
| 145 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("B") |
| 146 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("A") |
| 147 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT) PORT_NAME("select") |
| 148 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("start") |
| 149 | INPUT_PORTS_END |
| 150 | |
| 151 | /* palette in red, green, blue tribles */ |
| 152 | static unsigned char gmaster_palette[2][3] = |
| 153 | { |
| 154 | #if 1 |
| 155 | // ziemlich schwierig den lcd touch rüberzubringen |
| 156 | // es ist hauptsächlich die das fleckige grünlich, bläuliche |
| 157 | { 130, 159, 166 }, |
| 158 | { 45,45,43 } |
| 159 | #else |
| 160 | { 255,255,255 }, |
| 161 | { 0, 0, 0 } |
| 162 | #endif |
| 163 | }; |
| 164 | |
| 165 | static PALETTE_INIT( gmaster ) |
| 166 | { |
| 167 | palette_set_colors_rgb(machine, 0, (unsigned char*)gmaster_palette, sizeof(gmaster_palette)); |
| 168 | } |
| 169 | |
| 170 | static VIDEO_UPDATE( gmaster ) |
| 171 | { |
| 172 | int x,y; |
| 173 | // plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, Machine->pens[0]); //xmess rounds up to 64 pixel |
| 174 | for (y=0;y<ARRAY_LENGTH(gmaster_video.pixels); y++) { |
| 175 | for (x=0;x<ARRAY_LENGTH(gmaster_video.pixels[0]);x++) { |
| 176 | UINT8 d=gmaster_video.pixels[y][x]; |
| 177 | UINT16 *line; |
| 178 | line=BITMAP_ADDR16(bitmap, (y*8), x); |
| 179 | line[0]=(d>>0)&1; |
| 180 | line=BITMAP_ADDR16(bitmap, (y*8+1), x); |
| 181 | line[0]=(d>>1)&1; |
| 182 | line=BITMAP_ADDR16(bitmap, (y*8+2), x); |
| 183 | line[0]=(d>>2)&1; |
| 184 | line=BITMAP_ADDR16(bitmap, (y*8+3), x); |
| 185 | line[0]=(d>>3)&1; |
| 186 | line=BITMAP_ADDR16(bitmap, (y*8+4), x); |
| 187 | line[0]=(d>>4)&1; |
| 188 | line=BITMAP_ADDR16(bitmap, (y*8+5), x); |
| 189 | line[0]=(d>>5)&1; |
| 190 | line=BITMAP_ADDR16(bitmap, (y*8+6), x); |
| 191 | line[0]=(d>>6)&1; |
| 192 | line=BITMAP_ADDR16(bitmap, (y*8+7), x); |
| 193 | line[0]=(d>>7)&1; |
| 194 | } |
| 195 | } |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static INTERRUPT_GEN( gmaster_interrupt ) |
| 200 | { |
| 201 | cpunum_set_input_line(machine, 0, UPD7810_INTFE1, PULSE_LINE); |
| 202 | } |
| 203 | |
| 204 | static UPD7810_CONFIG config={ |
| 205 | // TYPE_7810, |
| 206 | TYPE_7801, // temporarily until 7810 core fixes synchronized |
| 207 | gmaster_io_callback |
| 208 | }; |
| 209 | |
| 210 | static const struct CustomSound_interface gmaster_sound_interface = |
| 211 | { |
| 212 | gmaster_custom_start |
| 213 | }; |
| 214 | |
| 215 | static MACHINE_DRIVER_START( gmaster ) |
| 216 | MDRV_CPU_ADD_TAG("main", UPD7810, 5000000) |
| 217 | MDRV_CPU_PROGRAM_MAP(gmaster_mem, 0) |
| 218 | MDRV_CPU_IO_MAP( gmaster_io, 0 ) |
| 219 | MDRV_CPU_CONFIG( config ) |
| 220 | MDRV_CPU_VBLANK_INT(gmaster_interrupt,1) |
| 221 | |
| 222 | MDRV_SCREEN_ADD("main", LCD) |
| 223 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 224 | MDRV_SCREEN_REFRESH_RATE(60) |
| 225 | MDRV_SCREEN_SIZE(64, 64) |
| 226 | MDRV_SCREEN_VISIBLE_AREA(0, 64-1-3, 0, 64-1) |
| 227 | MDRV_PALETTE_LENGTH(sizeof(gmaster_palette)/sizeof(gmaster_palette[0])) |
| 228 | MDRV_VIDEO_UPDATE(gmaster) |
| 229 | MDRV_PALETTE_INIT(gmaster) |
| 230 | |
| 231 | MDRV_SPEAKER_STANDARD_MONO("gmaster") |
| 232 | MDRV_SOUND_ADD(CUSTOM, 0) |
| 233 | MDRV_SOUND_CONFIG(gmaster_sound_interface) |
| 234 | MDRV_SOUND_ROUTE(0, "gmaster", 0.50) |
| 235 | MACHINE_DRIVER_END |
| 236 | |
| 237 | |
| 238 | ROM_START(gmaster) |
| 239 | ROM_REGION(0x10000,REGION_CPU1, 0) |
| 240 | ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) ) |
| 241 | ROM_CART_LOAD(0, "bin", 0x8000, 0x7eff, 0) |
| 242 | ROM_END |
| 243 | |
| 244 | static DRIVER_INIT( gmaster ) |
| 245 | { |
| 246 | memset(&gmaster_video, 0, sizeof(gmaster_video)); |
| 247 | |
| 248 | } |
| 249 | |
| 250 | #if 0 |
| 251 | static int gmaster_load_rom(int id) |
| 252 | { |
| 253 | FILE *cartfile; |
| 254 | UINT8 *rom = memory_region(REGION_CPU1); |
| 255 | int size; |
| 256 | |
| 257 | if (device_filename(IO_CARTSLOT, id) == NULL) |
| 258 | { |
| 259 | printf("%s requires Cartridge!\n", Machine->gamedrv->name); |
| 260 | return 0; |
| 261 | } |
| 262 | |
| 263 | if (!(cartfile = (FILE*)image_fopen(IO_CARTSLOT, id, OSD_FILETYPE_IMAGE_R, 0))) |
| 264 | { |
| 265 | logerror("%s not found\n",device_filename(IO_CARTSLOT,id)); |
| 266 | return 1; |
| 267 | } |
| 268 | size=osd_fsize(cartfile); |
| 269 | if (size>0x8000) { |
| 270 | logerror("%s: size %d not yet supported\n",device_filename(IO_CARTSLOT,id), size); |
| 271 | return 1; |
| 272 | } |
| 273 | |
| 274 | if (osd_fread(cartfile, rom+0x8000, size)!=size) { |
| 275 | logerror("%s load error\n",device_filename(IO_CARTSLOT,id)); |
| 276 | osd_fclose(cartfile); |
| 277 | return 1; |
| 278 | } |
| 279 | // memcpy(rom+0x0000, rom+0x8000, 0x4000); |
| 280 | osd_fclose(cartfile); |
| 281 | return 0; |
| 282 | } |
| 283 | #endif |
| 284 | |
| 285 | SYSTEM_CONFIG_START(gmaster) |
| 286 | CONFIG_DEVICE(cartslot_device_getinfo) |
| 287 | SYSTEM_CONFIG_END |
| 288 | |
| 289 | /* YEAR NAME PARENT MACHINE INPUT INIT |
| 290 | COMPANY FULLNAME */ |
| 291 | CONS( 1990, gmaster, 0, 0, gmaster, gmaster, gmaster, gmaster, "Hartung", "Gamemaster", GAME_IMPERFECT_SOUND) |
| 292 | |