monroeoc8800diag.asm 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. ; code: language=z80-asm tabSize=8
  2. ; SIMULATE_ERROR = $80
  3. ; SIMULATE_ERROR = $3C
  4. .include "inc/z80.mac"
  5. .include "inc/spt.mac"
  6. ; Notes on global register allocation:
  7. ;
  8. ; This ROM doesn't work like typical Z80 code, which assumes the presence of a stack.
  9. ; There may in fact be no working memory in the machine for holding the stack.
  10. ;
  11. ; An overall goal for this version of the code is to run in the absence of any working
  12. ; ram at all. There is no stack and no RAM variables. The only storage of variables
  13. ; is in registers, so the registers must be carefully preserved.
  14. ;
  15. ; Without a stack, that means either saving them to other registers and restoring before
  16. ; jumping to other code (remembering there can be no CALLs when there is no stack)
  17. ; or avoiding their use altogether. These are extremely confining restrictions.
  18. ;
  19. ; Assembly purists will shudder at the extensive use of macros, but for sanity it
  20. ; cannot be avoided.
  21. ;
  22. ; Globally, the contents of these registers must be preserved
  23. ; e = bit errors in the region of memory currently being tested
  24. ; ix = current location in VRAM for printing messages
  25. ; iy = current table entry for test parameters
  26. ;
  27. VBASE equ 03000h
  28. VSIZE equ 0ffeh
  29. VLINE equ 80
  30. .org 0000h ; z80 boot code starts at location 0
  31. reset:
  32. di ; mask INT
  33. im 1
  34. diagnostics:
  35. xor a
  36. out (0c0h),a ;0046 clear io, floppy control
  37. out (0c4h),a ;0048 clear io,Program map A base
  38. out (0c5h),a ;004a clear io,Program map B base
  39. out (0c6h),a ;004c clear io,DMA map A base
  40. out (0c7h),a ;004e clear io,DMA map B base
  41. out (0d4h),a ;0050 clear io,Hi-res color
  42. out (0d8h),a ;0052 clear io,Hi-res start
  43. ld hl,set_regs_start
  44. jp set_monroe_regs
  45. init_continue:
  46. jp setupclearscreen
  47. screen_clear_continue:
  48. ld a,080h ;0092
  49. out (0d4h),a
  50. ;
  51. ld a,005h ;00a8
  52. out (0a3h),a ;00aa DART B command
  53. ld a,068h ;00ac
  54. out (0a3h),a ;00ae DART B command
  55. ld a,0f0h ;00b0 ?????
  56. out (0c8h),a ;00b2 Map and system control
  57. ;select screen memory
  58. ld a,004h ;0541 Select display memory
  59. out (0c8h),a ;0543 Output to screen Map and system control
  60. ;
  61. ;ld a,0a0h
  62. ;out (0c5h),a ;00b2 Map and system control
  63. test_vram:
  64. SPTHREAD_BEGIN ; set up to begin running threaded code
  65. SPT_SKIP_NMIVEC
  66. ;dw spt_playmusic, tones_welcome
  67. dw spt_select_test, tp_vram
  68. dw memtestmarch ; test the VRAM
  69. dw spt_check_7bit_vram
  70. ; dw spt_sim_error, $40
  71. dw spt_jp_nc, .vram_ok
  72. ; we have bad vram
  73. dw spt_prepare_display
  74. dw spt_chartest
  75. .vram_bad_loop:
  76. ;dw spt_play_testresult ; play the tones for bit errorssetupcrt
  77. ;dw spt_pause, $0000
  78. dw spt_jp,.vram_bad_loop
  79. .vram_7bit:
  80. dw spt_con_print, msg_ok7bit
  81. ; dw spt_play_testresult ; play the tones for bit errors
  82. ;dw spt_jp,.vram_goodtones
  83. .vram_ok:
  84. dw spt_prepare_display
  85. MAC_SPT_CON_GOTO 2,0
  86. dw spt_announcetest2 ; print results of VRAM tst
  87. ; dw print_biterrs
  88. dw spt_jp_e_7bit_vram, .vram_7bit
  89. dw spt_con_print, msg_ok8bit
  90. .vram_goodtones:
  91. ;dw spt_playmusic, tones_vramgood ; play the VRAM good tones
  92. .vram_continue:
  93. MAC_SPT_CON_GOTO 3,0
  94. dw spt_select_test, tp_16k ; load the first test
  95. dw spt_jp, .start
  96. .start dw spt_con_goto
  97. MAC_SPT_CON_OFFSET 3,0
  98. .loop: dw spt_announcetest ; announce what test we are about to run
  99. dw memtestmarch2 ; test the current bank
  100. dw spt_jp_nc, .ok
  101. dw spt_con_print, msg_biterrs ; we have errors: print the bit string
  102. dw print_biterrs
  103. ;dw spt_play_testresult ; play the tones for bit errors
  104. dw spt_jp, .cont
  105. .ok: dw spt_con_print, msg_testok ; bank is good: print the OK message
  106. ;dw spt_play_testresult ; play the tones
  107. .cont:
  108. dw spt_tp_next, .start
  109. dw spt_jp, .loop
  110. ;; -------------------------------------------------------------------------------------------------
  111. ;; end of main program.
  112. spt_prepare_display:
  113. SPTHREAD_ENTER
  114. dw con_clear
  115. dw spt_con_print, msg_banner ; print the banner
  116. dw spt_print_charset
  117. dw spt_exit
  118. spt_check_vram_contents:
  119. pop bc
  120. ld a,b
  121. ld d,c
  122. ; confirm that all of VRAM contains the value in register A
  123. check_vram_contents:
  124. ld hl,VBASE
  125. ld bc,VSIZE
  126. .fillloop:
  127. ld (HL),a
  128. cpi
  129. jp pe,.fillloop
  130. ld hl,VBASE
  131. ld bc,VSIZE
  132. ld a,d
  133. .readloop:
  134. cpi
  135. jr nz,.bad
  136. jp pe,.readloop
  137. or a ; clear carry flag
  138. ret
  139. .bad: scf
  140. ret
  141. spt_check_7bit_vram:
  142. ret nc ; if carry flag is not set, do nothing
  143. ld a,01000000b
  144. cp e
  145. jr z,.scantests
  146. scf ; something other than bit 6 is bad, so this is not 7bit VRAM
  147. ret
  148. .scantests:
  149. SPTHREAD_ENTER
  150. dw spt_check_vram_contents, $0040
  151. dw spt_jp_c, .exit
  152. dw spt_check_vram_contents, $FFBF
  153. dw spt_jp_c, .exit
  154. dw spt_check_vram_contents, $AAAA
  155. dw spt_jp_c, .exit
  156. dw spt_check_vram_contents, $5555
  157. dw spt_jp_c, .exit
  158. .exit: dw spt_exit ; if carry flag is set, this is not good 7-bit VRAM
  159. spt_sim_error:
  160. pop de
  161. scf
  162. ret
  163. ; test if the error is $FF (all bits bad)
  164. spt_jp_all_bits_bad:
  165. pop hl ; get the address for jumping if match
  166. ld a,$FF ; check for all bits bad
  167. cp e
  168. ret nz ; return without jump if there is NOT a match
  169. ld sp,hl ; else jump to the requested location
  170. ret
  171. ; test if the e register matches 7-bit vram and jump to spt address if match
  172. spt_jp_e_7bit_vram:
  173. pop hl ; get the address for jumping if match
  174. ld a,01000000b ; ignore bit 6
  175. cp e ; see if there are other errors
  176. ret nz ; return without jump if there is NOT a match
  177. ld sp,hl ; else jump to the requested location
  178. ret
  179. ; test if the e register matches 7-bit vram and jump to spt address if match
  180. spt_jp_e_zero:
  181. pop hl ; get the address for jumping if match
  182. ld a,0 ; test clean
  183. cp e ; see if there are other errors
  184. ret nz ; return without jump if there is NOT a match
  185. ld sp,hl ; else jump to the requested location
  186. ret
  187. ; load the label string address from the current test parameter table entry into hl
  188. spt_ld_hl_tp_label:
  189. ld l,(iy+4)
  190. ld h,(iy+5)
  191. ret
  192. ; load the label string address from the current test parameter table entry into hl
  193. spt_ld_hl_tp_tones:
  194. ld l,(iy+6)
  195. ld h,(iy+7)
  196. ret
  197. spt_ld_new_line:
  198. ld a,(iy+9)
  199. ld ixh,a
  200. ld a,(iy+8)
  201. ld ixl,a
  202. ret
  203. ; move to the next test parameter table entry
  204. spt_tp_next: pop hl ; get the address to jump to if we are starting over
  205. ld bc,tp_size ; find the next entry
  206. add iy,bc
  207. ld a,(iy+0) ; is the length zero?
  208. add a,(iy+1)
  209. ret nz ; no, use it
  210. ld c,(iy+2) ; yes, get the address of the first entry
  211. ld b,(iy+3)
  212. ld iy,0
  213. add iy,bc
  214. ; sub a ; clear zero flag when restarting
  215. ld sp,hl ; jump to the next location
  216. ret
  217. spt_announcetest:
  218. ; pop hl ; get the message to be printed
  219. SPTHREAD_ENTER
  220. dw spt_ld_new_line
  221. ;dw con_NL
  222. dw spt_ld_hl_tp_label
  223. dw con_print ; picks up message from hl
  224. dw spt_con_print, msg_testing
  225. dw spt_con_index, -18
  226. dw spt_exit
  227. spt_announcetest2:
  228. ; pop hl ; get the message to be printed
  229. SPTHREAD_ENTER
  230. dw spt_ld_hl_tp_label
  231. dw con_print ; picks up message from hl
  232. dw spt_con_print, msg_testing
  233. dw spt_con_index, -18
  234. dw spt_exit
  235. spt_play_testresult:
  236. SPTHREAD_SAVE ; save the stack pointer
  237. SPTHREAD_BEGIN
  238. dw spt_ld_hl_tp_tones ; play the ID tune for current bank
  239. ;dw playmusic
  240. dw spt_pause, $2000
  241. SPTHREAD_END
  242. ld a,$FF
  243. cp e
  244. jr z,.allbad ; if all bits bad, play shorter tune
  245. cpl
  246. cp e
  247. jr z,.allgood ; if all bits good, play shorter tune
  248. ld d,8 ; play bit tune for each bit, high to low
  249. .showbit:
  250. rlc e
  251. jr nc,.zero
  252. ld hl,tones_bitbad
  253. jr .msbe_cont
  254. .zero:
  255. ld hl,tones_bitgood
  256. .msbe_cont:
  257. SPTHREAD_BEGIN
  258. ;dw playmusic
  259. dw spt_pause, $2000
  260. SPTHREAD_END
  261. ; pause $4000
  262. dec d
  263. jr nz,.showbit
  264. jr .done
  265. .allbad:
  266. SPTHREAD_BEGIN
  267. ;dw spt_playmusic, tones_bytebad
  268. dw spt_pause, $8000
  269. SPTHREAD_END
  270. jr .done
  271. .allgood:
  272. SPTHREAD_BEGIN
  273. ;dw spt_playmusic, tones_bytegood
  274. dw spt_pause, $8000
  275. SPTHREAD_END
  276. .done:
  277. SPTHREAD_RESTORE ; restore the stack pointer
  278. ret
  279. spt_pause:
  280. pop bc
  281. ; pause by an amount specified in BC
  282. pause_bc:
  283. .loop:
  284. dec bc
  285. ld a,b
  286. or c
  287. jr nz,.loop
  288. ret
  289. print_biterrs:
  290. ld a,004h ; Select display memory
  291. out (0c8h),a ; Output to screen Map and system control
  292. ld a,'7'
  293. ld b,8
  294. .showbit:
  295. rlc e
  296. jr nc,.zero
  297. ld (ix+1),a
  298. jr .cont
  299. .zero:
  300. ld (ix+1),'.'
  301. .cont:
  302. inc ix
  303. inc ix
  304. dec a
  305. djnz .showbit
  306. xor a ;054b Reset map
  307. out (0c8h),a ;054c Reset to memory Map and system control
  308. ret
  309. spt_ld_bc: pop bc
  310. ret
  311. spt_print_charset:
  312. ld a,ixh
  313. ld h,a
  314. ld a,ixl
  315. ld l,a
  316. ld a,0
  317. SPTHREAD_ENTER
  318. MAC_SPT_CON_GOTO 15,24
  319. dw spt_con_print, msg_charset ; show a copy of the character set
  320. MAC_SPT_CON_GOTO 16,0
  321. dw spt_ld_bc, $100
  322. dw do_charset_ix
  323. dw spt_exit
  324. spt_chartest:
  325. ld ix,VBASE
  326. ld bc,VSIZE
  327. do_charset_ix:
  328. ld a,004h ; Select display memory
  329. out (0c8h),a ; Output to screen Map and system control
  330. ld a,32
  331. .charloop:
  332. ld (ix+1),a ; copy A to byte pointed by HL
  333. inc a ; increments A
  334. inc ix
  335. inc ix
  336. cpi ; increments HL, decrements BC (and does a CP)
  337. jp pe, .charloop
  338. xor a ;054b Reset map
  339. out (0c8h),a ;054c Reset to memory Map and system control
  340. ret
  341. screenclearloop:
  342. otir ;0560 out B bytes from (HL) to (C)
  343. set_monroe_regs:
  344. ld c,(hl) ; get register
  345. inc hl ; bump
  346. ld b,(hl) ;get count
  347. inc hl ; bump
  348. ld a,b ;
  349. and a ;
  350. jr nz,screenclearloop ;0568 if count not 0 loop $-8
  351. jp init_continue
  352. setupclearscreen:
  353. ;entry during initiation w
  354. xor a ; start A=0
  355. ld bc,00eb9h ; C=B9 B=14
  356. ld hl,set_up_crt ;
  357. setupclearloop:
  358. out (0b8h),a ;CRT register select
  359. inc a ; A++
  360. outi ; C)=(HL++) and B--
  361. jr nz,setupclearloop ; loop until B==0 (14 bytes to write) $-5
  362. jp screen_clear_continue
  363. label_vram: dbz " 4K VRAM 3000-3FFE "
  364. label_dram16k1: dbz "16K DRAM 0 C000-FFFF "
  365. label_dram16k2: dbz "16K DRAM 1 C000-FFFF "
  366. label_dram16k3: dbz "16K DRAM 2 C000-FFFF "
  367. label_dram16k4: dbz "16K DRAM 3 C000-FFFF "
  368. label_dram16k5: dbz "16K DRAM 4 C000-FFFF "
  369. label_dram16k6: dbz "16K DRAM 5 C000-FFFF "
  370. label_dram16k7: dbz "16K DRAM 6 C000-FFFF "
  371. label_dram16k8: dbz "16K DRAM 7 C000-FFFF "
  372. msg_banner: dbz "Monroe OC8820 TEST ROM -- FRANK IZ8DWF / DAVE KI3V / ADRIAN BLACK"
  373. msg_charset: dbz "-CHARACTER SET-"
  374. ; msg_testing: db " ", " "+$80, "t"+$80, "e"+$80, "s"+$80, "t"+$80, " "+$80, " ", 0
  375. msg_testing: dbz "..TEST.. "
  376. msg_testok: dbz "---OK--- "
  377. msg_biterrs: dbz "BIT ERRS "
  378. msg_ok7bit: dbz "OK! (7-BIT MODEL 1)"
  379. msg_ok8bit: dbz "OK! (8-BIT)"
  380. ; test parameter table. 2-byte entries:
  381. ; 1. size of test in bytes
  382. ; 2. starting address
  383. ; 3. address of string for announcing test
  384. ; 4. address of tones for identifying the test audibly
  385. tp_size equ 10
  386. memtest_ld_bc_size .macro
  387. ld c,(iy+0)
  388. ld b,(iy+1)
  389. .endm
  390. memtest_ld_hl_base .macro
  391. ld l,(iy+2)
  392. ld h,(iy+3)
  393. .endm
  394. memtest_loadregs .macro
  395. memtest_ld_bc_size
  396. memtest_ld_hl_base
  397. .endm
  398. spt_ld_iya6 .macro
  399. ld a,(iy+6)
  400. .endm
  401. spt_ld_iya7 .macro
  402. ld a,(iy+7)
  403. .endm
  404. tp_vram: dw VSIZE, VBASE, label_vram, tones_vram
  405. tp_16k: dw $4000, $C000, label_dram16k1, $a100,$31e0
  406. dw $4000, $C000, label_dram16k2, $c100,$3280
  407. dw $4000, $C000, label_dram16k3, $e100,$3320
  408. dw $4000, $C000, label_dram16k4, $0000,$33c0
  409. dw $4000, $C000, label_dram16k5, $2000,$3460
  410. dw $4000, $C000, label_dram16k6, $4020,$3500
  411. dw $4000, $C000, label_dram16k7, $6020,$35a0
  412. dw $4000, $C000, label_dram16k8, $8020,$3640
  413. dw $0000, tp_16k
  414. set_regs_start:
  415. defb 0b5h ;005a io port CRT register select
  416. defb 004h ;005b count 4
  417. defb 0cfh ;005c
  418. defb 0b8h ;005d
  419. defb 037h ;005e
  420. defb 0efh ;005f
  421. ;
  422. defb 0b4h ;0060 io port PIO A data
  423. defb 001h ;0061 count 1
  424. defb 001h ;0062
  425. ;
  426. defb 0a1h ;0063 io port DART A command
  427. defb 006h ;0064 count 6
  428. defb 048h ;0065
  429. defb 048h ;0066
  430. defb 004h ;0067
  431. defb 044h ;0068
  432. defb 005h ;0069
  433. defb 0eah ;006a
  434. ;
  435. defb 0a3h ;006b io port DART B command
  436. defb 008h ;006c count 8
  437. defb 048h ;006d
  438. defb 048h ;006e
  439. defb 004h ;006f
  440. defb 044h ;0070
  441. defb 001h ;0071
  442. defb 000h ;0072
  443. defb 003h ;0073
  444. defb 0c1h ;0074
  445. ;
  446. defb 0a5h ;0075 io port SIO A command
  447. defb 002h ;0076 count 2
  448. defb 048h ;0077
  449. defb 048h ;0078
  450. ;
  451. defb 0a7h ;0079 io port SIO B command
  452. defb 002h ;007a count 2
  453. defb 048h ;007b
  454. defb 048h ;007c
  455. ;
  456. defb 0a8h ;007d io port CTC CHANNEL 0 - Communications baud rate
  457. defb 002h ;007e count 2
  458. defb 003h ;007f
  459. defb 003h ;0080
  460. ;
  461. defb 0a9h ;0081 io port CTC CHANNEL 1 - AUX RS-232C baud rate
  462. defb 002h ;0082 count 2
  463. defb 003h ;0083
  464. defb 003h ;0084
  465. ;
  466. defb 0aah ;0085 io port CTC CHANNEL 2 - Printer baud rate
  467. defb 002h ;0086 count 2
  468. defb 057h ;0087
  469. defb 04eh ;0088
  470. ;
  471. defb 000h ;0089 io port reset
  472. defb 000h ;008a count 0 terminator
  473. set_up_crt:
  474. ;data to be output to io port B9 14 byte CRT data register
  475. defb 069h ;054f
  476. defb 050h ;0550
  477. defb 056h ;0551
  478. defb 00bh ;0552
  479. defb 019h ;0553
  480. defb 003h ;0554
  481. defb 018h ;0555
  482. defb 018h ;0556
  483. defb 000h ;0557
  484. defb 00bh ;0558
  485. defb 020h ;0559
  486. defb 000h ;055a
  487. defb 000h ;055b
  488. defb 000h ;055c
  489. include "inc/spt.asm"
  490. include "inc/memtestmarch.asm"
  491. include "inc/monroecon.asm"
  492. include "inc/trs80music.asm"