LORDKG 1.3 - registration codes for LORD 4.06 and LORD 4.07 / 4.08 Beta
=======================================================================

LORDKG makes the five registration codes that LORDCFG asks for when you
register Legend of the Red Dragon.  One program covers both kinds of LORD
registration, and you choose which one when you run it:

  LORD 4.06            The five codes don't depend on any name.  LORDKG
                       makes a random set that LORDCFG accepts.
  LORD 4.07 / 4.08     The codes depend on the sysop name and the BBS name.
                       (The 2009 patch shows itself as "4.08 Beta".)

Gameport, which sold LORD registrations, has been unreachable for many
years, and Michael Preslar, the LORD 4.07 author, has not been able to
contact them either.  No one has been able to buy a registration code for
more than ten years, so a sysop running LORD today has no other way to
register it.  LORDKG makes that possible.

The package has three versions that work the same way:

  LORDKG.EXE    DOS (runs on any PC from an 8086 up, DOSBox, dosemu,
                FreeDOS, or a DOS window under 32-bit Windows)
  LORDKG.PY     Python 3, for Linux, Windows and macOS
  sbbs/         A sysop-only door for Synchronet BBS, so you can make
                codes while logged on to your board (see THE SYNCHRONET
                DOOR below)

USING IT
--------
Run it with no parameters and it asks which LORD version the key is for:

    C:\LORD> LORDKG
    LORDKG 1.3 - registration codes for LORD 4.06 and 4.07 / 4.08 Beta

     Which LORD version is the key for?
       1) LORD 4.06
       2) LORD 4.07 / 4.08 Beta
     Choice (1 or 2) ->

Choose 2 for LORD 4.07 and it asks for the two names:

     Choice (1 or 2) -> 2

    Type both names exactly as you will enter them in LORDCFG.

     Sysop name -> Seth Able
     BBS name   -> The Red Dragon BBS

     LORD version -> 4.07 / 4.08 Beta
     Sysop name   -> Seth Able
     BBS name     -> The Red Dragon BBS
    -=-=-=-=-=-=-=-=-=-=-
     Regcode #1 -> 48302
     Regcode #2 -> 60389
     Regcode #3 -> 1187
     Regcode #4 -> 6944
     Regcode #5 -> 1480
    -=-=-=-=-=-=-=-=-=-=-

Choose 1 for LORD 4.06 and it prints a set of codes straight away (the
numbers are different every time):

     Choice (1 or 2) -> 1

     LORD version -> 4.06
    -=-=-=-=-=-=-=-=-=-=-
     Regcode #1 -> 1798
     Regcode #2 -> 5025
     Regcode #3 -> 9377
     Regcode #4 -> 6052
     Regcode #5 -> 19255
    -=-=-=-=-=-=-=-=-=-=-
     Codes 1-4 are random.  Any set works when #5 = #1 + #2 + #3 + #4/2 + 29.
     LORD 4.06 does not use the sysop or BBS name for these codes.

COMMAND LINE
------------
The version can also be chosen with a switch, which is handy in batch
files and BBS menus:

    LORDKG /406                       random LORD 4.06 codes
    LORDKG /406 1000 0 0 0            LORD 4.06 with your own first four
                                      numbers: LORDKG works out the fifth
    LORDKG /407 "Seth Able" "The Red Dragon BBS"
                                      LORD 4.07 codes
    LORDKG /407 /U Seth_Able The_Red_Dragon_BBS
                                      the same, with _ for each space, for
                                      shells and menus that can't pass quotes
    LORDKG "Seth Able" "The Red Dragon BBS"
                                      two names and no switch mean LORD 4.07,
                                      as in LORDKG 1.0
    LORDKG /?                         a short help screen

The Python version takes the same parameters:

    python3 lordkg.py /406
    python3 lordkg.py /407 "Seth Able" "The Red Dragon BBS"

THE SYNCHRONET DOOR
-------------------
The sbbs folder has LORDKG as a JavaScript door for Synchronet BBS.  It was
tested on Synchronet 3.21 for Linux, and uses only Synchronet's standard
JavaScript, so it should work the same on Windows.  It shows the same menu
as LORDKG.EXE:

     Which LORD version is the key for?

       1) LORD 4.06
       2) LORD 4.07 / 4.08 Beta
       Q) Quit

Choose 1 for a random LORD 4.06 set, or 2 and type the sysop name and BBS
name for LORD 4.07 (leave a name blank to go back).  Each set of codes is
shown with a reminder of where to type it in LORDCFG.

The door is a sysop tool.  Make it sysop-only, so callers never see it.

Installing it:

1. Make a folder xtrn/lordkg in your Synchronet directory, for example
   /sbbs/xtrn/lordkg or C:\SBBS\XTRN\LORDKG, and copy the two files from
   the sbbs folder into it:

       lordkg.js     the door
       lordkglb.js   the code calculations (the same as LORDKG.PY)

   Keep the names in lower case: Synchronet on Linux looks for exactly
   these names.

