53 lines
1.3 KiB
C
53 lines
1.3 KiB
C
|
//
|
||
|
// Created by william on 1/9/24.
|
||
|
//
|
||
|
|
||
|
#ifndef NESEMULATOR_DECODING_H
|
||
|
#define NESEMULATOR_DECODING_H
|
||
|
|
||
|
#include "../include/types.h"
|
||
|
#include "../include/system.h"
|
||
|
#include "cpu.h"
|
||
|
|
||
|
typedef enum {
|
||
|
ADDR_MODE_ABSOLUTE, // a
|
||
|
ADDR_MODE_ABSOLUTE_INDEXED_X, // a,x
|
||
|
ADDR_MODE_ABSOLUTE_INDEXED_Y, // a,y
|
||
|
ADDR_MODE_ACCUMULATOR, // A
|
||
|
ADDR_MODE_IMMEDIATE, // #i
|
||
|
ADDR_MODE_IMPLICIT, // Imp
|
||
|
ADDR_MODE_INDIRECT_X, // (d,x)
|
||
|
ADDR_MODE_INDIRECT_JUMP, //
|
||
|
ADDR_MODE_INDIRECT_Y, // (d),y
|
||
|
ADDR_MODE_RELATIVE, // label
|
||
|
ADDR_MODE_ZERO_PAGE, // d
|
||
|
ADDR_MODE_ZERO_PAGE_INDEXED_X, // d,x
|
||
|
ADDR_MODE_ZERO_PAGE_INDEXED_Y, // d,y
|
||
|
} AddressingMode;
|
||
|
|
||
|
enum OperandType {
|
||
|
OPERAND_TYPE_ACCUMULATOR,
|
||
|
OPERAND_TYPE_IMMEDIATE,
|
||
|
OPERAND_TYPE_ADDRESS
|
||
|
};
|
||
|
|
||
|
typedef struct {
|
||
|
word value;
|
||
|
enum OperandType type;
|
||
|
bool is_page_crossing;
|
||
|
} Operand;
|
||
|
|
||
|
address decode_operand_addr(System *system, AddressingMode addr_mode, bool *page_crossing);
|
||
|
|
||
|
Operand decode_operand(System *system, AddressingMode addr_mode);
|
||
|
|
||
|
byte read_operand(System *system, Operand operand);
|
||
|
|
||
|
char *get_addr_mode_name(AddressingMode addr_mode);
|
||
|
|
||
|
char *operand_name(Operand *operand);
|
||
|
|
||
|
char *get_op_code_name(byte op);
|
||
|
|
||
|
#endif //NESEMULATOR_DECODING_H
|