X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fimfplay.c;h=697b6d3611e7f3d7940223948a5f91b58b0756a4;hb=2f706222157c9d186db8adf361542bb76ba259c6;hp=7fb6753e03abbba37982d3a636538c0d49666a9f;hpb=5b7cb93f7c6a5a008302efff5f68023005a4daaf;p=16.git diff --git a/src/imfplay.c b/src/imfplay.c index 7fb6753e..697b6d36 100755 --- a/src/imfplay.c +++ b/src/imfplay.c @@ -19,6 +19,8 @@ #include "src/lib/16_mm.h" #include "src/lib/16_hc.h" #include "src/lib/16_dbg.h" +#include "src/lib/16_sd.h" + // #include // #include /* this is where Open Watcom hides the outp() etc. functions */ // #include @@ -30,13 +32,9 @@ // #include // #include -#include -#include -#include /* 8254 timer */ -#include -#include +extern struct glob_game_vars *ggvv; -static void (interrupt *old_irq0)(); +/*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; @@ -113,11 +111,12 @@ int imf_load_music(const char *path, global_game_variables_t *gvar) { return 1; } -/* WARNING: subroutine call in interrupt handler. make sure you compile with -zu flag for large/compact memory models */ -void interrupt irq0() { - irq0_ticks++; - if ((irq0_cnt += irq0_add) >= irq0_max) { - irq0_cnt -= irq0_max; +// WARNING: subroutine call in interrupt handler. make sure you compile with -zu flag for large/compact memory models +void interrupt irq0() +{ + ggvv->ca.sd.irq0_ticks++; + if ((ggvv->ca.sd.irq0_cnt += ggvv->ca.sd.irq0_add) >= ggvv->ca.sd.irq0_max) { + ggvv->ca.sd.irq0_cnt -= ggvv->ca.sd.irq0_max; old_irq0(); } else { @@ -185,12 +184,11 @@ void adlib_shut_up() { } adlib_apply_all(); -} +}*/ 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; @@ -198,53 +196,40 @@ void main(int argc,char **argv) { #ifdef __DEBUG_MM_ dbg_debugmm=1; #endif - MM_Startup(&gvar); - PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); - CA_Startup(&gvar); + ggvv=&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 (!imf_load_music(argv[1], &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); - irq0_cnt = 0; - irq0_add = 182; - irq0_max = 1000; /* about 18.2Hz */ - old_irq0 = _dos_getvect(8);/*IRQ0*/ + old_irq0 = _dos_getvect(8); /*IRQ0*/ _dos_setvect(8,irq0); - adlib_shut_up(); - shutdown_adlib_opl3(); // NTS: Apparently the music won't play otherwise _cli(); - irq0_ticks = ptick = 0; + gvar.ca.sd.irq0_ticks = ptick = 0; _sti(); while (1) { unsigned long adv; _cli(); - adv = irq0_ticks - ptick; + adv = gvar.ca.sd.irq0_ticks - ptick; if (adv >= 100UL) adv = 100UL; - ptick = irq0_ticks; + ptick = gvar.ca.sd.irq0_ticks; _sti(); while (adv != 0) { - imf_tick(); + SD_imf_tick(&gvar); adv--; } @@ -259,12 +244,10 @@ void main(int argc,char **argv) { } // printf("contents of the imf_music\n[\n%s\n]\n", imf_music); - imf_free_music(&gvar); - adlib_shut_up(); + SD_imf_free_music(&gvar); + 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); }