equal
deleted
inserted
replaced
327 } |
327 } |
328 |
328 |
329 x = ((x << vp->zoom) + vp->virtual_left) >> 2; |
329 x = ((x << vp->zoom) + vp->virtual_left) >> 2; |
330 y = ((y << vp->zoom) + vp->virtual_top) >> 1; |
330 y = ((y << vp->zoom) + vp->virtual_top) >> 1; |
331 |
331 |
332 #if !defined(NEW_ROTATION) |
|
333 a = y-x; |
332 a = y-x; |
334 b = y+x; |
333 b = y+x; |
335 #else |
|
336 a = x+y; |
|
337 b = x-y; |
|
338 #endif |
|
339 |
334 |
340 /* we need to move variables in to the valid range, as the |
335 /* we need to move variables in to the valid range, as the |
341 * GetTileZoomCenterWindow() function can call here with invalid x and/or y, |
336 * GetTileZoomCenterWindow() function can call here with invalid x and/or y, |
342 * when the user tries to zoom out along the sides of the map */ |
337 * when the user tries to zoom out along the sides of the map */ |
343 a = clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1); |
338 a = clamp(a, 0, (int)(MapMaxX() * TILE_SIZE) - 1); |
717 bool direction; |
712 bool direction; |
718 |
713 |
719 _cur_ti = &ti; |
714 _cur_ti = &ti; |
720 |
715 |
721 // Transform into tile coordinates and round to closest full tile |
716 // Transform into tile coordinates and round to closest full tile |
722 #if !defined(NEW_ROTATION) |
|
723 x = ((vd->dpi.top >> 1) - (vd->dpi.left >> 2)) & ~0xF; |
717 x = ((vd->dpi.top >> 1) - (vd->dpi.left >> 2)) & ~0xF; |
724 y = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF; |
718 y = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF; |
725 #else |
719 |
726 x = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF; |
|
727 y = ((vd->dpi.left >> 2) - (vd->dpi.top >> 1)) & ~0xF; |
|
728 #endif |
|
729 // determine size of area |
720 // determine size of area |
730 { |
721 { |
731 Point pt = RemapCoords(x, y, 241); |
722 Point pt = RemapCoords(x, y, 241); |
732 width = (vd->dpi.left + vd->dpi.width - pt.x + 95) >> 6; |
723 width = (vd->dpi.left + vd->dpi.width - pt.x + 95) >> 6; |
733 height = (vd->dpi.top + vd->dpi.height - pt.y) >> 5 << 1; |
724 height = (vd->dpi.top + vd->dpi.height - pt.y) >> 5 << 1; |
760 ti.tile = 0; |
751 ti.tile = 0; |
761 ti.z = 0; |
752 ti.z = 0; |
762 tt = MP_VOID; |
753 tt = MP_VOID; |
763 } |
754 } |
764 |
755 |
765 #if !defined(NEW_ROTATION) |
|
766 y_cur += 0x10; |
756 y_cur += 0x10; |
767 x_cur -= 0x10; |
757 x_cur -= 0x10; |
768 #else |
758 |
769 y_cur += 0x10; |
|
770 x_cur += 0x10; |
|
771 #endif |
|
772 _added_tile_sprite = false; |
759 _added_tile_sprite = false; |
773 _offset_ground_sprites = false; |
760 _offset_ground_sprites = false; |
774 |
761 |
775 _tile_type_procs[tt]->draw_tile_proc(&ti); |
762 _tile_type_procs[tt]->draw_tile_proc(&ti); |
776 DrawTileSelection(&ti); |
763 DrawTileSelection(&ti); |
777 } while (--width_cur); |
764 } while (--width_cur); |
778 |
765 |
779 #if !defined(NEW_ROTATION) |
766 if ((direction ^= 1) != 0) { |
780 if ( (direction^=1) != 0) |
|
781 y += 0x10; |
767 y += 0x10; |
782 else |
768 } else { |
783 x += 0x10; |
769 x += 0x10; |
784 #else |
770 } |
785 if ( (direction^=1) != 0) |
|
786 x += 0x10; |
|
787 else |
|
788 y -= 0x10; |
|
789 #endif |
|
790 } while (--height); |
771 } while (--height); |
791 } |
772 } |
792 |
773 |
793 |
774 |
794 static void ViewportAddTownNames(DrawPixelInfo *dpi) |
775 static void ViewportAddTownNames(DrawPixelInfo *dpi) |
1261 vd.first_string = NULL; |
1242 vd.first_string = NULL; |
1262 vd.last_tile = &vd.first_tile; |
1243 vd.last_tile = &vd.first_tile; |
1263 vd.first_tile = NULL; |
1244 vd.first_tile = NULL; |
1264 |
1245 |
1265 ViewportAddLandscape(); |
1246 ViewportAddLandscape(); |
1266 #if !defined(NEW_ROTATION) |
|
1267 ViewportAddVehicles(&vd.dpi); |
1247 ViewportAddVehicles(&vd.dpi); |
1268 DrawTextEffects(&vd.dpi); |
1248 DrawTextEffects(&vd.dpi); |
1269 |
1249 |
1270 ViewportAddTownNames(&vd.dpi); |
1250 ViewportAddTownNames(&vd.dpi); |
1271 ViewportAddStationNames(&vd.dpi); |
1251 ViewportAddStationNames(&vd.dpi); |
1272 ViewportAddSigns(&vd.dpi); |
1252 ViewportAddSigns(&vd.dpi); |
1273 ViewportAddWaypoints(&vd.dpi); |
1253 ViewportAddWaypoints(&vd.dpi); |
1274 #endif |
|
1275 |
1254 |
1276 // This assert should never happen (because the length of the parent_list |
1255 // This assert should never happen (because the length of the parent_list |
1277 // is checked) |
1256 // is checked) |
1278 assert(vd.parent_list <= endof(parent_list)); |
1257 assert(vd.parent_list <= endof(parent_list)); |
1279 |
1258 |
1352 const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle); |
1331 const Vehicle* veh = GetVehicle(WP(w,vp_d).follow_vehicle); |
1353 Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
1332 Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos); |
1354 |
1333 |
1355 SetViewportPosition(w, pt.x, pt.y); |
1334 SetViewportPosition(w, pt.x, pt.y); |
1356 } else { |
1335 } else { |
1357 #if !defined(NEW_ROTATION) |
|
1358 int x; |
1336 int x; |
1359 int y; |
1337 int y; |
1360 int vx; |
1338 int vx; |
1361 int vy; |
1339 int vy; |
1362 |
1340 |
1374 x = (-vx + vy) / 2; |
1352 x = (-vx + vy) / 2; |
1375 y = ( vx + vy) / 4; |
1353 y = ( vx + vy) / 4; |
1376 // Set position |
1354 // Set position |
1377 WP(w, vp_d).scrollpos_x = x - vp->virtual_width / 2; |
1355 WP(w, vp_d).scrollpos_x = x - vp->virtual_width / 2; |
1378 WP(w, vp_d).scrollpos_y = y - vp->virtual_height / 2; |
1356 WP(w, vp_d).scrollpos_y = y - vp->virtual_height / 2; |
1379 #else |
|
1380 int x,y,t; |
|
1381 int err; |
|
1382 |
|
1383 x = WP(w,vp_d).scrollpos_x >> 2; |
|
1384 y = WP(w,vp_d).scrollpos_y >> 1; |
|
1385 |
|
1386 t = x; |
|
1387 x = x + y; |
|
1388 y = x - y; |
|
1389 err= 0; |
|
1390 |
|
1391 if (err != 0) { |
|
1392 /* coordinate remap */ |
|
1393 Point pt = RemapCoords(x, y, 0); |
|
1394 t = (-1) << vp->zoom; |
|
1395 WP(w,vp_d).scrollpos_x = pt.x & t; |
|
1396 WP(w,vp_d).scrollpos_y = pt.y & t; |
|
1397 } |
|
1398 #endif |
|
1399 |
1357 |
1400 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1358 SetViewportPosition(w, WP(w, vp_d).scrollpos_x, WP(w, vp_d).scrollpos_y); |
1401 } |
1359 } |
1402 } |
1360 } |
1403 |
1361 |