 ▄▄▄▄▄▄▄▄                                            ░                  ▄▄▄▄▄▄  
 █ ▄▄▄▄ ▓░    ░░▓▓▄▄▄▄▄▄    ░    ░          ▄▄▒▒   ░▄▓▀ ░░ ▄      ▄    ▄▀ ░░ █  
 █ ████  ▄▄▄▄   ▀▀ ▄▄▄ ▀▄   ▓    ▓ ▀▀▀▀▀▓▄▄▄▄ ▀▓▄░▒▓▀ ▄▄▓▓  █▄ ▄█▀   ▄▀ ▄▄▓▓ █  
 █ ████▄▄▄▄▄▄▀▄  ▄▀▄██▓▄ ▀▄  ▀▄  █ ▒▒▒ ▄▀▄████▄░▀▓▀ ▄█████   ██▀    ▀ ▄█████ █░ 
 █ ████████████ ▀▄███████▄ ▀▄  ▀▄█ ███▀▄█████████ ▄███████ ▄█▀▀█▄   ▄███████ ▀▓ 
▄▀▄████▒▒▀█████ ▓█████████▓▄ ▀▄    ▐█████  ▀▀▓███▄███▀████▀  ░░░▀▄ ▄████████░ █ 
 ▐█████   ▀████░████▓ ▀▓█████▄ ▀▄  ▐█████    ░▀█████ █████▄██▓▓▓   ██▓  ████▓ ▓ 
 ██████   ░████▓████░  ░██████▓▄ ▀▄ █████      ████  ██████████▌  ▄██░ ██████ ░ 
 ██████▄▄▄▓█████████     ▓███████▄ ▀█████▌  ░ ▐███   ██▀▀▀▀████▌ ░██▌  ▓▓▓▀▀▀   
 ▓▓▓▓▓██████████████▄█▓▀ ░███▀█████▄ █████▄█▓▀▐███░  ▀▀▀▀▀ ████▌ ▓██▌  ▒▒▒▀▀▀░░ 
 ░░░░░▀▀▀▀▀▀█████████▀░    ██▓ ▀███████████▀ ▄ ███▓▄▄▄▄▄   █████ ▐███▄▄  ▄███▓▓ 
           ░███▓██▌▀    ░░████▓  ▀▓█████▌▀ ▄▀  ▀██████████▄▓████  ▓████████████ 
   ▒▒▒▒▒  ░▓███░███▌  ░░▓▓█████░ ▀▄▀█████▌   ▄▄▄▄   ▀▀█████░████▌ ░  ▀▀▀█████   
   █████  ▓███▀ ███▌ ▄▓▓███████▓   ▀▄▀▓██▌ ▄█████    ▄████▀  ████░  ▄▀ ▄████▀█  
   ▀████  ███▀  ███▄▓████▀██ ███    ▓█▄██▄██████▀ ░▄█████▓ █  ███▓ ▀ ▄▓█████ ▓  
 ▄█ ████▒▒██▀▄▀ ███████▀▄▀██ ███    ░████▓▓███▀  ▄▓█████▀▄▀  ▄ ███ ▄██████▀▄▀░  
  █ ███████▓▀   ▓▓▓▀▀▄▄▀  ▓▓ ▀▓▓     ▀▀▀▀░░██████████▓▓▒▒    █ ████████▓▀▄▀     
  █ ██████▀░    ░░░       ░░  ░░     ▄██▀  ▀▀▓▓█████▀░░      ▀▀▀▀▀▀▀▀▒▒░▓  ▄▀   
  █ ▓▓▀▀                               ▄     ░░              ▄▄███▀     ▒    ▄  
░ █▄▄▄▓▓  G E N E S I S  P R O J E C T - C64 Scene MOD of CGterm        ░     ■ 
▓▄▄   ░░ ■■                                                  ■■■                
▀        New elite version of the classic BBS terminal CGTerm           ░       
■      ░ released by MagerValp. Many improvements making your           ▒       
       ▒ BBS experience sexier than all the spice girls morphed
         into one ultra sexy spice girl!                            ▀▄▄▀▓       
 ▄▄▄▄▌ ▓                                                            ▄▀▄▀▓       
 █░░ ▀▄█▀▀▀▀▀▀▀▀▀▀▀▓▓▀▀█▀▀▀▀▀▀▀█▀▀▀█▀▀▀█▀▀▀▀█████▀▀▌▀▀▀▀▀▀▀▀▀▀█▀▀▀▀▀▀▀▀▀▀       
 █▓▓▄▄ ▀▓▄▄■ ▄▄█▓▓▄▄ ▀▄▓  ▄▄▄▄  ▀▄  █▄▄▄▀▀▀▀      ▄▄▄▄▄ ▀▄■   █ ▄▄▄▄▄▄   ▄ ▀    
