1 /***************************************************************************
2                           environment.h - This is the environment file which
3                                           defines all the standard functions
4                                           to be inherited by the ICs.
5                              -------------------
6     begin                : Thu May 11 2000
7     copyright            : (C) 2000 by Simon White
8     email                : s_a_white@email.com
9  ***************************************************************************/
10 
11 /***************************************************************************
12  *                                                                         *
13  *   This program is free software; you can redistribute it and/or modify  *
14  *   it under the terms of the GNU General Public License as published by  *
15  *   the Free Software Foundation; either version 2 of the License, or     *
16  *   (at your option) any later version.                                   *
17  *                                                                         *
18  ***************************************************************************/
19 /***************************************************************************
20  *  $Log: sidenv.h,v $
21  *  Revision 1.5  2002/01/29 21:53:25  s_a_white
22  *  Fixed envSleep
23  *
24  *  Revision 1.4  2002/01/29 08:02:22  s_a_white
25  *  PSID sample improvements.
26  *
27  *  Revision 1.3  2001/07/14 13:09:35  s_a_white
28  *  Removed cache parameters.
29  *
30  *  Revision 1.2  2000/12/11 19:10:59  s_a_white
31  *  AC99 Update.
32  *
33  ***************************************************************************/
34 
35 #ifndef _environment_h_
36 #define _environment_h_
37 
38 #include "sidtypes.h"
39 
40 /*
41 // Enviroment functions - THESE FUNTIONS MUST BE PROVIDED
42 // TO ALLOW THE COMPONENTS TO SPEAK TO EACH OTHER.  ENVP
43 // CAN BE USED TO CREATE VERSIONS OF THESE FUNTIONS
44 // WHICH ACCESS MEMBER FUNTIONS OF OTHER C++ OBJECTS!
45 extern void    reset        (void);
46 extern uint8_t readMemByte  (uint_least16_t addr);
47 extern void    writeMemByte (uint_least16_t addr, uint8_t data);
48 
49 // Interrupts - You must raise the interrupt(s)
50 // every cycle if you have not yet been serviced
51 extern void  triggerIRQ (void);
52 extern void  triggerNMI (void);
53 extern void  triggerRST (void);
54 extern void  clearIRQ   (void);
55 
56 // Sidplay compatibily funtions
57 extern bool    checkBankJump  (uint_least16_t addr);
58 extern uint8_t readEnvMemByte (uint_least16_t addr);
59 */
60 
61 class C64Environment
62 {
63 /*
64 protected:
65     // Eniviroment functions
66     virtual inline void    envReset        (void)
67     { ::reset (); }
68     virtual inline uint8_t envReadMemByte  (uint_least16_t addr)
69     { ::readMemByte  (addr); }
70     virtual inline void    envWriteMemByte (uint_least16_t addr, uint8_t data)
71     { ::writeMemByte (addr, data); }
72 
73     // Interrupts
74     virtual inline void  encTriggerIRQ (void)
75     { ::triggerIRQ (); }
76     virtual inline void  envTriggerNMI (void)
77     { ::triggerNMI (); }
78     virtual inline void  envTriggerRST (void)
79     { ::triggerRST (); }
80     virtual inline void  envClearIRQ   (void)
81     { ::clearIRQ   (); }
82 
83     // Sidplay compatibily funtions
84     virtual inline bool    envCheckBankJump   (uint_least16_t addr)
85     { ::checkBankJump   (); }
86     virtual inline uint8_t envReadMemDataByte (uint_least16_t addr)
87     { ::readMemDataByte (); }
88     */
89 
90 private:
91     C64Environment *m_envp;
92 
93     // Sidplay2 Player Environemnt
94 public:
~C64Environment()95     virtual ~C64Environment () {}
setEnvironment(C64Environment * envp)96     virtual void setEnvironment (C64Environment *envp)
97     {
98         m_envp = envp;
99     }
100 
101 protected:
102     // Eniviroment functions
envReset(void)103     virtual inline void  envReset   (void)
104     { m_envp->envReset (); }
envReadMemByte(uint_least16_t addr)105     virtual inline uint8_t envReadMemByte  (uint_least16_t addr)
106     { return m_envp->envReadMemByte (addr); }
envWriteMemByte(uint_least16_t addr,uint8_t data)107     virtual inline void    envWriteMemByte (uint_least16_t addr, uint8_t data)
108     { m_envp->envWriteMemByte (addr, data); }
109 
110     // Interrupts
envTriggerIRQ(void)111     virtual inline void  envTriggerIRQ (void)
112     { m_envp->envTriggerIRQ (); }
envTriggerNMI(void)113     virtual inline void  envTriggerNMI (void)
114     { m_envp->envTriggerNMI (); }
envTriggerRST(void)115     virtual inline void  envTriggerRST (void)
116     { m_envp->envTriggerRST (); }
envClearIRQ(void)117     virtual inline void  envClearIRQ   (void)
118     { m_envp->envClearIRQ ();   }
119 
120     // Sidplay compatibily funtions
envCheckBankJump(uint_least16_t addr)121     virtual inline bool    envCheckBankJump   (uint_least16_t addr)
122     { return m_envp->envCheckBankJump   (addr); }
envReadMemDataByte(uint_least16_t addr)123     virtual inline uint8_t envReadMemDataByte (uint_least16_t addr)
124     { return m_envp->envReadMemDataByte (addr); }
envSleep(void)125     virtual inline void envSleep (void)
126     { m_envp->envSleep (); }
envLoadFile(char * file)127     virtual inline void envLoadFile (char *file)
128     { m_envp->envLoadFile (file); }
129 };
130 
131 #endif // _environment_h_
132