I saw the Coleco Adam SmartLogo demo where it shows all 32 sprites flying around the screen and wanted to see if I could reproduce it.

I run the adam driver and wrote a little lua script to save out the vram to a file.


[Linked Image from i.imgur.com]


So we launch the adam driver with "./mame64 adam smartlog -plugin console" and get to the examples screen so we can dump the vram. We run the following script with dofile("adam_dump_vram.lua")

Code
-- Coleco Adam calls its tms device ":tms9928a"

tms= manager:machine().devices[":tms9928a"]

mem = tms.spaces["vram"]

-- read vram and save to a file

outfile = assert(io.open("vram_dump_file", "wb"))

for i=0,16384-1 do
  outfile:write(string.char(mem:read_u8(i)))
end

assert(outfile:close())


I take the vram dump and load it into the apple2 arcade board's memory.

"./mame64 apple2e -sl4 arcbd -plugin console" and run this script to load the vram dump: dofile("arcbd_load_vram.lua")

Code
tms= manager:machine().devices[":sl4:arcbd:arcbd_tms"]

mem = tms.spaces["vram"]

-- read vram from a file and close it

infile = assert(io.open("vram_dump_file", "rb"))

datablock = infile:read("*all")    

assert(infile:close())

for i=0,16384-1 do
  mem:write_i8(i,string.byte(datablock,(i+1)))  -- datablock index starts at 1
end


and init the TMS9918 registers to match (since it puts its sprite attribute tables in a different spot than I was using at 1F80).


dofile("smartlogo_demo.lua")

Code
cpu = manager:machine().devices[":maincpu"];apmem = cpu.spaces["program"]

reginitarray = {2,194,14,255,3,63,3,1}

for i=1,table.maxn(reginitarray) do 
dummy=apmem:read_i8(0xc0c1);
apmem:write_i8(0xc0c1,reginitarray[i]); apmem:write_i8(0xc0c1,128+(i-1)); end


myspriteattributes = {}

for i=0,31 do
  myspriteattributes[i]={ }
end

for i = 0,31 do
  myspriteattributes[i][0] = 128
  myspriteattributes[i][1] = 96
  myspriteattributes[i][2] = (i+1)*4  -- pattern  (since we are doing 16x16 sprites must be multiples of 4
  myspriteattributes[i][3] = (i % 14) + 2   --color
  myspriteattributes[i][4] = .5   --speed
  myspriteattributes[i][5] = i * (360/32) -- heading
end


function setspritetable(tablepos,sprite,x,y,pattern,color)
  bytepos=tablepos+sprite*4
  if y>=0 then mem:write_i8(bytepos,y) end
  if x>=0 then mem:write_i8(bytepos+1,x)  end
  if pattern>=0 then mem:write_i8(bytepos+2,pattern) end
  if color >=0 then mem:write_i8(bytepos+3,color) end
end


deactivate = false


function do_each_frame()

  if not deactivate then 
  for i=0,31 do
    xoffset = spritespeed*math.cos(myspriteattributes[i][5]/360*2*math.pi)
    yoffset = spritespeed*math.sin(myspriteattributes[i][5]/360*2*math.pi) 

    myspriteattributes[i][0] =   myspriteattributes[i][0] + xoffset
    myspriteattributes[i][1] =   myspriteattributes[i][1] - yoffset 

    if myspriteattributes[i][0] < 0 then  myspriteattributes[i][0] = 256  end
    if myspriteattributes[i][0] > 256 then myspriteattributes[i][0] = 0 end

    if myspriteattributes[i][1] < 0 then myspriteattributes[i][1] = 192 end
    if myspriteattributes[i][1] > 192 then myspriteattributes[i][1] = 0 end

    setspritetable(0x1f80,i,math.floor(myspriteattributes[i][0]),
                            math.floor(myspriteattributes[i][1]),
                            myspriteattributes[i][2],
                            myspriteattributes[i][3])
  end -- for
  end -- if
end -- function

print("do you want to add the function do each frame to emu.register_frame?")
if io.read() == "y" then emu.register_frame(do_each_frame) end

spritespeed = 4


What's cool is to modify the myspriteattributes array in real time from the console and see the result.

For example:
for i = 0,31 do myspriteattributes[i][2]=36*4 end
spritespeed = 0.5