1 /*
2 * libtilemcore - Graphing calculator emulation library
3 *
4 * Copyright (C) 2001 Solignac Julien
5 * Copyright (C) 2004-2012 Benjamin Moody
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see
19 * <http://www.gnu.org/licenses/>.
20 */
21
22 #ifdef HAVE_CONFIG_H
23 # include <config.h>
24 #endif
25
26 #include <stdio.h>
27 #include <tilem.h>
28
29 #include "xs.h"
30
31 void xp_fix_cert(TilemCalc* calc, byte *cert);
32
xs_reset(TilemCalc * calc)33 void xs_reset(TilemCalc* calc)
34 {
35 calc->hwregs[PORT3] = 0x0B;
36 calc->hwregs[PORT4] = 0x77;
37 calc->hwregs[PORT6] = 0x7F;
38 calc->hwregs[PORT7] = 0x7F;
39
40 calc->mempagemap[0] = 0x00;
41 calc->mempagemap[1] = 0x7E;
42 calc->mempagemap[2] = 0x7F;
43 calc->mempagemap[3] = 0x7F;
44
45 calc->z80.r.pc.d = 0x8000;
46
47 calc->hwregs[PORT8] = 0x80;
48
49 calc->hwregs[PORT20] = 0;
50 calc->hwregs[PORT21] = 1;
51 calc->hwregs[PORT22] = 0x08;
52 calc->hwregs[PORT23] = 0x69;
53 calc->hwregs[PORT25] = 0x10;
54 calc->hwregs[PORT26] = 0x20;
55 calc->hwregs[PORT27] = 0;
56 calc->hwregs[PORT28] = 0;
57 calc->hwregs[PORT29] = 0x14;
58 calc->hwregs[PORT2A] = 0x27;
59 calc->hwregs[PORT2B] = 0x2F;
60 calc->hwregs[PORT2C] = 0x3B;
61 calc->hwregs[PORT2D] = 0x01;
62 calc->hwregs[PORT2E] = 0x44;
63 calc->hwregs[PORT2F] = 0x4A;
64
65 calc->hwregs[FLASH_READ_DELAY] = 0;
66 calc->hwregs[FLASH_WRITE_DELAY] = 0;
67 calc->hwregs[FLASH_EXEC_DELAY] = 0;
68 calc->hwregs[RAM_READ_DELAY] = 0;
69 calc->hwregs[RAM_WRITE_DELAY] = 0;
70 calc->hwregs[RAM_EXEC_DELAY] = 0;
71 calc->hwregs[LCD_PORT_DELAY] = 5;
72 calc->hwregs[NO_EXEC_RAM_MASK] = 0x7C00;
73 calc->hwregs[NO_EXEC_RAM_LOWER] = 0x4000;
74 calc->hwregs[NO_EXEC_RAM_UPPER] = 0x8000;
75
76 calc->hwregs[PROTECTSTATE] = 0;
77
78 calc->flash.overridegroup = 1;
79
80 tilem_z80_set_speed(calc, 6000);
81
82 tilem_z80_set_timer(calc, TIMER_INT1, 1600, 9277, 1);
83 tilem_z80_set_timer(calc, TIMER_INT2A, 1300, 9277, 1);
84 tilem_z80_set_timer(calc, TIMER_INT2B, 1000, 9277, 1);
85 }
86
xs_stateloaded(TilemCalc * calc,int savtype TILEM_ATTR_UNUSED)87 void xs_stateloaded(TilemCalc* calc, int savtype TILEM_ATTR_UNUSED)
88 {
89 tilem_calc_fix_certificate(calc, calc->mem + (0x7E * 0x4000L),
90 0x69, 0x0c, 0x1e50);
91 }
92