01.z80 7.5 KB

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