I figured out why using the debugger memory view to change the TMS9918 registers doesn't work.

so I try to set the TMS registers by hand with the debugger memory view, but it doesn't have any effect.

Because when you do it with the debugger memory view, it doesn't update the corresponding member variables. So not only do you have to set the m_Regs[x] variable, you also have to change the member variables.

In the file src/devices/video/tms9928.cpp when you write the registers with tms9928a_device::change_register, it updates other variables inside the driver, so for register 0, it will update m_color and m_pattern. Likewise for other registers.


Code
void tms9928a_device::change_register(uint8_t reg, uint8_t val)
{

...
		switch (reg)
	{
	case 0:
		/* re-calculate masks and pattern generator & colour */
		if (val & 2)
		{
			m_colour = ((m_Regs[3] & 0x80) * 64) & (m_vram_size - 1);
			m_pattern = ((m_Regs[4] & 4) * 2048) & (m_vram_size - 1);
			update_table_masks();
		}
		else
		{
			m_colour = (m_Regs[3] * 64) & (m_vram_size - 1);
			m_pattern = (m_Regs[4] * 2048) & (m_vram_size - 1);
		}
		m_mode = ( (m_reva ? (m_Regs[0] & 2) : 0) | ((m_Regs[1] & 0x10)>>4) | ((m_Regs[1] & 8)>>1));
		if ((val ^ prev) & 1)
			update_backdrop();
		if (TRACE_MODE) logerror("TMS9928A('%s'): %s\n", tag(), modes[m_mode]);
		break;



So I load my vram dump into the TMS.

The values to load into the registers are as follows:

Code
reginitarray = {2,194,14,255,3,63,3,1}; for index,val in pairs(reginitarray) do print(index-1,string.format("%x",val)) end
0	2
1	c2
2	e
3	ff
4	3
5	3f
6	3
7	1



so I set by hand with the debugger:

TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_Regs[0] to 2
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_Regs[1] to c2
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_pattern to 0 (address of the pattern table)
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_colour to 2000 (address of the color table)
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_nametbl to 3800 (address of the name table)
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_mode to 2 (graphics mode 2)

then I can see the bitmap display.

and if I further set:

TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_spritepattern to 1800
TMS9918A VDP/:sl4:arcbd:arcbd_tms/0/m_spriteattribute to 1f80

then I can see the sprites.

And if you want some weird effects, just set m_pattern to 1 to 7 (something you could never have on real hardware) or to 1800 (where the sprite patterns are).



I can see a table with the items in lua but it's just a list of items with the corresponding number.

Code
for i,j in pairs(manager:machine().devices[":sl4:arcbd:arcbd_tms"].items) do print(i,j) end
1/0/m_start.seconds	610
0/0/m_start.seconds	605
0/m_clock_scale	439
0/m_Regs[6]	437
0/m_pattern	448
0/m_colour	441
0/m_colourmask	442
0/m_palette	446
0/m_patternmask	449
0/m_Regs[7]	440
0/m_spriteattribute	450
0/m_spritepattern	451
0/m_FifthSprite	428
0/m_nametbl	445
0/m_Regs[1]	432
0/m_Regs[0]	431
0/0/m_enabled	594
1/0/m_enabled	602
1/0/m_start.attoseconds	609
0/0/m_start.attoseconds	601
1/0/m_param	606
0/0/m_param	598
0/m_ReadAhead	429
0/m_Regs[2]	433
0/m_unscaled_clock	452
1/00000000-0000ffff	673
1/0/m_period.seconds	608
0/0/m_period.seconds	600
0/m_Regs[4]	435
0/m_StatusReg	444
0/m_INT	427
1/0/m_expire.attoseconds	603
0/m_latch	447
0/0/m_expire.seconds	596
1/0/m_expire.seconds	604
0/0/m_period.attoseconds	599
0/m_clock	438
0/0/m_expire.attoseconds	595
1/0/m_period.attoseconds	607
0/m_mode	443
0/m_Regs[5]	436
0/m_Addr	425
0/m_Regs[3]	434



I wish that I could read/write these items with lua in the same way that I can read/write them with the debugger memory view window.