3737
3838 ld sp , kernelGarbage + kernelGarbageSize
3939
40- #ifndef SKIPON
4140 call suspendDevice
42- #endif
4341;; reboot [System]
4442;; Restarts the device.
4543reboot:
@@ -63,118 +61,24 @@ reboot:
6361 out (PORT_BANKB) , a
6462#endif
6563
66- ; Manipulate protection states
67- #ifdef CPU15 ; TI-83+ SE, TI-84+, TI-84+ SE, TI-84+ CSE
6864 call unlockFlash
69- ; Remove RAM Execution Protection
70- xor a
71- out (PORT_RAMEXEC_LOWLIMIT) , a ; RAM Lower Limit ; out (25), 0
72- dec a
73- out (PORT_RAMEXEC_UPLIMIT) , a ; RAM Upper Limit ; out (26), $FF
74-
75- ; Remove Flash Execution Protection
76- out (PORT_FLASHEXEC_LOWLIMIT) , a ; Flash Lower Limit ; out (22), $FF
77- out (PORT_FLASHEXEC_UPLIMIT) , a ; Flash Upper Limit ; out (23), $FF
65+ call unprotectRAM
66+ call unprotectFlash
7867 call lockFlash
7968
80- ; Set CPU speed to 15 MHz
69+ #ifdef CPU15
8170 ld a , BIT_CPUSPEED_15MHZ
8271 out (PORT_CPUSPEED) , a
83-
84- #else ; TI-73, TI-83+
85- #ifndef TI73 ; RAM does not have protection on the TI-73
86-
87- ; Remove RAM/Flash protection
88- call unlockFlash
89- xor a
90- out (PORT_RAM_PAGING) , a
91- out (PORT_FLASHEXCLUSION) , a
92-
93- ld a , 0b000000001
94- out (PORT_RAM_PAGING) , a
95- xor a
96- out (PORT_FLASHEXCLUSION) , a
97-
98- ld a , 0b000000010
99- out (PORT_RAM_PAGING) , a
100- xor a
101- out (PORT_FLASHEXCLUSION) , a
102-
103- ld a , 0b000000111
104- out (PORT_RAM_PAGING) , a
105- xor a
106- out (PORT_FLASHEXCLUSION) , a
107- call lockFlash
108- #endif
10972#endif
11073
111- ; Set interrupt mode
11274 ld a , INT_ON | INT_TIMER1 | INT_LINK
11375 out (PORT_INT_MASK) , a
114- ; Set timer frequency (TODO)
115-
116- ; Clear RAM
117- ld hl , 0x8000
118- ld (hl) , 0
119- ld de , 0x8001
120- ld bc , 0x7FFF
121- ldir
12276
12377 call formatMem
124-
125- ; Set all file handles to unused
126- ld hl , fileHandleTable
127- ld (hl) , 0xFF
128- ld de , fileHandleTable + 1
129- ld bc , 8 * maxFileStreams
130- ldir
131-
132- ld a , threadRangeMask ; When the first thread is allocated, this will wrap to 0
133- ld (lastThreadId) , a
134-
135- #ifdef COLOR
136- ; Set GPIO config
137- ld a , 0xE0
138- out (PORT_GPIO_CONFIG) , a
139- ld a , 1
140- ld (color_mode) , a
141- #else
142- ; Initialize LCD
143- ld a , 1 + LCD_CMD_AUTOINCDEC_SETX
144- call lcdDelay
145- out (PORT_LCD_CMD) , a ; X-Increment Mode
146-
147- ld a , 1 + LCD_CMD_SETOUTPUTMODE
148- call lcdDelay
149- out (PORT_LCD_CMD) , a ; 8-bit mode
150-
151- ld a , 1 + LCD_CMD_SETDISPLAY
152- call lcdDelay
153- out (PORT_LCD_CMD) , a ; Enable screen
154-
155- ld a , 7 + LCD_CMD_POWERSUPPLY_SETLEVEL ; versus +3? TIOS uses +7, and that's the only value that works (the datasheet says go with +3)
156- call lcdDelay
157- out (PORT_LCD_CMD) , a ; Op-amp control (OPA1) set to max (with DB1 set for some reason)
158-
159- ld a , 3 + LCD_CMD_POWERSUPPLY_SETENHANCEMENT ; B
160- call lcdDelay
161- out (PORT_LCD_CMD) , a ; Op-amp control (OPA2) set to max
162-
163- ; Different amounts of contrast look better on different models
164- #ifdef USB
165- ld a , 0x2F + LCD_CMD_SETCONTRAST
166- #else
167- #ifdef TI73
168- ld a , 0x3B + LCD_CMD_SETCONTRAST
169- #else
170- ld a , 0x34 + LCD_CMD_SETCONTRAST
171- #endif
172- #endif
173-
174- ld (currentContrast) , a
175- call lcdDelay
176- out (PORT_LCD_CMD) , a ; Contrast
177- #endif
78+ call initRandom
79+ call initFilesystem
80+ call initMultitasking
81+ call initDisplay
17882
17983 ld de , init
18084 call fileExists
0 commit comments