Guide to source files

From OHRRPGCE-Wiki
Jump to: navigation, search

This page attempts to document the many and confusing source files in the OHRRPGCE. This information is all subject to change, and might possibly change faster than this wiki page gets updated. If you spot anything that doesn't make sense, please mention it on the talk page

To understand how the OHRRPGCE continues to live and grow in spite of its remarkable level of chaos, read: BIG BALL OF MUD software architectures

Contents

[edit] Some History

Some of these source files are logically organized, for example the backends are pretty well organized, and so are many of the shared source files. Other files are completely arbitrary collections of subs and functions, for example, moresubs.bas, yetmore.bas, and yetmore2.bas are meaningless collections. These files hearken back to the bad old days when the OHRRPGCE was a DOS program written in QuickBasic, QuickBasic has a limit on the maximum size of a single source file. If any one file is too big, the compiler just freaks out and dies. To work around this problem, James created new files, and clumsily and messily converted GOSUB blocks into SUBs and FUNCTIONs so they could be moved to the other files. (The reasons why he was using GOSUB in the first place when he could have been using SUB all along hearken back to when he was 15, so cut him some slack ;)

[edit] Game Player

source file description status
game.bas main module, contains the main game loop and a lot of the map and walkabout logic. A lot of script command implementations (unnecessarily) live here. (Historically these commands needed to call toplevel GOSUBS in game.bas) messy
bmod.bas main battle module messy
bmodsubs.bas additional battle related stuff somewhat messy
hsinterpreter.bas contains the core of the old script interpreter (the rest is in game.bas, moresubs.bas and yetmore.bas). Mainly exists to ease the transition to the new script interpreter messy
menustuf.bas mostly stuff related to the built-in in-game menus messy
moresubs.bas misc unsorted stuff messy
savegame.bas loading and saving games still messy
yetmore.bas used to be misc unsorted, but now mostly contains plotscripting command implementations slightly messy
yetmore2.bas most of the rest of the map and walkabout logic and drawing code messy
battle_udts.bi defines types used by the battle system. not too messy
game_udts.bi defines types used by the game player (but most are actually in udts.bi). These types are good for code cleanup, but it would make more sense to keep them together with the code that uses them (after the code that uses them gets cleaned up). not too messy
gglobals.bi global variable declarations for the game player not too messy


[edit] Custom Editor

source file description status
custom.bas main editor module fairly messy
customsubs.bas misc editor subs and functions. Most of these are either new code or decently cleaned up code. mildly messy
drawing.bas contains the sprite editor, the maptile editor, and some other code. The graphics editors are some of the oldest code in the whole project. Some of it has been partially cleaned up. messy
editedit.bas code for the Editor Editor (hidden in Custom) not very messy
editrunner.bas interpreter for the RELOAD documents produced by the Editor Editor sparsely messy
flexmenu.bas contains an attempt at a generic editor menu system which is used by the attack editor and the enemy editor. Better than some other editor menus, but still has a lot of room for improvement somewhat messy
mapsubs.bas Map editor and related code. messy
menus.bas misc stuff, including some sound effect editor code and the general game data menu somewhat messy
reloadedit.bas contains the RELOAD editor (hidden in Custom) not very messy
sliceedit.bas contains the slice collection editor not very messy
subs.bas includes the enemy editor, hero editor, item editor, and stuff messy
subs2.bas text box editor and HSI exporter messy
custom_udts.bi defines types used by various editors. They types themselves are pretty good, but really belong together with the editors that use them (after those editors get cleaned up) not too messy
cglobals.bi global variable declarations for the game editor not too messy

[edit] Shared files

