openMSX
RomNettouYakyuu.cc
Go to the documentation of this file.
1 // Based on information from hap/enen, published here:
2 // http://www.msx.org/forumtopicl8552.html
3 // and his implementation in blueMSX
4 //
5 // Jaleco - Moero!! Nettou Yakyuu '88, 256KB ROM, CRC32 68745C64
6 // NEC D7756C 146 sample player with internal 256Kbit ROM, undumped. Same
7 // samples as Famicom Moero!! Pro Yakyuu (Black/Red), recording available at
8 // http://home.planet.nl/~haps/segali_archive/
9 
10 // 4*8KB pages at $4000-$BFFF, initialized to 0.
11 // Mapper chip is exactly the same as ASCII8, except for data bit 7:
12 // a:011ppxxx xxxxxxxx d:sxxbbbbb
13 // a:address, d:data, p: page, b:bank, x:don't care
14 // s:if set, page reads/writes redirect to sample player via a 74HC174, eg.
15 // write $80 to $7800 -> $A000-$BFFF = sample player I/O
16 
17 // Sample player (datasheet, 690KB one on
18 // http://www.datasheetarchive.com/search.php?t=0&q=uPD7756 ):
19 // reads: always $FF (/BUSY not used)
20 // writes: d:rsxxiiii
21 // i:I0-I3 (sample number, latched on /ST rising edge when not playing)
22 // s:/ST (start), r:1=enable continuous rising edges to /ST (ORed with s),
23 // 0=falling edge to /RESET
24 // As I'm unable to measure, s and r bits pin setups are guessed from knowing
25 // the behaviour (examples underneath).
26 
27 // examples:
28 // - $C0: nothing
29 // - $80: "strike, strike, strike, strike, ..."
30 // - $80, $C0: "strike"
31 // - $80, short delay, $00/$40: "stri"
32 // - $80, short delay, $81: "strike, ball, ball, ball, ball, ..."
33 
34 // note: writes to sample player are ignored if on page $6000-$7FFF, possibly
35 // due to conflict with mapper chip, reads still return $FF though.
36 
37 // regarding this implementation: part of the above behaviour is put in the
38 // sample player. It may be a good idea to move this behaviour to a more
39 // specialized class some time in the future.
40 
41 #include "RomNettouYakyuu.hh"
42 #include "FileOperations.hh"
43 #include "serialize.hh"
44 
45 namespace openmsx {
46 
48  : Rom8kBBlocks(config, std::move(rom_))
49  , samplePlayer(
50  "Nettou Yakyuu-DAC",
51  "Jaleco Moero!! Nettou Yakuu '88 DAC", config,
52  FileOperations::stripExtension(rom.getFilename()) + '_',
53  16, "nettou_yakyuu/nettou_yakyuu_")
54 {
56 }
57 
59 {
60  // ASCII8 behaviour
61  setUnmapped(0);
62  setUnmapped(1);
63  for (int i = 2; i < 6; i++) {
64  setRom(i, 0);
65  redirectToSamplePlayer[i - 2] = false;
66  }
67  setUnmapped(6);
68  setUnmapped(7);
69 
70  samplePlayer.reset();
71 }
72 
73 void RomNettouYakyuu::writeMem(word address, byte value, EmuTime::param /*time*/)
74 {
75  if ((address < 0x4000) || (0xC000 <= address)) return;
76 
77  // mapper stuff, like ASCII8
78  if ((0x6000 <= address) && (address < 0x8000)) {
79  // calculate region in switch zone
80  byte region = (address >> 11) & 3;
81  redirectToSamplePlayer[region] = (value & 0x80) != 0;
82  if (redirectToSamplePlayer[region]) {
83  setUnmapped(region + 2);
84  } else {
85  setRom(region + 2, value);
86  }
87  return;
88  }
89 
90  // sample player stuff
91  if (!redirectToSamplePlayer[(address >> 13) - 2]) {
92  // region not redirected to sample player
93  return;
94  }
95 
96  // bit 7==0: reset
97  if (!(value & 0x80)) {
98  samplePlayer.reset();
99  return;
100  }
101 
102  // bit 6==1: set no retrigger, don't alter playing sample
103  if (value & 0x40) {
104  samplePlayer.stopRepeat();
105  return;
106  }
107 
108  samplePlayer.repeat(value & 0xF);
109 }
110 
112 {
113  return nullptr;
114 }
115 
116 template<typename Archive>
117 void RomNettouYakyuu::serialize(Archive& ar, unsigned /*version*/)
118 {
119  ar.template serializeBase<Rom8kBBlocks>(*this);
120  ar.serialize("SamplePlayer", samplePlayer);
121  ar.serialize("redirectToSamplePlayer", redirectToSamplePlayer);
122 }
124 REGISTER_MSXDEVICE(RomNettouYakyuu, "RomNettouYakyuu");
125 
126 } // namespace openmsx
void setRom(byte region, int block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:86
REGISTER_MSXDEVICE(DebugDevice,"DebugDevice")
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
static param dummy()
Definition: EmuTime.hh:21
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
STL namespace.
void serialize(Archive &ar, unsigned version)
void repeat(unsigned sampleNum)
Keep on repeating the given sample data.
Definition: SamplePlayer.cc:98
string_ref getFilename(string_ref path)
Returns the file portion of a path name.
RomNettouYakyuu(const DeviceConfig &config, Rom &&rom)
void reset(EmuTime::param time) override
This method is called on reset.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:25
string_ref stripExtension(string_ref path)
Returns the path without extension.
void stopRepeat()
Stop repeat mode.
Definition: SamplePlayer.hh:39
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:802
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:73
unsigned short word
16 bit unsigned integer
Definition: openmsx.hh:28