Skip to content

Commit 1c2e42f

Browse files
IO interface improvements; optimization of the NOTE TUNE submodule and virtual piano visualization
1 parent 09fa19b commit 1c2e42f

22 files changed

Lines changed: 125 additions & 118 deletions

SFXMM.pas

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,39 @@ procedure init();
9595

9696
getTheme(0,PFCOLS); // set default theme color
9797

98-
fillchar(@screen[0],20,$40);
99-
10098
Init_UI(RESOURCES_ADDR);
10199
chars_alphaNum:=resptr[scan_to_scr];
102100
keys_alphaNum:=resptr[scan_key_codes];
103101
note_names:=resptr[str_NoteNames];
104102
keys_notes:=resptr[scan_piano_codes];
105103
themesNames:=resptr[themes_names_list];
104+
octShift:=resptr[octaveShifts];
106105

107-
fillchar(@listBuf,LIST_BUFFER_SIZE,0);
108-
109-
currentMenu:=0;
110-
106+
clearListBuf();
111107
IO_clearAllData();
112108

113109
reset_pianoVis();
114110
updatePiano();
115111
SFX_Start();
116112

117113
// load defaults
118-
IOLoadTheme(defaultThemeFile);
114+
setFilename(defaultThemeFile,otherFile);
115+
IOLoadTheme();
119116
IOLoadDefaultNoteTable();
120117

121118
// set defaults files
119+
clearFilename(otherFile);
122120
setFilename(defaultFileName,currentFile);
123121
setFilename(defaultSearchPath,searchPath);
122+
123+
currentMenu:=0;
124+
124125
end;
125126

126127
begin
127128
init();
128129
repeat
129-
fillchar(@screen,20,$40);
130+
clearTopMenu();
130131
if optionsList(menu_top,width_menuTop,5,currentMenu,key_Left,key_Right) then
131132
case currentMenu of
132133
0: GSDModule();

modules/io/io.pas

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
procedure IOModule();
66
begin
77
section:=1;
8-
fillchar(@screen,20,$40);
8+
clearTopMenu();
99
if optionsList(menu_IO,width_menuTop,5,section,key_Left,key_Right) then
1010
begin
1111
case section of
12+
0: exit;
1213
1: IOLoad();
1314
2: IOSave();
1415
4: IOQuit();

modules/io/io_dir.inc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var
1010

1111
begin
1212
SFX_End();
13-
fillchar(@listBuf,LIST_BUFFER_SIZE,0);
13+
clearListBuf();
1414
listOfs:=0; filesCount:=0;
1515
fillchar(@f.Name,16,0);
1616
FindFirst(path, faAnyFile, f);
@@ -63,7 +63,6 @@ begin
6363

6464
findNext(f);
6565
end;
66-
clearModuleBar();
6766
if (IOResult=1) then
6867
begin
6968
if (filesCount=IO_pageLimit) then
@@ -98,15 +97,13 @@ var
9897
begin
9998
listStart:=0; listPage:=0;
10099
repeat
101-
clearModule(); // fillchar(@moduleBar[20],180,$40);
102100
filesCount:=IOReadDir(searchPath,listStart);
103101
if filesCount>0 then
104102
begin
105103
clearModuleBar();
106104
putMultiText(msg_IO_DirPrompt,0);
107105
selFile:=0;
108106
selFile:=listChoice(0,2,width_fileList,9,selFile,listBuf,filesCount,false);
109-
clearModuleBar();
110107
if (selFile=-1) then
111108
begin
112109
result:=false; break;
@@ -143,11 +140,12 @@ begin
143140
end
144141
else
145142
begin
146-
putMultiText(msg_IO_noFiles,1);
143+
putMultiText(msg_IO_noFiles,0);
147144
result:=false;
148145
break;
149146
end;
150147
until false;
148+
clearModuleBar();
151149
end;
152150

153151
function IOPrompt(var promptFile:string):boolean;

modules/io/io_error.inc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,24 @@ begin
1515
screen2video();
1616
end;
1717
until kbcode<>255; kbcode:=255;
18-
fillchar(@statusBar,20,0);
19-
screen2video();
18+
clearStatusBar();
2019
end;
2120

22-
procedure showError(msg:byte);
21+
procedure drawError(msg:byte);
2322
begin
24-
fillchar(@statusBar,20,0);
23+
clearStatusBar();
2524
putMultiText(msg,0);
25+
end;
26+
27+
procedure showError(msg:byte);
28+
begin
29+
drawError(msg);
2630
flashError();
2731
end;
2832

2933
procedure IOError(err:byte);
3034
begin
31-
fillchar(@statusBar,20,0);
32-
putMultiText(msg_IO_Error,0);
35+
drawError(msg_IO_Error);
3336
putValue(14,11,err,3,0);
3437
flashError();
3538
end;

modules/io/io_load.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ var
124124
end;
125125

126126
begin
127-
fillchar(@statusBar,20,0);
127+
clearStatusBar();
128128

129129
err:=openFile(filename,file_read);
130130
while (err=IO_OK) and (IOResult<>3) do

modules/io/io_manage.inc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
procedure setFilename(var fn,dest:string);
1+
procedure clearFilename(var dest:string);
22
begin
33
fillchar(@dest,FILEPATHMaxLength+1,0);
4+
end;
5+
6+
procedure setFilename(var fn,dest:string);
7+
begin
8+
clearFilename(dest);
49
move(@fn,@dest,byte(fn[0])+1);
510
end;
611

