src/mame/video/snes.c
| r7577 | r7578 | |
| 997 | 997 | int height, width; |
| 998 | 998 | }; |
| 999 | 999 | |
| 1000 | | static struct OAM oam_list[SNES_SCR_WIDTH / 2]; |
| 1000 | static struct OAM oam_spritelist[SNES_SCR_WIDTH / 2]; |
| 1001 | 1001 | |
| 1002 | | #if 0 |
| 1003 | | |
| 1004 | | // FIXME: The following functions should be used to create sprite list with |
| 1005 | | // obsel data from the previous line. Unfortunately, some games are very picky |
| 1006 | | // about when you set up sprite attributes (e.g. Super Star Wars - The Empire |
| 1007 | | // Strikes Back and Super Street Fighter II) and they would freeze if we only build |
| 1008 | | // part of the sprite attributes at the right moment and part of them later, during |
| 1009 | | // scanline drawing. Hence, these functions are on hold until more OAM refactoring |
| 1010 | | // is done (soon-ish) |
| 1011 | 1002 | static void snes_update_obsel( void ) |
| 1012 | 1003 | { |
| 1013 | 1004 | snes_ppu.layer[SNES_OAM].charmap = snes_ppu.oam.next_charmap; |
| r7577 | r7578 | |
| 1030 | 1021 | |
| 1031 | 1022 | snes_ppu.update_oam_list = 0; // eventually, we can optimize the code by only calling this function when there is a change in size |
| 1032 | 1023 | |
| 1033 | | for (i = 128; i > 0; i--) |
| 1024 | for (i = 127; i >= 0; i--) |
| 1034 | 1025 | { |
| 1035 | | if ((i % 4) == 0) |
| 1026 | if (((i + 1) % 4) == 0) |
| 1036 | 1027 | extra = oamram[oam_extra--]; |
| 1037 | 1028 | |
| 1038 | | oam_list[i].vflip = (oamram[oam] & 0x80) >> 7; |
| 1039 | | oam_list[i].hflip = (oamram[oam] & 0x40) >> 6; |
| 1040 | | oam_list[i].priority_bits = (oamram[oam] & 0x30) >> 4; |
| 1041 | | oam_list[i].pal = 128 + ((oamram[oam] & 0x0e) << 3); |
| 1042 | | oam_list[i].tile = (oamram[oam--] & 0x1) << 8; |
| 1043 | | oam_list[i].tile |= oamram[oam--]; |
| 1044 | | oam_list[i].y = oamram[oam--] + 1; /* We seem to need to add one here.... */ |
| 1045 | | oam_list[i].x = oamram[oam--]; |
| 1046 | | oam_list[i].size = (extra & 0x80) >> 7; |
| 1029 | oam_spritelist[i].vflip = (oamram[oam] & 0x80) >> 7; |
| 1030 | oam_spritelist[i].hflip = (oamram[oam] & 0x40) >> 6; |
| 1031 | oam_spritelist[i].priority_bits = (oamram[oam] & 0x30) >> 4; |
| 1032 | oam_spritelist[i].pal = 128 + ((oamram[oam] & 0x0e) << 3); |
| 1033 | oam_spritelist[i].tile = (oamram[oam--] & 0x1) << 8; |
| 1034 | oam_spritelist[i].tile |= oamram[oam--]; |
| 1035 | oam_spritelist[i].y = oamram[oam--] + 1; /* We seem to need to add one here.... */ |
| 1036 | oam_spritelist[i].x = oamram[oam--]; |
| 1037 | oam_spritelist[i].size = (extra & 0x80) >> 7; |
| 1047 | 1038 | extra <<= 1; |
| 1048 | | oam_list[i].x |= ((extra & 0x80) << 1); |
| 1039 | oam_spritelist[i].x |= ((extra & 0x80) << 1); |
| 1049 | 1040 | extra <<= 1; |
| 1050 | | oam_list[i].y *= snes_ppu.obj_interlace; |
| 1051 | 1041 | |
| 1042 | oam_spritelist[i].y *= snes_ppu.obj_interlace; |
| 1043 | |
| 1052 | 1044 | /* Adjust if past maximum position */ |
| 1053 | | if (oam_list[i].y >= snes_ppu.beam.last_visible_line * snes_ppu.interlace) |
| 1054 | | oam_list[i].y -= 256 * snes_ppu.interlace; |
| 1055 | | if (oam_list[i].x > 255) |
| 1056 | | oam_list[i].x -= 512; |
| 1045 | if (oam_spritelist[i].y >= snes_ppu.beam.last_visible_line * snes_ppu.interlace) |
| 1046 | oam_spritelist[i].y -= 256 * snes_ppu.interlace; |
| 1057 | 1047 | |
| 1048 | oam_spritelist[i].x &= 0x1ff; |
| 1049 | |
| 1058 | 1050 | /* Determine object size */ |
| 1059 | | switch (snes_ppu.oam.next_size) |
| 1051 | switch (snes_ppu.oam.size_) |
| 1060 | 1052 | { |
| 1061 | 1053 | case 0: /* 8x8 or 16x16 */ |
| 1062 | | oam_list[i].width = oam_list[i].size ? 2 : 1; |
| 1063 | | oam_list[i].height = oam_list[i].size ? 2 : 1; |
| 1054 | oam_spritelist[i].width = oam_spritelist[i].size ? 2 : 1; |
| 1055 | oam_spritelist[i].height = oam_spritelist[i].size ? 2 : 1; |
| 1064 | 1056 | break; |
| 1065 | 1057 | case 1: /* 8x8 or 32x32 */ |
| 1066 | | oam_list[i].width = oam_list[i].size ? 4 : 1; |
| 1067 | | oam_list[i].height = oam_list[i].size ? 4 : 1; |
| 1058 | oam_spritelist[i].width = oam_spritelist[i].size ? 4 : 1; |
| 1059 | oam_spritelist[i].height = oam_spritelist[i].size ? 4 : 1; |
| 1068 | 1060 | break; |
| 1069 | 1061 | case 2: /* 8x8 or 64x64 */ |
| 1070 | | oam_list[i].width = oam_list[i].size ? 8 : 1; |
| 1071 | | oam_list[i].height = oam_list[i].size ? 8 : 1; |
| 1062 | oam_spritelist[i].width = oam_spritelist[i].size ? 8 : 1; |
| 1063 | oam_spritelist[i].height = oam_spritelist[i].size ? 8 : 1; |
| 1072 | 1064 | break; |
| 1073 | 1065 | case 3: /* 16x16 or 32x32 */ |
| 1074 | | oam_list[i].width = oam_list[i].size ? 4 : 2; |
| 1075 | | oam_list[i].height = oam_list[i].size ? 4 : 2; |
| 1066 | oam_spritelist[i].width = oam_spritelist[i].size ? 4 : 2; |
| 1067 | oam_spritelist[i].height = oam_spritelist[i].size ? 4 : 2; |
| 1076 | 1068 | break; |
| 1077 | 1069 | case 4: /* 16x16 or 64x64 */ |
| 1078 | | oam_list[i].width = oam_list[i].size ? 8 : 2; |
| 1079 | | oam_list[i].height = oam_list[i].size ? 8 : 2; |
| 1070 | oam_spritelist[i].width = oam_spritelist[i].size ? 8 : 2; |
| 1071 | oam_spritelist[i].height = oam_spritelist[i].size ? 8 : 2; |
| 1080 | 1072 | break; |
| 1081 | 1073 | case 5: /* 32x32 or 64x64 */ |
| 1082 | | oam_list[i].width = oam_list[i].size ? 8 : 4; |
| 1083 | | oam_list[i].height = oam_list[i].size ? 8 : 4; |
| 1074 | oam_spritelist[i].width = oam_spritelist[i].size ? 8 : 4; |
| 1075 | oam_spritelist[i].height = oam_spritelist[i].size ? 8 : 4; |
| 1084 | 1076 | break; |
| 1085 | 1077 | case 6: /* undocumented: 16x32 or 32x64 */ |
| 1086 | | oam_list[i].width = oam_list[i].size ? 4 : 2; |
| 1087 | | oam_list[i].height = oam_list[i].size ? 8 : 4; |
| 1088 | | if (snes_ppu.obj_interlace && !oam_list[i].size) |
| 1089 | | oam_list[i].height = 2; |
| 1078 | oam_spritelist[i].width = oam_spritelist[i].size ? 4 : 2; |
| 1079 | oam_spritelist[i].height = oam_spritelist[i].size ? 8 : 4; |
| 1080 | if (snes_ppu.obj_interlace && !oam_spritelist[i].size) |
| 1081 | oam_spritelist[i].height = 2; |
| 1090 | 1082 | break; |
| 1091 | 1083 | case 7: /* undocumented: 16x32 or 32x32 */ |
| 1092 | | oam_list[i].width = oam_list[i].size ? 4 : 2; |
| 1093 | | oam_list[i].height = oam_list[i].size ? 4 : 4; |
| 1094 | | if (snes_ppu.obj_interlace && !oam_list[i].size) |
| 1095 | | oam_list[i].height = 2; |
| 1084 | oam_spritelist[i].width = oam_spritelist[i].size ? 4 : 2; |
| 1085 | oam_spritelist[i].height = oam_spritelist[i].size ? 4 : 4; |
| 1086 | if (snes_ppu.obj_interlace && !oam_spritelist[i].size) |
| 1087 | oam_spritelist[i].height = 2; |
| 1096 | 1088 | break; |
| 1097 | 1089 | default: |
| 1098 | 1090 | /* we should never enter here... */ |
| r7577 | r7578 | |
| 1101 | 1093 | } |
| 1102 | 1094 | } |
| 1103 | 1095 | } |
| 1104 | | #endif |
| 1105 | 1096 | |
| 1106 | | static void snes_update_objects( UINT8 priority_tbl, UINT16 curline ) |
| 1097 | static UINT8 oam_itemlist[32]; |
| 1098 | |
| 1099 | struct TILELIST { |
| 1100 | UINT16 x, priority, pal, tileaddr; |
| 1101 | int hflip; |
| 1102 | }; |
| 1103 | |
| 1104 | struct TILELIST oam_tilelist[34]; |
| 1105 | |
| 1106 | static int is_sprite_on_scanline( UINT16 curline, UINT8 sprite ) |
| 1107 | 1107 | { |
| 1108 | //if sprite is entirely offscreen and doesn't wrap around to the left side of the screen, |
| 1109 | //then it is not counted. this *should* be 256, and not 255, even though dot 256 is offscreen. |
| 1110 | int spr_height = (oam_spritelist[sprite].height << 3); |
| 1111 | |
| 1112 | if (oam_spritelist[sprite].x > 256 && (oam_spritelist[sprite].x + (oam_spritelist[sprite].width << 3) - 1) < 512) |
| 1113 | return 0; |
| 1114 | |
| 1115 | if (curline >= oam_spritelist[sprite].y && curline < (oam_spritelist[sprite].y + spr_height)) |
| 1116 | return 1; |
| 1117 | |
| 1118 | if ((oam_spritelist[sprite].y + spr_height) >= 256 && curline < ((oam_spritelist[sprite].y + spr_height) & 255)) |
| 1119 | return 1; |
| 1120 | |
| 1121 | return 0; |
| 1122 | } |
| 1123 | |
| 1124 | static void snes_update_objects_rto( UINT16 curline ) |
| 1125 | { |
| 1126 | int active_sprite; |
| 1127 | UINT8 range_over, time_over; |
| 1108 | 1128 | INT8 xs, ys; |
| 1109 | 1129 | UINT8 line; |
| 1110 | | UINT8 range_over = 0, time_over = 0; |
| 1111 | | UINT8 height, width, vflip, hflip, priority, pal, blend; |
| 1130 | UINT8 height, width, vflip, hflip, priority, pal; |
| 1112 | 1131 | UINT16 tile; |
| 1113 | 1132 | INT16 i, x, y; |
| 1114 | | UINT32 name_sel = 0, charaddr; |
| 1133 | UINT32 name_sel = 0; |
| 1134 | |
| 1135 | snes_oam_list_build(); |
| 1136 | |
| 1137 | /* initialize counters */ |
| 1138 | range_over = 0; |
| 1139 | time_over = 0; |
| 1140 | |
| 1141 | /* setup the proper line */ |
| 1142 | curline /= snes_ppu.interlace; |
| 1143 | curline *= snes_ppu.obj_interlace; |
| 1144 | |
| 1145 | /* reset the list of first 32 objects which intersect current scanline */ |
| 1146 | memset(oam_itemlist, 0xff, 32); |
| 1147 | |
| 1148 | /* populate the list of 32 objects */ |
| 1149 | for (i = 0; i < 128; i++) |
| 1150 | { |
| 1151 | active_sprite = (i + snes_ppu.oam.first_sprite) & 0x7f; |
| 1152 | |
| 1153 | if (!is_sprite_on_scanline(curline, active_sprite)) |
| 1154 | continue; |
| 1155 | |
| 1156 | if (range_over++ >= 32) |
| 1157 | break; |
| 1158 | |
| 1159 | oam_itemlist[range_over - 1] = active_sprite; |
| 1160 | } |
| 1161 | |
| 1162 | /* reset the list of first 34 tiles to be drawn */ |
| 1163 | for (i = 0; i < 34; i++) |
| 1164 | oam_tilelist[i].tileaddr = 0xffff; |
| 1165 | |
| 1166 | /* populate the list of 34 tiles */ |
| 1167 | for (i = 31; i >= 0; i--) |
| 1168 | { |
| 1169 | if (oam_itemlist[i] == 0xff) |
| 1170 | continue; |
| 1171 | |
| 1172 | active_sprite = oam_itemlist[i]; |
| 1173 | |
| 1174 | tile = oam_spritelist[active_sprite].tile; |
| 1175 | x = oam_spritelist[active_sprite].x; |
| 1176 | y = oam_spritelist[active_sprite].y; |
| 1177 | height = oam_spritelist[active_sprite].height; |
| 1178 | width = oam_spritelist[active_sprite].width; |
| 1179 | vflip = oam_spritelist[active_sprite].vflip; |
| 1180 | hflip = oam_spritelist[active_sprite].hflip; |
| 1181 | priority = oam_spritelist[active_sprite].priority_bits; |
| 1182 | pal = oam_spritelist[active_sprite].pal; |
| 1183 | |
| 1184 | /* Only objects using tiles over 255 use name select */ |
| 1185 | name_sel = (tile < 256) ? 0 : snes_ppu.oam.name_select; |
| 1186 | |
| 1187 | ys = (curline - y) >> 3; |
| 1188 | line = (curline - y) % 8; |
| 1189 | if (vflip) |
| 1190 | { |
| 1191 | ys = height - ys - 1; |
| 1192 | line = (-1 * line) + 7; |
| 1193 | } |
| 1194 | line <<= 1; |
| 1195 | tile <<= 5; |
| 1196 | |
| 1197 | int ii; |
| 1198 | |
| 1199 | for (ii = 0; ii < width; ii++) |
| 1200 | { |
| 1201 | INT16 xx = (x + (ii << 3)) & 0x1ff; |
| 1202 | |
| 1203 | if (x != 256 && xx >= 256 && (xx + 7) < 512) |
| 1204 | continue; |
| 1205 | |
| 1206 | if (time_over++ >= 34) |
| 1207 | break; |
| 1208 | |
| 1209 | xs = (hflip) ? (width - 1 - ii) : ii; |
| 1210 | oam_tilelist[time_over - 1].tileaddr = name_sel + tile + table_obj_offset[ys][xs] + line; |
| 1211 | oam_tilelist[time_over - 1].hflip = hflip; |
| 1212 | oam_tilelist[time_over - 1].x = xx; |
| 1213 | oam_tilelist[time_over - 1].pal = pal; |
| 1214 | oam_tilelist[time_over - 1].priority = priority; |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | /* set Range Over flag if necessary */ |
| 1219 | if (range_over > 32) |
| 1220 | snes_ppu.stat77_flags |= 0x40; |
| 1221 | |
| 1222 | /* set Time Over flag if necessary */ |
| 1223 | if (time_over > 34) |
| 1224 | snes_ppu.stat77_flags |= 0x80; |
| 1225 | } |
| 1226 | |
| 1227 | static void snes_update_objects( UINT8 priority_tbl ) |
| 1228 | { |
| 1229 | UINT8 blend, priority; |
| 1230 | UINT32 charaddr; |
| 1231 | int i; |
| 1115 | 1232 | static const UINT8 table_obj_priority[10][4] = { |
| 1116 | 1233 | {2, 5, 8, 11}, // mode 0 |
| 1117 | 1234 | {1, 3, 6, 9}, // mode 1 |
| r7577 | r7578 | |
| 1124 | 1241 | {1, 3, 5, 6}, // mode 7 EXTBG |
| 1125 | 1242 | {1, 2, 5, 8} // mode 1 + BG3 priority bit |
| 1126 | 1243 | }; |
| 1127 | | UINT8 *oamram = (UINT8 *)snes_oam; |
| 1128 | | INT16 oam = 0x1ff; |
| 1129 | | UINT16 oam_extra = oam + 0x20; |
| 1130 | | UINT16 extra = 0; |
| 1131 | 1244 | |
| 1132 | 1245 | #ifdef SNES_LAYER_DEBUG |
| 1133 | 1246 | if (debug_options.bg_disabled[SNES_OAM]) |
| r7577 | r7578 | |
| 1142 | 1255 | if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable) |
| 1143 | 1256 | return; |
| 1144 | 1257 | |
| 1145 | | curline /= snes_ppu.interlace; |
| 1146 | | curline *= snes_ppu.obj_interlace; |
| 1258 | charaddr = snes_ppu.layer[SNES_OAM].charmap << 13; |
| 1147 | 1259 | |
| 1148 | | charaddr = snes_ppu.oam.next_charmap << 13; |
| 1149 | | |
| 1150 | | for (i = 128; i > 0; i--) |
| 1260 | /* finally draw the tiles from the tilelist */ |
| 1261 | for (i = 0; i < 34; i++) |
| 1151 | 1262 | { |
| 1152 | | if ((i % 4) == 0) |
| 1153 | | extra = oamram[oam_extra--]; |
| 1263 | if (oam_tilelist[i].tileaddr == 0xffff) |
| 1264 | continue; |
| 1154 | 1265 | |
| 1155 | | oam_list[i].vflip = (oamram[oam] & 0x80) >> 7; |
| 1156 | | oam_list[i].hflip = (oamram[oam] & 0x40) >> 6; |
| 1157 | | oam_list[i].priority_bits = (oamram[oam] & 0x30) >> 4; |
| 1158 | | oam_list[i].pal = 128 + ((oamram[oam] & 0x0e) << 3); |
| 1159 | | oam_list[i].tile = (oamram[oam--] & 0x1) << 8; |
| 1160 | | oam_list[i].tile |= oamram[oam--]; |
| 1161 | | oam_list[i].y = oamram[oam--] + 1; /* We seem to need to add one here.... */ |
| 1162 | | oam_list[i].x = oamram[oam--]; |
| 1163 | | oam_list[i].size = (extra & 0x80) >> 7; |
| 1164 | | extra <<= 1; |
| 1165 | | oam_list[i].x |= ((extra & 0x80) << 1); |
| 1166 | | extra <<= 1; |
| 1167 | | oam_list[i].y *= snes_ppu.obj_interlace; |
| 1168 | | |
| 1169 | | /* Adjust if past maximum position */ |
| 1170 | | if (oam_list[i].y >= snes_ppu.beam.last_visible_line * snes_ppu.interlace) |
| 1171 | | oam_list[i].y -= 256 * snes_ppu.interlace; |
| 1172 | | if (oam_list[i].x > 255) |
| 1173 | | oam_list[i].x -= 512; |
| 1174 | | tile = oam_list[i].tile; |
| 1175 | | x = oam_list[i].x; |
| 1176 | | y = oam_list[i].y; |
| 1177 | | height = oam_list[i].height; |
| 1178 | | width = oam_list[i].width; |
| 1179 | | vflip = oam_list[i].vflip; |
| 1180 | | hflip = oam_list[i].hflip; |
| 1181 | | priority = table_obj_priority[priority_tbl][oam_list[i].priority_bits]; |
| 1182 | | pal = oam_list[i].pal; |
| 1183 | | |
| 1184 | | /* Draw sprite if it intersects the current line */ |
| 1185 | | if (curline >= y && curline < (y + (snes_ppu.oam.size[oam_list[i].size] << 3))) |
| 1186 | | { |
| 1187 | | /* Only objects using palettes 4-7 can be transparent */ |
| 1188 | | blend = (pal < 192) ? 1 : 0; |
| 1189 | | |
| 1190 | | /* Only objects using tiles over 255 use name select */ |
| 1191 | | name_sel = (tile < 256) ? 0 : snes_ppu.oam.next_name_select; |
| 1192 | | |
| 1193 | | ys = (curline - y) >> 3; |
| 1194 | | line = (curline - y) % 8; |
| 1195 | | if (vflip) |
| 1196 | | { |
| 1197 | | ys = snes_ppu.oam.size[oam_list[i].size] - ys - 1; |
| 1198 | | line = (-1 * line) + 7; |
| 1199 | | } |
| 1200 | | line <<= 1; |
| 1201 | | tile <<= 5; |
| 1202 | | if (hflip) |
| 1203 | | { |
| 1204 | | UINT8 count = 0; |
| 1205 | | for (xs = (snes_ppu.oam.size[oam_list[i].size] - 1); xs >= 0; xs--) |
| 1206 | | { |
| 1207 | | if ((x + (count << 3) < SNES_SCR_WIDTH)) |
| 1208 | | { |
| 1209 | | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend); |
| 1210 | | } |
| 1211 | | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 1212 | | } |
| 1213 | | } |
| 1214 | | else |
| 1215 | | { |
| 1216 | | for (xs = 0; xs < snes_ppu.oam.size[oam_list[i].size]; xs++) |
| 1217 | | { |
| 1218 | | if ((x + (xs << 3) < SNES_SCR_WIDTH)) |
| 1219 | | { |
| 1220 | | snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend); |
| 1221 | | } |
| 1222 | | time_over++; /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */ |
| 1223 | | } |
| 1224 | | } |
| 1225 | | |
| 1226 | | /* Increase range_over. Stop drawing if exceeded 32 objects and enforcing that limit is enabled */ |
| 1227 | | range_over++; |
| 1228 | | if (range_over == 32) //&& (input_port_read(machine, "INTERNAL") & 0x01) ) |
| 1229 | | { |
| 1230 | | /* Set the flag in STAT77 register */ |
| 1231 | | snes_ppu.stat77_flags |= 0x40; |
| 1232 | | /* FIXME: This stops the SNESTest rom from drawing the object test properly. Maybe we shouldn't stop drawing? */ |
| 1233 | | /* return; */ |
| 1234 | | } |
| 1235 | | } |
| 1266 | blend = (oam_tilelist[i].pal < 192) ? 1 : 0; |
| 1267 | priority = table_obj_priority[priority_tbl][oam_tilelist[i].priority]; |
| 1268 | snes_draw_tile_object(charaddr + oam_tilelist[i].tileaddr, oam_tilelist[i].x, priority, oam_tilelist[i].hflip, oam_tilelist[i].pal, blend); |
| 1236 | 1269 | } |
| 1237 | | |
| 1238 | | if (time_over >= 34) |
| 1239 | | { |
| 1240 | | /* Set the flag in STAT77 register */ |
| 1241 | | snes_ppu.stat77_flags |= 0x80; |
| 1242 | | } |
| 1243 | 1270 | } |
| 1244 | 1271 | |
| 1245 | 1272 | |
| r7577 | r7578 | |
| 1260 | 1287 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1261 | 1288 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1262 | 1289 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1263 | | snes_update_objects(0, curline); |
| 1290 | snes_update_objects(0); |
| 1264 | 1291 | } |
| 1265 | 1292 | |
| 1266 | 1293 | static void snes_update_mode_1( UINT16 curline ) |
| r7577 | r7578 | |
| 1275 | 1302 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1276 | 1303 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1277 | 1304 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1278 | | snes_update_objects(1, curline); |
| 1305 | snes_update_objects(1); |
| 1279 | 1306 | } |
| 1280 | 1307 | else |
| 1281 | 1308 | { |
| 1282 | 1309 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, SNES_OPT_NONE, 0); |
| 1283 | 1310 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1284 | 1311 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1285 | | snes_update_objects(9, curline); |
| 1312 | snes_update_objects(9); |
| 1286 | 1313 | } |
| 1287 | 1314 | } |
| 1288 | 1315 | |
| r7577 | r7578 | |
| 1295 | 1322 | |
| 1296 | 1323 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE2, 0); |
| 1297 | 1324 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE2, 0); |
| 1298 | | snes_update_objects(2, curline); |
| 1325 | snes_update_objects(2); |
| 1299 | 1326 | } |
| 1300 | 1327 | |
| 1301 | 1328 | static void snes_update_mode_3( UINT16 curline ) |
| r7577 | r7578 | |
| 1307 | 1334 | |
| 1308 | 1335 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1309 | 1336 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, snes_ppu.direct_color); |
| 1310 | | snes_update_objects(3, curline); |
| 1337 | snes_update_objects(3); |
| 1311 | 1338 | } |
| 1312 | 1339 | |
| 1313 | 1340 | static void snes_update_mode_4( UINT16 curline ) |
| r7577 | r7578 | |
| 1319 | 1346 | |
| 1320 | 1347 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE4, 0); |
| 1321 | 1348 | snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE4, snes_ppu.direct_color); |
| 1322 | | snes_update_objects(4, curline); |
| 1349 | snes_update_objects(4); |
| 1323 | 1350 | } |
| 1324 | 1351 | |
| 1325 | 1352 | static void snes_update_mode_5( UINT16 curline ) |
| r7577 | r7578 | |
| 1331 | 1358 | |
| 1332 | 1359 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0); |
| 1333 | 1360 | snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0); |
| 1334 | | snes_update_objects(5, curline); |
| 1361 | snes_update_objects(5); |
| 1335 | 1362 | } |
| 1336 | 1363 | |
| 1337 | 1364 | static void snes_update_mode_6( UINT16 curline ) |
| r7577 | r7578 | |
| 1342 | 1369 | #endif /* SNES_LAYER_DEBUG */ |
| 1343 | 1370 | |
| 1344 | 1371 | snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, SNES_OPT_MODE6, 0); |
| 1345 | | snes_update_objects(6, curline); |
| 1372 | snes_update_objects(6); |
| 1346 | 1373 | } |
| 1347 | 1374 | |
| 1348 | 1375 | static void snes_update_mode_7( UINT16 curline ) |
| r7577 | r7578 | |
| 1355 | 1382 | if (!snes_ppu.mode7.extbg) |
| 1356 | 1383 | { |
| 1357 | 1384 | snes_update_line_mode7(1, 1, SNES_BG1, curline); |
| 1358 | | snes_update_objects(7, curline); |
| 1385 | snes_update_objects(7); |
| 1359 | 1386 | } |
| 1360 | 1387 | else |
| 1361 | 1388 | { |
| 1362 | 1389 | snes_update_line_mode7(0, 4, SNES_BG2, curline); |
| 1363 | 1390 | snes_update_line_mode7(2, 2, SNES_BG1, curline); |
| 1364 | | snes_update_objects(8, curline); |
| 1391 | snes_update_objects(8); |
| 1365 | 1392 | } |
| 1366 | 1393 | } |
| 1367 | 1394 | |
| r7577 | r7578 | |
| 1531 | 1558 | scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0]; |
| 1532 | 1559 | } |
| 1533 | 1560 | |
| 1534 | | /* Draw screens */ |
| 1561 | /* Prepare OAM for this scanline */ |
| 1562 | snes_update_objects_rto(curline); |
| 1563 | |
| 1564 | /* Draw scanline */ |
| 1535 | 1565 | snes_draw_screens(curline); |
| 1536 | 1566 | |
| 1567 | snes_update_obsel(); |
| 1568 | |
| 1537 | 1569 | #ifdef SNES_LAYER_DEBUG |
| 1538 | 1570 | if (snes_dbg_video(machine, bitmap, curline)) |
| 1539 | 1571 | { |
| r7577 | r7578 | |
| 1554 | 1586 | scanline2 = &scanlines[SNES_SUBSCREEN]; |
| 1555 | 1587 | } |
| 1556 | 1588 | |
| 1557 | | /* Phew! Draw the line to screen */ |
| 1589 | /* Draw the scanline to screen */ |
| 1590 | |
| 1558 | 1591 | fade = snes_ppu.screen_brightness; |
| 1559 | 1592 | |
| 1560 | 1593 | for (x = 0; x < SNES_SCR_WIDTH; x++) |