01.z80 7.5 KB

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