Guest User

Untitled

a guest
Sep 10th, 2025
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.74 KB | None | 0 0
  1. ; Stub for the TI 83+ calculator
  2. ;
  3. ; Stefano Bodrato - Dec 2000
  4. ; Feb 2000 - Speeded up the cpygraph
  5. ;
  6. ; $Id: ti83p_crt0.asm,v 1.33 2016-07-11 05:58:34 stefano Exp $
  7. ;
  8. ; startup =
  9. ; n - Primary shell, compatible shells
  10. ; (Primary shell merely means it's the smallest implementation
  11. ; for that shell, that uses full capabilities of the shell)
  12. ;
  13. ; 1 - Ion (default)
  14. ; 2 - MirageOS without quit key
  15. ; 3 -
  16. ; 4 - TSE Kernel
  17. ; 10 - asm( executable
  18. ; 11 - DoorsCS executable
  19. ;
  20. ;-----------------------------------------------------
  21. ; Some general PUBLICs and EXTERNs needed by the assembler
  22. ;-----------------------------------------------------
  23.  
  24. MODULE Ti83plus_crt0
  25.  
  26. EXTERN _main ; No matter what set up we have, main is
  27. ; always, always external to this file.
  28.  
  29. PUBLIC crt0_exit ; used by exit()
  30. PUBLIC l_dcal ; used by calculated calls = "call (hl)"
  31.  
  32.  
  33. PUBLIC cpygraph ; TI calc specific stuff
  34. PUBLIC tidi ;
  35. PUBLIC tiei ;
  36. PUBLIC __Exit
  37.  
  38.  
  39. ;-------------------------
  40. ; Begin of (shell) headers
  41. ;-------------------------
  42.  
  43. INCLUDE "Ti83p.def" ; ROM / RAM adresses on Ti83+[SE]
  44. defc crt0 = 1
  45. INCLUDE "zcc_opt.def" ; Receive all compiler-defines
  46.  
  47. defc CONSOLE_ROWS = 8
  48. defc TAR__clib_exit_stack_size = 3
  49. defc TAR__register_sp = -1
  50. defc __CPU_CLOCK = 6000000
  51. INCLUDE "crt/classic/crt_rules.inc"
  52.  
  53. ;-----------------------------
  54. ;2 - MirageOS without quit key
  55. ;-----------------------------
  56. IF (startup=2)
  57. DEFINE MirageOS ;Used by greyscale interrupt etc.
  58. DEFINE NOT_DEFAULT_SHELL ;Else we would use Ion
  59. org $9D95
  60. ;org $9D93
  61. ;defb $BB,$6D
  62. ret ;So TIOS wont run the program
  63. defb 1 ;Identifier as MirageOS program
  64. DEFINE NEED_mirage_icon
  65. INCLUDE "zcc_opt.def"
  66. UNDEFINE NEED_mirage_icon
  67. IF !DEFINED_NEED_mirage_icon
  68. defb @01111000,@00000000 ;Picture of a map with "C+" on it
  69. defb @10000100,@00000000
  70. defb @10000011,@11111100 ;15x15 button
  71. defb @10000000,@00000010
  72. defb @10011111,@00000010
  73. defb @10111111,@00000010
  74. defb @10110000,@00110010
  75. defb @10110000,@01111010
  76. defb @10110000,@01111010
  77. defb @10110000,@00110010
  78. defb @10111111,@00000010
  79. defb @10011111,@00000010
  80. defb @10000000,@00000010
  81. defb @10000000,@00000010
  82. defb @01111111,@11111100
  83. ENDIF
  84. DEFINE NEED_name
  85. INCLUDE "zcc_opt.def" ; Get namestring from zcc_opt.def
  86. UNDEFINE NEED_name
  87. IF !DEFINED_NEED_name
  88. defm "Z88DK Small C+ Program"
  89. ENDIF
  90. defb $0 ; Termination zero
  91. im 1 ; Disable MirageOS tasker interrupt...
  92. ENDIF
  93.  
  94. ;--------------
  95. ;4 - TSE Kernel
  96. ;--------------
  97. IF (startup = 4)
  98. DEFINE TSE
  99. DEFINE NOT_DEFAULT_SHELL
  100. org $9D94
  101. ret
  102. defm "TSE"
  103. defb 1
  104. defm " "
  105. DEFINE NEED_name
  106. INCLUDE "zcc_opt.def"
  107. UNDEFINE NEED_name
  108. IF !DEFINED_NEED_name
  109. defm "Z88DK Small C+ Program"
  110. ENDIF
  111. defb $0
  112. ;-----------------------------------------------------------------------------
  113. ; External Data Required for virtual stack. I've set this to 400
  114. ; (the normal size of the Ti83+ stack). You can use #pragma to set
  115. ; a userdefined value (RECOMMENDED):
  116. ; #pragma output StackNeeded = nnn;
  117. ;-----------------------------------------------------------------------------
  118. IF !DEFINED_StackNeeded
  119. defw 400
  120. ELSE
  121. defw DEFINED_StackNeeded
  122. ENDIF
  123. ENDIF
  124.  
  125. ;--------------------
  126. ;10 - asm( executable
  127. ;--------------------
  128. IF (startup=10)
  129. DEFINE ASM
  130. DEFINE NOT_DEFAULT_SHELL
  131. org $9D95
  132. ;org $9D93
  133. ;defb $BB,$6D
  134. ENDIF
  135.  
  136. ;--------------------
  137. ;11 - DoorsCS executable
  138. ;--------------------
  139. IF (startup=11)
  140. DEFINE DCS
  141. DEFINE NOT_DEFAULT_SHELL
  142. org $9D95
  143. xor d
  144. ret
  145. jr _ENDHEADER_
  146.  
  147. DEFINE NEED_dc_desc
  148. DEFINE NEED_dc_icon
  149. DEFINE NEED_dc_ales
  150. INCLUDE "zcc_opt.def"
  151. UNDEFINE NEED_dc_desc
  152. UNDEFINE NEED_dc_icon
  153. UNDEFINE NEED_dc_ales
  154.  
  155. IF DEFINED_NEED_dc_desc
  156. dw _program_description
  157. ELSE
  158. dw DefaultDescription
  159. ENDIF
  160. db $07,$00
  161. IF DEFINED_NEED_dc_icon
  162. dw _icon_data
  163. ELSE
  164. dw DefaultIcon
  165. ENDIF
  166. IF DEFINED_NEED_dc_ales
  167. dw _ales
  168. ELSE
  169. db $00,$00
  170. ENDIF
  171.  
  172. IF !DEFINE_NEED_dc_desc
  173. DefaultDescription:
  174. defb "DoorsCS Program",0
  175. ENDIF
  176. IF !DEFINED_NEED_dc_icon
  177. DefaultIcon:
  178. db @11111111,@11111111
  179. db @11111111,@11111111
  180. db @11111111,@11111111
  181. db @11111111,@11111111
  182. db @11111111,@11111111
  183. db @11111111,@11111111
  184. db @11111111,@11111111
  185. db @11111111,@11111111
  186. db @11111111,@11111111
  187. db @11111111,@11111111
  188. db @11111111,@11111111
  189. db @11111111,@11111111
  190. db @11111111,@11111111
  191. db @11111111,@11111111
  192. db @11111111,@11111111
  193. db @11111111,@11111111
  194. ENDIF
  195. _ENDHEADER_:
  196.  
  197. ENDIF
  198.  
  199.  
  200. ;-----------------
  201. ;1 - Ion (default)
  202. ;-----------------
  203. IF !NOT_DEFAULT_SHELL
  204. DEFINE Ion
  205. org $9D95
  206. ;org $9D93
  207. ;defb $BB,$6D
  208. ret
  209. jr nc,start
  210. DEFINE NEED_name
  211. INCLUDE "zcc_opt.def"
  212. UNDEFINE NEED_name
  213. IF !DEFINED_NEED_name
  214. defm "Z88DK Small C+ Program"
  215. ENDIF
  216. defb $0
  217. ENDIF
  218.  
  219.  
  220. ;-------------------------------------
  221. ; End of header, begin of startup part
  222. ;-------------------------------------
  223. start:
  224. IF DEFINED_GimmeSpeed
  225. ld a,1 ; switch to 15MHz (extra fast)
  226. rst 28 ; bcall(SetExSpeed)
  227. defw SetExSpeed ;
  228. ENDIF ;
  229. ld (__restore_sp_onexit+1),sp ;
  230. INCLUDE "crt/classic/crt_init_sp.inc"
  231. call crt0_init
  232. INCLUDE "crt/classic/crt_init_atexit.inc"
  233.  
  234. INCLUDE "crt/classic/crt_init_heap.inc"
  235.  
  236.  
  237. EXTERN fputc_cons
  238. ld hl,12
  239. push hl
  240. call fputc_cons
  241. pop hl
  242.  
  243. IF DEFINED_GRAYlib
  244. IF DEFINED_GimmeSpeed
  245. INCLUDE "target/ti83p/classic/gray83pSE.asm" ; 15MHz grayscale interrupt
  246. ELSE
  247. INCLUDE "target/ti83p/classic/gray83p.asm" ; 6MHz grayscale interrupt
  248. ENDIF
  249. ELSE
  250. INCLUDE "target/ti83p/classic/intwrap83p.asm" ; Interrupt Wrapper
  251. ENDIF
  252.  
  253. im 2 ; enable IM2 interrupt
  254. call _main ; call main()
  255. __Exit: ; exit() jumps to this point
  256. ld iy,_IY_TABLE ; Restore flag pointer
  257. im 1 ;
  258. IF DEFINED_GimmeSpeed ;
  259. xor a ; Switch to 6MHz (normal speed)
  260. rst 28 ; bcall(SetExSpeed)
  261. defw SetExSpeed ;
  262. ENDIF ;
  263. __restore_sp_onexit:
  264. ld sp,0 ; Restore SP
  265. IF TSE ; TSE Kernel
  266. call _tseForceYield ; Task-switch back to shell (can return...)
  267. jp start ; begin again if needed...
  268. ENDIF ;
  269. tiei: ei ;
  270. IF DEFINED_GRAYlib ;
  271. cpygraph:
  272. ENDIF ;
  273. tidi: ret ;
  274.  
  275. ;----------------------------------------
  276. ; End of startup part, routines following
  277. ;----------------------------------------
  278. l_dcal:
  279. jp (hl) ; used as "call (hl)"
  280.  
  281. IF !DEFINED_GRAYlib
  282. IF DEFINED_GimmeSpeed
  283. cpygraph:
  284. call $50 ; bjump(GrBufCpy)
  285. defw GrBufCpy ; FastCopy is far too fast at 15MHz...
  286. ELSE
  287. IF Ion
  288. defc cpygraph = $966E+80+15 ; Ion FastCopy call
  289. ENDIF
  290. IF MirageOS
  291. defc cpygraph = $4092 ; MirageOS FastCopy call
  292. ENDIF
  293. IF TSE
  294. defc cpygraph = $8A3A+18 ; TSE FastCopy call
  295. ENDIF
  296. IF DCS
  297. defc cpygraph = $4092 ; I guess this is DCS FastCopy call?
  298. ENDIF
  299. IF ASM
  300. cpygraph:
  301. ;(ion)FastCopy from Joe Wingbermuehle
  302. di
  303. ld a,$80 ; 7
  304. out ($10),a ; 11
  305. ld hl,plotSScreen-12-(-(12*64)+1) ; 10
  306. ld a,$20 ; 7
  307. ld c,a ; 4
  308. inc hl ; 6 waste
  309. dec hl ; 6 waste
  310. fastCopyAgain:
  311. ld b,64 ; 7
  312. inc c ; 4
  313. ld de,-(12*64)+1 ; 10
  314. out ($10),a ; 11
  315. add hl,de ; 11
  316. ld de,10 ; 10
  317. fastCopyLoop:
  318. add hl,de ; 11
  319. inc hl ; 6 waste
  320. inc hl ; 6 waste
  321. inc de ; 6
  322. ld a,(hl) ; 7
  323. out ($11),a ; 11
  324. dec de ; 6
  325. djnz fastCopyLoop ; 13/8
  326. ld a,c ; 4
  327. cp $2B+1 ; 7
  328. jr nz,fastCopyAgain ; 10/1
  329. ret ; 10
  330. ENDIF
  331. ENDIF
  332. ENDIF
  333.  
  334. defc ansipixels = 96
  335. IF !DEFINED_ansicolumns
  336. defc DEFINED_ansicolumns = 1
  337. defc ansicolumns = 32
  338. ENDIF
  339.  
  340. INCLUDE "crt/classic/crt_runtime_selection.inc"
  341. INCLUDE "crt/classic/crt_section.inc"
  342.  
  343. SECTION code_crt_init
  344. ld hl,plotSScreen
  345. ld (base_graphics),hl
  346.  
Advertisement
Add Comment
Please, Sign In to add comment