Changelog
Revision 1130
Author glx
Date 20/07/2010 16:23:07
Message -Add: C-ified Map_IsPositionInViewport()
Changed files: (view/hide)
/trunk/decompiled/cs__07D4.c
 
3359 3359 emu_pop(&emu_cs);
3360 3360 return;
3361 3361 }
3362  
3363   /**
3364   * Decompiled function emu_Map_IsPositionInViewport()
3365   *
3366   * @name emu_Map_IsPositionInViewport
3367   * @implements 07D4:196B:0073:56C1 ()
3368   * @implements 07D4:19AF:002F:75C1
3369   * @implements 07D4:19C0:001E:03DD
3370   * @implements 07D4:19DA:0004:EAB9
3371   * @implements 07D4:19DC:0002:C2BA
3372   * @implements 07D4:19DE:0005:A97A
3373   * @implements 07D4:19E3:0004:893F
3374   *
3375   * Called From: 07D4:069F:0028:4EFB
3376   * Called From: 07D4:06E3:001C:B1AC
3377   * Called From: 07D4:06E3:0019:3A04
3378   * Called From: 07D4:0727:001C:B1A3
3379   * Called From: 07D4:0727:0019:3A0B
3380   * Called From: 07D4:077D:002E:5463
3381   * Called From: 07D4:077D:002B:7689
3382   * Called From: 07D4:0A04:0031:066B
3383   * Called From: 07D4:0F49:0019:6454
3384   * Called From: 07D4:10A4:0031:05C3
3385   * Called From: 176C:06F4:0029:3063
3386   */
3387   void emu_Map_IsPositionInViewport()
3388   {
3389   l__196B:
3390   emu_push(emu_bp);
3391   emu_bp = emu_sp;
3392   emu_subw(&emu_sp, 0x4);
3393   emu_cl = 0x4;
3394   emu_ax = emu_get_memory16(emu_ss, emu_bp, 0x6);
3395   emu_shrw(&emu_ax, emu_cl);
3396   emu_bx = emu_get_memory16(emu_ds, 0x00, 0x39FE);
3397   emu_andw(&emu_bx, 0x3F);
3398   emu_shlw(&emu_bx, emu_cl);
3399   emu_subw(&emu_ax, emu_bx);
3400   emu_get_memory16(emu_ss, emu_bp, -0x2) = emu_ax;
3401   emu_cl = 0x4;
3402   emu_ax = emu_get_memory16(emu_ss, emu_bp, 0x8);
3403   emu_shrw(&emu_ax, emu_cl);
3404   emu_bx = emu_get_memory16(emu_ds, 0x00, 0x39FE);
3405   emu_andw(&emu_bx, 0xFC0);
3406   emu_cl = 0x2;
3407   emu_shrw(&emu_bx, emu_cl);
3408   emu_subw(&emu_ax, emu_bx);
3409   emu_get_memory16(emu_ss, emu_bp, -0x4) = emu_ax;
3410   emu_ax = emu_get_memory16(emu_ss, emu_bp, 0xA);
3411   emu_orw(&emu_ax, emu_get_memory16(emu_ss, emu_bp, 0xC));
3412   if (emu_ax != 0) {
3413   emu_lfp(&emu_es, &emu_bx, &emu_get_memory16(emu_ss, emu_bp, 0xA));
3414   emu_ax = emu_get_memory16(emu_ss, emu_bp, -0x2);
3415   emu_get_memory16(emu_es, emu_bx, 0x0) = emu_ax;
3416   }
3417   l__19AF:
3418   emu_ax = emu_get_memory16(emu_ss, emu_bp, 0xE);
3419   emu_orw(&emu_ax, emu_get_memory16(emu_ss, emu_bp, 0x10));
3420   if (emu_ax != 0) {
3421   emu_lfp(&emu_es, &emu_bx, &emu_get_memory16(emu_ss, emu_bp, 0xE));
3422   emu_ax = emu_get_memory16(emu_ss, emu_bp, -0x4);
3423   emu_get_memory16(emu_es, emu_bx, 0x0) = emu_ax;
3424   }
3425   l__19C0:
3426   emu_cmpw(&emu_get_memory16(emu_ss, emu_bp, -0x2), 0xFFF0);
3427   if ((int16)emu_get_memory16(emu_ss, emu_bp, -0x2) >= (int16)0xFFF0) {
3428   emu_cmpw(&emu_get_memory16(emu_ss, emu_bp, -0x2), 0x100);
3429   if ((int16)emu_get_memory16(emu_ss, emu_bp, -0x2) <= (int16)0x100) {
3430   emu_cmpw(&emu_get_memory16(emu_ss, emu_bp, -0x4), 0xFFF0);
3431   if ((int16)emu_get_memory16(emu_ss, emu_bp, -0x4) >= (int16)0xFFF0) {
3432   emu_cmpw(&emu_get_memory16(emu_ss, emu_bp, -0x4), 0xB0);
3433   if ((int16)emu_get_memory16(emu_ss, emu_bp, -0x4) <= (int16)0xB0) goto l__19DE;
3434   }
3435   }
3436   }
3437   l__19DA:
3438   emu_xorw(&emu_ax, emu_ax);
3439   l__19DC:
3440   goto l__19E3;
3441   l__19DE:
3442   emu_ax = 0x1;
3443   goto l__19DC;
3444   l__19E3:
3445   emu_sp = emu_bp;
3446   emu_pop(&emu_bp);
3447  
3448   /* Return from this function */
3449   emu_pop(&emu_ip);
3450   emu_pop(&emu_cs);
3451   return;
3452   }
 
/trunk/decompiled/decompiled.h
 
