Minor I/O write improvements
This commit is contained in:
parent
6eb1071dec
commit
6bf53cf3db
1
common.h
1
common.h
|
@ -145,6 +145,7 @@ typedef u32 fixed8_24;
|
|||
|
||||
#define read_ioreg(regnum) (eswap16(io_registers[(regnum)]))
|
||||
#define write_ioreg(regnum, val) io_registers[(regnum)] = eswap16(val)
|
||||
#define read_ioreg32(regnum) (read_ioreg(regnum) | (read_ioreg((regnum)+1) << 16))
|
||||
|
||||
#define read_dmareg(regnum, dmachan) (eswap16(io_registers[(regnum) + (dmachan) * 6]))
|
||||
#define write_dmareg(regnum, dmachan, val) io_registers[(regnum) + (dmachan) * 6] = eswap16(val)
|
||||
|
|
17
gba_memory.c
17
gba_memory.c
|
@ -56,11 +56,12 @@
|
|||
} \
|
||||
\
|
||||
gbc_sound_update = 1; \
|
||||
write_ioreg(regn, value); \
|
||||
write_ioreg(regn, value & 0x47FF); \
|
||||
} \
|
||||
|
||||
#define gbc_sound_tone_control_sweep() \
|
||||
{ \
|
||||
value &= 0x007F; \
|
||||
u32 sweep_ticks = ((value >> 4) & 0x07) * 2; \
|
||||
gbc_sound_channel[0].sweep_shift = value & 0x07; \
|
||||
gbc_sound_channel[0].sweep_direction = (value >> 3) & 0x01; \
|
||||
|
@ -80,7 +81,7 @@
|
|||
gbc_sound_channel[2].master_enable = 1; \
|
||||
\
|
||||
gbc_sound_update = 1; \
|
||||
write_ioreg(REG_SOUND3CNT_L, value); \
|
||||
write_ioreg(REG_SOUND3CNT_L, value & 0x00E0); \
|
||||
} \
|
||||
|
||||
static const u32 gbc_sound_wave_volume[4] = { 0, 16384, 8192, 4096 };
|
||||
|
@ -141,7 +142,7 @@ static const u32 gbc_sound_wave_volume[4] = { 0, 16384, 8192, 4096 };
|
|||
gbc_sound_channel[3].envelope_initial_volume; \
|
||||
} \
|
||||
gbc_sound_update = 1; \
|
||||
write_ioreg(REG_SOUND4CNT_H, value); \
|
||||
write_ioreg(REG_SOUND4CNT_H, value & 0x40FF); \
|
||||
} \
|
||||
|
||||
static void gbc_trigger_sound(u32 value)
|
||||
|
@ -156,7 +157,7 @@ static void gbc_trigger_sound(u32 value)
|
|||
gbc_sound_channel[channel].status =
|
||||
(((value >> (channel + 8)) & 0x1) | ((value >> (channel + 11)) & 0x3));
|
||||
}
|
||||
write_ioreg(REG_SOUNDCNT_L, value);
|
||||
write_ioreg(REG_SOUNDCNT_L, value & 0xFF77);
|
||||
}
|
||||
|
||||
#define trigger_sound() \
|
||||
|
@ -175,7 +176,7 @@ static void gbc_trigger_sound(u32 value)
|
|||
sound_reset_fifo(0); \
|
||||
if((value >> 15) & 0x01) \
|
||||
sound_reset_fifo(1); \
|
||||
write_ioreg(REG_SOUNDCNT_H, value); \
|
||||
write_ioreg(REG_SOUNDCNT_H, value & 0x770F); \
|
||||
} \
|
||||
|
||||
static void sound_control_x(u32 value)
|
||||
|
@ -875,12 +876,6 @@ cpu_alert_type function_cc write_io_register8(u32 address, u32 value)
|
|||
|
||||
// Sound 1 control sweep
|
||||
case 0x60:
|
||||
access_register8_low(0x60);
|
||||
gbc_sound_tone_control_sweep();
|
||||
break;
|
||||
|
||||
case 0x61:
|
||||
access_register8_low(0x60);
|
||||
gbc_sound_tone_control_sweep();
|
||||
break;
|
||||
|
||||
|
|
26
gba_memory.h
26
gba_memory.h
|
@ -69,13 +69,13 @@ typedef struct
|
|||
|
||||
typedef enum
|
||||
{
|
||||
REG_DISPCNT = 0x000,
|
||||
REG_DISPSTAT = 0x002,
|
||||
REG_VCOUNT = 0x003,
|
||||
REG_BG0CNT = 0x004,
|
||||
REG_BG1CNT = 0x005,
|
||||
REG_BG2CNT = 0x006,
|
||||
REG_BG3CNT = 0x007,
|
||||
REG_DISPCNT = 0x00,
|
||||
REG_DISPSTAT = 0x02,
|
||||
REG_VCOUNT = 0x03,
|
||||
REG_BG0CNT = 0x04,
|
||||
REG_BG1CNT = 0x05,
|
||||
REG_BG2CNT = 0x06,
|
||||
REG_BG3CNT = 0x07,
|
||||
REG_BG0HOFS = 0x08,
|
||||
REG_BG0VOFS = 0x09,
|
||||
REG_BG1HOFS = 0x0A,
|
||||
|
@ -123,6 +123,18 @@ typedef enum
|
|||
REG_SOUNDCNT_L = 0x40,
|
||||
REG_SOUNDCNT_H = 0x41,
|
||||
REG_SOUNDCNT_X = 0x42,
|
||||
REG_SOUNDWAVE_0 = 0x48,
|
||||
REG_SOUNDWAVE_1 = 0x49,
|
||||
REG_SOUNDWAVE_2 = 0x4A,
|
||||
REG_SOUNDWAVE_3 = 0x4B,
|
||||
REG_SOUNDWAVE_4 = 0x4C,
|
||||
REG_SOUNDWAVE_5 = 0x4D,
|
||||
REG_SOUNDWAVE_6 = 0x4E,
|
||||
REG_SOUNDWAVE_7 = 0x4F,
|
||||
REG_SOUND_FIFOA_L = 0x50,
|
||||
REG_SOUND_FIFOA_H = 0x51,
|
||||
REG_SOUND_FIFOB_L = 0x52,
|
||||
REG_SOUND_FIFOB_H = 0x53,
|
||||
// DMA control
|
||||
REG_DMA0SAD = 0x58,
|
||||
REG_DMA0DAD = 0x5A,
|
||||
|
|
12
video.c
12
video.c
|
@ -2345,14 +2345,10 @@ static inline s32 signext28(u32 value)
|
|||
void video_reload_counters()
|
||||
{
|
||||
/* This happens every Vblank */
|
||||
affine_reference_x[0] = signext28(read_ioreg(REG_BG2X_L) |
|
||||
(read_ioreg(REG_BG2X_H) << 16));
|
||||
affine_reference_y[0] = signext28(read_ioreg(REG_BG2Y_L) |
|
||||
(read_ioreg(REG_BG2Y_H) << 16));
|
||||
affine_reference_x[1] = signext28(read_ioreg(REG_BG3X_L) |
|
||||
(read_ioreg(REG_BG3X_H) << 16));
|
||||
affine_reference_y[1] = signext28(read_ioreg(REG_BG3Y_L) |
|
||||
(read_ioreg(REG_BG3Y_H) << 16));
|
||||
affine_reference_x[0] = signext28(read_ioreg32(REG_BG2X_L));
|
||||
affine_reference_y[0] = signext28(read_ioreg32(REG_BG2Y_L));
|
||||
affine_reference_x[1] = signext28(read_ioreg32(REG_BG3X_L));
|
||||
affine_reference_y[1] = signext28(read_ioreg32(REG_BG3Y_L));
|
||||
}
|
||||
|
||||
#define affine_render_bg_pixel_normal() \
|
||||
|
|
Loading…
Reference in New Issue