Mercurial > audlegacy-plugins
annotate src/console/Kss_Emu.h @ 334:a9f1bd76a3e6 trunk
[svn] - apply_xform(): check for NULL vfield (broken scripts)
- add tan(), asin(), acos(), atan(), log() to script engine.
author | nenolod |
---|---|
date | Tue, 05 Dec 2006 03:40:04 -0800 |
parents | fb513e10174e |
children | 986f098da058 |
rev | line source |
---|---|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
1 // MSX computer KSS music file emulator |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
2 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
3 // Game_Music_Emu 0.5.1 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
4 #ifndef KSS_EMU_H |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
5 #define KSS_EMU_H |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
6 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
7 #include "Classic_Emu.h" |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
8 #include "Kss_Scc_Apu.h" |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
9 #include "Kss_Cpu.h" |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
10 #include "Sms_Apu.h" |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
11 #include "Ay_Apu.h" |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
12 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
13 class Kss_Emu : private Kss_Cpu, public Classic_Emu { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
14 typedef Kss_Cpu cpu; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
15 public: |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
16 // KSS file header |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
17 struct header_t |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
18 { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
19 byte tag [4]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
20 byte load_addr [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
21 byte load_size [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
22 byte init_addr [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
23 byte play_addr [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
24 byte first_bank; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
25 byte bank_mode; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
26 byte extra_header; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
27 byte device_flags; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
28 }; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
29 BOOST_STATIC_ASSERT( sizeof (header_t) == 0x10 ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
30 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
31 struct ext_header_t |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
32 { |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
33 byte data_size [4]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
34 byte unused [4]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
35 byte first_track [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
36 byte last_tack [2]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
37 byte psg_vol; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
38 byte scc_vol; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
39 byte msx_music_vol; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
40 byte msx_audio_vol; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
41 }; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
42 BOOST_STATIC_ASSERT( sizeof (ext_header_t) == 0x10 ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
43 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
44 struct composite_header_t : header_t, ext_header_t { }; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
45 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
46 // Header for currently loaded file |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
47 composite_header_t const& header() const { return header_; } |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
48 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
49 static gme_type_t static_type() { return gme_kss_type; } |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
50 public: |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
51 Kss_Emu(); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
52 ~Kss_Emu(); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
53 protected: |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
54 blargg_err_t track_info_( track_info_t*, int track ) const; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
55 blargg_err_t load_( Data_Reader& ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
56 blargg_err_t start_track_( int ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
57 blargg_err_t run_clocks( blip_time_t&, int ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
58 void set_tempo_( double ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
59 void set_voice( int, Blip_Buffer*, Blip_Buffer*, Blip_Buffer* ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
60 void update_eq( blip_eq_t const& ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
61 void unload(); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
62 private: |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
63 Rom_Data<page_size> rom; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
64 composite_header_t header_; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
65 byte* unmapped_write() { return rom.unmapped(); } |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
66 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
67 bool scc_accessed; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
68 bool gain_updated; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
69 void update_gain(); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
70 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
71 unsigned scc_enabled; // 0 or 0xC000 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
72 byte const* bank_data; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
73 int bank_count; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
74 void set_bank( int logical, int physical ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
75 blargg_long bank_size() const { return (16 * 1024L) >> (header_.bank_mode >> 7 & 1); } |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
76 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
77 blip_time_t play_period; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
78 blip_time_t next_play; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
79 int ay_latch; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
80 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
81 friend void kss_cpu_out( class Kss_Cpu*, cpu_time_t, unsigned addr, int data ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
82 friend int kss_cpu_in( class Kss_Cpu*, cpu_time_t, unsigned addr ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
83 void cpu_write( unsigned addr, int data ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
84 friend void kss_cpu_write( class Kss_Cpu*, unsigned addr, int data ); |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
85 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
86 // large items |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
87 enum { mem_size = 0x10000 }; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
88 byte ram [mem_size + cpu_padding]; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
89 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
90 Ay_Apu ay; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
91 Scc_Apu scc; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
92 Sms_Apu* sn; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
93 }; |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
94 |
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
diff
changeset
|
95 #endif |