Guest User

Untitled

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