diff options
author | Ian C <ianc@noddybox.co.uk> | 2007-04-10 23:59:35 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2007-04-10 23:59:35 +0000 |
commit | 6701f6a9d4f979cc1eadb673e767b5c46cd2a9c8 (patch) | |
tree | 5996a9d0a8bb393afc4ef3da9609df7a22af32a1 /arm9/source/tapes.c | |
parent | cd4886b4b099367c561fa5af6d7346bd43d7e2a7 (diff) |
Initial import
Diffstat (limited to 'arm9/source/tapes.c')
-rw-r--r-- | arm9/source/tapes.c | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/arm9/source/tapes.c b/arm9/source/tapes.c new file mode 100644 index 0000000..1ec8bc5 --- /dev/null +++ b/arm9/source/tapes.c @@ -0,0 +1,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; + } + } +} + |