░██████▄ ▀ ▄█████████▄  ▄██████▄  ▀▀▀    ▄▄▄████ ████▓▄ ▀  ▀▀▀▀ ████ ██▌▄▌      
▓▀██████▄█████▀▀▀██████▄████████▄░░▄▄▄█████████▄████████▄ ▄▄████████ ████▓▓▄▄░░ 
█ ████████████    ▀▓███████▀▓████▓▓██▓▓███▀▀   ▓██▀▀████████████████ ████████▓▓ 
▓ ████  ▀█████░    ░▀█████▀ ░▓████▀▀▀ ░███   ░████    ▀████▓▓   ████ █  ▀▀█████ 
░ █████  ▐████▓      █████    ▓███▓    ▀███  ▓████   ░█████░░   ████ █   ████▀▀ 
  ▀▀▀▀█   █▓▓██▄ ▒▒▒▒███▀▓    ░████     ▀███ █████   ▓███▓      ████ █  ████    
░░▀▀▀▀▀  ▐███████████████▄     ▒███      ▀████████▄█▓▀███░      ▒▒▒▒ █ ███▓     
▓▓██▄  ▄▄███  █████▀▀██████▄   ░███▌ ░░   ▀█████████▀░███       ▄▄▄▄▄█████░  ░░ 
███████████▓ ▓▀████ ▄ ▀█████▀▄▀▄███▌█▓▓▄   ▀█████▌▀  ▄▀▄█   ■▄       ████▓   ▒▒ 
  ████▀▀▀  ░ ▒ ████▄ ▀  ▀██▄▀ ▄███████████▄▄██▓███▌▄▀ ▄██▄    ▄▀ ▓███████░   ▓▓ 
█▀████▄ ▀▄    ▀▄▀████▄  ▓▓▓█▓▓████   ▒▒▓▓█████░███▌ ▄█████▄    ▄█████████ █▀▀▀▀ 
▓ █████▓▄ ▀ ░░  ▀█████▓  ▀█████▓▓ ▄▄   ░░▀▀▀▀ ▐███▄████▓▀█████████████▄▄▄▄█     
░▀▄▀██████▄ ▓▓ ▀▄ ███▓▓ ▄▄ ▀▀▀▀░░  █       ▄▄  ▀██████▀ ████████▓▓▀▀    █       
   ▀▄▀▓███████   █▄▄ ░░ █          ▀▀▀▀     ▀▓    ▓▓▓▀▀   ▀▀▀▀▀▀░░txt▄▓▀▀       
                   █                         ░▀▄▄   ░░░     ▄▄▄▄▄▄▀▀▀           
       ▄▄█████▌    ▀▀▀▀                                                         
                                                                                
         ███▓▌▓▒░     
            ▄▄             

    CGTERM 3.0 ::: C64 SCENE EDiTiON //scene code by...... m00p
                                     //support by......... mermaid
                                     //ideas by........... Larry
                                     //tested by.......... hedning
                                     //original code by... MagerValp



--------------------------------------------------
[ INTRO ]
--------------------------------------------------

CGTerm is the legendary C64 BBS terminal originally written by MagerValp.
For years it has been the one and only client for connecting to the elite
Commodore 64 BBSes around the world.

The original CGTerm worked well, but the codebase had not seen much
maintenance for quite some time.

Also with BBS software evolving, especially new mods and protocols in
systems like C*BASE it felt like the terminal side of the ecosystem deserved
some love as well.

We have listened to the sceners and this release is the result of feedback
ideas and experimentation from people across the sysops, swappers and elites.

The goal was simple:

Keep the soul of CGTerm.
Clean the code.
Modernize the foundation.
Make it easier to build, maintain and extend.

The result is a cleaner codebase, improved rendering, better networking
behavior, newly added transfer protocols, security and stability fixes,
Proper color palette and a reorganized project structure designed for
modern development.

Installation scripts are now included for Linux, MacOS and Windows so
getting CGTerm running on a modern machine is easier than ever.

Oldschool terminal.
Modern systems.