source file description status
allmodex.bas Core graphics, sound, input. In practice, this is a library on which the rest of the engine is built. Also an abstraction layer on top of the graphics and music backends APIs. This module gets its name from Brian Fisher's Allmodex Assembly library for QuickBasic, but it has evolved so much that it is a whole new animal now. mostly not messy
backends.bas handles loading of the graphics backend (no similar dynamic loading capability for the music backend) barely messy at all
blit.c this contains the most CPU-intensive drawing code, written in C barely messy
browse.bas The file-browser used for picking the RPG file to play, or for importing stuff into editors. Although messy and complicated, it is pretty well modular. messy
bam2mid.bas tool to convert bam files into midi files (can also be compiled a s a standalone tool) not too messy
common.bas An eclectic collection of code that is shared between game and custom, including the whole customisable menu system and lots of loading and saving code. In spite of the eclecticness, most of the code is pretty decent. not too messy
loading.bas code for reading and writing various data files. slightly messy
lumpfile.bas code for reading and writing lumpfiles. Most of this is not used yet not very messy
misc.bas Originally contained code to ease the transition from QuickBasic to FreeBasic, now also includes command-line processing and a few Linux/Windows compatibility things somewhat messy
os_*.bas most of the completely OS-specific code is here (exception: Windows-only private heap code in reload.bas). os_unix.bas is used by all supported platforms except Windows (and is currently just a bunch of stubs anyway) barely messy at all
reload.bas code for reading and writing and manipulating files in RELOAD format barely messy at all
reloadext.bas more functions for RELOAD documents which don't depend on reload.bas internals barely messy at all
slices.bas code for displaying, saving, loading, manipulating slice trees not very messy
util.bas misc utility functions, data structures, string manipulation. Everything here is non-interactive code with minimal side-effects. not very messy
config.bi not a normal header file; secret location of several important macros. Included in every .bas file. fairly messy
udts.bi location of most Types/User Defined Class definitions, many of which are only used by the game player so should probably be in game_udts.bi fairly messy
util.bi as well as function declarations for util.bas, contains macros for template emulation (which you probably don't want to touch) and linked lists #MACRO mess

[edit] Backend Modules

source file description status
gfx_*.bas graphics backends. All share the same api. (But see below for gfx_directx, gfx_sdl++, and gfx_sdl on Mac OS X) varying messiness
music_*.bas music backends. All share the same api varying messiness
sdl_lumprwops.bas A wrapper between SDL and lumpfile.bas, to be used by the music_sdl backend for direct lump access. Not used yet barely messy
audwrap\* C++ wrapper around the Audiere sound and music library. Needed by music_native/native2, which can't interface with C++ classes barely messy at all
gfx_common\* C++ code common to gfx_directx and gfx_sdl++ not too messy
gfx_directx\* C++ DirectX backend. Supports both old and new apis not too messy
gfx_sdl\* completely new C++ SDL graphics backend, referred to by gfx_sdl++. Supports both old and new apis. Experimental not too messy
mac\SDLmain.m Objective-C portion of gfx_sdl, used on Mac OS X only. Derived from the standard SDL template. Cocoa code lives here. somewhat messy
gfx.bi current graphics backend api messy
gfx_new.* new graphics backend api proposal less messy
music.bi music backend api barely messy

[edit] Separate utilities, tools and tests

source file description status
fixqb.bas A tool for removing certain QuickBasic-isms from source files. Not used in years not too messy
hspeak.exw HSpeak compiler somewhat messy
hsspiffy.e Euphoria routines used by HSpeak barely messy
Makefile GNU Make makefile for compiling the engine messy
miditest.bas A tool for testing midi output on Windows (do we still need this one?) not too messy
misc/gosub.el Emacs Lisp script to detect a type of GOSUB usage bug barely messy
misc/with.el Emacs Lisp script to detect a type of mixed WITH and GOSUB usage bug barely messy
misc/lumpfix.ex Euphoria program to attempt to fix damaged lumpfiles (dead code?) barely messy
misc/sl_lookup.py Python script to update hardcoded slice lookup codes throughout the source barely messy at all
ohrbuild.py Python rewrite of verprint, used by Scons script barely messy at all
reloadtest.bas a battery of tests for reload.bas barely messy at all
reloadutil.bas RELOAD load/save benchmark, and file compare barely messy at all
reload2xml.bas dump RELOAD to XML barely messy at all
relump.bas a standalone tool for extracting lumpfiles not terribly messy
Sconscript Scons script for compiling the engine not terribly messy
unlump.bas a standalone tool for packaging lumpfiles not terribly messy
verprint.bas used as part of the build system for updating version numbers. Could be obsoleted by a better build system messyish
xml2reload.bas tool for converting an XML file (especially as produced by reload2xml) into a RELOAD document not too messy

[edit] Style Inconsistencies

Different files use different styles. This is mostly okay, and we try to just keep new code consistent with the style of other code in the same module. Some modules break this rule worse than others do.

Some code uses tab indentation. Some code uses single-space indentation, and some uses double-space indentation. Adapting one's indentation style to the match the current file is not much work, and seems like less work than fighting the holy war of deciding which style to standardize on.

Some code puts all FreeBasic commands IN BLOCK CAPS. This is mostly James's fault because the QuickBasic editor drilled it into his brain so hard by automatically enforcing this style. Amongst the block-caps-keywords source, some uses block caps for builtin type names (eg. INTEGER) and other source doesn't.

Some code uses CamelCaseCaps for sub and function names. Some code uses lower_case_words_with_underscores. James thinks this is probably not a big deal.

There is just one style that is used consistently throughout the source - even the C++ source! - non-builtin type/class names are in CamelCase. Please don't take away all we have!

As a general rule, just try to match the style of surrounding code. For larger style cleanups, discuss first with the other Developers.

[edit] See Also

Personal tools