src/mess/drivers/pc6001.c
| r8698 | r8699 | |
| 126 | 126 | pc6001_video_ram = auto_alloc_array(machine, UINT8, 0x2000); //0x400? We'll see... |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | | static VIDEO_UPDATE( pc6001 ) |
| 129 | static void draw_bitmap_1bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int attr) |
| 130 | 130 | { |
| 131 | | UINT8 *gfx_data = memory_region(screen->machine, "gfx1"); |
| 132 | | int x,y,xi,yi; |
| 133 | | int tile,attr,pen,color; |
| 134 | | int fgcol; |
| 131 | int x,y,xi; |
| 132 | int fgcol,color; |
| 135 | 133 | |
| 136 | | attr = pc6001_video_ram[0]; |
| 134 | fgcol = (attr & 2) ? 7 : 2; |
| 137 | 135 | |
| 138 | | if(attr & 0x80) // gfx mode |
| 136 | for(y=0;y<192;y++) |
| 139 | 137 | { |
| 140 | | if(attr & 0x10) // 256x192x1 mode (FIXME: might be a different trigger) |
| 138 | for(x=0;x<32;x++) |
| 141 | 139 | { |
| 142 | | fgcol = (attr & 2) ? 7 : 2; |
| 140 | int tile = pc6001_video_ram[(x+(y*32))+0x200]; |
| 143 | 141 | |
| 144 | | for(y=0;y<192;y++) |
| 142 | for(xi=0;xi<8;xi++) |
| 145 | 143 | { |
| 146 | | for(x=0;x<32;x++) |
| 144 | color = ((tile)>>(7-xi) & 1) ? fgcol : 0; |
| 145 | |
| 146 | *BITMAP_ADDR16(bitmap, (y+24), (x*8+xi)+32) = machine->pens[color]; |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | static void draw_bitmap_2bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int attr) |
| 153 | { |
| 154 | int color,x,y,xi,yi; |
| 155 | |
| 156 | int shrink_x = 2*4; |
| 157 | int shrink_y = (attr & 8) ? 1 : 2; |
| 158 | int w = (shrink_x == 8) ? 32 : 16; |
| 159 | int col_bank = ((attr & 2)<<1); |
| 160 | |
| 161 | for(y=0;y<(192/shrink_y);y++) |
| 162 | { |
| 163 | for(x=0;x<w;x++) |
| 164 | { |
| 165 | int tile = pc6001_video_ram[(x+(y*32))+0x200]; |
| 166 | |
| 167 | for(yi=0;yi<shrink_y;yi++) |
| 168 | { |
| 169 | for(xi=0;xi<shrink_x;xi++) |
| 147 | 170 | { |
| 148 | | tile = pc6001_video_ram[(x+(y*32))+0x200]; |
| 171 | int i; |
| 172 | i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1; |
| 173 | color = ((tile >> i) & 3)+8; |
| 174 | color+= col_bank; |
| 149 | 175 | |
| 150 | | for(xi=0;xi<8;xi++) |
| 151 | | { |
| 152 | | color = ((tile)>>(7-xi) & 1) ? fgcol : 0; |
| 153 | | |
| 154 | | *BITMAP_ADDR16(bitmap, (y+24), (x*8+xi)+32) = screen->machine->pens[color]; |
| 155 | | } |
| 176 | *BITMAP_ADDR16(bitmap, ((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = machine->pens[color]; |
| 156 | 177 | } |
| 157 | 178 | } |
| 158 | 179 | } |
| 159 | | else // 128x192x2 mode |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | static void draw_tile_3bpp(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int x,int y,int tile,int attr) |
| 184 | { |
| 185 | int color,pen,xi,yi; |
| 186 | |
| 187 | if(attr & 0x10) //2x2 squares on a single cell |
| 188 | pen = (tile & 0x70)>>4; |
| 189 | else //2x3 |
| 190 | pen = (tile & 0xc0) >> 6 | (attr & 2)<<1; |
| 191 | |
| 192 | for(yi=0;yi<12;yi++) |
| 193 | { |
| 194 | for(xi=0;xi<8;xi++) |
| 160 | 195 | { |
| 161 | | int shrink_x = 2*4; |
| 162 | | int shrink_y = (attr & 8) ? 1 : 2; |
| 163 | | int w = (shrink_x == 8) ? 32 : 16; |
| 164 | | int col_bank = ((attr & 2)<<1); |
| 196 | int i; |
| 197 | i = (xi & 4)>>2; //x-axis |
| 198 | if(attr & 0x10) //2x2 |
| 199 | { |
| 200 | i+= (yi >= 6) ? 2 : 0; //y-axis |
| 201 | } |
| 202 | else //2x3 |
| 203 | { |
| 204 | i+= (yi & 4)>>1; //y-axis 1 |
| 205 | i+= (yi & 8)>>1; //y-axis 2 |
| 206 | } |
| 165 | 207 | |
| 166 | | for(y=0;y<(192/shrink_y);y++) |
| 208 | color = ((tile >> i) & 1) ? pen+8 : 0; |
| 209 | |
| 210 | *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = machine->pens[color]; |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | static void draw_tile_text(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int x,int y,int tile,int attr,int has_mc6847) |
| 216 | { |
| 217 | int xi,yi,pen,fgcol,color; |
| 218 | UINT8 *gfx_data = memory_region(machine, "gfx1"); |
| 219 | |
| 220 | for(yi=0;yi<12;yi++) |
| 221 | { |
| 222 | for(xi=0;xi<8;xi++) |
| 223 | { |
| 224 | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 225 | |
| 226 | if(has_mc6847) |
| 167 | 227 | { |
| 168 | | for(x=0;x<w;x++) |
| 169 | | { |
| 170 | | tile = pc6001_video_ram[(x+(y*32))+0x200]; |
| 228 | fgcol = (attr & 2) ? 0x12 : 0x10; |
| 171 | 229 | |
| 172 | | for(yi=0;yi<shrink_y;yi++) |
| 173 | | { |
| 174 | | for(xi=0;xi<shrink_x;xi++) |
| 175 | | { |
| 176 | | int i; |
| 177 | | i = (shrink_x == 8) ? (xi & 0x06) : (xi & 0x0c)>>1; |
| 178 | | color = ((tile >> i) & 3)+8; |
| 179 | | color+= col_bank; |
| 230 | if(attr & 1) |
| 231 | color = pen ? (fgcol+0) : (fgcol+1); |
| 232 | else |
| 233 | color = pen ? (fgcol+1) : (fgcol+0); |
| 180 | 234 | |
| 181 | | *BITMAP_ADDR16(bitmap, ((y*shrink_y+yi)+24), (x*shrink_x+((shrink_x-1)-xi))+32) = screen->machine->pens[color]; |
| 182 | | } |
| 183 | | } |
| 184 | | } |
| 185 | 235 | } |
| 236 | else |
| 237 | { |
| 238 | fgcol = (attr & 2) ? 2 : 7; |
| 239 | |
| 240 | if(attr & 1) |
| 241 | color = pen ? 0 : fgcol; |
| 242 | else |
| 243 | color = pen ? fgcol : 0; |
| 244 | } |
| 245 | |
| 246 | *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = machine->pens[color]; |
| 186 | 247 | } |
| 187 | 248 | } |
| 249 | } |
| 250 | |
| 251 | static void pc6001_screen_draw(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int has_mc6847) |
| 252 | { |
| 253 | int x,y; |
| 254 | int tile,attr; |
| 255 | |
| 256 | attr = pc6001_video_ram[0]; |
| 257 | |
| 258 | if(attr & 0x80) // gfx mode |
| 259 | { |
| 260 | if(attr & 0x10) // 256x192x1 mode (FIXME: might be a different trigger) |
| 261 | { |
| 262 | draw_bitmap_1bpp(machine,bitmap,cliprect,attr); |
| 263 | } |
| 264 | else // 128x192x2 mode |
| 265 | { |
| 266 | draw_bitmap_2bpp(machine,bitmap,cliprect,attr); |
| 267 | } |
| 268 | } |
| 188 | 269 | else // text mode |
| 189 | 270 | { |
| 190 | 271 | for(y=0;y<16;y++) |
| r8698 | r8699 | |
| 196 | 277 | |
| 197 | 278 | if(attr & 0x40) |
| 198 | 279 | { |
| 199 | | if(attr & 0x10) //2x2 squares on a single cell |
| 200 | | pen = (tile & 0x70)>>4; |
| 201 | | else //2x3 |
| 202 | | pen = (tile & 0xc0) >> 6 | (attr & 2)<<1; |
| 203 | | |
| 204 | | for(yi=0;yi<12;yi++) |
| 205 | | { |
| 206 | | for(xi=0;xi<8;xi++) |
| 207 | | { |
| 208 | | int i; |
| 209 | | i = (xi & 4)>>2; //x-axis |
| 210 | | if(attr & 0x10) //2x2 |
| 211 | | { |
| 212 | | i+= (yi >= 6) ? 2 : 0; //y-axis |
| 213 | | } |
| 214 | | else //2x3 |
| 215 | | { |
| 216 | | i+= (yi & 4)>>1; //y-axis 1 |
| 217 | | i+= (yi & 8)>>1; //y-axis 2 |
| 218 | | } |
| 219 | | |
| 220 | | color = ((tile >> i) & 1) ? pen+8 : 0; |
| 221 | | |
| 222 | | *BITMAP_ADDR16(bitmap, ((y*12+(11-yi))+24), (x*8+(7-xi))+32) = screen->machine->pens[color]; |
| 223 | | } |
| 224 | | } |
| 280 | draw_tile_3bpp(machine,bitmap,cliprect,x,y,tile,attr); |
| 225 | 281 | } |
| 226 | 282 | else |
| 227 | 283 | { |
| 228 | | for(yi=0;yi<12;yi++) |
| 229 | | { |
| 230 | | for(xi=0;xi<8;xi++) |
| 231 | | { |
| 232 | | pen = gfx_data[(tile*0x10)+yi]>>(7-xi) & 1; |
| 233 | | |
| 234 | | fgcol = (attr & 2) ? 2 : 7; |
| 235 | | |
| 236 | | if(attr & 1) |
| 237 | | color = pen ? 0 : fgcol; |
| 238 | | else |
| 239 | | color = pen ? fgcol : 0; |
| 240 | | |
| 241 | | *BITMAP_ADDR16(bitmap, ((y*12+yi)+24), (x*8+xi)+32) = screen->machine->pens[color]; |
| 242 | | } |
| 243 | | } |
| 284 | draw_tile_text(machine,bitmap,cliprect,x,y,tile,attr,has_mc6847); |
| 244 | 285 | } |
| 245 | 286 | } |
| 246 | 287 | } |
| 247 | 288 | } |
| 289 | } |
| 248 | 290 | |
| 291 | static VIDEO_UPDATE( pc6001 ) |
| 292 | { |
| 293 | pc6001_screen_draw(screen->machine,bitmap,cliprect,1); |
| 294 | |
| 249 | 295 | return 0; |
| 250 | 296 | } |
| 251 | 297 | |
| 298 | static VIDEO_UPDATE( pc6001m2 ) |
| 299 | { |
| 300 | pc6001_screen_draw(screen->machine,bitmap,cliprect,0); |
| 301 | |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 252 | 305 | static WRITE8_HANDLER ( pc6001_system_latch_w ) |
| 253 | 306 | { |
| 254 | 307 | UINT16 startaddr[] = {0xC000, 0xE000, 0x8000, 0xA000 }; |
| r8698 | r8699 | |
| 353 | 406 | |
| 354 | 407 | static ADDRESS_MAP_START(pc6001_map, ADDRESS_SPACE_PROGRAM, 8) |
| 355 | 408 | ADDRESS_MAP_UNMAP_HIGH |
| 356 | | AM_RANGE(0x0000, 0x3fff) AM_ROM |
| 409 | AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITENOP |
| 357 | 410 | AM_RANGE(0x4000, 0x5fff) AM_ROM AM_REGION("cart_img",0) |
| 358 | 411 | AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1") |
| 359 | 412 | AM_RANGE(0x8000, 0xffff) AM_RAM AM_BASE(&pc6001_ram) |
| r8698 | r8699 | |
| 667 | 720 | |
| 668 | 721 | static WRITE8_DEVICE_HANDLER (pc6001_8255_portb_w ) |
| 669 | 722 | { |
| 670 | | // printf("pc6001_8255_portb_w %02x\n",data); |
| 723 | //printf("pc6001_8255_portb_w %02x\n",data); |
| 671 | 724 | } |
| 672 | 725 | |
| 673 | 726 | static WRITE8_DEVICE_HANDLER (pc6001_8255_portc_w ) |
| 674 | 727 | { |
| 675 | | // printf("pc6001_8255_portc_w %02x\n",data); |
| 728 | //printf("pc6001_8255_portc_w %02x\n",data); |
| 676 | 729 | } |
| 677 | 730 | |
| 678 | 731 | static READ8_DEVICE_HANDLER (pc6001_8255_portc_r ) |
| r8698 | r8699 | |
| 866 | 919 | MAKE_RGB(0xff, 0xff, 0xff), /* BUFF */ |
| 867 | 920 | MAKE_RGB(0x00, 0xff, 0xff), /* CYAN */ |
| 868 | 921 | MAKE_RGB(0xff, 0x00, 0xff), /* MAGENTA */ |
| 869 | | MAKE_RGB(0xff, 0x80, 0x00) /* ORANGE */ |
| 922 | MAKE_RGB(0xff, 0x80, 0x00), /* ORANGE */ |
| 923 | |
| 924 | /* MC6847 specific */ |
| 925 | MAKE_RGB(0x00, 0x40, 0x00), /* ALPHANUMERIC DARK GREEN */ |
| 926 | MAKE_RGB(0x00, 0xff, 0x00), /* ALPHANUMERIC BRIGHT GREEN */ |
| 927 | MAKE_RGB(0x40, 0x10, 0x00), /* ALPHANUMERIC DARK ORANGE */ |
| 928 | MAKE_RGB(0xff, 0xc4, 0x18) /* ALPHANUMERIC BRIGHT ORANGE */ |
| 929 | |
| 870 | 930 | }; |
| 871 | 931 | |
| 872 | 932 | static PALETTE_INIT(pc6001) |
| 873 | 933 | { |
| 874 | 934 | int i; |
| 875 | 935 | |
| 876 | | for(i=0;i<8;i++) |
| 936 | for(i=0;i<8+4;i++) |
| 877 | 937 | palette_set_color(machine, i+8,defcolors[i]); |
| 878 | 938 | } |
| 879 | 939 | |
| r8698 | r8699 | |
| 923 | 983 | // MDRV_VIDEO_UPDATE(m6847) |
| 924 | 984 | // MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 925 | 985 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 926 | | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 927 | | MDRV_PALETTE_LENGTH(16) |
| 986 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 0, 239) |
| 987 | MDRV_PALETTE_LENGTH(16+4) |
| 928 | 988 | MDRV_PALETTE_INIT(pc6001) |
| 929 | 989 | |
| 930 | 990 | MDRV_I8255A_ADD( "ppi8255", pc6001_ppi8255_interface ) |
| r8698 | r8699 | |
| 955 | 1015 | |
| 956 | 1016 | MDRV_MACHINE_RESET(pc6001m2) |
| 957 | 1017 | |
| 1018 | MDRV_VIDEO_UPDATE(pc6001m2) |
| 1019 | |
| 958 | 1020 | /* basic machine hardware */ |
| 959 | 1021 | MDRV_CPU_MODIFY("maincpu") |
| 960 | 1022 | MDRV_CPU_PROGRAM_MAP(pc6001m2_map) |
| r8698 | r8699 | |
| 964 | 1026 | static MACHINE_DRIVER_START( pc6001sr ) |
| 965 | 1027 | MDRV_IMPORT_FROM(pc6001) |
| 966 | 1028 | |
| 1029 | MDRV_VIDEO_UPDATE(pc6001m2) |
| 1030 | |
| 967 | 1031 | /* basic machine hardware */ |
| 968 | 1032 | MDRV_CPU_REPLACE("maincpu", Z80, XTAL_3_579545MHz) |
| 969 | 1033 | MDRV_CPU_PROGRAM_MAP(pc6001m2_map) |