Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What language is this old program written in?

"Hi, could you rewrite something for me", my boss said, "some legacy code". Yeah, legacy code written somewhere in early Mesozoic.

I have 30 hours left, and I still don't know, what kind of syntax is this! VHLD? VBA? Program is dedicated do to something with audio files, and dedicated to run under DOS.

Could you give me a hint what is this? How to compile it?

Code snippet:

enter \ Load - main screen
empty  forth definitions  decimal
application  warning on

: TITLE ." KCS version 0.8  28-Jan-06" cr ;

cr .( Compiling: )  title  2 load

 cr .( Save to disk? )  y/n
[if]
\  pad reserve @ + 256 + limit s0 @ - + set-limit
  turnkey program  KCS
[then]



\ Load - defaults
 variable RESERVE  0 reserve !       \ reserved memory tally
 defer ?BREAK  ' noop is ?break      \ break check off
 defer SET-IO  ' bios-io is set-io   \ default console mode
 defer ERRFIX  ' noop is errfix      \ reset on-error handler

 blk @ 1+ #screens 1- thru       \ load electives & application

 ' (?break) is ?break           \ enable user break
\ ' dos-io is set-io             \ enable console redirection
\ ' deloutfile +is errfix        \ delete outfile on error
\ wrtchk off                     \ disable overwrite check




\ Load - electives
  1 fload DOSLIB     \ load DOSLIB library

 _Errors            \ error handler
 _Inout1            \ number output
 _Inout2            \ string & number input
 _String1           \ basic strings
\ _String2           \ extra strings
 _Parsing           \ command-line parsing
 _Fileprims         \ file primitives
 _Files             \ default files
 _Bufinfile         \ buffered input file
 _Bufoutfile        \ buffered output file


\ DECODE
\ Convert wave file to program
: DECODE  ( -- )
  0. decodecount 2!  0. paritycount 2!  0 errors !
  skipheader
  begin
    ['] decodebyte  1 ?catch 0=
   while ( not EOF )


 conout @ if  emit  else  writechar  then
    1 decodecount m+!
  repeat
  .decoded ;




\ SETMODE
\ Select Kansas City Standard or Processor Tech. CUTS mode
: SETMODE  ( -- )
  mode @ if ( CUTS )
    8 to databits  2 sbits !  4 speed !  parity off  pace off
    nullcnt off
    ['] 0bit-sqr-cuts is 0bit-sqr  ['] 1bit-sqr-cuts is 1bit-sqr
    ['] 0bit-sin-cuts is 0bit-sin  ['] 1bit-sin-cuts is 1bit-sin
    ['] seekstart-cuts is seekstart  ['] getbit-cuts is getbit
  else ( KCS )
    ['] 0bit-sqr-kcs is 0bit-sqr  ['] 1bit-sqr-kcs is 1bit-sqr
    ['] 0bit-sin-kcs is 0bit-sin  ['] 1bit-sin-kcs is 1bit-sin
    ['] seekstart-kcs is seekstart  ['] getbit-kcs is getbit
  then ;


\ (RUN)
\ Run application
: (RUN)  ( -- )
  setmode
  r/o openinfile
  decoding @ if
    conout @ 0= if  r/w makeoutfile  then
    cr decode
  else
    r/w makeoutfile
    cr encode
  then
  closefiles
  ;


\ DEFAULTS
\ Set application defaults
: DEFAULTS  ( -- )
  mode off  decoding on  strict off  ignore off  conout off
  1 speed !  2 sbits !  parity off  5 leadtime !  10 nullchar !
  pace off  nullcnt off  wave off  tone off  inverted off ;

defaults








\ RUN PROGRAM
\ Run application with error handling
: RUN  ( -- )
  ['] (run) catch ?dup if  >r errfix r> throw  then ;

\ Main
: PROGRAM  ( -- )
  set-io                \ set console mode
  defaults              \ set defaults
  cr title              \ show application name
  parsecmd              \ get options/filenames
  run                   \ run application
  cr ." done"           \ show success
  ;
like image 833
Rajju Avatar asked Dec 16 '25 12:12

Rajju


1 Answers

It's written in Forth, probably the DX-Forth dialect. The program decodes and encodes WAVE files that contain data in the Kansas City standard format. This format was used to record data on cassette tapes on early S-100 CP/M machines. Searching the web reveals that there was a program written in DX-Forth that could decode and encode WAVE files in this format, so I'm guessing it's the program you've be tasked with rewriting.

Rather than rewriting this code however, a simpler thing to do would be to use existing free software that already does the job. For example there's a program called py-kcs written in Python that should be a functional replacement and one called hx-kcs written in Haxe that can do decoding.

like image 72
Ross Ridge Avatar answered Dec 19 '25 06:12

Ross Ridge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!