Mirror of CollapseOS
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

263 行
6.3KB

  1. .equ IYBAS 23610 ; user.h
  2. ; The ZX Spectrum firmware requires IY value to be equal to 23610
  3. ; (in this case, to handle keyboard interrupts and screen correctly).
  4. ; an IM2 handler has to be included to manage this.
  5. .equ RAMEND 0xffff ; user.h
  6. .equ USER_CODE 41639 ; = BAS_RAMEND+527 in user.h
  7. ; when changing the memory layout, it should have a dummy value for a test assembly,
  8. ; then changed to the actual value in relation to the new BAS_RAMEND
  9. .org 0x5efd
  10. jp init
  11. .inc "err.h"
  12. .inc "ascii.h"
  13. .inc "blkdev.h"
  14. .inc "fs.h"
  15. .inc "kernel/zxs/jumps.asm"
  16. .inc "core.asm"
  17. .inc "kernel/str.asm"
  18. .inc "kernel/zxs/vid.asm"
  19. .inc "kernel/zxs/kbd.asm"
  20. .equ GRID_COLS 32
  21. .equ GRID_ROWS 21 ; to avoid CRLF outside of the #2 screen
  22. .equ GRID_SETCELL v_putc
  23. .equ GRID_GETC k_getc
  24. .equ GRID_RAMSTART RAMSTART
  25. .inc "kernel/grid.asm"
  26. .equ BLOCKDEV_RAMSTART GRID_RAMEND
  27. .equ BLOCKDEV_COUNT 4
  28. .inc "kernel/blockdev.asm"
  29. ; List of devices
  30. .dw mmapGetB, mmapPutB
  31. .dw blk1GetB, blk1PutB
  32. .dw blk2GetB, blk2PutB
  33. .dw tapeGetB, unsetZ ;read-only
  34. .equ STDIO_RAMSTART BLOCKDEV_RAMEND
  35. .equ STDIO_GETC gridGetC
  36. .equ STDIO_PUTC gridPutC
  37. .equ STDIO_SETCUR gridSetCurH
  38. .inc "kernel/stdio.asm"
  39. .equ MMAP_START 0xc000 ; 49152
  40. .equ MMAP_LEN RAMEND-MMAP_START+1
  41. ; 16K, 64 fs blocks for MMAP FS
  42. .inc "kernel/mmap.asm"
  43. .equ FS_RAMSTART STDIO_RAMEND
  44. .equ FS_HANDLE_COUNT 2
  45. .inc "kernel/fs.asm"
  46. ; BASIC shell
  47. ; RAM space used in different routines for short term processing.
  48. .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
  49. .equ SCRATCHPAD FS_RAMEND
  50. .inc "lib/util.asm"
  51. .inc "lib/ari.asm"
  52. .inc "lib/parse.asm"
  53. .inc "lib/fmt.asm"
  54. .equ EXPR_PARSE parseLiteralOrVar
  55. .inc "lib/expr.asm"
  56. .inc "basic/util.asm"
  57. .inc "basic/parse.asm"
  58. .inc "basic/tok.asm"
  59. .equ VAR_RAMSTART SCRATCHPAD+SCRATCHPAD_SIZE
  60. .inc "basic/var.asm"
  61. .equ BUF_RAMSTART VAR_RAMEND
  62. .equ BUF_POOLSIZE 0x800 ; 0x1000 by default, cut to save some RAM
  63. .equ BUF_POOL shell_buf ; in contended memory
  64. .equ BUF_MAXLINES 0x100
  65. .equ BUF_LINES BUF_RAMSTART+4
  66. .equ BUF_RAMEND @+BUF_MAXLINES*4 ; continue allocating in higher RAM
  67. .inc "basic/buf.asm"
  68. .equ BFS_RAMSTART BUF_RAMEND
  69. .inc "basic/fs.asm"
  70. .inc "basic/blk.asm"
  71. .equ BAS_RAMSTART BFS_RAMEND
  72. .inc "basic/main.asm"
  73. ; BASIC records the SP value, which is glue init value-2; the address of this storage +6 is BAS_RAMEND
  74. ; this is the value to be learned from a memory dump for user.h!
  75. .equ tap_buffer BAS_RAMEND
  76. .equ buf_pos @+256
  77. .equ tap_pos @+1
  78. .equ TAP_RAMEND @+8 ; user.h for assembling zxs/tapeutil.bin, BAS_RAMEND+265
  79. .inc "kernel/zxs/tapeblk.asm"
  80. ;.equ USER_CODE BAS_RAMEND+527 ; 265 tapeblk + 262 tapeutil.bin below
  81. .equ ZBCOUNT USER_CODE+14
  82. tpztell:
  83. ; fetches the zasm internal counter (IO_OUT_BLK) at ZASM_RAMSTART+14
  84. ; it's called through 'addr ztell: s=a: usr s: print h'
  85. ld hl, (ZBCOUNT)
  86. xor a
  87. ret
  88. basFindCmdExtra:
  89. ld hl, basBLKCmds
  90. call basFindCmd
  91. ret z
  92. ld hl, basFSCmds
  93. call basFindCmd
  94. ret z
  95. ld hl, .mycmds
  96. call basFindCmd
  97. ret z
  98. jp basPgmHook
  99. .mycmds:
  100. .db "binsv", 0
  101. .dw tapeutil
  102. .db "binld", 0
  103. .dw tapeutil+3
  104. .db "head", 0
  105. .dw tapeutil+6
  106. .db "filsv", 0
  107. .dw tapeutil+9
  108. .db "filld", 0
  109. .dw tapeutil+12
  110. .db "cfssv", 0
  111. .dw tapeutil+15
  112. .db "cfsld", 0
  113. .dw tapeutil+18
  114. .db "cutsv", 0
  115. .dw tapeutil+21
  116. .db "ztell", 0
  117. .dw tpztell
  118. .db "ed", 0
  119. .dw edrun
  120. .db "zasm", 0
  121. .dw zasmrun
  122. .db 0xff
  123. init:
  124. di
  125. ld sp, 0x8000
  126. ; if precise timings are needed,
  127. ; the stack should be moved to non-contended memory
  128. call int_init
  129. call v_init
  130. call tapeblk_init
  131. ; init a FS in mmap
  132. ; possibly not needed in the final build
  133. ld hl, MMAP_START
  134. ld a, 'C'
  135. ld (hl), a
  136. inc hl
  137. ld a, 'F'
  138. ld (hl), a
  139. inc hl
  140. ld a, 'S'
  141. ld (hl), a
  142. call gridInit
  143. call fsInit
  144. xor a
  145. ld de, BLOCKDEV_SEL
  146. call blkSel
  147. call fsOn
  148. call basInit
  149. ld hl, basFindCmdExtra
  150. ld (BAS_FINDHOOK), hl
  151. ei
  152. jp basStart
  153. ; *** blkdev 1: file handle 0 ***
  154. blk1GetB:
  155. ld ix, FS_HANDLES
  156. jp fsGetB
  157. blk1PutB:
  158. ld ix, FS_HANDLES
  159. jp fsPutB
  160. ; *** blkdev 2: file handle 1 ***
  161. blk2GetB:
  162. ld ix, FS_HANDLES+FS_HANDLE_SIZE
  163. jp fsGetB
  164. blk2PutB:
  165. ld ix, FS_HANDLES+FS_HANDLE_SIZE
  166. jp fsPutB
  167. int_init:
  168. di
  169. ld a,0x80
  170. ld i,a
  171. im 2
  172. ret ; does not enable interrupts yet
  173. tapeutil:
  174. .bin "zxs/tapeutil.bin"
  175. ; all tape utilities in one block with library
  176. ; t_load ROM call routine is duplicated in zxs/tapeblk.asm in case those utilities are moved to userspace
  177. ; 0x7492 is free space, +2K=7c92, the rest 0x36e=878b for stack space
  178. shell_buf:
  179. ; basic shell BUF_POOL points here
  180. .fill 0x8000-$
  181. ; The ZX Spectrum hardware noises the CPU data bus so that any value can appear on interrupt instead of 0xFF.
  182. ; A 257-byte table is thus required to hold the INT handler address for IM2 mode.
  183. ; interrupt table = 128 words + 1 byte
  184. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  185. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  186. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  187. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  188. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  189. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  190. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  191. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  192. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  193. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  194. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  195. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  196. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  197. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  198. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  199. .dw 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181, 0x8181
  200. .db 0x81
  201. ; the handler and the table are to reside in the non-contended memory, i.e. in 0x8000-0xC000
  202. ; (or rather in 0x8080-0xBFBF)
  203. .fill 0x8181-$
  204. ; *** interrupt handler
  205. ; other possible int routines here, e.g. RS232 or debug calls
  206. push iy
  207. ld iy, IYBAS
  208. rst 56
  209. pop iy
  210. ei
  211. ret
  212. ;0x818c
  213. edrun:
  214. .bin "zxs/ed.bin" ;1108 = 0x0454
  215. ;0x85e0 = 0x818c+0x454
  216. zasmrun:
  217. .bin "zxs/zasm.bin" ;4881 = 0x1311
  218. RAMSTART: ; 0x98f1 = 0x85e0+0x1311 (39153)
  219. ; bin length (14836)