@@ -20,17 +20,17 @@ public static IndexedImage[] method337(CacheArchive arg1, int arg2, int arg3) {
20
20
return Class22_Sub2 .method315 ();
21
21
}
22
22
23
- public static int method338 (int arg0 , boolean arg1 , int arg2 , int arg3 ) {
24
- arg0 &= 0x3 ;
23
+ public static int getRotatedTileX (int rotation , boolean arg1 , int x , int y ) {
24
+ rotation &= 0x3 ;
25
25
if (arg1 )
26
26
return 68 ;
27
- if (arg0 == 0 )
28
- return arg2 ;
29
- if (arg0 == 1 )
30
- return arg3 ;
31
- if (arg0 == 2 )
32
- return -arg2 + 7 ;
33
- return 7 + -arg3 ;
27
+ if (rotation == 0 )
28
+ return x ;
29
+ if (rotation == 1 )
30
+ return y ;
31
+ if (rotation == 2 )
32
+ return -x + 7 ;
33
+ return 7 + -y ;
34
34
}
35
35
36
36
@@ -39,64 +39,73 @@ public static boolean method340() {
39
39
40
40
}
41
41
42
- public static void method341 (int arg0 , Scene arg1 , int arg2 , int arg3 , int arg4 , int arg5 , byte [] arg6 , int arg7 , CollisionMap [] arg8 , int arg9 , int arg10 ) {
43
- do {
44
- Buffer class40_sub1 = new Buffer (arg6 );
45
- int i = -1 ;
42
+ public static void constructMapRegionObjects (int drawX , int drawY , int drawingPlane , int orientation , int x , int y , int plane , Scene scene , byte [] objectData , CollisionMap [] collisionMaps ) {
43
+ Buffer objectBuffer = new Buffer (objectData );
44
+ int i = -1 ;
45
+ for (; ; ) {
46
+ int idOffset = objectBuffer .getSmart ();
47
+ if (idOffset == 0 )
48
+ break ;
49
+ int objectPositionInfo = 0 ;
50
+ i += idOffset ;
46
51
for (; ; ) {
47
- int i_0_ = class40_sub1 .getSmart ();
48
- if (i_0_ == 0 )
52
+ int objectInfoOffset = objectBuffer .getSmart ();
53
+ if (objectInfoOffset == 0 )
49
54
break ;
50
- int i_1_ = 0 ;
51
- i += i_0_ ;
52
- for (; ; ) {
53
- int i_2_ = class40_sub1 .getSmart ();
54
- if (i_2_ == 0 )
55
- break ;
56
- i_1_ += -1 + i_2_ ;
57
- int i_3_ = i_1_ >> 12 ;
58
- int i_4_ = 0x3f & i_1_ >> 6 ;
59
- int i_5_ = class40_sub1 .getUnsignedByte ();
60
- int i_6_ = i_5_ >> 2 ;
61
- int i_7_ = i_1_ & 0x3f ;
62
- int i_8_ = i_5_ & 0x3 ;
63
- if (i_3_ == arg5 && arg0 <= i_4_ && i_4_ < 8 + arg0 && arg9 <= i_7_ && arg9 + 8 > i_7_ ) {
64
- GameObjectDefinition gameObjectDefinition = GameObjectDefinition .getDefinition (i );
65
- int i_9_ = Main .method42 (arg2 ^ 0x1 , i_8_ , gameObjectDefinition .sizeX , i_4_ & 0x7 , gameObjectDefinition .sizeY , arg4 , 0x7 & i_7_ ) + arg10 ;
66
- int i_10_ = method564 (i_7_ & 0x7 , gameObjectDefinition .sizeY , i_4_ & 0x7 , gameObjectDefinition .sizeX , arg4 , i_8_ ) + arg7 ;
67
- if (i_9_ > 0 && i_10_ > 0 && i_9_ < 103 && i_10_ < 103 ) {
68
- CollisionMap collisionMap = null ;
69
- int i_11_ = arg3 ;
70
- if ((OverlayDefinition .tile_flags [1 ][i_9_ ][i_10_ ] & 0x2 ) == 2 )
71
- i_11_ --;
72
- if (i_11_ >= 0 )
73
- collisionMap = arg8 [i_11_ ];
74
- Class40_Sub5_Sub17_Sub1 .addObject (i , i_9_ , i_10_ , arg3 , i_8_ + arg4 & 0x3 , i_6_ , arg1 , collisionMap );
75
- }
55
+ objectPositionInfo += -1 + objectInfoOffset ;
56
+ int objectPlane = objectPositionInfo >> 12 ;
57
+ int objectX = 0x3f & objectPositionInfo >> 6 ;
58
+ int objectMetadata = objectBuffer .getUnsignedByte ();
59
+ int objectType = objectMetadata >> 2 ;
60
+ int objectY = objectPositionInfo & 0x3f ;
61
+ int originalOrientation = objectMetadata & 0x3 ;
62
+ if (objectPlane == drawingPlane && drawX <= objectX && objectX < 8 + drawX && drawY <= objectY && drawY + 8 > objectY ) {
63
+ GameObjectDefinition gameObjectDefinition = GameObjectDefinition .getDefinition (i );
64
+ int tileX = getRotatedObjectX (objectX & 0x7 , 0x7 & objectY , gameObjectDefinition .sizeX , gameObjectDefinition .sizeY , orientation , originalOrientation ) + x ;
65
+ int tileY = getRotatedObjectY (objectX & 0x7 , objectY & 0x7 , gameObjectDefinition .sizeX , gameObjectDefinition .sizeY , orientation , originalOrientation ) + y ;
66
+ if (tileX > 0 && tileY > 0 && tileX < 103 && tileY < 103 ) {
67
+ CollisionMap collisionMap = null ;
68
+ int collisionMapPlane = plane ;
69
+ if ((OverlayDefinition .tile_flags [1 ][tileX ][tileY ] & 0x2 ) == 2 ) // bridge tile, go down 1 level
70
+ collisionMapPlane --;
71
+ if (collisionMapPlane >= 0 )
72
+ collisionMap = collisionMaps [collisionMapPlane ];
73
+ Class40_Sub5_Sub17_Sub1 .addObject (i , tileX , tileY , plane , originalOrientation + orientation & 0x3 , objectType , scene , collisionMap );
76
74
}
77
75
}
78
76
}
79
- if (arg2 == 0 )
80
- break ;
81
- aClass6_Sub1Array580 = null ;
77
+ }
78
+ }
82
79
83
- break ;
84
- } while (false );
80
+ public static int getRotatedObjectX (int x , int y , int sizeX , int sizeY , int orientation , int originalOrientation ) {
81
+ orientation &= 0x3 ;
82
+ if ((originalOrientation & 0x1 ) == 1 ) {
83
+ int i = sizeX ;
84
+ sizeX = sizeY ;
85
+ sizeY = i ;
86
+ }
87
+ if (orientation == 0 )
88
+ return x ;
89
+ if (orientation == 1 )
90
+ return y ;
91
+ if (orientation == 2 )
92
+ return 7 - (x + sizeX ) + 1 ;
93
+ return 7 + -y + 1 + -sizeY ;
85
94
}
86
95
87
- public static int method564 (int arg0 , int arg1 , int arg2 , int arg3 , int arg4 , int arg5 ) {
88
- arg4 &= 0x3 ;
89
- if ((arg5 & 0x1 ) == 1 ) {
90
- int i = arg3 ;
91
- arg3 = arg1 ;
92
- arg1 = i ;
96
+ public static int getRotatedObjectY (int x , int y , int sizeX , int sizeY , int orientation , int originalOrientation ) {
97
+ orientation &= 0x3 ;
98
+ if ((originalOrientation & 0x1 ) == 1 ) {
99
+ int i = sizeX ;
100
+ sizeX = sizeY ;
101
+ sizeY = i ;
93
102
}
94
- if (arg4 == 0 )
95
- return arg0 ;
96
- if (arg4 == 1 )
97
- return 1 + -arg3 + 7 - arg2 ;
98
- if (arg4 == 2 )
99
- return -arg1 + 1 + -arg0 + 7 ;
100
- return arg2 ;
103
+ if (orientation == 0 )
104
+ return y ;
105
+ if (orientation == 1 )
106
+ return 1 + -sizeX + 7 - x ;
107
+ if (orientation == 2 )
108
+ return -sizeY + 1 + -y + 7 ;
109
+ return x ;
101
110
}
102
111
}
0 commit comments