Skip to content

reformed-witness/gba-2lbcf

Repository files navigation

Second London Baptist Confession - GBA Reader

A Game Boy Advance homebrew application for reading the Second London Baptist Confession of Faith (1689). This project provides a complete text reader with scrolling, chapter navigation, and a custom font rendering system optimized for the GBA's 240x160 screen.

GBA Screenshot

Features

  • Full text display of the 1689 Baptist Confession with all 32 chapters
  • Smooth scrolling with proper VSync timing to prevent flicker
  • Chapter navigation using A/B buttons to jump between chapters

Controls

Button Action
UP Scroll up one line
DOWN Scroll down one line
A Jump to next chapter
B Jump to previous chapter

Quick Start

Option 1: Use Pre-built ROM

Download confession.gba and load it in your favorite GBA emulator.

Option 2: Build from Source

Prerequisites

  • devkitPro toolchain with GBA development tools
  • Python 3 (for optional JSON conversion)
  • GBA emulator (mGBA, VisualBoyAdvance-M, etc.)

Installation Steps

  1. Install devkitPro:

    • Windows: Download installer from devkitPro releases
    • Linux: sudo apt install devkitpro-pacman && sudo dkp-pacman -S gba-dev
    • macOS: brew install devkitpro/devkitpro/devkitarm
  2. Set environment variables:

    export DEVKITPRO=/opt/devkitpro
    export DEVKITARM=$DEVKITPRO/devkitARM
    export PATH=$DEVKITARM/bin:$PATH
  3. Clone and build:

    git clone <repository-url>
    cd gba-confession
    make clean
    make
  4. Fix ROM header:

    python3 fix_header.py confession.gba
  5. Test in emulator: Load confession.gba in mGBA or your preferred emulator.

Project Structure

gba-confession/
├── confession.c          # Main application code
├── crt0.s               # GBA startup assembly code
├── linker.ld            # Memory layout linker script
├── Makefile             # Build configuration
├── fix_header.py        # ROM header fixer script
├── convert_json.py      # JSON to C array converter
└── README.md            # This file

Customizing Content

The confession text is stored as a C string array in confession.c. To use different text:

Method 1: JSON Conversion (Recommended)

  1. Prepare your JSON in the format:

    {
      "title": "Your Document Title",
      "chapters": {
        "1": {
          "title": "Chapter Title",
          "paragraphs": {
            "1": "Paragraph text...",
            "2": "More text..."
          }
        }
      }
    }
  2. Convert to GBA format:

    python3 convert_json.py your_document.json
  3. Rebuild:

    make clean
    make
    python3 fix_header.py confession.gba

Method 2: Direct Editing

Edit the confession_text[] array in confession.c directly, ensuring:

  • Each line is ≤27 characters for proper display
  • Update total_lines variable
  • Maintain empty strings "" for spacing

Technical Details

Memory Layout

  • ROM: Code and data starting at 0x08000000
  • IWRAM: Fast work RAM at 0x03000000 (32KB)
  • EWRAM: External work RAM at 0x02000000 (256KB)
  • VRAM: Video memory at 0x06000000 (in Mode 3)

Graphics System

  • Mode 3: 15-bit color, 240x160 resolution
  • Direct pixel access to framebuffer
  • VSync synchronization to prevent tearing
  • Custom font rendering with 8x8 character cells

Text Formatting

  • 27 characters per line to accommodate scrollbar
  • 12 lines visible on screen simultaneously
  • 12-pixel line spacing for readability
  • Color coding: Blue for chapter headers, white for text

Troubleshooting

Build Errors

"arm-none-eabi-gcc not found":

  • Install devkitPro toolchain
  • Check environment variables are set correctly
  • Restart terminal after installation

"gbafix not found":

  • Install gba-tools: sudo dkp-pacman -S gba-tools
  • Or use the Python header fixer: python3 fix_header.py confession.gba

ROM Issues

"Could not load game" in emulator:

  • Run header fixer: python3 fix_header.py confession.gba
  • Try different emulator (mGBA, VBA-M, No$GBA)
  • Check ROM file size (should be several KB, not 0 bytes)

Black screen:

  • Verify ROM header is correct with hexdump -C confession.gba | head -5
  • Should start with ea 00 00 xx 24 ff ae 51...

Text flickering/overlapping:

  • Ensure you're using the latest version with VSync fixes
  • Check that wait_vblank() function is being called

Performance

Slow compilation:

  • Use make -j4 for parallel compilation
  • Consider using Docker if native installation is problematic

Development

Adding Features

The codebase is structured for easy modification:

  • Font changes: Edit font_data array in confession.c
  • Screen layout: Modify draw_text_screen() function
  • Input handling: Update the main game loop
  • Colors: Change the color constants at the top of the file

Testing

Test on multiple emulators for compatibility:

  • mGBA: Most accurate, recommended for development
  • VisualBoyAdvance-M: Good compatibility, cross-platform
  • No$GBA: Windows only, good for debugging

For real hardware testing, use flash carts like:

  • EZ-Flash Omega DE
  • Everdrive GBA X5

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Test on multiple emulators
  4. Ensure ROM works on real hardware (if possible)
  5. Submit a pull request

License

This project is released into the public domain. The Second London Baptist Confession of Faith (1689) is a historical document in the public domain.

References

Acknowledgments

  • devkitPro team for the excellent GBA toolchain
  • Baptist churches for preserving this historic confession
  • GBA homebrew community for documentation and tools

For support or questions, please open an issue on the project repository.

About

A program for reading the Second London on the GBA

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages