1 // Copyright 2021 Jean Pierre Cimalando
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // SPDX-License-Identifier: Apache-2.0
18 #include "ysfx_eel_utils.hpp"
20 ysfx_eel_ram_reader::ysfx_eel_ram_reader(NSEEL_VMCTX vm
, int64_t addr
)
26 EEL_F
ysfx_eel_ram_reader::read_next()
28 if (m_block_avail
== 0) {
29 m_block
= (m_addr
< 0 || m_addr
> 0xFFFFFFFFu
) ? nullptr :
30 NSEEL_VM_getramptr_noalloc(m_vm
, (uint32_t)m_addr
, (int32_t *)&m_block_avail
);
32 m_addr
+= m_block_avail
;
38 EEL_F value
= m_block
? *m_block
++ : 0;
43 //------------------------------------------------------------------------------
44 ysfx_eel_ram_writer::ysfx_eel_ram_writer(NSEEL_VMCTX vm
, int64_t addr
)
50 bool ysfx_eel_ram_writer::write_next(EEL_F value
)
52 if (m_block_avail
== 0) {
53 m_block
= (m_addr
< 0 || m_addr
> 0xFFFFFFFFu
) ? nullptr :
54 NSEEL_VM_getramptr(m_vm
, (uint32_t)m_addr
, (int32_t *)&m_block_avail
);
56 m_addr
+= m_block_avail
;