libsidplayfp  1.0.3
reloc65.h
00001 /* reloc65 -- A part of xa65 - 65xx/65816 cross-assembler and utility suite
00002  * o65 file relocator
00003  *
00004  * Copyright (C) 1989-1997 André Fachat (a.fachat@physik.tu-chemnitz.de)
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
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 /*
00022     Modified by Dag Lem <resid@nimrod.no>
00023     Relocate and extract text segment from memory buffer instead of file.
00024     For use with VICE VSID.
00025 
00026     Ported to c++ by Leandro Nini
00027 */
00028 
00029 #ifndef RELOC65_H
00030 #define RELOC65_H
00031 
00032 class reloc65
00033 {
00034 public:
00035     typedef enum
00036     {
00037         WHOLE,
00038         TEXT,
00039         DATA,
00040         BSS,
00041         ZEROPAGE
00042     } segment_t;
00043 
00044 private:
00045     bool m_tflag, m_dflag, m_bflag, m_zflag;
00046     int m_tbase, m_dbase, m_bbase, m_zbase;
00047     int m_tdiff, m_ddiff, m_bdiff, m_zdiff;
00048 
00049     segment_t m_extract;
00050 
00051 private:
00052     static int read_options(unsigned char *buf);
00053     static int read_undef(unsigned char *buf);
00054 
00055     int reldiff(unsigned char s);
00056     unsigned char *reloc_seg(unsigned char *buf, int len, unsigned char *rtab);
00057     unsigned char *reloc_globals(unsigned char *buf);
00058 
00059 public:
00060     reloc65();
00061 
00068     void setReloc(segment_t type, int addr);
00069 
00075     void setExtract(segment_t type);
00076 
00083     bool reloc(unsigned char **buf, int *fsize);
00084 };
00085 
00086 #endif