ScreenWindow

From Moonlight Design
Jump to navigation Jump to search
Screen shot of Jingle Bell's Win16 port, which uses ScreenWindow

ScreenWindow is a text console and MIDI sound library for Win16 programs that was written to ease the annual December holiday song mid-year project for first-year computer science students at Grapevine High School when the course moved from DOS to Windows 3.1.

ScreenWindow's codebase was used in the subsequent Win32 projects ScreenWindowX and EzMIDI32.

Download

Documentation

EzMIDI32 has better documentation, which almost entirely applies to ScreenWindow, too.

The functions below were written with contracts that resemble their implementations in DOS.

Function Description
getch() Reads the next character; does not wait for an enter; if enter, it reads it as cr; nothing is printed
getchar() Reads the next character from stdin; waits for an enter; displays entry as it's typed including enter. Enter is read as newline. if newline is entry, it writes cr/nl pair (beginning of next line). First nl entered is not echoed; subsequent ones are. NLs entered are not reflected in memory; only the last cr (the one cvted to nl) is.
fgetchar() Same as getchar()
getche() Same as getch(), but echos character. Reads enter as carriage return. If newline is input, it goes to next line without cr on echo.
gets(str) Echos input including enter. NL behavior is same as getchar(), except enter is not reflected in gets as it is in getchar.
perror(str) Prints str then ": Error %i", where %i is current error number
puts(str) Prints string, then a newline.
cgets(str) str[0] is the max number of chars to get - 1. str[1] is the number of characters read - 1. When NL is entered, it goes to next line without cr first. NLs that are entered are saved in string. Very wild and wacky.
cputs(str) Like puts, but does not translate NL into CR/NL.
cscanf, cprintf Exactly like their scanf/printf counterparts, except that cprintf does not translate newlines into cr/nl.
getpass(str) Asks for a password and returns a pointer to a string that has 8 chars in it, not counting the terminating null. Immediately after the 8th character is entered, the function automatically returns. Pressing enter before the 8th character returns the function.
gettext(x, y, x, y, buffer) Gets text from the screen, ignoring CRs and NLs.
puttext(x, y, x, y, buffer) Puts buffer onto the screen.
highvideo, lowvideo, normvideo Makes fgColor high/low/normal intensity
delline Moves remaining rows up by 1.
window(x, y, x, y) Creates a text window.
_setcursortype(type) Selects no/underscore/block cursor
textattr(attr) Selects attr text attribute
putch Writes a character, but does not translate newline to CR/NL.
insline Inserts a blank line in the current text window.

The library included the following MIDI functions:

  • midiInitialize
  • midiNoteOn(channel, note, pressure : integer)
  • midiNoteOff(channel, note, velocity : integer)
  • midiInstrument(channel, instrument : integer)
  • midiUninitialize
  • midiHoldPedal(channel : integer; hold : boolean)
  • midiWait(ms : integer)