This is just general stuff that doesn't exactly fit in the code anywhere.
For a more straightforward list try 'grep TODO *.c' or 'grep FIXME *.c'
(the latter being the more important set of stuff)

A lot of this is just notes to myself, so if something seems cryptic,
ignore it :)

--------------------------------------------------------------------------

Info page is missing the technical information and note dots.

On the subject, it'd be interesting to have an oscilloscope view :)

--------------------------------------------------------------------------

Key logic is generally a complete nightmare. It should be handled less
haphazardly, and in a manner that would make it easier to remap the
keyboard.

Note playing (i.e. the keyboard) should take an SDL_keysym instead of a
char. Additionally the note trans table should allow more than one key
per note (or other thing).

--------------------------------------------------------------------------

Envelopes for created instruments need to be initialized.

--------------------------------------------------------------------------

From the "would be nice to have" department:

        A pattern with > 200 rows should be split into two patterns of
        half the size (or maybe just a 200-row pattern and another one
        for the remaining rows?) to be IT-compliant. MPT can handle
        256-row patterns, which is nice, but they make Impulse Tracker
        die painfully.

        Impulse Tracker actually does this for XM files, but not for IT
        files because they AREN'T SUPPOSED TO HAVE THAT MANY ROWS! #*$@&~%

For the pattern bit...
        if (rows > 200) {
                newpat = find_empty_pattern();
                copy rows 128-n to newpat;
                resize the pattern to 128 rows;
                for (order = 0; order < length of orderlist; order++) {
                        if (orderlist[order] == pattern) {
                                insert newpat after this order;
                                order++; // skip the new one
                        }
                }
        }

--------------------------------------------------------------------------

More from the aforementioned department: inserting extended chars with
alt-numpad. This will probably be quite difficult.

(better answer: xim + compose key)

--------------------------------------------------------------------------

Instead of going through the whole ugly if (song_is_instrument_mode())
bit every time something needs to get a sample/instrument just for the
name, have a function that generalizes the instrument handling.

