Page 1 of 1

Some questions

Posted: Tue May 06, 2008 2:16 pm
by TmEE
I'm gonna port MD tracker to FreeBASIC (since I've hit some major QB limitation) and I've managed to run into some troubles...

1) How can I get keyboard scan codes ? INP(&H60) doesn't do anymore...

2) There is no ON TIMER anymore... I need something that executes part of code after (insert time here)... in QB45 I just wrote new value to PIT and got ON TIMER(1) to do what required...

3) I can do MIDI anymore by just writing to $330 ($ means HEX here... I'm 68K programmer... Mega Drive / Genesis kicks @$$)...

Posted: Tue May 06, 2008 3:50 pm
by Antoni
1.- FreeBASIC has a built-in multikey
as those found in QB libraries.

2.-You can emulate ON-TIMER using a background thread. See code .This solution won't compile for DOS...

3.- FB can write to port to $330 if your present compiler can do it. But this is not likely to work in other people's soundcards. For alternative solutions see this thread

Posted: Tue May 06, 2008 6:40 pm
by TmEE
multikey has no use in my case, I just need keyboard scan codes... hit a key down / release key, the scan code... one key at time.

I'll try to understand the ON TIMER emulation.... I have zero experience with windows programming... and I will not do any pmode DOS stuff...

And for MIDI, writing to $330 won't do in Windows... only in DOS it seems... and I DO NOT want to use any libraries. And I need something very basic.. I don't play MIDI files, I just send in some MIDI commands... stuff like Key On/Off, Program change, Parameter change etc.... I guess Windows API comes here...

Posted: Tue May 06, 2008 7:33 pm
by MystikShadows
You're right, Windows API is the better way to go in Windows. I did a series on MIDI Programming in QB Express I have 3 parts so far and working on the 4th part.

Part one .MID File format
http://www.petesqbsite.com/sections/exp ... .html#midi

Part Two - Processing of a midi file with interpreted results.
http://www.petesqbsite.com/sections/exp ... ogramming2

Part tree - Actual formatting and sending of MIDI messages to the MIDI devices.
http://www.petesqbsite.com/sections/exp ... ogramming3

The last one shows how to use the API to open MIDI channels formulate and send MIDI messages of all types (note on/off, and the likes.).

For good timing, the API again in Windows, see the QueryPerformanceTimer function for details.


Hope these help.

Posted: Tue May 06, 2008 8:11 pm
by TmEE
I've got all answers for my MIDI stuff. Thank you MystikShadows. I might be able to add a MIDI file exporting option too into my tracker.

Scancodes probably come form WinAPI too...

Now I just need to get the playback routine called every 49.4Hz (the closest speed to Mega Drive I got using PCs PIT in QB version).

What a big bite... I need to digest it a little...

EDIT : if anyone's interested in the DOS verison, here's some OLD version : http://www.spritesmind.net/_GenDev//for ... .php?t=220 (latest is 0.4a, but its used for commercial stuff...)

Posted: Wed May 07, 2008 8:51 am
by MystikShadows
You're welcome. :-).

Glad it could be of help. I can't wait to see what you'll come with :-).