2020-06-11 01:47:00 +00:00
|
|
|
/*
|
|
|
|
* main.c
|
|
|
|
* BuGS
|
|
|
|
*
|
|
|
|
* Created by Jeremy Rand on 2020-06-10.
|
|
|
|
* Copyright (c) 2020 Jeremy Rand. All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-07-15 04:32:14 +00:00
|
|
|
#include <stdlib.h>
|
2020-06-11 01:47:00 +00:00
|
|
|
|
|
|
|
#include <Memory.h>
|
|
|
|
#include <Locator.h>
|
|
|
|
#include <MiscTool.h>
|
|
|
|
|
|
|
|
#include "main.h"
|
2020-07-15 04:32:14 +00:00
|
|
|
#include "game.h"
|
|
|
|
#include "tiles.h"
|
2020-06-11 01:47:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Defines and macros */
|
|
|
|
|
|
|
|
#define TOOLFAIL(string) \
|
|
|
|
if (toolerror()) SysFailMgr(toolerror(), "\p" string "\n\r Error Code -> $");
|
|
|
|
|
|
|
|
|
|
|
|
/* Globals */
|
|
|
|
|
|
|
|
unsigned int userid;
|
|
|
|
|
|
|
|
|
|
|
|
/* Implementation */
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int event;
|
|
|
|
Ref toolStartupRef;
|
|
|
|
|
|
|
|
userid = MMStartUp();
|
|
|
|
TOOLFAIL("Unable to start memory manager");
|
|
|
|
|
|
|
|
TLStartUp();
|
|
|
|
TOOLFAIL("Unable to start tool locator");
|
|
|
|
|
|
|
|
toolStartupRef = StartUpTools(userid, refIsResource, TOOL_STARTUP);
|
|
|
|
TOOLFAIL("Unable to start tools");
|
|
|
|
|
2020-06-11 03:51:53 +00:00
|
|
|
CompactMem();
|
2020-06-23 03:45:25 +00:00
|
|
|
/* Allocate $1000 extra before the SHR screen so I can write sprites above the start of the
|
|
|
|
screen without overwriting memory I do not own. */
|
|
|
|
NewHandle(0x9000, userid, attrLocked | attrFixed | attrAddr | attrBank, (Pointer)0x011000);
|
2020-06-11 03:51:53 +00:00
|
|
|
TOOLFAIL("Unable to allocate SHR screen");
|
2020-06-11 01:47:00 +00:00
|
|
|
|
2020-07-15 04:32:14 +00:00
|
|
|
srand((int)(time(NULL)));
|
|
|
|
|
|
|
|
initTiles();
|
2020-07-16 03:10:25 +00:00
|
|
|
initNonGameTiles();
|
2020-07-15 04:32:14 +00:00
|
|
|
addStartingMushrooms();
|
|
|
|
|
2020-06-11 03:51:53 +00:00
|
|
|
game();
|
2020-06-11 01:47:00 +00:00
|
|
|
|
|
|
|
ShutDownTools(refIsHandle, toolStartupRef);
|
|
|
|
TOOLFAIL("Unable to shutdown tools");
|
|
|
|
|
|
|
|
TLShutDown();
|
|
|
|
TOOLFAIL("Unable to shutdown tool locator");
|
|
|
|
|
|
|
|
MMShutDown(userid);
|
|
|
|
TOOLFAIL("Unable to shutdown memory manager");
|
|
|
|
}
|