From 5b7cb93f7c6a5a008302efff5f68023005a4daaf Mon Sep 17 00:00:00 2001 From: sparky4 Date: Fri, 7 Apr 2017 14:44:03 -0500 Subject: [PATCH] p16 is being worked on a bunch by me wwww [16_ca needs huge amounts of work and I should remember what needs to be done soon][OpenVGMFile needs to be ported to 16_snd.c]going to port rest of code to borland c some time so we can use the core components of id engine here [going to add 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop system with PROPER data usage with CAMMPM] MM_ShowMemory is quite buggy on real machines. i need to debug it and fix added a struct printer[gvar.mm is FUCKING HUGE 14402 bytes FAT\!]imfplay works better than vgmtest --- data/02.imf | Bin 0 -> 8426 bytes data/searchin.imf | Bin 0 -> 12978 bytes makefile | 17 ++- src/exmmtest.c | 23 ++-- src/imfplay.c | 270 ++++++++++++++++++++++++++++++++++++++++ src/lib/16_map.c | 2 + src/lib/16_tdef.h | 11 ++ src/lib/vgmsnd/vgmSnd.c | 12 +- src/lib/vgmsnd/vgmSnd.h | 4 +- src/vgmtest.c | 25 ++-- 10 files changed, 333 insertions(+), 31 deletions(-) create mode 100755 data/02.imf create mode 100755 data/searchin.imf create mode 100755 src/imfplay.c diff --git a/data/02.imf b/data/02.imf new file mode 100755 index 0000000000000000000000000000000000000000..364012d4f6669288f5b33b6f4f4cde28d2adcb8b GIT binary patch literal 8426 zcmbW6?Q_&u702%`CC~&D*^H>nh&-t@feq|Z#%jj`C0Lr!@(}7^QA-6ZPgS1Aw-)V8 zTiOm#plaVV2@u}tCcD|ZaeQdCm2rlD!9F;nRvjPeIAiOKpL6d$_jh*LL~LeuZub1{ z!#U@BzUQ3#+p~)ue?Q?fm(ThKo%>mvbC3MZx$o?BZgI}J-y+|D{O8E`B7Xw;669|n z--!Gd$R9<18u?P>Zz8{!&)5I%+;>kpw`{(1Z}EK-pMA)_hio~rxB1@BXFswhk$no; z@A!Tnd%nV+kFn=d?74zHe~)|%@>h``ME*4LJCOeY`TfX$iT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o(!-p(MvrR4|aG;7VO z?~_d6%4E&;(&|0vX5R;23#Iv4p!1rO;4>LcgdOy)9bE)d%V@1qt$b3H(}bF(AmIR z7=<3OH}dH83O(l>m+-?kBkKLqIY_d@kC>vfvvAdUg6$4h$36AcV_ zzp-||Q=Wq)TF@UYFqiO@c&mCJcy3Ry=6Fs2tFhVa>%h64gG9fcd%Z=Rr~a$@9q`uH z-$3}8j@N(LuEI=NA3)D=1-7f+1Ps~vU^?#*7O9trCmAa`?@%8^?`wV}o3M{&dTpL} zlz+!ZZh9f|obBy3P1Q3%s}|dI=CaOtM%6PUzE#u6HpGJJJR{cAnb#DDgq`{xS>#K4 zEO8j|wr)>gSOy1Gt)}yeovt&<6ziVc6U5k%eHL4+vzIFyS}b&XWm(Et2>uic56Tya zQ`LC|<88$iw~gU~?^115*|6wiEROI^QFqL}-WTy!olBrsuSp{|qU|!?N*Sf=ThU26 zm*`cmkHMqPkl7D{w@j0BWRq!}_dm(GgvUOsqgThiTt~;aur}YychvY66X4tGXvIHd zVt+QCJ2>WUsE!76ju-U-88c=6)t(=JU*R=my-v>fHC&8wj&(!l3ao3jYgs2F!)T9s za~&+kIvCyzi_n@vh6+PDzC_;0hhQ5oeHikR;5}r@yEB-`GNLE(%v59IvcYZLv>NfYdSvwv$Cb-V7?#oKF9pWo{Ik`L4P-`zlGM{ zH4A(C{|EZN2OGlN+0*ym`JQ{jxeM + * + * Compiles for intended target environments: + * - MS-DOS [pure DOS mode, or Windows or OS/2 DOS Box] + */ + +#include "src/lib/16_head.h" +#include "src/lib/16_tail.h" +#include "src/lib/16_pm.h" +#include "src/lib/16_ca.h" +#include "src/lib/16_mm.h" +#include "src/lib/16_hc.h" +#include "src/lib/16_dbg.h" +// #include +// #include /* this is where Open Watcom hides the outp() etc. functions */ +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include + +#include +#include +#include /* 8254 timer */ +#include +#include + +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; + +#pragma pack(push,1) +struct imf_entry { + uint8_t reg,data; + uint16_t delay; +}; +#pragma pack(pop) + +static struct imf_entry* imf_music=NULL; +static struct imf_entry* imf_play_ptr=NULL; +static struct imf_entry* imf_music_end=NULL; +static uint16_t imf_delay_countdown=0; + +#define PRINTBB {\ + printf("-------------------------------------------------------------------------------\n");\ + printf("buffer:\n");\ + printf("bigbuffer %Fp\t", gvar->ca.audiosegs[0]);\ + printf("&%Fp\n", MEMPTR gvar->ca.audiosegs[0]);\ + printf("imf_music %Fp\t", imf_music);\ + printf("&%Fp\n", imf_music);\ + printf("imf_play_ptr %Fp\t", imf_play_ptr);\ + printf("&%Fp\n", imf_play_ptr);\ + printf("imf_music_end %Fp\t", imf_music_end);\ + printf("&%Fp\n", imf_music_end);\ + printf("-------------------------------------------------------------------------------\n");\ +} + +void imf_free_music(global_game_variables_t *gvar) { + if (imf_music) free(imf_music); + MM_FreePtr(MEMPTR gvar->ca.audiosegs[0], gvar); + imf_music = imf_play_ptr = imf_music_end = NULL; + imf_delay_countdown = 0; +} + +int imf_load_music(const char *path, global_game_variables_t *gvar) { + unsigned long len; + unsigned char buf[8]; + int fd; + + imf_free_music(gvar); + + fd = open(path,O_RDONLY|O_BINARY); + if (fd < 0) return 0; + + len = lseek(fd,0,SEEK_END); + lseek(fd,0,SEEK_SET); + read(fd,buf,2); + if (buf[0] != 0 || buf[1] != 0) // type 1 IMF + len = *((uint16_t*)buf); + else + lseek(fd,0,SEEK_SET); + + if (len == 0 || len > 65535UL) { + close(fd); + return 0; + } + len -= len & 3; + +// imf_music = malloc(len); + MM_GetPtr(MEMPTR gvar->ca.audiosegs[0],len, gvar); + imf_music = (struct imf_entry *)gvar->ca.audiosegs[0]; + if (imf_music == NULL) { + close(fd); + return 0; + } + read(fd,imf_music,len); + close(fd); + + imf_play_ptr = imf_music; + imf_music_end = imf_music + (len >> 2UL); + PRINTBB; + 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; + old_irq0(); + } + else { + p8259_OCW2(0,P8259_OCW2_NON_SPECIFIC_EOI); + } +} + +void imf_tick() { + if (imf_delay_countdown == 0) { + do { + adlib_write(imf_play_ptr->reg,imf_play_ptr->data); + imf_delay_countdown = imf_play_ptr->delay; + imf_play_ptr++; + if (imf_play_ptr == imf_music_end) + { + printf("replay\n"); + imf_play_ptr = imf_music; + } + } while (imf_delay_countdown == 0); + } + else { + imf_delay_countdown--; + } +} + +void adlib_shut_up() { + int i; + + memset(adlib_fm,0,sizeof(adlib_fm)); + memset(&adlib_reg_bd,0,sizeof(adlib_reg_bd)); + for (i=0;i < adlib_fm_voices;i++) { + struct adlib_fm_operator *f; + f = &adlib_fm[i].mod; + f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1; + f = &adlib_fm[i].car; + f->ch_a = f->ch_b = f->ch_c = f->ch_d = 1; + } + + for (i=0;i < adlib_fm_voices;i++) { + struct adlib_fm_operator *f; + + f = &adlib_fm[i].mod; + f->mod_multiple = 1; + f->total_level = 63 - 16; + f->attack_rate = 15; + f->decay_rate = 4; + f->sustain_level = 0; + f->release_rate = 8; + f->f_number = 400; + f->sustain = 1; + f->octave = 4; + f->key_on = 0; + + f = &adlib_fm[i].car; + f->mod_multiple = 1; + f->total_level = 63 - 16; + f->attack_rate = 15; + f->decay_rate = 4; + f->sustain_level = 0; + f->release_rate = 8; + f->f_number = 0; + f->sustain = 1; + f->octave = 0; + f->key_on = 0; + } + + adlib_apply_all(); +} + +void main(int argc,char **argv) { + static global_game_variables_t gvar; + unsigned long tickrate = 700; + unsigned long ptick; + int c; +#ifdef __DEBUG_CA__ + dbg_debugca=1; +#endif +#ifdef __DEBUG_MM_ + dbg_debugmm=1; +#endif + MM_Startup(&gvar); + PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); + CA_Startup(&gvar); + printf("ADLIB FM test program IMFPLAY\n"); + if (argc < 2) { + printf("You must specify an IMF file to play\n"); + 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; + } + + if (!imf_load_music(argv[1], &gvar)) { + printf("Failed to load IMF Music\n"); + 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*/ + _dos_setvect(8,irq0); + + adlib_shut_up(); + shutdown_adlib_opl3(); // NTS: Apparently the music won't play otherwise + _cli(); + irq0_ticks = ptick = 0; + _sti(); + + while (1) { + unsigned long adv; + + _cli(); + adv = irq0_ticks - ptick; + if (adv >= 100UL) adv = 100UL; + ptick = irq0_ticks; + _sti(); + + while (adv != 0) { + imf_tick(); + adv--; + } + + if (kbhit()) { + c = getch(); + if (c == 0) c = getch() << 8; + + if (c == 27) { + break; + } + } + } +// printf("contents of the imf_music\n[\n%s\n]\n", imf_music); + + imf_free_music(&gvar); + 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); +} diff --git a/src/lib/16_map.c b/src/lib/16_map.c index bcda288f..e598d36b 100755 --- a/src/lib/16_map.c +++ b/src/lib/16_map.c @@ -20,6 +20,8 @@ * */ +//TODO USE CA AND THIS FILE FORMAT + #include "src/lib/16_map.h" #include diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index c5775387..c87b272e 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -594,6 +594,17 @@ typedef struct //========================================================================== +/* +#pragma pack(push,1) +typedef struct imf_entry { + uint8_t reg,data; + uint16_t delay; +} imf_entry_t; +#pragma pack(pop) +*/ + +//========================================================================== + //from 16_ca //========================================================================== diff --git a/src/lib/vgmsnd/vgmSnd.c b/src/lib/vgmsnd/vgmSnd.c index 1bd719f8..d41f2abe 100755 --- a/src/lib/vgmsnd/vgmSnd.c +++ b/src/lib/vgmsnd/vgmSnd.c @@ -137,7 +137,7 @@ static const UINT8 CHN_OPMASK_REV[0x20] = 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; -UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile) +UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile, global_game_variables_t *gvar) { size_t hdrSize; size_t readEl; // 'elements' read from file @@ -171,7 +171,9 @@ UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile) } vgmFile->dataLen = vgmBaseHdr.lngEOFOffset + 0x04; - vgmFile->data = (UINT8*)malloc(vgmFile->dataLen); + //vgmFile->data = (UINT8*)malloc(vgmFile->dataLen); + MM_GetPtr(MEMPTR gvar->ca.audiosegs[0], vgmFile->dataLen, gvar); + vgmFile->data = (UINT8*)gvar->ca.audiosegs[0]; if (vgmFile->data == NULL) { fclose(hFile); @@ -212,9 +214,11 @@ UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile) return 0x00; } -void FreeVGMFile(VGM_FILE* vgmFile) +void FreeVGMFile(VGM_FILE* vgmFile, global_game_variables_t *gvar) { - free(vgmFile->data); vgmFile->data = NULL; + //if(vgmFile->data){ free(vgmFile->data); vgmFile->data = NULL; } +// if(vgmFile->data) free(vgmFile->data); + MM_FreePtr(MEMPTR gvar->ca.audiosegs[0], gvar); vgmFile->dataLen = 0; return; diff --git a/src/lib/vgmsnd/vgmSnd.h b/src/lib/vgmsnd/vgmSnd.h index 373d73dd..9bfdbc30 100755 --- a/src/lib/vgmsnd/vgmSnd.h +++ b/src/lib/vgmsnd/vgmSnd.h @@ -56,8 +56,8 @@ typedef struct _vgm_file } VGM_FILE; -UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile); -void FreeVGMFile(VGM_FILE* vgmFile); +UINT8 OpenVGMFile(const char* FileName, VGM_FILE* vgmFile, global_game_variables_t *gvar); +void FreeVGMFile(VGM_FILE* vgmFile, global_game_variables_t *gvar); void InitEngine(void); void DeinitEngine(void); diff --git a/src/vgmtest.c b/src/vgmtest.c index ee9e09fe..ef8d242d 100755 --- a/src/vgmtest.c +++ b/src/vgmtest.c @@ -27,6 +27,12 @@ #include "src/lib/16_sd.h" //#include "src/lib/doslib/adlib.h" #include "src/lib/16_in.h" +#include "src/lib/16_tail.h" +#include "src/lib/16_pm.h" +#include "src/lib/16_ca.h" +#include "src/lib/16_mm.h" +#include "src/lib/16_hc.h" +#include "src/lib/16_dbg.h" void OPL2_Write(UINT8 reg, UINT8 data); UINT8 OPL2_ReadStatus(void); @@ -48,14 +54,16 @@ UINT8 OPL2_ReadStatus(void) void main(int argc, char *argv[]) { -// static global_game_variables_t gvar; + static global_game_variables_t gvar; VGM_FILE pee[9]; - char *bakapee; + char bakapee[64] = "data/adlib.vgm"; - bakapee = malloc(64); - if(argv[1]) bakapee = argv[1]; - else bakapee = "data/adlib.vgm"; - printf("%x\n", OpenVGMFile(bakapee, &pee[0])); + if(argv[1]) strcpy(bakapee, argv[1]); + + MM_Startup(&gvar); +// PM_Startup(&gvar); PM_CheckMainMem(&gvar); PM_UnlockMainMem(&gvar); +// CA_Startup(&gvar); + printf("%x\n", OpenVGMFile(bakapee, &pee[0], &gvar)); // IN_Startup(); IN_Default(0,&gvar.player[0],ctrl_Keyboard1); InitEngine(); PlayMusic(&pee[0]); @@ -66,7 +74,10 @@ main(int argc, char *argv[]) UpdateSoundEngine(); } StopMusic(); - FreeVGMFile(&pee[0]); + FreeVGMFile(&pee[0], &gvar); DeinitEngine(); //IN_Shutdown(); +// PM_Shutdown(&gvar); +// CA_Shutdown(&gvar); + MM_Shutdown(&gvar); } -- 2.39.5