@@ -116,12 +116,14 @@ APTR GetAudioInterruptHandler() {
116116static __attribute__((interrupt )) void audioInterruptHandler ();
117117
118118void TakeSystem () {
119- #ifndef NO_INT
119+ SystemDMA = custom -> dmaconr ;
120+
120121 Forbid ();
122+
123+ #ifndef NO_INT
121124 //Save current interrupts and DMA settings so we can restore them upon exit.
122125 SystemADKCON = custom -> adkconr ;
123126 SystemInts = custom -> intenar ;
124- SystemDMA = custom -> dmaconr ;
125127
126128 //https://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_3._guide/node0203.html
127129 // Disable -- disable interrupt processing.
@@ -186,9 +188,10 @@ void FreeSystem() {
186188
187189 //Restore all interrupts and DMA settings.
188190 custom -> intena = SystemInts |0x8000 ;
189- custom -> dmacon = SystemDMA |0x8000 ;
190191 custom -> adkcon = SystemADKCON |0x8000 ;
191192#endif
193+ custom -> dmacon = SystemDMA |0x8000 ;
194+
192195 for (int i = 0 ; i < 256 ; i ++ )
193196 {
194197 if (pcmDataTable [i ].dataPtr != NULL )
@@ -215,8 +218,9 @@ void FreeSystem() {
215218
216219#ifndef NO_INT
217220 Enable ();
218- Permit ();
219221#endif
222+ Permit ();
223+
220224 Exit (0 );
221225}
222226
@@ -500,14 +504,14 @@ void showMessage(char *message)
500504// }
501505}
502506
503- void printText (char * message )
507+ void printText (char * message , int ofst_x , int ofst_y )
504508{
505509 if (mainWin )
506510 {
507511 int clientWidth = mainWin -> Width - mainWin -> BorderLeft - mainWin -> BorderRight ;
508512 int clientHeight = mainWin -> Height - mainWin -> BorderTop - mainWin -> BorderBottom ;
509- int text_x = mainWin -> BorderLeft ;
510- int text_y = mainWin -> BorderTop ;
513+ int text_x = mainWin -> BorderLeft + ofst_x ;
514+ int text_y = mainWin -> BorderTop + ofst_y ;
511515 struct IntuiText label = {
512516 1 , 0 , JAM2 , text_x , text_y , NULL , (UBYTE * )message , NULL
513517 };
@@ -536,26 +540,21 @@ void InitHook(struct Hook *hook, ULONG (*c_function)(), APTR userdata)
536540 hook -> h_Data = userdata ;
537541}
538542
539- /*
540- */
541- void main (struct WBStartup * wb )
543+ int WBmain (struct WBStartup * wb )
542544{
543545 SysBase = * ((struct ExecBase * * )4UL );
544546 custom = (struct Custom * )0xdff000 ;
545547
546- TakeSystem ();
547-
548548 // used for printing
549549 DOSBase = (struct DosLibrary * )OpenLibrary ((CONST_STRPTR )"dos.library" , 0 );
550550 if (!DOSBase )
551551 FreeSystem ();
552-
553- #ifdef NOGUI
554- wb = NULL ;
555- #endif
552+
553+ TakeSystem ();
554+
556555 if (wb ) {
557556 // Intuition ライブラリを開く
558- IntuitionBase = (struct IntuitionBase * )OpenLibrary ((CONST_STRPTR )"intuition.library" , 37 );
557+ IntuitionBase = (struct IntuitionBase * )OpenLibrary ((CONST_STRPTR )"intuition.library" , 0 );
559558 if (!IntuitionBase ) {
560559 showMessage ("Failed to load GUI!" );
561560 FreeSystem ();
@@ -701,7 +700,7 @@ VWritef("Completed serial setting.\n", NULL);
701700
702701 for (int i = 0 ;i < 12 * (100 );i ++ )
703702 SineData [12 + i ] = SineData [i ];
704-
703+ /*
705704 SineData[12 * 100 - 12] = -125;
706705 SineData[12 * 100 - 11] = -100;
707706 SineData[12 * 100 - 10] = -75;
@@ -715,10 +714,10 @@ VWritef("Completed serial setting.\n", NULL);
715714 SineData[12 * 100 - 3] = 100;
716715 SineData[12 * 100 - 2] = 125;
717716 SineData[12 * 100 - 1] = 127;
718-
717+ */
719718 pcmDataTable [0 ].dataPtr = SineData ;
720719 pcmDataTable [0 ].length = 12 * 100 ;
721- pcmDataTable [0 ].loop = 12 * 100 - 12 ;
720+ // pcmDataTable[0].loop = 12*100 - 12;
722721 //pcmDataTable[0].loop = 0;
723722
724723 // PLAY SOUND
@@ -869,10 +868,12 @@ VWritef("Completed serial setting.\n", NULL);
869868*/
870869
871870#endif
872- if (mainWin )
873- printText ("MAmi VSIF driver ready." );
874- else
875- printText ("Ready.\n**Press Ctrl-C** to exit. If not, System may crash." );
871+ if (mainWin )
872+ {
873+ printText ("MAmi VSIF driver ready." , 0 , 0 );
874+ printText ("DO NOT touch mouse/key while sounding!" , 0 , 16 );
875+ }else
876+ printText ("Ready.\n**Press Ctrl-C** to exit. If not, System may crash." , 0 , 0 );
876877 //int val = readCMD();
877878 int error = 0 ;
878879 //UBYTE *dataBufPtr = (UBYTE *)readArray(6);
@@ -1075,3 +1076,19 @@ VWritef("Completed serial setting.\n", NULL);
10751076 // END
10761077 FreeSystem ();
10771078}
1079+
1080+ /*
1081+ */
1082+ /* 通常のmain関数:CLIまたはWorkbench起動両方をここから呼ぶ */
1083+ int main (int argc , char * * argv ) {
1084+ struct WBStartup * wb = (struct WBStartup * )argv ;
1085+ if (argc == 0 ) {
1086+ // GUIから起動された
1087+ } else {
1088+ // CLIから起動された
1089+ }
1090+ #ifdef NOGUI
1091+ wb = NULL ;
1092+ #endif
1093+ WBmain (wb );
1094+ }
0 commit comments