01.z80 7.6 KB

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