Thank you MagerValp for an amazing software, i hope you will enjoy
these mods as well! 

--------------------------------------------------
[ INSTALLATION NOTES ]
--------------------------------------------------
On most of the platforms you can simply just run
"make && make install" in the directory, and everything
will just be fixed.

On MacOS ive made an installation script which is
recommended to run. From the main directory run
the script like this: ./scripts/install-macos.sh



--------------------------------------------------
[ SOURCE CODE IMPROVEMENTS ]
--------------------------------------------------
Some of the elite improvements and modifications we added to this version
is  for example:



+ Rainbow Protocol Support
-----------------------------
- Added Rainbow transfer protocol implementation
- Integrated into the CGTerm transfer system
- Single-file send support
- Single-file receive support
- Block-based transfer with checksum validation
- ACK / NAK retry handling
- Basic error detection and cancel support

Rainbow protocol documentation can be found at:

    ./docs/RAINBOW.TXT


+ Rendering & Color Improvements
--------------------------------
- Improved Commodore 64 color palette implementation
- More accurate RGB values for the original C64 palette
- Better foreground/background color handling
- Improved PETSCII color mapping


+ Improved Terminal Rendering
------------------------------
- Improved screen redraw behavior
- More consistent cursor updates
- More reliable terminal refresh logic
- Better SDL surface handling


+ Major Networking Improvements
--------------------------------
- Improved connection stability
- More robust socket communication
- Reduced connection drop issues
- Improved telnet session behavior


+ Improved Keyboard Handling //(still a work in progress)
--------------------------------
- Improved keyboard layout handling
- Added additional keyboard mapping files (.kbd)
- Better compatibility with modern keyboards
- Improved PETSCII key mapping logic
- Added cross-platform keyboard profiles for Windows, Linux and macOS
- Added Swedish and US keyboard layout support
- Modern PC keyboards can now behave closer to a real C64 keyboard
- More consistent mapping for RUN/STOP, Commodore, cursor keys and function keys
- Introduced dedicated keyboard profiles selectable at startup


[LAYOUTS]
 cgterm -k assets/mac-se-c64.kbd
 cgterm -k assets/mac-us-c64.kbd
 cgterm -k assets/linux-se-c64.kbd
 cgterm -k assets/linux-us-c64.kbd
 cgterm -k assets/win-se-c64.kbd
 cgterm -k assets/win-us-c64.kbd



+ Improved SDL Compatibility
----------------------------
- Better compatibility with modern SDL builds
- Improved surface initialization
- More stable rendering behavior across platforms


+ Major Code Cleanup
--------------------
- Removed legacy artifacts
- Improved readability across several modules
- Safer memory handling in multiple areas
- Prepared codebase for future development
- Various stability and security improvements


Cleaned starter tree
- Asset lookup via runtime path resolver
- Linux assets prefer:

      /usr/local/share/cgterm/assets
      /usr/share/cgterm/assets

- Portable development builds still work from:

      ./assets

- Updated installer scripts for Linux, macOS and Windows
- Linux installer checks for SDL 1.2 and only elevates
  privileges when required
- MacOS installer now builds a native application bundle


--------------------------------------------------
[ PROJECT RESTRUCTURE ]
--------------------------------------------------
One of the biggest changes in this release is the
reorganization of the entire project tree.

The original CGTerm source placed everything in
the root directory, which made packaging and
long-term maintenance difficult.

This version introduces a cleaner and more
developer-friendly layout.


New Directory Layout
--------------------

src/            C source files and headers
assets/         Runtime assets (.bmp, .kbd, .wav, help files)
bin/            Destination for compiled binaries
build/obj/      Intermediate object files created during build
scripts/        Installation helpers (Linux / macOS / Windows)
platform/macos/ Legacy SDL bootstrap files kept for reference
Makefile        Main build logic
dist/           macOS CGTerm.app bundle


--------------------------------------------------
[ PROGRAMS BUILT ]
--------------------------------------------------

cgterm          Main CGTerm terminal client
cgchat          Chat utility
cgedit          Message editor
testkbd         Keyboard layout test tool


--------------------------------------------------
[ INSTALLATION ]
--------------------------------------------------

Linux

    ./scripts/install-linux.sh

or

    make && make install

Installs to:

    /usr/local/bin
    /usr/local/share/cgterm


macOS

    ./scripts/install-macos.sh

Creates a native macOS application bundle:

    ./dist/CGTerm.app        <- build location
    /Applications/CGTerm.app <- install location


