blob: 71edec1b8c1bfe950be989bc1627dd88817c0222 [file] [log] [blame]
;; This example shows how to perform a directory of a disc
;; and extract the filenames.
;;
;; This code is public domain and can freely be used in your
;; own programs.
;;
;; Written by Kevin Thacker. 2002
;;------------------------------------------------------------------
;; firmware function to catalog a disc or cassette
cas_catalog == 0xbc9b
;; firmware function to disable text output
txt_vdu_enable == 0xbb54
;; firmware function to enable text output
txt_vdu_disable == 0xbb57
;; firmware function to find a RSX
kl_find_command == 0xbcd4
.globl __readdir
.area _CODE
;; void _readdir(void*)
;; Input: pointer to buffer in HL
__readdir::
; The AMSDOS call corrupts IX, which must be saved for SDCC code to work
PUSH IX
; The parameter is passed in HL but we need it in DE
EX DE,HL
;; disable disc messages. Error messages will not be displayed.
ld a,#0xff
rst 0x018 ;; KL FAR CALL
.dw bios_set_message
;; disable text output
call txt_vdu_disable
; Make sure to return an empty buffer if getting the catalog fails
xor a
ld (DE),a
;; do catalog
call cas_catalog
;; enable text output
call txt_vdu_enable
;; enable disc messages. Error messages will be displayed
xor a
rst 0x018 ;; KL FAR CALL
.dw bios_set_message
POP IX
ret
;;------------------------------------------------------------------
;; this is initialised when the "BIOS SET MESSAGE" RSX has been found.
bios_set_message:
.dw 0xc033 ;; address of function
.db 7 ;; "rom select" for function