2. Run SCFG, choose External Programs, then Online Programs (Doors), pick
   the section for sysop tools (the stock Operator section is already
   sysop-only) and add a program:

       Name                     LORDKG - LORD Registration Codes
       Internal Code            LORDKG
       Start-up Directory       ../xtrn/lordkg
       Command Line             ?lordkg.js
       Access Requirements      SYSOP
       Execution Requirements   SYSOP

   Leave the other settings as they are.  The ? at the start of the
   command line tells Synchronet that it is a JavaScript module.

   If you edit ctrl/xtrn.ini by hand instead, the entry looks like this
   (OPERATOR is the section's internal code):

       [prog:OPERATOR:LORDKG]
               name=LORDKG - LORD Registration Codes
               ars=SYSOP
               execution_ars=SYSOP
               cmd=?lordkg.js
               startup_dir=../xtrn/lordkg

3. Save and exit SCFG.  Synchronet loads the change the next time a node
   is free.  Log on as a sysop and find LORDKG under External Programs.

REGISTERING LORD 4.07 / 4.08 BETA
---------------------------------
1. Run LORDKG, choose 2, and type your sysop name and BBS name.
2. Run LORDCFG.EXE in your LORD directory and choose to enter the
   registration information.
3. Type the sysop name and BBS name EXACTLY as you gave them to LORDKG,
   then the five codes.
4. LORD's title screen now says REGISTERED!

The names must match character for character.  Capitals and spaces
change the codes: "Seth Able" and "SETH ABLE" get different codes.
Names can be up to 30 characters long; LORDKG ignores anything past that.

REGISTERING LORD 4.06
---------------------
1. Run LORDKG and choose 1 (or run LORDKG /406).
2. Run LORDCFG.EXE in your LORD directory, choose Register Lord, then
   Enter registration codes, and type the five numbers.
3. LORDCFG says "THE GAME IS NOW REGISTERED!".  Quit and save.

LORD 4.06 asks for no names, and the five numbers aren't tied to your
board: any set that passes the check works.  LORDKG picks a random set so
that different boards don't all use the same code.

HOW THE CODES ARE WORKED OUT
----------------------------
LORD 4.06
  LORDCFG.EXE 4.06 only checks that the five numbers fit together:

      Code 5 = Code 1 + Code 2 + Code 3 + (Code 4 / 2) + 29

  Code 4 counts at half its value, rounded down: 6052 counts as 3026,
  and 7777 as 3888.  Codes 1 to 4 must each be from 0 to 10000, and
  code 5 must be at least 1000.  This was read from the checking code in
  LORDCFG.EXE 4.06 itself, and LORD.EXE 4.06 checks the codes again in
  exactly the same way each time it starts.  LORDKG's random
  codes 1-4 are each from 1000 to 9999, which always passes.

LORD 4.07 / 4.08 Beta
  This is the same calculation as the Windows program lord47kg.exe
  (author unknown), worked out from its machine code.  Both names are
  first padded to 10 characters with A, B, C ... if they are shorter.

  Code 1  Sum of the sysop name's characters.  Every second character
          counts 256 times its value.  Kept to 16 bits (0-65535).
  Code 2  The same, for the BBS name.
  Code 3  Characters taken in turn from the sysop name (1st, 3rd, 5th ...)
          and the BBS name (2nd, 4th, 6th ...), added up.  The shorter
          name is padded with the bytes 0, 1, 2 ... to the longer length.
  Code 4  Half of each sysop name character (rounded down), added up, then
          doubled once for each space or capital letter A-Z in the padded
          name, at most 4 times (x16).
  Code 5  Half of each BBS name character (rounded down), added up, kept to
          16 bits, then doubled.

lordkg.py has the same steps as plain Python functions.

FILES
-----
  LORDKG.EXE    DOS program
  LORDKG.PY     Python 3 program (no extra modules needed)
  LORDKG.PAS    Free Pascal source of LORDKG.EXE
  sbbs/lordkg.js     Synchronet door (sysop only)
  sbbs/lordkglb.js   The door's code calculations
  LORDKG.TXT    This file
  FILE_ID.DIZ   File description
  COPYING       GNU General Public License version 2

BUILDING LORDKG.EXE
-------------------
LORDKG.EXE is built with the Free Pascal 3.2.2 i8086 cross compiler for the
msdos target:

    ppcross8086 -Tmsdos -WmLarge -O2 -XX -Xs LORDKG.PAS

The same source also builds with ordinary Free Pascal for Linux or Windows:

    fpc -O2 LORDKG.PAS

The Python and Pascal versions were checked against each other on 4,913
random and edge-case name pairs, and the DOS build in DOSBox, with the
same results.  The Synchronet door's code calculations were checked
against the Python version on 3,001 name pairs.  They also give the sample codes shipped with lord47kg.exe
(sysop / bbs: 45788 29601 846 7216 782).  Every LORD 4.06 set they make
is checked against the rule above.

LICENCE
-------
LORDKG is Copyright (C) 2026 Michael Slater.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.  See COPYING.

Legend of the Red Dragon is by Seth Robinson (versions up to 4.06) and
Michael Preslar (4.07).  LORDKG is not connected with Gameport or with the
authors of LORD.

CONTACT
-------
Kalgoorlie Retro Gaming - https://retro.theiguru.au/
Kalgoorlie Retro BBS - telnet bbs.theiguru.au
slaterm@theiguru.au

HISTORY
-------
1.3  2026-11-09  FIX: LORD 4.06 codes from 1.1 and 1.2 were wrong.  LORD
                 4.06 counts code 4 at half its value, and LORDKG added all
                 of it, so the fifth code was too high and LORDCFG refused
                 it.  If you used LORDKG 1.1 or 1.2 for LORD 4.06, make a
                 new set.  LORD 4.07 codes were right and are unchanged.
1.2  2026-11-08  A sysop-only Synchronet door (sbbs folder), with the same
                 menu.  The DOS and Python programs are unchanged.
1.1  2026-11-08  LORD 4.06 codes as well as 4.07.  The program asks which
                 LORD version the key is for; /406 and /407 choose it on the
                 command line.  /406 can take your own first four numbers.
1.0  2026-11-08  First release: LORD 4.07 / 4.08 Beta codes, DOS and
                 Python versions.
