added tools to pack and unpack Avish resource files
[awish.git] / src / title.c
blobeaf3ada8522cfba6b1ea8059c10eb98c5925b5e9
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "title.h"
7 #include "resfile.h"
8 #include "video.h"
9 #include "mainloop.h"
10 #include "vm.h"
11 #include "gameglobals.h"
12 #include "game.h"
16 static void scrDrawCrashMask (SDL_Surface *frame, int phase) {
17 if (phase <= 0) {
18 SDL_Rect dst;
20 dst.x = 0;
21 dst.y = 0;
22 dst.w = frame->w;
23 dst.h = frame->h;
24 SDL_FillRect(frame, &dst, palette[0]);
25 } else if (phase < 5) {
26 for (int y = 0; y < 20; ++y) {
27 for (int x = 0; x < 16; ++x) {
28 blitSurface2x(frame, x*20, y*10, banks[CONST_BANK_FG_TILES].spr[16-phase][0]);
35 static void frmTitleDraw (SDL_Surface *frame) {
36 blitSurface(frame, 0, 0, backs[0]);
37 scrDrawCrashMask(frame, vmGVars[GVAR_TITLE_PHASE]);
41 static void frmTitleKey (SDL_KeyboardEvent *key) {
42 if (key->type == SDL_KEYDOWN) {
43 switch (key->keysym.sym) {
44 case SDLK_ESCAPE:
45 case SDLK_F12:
46 vmGVars[GVAR_KEY_QUIT] = 1;
47 break;
48 case SDLK_SPACE:
49 case SDLK_RETURN:
50 vmGVars[GVAR_KEY_START] = 1;
51 break;
52 default: ;
58 void setMainLoopTitle (void) {
59 frameCB = frmTitleDraw;
60 keyCB = frmTitleKey;
61 vmMapGetCB = NULL;
62 vmMapSetCB = NULL;
63 vmPaused = 0;