Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features » Arcade/!Hive/c/waves
Arcade/!Hive/c/waves
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » Archimedes archive » Acorn User » AU 1997-01 B.adf » Features |
Filename: | Arcade/!Hive/c/waves |
Read OK: | ✔ |
File size: | 04D1 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
#include <stdio.h> #include <string.h> #include "DeskLib:h.File" #include "DeskLib:h.SWI" #include "Popcorn:h.Popcorn" #include "h.game" #include "h.sound" #include "h.useful" void wave_initialise(int num) { FILE *wave_file; char filename[256], back_name[256]; struct game_object *obj; int id,x,y,xv,yv; sprintf(filename, "<Hive$Dir>.Data.Wave%d\0", num); wave_file = fopen(filename, "rb"); if (wave_file == NULL) return; fscanf(wave_file, "%s\n", back_name); File_LoadTo(back_name, backdrop, NULL); while (!feof(wave_file)) { fscanf(wave_file, "%s %d %d %d %d\n", &id, &x, &y, &xv, &yv); obj = Popcorn_NewPrototype(alien_table, id, x<<12, y<<12); obj->xv = xv; obj->yv = yv; aliens_left++; } fclose(wave_file); } void check_newwave(void) { int time; if (aliens_left == 0 && wave != 0) { SWI(0, 1, SWI_OS_ReadMonotonicTime, &time); if (last_killed_at == -1) { make_sound("<Hive$Dir>.Sounds.EndLevel"); last_killed_at = time; } if ( (time - last_killed_at) >= 400 ) { hit_bottom = FALSE; last_killed_at = -1; fire_freq = 50; wave++; wave_initialise(wave); } } }
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.| 00000010 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 72 |h>.#include <str| 00000020 69 6e 67 2e 68 3e 0a 0a 23 69 6e 63 6c 75 64 65 |ing.h>..#include| 00000030 20 22 44 65 73 6b 4c 69 62 3a 68 2e 46 69 6c 65 | "DeskLib:h.File| 00000040 22 0a 23 69 6e 63 6c 75 64 65 20 22 44 65 73 6b |".#include "Desk| 00000050 4c 69 62 3a 68 2e 53 57 49 22 0a 0a 23 69 6e 63 |Lib:h.SWI"..#inc| 00000060 6c 75 64 65 20 22 50 6f 70 63 6f 72 6e 3a 68 2e |lude "Popcorn:h.| 00000070 50 6f 70 63 6f 72 6e 22 0a 0a 23 69 6e 63 6c 75 |Popcorn"..#inclu| 00000080 64 65 20 22 68 2e 67 61 6d 65 22 0a 23 69 6e 63 |de "h.game".#inc| 00000090 6c 75 64 65 20 22 68 2e 73 6f 75 6e 64 22 0a 23 |lude "h.sound".#| 000000a0 69 6e 63 6c 75 64 65 20 22 68 2e 75 73 65 66 75 |include "h.usefu| 000000b0 6c 22 0a 0a 76 6f 69 64 20 77 61 76 65 5f 69 6e |l"..void wave_in| 000000c0 69 74 69 61 6c 69 73 65 28 69 6e 74 20 6e 75 6d |itialise(int num| 000000d0 29 0a 7b 0a 20 20 46 49 4c 45 20 20 20 20 20 20 |).{. FILE | 000000e0 20 20 20 20 20 20 20 20 20 20 20 2a 77 61 76 65 | *wave| 000000f0 5f 66 69 6c 65 3b 0a 20 20 63 68 61 72 09 09 20 |_file;. char.. | 00000100 20 20 20 20 20 20 66 69 6c 65 6e 61 6d 65 5b 32 | filename[2| 00000110 35 36 5d 2c 20 62 61 63 6b 5f 6e 61 6d 65 5b 32 |56], back_name[2| 00000120 35 36 5d 3b 0a 20 20 73 74 72 75 63 74 20 67 61 |56];. struct ga| 00000130 6d 65 5f 6f 62 6a 65 63 74 20 20 20 2a 6f 62 6a |me_object *obj| 00000140 3b 0a 20 20 69 6e 74 09 09 20 20 20 20 20 20 20 |;. int.. | 00000150 69 64 2c 78 2c 79 2c 78 76 2c 79 76 3b 0a 0a 20 |id,x,y,xv,yv;.. | 00000160 20 73 70 72 69 6e 74 66 28 66 69 6c 65 6e 61 6d | sprintf(filenam| 00000170 65 2c 20 22 3c 48 69 76 65 24 44 69 72 3e 2e 44 |e, "<Hive$Dir>.D| 00000180 61 74 61 2e 57 61 76 65 25 64 5c 30 22 2c 20 6e |ata.Wave%d\0", n| 00000190 75 6d 29 3b 0a 0a 20 20 77 61 76 65 5f 66 69 6c |um);.. wave_fil| 000001a0 65 20 3d 20 66 6f 70 65 6e 28 66 69 6c 65 6e 61 |e = fopen(filena| 000001b0 6d 65 2c 20 22 72 62 22 29 3b 0a 20 20 69 66 20 |me, "rb");. if | 000001c0 28 77 61 76 65 5f 66 69 6c 65 20 3d 3d 20 4e 55 |(wave_file == NU| 000001d0 4c 4c 29 0a 20 20 20 20 72 65 74 75 72 6e 3b 0a |LL). return;.| 000001e0 0a 20 20 66 73 63 61 6e 66 28 77 61 76 65 5f 66 |. fscanf(wave_f| 000001f0 69 6c 65 2c 20 22 25 73 5c 6e 22 2c 20 62 61 63 |ile, "%s\n", bac| 00000200 6b 5f 6e 61 6d 65 29 3b 0a 20 20 46 69 6c 65 5f |k_name);. File_| 00000210 4c 6f 61 64 54 6f 28 62 61 63 6b 5f 6e 61 6d 65 |LoadTo(back_name| 00000220 2c 20 62 61 63 6b 64 72 6f 70 2c 20 4e 55 4c 4c |, backdrop, NULL| 00000230 29 3b 0a 0a 20 20 77 68 69 6c 65 20 28 21 66 65 |);.. while (!fe| 00000240 6f 66 28 77 61 76 65 5f 66 69 6c 65 29 29 0a 20 |of(wave_file)). | 00000250 20 7b 0a 20 20 20 20 66 73 63 61 6e 66 28 77 61 | {. fscanf(wa| 00000260 76 65 5f 66 69 6c 65 2c 20 22 25 73 20 25 64 20 |ve_file, "%s %d | 00000270 25 64 20 25 64 20 25 64 5c 6e 22 2c 20 26 69 64 |%d %d %d\n", &id| 00000280 2c 20 26 78 2c 20 26 79 2c 20 26 78 76 2c 20 26 |, &x, &y, &xv, &| 00000290 79 76 29 3b 0a 20 20 20 20 6f 62 6a 20 3d 20 50 |yv);. obj = P| 000002a0 6f 70 63 6f 72 6e 5f 4e 65 77 50 72 6f 74 6f 74 |opcorn_NewProtot| 000002b0 79 70 65 28 61 6c 69 65 6e 5f 74 61 62 6c 65 2c |ype(alien_table,| 000002c0 20 69 64 2c 20 78 3c 3c 31 32 2c 20 79 3c 3c 31 | id, x<<12, y<<1| 000002d0 32 29 3b 0a 20 20 20 20 6f 62 6a 2d 3e 78 76 20 |2);. obj->xv | 000002e0 3d 20 78 76 3b 20 6f 62 6a 2d 3e 79 76 20 3d 20 |= xv; obj->yv = | 000002f0 79 76 3b 0a 20 20 20 20 61 6c 69 65 6e 73 5f 6c |yv;. aliens_l| 00000300 65 66 74 2b 2b 3b 0a 20 20 7d 0a 20 20 66 63 6c |eft++;. }. fcl| 00000310 6f 73 65 28 77 61 76 65 5f 66 69 6c 65 29 3b 0a |ose(wave_file);.| 00000320 0a 7d 0a 0a 76 6f 69 64 20 63 68 65 63 6b 5f 6e |.}..void check_n| 00000330 65 77 77 61 76 65 28 76 6f 69 64 29 0a 7b 0a 20 |ewwave(void).{. | 00000340 20 69 6e 74 20 20 74 69 6d 65 3b 0a 0a 20 20 69 | int time;.. i| 00000350 66 20 28 61 6c 69 65 6e 73 5f 6c 65 66 74 20 3d |f (aliens_left =| 00000360 3d 20 30 20 26 26 20 77 61 76 65 20 21 3d 20 30 |= 0 && wave != 0| 00000370 29 0a 20 20 7b 0a 20 20 20 20 53 57 49 28 30 2c |). {. SWI(0,| 00000380 20 31 2c 20 53 57 49 5f 4f 53 5f 52 65 61 64 4d | 1, SWI_OS_ReadM| 00000390 6f 6e 6f 74 6f 6e 69 63 54 69 6d 65 2c 20 26 74 |onotonicTime, &t| 000003a0 69 6d 65 29 3b 0a 0a 20 20 20 20 69 66 20 28 6c |ime);.. if (l| 000003b0 61 73 74 5f 6b 69 6c 6c 65 64 5f 61 74 20 3d 3d |ast_killed_at ==| 000003c0 20 2d 31 29 0a 20 20 20 20 7b 0a 20 20 20 20 20 | -1). {. | 000003d0 20 6d 61 6b 65 5f 73 6f 75 6e 64 28 22 3c 48 69 | make_sound("<Hi| 000003e0 76 65 24 44 69 72 3e 2e 53 6f 75 6e 64 73 2e 45 |ve$Dir>.Sounds.E| 000003f0 6e 64 4c 65 76 65 6c 22 29 3b 0a 20 20 20 20 20 |ndLevel");. | 00000400 20 6c 61 73 74 5f 6b 69 6c 6c 65 64 5f 61 74 20 | last_killed_at | 00000410 3d 20 74 69 6d 65 3b 0a 20 20 20 20 7d 0a 0a 20 |= time;. }.. | 00000420 20 20 20 69 66 20 28 20 28 74 69 6d 65 20 2d 20 | if ( (time - | 00000430 6c 61 73 74 5f 6b 69 6c 6c 65 64 5f 61 74 29 20 |last_killed_at) | 00000440 3e 3d 20 34 30 30 20 29 0a 20 20 20 20 7b 0a 20 |>= 400 ). {. | 00000450 20 20 20 20 20 68 69 74 5f 62 6f 74 74 6f 6d 20 | hit_bottom | 00000460 3d 20 46 41 4c 53 45 3b 0a 20 20 20 20 20 20 6c |= FALSE;. l| 00000470 61 73 74 5f 6b 69 6c 6c 65 64 5f 61 74 20 3d 20 |ast_killed_at = | 00000480 2d 31 3b 0a 20 20 20 20 20 20 66 69 72 65 5f 66 |-1;. fire_f| 00000490 72 65 71 20 3d 20 35 30 3b 0a 20 20 20 20 20 20 |req = 50;. | 000004a0 77 61 76 65 2b 2b 3b 0a 20 20 20 20 20 20 77 61 |wave++;. wa| 000004b0 76 65 5f 69 6e 69 74 69 61 6c 69 73 65 28 77 61 |ve_initialise(wa| 000004c0 76 65 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a 7d |ve);. }. }.}| 000004d0 0a |.| 000004d1