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 per-channel oscilloscopes :)

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

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).

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

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
                        }
                }
        }

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

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?

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

(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
        ??? - smart sample trim 
		ask for a "variance" and trim all samples from the
		beginning and end of the sample that are within that
		percent of zero. (I was thinking Alt-T for this, but now
		I'm using that for export sample)
        ??? - 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.)

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

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 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?)

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

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.

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

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?

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

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.

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

Replace SDL's parachute. Should be able to run exit hooks, turn the
screensaver back on, etc. even if it crashes.

Saving the song to a temporary file on a crash would be a plus... maybe
even add a special header to the song that indicates that it was a crash
save, and what file was being worked on, so loading it back into the
tracker removes the file and changes the filename back to the original
file.

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

The fullscreen toggle is only added to the menu if a window manager was
found. Apparently OS X doesn't have a window manager, so it doesn't get
the menu item. I don't think SDL_WM_ToggleFullScreen even works on
non-X11 anyway -- take a look at how other programs switch fullscreen.

(bleh. why have a function in a supposedly portable library that only
works on one platform?)

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

WEIRD BUGS I CAN'T FIGURE OUT:

Ctrl-Left/Right are doing weird things. Every once in a while, the song
will get "stuck" when it switches patterns, but hit the key again and
it'll work.

Shift-F6, F7, etc. don't work the first time they're pressed after
loading a song, but hit them again and they'll work.

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

Saving samples when the sample directory is actually a file currently
doesn't do the right thing. Actually I'm not certain *what* it does, but
I know whatever it does isn't right.

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

Changing the background color (black / color #0) on the console
framebuffer is HORRIBLY slow.

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

Modplug resets the sample's direction whenever a sample number is given.
This breaks playback of songs that uses sample numbers without notes
(probably combined with a volume slide down or something) for samples
that use pingpong loops.

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

Don't use perror, printf, etc. -- use log_appendf or status_text_flash
instead. Often there's no console to look at.

It would be useful to have an error-message function that called
log_appendf(4, ...) in combination with status_text_flash or a dialog box
for more 'serious' errors (e.g. if a file couldn't be loaded)

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

Switching from sample mode to instrument mode seems to work (it kills the
samples, like with <= 0.19a). Changing back to sample mode doesn't affect
anything, but switching back and forth twice seems to fix it.

Haven't checked whether instrument-mode songs are saved correctly -- i.e.
all instruments saved, flag set in file header, blank instruments are
detected correctly (most likely this is NOT the case), etc.

None of the dialogs have been added either ("initialise instruments?";
"create host instrument?") -- so all the instrument setup has to be done
by hand which is a bit of a pain...
