Misol and Cari had a lovechild!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
misol101
Posts: 408
Joined: 02 May 2016 18:20

Misol and Cari had a lovechild!

#1 Post by misol101 » 01 May 2017 17:34

Image

What a mistake! For fun, I decided to make a demo with cmdgfx by putting together som old and new effects (particularly a kaleidoscope effect I was fairly happy with), accompanied with music from the old techno legend Cari Lekebusch. Problem was, i also wanted to synch the effects with the music... big mistake. Manually timing the first minute or so was ok, but after that it just got more and more painful and about 3-4 minutes in I just gave up... :P

Anyway... I would be happy if some of you could run this (run demo.bat) and tell me if the synching with music is working (calculating time passed is done with code borrowed from einstein1969, which I'm sure works, but there are many aspects involved in synching). Basically it should be easy to determine if synching works; when the tune changes in some way, the effects should change too. Also,does speed seem to be ok, or is it lagging?

Here's a link for download (file size is due to the mp3): http://www.mediafire.com/file/af5656ss58l37jx/lovechild.zip

Image

aGerman
Expert
Posts: 3852
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Misol and Cari had a lovechild!

#2 Post by aGerman » 01 May 2017 18:08

The synchronization seems to work on Win10 x86. The moves are a little fluttery. Although initially the window shows only the left half of the images. I had to widen it with the mouse pointer.

Steffen

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#3 Post by misol101 » 01 May 2017 18:31

Thanks for running!

Hmm, that's strange about the window size,any idea why that might be? I'm just using a regular call to "mode" to set the window size.

Fluttery motion does not sound good either, but atleast the synchronization is ok then... :) This thing runs quite smoothly on my old Windows 7 machine, but I don't recall ever trying cmdgfx on a Win10 machine. Hmmm. Just to be sure, can you check that no other process is hogging a lot of the CPU time? (On my machine, Firefox likes to use a lot of CPU, I sometimes have to kill it). It seems that Windows does not give a high priority to the cmd window. Also, antivirus programs might slow it down, especially if running in sandbox mode.

How fluttery is it? Would you say it's even worse than the gif animation above?

penpen
Expert
Posts: 1786
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Misol and Cari had a lovechild!

#4 Post by penpen » 02 May 2017 06:23

misol101 wrote:Hmm, that's strange about the window size,any idea why that might be?
Mode succeeds and sets screen to 55 x 55, so the font size (Lucida Console, 9x14) causes this result.

With the above font a screen size of 110 x 47 is optimal.


penpen

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#5 Post by misol101 » 02 May 2017 06:36