Bundle structure

    CGTerm.app
        Contents/
        MacOS/
        Resources/
        Frameworks/


Windows

    scripts\install-windows.bat

or

    powershell -ExecutionPolicy Bypass \
        -File scripts\install-windows.ps1


--------------------------------------------------
[ DEFAULT INSTALL PATHS ]
--------------------------------------------------

Linux / macOS

    /usr/local/bin
    /usr/local/share/cgterm
    /Applications/CGTerm.app


Windows

    %ProgramFiles%\CGTerm


--------------------------------------------------
[ GREETZ ]
--------------------------------------------------
Abyss Connection
Arsenic
Booze Design
Camelot
Cosine
Crest
Danish Gold
Dutch Cracking Team
Dynamic Duo
Eaglesoft
Eclipse
Electronic Arts Crackers
Elite Cracking Group
Excess
Fairlight
Finnish Gold
FLT
German Cracking Service
Hitmen
Hokuto Force
Ikari + Talent
Laxity
New Generation
Nostalgia
Onslaught
Padua
Razor 1911
Red Sector
Remember
Software of Sweden
Success + The Ruling Company
Swedish Cracking Crew
The Crackers
The Dreams
The Judges
The Light Circle
The Movers
The Sharks
The Silents
The Supply Team
Triad
TRSI (Tristar & Red Sector Inc)
West Coast Crackers


All elite BBS sysops
PETSCII artists
Retro coders
And everyone still dialing in.


--------------------------------------------------
[ FINAL WORDS ]
--------------------------------------------------
Any bugs, feature requests or random elite spam
is welcome as a message on the FRoZEN FLoPPY BBS.

telnet://bbs.retrohack.se:64128




--------------------------------------------------
[ PATCH: 2026-03-23 // SECURITY FIXES            ]
--------------------------------------------------

Critical Bug Fix (diskimage.c)
------------------------------
- Fixed err->number++ to ++err in di_status()
- The old code corrupted the error message table instead
  of advancing to the next entry, breaking all disk image
  status lookups after the first call

Buffer Safety Fixes
--------------------
- Replaced all unsafe strcpy/strcat/sprintf with snprintf
  across xfer.c, menu.c, chat.c, config.c, cgterm.c,
  diskimage.c, rainbow.c, punter.c, and fileselector.c
- Added width limits to sscanf bookmark parsing in config.c
- Prevents buffer overflows from long filenames, paths,
  bookmarks, or protocol data

NULL Pointer Fix (ui_term.c)
----------------------------
- Added NULL check for file selector before dereferencing
- Prevents crash when file selector fails to initialize


--------------------------------------------------
[ PATCH: 2026-03-28 // PUNTER UPLOAD + UI FIXES  ]
--------------------------------------------------

Punter Upload Implementation
-----------------------------
- Full Punter upload support, verified against C*BASE 3.3.8
- Pre-handshake: sends GOO to signal BBS readiness
  (C*BASE bbs.bas lines 5591-5620 require this)
- Phase 1: filetype init block with blknum=$ffff
  triggers BBS lastblock/SYN exchange
- Phase 2: double-buffered data blocks with look-ahead
  so byte[4] contains the NEXT block's size (matching
  BBS sender behavior)
- Block size: 247 data bytes per block (pktsize=254)
- Final SYN exchange for clean completion

Terminal Rendering Fix (kernal.c)
----------------------------------
- Fixed CR+LF handling: LF after CR is now suppressed
  to prevent double line breaks
- Bare LF still works as cursor-down

Network Buffering Fix (cgterm.c)
---------------------------------
- Main loop no longer consumes network bytes while
  menus or dialogs are active
- Prevents protocol handshake data from being eaten
  as terminal characters during transfer setup

Transfer Progress UI Redesign (menu.c)
---------------------------------------
- New layout with labeled rows:
  [protocol]: uploadIng/downloadIng
  [fIlename]: name
  [block sIze]: current / total
  [status]: bytes / total bytes
  <progress bar>
- Filename no longer overlaps other text
- Expanded transfer window height
- Fixed Rainbow block progress bar for unknown totals

Asset Path Resolution Fix (paths.c)
-------------------------------------
- Binary in bin/ now finds assets in ../assets/
- Checks parent directory when assets not found
  next to the binary


TODO:
- Add support for connection status
- Add support for larger bookmarks
- Migrate from SDL 1.2 to SDL 2.0