776 776 extern void f__AB01_18AC_0082_307C();
777 777 extern void f__07D4_18BD_0016_68BB();
778 778 extern void f__1DD7_1940_0021_1C0F();
779   extern void emu_Map_IsPositionInViewport();
780 779 extern void f__B495_19B0_0016_09F7();
781 780 extern void f__B4DA_19E6_0016_C1CB();
782 781 extern void f__B495_1A14_0013_AE3F();
 
/trunk/src/unit.c
 
54 54 extern void f__B4CD_1816_0033_B55B();
55 55 extern void f__B4E9_0050_003F_292A();
56 56 extern void emu_Map_DeviateArea();
57   extern void emu_Map_IsPositionInViewport();
58 57 extern void emu_Structure_UpdateMap();
59 58 extern void emu_Tile_RemoveFogInRadius();
60 59 extern void overlay(uint16 cs, uint8 force);
 
 
377 377 if (u->scriptDelay == 0) {
378 378 if (Script_IsLoaded(&u->script)) {
379 379 g_global->scriptUnitLeft = g_global->scriptUnitSpeed * 5;
380   if (!ui->flags.s.scriptNoSlowdown) {
381   emu_push(0); emu_push(0);
382   emu_push(0); emu_push(0);
383   emu_push(u->position.s.y); emu_push(u->position.s.x);
384   emu_push(emu_cs); emu_push(0x06F9); emu_cs = 0x07D4; emu_Map_IsPositionInViewport();
385   emu_sp += 12;
386  
387   if (emu_ax == 0) g_global->scriptUnitLeft = 1;
  380 if (!ui->flags.s.scriptNoSlowdown && !Map_IsPositionInViewport(u->position, NULL, NULL)) {
  381 g_global->scriptUnitLeft = 1;
388 382 }
389 383
390 384 u->script.variables[3] = g_global->playerHouseID;
 
/trunk/src/emu_map.c
 
3 3 #include <stdio.h>
4 4 #include "types.h"
5 5 #include "libemu.h"
  6 #include "global.h"
6 7 #include "map.h"
7 8
8 9 /**
 
 
139 139
140 140 emu_ax = Map_IsPositionUnveiled(position) ? 1 : 0;
141 141 }
  142
  143
  144 /**
  145 * Emulator wrapper around Map_IsPositionInViewport()
  146 *
  147 * @name emu_Map_IsPositionInViewport
  148 * @implements 07D4:196B:0073:56C1 ()
  149 */
  150 void emu_Map_IsPositionInViewport()
  151 {
  152 tile32 position;
  153 csip32 retX_csip;
  154 csip32 retY_csip;
  155 uint16 *retX;
  156 uint16 *retY;
  157
  158 /* Pop the return CS:IP. */
  159 emu_pop(&emu_ip);
  160 emu_pop(&emu_cs);
  161
  162 position = emu_get_tile32(emu_ss, emu_sp, 0x0);
  163 retX_csip = emu_get_csip32(emu_ss, emu_sp, 0x4);
  164 retY_csip = emu_get_csip32(emu_ss, emu_sp, 0x8);
  165
  166 retX = (uint16 *)emu_get_memorycsip(retX_csip);
  167 retY = (uint16 *)emu_get_memorycsip(retY_csip);
  168
  169 emu_ax = Map_IsPositionInViewport(position, retX, retY) ? 1 : 0;
  170 }
 
/trunk/src/function_names.txt
 
82 82
83 83 06F7:0402:0020:9091 emu_Map_DeviateArea # (tile, radius) Try to deviate all units in an area
84 84
85   07D4:196B:0073:56C1 emu_Map_IsPositionInViewport # (position, ??_csip, ??_csip), check if a position is inside the viewport
86  
87 85 0AEC:0005:0010:9634 emu_GUI_Name # (csip) Handles click on structure/unit name
88 86 0AEC:0FD8:0017:6202 emu_GUI_Cancel # (csip) Handles click on "Cancel" button
89 87 0AEC:1181:001C:DFE4 emu_GUI_Picture # (csip) Handles click on "Picture" button
 
/trunk/src/map.c
 
396 396
397 397 return true;
398 398 }
  399
  400 /**
  401 * Check if a position is in the viewport.
  402 *
  403 * @param position For which position to check.
  404 * @param retX Pointer to X inside the viewport.
  405 * @param retY Pointer to Y inside the viewport.
  406 * @return True if and only if the position is in the viewport.
  407 */
  408 bool Map_IsPositionInViewport(tile32 position, int16 *retX, int16 *retY)
  409 {
  410 int16 x, y;
  411
  412 x = (position.s.x >> 4) - (Tile_GetPackedX(g_global->viewportPosition) << 4);
  413 y = (position.s.y >> 4) - (Tile_GetPackedY(g_global->viewportPosition) << 4);
  414
  415 if (retX != NULL) *retX = x;
  416 if (retY != NULL) *retY = y;
  417
  418 return x >= -16 && x <= 256 && y >= -16 && y <= 176;
  419 }
 
/trunk/src/map.h
 
33 33 extern bool Map_Save(FILE *fp);
34 34 extern bool Map_Load(FILE *fp, uint32 length);
35 35 extern bool Map_IsPositionUnveiled(uint16 position);
  36 extern bool Map_IsPositionInViewport(tile32 position, int16 *retX, int16 *retY);
36 37
37 38 extern void emu_Map_MoveDirection();
38 39 extern void emu_Map_SetSelection();
 
 
41 41 extern void emu_Map_UpdateMinimapPosition();
42 42 extern void emu_Map_IsValidPosition();
43 43 extern void emu_Map_IsPositionUnveiled();
  44 extern void emu_Map_IsPositionInViewport();
44 45
45 46 #endif /* MAP_H */
 
<<   1 2 ... 1127 1128 1129 1130 1131   >>