home *** CD-ROM | disk | FTP | other *** search
- #include "manic.h"
- #include "functions.h"
- #include "gfxdata/gfxdata.h"
- #include "gfxlibs/keyboard.h"
- #include "miscdata/misc.h"
- #include "gfxlibs/gfx.h"
- #include "sndlibs/snd.h"
- #include <string.h>
-
- static void ClearPiano (void);
- static void DoPiano (void);
- static void DoPrefs (void);
- static void DoPrefsExtra (void);
- static void DoPrefsPage (void);
- static void DoTitleScroll (void);
- static void DrawScroll (void);
- static void DrawTPlate2 (void);
- static void DoTPlate (void);
- static void DrawWilly4 (BYTE block);
- static void FillPixelBuff (void);
- static void PrefsUpdate (void);
- static void PrintPrefs (void);
- static void SetupPrefs (void);
- static void TitleSetup (void);
- static void TitleSetupExtra (void);
- static void UpdatePianoKeys (int);
- static void UpdateScrollBuffer (void);
-
- #ifdef __riscos
- # define PREFx 10
- #else
- # define PREFx 15
- #endif
-
- static struct
- {
- BYTE m, c, p;
- BYTE h[4];
- }
- PREFS;
-
- static struct
- {
- unsigned long khit;
- WORD c;
- BYTE bodge1, bodge2, bodgep, bodgep2;
- }
- PIANO =
- { 0 };
-
- static BYTE SCROLLbuff[34];
- static WORD SCROLLpos;
- static BYTE PIXELbuff[264 * 8];
- static WORD PIXELoff;
-
- void
- Titles (void)
- {
- switch (TITLEm) {
- case 0:
- TitleSetup ();
- break;
- case 1:
- DoPiano ();
- break;
- case 2:
- ClearPiano ();
- break;
- case 3:
- DoTitleScroll ();
- break;
- case 4:
- DoPrefs ();
- break;
- }
- }
-
- /* ////////////////////////////////////////////////////////////
- // Setup Tiltes
- //////////////////////////////////////////////////////////// */
- static void
- TitleSetup (void)
- {
- memcpy (PALover, PALmain, sizeof (PALover));
-
- TITLEwf = 2;
- TITLEwp = 0;
- SCROLLpos = 0;
- PIXELoff = 0;
-
- UpdateScrollBuffer ();
- FillPixelBuff ();
-
- TITLEm = 1;
- PREFS.c = 128;
- PREFS.p = 0;
-
- mm_snd_playmod (0x0d);
- mm_snd_unmute ();
-
- TitleSetupExtra ();
- mm_gfx_palset (PALblack);
- mm_gfx_flush ();
- mm_gfx_palset (PALmain);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Setup Extra Bits
- //////////////////////////////////////////////////////////// */
- static void
- TitleSetupExtra (void)
- {
- int l;
-
- mm_gfx_cls (240);
-
- PAPER = 0;
- mm_gfx_fillbox (0, 0, 256, 192, PAPER);
- DrawFinal ();
- PlotXY (152, 40, GFXfill, 16, 24);
- PlotXY (176, 40, GFXfill + 384, 72, 24);
-
- SUN.m = 1;
- SUN.y = 32;
- SUN.h = 16;
- DoSun ();
-
- PlotXY (0, 64, GFXpiano, 256, 64);
- DrawWilly4 (TITLEwf);
-
- DrawTPlate2 ();
- DrawAirBG ();
-
- INK = 122;
- l = strlen (LEVELSNAME);
- FontPrintSmall (27, 28, "Level set:");
- FontPrint (16 - strlen (LEVELSNAME) / 2 + 127 * (l & 1), 22, LEVELSNAME);
-
- PIANO.c = 0;
- PIANO.khit = 0;
- UpdatePianoKeys (0);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Play The Piano
- //////////////////////////////////////////////////////////// */
- static void
- DoPiano (void)
- {
- if (mm_snd_getmodpos () == 0x11 ) {
- TITLEm = 2;
- mm_snd_stopmod ();
- }
-
- UpdatePianoKeys (1);
- mm_gfx_flush ();
-
- if (mm_keyb_pressed (KEYB_F1)) {
- TITLEm = 4;
- PREFS.m = 0;
- mm_snd_stopmod ();
- }
- if (mm_keyb_pressed (KEYB_ENTER)) {
- TITLEm = 0;
- DEMOm = 0;
- MODE = 2;
- mm_snd_stopmod ();
- }
- DoTPlate ();
- }
-
- /* ////////////////////////////////////////////////////////////
- // Draw Piano Key
- //////////////////////////////////////////////////////////// */
- static void
- DrawKey (int xpos, int ypos, BYTE block)
- {
- PlotXY (xpos * 8, ypos * 8, GFXpkeys + block * 128, 8, 16);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Update Piano Keys
- //////////////////////////////////////////////////////////// */
- static void
- UpdatePianoKeys (int play)
- {
- static const BYTE keytype[] = {
- 0, 1, 2,
- 0, 1, 2, 0, 1, 1, 2,
- 0, 1, 2, 0, 1, 1, 2,
- 0, 1, 2, 0, 1, 1, 2,
- 0, 1, 2, 0, 1, 1, 2,
- 3
- };
- int i;
- unsigned long newkhit = play ? mm_snd_hitpianokeys () : 0;
-
- for (i = 31; i >= 0; --i)
- if ((newkhit ^ PIANO.khit) & 1 << i)
- DrawKey (i, 14, keytype[i] + ((newkhit & 1 << i) ? 4 : 0));
- PIANO.khit = newkhit;
- }
-
- /* ////////////////////////////////////////////////////////////
- // Clear Piano
- //////////////////////////////////////////////////////////// */
- static void
- ClearPiano (void)
- {
- PIANO.khit = 0;
-
- UpdatePianoKeys (0);
- mm_gfx_flush ();
-
- TITLEm = 3;
- SCROLLpos = 0;
- }
-
- /* ////////////////////////////////////////////////////////////
- // Do Title Scroll
- //////////////////////////////////////////////////////////// */
- static void
- DoTitleScroll (void)
- {
- mm_gfx_flush ();
-
- if (++TITLEwp == 16) {
- TITLEwp = 0;
- TITLEwf = (TITLEwf + 2) & 7;
- }
- DrawWilly4 (TITLEwf + 4);
- DrawScroll ();
-
- if (++PIXELoff == 8) {
- PIXELoff = 0;
- if (++SCROLLpos == strlen (SCROLLtext) - 32) {
- TITLEm = 0;
- DEMOm = 0;
- MODE = 1;
-
- mm_snd_playmod (MUSICtype ? 9 : 0);
- }
- else {
- UpdateScrollBuffer ();
- FillPixelBuff ();
- }
- }
-
- if (mm_keyb_pressed (KEYB_F1)) {
- TITLEm = 4;
- PREFS.m = 0;
- }
- if (mm_keyb_pressed (KEYB_ENTER)) {
- TITLEm = 0;
- DEMOm = 0;
- MODE = 2;
- }
-
- DoTPlate ();
- }
-
- /* ////////////////////////////////////////////////////////////
- // Update Scroll Buffer
- //////////////////////////////////////////////////////////// */
- static void
- UpdateScrollBuffer (void)
- {
- memcpy (SCROLLbuff, SCROLLtext + SCROLLpos, 33);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Fill Pixel buffer with text
- //////////////////////////////////////////////////////////// */
- static void
- FillPixelBuff (void)
- {
- int i, x, y, dx = 0, dy = 0;
-
- for (i = 0; i < 33; i++) {
- WORD alpha = (WORD) SCROLLbuff[i] - 32;
- BYTE *font = fontb + alpha * 8;
- BYTE *alias = GFXfant + alpha * 8;
-
- for (y = 0; y < 8; y++) {
- for (x = 0; x < 8; x++)
- PIXELbuff[((dy + y) * 264) + dx + x] = (*font & 1 << x) ? 102 :
- (*alias & 1 << x) ? 107 :
- PAPER;
- font++;
- alias++;
- }
- dx += 8;
- }
- }
-
- /* ////////////////////////////////////////////////////////////
- // Draw Scroll
- //////////////////////////////////////////////////////////// */
- static void
- DrawScroll (void)
- {
- int y;
- for (y = 0; y < 8; y++)
- PlotXY (0, 152 + y, PIXELbuff + y * 264 + PIXELoff, 256, 1);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Draw Level Title Plate
- //////////////////////////////////////////////////////////// */
- static void
- DrawTPlate2 (void)
- {
- static const char *const o[] = {
- "\x7F" "1997 Andy Noble",
- "\x7F" "1998, 2000 Darren Salt",
- "\x7F" "2000 Stuart Brady"
- };
- int l = strlen (o[PREFS.p]);
- PlotXY (0, 128, GFXtplate, 256, 8);
- FontPrint2 (16 - l / 2 + 127 * (l & 1), 16, o[PREFS.p]);
- }
-
- static void
- DoTPlate (void)
- {
- if (--PREFS.c)
- return;
- PREFS.c = 128;
- PREFS.p = (PREFS.p + 1) % 3;
- DrawTPlate2 ();
- }
-
- /* ////////////////////////////////////////////////////////////
- // Draw Willy
- //////////////////////////////////////////////////////////// */
- static void
- DrawWilly4 (BYTE block)
- {
- Plot16ink (232, 72, GFXwilly + 256 * block, 0, 39);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Preferences Screen
- //////////////////////////////////////////////////////////// */
- static void
- DoPrefs (void)
- {
- switch (PREFS.m) {
- case 0:
- SetupPrefs ();
- break;
- case 1:
- PrefsUpdate ();
- break;
- }
- }
-
- /* ////////////////////////////////////////////////////////////
- // Setup Prefs
- //////////////////////////////////////////////////////////// */
- static void
- SetupPrefs (void)
- {
- memcpy (PALover, PALmain, sizeof (PALover));
-
- DoPrefsExtra ();
- mm_gfx_flush ();
- mm_gfx_palset (PALover);
-
- PREFS.h[0] = PREFS.h[1] = PREFS.h[2] = 0;
- PREFS.m = 1;
- PREFS.c = 100;
- PREFS.p = 0;
-
- mm_snd_playmod (0x12);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Prefs Screen Setup
- //////////////////////////////////////////////////////////// */
- static void
- DoPrefsExtra (void)
- {
- int x, y, i;
-
- i = 240;
-
- mm_gfx_cls (0);
-
- for (x = 0; x < 31; x++) {
- PAPER = i++;
- if (i > 254)
- i = 240;
- FontPrint (x, 0, " ");
- }
-
- for (y = 0; y < 23; y++) {
- PAPER = i++;
- if (i > 254)
- i = 240;
- FontPrint (31, y, " ");
- }
-
- for (x = 31; x; x--) {
- PAPER = i++;
- if (i > 254)
- i = 240;
- FontPrint (x, 23, " ");
- }
-
- for (y = 23; y; y--) {
- PAPER = i++;
- if (i > 254)
- i = 240;
- FontPrint (0, y, " ");
- }
-
- PAPER = 0;
- INK = 7;
- FontPrintSmall (24, 2, "`fManic Miner PC");
- FontPrintSmall (23, 3, "`g(C)`e1997 `gAndy Noble");
- FontPrintSmall (10, 4, "`gBased on an original game by `eMatthew Smith`g.");
- FontPrintSmall ( 7, 5, "`g(C) `e1983 `fBUG-BYTE`g Ltd. And `fSoftware Projects`g Ltd.");
-
- DoPrefsPage ();
-
- #ifdef __riscos
- FontPrintSmall (PREFx, 27, "`f F2 F3 F4 F5");
- FontPrintSmall (PREFx, 28, "`bGame Speed Pause music? Melody Resolution");
- #else
- FontPrintSmall (PREFx, 27, "`f F2 F3 F4");
- FontPrintSmall (PREFx, 28, "`bGame Speed Pause music? Melody");
- #endif
-
- PrintPrefs ();
- }
-
- typedef struct
- {
- coords_t pos;
- const char *text;
- }
- text_t;
-
- static void
- DoPrefsPage (void)
- {
- static const text_t One[] = {
- {{18, 6}, "`g(C) `e1997 `fAlchemist Research`g."},
- {{ 7, 8}, "`dProgramming`g, `dGraphics`e................`fAndy Noble`e."},
- {{ 7, 9}, "`dMUSIC ARRANGED BY`e.................`fMatt Simmonds`e."},
- {{ 7, 10}, "`dExtra Levels`e.................`fLee `d'`gBLOOD!`d' `fTonks`e."},
- {{ 7, 11}, "`dTesting and Ideas`e.................`fEwan Christie`e."},
- {{ 3, 13}, "`dI would just like to say ThankYou to the following people"},
- {{ 3, 15}, "`fSahara Surfers`d..............`eFor MIDAS Digital Audio System"},
- {{ 3, 17}, "`fTyrone L. Cartwright`d............`eFor help with the bad guys"},
- {{ 3, 19}, "`fDavid H. Tolley`d.................`eFor the constant slaggings"},
- {{ 3, 20}, "`fGerton Lunter`d........................`eFor the excellent Z80"},
- {{ 3, 21}, "`fJames McKay`d.................`eFor the equally excellent X128"},
- {{ 5, 22}, "`cEverybody who e-mailed me with words of encouragement."},
- {{13, 24}, "`fAnd all the Guys on COMP.SYS.SINCLAIR"},
- {{ 4, 25}, "`eWho keep me informed and amused about all things Speccy."},
- {{0}}
- };
-
- static const text_t Two[] = {
- {{18, 6}, "`g(C) `e1998, 2000 `fDarren Salt`g."},
- {{21, 7}, "`g(C) `e2000 `fStuart Brady`g."},
- {{ 7, 9}, "`dLinux port`e...........................`fStuart Brady`e."},
- {{ 7, 10}, "`dAdditional programming`c and"},
- {{ 7, 11}, "`dRISC OS port`e..........................`fDarren Salt`e."},
- {{ 7, 13}, "`dRISC OS 16-bit sound support`e....`fAndre' Timmermans`e."},
- {{ 7, 15}, "`dTesting, testing, testing`e..........`fRichard Hallas`e."},
- {{ 5, 17}, "`dWe'd just like to say ThankYou to the following people"},
- {{ 4, 19}, "`fAll who have contributed to`d......................`eAllegro"},
- {{ 4, 20}, "`cand`d..`eany other libraries which may be used in this build"},
- {{19, 22}, "`ghttp://www.retrospec.co.uk/"},
- {{11, 24}, "`fYou haven't played the original version...?"},
- {{ 8, 25}, "`eThen visit `ghttp://www.void.jump.org/`e immediately!"},
- {{0}}
- };
-
- static const text_t *const Page[] = { One, Two };
- int i = 0;
-
- PAPER = 0;
- INK = 7;
- PlotXYback (8, 36, 0, 240, 120);
-
- do {
- FontPrintSmall (Page[PREFS.p][i].pos.x, Page[PREFS.p][i].pos.y,
- Page[PREFS.p][i].text);
- } while (Page[PREFS.p][++i].text);
- }
-
- /* ////////////////////////////////////////////////////////////
- // Update setup screen
- //////////////////////////////////////////////////////////// */
- static void
- PrefsUpdate (void)
- {
- RotPal ();
- mm_gfx_flush ();
- mm_gfx_palset (PALover);
-
- if (!--PREFS.c) {
- PREFS.p = (PREFS.p + 1) % 2;
- DoPrefsPage ();
- }
-
- if (mm_keyb_pressed (KEYB_F2)) {
- if (!PREFS.h[0]) {
- SPEED = (SPEED + 1) % 5;
- PREFS.h[0] = 1;
- }
- } else
- PREFS.h[0] = 0;
-
- if (mm_keyb_pressed (KEYB_F3)) {
- if (!PREFS.h[1]) {
- PAUSEtype=!PAUSEtype;
- PREFS.h[1] = 1;
- }
- } else
- PREFS.h[1] = 0;
-
- if (mm_keyb_pressed (KEYB_F4)) {
- if (!PREFS.h[2]) {
- MUSICtype ^= 1;
- PREFS.h[2] = 1;
- }
- } else
- PREFS.h[2] = 0;
-
- #ifdef __riscos
- if (mm_keyb_pressed (KEYB_F5)) {
- if (!PREFS.h[3]) {
- VidMode = !VidMode;
- PREFS.h[3] = 1;
- if (hires_ok) {
- SelMode (VidMode);
- mm_gfx_palset (PALover);
- DoPrefsExtra();
- }
- }
- } else
- PREFS.h[3]=0;
- #endif
-
- if (mm_keyb_pressed (KEYB_ESC)) {
- MODE = 0;
- TITLEm = 0;
- mm_snd_stopmod ();
- }
-
- PrintPrefs ();
- }
-
- /* ////////////////////////////////////////////////////////////
- // Display preferences
- //////////////////////////////////////////////////////////// */
- static void
- PrintPrefs (void)
- {
- static const char speed[][12] =
- {"`a SILLY! ", "`c HARD ", "`d 1997 ", "`gORIGINAL", "`e BORING "};
-
- FontPrintSmall (PREFx + 1, 29, speed[SPEED]);
- FontPrintSmall (PREFx + 16, 29, PAUSEtype ? "`gYES" : "`e NO");
- FontPrintSmall (PREFx + 25, 29, MUSICtype ? "`gORIGINAL" : "`d 1997 ");
- #ifdef __riscos
- FontPrintSmall (PREFx + 34, 29,
- VidMode ? (hires_ok ? "`d HI RES " : "`cHI RES N/A") :
- "`g LO RES ");
- #endif
- }
-