static void fm7_alu_function(fm7_state *state, UINT32 offset) { switch(state->m_alu.command & 0x07) { case 0x00: // PSET fm7_alu_function_pset(state, offset); break; case 0x02: // OR fm7_alu_function_or(state, offset); break; case 0x03: // AND fm7_alu_function_and(state, offset); break; case 0x04: // XOR fm7_alu_function_xor(state, offset); break; case 0x05: // NOT fm7_alu_function_not(state, offset); break; case 0x06: // TILEPAINT fm7_alu_function_tilepaint(state, offset); break; case 0x07: // COMPARE fm7_alu_function_compare(state, offset); break; case 0x01: default: fm7_alu_function_invalid(state, offset); } }
static void fm7_alu_function_invalid(fm7_state *state, UINT32 offset) { // Invalid function, still does something though (used by Laydock) int x; UINT8 dat; int page = 0; UINT8 mask; if(state->m_alu.command & 0x40) fm7_alu_function_compare(state, offset); if(offset >= 0xc000) { page = 1; offset += state->m_video.vram_offset2; } else offset += state->m_video.vram_offset; for(x=0;x<3;x++) // cycle through banks { if(!(state->m_alu.bank_disable & (1 << x))) { mask = (state->m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); dat = mask & state->m_alu.mask; fm7_alu_mask_write(state, offset,x,dat); } } }
static void fm7_alu_function_tilepaint(fm7_state *state, UINT32 offset) { // TILEPAINT - writes to VRAM based on the tilepaint colour registers int x; UINT8 dat = 0; int page = 0; UINT8 mask; if(state->m_alu.command & 0x40) fm7_alu_function_compare(state, offset); if(offset >= 0xc000) { page = 1; offset += state->m_video.vram_offset2; } else offset += state->m_video.vram_offset; for(x=0;x<3;x++) // cycle through banks { if(!(state->m_alu.bank_disable & (1 << x))) { switch(x) { case 0: dat = state->m_alu.tilepaint_b; break; case 1: dat = state->m_alu.tilepaint_r; break; case 2: dat = state->m_alu.tilepaint_g; break; } dat &= ~state->m_alu.mask; mask = (state->m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]) & state->m_alu.mask; dat |= mask; fm7_alu_mask_write(state, offset,x,dat); } } }
static void fm7_alu_function_not(fm7_state *state, UINT32 offset) { int x; UINT8 dat; int page = 0; UINT8 mask; if(state->m_alu.command & 0x40) fm7_alu_function_compare(state, offset); if(offset >= 0xc000) { page = 1; offset += state->m_video.vram_offset2; } else offset += state->m_video.vram_offset; for(x=0;x<3;x++) // cycle through banks { if(!(state->m_alu.bank_disable & (1 << x))) { if(state->m_alu.lcolour & (1 << x)) dat = 0xff; else dat = 0; mask = (state->m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]); dat = ~mask; mask &= state->m_alu.mask; dat &= ~state->m_alu.mask; dat |= mask; fm7_alu_mask_write(state, offset,x,dat); } } }
void fm7_state::fm7_alu_function_pset(UINT32 offset) { // PSET - simply sets the pixels to the selected logical colour int x; UINT8 dat; int page = 0; UINT8 mask; if(m_alu.command & 0x40) fm7_alu_function_compare(offset); if(offset >= 0xc000) { page = 1; offset += m_video.vram_offset2; } else offset += m_video.vram_offset; for(x=0;x<3;x++) // cycle through banks { if(!(m_alu.bank_disable & (1 << x))) { if(m_alu.lcolour & (1 << x)) dat = 0xff; else dat = 0; mask = (m_video_ram[(offset & 0x3fff) + (x * 0x4000) + (page * 0xc000)]) & m_alu.mask; dat &= ~m_alu.mask; dat |= mask; fm7_alu_mask_write(offset,x,dat); } } }