Skip to content

Commit f92cb92

Browse files
committed
amiga/amigaaga.cpp: implement palette reads
1 parent a7b26f0 commit f92cb92

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

src/mame/amiga/amiga.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ class amiga_state : public driver_device
660660
void render_scanline(bitmap_rgb32 &bitmap, int scanline);
661661

662662
// AGA video helpers
663-
void aga_palette_write(int color_reg, uint16_t data);
663+
u16 aga_palette_read(offs_t color_reg);
664+
void aga_palette_write(offs_t color_reg, uint16_t data);
664665
void aga_fetch_sprite_data(int scanline, int sprite);
665666
void aga_render_scanline(bitmap_rgb32 &bitmap, int scanline);
666667
void aga_update_sprite_dma(int scanline, int num);

src/mame/amiga/amiga_m.cpp

+13-21
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,17 @@ void amiga_state::ocs_map(address_map &map)
11911191
// Sprite section
11921192
// map(0x120, 0x17f).m(amiga_state::sprxpt_map));
11931193
// Color section
1194-
// map(0x180, 0x1bf).m(amiga_state::colorxx_map));
1194+
map(0x180, 0x1bf).lrw16(
1195+
NAME([this] (offs_t offset) {
1196+
return CUSTOM_REG(REG_COLOR00 + offset);
1197+
}),
1198+
NAME([this] (offs_t offset, u16 data) {
1199+
CUSTOM_REG(REG_COLOR00 + offset) = data;
1200+
data &= 0xfff;
1201+
// Extra Half-Brite
1202+
CUSTOM_REG(REG_COLOR00 + offset + 32) = (data >> 1) & 0x777;
1203+
})
1204+
);
11951205
}
11961206

11971207
void amiga_state::ecs_map(address_map &map)
@@ -1229,6 +1239,8 @@ void amiga_state::aga_map(address_map &map)
12291239

12301240
map(0x10e, 0x10f).w(FUNC(amiga_state::clxcon2_w));
12311241

1242+
map(0x180, 0x1bf).rw(FUNC(amiga_state::aga_palette_read), FUNC(amiga_state::aga_palette_write));
1243+
12321244
// UHRES regs
12331245
// TODO: may be shared with ECS?
12341246
// map(0x1e6, 0x1e7).w(FUNC(amiga_state::bplhmod_w));
@@ -1699,26 +1711,6 @@ void amiga_state::custom_chip_w(offs_t offset, uint16_t data)
16991711
data &= ~1;
17001712
break;
17011713

1702-
case REG_COLOR00: case REG_COLOR01: case REG_COLOR02: case REG_COLOR03:
1703-
case REG_COLOR04: case REG_COLOR05: case REG_COLOR06: case REG_COLOR07:
1704-
case REG_COLOR08: case REG_COLOR09: case REG_COLOR10: case REG_COLOR11:
1705-
case REG_COLOR12: case REG_COLOR13: case REG_COLOR14: case REG_COLOR15:
1706-
case REG_COLOR16: case REG_COLOR17: case REG_COLOR18: case REG_COLOR19:
1707-
case REG_COLOR20: case REG_COLOR21: case REG_COLOR22: case REG_COLOR23:
1708-
case REG_COLOR24: case REG_COLOR25: case REG_COLOR26: case REG_COLOR27:
1709-
case REG_COLOR28: case REG_COLOR29: case REG_COLOR30: case REG_COLOR31:
1710-
if (IS_AGA())
1711-
{
1712-
aga_palette_write(offset - REG_COLOR00, data);
1713-
}
1714-
else
1715-
{
1716-
data &= 0xfff;
1717-
// Extra Half-Brite
1718-
CUSTOM_REG(offset + 32) = (data >> 1) & 0x777;
1719-
}
1720-
break;
1721-
17221714
// display window start/stop
17231715
case REG_DIWSTRT:
17241716
case REG_DIWSTOP:

src/mame/amiga/amigaaga.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,26 @@
4141
*
4242
*************************************/
4343

44-
void amiga_state::aga_palette_write(int color_reg, uint16_t data)
44+
u16 amiga_state::aga_palette_read(offs_t color_reg)
45+
{
46+
u8 pal_bank = (CUSTOM_REG(REG_BPLCON3) >> 13) & 0x07;
47+
48+
int color = (pal_bank * 32) + color_reg;
49+
50+
u8 cr = m_aga_palette[color].r();
51+
u8 cg = m_aga_palette[color].g();
52+
u8 cb = m_aga_palette[color].b();
53+
54+
// LOCT
55+
if (BIT(CUSTOM_REG(REG_BPLCON3),9))
56+
{
57+
return ((cr & 0xf) << 8) | ((cg & 0xf) << 4) | ((cb & 0xf) << 0);
58+
}
59+
60+
return ((cr & 0xf0) << 4) | (cg & 0xf0) | ((cb & 0xf0) >> 4);
61+
}
62+
63+
void amiga_state::aga_palette_write(offs_t color_reg, uint16_t data)
4564
{
4665
int r,g,b;
4766
int cr,cg,cb;
@@ -68,7 +87,9 @@ void amiga_state::aga_palette_write(int color_reg, uint16_t data)
6887
cr = (r << 4) | r;
6988
cg = (g << 4) | g;
7089
cb = (b << 4) | b;
90+
// TODO: transparency, bit 15
7191
}
92+
7293
m_aga_palette[color] = rgb_t(cr, cg, cb);
7394
// make a copy for Extra Half Brite mode
7495
if (pal_bank == 0)
@@ -499,6 +520,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
499520
CUSTOM_REG(REG_VPOSR) ^= VPOSR_LOF;
500521

501522
m_copper->vblank_sync(true);
523+
// TODO: shouldn't be raw color ...
502524
m_ham_color = CUSTOM_REG(REG_COLOR00);
503525
}
504526

0 commit comments

Comments
 (0)