

; play sound de on channel c
PlaySFXFromRAM:

    	;call InitSFXVariables

    ld h, 00
    ld l, c
    ld bc, $C00E
    add hl, hl
    add hl, bc
    ld [hl], e
    inc hl
    ld [hl], d

    ;xor a
    ;ld bc, $0004
    ;ld hl, $C01E
    ;call FillMemory
    ;ld a, $01
    ;ld bc, $0004
    ;ld hl, $C0BE
    ;call FillMemory
    ;ld a, $e0
    ;ld bc, $0004
    ;ld hl, $C02E
    ;jp FillMemory

        ;xor a
	;ld [wChannelSoundIDs + Ch5], a
	;ld [wChannelSoundIDs + Ch6], a
	;ld [wChannelSoundIDs + Ch7], a
	;ld [wChannelSoundIDs + Ch8], a

    ret

TextboxEnable:
    ;call SaveScreenTilesToBuffer1
    ;call SaveScreenTilesToBuffer2
    ;call LoadFontTilePatterns
TextboxEnable_NoLoadFont:
    ;ld b, $9c
    ;ld hl, CopyScreenTileBufferToVRAM
    ;call SafeCallHL
    ;ld c, 3
    ;call DelayFrames
    	;xor a
    ;ld a, $5A
    ;ldh [$b0], a
    	;inc a
    ;ldh [$ba], a
    ret

PlayMusicFromRAM:
    ld bc, $0008
    ld de, $C006
    call CopyData
    xor a
    ld bc, $0004
    ld hl, $C016
    call FillMemory
    ld a, $01
    ld bc, $0004
    ld hl, $C0B6
    call FillMemory
    ld a, $e0
    ld bc, $0004
    ld hl, $C026
    jp FillMemory
    
BlackOutPals:
    ld a, %11111111
WriteAToPals:
	ld [rBGP], a
    ld [rOBP0], a
    ld [rOBP1], a
    ret


;PlayInventoryMusic:
    ;ld de, $c9e0
    ;ld bc, 512
    ;ld hl, Music_InventoryScreen
    ;ld a, 3
    ;call CopyDataFromSRAX
    ;ld de, $c9d0
    ;ld bc, 8
    ;ld hl, Music_InventoryScreen_Pointers
    ;ld a, 3
    ;call CopyDataFromSRAX
    ;ld hl, $c9d0
    ;jr PlayMusicFromRAM

PlaySongFromHL:
    ld de, $c9d0
    ld bc, 8
    push hl
    ld a, 3
    call CopyDataFromSRAX
    ld de, $c9e0
    pop hl
    ld bc, 8
    add hl, bc
    ld bc, 512
    ld a, 3
    call CopyDataFromSRAX
    ld hl, $c9d0
    jr PlayMusicFromRAM


CompareBCToDE:
    ld a, b
    cp d
    jr nz, .nope
    ld a, c
    cp e
.nope
    ret

PlaceStringSimple:
    push bc
    push hl
    ld bc, 20
.nextChar
    ld a, [de]
    inc de
    cp $50
    jr z, .finished
    cp $4f
    jr z, .nextLine
    ld [hli], a
    jr .nextChar
.nextLine
    pop hl
    add hl, bc
    push hl
    jr .nextChar
.finished
    pop hl
    pop bc
    ret

SaveScreenTilesToBuffer2_SaveAll:
    push af
    push bc
    push de
    push hl
    call SaveScreenTilesToBuffer2
    pop hl
    pop de
    pop bc
    pop af
    ret

LoaderTextbox:
    coord hl, 17, 15
    ld bc, $0101
    call TextBoxBorder
    jp UpdateSprites

ClearSpriteData:
    push hl
    ld hl, wSpriteStateData1 + $10
	ld de, wSpriteStateData2 + $10
	xor a
	ld c, $f0
.clearSpriteData
	ld [hli], a
	ld [de], a
	inc e
	dec c
	jr nz, .clearSpriteData
    ld hl, wSpriteStateData1 + $12
	ld de, $0010
	ld c, $0f
.disableAllSprites
	ld [hl], $ff
	add hl, de
	dec c
	jr nz,.disableAllSprites
    pop hl
    ret

; copy c bytes from de to hl during hblank periods
CopyDataDuringHblank:
.waitHblank
    ldh a, [rSTAT]
    and %00000011
    jr nz, .waitHblank
    ld a, [de]
    ld [hli], a
    inc de
    ld a, [de]
    ld [hli], a
    inc de
    dec c
    dec c
    jr z, .done
.waitNoHblank
    ldh a, [rSTAT]
    and %00000011
    jr z, .waitNoHblank
    jr .waitHblank
.done
    ret