I found a c64 computereyes disk on the net (just search for "computereyes c64")
and thought I'd have a look.

It uses the userport and from the info at: https://www.c64-wiki.com/wiki/CIA the important addresses are $DD01 (read/write data) and $DD03 (sets io direction).

Making some hacky changes to c64.cpp:

Code
uint m_computereyescapturebuffer[200][320];  // resolution of c64 capture is 320x200
int  m_cex, m_cey;
int m_portb_write;

add the save item:

Code
 save_item(NAME(m_computereyescapturebuffer));

make some changes to the cia2:

Code
READ8_MEMBER( c64_state::cia2_pb_r )
{

int threshold = ((m_portb_write & (1<<2)) ? 128 : 0) +      // bit 2 = threshold bit 7
                ((m_portb_write & (1<<1)) ? 64  : 0) +      // bit 1 = threshold bit 6
                ((m_portb_write & (1<<0)) ? 32  : 0) ;      // bit 0 = threshold bit 5

//threshold = threshold;  // compiler keeps complaining about unused variables!!!
int valtoreturn = m_computereyescapturebuffer[std::min(m_cey,199)][std::min(m_cex,319)]>threshold ? 0x40:0;  // return capture in bit 6, sync is bit 7
//int valtoreturn = m_joy2->read_joy()&(1<<5) ? 0x40:0;  // return capture in bit 6, sync is bit 7, joystick button to set the capture bit

// find address of pc
std::string mycontext = machine().describe_context();
int myaddr = stoi(mycontext.substr(mycontext.find("(")+1,4),nullptr,16);
if (myaddr==0xc101) // only increment our position if we are reading $DD01 at address 0xc101 since we read $DD01 in multiple places
{
m_cey=m_cey+1;
if(m_cey>199) {m_cey=0; m_cex=m_cex+1;}
}

return valtoreturn;  
        return m_user_pb;
}

WRITE8_MEMBER( c64_state::cia2_pb_w )
{
        m_user->write_c((data>>0)&1);
        m_user->write_d((data>>1)&1);
        m_user->write_e((data>>2)&1);
        m_user->write_f((data>>3)&1);
        m_user->write_h((data>>4)&1);
        m_user->write_j((data>>5)&1);
        m_user->write_k((data>>6)&1);
        m_user->write_l((data>>7)&1);

printf("wrote %x to pb_w      m_user_pb=%x\n",data,m_user_pb);  // why doesn't m_user_pb == data?
if ((data&0xf) != (m_portb_write&0xf)) {printf("LOW NIBBLE CHANGED RESETTING m_cex,m_cey=0\n");m_cex=0;m_cey=0;}
m_portb_write=data;
}

and our pic must be 320x200 now, so I made a little file in Gimp to "capture"


Code
f=assert(io.open("c64raw.data"))
a=f:read("*a") f:close() print(#a) 
quick = emu.items()["Commodore 64 (NTSC)/:/0/m_computereyescapturebuffer"] print(quick)
for i=0,320*200-1 do emu.item(quick):write(i,a:byte(1+i*4)) end  -- just grab the red component to make it simple

The first thing I'd thought I'd try was to hook up the joystick 2 button and get it to return some values into bit 6 of the user port b at $dd01.

After that worked I tried to get a picture to load, but I noticed that it keeps reading from $dd01 in multiple locations since it gets the sync bit in bit 7,
so we only increment the position when we read at address $c101.

[Linked Image from i.imgur.com] Using the joystick 2 button: [Linked Image from i.imgur.com]
[Linked Image from i.imgur.com]
[Linked Image from i.imgur.com][Linked Image from i.imgur.com][Linked Image from i.imgur.com]

It gets a higher resolution 320x200 than the apple's 280x192 capture which is a slight improvement, but still black and white. Unfortunately, it blanks the screen while capturing (probably to avoid any cpu slowdown) so you can't see what's going on.

Last edited by Golden Child; 04/28/19 03:08 PM.