'******************************************************************************
'* 
'* INIT OF COLECOVISION (Video game console by Coleco, 1982-198x)
'*
'* Note: - This script always executed while emulation starting and then 
'*         "used" by other emulation scripts (to provide access to CPU etc.)
'*
'******************************************************************************

? "[INIT] Started emulation of ColecoVision"

'Configuring memory and loading ROM
mem.Size=64*1024 : mem.Limit=0xFFFF '64 Kb of memory
dim rom as object=emuDrives.ROM(0)
if (rom.Ready) and (rom.Latched) and (rom.Size<=0x8000) then 
  mem.Pos=0x8000 : rom.Pos=0 : mem.Copy(rom.Object)  'load ROM to memory
  rom.Detected=true
else : rom.Detected=false : end if

'Assembling
public use object CPU_Z80 as CPU 'processor Z80
cpu.Frequency=3579545 '3,58Mhz
public use object "mboard" as MB : pc.AddDevice(MB) 'motherboard

