#pragma once
#include <stdint.h>
#include <stdio.h>
namespace mem
{
    #define MEMTAG_NONE     0x00
    #define MEMTAG_DATA     0x01
    #define MEMTAG_INST     0x02
    #define MEMTAG_CODE     0x04
    #define MEMTAG_IGNORE   0x08
    #define MEMTAG_TDATA    0x10
    #define MEMTAG_TINST    0x20
    #define MEMTAG_TREPEAT  0x40
    #define MEMTAG_MODIFIED 0x80

    #define MEMTAG_KNOWN    0x07
    #define MEMTAG_TOUCHED  0x70

    #define MBC_NONE     0
    #define MBC1         1
    #define MBC2         2
    #define MBC3         3
    #define MBC5         5
    #define MBC6         6
    #define MBC7         7
    
    void init(uint8_t* rom, const int size);
    void reset();
    
    uint8_t readMem(uint16_t address);
    void writeMem(uint16_t address, uint8_t value);

    uint8_t getTag(uint16_t address);
    void setTag(uint16_t address, uint8_t value);

    void saveState(FILE* f);
    void loadState(FILE* f);

    uint8_t *rawVram();
    uint8_t *rawHram(uint16_t address);

    void init_dma_transfer(uint8_t source);
    void update_mapped(const uint32_t dt);
}