712
procedure closeFile();
813
begin
9-
fillchar(@statusBar,20,0);
14+
clearStatusBar();
1015
close(f);
1116
SFX_Start();
1217
end;
@@ -21,19 +26,17 @@ begin
2126
assign(f,fn);
2227
case mode of
2328
file_read: begin
24-
reset(f,1);
25-
msgPtr:=msg_IO_reading;
26-
end;
29+
reset(f,1);
30+
msgPtr:=msg_IO_reading;
31+
end;
2732
file_write: begin
28-
rewrite(f,1);
29-
msgPtr:=msg_IO_writing;
30-
end;
33+
rewrite(f,1);
34+
msgPtr:=msg_IO_writing;
35+
end;
3136
end;
3237
result:=IOResult;
3338
if (IOResult<>1) then
34-
begin
35-
closeFile();
36-
end
39+
closeFile()
3740
else
3841
begin
3942
result:=IO_OK;

modules/io/io_quit.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ var
55
begin
66
answer:=messageBox(msg_IO_Quit,color_choice,but_IO_Quit,16,2,1,key_Up,key_Down);
77
if answer=0 then halt(1);
8-
move(@tmpbuf[40],@screen[40],60)
98
end;

modules/io/io_save.inc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ var
5858
dataSize:word;
5959

6060
begin
61-
IOofs:=0;
61+
IOOfs:=0;
6262
push2IOBuf(@section_SONG,5);
6363
dataSize:=$100;
6464
push2IOBuf(@dataSize,2);
@@ -74,12 +74,13 @@ var
7474
i:byte;
7575

7676
begin
77+
IOOfs:=0;
7778
// prepare main section data
78-
move(@section_main,@IOBuf,5);
79-
IOBuf[5]:=SFXMM_VER1_1;
80-
IOBuf[6]:=SONGNameLength;
81-
move(@SONGTitle[1],@IOBuf[7],SONGNameLength);
82-
BlockWrite(f,IOBuf,5+1+1+SONGNameLength);
79+
push2IOBuf(@section_main,5); // move(@section_main,@IOBuf,5);
80+
i:=SFXMM_VER1_1; push2IOBuf(@i,1); // IOBuf[5]:=SFXMM_VER1_1;
81+
i:=SONGNameLength; push2IOBuf(@i,1); // IOBuf[6]:=SONGNameLength;
82+
push2IOBuf(@SONGTitle[1],SONGNameLength); // move(@SONGTitle[1],@IOBuf[7],SONGNameLength);
83+
BlockWrite(f,IOBuf,IOOfs);
8384

8485
if IOResult<>1 then exit(false);
8586

modules/sfx/notetune_edit.inc

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
procedure NoteTuneLoop();
22
var
3-
_pos,notePos,noteShift,noteVal,noteKey:byte;
3+
_pos,notePos,noteShift,noteVal,noteKey,noteOct:byte;
44

55
begin
66
notePos:=0; _pos:=0;
7-
noteShift:=currentOct*12;
7+
noteOct:=currentOct;
88
definedNoteTune:=pointer(NOTE_TABLE_ADDR+currentNoteTableOfs);
99

1010
reset_pianoVis();
11-
updateNoteTune(noteShift);
11+
updateNoteTune(noteOct);
1212
colorVLine(tuneBarsPos+notePos,0,5,3);
1313
screen2video();
1414
repeat
@@ -18,33 +18,28 @@ begin
1818
key_ESC: break;
1919
end;
2020

21-
if controlSelectionKeys(key,key_Left,key_Right,_pos,0,63) then
22-
begin
23-
noteShift:=(_pos div 12)*12;
24-
notePos:=_pos mod 12;
25-
end
26-
else
21+
if not controlSelectionKeys(key,key_Left,key_Right,_pos,0,63) then
2722
begin
2823
noteKey:=pianoKeyScan(0);
2924
if noteKey<>255 then
30-
begin
3125
_pos:=noteKey;
32-
noteShift:=(_pos div 12)*12;
33-
notePos:=_pos mod 12;
34-
end;
3526
end;
3627

28+
noteOct:=_pos div 12;
29+
noteShift:=octShift[noteOct];
30+
notePos:=_pos mod 12;
31+
3732
noteVal:=definedNoteTune[_pos];
3833
if controlSelectionKeys(key,key_Up,key_Down,noteVal,0,255) then
3934
definedNoteTune[_pos]:=noteVal;
4035

41-
updateNoteTune(noteShift);
36+
updateNoteTune(noteOct);
4237
colorVLine(tuneBarsPos+notePos,0,5,3);
4338
screen2video();
4439
end;
4540
updatePianoVis();
4641
until false;
47-
updateNoteTune(noteShift);
42+
updateNoteTune(noteOct);
4843
SFX_Off();
4944
reset_pianoVis();
5045
end;

modules/sfx/notetune_io.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,11 @@ begin
2424
IOError(IOResult);
2525
end;
2626
end;
27+
28+
procedure NoteTune_IO_Options();
29+
begin
30+
case IO_Options of
31+
0:NoteTune_load();
32+
1:NoteTune_save();
33+
end;
34+
end;

0 commit comments

Comments
 (0)