Minecraft textures on dos batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
einstein1969
Expert
Posts: 961
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Minecraft textures on dos batch

#1 Post by einstein1969 » 27 Apr 2016 07:07

Hi,
I have partial ported this work.
These are textures of notch's minexcraft on dos batch window.

results:
ImageImage

notch_minecraft_textures.cmd:

Code: Select all

:::::::::::::::::::::::::::::::::::::::::::::::::::
:: Porting of Notch's minecraft4kjs by einstein1969
:: Ref.:
:: http://jsdo.it/notch/dB1E
:: http://jsdo.it/nishink/go6q
:: the8bitpimp.wordpress.com C++ port of Minecraft 4k JS
:: colorsRGB.cmd
:: http://postimg.org/image/t1hh3kppt/
:: http://s32.postimg.org/6csa408c5/minecraft_textures.png
:: http://postimg.org/image/9q62ur1o1/
:: http://s32.postimg.org/uaawt8hf9/minecraft_textures_2.png
:::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal EnableDelayedExpansion

mode 100,200
chcp 437

if "%1"=="" (
   call :init_screen %1
   start "minecraft_textures" /max "%ComSpec%" /c "%~f0" 1&goto:eof
) else call :init_screen %1

pushd %tmp%

call :init_colors

call :init_textures

pause

popd

exit /b
:::::::::::::::::::::::::::::::::::::::::::::::::::


:::::::::::::::::::::::::::::::::::::::::::::::::::
:init_screen
if "%1"=="" (
  echo Use Lucida console font 5
  echo Disable ClearType
  echo Enable "Smooth Edges of Screen Fonts"
  ping -n 5 localhost >nul
  for %%a in (  FontSize:00050000
                FontFamily:00000036
                WindowSize:003c005a
                ScreenColors:0000000f
                CodePage:000001b5
                ScreenBufferSize:003c005a
                FontWeight:00000190
  ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
    >nul reg add HKCU\Console\minecraft_textures /v %%b /t reg_dword /d 0x%%c /f
  )
  >nul reg add HKCU\Console\minecraft_textures /v FaceName /t reg_sz /d "Lucida Console" /f
) else ( >nul reg delete HKCU\Console\minecraft_textures /f )
exit/b
:::::::::::::::::::::::::::::::::::::::::::::::::::



:::::::::::::::::::::::::::::::::::::::::::::::::::
:init_colors
:: prepare for color function
  for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
    set "DEL=%%a"
  )
  <nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"
  <nul > X set /p ".=."
  for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"


:: Set the 16 color standard palette
  set /a i=0
  for %%c in (   000000 000080 008000 008080 800000 800080 808000 C0C0C0
      808080 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )

  :: gamma 2.2
  set /a i=0
  for %%c in (   000000 000037 003700 003737 370000 370037 373700 898989
      373737 0000FF 00FF00 00FFFF FF0000 FF00FF FFFF00 FFFFFF) do (
      set p16[!i!]=%%c
      set /a i=i+1
  )


:: Calculate all colors

  set "map=0123456789ABCDEF"

  set cont=-1
  For /L %%i in (0,1,15) do (

   set /a bg=%%i, fg=%%i
   for %%D in (!bg!) do (set bg=!map:~%%D,1!)
        for %%D in (!fg!) do (set fg=!map:~%%D,1!)

   set /a "rgb=0x!p16[%%i]!, rri=rgb >> 16, ggi=(rgb >> 8) & 0xFF, bbi=rgb & 0xFF"

   set /a cont+=1

   set "pRGB!cont!=!p16[%%i]!"

   set "z!cont!=!bg!!fg! !"

   set /a si=%%i+1
      For /L %%j in (!si!,1,15) do (

      set fg=%%j
           for %%D in (!fg!) do (set fg=!map:~%%D,1!)

      set /a "rgb=0x!p16[%%j]!, rrj=rgb >> 16, ggj=(rgb >> 8) & 0xFF, bbj=rgb & 0xFF"

      set /a cont+=1
             set /a "pR=(ddr=rrj-rri)/4+rri, pG=(ddg=ggj-ggi)/4+ggi, pB=(ddb=bbj-bbi)/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!°"
   
           set /a cont+=1
           Set /a "pR=ddr/2+rri, pG=ddg/2+ggi, pB=ddb/2+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!±"

      set /a cont+=1
      Set /a "pR=ddr*3/4+rri, pG=ddg*3/4+ggi, pB=ddb*3/4+bbi"
      call :RGBHex
      set "z!cont!=!bg!!fg!²"

   )
  )

  set pal16_4.size=!cont!

  for /L %%i in (0,1,15) do set "p16[%%i]="

