kthacker | 6de6775 | 2006-04-17 15:02:26 +0000 | [diff] [blame^] | 1 | ;; This example shows how to perform a directory of a disc |
| 2 | ;; and extract the filenames. |
| 3 | ;; |
| 4 | ;; This code is public domain and can freely be used in your |
| 5 | ;; own programs. |
| 6 | ;; |
| 7 | ;; Written by Kevin Thacker. 2002 |
| 8 | |
| 9 | |
| 10 | |
| 11 | ;;------------------------------------------------------------------ |
| 12 | |
| 13 | ;; firmware function to catalog a disc or cassette |
| 14 | cas_catalog == 0xbc9b |
| 15 | ;; firmware function to disable text output |
| 16 | txt_vdu_enable == 0xbb54 |
| 17 | ;; firmware function to enable text output |
| 18 | txt_vdu_disable == 0xbb57 |
| 19 | ;; firmware function to find a RSX |
| 20 | kl_find_command == 0xbcd4 |
| 21 | |
| 22 | .globl __readdir |
| 23 | .area _CODE |
| 24 | |
| 25 | ;;------------------------------------------------------------------ |
| 26 | ;; find BIOS SET MESSAGE command |
| 27 | ;; this is used to disable disc messages. |
| 28 | ;; this is compatible with other DOSs that also provide this command |
| 29 | __readdir:: |
| 30 | |
| 31 | ld hl,#cmd_bios_set_message |
| 32 | call kl_find_command |
| 33 | ret nc |
| 34 | |
| 35 | ;; command found |
| 36 | |
| 37 | ;; store address of command |
| 38 | ld (bios_set_message),hl |
| 39 | ld a,c |
| 40 | ;; store "rom select" of command |
| 41 | ld (bios_set_message+2),a |
| 42 | |
| 43 | ;;------------------------------------------------------------------ |
| 44 | |
| 45 | ;; do CAT |
| 46 | ld hl,#2 |
| 47 | add hl,sp |
| 48 | ld e,(hl) |
| 49 | inc hl |
| 50 | ld d,(hl) |
| 51 | call fetch_directory |
| 52 | ret |
| 53 | |
| 54 | |
| 55 | ;;------------------------------------------------------------------ |
| 56 | ;; display files from data generated by CAS CATALOG function |
| 57 | |
| 58 | ;; perform a CAT command |
| 59 | |
| 60 | fetch_directory:: |
| 61 | push de |
| 62 | ;; disable disc messages. Error messages will not be displayed. |
| 63 | ld a,#0xff |
| 64 | rst 0x018 ;; KL FAR CALL |
| 65 | .dw bios_set_message |
| 66 | |
| 67 | ;; disable text output |
| 68 | call txt_vdu_disable |
| 69 | |
| 70 | pop de |
| 71 | |
| 72 | ;; initialise in case of an error |
| 73 | xor a |
| 74 | ld (de),a |
| 75 | |
| 76 | ;; do catalog |
| 77 | call cas_catalog |
| 78 | |
| 79 | ;; enable text output |
| 80 | call txt_vdu_enable |
| 81 | |
| 82 | ;; enable disc messages. Error messages will be displayed |
| 83 | ld a,#0x0 |
| 84 | rst 0x018 ;; KL FAR CALL |
| 85 | .dw bios_set_message |
| 86 | ret |
| 87 | |
| 88 | |
| 89 | ;;------------------------------------------------------------------ |
| 90 | |
| 91 | ;; this is initialised when the "BIOS SET MESSAGE" RSX has been found. |
| 92 | bios_set_message: |
| 93 | .dw 0 ;; address of function |
| 94 | .db 0 ;; "rom select" for function |
| 95 | |
| 96 | |
| 97 | cmd_bios_set_message: |
| 98 | .db #0x01+#0x80 ;; this is the "BIOS SET MESSAGE" RSX |
| 99 | |