;license:MIT ;(c) 2018-2020 by 4am & qkumba ; ; ProRWTS2 glue functions ; ; /!\ These live in LC RAM 2 and rely on the ProRWTS code which is also in LC RAM 2. /!\ ; Code in LC RAM 1 (which is most program code) should call the functions in glue.prorwts2 ; and parse.prefs which handle bank switching for you. LoadFileInternal ldx #0 ; 0 = read into main memory LoadFileAuxInternal +LDADDR gPathname LoadFileDirect +ST16 namlo ; set filename txa pha jsr traverse ; go to subdirectory, set up filename for read lda #cmdread ; read (instead of write) sta reqcmd lsr sta auxreq lda ldrhi bne + ; if caller provided a load address, use it sta sizelo ; otherwise query the load address from file metadata sta sizehi ; 0 = query load address jsr hddopendir ; call ProRWTS2 +LD16 ldrlo2 +ST16 ldrlo + lda #$FF ; read entire file (ProRWTS2 will figure out exact size) LoadFileInternal_SizePatch sta sizehi pla sta auxreq JumpOpen jmp hddopendir ; exit via ProRWTS2 LoadDHRFileInternal +LDADDR gPathname +ST16 namlo ; set filename jsr traverse ; go to subdirectory, set up filename for read lda #$20 sta sizehi asl sta ldrhi ; into $4000 lda #cmdread ; read (instead of write) sta reqcmd ;;lda #1 ; 1 = read into aux memory sta auxreq lsr ; read first $2000 bytes sta sizelo sta ldrlo jsr hddopendir ; call ProRWTS2 lda #$20 ; read next $2000 bytes sta sizehi dec auxreq ; 0 = read into main memory clc ; not a subdirectory jmp hddrdwrpart ; call ProRWTS2 SaveSmallFileInternal +LDADDR gPathname +ST16 namlo ; set filename for ProRWTS2 jsr traverse ; go to subdirectory, set up filename for read ;lda #cmdread ; read (instead of write) ;sta reqcmd lda #0 ; 0 = read into main memory sta sizelo ;sta sizehi ; 0 = query load address ;jsr hddopendir ; call ProRWTS2 ;lda ldrlo2 sta ldrlo lda #>kGlobalPrefsBuffer ;lda ldrhi2 sta ldrhi lda #cmdwrite ; write (instead of read) sta reqcmd sta sizehi ; 512 bytes bne JumpOpen ; exit via ProRWTS2 (must re-open the file after query)