Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > VICE or similar cycle "perfect" emulator for screenshot?
2015-06-13 11:18
Scarzix

Registered: Aug 2010
Posts: 143
VICE or similar cycle "perfect" emulator for screenshot?

Question: is there a way to get VICE or other "almost perfect emulater" to run a PRG for eg. 100 frames and then produce a screenshot automatically?

Scenario:
1) Run assembler
2) Spawn VICE ( or other near perfect emulator ) with PRG from assembler
3) Run for xxx frames
4) Save screen (including border colors/rastersplits) as a bitmap file (fileformat is not an issue)

I need to call this from within a program automatically. So a Commandline interface or a Dll perhaps. Writing my mainprogram in C# so a slow, but "true emulation" is needed.

Hope someone has a solution?

Cheers,
Scarzix/Offence
2015-06-13 11:22
Scarzix

Registered: Aug 2010
Posts: 143
infact, I dont spawn VICE from assembler, I use a C# program to call KickAssembler to generate the PRG, and then I would like to grab a screenshot from that PRG at random frame...

to generate eg. an animation or just stills from it.

If its a slow Implementation without the full VICE its also a solution, as I dont need all the stuff about tape, diskimages, SID settings etc.

I am just searching for a way to see the output from the code as eg. a PNG
2015-06-13 11:55
Brush

Registered: Apr 2002
Posts: 21
HI,

I'm not sure what is your ultimate goal but Vice has a built in feature to record a video (under Snapshot menu). I don't have it handy here but if there is a lossless codec in ffmpeg (that's what vice is using) you should be able to have a video recorded in a way that could be further manipulated.
2015-06-13 17:40
Scarzix

Registered: Aug 2010
Posts: 143
sorry, but it has to be 100% automatically... so it can be done by using params or open VICE or other emulator from code... no human interaction.
2015-06-14 10:27
Burglar

Registered: Dec 2004
Posts: 1031
I actually tried it with vice, but didnt work. also wanted automatic screenshot to tie into the X voting system.

so, lemme know if you get it to work ;)
2015-06-14 10:40
Oswald

Registered: Apr 2002
Posts: 5017
there are some sceners around who are able modify vice to do this for you, Groepaz for example.
2015-06-14 11:44
soci

Registered: Sep 2003
Posts: 473
A not very sophisticated solution using shell scripting and remote monitor with netcat:
#!/bin/sh
x64 -remotemonitor "$1" &
sleep 10
nc 127.0.0.1 6510 <<END
screenshot "$1"
quit
END
But as you've been talking about C# I think it's not going to help much.
2015-06-14 13:24
Burglar

Registered: Dec 2004
Posts: 1031
a remotemonitor! of course :)

thanks soci, this will do just fine for me
2015-06-14 15:58
chatGPZ

Registered: Dec 2001
Posts: 11111
i like the proposed idea with using ffmpeg output more somehow.... at least that would enable some more sophisticated things like "skip N frames, then take the 10th of 10 consecutive non black frames" relatively easily :)
2015-06-14 21:00
Scarzix

Registered: Aug 2010
Posts: 143
Nice ideas, might have to try them even the remote version. Still I wouldn't "feel in control" with frames so a bit hard to step through frames.

Wish there was some way to "pause" then "step" frame by frame.. or... "start with PRG and run until frame xxxx" then save PNG or something.
2015-06-14 21:03
Scarzix

Registered: Aug 2010
Posts: 143
Thinking, maybe I could just embed VICE inside a Windows program and then mimick some sort of user-control on top of it... hmmm..
2015-06-14 22:06
Oswald

Registered: Apr 2002
Posts: 5017
Quote: Thinking, maybe I could just embed VICE inside a Windows program and then mimick some sort of user-control on top of it... hmmm..

autoit/autohotkey is the tool for that
2015-06-15 22:52
Scarzix

Registered: Aug 2010
Posts: 143
Problem is that I in the end I will be running this on a webserver without anyone logged in, so actually no desktop user... no interaction.

Must figure out a way to "call the render" and "retrieve screenshot".
2015-06-16 17:20
Rex

Registered: Sep 2011
Posts: 14
I have had some success using Tcl Expect and VICE Remote Monitor to remote control VICE to automatically create screenshots after the program has run for a while.

Using Expect to communicate with VICE remote monitor will allow you to call monitor commands , run the program for a while, send more monitor commands when the monitor regains control and so on.

This still requires a desktop on the computer running VICE and Tcl/Expect.

