If you looks in huc libraries, you should see that cd_loadvram function is very small.
this function use a cd bios routine called cd_load, once, no loop ..
This routine can transfert datas in cd ram, in vram or in mprs ..
A person has found a routine who's using cd ram as buffer and divide by 4 load time.
/* FastVRamCDLoad by Orion_ [06/2009]
Read CD Data by Chunk of 24k in SCD RAM, then Transfer in VRAM
FastVRamCDLoad(Overlay Index, Sector Base, VRAM Address, Size);
(use same parameters as cd_loadvram function) */
int FVCLtmpadrs;
int FVCLtmpsize;
int FVCLtmpsect;
#pragma fastcall FastVRamCDLoad(byte al, word bx, word dx, word cx);
FastVRamCDLoad()
{
#asm
_FastVRamCDLoad.4:
; _al = Overlay index
; _bx = Sector
; _cx = Size
; _dx = VRAM Address
; Save MPRs
tma #2
pha
tma #3
pha
tma #4
pha
; Save Parameters
stw _bx,_FVCLtmpsect
stw _dx,_FVCLtmpadrs
stw _cx,_FVCLtmpsize
.loop:
lda _al
pha
; If Size > 24k, then read first 24k
cmpw #24*1024,_cx
blo .ok
stw #24*1024,_cx
.ok:
; Save Size
lda _cx
pha
lda _cx+1
pha
; Modify TIA with VRAM Address
lda _dx
sta .TIASMCL+1
lda _dx+1
sta .TIASMCH+1
stw _cx,.TIASMC+5 ; and Size
; Get Overlay Sector from Index in _ax
lda <_al
asl a
asl a
tay
map ovlarray
ldx ovlarray,Y
iny
lda ovlarray,Y
stx <_al
sta <_ah
; Map 24k of SCD Ram to $4000-$A000
; Free SCD Ram from $DA000 ($6D)
lda #$6D
tam #2
inc a
tam #3
inc a
tam #4
; Add our Sector Offset
addw _bx,_ax
; Store Sector Offset Part 1
lda <_al
sta <_dl
; Compute N Sector to load from Size
addw #2047,_cx ; Round up Size to 2048
lda <_ch
lsr a
lsr a ; = Size / 2048
lsr a
sta <_al
; Store Sector Offset Part 2
lda <_ah
sta <_ch
stz <_cl
; Local Ram Load
lda #1
sta <_dh
; Ram Address
stw #$4000,_bx
; Go Read !
jsr cd_read
; VRAM Transfer
st0 #0
.TIASMCL:
st1 #LOW(0)
.TIASMCH:
st2 #HIGH(0)
st0 #2
.TIASMC:
tia $4000, 2, 0
; Restore Parameters
pla
sta _cx+1
pla
sta _cx
pla
sta _al
; Add 12 Sectors (24k) to Sector Base
addw #12,_FVCLtmpsect
stw _FVCLtmpsect,_bx
; Substract Readed Size from Size
subw _cx,_FVCLtmpsize
beq .end
; If not 0, then read again
lsrw _cx ; Size / 2, because VRAM is word !
addw _cx,_FVCLtmpadrs ; Increment VRAM Address from Readed Size
stw _FVCLtmpadrs,_dx
stw _FVCLtmpsize,_cx ; Remaining Size to Read
jmp .loop
.end:
; Restore MPRs
pla
tam #4
pla
tam #3
pla
tam #2
#endasm
}
The problem is that routine need 24 Kb of cd-ram to works .