trunk/src/mame/video/tx1.c
r22873 | r22874 | |
11 | 11 | #include "includes/tx1.h" |
12 | 12 | |
13 | 13 | |
| 14 | #define OBJ_FRAC 16 |
| 15 | |
14 | 16 | /************************************* |
15 | 17 | * |
16 | 18 | * HD46505S-2 CRT Controller |
r22873 | r22874 | |
226 | 228 | * |
227 | 229 | *************************************/ |
228 | 230 | |
229 | | static void tx1_draw_char(running_machine &machine, UINT8 *bitmap) |
| 231 | void tx1_state::tx1_draw_char(UINT8 *bitmap) |
230 | 232 | { |
231 | | tx1_state *state = machine.driver_data<tx1_state>(); |
232 | | UINT16 *tx1_vram = state->m_vram; |
| 233 | UINT16 *tx1_vram = m_vram; |
233 | 234 | INT32 x, y; |
234 | 235 | UINT32 scroll_x; |
235 | 236 | UINT8 *chars, *gfx2; |
236 | 237 | |
237 | 238 | /* 2bpp characters */ |
238 | | chars = state->memregion("char_tiles")->base(); |
| 239 | chars = memregion("char_tiles")->base(); |
239 | 240 | gfx2 = chars + 0x4000; |
240 | 241 | |
241 | 242 | /* X scroll value is the last word in char RAM */ |
r22873 | r22874 | |
253 | 254 | y_offs = y; |
254 | 255 | |
255 | 256 | if ((y_offs >= 64) && (y_offs < 128)) |
256 | | x_offs = state->m_vregs.slock ? scroll_x : 0; |
| 257 | x_offs = m_vregs.slock ? scroll_x : 0; |
257 | 258 | else |
258 | 259 | x_offs = 0; |
259 | 260 | |
r22873 | r22874 | |
314 | 315 | pix[NUM][3][0] = prom_a[0]; pix[NUM][3][1] = prom_b[0]; pix[NUM][3][2] = prom_c[0]; \ |
315 | 316 | } |
316 | 317 | |
317 | | INLINE void tx1_draw_road_pixel(running_machine &machine, int screen, UINT8 *bmpaddr, |
318 | | UINT8 apix[3], UINT8 bpix[3], UINT32 pixnuma, UINT32 pixnumb, |
319 | | UINT8 stl, UINT8 sld, UINT8 selb, |
320 | | UINT8 bnk, UINT8 rorev, UINT8 eb, UINT8 r, UINT8 delr) |
| 318 | void tx1_state::tx1_draw_road_pixel(int screen, UINT8 *bmpaddr, |
| 319 | UINT8 apix[3], UINT8 bpix[3], UINT32 pixnuma, UINT32 pixnumb, |
| 320 | UINT8 stl, UINT8 sld, UINT8 selb, |
| 321 | UINT8 bnk, UINT8 rorev, UINT8 eb, UINT8 r, UINT8 delr) |
321 | 322 | { |
322 | | tx1_state *state = machine.driver_data<tx1_state>(); |
323 | | vregs_t &tx1_vregs = state->m_vregs; |
| 323 | vregs_t &tx1_vregs = m_vregs; |
324 | 324 | UINT8 a0 = BIT(apix[0], pixnuma); |
325 | 325 | UINT8 a1 = BIT(apix[1], pixnuma); |
326 | 326 | UINT8 a2 = BIT(apix[2], pixnuma); |
r22873 | r22874 | |
394 | 394 | } |
395 | 395 | |
396 | 396 | /* This could do with a tidy up and more comments... */ |
397 | | static void tx1_draw_road(running_machine &machine, UINT8 *bitmap) |
| 397 | void tx1_state::tx1_draw_road(UINT8 *bitmap) |
398 | 398 | { |
399 | | tx1_state *state = machine.driver_data<tx1_state>(); |
400 | | UINT16 *tx1_rcram = state->m_rcram; |
401 | | vregs_t &tx1_vregs = state->m_vregs; |
| 399 | UINT16 *tx1_rcram = m_rcram; |
| 400 | vregs_t &tx1_vregs = m_vregs; |
402 | 401 | INT32 y; |
403 | 402 | UINT32 rva9_8; |
404 | 403 | UINT32 rva7; |
r22873 | r22874 | |
415 | 414 | UINT8 pix[2][4][3]; |
416 | 415 | |
417 | 416 | /* Road slice map ROMs */ |
418 | | const UINT8 *const gfx3 = state->memregion("gfx3")->base(); |
| 417 | const UINT8 *const gfx3 = memregion("gfx3")->base(); |
419 | 418 | const UINT8 *const rom_a = gfx3; |
420 | 419 | const UINT8 *const rom_b = gfx3 + 0x2000; |
421 | 420 | const UINT8 *const rom_c = gfx3 + 0x4000; |
422 | 421 | |
423 | 422 | /* Pixel data */ |
424 | | const UINT8 *const proms = state->memregion("proms")->base(); |
| 423 | const UINT8 *const proms = memregion("proms")->base(); |
425 | 424 | const UINT8 *const prom_a = proms + 0x1100; |
426 | 425 | const UINT8 *const prom_b = proms + 0x1300; |
427 | 426 | const UINT8 *const prom_c = proms + 0x1500; |
r22873 | r22874 | |
764 | 763 | else |
765 | 764 | b = 3; |
766 | 765 | |
767 | | tx1_draw_road_pixel(machine, 0, bmpaddr, |
| 766 | tx1_draw_road_pixel(0, bmpaddr, |
768 | 767 | &pix[0][a][0], &pix[1][b][0], |
769 | 768 | pixnum0, pixnum1, |
770 | 769 | stl, sld, selb, bnkls, rorevls, ebls, rl, delrl); |
r22873 | r22874 | |
786 | 785 | else |
787 | 786 | b = 3; |
788 | 787 | |
789 | | tx1_draw_road_pixel(machine, 1, bmpaddr, |
| 788 | tx1_draw_road_pixel(1, bmpaddr, |
790 | 789 | &pix[0][a][0], &pix[1][b][0], |
791 | 790 | pixnum0, pixnum1, |
792 | 791 | stl, sld, selb, bnkcs, rorevcs, ebcs, rc, delrc); |
r22873 | r22874 | |
808 | 807 | else |
809 | 808 | b = 3; |
810 | 809 | |
811 | | tx1_draw_road_pixel(machine, 2, bmpaddr, |
| 810 | tx1_draw_road_pixel(2, bmpaddr, |
812 | 811 | &pix[0][a][0], &pix[1][b][0], |
813 | 812 | pixnum0, pixnum1, |
814 | 813 | stl, sld, selb, bnkrs, rorevrs, ebrs, rr, delrr); |
r22873 | r22874 | |
849 | 848 | * |
850 | 849 | *************************************/ |
851 | 850 | |
852 | | static void tx1_draw_objects(running_machine &machine, UINT8 *bitmap) |
| 851 | void tx1_state::tx1_draw_objects(UINT8 *bitmap) |
853 | 852 | { |
854 | | tx1_state *state = machine.driver_data<tx1_state>(); |
855 | | UINT16 *tx1_objram = state->m_objram; |
856 | | #define FRAC 16 |
| 853 | UINT16 *tx1_objram = m_objram; |
857 | 854 | |
858 | 855 | UINT32 offs; |
859 | 856 | |
860 | 857 | /* The many lookup table ROMs */ |
861 | | const UINT8 *const ic48 = state->memregion("user3")->base(); |
| 858 | const UINT8 *const ic48 = memregion("user3")->base(); |
862 | 859 | const UINT8 *const ic281 = ic48 + 0x2000; |
863 | 860 | |
864 | | const UINT8 *const proms = state->memregion("proms")->base(); |
| 861 | const UINT8 *const proms = memregion("proms")->base(); |
865 | 862 | const UINT8 *const ic190 = proms + 0xc00; |
866 | 863 | const UINT8 *const ic162 = proms + 0xe00; |
867 | 864 | const UINT8 *const ic25 = proms + 0x1000; |
868 | 865 | |
869 | | const UINT8 *const ic106 = state->memregion("obj_map")->base(); |
| 866 | const UINT8 *const ic106 = memregion("obj_map")->base(); |
870 | 867 | const UINT8 *const ic73 = ic106 + 0x4000; |
871 | 868 | |
872 | | const UINT8 *const pixdata_rgn = state->memregion("obj_tiles")->base(); |
| 869 | const UINT8 *const pixdata_rgn = memregion("obj_tiles")->base(); |
873 | 870 | |
874 | 871 | for (offs = 0x0; offs <= 0x300; offs += 8) |
875 | 872 | { |
r22873 | r22874 | |
954 | 951 | rom_addr = (psa0_11 & ~0xff) << 2; |
955 | 952 | |
956 | 953 | /* Prepare the x-scaling */ |
957 | | x_step = (128 << FRAC) / x_scale; |
958 | | x_acc = (psa0_11 & 0xff) << (FRAC + 5); |
| 954 | x_step = (128 << OBJ_FRAC) / x_scale; |
| 955 | x_acc = (psa0_11 & 0xff) << (OBJ_FRAC + 5); |
959 | 956 | |
960 | 957 | #define TX1_MASK 0xfff |
961 | 958 | |
r22873 | r22874 | |
972 | 969 | UINT32 ic281_addr; |
973 | 970 | UINT32 grom_addr; |
974 | 971 | UINT32 lut_data; |
975 | | UINT32 low_addr = ((x_acc >> (FRAC + 3)) & TX1_MASK); |
| 972 | UINT32 low_addr = ((x_acc >> (OBJ_FRAC + 3)) & TX1_MASK); |
976 | 973 | |
977 | 974 | if (gxflip) |
978 | 975 | { |
r22873 | r22874 | |
1050 | 1047 | UINT8 pix; |
1051 | 1048 | UINT8 bit; |
1052 | 1049 | |
1053 | | bit = (x_acc >> FRAC) & 7; |
| 1050 | bit = (x_acc >> OBJ_FRAC) & 7; |
1054 | 1051 | |
1055 | 1052 | if (xflip) |
1056 | 1053 | bit ^= 7; |
r22873 | r22874 | |
1077 | 1074 | |
1078 | 1075 | /* Check if we've stepped into a new 8x8 tile */ |
1079 | 1076 | |
1080 | | if ((((x_acc + x_step) >> (FRAC + 3)) & TX1_MASK) != ((x_acc >> (FRAC + 3)) & TX1_MASK)) |
| 1077 | if ((((x_acc + x_step) >> (OBJ_FRAC + 3)) & TX1_MASK) != ((x_acc >> (OBJ_FRAC + 3)) & TX1_MASK)) |
1081 | 1078 | { |
1082 | 1079 | if (lasttile) |
1083 | 1080 | break; |
r22873 | r22874 | |
1125 | 1122 | { |
1126 | 1123 | /* /VSYNC: Update TZ113 */ |
1127 | 1124 | m_vregs.slin_val += m_vregs.slin_inc; |
| 1125 | |
| 1126 | m_needs_update = true; |
1128 | 1127 | } |
1129 | 1128 | } |
1130 | 1129 | |
1131 | | static void tx1_combine_layers(running_machine &machine, bitmap_ind16 &bitmap, int screen) |
| 1130 | void tx1_state::tx1_combine_layers(bitmap_ind16 &bitmap, int screen) |
1132 | 1131 | { |
1133 | | tx1_state *state = machine.driver_data<tx1_state>(); |
1134 | 1132 | int x, y; |
1135 | | UINT8 *chr_pal = state->memregion("proms")->base() + 0x900; |
| 1133 | UINT8 *chr_pal = memregion("proms")->base() + 0x900; |
1136 | 1134 | |
1137 | 1135 | int x_offset = screen * 256; |
1138 | 1136 | |
r22873 | r22874 | |
1142 | 1140 | |
1143 | 1141 | UINT32 bmp_offset = y * 768 + x_offset; |
1144 | 1142 | |
1145 | | UINT8 *chr_addr = state->m_chr_bmp + bmp_offset; |
1146 | | UINT8 *rod_addr = state->m_rod_bmp + bmp_offset; |
1147 | | UINT8 *obj_addr = state->m_obj_bmp + bmp_offset; |
| 1143 | UINT8 *chr_addr = m_chr_bmp + bmp_offset; |
| 1144 | UINT8 *rod_addr = m_rod_bmp + bmp_offset; |
| 1145 | UINT8 *obj_addr = m_obj_bmp + bmp_offset; |
1148 | 1146 | |
1149 | 1147 | for (x = 0; x < 256; ++x) |
1150 | 1148 | { |
r22873 | r22874 | |
1179 | 1177 | } |
1180 | 1178 | } |
1181 | 1179 | |
1182 | | UINT32 tx1_state::screen_update_tx1_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 1180 | |
| 1181 | void tx1_state::tx1_update_layers() |
1183 | 1182 | { |
1184 | 1183 | memset(m_obj_bmp, 0, 768*240); |
1185 | 1184 | |
1186 | | tx1_draw_char(machine(), m_chr_bmp); |
1187 | | tx1_draw_road(machine(), m_rod_bmp); |
1188 | | tx1_draw_objects(machine(), m_obj_bmp); |
| 1185 | tx1_draw_char(m_chr_bmp); |
| 1186 | tx1_draw_road(m_rod_bmp); |
| 1187 | tx1_draw_objects(m_obj_bmp); |
1189 | 1188 | |
1190 | | tx1_combine_layers(machine(), bitmap, 0); |
| 1189 | m_needs_update = false; |
| 1190 | } |
| 1191 | |
| 1192 | UINT32 tx1_state::screen_update_tx1_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 1193 | { |
| 1194 | if (m_needs_update) |
| 1195 | tx1_update_layers(); |
| 1196 | |
| 1197 | tx1_combine_layers(bitmap, 0); |
1191 | 1198 | return 0; |
1192 | 1199 | } |
1193 | 1200 | |
1194 | 1201 | UINT32 tx1_state::screen_update_tx1_middle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
1195 | 1202 | { |
1196 | | tx1_combine_layers(machine(), bitmap, 1); |
| 1203 | if (m_needs_update) |
| 1204 | tx1_update_layers(); |
| 1205 | |
| 1206 | tx1_combine_layers(bitmap, 1); |
1197 | 1207 | return 0; |
1198 | 1208 | } |
1199 | 1209 | |
1200 | 1210 | UINT32 tx1_state::screen_update_tx1_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
1201 | 1211 | { |
1202 | | tx1_combine_layers(machine(), bitmap, 2); |
| 1212 | if (m_needs_update) |
| 1213 | tx1_update_layers(); |
| 1214 | |
| 1215 | tx1_combine_layers(bitmap, 2); |
1203 | 1216 | return 0; |
1204 | 1217 | } |
1205 | 1218 | |
r22873 | r22874 | |
1283 | 1296 | * |
1284 | 1297 | *************************************/ |
1285 | 1298 | |
1286 | | static void buggyboy_draw_char(running_machine &machine, UINT8 *bitmap, int wide) |
| 1299 | void tx1_state::buggyboy_draw_char(UINT8 *bitmap, bool wide) |
1287 | 1300 | { |
1288 | | tx1_state *state = machine.driver_data<tx1_state>(); |
1289 | | UINT16 *buggyboy_vram = state->m_vram; |
| 1301 | UINT16 *buggyboy_vram = m_vram; |
1290 | 1302 | INT32 x, y; |
1291 | 1303 | UINT32 scroll_x, scroll_y; |
1292 | 1304 | UINT8 *chars, *gfx2; |
r22873 | r22874 | |
1294 | 1306 | UINT32 x_mask; |
1295 | 1307 | |
1296 | 1308 | /* 2bpp characters */ |
1297 | | chars = state->memregion("char_tiles")->base(); |
1298 | | gfx2 = state->memregion("char_tiles")->base() + 0x4000; |
| 1309 | chars = memregion("char_tiles")->base(); |
| 1310 | gfx2 = memregion("char_tiles")->base() + 0x4000; |
1299 | 1311 | |
1300 | 1312 | /* X/Y scroll values are the last word in char RAM */ |
1301 | 1313 | if (wide) |
r22873 | r22874 | |
1425 | 1437 | |
1426 | 1438 | ***************************************************************************/ |
1427 | 1439 | |
1428 | | static void buggyboy_get_roadpix(int screen, int ls161, UINT8 rva0_6, UINT8 sld, UINT32 *_rorev, |
1429 | | UINT8 *rc0, UINT8 *rc1, UINT8 *rc2, UINT8 *rc3, |
1430 | | const UINT8 *rom, const UINT8 *prom0, const UINT8 *prom1, const UINT8 *prom2) |
| 1440 | void tx1_state::buggyboy_get_roadpix(int screen, int ls161, UINT8 rva0_6, UINT8 sld, UINT32 *_rorev, |
| 1441 | UINT8 *rc0, UINT8 *rc1, UINT8 *rc2, UINT8 *rc3, |
| 1442 | const UINT8 *rom, const UINT8 *prom0, const UINT8 *prom1, const UINT8 *prom2) |
1431 | 1443 | { |
1432 | 1444 | /* Counter Q10-7 are added to 384 */ |
1433 | 1445 | UINT16 ls283_159 = (ls161 & 0x780) + 128 + (256 * screen); |
r22873 | r22874 | |
1508 | 1520 | else \ |
1509 | 1521 | hp##NUM = hp##NUM + 1; \ |
1510 | 1522 | } |
1511 | | static void buggyboy_draw_road(running_machine &machine, UINT8 *bitmap) |
| 1523 | void tx1_state::buggyboy_draw_road(UINT8 *bitmap) |
1512 | 1524 | { |
1513 | | tx1_state *state = machine.driver_data<tx1_state>(); |
1514 | | UINT16 *buggyboy_rcram = state->m_rcram; |
1515 | | vregs_t &vregs = state->m_vregs; |
| 1525 | UINT16 *buggyboy_rcram = m_rcram; |
| 1526 | vregs_t &vregs = m_vregs; |
1516 | 1527 | INT32 x; |
1517 | 1528 | UINT32 y; |
1518 | 1529 | UINT16 rva_offs; |
r22873 | r22874 | |
1527 | 1538 | UINT32 rva20_6; |
1528 | 1539 | |
1529 | 1540 | /* ROM/PROM lookup tables */ |
1530 | | const UINT8 *rcols = (UINT8*)(state->memregion("proms")->base() + 0x1500); |
1531 | | const UINT8 *rom = state->memregion("road")->base(); |
| 1541 | const UINT8 *rcols = (UINT8*)(memregion("proms")->base() + 0x1500); |
| 1542 | const UINT8 *rom = memregion("road")->base(); |
1532 | 1543 | const UINT8 *prom0 = rom + 0x4000; |
1533 | 1544 | const UINT8 *prom1 = rom + 0x4200; |
1534 | 1545 | const UINT8 *prom2 = rom + 0x4400; |
r22873 | r22874 | |
2140 | 2151 | } |
2141 | 2152 | } |
2142 | 2153 | |
2143 | | static void buggybjr_draw_road(running_machine &machine, UINT8 *bitmap, int wide) |
| 2154 | void tx1_state::buggybjr_draw_road(UINT8 *bitmap) |
2144 | 2155 | { |
2145 | | tx1_state *state = machine.driver_data<tx1_state>(); |
2146 | | UINT16 *buggyboy_rcram = state->m_rcram; |
2147 | | vregs_t &vregs = state->m_vregs; |
| 2156 | UINT16 *buggyboy_rcram = m_rcram; |
| 2157 | vregs_t &vregs = m_vregs; |
2148 | 2158 | INT32 x; |
2149 | 2159 | UINT32 y; |
2150 | 2160 | UINT16 rva_offs; |
r22873 | r22874 | |
2159 | 2169 | UINT32 rva20_6; |
2160 | 2170 | |
2161 | 2171 | /* ROM/PROM lookup tables */ |
2162 | | const UINT8 *rcols = (UINT8*)(state->memregion("proms")->base() + 0x1500); |
2163 | | const UINT8 *rom = state->memregion("road")->base(); |
| 2172 | const UINT8 *rcols = (UINT8*)(memregion("proms")->base() + 0x1500); |
| 2173 | const UINT8 *rom = memregion("road")->base(); |
2164 | 2174 | const UINT8 *prom0 = rom + 0x4000; |
2165 | 2175 | const UINT8 *prom1 = rom + 0x4200; |
2166 | 2176 | const UINT8 *prom2 = rom + 0x4400; |
r22873 | r22874 | |
2560 | 2570 | |
2561 | 2571 | **************************************************************************/ |
2562 | 2572 | |
2563 | | static void buggyboy_draw_objs(running_machine &machine, UINT8 *bitmap, int wide) |
| 2573 | void tx1_state::buggyboy_draw_objs(UINT8 *bitmap, bool wide) |
2564 | 2574 | { |
2565 | | tx1_state *state = machine.driver_data<tx1_state>(); |
2566 | | UINT16 *buggyboy_objram = state->m_objram; |
2567 | | #define FRAC 16 |
| 2575 | UINT16 *buggyboy_objram = m_objram; |
2568 | 2576 | |
2569 | 2577 | UINT32 offs; |
2570 | 2578 | |
r22873 | r22874 | |
2572 | 2580 | UINT32 x_stride; |
2573 | 2581 | |
2574 | 2582 | /* The many lookup table ROMs */ |
2575 | | const UINT8 *const bug13 = (UINT8*)state->memregion("obj_luts")->base(); |
| 2583 | const UINT8 *const bug13 = (UINT8*)memregion("obj_luts")->base(); |
2576 | 2584 | const UINT8 *const bug18s = bug13 + 0x2000; |
2577 | | const UINT8 *const bb8 = (UINT8*)state->memregion("proms")->base() + 0x1600; |
| 2585 | const UINT8 *const bb8 = (UINT8*)memregion("proms")->base() + 0x1600; |
2578 | 2586 | |
2579 | | const UINT8 *const bug16s = (UINT8*)state->memregion("obj_map")->base(); |
| 2587 | const UINT8 *const bug16s = (UINT8*)memregion("obj_map")->base(); |
2580 | 2588 | const UINT8 *const bug17s = bug16s + 0x8000; |
2581 | 2589 | |
2582 | | const UINT8 *const bb9o = (UINT8*)state->memregion("proms")->base() + 0x500; |
| 2590 | const UINT8 *const bb9o = (UINT8*)memregion("proms")->base() + 0x500; |
2583 | 2591 | const UINT8 *const bb9e = bb9o + 0x800; |
2584 | 2592 | |
2585 | | const UINT8 *const pixdata_rgn = (UINT8*)state->memregion("obj_tiles")->base(); |
| 2593 | const UINT8 *const pixdata_rgn = (UINT8*)memregion("obj_tiles")->base(); |
2586 | 2594 | |
2587 | 2595 | if (wide) |
2588 | 2596 | { |
r22873 | r22874 | |
2680 | 2688 | rom_addr = (psa0_12 & ~0xff) << 2; |
2681 | 2689 | |
2682 | 2690 | /* Prepare the x-scaling */ |
2683 | | x_step = (128 << FRAC) / x_scale; |
2684 | | x_acc = (psa0_12 & 0xff) << (FRAC + 5); |
| 2691 | x_step = (128 << OBJ_FRAC) / x_scale; |
| 2692 | x_acc = (psa0_12 & 0xff) << (OBJ_FRAC + 5); |
2685 | 2693 | |
2686 | 2694 | /* TODO Add note */ |
2687 | 2695 | x = buggyboy_objram[offs + 4] & x_mask; |
r22873 | r22874 | |
2697 | 2705 | UINT32 rombank; |
2698 | 2706 | UINT8 *romptr; |
2699 | 2707 | UINT32 bug18s_data; |
2700 | | UINT32 low_addr = ((x_acc >> (FRAC + 3)) & x_mask); |
| 2708 | UINT32 low_addr = ((x_acc >> (OBJ_FRAC + 3)) & x_mask); |
2701 | 2709 | |
2702 | 2710 | /* |
2703 | 2711 | Objects are grouped by width (either 16, 8 or 4 tiles) in |
r22873 | r22874 | |
2767 | 2775 | UINT8 pix; |
2768 | 2776 | UINT8 bit; |
2769 | 2777 | |
2770 | | bit = (x_acc >> FRAC) & 7; |
| 2778 | bit = (x_acc >> OBJ_FRAC) & 7; |
2771 | 2779 | |
2772 | 2780 | if (xflip) |
2773 | 2781 | bit ^= 7; |
r22873 | r22874 | |
2794 | 2802 | } |
2795 | 2803 | |
2796 | 2804 | /* Check if we've stepped into a new 8x8 tile */ |
2797 | | if ((((x_acc + x_step) >> (FRAC + 3)) & x_mask) != ((x_acc >> (FRAC + 3)) & x_mask)) |
| 2805 | if ((((x_acc + x_step) >> (OBJ_FRAC + 3)) & x_mask) != ((x_acc >> (OBJ_FRAC + 3)) & x_mask)) |
2798 | 2806 | { |
2799 | 2807 | if (lasttile) |
2800 | 2808 | break; |
r22873 | r22874 | |
2920 | 2928 | * |
2921 | 2929 | *************************************/ |
2922 | 2930 | |
2923 | | static void bb_combine_layers(running_machine &machine, bitmap_ind16 &bitmap, int screen) |
| 2931 | void tx1_state::bb_combine_layers(bitmap_ind16 &bitmap, int screen) |
2924 | 2932 | { |
2925 | | tx1_state *state = machine.driver_data<tx1_state>(); |
2926 | | UINT8 *chr_pal = state->memregion("proms")->base() + 0x400; |
| 2933 | UINT8 *chr_pal = memregion("proms")->base() + 0x400; |
2927 | 2934 | UINT32 bmp_stride; |
2928 | 2935 | UINT32 x_offset; |
2929 | 2936 | UINT32 y; |
r22873 | r22874 | |
2945 | 2952 | |
2946 | 2953 | UINT32 bmp_offset = y * bmp_stride + x_offset; |
2947 | 2954 | |
2948 | | UINT8 *chr_addr = state->m_chr_bmp + bmp_offset; |
2949 | | UINT8 *rod_addr = state->m_rod_bmp + bmp_offset; |
2950 | | UINT8 *obj_addr = state->m_obj_bmp + bmp_offset; |
| 2955 | UINT8 *chr_addr = m_chr_bmp + bmp_offset; |
| 2956 | UINT8 *rod_addr = m_rod_bmp + bmp_offset; |
| 2957 | UINT8 *obj_addr = m_obj_bmp + bmp_offset; |
2951 | 2958 | |
2952 | | UINT32 sky_en = BIT(state->m_vregs.sky, 7); |
2953 | | UINT32 sky_val = (((state->m_vregs.sky & 0x7f) + y) >> 2) & 0x3f; |
| 2959 | UINT32 sky_en = BIT(m_vregs.sky, 7); |
| 2960 | UINT32 sky_val = (((m_vregs.sky & 0x7f) + y) >> 2) & 0x3f; |
2954 | 2961 | |
2955 | 2962 | UINT16 *bmp_addr = &bitmap.pix16(y); |
2956 | 2963 | |
r22873 | r22874 | |
3026 | 3033 | |
3027 | 3034 | /* /VSYNC: Clear wave LFSR */ |
3028 | 3035 | m_vregs.wave_lfsr = 0; |
| 3036 | |
| 3037 | m_needs_update = true; |
3029 | 3038 | } |
3030 | 3039 | } |
3031 | 3040 | |
3032 | 3041 | |
3033 | | UINT32 tx1_state::screen_update_buggyboy_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 3042 | void tx1_state::bb_update_layers() |
3034 | 3043 | { |
3035 | 3044 | memset(m_obj_bmp, 0, 768*240); |
3036 | 3045 | memset(m_rod_bmp, 0, 768*240); |
3037 | 3046 | |
3038 | | buggyboy_draw_char(machine(), m_chr_bmp, 1); |
3039 | | buggyboy_draw_road(machine(), m_rod_bmp); |
3040 | | buggyboy_draw_objs(machine(), m_obj_bmp, 1); |
| 3047 | buggyboy_draw_char(m_chr_bmp, 1); |
| 3048 | buggyboy_draw_road(m_rod_bmp); |
| 3049 | buggyboy_draw_objs(m_obj_bmp, 1); |
3041 | 3050 | |
3042 | | bb_combine_layers(machine(), bitmap, 0); |
| 3051 | m_needs_update = false; |
| 3052 | } |
| 3053 | |
| 3054 | UINT32 tx1_state::screen_update_buggyboy_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 3055 | { |
| 3056 | if (m_needs_update) |
| 3057 | bb_update_layers(); |
| 3058 | |
| 3059 | bb_combine_layers(bitmap, 0); |
3043 | 3060 | return 0; |
3044 | 3061 | } |
3045 | 3062 | |
3046 | 3063 | UINT32 tx1_state::screen_update_buggyboy_middle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
3047 | 3064 | { |
3048 | | bb_combine_layers(machine(), bitmap, 1); |
| 3065 | if (m_needs_update) |
| 3066 | bb_update_layers(); |
| 3067 | |
| 3068 | bb_combine_layers(bitmap, 1); |
3049 | 3069 | return 0; |
3050 | 3070 | } |
3051 | 3071 | |
3052 | 3072 | UINT32 tx1_state::screen_update_buggyboy_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
3053 | 3073 | { |
3054 | | bb_combine_layers(machine(), bitmap, 2); |
| 3074 | if (m_needs_update) |
| 3075 | bb_update_layers(); |
| 3076 | |
| 3077 | bb_combine_layers(bitmap, 2); |
3055 | 3078 | return 0; |
3056 | 3079 | } |
3057 | 3080 | |
r22873 | r22874 | |
3059 | 3082 | { |
3060 | 3083 | memset(m_obj_bmp, 0, 256*240); |
3061 | 3084 | |
3062 | | buggyboy_draw_char(machine(), m_chr_bmp, 0); |
3063 | | buggybjr_draw_road(machine(), m_rod_bmp, 0); |
3064 | | buggyboy_draw_objs(machine(), m_obj_bmp, 0); |
| 3085 | buggyboy_draw_char(m_chr_bmp, 0); |
| 3086 | buggybjr_draw_road(m_rod_bmp); |
| 3087 | buggyboy_draw_objs(m_obj_bmp, 0); |
3065 | 3088 | |
3066 | | bb_combine_layers(machine(), bitmap, -1); |
| 3089 | bb_combine_layers(bitmap, -1); |
3067 | 3090 | return 0; |
3068 | 3091 | } |
trunk/src/mame/includes/tx1.h
r22873 | r22874 | |
38 | 38 | UINT32 mux; |
39 | 39 | UINT16 ppshift; |
40 | 40 | UINT32 i0ff; |
41 | | |
42 | 41 | UINT16 retval; |
43 | | |
44 | 42 | UINT16 muxlatch; // TX-1 |
45 | | |
46 | | int dbgaddr; |
47 | | int dbgpc; |
| 43 | int dbgaddr; |
| 44 | int dbgpc; |
48 | 45 | }; |
49 | 46 | |
50 | 47 | /* |
r22873 | r22874 | |
103 | 100 | public: |
104 | 101 | tx1_state(const machine_config &mconfig, device_type type, const char *tag) |
105 | 102 | : driver_device(mconfig, type, tag), |
106 | | m_z80_ram(*this, "z80_ram"), |
| 103 | m_maincpu(*this, "main_cpu"), |
| 104 | m_mathcpu(*this, "math_cpu"), |
| 105 | m_audiocpu(*this, "audio_cpu"), |
107 | 106 | m_math_ram(*this, "math_ram"), |
108 | 107 | m_vram(*this, "vram"), |
109 | 108 | m_objram(*this, "objram"), |
110 | 109 | m_rcram(*this, "rcram"), |
111 | | m_maincpu(*this, "main_cpu"), |
112 | | m_mathcpu(*this, "math_cpu"), |
113 | | m_audiocpu(*this, "audio_cpu") { } |
| 110 | m_z80_ram(*this, "z80_ram") { } |
114 | 111 | |
115 | | math_t m_math; |
116 | | sn74s516_t m_sn74s516; |
| 112 | required_device<cpu_device> m_maincpu; |
| 113 | required_device<cpu_device> m_mathcpu; |
| 114 | required_device<cpu_device> m_audiocpu; |
| 115 | required_shared_ptr<UINT16> m_math_ram; |
| 116 | required_shared_ptr<UINT16> m_vram; |
| 117 | required_shared_ptr<UINT16> m_objram; |
| 118 | required_shared_ptr<UINT16> m_rcram; |
117 | 119 | required_shared_ptr<UINT8> m_z80_ram; |
| 120 | |
| 121 | emu_timer *m_interrupt_timer; |
| 122 | |
118 | 123 | UINT8 m_ppi_latch_a; |
119 | 124 | UINT8 m_ppi_latch_b; |
120 | 125 | UINT32 m_ts; |
121 | | required_shared_ptr<UINT16> m_math_ram; |
| 126 | |
| 127 | |
| 128 | math_t m_math; |
| 129 | sn74s516_t m_sn74s516; |
| 130 | |
122 | 131 | vregs_t m_vregs; |
123 | | required_shared_ptr<UINT16> m_vram; |
124 | | required_shared_ptr<UINT16> m_objram; |
125 | | required_shared_ptr<UINT16> m_rcram; |
126 | | emu_timer *m_interrupt_timer; |
127 | 132 | UINT8 *m_chr_bmp; |
128 | 133 | UINT8 *m_obj_bmp; |
129 | 134 | UINT8 *m_rod_bmp; |
130 | 135 | bitmap_ind16 *m_bitmap; |
| 136 | |
| 137 | bool m_needs_update; |
| 138 | |
131 | 139 | DECLARE_READ16_MEMBER(tx1_math_r); |
132 | 140 | DECLARE_WRITE16_MEMBER(tx1_math_w); |
133 | 141 | DECLARE_READ16_MEMBER(tx1_spcs_rom_r); |
r22873 | r22874 | |
171 | 179 | DECLARE_VIDEO_START(buggyboy); |
172 | 180 | DECLARE_PALETTE_INIT(buggyboy); |
173 | 181 | DECLARE_VIDEO_START(buggybjr); |
| 182 | |
| 183 | void tx1_draw_char(UINT8 *bitmap); |
| 184 | void tx1_draw_road_pixel(int screen, UINT8 *bmpaddr, |
| 185 | UINT8 apix[3], UINT8 bpix[3], UINT32 pixnuma, UINT32 pixnumb, |
| 186 | UINT8 stl, UINT8 sld, UINT8 selb, |
| 187 | UINT8 bnk, UINT8 rorev, UINT8 eb, UINT8 r, UINT8 delr); |
| 188 | void tx1_draw_road(UINT8 *bitmap); |
| 189 | void tx1_draw_objects(UINT8 *bitmap); |
| 190 | void tx1_update_layers(); |
| 191 | void tx1_combine_layers(bitmap_ind16 &bitmap, int screen); |
| 192 | |
| 193 | void buggyboy_draw_char(UINT8 *bitmap, bool wide); |
| 194 | void buggyboy_get_roadpix(int screen, int ls161, UINT8 rva0_6, UINT8 sld, UINT32 *_rorev, |
| 195 | UINT8 *rc0, UINT8 *rc1, UINT8 *rc2, UINT8 *rc3, |
| 196 | const UINT8 *rom, const UINT8 *prom0, const UINT8 *prom1, const UINT8 *prom2); |
| 197 | void buggyboy_draw_road(UINT8 *bitmap); |
| 198 | void buggybjr_draw_road(UINT8 *bitmap); |
| 199 | void buggyboy_draw_objs(UINT8 *bitmap, bool wide); |
| 200 | void bb_combine_layers(bitmap_ind16 &bitmap, int screen); |
| 201 | void bb_update_layers(); |
| 202 | |
174 | 203 | UINT32 screen_update_tx1_left(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
175 | 204 | UINT32 screen_update_tx1_middle(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
176 | 205 | UINT32 screen_update_tx1_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
r22873 | r22874 | |
182 | 211 | void screen_eof_buggyboy(screen_device &screen, bool state); |
183 | 212 | INTERRUPT_GEN_MEMBER(z80_irq); |
184 | 213 | TIMER_CALLBACK_MEMBER(interrupt_callback); |
185 | | required_device<cpu_device> m_maincpu; |
186 | | required_device<cpu_device> m_mathcpu; |
187 | | required_device<cpu_device> m_audiocpu; |
188 | 214 | }; |
189 | 215 | |
190 | 216 | /*----------- defined in audio/tx1.c -----------*/ |