Skip to content

Commit

Permalink
player: minor amiga clean-up.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Mar 31, 2024
1 parent 684cff5 commit 5d39997
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion include/wildplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ extern audiodrv_info audiodrv_openal;
extern void msleep(uint32_t msec);

#if defined(WILDMIDI_AMIGA)
extern void amiga_sysinit (void);
extern void amiga_sysinit (void); /* must be called first. */

extern void amiga_inittty (void);
extern void amiga_resetty (void);
extern int amiga_getch (unsigned char *ch);
extern void amiga_usleep (uint32_t usec);
#endif
Expand Down
12 changes: 9 additions & 3 deletions src/player/amiga.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ static BPTR amiga_stdin, amiga_stdout;
#define MODE_NORMAL 0

static void amiga_atexit (void) {
if (amiga_stdin)
SetMode(amiga_stdin, MODE_NORMAL);
if (TimerBase) {
WaitIO((struct IORequest *) timerio);
CloseDevice((struct IORequest *) timerio);
Expand Down Expand Up @@ -84,11 +82,19 @@ void amiga_sysinit (void) {
SendIO((struct IORequest *) timerio);
WaitIO((struct IORequest *) timerio);

atexit (amiga_atexit);
}

void amiga_inittty (void) {
amiga_stdout = Output();
amiga_stdin = Input();
SetMode(amiga_stdin, MODE_RAW);
}

atexit (amiga_atexit);
void amiga_resetty (void) {
if (amiga_stdin) {
SetMode(amiga_stdin, MODE_NORMAL);
}
}

int amiga_getch (unsigned char *c) {
Expand Down
2 changes: 1 addition & 1 deletion src/player/wildmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,10 @@ int main(int argc, char **argv) {
return (1);
}

wm_inittty();
#ifdef WILDMIDI_AMIGA
amiga_sysinit();
#endif
wm_inittty();

WildMidi_MasterVolume(master_volume);

Expand Down
8 changes: 6 additions & 2 deletions src/player/wm_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ void wm_getch(unsigned char *c) {
if (amiga_getch (c) <= 0)
*c = 0;
}
void wm_inittty(void) {}
void wm_resetty(void) {}
void wm_inittty(void) {
amiga_inittty();
}
void wm_resetty(void) {
amiga_resetty();
}

#else /* unix case: */

Expand Down

0 comments on commit 5d39997

Please sign in to comment.