home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / MISSING / CIVMAP21.ZIP / civext21.asm next >
Assembly Source File  |  1993-06-20  |  10KB  |  208 lines

  1. ; This procedure gets the x and y coordinates of the map field and the
  2. ; positions of the interesting memory parts. It profits by that all civ.exe
  3. ; versions need most of these informations, when they calculate whether a
  4. ; field is know or not. This happens for example, when you right click on
  5. ; a field of the map, because the program has to test, whether you can get
  6. ; informations of the landscape (when it is known) or not. The program code
  7. ; has the following appearance (version 1, 2(?)):
  8. ;
  9. ; E9 54 00       a jmp call           ; these bytes are varying between the
  10. ;                                     ; different versions
  11. ; B8 32 00       mov ax, 0032         ; these bytes you have changed to
  12. ;                                     ;  CD F1 90  int F1, nop
  13. ; F7 6E E4       imul word ptr [bp-1C]; at this stack position lies the x position
  14. ; 8B F0          mov si, ax
  15. ; 8B 5E DA       mov bx, [bp-26]      ; y position
  16. ; 8A 80 F8 7F    mov al, [bx+si+7FF8] ; offset of known/unknown data address
  17. ;                                     ; (segment: ds register)
  18. ; 98             cbw
  19. ; BA 01 00       mov dx, 0001
  20. ; 8A 0E 10 E7    mov cl, [E710]       ; ds:[E710] contains at with bit is
  21. ;                                     ; stored, whether YOUR civilization
  22. ;                                     ; knows that place
  23. ; D3 E2          shl dx, cl
  24. ; 85 C2          test dx, ax
  25. ; ...
  26. ;
  27. ; version 3-5:
  28. ;
  29. ; ?? ?? ??       a jmp call           ; these bytes are varying between the
  30. ;                                     ; different versions
  31. ; B8 32 00       mov ax, 0032         ; these bytes you have changed to
  32. ;                                     ;  CD F1 90  int F1, nop
  33. ; F7 6E E4       imul word ptr [bp-1C]; at this stack position lies the x position
  34. ; 8B D8          mov bx, ax
  35. ; 03 5E DA       add bx, [bp-26]      ; y position
  36. ; 8E 06 E4 63    mov es, [63E4]       ; ds:[63E4] contains segment address of
  37. ;                                     ; known/unknown data (this address like
  38. ;                                     ; all segment addresses will be created
  39. ;                                     ; after starting civ.exe)
  40. ; 26 8A 87 40 07 mov al, es:[bx+0740] ; offset of known/unknown address
  41. ; 98             cbw
  42. ; BA 01 00       mov dx, 0001
  43. ; 8A 0E EE D7    mov cl, [D7EE]       ; ds:[D7EE] contains at with bit is
  44. ;                                     ; stored, whether YOUR civilization
  45. ;                                     ; knows that place
  46. ; D3 E2          shl dx, cl
  47. ; 85 C2          test dx, ax
  48. ; ...
  49. ;
  50. ; The procedure civext2 steps over this program code and gets the interesting
  51. ; informations. To find the main data area which e.g. contains the map itsself
  52. ; it searches near the probable position for 80 bytes, which only consist of
  53. ; 07 and 0F (at least 5 of each; the first map row only contains tundra (07)
  54. ; and arctic (0F)), and then for 80 bytes, which consists of 01, 07 or 0F.
  55. ; Because of this you are not allowed to change the first two map rows !
  56.  
  57. code       segment word public
  58.            assume cs:code
  59.            public civext21;
  60.  
  61. civext21    proc far
  62.             push bp
  63.             mov di, sp                 ; stack position to di
  64.             push ds
  65.             mov si, ss:[bp+14h]        ; get segment of int F1 call from
  66.             mov es, si                 ;   stack -> es
  67.             mov bx, ss:[bp+12h]        ; get offset of int F1 call -> bx
  68.             inc bx                     ; jump over the nop; es:bx now points
  69.                                        ;   to the imul ... command of civ.exe
  70.                                        ;   (see above)
  71.             mov si, ss:[bp+4h]
  72.             mov ds, si                 ; get data segment of civ.exe before
  73.                                        ;   the int f1 call from stack -> ds
  74.             mov bp, ss:[bp]            ; bp before int f1 call -> bp
  75.             mov ax, es:[bx]            ; get first bytes after the nop
  76.             cmp ax, 6ef7h              ; test: are they F7 6E (imul ...)
  77.             jne error
  78.             inc bx                     ; bx two bytes further on
  79.             inc bx
  80.             mov ch, 0FFh
  81.             mov cl, byte ptr es:[bx]   ; get position of x position on stack
  82.                                        ;   (e.g. E4 means [bp+FFE4] = [bp-1C])
  83.             mov si, cx
  84.             mov ax, ss:[bp+si]         ; get x position
  85.             mov si, ss:[di+0ah]        ; write to variable column
  86.             mov ss:[si], ax
  87.             add bx, 04h                ; bx = bx+4
  88.             cmp byte ptr es:[bx], 5eh  ; there should be a 5E
  89.             jne error
  90.             inc bx
  91.             mov ch, 0ffh               ; then follows the position of the
  92.             mov cl, byte ptr es:[bx]   ; y position on stack
  93.             mov si, cx
  94.             mov ax, ss:[bp+si]         ; get y position
  95.             mov si, ss:[di+0eh]        ; write to variable row
  96.             mov ss:[si], ax
  97.             inc bx
  98.             mov al, byte ptr es:[bx]   ; the next byte is a 8A in version 1,2
  99.             cmp al, 8eh                ; and a 8E in version 3-5
  100.             je ver5
  101.             cmp al, 8ah
  102.             jne error
  103.             mov ax, ds                 ; version 1,2: ds contains the segment
  104.                                        ;   of the known/unknown data
  105.             mov si, ss:[di+1eh]        ; write to variable segm_dark
  106.             mov ss:[si], ax
  107.             inc bx                     ; bx = bx+2
  108.             inc bx
  109.             mov ax, es:[bx]            ; get offset of known/unknown data
  110.             jmp l1
  111. error:      jmp error1                 ; a dummy; the first jne error cannot
  112.                                        ;   reach the error procedure otherwise
  113. ver5:       inc bx                     ; version 3-5:
  114.             inc bx
  115.             mov si, es:[bx]            ; get pointer to segment address of
  116.                                        ; known/unknown data
  117.             mov ax, ds:[si]            ; get segment address
  118.             mov si, ss:[di+1eh]        ; write this to variable segm_dark
  119.             mov ss:[si], ax
  120.             add bx, 05h                ; bx = bx+5
  121.             mov ax, es:[bx]            ; get offset address of these data
  122. l1:         mov si, ss:[di+1ah]        ; write it to variable off_dark
  123.             mov ss:[si], ax
  124.             add bx, 07h                ; bx = bx+7
  125.             cmp byte ptr es:[bx], 0eh  ; if all is ok., then is here a 0E
  126.             jne error
  127.             inc bx
  128.             mov si, es:[bx]            ; get pointer on number of own civil.
  129.             mov cl, ds:[si]            ; get number
  130.             mov ax, 0001               ; calculate at which bit is stored
  131.                                        ; whether YOUR civ. knows a map field
  132.             shl ax,cl
  133.             mov si, ss:[di+16h]        ; put this to variable dark_pos
  134.             mov ss:[si], ax
  135.             mov si, es                 ; estimate segment address where the
  136.                                        ; start of the main data can be found
  137.             add si, 4a00h
  138.             mov es, si
  139.             mov bx, 0h
  140.             mov cx, 0h
  141.             mov si, 0h
  142. l3:         mov dx, 50h                ; searching for the first 50h bytes
  143.             mov bx, 0h
  144.             mov cx, 0h
  145. l4:         inc si                     ; offset = offset+1
  146.             jz error                   ; end of segment reached ?
  147.             mov al, byte ptr es:[si]   ; get byte
  148.             cmp al, 07h                ; is it a 07h (tundra)
  149.             jne l6
  150.             inc bx
  151.             jmp l7
  152. l6:         cmp al, 0fh                ; or a 0fh (arctic)
  153.             jne l3
  154.             inc cx
  155. l7:         dec dx
  156.             je l5                      ; the $50th byte found?
  157.             jmp l4
  158. l5:         cmp bl, 05h                ; has there been 5 tundra at least
  159.             jl l3
  160.             cmp cl, 10h                ; and at least 16 arctic ?
  161.             jl l3
  162.             mov dx, 50h                ; test the next 50h bytes as a
  163.             mov bx, 0h                 ;   precaution
  164.             mov cx, 0h
  165.             add si, 0f0h
  166.             jc error1 
  167. l14:        inc si                     ; offset = offset+1
  168.             jz error1                  ; end of segment reached ?
  169.             mov al, byte ptr es:[si]   ; get byte
  170.             cmp al, 07h                ; is it a 07h (tundra)
  171.             jne l16
  172.             inc bx
  173.             jmp l17
  174. l16:        cmp al, 0fh                ; or a 0fh (arctic)
  175.             jne l18
  176.             inc bx
  177.             jmp l17
  178. l18:        cmp al,01h                 ; or 01h (water)
  179.             jne l3                     ; no, hasn't been the right block
  180.             inc cx
  181. l17:        dec dx
  182.             je l15                      ; the $50th byte found?
  183.             jmp l14
  184. l15:        cmp bl, 05h                ; has there been 5 land at least
  185.             jl l3
  186.             cmp cl, 10h                ; and at least 16 water ?
  187.             jl l3
  188.             mov cl, 4                  ; calculate correct data segment
  189.             shr si, cl                 ;  (offset of data start should be 0h)
  190.             sub si, 18h
  191.             mov ax, es
  192.             add ax, si
  193.             mov si, ss:[di+12h]        ; segment to variable segm_data
  194.             mov ss:[si], ax
  195.             mov ax,0                   ; no error!
  196.             jmp l2
  197. error1:     mov ax,1                   ; error!
  198. l2:         mov si, ss:[di+06h]        ; write errorlevel to variable error
  199.             mov ss:[si], ax
  200.             pop ds
  201.             mov sp, di
  202.             pop bp
  203.             ret                        ; that's all
  204. civext21    endp
  205.  
  206. code        ends
  207.             end
  208.