Penpen: aha, yes that would be my next question actually. Because the script calls "cmdwiz setfont 7" in the initial phase in order to ensure that bitmap font 7 is used before calling "mode" (to ensure a specific window size). So I guess that means that "cmdwiz setfont" does not work (on yours and aGerman's platform)?! Are you also running Windows 10?

Can you confirm that "cmdwiz setfont [0-9]" does not work? How about carlos old bg utility? ("bg font [0-9]" ?

I've seen neorobin use some sort of regkey method to set the font, perhaps I will have to use that instead...

penpen
Expert
Posts: 1786
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Misol and Cari had a lovechild!

#6 Post by penpen » 02 May 2017 07:54

My test system is Windows 10, 32 bit, german localization;
i can confirm, that "cmdwiz setfont [0-9]" has no effect on my Win10.

Carlos bg.exe (v3.5) tool changes the font.

Sidenote:
My "CmdFont.exe" (created with "CmdFont.cs.bat") also doesn't work, which is irritating,
because carlos uses the same C function (but i use c#/pinvoke, probably something has been changed since xp):
"int SetConsoleFont (HANDLE hOut, DWORD nFont)".


penpen

aGerman
Expert
Posts: 3852
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Misol and Cari had a lovechild!

#7 Post by aGerman » 02 May 2017 13:22

misol101 wrote:Just to be sure, can you check that no other process is hogging a lot of the CPU time?

That's for sure not the problem. I looks rather like the motion is a little too fast and is adjusted quite often. Because of the helical movement of the kaleidoscope it looks like it steps back before it moves forward again. But that might be an optical illusion. Most likely the rotation simply stops for some milliseconds.

Steffen

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#8 Post by misol101 » 02 May 2017 16:53

penpen wrote:My test system is Windows 10, 32 bit, german localization;
i can confirm, that "cmdwiz setfont [0-9]" has no effect on my Win10.

Carlos bg.exe (v3.5) tool changes the font.

Sidenote:
My "CmdFont.exe" (created with "CmdFont.cs.bat") also doesn't work, which is irritating,
because carlos uses the same C function (but i use c#/pinvoke, probably something has been changed since xp):
"int SetConsoleFont (HANDLE hOut, DWORD nFont)".

Hmm... I temporarily "fixed" this by re-uploading the archive with bg.exe and calling that to set the font. But I have to look into what the problem is. I have confirmed that "cmdwiz setfont" works both on my Win7, 64 bit and my Win 8.1, 32 bit machines. I don't have a Win10 machine to test on at the moment. Quite strange that it just stops working there. Also, the font code in cmdwiz is pretty much taken straight from bg's code (credited as such too), and uses the same API SetConsoleFont etc. So it's kind of strange. If you reach some insight into the problem I'd be happy to know.


aGerman wrote:I looks rather like the motion is a little too fast and is adjusted quite often. Because of the helical movement of the kaleidoscope it looks like it steps back before it moves forward again. But that might be an optical illusion. Most likely the rotation simply stops for some milliseconds.

Hmm... First I couldn't see this on my machine at all, but when I tried slowing the effect down quite a bit it was visible. This makes me suspect that the effect is running pretty slow on your machine. Might be something wrong with my time-interval measurements for microseconds. Could you try this: on line 125 in demo.bat, change cmdgfx "" knW12 into cmdgfx "" knW0 .

Does that make any impact when running? (to skip the possibly annoying initial dead screen effect, comment out the CALL to the :STATIC label)

aGerman
Expert
Posts: 3852
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Misol and Cari had a lovechild!

#9 Post by aGerman » 02 May 2017 17:30

I tried several values without noticeable improvement. knW9 seems to be the best but still not sure.

Steffen

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#10 Post by misol101 » 02 May 2017 18:08

Ok, so even W0 didn't make it faster? Or just not less fluttery? Just one more thing, to get an idea of how fast it's running on your machine, on line 124, could you remove the word "skip" and change !a! into !CNT! (so it looks like):

Code: Select all

start /B /High cmdgfx_gdi "!OUTP:~1,-1! & !MONS! & !FADE! &  text a 0 0 _!CNT!_ 1,1 & !TTEXT! & !TORUS!" f!FNT!:0,0,!W!,!H!

Then run (without intro effect) for, say, *approximately* 10 seconds and note how high the value is in the top left. On my Win 7 machine I get around 800, so my FPS is around 80. (that's with W12, if I run with W0 I get an FPS around 130)

aGerman
Expert
Posts: 3852
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Misol and Cari had a lovechild!

#11 Post by aGerman » 02 May 2017 18:36

Yeah that seems to be the culprit. Get ~35 FPS. I think it should be minimum 50 FPS to run smoothly.

Steffen

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#12 Post by misol101 » 02 May 2017 19:07

Ouch, that sucks... This thing won't look very good at all when it runs at less than half the speed it's supposed to... ! Wonder why, could it be Win 10 related? Do you have any antivirus software running? (some of them do a quick scan every time an executable is run).

(About the W flag, this is the (minimum) wait in milliseconds per frame. So W12 is 1000/12 = 83, which means the target frame rate for this effect is 83 FPS, which is approximately what I get.)

Could you try one more thing? The new version of cmdgfx allows running as a server, which takes away the startup overhead. Save this in the same folder as the demo as server.bat and run it. Does it perform better? (if not, how about with W0? As a final attempt, remove or comment out the line: cmdgfx "" knW9 completely. If that doesn't do the trick I don't know what will)

Code: Select all

@echo off
bg font 0 & cls & cmdwiz showcursor 0
if defined __ goto :START
set __=.
call %0 %* | cmdgfx_gdi "" Sf0:0,0,220,110
set __=
cls
bg font 6 & cmdwiz showcursor 1 & mode 80,50
goto :eof

:START
setlocal ENABLEDELAYEDEXPANSION
set /a W=220, H=110
mode %W%,%H%
for /F "Tokens=1 delims==" %%v in ('set') do if not %%v==H if not %%v==W set "%%v="

set /a XMID=%W%/2, YMID=%H%/2, DIST=7000, DRAWMODE=0, MODE=0
set /a CRX=0,CRY=0,CRZ=0
set ASPECT=0.6665

set /a S1=66, S2=12, S3=30
if "%~1" == "1" set /a S1=33, S2=24, S3=15
if "%~1" == "2" set /a S1=100, S2=8, S3=45
if "%~1" == "3" set /a S1=25, S2=30, S3=12

set FN=tri.obj
echo usemtl cmdblock 0 0 70 70 >%FN%
echo v  0 0 0 >>%FN%
echo v  0 100 0 >>%FN%
echo v  %S1% 100 0 >>%FN%
echo vt 0 0 >>%FN%
echo vt 0 1 >>%FN%
echo vt 1 1 >>%FN%
echo f 1/1/ 2/2/ 3/3/ >>%FN%

set /a A1=155, A2=0, A3=0, CNT=0
set /a TRANSP=0, TV=-1
set /a MONO=0 & set MONS=

set /a LIGHT=0, LTIME=990

set /a CS=0,CCNT=0,C0=8,C1=7,CDIV=6,CW=0 & set /a CEND=2*!CDIV! & set C2=f&set C3=f&set C4=f

set STOP=
:LOOP
for /L %%_ in (1,1,300) do if not defined STOP (

   set /a A1+=1, A2+=2, A3-=1, TRZ=!CRZ!
   if !MODE!==0 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t3.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 810,810,810,0,0,0 0,0,0,10 35,35,4000,%ASPECT% 1 0 db"
   if !MODE!==1 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t6.obj 5,!TV! !A1!,!A2!,!A3! 0,0,0 810,810,810,0,0,0 0,0,0,10 35,35,4000,%ASPECT% 1 0 db 9 0 db 2 0 db a 0 db 3 0 db b 0 db 4 0 db c 0 db 5 0 db d 0 db 6 0 db e 0 db"
   if !MODE!==2 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\spaceship.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 410,410,410,0,0,0 1,0,0,10 35,35,!DIST!,%ASPECT% 1 0 db"
   if !MODE!==3 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t-checkers.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 1810,1810,1810,0,0,0 0,0,0,10 35,35,!DIST!,%ASPECT% 0 0 db -1 -6 db 0 2 db 0 -8 db 0 -1 db"
   if !MODE!==4 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\hulk.obj %DRAWMODE%,-1 !A1!,!A2!,!A3! 0,0,0 210,210,210,0,-2,0 0,0,0,10 35,35,!DIST!,%ASPECT% 0 0 db"
   if !MODE!==5 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t3.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 1810,1810,1810,0,0,0 0,0,0,10 35,35,!DIST!,%ASPECT% 0 0 db -1 -6 db 0 2 db 0 -8 db 0 -1 db"
   if !MODE!==6 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t3.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 810,810,810,0,0,0 0,0,0,10 35,35,!DIST!,%ASPECT% 0 0 db -1 -6 db 0 2 db 0 -8 db 0 -1 db"
   if !MODE!==7 set OUTP="fbox 7 0 20 0,0,%W%,%H% & 3d objects\cube-t3.obj 6,!TV! !A1!,!A2!,!A3! 0,0,0 810,810,810,0,0,0 0,0,0,10 35,35,!DIST!,%ASPECT% 1 0 db"

   for /L %%1 in (1,1,%S2%) do set OUTP="!OUTP:~1,-1! & 3d %FN% 1,-1 0,0,!TRZ! 0,0,0 20,20,20,0,0,0 0,0,0,10 %XMID%,%YMID%,7000,%ASPECT% 0 0 db & 3d %FN% %DRAWMODE%,-1 0,0,!TRZ! 0,0,0 20,20,20,0,0,0 0,0,0,10 %XMID%,%YMID%,7000,%ASPECT% 0 0 db"&set /A TRZ+=%S3%*4
   
   echo "cmdgfx: !OUTP:~1,-1! & !MONS! & !FADE! & text 7 0 0 SPACE_ENTER 103,108" F
   cmdgfx "" knW9
   set KEY=!ERRORLEVEL!

   set /a CRZ+=3, CNT+=1

   if !CS! gtr 0 (
      set /a CP=!CCNT!/%CDIV%,CCP=!CCNT!/%CDIV%+2 & for %%a in (!CP!) do for %%b in (!CCP!) do set FADE=block 0 0,0,%W%,%H% 0,0 -1 0 0 ????=!C%%b!!C%%a!??
      if !CS!==2 set /a CCNT-=1&if !CCNT! lss 0 set /a CS=0&set FADE=
      if !CS!==1 set /a CCNT+=1&if !CCNT! gtr %CEND% set /a CCNT=%CEND%,CW+=1
      if !CW! gtr 35 set /a CW=0,CS=2,KEY=32
   )
   
   if !LIGHT! == 1 for /F "tokens=1-8 delims=:.," %%a in ("!t1!:!time: =0!") do set /a "a=((((1%%e-1%%a)*60)+1%%f-1%%b)*6000+1%%g%%h-1%%c%%d)*10,a+=(a>>31)&8640000" & if !a! geq %LTIME% set /a KEY=109 & set t1=!time: =0!
   if !KEY! == 115 set /A LIGHT=1-!LIGHT! & if !LIGHT! == 1 set /a KEY=109 & set t1=!time: =0!
   
   if !CNT! gtr 1307 set /a A3+=1
   if !CNT! gtr 1400 set /a CNT=0
   if !KEY! == 112 cmdwiz getch
   if !KEY! == 102 if !CS!==0 set /a CS=1,CCNT=0
   if !KEY! == 100 set /A DIST+=50
   if !KEY! == 68 set /A DIST-=50
   if !KEY! == 13 set /A TRANSP=1-!TRANSP!&(if !TRANSP!==1 set /a TV=20)&(if !TRANSP!==0 set /a TV=-1)
   if !KEY! == 109 set /A MONO=1-!MONO!&(if !MONO!==1 set MONS=block 0 0,0,%W%,%H% 0,0 -1 0 0 ????=fe??)&(if !MONO!==0 set MONS=)
   if !KEY! == 32 set /A MODE+=1&if !MODE! gtr 7 set MODE=0
   if !KEY! == 27 set STOP=1
)
if not defined STOP goto LOOP

endlocal
del /Q tri.obj
echo "cmdgfx: quit"
Last edited by misol101 on 03 May 2017 03:20, edited 1 time in total.

ShadowThief
Expert
Posts: 929
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Misol and Cari had a lovechild!

#13 Post by ShadowThief » 02 May 2017 21:09

I'm running it on Windows 10 Pro 64-bit and it looks fine, minus the flickering that I assume comes from a low refresh rate.

misol101
Posts: 408
Joined: 02 May 2016 18:20

Re: Misol and Cari had a lovechild!

#14 Post by misol101 » 03 May 2017 01:57

ShadowThief wrote:I'm running it on Windows 10 Pro 64-bit and it looks fine, minus the flickering that I assume comes from a low refresh rate.

Crap, so it's a thing then. (I'm assuming you cannot all have low-end machines much worse than my 5 year old Windows 7 machine :) So it's somehow related to the Windows version.)

Could you try running the code I posted for aGerman above? (see instructions in the text)

ShadowThief
Expert
Posts: 929
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Misol and Cari had a lovechild!

#15 Post by ShadowThief » 03 May 2017 11:54

So server.bat doesn't have the flicker (and looking at it again, it's less of a flicker and more of a strobe effect that in retrospect may have been deliberate), but it does jitter like aGerman was mentioning until I comment out the cmdgfx line.

demo.bat: flickers but doesn't jitter
server.bat: jitters but doesn't flicker

Post Reply