Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 154 lines (124 sloc) 3.394 kB
a9461cd initializing repo from version 0.10.2 minus the example files
Julian authored
1 // sysvar.cpp
2 // Revision 6-feb-2005
3
4 #include "sysvar.h"
5
6 #include "charset.h"
7 #include "trace.h"
8
9 // For debugging.
10 #include <sstream>
11
12
13 namespace {
14
15 BlChar system_vars [blassic::sysvar::EndSysVar];
16
17 } // namespace
18
19
20 size_t blassic::sysvar::address ()
21 {
22 return reinterpret_cast <size_t> (system_vars);
23 }
24
25 void blassic::sysvar::set (size_t var, BlChar value)
26 {
27 system_vars [var]= value;
28 }
29
30 void blassic::sysvar::set16 (size_t var, short value)
31 {
32 poke16 (system_vars + var, value);
33 }
34
35 void blassic::sysvar::set32 (size_t var, BlInteger value)
36 {
37 poke32 (system_vars + var, value);
38 }
39
40 BlChar blassic::sysvar::get (size_t var)
41 {
42 return system_vars [var];
43 }
44
45 unsigned short blassic::sysvar::get16 (size_t var)
46 {
47 return static_cast <unsigned short> (peek16 (system_vars + var) );
48 }
49
50 unsigned long blassic::sysvar::get32 (size_t var)
51 {
52 return peek32 (system_vars + var);
53 }
54
55 // Flags operations.
56
57 blassic::sysvar::Flags1Bit blassic::sysvar::getFlags1 ()
58 {
59 return static_cast <Flags1Bit> (system_vars [Flags1] );
60 }
61
62 blassic::sysvar::Flags2Bit blassic::sysvar::getFlags2 ()
63 {
64 return static_cast <Flags2Bit> (system_vars [Flags2] );
65 }
66
67 bool blassic::sysvar::hasFlags1 (Flags1Bit f)
68 {
69 //return (getFlags1 () & f) != Flags1Clean;
70 return getFlags1 ().has (f);
71 }
72
73 bool blassic::sysvar::hasFlags2 (Flags2Bit f)
74 {
75 //return (getFlags2 () & f) != Flags2Clean;
76 return getFlags2 ().has (f);
77 }
78
79 void blassic::sysvar::setFlags1 (Flags1Bit f)
80 {
81 BlChar * const pflag= system_vars + Flags1;
82 *pflag|= f.get ();
83 }
84
85 void blassic::sysvar::setFlags2 (Flags2Bit f)
86 {
87 BlChar * const pflag= system_vars + Flags2;
88 *pflag|= f.get ();
89 }
90
91 // Initialization
92
93 void blassic::sysvar::init ()
94 {
95 TRACEFUNC (tr, "blassic::sysvar::init");
96 #ifndef NDEBUG
97 {
98 std::ostringstream oss;
99 oss << "System vars address: " <<
100 static_cast <void *> (system_vars);
101 TRMESSAGE (tr, oss.str () );
102 }
103 #endif
104
105 set16 (GraphicsWidth, 0);
106 set16 (GraphicsHeight, 0);
107 set16 (NumArgs, 0);
108 set16 (VersionMajor, version::Major);
109 set16 (VersionMinor, version::Minor);
110 set16 (VersionRelease, version::Release);
111 set32 (AutoInit, 10);
112 set32 (AutoInc, 10);
113 set32 (CharGen, reinterpret_cast <size_t> (& charset::data) );
114 set (ShellResult, 0);
115 set (TypeOfVal, 0); // VAL simple, number only.
116 set (TypeOfNextCheck, 0); // Strict next check
117 set (TypeOfDimCheck, 0); // Need erase before dim already dimensioned
118 set16 (MaxHistory, 100);
119 setFlags1 (Flags1Clean);
120 // Bit 0: LOCATE style Microsoft (row, col),
121 // Bit 1: TAB style normal.
122 // Bit 2: THEN omitted not accepted.
123 // Bit 3: Without space before number in PRINT.
124 // Bit 4: Without initial space in STR$.
125 // Bit 5: Without convert LF to CR.
126 // Bit 6: Do not show debug info.
127 // Bit 7: Strict GOTO mode.
128
129 #ifdef BLASSIC_USE_WINDOWS
130 const BlChar defaultprinterline= 1;
131 #else
132 const BlChar defaultprinterline= 0;
133 #endif
134 set (PrinterLine, defaultprinterline);
135
136 // Changed this, the processor stack overflows easily
137 // in windows, at least in W98 with C++ Builder.
138 //set32 (MaxFnLevel, 1000); // Seems a good limit.
139 set32 (MaxFnLevel, 50);
140
141 set16 (DebugLevel, 0);
142 set16 (Zone, 8);
143 set (GraphRotate, 0);
144 setFlags2 (Flags2Clean);
145 // Bit 0: GOTO and GOSUB listed as one word.
146 // Bit 1: true is -1
147 // Bit 2: logical ops are binary
148 // Bit 3: blank lines as comments.
149 set16 (TronChannel, 0);
150 set (TronFlags, 0);
151 }
152
153 // Fin de sysvar.cpp
Something went wrong with that request. Please try again.