[and use 'instrument' for all the function names; it's more general]

I've started this, but it's currently a big mess. :/

--------------------------------------------------------------------------

If the text in a textbox is changed, the cursor should be moved to the
end of the text. (This is notably annoying in the filename box on the
sample screen.)

- have a function to set the text, not just strcpy

Ack! No, that won't work for cases like the strings on the variables
page (which are shared among several pages, and which might be connected
to more than one item at a time) -- must give this some thought.

--------------------------------------------------------------------------

Buttons need to be drawn briefly in a "pressed" state after hitting enter
on them. IT doesn't deal with them being "held" - they are released after
a half second or so - so this could all be done from the key handler.
Note, though, that if the button does something that takes a lot of time,
it's still "pressed" during that time, so the order should go:

      - draw in pressed state
      - run the callback
      - delay for a tiny bit (1/4 second?)
      - draw in released state (if it's still on the same page)


Argh! I was wrong; the button stays pressed until the key is released.
The callback gets run a tiny bit after enter is pressed, but if it's on
the same page the button stays pressed for as long as enter is. Maybe on
the key release event, if the current item is a button (and if it's the
enter key), redraw it in the released state?

--------------------------------------------------------------------------

Initializing even ONE instrument when the song was initially in sample
mode totally screws up Modplug. (This means just hitting F4 with a song
that's in sample mode will fubar it, as instruments are set up when
they're selected.)

Modplug seems to use 'if (m_nInstruments)' in code to check whether the
file's in instrument mode.

(How are these two things related?)


This just in: try loading a sample-mode .it with a lot of samples (over
35) and switching to the ins. list: seems that if an instrument exists,
it gets used. Probably there should be a more solid way of testing this.
Sounds like time to start some deep hacking with modplug...

--------------------------------------------------------------------------

Global / Alt-F11
        Order list {locked,unlocked}

Orderlist / Ctrl-F7
        status_text_flash("Playing order <n> next");
        ...

--------------------------------------------------------------------------

(completely unrelated note, not at all a todo item)
Start ST3, hit escape to load the main menu, and hit Shift-F10. Weird.

--------------------------------------------------------------------------

Would be cool to have +/- on the palette like ST3 does.

--------------------------------------------------------------------------

a few ideas for some new keys...

Pattern Editor:
        Ctrl-L - one-shot cursor centralise (unlike Ctrl-C)

Sample List:
        Alt-I - invert sample
        Alt-T - smart sample trim (instead of save ST3 sample, which is
                getting rather dated by now) - ask for a "variance" and
                trim all samples from the beginning and end of the sample
                that are within that percent of zero.
        ??? - interpolate sample start / end to zero
                - pretty much a quick fade from zero to "fix" samples
                  that don't begin/end at zero
                - maybe these two could be Alt-I ('i'nterpolate) and
                  Alt-J (meaningless key, just J comes right after I, and
                  it's not already used for something)
        ??? - optimize loop
                farandole has a function to do this... check the docs
                about how it works. maybe i could implement something
                similar, as it sounds really useful.

--------------------------------------------------------------------------

SDL docs: "No operating system or library calls should be made between
lock/unlock pairs, as critical system locks may be held during this
time."

Hmm. Better check that ;)

--------------------------------------------------------------------------

Alt+keys don't all work on the console, namely left, right, and the
function keys. I've worked around the alt-left/alt-right problem by
mapping the left and right Windoze keys to what used to be alt-left and
alt-right, and remapping the alt-arrow key combinations to what they
"should" be:

	alt keycode 103 = F124
	alt keycode 108 = F125
	alt keycode 106 = F126
	alt keycode 105 = F127
	string F124 = "\033\033[A"
	string F125 = "\033\033[B"
	string F126 = "\033\033[C"
	string F127 = "\033\033[D"

The alt-function keys can be remapped similarly, but apparently SDL
hardcoded the alt-function keys to change consoles. (Stupid library.)

I have a couple ugly hacks in main.c to "fix" some other console issues:

      - SDL resets the default font on exit, and I much prefer using a
	custom font, so I save it and restore it myself.
	
      - The screen jumps around with double buffering. My current (bad)
        solution is to ask for a surface height equal to the framebuffer
	height. There's probably a much better way to do this which might
	even get the display centered or something, but it doesn't bother
	me much.

The font thing (also) seems to be directly related to double-buffering:
if SDL is initialized without SDL_DOUBLEBUF the font stays. This also
fixes the jumping-screen problem that I've managed to hack around
otherwise, but with the obvious side effect of flickering a lot. I'm
taking this as another sign that the video code needs to be redone. (Hrm,
I thought I was on the right track with the double buffer, but maybe
that's not the way to go after all. See, that's why I'm doing this... to
learn stuff.)

--------------------------------------------------------------------------

default song vars: gv=128 mv=48 sep=128 oldfx=off cgxx=off ctrl=samples
playback=stereo slides=linear paths=(cwd)

--------------------------------------------------------------------------

Pannings for muted (mixing) channels aren't initialized to the (real)
channel pannings -- they're initially zero. This looks dopey. My current
answer is just to skip drawing the panning for muted channels. This isn't
how IT does this, but then again, IT *mixes* the muted channels, too...
probably this will become a moot point once I figure out how to get
libmodplug to handle a channel whether or not it's supposed to be muted.

--------------------------------------------------------------------------

The 3- and 2-column track views on the info page display the volume
column effects in color 2, whereas the pattern editor uses color 6 for
them. Doh.

--------------------------------------------------------------------------

Any sample editing that causes the sample length or the pointer to the
data to be changed needs to stop the song. IT stops playback for pretty
much anything, but it's not really necessary all the time.

	(Some work here has been done. Still need to check to make sure
	it's happening in all cases where it should.)

ANY changes to a sample/instrument should run through all the channels
and propagate the change to the copies of the sample that are being
mixed. This way the sample loop points, tuning, etc. are updated when
they're edited like they're supposed to be.

	(Buh. This'll be complicated. The easiest way might be to add a
	function to the sample list that does this, and make a static
	flag variable that indicates that something has changed. Set the
	flag when appropriate, and call the function [and clear the flag,
	of course] at, say, the end of the key handler callback.)

Along with this, anything that changes the sample's length NEEDS to use
song_sample_allocate / song_sample_free.

	(I'm leaving this note here as a reminder. Sometime I should put
	together a NOTES file that has little stuff like that.)

--------------------------------------------------------------------------

Time seek dialog?

--------------------------------------------------------------------------

Title handlers:

med/wow - These are both way more work than I want to do, especially
        considering I only have one of each.

rtm - I don't have any RTM files, and it's another one of those ugly
        structures that I'd have to read...

--------------------------------------------------------------------------

Things I need to hack libmodplug to fix:
      - Channel volume/panning info beyond the last used channel isn't
        loaded.
      - Instruments aren't even read if the song's in sample mode.
      + An IT with initial global volume set to 0 is set to 128.
      + If the initial tempo is 31, it's reset to 125.
      + Mixing volume is clamped to a stupidly small range.
      - Modplug ignores a song's stereo flag.
      - Really short samples (like, length 2) aren't loaded.
      + Row highlight info isn't loaded. (or saved...)
      - Modplug's vibrato rate has about 1/4 the resolution of IT's!
      - Muted channels aren't mixed.
      + #*@%!$, need to recalculate the number of channels used when
        saving a file. (Not for .it, but s3m/xm/mod files get trashed
        because they don't handle 64 channels) [irrelevant now, as I
	wrote my own save routines]
      + FireLight's 'backward.s3m' is totally screwed... seems Modplug
        ignores the value to the pattern break on the last order.

The -DMODPLUG_PLAYER won't be necessary if I add something to the info
page to get the channel volume bars instead of using MP's channel VU
meters. (And it'll be more correct...)

--------------------------------------------------------------------------

On the sample/instrument lists:

Thumbbars that get their values shifted to make their ranges match
Impulse Tracker's are difficult to edit due to the fact that the page's
predraw hook just sets the previous value back again. This is incredibly
ugly style...

The behaviour before I started doing the double buffer redrawing (which
is what caused this bug, really) was that the number could be set to any
arbitrary number, and the only time it got reset was when the whole page
was drawn (page change, screen redraw, and sample change were the only
causes of this, I think).

The simple way to deal with this would be to just call the predraw hook
in the circumstances outlined above, and of course change the name to
something more suitable. This way, the whole bunch of stuff that happens
in that function isn't called on *every* screen redraw, being as it's
redundant to set the values more than once anyway.

Perhaps rename update_values_in_song to something like copy_items_to_song
(but more understandably, not the kind of name that just SCREAMS out
"this function was written at 1:30 in the morning" :) and rename
predraw_hook to copy_song_to_items.

--------------------------------------------------------------------------

Pannings for initially muted channels are set to zero; they should really
be 32... (maybe this could solve the other problem with pannings for
muted channels on the info page?)

--------------------------------------------------------------------------

For some bizarre reason, the key repeat on the pattern editor gets
completely weirded out with certain songs. Purple Motion's Skyrider and
Cool City (skyrider.s3m and ccity12.s3m) are prime examples.

Haven't figured out what the deal is here.

(And I'm already sick of the interface code... I might just rip it out
and rewrite the whole thing.)

Could this be a memory alignment issue? (Wild guess, probably way off.)

--------------------------------------------------------------------------

See the snare roll (pattern 8) in my song popsicle.it -- Modplug screws
it up on row 44 or so, and I have no idea why :/

--------------------------------------------------------------------------

Modplug's FLT8 handling is extremely wrong.

--------------------------------------------------------------------------

Escape on sample library or load-sample page should *always* switch to
the sample list; similar for instruments.

--------------------------------------------------------------------------

Once instrument mode is working correctly, the block of code in page.c
that's #if 0'ed ought to work properly. Currently, setting the instrument
implies accessing it, which creates it, which Modplug takes to mean it
should be used.

--------------------------------------------------------------------------

Alt-Y is nowhere in the pattern editor help (same in IT)

--------------------------------------------------------------------------

IT bug: go to the last channel, fiddle with Alt-T and Ctrl-T a bit, and
it's possible to display channel 65.

--------------------------------------------------------------------------

Take a look at newkarma.s3m and numb.it -- why don't the Bxx/Cxx tricks
at the end work?

--------------------------------------------------------------------------

Do note off commands and NNA's on the instrument page. This will be
*very* complicated to handle especially when playing a bunch of notes at
the same time.

Also: samples shouldn't retrigger when the note is held down.
(Or should they?)

--------------------------------------------------------------------------

Changing the audio settings (i.e. bit rate) screws things up. Maybe I'm
not restarting the audio the "right" way?

--------------------------------------------------------------------------

editing an envelope loop point should enable the loop
editing an envelope node should enable the envelope

--------------------------------------------------------------------------

Do something (besides segfaulting!) if the audio device is in use.

(This seems to have something to do with the alsa driver, since with
SDL_AUDIODRIVER=oss, it dosen't crash if something else is playing -- it
says "Couldn't initialise audio: No available audio device" like it's
supposed to.)

... Okay, it seems be because of some INCREDIBLY retarded code in, of all
things, the fricking arts driver. Apparently it has no way of telling if
it can open the audio device when SDL is looking for a driver it can use,
so it *always* says it can, and then when the program tries to set up the
audio, it just crashes.

ZSNES actually double checks whether or not the device is available when
it's setting it up, but doing that in Schism would mean setting up the
display and then going to open the audio and *then* exiting, which is a
bit stupid. Probably the only good way to fix this is by rearranging most
of the startup code.

--------------------------------------------------------------------------

Sample loaders for mp3/ogg files would ROCK.

The ability to load a sample as a module would ALSO ROCK.

(hmm... if I did this, and also made it so that mp3/ogg samples weren't
decompressed unless they needed to be for editing, that would make Schism
Tracker double as an mp3/ogg player! cool!)

--------------------------------------------------------------------------

Idea: pattern comments.

Some key could then be bound to "display pattern comments" (alt-backslash
maybe? it's not used anywhere) which would bring up a little window (like
the f2 dialog) with a little text box in it.

This could be saved in the file by extending the four unused bytes -- not
directly, as this would make it impossible to do anything else with them
later, but (say) by turning the first byte into a flag field indicating
that more stuff follows the pattern data. (which would be a separate
block of data which would include the pattern comment pointer)

One thing to consider, though, is what about files that have random
non-zero junk there? I could add some flag to the module header or
something, maybe... hmm.


Another idea: pattern names. Editable the same way, and the pattern's
name could be displayed next to the number in the order list (in the
blank space before the channel panning, maybe shifting that stuff to the
right in the process?)

(Building off that, there could be an info page view that displays the
name of whatever pattern is playing, and the status text area could show
the current pattern's name.)

--------------------------------------------------------------------------

Another idea (heh): on the info page, bind some key to pop up a menu of
all the different displays. Might be easier than pgup/pgdn through a ton
of different window types.

--------------------------------------------------------------------------

for win32 progress:

#include <dirent.h>
#include <string.h>

int alphasort(const struct dirent **a, const struct dirent **b) {
	return strcmp((*a)->d_name, (*b)->d_name);
}

--------------------------------------------------------------------------

Take a look at libvo/x11_common.c in mplayer's source to see how it
disables the screensaver.

--------------------------------------------------------------------------

Fix envelope loops; they're broken and always have been.
