NesFishy game modules
=====================

A module is a folder in your game folder's "modules" folder. NesFishy adds every
module folder it finds to the game (it writes modules.s when you build), so to
turn a module off, move its folder out (or rename it to start with "_").

Each module folder has:

  module.txt   name, what it does, which hooks it has, RAM it needs (for people
               and for tools; NesFishy reads "name" from it, else the folder name)
  module.s     ca65 code, included into the engine's CODE segment

Hooks: a module defines any of these labels and the engine calls them
(JSR; end with RTS). <name> is the module's name:

  <name>_init     once at power on, before the level loads
  <name>_frame    every frame, after the controller is read, before objects move
                  (also while the game is paused)
  <name>_object   every frame for each object after it moved; X = its slot
                  (obj_type, obj_state, obj_xl / obj_xh, obj_y, obj_flags, ... ,x)
  <name>_touch    when an object touches the player; X = the object,
                  player_slot = the player's slot. Set obj_type, x to $FF to
                  remove it.
  <name>_sound    a sound event: A (and snd_id) = SND_JUMP, SND_HURT, SND_STOMP,
                  SND_PICKUP, SND_DIE or SND_LEVEL. Your own code can call
                  "jsr play_sound" with any id (keep X / Y).

Rules:
  - Keep X when you return from _object and _touch (the engine reloads it, but
    other modules called after you get the X you leave).
  - Zero page: use your own (.segment "ZEROPAGE" ... then back to .segment
    "CODE"). The engine's t0-t4, ptr0 / ptr1 are free to use inside a hook.
  - RAM: .segment "BSS" for your variables, then .segment "CODE" again.
  - Labels start with your module name so modules don't clash.
  - The engine's variables you can read / change: buttons, pressed, released,
    game_paused, frame_count, score, coins, lives, level, hud_var (8 bytes: HUD
    numbers / meters whose names the engine doesn't know), cam_x, player_slot,
    climbing and the obj_* tables.

Modules that come with it: pause (Start pauses), sfx (sound effects).

Later, an AI helper will be able to write modules for you from a description;
it follows the same rules (this file is what it reads).