exit/b
:::::::::::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::
:RGBhex

set /a "d=pR&15,pR>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pR!) do set "HH=!map:~%%D,1!"

set pRGB=!HH!!LH!

set /a "d=pG&15,pG>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pG!) do set "HH=!map:~%%D,1!"

set pRGB=!pRGB!!HH!!LH!

set /a "d=pB&15,pB>>=4"
for %%D in (!d!) do set "LH=!map:~%%D,1!"
for %%D in (!pB!) do set "HH=!map:~%%D,1!"

set pRGB!cont!=!pRGB!!HH!!LH!

exit/b

:::::::::::::::::::::::::::::::::::::::::::

:::::::::::::::::::::::::::::::::::::::::::
:plot R G B
  set /a "AArt=%1, AAgt=%2, AAbt=%3"
  set /a dm=256*256*256, fg=-1, bg=-1, ind=-1

  For /L %%i in (0,1,!pal16_4.size!) do (

   set /a "AAArgb=0x!pRGB%%i!, d=(AArt-(AAArgb >> 16))*(AArt-(AAArgb >> 16))+(AAgt-((AAArgb >> 8) & 0xFF))*(AAgt-((AAArgb >> 8) & 0xFF))+(AAbt-(AAArgb & 0xFF))*(AAbt-(AAArgb & 0xFF))"

   if !dm! gtr !d! set /a dm=d, ind=%%i
  )

  for %%i in (!ind!) do (
   set bg=!z%%i:~0,1!
   set fg=!z%%i:~1,1!
   set "char=!z%%i:~2,1!"
  )

  rem Fast color
  > colorPrint.txt (echo !char!\..\') && findstr /a:!bg!!fg! /f:colorPrint.txt "."

exit/b
:::::::::::::::::::::::::::::::::::::::::::::::::::


:::::::::::::::::::::::::::::::::::::::::::::::::::
:init_textures

  rem Each texture
  rem For /L %%i in (1,1,16) do (
  For /L %%i in (4,1,9) do (

    rem random set the brightness
    set /A "br= 255 - ((!random! %% 96) | 0)"

    rem each pixel in the texture
    set /A ymax=16*3
    for /L %%y in (0,1,!ymax!) do (
      title Generate Textures: %%i/16 %%y/!ymax!
      for /L %%x in (0,1,16) do (

          rem earth block basic colors
          set /a Color = 0x966C4A

          rem stone block basic colors
          if %%i equ 4 set /a color = 0x7F7F7F

          set /a "q1=(!random! %% 3) | 0"
          if %%i neq 4 set /a "br = 255 - ((!random! %% 96) | 0)"
          if !q1! equ 0 set /a "br = 255 - ((!random! %% 96) | 0)"
          set /a "q1=(((%%x * %%x * 3 + %%x * 81) >> 2) & 3) + 18"
          set /a "q2=(((%%x * %%x * 3 + %%x * 81) >> 2) & 3) + 19"
          if %%i equ 1 (
            if %%y lss !q1! (
                rem grass block basic colors
                set /a color=0x6AAA40
            ) else if %%y lss !q2! set /a br=br*2/3 & rem grass and soil to a little darker in the boundary
          )
          if %%i equ 7 (
             rem raw wood block basic color of the (side)
             set /a color = 0x675231
             if %%y gtr 0 if %%y lss 15 (set i1=1) else set i1=0
             if %%y gtr 32 if %%y lss 47 (set i2=1) else set i2=0
             set /a "i1=i1|i2"
             if %%x gtr 0 if %%x lss 15 if !i1! equ 1 (
                rem raw wood block basic colors (tree rings)
                set /a color = 0xBC9862
                set /a "xd=%%x - 7, yd=(%%y & 15) - 7"
                if !xd! lss 0 set /a xd=1-xd
                if !yd! lss 0 set /a yd=1-yd
                if !yd! gtr !xd! set /a xd=yd
                set /a "br = 196 - ((!random! %% 32) | 0) + xd %% 3 * 32"
             ) else (
               set /a "q1=(!random! %% 2 )|0"
               if !q1! equ 0 set /a "br=br*(150-(%%x & 1)*100)/100"
             )
          )
          if %%i equ 5 (
            rem brick block basic colors
            set /a color = 0xB53A15
            set /a "q1=(%%x + (%%y >> 2) * 4)%% 8"
            set /a "q2=%%y %% 4"
            if !q1! equ 0 set /a color = 0xBCAFA5
            if !q2! equ 0 set /a color = 0xBCAFA5
          )
          rem water block basic colors
          if %%i equ 9 set /a color = 0x4040ff
          set /a brr=br
          if %%y geq 32 set /a brr/=2 & rem bottom is dark
          if %%i equ 8 (
             rem leaves block the basic color
             set /a color = 0x50D937
             rem where there is no leaf is in black (transmission at the time of the drawing)
             set /a "q1=((!random! %% 2)|0)"
             if !q1! equ 0 set /a color=0, brr=255
          )
          set /a "col=((( color >> 16) & 0xff) * brr / 255) << 16 | (((color >> 8) & 0xff) * brr / 255) << 8 | (((color) & 0xff) * brr / 255)"
          rem echo brr:!brr! - Color:!color! - Col:!col!
          set /a q1=%%x+%%y*16+%%i*256*3
          set textmap[!q1!]=!col!
          rem title Generate Textures: index:!q1! col:!col! %%i/16 %%y/!ymax! %%x/16

          rem from textures.txt
          rem (col >> 16) & 0xFF, (col >> 8) & 0xFF, col & 0xFF
          set /A "R=(col >> 16) & 0xFF, G=(col >> 8) & 0xFF, B=col & 0xFF "

          call :plot !R! !G! !B!

      )
      rem Flush for speedup SET
      for /L %%x in (0,1,16) do (
          set /a q1=%%x+%%y*16+%%i*256*3
          set textmap[!q1!]=
      )
      echo(
    )
    echo Next type
  )

exit/b
:::::::::::::::::::::::::::::::::::::::::::::::::::


einstein1969

jeb
Expert
Posts: 1057
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Minecraft textures on dos batch

#2 Post by jeb » 27 Apr 2016 07:35

Your work on batch graphics is really incredible :shock:

einstein1969
Expert
Posts: 961
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Minecraft textures on dos batch

#3 Post by einstein1969 » 27 Apr 2016 07:44

thanks jeb :)

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Minecraft textures on dos batch

#4 Post by npocmaka_ » 27 Apr 2016 08:49

Great!

Btw. weren't you in academic career :?:
Just wondered is it possible/are you intending to publish a paper based on work with the cmd?

einstein1969
Expert
Posts: 961
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Minecraft textures on dos batch

#5 Post by einstein1969 » 27 Apr 2016 09:19

npocmaka_ wrote:Btw. weren't you in academic career :?:
Just wondered is it possible/are you intending to publish a paper based on work with the cmd?


I do not understand what you mean. However, it is a tribute to dos batch before powershell replace it altogether. :(

Squashman
Expert
Posts: 4487
Joined: 23 Dec 2011 13:59

Re: Minecraft textures on dos batch

#6 Post by Squashman » 27 Apr 2016 14:04

einstein1969 wrote:I do not understand what you mean. However, it is a tribute to dos batch before powershell replace it altogether. :(

Maybe. But I doubt it. Why get rid of it? It is not hurting MS to keep it in the operating system.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Minecraft textures on dos batch

#7 Post by foxidrive » 05 May 2016 10:56

jeb wrote:Your work on batch graphics is really incredible :shock:


I agree, it's wonderful stuff.

Post Reply