Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

htneimg.cc

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      htneimg.cc
00004  *
00005  *      Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #include "log.h"
00022 #include "htnewexe.h"
00023 #include "htpal.h"
00024 #include "htneimg.h"
00025 #include "htstring.h"
00026 #include "formats.h"
00027 #include "tools.h"
00028 
00029 #include "nestruct.h"
00030 
00031 #include "htanaly.h"
00032 #include "ne_analy.h"
00033 
00034 static ht_view *htneimage_init(bounds *b, ht_streamfile *file, ht_format_group *group)
00035 {
00036         ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data();
00037 
00038         LOG("%s: NE: loading image (starting analyser)...", file->get_filename());
00039         NEAnalyser *p = new NEAnalyser();
00040         p->init(ne_shared, file);
00041 
00042         bounds c=*b;
00043         ht_group *g=new ht_group();
00044         g->init(&c, VO_RESIZE, DESC_NE_IMAGE"-g");
00045         AnalyInfoline *head;
00046 
00047         c.y += 2;
00048         c.h -= 2;
00049         ht_ne_aviewer *v=new ht_ne_aviewer();
00050         v->init(&c, DESC_NE_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, ne_shared);
00051 
00052         c.y-=2;
00053         c.h=2;
00054         head=new AnalyInfoline();
00055         head->init(&c, v, ANALY_STATUS_DEFAULT);
00056 
00057         v->attachInfoline(head);
00058 
00059 /* search for lowest/highest */
00060         NEAddress l=(NEAddress)-1, h=0;
00061         NE_SEGMENT *s = ne_shared->segments.segments;
00062         for (UINT i=0; i<ne_shared->segments.segment_count; i++) {
00063                 NEAddress base = NE_MAKE_ADDR(i+1, 0);
00064                 UINT evsize = MAX(NE_get_seg_vsize(ne_shared, i), NE_get_seg_psize(ne_shared, i));
00065                 if (base < l) l = base;
00066                 if ((base + evsize > h) && (evsize)) h = base + evsize - 1;
00067                 s++;
00068         }
00069 
00070         Address *low = p->createAddress1616(NE_ADDR_SEG(l), NE_ADDR_OFS(l));
00071         Address *high = p->createAddress1616(NE_ADDR_SEG(h), NE_ADDR_OFS(h));
00072         ht_analy_sub *analy=new ht_analy_sub();
00073         analy->init(file, v, p, low, high);
00074         v->analy_sub = analy;
00075         v->insertsub(analy);
00076         delete high;
00077         delete low;
00078 
00079         v->sendmsg(msg_complete_init, 0);
00080 
00081         if (!(ne_shared->hdr.flags & NE_FLAGS_SELFLOAD)) {
00082                 Address *tmpaddr = p->createAddress1616(NE_ADDR_SEG(ne_shared->hdr.csip), NE_ADDR_OFS(ne_shared->hdr.csip));
00083                 v->gotoAddress(tmpaddr, NULL);
00084                 delete tmpaddr;
00085         } /* FIXME: else what ? */
00086 
00087         g->insert(head);
00088         g->insert(v);
00089 
00090         g->setpalette(palkey_generic_window_default);
00091 
00092         ne_shared->v_image=v;
00093         return g;
00094 }
00095 
00096 format_viewer_if htneimage_if = {
00097         htneimage_init,
00098         0
00099 };
00100 
00101 /*
00102  *      CLASS ht_ne_aviewer
00103  */
00104 
00105 void ht_ne_aviewer::init(bounds *b, char *desc, int caps, ht_streamfile *File, ht_format_group *format_group, Analyser *Analy, ht_ne_shared_data *NE_shared)
00106 {
00107         ht_aviewer::init(b, desc, caps, File, format_group, Analy);
00108         ne_shared = NE_shared;
00109         file = File;
00110 }
00111 
00112 char *ht_ne_aviewer::func(UINT i, bool execute)
00113 {
00114         switch (i) {
00115                 case 3: {
00116                         bool e = false;
00117                         file->cntl(FCNTL_GET_RELOC, &e);
00118                         if (execute) {
00119                                 file->cntl(FCNTL_SET_RELOC, !e);
00120                         }
00121                         return e ? (char*)"unrelocate" : (char*)"relocate";
00122                 }
00123         }
00124         return ht_aviewer::func(i, execute);
00125 }
00126 
00127 void ht_ne_aviewer::setAnalyser(Analyser *a)
00128 {
00129         ((NEAnalyser*)a)->ne_shared = ne_shared;
00130         ((NEAnalyser*)a)->file = file;
00131         analy = a;
00132         analy_sub->setAnalyser(a);
00133 }

Generated on Fri May 7 21:15:35 2004 by doxygen 1.3.5