OSCR
Open Source Cartridge Reader
Loading...
Searching...
No Matches
WonderSwan.h
1#pragma once
2#if !defined(OSCR_CORE_WONDERSWAN_H_)
3# define OSCR_CORE_WONDERSWAN_H_
4
5# include "config.h"
6
7# if HAS_WS
8# include "syslibinc.h"
9# include "common/Types.h"
10
11# ifdef OPTION_WS_ADAPTER_V2
12# define WS_CLK_BIT 5 // USE PE5 as CLK
13# else
14# define WS_CLK_BIT 3 // USE PE3 as CLK
15# endif
16
21{
22 enum class MenuOption : uint8_t
23 {
24 ReadROM,
25 ReadSave,
26 WriteSave,
27 RefreshCart,
28 WriteWitchOS,
29 Back,
30 };
31
32 constexpr uint8_t const kMenuOptionMax = 6;
33
34 void menu();
35
36 void openCRDB();
37 void closeCRDB();
38
39 void cartOn();
40 void cartOff();
41
42 void printHeader();
43
44 uint8_t refreshCart(__FlashStringHelper const * menuOptions[], MenuOption * const menuOptionMap, bool & hasWitchOS);
45 bool headerCheck();
46 bool getCartInfo();
47
48 void readROM(bool hasWitchOS);
49
50 void readSave();
51 void readSRAM();
52 void readEEPROM();
53
54 void writeSave();
55 void writeSRAM();
56 void writeEEPROM();
57
58 void writeWitchOS();
59
60 void fastProgramWitchFlash(uint32_t addr, uint16_t data);
61 void eraseWitchFlashSector(uint32_t sector_addr);
62 uint8_t readBytePort(uint8_t port);
63 uint8_t readByte(uint32_t addr);
64 uint16_t readWord(uint32_t addr);
65
66 void writeBytePort(uint8_t port, uint8_t data);
67 void writeByte(uint32_t addr, uint8_t data);
68 void writeWord(uint32_t addr, uint16_t data);
69
70 void unprotectEEPROM();
71
72 void generateEepromInstruction(uint8_t *instruction, uint8_t opcode, uint16_t addr);
73 bool unlockMMC2003();
74 void pulseCLK(uint8_t count);
75
76 void dataIn();
77 void dataOut();
78} /* namespace OSCR::Cores::WonderSwan */
79
80# endif /* HAS_WS */
81#endif /* OSCR_CORE_WONDERSWAN_H_ */
System core for the Bandai WonderSwan and the Benesse Pocket Challenge V2.
Definition WonderSwan.h:21