SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
z80_ctrl.h
Go to the documentation of this file.
1
14
15#ifndef _Z80_CTRL_H_
16#define _Z80_CTRL_H_
17
18
19#define Z80_HALT_PORT 0xA11100
20#define Z80_RESET_PORT 0xA11200
21
27#define Z80_RAM_START 0xA00000
33#define Z80_RAM_END 0xA01FFF
39#define Z80_RAM Z80_RAM_START
45#define Z80_RAM_LEN ((Z80_RAM_END - Z80_RAM_START) + 1)
51#define Z80_YM2612 0xA04000
57#define Z80_BANK_REGISTER 0xA06000
58
64#define Z80_DRV_COMMAND 0xA00100
70#define Z80_DRV_STATUS 0xA00102
76#define Z80_DRV_PARAMS 0xA00104
77
78// default command and status value
79#define Z80_DRV_COM_PLAY_SFT 0
80#define Z80_DRV_COM_STOP_SFT 4
81#define Z80_DRV_STAT_PLAYING_SFT 0
82#define Z80_DRV_STAT_READY_SFT 7
83
88#define Z80_DRV_COM_PLAY (1 << Z80_DRV_COM_PLAY_SFT)
93#define Z80_DRV_COM_STOP (1 << Z80_DRV_COM_STOP_SFT)
98#define Z80_DRV_STAT_PLAYING (1 << Z80_DRV_STAT_PLAYING_SFT)
103#define Z80_DRV_STAT_READY (1 << Z80_DRV_STAT_READY_SFT)
104
105
106#define Z80_DRV_CH0_SFT _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH1 instead.\"")
107#define Z80_DRV_CH1_SFT _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH2 instead.\"")
108#define Z80_DRV_CH2_SFT _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH3 instead.\"")
109#define Z80_DRV_CH3_SFT _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH4 instead.\"")
110
111#define Z80_DRV_CH0 _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH1_MSK instead.\"")
112#define Z80_DRV_CH1 _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH2_MSK instead.\"")
113#define Z80_DRV_CH2 _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH3_MSK instead.\"")
114#define Z80_DRV_CH3 _Pragma("GCC error \"This method is deprecated, use SOUND_PCM_CH4_MSK instead.\"")
115
116
121#define Z80_DRIVER_NULL 0
127#define Z80_DRIVER_PCM 1
133#define Z80_DRIVER_DPCM2 2
140#define Z80_DRIVER_PCM4 3
148#define Z80_DRIVER_XGM 4
157#define Z80_DRIVER_XGM2 5
162#define Z80_DRIVER_CUSTOM -1
163
164
165#define Z80_DRIVER_4PCM_ENV _Pragma("GCC error \"This definition is deprecated, use Z80_DRIVER_PCM4 instead.\"")
166#define Z80_DRIVER_2ADPCM _Pragma("GCC error \"This definition is deprecated, use Z80_DRIVER_DPCM2 instead.\"")
167
168
175void Z80_init(void);
176
181bool Z80_isBusTaken(void);
188void Z80_requestBus(bool wait);
197bool Z80_getAndRequestBus(bool wait);
198
203void Z80_releaseBus(void);
204
209void Z80_startReset(void);
214void Z80_endReset(void);
215
222void Z80_setBank(const u16 bank);
223
234u8 Z80_read(const u16 addr);
247void Z80_write(const u16 addr, const u8 value);
248
257void Z80_clear(void);
268void Z80_upload(const u16 dest, const u8 *data, const u16 size);
280void Z80_download(const u16 from, u8 *dest, const u16 size);
281
300void Z80_unloadDriver(void);
316void Z80_loadDriver(const u16 driver, const bool waitReady);
326void Z80_loadCustomDriver(const u8 *drv, u16 size);
327
332bool Z80_isDriverReady(void);
333
342void Z80_useBusProtection(u16 signalAddress);
343
362void Z80_setBusProtection(bool value);
381
388bool Z80_getForceDelayDMA(void);
402void Z80_setForceDelayDMA(bool value);
403
404#endif // _Z80_CTRL_H_
unsigned short u16
Definition types.h:100
unsigned char u8
Definition types.h:95
void Z80_loadDriver(const u16 driver, const bool waitReady)
Load a Z80 driver.
Definition z80_ctrl.c:285
void Z80_disableBusProtection()
Disable temporary 68K BUS protection from Z80 (for sound driver supporting it). See Z80_setBusProtect...
Definition z80_ctrl.c:372
bool Z80_isDriverReady(void)
Return driver ready state (only for non custom driver).
Definition z80_ctrl.c:324
void Z80_loadCustomDriver(const u8 *drv, u16 size)
Load a custom Z80 driver.
Definition z80_ctrl.c:276
u8 Z80_read(const u16 addr)
Read Z80 memory (Z80_RAM).
Definition z80_ctrl.c:156
void Z80_clear(void)
Clear Z80 memory.
Definition z80_ctrl.c:167
void Z80_setForceDelayDMA(bool value)
This method can be used to improve the PCM playback during music play and while DMA queue is used....
Definition z80_ctrl.c:382
void Z80_requestBus(bool wait)
Request Z80 BUS.
Definition z80_ctrl.c:69
bool Z80_isBusTaken(void)
Return Z80 BUS taken state.
Definition z80_ctrl.c:60
void Z80_download(const u16 from, u8 *dest, const u16 size)
Read data from Z80 memory.
Definition z80_ctrl.c:200
void Z80_unloadDriver(void)
Unload Z80 driver (set NULL driver).
Definition z80_ctrl.c:223
void Z80_upload(const u16 dest, const u8 *data, const u16 size)
Upload data in Z80 memory.
Definition z80_ctrl.c:183
bool Z80_getAndRequestBus(bool wait)
Request Z80 BUS if not yet taken.
Definition z80_ctrl.c:89
void Z80_setBank(const u16 bank)
Set Z80 memory bank.
Definition z80_ctrl.c:140
void Z80_init(void)
Initialize Z80 sub system.
Definition z80_ctrl.c:43
bool Z80_getForceDelayDMA(void)
Returns TRUE if DMA delay is enabled to improve PCM playback.
Definition z80_ctrl.c:377
void Z80_releaseBus(void)
Release Z80 BUS.
Definition z80_ctrl.c:114
void Z80_endReset(void)
End Z80 reset.
Definition z80_ctrl.c:131
void Z80_setBusProtection(bool value)
Set temporary 68K BUS protection from Z80 (for sound driver supporting it). You should protect BUS A...
Definition z80_ctrl.c:348
void Z80_enableBusProtection()
Enable temporary 68K BUS protection from Z80 (for sound driver supporting it). See Z80_setBusProtecti...
Definition z80_ctrl.c:367
void Z80_write(const u16 addr, const u8 value)
Write to Z80 memory (Z80_RAM).
Definition z80_ctrl.c:161
void Z80_useBusProtection(u16 signalAddress)
Enable/disable 68K bus access protection from Z80 (can be used by any sound driver).
Definition z80_ctrl.c:343
u16 Z80_getLoadedDriver(void)
Return currently loaded Z80 driver.
Definition z80_ctrl.c:218
void Z80_startReset(void)
Start Z80 reset.
Definition z80_ctrl.c:123