├── src ├── _G1.DSK ├── _G1.PRJ ├── GOT2 │ ├── _G2.DSK │ ├── _G2.PRJ │ ├── .kdev4 │ │ └── GOT2.kdev4 │ ├── 2_MASK.H │ ├── 2_MUSIC.C │ ├── 2_SBFX.C │ ├── 2_SOUND.C │ ├── 2_SHTPAT.C │ ├── 2_FILE.C │ ├── 2_GRP.C │ ├── 2_BOSS1.C │ ├── 2_SPTILE.C │ ├── 2_BOSS21.C │ ├── 2_PROTO.H │ └── 2_BOSS22.C ├── GOT3 │ ├── _G3.DSK │ ├── _G3.PRJ │ ├── 3_MASK.H │ ├── 3_MUSIC.C │ ├── 3_SBFX.C │ ├── 3_SOUND.C │ ├── 3_SHTPAT.C │ ├── 3_FILE.C │ ├── 3_SPTILE.C │ ├── 3_GRP.C │ ├── 3_BOSS1.C │ ├── 3_BOSS21.C │ ├── 3_PROTO.H │ └── 3_BOSS22.C ├── 1_MASK.H ├── 1_MUSIC.C ├── 1_SBFX.C ├── 1_SOUND.C ├── 1_SHTPAT.C ├── 1_SPTILE.C ├── 1_GRP.C ├── 1_BOSS1.C ├── 1_BOSS21.C ├── 1_FILE.C ├── 1_PROTO.H ├── 1_BOSS22.C └── 1_MOVE.C └── README.md /src/_G1.DSK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/_G1.DSK -------------------------------------------------------------------------------- /src/_G1.PRJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/_G1.PRJ -------------------------------------------------------------------------------- /src/GOT2/_G2.DSK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/GOT2/_G2.DSK -------------------------------------------------------------------------------- /src/GOT2/_G2.PRJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/GOT2/_G2.PRJ -------------------------------------------------------------------------------- /src/GOT3/_G3.DSK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/GOT3/_G3.DSK -------------------------------------------------------------------------------- /src/GOT3/_G3.PRJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SheridanR/god-of-thunder/HEAD/src/GOT3/_G3.PRJ -------------------------------------------------------------------------------- /src/GOT2/.kdev4/GOT2.kdev4: -------------------------------------------------------------------------------- 1 | [Buildset] 2 | BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x08\x00G\x00O\x00T\x002) 3 | -------------------------------------------------------------------------------- /src/1_MASK.H: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | 4 | //XMASKIM.H: structures used for storing and manipulating masked images 5 | 6 | //Describes one alignment of a mask-image pair 7 | 8 | typedef struct { 9 | int ImageWidth; //image width in addresses in display memory 10 | //(also mask width in bytes) 11 | unsigned int ImagePtr; //offset of image bitmap in display mem 12 | char *MaskPtr; //pointer to mask bitmap 13 | } AlignedMaskedImage; 14 | 15 | //Describes all four alignments of a mask-image pair 16 | 17 | typedef struct { 18 | AlignedMaskedImage *Alignments[4]; //ptrs to AlignedMaskedImage 19 | //structs for four possible destination 20 | //image alignments 21 | } MaskedImage; 22 | -------------------------------------------------------------------------------- /src/GOT2/2_MASK.H: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | //XMASKIM.H: structures used for storing and manipulating masked images 4 | 5 | //Describes one alignment of a mask-image pair 6 | 7 | typedef struct { 8 | int ImageWidth; //image width in addresses in display memory 9 | //(also mask width in bytes) 10 | unsigned int ImagePtr; //offset of image bitmap in display mem 11 | char *MaskPtr; //pointer to mask bitmap 12 | } AlignedMaskedImage; 13 | 14 | //Describes all four alignments of a mask-image pair 15 | 16 | typedef struct { 17 | AlignedMaskedImage *Alignments[4]; //ptrs to AlignedMaskedImage 18 | //structs for four possible destination 19 | //image alignments 20 | } MaskedImage; 21 | -------------------------------------------------------------------------------- /src/GOT3/3_MASK.H: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | //XMASKIM.H: structures used for storing and manipulating masked images 4 | 5 | //Describes one alignment of a mask-image pair 6 | 7 | typedef struct { 8 | int ImageWidth; //image width in addresses in display memory 9 | //(also mask width in bytes) 10 | unsigned int ImagePtr; //offset of image bitmap in display mem 11 | char *MaskPtr; //pointer to mask bitmap 12 | } AlignedMaskedImage; 13 | 14 | //Describes all four alignments of a mask-image pair 15 | 16 | typedef struct { 17 | AlignedMaskedImage *Alignments[4]; //ptrs to AlignedMaskedImage 18 | //structs for four possible destination 19 | //image alignments 20 | } MaskedImage; 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # god-of-thunder 2 | God of Thunder (1993, DOS) open-source release 3 | 4 | The goal of this project is to port this classic 16-bit DOS game to modern operating systems. 5 | 6 | From Ron Davis's original source release on [Sourceforge](https://sourceforge.net/projects/god-of-thunder-1994-dos-game/): 7 | 8 | ``` 9 | This is the source code for the 1994 DOS shareware game God of Thunder (Turbo C/Assembler). 10 | 11 | It is a good example of how not to code in C. I was once told it was impressive that it 12 | actually worked, so that's something. 13 | 14 | This is only the main source code here. I have released it to the public domain. Do whatever 15 | you want with it. It will not compile as-is. There is at least 1 3rd party compression file 16 | missing and the sound/music code was a licensed library that is not open source. The 17 | opening/high score/game select screens are also not included. I have had requests to release 18 | the source, so here it is. 19 | 20 | Unfortunately, the source for the sprite editor, level editor and resource packer are apparently 21 | lost to the unreliability of floppy disks. 22 | 23 | The game itself can be found for free on Steam. The assets of the game are not open source. 24 | Contact me if you wish to use them in any commercial projects because there are some restrictions. 25 | 26 | Sorry, but I cannot offer any support. 27 | 28 | Features 29 | 30 | * Very questionable C code (to put it nicely) 31 | ``` 32 | -------------------------------------------------------------------------------- /src/1_MUSIC.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include <1_define.h> 11 | #include <1_proto.h> 12 | #include 13 | #include "FX_Manc.h" 14 | #include "MU_Manc.h" 15 | #include "SB_Manc.h" 16 | 17 | extern char far *song; 18 | extern char music_current; 19 | extern struct sup setup; 20 | //========================================================================= 21 | int music_init(void){ 22 | 23 | if(!setup.music) return 0; 24 | music_current=-1; 25 | return 1; 26 | } 27 | //========================================================================= 28 | void music_play(int num,int override){ 29 | 30 | if(!setup.music) return; 31 | if((num!=music_current) || override){ 32 | if(num!=music_current) load_music(num); 33 | MU_StartMusic(song,1); 34 | music_current=num; 35 | } 36 | } 37 | //========================================================================= 38 | void music_pause(void){ 39 | 40 | if(!setup.music) return; 41 | MU_MusicOff(); 42 | } 43 | //========================================================================= 44 | void music_resume(void){ 45 | 46 | if(!setup.music) return; 47 | MU_MusicOn(); 48 | } 49 | //========================================================================= 50 | int music_is_on(void){ 51 | 52 | if(!setup.music) return 0; 53 | return MU_MusicPlaying(); 54 | } 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/GOT2/2_MUSIC.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include <2_define.h> 11 | #include <2_proto.h> 12 | #include 13 | #include "FX_Manc.h" 14 | #include "MU_Manc.h" 15 | #include "SB_Manc.h" 16 | 17 | extern char far *song; 18 | extern char music_current; 19 | extern struct sup setup; 20 | //========================================================================= 21 | int music_init(void){ 22 | 23 | if(!setup.music) return 0; 24 | music_current=-1; 25 | return 1; 26 | } 27 | //========================================================================= 28 | void music_play(int num,int override){ 29 | 30 | if(!setup.music) return; 31 | if((num!=music_current) || override){ 32 | if(num!=music_current) load_music(num); 33 | MU_StartMusic(song,1); 34 | music_current=num; 35 | } 36 | } 37 | //========================================================================= 38 | void music_pause(void){ 39 | 40 | if(!setup.music) return; 41 | MU_MusicOff(); 42 | } 43 | //========================================================================= 44 | void music_resume(void){ 45 | 46 | if(!setup.music) return; 47 | MU_MusicOn(); 48 | } 49 | //========================================================================= 50 | int music_is_on(void){ 51 | 52 | if(!setup.music) return 0; 53 | return MU_MusicPlaying(); 54 | } 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/GOT3/3_MUSIC.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include <3_define.h> 11 | #include <3_proto.h> 12 | #include 13 | #include "FX_Manc.h" 14 | #include "MU_Manc.h" 15 | #include "SB_Manc.h" 16 | 17 | extern char far *song; 18 | extern char music_current; 19 | extern struct sup setup; 20 | //========================================================================= 21 | int music_init(void){ 22 | 23 | if(!setup.music) return 0; 24 | music_current=-1; 25 | return 1; 26 | } 27 | //========================================================================= 28 | void music_play(int num,int override){ 29 | 30 | if(!setup.music) return; 31 | if((num!=music_current) || override){ 32 | if(num!=music_current) load_music(num); 33 | MU_StartMusic(song,1); 34 | music_current=num; 35 | } 36 | } 37 | //========================================================================= 38 | void music_pause(void){ 39 | 40 | if(!setup.music) return; 41 | MU_MusicOff(); 42 | } 43 | //========================================================================= 44 | void music_resume(void){ 45 | 46 | if(!setup.music) return; 47 | MU_MusicOn(); 48 | } 49 | //========================================================================= 50 | int music_is_on(void){ 51 | 52 | if(!setup.music) return 0; 53 | return MU_MusicPlaying(); 54 | } 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/1_SBFX.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include <1_define.h> 12 | #include <1_proto.h> 13 | #include "FX_Man.h" 14 | #include "MU_Man.h" 15 | #include "SB_Man.h" 16 | 17 | extern SETUP setup; 18 | extern char AdLibPresent; 19 | extern volatile unsigned int timer_cnt,vbl_cnt,magic_cnt,extra_cnt; 20 | extern int music_flag,sound_flag,pcsound_flag; 21 | extern char noal,nosb; 22 | 23 | void interrupt far (*t0OldService)(void); 24 | long TimerDivisor,TimerCount; 25 | volatile long TickCount2,TickCount; 26 | //=========================================================================== 27 | void interrupt t0Service(void){ 28 | 29 | timer_cnt++; 30 | vbl_cnt++; 31 | magic_cnt++; 32 | extra_cnt++; 33 | 34 | FX_ServicePC(); 35 | MU_Service(); 36 | 37 | TickCount2++; 38 | TickCount = TickCount2 >> 1; 39 | TimerCount += TimerDivisor; 40 | if(TimerCount >= 0x10000L){ 41 | TimerCount -= 0x10000L; 42 | t0OldService(); // Chain to old ISR 43 | } 44 | else outportb(0x20,0x20); // Do the EOI 45 | } 46 | char *SB_DetectAdLib(void); 47 | //=========================================================================== 48 | int sbfx_init(void){ 49 | unsigned speed; 50 | char *sberr; 51 | 52 | t0OldService = getvect(8); 53 | setvect(8,t0Service); 54 | 55 | speed=(unsigned) (1192030L/120L); 56 | outportb(0x43,0x36); 57 | outportb(0x40,speed); 58 | outportb(0x40,speed >> 8); 59 | TimerDivisor=speed; 60 | 61 | music_flag=0; //is hardware available flags 62 | sound_flag=0; 63 | if(noal) return 1; 64 | if(nosb){ 65 | sberr=SB_DetectAdLib(); 66 | // if(sberr) return 0; 67 | if(!AdLibPresent){ 68 | SB_Shutdown(); 69 | return 0; 70 | } 71 | music_flag=1; 72 | return 1; 73 | } 74 | else{ 75 | sberr=SB_Startup(getenv("BLASTER")); 76 | if(sberr){ 77 | exit_code(0); 78 | printf("\r\n%s\r\n",sberr); 79 | getch(); 80 | exit(0); 81 | } 82 | if(!SoundBlasterPresent){ 83 | SB_Shutdown(); 84 | return 0; 85 | } 86 | music_flag=1; 87 | sound_flag=1; 88 | } 89 | return 1; 90 | } 91 | //=========================================================================== 92 | void sbfx_exit(void){ 93 | int i; 94 | 95 | if(setup.pc_sound) FX_StopPC(); 96 | if(setup.music) MU_MusicOff(); 97 | if(setup.music || setup.dig_sound) SB_Shutdown(); 98 | 99 | for(i=0;i<0xf5;i++) SB_ALOut(i,0); 100 | 101 | outportb(0x43,0x36); // Change timer 0 102 | outportb(0x40,0); 103 | outportb(0x40,0); 104 | setvect(8,t0OldService); // Restore old timer 0 ISR 105 | } 106 | -------------------------------------------------------------------------------- /src/GOT3/3_SBFX.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include <3_define.h> 12 | #include <3_proto.h> 13 | #include "FX_Man.h" 14 | #include "MU_Man.h" 15 | #include "SB_Man.h" 16 | 17 | extern SETUP setup; 18 | extern char AdLibPresent; 19 | extern volatile unsigned int timer_cnt,vbl_cnt,magic_cnt,extra_cnt; 20 | extern int music_flag,sound_flag,pcsound_flag; 21 | extern char noal,nosb; 22 | 23 | void interrupt far (*t0OldService)(void); 24 | long TimerDivisor,TimerCount; 25 | volatile long TickCount2,TickCount; 26 | //=========================================================================== 27 | void interrupt t0Service(void){ 28 | 29 | timer_cnt++; 30 | vbl_cnt++; 31 | magic_cnt++; 32 | extra_cnt++; 33 | 34 | FX_ServicePC(); 35 | MU_Service(); 36 | 37 | TickCount2++; 38 | TickCount = TickCount2 >> 1; 39 | TimerCount += TimerDivisor; 40 | if(TimerCount >= 0x10000L){ 41 | TimerCount -= 0x10000L; 42 | t0OldService(); // Chain to old ISR 43 | } 44 | else outportb(0x20,0x20); // Do the EOI 45 | } 46 | //=========================================================================== 47 | int sbfx_init(void){ 48 | unsigned speed; 49 | char *sberr; 50 | 51 | t0OldService = getvect(8); // Get old timer 0 ISR 52 | setvect(8,t0Service); // Set to my timer 0 ISR 53 | 54 | speed=(unsigned) (1192030L/120L); 55 | //speed=9933; 56 | outportb(0x43,0x36); // Change timer 0 57 | outportb(0x40,speed); 58 | outportb(0x40,speed >> 8); 59 | TimerDivisor=speed; 60 | music_flag=0; //is hardware available flags 61 | sound_flag=0; 62 | if(noal) return 1; 63 | if(nosb){ 64 | SB_DetectAdLib(); 65 | if(!AdLibPresent){ 66 | SB_Shutdown(); 67 | return 0; 68 | } 69 | music_flag=1; 70 | return 1; 71 | } 72 | else{ 73 | sberr=SB_Startup(getenv("BLASTER")); 74 | if(sberr){ 75 | exit_code(0); 76 | printf("\r\n%s\r\n",sberr); 77 | getch(); 78 | exit(0); 79 | } 80 | if(!SoundBlasterPresent){ 81 | SB_Shutdown(); 82 | return 0; 83 | } 84 | music_flag=1; 85 | sound_flag=1; 86 | } 87 | return 1; 88 | } 89 | //=========================================================================== 90 | void sbfx_exit(void){ 91 | int i; 92 | 93 | if(setup.pc_sound) FX_StopPC(); 94 | if(setup.music) MU_MusicOff(); 95 | if(setup.music || setup.dig_sound) SB_Shutdown(); 96 | 97 | for(i=0;i<0xf5;i++) SB_ALOut(i,0); 98 | 99 | outportb(0x43,0x36); // Change timer 0 100 | outportb(0x40,0); 101 | outportb(0x40,0); 102 | setvect(8,t0OldService); // Restore old timer 0 ISR 103 | } 104 | -------------------------------------------------------------------------------- /src/GOT2/2_SBFX.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include <2_define.h> 12 | #include <2_proto.h> 13 | #include "FX_Man.h" 14 | #include "MU_Man.h" 15 | #include "SB_Man.h" 16 | 17 | extern SETUP setup; 18 | extern char AdLibPresent; 19 | extern volatile unsigned int timer_cnt,vbl_cnt,magic_cnt,extra_cnt; 20 | extern int music_flag,sound_flag,pcsound_flag; 21 | extern char noal,nosb; 22 | 23 | void interrupt far (*t0OldService)(void); 24 | long TimerDivisor,TimerCount; 25 | volatile long TickCount2,TickCount; 26 | //=========================================================================== 27 | void interrupt t0Service(void){ 28 | 29 | timer_cnt++; 30 | vbl_cnt++; 31 | magic_cnt++; 32 | extra_cnt++; 33 | 34 | FX_ServicePC(); 35 | MU_Service(); 36 | 37 | TickCount2++; 38 | TickCount = TickCount2 >> 1; 39 | TimerCount += TimerDivisor; 40 | if(TimerCount >= 0x10000L){ 41 | TimerCount -= 0x10000L; 42 | t0OldService(); // Chain to old ISR 43 | } 44 | else outportb(0x20,0x20); // Do the EOI 45 | } 46 | //=========================================================================== 47 | int sbfx_init(void){ 48 | unsigned speed; 49 | char *sberr; 50 | 51 | t0OldService = getvect(8); // Get old timer 0 ISR 52 | setvect(8,t0Service); // Set to my timer 0 ISR 53 | 54 | speed=(unsigned) (1192030L/120L); 55 | //speed=9933; 56 | outportb(0x43,0x36); // Change timer 0 57 | outportb(0x40,speed); 58 | outportb(0x40,speed >> 8); 59 | TimerDivisor=speed; 60 | 61 | music_flag=0; //is hardware available flags 62 | sound_flag=0; 63 | if(noal) return 1; 64 | if(nosb){ 65 | SB_DetectAdLib(); 66 | if(!AdLibPresent){ 67 | SB_Shutdown(); 68 | return 0; 69 | } 70 | music_flag=1; 71 | return 1; 72 | } 73 | else{ 74 | sberr=SB_Startup(getenv("BLASTER")); 75 | if(sberr){ 76 | exit_code(0); 77 | printf("\r\n%s\r\n",sberr); 78 | getch(); 79 | exit(0); 80 | } 81 | if(!SoundBlasterPresent){ 82 | SB_Shutdown(); 83 | return 0; 84 | } 85 | music_flag=1; 86 | sound_flag=1; 87 | } 88 | return 1; 89 | } 90 | //=========================================================================== 91 | void sbfx_exit(void){ 92 | int i; 93 | 94 | if(setup.pc_sound) FX_StopPC(); 95 | if(setup.music) MU_MusicOff(); 96 | if(setup.music || setup.dig_sound) SB_Shutdown(); 97 | 98 | for(i=0;i<0xf5;i++) SB_ALOut(i,0); 99 | 100 | outportb(0x43,0x36); // Change timer 0 101 | outportb(0x40,0); 102 | outportb(0x40,0); 103 | setvect(8,t0OldService); // Restore old timer 0 ISR 104 | } 105 | -------------------------------------------------------------------------------- /src/1_SOUND.C: -------------------------------------------------------------------------------- 1 | //Source code released to the public domain on March 27th, 2020. 2 | 3 | #include 4 | #include 5 | 6 | #include <1_define.h> 7 | #include <1_proto.h> 8 | #include 9 | 10 | #include "FX_Manc.h" 11 | #include "MU_Manc.h" 12 | #include "SB_Manc.h" 13 | 14 | void play_pc_sound(int index, int priority_override); 15 | //=========================================================================== 16 | extern char far *std_sounds; 17 | extern char far *pcstd_sounds; 18 | extern char far *pc_sound[NUM_SOUNDS]; 19 | extern char far *dig_sound[NUM_SOUNDS]; 20 | extern char far *std_sound_start; 21 | extern char far *pcstd_sound_start; 22 | extern int level; 23 | 24 | //enum{OW,GULP,SWISH,YAH,ELECTRIC,THUNDER,DOOR,FALL, 25 | // ANGEL,WOOP,ANGEL,BRAAPP,WIND,PUNCH1,CLANG,EXPLODE 26 | // BOSS11,BOSS12,BOSS13 27 | int sound_priority[]={1,2,3,3,3,1,4,4,4,5,4,3,1,2,2,5,1,3,1}; 28 | extern long pcsound_length[NUM_SOUNDS]; 29 | 30 | int current_priority; 31 | //=========================================================================== 32 | extern SETUP setup; 33 | extern char ds_file[]; 34 | //=========================================================================== 35 | int sound_init(void){ 36 | int i; 37 | char far *p; 38 | HEADER far *header; 39 | 40 | std_sound_start=res_falloc_read("DIGSOUND"); 41 | if(!std_sound_start) return 0; 42 | std_sounds=std_sound_start; 43 | header=(HEADER far *) std_sounds; 44 | std_sounds=std_sounds+(sizeof(HEADER) * 16); 45 | 46 | p=std_sounds; 47 | for(i=0;i<16;i++){ 48 | dig_sound[i]=p; 49 | p+=(int) header->length; 50 | header++; 51 | } 52 | 53 | pcstd_sound_start=res_falloc_read("PCSOUNDS"); 54 | if(!pcstd_sound_start) return 0; 55 | pcstd_sounds=pcstd_sound_start; 56 | header=(HEADER far *) pcstd_sounds; 57 | pcstd_sounds=pcstd_sounds+(sizeof(HEADER) * 16); 58 | 59 | p=pcstd_sounds; 60 | for(i=0;i<16;i++){ 61 | pc_sound[i]=p; 62 | pc_sound[i][0]=0; 63 | pc_sound[i][1]=0; 64 | pcsound_length[i]=header->length; 65 | p+=(int) header->length; 66 | header++; 67 | } 68 | current_priority=255; 69 | return 1; 70 | } 71 | //=========================================================================== 72 | void sound_exit(void){ 73 | 74 | FX_StopPC(); 75 | while(FX_PCPlaying()); 76 | SB_StopVOC(); 77 | while(sound_playing()); 78 | 79 | if(std_sound_start) farfree(std_sounds); 80 | if(pcstd_sound_start) farfree(pcstd_sounds); 81 | } 82 | //=========================================================================== 83 | void play_sound(int index, int priority_override){ 84 | 85 | if(index>=NUM_SOUNDS) return; 86 | if(setup.pc_sound){ 87 | play_pc_sound(index,priority_override); 88 | return; 89 | } 90 | if(!setup.dig_sound) return; 91 | 92 | if(sound_playing()){ 93 | if((!priority_override) && current_priority 4 | #include 5 | 6 | #include <2_define.h> 7 | #include <2_proto.h> 8 | #include 9 | 10 | #include "FX_Manc.h" 11 | #include "MU_Manc.h" 12 | #include "SB_Manc.h" 13 | 14 | void play_pc_sound(int index, int priority_override); 15 | //=========================================================================== 16 | extern char far *std_sounds; 17 | extern char far *pcstd_sounds; 18 | extern char far *pc_sound[NUM_SOUNDS]; 19 | extern char far *dig_sound[NUM_SOUNDS]; 20 | extern char far *std_sound_start; 21 | extern char far *pcstd_sound_start; 22 | extern int level; 23 | 24 | //enum{OW,GULP,SWISH,YAH,ELECTRIC,THUNDER,DOOR,FALL, 25 | // ANGEL,WOOP,ANGEL,BRAAPP,WIND,PUNCH1,CLANG,EXPLODE 26 | // BOSS11,BOSS12,BOSS13 27 | int sound_priority[]={1,2,3,3,3,1,4,4,4,5,4,3,1,2,2,5,1,3,1}; 28 | extern long pcsound_length[NUM_SOUNDS]; 29 | 30 | int current_priority; 31 | //=========================================================================== 32 | extern SETUP setup; 33 | extern char ds_file[]; 34 | //=========================================================================== 35 | int sound_init(void){ 36 | int i; 37 | char far *p; 38 | HEADER far *header; 39 | 40 | std_sound_start=res_falloc_read("DIGSOUND"); 41 | if(!std_sound_start) return 0; 42 | std_sounds=std_sound_start; 43 | header=(HEADER far *) std_sounds; 44 | std_sounds=std_sounds+(sizeof(HEADER) * 16); 45 | 46 | p=std_sounds; 47 | for(i=0;i<16;i++){ 48 | dig_sound[i]=p; 49 | p+=(int) header->length; 50 | header++; 51 | } 52 | 53 | pcstd_sound_start=res_falloc_read("PCSOUNDS"); 54 | if(!pcstd_sound_start) return 0; 55 | pcstd_sounds=pcstd_sound_start; 56 | header=(HEADER far *) pcstd_sounds; 57 | pcstd_sounds=pcstd_sounds+(sizeof(HEADER) * 16); 58 | 59 | p=pcstd_sounds; 60 | for(i=0;i<16;i++){ 61 | pc_sound[i]=p; 62 | pc_sound[i][0]=0; 63 | pc_sound[i][1]=0; 64 | pcsound_length[i]=header->length; 65 | p+=(int) header->length; 66 | header++; 67 | } 68 | current_priority=255; 69 | return 1; 70 | } 71 | //=========================================================================== 72 | void sound_exit(void){ 73 | 74 | FX_StopPC(); 75 | while(FX_PCPlaying()); 76 | SB_StopVOC(); 77 | while(sound_playing()); 78 | 79 | if(std_sound_start) farfree(std_sounds); 80 | if(pcstd_sound_start) farfree(pcstd_sounds); 81 | } 82 | //=========================================================================== 83 | void play_sound(int index, int priority_override){ 84 | 85 | if(index>=NUM_SOUNDS) return; 86 | if(setup.pc_sound){ 87 | play_pc_sound(index,priority_override); 88 | return; 89 | } 90 | if(!setup.dig_sound) return; 91 | 92 | if(sound_playing()){ 93 | if((!priority_override) && current_priority 4 | #include 5 | 6 | #include <3_define.h> 7 | #include <3_proto.h> 8 | #include 9 | 10 | #include "FX_Manc.h" 11 | #include "MU_Manc.h" 12 | #include "SB_Manc.h" 13 | 14 | void play_pc_sound(int index, int priority_override); 15 | //=========================================================================== 16 | extern char far *std_sounds; 17 | extern char far *pcstd_sounds; 18 | extern char far *pc_sound[NUM_SOUNDS]; 19 | extern char far *dig_sound[NUM_SOUNDS]; 20 | extern char far *std_sound_start; 21 | extern char far *pcstd_sound_start; 22 | extern int level; 23 | 24 | //enum{OW,GULP,SWISH,YAH,ELECTRIC,THUNDER,DOOR,FALL, 25 | // ANGEL,WOOP,ANGEL,BRAAPP,WIND,PUNCH1,CLANG,EXPLODE 26 | // BOSS11,BOSS12,BOSS13 27 | int sound_priority[]={1,2,3,3,3,1,4,4,4,5,4,3,1,2,2,5,1,3,1}; 28 | extern long pcsound_length[NUM_SOUNDS]; 29 | 30 | int current_priority; 31 | //=========================================================================== 32 | extern SETUP setup; 33 | extern char ds_file[]; 34 | //=========================================================================== 35 | int sound_init(void){ 36 | int i; 37 | char far *p; 38 | HEADER far *header; 39 | 40 | std_sound_start=res_falloc_read("DIGSOUND"); 41 | if(!std_sound_start) return 0; 42 | std_sounds=std_sound_start; 43 | header=(HEADER far *) std_sounds; 44 | std_sounds=std_sounds+(sizeof(HEADER) * 16); 45 | 46 | p=std_sounds; 47 | for(i=0;i<16;i++){ 48 | dig_sound[i]=p; 49 | p+=(int) header->length; 50 | header++; 51 | } 52 | 53 | pcstd_sound_start=res_falloc_read("PCSOUNDS"); 54 | if(!pcstd_sound_start) return 0; 55 | pcstd_sounds=pcstd_sound_start; 56 | header=(HEADER far *) pcstd_sounds; 57 | pcstd_sounds=pcstd_sounds+(sizeof(HEADER) * 16); 58 | 59 | p=pcstd_sounds; 60 | for(i=0;i<16;i++){ 61 | pc_sound[i]=p; 62 | pc_sound[i][0]=0; 63 | pc_sound[i][1]=0; 64 | pcsound_length[i]=header->length; 65 | p+=(int) header->length; 66 | header++; 67 | } 68 | current_priority=255; 69 | return 1; 70 | } 71 | //=========================================================================== 72 | void sound_exit(void){ 73 | 74 | FX_StopPC(); 75 | while(FX_PCPlaying()); 76 | SB_StopVOC(); 77 | while(sound_playing()); 78 | 79 | if(std_sound_start) farfree(std_sounds); 80 | if(pcstd_sound_start) farfree(pcstd_sounds); 81 | } 82 | //=========================================================================== 83 | void play_sound(int index, int priority_override){ 84 | 85 | if(index>=NUM_SOUNDS) return; 86 | if(setup.pc_sound){ 87 | play_pc_sound(index,priority_override); 88 | return; 89 | } 90 | if(!setup.dig_sound) return; 91 | 92 | if(sound_playing()){ 93 | if((!priority_override) && current_priority 5 | #include 6 | #include 7 | #include 8 | 9 | #include <1_define.h> 10 | #include <1_proto.h> 11 | //=========================================================================== 12 | extern ACTOR actor[MAX_ACTORS]; //current actors 13 | extern ACTOR *thor; 14 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 15 | extern int rand1,rand2; 16 | extern int thor_pos; 17 | extern SETUP setup; 18 | //=========================================================================== 19 | int shot_pattern_none(ACTOR *actr); 20 | int shot_pattern_one(ACTOR *actr); 21 | int shot_pattern_two(ACTOR *actr); 22 | int shot_pattern_three(ACTOR *actr); 23 | int shot_pattern_four(ACTOR *actr); 24 | int shot_pattern_five(ACTOR *actr); 25 | int shot_pattern_six(ACTOR *actr); 26 | int shot_pattern_seven(ACTOR *actr); 27 | int shot_pattern_eight(ACTOR *actr); 28 | 29 | int (*shot_pattern_func[]) (ACTOR *actr) = 30 | { shot_pattern_none, 31 | shot_pattern_one, 32 | shot_pattern_two, 33 | shot_pattern_three, 34 | shot_pattern_four, 35 | shot_pattern_five, 36 | shot_pattern_six, 37 | shot_pattern_seven, 38 | shot_pattern_eight, 39 | }; 40 | //=========================================================================== 41 | int shot_pattern_none(ACTOR *actr){ //no shooting 42 | 43 | actr=actr; 44 | return 0; 45 | } 46 | //=========================================================================== 47 | int shot_pattern_one(ACTOR *actr){ //uni-directional seek 48 | 49 | switch(actr->last_dir){ 50 | case 0: 51 | if(abs(thor_x1-actr->x)<8){ 52 | if(actr->y>thor_real_y1){ //r 53 | if(actor_shoots(actr,0)) return 1; 54 | } 55 | } 56 | break; 57 | case 1: 58 | if(abs(thor_x1-actr->x)<8){ 59 | if(actr->yy)<8){ //r 66 | if(actr->x>thor_x1){ 67 | if(actor_shoots(actr,2)) return 1; 68 | } 69 | } 70 | break; 71 | case 3: 72 | if(abs(thor_real_y1-actr->y)<8){ //r 73 | if(actr->xx-actr->x)<8){ 85 | if(thor->y > actr->y) actor_shoots(actr,1); 86 | else if(thor->y < actr->y) actor_shoots(actr,0); 87 | else return 0; 88 | } 89 | else if(abs(thor->y-actr->y)<8){ 90 | if(thor->x > actr->x) actor_shoots(actr,3); 91 | else if(thor->x < actr->x) actor_shoots(actr,2); 92 | } 93 | else return 0; 94 | 95 | return 1; 96 | } 97 | //=========================================================================== 98 | int shot_pattern_three(ACTOR *actr){ //uni directional (backwards) 99 | int ld; 100 | 101 | ld=actr->last_dir; 102 | if(shot_pattern_one(actr)){ 103 | actr->last_dir=reverse_direction(actr); 104 | return 1; 105 | } 106 | actr->last_dir=reverse_direction(actr); 107 | shot_pattern_one(actr); 108 | actr->last_dir=ld; 109 | return 1; 110 | } 111 | //=========================================================================== 112 | int shot_pattern_four(ACTOR *actr){ //omni-directional not solid shot 113 | 114 | if(abs(thor->x-actr->x)<8){ 115 | if(thor->y > actr->y) actor_always_shoots(actr,1); 116 | else if(thor->y < actr->y) actor_always_shoots(actr,0); 117 | else return 0; 118 | } 119 | else if(abs(thor->y-actr->y)<8){ 120 | if(thor->x > actr->x) actor_always_shoots(actr,3); 121 | else if(thor->x < actr->x) actor_always_shoots(actr,2); 122 | } 123 | else return 0; 124 | 125 | return 1; 126 | } 127 | //=========================================================================== 128 | int shot_pattern_five(ACTOR *actr){ //boss - snake 129 | int num; 130 | 131 | if(rand1<15){ 132 | if((actr->temp1==0) && (actr->temp2==0)){ 133 | actr->y+=16; 134 | actr->shots_allowed=3+setup.skill; 135 | actor_shoots(actr,2); 136 | play_sound(BOSS12,0); 137 | // num=actr->creator; 138 | num=actr->shot_actor; 139 | actr->shot_cnt=50; 140 | actor[num].temp3=120; 141 | actor[num].temp4=5+(rand2%17); 142 | actor[num].temp5=actor[num].temp4; 143 | actr->y-=16; 144 | return 1; 145 | } 146 | } 147 | return 0; 148 | } 149 | //=========================================================================== 150 | int shot_pattern_six(ACTOR *actr){ //4 surrounding squares 151 | int pos; 152 | 153 | pos=((actr->x)/16)+(((actr->y)/16)*20); 154 | 155 | if(thor_pos==pos-20) actor_shoots(actr,0); 156 | else if(thor_pos==pos+20) actor_shoots(actr,1); 157 | else if(thor_pos==pos-1) actor_shoots(actr,2); 158 | else if(thor_pos==pos+1) actor_shoots(actr,3); 159 | else return 0; 160 | 161 | actr->frame_sequence[3]=3; 162 | actr->next=3; 163 | return 1; 164 | } 165 | //=========================================================================== 166 | int shot_pattern_seven(ACTOR *actr){ //none 167 | 168 | actr=actr; 169 | return 0; 170 | } 171 | //=========================================================================== 172 | int shot_pattern_eight(ACTOR *actr){ //random 173 | 174 | if(!actr->i2){ 175 | actr->i1=actr->func_pass; 176 | actr->i2=1; 177 | } 178 | 179 | if(actr->i1) actr->i1--; 180 | else{ 181 | if(rand1<10){ 182 | actr->i1=thor_x1; 183 | actr->i2=thor_real_y1; 184 | actr->i1=actr->func_pass; 185 | actor_shoots(actr,0); 186 | return 1; 187 | } 188 | } 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /src/GOT2/2_SHTPAT.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <2_define.h> 10 | #include <2_proto.h> 11 | //=========================================================================== 12 | extern ACTOR actor[MAX_ACTORS]; //current actors 13 | extern ACTOR *thor; 14 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 15 | extern int rand1,rand2; 16 | extern int thor_pos; 17 | extern SETUP setup; 18 | //=========================================================================== 19 | int shot_pattern_none(ACTOR *actr); 20 | int shot_pattern_one(ACTOR *actr); 21 | int shot_pattern_two(ACTOR *actr); 22 | int shot_pattern_three(ACTOR *actr); 23 | int shot_pattern_four(ACTOR *actr); 24 | int shot_pattern_five(ACTOR *actr); 25 | int shot_pattern_six(ACTOR *actr); 26 | int shot_pattern_seven(ACTOR *actr); 27 | int shot_pattern_eight(ACTOR *actr); 28 | 29 | int (*shot_pattern_func[]) (ACTOR *actr) = 30 | { shot_pattern_none, 31 | shot_pattern_one, 32 | shot_pattern_two, 33 | shot_pattern_three, 34 | shot_pattern_four, 35 | shot_pattern_five, 36 | shot_pattern_six, 37 | shot_pattern_seven, 38 | shot_pattern_eight, 39 | }; 40 | //=========================================================================== 41 | int shot_pattern_none(ACTOR *actr){ //no shooting 42 | 43 | actr=actr; 44 | return 0; 45 | } 46 | //=========================================================================== 47 | int shot_pattern_one(ACTOR *actr){ //uni-directional seek 48 | 49 | switch(actr->last_dir){ 50 | case 0: 51 | if(abs(thor_x1-actr->x)<8){ 52 | if(actr->y>thor_real_y1){ //r 53 | if(actor_shoots(actr,0)) return 1; 54 | } 55 | } 56 | break; 57 | case 1: 58 | if(abs(thor_x1-actr->x)<8){ 59 | if(actr->yy)<8){ //r 66 | if(actr->x>thor_x1){ 67 | if(actor_shoots(actr,2)) return 1; 68 | } 69 | } 70 | break; 71 | case 3: 72 | if(abs(thor_real_y1-actr->y)<8){ //r 73 | if(actr->xx-actr->x)<8){ 85 | if(thor->y > actr->y) actor_shoots(actr,1); 86 | else if(thor->y < actr->y) actor_shoots(actr,0); 87 | else return 0; 88 | } 89 | else if(abs(thor->y-actr->y)<8){ 90 | if(thor->x > actr->x) actor_shoots(actr,3); 91 | else if(thor->x < actr->x) actor_shoots(actr,2); 92 | } 93 | else return 0; 94 | 95 | return 1; 96 | } 97 | //=========================================================================== 98 | int shot_pattern_three(ACTOR *actr){ //uni directional (backwards) 99 | int ld; 100 | 101 | ld=actr->last_dir; 102 | if(shot_pattern_one(actr)){ 103 | actr->last_dir=reverse_direction(actr); 104 | return 1; 105 | } 106 | actr->last_dir=reverse_direction(actr); 107 | shot_pattern_one(actr); 108 | actr->last_dir=ld; 109 | return 1; 110 | } 111 | //=========================================================================== 112 | int shot_pattern_four(ACTOR *actr){ //omni-directional not solid shot 113 | 114 | if(abs(thor->x-actr->x)<8){ 115 | if(thor->y > actr->y) actor_always_shoots(actr,1); 116 | else if(thor->y < actr->y) actor_always_shoots(actr,0); 117 | else return 0; 118 | } 119 | else if(abs(thor->y-actr->y)<8){ 120 | if(thor->x > actr->x) actor_always_shoots(actr,3); 121 | else if(thor->x < actr->x) actor_always_shoots(actr,2); 122 | } 123 | else return 0; 124 | 125 | return 1; 126 | } 127 | //=========================================================================== 128 | int shot_pattern_five(ACTOR *actr){ //boss - snake 129 | int num; 130 | 131 | if(rand1<15){ 132 | if((actr->temp1==0) && (actr->temp2==0)){ 133 | actr->y+=16; 134 | actr->shots_allowed=3+setup.skill; 135 | actor_shoots(actr,2); 136 | play_sound(BOSS12,0); 137 | // num=actr->creator; 138 | num=actr->shot_actor; 139 | actr->shot_cnt=50; 140 | actor[num].temp3=120; 141 | actor[num].temp4=5+(rand2%17); 142 | actor[num].temp5=actor[num].temp4; 143 | actr->y-=16; 144 | return 1; 145 | } 146 | } 147 | return 0; 148 | } 149 | //=========================================================================== 150 | int shot_pattern_six(ACTOR *actr){ //4 surrounding squares 151 | int pos; 152 | 153 | pos=((actr->x)/16)+(((actr->y)/16)*20); 154 | 155 | if(thor_pos==pos-20) actor_shoots(actr,0); 156 | else if(thor_pos==pos+20) actor_shoots(actr,1); 157 | else if(thor_pos==pos-1) actor_shoots(actr,2); 158 | else if(thor_pos==pos+1) actor_shoots(actr,3); 159 | else return 0; 160 | 161 | actr->frame_sequence[3]=3; 162 | actr->next=3; 163 | return 1; 164 | } 165 | //=========================================================================== 166 | int shot_pattern_seven(ACTOR *actr){ //none 167 | 168 | actr=actr; 169 | return 0; 170 | } 171 | //=========================================================================== 172 | int shot_pattern_eight(ACTOR *actr){ //random 173 | 174 | if(!actr->i2){ 175 | actr->i1=actr->func_pass; 176 | actr->i2=1; 177 | } 178 | 179 | if(actr->i1) actr->i1--; 180 | else{ 181 | if(rand1<10){ 182 | actr->i1=thor_x1; 183 | actr->i2=thor_real_y1; 184 | actr->i1=actr->func_pass; 185 | actor_shoots(actr,0); 186 | return 1; 187 | } 188 | } 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /src/GOT3/3_SHTPAT.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <3_define.h> 10 | #include <3_proto.h> 11 | //=========================================================================== 12 | extern ACTOR actor[MAX_ACTORS]; //current actors 13 | extern ACTOR *thor; 14 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 15 | extern int rand1,rand2; 16 | extern int thor_pos; 17 | extern SETUP setup; 18 | //=========================================================================== 19 | int shot_pattern_none(ACTOR *actr); 20 | int shot_pattern_one(ACTOR *actr); 21 | int shot_pattern_two(ACTOR *actr); 22 | int shot_pattern_three(ACTOR *actr); 23 | int shot_pattern_four(ACTOR *actr); 24 | int shot_pattern_five(ACTOR *actr); 25 | int shot_pattern_six(ACTOR *actr); 26 | int shot_pattern_seven(ACTOR *actr); 27 | int shot_pattern_eight(ACTOR *actr); 28 | 29 | int (*shot_pattern_func[]) (ACTOR *actr) = 30 | { shot_pattern_none, 31 | shot_pattern_one, 32 | shot_pattern_two, 33 | shot_pattern_three, 34 | shot_pattern_four, 35 | shot_pattern_five, 36 | shot_pattern_six, 37 | shot_pattern_seven, 38 | shot_pattern_eight, 39 | }; 40 | //=========================================================================== 41 | int shot_pattern_none(ACTOR *actr){ //no shooting 42 | 43 | actr=actr; 44 | return 0; 45 | } 46 | //=========================================================================== 47 | int shot_pattern_one(ACTOR *actr){ //uni-directional seek 48 | 49 | switch(actr->last_dir){ 50 | case 0: 51 | if(abs(thor_x1-actr->x)<8){ 52 | if(actr->y>thor_real_y1){ //r 53 | if(actor_shoots(actr,0)) return 1; 54 | } 55 | } 56 | break; 57 | case 1: 58 | if(abs(thor_x1-actr->x)<8){ 59 | if(actr->yy)<8){ //r 66 | if(actr->x>thor_x1){ 67 | if(actor_shoots(actr,2)) return 1; 68 | } 69 | } 70 | break; 71 | case 3: 72 | if(abs(thor_real_y1-actr->y)<8){ //r 73 | if(actr->xx-actr->x)<8){ 85 | if(thor->y > actr->y) actor_shoots(actr,1); 86 | else if(thor->y < actr->y) actor_shoots(actr,0); 87 | else return 0; 88 | } 89 | else if(abs(thor->y-actr->y)<8){ 90 | if(thor->x > actr->x) actor_shoots(actr,3); 91 | else if(thor->x < actr->x) actor_shoots(actr,2); 92 | } 93 | else return 0; 94 | 95 | return 1; 96 | } 97 | //=========================================================================== 98 | int shot_pattern_three(ACTOR *actr){ //uni directional (backwards) 99 | int ld; 100 | 101 | ld=actr->last_dir; 102 | if(shot_pattern_one(actr)){ 103 | actr->last_dir=reverse_direction(actr); 104 | return 1; 105 | } 106 | actr->last_dir=reverse_direction(actr); 107 | shot_pattern_one(actr); 108 | actr->last_dir=ld; 109 | return 1; 110 | } 111 | //=========================================================================== 112 | int shot_pattern_four(ACTOR *actr){ //omni-directional not solid shot 113 | 114 | if(abs(thor->x-actr->x)<8){ 115 | if(thor->y > actr->y) actor_always_shoots(actr,1); 116 | else if(thor->y < actr->y) actor_always_shoots(actr,0); 117 | else return 0; 118 | } 119 | else if(abs(thor->y-actr->y)<8){ 120 | if(thor->x > actr->x) actor_always_shoots(actr,3); 121 | else if(thor->x < actr->x) actor_always_shoots(actr,2); 122 | } 123 | else return 0; 124 | 125 | return 1; 126 | } 127 | //=========================================================================== 128 | int shot_pattern_five(ACTOR *actr){ //boss - snake 129 | int num; 130 | 131 | if(rand1<15){ 132 | if((actr->temp1==0) && (actr->temp2==0)){ 133 | actr->y+=16; 134 | actr->shots_allowed=3+setup.skill; 135 | actor_shoots(actr,2); 136 | play_sound(BOSS12,0); 137 | // num=actr->creator; 138 | num=actr->shot_actor; 139 | actr->shot_cnt=50; 140 | actor[num].temp3=120; 141 | actor[num].temp4=5+(rand2%17); 142 | actor[num].temp5=actor[num].temp4; 143 | actr->y-=16; 144 | return 1; 145 | } 146 | } 147 | return 0; 148 | } 149 | //=========================================================================== 150 | int shot_pattern_six(ACTOR *actr){ //4 surrounding squares 151 | int pos; 152 | 153 | pos=((actr->x)/16)+(((actr->y)/16)*20); 154 | 155 | if(thor_pos==pos-20) actor_shoots(actr,0); 156 | else if(thor_pos==pos+20) actor_shoots(actr,1); 157 | else if(thor_pos==pos-1) actor_shoots(actr,2); 158 | else if(thor_pos==pos+1) actor_shoots(actr,3); 159 | else return 0; 160 | 161 | actr->frame_sequence[3]=3; 162 | actr->next=3; 163 | return 1; 164 | } 165 | //=========================================================================== 166 | int shot_pattern_seven(ACTOR *actr){ //none 167 | 168 | actr=actr; 169 | return 0; 170 | } 171 | //=========================================================================== 172 | int shot_pattern_eight(ACTOR *actr){ //random 173 | 174 | if(!actr->i2){ 175 | actr->i1=actr->func_pass; 176 | actr->i2=1; 177 | } 178 | 179 | if(actr->i1) actr->i1--; 180 | else{ 181 | if(rand1<10){ 182 | actr->i1=thor_x1; 183 | actr->i2=thor_real_y1; 184 | actr->i1=actr->func_pass; 185 | actor_shoots(actr,0); 186 | return 1; 187 | } 188 | } 189 | return 0; 190 | } 191 | -------------------------------------------------------------------------------- /src/1_SPTILE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <1_define.h> 10 | #include <1_proto.h> 11 | //=========================================================================== 12 | extern int new_level,current_level,new_level_tile; 13 | extern int warp_flag; 14 | extern LEVEL scrn; 15 | extern ACTOR actor[MAX_ACTORS]; 16 | extern ACTOR *thor; 17 | extern char far *bg_pics; 18 | extern THOR_INFO thor_info; 19 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 20 | extern unsigned int display_page,draw_page; 21 | extern int cash1_inform,cash2_inform,door_inform; 22 | extern char diag; 23 | extern char warp_scroll; 24 | extern int exit_flag; 25 | extern char end_tile; 26 | //=========================================================================== 27 | int open_door1(int y,int x); 28 | int cash_door1(int y,int x,int amount); 29 | //=========================================================================== 30 | int special_tile_thor(int x,int y,int icon){ 31 | int cx,cy,f; 32 | 33 | f=0; 34 | switch(icon){ 35 | case 201: 36 | return open_door1(x,y); 37 | case 202: 38 | if(thor->x>300) end_tile=1; //ending bridge 39 | return 1; 40 | case 203: 41 | return 0; 42 | case 204: 43 | return 0; 44 | case 205: 45 | if(!diag && thor->dir!=1) return 1; 46 | break; 47 | case 206: 48 | if(!diag && thor->dir!=0) return 1; 49 | break; 50 | case 207: 51 | if(!diag && thor->dir!=3) return 1; 52 | break; 53 | case 208: 54 | if(!diag && thor->dir!=2) return 1; 55 | break; 56 | case 209: 57 | return cash_door1(x,y,10); 58 | case 210: 59 | return cash_door1(x,y,100); 60 | case 211: 61 | // if(thor->center_x=y && thor->center_y==x){ 62 | place_tile(y,x,79); 63 | exit_flag=2; 64 | // } 65 | return 1; 66 | case 212: 67 | case 213: 68 | return 0; 69 | case 214: //teleport tiles 70 | case 215: 71 | case 216: 72 | case 217: 73 | return 0; 74 | case 218: 75 | case 219: 76 | f=1; 77 | case 220: //hole tiles 78 | case 221: 79 | case 222: 80 | case 223: 81 | case 224: 82 | case 225: 83 | case 226: 84 | case 227: 85 | case 228: 86 | case 229: 87 | // mx=(thor->x+6)%16; 88 | // my=(thor->y+12)%16; 89 | // if(mx<4 || mx>12) return 1; 90 | // if(my<4) return 1; 91 | 92 | cx=(thor_x1+7)/16; 93 | cy=(thor_real_y1+8)/16; 94 | if(scrn.icon[cy][cx]==icon){ 95 | thor->vunerable=STAMINA; 96 | if(icon<224 && icon>219) play_sound(FALL,0); 97 | new_level=scrn.new_level[icon-220+(f*6)]; 98 | warp_scroll=0; 99 | if(new_level>119){ 100 | warp_scroll=1; 101 | new_level-=128; 102 | } 103 | new_level_tile=scrn.new_level_loc[icon-220+(f*6)]; 104 | warp_flag=1; 105 | if(warp_scroll){ 106 | if(thor->dir==0) thor->y=175; 107 | else if(thor->dir==1) thor->y=0; 108 | else if(thor->dir==2) thor->x=304; 109 | else if(thor->dir==3) thor->x=0; 110 | } 111 | else{ 112 | thor->x=(new_level_tile%20)*16; 113 | thor->y=((new_level_tile/20)*16)-2; 114 | } 115 | thor->last_x[0]=thor->x; 116 | thor->last_x[1]=thor->x; 117 | thor->last_y[0]=thor->y; 118 | thor->last_y[1]=thor->y; 119 | return 0; 120 | } 121 | return 1; 122 | } 123 | return 0; 124 | } 125 | //=========================================================================== 126 | int special_tile(ACTOR *actr,int x,int y,int icon){ 127 | 128 | switch(icon){ 129 | case 201: 130 | case 202: 131 | case 203: 132 | case 204: 133 | break; 134 | case 205: 135 | // if(actr->last_dir==0 || actr->flying) return 1; 136 | // break; 137 | case 206: 138 | case 207: 139 | case 208: 140 | return 1; 141 | case 209: 142 | case 210: 143 | return 0; 144 | case 214: 145 | case 215: 146 | case 216: 147 | case 217: 148 | return 0; 149 | case 224: 150 | case 225: 151 | case 226: 152 | case 227: 153 | if(!actr->flying) return 0; 154 | return 1; 155 | default: 156 | x=x; 157 | y=y; 158 | // if(actr->flying) return 1; 159 | return 1; 160 | 161 | } 162 | return 0; 163 | } 164 | //=========================================================================== 165 | void erase_door(int x,int y){ 166 | 167 | play_sound(DOOR,0); 168 | scrn.icon[y][x]=scrn.bg_color; 169 | x=x<<4; 170 | y=y<<4; 171 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 172 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,draw_page,320,320); 173 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,display_page,320,320); 174 | } 175 | //=========================================================================== 176 | int open_door1(int y,int x){ 177 | 178 | if(thor_info.keys>0){ 179 | erase_door(x,y); 180 | thor_info.keys--; 181 | display_keys(); 182 | return 1; 183 | } 184 | else{ 185 | if(!door_inform){ 186 | odin_speaks(2003,0); 187 | door_inform=1; 188 | } 189 | } 190 | return 0; 191 | } 192 | //=========================================================================== 193 | int cash_door1(int y,int x,int amount){ 194 | 195 | if(thor_info.jewels>=amount){ 196 | erase_door(x,y); 197 | thor_info.jewels-=amount; 198 | display_jewels(); 199 | return 1; 200 | } 201 | else{ 202 | if(amount==10 && !cash1_inform){ 203 | odin_speaks(2005,0); 204 | cash1_inform=1; 205 | } 206 | if(amount==100 && !cash2_inform){ 207 | odin_speaks(2004,0); 208 | cash2_inform=1; 209 | } 210 | } 211 | return 0; 212 | } 213 | 214 | 215 | -------------------------------------------------------------------------------- /src/GOT2/2_FILE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include <2_define.h> 17 | #include <2_proto.h> 18 | //============================================================================ 19 | extern char far *bg_pics; 20 | extern char far objects[NUM_OBJECTS][262]; 21 | extern char far *sd_data; 22 | extern char *tmp_buff; 23 | //extern char file_str[10]; 24 | extern char res_file[]; 25 | extern THOR_INFO thor_info; 26 | extern int current_area; 27 | extern ACTOR *thor; 28 | extern char *save_filename; 29 | extern union REGS in,out; 30 | extern SETUP setup; 31 | extern char level_type,slow_mode; 32 | extern int boss_active; 33 | extern char area; 34 | extern char test_sdf[]; 35 | extern char far *song; 36 | extern char far *lzss_buff; 37 | extern char *options_yesno[]; 38 | extern int music_flag,sound_flag,pcsound_flag; 39 | extern char game_over; 40 | extern unsigned int display_page,draw_page; 41 | extern volatile char key_flag[100]; 42 | extern int game_is_over; 43 | //=========================================================================== 44 | long file_size(char *path){ 45 | long tmpl; 46 | FILE *tmp_fp; 47 | 48 | tmp_fp=fopen(path,"rb"); 49 | if(!tmp_fp) return -1; 50 | fseek(tmp_fp,0l,SEEK_END); 51 | tmpl=ftell(tmp_fp); 52 | fclose(tmp_fp); 53 | return tmpl; 54 | } 55 | //=========================================================================== 56 | int load_bg_data(void){ 57 | char s[21]; 58 | char str[21]; 59 | 60 | strcpy(s,"BPICS"); 61 | itoa(area,str,10); 62 | strcat(s,str); 63 | 64 | bg_pics=farmalloc(60460l); 65 | if(!bg_pics) return 0; 66 | if(res_read(s,bg_pics)<0) return 0; 67 | return 1; 68 | } 69 | //=========================================================================== 70 | int load_sd_data(void){ 71 | char s[21]; 72 | char str[21]; 73 | 74 | strcpy(s,"SDAT"); 75 | itoa(area,str,10); 76 | strcat(s,str); 77 | 78 | if(!sd_data) sd_data=farmalloc(61440l); 79 | if(!sd_data) return 0; 80 | if(res_read(s,sd_data)<0) return 0; 81 | return 1; 82 | } 83 | //=========================================================================== 84 | int load_objects(void){ 85 | 86 | if(res_read("OBJECTS",(char far *)objects)<0) return 0; 87 | return 1; 88 | } 89 | //=========================================================================== 90 | int load_actor(int file,int num){ 91 | char s[21]; 92 | char rs[21]; 93 | 94 | itoa(num,s,10); 95 | strcpy(rs,"ACTOR"); 96 | strcat(rs,s); 97 | if(res_read(rs,tmp_buff)<0) return 0; 98 | file=file; 99 | return 1; 100 | } 101 | //=========================================================================== 102 | void help(void){ 103 | 104 | 105 | odin_speaks(2008,0); 106 | } 107 | //=========================================================================== 108 | void save_game(void){ 109 | int handle; 110 | unsigned int total; 111 | char buff[32]; 112 | 113 | if(game_is_over) return; 114 | setup.area=area; 115 | setup.game_over=game_over; 116 | if(select_option(options_yesno,"Save Game?",0)!=1) return; 117 | 118 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return; 119 | _dos_read(handle, buff,32,&total); 120 | _dos_close(handle); 121 | 122 | if(_dos_open(save_filename,O_WRONLY, &handle)!=0) return; 123 | _dos_write(handle, buff,32,&total); 124 | _dos_write(handle, &setup,sizeof(SETUP),&total); 125 | _dos_write(handle, &thor_info,sizeof(THOR_INFO),&total); 126 | _dos_write(handle, sd_data,61440u,&total); 127 | _dos_close(handle); 128 | odin_speaks(2009,0); 129 | } 130 | //=========================================================================== 131 | int load_game(int flag){ 132 | int handle; 133 | unsigned int total; 134 | char buff[32]; 135 | 136 | if(flag) if(select_option(options_yesno,"Load Game?",0)!=1) return 0; 137 | 138 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return 0; 139 | _dos_read(handle, buff,32,&total); 140 | _dos_read(handle, &setup,sizeof(SETUP),&total); 141 | _dos_read(handle, &thor_info,sizeof(THOR_INFO),&total); 142 | _dos_read(handle, sd_data,61440u,&total); 143 | _dos_close(handle); 144 | 145 | current_area=thor_info.last_screen; 146 | area=setup.area; 147 | if(area==0) area=1; 148 | 149 | thor->x=(thor_info.last_icon%20)*16; 150 | thor->y=((thor_info.last_icon/20)*16)-1; 151 | if(thor->x<1) thor->x=1; 152 | if(thor->y<0) thor->y=0; 153 | thor->dir=thor_info.last_dir; 154 | thor->last_dir=thor_info.last_dir; 155 | thor->health=thor_info.last_health; 156 | thor->num_moves=1; 157 | thor->vunerable=60; 158 | thor->show=60; 159 | thor->speed_count=6; 160 | load_new_thor(); 161 | display_health(); 162 | display_magic(); 163 | display_jewels(); 164 | display_keys(); 165 | display_item(); 166 | if(!music_flag) setup.music=0; 167 | if(!sound_flag) setup.dig_sound=0; 168 | if(setup.music==1){ 169 | if(current_area==BOSS_LEVEL){ 170 | if(flag) music_play(6,1); 171 | } 172 | else if(flag) music_play(level_type,1); 173 | } 174 | else{ 175 | setup.music=1; 176 | music_pause(); 177 | setup.music=0; 178 | } 179 | game_over=setup.game_over; 180 | slow_mode=setup.speed; 181 | return 1; 182 | } 183 | //========================================================================== 184 | /* 185 | long res_read(char *name,char far *buff){ 186 | int num,bytes; 187 | size_t len; 188 | size_t total; 189 | char bf[256]; 190 | char far *p; 191 | unsigned int clen; 192 | unsigned int far *up; 193 | 194 | if(!res_active) return RES_NOT_ACTIVE; 195 | if(!res_fp) return RES_NOT_OPEN; 196 | 197 | num=res_find_name(name); 198 | if(num<0) return RES_CANT_FIND; 199 | 200 | if(fseek(res_fp,res_header[num].offset,SEEK_SET)) return RES_CANT_SEEK; 201 | len=(size_t) res_header[num].length; 202 | 203 | total=0; 204 | if(res_header[num].key) p=buff; 205 | else p=lzss_buff; 206 | while(total255) && (len > 255)) bytes=fread(bf,1,256,res_fp); 208 | else bytes=fread(bf,1,len-total,res_fp); 209 | if(!bytes) break; 210 | total+=bytes; 211 | movedata(FP_SEG(bf),FP_OFF(bf),FP_SEG(p),FP_OFF(p),bytes); 212 | p+=bytes; 213 | } 214 | if(res_header[num].key) res_decode(buff,len,res_header[num].key); 215 | else{ 216 | p=lzss_buff; 217 | up=(unsigned int far *) p; 218 | clen=*up; 219 | p+=4; 220 | UnLZSS(p,buff,clen); 221 | } 222 | return res_header[num].length; 223 | } 224 | */ 225 | //========================================================================== 226 | int load_music(int num){ 227 | 228 | switch(num){ 229 | case 0: 230 | res_read("SONG21",song); 231 | break; 232 | case 1: 233 | res_read("SONG22",song); 234 | break; 235 | case 2: 236 | res_read("SONG23",song); 237 | break; 238 | case 3: 239 | res_read("SONG24",song); 240 | break; 241 | case 4: 242 | res_read("SONG35",song); 243 | break; 244 | case 5: 245 | res_read("SONG25",song); 246 | break; 247 | case 6: 248 | res_read("WINSONG",song); 249 | break; 250 | case 7: 251 | res_read("BOSSSONG",song); 252 | break; 253 | } 254 | if(!song) return 0; 255 | return 1; 256 | } 257 | -------------------------------------------------------------------------------- /src/GOT3/3_FILE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include <3_define.h> 17 | #include <3_proto.h> 18 | //============================================================================ 19 | extern char far *bg_pics; 20 | extern char far objects[NUM_OBJECTS][262]; 21 | extern char far *sd_data; 22 | extern char *tmp_buff; 23 | //extern char file_str[10]; 24 | extern char res_file[]; 25 | extern THOR_INFO thor_info; 26 | extern int current_area; 27 | extern ACTOR *thor; 28 | extern char *save_filename; 29 | extern union REGS in,out; 30 | extern SETUP setup; 31 | extern char level_type,slow_mode; 32 | extern int boss_active; 33 | extern char area; 34 | extern char test_sdf[]; 35 | extern char far *song; 36 | extern char far *lzss_buff; 37 | extern char *options_yesno[]; 38 | extern int music_flag,sound_flag,pcsound_flag; 39 | extern char game_over; 40 | extern unsigned int display_page,draw_page; 41 | extern volatile char key_flag[100]; 42 | extern int game_is_over; 43 | //=========================================================================== 44 | long file_size(char *path){ 45 | long tmpl; 46 | FILE *tmp_fp; 47 | 48 | tmp_fp=fopen(path,"rb"); 49 | if(!tmp_fp) return -1; 50 | fseek(tmp_fp,0l,SEEK_END); 51 | tmpl=ftell(tmp_fp); 52 | fclose(tmp_fp); 53 | return tmpl; 54 | } 55 | //=========================================================================== 56 | int load_bg_data(void){ 57 | char s[21]; 58 | char str[21]; 59 | 60 | strcpy(s,"BPICS"); 61 | itoa(area,str,10); 62 | strcat(s,str); 63 | 64 | bg_pics=farmalloc(60460l); 65 | if(!bg_pics) return 0; 66 | if(res_read(s,bg_pics)<0) return 0; 67 | return 1; 68 | } 69 | //=========================================================================== 70 | int load_sd_data(void){ 71 | char s[21]; 72 | char str[21]; 73 | 74 | strcpy(s,"SDAT"); 75 | itoa(area,str,10); 76 | strcat(s,str); 77 | 78 | if(!sd_data) sd_data=farmalloc(61440l); 79 | if(!sd_data) return 0; 80 | if(res_read(s,sd_data)<0) return 0; 81 | return 1; 82 | } 83 | //=========================================================================== 84 | int load_objects(void){ 85 | 86 | if(res_read("OBJECTS",(char far *)objects)<0) return 0; 87 | return 1; 88 | } 89 | //=========================================================================== 90 | int load_actor(int file,int num){ 91 | char s[21]; 92 | char rs[21]; 93 | 94 | itoa(num,s,10); 95 | strcpy(rs,"ACTOR"); 96 | strcat(rs,s); 97 | if(res_read(rs,tmp_buff)<0) return 0; 98 | file=file; 99 | return 1; 100 | } 101 | //=========================================================================== 102 | void help(void){ 103 | 104 | 105 | odin_speaks(2008,0); 106 | } 107 | //=========================================================================== 108 | void save_game(void){ 109 | int handle; 110 | unsigned int total; 111 | char buff[32]; 112 | 113 | if(game_is_over) return; 114 | setup.area=area; 115 | setup.game_over=game_over; 116 | if(select_option(options_yesno,"Save Game?",0)!=1) return; 117 | 118 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return; 119 | _dos_read(handle, buff,32,&total); 120 | _dos_close(handle); 121 | 122 | if(_dos_open(save_filename,O_WRONLY, &handle)!=0) return; 123 | _dos_write(handle, buff,32,&total); 124 | _dos_write(handle, &setup,sizeof(SETUP),&total); 125 | _dos_write(handle, &thor_info,sizeof(THOR_INFO),&total); 126 | _dos_write(handle, sd_data,61440u,&total); 127 | _dos_close(handle); 128 | odin_speaks(2009,0); 129 | } 130 | //=========================================================================== 131 | int load_game(int flag){ 132 | int handle; 133 | unsigned int total; 134 | char buff[32]; 135 | 136 | if(flag) if(select_option(options_yesno,"Load Game?",0)!=1) return 0; 137 | 138 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return 0; 139 | _dos_read(handle, buff,32,&total); 140 | _dos_read(handle, &setup,sizeof(SETUP),&total); 141 | _dos_read(handle, &thor_info,sizeof(THOR_INFO),&total); 142 | _dos_read(handle, sd_data,61440u,&total); 143 | _dos_close(handle); 144 | 145 | current_area=thor_info.last_screen; 146 | area=setup.area; 147 | if(area==0) area=1; 148 | 149 | thor->x=(thor_info.last_icon%20)*16; 150 | thor->y=((thor_info.last_icon/20)*16)-1; 151 | if(thor->x<1) thor->x=1; 152 | if(thor->y<0) thor->y=0; 153 | thor->dir=thor_info.last_dir; 154 | thor->last_dir=thor_info.last_dir; 155 | thor->health=thor_info.last_health; 156 | thor->num_moves=1; 157 | thor->vunerable=60; 158 | thor->show=60; 159 | thor->speed_count=6; 160 | load_new_thor(); 161 | display_health(); 162 | display_magic(); 163 | display_jewels(); 164 | display_keys(); 165 | display_item(); 166 | if(!music_flag) setup.music=0; 167 | if(!sound_flag) setup.dig_sound=0; 168 | if(setup.music==1){ 169 | if(current_area==BOSS_LEVEL){ 170 | if(flag) music_play(6,1); 171 | } 172 | else if(flag) music_play(level_type,1); 173 | } 174 | else{ 175 | setup.music=1; 176 | music_pause(); 177 | setup.music=0; 178 | } 179 | game_over=setup.game_over; 180 | slow_mode=setup.speed; 181 | return 1; 182 | } 183 | //========================================================================== 184 | /* 185 | long res_read(char *name,char far *buff){ 186 | int num,bytes; 187 | size_t len; 188 | size_t total; 189 | char bf[256]; 190 | char far *p; 191 | unsigned int clen; 192 | unsigned int far *up; 193 | 194 | if(!res_active) return RES_NOT_ACTIVE; 195 | if(!res_fp) return RES_NOT_OPEN; 196 | 197 | num=res_find_name(name); 198 | if(num<0) return RES_CANT_FIND; 199 | 200 | if(fseek(res_fp,res_header[num].offset,SEEK_SET)) return RES_CANT_SEEK; 201 | len=(size_t) res_header[num].length; 202 | 203 | total=0; 204 | if(res_header[num].key) p=buff; 205 | else p=lzss_buff; 206 | while(total255) && (len > 255)) bytes=fread(bf,1,256,res_fp); 208 | else bytes=fread(bf,1,len-total,res_fp); 209 | if(!bytes) break; 210 | total+=bytes; 211 | movedata(FP_SEG(bf),FP_OFF(bf),FP_SEG(p),FP_OFF(p),bytes); 212 | p+=bytes; 213 | } 214 | if(res_header[num].key) res_decode(buff,len,res_header[num].key); 215 | else{ 216 | p=lzss_buff; 217 | up=(unsigned int far *) p; 218 | clen=*up; 219 | p+=4; 220 | UnLZSS(p,buff,clen); 221 | } 222 | return res_header[num].length; 223 | } 224 | */ 225 | //========================================================================== 226 | int load_music(int num){ 227 | 228 | switch(num){ 229 | case 0: 230 | res_read("SONG31",song); 231 | break; 232 | case 1: 233 | res_read("SONG32",song); 234 | break; 235 | case 2: 236 | res_read("SONG33",song); 237 | break; 238 | case 3: 239 | res_read("SONG34",song); 240 | break; 241 | case 4: 242 | res_read("SONG35",song); 243 | break; 244 | case 5: 245 | res_read("SONG36",song); 246 | break; 247 | case 6: 248 | res_read("WINSONG",song); 249 | break; 250 | case 7: 251 | res_read("BOSSSONG",song); 252 | break; 253 | } 254 | if(!song) return 0; 255 | return 1; 256 | } 257 | -------------------------------------------------------------------------------- /src/GOT3/3_SPTILE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <3_define.h> 10 | #include <3_proto.h> 11 | //=========================================================================== 12 | extern int new_level,current_level,new_level_tile; 13 | extern int warp_flag; 14 | extern LEVEL scrn; 15 | extern ACTOR actor[MAX_ACTORS]; 16 | extern ACTOR *thor; 17 | extern char far *bg_pics; 18 | extern THOR_INFO thor_info; 19 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 20 | extern unsigned int display_page,draw_page; 21 | extern int cash1_inform,cash2_inform,door_inform; 22 | extern char diag; 23 | extern char warp_scroll; 24 | extern int exit_flag; 25 | extern SETUP setup; 26 | extern char end_tile; 27 | //=========================================================================== 28 | void erase_door(int x,int y); 29 | int open_door1(int y,int x); 30 | int cash_door1(int y,int x,int amount); 31 | //=========================================================================== 32 | int special_tile_thor(int x,int y,int icon){ 33 | int cx,cy,nt,f; 34 | 35 | f=0; 36 | switch(icon){ 37 | case 201: 38 | return open_door1(x,y); 39 | case 202: 40 | if(thor_info.inventory & 64){ 41 | if(thor_info.object==4){ 42 | erase_door(y,x); 43 | delete_object(); 44 | return 1; 45 | } 46 | } 47 | return 0; 48 | case 203: 49 | if((thor_info.inventory & 64) && thor_info.object==5){ 50 | odin_speaks(2012,0); 51 | delete_object(); 52 | setup.f10=1; 53 | } 54 | else if(!setup.f10){ 55 | odin_speaks(2011,0); 56 | setup.f10=1; 57 | } 58 | return 1; 59 | case 204: 60 | if(thor->x<4) end_tile=1; 61 | return 1; 62 | case 205: 63 | if(!diag && thor->dir!=1) return 1; 64 | break; 65 | case 206: 66 | if(!diag && thor->dir!=0) return 1; 67 | break; 68 | case 207: 69 | if(!diag && thor->dir!=3) return 1; 70 | break; 71 | case 208: 72 | if(!diag && thor->dir!=2) return 1; 73 | break; 74 | case 209: 75 | return cash_door1(x,y,10); 76 | case 210: 77 | return cash_door1(x,y,100); 78 | case 211: 79 | case 212: 80 | case 213: 81 | return 0; 82 | case 214: //teleport tiles 83 | case 215: 84 | case 216: 85 | case 217: 86 | // mx=(thor->x+6)%16; 87 | // my=(thor->y+12)%16; 88 | // if(mx<4 || mx>12) return 1; 89 | // if(my<4) return 1; 90 | cx=(thor_x1+7)/16; 91 | cy=(thor_real_y1+8)/16; 92 | if(scrn.icon[cy][cx]==icon){ 93 | thor->vunerable=STAMINA; 94 | play_sound(WOOP,0); 95 | nt=scrn.new_level_loc[icon-214]; 96 | thor->last_x[display_page]=thor->x; 97 | thor->last_y[display_page]=thor->y; 98 | thor->x=(nt%20)*16; 99 | thor->y=((nt/20)*16)-2; 100 | thor->last_x[draw_page]=thor->x; 101 | thor->last_y[draw_page]=thor->y; 102 | return 0; 103 | } 104 | return 1; 105 | case 218: 106 | case 219: 107 | f=1; 108 | case 220: //hole tiles 109 | case 221: 110 | case 222: 111 | case 223: 112 | case 224: 113 | case 225: 114 | case 226: 115 | case 227: 116 | case 228: 117 | case 229: 118 | cx=(thor_x1+7)/16; 119 | cy=(thor_real_y1+8)/16; 120 | if(scrn.icon[cy][cx]==icon){ 121 | thor->vunerable=STAMINA; 122 | if(icon<224 && icon>219) play_sound(FALL,0); 123 | new_level=scrn.new_level[icon-220+(f*6)]; 124 | warp_scroll=0; 125 | if(new_level>119){ 126 | warp_scroll=1; 127 | new_level-=128; 128 | } 129 | new_level_tile=scrn.new_level_loc[icon-220+(f*6)]; 130 | warp_flag=1; 131 | if(warp_scroll){ 132 | if(thor->dir==0) thor->y=175; 133 | else if(thor->dir==1) thor->y=0; 134 | else if(thor->dir==2) thor->x=304; 135 | else if(thor->dir==3) thor->x=0; 136 | } 137 | else{ 138 | thor->x=(new_level_tile%20)*16; 139 | thor->y=((new_level_tile/20)*16)-2; 140 | } 141 | thor->last_x[0]=thor->x; 142 | thor->last_x[1]=thor->x; 143 | thor->last_y[0]=thor->y; 144 | thor->last_y[1]=thor->y; 145 | return 0; 146 | } 147 | return 1; 148 | } 149 | return 0; 150 | } 151 | //=========================================================================== 152 | int special_tile(ACTOR *actr,int x,int y,int icon){ 153 | 154 | switch(icon){ 155 | case 201: 156 | case 202: 157 | case 203: 158 | case 204: 159 | break; 160 | case 205: 161 | // if(actr->last_dir==0 || actr->flying) return 1; 162 | // break; 163 | case 206: 164 | case 207: 165 | case 208: 166 | return 1; 167 | case 209: 168 | case 210: 169 | return 0; 170 | case 211: //house sides 171 | case 212: 172 | return 0; 173 | case 224: 174 | case 225: 175 | case 226: 176 | case 227: 177 | if(!actr->flying) return 0; 178 | return 1; 179 | default: 180 | x=x; 181 | y=y; 182 | // if(actr->flying) return 1; 183 | return 1; 184 | 185 | } 186 | return 0; 187 | } 188 | //=========================================================================== 189 | void erase_door(int x,int y){ 190 | 191 | play_sound(DOOR,0); 192 | scrn.icon[y][x]=scrn.bg_color; 193 | x=x<<4; 194 | y=y<<4; 195 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 196 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,draw_page,320,320); 197 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,display_page,320,320); 198 | } 199 | //=========================================================================== 200 | int open_door1(int y,int x){ 201 | 202 | if(thor_info.keys>0){ 203 | erase_door(x,y); 204 | thor_info.keys--; 205 | display_keys(); 206 | return 1; 207 | } 208 | else{ 209 | if(!door_inform){ 210 | odin_speaks(2003,0); 211 | door_inform=1; 212 | } 213 | } 214 | return 0; 215 | } 216 | //=========================================================================== 217 | int cash_door1(int y,int x,int amount){ 218 | 219 | if(thor_info.jewels>=amount){ 220 | erase_door(x,y); 221 | thor_info.jewels-=amount; 222 | display_jewels(); 223 | return 1; 224 | } 225 | else{ 226 | if(amount==10 && !cash1_inform){ 227 | odin_speaks(2005,0); 228 | cash1_inform=1; 229 | } 230 | if(amount==100 && !cash2_inform){ 231 | odin_speaks(2004,0); 232 | cash2_inform=1; 233 | } 234 | } 235 | return 0; 236 | } 237 | 238 | 239 | -------------------------------------------------------------------------------- /src/1_GRP.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include <1_define.h> 12 | #include <1_proto.h> 13 | //=========================================================================== 14 | extern char far text[94][72]; 15 | extern union REGS in,out; 16 | char pbuff[768]; 17 | extern char dialog_color[16]; 18 | extern char cheat; 19 | extern unsigned int display_page,draw_page; 20 | extern volatile char key_flag[100]; 21 | extern ACTOR actor[MAX_ACTORS]; 22 | //=========================================================================== 23 | void xprint(int x,int y,char *string,unsigned int page,int color){ 24 | char ch; 25 | char str[4]; 26 | 27 | str[3]=0; 28 | x &= 0xfffc; 29 | while(*string){ 30 | ch=*string++; 31 | if(ch=='~' && isxdigit(*string)){ 32 | ch=*string++; 33 | if(isdigit(ch)) ch-=48; 34 | else{ 35 | ch=toupper(ch)-55; 36 | } 37 | color=dialog_color[ch]; 38 | continue; 39 | } 40 | if(ch>31 && ch<127){ 41 | xtext1(x,y,page,text[ch-32],0); 42 | xtext(x,y,page,text[ch-32],color); 43 | } 44 | x+=8; 45 | } 46 | } 47 | //=========================================================================== 48 | void xprintx(int x,int y,char *string,unsigned int page,int color){ 49 | char ch; 50 | char str[4]; 51 | int c; 52 | 53 | c=26; 54 | str[3]=0; 55 | x &= 0xfffc; 56 | while(*string){ 57 | ch=*string++; 58 | if(ch=='~' && isxdigit(*string)){ 59 | ch=*string++; 60 | if(isdigit(ch)) ch-=48; 61 | else{ 62 | ch=toupper(ch)-55; 63 | } 64 | color=dialog_color[ch]; 65 | continue; 66 | } 67 | if(ch>31 && ch<127){ 68 | xtextx(x,y-1,page,text[ch-32],c); 69 | xtextx(x,y+1,page,text[ch-32],c); 70 | xtextx(x+1,y,page,text[ch-32],c); 71 | xtextx(x-1,y,page,text[ch-32],c); 72 | xtextx(x-1,y-1,page,text[ch-32],c); 73 | xtextx(x+1,y+1,page,text[ch-32],c); 74 | xtextx(x+1,y-1,page,text[ch-32],c); 75 | xtextx(x-1,y+1,page,text[ch-32],c); 76 | xtext(x,y,page,text[ch-32],color); 77 | } 78 | x+=8; 79 | } 80 | } 81 | //=========================================================================== 82 | void split_screen(void){ 83 | 84 | asm{ 85 | 86 | mov dx,0x03d4 //CRTC 87 | mov al,0x18 //select LINE COMPARE reg 88 | out dx,al 89 | inc dx 90 | mov ax,128 //set bits 0-7 of LINE COMPARE 91 | //I believe this is what I changed 92 | //I am loading the LINE compare with 93 | //384 (192x2) (128 here + 256 in bit 8) 94 | //since mode X displays each scan line 95 | //twice. I was originally loading 96 | //385, since that was the first 97 | //scan line I wanted for the upper 98 | //half of the screen. 99 | out dx,al 100 | dec dx 101 | mov al,7 //OVERFLOW reg 102 | out dx,al 103 | inc dx 104 | in al,dx 105 | or al,0x10 //set bit 8 of LINE COMPARE 106 | out dx,al 107 | dec dx 108 | mov al,9 109 | out dx,al 110 | inc dx 111 | in al,dx 112 | and al,0xbf //clear bit 9 of LINE COMPARE 113 | out dx,al 114 | } 115 | } 116 | //=========================================================================== 117 | int load_palette(void){ 118 | int i; 119 | char r,g,b,n; 120 | #define DAC_READ_INDEX 03c7h 121 | #define DAC_WRITE_INDEX 03c8h 122 | #define DAC_DATA 03c9h 123 | 124 | 125 | if(res_read("palette",(char far *) pbuff)<0) return 0; 126 | for(i=0;i<768;i++) pbuff[i]=pbuff[i] >> 2; 127 | 128 | for(i=240;i<244;i++){ 129 | *(pbuff+((i*3)+0))=0; 130 | *(pbuff+((i*3)+1))=0; 131 | *(pbuff+((i*3)+2))=0x3b; 132 | } 133 | for(i=244;i<248;i++){ 134 | *(pbuff+((i*3)+0))=0x3b; 135 | *(pbuff+((i*3)+1))=0; 136 | *(pbuff+((i*3)+2))=0; 137 | } 138 | in.h.al=0x10; 139 | in.h.ah=0x10; 140 | for(i=0;i<256;i++){ 141 | n=i; 142 | r=pbuff[i*3]; 143 | g=pbuff[(i*3)+1]; 144 | b=pbuff[(i*3)+2]; 145 | asm mov al,n 146 | asm mov dx,DAC_WRITE_INDEX // Tell DAC what colour index to 147 | asm out dx,al // write to 148 | asm mov dx,DAC_DATA 149 | 150 | asm mov bl,r 151 | asm mov al,bl // Set the red component 152 | asm out dx,al 153 | 154 | asm mov ch,g 155 | asm mov al,ch // Set the green component 156 | asm out dx,al 157 | 158 | asm mov cl,b 159 | asm mov al,cl // Set the blue component 160 | asm out dx,al 161 | } 162 | return 1; 163 | } 164 | /*=========================================================================*/ 165 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color){ 166 | 167 | xline(x1,y1,x2,y1,page,color); 168 | xline(x1,y2,x2,y2,page,color); 169 | xline(x1,y1,x1,y2,page,color); 170 | xline(x2,y1,x2,y2,page,color); 171 | } 172 | /*=========================================================================*/ 173 | void xline(int x0,int y0,int x1,int y1,int page,int color){ 174 | int x,y; 175 | 176 | if(x0==x1 && y0==y1) xpset(x0, y0, page, color); 177 | 178 | else if(abs(x1-x0) >= abs(y1-y0)){ 179 | if(x1 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include <2_define.h> 12 | #include <2_proto.h> 13 | //=========================================================================== 14 | extern char far text[94][72]; 15 | extern union REGS in,out; 16 | char pbuff[768]; 17 | extern char dialog_color[16]; 18 | extern char cheat; 19 | extern unsigned int display_page,draw_page; 20 | extern volatile char key_flag[100]; 21 | extern ACTOR actor[MAX_ACTORS]; 22 | //=========================================================================== 23 | void xprint(int x,int y,char *string,unsigned int page,int color){ 24 | char ch; 25 | char str[4]; 26 | 27 | str[3]=0; 28 | x &= 0xfffc; 29 | while(*string){ 30 | ch=*string++; 31 | if(ch=='~' && isxdigit(*string)){ 32 | ch=*string++; 33 | if(isdigit(ch)) ch-=48; 34 | else{ 35 | ch=toupper(ch)-55; 36 | } 37 | color=dialog_color[ch]; 38 | continue; 39 | } 40 | if(ch>31 && ch<127){ 41 | xtext1(x,y,page,text[ch-32],0); 42 | xtext(x,y,page,text[ch-32],color); 43 | } 44 | x+=8; 45 | } 46 | } 47 | //=========================================================================== 48 | void xprintx(int x,int y,char *string,unsigned int page,int color){ 49 | char ch; 50 | char str[4]; 51 | int c; 52 | 53 | c=26; 54 | str[3]=0; 55 | x &= 0xfffc; 56 | while(*string){ 57 | ch=*string++; 58 | if(ch=='~' && isxdigit(*string)){ 59 | ch=*string++; 60 | if(isdigit(ch)) ch-=48; 61 | else{ 62 | ch=toupper(ch)-55; 63 | } 64 | color=dialog_color[ch]; 65 | continue; 66 | } 67 | if(ch>31 && ch<127){ 68 | xtextx(x,y-1,page,text[ch-32],c); 69 | xtextx(x,y+1,page,text[ch-32],c); 70 | xtextx(x+1,y,page,text[ch-32],c); 71 | xtextx(x-1,y,page,text[ch-32],c); 72 | xtextx(x-1,y-1,page,text[ch-32],c); 73 | xtextx(x+1,y+1,page,text[ch-32],c); 74 | xtextx(x+1,y-1,page,text[ch-32],c); 75 | xtextx(x-1,y+1,page,text[ch-32],c); 76 | xtext(x,y,page,text[ch-32],color); 77 | } 78 | x+=8; 79 | } 80 | } 81 | //=========================================================================== 82 | void split_screen(void){ 83 | 84 | asm{ 85 | 86 | mov dx,0x03d4 //CRTC 87 | mov al,0x18 //select LINE COMPARE reg 88 | out dx,al 89 | inc dx 90 | mov ax,128 //set bits 0-7 of LINE COMPARE 91 | //I believe this is what I changed 92 | //I am loading the LINE compare with 93 | //384 (192x2) (128 here + 256 in bit 8) 94 | //since mode X displays each scan line 95 | //twice. I was originally loading 96 | //385, since that was the first 97 | //scan line I wanted for the upper 98 | //half of the screen. 99 | out dx,al 100 | dec dx 101 | mov al,7 //OVERFLOW reg 102 | out dx,al 103 | inc dx 104 | in al,dx 105 | or al,0x10 //set bit 8 of LINE COMPARE 106 | out dx,al 107 | dec dx 108 | mov al,9 109 | out dx,al 110 | inc dx 111 | in al,dx 112 | and al,0xbf //clear bit 9 of LINE COMPARE 113 | out dx,al 114 | } 115 | } 116 | //=========================================================================== 117 | int load_palette(void){ 118 | int i; 119 | char r,g,b,n; 120 | #define DAC_READ_INDEX 03c7h 121 | #define DAC_WRITE_INDEX 03c8h 122 | #define DAC_DATA 03c9h 123 | 124 | 125 | if(res_read("palette",(char far *) pbuff)<0) return 0; 126 | for(i=0;i<768;i++) pbuff[i]=pbuff[i] >> 2; 127 | 128 | for(i=240;i<244;i++){ 129 | *(pbuff+((i*3)+0))=0; 130 | *(pbuff+((i*3)+1))=0; 131 | *(pbuff+((i*3)+2))=0x3b; 132 | } 133 | for(i=244;i<248;i++){ 134 | *(pbuff+((i*3)+0))=0x3b; 135 | *(pbuff+((i*3)+1))=0; 136 | *(pbuff+((i*3)+2))=0; 137 | } 138 | in.h.al=0x10; 139 | in.h.ah=0x10; 140 | for(i=0;i<256;i++){ 141 | n=i; 142 | r=pbuff[i*3]; 143 | g=pbuff[(i*3)+1]; 144 | b=pbuff[(i*3)+2]; 145 | asm mov al,n 146 | asm mov dx,DAC_WRITE_INDEX // Tell DAC what colour index to 147 | asm out dx,al // write to 148 | asm mov dx,DAC_DATA 149 | 150 | asm mov bl,r 151 | asm mov al,bl // Set the red component 152 | asm out dx,al 153 | 154 | asm mov ch,g 155 | asm mov al,ch // Set the green component 156 | asm out dx,al 157 | 158 | asm mov cl,b 159 | asm mov al,cl // Set the blue component 160 | asm out dx,al 161 | } 162 | return 1; 163 | } 164 | /*=========================================================================*/ 165 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color){ 166 | 167 | xline(x1,y1,x2,y1,page,color); 168 | xline(x1,y2,x2,y2,page,color); 169 | xline(x1,y1,x1,y2,page,color); 170 | xline(x2,y1,x2,y2,page,color); 171 | } 172 | /*=========================================================================*/ 173 | void xline(int x0,int y0,int x1,int y1,int page,int color){ 174 | int x,y; 175 | 176 | if(x0==x1 && y0==y1) xpset(x0, y0, page, color); 177 | 178 | else if(abs(x1-x0) >= abs(y1-y0)){ 179 | if(x1 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include <3_define.h> 12 | #include <3_proto.h> 13 | //=========================================================================== 14 | extern char far text[94][72]; 15 | extern union REGS in,out; 16 | char pbuff[768]; 17 | extern char dialog_color[16]; 18 | extern char cheat; 19 | extern unsigned int display_page,draw_page; 20 | extern volatile char key_flag[100]; 21 | extern ACTOR actor[MAX_ACTORS]; 22 | //=========================================================================== 23 | void xprint(int x,int y,char *string,unsigned int page,int color){ 24 | char ch; 25 | char str[4]; 26 | 27 | str[3]=0; 28 | x &= 0xfffc; 29 | while(*string){ 30 | ch=*string++; 31 | if(ch=='~' && isxdigit(*string)){ 32 | ch=*string++; 33 | if(isdigit(ch)) ch-=48; 34 | else{ 35 | ch=toupper(ch)-55; 36 | } 37 | color=dialog_color[ch]; 38 | continue; 39 | } 40 | if(ch>31 && ch<127){ 41 | xtext1(x,y,page,text[ch-32],0); 42 | xtext(x,y,page,text[ch-32],color); 43 | } 44 | x+=8; 45 | } 46 | } 47 | //=========================================================================== 48 | void xprintx(int x,int y,char *string,unsigned int page,int color){ 49 | char ch; 50 | char str[4]; 51 | int c; 52 | 53 | c=26; 54 | str[3]=0; 55 | x &= 0xfffc; 56 | while(*string){ 57 | ch=*string++; 58 | if(ch=='~' && isxdigit(*string)){ 59 | ch=*string++; 60 | if(isdigit(ch)) ch-=48; 61 | else{ 62 | ch=toupper(ch)-55; 63 | } 64 | color=dialog_color[ch]; 65 | continue; 66 | } 67 | if(ch>31 && ch<127){ 68 | xtextx(x,y-1,page,text[ch-32],c); 69 | xtextx(x,y+1,page,text[ch-32],c); 70 | xtextx(x+1,y,page,text[ch-32],c); 71 | xtextx(x-1,y,page,text[ch-32],c); 72 | xtextx(x-1,y-1,page,text[ch-32],c); 73 | xtextx(x+1,y+1,page,text[ch-32],c); 74 | xtextx(x+1,y-1,page,text[ch-32],c); 75 | xtextx(x-1,y+1,page,text[ch-32],c); 76 | xtext(x,y,page,text[ch-32],color); 77 | } 78 | x+=8; 79 | } 80 | } 81 | //=========================================================================== 82 | void split_screen(void){ 83 | 84 | asm{ 85 | 86 | mov dx,0x03d4 //CRTC 87 | mov al,0x18 //select LINE COMPARE reg 88 | out dx,al 89 | inc dx 90 | mov ax,128 //set bits 0-7 of LINE COMPARE 91 | //I believe this is what I changed 92 | //I am loading the LINE compare with 93 | //384 (192x2) (128 here + 256 in bit 8) 94 | //since mode X displays each scan line 95 | //twice. I was originally loading 96 | //385, since that was the first 97 | //scan line I wanted for the upper 98 | //half of the screen. 99 | out dx,al 100 | dec dx 101 | mov al,7 //OVERFLOW reg 102 | out dx,al 103 | inc dx 104 | in al,dx 105 | or al,0x10 //set bit 8 of LINE COMPARE 106 | out dx,al 107 | dec dx 108 | mov al,9 109 | out dx,al 110 | inc dx 111 | in al,dx 112 | and al,0xbf //clear bit 9 of LINE COMPARE 113 | out dx,al 114 | } 115 | } 116 | //=========================================================================== 117 | int load_palette(void){ 118 | int i; 119 | char r,g,b,n; 120 | #define DAC_READ_INDEX 03c7h 121 | #define DAC_WRITE_INDEX 03c8h 122 | #define DAC_DATA 03c9h 123 | 124 | 125 | if(res_read("palette",(char far *) pbuff)<0) return 0; 126 | for(i=0;i<768;i++) pbuff[i]=pbuff[i] >> 2; 127 | 128 | for(i=240;i<244;i++){ 129 | *(pbuff+((i*3)+0))=0; 130 | *(pbuff+((i*3)+1))=0; 131 | *(pbuff+((i*3)+2))=0x3b; 132 | } 133 | for(i=244;i<248;i++){ 134 | *(pbuff+((i*3)+0))=0x3b; 135 | *(pbuff+((i*3)+1))=0; 136 | *(pbuff+((i*3)+2))=0; 137 | } 138 | in.h.al=0x10; 139 | in.h.ah=0x10; 140 | for(i=0;i<256;i++){ 141 | n=i; 142 | r=pbuff[i*3]; 143 | g=pbuff[(i*3)+1]; 144 | b=pbuff[(i*3)+2]; 145 | asm mov al,n 146 | asm mov dx,DAC_WRITE_INDEX // Tell DAC what colour index to 147 | asm out dx,al // write to 148 | asm mov dx,DAC_DATA 149 | 150 | asm mov bl,r 151 | asm mov al,bl // Set the red component 152 | asm out dx,al 153 | 154 | asm mov ch,g 155 | asm mov al,ch // Set the green component 156 | asm out dx,al 157 | 158 | asm mov cl,b 159 | asm mov al,cl // Set the blue component 160 | asm out dx,al 161 | } 162 | return 1; 163 | } 164 | /*=========================================================================*/ 165 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color){ 166 | 167 | xline(x1,y1,x2,y1,page,color); 168 | xline(x1,y2,x2,y2,page,color); 169 | xline(x1,y1,x1,y2,page,color); 170 | xline(x2,y1,x2,y2,page,color); 171 | } 172 | /*=========================================================================*/ 173 | void xline(int x0,int y0,int x1,int y1,int page,int color){ 174 | int x,y; 175 | 176 | if(x0==x1 && y0==y1) xpset(x0, y0, page, color); 177 | 178 | else if(abs(x1-x0) >= abs(y1-y0)){ 179 | if(x1 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | //=========================================================================== 12 | extern char *tmp_buff; 13 | extern int new_level,current_level; 14 | extern LEVEL scrn; 15 | extern ACTOR actor[MAX_ACTORS]; 16 | extern ACTOR *thor; 17 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 18 | extern ACTOR *hammer; 19 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 20 | extern int lightning_used,tornado_used,hourglass_flag; 21 | extern unsigned int display_page,draw_page; 22 | extern THOR_INFO thor_info; 23 | extern int boss_dead; 24 | extern int boss_active; 25 | extern char pge; 26 | extern ACTOR explosion; 27 | extern volatile char key_flag[100]; 28 | extern volatile unsigned int timer_cnt; 29 | extern SETUP setup; 30 | extern char far *sd_data; 31 | extern char game_over; 32 | extern char cheat; 33 | //=========================================================================== 34 | int boss1_movement(ACTOR *actr){ //boss - snake 35 | int d,x1,y1,f; 36 | 37 | if(boss_dead) return boss_dead1(); 38 | d=actr->last_dir; 39 | if(actr->edge_counter){ 40 | actr->edge_counter--; 41 | goto done; 42 | } 43 | x1=actr->x; 44 | y1=actr->y; 45 | 46 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 47 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 48 | thor_damaged(actr); 49 | } 50 | if(actr->temp3){ //start striking 51 | actr->temp3--; 52 | if(!actr->temp3) play_sound(BOSS11,0); 53 | if(hourglass_flag) actr->num_moves=3; 54 | else actr->num_moves=6; 55 | goto done0; 56 | } 57 | if(actr->temp1){ //strike 58 | actr->temp1--; 59 | if(actr->x<(thor_x1+12)) actr->temp1=0; 60 | actr->temp2=1; 61 | d=2; 62 | actr->x-=2; 63 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 64 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 65 | actr->temp1=0; 66 | goto done1; 67 | } 68 | actr->next=3; 69 | actr->num_moves=setup.skill+2; 70 | goto done1; 71 | } 72 | if(actr->temp2){ //retreating 73 | if(actr->x<256){ 74 | d=3; 75 | actr->x+=2; 76 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 77 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 78 | goto done1; 79 | } 80 | actr->num_moves=setup.skill+1; 81 | goto done0; 82 | } 83 | else actr->temp2=0; 84 | } 85 | if(abs((thor_y1)-(actr->y+20))<8){ 86 | if(!actr->temp1){ 87 | if(actr->x>thor_x1){ 88 | actr->temp3=75; 89 | actr->temp1=130; 90 | actr->temp2=0; 91 | } 92 | } 93 | } 94 | f=0; 95 | if(actr->counter){ 96 | actr->counter--; 97 | switch(d){ 98 | case 1: 99 | x1=actor[5].x; 100 | y1=actor[5].y; 101 | y1+=2; 102 | if(!check_move2(x1,y1,&actor[5])) f=1; 103 | else{ 104 | actr->x=actor[5].x; 105 | actr->y=actor[5].y-16; 106 | } 107 | break; 108 | case 0: 109 | y1-=2; 110 | if(!check_move2(x1,y1,actr)) f=1; 111 | break; 112 | case 3: 113 | x1=actor[5].x; 114 | y1=actor[5].y; 115 | y1+=2; 116 | if(!check_move2(x1,y1,&actor[5])) f=1; 117 | else{ 118 | actr->x=actor[5].x; 119 | actr->y=actor[5].y-16; 120 | } 121 | break; 122 | case 2: 123 | y1-=2; 124 | if(!check_move2(x1,y1,actr)) f=1; 125 | break; 126 | } 127 | } 128 | else f=1; 129 | 130 | if(f==1){ 131 | // if(key_flag[_Z]){ 132 | // f=5; 133 | // } 134 | actr->counter=rnd(90)+10; 135 | // if(BP) printt(actr->counter); 136 | d=rnd(2); 137 | actr->edge_counter=20; 138 | } 139 | 140 | done: 141 | if(d>1) d-=2; 142 | 143 | done0: 144 | next_frame(actr); 145 | if(actr->next==3) actr->next=0; 146 | 147 | done1: 148 | actr->last_dir=d; 149 | 150 | actor[4].next=actr->next; 151 | actor[5].next=actr->next; 152 | actor[6].next=actr->next; 153 | 154 | actor[4].last_dir=d; 155 | actor[5].last_dir=d; 156 | actor[6].last_dir=d; 157 | 158 | actor[4].x=actr->x+16; 159 | actor[4].y=actr->y; 160 | actor[5].x=actr->x; 161 | actor[5].y=actr->y+16; 162 | actor[6].x=actr->x+16; 163 | actor[6].y=actr->y+16; 164 | actor[4].num_moves=actr->num_moves; 165 | actor[5].num_moves=actr->num_moves; 166 | actor[6].num_moves=actr->num_moves; 167 | 168 | if(actr->directions==1) return 0; 169 | return d; 170 | } 171 | //=========================================================================== 172 | void check_boss1_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 173 | int rep; 174 | 175 | if(actr->move==15 && act_num==4){ 176 | if((!actor[3].vunerable) && (actor[3].next!=3) && 177 | overlap(x1,y1,x2,y2,actr->x+6,actr->y+4,actr->x+14,actr->y+20)){ 178 | actor_damaged(&actor[3],hammer->strength); 179 | if(cheat && key_flag[_Z]) actor[3].health=0; 180 | else actor[3].health-=10; 181 | actor[3].speed_count=50; 182 | boss_status(actor[3].health); 183 | actor[3].vunerable=100; 184 | play_sound(BOSS13,1); 185 | actor[3].next=1; 186 | for(rep=4;rep<7;rep++){ 187 | actor[rep].next=1; 188 | actor[rep].speed_count=50; 189 | } 190 | if(actor[3].health==0) boss_dead=1; 191 | } 192 | } 193 | } 194 | //=========================================================================== 195 | void boss_level1(void){ 196 | 197 | setup_boss(1); 198 | boss_active=1; 199 | boss_status(-1); 200 | music_pause(); 201 | play_sound(BOSS11,1); 202 | pause(120); 203 | music_play(5,1); 204 | } 205 | //=========================================================================== 206 | int boss_dead1(void){ 207 | int rep,n,x,y,r,x1,y1; 208 | 209 | hourglass_flag=0; 210 | if(boss_dead==1){ 211 | REPEAT(4){ 212 | x1=actor[3+rep].last_x[pge]; 213 | y1=actor[3+rep].last_y[pge]; 214 | x=actor[3+rep].x; 215 | y=actor[3+rep].y; 216 | n=actor[3+rep].actor_num; 217 | r=actor[3+rep].rating; 218 | memcpy(&actor[3+rep],&explosion,sizeof(ACTOR)); 219 | actor[3+rep].actor_num=n; 220 | actor[3+rep].rating=r; 221 | actor[3+rep].x=x; 222 | actor[3+rep].y=y; 223 | actor[3+rep].last_x[pge]=x1; 224 | actor[3+rep].last_x[pge^1]=x; 225 | actor[3+rep].last_y[pge]=y1; 226 | actor[3+rep].last_y[pge^1]=y; 227 | actor[3+rep].used=1; 228 | actor[3+rep].vunerable=255; 229 | actor[3+rep].move=6; 230 | actor[3+rep].next=rep; 231 | actor[3+rep].speed=rnd(3)+6; 232 | actor[3+rep].num_shots=(10-actor[3+rep].speed)*10; 233 | actor[3+rep].speed_count=actor[3+rep].speed; 234 | } 235 | play_sound(EXPLODE,1); 236 | boss_dead++; 237 | for(rep=7;repicon[0][9]=149; 272 | lvl->icon[0][10]=150; 273 | } 274 | -------------------------------------------------------------------------------- /src/GOT3/3_BOSS1.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | //=========================================================================== 12 | extern char *tmp_buff; 13 | extern int new_level,current_level; 14 | extern LEVEL scrn; 15 | extern ACTOR actor[MAX_ACTORS]; 16 | extern ACTOR *thor; 17 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 18 | extern ACTOR *hammer; 19 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 20 | extern int lightning_used,tornado_used,hourglass_flag; 21 | extern unsigned int display_page,draw_page; 22 | extern THOR_INFO thor_info; 23 | extern int boss_dead; 24 | extern int boss_active; 25 | extern char pge; 26 | extern ACTOR explosion; 27 | extern volatile char key_flag[100]; 28 | extern volatile unsigned int timer_cnt; 29 | extern SETUP setup; 30 | extern char far *sd_data; 31 | extern char game_over; 32 | extern char cheat; 33 | //=========================================================================== 34 | int boss1_movement(ACTOR *actr){ //boss - snake 35 | int d,x1,y1,f; 36 | 37 | if(boss_dead) return boss_dead1(); 38 | d=actr->last_dir; 39 | if(actr->edge_counter){ 40 | actr->edge_counter--; 41 | goto done; 42 | } 43 | x1=actr->x; 44 | y1=actr->y; 45 | 46 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 47 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 48 | thor_damaged(actr); 49 | } 50 | if(actr->temp3){ //start striking 51 | actr->temp3--; 52 | if(!actr->temp3) play_sound(BOSS11,0); 53 | if(hourglass_flag) actr->num_moves=3; 54 | else actr->num_moves=6; 55 | goto done0; 56 | } 57 | if(actr->temp1){ //strike 58 | actr->temp1--; 59 | if(actr->x<(thor_x1+12)) actr->temp1=0; 60 | actr->temp2=1; 61 | d=2; 62 | actr->x-=2; 63 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 64 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 65 | actr->temp1=0; 66 | goto done1; 67 | } 68 | actr->next=3; 69 | actr->num_moves=setup.skill+2; 70 | goto done1; 71 | } 72 | if(actr->temp2){ //retreating 73 | if(actr->x<256){ 74 | d=3; 75 | actr->x+=2; 76 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 77 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 78 | goto done1; 79 | } 80 | actr->num_moves=setup.skill+1; 81 | goto done0; 82 | } 83 | else actr->temp2=0; 84 | } 85 | if(abs((thor_y1)-(actr->y+20))<8){ 86 | if(!actr->temp1){ 87 | if(actr->x>thor_x1){ 88 | actr->temp3=75; 89 | actr->temp1=130; 90 | actr->temp2=0; 91 | } 92 | } 93 | } 94 | f=0; 95 | if(actr->counter){ 96 | actr->counter--; 97 | switch(d){ 98 | case 1: 99 | x1=actor[5].x; 100 | y1=actor[5].y; 101 | y1+=2; 102 | if(!check_move2(x1,y1,&actor[5])) f=1; 103 | else{ 104 | actr->x=actor[5].x; 105 | actr->y=actor[5].y-16; 106 | } 107 | break; 108 | case 0: 109 | y1-=2; 110 | if(!check_move2(x1,y1,actr)) f=1; 111 | break; 112 | case 3: 113 | x1=actor[5].x; 114 | y1=actor[5].y; 115 | y1+=2; 116 | if(!check_move2(x1,y1,&actor[5])) f=1; 117 | else{ 118 | actr->x=actor[5].x; 119 | actr->y=actor[5].y-16; 120 | } 121 | break; 122 | case 2: 123 | y1-=2; 124 | if(!check_move2(x1,y1,actr)) f=1; 125 | break; 126 | } 127 | } 128 | else f=1; 129 | 130 | if(f==1){ 131 | // if(key_flag[_Z]){ 132 | // f=5; 133 | // } 134 | actr->counter=rnd(90)+10; 135 | // if(BP) printt(actr->counter); 136 | d=rnd(2); 137 | actr->edge_counter=20; 138 | } 139 | 140 | done: 141 | if(d>1) d-=2; 142 | 143 | done0: 144 | next_frame(actr); 145 | if(actr->next==3) actr->next=0; 146 | 147 | done1: 148 | actr->last_dir=d; 149 | 150 | actor[4].next=actr->next; 151 | actor[5].next=actr->next; 152 | actor[6].next=actr->next; 153 | 154 | actor[4].last_dir=d; 155 | actor[5].last_dir=d; 156 | actor[6].last_dir=d; 157 | 158 | actor[4].x=actr->x+16; 159 | actor[4].y=actr->y; 160 | actor[5].x=actr->x; 161 | actor[5].y=actr->y+16; 162 | actor[6].x=actr->x+16; 163 | actor[6].y=actr->y+16; 164 | actor[4].num_moves=actr->num_moves; 165 | actor[5].num_moves=actr->num_moves; 166 | actor[6].num_moves=actr->num_moves; 167 | 168 | if(actr->directions==1) return 0; 169 | return d; 170 | } 171 | //=========================================================================== 172 | void check_boss1_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 173 | int rep; 174 | 175 | if(actr->move==15 && act_num==4){ 176 | if((!actor[3].vunerable) && (actor[3].next!=3) && 177 | overlap(x1,y1,x2,y2,actr->x+6,actr->y+4,actr->x+14,actr->y+20)){ 178 | actor_damaged(&actor[3],hammer->strength); 179 | if(cheat && key_flag[_Z]) actor[3].health=0; 180 | else actor[3].health-=10; 181 | actor[3].speed_count=50; 182 | boss_status(actor[3].health); 183 | actor[3].vunerable=100; 184 | play_sound(BOSS13,1); 185 | actor[3].next=1; 186 | for(rep=4;rep<7;rep++){ 187 | actor[rep].next=1; 188 | actor[rep].speed_count=50; 189 | } 190 | if(actor[3].health==0) boss_dead=1; 191 | } 192 | } 193 | } 194 | //=========================================================================== 195 | void boss_level1(void){ 196 | 197 | setup_boss(1); 198 | boss_active=1; 199 | boss_status(-1); 200 | music_pause(); 201 | play_sound(BOSS11,1); 202 | pause(120); 203 | music_play(5,1); 204 | } 205 | //=========================================================================== 206 | int boss_dead1(void){ 207 | int rep,n,x,y,r,x1,y1; 208 | 209 | hourglass_flag=0; 210 | if(boss_dead==1){ 211 | REPEAT(4){ 212 | x1=actor[3+rep].last_x[pge]; 213 | y1=actor[3+rep].last_y[pge]; 214 | x=actor[3+rep].x; 215 | y=actor[3+rep].y; 216 | n=actor[3+rep].actor_num; 217 | r=actor[3+rep].rating; 218 | memcpy(&actor[3+rep],&explosion,sizeof(ACTOR)); 219 | actor[3+rep].actor_num=n; 220 | actor[3+rep].rating=r; 221 | actor[3+rep].x=x; 222 | actor[3+rep].y=y; 223 | actor[3+rep].last_x[pge]=x1; 224 | actor[3+rep].last_x[pge^1]=x; 225 | actor[3+rep].last_y[pge]=y1; 226 | actor[3+rep].last_y[pge^1]=y; 227 | actor[3+rep].used=1; 228 | actor[3+rep].vunerable=255; 229 | actor[3+rep].move=6; 230 | actor[3+rep].next=rep; 231 | actor[3+rep].speed=rnd(3)+6; 232 | actor[3+rep].num_shots=(10-actor[3+rep].speed)*10; 233 | actor[3+rep].speed_count=actor[3+rep].speed; 234 | } 235 | play_sound(EXPLODE,1); 236 | boss_dead++; 237 | for(rep=7;repicon[0][9]=149; 272 | lvl->icon[0][10]=150; 273 | } 274 | -------------------------------------------------------------------------------- /src/GOT2/2_SPTILE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <2_define.h> 10 | #include <2_proto.h> 11 | //=========================================================================== 12 | extern int new_level,current_level,new_level_tile; 13 | extern int warp_flag; 14 | extern LEVEL scrn; 15 | extern ACTOR actor[MAX_ACTORS]; 16 | extern ACTOR *thor; 17 | extern char far *bg_pics; 18 | extern THOR_INFO thor_info; 19 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 20 | extern unsigned int display_page,draw_page; 21 | extern int cash1_inform,cash2_inform,door_inform; 22 | extern char diag; 23 | extern char warp_scroll; 24 | extern int exit_flag; 25 | extern SETUP setup; 26 | extern char slip_flag; 27 | extern int thunder_flag; 28 | extern char end_tile; 29 | //=========================================================================== 30 | void erase_door(int x,int y); 31 | int open_door1(int y,int x); 32 | int cash_door1(int y,int x,int amount); 33 | //=========================================================================== 34 | int special_tile_thor(int x,int y,int icon){ 35 | int cx,cy,nt,f; 36 | 37 | f=0; 38 | switch(icon){ 39 | case 201: 40 | return open_door1(x,y); 41 | case 202: 42 | if(thor->x>300) end_tile=1; //ending bridge 43 | return 1; 44 | case 203: 45 | if((thor_info.inventory & 64) && thor_info.object==5){ 46 | odin_speaks(2012,0); 47 | delete_object(); 48 | setup.f10=1; 49 | } 50 | else if(!setup.f10){ 51 | odin_speaks(2011,0); 52 | setup.f10=1; 53 | } 54 | return 1; 55 | case 204: //teflor 56 | if(!setup.f19) slip_flag=1; 57 | return 1; 58 | case 205: 59 | if(!diag && thor->dir!=1) return 1; 60 | break; 61 | case 206: 62 | if(!diag && thor->dir!=0) return 1; 63 | break; 64 | case 207: 65 | if(!diag && thor->dir!=3) return 1; 66 | break; 67 | case 208: 68 | if(!diag && thor->dir!=2) return 1; 69 | break; 70 | case 209: 71 | return cash_door1(x,y,10); 72 | case 210: 73 | return cash_door1(x,y,100); 74 | case 211: 75 | if(thor->dir==0 && setup.f29 && setup.f21 && !setup.f22){ 76 | actor_visible(1); 77 | actor_visible(2); 78 | actor_visible(3); 79 | actor_visible(4); 80 | actor_visible(5); 81 | memset(scrn.actor_invis,0,16); 82 | thunder_flag=60; 83 | play_sound(THUNDER,1); 84 | setup.f22=1; 85 | } 86 | return 1; 87 | case 212: 88 | return 0; 89 | case 213: 90 | case 214: //mushroom 91 | case 215: 92 | case 216: 93 | return 0; 94 | case 217: 95 | cx=(thor_x1+7)/16; 96 | cy=(thor_real_y1+8)/16; 97 | if(scrn.icon[cy][cx]==icon){ 98 | thor->vunerable=STAMINA; 99 | play_sound(WOOP,0); 100 | nt=scrn.new_level_loc[icon-214]; 101 | thor->last_x[display_page]=thor->x; 102 | thor->last_y[display_page]=thor->y; 103 | thor->x=(nt%20)*16; 104 | thor->y=((nt/20)*16)-2; 105 | thor->last_x[draw_page]=thor->x; 106 | thor->last_y[draw_page]=thor->y; 107 | return 0; 108 | } 109 | return 1; 110 | case 218: 111 | case 219: 112 | f=1; 113 | case 220: //hole tiles 114 | case 221: 115 | case 222: 116 | case 223: 117 | case 224: 118 | case 225: 119 | case 226: 120 | case 227: 121 | case 228: 122 | case 229: 123 | // mx=(thor->x+6)%16; 124 | // my=(thor->y+12)%16; 125 | // if(mx<4 || mx>12) return 1; 126 | // if(my<4) return 1; 127 | cx=(thor_x1+7)/16; 128 | cy=(thor_real_y1+8)/16; 129 | if(scrn.icon[cy][cx]==icon){ 130 | thor->vunerable=STAMINA; 131 | if(icon<224 && icon>219) play_sound(FALL,0); 132 | new_level=scrn.new_level[icon-220+(f*6)]; 133 | warp_scroll=0; 134 | if(new_level>119){ 135 | warp_scroll=1; 136 | new_level-=128; 137 | } 138 | new_level_tile=scrn.new_level_loc[icon-220+(f*6)]; 139 | warp_flag=1; 140 | if(warp_scroll){ 141 | if(thor->dir==0) thor->y=175; 142 | else if(thor->dir==1) thor->y=0; 143 | else if(thor->dir==2) thor->x=304; 144 | else if(thor->dir==3) thor->x=0; 145 | } 146 | else{ 147 | thor->x=(new_level_tile%20)*16; 148 | thor->y=((new_level_tile/20)*16)-2; 149 | } 150 | thor->last_x[0]=thor->x; 151 | thor->last_x[1]=thor->x; 152 | thor->last_y[0]=thor->y; 153 | thor->last_y[1]=thor->y; 154 | return 0; 155 | } 156 | return 1; 157 | } 158 | return 0; 159 | } 160 | //=========================================================================== 161 | int special_tile(ACTOR *actr,int x,int y,int icon){ 162 | 163 | switch(icon){ 164 | case 201: 165 | case 202: 166 | case 203: 167 | break; 168 | case 204: 169 | return 1; 170 | case 205: 171 | // if(actr->last_dir==0 || actr->flying) return 1; 172 | // break; 173 | case 206: 174 | case 207: 175 | case 208: 176 | return 1; 177 | case 209: 178 | case 210: 179 | return 0; 180 | case 211: 181 | return 1; 182 | case 212: 183 | return 0; 184 | case 213: 185 | case 214: 186 | case 215: 187 | case 216: 188 | return 0; 189 | case 224: 190 | case 225: 191 | case 226: 192 | case 227: 193 | if(!actr->flying) return 0; 194 | return 1; 195 | default: 196 | x=x; 197 | y=y; 198 | // if(actr->flying) return 1; 199 | return 1; 200 | 201 | } 202 | return 0; 203 | } 204 | //=========================================================================== 205 | void erase_door(int x,int y){ 206 | 207 | play_sound(DOOR,0); 208 | scrn.icon[y][x]=scrn.bg_color; 209 | x=x<<4; 210 | y=y<<4; 211 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 212 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,draw_page,320,320); 213 | xcopyd2d(x,y,x+16,y+16,x,y,PAGE2,display_page,320,320); 214 | } 215 | //=========================================================================== 216 | int open_door1(int y,int x){ 217 | 218 | if(thor_info.keys>0){ 219 | erase_door(x,y); 220 | thor_info.keys--; 221 | display_keys(); 222 | return 1; 223 | } 224 | else{ 225 | if(!door_inform){ 226 | odin_speaks(2003,0); 227 | door_inform=1; 228 | } 229 | } 230 | return 0; 231 | } 232 | //=========================================================================== 233 | int cash_door1(int y,int x,int amount){ 234 | 235 | if(thor_info.jewels>=amount){ 236 | erase_door(x,y); 237 | thor_info.jewels-=amount; 238 | display_jewels(); 239 | return 1; 240 | } 241 | else{ 242 | if(amount==10 && !cash1_inform){ 243 | odin_speaks(2005,0); 244 | cash1_inform=1; 245 | } 246 | if(amount==100 && !cash2_inform){ 247 | odin_speaks(2004,0); 248 | cash2_inform=1; 249 | } 250 | } 251 | return 0; 252 | } 253 | 254 | 255 | -------------------------------------------------------------------------------- /src/1_BOSS1.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | // 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include <1_define.h> 11 | #include <1_proto.h> 12 | //=========================================================================== 13 | extern char *tmp_buff; 14 | extern int new_level,current_level; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern char far *sd_data; 32 | extern char game_over; 33 | extern char cheat; 34 | extern int exit_flag; 35 | //=========================================================================== 36 | int boss1_movement(ACTOR *actr){ //boss - snake 37 | int d,x1,y1,f; 38 | 39 | if(boss_dead) return boss_dead1(); 40 | d=actr->last_dir; 41 | if(actr->edge_counter){ 42 | actr->edge_counter--; 43 | goto done; 44 | } 45 | x1=actr->x; 46 | y1=actr->y; 47 | 48 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 49 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 50 | thor_damaged(actr); 51 | } 52 | if(actr->temp3){ //start striking 53 | actr->temp3--; 54 | if(!actr->temp3) play_sound(BOSS11,0); 55 | if(hourglass_flag) actr->num_moves=3; 56 | else actr->num_moves=6; 57 | goto done0; 58 | } 59 | if(actr->temp1){ //strike 60 | actr->temp1--; 61 | if(actr->x<(thor_x1+12)) actr->temp1=0; 62 | actr->temp2=1; 63 | d=2; 64 | actr->x-=2; 65 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 66 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 67 | actr->temp1=0; 68 | goto done1; 69 | } 70 | actr->next=3; 71 | actr->num_moves=setup.skill+2; 72 | goto done1; 73 | } 74 | if(actr->temp2){ //retreating 75 | if(actr->x<256){ 76 | d=3; 77 | actr->x+=2; 78 | if(overlap(actr->x+2,actr->y+8,actr->x+32,actr->y+30, 79 | thor->x,thor->y+8,thor->x+15,thor->y+15)){ 80 | goto done1; 81 | } 82 | actr->num_moves=setup.skill+1; 83 | goto done0; 84 | } 85 | else actr->temp2=0; 86 | } 87 | if(abs((thor_y1)-(actr->y+20))<8){ 88 | if(!actr->temp1){ 89 | if(actr->x>thor_x1){ 90 | actr->temp3=75; 91 | actr->temp1=130; 92 | actr->temp2=0; 93 | } 94 | } 95 | } 96 | f=0; 97 | if(actr->counter){ 98 | actr->counter--; 99 | switch(d){ 100 | case 1: 101 | x1=actor[5].x; 102 | y1=actor[5].y; 103 | y1+=2; 104 | if(!check_move2(x1,y1,&actor[5])) f=1; 105 | else{ 106 | actr->x=actor[5].x; 107 | actr->y=actor[5].y-16; 108 | } 109 | break; 110 | case 0: 111 | y1-=2; 112 | if(!check_move2(x1,y1,actr)) f=1; 113 | break; 114 | case 3: 115 | x1=actor[5].x; 116 | y1=actor[5].y; 117 | y1+=2; 118 | if(!check_move2(x1,y1,&actor[5])) f=1; 119 | else{ 120 | actr->x=actor[5].x; 121 | actr->y=actor[5].y-16; 122 | } 123 | break; 124 | case 2: 125 | y1-=2; 126 | if(!check_move2(x1,y1,actr)) f=1; 127 | break; 128 | } 129 | } 130 | else f=1; 131 | 132 | if(f==1){ 133 | // if(key_flag[_Z]){ 134 | // f=5; 135 | // } 136 | actr->counter=rnd(90)+10; 137 | // if(BP) printt(actr->counter); 138 | d=rnd(2); 139 | actr->edge_counter=20; 140 | } 141 | 142 | done: 143 | if(d>1) d-=2; 144 | 145 | done0: 146 | next_frame(actr); 147 | if(actr->next==3) actr->next=0; 148 | 149 | done1: 150 | actr->last_dir=d; 151 | 152 | actor[4].next=actr->next; 153 | actor[5].next=actr->next; 154 | actor[6].next=actr->next; 155 | 156 | actor[4].last_dir=d; 157 | actor[5].last_dir=d; 158 | actor[6].last_dir=d; 159 | 160 | actor[4].x=actr->x+16; 161 | actor[4].y=actr->y; 162 | actor[5].x=actr->x; 163 | actor[5].y=actr->y+16; 164 | actor[6].x=actr->x+16; 165 | actor[6].y=actr->y+16; 166 | actor[4].num_moves=actr->num_moves; 167 | actor[5].num_moves=actr->num_moves; 168 | actor[6].num_moves=actr->num_moves; 169 | 170 | if(actr->directions==1) return 0; 171 | return d; 172 | } 173 | //=========================================================================== 174 | void check_boss1_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 175 | int rep; 176 | 177 | if(actr->move==15 && act_num==4){ 178 | if((!actor[3].vunerable) && (actor[3].next!=3) && 179 | overlap(x1,y1,x2,y2,actr->x+6,actr->y+4,actr->x+14,actr->y+20)){ 180 | actor_damaged(&actor[3],hammer->strength); 181 | if(cheat && key_flag[_Z]) actor[3].health=0; 182 | else actor[3].health-=10; 183 | actor[3].speed_count=50; 184 | boss_status(actor[3].health); 185 | actor[3].vunerable=100; 186 | play_sound(BOSS13,1); 187 | actor[3].next=1; 188 | for(rep=4;rep<7;rep++){ 189 | actor[rep].next=1; 190 | actor[rep].speed_count=50; 191 | } 192 | if(actor[3].health==0) boss_dead=1; 193 | } 194 | } 195 | } 196 | //=========================================================================== 197 | void boss_level1(void){ 198 | 199 | setup_boss(1); 200 | boss_active=1; 201 | boss_status(-1); 202 | music_pause(); 203 | play_sound(BOSS11,1); 204 | pause(120); 205 | music_play(5,1); 206 | } 207 | //=========================================================================== 208 | int boss_dead1(void){ 209 | int rep,n,x,y,r,x1,y1; 210 | 211 | hourglass_flag=0; 212 | if(boss_dead==1){ 213 | REPEAT(4){ 214 | x1=actor[3+rep].last_x[pge]; 215 | y1=actor[3+rep].last_y[pge]; 216 | x=actor[3+rep].x; 217 | y=actor[3+rep].y; 218 | n=actor[3+rep].actor_num; 219 | r=actor[3+rep].rating; 220 | memcpy(&actor[3+rep],&explosion,sizeof(ACTOR)); 221 | actor[3+rep].actor_num=n; 222 | actor[3+rep].rating=r; 223 | actor[3+rep].x=x; 224 | actor[3+rep].y=y; 225 | actor[3+rep].last_x[pge]=x1; 226 | actor[3+rep].last_x[pge^1]=x; 227 | actor[3+rep].last_y[pge]=y1; 228 | actor[3+rep].last_y[pge^1]=y; 229 | actor[3+rep].used=1; 230 | actor[3+rep].vunerable=255; 231 | actor[3+rep].move=6; 232 | actor[3+rep].next=rep; 233 | actor[3+rep].speed=rnd(3)+6; 234 | actor[3+rep].num_shots=(10-actor[3+rep].speed)*10; 235 | actor[3+rep].speed_count=actor[3+rep].speed; 236 | } 237 | play_sound(EXPLODE,1); 238 | boss_dead++; 239 | for(rep=7;repdir=1; 254 | thor->next=0; 255 | xerase_actors(actor,display_page); 256 | xdisplay_actors(&actor[MAX_ACTORS-1],display_page); 257 | fill_score(20); 258 | score_for_inv(); 259 | 260 | fill_health(); 261 | fill_magic(); 262 | odin_speaks(1002,0); 263 | 264 | REPEAT(16) scrn.actor_type[rep]=0; 265 | boss_dead=0; 266 | setup.boss_dead[0]=1; 267 | game_over=1; 268 | boss_active=0; 269 | scrn.type=4; 270 | show_level(BOSS_LEVEL1); 271 | 272 | play_sound(ANGEL,1); 273 | place_tile(18,6,148); 274 | place_tile(19,6,202); 275 | actor_visible(1); 276 | actor_visible(2); 277 | 278 | lvl=(LEVEL far *) (sd_data+(59*512)); 279 | lvl->icon[6][18]=148; 280 | lvl->icon[6][19]=202; 281 | exit_flag=0; 282 | } 283 | -------------------------------------------------------------------------------- /src/GOT2/2_BOSS21.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <3_define.h> 10 | #include <3_proto.h> 11 | 12 | void check_boss_hit(void); 13 | //=========================================================================== 14 | extern int new_level,current_level; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern int rand1,rand2; 32 | extern char apple_drop; 33 | //=========================================================================== 34 | int boss_movement(ACTOR *actr){ //boss - wraith 35 | int d,x1,y1,f,ox,oy; 36 | 37 | if(boss_dead) return boss_dead(); 38 | check_boss_hit(); 39 | d=actr->last_dir; 40 | actr->num_moves=2; 41 | actr->temp3++; 42 | 43 | if(actr->temp2) actr->temp2--; 44 | if(actr->temp1) actr->temp1--; 45 | else if(actor[4].num_shotstemp1=20; 49 | } 50 | f=0; 51 | if(actr->temp4){ 52 | actr->temp4--; 53 | if(!actr->temp4){ 54 | actr->temp3=0; 55 | actor[3].frame_speed=4; 56 | actor[3].dir=0; 57 | actor[3].last_dir=0; 58 | actor[3].next=0; 59 | actor[4].dir=0; 60 | actor[4].last_dir=0; 61 | actor[4].next=0; 62 | actor_always_shoots(actr,0); 63 | actor[actr->shot_actor].x=actr->x+8; 64 | actor[actr->shot_actor].y=actr->y; 65 | actor[actr->shot_actor].temp1=rnd(100)+60; 66 | actor[actr->shot_actor].speed=2; 67 | } 68 | goto skip_move; 69 | } 70 | 71 | if(actr->edge_counter) actr->edge_counter--; 72 | else goto new_dir; 73 | 74 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 75 | thor->x,thor->y+4,thor->x+15,thor->y+15)) 76 | thor_damaged(actr); 77 | 78 | ox=actr->x; 79 | oy=actr->y; 80 | switch(actr->temp5){ 81 | case 0: 82 | x1=actor[3].x; 83 | y1=actor[3].y-2; 84 | if(!check_move2(x1,y1,&actor[3])){ 85 | f=1; 86 | break; 87 | } 88 | if(!check_move2(x1+16,y1,&actor[4])) f=1; 89 | actr->y=oy-2; 90 | break; 91 | case 1: 92 | x1=actor[5].x; 93 | y1=actor[5].y+2; 94 | if(!check_move2(x1,y1,&actor[5])){ 95 | f=1; 96 | break; 97 | } 98 | if(!check_move2(x1+16,y1,&actor[6])) f=1; 99 | actr->y=oy+2; 100 | break; 101 | case 2: 102 | x1=actor[3].x-2; 103 | y1=actor[3].y; 104 | if(!check_move2(x1,y1,&actor[3])){ 105 | f=1; 106 | break; 107 | } 108 | if(!check_move2(x1,y1+16,&actor[5])) f=1; 109 | actr->x=ox-2; 110 | break; 111 | case 3: 112 | x1=actor[4].x+2; 113 | y1=actor[4].y; 114 | if(!check_move2(x1,y1,&actor[4])){ 115 | f=1; 116 | break; 117 | } 118 | if(!check_move2(x1,y1+16,&actor[6])) f=1; 119 | actr->x=ox+2; 120 | break; 121 | case 4: //ul 122 | x1=actor[3].x-2; 123 | y1=actor[3].y-2; 124 | if(!check_move2(x1,y1,&actor[3])){ 125 | f=1; 126 | break; 127 | } 128 | actr->x=ox-2; 129 | actr->y=oy-2; 130 | break; 131 | case 5: 132 | x1=actor[4].x+2; 133 | y1=actor[4].y-2; 134 | if(!check_move2(x1,y1,&actor[4])){ 135 | f=1; 136 | break; 137 | } 138 | actr->x=ox+2; 139 | actr->y=oy-2; 140 | break; 141 | case 6: 142 | x1=actor[6].x+2; 143 | y1=actor[6].y+2; 144 | if(!check_move2(x1,y1,&actor[6])){ 145 | f=1; 146 | break; 147 | } 148 | actr->x=ox+2; 149 | actr->y=oy+2; 150 | break; 151 | case 7: 152 | x1=actor[5].x-2; 153 | y1=actor[5].y+2; 154 | if(!check_move2(x1,y1,&actor[5])){ 155 | f=1; 156 | break; 157 | } 158 | actr->x=ox-2; 159 | actr->y=oy+2; 160 | break; 161 | } 162 | 163 | skip_move: 164 | next_frame(actr); 165 | 166 | actor[4].next=actr->next; 167 | actor[5].next=actr->next; 168 | actor[6].next=actr->next; 169 | 170 | actor[4].last_dir=d; 171 | actor[5].last_dir=d; 172 | actor[6].last_dir=d; 173 | 174 | actor[4].x=actr->x+16; 175 | actor[4].y=actr->y; 176 | actor[5].x=actr->x; 177 | actor[5].y=actr->y+16; 178 | actor[6].x=actr->x+16; 179 | actor[6].y=actr->y+16; 180 | 181 | if(!f) goto done; 182 | 183 | new_dir: 184 | if(actr->temp3<120) goto new_dir1; 185 | actor[3].frame_speed=8; 186 | actor[3].dir=1; 187 | actor[3].last_dir=1; 188 | actor[3].next=0; 189 | actor[4].last_dir=1; 190 | actor[4].dir=1; 191 | actor[4].next=0; 192 | actr->temp4=120; 193 | play_sound(BOSS12,1); 194 | 195 | new_dir1: 196 | actr->temp5=rand1%8; 197 | actr->edge_counter=rand2+60; 198 | 199 | done: 200 | if(actr->directions==1) return 0; 201 | return d; 202 | } 203 | //=========================================================================== 204 | void check_boss_hit(void){ 205 | int rep; 206 | 207 | if(actor[3].magic_hit || actor[4].magic_hit || 208 | actor[5].magic_hit || actor[6].magic_hit){ 209 | if(!actor[3].temp2){ 210 | actor_damaged(&actor[3],10); 211 | actor[3].health-=10; 212 | actor[3].speed_count=50; 213 | boss_status(actor[3].health); 214 | actor[3].vunerable=50; 215 | play_sound(BOSS13,1); 216 | for(rep=4;rep<7;rep++){ 217 | actor[rep].magic_hit=0; 218 | actor[rep].next=1; 219 | actor[rep].speed_count=50; 220 | } 221 | if(actor[3].health==0){ 222 | boss_dead=1; 223 | for(rep=7;rep 5 | #include 6 | #include 7 | #include 8 | 9 | #include <3_define.h> 10 | #include <3_proto.h> 11 | 12 | void check_boss_hit(void); 13 | //=========================================================================== 14 | extern int new_level,current_level; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern int rand1,rand2; 32 | extern char apple_drop; 33 | //=========================================================================== 34 | int boss_movement(ACTOR *actr){ //boss - wraith 35 | int d,x1,y1,f,ox,oy; 36 | 37 | if(boss_dead) return boss_dead(); 38 | check_boss_hit(); 39 | d=actr->last_dir; 40 | actr->num_moves=2; 41 | actr->temp3++; 42 | 43 | if(actr->temp2) actr->temp2--; 44 | if(actr->temp1) actr->temp1--; 45 | else if(actor[4].num_shotstemp1=20; 49 | } 50 | f=0; 51 | if(actr->temp4){ 52 | actr->temp4--; 53 | if(!actr->temp4){ 54 | actr->temp3=0; 55 | actor[3].frame_speed=4; 56 | actor[3].dir=0; 57 | actor[3].last_dir=0; 58 | actor[3].next=0; 59 | actor[4].dir=0; 60 | actor[4].last_dir=0; 61 | actor[4].next=0; 62 | actor_always_shoots(actr,0); 63 | actor[actr->shot_actor].x=actr->x+8; 64 | actor[actr->shot_actor].y=actr->y; 65 | actor[actr->shot_actor].temp1=rnd(100)+60; 66 | actor[actr->shot_actor].speed=2; 67 | } 68 | goto skip_move; 69 | } 70 | 71 | if(actr->edge_counter) actr->edge_counter--; 72 | else goto new_dir; 73 | 74 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 75 | thor->x,thor->y+4,thor->x+15,thor->y+15)) 76 | thor_damaged(actr); 77 | 78 | ox=actr->x; 79 | oy=actr->y; 80 | switch(actr->temp5){ 81 | case 0: 82 | x1=actor[3].x; 83 | y1=actor[3].y-2; 84 | if(!check_move2(x1,y1,&actor[3])){ 85 | f=1; 86 | break; 87 | } 88 | if(!check_move2(x1+16,y1,&actor[4])) f=1; 89 | actr->y=oy-2; 90 | break; 91 | case 1: 92 | x1=actor[5].x; 93 | y1=actor[5].y+2; 94 | if(!check_move2(x1,y1,&actor[5])){ 95 | f=1; 96 | break; 97 | } 98 | if(!check_move2(x1+16,y1,&actor[6])) f=1; 99 | actr->y=oy+2; 100 | break; 101 | case 2: 102 | x1=actor[3].x-2; 103 | y1=actor[3].y; 104 | if(!check_move2(x1,y1,&actor[3])){ 105 | f=1; 106 | break; 107 | } 108 | if(!check_move2(x1,y1+16,&actor[5])) f=1; 109 | actr->x=ox-2; 110 | break; 111 | case 3: 112 | x1=actor[4].x+2; 113 | y1=actor[4].y; 114 | if(!check_move2(x1,y1,&actor[4])){ 115 | f=1; 116 | break; 117 | } 118 | if(!check_move2(x1,y1+16,&actor[6])) f=1; 119 | actr->x=ox+2; 120 | break; 121 | case 4: //ul 122 | x1=actor[3].x-2; 123 | y1=actor[3].y-2; 124 | if(!check_move2(x1,y1,&actor[3])){ 125 | f=1; 126 | break; 127 | } 128 | actr->x=ox-2; 129 | actr->y=oy-2; 130 | break; 131 | case 5: 132 | x1=actor[4].x+2; 133 | y1=actor[4].y-2; 134 | if(!check_move2(x1,y1,&actor[4])){ 135 | f=1; 136 | break; 137 | } 138 | actr->x=ox+2; 139 | actr->y=oy-2; 140 | break; 141 | case 6: 142 | x1=actor[6].x+2; 143 | y1=actor[6].y+2; 144 | if(!check_move2(x1,y1,&actor[6])){ 145 | f=1; 146 | break; 147 | } 148 | actr->x=ox+2; 149 | actr->y=oy+2; 150 | break; 151 | case 7: 152 | x1=actor[5].x-2; 153 | y1=actor[5].y+2; 154 | if(!check_move2(x1,y1,&actor[5])){ 155 | f=1; 156 | break; 157 | } 158 | actr->x=ox-2; 159 | actr->y=oy+2; 160 | break; 161 | } 162 | 163 | skip_move: 164 | next_frame(actr); 165 | 166 | actor[4].next=actr->next; 167 | actor[5].next=actr->next; 168 | actor[6].next=actr->next; 169 | 170 | actor[4].last_dir=d; 171 | actor[5].last_dir=d; 172 | actor[6].last_dir=d; 173 | 174 | actor[4].x=actr->x+16; 175 | actor[4].y=actr->y; 176 | actor[5].x=actr->x; 177 | actor[5].y=actr->y+16; 178 | actor[6].x=actr->x+16; 179 | actor[6].y=actr->y+16; 180 | 181 | if(!f) goto done; 182 | 183 | new_dir: 184 | if(actr->temp3<120) goto new_dir1; 185 | actor[3].frame_speed=8; 186 | actor[3].dir=1; 187 | actor[3].last_dir=1; 188 | actor[3].next=0; 189 | actor[4].last_dir=1; 190 | actor[4].dir=1; 191 | actor[4].next=0; 192 | actr->temp4=120; 193 | play_sound(BOSS12,1); 194 | 195 | new_dir1: 196 | actr->temp5=rand1%8; 197 | actr->edge_counter=rand2+60; 198 | 199 | done: 200 | if(actr->directions==1) return 0; 201 | return d; 202 | } 203 | //=========================================================================== 204 | void check_boss_hit(void){ 205 | int rep; 206 | 207 | if(actor[3].magic_hit || actor[4].magic_hit || 208 | actor[5].magic_hit || actor[6].magic_hit){ 209 | if(!actor[3].temp2){ 210 | actor_damaged(&actor[3],10); 211 | actor[3].health-=10; 212 | actor[3].speed_count=50; 213 | boss_status(actor[3].health); 214 | actor[3].vunerable=50; 215 | play_sound(BOSS13,1); 216 | for(rep=4;rep<7;rep++){ 217 | actor[rep].magic_hit=0; 218 | actor[rep].next=1; 219 | actor[rep].speed_count=50; 220 | } 221 | if(actor[3].health==0){ 222 | boss_dead=1; 223 | for(rep=7;rep 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | void check_boss21_hit(void); 14 | //=========================================================================== 15 | extern int new_level,current_level; 16 | extern LEVEL scrn; 17 | extern ACTOR actor[MAX_ACTORS]; 18 | extern ACTOR *thor; 19 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 20 | extern ACTOR *hammer; 21 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 22 | extern int lightning_used,tornado_used,hourglass_flag; 23 | extern unsigned int display_page,draw_page; 24 | extern THOR_INFO thor_info; 25 | extern int boss_dead; 26 | extern int boss_active; 27 | extern char pge; 28 | extern ACTOR explosion; 29 | extern volatile char key_flag[100]; 30 | extern volatile unsigned int timer_cnt; 31 | extern SETUP setup; 32 | extern int rand1,rand2; 33 | extern char apple_drop; 34 | //=========================================================================== 35 | int boss21_movement(ACTOR *actr){ //boss - wraith 36 | int d,x1,y1,f,ox,oy; 37 | 38 | if(boss_dead) return boss_dead21(); 39 | check_boss21_hit(); 40 | d=actr->last_dir; 41 | actr->num_moves=2; 42 | actr->temp3++; 43 | 44 | if(actr->temp2) actr->temp2--; 45 | if(actr->temp1) actr->temp1--; 46 | else if(actor[4].num_shotstemp1=20; 50 | } 51 | f=0; 52 | if(actr->temp4){ 53 | actr->temp4--; 54 | if(!actr->temp4){ 55 | actr->temp3=0; 56 | actor[3].frame_speed=4; 57 | actor[3].dir=0; 58 | actor[3].last_dir=0; 59 | actor[3].next=0; 60 | actor[4].dir=0; 61 | actor[4].last_dir=0; 62 | actor[4].next=0; 63 | actor_always_shoots(actr,0); 64 | actor[actr->shot_actor].x=actr->x+8; 65 | actor[actr->shot_actor].y=actr->y; 66 | actor[actr->shot_actor].temp1=rnd(100)+60; 67 | actor[actr->shot_actor].speed=2; 68 | } 69 | goto skip_move; 70 | } 71 | 72 | if(actr->edge_counter) actr->edge_counter--; 73 | else goto new_dir; 74 | 75 | if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 76 | thor->x,thor->y+4,thor->x+15,thor->y+15)) 77 | thor_damaged(actr); 78 | 79 | ox=actr->x; 80 | oy=actr->y; 81 | switch(actr->temp5){ 82 | case 0: 83 | x1=actor[3].x; 84 | y1=actor[3].y-2; 85 | if(!check_move2(x1,y1,&actor[3])){ 86 | f=1; 87 | break; 88 | } 89 | if(!check_move2(x1+16,y1,&actor[4])) f=1; 90 | actr->y=oy-2; 91 | break; 92 | case 1: 93 | x1=actor[5].x; 94 | y1=actor[5].y+2; 95 | if(!check_move2(x1,y1,&actor[5])){ 96 | f=1; 97 | break; 98 | } 99 | if(!check_move2(x1+16,y1,&actor[6])) f=1; 100 | actr->y=oy+2; 101 | break; 102 | case 2: 103 | x1=actor[3].x-2; 104 | y1=actor[3].y; 105 | if(!check_move2(x1,y1,&actor[3])){ 106 | f=1; 107 | break; 108 | } 109 | if(!check_move2(x1,y1+16,&actor[5])) f=1; 110 | actr->x=ox-2; 111 | break; 112 | case 3: 113 | x1=actor[4].x+2; 114 | y1=actor[4].y; 115 | if(!check_move2(x1,y1,&actor[4])){ 116 | f=1; 117 | break; 118 | } 119 | if(!check_move2(x1,y1+16,&actor[6])) f=1; 120 | actr->x=ox+2; 121 | break; 122 | case 4: //ul 123 | x1=actor[3].x-2; 124 | y1=actor[3].y-2; 125 | if(!check_move2(x1,y1,&actor[3])){ 126 | f=1; 127 | break; 128 | } 129 | actr->x=ox-2; 130 | actr->y=oy-2; 131 | break; 132 | case 5: 133 | x1=actor[4].x+2; 134 | y1=actor[4].y-2; 135 | if(!check_move2(x1,y1,&actor[4])){ 136 | f=1; 137 | break; 138 | } 139 | actr->x=ox+2; 140 | actr->y=oy-2; 141 | break; 142 | case 6: 143 | x1=actor[6].x+2; 144 | y1=actor[6].y+2; 145 | if(!check_move2(x1,y1,&actor[6])){ 146 | f=1; 147 | break; 148 | } 149 | actr->x=ox+2; 150 | actr->y=oy+2; 151 | break; 152 | case 7: 153 | x1=actor[5].x-2; 154 | y1=actor[5].y+2; 155 | if(!check_move2(x1,y1,&actor[5])){ 156 | f=1; 157 | break; 158 | } 159 | actr->x=ox-2; 160 | actr->y=oy+2; 161 | break; 162 | } 163 | 164 | skip_move: 165 | next_frame(actr); 166 | 167 | actor[4].next=actr->next; 168 | actor[5].next=actr->next; 169 | actor[6].next=actr->next; 170 | 171 | actor[4].last_dir=d; 172 | actor[5].last_dir=d; 173 | actor[6].last_dir=d; 174 | 175 | actor[4].x=actr->x+16; 176 | actor[4].y=actr->y; 177 | actor[5].x=actr->x; 178 | actor[5].y=actr->y+16; 179 | actor[6].x=actr->x+16; 180 | actor[6].y=actr->y+16; 181 | 182 | if(!f) goto done; 183 | 184 | new_dir: 185 | if(actr->temp3<120) goto new_dir1; 186 | actor[3].frame_speed=8; 187 | actor[3].dir=1; 188 | actor[3].last_dir=1; 189 | actor[3].next=0; 190 | actor[4].last_dir=1; 191 | actor[4].dir=1; 192 | actor[4].next=0; 193 | actr->temp4=120; 194 | play_sound(BOSS12,1); 195 | 196 | new_dir1: 197 | actr->temp5=rand1%8; 198 | actr->edge_counter=rand2+60; 199 | 200 | done: 201 | if(actr->directions==1) return 0; 202 | return d; 203 | } 204 | //=========================================================================== 205 | void check_boss21_hit(void){ 206 | int rep; 207 | 208 | if(actor[3].magic_hit || actor[4].magic_hit || 209 | actor[5].magic_hit || actor[6].magic_hit){ 210 | if(!actor[3].temp2){ 211 | actor_damaged(&actor[3],10); 212 | actor[3].health-=10; 213 | actor[3].speed_count=50; 214 | boss_status(actor[3].health); 215 | actor[3].vunerable=50; 216 | play_sound(BOSS13,1); 217 | for(rep=4;rep<7;rep++){ 218 | actor[rep].magic_hit=0; 219 | actor[rep].next=1; 220 | actor[rep].speed_count=50; 221 | } 222 | if(actor[3].health==0){ 223 | boss_dead=1; 224 | for(rep=7;rep 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include <1_define.h> 17 | #include <1_proto.h> 18 | //============================================================================ 19 | extern char far *bg_pics; 20 | extern char far objects[NUM_OBJECTS][262]; 21 | extern char far *sd_data; 22 | extern char *tmp_buff; 23 | //extern char file_str[10]; 24 | extern char res_file[]; 25 | extern THOR_INFO thor_info; 26 | extern int current_area; 27 | extern ACTOR *thor; 28 | extern char *save_filename; 29 | extern union REGS in,out; 30 | extern SETUP setup; 31 | extern char level_type,slow_mode; 32 | extern int boss_active; 33 | extern char area; 34 | extern char test_sdf[]; 35 | extern char far *song; 36 | extern char far *lzss_buff; 37 | extern char *options_yesno[]; 38 | extern int music_flag,sound_flag,pcsound_flag; 39 | extern char game_over; 40 | extern unsigned int display_page,draw_page; 41 | extern volatile char key_flag[100]; 42 | 43 | char *gotres="GOTRES.00"; 44 | //=========================================================================== 45 | long file_size(char *path){ 46 | long tmpl; 47 | FILE *tmp_fp; 48 | 49 | tmp_fp=fopen(path,"rb"); 50 | if(!tmp_fp) return -1; 51 | fseek(tmp_fp,0l,SEEK_END); 52 | tmpl=ftell(tmp_fp); 53 | fclose(tmp_fp); 54 | return tmpl; 55 | } 56 | //=========================================================================== 57 | int load_bg_data(void){ 58 | 59 | bg_pics=farmalloc(60460l); 60 | if(!bg_pics) return 0; 61 | if(GAME1) if(res_read("BPICS1",bg_pics)<0) return 0; 62 | return 1; 63 | } 64 | //=========================================================================== 65 | int load_sd_data(void){ 66 | char s[21]; 67 | char str[21]; 68 | 69 | strcpy(s,"SDAT"); 70 | itoa(area,str,10); 71 | strcat(s,str); 72 | 73 | if(!sd_data) sd_data=farmalloc(61440l); 74 | if(!sd_data) return 0; 75 | if(res_read(s,sd_data)<0) return 0; 76 | return 1; 77 | } 78 | //=========================================================================== 79 | int load_objects(void){ 80 | 81 | if(res_read("OBJECTS",(char far *)objects)<0) return 0; 82 | return 1; 83 | } 84 | //=========================================================================== 85 | int load_actor(int file,int num){ 86 | char s[21]; 87 | char rs[21]; 88 | 89 | itoa(num,s,10); 90 | strcpy(rs,"ACTOR"); 91 | strcat(rs,s); 92 | if(res_read(rs,tmp_buff)<0) return 0; 93 | file=file; 94 | return 1; 95 | } 96 | //=========================================================================== 97 | int load_speech(int index){ 98 | int cnt; 99 | char tmps[30]; 100 | char str[30]; 101 | char far *p; 102 | char far *pm; 103 | char far *sp; 104 | 105 | sp=farmalloc(30000l); 106 | if(!sp) return 0; 107 | 108 | strcpy(str,"SPEAK"); 109 | itoa(area,tmps,10); 110 | strcat(str,tmps); 111 | if(res_read(str,sp)<0){ 112 | farfree(sp); 113 | return 0; 114 | } 115 | 116 | p=sp; 117 | 118 | cnt=0; 119 | while(1){ 120 | if(*p==':'){ 121 | p++; 122 | cnt++; 123 | _fstrncpy(tmps,p,4); 124 | tmps[4]=0; 125 | if(atoi(tmps)==index){ 126 | break; 127 | } 128 | } 129 | p++; 130 | cnt++; 131 | } 132 | while(*p!=10) p++; 133 | p++; 134 | pm=p; 135 | cnt=0; 136 | while(1){ 137 | if(*p==13) *p=32; 138 | if(*p==':'){ 139 | if( (*(p+1)=='E') && (*(p+2)=='N') && (*(p+3)=='D')) break; 140 | } 141 | p++; 142 | cnt++; 143 | if(cnt>5799){ 144 | farfree(sp); 145 | return 0; 146 | } 147 | } 148 | if(*(p-1)==10) *(p-1)=0; 149 | *p=0; 150 | _fmemcpy(tmp_buff,pm,cnt); 151 | tmp_buff[cnt]=0; 152 | farfree(sp); 153 | return 1; 154 | } 155 | //=========================================================================== 156 | void setup_filenames(int level){ 157 | //char s[21]; 158 | 159 | //strcpy(res_file,gotres); 160 | //itoa(level,s,10); 161 | //strcat(res_file,s); 162 | level=level; 163 | } 164 | //=========================================================================== 165 | void help(void){ 166 | 167 | 168 | odin_speaks(2008,-1); 169 | } 170 | //=========================================================================== 171 | void save_game(void){ 172 | int handle; 173 | unsigned int total; 174 | char buff[32]; 175 | 176 | if(game_over) return; 177 | setup.area=area; 178 | setup.game_over=game_over; 179 | if(select_option(options_yesno,"Save Game?",0)!=1){ 180 | d_restore(); 181 | return; 182 | } 183 | d_restore(); 184 | 185 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return; 186 | _dos_read(handle, buff,32,&total); 187 | _dos_close(handle); 188 | 189 | if(_dos_open(save_filename,O_WRONLY, &handle)!=0) return; 190 | _dos_write(handle, buff,32,&total); 191 | _dos_write(handle, &setup,sizeof(SETUP),&total); 192 | _dos_write(handle, &thor_info,sizeof(THOR_INFO),&total); 193 | _dos_write(handle, sd_data,61440u,&total); 194 | _dos_close(handle); 195 | odin_speaks(2009,0); 196 | } 197 | //=========================================================================== 198 | int load_game(int flag){ 199 | int handle; 200 | unsigned int total; 201 | char buff[32]; 202 | 203 | if(flag){ 204 | if(select_option(options_yesno,"Load Game?",0)!=1){ 205 | d_restore(); 206 | return 0; 207 | } 208 | d_restore(); 209 | } 210 | if(_dos_open(save_filename,O_RDONLY, &handle)!=0) return 0; 211 | _dos_read(handle, buff,32,&total); 212 | _dos_read(handle, &setup,sizeof(SETUP),&total); 213 | _dos_read(handle, &thor_info,sizeof(THOR_INFO),&total); 214 | _dos_read(handle, sd_data,61440u,&total); 215 | _dos_close(handle); 216 | 217 | current_area=thor_info.last_screen; 218 | area=setup.area; 219 | if(area==0) area=1; 220 | 221 | thor->x=(thor_info.last_icon%20)*16; 222 | thor->y=((thor_info.last_icon/20)*16)-1; 223 | if(thor->x<1) thor->x=1; 224 | if(thor->y<0) thor->y=0; 225 | thor->dir=thor_info.last_dir; 226 | thor->last_dir=thor_info.last_dir; 227 | thor->health=thor_info.last_health; 228 | thor->num_moves=1; 229 | thor->vunerable=60; 230 | thor->show=60; 231 | thor->speed_count=6; 232 | load_new_thor(); 233 | display_health(); 234 | display_magic(); 235 | display_jewels(); 236 | display_keys(); 237 | display_item(); 238 | if(!music_flag) setup.music=0; 239 | if(!sound_flag) setup.dig_sound=0; 240 | if(setup.music==1){ 241 | if(GAME1==1 && current_area==59){ 242 | if(flag) music_play(5,1); 243 | } 244 | else if(flag) music_play(level_type,1); 245 | } 246 | else{ 247 | setup.music=1; 248 | music_pause(); 249 | setup.music=0; 250 | } 251 | game_over=setup.game_over; 252 | slow_mode=setup.speed; 253 | return 1; 254 | } 255 | //========================================================================== 256 | /* 257 | long res_read(char *name,char far *buff){ 258 | int num,bytes; 259 | size_t len; 260 | size_t total; 261 | char bf[256]; 262 | char far *p; 263 | unsigned int clen; 264 | unsigned int far *up; 265 | 266 | if(!res_active) return RES_NOT_ACTIVE; 267 | if(!res_fp) return RES_NOT_OPEN; 268 | 269 | num=res_find_name(name); 270 | if(num<0) return RES_CANT_FIND; 271 | 272 | if(fseek(res_fp,res_header[num].offset,SEEK_SET)) return RES_CANT_SEEK; 273 | len=(size_t) res_header[num].length; 274 | 275 | total=0; 276 | if(res_header[num].key) p=buff; 277 | else p=lzss_buff; 278 | while(total255) && (len > 255)) bytes=fread(bf,1,256,res_fp); 280 | else bytes=fread(bf,1,len-total,res_fp); 281 | if(!bytes) break; 282 | total+=bytes; 283 | movedata(FP_SEG(bf),FP_OFF(bf),FP_SEG(p),FP_OFF(p),bytes); 284 | p+=bytes; 285 | } 286 | if(res_header[num].key) res_decode(buff,len,res_header[num].key); 287 | else{ 288 | p=lzss_buff; 289 | up=(unsigned int far *) p; 290 | clen=*up; 291 | p+=4; 292 | UnLZSS(p,buff,clen); 293 | } 294 | return res_header[num].length; 295 | } 296 | */ 297 | //========================================================================== 298 | int load_music(int num){ 299 | 300 | switch(num){ 301 | case 0: 302 | res_read("SONG1",song); 303 | break; 304 | case 1: 305 | res_read("SONG2",song); 306 | break; 307 | case 2: 308 | res_read("SONG3",song); 309 | break; 310 | case 3: 311 | res_read("SONG4",song); 312 | break; 313 | case 4: 314 | res_read("WINSONG",song); 315 | break; 316 | case 5: 317 | res_read("BOSSSONG",song); 318 | break; 319 | } 320 | if(!song) return 0; 321 | return 1; 322 | } 323 | -------------------------------------------------------------------------------- /src/GOT3/3_PROTO.H: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | 5 | //G_LIB.LIB 6 | 7 | void xsetmode(void); 8 | void xshowpage(unsigned page); 9 | void xline(int x0,int y0,int x1,int y1,int page,int color); 10 | void xfillrectangle(int StartX, int StartY, int EndX, int EndY, 11 | unsigned int PageBase, int Color); 12 | void xpset(int X, int Y, unsigned int PageBase, int Color); 13 | int xpoint(int X, int Y, unsigned int PageBase); 14 | void xget(int x1,int y1,int x2,int y2,unsigned int pagebase, 15 | char far *buff,int invis); 16 | void xput(int x,int y,unsigned int pagebase,char *buff); 17 | void xput2(int x,int y,unsigned int pagebase,char *buff); 18 | void xtext(int x,int y,unsigned int pagebase,char far *buff,int color); 19 | void xtext1(int x,int y,unsigned int pagebase,char far *buff,int color); 20 | void xtextx(int x,int y,unsigned int pagebase,char far *buff,int color); 21 | 22 | void xfput(int x,int y,unsigned int pagebase,char far *buff); 23 | void xfarput(int x,int y,unsigned int pagebase,char far *buff); 24 | void xcopyd2dmasked(int SourceStartX, 25 | int SourceStartY, int SourceEndX, int SourceEndY, 26 | int DestStartX, int DestStartY, MASK_IMAGE * Source, 27 | unsigned int DestPageBase, int DestBitmapWidth); 28 | void xcopyd2dmasked2( 29 | int SourceEndX, int SourceEndY, 30 | int DestStartX, int DestStartY, MASK_IMAGE *Source, 31 | unsigned int DestPageBase); 32 | void xcopys2d(int SourceStartX, int SourceStartY, 33 | int SourceEndX, int SourceEndY, int DestStartX, 34 | int DestStartY, char* SourcePtr, unsigned int DestPageBase, 35 | int SourceBitmapWidth, int DestBitmapWidth); 36 | void xcopyd2d(int SourceStartX, int SourceStartY, 37 | int SourceEndX, int SourceEndY, int DestStartX, 38 | int DestStartY, unsigned int SourcePageBase, 39 | unsigned int DestPageBase, int SourceBitmapWidth, 40 | int DestBitmapWidth); 41 | unsigned int xcreatmaskimage(MASK_IMAGE * ImageToSet, 42 | unsigned int DispMemStart, char * Image, int ImageWidth, 43 | int ImageHeight, char * Mask); 44 | unsigned int xcreatmaskimage2(MASK_IMAGE * ImageToSet, 45 | unsigned int DispMemStart, char * Image, int ImageWidth, 46 | int ImageHeight, char * Mask); 47 | 48 | void xddfast(int source_x,int source_y, int width, int height, 49 | int dest_x, int dest_y, 50 | unsigned int source_page,unsigned int dest_page); 51 | xsetpal(unsigned char color, unsigned char R,unsigned char G,unsigned char B); 52 | xgetpal(char far * pal, int num_colrs, int start_index); 53 | 54 | //G_MAIN.C 55 | void run_gotm(void); 56 | void printt(int val); 57 | void thor_dies(void); 58 | void thor_spins(int flag); 59 | void thor_spins(int flag); 60 | void pause(int delay); 61 | void rotate_pal(void); 62 | int rnd(int max); 63 | 64 | //G_GRP.C 65 | 66 | void xprint(int x,int y,char *string,unsigned int page,int color); 67 | void xprintx(int x,int y,char *string,unsigned int page,int color); 68 | void split_screen(void); 69 | int load_palette(void); 70 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color); 71 | void fade_in(void); 72 | void fade_out(void); 73 | void unsplit_screen(void); 74 | void screen_dump(void); 75 | void d_restore(void); 76 | 77 | //G_INIT.C 78 | int initialize(void); 79 | void exit_code(int ex_flag); 80 | void interrupt keyboard_int(); // interrupt prototype 81 | void demo_key_set(void); 82 | void wait_not_response(void); 83 | int wait_response(void); 84 | int get_response(void); 85 | void wait_key(int index); 86 | void wait_not_key(int index); 87 | int wait_ekey(int index); 88 | int wait_not_ekey(int index); 89 | void joy_key(void); 90 | void set_joy(void); 91 | void merge_keys(void); 92 | int setup_boss(int num); 93 | void story(void); 94 | 95 | //G_FILE.C 96 | long file_size(char *path); 97 | unsigned int read_file(char *filename,char far *buff, 98 | long offset, unsigned int amount,int key); 99 | int load_bg_data(void); 100 | int load_sd_data(void); 101 | int load_objects(void); 102 | int load_actor(int file,int num); 103 | int load_picture(int index,char *buff); 104 | void setup_filenames(int level); 105 | int load_speech(int index); 106 | long file_size(char *path); 107 | void far *get_file(char *filename,int key); 108 | void save_game(void); 109 | int load_game(int flag); 110 | void help(void); 111 | long res_read(char *name,char far *buff); 112 | int load_music(int num); 113 | 114 | //G_PANEL.C 115 | void status_panel(void); 116 | void display_health(void); 117 | void display_magic(void); 118 | void display_jewels(void); 119 | void display_score(void); 120 | void display_keys(void); 121 | void display_item(void); 122 | int init_status_panel(void); 123 | void add_jewels(int num); 124 | void add_score(int num); 125 | void add_magic(int num); 126 | void add_health(int num); 127 | void add_keys(int num); 128 | void fill_health(void); 129 | void fill_magic(void); 130 | void fill_score(int num); 131 | void score_for_inv(void); 132 | void boss_status(int health); 133 | int select_option(char *option[],char *title,int ipos); 134 | int option_menu(void); 135 | int ask_exit(void); 136 | int select_sound(void); 137 | int select_music(void); 138 | int select_slow(void); 139 | int select_scroll(void); 140 | void select_fastmode(void); 141 | void select_skill(void); 142 | void hammer_smack(int x,int y); 143 | void show_scr(void); 144 | 145 | 146 | //G_BACK.C 147 | void build_screen(unsigned int pg); 148 | void show_level(int new_level); 149 | void scroll_level_left(void); 150 | void scroll_level_up(void); 151 | void scroll_level_right(void); 152 | void scroll_level_down(void); 153 | void phase_level(void); 154 | void copy_bg_icon(int num,unsigned int src_page,unsigned int dst_page); 155 | int odin_speaks(int index,int item); 156 | int actor_speaks(ACTOR *actr,int index,int item); 157 | int display_speech(int item, char *pic,int tf); 158 | void select_item(void); 159 | void show_item(int item); 160 | int use_thunder(int flag); 161 | int use_hourglass(int flag); 162 | int use_boots(int flag); 163 | void use_item(void); 164 | int switch_icons(void); 165 | int rotate_arrows(void); 166 | void kill_enemies(int iy,int ix); 167 | void remove_objects(int y,int x); 168 | void place_tile(int x,int y,int tile); 169 | int bgtile(int x,int y); 170 | 171 | //G_IMAGE.C 172 | unsigned int make_mask(MASK_IMAGE * image, 173 | unsigned int page_start, char * Image, int image_width, 174 | int image_height); 175 | int load_standard_actors(void); 176 | void setup_actor(ACTOR *actr,char num,char dir,int x, int y); 177 | void show_enemies(void); 178 | int load_enemy(int type); 179 | int actor_visible(int invis_num); 180 | void setup_magic_item(int item); 181 | void load_new_thor(void); 182 | 183 | //G_MOVE.C 184 | void next_frame(ACTOR *actr); 185 | int point_within(int x,int y,int x1,int y1,int x2,int y2); 186 | int overlap(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4); 187 | int reverse_direction(ACTOR *actr); 188 | void thor_shoots(void); 189 | void actor_damaged(ACTOR *actr,int damage); 190 | void thor_damaged(ACTOR *actr); 191 | void actor_destroyed(ACTOR *actr); 192 | int actor_shoots(ACTOR *actr,int dir); 193 | void actor_always_shoots(ACTOR *actr,int dir); 194 | void move_actor(ACTOR *actr); 195 | 196 | //G_MOVPAT.C 197 | int check_move0(int x,int y, ACTOR *actr); 198 | int check_move1(int x,int y, ACTOR *actr); 199 | int check_move2(int x,int y, ACTOR *actr); 200 | int check_move3(int x,int y, ACTOR *actr); 201 | int check_move4(int x,int y, ACTOR *actr); 202 | int check_thor_move(int x,int y, ACTOR *actr); 203 | void set_thor_vars(void); 204 | 205 | //G_OBJECT.C 206 | void show_objects(int level,unsigned int pg); 207 | void pick_up_object(int p); 208 | int drop_object(ACTOR *actr); 209 | int _drop_obj(ACTOR *actr,int o); 210 | void delete_object(void); 211 | 212 | //G_SPTILE.C 213 | int special_tile_thor(int x,int y,int icon); 214 | int special_tile(ACTOR *actr,int x,int y,int icon); 215 | 216 | //G_SBFX.C 217 | int sbfx_init(void); 218 | void sbfx_exit(void); 219 | 220 | //G_SOUND.C 221 | int sound_init(void); 222 | void sound_exit(void); 223 | void play_sound(int index, int priority_override); 224 | int sound_playing(void); 225 | 226 | //G_MUSIC.C 227 | int music_init(void); 228 | void music_play(int num,int override); 229 | void music_pause(void); 230 | void music_resume(void); 231 | int music_is_on(void); 232 | 233 | //G_SCRIPT.C 234 | void execute_script(long index,char *pic); 235 | 236 | //G_BOSS.C 237 | 238 | int boss_movement(ACTOR *actr); 239 | void check_boss_hit(void); 240 | void boss_level(void); 241 | int boss_die(void); 242 | void closing_sequence(void); 243 | void ending_screen(void); 244 | int endgame_movement(void); 245 | 246 | //G_ASM.ASM 247 | void xdisplay_actors(ACTOR *act,unsigned int page); 248 | void xerase_actors(ACTOR *act,unsigned int page); 249 | void pal_fade_in(char *buff); 250 | void pal_fade_out(char *buff); 251 | void read_joystick(void); 252 | void UnLZSS(char far *src,char far *dest,int len); 253 | #define REPEAT(a) for(rep=0;rep=l && v<=h) 255 | -------------------------------------------------------------------------------- /src/GOT2/2_PROTO.H: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | 5 | //G_LIB.LIB 6 | 7 | void xsetmode(void); 8 | void xshowpage(unsigned page); 9 | void xline(int x0,int y0,int x1,int y1,int page,int color); 10 | void xfillrectangle(int StartX, int StartY, int EndX, int EndY, 11 | unsigned int PageBase, int Color); 12 | void xpset(int X, int Y, unsigned int PageBase, int Color); 13 | int xpoint(int X, int Y, unsigned int PageBase); 14 | void xget(int x1,int y1,int x2,int y2,unsigned int pagebase, 15 | char *buff,int invis); 16 | void xput(int x,int y,unsigned int pagebase,char *buff); 17 | void xput2(int x,int y,unsigned int pagebase,char *buff); 18 | void xtext(int x,int y,unsigned int pagebase,char far *buff,int color); 19 | void xtext1(int x,int y,unsigned int pagebase,char far *buff,int color); 20 | void xtextx(int x,int y,unsigned int pagebase,char far *buff,int color); 21 | 22 | void xfput(int x,int y,unsigned int pagebase,char far *buff); 23 | void xfarput(int x,int y,unsigned int pagebase,char far *buff); 24 | void xcopyd2dmasked(int SourceStartX, 25 | int SourceStartY, int SourceEndX, int SourceEndY, 26 | int DestStartX, int DestStartY, MASK_IMAGE * Source, 27 | unsigned int DestPageBase, int DestBitmapWidth); 28 | void xcopyd2dmasked2( 29 | int SourceEndX, int SourceEndY, 30 | int DestStartX, int DestStartY, MASK_IMAGE *Source, 31 | unsigned int DestPageBase); 32 | void xcopys2d(int SourceStartX, int SourceStartY, 33 | int SourceEndX, int SourceEndY, int DestStartX, 34 | int DestStartY, char* SourcePtr, unsigned int DestPageBase, 35 | int SourceBitmapWidth, int DestBitmapWidth); 36 | void xcopyd2d(int SourceStartX, int SourceStartY, 37 | int SourceEndX, int SourceEndY, int DestStartX, 38 | int DestStartY, unsigned int SourcePageBase, 39 | unsigned int DestPageBase, int SourceBitmapWidth, 40 | int DestBitmapWidth); 41 | unsigned int xcreatmaskimage(MASK_IMAGE * ImageToSet, 42 | unsigned int DispMemStart, char * Image, int ImageWidth, 43 | int ImageHeight, char * Mask); 44 | unsigned int xcreatmaskimage2(MASK_IMAGE * ImageToSet, 45 | unsigned int DispMemStart, char * Image, int ImageWidth, 46 | int ImageHeight, char * Mask); 47 | 48 | void xddfast(int source_x,int source_y, int width, int height, 49 | int dest_x, int dest_y, 50 | unsigned int source_page,unsigned int dest_page); 51 | xsetpal(unsigned char color, unsigned char R,unsigned char G,unsigned char B); 52 | xgetpal(char far * pal, int num_colrs, int start_index); 53 | 54 | //G_MAIN.C 55 | void run_gotm(void); 56 | void printt(int val); 57 | void thor_dies(void); 58 | void thor_spins(int flag); 59 | void thor_spins(int flag); 60 | void pause(int delay); 61 | void rotate_pal(void); 62 | int rnd(int max); 63 | 64 | //G_GRP.C 65 | 66 | void xprint(int x,int y,char *string,unsigned int page,int color); 67 | void xprintx(int x,int y,char *string,unsigned int page,int color); 68 | void split_screen(void); 69 | int load_palette(void); 70 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color); 71 | void fade_in(void); 72 | void fade_out(void); 73 | void unsplit_screen(void); 74 | void screen_dump(void); 75 | void d_restore(void); 76 | 77 | //G_INIT.C 78 | int initialize(void); 79 | void exit_code(int ex_flag); 80 | void interrupt keyboard_int(); // interrupt prototype 81 | void demo_key_set(void); 82 | void wait_not_response(void); 83 | int wait_response(void); 84 | int get_response(void); 85 | void wait_key(int index); 86 | void wait_not_key(int index); 87 | int wait_ekey(int index); 88 | int wait_not_ekey(int index); 89 | void joy_key(void); 90 | void set_joy(void); 91 | void merge_keys(void); 92 | int setup_boss(int num); 93 | void story(void); 94 | 95 | //G_FILE.C 96 | long file_size(char *path); 97 | unsigned int read_file(char *filename,char far *buff, 98 | long offset, unsigned int amount,int key); 99 | int load_bg_data(void); 100 | int load_sd_data(void); 101 | int load_objects(void); 102 | int load_actor(int file,int num); 103 | int load_picture(int index,char *buff); 104 | void setup_filenames(int level); 105 | int load_speech(int index); 106 | long file_size(char *path); 107 | void far *get_file(char *filename,int key); 108 | void save_game(void); 109 | int load_game(int flag); 110 | void help(void); 111 | long res_read(char *name,char far *buff); 112 | int load_music(int num); 113 | 114 | //G_PANEL.C 115 | void status_panel(void); 116 | void display_health(void); 117 | void display_magic(void); 118 | void display_jewels(void); 119 | void display_score(void); 120 | void display_keys(void); 121 | void display_item(void); 122 | int init_status_panel(void); 123 | void add_jewels(int num); 124 | void add_score(int num); 125 | void add_magic(int num); 126 | void add_health(int num); 127 | void add_keys(int num); 128 | void fill_health(void); 129 | void fill_magic(void); 130 | void fill_score(int num); 131 | void score_for_inv(void); 132 | void boss_status(int health); 133 | int select_option(char *option[],char *title,int ipos); 134 | int option_menu(void); 135 | int ask_exit(void); 136 | int select_sound(void); 137 | int select_music(void); 138 | int select_slow(void); 139 | int select_scroll(void); 140 | void select_fastmode(void); 141 | void select_skill(void); 142 | void hammer_smack(int x,int y); 143 | void show_scr(void); 144 | 145 | 146 | //G_BACK.C 147 | void build_screen(unsigned int pg); 148 | void show_level(int new_level); 149 | void scroll_level_left(void); 150 | void scroll_level_up(void); 151 | void scroll_level_right(void); 152 | void scroll_level_down(void); 153 | void phase_level(void); 154 | void copy_bg_icon(int num,unsigned int src_page,unsigned int dst_page); 155 | int odin_speaks(int index,int item); 156 | int actor_speaks(ACTOR *actr,int index,int item); 157 | int display_speech(int item, char *pic,int tf); 158 | void select_item(void); 159 | void show_item(int item); 160 | int use_thunder(int flag); 161 | int use_hourglass(int flag); 162 | int use_boots(int flag); 163 | void use_item(void); 164 | int switch_icons(void); 165 | int rotate_arrows(void); 166 | void kill_enemies(int iy,int ix); 167 | void remove_objects(int y,int x); 168 | void place_tile(int x,int y,int tile); 169 | int bgtile(int x,int y); 170 | 171 | //G_IMAGE.C 172 | unsigned int make_mask(MASK_IMAGE * image, 173 | unsigned int page_start, char * Image, int image_width, 174 | int image_height); 175 | int load_standard_actors(void); 176 | void setup_actor(ACTOR *actr,char num,char dir,int x, int y); 177 | void show_enemies(void); 178 | int load_enemy(int type); 179 | int actor_visible(int invis_num); 180 | void setup_magic_item(int item); 181 | void load_new_thor(void); 182 | 183 | //G_MOVE.C 184 | void next_frame(ACTOR *actr); 185 | int point_within(int x,int y,int x1,int y1,int x2,int y2); 186 | int overlap(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4); 187 | int reverse_direction(ACTOR *actr); 188 | void thor_shoots(void); 189 | void actor_damaged(ACTOR *actr,int damage); 190 | void thor_damaged(ACTOR *actr); 191 | void actor_destroyed(ACTOR *actr); 192 | int actor_shoots(ACTOR *actr,int dir); 193 | void actor_always_shoots(ACTOR *actr,int dir); 194 | void move_actor(ACTOR *actr); 195 | 196 | //G_MOVPAT.C 197 | int check_move0(int x,int y, ACTOR *actr); 198 | int check_move1(int x,int y, ACTOR *actr); 199 | int check_move2(int x,int y, ACTOR *actr); 200 | int check_move3(int x,int y, ACTOR *actr); 201 | int check_move4(int x,int y, ACTOR *actr); 202 | int check_thor_move(int x,int y, ACTOR *actr); 203 | void set_thor_vars(void); 204 | 205 | //G_OBJECT.C 206 | void show_objects(int level,unsigned int pg); 207 | void pick_up_object(int p); 208 | int drop_object(ACTOR *actr); 209 | int _drop_obj(ACTOR *actr,int o); 210 | void delete_object(void); 211 | 212 | //G_SPTILE.C 213 | int special_tile_thor(int x,int y,int icon); 214 | int special_tile(ACTOR *actr,int x,int y,int icon); 215 | 216 | //G_SBFX.C 217 | int sbfx_init(void); 218 | void sbfx_exit(void); 219 | 220 | //G_SOUND.C 221 | int sound_init(void); 222 | void sound_exit(void); 223 | void play_sound(int index, int priority_override); 224 | int sound_playing(void); 225 | 226 | //G_MUSIC.C 227 | int music_init(void); 228 | void music_play(int num,int override); 229 | void music_pause(void); 230 | void music_resume(void); 231 | int music_is_on(void); 232 | 233 | //G_SCRIPT.C 234 | void execute_script(long index,char *pic); 235 | 236 | //G_BOSS.C 237 | 238 | int boss_movement(ACTOR *actr); 239 | void check_boss_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num); 240 | void boss_level(void); 241 | int boss_die(void); 242 | void closing_sequence(void); 243 | void ending_screen(void); 244 | int endgame_movement(void); 245 | 246 | //G_ASM.ASM 247 | void xdisplay_actors(ACTOR *act,unsigned int page); 248 | void xerase_actors(ACTOR *act,unsigned int page); 249 | void pal_fade_in(char *buff); 250 | void pal_fade_out(char *buff); 251 | void read_joystick(void); 252 | void UnLZSS(char far *src,char far *dest,int len); 253 | #define REPEAT(a) for(rep=0;rep=l && v<=h) 255 | -------------------------------------------------------------------------------- /src/1_PROTO.H: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | 5 | //G_LIB.LIB 6 | 7 | void xsetmode(void); 8 | void xshowpage(unsigned page); 9 | void xline(int x0,int y0,int x1,int y1,int page,int color); 10 | void xfillrectangle(int StartX, int StartY, int EndX, int EndY, 11 | unsigned int PageBase, int Color); 12 | void xpset(int X, int Y, unsigned int PageBase, int Color); 13 | int xpoint(int X, int Y, unsigned int PageBase); 14 | void xget(int x1,int y1,int x2,int y2,unsigned int pagebase, 15 | char far *buff,int invis); 16 | void xput(int x,int y,unsigned int pagebase,char *buff); 17 | void xput2(int x,int y,unsigned int pagebase,char *buff); 18 | void xtext(int x,int y,unsigned int pagebase,char far *buff,int color); 19 | void xtext1(int x,int y,unsigned int pagebase,char far *buff,int color); 20 | void xtextx(int x,int y,unsigned int pagebase,char far *buff,int color); 21 | 22 | void xfput(int x,int y,unsigned int pagebase,char far *buff); 23 | void xfarput(int x,int y,unsigned int pagebase,char far *buff); 24 | void xcopyd2dmasked(int SourceStartX, 25 | int SourceStartY, int SourceEndX, int SourceEndY, 26 | int DestStartX, int DestStartY, MASK_IMAGE * Source, 27 | unsigned int DestPageBase, int DestBitmapWidth); 28 | void xcopyd2dmasked2( 29 | int SourceEndX, int SourceEndY, 30 | int DestStartX, int DestStartY, MASK_IMAGE *Source, 31 | unsigned int DestPageBase); 32 | void xcopys2d(int SourceStartX, int SourceStartY, 33 | int SourceEndX, int SourceEndY, int DestStartX, 34 | int DestStartY, char* SourcePtr, unsigned int DestPageBase, 35 | int SourceBitmapWidth, int DestBitmapWidth); 36 | void xcopyd2d(int SourceStartX, int SourceStartY, 37 | int SourceEndX, int SourceEndY, int DestStartX, 38 | int DestStartY, unsigned int SourcePageBase, 39 | unsigned int DestPageBase, int SourceBitmapWidth, 40 | int DestBitmapWidth); 41 | unsigned int xcreatmaskimage(MASK_IMAGE * ImageToSet, 42 | unsigned int DispMemStart, char * Image, int ImageWidth, 43 | int ImageHeight, char * Mask); 44 | unsigned int xcreatmaskimage2(MASK_IMAGE * ImageToSet, 45 | unsigned int DispMemStart, char * Image, int ImageWidth, 46 | int ImageHeight, char * Mask); 47 | 48 | void xddfast(int source_x,int source_y, int width, int height, 49 | int dest_x, int dest_y, 50 | unsigned int source_page,unsigned int dest_page); 51 | xsetpal(unsigned char color, unsigned char R,unsigned char G,unsigned char B); 52 | xgetpal(char far * pal, int num_colrs, int start_index); 53 | 54 | //G_MAIN.C 55 | void run_gotm(void); 56 | void printt(int val); 57 | void thor_dies(void); 58 | void thor_spins(int flag); 59 | void thor_spins(int flag); 60 | void pause(int delay); 61 | void rotate_pal(void); 62 | int rnd(int max); 63 | 64 | //G_GRP.C 65 | 66 | void xprint(int x,int y,char *string,unsigned int page,int color); 67 | void xprintx(int x,int y,char *string,unsigned int page,int color); 68 | void split_screen(void); 69 | int load_palette(void); 70 | void xbox(int x1,int y1,int x2,int y2,unsigned page,int color); 71 | void fade_in(void); 72 | void fade_out(void); 73 | void unsplit_screen(void); 74 | void screen_dump(void); 75 | void show_all_actors(void); 76 | 77 | //G_INIT.C 78 | int initialize(void); 79 | void exit_code(int ex_flag); 80 | void interrupt keyboard_int(); // interrupt prototype 81 | void demo_key_set(void); 82 | void wait_not_response(void); 83 | int wait_response(void); 84 | int get_response(void); 85 | void wait_key(int index); 86 | void wait_not_key(int index); 87 | int wait_ekey(int index); 88 | int wait_not_ekey(int index); 89 | void joy_key(void); 90 | void set_joy(void); 91 | void merge_keys(void); 92 | int setup_boss(int num); 93 | void story(void); 94 | 95 | //G_FILE.C 96 | long file_size(char *path); 97 | unsigned int read_file(char *filename,char far *buff, 98 | long offset, unsigned int amount,int key); 99 | int load_bg_data(void); 100 | int load_sd_data(void); 101 | int load_objects(void); 102 | int load_actor(int file,int num); 103 | int load_picture(int index,char *buff); 104 | void setup_filenames(int level); 105 | int load_speech(int index); 106 | long file_size(char *path); 107 | void far *get_file(char *filename,int key); 108 | void save_game(void); 109 | int load_game(int flag); 110 | void help(void); 111 | long res_read(char *name,char far *buff); 112 | int load_music(int num); 113 | 114 | //G_PANEL.C 115 | void status_panel(void); 116 | void display_health(void); 117 | void display_magic(void); 118 | void display_jewels(void); 119 | void display_score(void); 120 | void display_keys(void); 121 | void display_item(void); 122 | int init_status_panel(void); 123 | void add_jewels(int num); 124 | void add_score(int num); 125 | void add_magic(int num); 126 | void add_health(int num); 127 | void add_keys(int num); 128 | void fill_health(void); 129 | void fill_magic(void); 130 | void fill_score(int num); 131 | void score_for_inv(void); 132 | void boss_status(int health); 133 | int select_option(char *option[],char *title,int ipos); 134 | int option_menu(void); 135 | int ask_exit(void); 136 | int select_sound(void); 137 | int select_music(void); 138 | int select_slow(void); 139 | int select_scroll(void); 140 | void select_fastmode(void); 141 | void select_skill(void); 142 | void hammer_smack(int x,int y); 143 | void show_scr(void); 144 | 145 | 146 | //G_BACK.C 147 | void build_screen(unsigned int pg); 148 | void show_level(int new_level); 149 | void scroll_level_left(void); 150 | void scroll_level_up(void); 151 | void scroll_level_right(void); 152 | void scroll_level_down(void); 153 | void phase_level(void); 154 | void copy_bg_icon(int num,unsigned int src_page,unsigned int dst_page); 155 | int odin_speaks(int index,int item); 156 | void d_restore(void); 157 | int actor_speaks(ACTOR *actr,int index,int item); 158 | int display_speech(int item, char *pic,int tf); 159 | void select_item(void); 160 | void show_item(int item); 161 | int use_thunder(int flag); 162 | int use_hourglass(int flag); 163 | int use_boots(int flag); 164 | void use_item(void); 165 | int switch_icons(void); 166 | int rotate_arrows(void); 167 | void kill_enemies(int iy,int ix); 168 | void remove_objects(int y,int x); 169 | void place_tile(int x,int y,int tile); 170 | int bgtile(int x,int y); 171 | 172 | //G_IMAGE.C 173 | unsigned int make_mask(MASK_IMAGE * image, 174 | unsigned int page_start, char * Image, int image_width, 175 | int image_height); 176 | int load_standard_actors(void); 177 | void setup_actor(ACTOR *actr,char num,char dir,int x, int y); 178 | void show_enemies(void); 179 | int load_enemy(int type); 180 | int actor_visible(int invis_num); 181 | void setup_magic_item(int item); 182 | void load_new_thor(void); 183 | 184 | //G_MOVE.C 185 | void next_frame(ACTOR *actr); 186 | int point_within(int x,int y,int x1,int y1,int x2,int y2); 187 | int overlap(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4); 188 | int reverse_direction(ACTOR *actr); 189 | void thor_shoots(void); 190 | void actor_damaged(ACTOR *actr,int damage); 191 | void thor_damaged(ACTOR *actr); 192 | void actor_destroyed(ACTOR *actr); 193 | int actor_shoots(ACTOR *actr,int dir); 194 | void actor_always_shoots(ACTOR *actr,int dir); 195 | void move_actor(ACTOR *actr); 196 | 197 | //G_MOVPAT.C 198 | int check_move0(int x,int y, ACTOR *actr); 199 | int check_move1(int x,int y, ACTOR *actr); 200 | int check_move2(int x,int y, ACTOR *actr); 201 | int check_move3(int x,int y, ACTOR *actr); 202 | int check_move4(int x,int y, ACTOR *actr); 203 | int check_thor_move(int x,int y, ACTOR *actr); 204 | void set_thor_vars(void); 205 | 206 | //G_OBJECT.C 207 | void show_objects(int level,unsigned int pg); 208 | void pick_up_object(int p); 209 | int drop_object(ACTOR *actr); 210 | int _drop_obj(ACTOR *actr,int o); 211 | void delete_object(void); 212 | 213 | //G_SPTILE.C 214 | int special_tile_thor(int x,int y,int icon); 215 | int special_tile(ACTOR *actr,int x,int y,int icon); 216 | 217 | //G_SBFX.C 218 | int sbfx_init(void); 219 | void sbfx_exit(void); 220 | 221 | //G_SOUND.C 222 | int sound_init(void); 223 | void sound_exit(void); 224 | void play_sound(int index, int priority_override); 225 | int sound_playing(void); 226 | 227 | //G_MUSIC.C 228 | int music_init(void); 229 | void music_play(int num,int override); 230 | void music_pause(void); 231 | void music_resume(void); 232 | int music_is_on(void); 233 | 234 | //G_SCRIPT.C 235 | void execute_script(long index,char *pic); 236 | 237 | //G_BOSS1.C //serpent 238 | 239 | int boss1_movement(ACTOR *actr); 240 | void check_boss1_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num); 241 | void boss_level1(void); 242 | int boss_dead1(void); 243 | void closing_sequence1(void); 244 | 245 | //G_BOSS21.C //wraith 246 | 247 | int boss21_movement(ACTOR *actr); 248 | void check_boss21_hit(void); 249 | void boss_level21(void); 250 | int boss_dead21(void); 251 | void closing_sequence21(void); 252 | 253 | //G_BOSS22.C //skull 254 | 255 | int boss22_movement(ACTOR *actr); 256 | void check_boss22_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num); 257 | void boss_level22(void); 258 | int boss_dead22(void); 259 | void check_boss21_hit(void); 260 | void closing_sequence22(void); 261 | void boss22_set(int d,int x,int y); 262 | int boss22a_movement(ACTOR *actr); 263 | int boss22b_movement(ACTOR *actr); 264 | 265 | //G_ASM.ASM 266 | void xdisplay_actors(ACTOR *act,unsigned int page); 267 | void xerase_actors(ACTOR *act,unsigned int page); 268 | void pal_fade_in(char *buff); 269 | void pal_fade_out(char *buff); 270 | void read_joystick(void); 271 | void UnLZSS(char far *src,char far *dest,int len); 272 | #define REPEAT(a) for(rep=0;rep=l && v<=h) 274 | -------------------------------------------------------------------------------- /src/1_BOSS22.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | //=========================================================================== 13 | extern int new_level,current_level; 14 | extern char far *bg_pics; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern int rand1,rand2; 32 | extern int thunder_flag; 33 | //=========================================================================== 34 | char exp[]={ 61, 62, 65, 66, 69, 70, 73, 74, 77, 78, 35 | 81, 82, 85, 86, 89, 90, 93, 94, 97, 98, 36 | 101,102,105,106,109,110,113,114,117,118, 37 | 121,122,125,126,129,130,133,134,137,138, 38 | 141,142,145,146,149,150,153,154,157,158, 39 | 161,162,165,166,169,170,173,174,177,178}; 40 | char expf[60]; 41 | 42 | //=========================================================================== 43 | int boss22_movement(ACTOR *actr){ //boss - skull 44 | int d,f,x; 45 | static int drop_flag=0; 46 | 47 | if(boss_dead) return boss_dead22(); 48 | if(actr->i1){ 49 | if(actr->i1==1) return boss22a_movement(actr); 50 | else return boss22b_movement(actr); 51 | } 52 | d=actr->last_dir; 53 | 54 | //if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 55 | // thor->x,thor->y+4,thor->x+15,thor->y+15)) 56 | // thor_damaged(actr); 57 | 58 | x=actr->x; 59 | 60 | f=0; 61 | if(actr->temp6) actr->temp6--; 62 | if(!actr->temp6){ 63 | drop_flag=0; 64 | if(actr->temp5) actr->temp5--; 65 | if(!actr->temp5) f=1; 66 | else{ 67 | if(d==2){ 68 | if(x>18) actr->x-=2; 69 | else f=1; 70 | } 71 | else if(d==3){ 72 | if(x<272) actr->x+=2; 73 | else f=1; 74 | } 75 | } 76 | if(f){ 77 | actr->temp5=rand1+60; 78 | if(d==2) d=3; 79 | else d=2; 80 | } 81 | } 82 | 83 | actr->frame_count--; 84 | if(actr->frame_count<=0){ 85 | actr->next++; 86 | if(actr->next>2) actr->next=0; 87 | actr->frame_count=actr->frame_speed; 88 | } 89 | x=actr->x; 90 | if(actr->num_shotsshots_allowed && !drop_flag){ 91 | if(x==48 || x==112 || x==176 || x==240){ 92 | drop_flag=1; 93 | actor[3].temp6=40; 94 | // actr->next=3; 95 | actor_always_shoots(actr,1); 96 | play_sound(FALL,0); 97 | actor[actr->shot_actor].x=actr->x+12; 98 | actor[actr->shot_actor].y=actr->y+32; 99 | actor[actr->shot_actor].temp2=0; 100 | actor[actr->shot_actor].temp3=4; 101 | actor[actr->shot_actor].temp4=4; 102 | } 103 | } 104 | 105 | boss22_set(d,x,actr->y); 106 | 107 | done: 108 | if(actr->directions==1) return 0; 109 | return d; 110 | } 111 | //=========================================================================== 112 | void boss22_set(int d,int x,int y){ 113 | 114 | actor[4].next=actor[3].next; 115 | actor[5].next=actor[3].next; 116 | actor[6].next=actor[3].next; 117 | actor[3].last_dir=d; 118 | actor[4].last_dir=d; 119 | actor[5].last_dir=d; 120 | actor[6].last_dir=d; 121 | actor[4].x=x+16; 122 | actor[4].y=y; 123 | actor[5].x=x; 124 | actor[5].y=y+16; 125 | actor[6].x=x+16; 126 | actor[6].y=y+16; 127 | } 128 | //=========================================================================== 129 | void check_boss22_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 130 | int rep; 131 | 132 | if((!actor[3].vunerable)){ 133 | actor_damaged(&actor[3],hammer->strength); 134 | actor[3].health-=10; 135 | if(actor[3].health==50){ 136 | play_sound(BOSS12,1); 137 | timer_cnt=0; 138 | while(timer_cnt<120); 139 | actor[3].i1=1; 140 | actor[3].i2=0; 141 | memset(expf,0,60); 142 | for(rep=7;repnext; 259 | actor[5].next=actr->next; 260 | actor[6].next=actr->next; 261 | actr->vunerable=20; 262 | if(actr->num_shots) return 0; 263 | if(actor[5].num_shots) return 0; 264 | 265 | play_sound(EXPLODE,1); 266 | actor_always_shoots(&actor[5],0); 267 | an=actor[5].shot_actor; 268 | actor[an].move=9; 269 | 270 | r=rand1%60; 271 | while(expf[r]){ 272 | r++; 273 | if(r>59) r=0; 274 | } 275 | expf[r]=1; 276 | x=(exp[r]%20)*16; 277 | y=(exp[r]/20)*16; 278 | actor[an].x=x; 279 | actor[an].y=y; 280 | 281 | xfput(x,y,display_page,(char far *) (bg_pics+(scrn.bg_color*262))); 282 | xfput(x,y,draw_page,(char far *) (bg_pics+(scrn.bg_color*262))); 283 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 284 | scrn.icon[y/16][x/16]=scrn.bg_color; 285 | 286 | actor[3].i2++; 287 | if(actor[3].i2>59){ 288 | actor[3].i1=2; 289 | actor[3].i2=0; 290 | actor[3].num_moves=3; 291 | } 292 | return 0; 293 | } 294 | //=========================================================================== 295 | int boss22b_movement(ACTOR *actr){ //boss - skull - shake 296 | int rep,an,hx,hy,d; 297 | char su[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 298 | 299 | if(hammer->used && hammer->move!=5){ 300 | hx=hammer->x; 301 | hy=hammer->y; 302 | for(rep=7;rep<15;rep++){ 303 | if(!actor[rep].used) continue; 304 | if(overlap(hx+1,hy+1,hx+10,hy+10,actor[rep].x,actor[rep].y, 305 | actor[rep].x+actor[rep].size_x-1,actor[rep].y+actor[rep].size_y-1)){ 306 | hammer->move=5; 307 | d=reverse_direction(hammer); 308 | hammer->dir=d; 309 | break; 310 | } 311 | } 312 | } 313 | if(actr->i4){ 314 | actr->i4--; 315 | if(!actr->i4) thunder_flag=0; 316 | } 317 | if(!actr->i2){ 318 | if(actr->x<144) actr->x+=2; 319 | else if(actr->x>144) actr->x-=2; 320 | else{ 321 | actr->i2=1; 322 | actr->i3=0; 323 | } 324 | goto done; 325 | } 326 | if(actor[4].num_shots) goto done; 327 | 328 | if(!actr->i3){ 329 | actr->i3=rnd(2)+2; 330 | } 331 | 332 | if(actr->i3==2) actr->x-=2; 333 | else actr->x+=2; 334 | 335 | if(actr->x<20 || actr->x>270){ 336 | thunder_flag=100; 337 | actr->i4=50; 338 | play_sound(EXPLODE,1); 339 | actr->i2=0; 340 | hx=thor->x; 341 | memset(su,0,18); 342 | actor_always_shoots(&actor[4],1); 343 | an=actor[4].shot_actor; 344 | hx=(thor->x/16); 345 | actor[an].x=thor->x; //hx*16; 346 | actor[an].y=rnd(16); 347 | su[hx]=1; 348 | actor[an].next=rnd(4); 349 | REPEAT(7){ 350 | while(1){ 351 | hx=rnd(18); 352 | if(!su[hx]) break; 353 | } 354 | su[hx]=1; 355 | actor_always_shoots(&actor[4],1); 356 | an=actor[4].shot_actor; 357 | actor[an].next=rnd(4); 358 | actor[an].x=16+hx*16; 359 | actor[an].y=rnd(16); 360 | } 361 | } 362 | 363 | done: 364 | next_frame(actr); 365 | boss22_set(actr->dir,actr->x,actr->y); 366 | return 0; 367 | } 368 | -------------------------------------------------------------------------------- /src/GOT2/2_BOSS22.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | //=========================================================================== 13 | extern int new_level,current_level; 14 | extern char far *bg_pics; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern int rand1,rand2; 32 | extern int thunder_flag; 33 | //=========================================================================== 34 | char exp[]={ 61, 62, 65, 66, 69, 70, 73, 74, 77, 78, 35 | 81, 82, 85, 86, 89, 90, 93, 94, 97, 98, 36 | 101,102,105,106,109,110,113,114,117,118, 37 | 121,122,125,126,129,130,133,134,137,138, 38 | 141,142,145,146,149,150,153,154,157,158, 39 | 161,162,165,166,169,170,173,174,177,178}; 40 | char expf[60]; 41 | 42 | //=========================================================================== 43 | int boss22_movement(ACTOR *actr){ //boss - skull 44 | int d,f,x; 45 | static int drop_flag=0; 46 | 47 | if(boss_dead) return boss_dead22(); 48 | if(actr->i1){ 49 | if(actr->i1==1) return boss22a_movement(actr); 50 | else return boss22b_movement(actr); 51 | } 52 | d=actr->last_dir; 53 | 54 | //if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 55 | // thor->x,thor->y+4,thor->x+15,thor->y+15)) 56 | // thor_damaged(actr); 57 | 58 | x=actr->x; 59 | 60 | f=0; 61 | if(actr->temp6) actr->temp6--; 62 | if(!actr->temp6){ 63 | drop_flag=0; 64 | if(actr->temp5) actr->temp5--; 65 | if(!actr->temp5) f=1; 66 | else{ 67 | if(d==2){ 68 | if(x>18) actr->x-=2; 69 | else f=1; 70 | } 71 | else if(d==3){ 72 | if(x<272) actr->x+=2; 73 | else f=1; 74 | } 75 | } 76 | if(f){ 77 | actr->temp5=rand1+60; 78 | if(d==2) d=3; 79 | else d=2; 80 | } 81 | } 82 | 83 | actr->frame_count--; 84 | if(actr->frame_count<=0){ 85 | actr->next++; 86 | if(actr->next>2) actr->next=0; 87 | actr->frame_count=actr->frame_speed; 88 | } 89 | x=actr->x; 90 | if(actr->num_shotsshots_allowed && !drop_flag){ 91 | if(x==48 || x==112 || x==176 || x==240){ 92 | drop_flag=1; 93 | actor[3].temp6=40; 94 | // actr->next=3; 95 | actor_always_shoots(actr,1); 96 | play_sound(FALL,0); 97 | actor[actr->shot_actor].x=actr->x+12; 98 | actor[actr->shot_actor].y=actr->y+32; 99 | actor[actr->shot_actor].temp2=0; 100 | actor[actr->shot_actor].temp3=4; 101 | actor[actr->shot_actor].temp4=4; 102 | } 103 | } 104 | 105 | boss22_set(d,x,actr->y); 106 | 107 | done: 108 | if(actr->directions==1) return 0; 109 | return d; 110 | } 111 | //=========================================================================== 112 | void boss22_set(int d,int x,int y){ 113 | 114 | actor[4].next=actor[3].next; 115 | actor[5].next=actor[3].next; 116 | actor[6].next=actor[3].next; 117 | actor[3].last_dir=d; 118 | actor[4].last_dir=d; 119 | actor[5].last_dir=d; 120 | actor[6].last_dir=d; 121 | actor[4].x=x+16; 122 | actor[4].y=y; 123 | actor[5].x=x; 124 | actor[5].y=y+16; 125 | actor[6].x=x+16; 126 | actor[6].y=y+16; 127 | } 128 | //=========================================================================== 129 | void check_boss22_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 130 | int rep; 131 | 132 | if((!actor[3].vunerable)){ 133 | actor_damaged(&actor[3],hammer->strength); 134 | actor[3].health-=10; 135 | if(actor[3].health==50){ 136 | play_sound(BOSS12,1); 137 | timer_cnt=0; 138 | while(timer_cnt<120); 139 | actor[3].i1=1; 140 | actor[3].i2=0; 141 | memset(expf,0,60); 142 | for(rep=7;repnext; 259 | actor[5].next=actr->next; 260 | actor[6].next=actr->next; 261 | actr->vunerable=20; 262 | if(actr->num_shots) return 0; 263 | if(actor[5].num_shots) return 0; 264 | 265 | play_sound(EXPLODE,1); 266 | actor_always_shoots(&actor[5],0); 267 | an=actor[5].shot_actor; 268 | actor[an].move=9; 269 | 270 | r=rand1%60; 271 | while(expf[r]){ 272 | r++; 273 | if(r>59) r=0; 274 | } 275 | expf[r]=1; 276 | x=(exp[r]%20)*16; 277 | y=(exp[r]/20)*16; 278 | actor[an].x=x; 279 | actor[an].y=y; 280 | 281 | xfput(x,y,display_page,(char far *) (bg_pics+(scrn.bg_color*262))); 282 | xfput(x,y,draw_page,(char far *) (bg_pics+(scrn.bg_color*262))); 283 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 284 | scrn.icon[y/16][x/16]=scrn.bg_color; 285 | 286 | actor[3].i2++; 287 | if(actor[3].i2>59){ 288 | actor[3].i1=2; 289 | actor[3].i2=0; 290 | actor[3].num_moves=3; 291 | } 292 | return 0; 293 | } 294 | //=========================================================================== 295 | int boss22b_movement(ACTOR *actr){ //boss - skull - shake 296 | int rep,an,hx,hy,d; 297 | char su[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 298 | 299 | if(hammer->used && hammer->move!=5){ 300 | hx=hammer->x; 301 | hy=hammer->y; 302 | for(rep=7;rep<15;rep++){ 303 | if(!actor[rep].used) continue; 304 | if(overlap(hx+1,hy+1,hx+10,hy+10,actor[rep].x,actor[rep].y, 305 | actor[rep].x+actor[rep].size_x-1,actor[rep].y+actor[rep].size_y-1)){ 306 | hammer->move=5; 307 | d=reverse_direction(hammer); 308 | hammer->dir=d; 309 | break; 310 | } 311 | } 312 | } 313 | if(actr->i4){ 314 | actr->i4--; 315 | if(!actr->i4) thunder_flag=0; 316 | } 317 | if(!actr->i2){ 318 | if(actr->x<144) actr->x+=2; 319 | else if(actr->x>144) actr->x-=2; 320 | else{ 321 | actr->i2=1; 322 | actr->i3=0; 323 | } 324 | goto done; 325 | } 326 | if(actor[4].num_shots) goto done; 327 | 328 | if(!actr->i3){ 329 | actr->i3=rnd(2)+2; 330 | } 331 | 332 | if(actr->i3==2) actr->x-=2; 333 | else actr->x+=2; 334 | 335 | if(actr->x<20 || actr->x>270){ 336 | thunder_flag=100; 337 | actr->i4=50; 338 | play_sound(EXPLODE,1); 339 | actr->i2=0; 340 | hx=thor->x; 341 | memset(su,0,18); 342 | actor_always_shoots(&actor[4],1); 343 | an=actor[4].shot_actor; 344 | hx=(thor->x/16); 345 | actor[an].x=thor->x; //hx*16; 346 | actor[an].y=rnd(16); 347 | su[hx]=1; 348 | actor[an].next=rnd(4); 349 | REPEAT(7){ 350 | while(1){ 351 | hx=rnd(18); 352 | if(!su[hx]) break; 353 | } 354 | su[hx]=1; 355 | actor_always_shoots(&actor[4],1); 356 | an=actor[4].shot_actor; 357 | actor[an].next=rnd(4); 358 | actor[an].x=16+hx*16; 359 | actor[an].y=rnd(16); 360 | } 361 | } 362 | 363 | done: 364 | next_frame(actr); 365 | boss22_set(actr->dir,actr->x,actr->y); 366 | return 0; 367 | } 368 | -------------------------------------------------------------------------------- /src/GOT3/3_BOSS22.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | //=========================================================================== 13 | extern int new_level,current_level; 14 | extern char far *bg_pics; 15 | extern LEVEL scrn; 16 | extern ACTOR actor[MAX_ACTORS]; 17 | extern ACTOR *thor; 18 | extern int thor_x1,thor_y1,thor_x2,thor_y2,thor_real_y1; 19 | extern ACTOR *hammer; 20 | extern int key_fire,key_up,key_down,key_left,key_right,key_magic,key_select; 21 | extern int lightning_used,tornado_used,hourglass_flag; 22 | extern unsigned int display_page,draw_page; 23 | extern THOR_INFO thor_info; 24 | extern int boss_dead; 25 | extern int boss_active; 26 | extern char pge; 27 | extern ACTOR explosion; 28 | extern volatile char key_flag[100]; 29 | extern volatile unsigned int timer_cnt; 30 | extern SETUP setup; 31 | extern int rand1,rand2; 32 | extern int thunder_flag; 33 | //=========================================================================== 34 | char exp[]={ 61, 62, 65, 66, 69, 70, 73, 74, 77, 78, 35 | 81, 82, 85, 86, 89, 90, 93, 94, 97, 98, 36 | 101,102,105,106,109,110,113,114,117,118, 37 | 121,122,125,126,129,130,133,134,137,138, 38 | 141,142,145,146,149,150,153,154,157,158, 39 | 161,162,165,166,169,170,173,174,177,178}; 40 | char expf[60]; 41 | 42 | //=========================================================================== 43 | int boss22_movement(ACTOR *actr){ //boss - skull 44 | int d,f,x; 45 | static int drop_flag=0; 46 | 47 | if(boss_dead) return boss_dead22(); 48 | if(actr->i1){ 49 | if(actr->i1==1) return boss22a_movement(actr); 50 | else return boss22b_movement(actr); 51 | } 52 | d=actr->last_dir; 53 | 54 | //if(overlap(actr->x+2,actr->y+8,actr->x+30,actr->y+30, 55 | // thor->x,thor->y+4,thor->x+15,thor->y+15)) 56 | // thor_damaged(actr); 57 | 58 | x=actr->x; 59 | 60 | f=0; 61 | if(actr->temp6) actr->temp6--; 62 | if(!actr->temp6){ 63 | drop_flag=0; 64 | if(actr->temp5) actr->temp5--; 65 | if(!actr->temp5) f=1; 66 | else{ 67 | if(d==2){ 68 | if(x>18) actr->x-=2; 69 | else f=1; 70 | } 71 | else if(d==3){ 72 | if(x<272) actr->x+=2; 73 | else f=1; 74 | } 75 | } 76 | if(f){ 77 | actr->temp5=rand1+60; 78 | if(d==2) d=3; 79 | else d=2; 80 | } 81 | } 82 | 83 | actr->frame_count--; 84 | if(actr->frame_count<=0){ 85 | actr->next++; 86 | if(actr->next>2) actr->next=0; 87 | actr->frame_count=actr->frame_speed; 88 | } 89 | x=actr->x; 90 | if(actr->num_shotsshots_allowed && !drop_flag){ 91 | if(x==48 || x==112 || x==176 || x==240){ 92 | drop_flag=1; 93 | actor[3].temp6=40; 94 | // actr->next=3; 95 | actor_always_shoots(actr,1); 96 | play_sound(FALL,0); 97 | actor[actr->shot_actor].x=actr->x+12; 98 | actor[actr->shot_actor].y=actr->y+32; 99 | actor[actr->shot_actor].temp2=0; 100 | actor[actr->shot_actor].temp3=4; 101 | actor[actr->shot_actor].temp4=4; 102 | } 103 | } 104 | 105 | boss22_set(d,x,actr->y); 106 | 107 | done: 108 | if(actr->directions==1) return 0; 109 | return d; 110 | } 111 | //=========================================================================== 112 | void boss22_set(int d,int x,int y){ 113 | 114 | actor[4].next=actor[3].next; 115 | actor[5].next=actor[3].next; 116 | actor[6].next=actor[3].next; 117 | actor[3].last_dir=d; 118 | actor[4].last_dir=d; 119 | actor[5].last_dir=d; 120 | actor[6].last_dir=d; 121 | actor[4].x=x+16; 122 | actor[4].y=y; 123 | actor[5].x=x; 124 | actor[5].y=y+16; 125 | actor[6].x=x+16; 126 | actor[6].y=y+16; 127 | } 128 | //=========================================================================== 129 | void check_boss22_hit(ACTOR *actr,int x1,int y1,int x2,int y2,int act_num){ 130 | int rep; 131 | 132 | if((!actor[3].vunerable)){ 133 | actor_damaged(&actor[3],hammer->strength); 134 | actor[3].health-=10; 135 | if(actor[3].health==50){ 136 | play_sound(BOSS12,1); 137 | timer_cnt=0; 138 | while(timer_cnt<120); 139 | actor[3].i1=1; 140 | actor[3].i2=0; 141 | memset(expf,0,60); 142 | for(rep=7;repnext; 259 | actor[5].next=actr->next; 260 | actor[6].next=actr->next; 261 | actr->vunerable=20; 262 | if(actr->num_shots) return 0; 263 | if(actor[5].num_shots) return 0; 264 | 265 | play_sound(EXPLODE,1); 266 | actor_always_shoots(&actor[5],0); 267 | an=actor[5].shot_actor; 268 | actor[an].move=9; 269 | 270 | r=rand1%60; 271 | while(expf[r]){ 272 | r++; 273 | if(r>59) r=0; 274 | } 275 | expf[r]=1; 276 | x=(exp[r]%20)*16; 277 | y=(exp[r]/20)*16; 278 | actor[an].x=x; 279 | actor[an].y=y; 280 | 281 | xfput(x,y,display_page,(char far *) (bg_pics+(scrn.bg_color*262))); 282 | xfput(x,y,draw_page,(char far *) (bg_pics+(scrn.bg_color*262))); 283 | xfput(x,y,PAGE2,(char far *) (bg_pics+(scrn.bg_color*262))); 284 | scrn.icon[y/16][x/16]=scrn.bg_color; 285 | 286 | actor[3].i2++; 287 | if(actor[3].i2>59){ 288 | actor[3].i1=2; 289 | actor[3].i2=0; 290 | actor[3].num_moves=3; 291 | } 292 | return 0; 293 | } 294 | //=========================================================================== 295 | int boss22b_movement(ACTOR *actr){ //boss - skull - shake 296 | int rep,an,hx,hy,d; 297 | char su[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 298 | 299 | if(hammer->used && hammer->move!=5){ 300 | hx=hammer->x; 301 | hy=hammer->y; 302 | for(rep=7;rep<15;rep++){ 303 | if(!actor[rep].used) continue; 304 | if(overlap(hx+1,hy+1,hx+10,hy+10,actor[rep].x,actor[rep].y, 305 | actor[rep].x+actor[rep].size_x-1,actor[rep].y+actor[rep].size_y-1)){ 306 | hammer->move=5; 307 | d=reverse_direction(hammer); 308 | hammer->dir=d; 309 | break; 310 | } 311 | } 312 | } 313 | if(actr->i4){ 314 | actr->i4--; 315 | if(!actr->i4) thunder_flag=0; 316 | } 317 | if(!actr->i2){ 318 | if(actr->x<144) actr->x+=2; 319 | else if(actr->x>144) actr->x-=2; 320 | else{ 321 | actr->i2=1; 322 | actr->i3=0; 323 | } 324 | goto done; 325 | } 326 | if(actor[4].num_shots) goto done; 327 | 328 | if(!actr->i3){ 329 | actr->i3=rnd(2)+2; 330 | } 331 | 332 | if(actr->i3==2) actr->x-=2; 333 | else actr->x+=2; 334 | 335 | if(actr->x<20 || actr->x>270){ 336 | thunder_flag=100; 337 | actr->i4=50; 338 | play_sound(EXPLODE,1); 339 | actr->i2=0; 340 | hx=thor->x; 341 | memset(su,0,18); 342 | actor_always_shoots(&actor[4],1); 343 | an=actor[4].shot_actor; 344 | hx=(thor->x/16); 345 | actor[an].x=thor->x; //hx*16; 346 | actor[an].y=rnd(16); 347 | su[hx]=1; 348 | actor[an].next=rnd(4); 349 | REPEAT(7){ 350 | while(1){ 351 | hx=rnd(18); 352 | if(!su[hx]) break; 353 | } 354 | su[hx]=1; 355 | actor_always_shoots(&actor[4],1); 356 | an=actor[4].shot_actor; 357 | actor[an].next=rnd(4); 358 | actor[an].x=16+hx*16; 359 | actor[an].y=rnd(16); 360 | } 361 | } 362 | 363 | done: 364 | next_frame(actr); 365 | boss22_set(actr->dir,actr->x,actr->y); 366 | return 0; 367 | } 368 | -------------------------------------------------------------------------------- /src/1_MOVE.C: -------------------------------------------------------------------------------- 1 | // THOR - The God of Thunder 2 | //Source code released to the public domain on March 27th, 2020. 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include <1_define.h> 10 | #include <1_proto.h> 11 | //=========================================================================== 12 | extern unsigned int draw_page,display_page; 13 | extern char pge; 14 | extern int exit_flag; 15 | extern volatile char key_flag[100]; 16 | extern char break_code; 17 | extern char scan_code; 18 | extern int new_level,current_level; 19 | extern LEVEL scrn; 20 | extern char *scrnp; 21 | 22 | extern char far *sd_data; 23 | extern char far *bg_pics; 24 | extern char diag; 25 | extern ACTOR *thor; 26 | extern int thor_x1,thor_y1,thor_x2,thor_y2; 27 | extern ACTOR *hammer; 28 | extern ACTOR actor[MAX_ACTORS]; 29 | extern ACTOR enemy[MAX_ENEMIES]; //current enemies 30 | extern ACTOR shot[MAX_ENEMIES]; //current shots 31 | extern char enemy_type[MAX_ENEMIES]; 32 | 33 | extern ACTOR explosion; 34 | extern ACTOR sparkle; 35 | extern char shot_ok; 36 | extern char far *std_sound_start; 37 | extern int max_shot; 38 | extern THOR_INFO thor_info; 39 | extern char object_map[240]; 40 | extern int shield_on,hourglass_flag; 41 | extern char cheat; 42 | extern int killgg_inform; 43 | extern SETUP setup; 44 | extern int thunder_flag; 45 | 46 | extern int (*movement_func[]) (ACTOR *actr); 47 | extern int (*shot_movement_func[]) (ACTOR *actr); 48 | extern int (*shot_pattern_func[]) (ACTOR *actr); 49 | //=========================================================================== 50 | void next_frame(ACTOR *actr){ 51 | 52 | actr->frame_count--; 53 | if(actr->frame_count<=0){ 54 | actr->next++; 55 | // if(actr->next >= actr->frames) actr->next=0; 56 | if(actr->next>3) actr->next=0; 57 | actr->frame_count=actr->frame_speed; 58 | } 59 | } 60 | /*=========================================================================*/ 61 | int point_within(int x,int y,int x1,int y1,int x2,int y2){ 62 | 63 | if((x>=x1) && (x<=x2) && (y>=y1) && (y<=y2)) return 1; 64 | return 0; 65 | } 66 | //=========================================================================== 67 | int overlap(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4){ 68 | 69 | if((x1>=x3) && (x1<=x4) && (y1>=y3) && (y1<=y4)) return 1; 70 | if((x2>=x3) && (x2<=x4) && (y2>=y3) && (y2<=y4)) return 1; 71 | if((x1>=x3) && (x1<=x4) && (y2>=y3) && (y2<=y4)) return 1; 72 | if((x2>=x3) && (x2<=x4) && (y1>=y3) && (y1<=y4)) return 1; 73 | if((x3>=x1) && (x3<=x2) && (y3>=y1) && (y3<=y2)) return 1; 74 | if((x4>=x1) && (x4<=x2) && (y4>=y1) && (y4<=y2)) return 1; 75 | if((x3>=x1) && (x3<=x2) && (y4>=y1) && (y4<=y2)) return 1; 76 | if((x4>=x1) && (x4<=x2) && (y3>=y1) && (y3<=y2)) return 1; 77 | return 0; 78 | } 79 | //=========================================================================== 80 | int reverse_direction(ACTOR *actr){ 81 | 82 | if(actr->dir==1) return 0; 83 | if(actr->dir==2) return 3; 84 | if(actr->dir==3) return 2; 85 | return 1; 86 | } 87 | //=========================================================================== 88 | void thor_shoots(void){ 89 | 90 | if((hammer->used!=1) && (!hammer->dead) && (!thor->shot_cnt)){ 91 | play_sound(SWISH,0); 92 | thor->shot_cnt=20; 93 | hammer->used=1; 94 | hammer->dir=thor->dir; 95 | hammer->last_dir=thor->dir; 96 | hammer->x=thor->x; 97 | hammer->y=thor->y+2; 98 | hammer->move=2; 99 | hammer->next=0; 100 | hammer->last_x[0]=hammer->x; 101 | hammer->last_x[1]=hammer->x; 102 | hammer->last_y[0]=hammer->y; 103 | hammer->last_y[1]=hammer->y; 104 | } 105 | } 106 | //=========================================================================== 107 | int kill_good_guy(void){ 108 | 109 | if(!killgg_inform && !thunder_flag){ 110 | odin_speaks(2010,0); 111 | killgg_inform=1; 112 | } 113 | add_score(-1000); 114 | return 0; 115 | } 116 | //=========================================================================== 117 | void actor_damaged(ACTOR *actr,int damage){ 118 | 119 | if(!setup.skill) damage*=2; 120 | else if(setup.skill==2) damage/=2; 121 | 122 | if(!actr->vunerable && actr->type!=3 && (actr->solid & 0x7f) !=2){ 123 | actr->vunerable=STAMINA; 124 | if(damage >= actr->health){ 125 | if(actr->type!=4){ 126 | add_score(actr->init_health*10); 127 | display_score(); 128 | } 129 | else kill_good_guy(); 130 | actor_destroyed(actr); 131 | } 132 | else{ 133 | actr->show=10; 134 | actr->health-=damage; 135 | actr->speed_count+=8; 136 | } 137 | } 138 | else if(!actr->vunerable){ 139 | actr->vunerable=STAMINA; 140 | if(actr->func_num==4){ 141 | switch_icons(); 142 | } 143 | if(actr->func_num==7){ 144 | rotate_arrows(); 145 | } 146 | } 147 | 148 | } 149 | //=========================================================================== 150 | void thor_damaged(ACTOR *actr){ 151 | int damage; 152 | 153 | actr->hit_thor=1; 154 | if(cheat) if(key_flag[_FOUR]) return; 155 | damage=actr->strength; 156 | if(damage!=255){ 157 | if(!setup.skill) damage/=2; 158 | else if(setup.skill==2) damage*=2; 159 | } 160 | if((!thor->vunerable && !shield_on) || damage==255){ 161 | if(damage >= thor->health){ 162 | thor->vunerable=40; 163 | thor->show=0; 164 | thor->health=0; 165 | display_health(); 166 | exit_flag=2; 167 | } 168 | else if(damage){ 169 | thor->vunerable=40; 170 | play_sound(OW,0); 171 | thor->show=10; 172 | thor->health-=damage; 173 | display_health(); 174 | } 175 | } 176 | } 177 | //=========================================================================== 178 | void actor_destroyed(ACTOR *actr){ 179 | int x,y,x1,y1,r,n,t; 180 | 181 | if(actr->actor_num>2){ 182 | x=actr->last_x[pge^1]; 183 | y=actr->last_y[pge^1]; 184 | x1=actr->last_x[pge]; 185 | y1=actr->last_y[pge]; 186 | r=actr->rating; 187 | n=actr->actor_num; 188 | t=actr->type; 189 | if(actr->func_num==255) memcpy(actr,&explosion,sizeof(ACTOR)); 190 | else memcpy(actr,&sparkle,sizeof(ACTOR)); 191 | actr->type=t; 192 | actr->actor_num=n; 193 | actr->rating=r; 194 | actr->x=x; 195 | actr->y=y; 196 | actr->last_x[pge]=x1; 197 | actr->last_x[pge^1]=x; 198 | actr->last_y[pge]=y1; 199 | actr->last_y[pge^1]=y; 200 | actr->speed_count=actr->speed; 201 | actr->used=1; 202 | actr->num_shots=3; //used to reverse explosion 203 | actr->vunerable=255; 204 | } 205 | else{ 206 | actr->dead=2; 207 | actr->used=0; 208 | } 209 | } 210 | //=========================================================================== 211 | int _actor_shoots(ACTOR *actr,int dir){ 212 | int t,i,cx,cy; 213 | ACTOR *act; 214 | 215 | t=actr->shot_type-1; 216 | for(i=MAX_ENEMIES+3;isize_ysize_y) cy=actr->y-((act->size_y-actr->size_y)/2); 221 | else cy=actr->y+((actr->size_y-act->size_y)/2); 222 | if(actr->size_xsize_x) cx=actr->x-((act->size_x-actr->size_x)/2); 223 | else cx=actr->x+((actr->size_x-act->size_x)/2); 224 | if(cy>174) cy=174; 225 | if(cx>304) cx=304; 226 | act->x=cx; 227 | act->y=cy; 228 | act->last_dir=dir; 229 | act->next=0; 230 | act->dir=dir; 231 | if(act->directions==1) act->dir=0; 232 | else if(act->directions==4 && act->frames==1){ 233 | act->next=dir; 234 | act->dir=0; 235 | } 236 | act->frame_count=act->frame_speed; 237 | act->speed_count=act->speed; 238 | act->last_x[0]=cx; 239 | act->last_x[1]=cx; 240 | act->last_x[0]=actr->x; 241 | act->last_x[1]=actr->x; 242 | act->last_y[0]=cy; 243 | act->last_y[1]=cy; 244 | act->used=1; 245 | act->creator=actr->actor_num; 246 | act->move_count=act->num_moves; 247 | act->dead=0; 248 | actr->shot_actor=i; 249 | actr->num_shots++; 250 | actr->shot_cnt=20; 251 | shot_ok=0; 252 | return 1; 253 | } 254 | } 255 | return 0; 256 | } 257 | //=========================================================================== 258 | void actor_always_shoots(ACTOR *actr,int dir){ 259 | 260 | 261 | _actor_shoots(actr,dir); 262 | } 263 | //=========================================================================== 264 | int actor_shoots(ACTOR *actr,int dir){ 265 | int i,cx,cy,tx,ty; 266 | int icn; 267 | 268 | cx=(actr->x+(actr->size_x/2)) >> 4; 269 | cy=((actr->y+actr->size_y)-2) >> 4; 270 | 271 | tx=thor->center_x; 272 | ty=thor->center_y; 273 | 274 | icn=140; 275 | if(shot[actr->shot_type-1].flying==1) icn=80; 276 | 277 | switch(dir){ 278 | case 0: 279 | for(i=ty+1;i<=cy;i++) 280 | if(scrn.icon[i][cx]vunerable!=0) actr->vunerable--; 302 | if(actr->shot_cnt!=0) actr->shot_cnt--; 303 | if(actr->show!=0) actr->show--; 304 | 305 | if(!actr->shot_cnt && shot_ok){ 306 | if(actr->shots_allowed){ 307 | if(actr->num_shots < actr->shots_allowed){ 308 | shot_pattern_func[actr->shot_pattern] (actr); 309 | } 310 | } 311 | } 312 | 313 | actr->speed_count--; 314 | if(actr->speed_count<=0){ 315 | if(!actr->move_counter) actr->speed_count=actr->speed; 316 | else actr->speed_count=(actr->speed << 1); 317 | if(actr->type==3) i=shot_movement_func[actr->move] (actr); 318 | else i=movement_func[actr->move] (actr); 319 | if(actr->directions==2) i&=1; 320 | if(i!=actr->dir) actr->dir=i; 321 | 322 | if(actr->move==0 && current_level!=new_level && shield_on){ 323 | actor[2].x=actr->x-2; 324 | if(actor[2].x<0) actor[2].x=0; 325 | actor[2].y=actr->y; 326 | actor[2].last_x[0]=actor[2].x; 327 | actor[2].last_x[1]=actor[2].x; 328 | actor[2].last_y[0]=actor[2].y; 329 | actor[2].last_y[1]=actor[2].y; 330 | } 331 | } 332 | else i=actr->dir; 333 | 334 | actr->x &= 0xfffe; 335 | } 336 | 337 | 338 | --------------------------------------------------------------------------------