puce6502/README.md

32 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2020-08-08 20:27:09 +00:00
# puce6502
This is a simple and readable emulation of the MOS 6502 CPU\
2021-06-24 22:11:00 +00:00
It implements all original instructions and is cycle accurate\
It also passes the [Klaus Test Suite](https://github.com/Klaus2m5/6502_65C02_functional_tests) : set `_FUNCTIONNAL_TESTS` to 1 and compile it as a standalone program.
2020-08-08 20:27:09 +00:00
2021-06-24 22:04:03 +00:00
API is as simple as :
2020-08-08 20:27:09 +00:00
2021-06-24 22:04:03 +00:00
```C
uint16_t puce6502Exec(unsigned long long int cycleCount);
void puce6502RST();
void puce6502IRQ();
void puce6502NMI();
2020-08-08 20:27:09 +00:00
```
2020-08-08 22:09:10 +00:00
2021-06-24 22:11:00 +00:00
The first function will execute as many instructions as needed to reach cycleCount clock cycles - it will return the updated value of the Program Counter
2021-06-24 22:04:03 +00:00
the 3 others will simulate a RESET, INTERUPT and NON-MASKABLE INTERUPT.
2020-08-08 22:09:10 +00:00
2021-06-24 22:11:51 +00:00
You are expected to provide the functions to handle read and writes to memory (ROM, RAM, Soft Switches, extension cards, PIA, VIA, ACIA etc...)
2021-06-24 22:04:03 +00:00
They have to comply with these prototypes :
2020-08-08 20:27:09 +00:00
2021-06-24 22:04:03 +00:00
```C
2021-06-24 22:09:17 +00:00
uint8_t readMem(uint16_t address);
void writeMem(uint16_t address, uint8_t value);
2020-08-08 20:27:09 +00:00
```
2021-06-24 22:11:00 +00:00
Finnaly, you can import the variable `ticks` (extern ticks) into your code - it holds the accumulated clock cycles since start.
2020-08-08 22:09:10 +00:00
2020-08-08 20:32:54 +00:00
For an example of use, you can refer to [reinette II plus](https://github.com/ArthurFerreira2/reinette-II-plus) a french Apple II plus emulator.
2020-08-08 20:27:09 +00:00
Have fun !