summaryrefslogtreecommitdiff
path: root/arm9/source/tapes.c
blob: 1ec8bc5c784c5548cda707e05d182dddff0283b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
   ds48 - Nintendo DS ZX Spectrum emulator.

   Copyright (C) 2007  Ian Cowburn <ianc@noddybox.co.uk>
   
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  
   $Id$
*/

#include <nds.h>
#include <stdlib.h>

#include "tapes.h"
#include "framebuffer.h"
#include "keyboard.h"

#include "ant_tape_bin.h"


/* ---------------------------------------- STATIC DATA
*/
typedef struct
{
    const u8	*tape;
    const u32	*tape_len;
    SoftKey	*keys;
    const char	**text;
} Tape;

#define NO_TAPES	1

static SoftKey	ant_keys[]=
		    {
		    	SK_PAD_UP,	SK_V,
		    	SK_PAD_LEFT,	SK_M,
		    	SK_PAD_RIGHT,	SK_SYMBOL_SHIFT,
			SK_PAD_Y,	SK_S,
			SK_PAD_X,	SK_D,
			SK_PAD_A,	SK_F,
			SK_PAD_DOWN,	SK_G,
			SK_PAD_B,	SK_C,
			SK_PAD_L,	SK_O,
			SK_PAD_R,	SK_P,
			SK_PAD_START,	SK_ENTER,
			SK_PAD_SELECT,	SK_SPACE,
			NUM_SOFT_KEYS
		    };

static const char *ant_text[]=
		    {
		      /* 01234567890123456789012345678901 */
			"ANT ATTACK",
			" ",
			"(c) 1983",
			"Sandy White & Angela Sutherland",
			" ",
			"Brave the city of Antescher.",
			" ",
			"Use left and right to turn, up",
			"to go forwards and B to jump.",
			" ",
			"Y, X and A throw grenades near,",
			"then further away.  Down throws",
			"as hard as you can.",
			" ",
			"Use the shoulder buttons, start",
			"and select to alter the view.",
			NULL
		    };

static Tape	tapes[NO_TAPES]=
		{
		    {
		    	ant_tape_bin,
			&ant_tape_bin_size,
			ant_keys,
			ant_text
		    }
		};


static int	current=0;

/* ---------------------------------------- PRIVATE INTERFACES
*/
static void DisplayTape(Tape *t)
{
    int f;

    FB_Clear();

    for(f=0;t->text[f];f++)
    {
	FB_Centre(t->text[f],f*8,COL_WHITE,COL_TRANSPARENT);
    }

    FB_Centre("Press A to select this tape.",180,COL_YELLOW,COL_TRANSPARENT);
}

/* ---------------------------------------- PUBLIC INTERFACES
*/
void SelectTape(void)
{
    int done=FALSE;

    while(!done)
    {
	uint32 key=0;

    	DisplayTape(tapes+current);

        do
        {
            swiWaitForVBlank();
        } while(!(key=keysDownRepeat()));

	if (key & KEY_LEFT)
	{
	    if (--current<0)
	    {
	    	current=NO_TAPES-1;
	    }
	}
	else if (key & KEY_RIGHT)
	{
	    current=(current+1)%NO_TAPES;
	}
	else if (key & KEY_A)
	{
	    int f;

	    done=TRUE;
	    /* ZX81SetTape(tapes[current].tape,*tapes[current].tape_len); */

	    for(f=0;tapes[current].keys[f]!=NUM_SOFT_KEYS;f+=2)
	    {
	    	SK_DefinePad(tapes[current].keys[f],
			     tapes[current].keys[f+1]);
	    }
	}
	else if (key & KEY_B)
	{
	    done=TRUE;
	}
    }
}