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 "ranges.hh"
44#include "serialize.hh"
45#include "xrange.hh"
46
47namespace openmsx {
48
50 : Rom8kBBlocks(config, std::move(rom_))
51 , samplePlayer(
52 "Nettou Yakyuu-DAC",
53 "Jaleco Moero!! Nettou Yakuu '88 DAC", config,
54 strCat(FileOperations::stripExtension(rom.getFilename()), '_'),
55 16, "nettou_yakyuu/nettou_yakyuu_")
56{
57 reset(EmuTime::dummy());
58}
59
60void RomNettouYakyuu::reset(EmuTime::param /*time*/)
61{
62 // ASCII8 behaviour
63 setUnmapped(0);
64 setUnmapped(1);
65 for (auto i : xrange(2, 6)) {
66 setRom(i, 0);
67 }
68 setUnmapped(6);
69 setUnmapped(7);
70
71 ranges::fill(redirectToSamplePlayer, false);
72 samplePlayer.reset();
73}
74
75void RomNettouYakyuu::writeMem(word address, byte value, EmuTime::param /*time*/)
76{
77 if ((address < 0x4000) || (0xC000 <= address)) return;
78
79 // mapper stuff, like ASCII8
80 if ((0x6000 <= address) && (address < 0x8000)) {
81 // calculate region in switch zone
82 byte region = (address >> 11) & 3;
83 redirectToSamplePlayer[region] = (value & 0x80) != 0;
84 if (redirectToSamplePlayer[region]) {
85 setUnmapped(region + 2);
86 } else {
87 setRom(region + 2, value);
88 }
89 return;
90 }
91
92 // sample player stuff
93 if (!redirectToSamplePlayer[(address >> 13) - 2]) {
94 // region not redirected to sample player
95 return;
96 }
97
98 // bit 7==0: reset
99 if (!(value & 0x80)) {
100 samplePlayer.reset();
101 return;
102 }
103
104 // bit 6==1: set no retrigger, don't alter playing sample
105 if (value & 0x40) {
106 samplePlayer.stopRepeat();
107 return;
108 }
109
110 samplePlayer.repeat(value & 0xF);
111}
112
114{
115 return nullptr;
116}
117
118template<typename Archive>
119void RomNettouYakyuu::serialize(Archive& ar, unsigned /*version*/)
120{
121 ar.template serializeBase<Rom8kBBlocks>(*this);
122 ar.serialize("SamplePlayer", samplePlayer,
123 "redirectToSamplePlayer", redirectToSamplePlayer);
124}
127
128} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:354
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
Definition RomBlocks.cc:92
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
void serialize(Archive &ar, unsigned version)
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
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.
void reset(EmuTime::param time) override
This method is called on reset.
RomNettouYakyuu(const DeviceConfig &config, Rom &&rom)
void repeat(unsigned sampleNum)
Keep on repeating the given sample data.
void stopRepeat()
Stop repeat mode.
This file implemented 3 utility functions:
Definition Autofire.cc:9
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
constexpr void fill(ForwardRange &&range, const T &value)
Definition ranges.hh:305
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
std::string strCat()
Definition strCat.hh:703
constexpr auto xrange(T e)
Definition xrange.hh:132