Canola
0.8.D001
|
00001 // 00002 // canola - canon canola 1614p emulator 00003 // Copyright (C) 2011 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License, version 3, as 00007 // published by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along 00015 // with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #include <lib/display.h> 00019 #include <lib/sizeof.h> 00020 00021 00022 display::~display() 00023 { 00024 } 00025 00026 00027 display::display() : 00028 overflow(false), 00029 negative(false), 00030 m1(false), 00031 m2(false), 00032 entry(false), 00033 column18(column18_blank), 00034 column19(column19_blank), 00035 column20(column20_blank), 00036 column21(column21_blank) 00037 { 00038 } 00039 00040 00041 display::display(const display &rhs) : 00042 overflow(rhs.overflow), 00043 negative(rhs.negative), 00044 m1(rhs.m1), 00045 m2(rhs.m2), 00046 entry(rhs.entry), 00047 column18(rhs.column18), 00048 column19(rhs.column19), 00049 column20(rhs.column20), 00050 column21(rhs.column21) 00051 { 00052 for (size_t j = 0; j < SIZEOF(tubes); ++j) 00053 tubes[j] = rhs.tubes[j]; 00054 } 00055 00056 00057 display & 00058 display::operator=(const display &rhs) 00059 { 00060 if (this != &rhs) 00061 { 00062 overflow = rhs.overflow; 00063 for (size_t j = 0; j < SIZEOF(tubes); ++j) 00064 tubes[j] = rhs.tubes[j]; 00065 negative = rhs.negative; 00066 m1 = rhs.m1; 00067 m2 = rhs.m2; 00068 entry = rhs.entry; 00069 column18 = rhs.column18; 00070 column19 = rhs.column19; 00071 column20 = rhs.column20; 00072 column21 = rhs.column21; 00073 } 00074 return *this; 00075 } 00076 00077 00078 display::tube_t::~tube_t() 00079 { 00080 } 00081 00082 00083 display::tube_t::tube_t() : 00084 digit(10), 00085 dot(false), 00086 tick(false) 00087 { 00088 } 00089 00090 00091 display::tube_t::tube_t(const tube_t &rhs) : 00092 digit(rhs.digit), 00093 dot(rhs.dot), 00094 tick(rhs.tick) 00095 { 00096 } 00097 00098 00099 display::tube_t & 00100 display::tube_t::operator=(const tube_t &rhs) 00101 { 00102 if (this != &rhs) 00103 { 00104 digit = rhs.digit; 00105 dot = rhs.dot; 00106 tick = rhs.tick; 00107 } 00108 return *this; 00109 } 00110 00111 00112 void 00113 display::set_opcode(opcode_t op) 00114 { 00115 column18 = column18_blank; 00116 column19 = column19_blank; 00117 column20 = column20_blank; 00118 column21 = column21_blank; 00119 switch (op) 00120 { 00121 case opcode_zero: 00122 goto yuck; 00123 00124 case opcode_plus_equals: 00125 column19 = column19_plus_equals; 00126 break; 00127 00128 case opcode_minus_equals: 00129 column19 = column19_minus_equals; 00130 break; 00131 00132 case opcode_mul: 00133 column19 = column19_times; 00134 break; 00135 00136 case opcode_div: 00137 column19 = column19_divide; 00138 break; 00139 00140 case opcode_sqrt: 00141 column19 = column19_sqrt; 00142 break; 00143 00144 case opcode_ent: 00145 column18 = column18_e; 00146 break; 00147 00148 case opcode_sj: 00149 column18 = column18_sj; 00150 break; 00151 00152 case opcode_ej: 00153 column18 = column18_ej; 00154 break; 00155 00156 case opcode_mj: 00157 column18 = column18_mj; 00158 break; 00159 00160 case opcode_uj: 00161 column18 = column18_uj; 00162 break; 00163 00164 case opcode_fj: 00165 column18 = column18_fj; 00166 break; 00167 00168 case opcode_suj: 00169 column18 = column18_suj; 00170 break; 00171 00172 case opcode_sfj: 00173 column18 = column18_sfj; 00174 break; 00175 00176 case opcode_srj: 00177 column18 = column18_srj; 00178 break; 00179 00180 case opcode_m1: 00181 case opcode_m2: 00182 case opcode_m3: 00183 case opcode_m4: 00184 case opcode_m5: 00185 case opcode_m6: 00186 case opcode_m7: 00187 case opcode_m8: 00188 case opcode_m9: 00189 case opcode_m10: 00190 case opcode_m11: 00191 case opcode_m12: 00192 case opcode_m13: 00193 case opcode_m14: 00194 { 00195 int n = op - (opcode_m1 - 1); 00196 column19 = column19_m_plus; 00197 if (n >= 10) 00198 { 00199 column20 = column20_n1; 00200 n -= 10; 00201 } 00202 column21 = column21_t(column21_n0 + n); 00203 } 00204 break; 00205 00206 case opcode_mm1: 00207 case opcode_mm2: 00208 column19 = column19_m_minus; 00209 column21 = column21_t(column21_n0 + (op - (opcode_mm1 - 1))); 00210 break; 00211 00212 case opcode_sm3: 00213 case opcode_sm4: 00214 case opcode_sm5: 00215 case opcode_sm6: 00216 case opcode_sm7: 00217 case opcode_sm8: 00218 case opcode_sm9: 00219 case opcode_sm10: 00220 case opcode_sm11: 00221 case opcode_sm12: 00222 case opcode_sm13: 00223 case opcode_sm14: 00224 { 00225 int n = op - (opcode_sm3 - 3); 00226 column19 = column19_sm; 00227 if (n >= 10) 00228 { 00229 column20 = column20_n1; 00230 n -= 10; 00231 } 00232 column21 = column21_t(column21_n0 + n); 00233 } 00234 break; 00235 00236 case opcode_rm1: 00237 case opcode_rm2: 00238 case opcode_rm3: 00239 case opcode_rm4: 00240 case opcode_rm5: 00241 case opcode_rm6: 00242 case opcode_rm7: 00243 case opcode_rm8: 00244 case opcode_rm9: 00245 case opcode_rm10: 00246 case opcode_rm11: 00247 case opcode_rm12: 00248 case opcode_rm13: 00249 case opcode_rm14: 00250 { 00251 int n = op - (opcode_rm1 - 1); 00252 column19 = column19_rm; 00253 if (n >= 10) 00254 { 00255 column20 = column20_n1; 00256 n -= 10; 00257 } 00258 column21 = column21_t(column21_n0 + n); 00259 } 00260 break; 00261 00262 case opcode_clear_indicator: 00263 column18 = column18_ce; 00264 break; 00265 00266 case opcode_cm1: 00267 case opcode_cm2: 00268 case opcode_cm3: 00269 case opcode_cm4: 00270 case opcode_cm5: 00271 case opcode_cm6: 00272 case opcode_cm7: 00273 case opcode_cm8: 00274 case opcode_cm9: 00275 case opcode_cm10: 00276 case opcode_cm11: 00277 case opcode_cm12: 00278 case opcode_cm13: 00279 case opcode_cm14: 00280 { 00281 int n = op - (opcode_cm1 - 1); 00282 column18 = column18_cm; 00283 if (n >= 10) 00284 { 00285 column20 = column20_n1; 00286 n -= 10; 00287 } 00288 column21 = column21_t(column21_n0 + n); 00289 } 00290 break; 00291 00292 case opcode_dot: 00293 column20 = column20_dot; 00294 break; 00295 00296 case opcode_rv: 00297 column18 = column18_rv; 00298 break; 00299 00300 case opcode_right: 00301 column18 = column18_right; 00302 break; 00303 00304 case opcode_chg_sign: 00305 column18 = column18_cs; 00306 break; 00307 00308 case opcode_round_down: 00309 column20 = column20_round_down; 00310 break; 00311 00312 case opcode_round_off: 00313 column20 = column20_round_off; 00314 break; 00315 00316 case opcode_round_up: 00317 column20 = column20_round_up; 00318 break; 00319 00320 case opcode_print: 00321 column19 = column19_print; 00322 break; 00323 00324 case opcode_fd: 00325 column20 = column20_fd; 00326 break; 00327 00328 case opcode_n0: 00329 case opcode_n1: 00330 case opcode_n2: 00331 case opcode_n3: 00332 case opcode_n4: 00333 case opcode_n5: 00334 case opcode_n6: 00335 case opcode_n7: 00336 case opcode_n8: 00337 case opcode_n9: 00338 case opcode_n10: 00339 case opcode_n11: 00340 case opcode_n12: 00341 case opcode_n13: 00342 case opcode_n14: 00343 { 00344 int n = op - opcode_n0; 00345 if (n >= 10) 00346 { 00347 column20 = column20_n1; 00348 n -= 10; 00349 } 00350 column21 = column21_t(column21_n0 + n); 00351 } 00352 break; 00353 00354 case opcode_extended_c: 00355 case opcode_extended_start: 00356 case opcode_extended_m3_tilde: 00357 case opcode_extended_sm3_tilde: 00358 case opcode_extended_rm3_tilde: 00359 case opcode_extended_cm3_tilde: 00360 case opcode_extended_off: 00361 case opcode_extended_program_print: 00362 case opcode_extended_display_print: 00363 case opcode_extended_paper_feed: 00364 case opcode_extended_rounding_switch_up: 00365 case opcode_extended_rounding_switch_off: 00366 case opcode_extended_rounding_switch_down: 00367 case opcode_extended_decimal_point_selector_0: 00368 case opcode_extended_decimal_point_selector_1: 00369 case opcode_extended_decimal_point_selector_2: 00370 case opcode_extended_decimal_point_selector_3: 00371 case opcode_extended_decimal_point_selector_4: 00372 case opcode_extended_decimal_point_selector_5: 00373 case opcode_extended_decimal_point_selector_6: 00374 case opcode_extended_decimal_point_selector_7: 00375 case opcode_extended_decimal_point_selector_8: 00376 case opcode_extended_decimal_point_selector_9: 00377 case opcode_extended_decimal_point_selector_10: 00378 case opcode_extended_decimal_point_selector_11: 00379 case opcode_extended_decimal_point_selector_12: 00380 case opcode_extended_decimal_point_selector_float: 00381 case opcode_extended_goto_000: 00382 case opcode_extended_goto_001: 00383 case opcode_extended_goto_002: 00384 case opcode_extended_goto_003: 00385 case opcode_extended_goto_004: 00386 case opcode_extended_goto_005: 00387 case opcode_extended_goto_006: 00388 case opcode_extended_goto_007: 00389 case opcode_extended_goto_008: 00390 case opcode_extended_goto_009: 00391 case opcode_extended_goto_010: 00392 case opcode_extended_goto_011: 00393 case opcode_extended_goto_012: 00394 case opcode_extended_goto_013: 00395 case opcode_extended_goto_014: 00396 case opcode_extended_goto_015: 00397 case opcode_extended_goto_100: 00398 case opcode_extended_goto_101: 00399 case opcode_extended_goto_102: 00400 case opcode_extended_goto_103: 00401 case opcode_extended_goto_104: 00402 case opcode_extended_goto_105: 00403 case opcode_extended_goto_106: 00404 case opcode_extended_goto_107: 00405 case opcode_extended_goto_108: 00406 case opcode_extended_goto_109: 00407 case opcode_extended_goto_110: 00408 case opcode_extended_goto_111: 00409 case opcode_extended_goto_112: 00410 case opcode_extended_goto_113: 00411 case opcode_extended_goto_114: 00412 case opcode_extended_goto_115: 00413 case opcode_extended_goto_200: 00414 case opcode_extended_goto_201: 00415 case opcode_extended_goto_202: 00416 case opcode_extended_goto_203: 00417 case opcode_extended_goto_204: 00418 case opcode_extended_goto_205: 00419 case opcode_extended_goto_206: 00420 case opcode_extended_goto_207: 00421 case opcode_extended_goto_208: 00422 case opcode_extended_goto_209: 00423 case opcode_extended_goto_210: 00424 case opcode_extended_goto_211: 00425 case opcode_extended_goto_212: 00426 case opcode_extended_goto_213: 00427 case opcode_extended_goto_214: 00428 case opcode_extended_goto_215: 00429 case opcode_extended_goto_300: 00430 case opcode_extended_goto_301: 00431 case opcode_extended_goto_302: 00432 case opcode_extended_goto_303: 00433 case opcode_extended_goto_304: 00434 case opcode_extended_goto_305: 00435 case opcode_extended_goto_306: 00436 case opcode_extended_goto_307: 00437 case opcode_extended_goto_308: 00438 case opcode_extended_goto_309: 00439 case opcode_extended_goto_310: 00440 case opcode_extended_goto_311: 00441 case opcode_extended_goto_312: 00442 case opcode_extended_goto_313: 00443 case opcode_extended_goto_314: 00444 case opcode_extended_goto_315: 00445 case opcode_extended_goto_400: 00446 case opcode_extended_goto_401: 00447 case opcode_extended_goto_402: 00448 case opcode_extended_goto_403: 00449 case opcode_extended_goto_404: 00450 case opcode_extended_goto_405: 00451 case opcode_extended_goto_406: 00452 case opcode_extended_goto_407: 00453 case opcode_extended_goto_408: 00454 case opcode_extended_goto_409: 00455 case opcode_extended_goto_410: 00456 case opcode_extended_goto_411: 00457 case opcode_extended_goto_412: 00458 case opcode_extended_goto_413: 00459 case opcode_extended_goto_414: 00460 case opcode_extended_goto_415: 00461 case opcode_extended_goto_500: 00462 case opcode_extended_goto_501: 00463 case opcode_extended_goto_502: 00464 case opcode_extended_goto_503: 00465 case opcode_extended_goto_504: 00466 case opcode_extended_goto_505: 00467 case opcode_extended_goto_506: 00468 case opcode_extended_goto_507: 00469 case opcode_extended_goto_508: 00470 case opcode_extended_goto_509: 00471 case opcode_extended_goto_510: 00472 case opcode_extended_goto_511: 00473 case opcode_extended_goto_512: 00474 case opcode_extended_goto_513: 00475 case opcode_extended_goto_514: 00476 case opcode_extended_goto_515: 00477 case opcode_extended_goto_600: 00478 case opcode_extended_goto_601: 00479 case opcode_extended_goto_602: 00480 case opcode_extended_goto_603: 00481 case opcode_extended_goto_604: 00482 case opcode_extended_goto_605: 00483 case opcode_extended_goto_606: 00484 case opcode_extended_goto_607: 00485 case opcode_extended_goto_608: 00486 case opcode_extended_goto_609: 00487 case opcode_extended_goto_610: 00488 case opcode_extended_goto_611: 00489 case opcode_extended_goto_612: 00490 case opcode_extended_goto_613: 00491 case opcode_extended_goto_614: 00492 case opcode_extended_goto_615: 00493 case opcode_extended_goto_700: 00494 case opcode_extended_goto_701: 00495 case opcode_extended_goto_702: 00496 case opcode_extended_goto_703: 00497 case opcode_extended_goto_704: 00498 case opcode_extended_goto_705: 00499 case opcode_extended_goto_706: 00500 case opcode_extended_goto_707: 00501 case opcode_extended_goto_708: 00502 case opcode_extended_goto_709: 00503 case opcode_extended_goto_710: 00504 case opcode_extended_goto_711: 00505 case opcode_extended_goto_712: 00506 case opcode_extended_goto_713: 00507 case opcode_extended_goto_714: 00508 case opcode_extended_goto_715: 00509 // nothing for extended opcodes 00510 break; 00511 00512 default: 00513 yuck: 00514 if ((int)op < 128) 00515 { 00516 // used to indicate an invalid opcode 00517 column18 = column18_minus; 00518 } 00519 break; 00520 } 00521 }