// #include <fcntl.h>
// #include <math.h>
// #include <dos.h>
-struct glob_game_vars *ggvv;
-static void (interrupt *old_irq0)();
+extern struct glob_game_vars *ggvv;
+
/*static void (interrupt *old_irq0)();
static volatile unsigned long irq0_ticks=0;
static volatile unsigned int irq0_cnt=0,irq0_add=0,irq0_max=0;
PRINTBB;
return 1;
}
-*/
+
// WARNING: subroutine call in interrupt handler. make sure you compile with -zu flag for large/compact memory models
void interrupt irq0()
{
p8259_OCW2(0,P8259_OCW2_NON_SPECIFIC_EOI);
}
}
-/*
+
void imf_tick() {
if (imf_delay_countdown == 0) {
do {
void main(int argc,char **argv) {
static global_game_variables_t gvar;
- unsigned long tickrate = 700;
- unsigned long ptick;
+ unsigned long ptick, tickrate = 700;
int c;
#ifdef __DEBUG_CA__
dbg_debugca=1;
dbg_debugmm=1;
#endif
ggvv=&gvar;
- MM_Startup(&gvar);
- PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar);
- CA_Startup(&gvar);
+ StartupCAMMPM(&gvar);
printf("ADLIB FM test program IMFPLAY\n");
if (argc < 2) {
printf("You must specify an IMF file to play\n");
- return;
+// return;
}
- if (!init_adlib()) {
- printf("Cannot init library\n");
- return;
- }
- if (!probe_8254()) { /* we need the timer to keep time with the music */
- printf("8254 timer not found\n");
- return;
- }
+ SD_Initimf(&gvar);
if (!SD_imf_load_music(argv[1], &gvar)) {
printf("Failed to load IMF Music\n");
- return;
+// return;
}
write_8254_system_timer(T8254_REF_CLOCK_HZ / tickrate);
- gvar.ca.sd.irq0_cnt = 0;
- gvar.ca.sd.irq0_add = 182;
- gvar.ca.sd.irq0_max = 1000; /* about 18.2Hz */
- old_irq0 = _dos_getvect(8);/*IRQ0*/
+ old_irq0 = _dos_getvect(8); /*IRQ0*/
_dos_setvect(8,irq0);
- SD_adlib_shut_up();
- shutdown_adlib_opl3(); // NTS: Apparently the music won't play otherwise
_cli();
gvar.ca.sd.irq0_ticks = ptick = 0;
_sti();
SD_adlib_shut_up();
shutdown_adlib();
_dos_setvect(8,old_irq0);
- write_8254_system_timer(0);/* back to normal 18.2Hz */
- PM_Shutdown(&gvar);
- CA_Shutdown(&gvar);
- MM_Shutdown(&gvar);
+ write_8254_system_timer(0); /* back to normal 18.2Hz */
+ ShutdownCAMMPM(&gvar);
}