Determining when to make the screenshot could be done using the "step <count>" command of the monitor. This wont wait an exact number of cycles, but based on the average cycle consumption of instructions you should be able to find an OK value to use.

My Expect Code for creating a screenshot looks like this:
           # Create a screenshot
            set shotnameout "$output.$shotnum"
            incr shotnum 
            set command "screenshot \"$shotnameout\""
            # Send the command from the input-file
            send "$command\r"
            # Wait for the monitor to complete the command (or meet the next breakpoint)
            expect "(C:*) $"
2015-06-17 09:09
MagerValp

Registered: Dec 2001
Posts: 1055
Quoting Rex
Determining when to make the screenshot could be done using the "step <count>" command of the monitor. This wont wait an exact number of cycles, but based on the average cycle consumption of instructions you should be able to find an OK value to use.


You can use the "registers" command to display the current line, cycle, and total cycle count, allowing you to pinpoint a specific frame and raster line.
2015-06-17 11:52
Perplex

Registered: Feb 2009
Posts: 254
Is there a way via the remote monitor to wait for a breakpoint to be triggered, then run some commands? Then you could do all the timing/frame counting from the C64 code and trigger the breakpoint at the exact right time.
2015-06-17 13:54
Mr. SID

Registered: Jan 2003
Posts: 421
Yes you can attach a command to a breakpoint:

Syntax: command <checknum> "<Command>"

Specify `command' as the command to execute when checkpoint `checknum'
is hit. Note that the `x' command is not yet supported as a
command argument.
2015-06-18 18:51
Rex

Registered: Sep 2011
Posts: 14
Quote: Is there a way via the remote monitor to wait for a breakpoint to be triggered, then run some commands? Then you could do all the timing/frame counting from the C64 code and trigger the breakpoint at the exact right time.

The reason for using Expect/Tcl is that it allows you to do exactly that.

The following code will create a breakpoint, run the program, wait for the breakpoint to trigger and the save a screenshot:

            send "b $2100\r"
            send "r\r"
            expect "(C:*) $"
            send "screenshot \"screen\""
            expect "(C:*) $"



However what Scarzix wanted was a program to create screenshots automatically - so he probably does not know where to set a breakpoint to wait the right amount of cycles.
2015-06-18 19:56
Scarzix

Registered: Aug 2010
Posts: 143
Correct Rex, I am looking for "frames" - like "100" frames from boot and that number could be changed or multiple shots could be made to form an animation.
2015-06-19 11:41
MagerValp

Registered: Dec 2001
Posts: 1055
You can use expect to send the z command until the r command ends up at the right cycle count (100 * 312 * 63). Use a decreasing step count depending on how many cycles are left.
2015-06-19 13:26
Scarzix

Registered: Aug 2010
Posts: 143
Very interesting MagerValp, will check that out once I get the connection to work.
2015-06-19 21:08
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
run CCS64, skip 99 frames in stepmode, then save pic.
is all i know.
2015-06-20 21:55
Scarzix

Registered: Aug 2010
Posts: 143
SIDWAVE, this has to be controlled from another program that loads and steps through the C64 program. So if thats going to work, it has to have some commands that can be called by a program and not a user as I am putting this inside a server where there is nobody logged in.
2015-06-21 02:46
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
IMO its simply a missing feature of VICE.

i dont know what you need carsten, but if you record whole thing on video with a tool, then maybe you could edit videofile instead ?
2015-08-20 19:47
Digger

Registered: Mar 2005
Posts: 421
Have you found any solution yet, Carsten?
2016-02-28 12:47
Burglar

Registered: Dec 2004
Posts: 1031
argh, there was a commandline option added to vice for this (make screenshot after N cycles), but I just cannot find the thread...
2016-02-28 14:32
chatGPZ

Registered: Dec 2001
Posts: 11111
yup, i am using it extensively for automated testing now.... one thing that doesnt work yet is combining it with -console, so it will always pop up a gui window atm. will look into that later ;)
2016-02-28 15:38
Burglar

Registered: Dec 2004
Posts: 1031
x64 +cart -warp -limitcycles 19000000 -exitscreenshot "screenshot.png" "bla.d64"
2016-02-28 16:06
Scarzix

Registered: Aug 2010
Posts: 143
cool, that looks easy, gonna try that on my solution soon then
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Lord Crucifier/SCS*TRC
www.gb64.com
csabanw
MCM/ONSLAUGHT
Moderators/CSDb Staff
Martin Piper
Guests online: 83
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Jeroen Tel  (9.7)
3 Stinsen  (9.6)
4 Mutetus  (9.6)
5 Linus  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.082 sec.