01.z80 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. .org $4000
  2. #define scrap 8000h
  3. #include "gfx/bigtile.z80"
  4. #include "isort.z80"
  5. ;#include "compile.z80"
  6. drawrect:
  7. #include "gfx/drawrect.z80"
  8. #include "math/rand_single.z80"
  9. #include "math/atanbin.z80"
  10. #include "gfx/circle.z80"
  11. #include "gfx/filledcircle.z80"
  12. #include "gfx/tilemap.z80"
  13. p1_GraphToLCD:
  14. #include "gfx/gbufToLCD_speed.z80"
  15. call_ix_01:
  16. jp (ix)
  17. pixelOn_pattern:
  18. call getpixelloc
  19. ret nc
  20. or (hl)
  21. ld (hl),a
  22. ret
  23. pixelOff_pattern:
  24. call getpixelloc
  25. ret nc
  26. cpl
  27. and (hl)
  28. ld (hl),a
  29. ret
  30. pixelToggle_pattern:
  31. call getpixelloc
  32. ret nc
  33. xor (hl)
  34. ld (hl),a
  35. ret
  36. #include "absSingle.z80"
  37. #include "negSingle.z80"
  38. #include "cmpSingle.z80"
  39. #include "randSingle.z80"
  40. #include "acosSingle.z80"
  41. #include "asinSingle.z80"
  42. #include "atanSingle.z80"
  43. #include "acoshSingle.z80"
  44. #include "asinhSingle.z80"
  45. #include "atanhSingle.z80"
  46. #include "coshSingle.z80"
  47. #include "sinhSingle.z80"
  48. #include "tanhSingle.z80"
  49. #include "tanSingle.z80"
  50. #include "powSingle.z80"
  51. #include "pow10Single.z80"
  52. #include "logSingle.z80"
  53. #include "lgSingle.z80"
  54. #include "log10Single.z80"
  55. #include "single2str.z80"
  56. #include "str2single.z80"
  57. #include "singleTo_int16.z80"
  58. #ifdef INCLUDE_GRAMPKG
  59. grampkg_start:
  60. #define EXCLUDE_GRAMPKG_INC
  61. #include "grampkg.z80"
  62. grampkg_end:
  63. #endif
  64. menu_code_start:
  65. #include "cmd/menu.z80"
  66. #include "cmd/searchstring.z80"
  67. #include "io/getKeyChar.z80"
  68. #include "io/getKeyTok.z80"
  69. #include "io/input.z80"
  70. #include "io/menu.z80"
  71. #include "io/sound.z80"
  72. #include "cmd/prime.z80"
  73. #include "cmd/param.z80"
  74. #include "cmd/solve.z80"
  75. #include "subroutines/searchline.z80"
  76. #include "subroutines/zlz_decomp.z80"
  77. #include "subroutines/zlz_comp.z80"
  78. #include "subroutines/heapsort.z80"
  79. #include "subroutines/zcomp.z80"
  80. p1_PutTokenText:
  81. ld bc,PutTokenText
  82. ld (prev_page_call_address),bc
  83. jp prev_page_call
  84. p1_ParseFullArg:
  85. ld hl,ParseFullArg
  86. ld (prev_page_call_address),hl
  87. jp prev_page_call
  88. p1_ParseNextFullArg:
  89. ld hl,ParseNextFullArg
  90. ld (prev_page_call_address),hl
  91. jp prev_page_call
  92. p1_ParserNext:
  93. ld hl,ParserNext
  94. ld (prev_page_call_address),hl
  95. jp prev_page_call
  96. p1_err_fatal:
  97. p1_err_syntax:
  98. push hl
  99. ld hl,err_fatal
  100. jr jp_prev_page_call
  101. p1_ErrBadToken:
  102. push hl
  103. ld hl,ErrBadToken
  104. jr jp_prev_page_call
  105. p1_ErrStackOverflow_push:
  106. push hl
  107. ld hl,ErrStackOverflow_push
  108. jr jp_prev_page_call
  109. p1_ErrStackOverflow_pop:
  110. push hl
  111. ld hl,ErrStackOverflow_pop
  112. jr jp_prev_page_call
  113. p1_ErrMem:
  114. push hl
  115. ld hl,ErrMem
  116. jr jp_prev_page_call
  117. p1_VarP:
  118. push hl
  119. ld hl,VarP
  120. jr jp_prev_page_call
  121. p1_parse_by_ptr_to_ptr:
  122. push hl
  123. ld hl,parse_by_ptr_to_ptr
  124. jr jp_prev_page_call
  125. p1_GetGrammerStr:
  126. push hl
  127. ld hl,GetGrammerStr
  128. jr jp_prev_page_call
  129. p1_GetVarInfo2:
  130. push hl
  131. ld hl,GetVarInfo2
  132. jr jp_prev_page_call
  133. p1_GetVarInfo:
  134. push hl
  135. ld hl,GetVarInfo
  136. jr jp_prev_page_call
  137. p1_EndOfLine:
  138. push hl
  139. ld hl,EndOfLine
  140. jr jp_prev_page_call
  141. p1_getKeyDebounce:
  142. push hl
  143. ld hl,getKeyDebounce
  144. jp_prev_page_call:
  145. ld (prev_page_call_address),hl
  146. pop hl
  147. jp prev_page_call
  148. verify_package:
  149. ;A:HL points to the data
  150. ;BC is the size of the data
  151. ;Returns carry flag reset if good, carry set if bad
  152. ;Need to read 4-byte magic number
  153. ;Need to read the valid version number and size of table
  154. ;Verify that the package has at least 8 bytes
  155. inc b
  156. dec b
  157. jr nz,+_
  158. ld b,a
  159. ld a,c
  160. cp 8
  161. ld a,b
  162. ret c
  163. _:
  164. ;If magic number doesn't match, then we quit
  165. ;If it does match, then we'll assume it is formatted
  166. ;correctly. No need to save BC (or DE for that matter)
  167. ;Just need A:HL
  168. ld bc,6
  169. ld de,cmdShadow
  170. call ReadArc
  171. ;magic number
  172. ex de,hl
  173. or a
  174. ld hl,(cmdShadow)
  175. .db 1 ;start of ld bc,**
  176. .db "Gr"
  177. sbc hl,bc
  178. scf
  179. ret nz
  180. or a
  181. ld hl,(cmdShadow+2)
  182. .db 1 ;start of ld bc,**
  183. .db "am"
  184. sbc hl,bc
  185. scf
  186. ret nz
  187. ;pkg version
  188. ld hl,(cmdShadow+4)
  189. ld bc,MODULE_VERSION-1
  190. sbc hl,bc
  191. ret
  192. FS_find_new:
  193. ld hl,(FS_begin)
  194. jr FS_find_new_start
  195. FS_find_new_loop:
  196. ld b,a
  197. ld c,a
  198. cpir
  199. ld c,(hl)
  200. inc hl
  201. ld b,(hl)
  202. inc hl
  203. add hl,bc
  204. FS_find_new_start:
  205. xor a
  206. cp (hl)
  207. jr nz,FS_find_new_loop
  208. ret
  209. FS_createvar_max_01:
  210. ;Input:
  211. ; HL points to the name
  212. ; BC is the size of the name (sans null-byte)
  213. ;Output:
  214. ; HL points to the data
  215. ; BC is the size
  216. ; DE points to the name
  217. ;
  218. push hl
  219. push bc
  220. call FS_find_new
  221. ;HL points to where to write it
  222. ;Make sure that HL+BC+2 - (FS_end) < 0
  223. push hl
  224. add hl,bc
  225. inc hl
  226. inc hl
  227. ld de,(FS_end)
  228. ; or a
  229. sbc hl,de
  230. jp nc,p1_ErrMem
  231. ;Now -HL-1 is going to be the size of the var!
  232. ld a,h
  233. cpl
  234. ld h,a
  235. ld a,l
  236. cpl
  237. ld l,a
  238. pop de
  239. pop bc
  240. ex (sp),hl
  241. ;DE is where to write
  242. ;HL is the string
  243. ;BC is the size
  244. push de
  245. ldir
  246. ex de,hl
  247. pop de
  248. pop bc
  249. ld (hl),0
  250. inc hl
  251. ld (hl),c
  252. inc hl
  253. ld (hl),b
  254. inc hl
  255. ret
  256. FS_delvar_01:
  257. call FS_findvar_01
  258. add hl,bc
  259. ; or a
  260. sbc hl,de
  261. ; Need to delete HL bytes at DE
  262. ;Need to set up the buf_end and buf_top, first
  263. push hl
  264. ld hl,(FS_end)
  265. ld (buf_top),hl
  266. call FS_find_new
  267. ld (buf_end),hl
  268. pop bc
  269. ex de,hl
  270. call delmem
  271. ret nc
  272. jp p1_ErrMem
  273. FS_resize_01:
  274. ;HL points to the data
  275. ;BC is the new size
  276. ;Need to set up the buf_end and buf_top, though
  277. ex de,hl
  278. push bc
  279. ld hl,(FS_end)
  280. ld (buf_top),hl
  281. call FS_find_new
  282. ld (buf_end),hl
  283. pop bc
  284. ex de,hl
  285. dec hl
  286. ld d,(hl)
  287. ld (hl),b
  288. dec hl
  289. ld e,(hl)
  290. ld (hl),c
  291. inc hl
  292. inc hl
  293. push hl
  294. push bc
  295. add hl,bc
  296. ;HL points to the end of the data
  297. ;need to deallocate DE-BC bytes (if negative, then bytes are allocated!)
  298. ex de,hl
  299. ; or a
  300. sbc hl,bc
  301. ex de,hl
  302. ld b,d
  303. ld c,e
  304. call delmem
  305. pop bc
  306. pop hl
  307. ret nc
  308. jp p1_ErrMem
  309. #include "subroutines/insertdelmem.z80"
  310. FS_findvar_01:
  311. ;Input:
  312. ; HL points to the name of the var to find
  313. ;Output:
  314. ; Carry flag is set if found
  315. ; HL points to the var's data
  316. ; DE pointing to the var name
  317. ; BC is the size
  318. ;
  319. ex de,hl
  320. ld hl,(FS_begin)
  321. jr FS_findvar_begin
  322. FS_findvar_loop:
  323. ;Then assume the file is not malformed
  324. push hl
  325. push de
  326. call cpstr
  327. pop de
  328. jr z,FS_file_found
  329. pop af ;Don't need to save the pointer to the file name
  330. ;File not found, so seek the end of the name
  331. xor a
  332. ld b,a
  333. ld c,a
  334. cpir
  335. ;Now HL points to the size bytes
  336. ;need to skip the data
  337. ld c,(hl)
  338. inc hl
  339. ld b,(hl)
  340. inc hl
  341. add hl,bc
  342. FS_findvar_begin:
  343. ;Check if there are any more files
  344. ld a,(hl)
  345. or a
  346. ret z
  347. ;Check if HL is past FS_end
  348. ld bc,FS_end
  349. or a
  350. sbc hl,bc
  351. add hl,bc
  352. ret z
  353. jr c,FS_findvar_loop
  354. scf
  355. ret
  356. FS_file_found:
  357. inc hl
  358. ld c,(hl)
  359. inc hl
  360. ld b,(hl)
  361. inc hl
  362. pop de
  363. ret
  364. _:
  365. inc de
  366. inc hl
  367. cpstr:
  368. ;Compare two strings at HL and DE
  369. ;returns z if they are equal
  370. ;returns c is DE points to the smaller string
  371. ;returns nc if DE is the bigger (or equal) string.
  372. ld a,(de)
  373. cp (hl)
  374. ret nz
  375. or a
  376. jr nz,-_
  377. ret
  378. LblToken_01:
  379. call p1_ParseFullArg
  380. push bc
  381. ld h,b
  382. ld l,c
  383. call p1_GetGrammerStr
  384. pop hl
  385. push bc
  386. ld de,OP2
  387. ld a,3Fh
  388. ld (de),a
  389. inc de
  390. ld a,3Ah
  391. ld (de),a
  392. inc de
  393. ldir
  394. ld a,3Fh
  395. ld (de),a
  396. ld hl,(parsePtr)
  397. ld a,(hl)
  398. cp 2Bh
  399. jr nz,+_
  400. inc hl
  401. ld (parsePtr),hl
  402. call p1_GetVarInfo2
  403. jr nc,LblToken_ptrdone
  404. _:
  405. ld hl,(progEnd)
  406. ld de,(progStart)
  407. or a
  408. sbc hl,de
  409. ld b,h
  410. ld c,l
  411. ex de,hl
  412. LblToken_ptrdone:
  413. ld de,OP2
  414. pop ix
  415. ld de,3
  416. add ix,de
  417. ld de,OP2
  418. call searchstring_routine
  419. jp nc,p1_ErrBadToken
  420. inc hl
  421. call p1_EndOfLine
  422. ld b,h
  423. ld c,l
  424. ret
  425. #include "tokenhook.z80"
  426. #include "modemenu.z80"
  427. .echo "Page 1: ",$8000-$," bytes remaining"