-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.c
122 lines (106 loc) · 3.94 KB
/
engine.c
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
// Verlies - ein Adventure im Retrodesign
//
// Copyright (C) 2018-2022 Heiko Wolf
//
// 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.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Kontakt: projekte@kabelmail.net
//#include <rand.h>
//#include <gb/hardware.h>
#include "globals.h"
#include "truhen.h"
#include "gegner.h"
#include "lvlstatus.h"
#include "player.h"
#include "hud.h"
#include "lvlgegner.h"
///aktiviert Tileset für Backgroundlayer
///Aufruf: Bank wo die Tiledaten liegen, erste Tilenummer, letzte Tilenummer, Tileset, Rückkehrbank (wovon Funktion aufgerufen wurde)
void p_engine_loadTileset (UINT8 l_bank, UINT8 l_ftile, UINT8 l_ltile, unsigned char l_tileset [100], UINT8 l_bnk) __nonbanked
{
DISPLAY_OFF;
SWITCH_ROM_MBC5 (l_bank);
set_bkg_data (l_ftile, l_ltile + 1, l_tileset);
SWITCH_ROM_MBC5 (l_bnk);
}
///aktiviert Spritelayer
///Bank wo die Spritedaten liegen, erste Spritenummer, letzte Spritenummer, Spriteset, Rückkehrbank (wovon Funktion aufgerufen wurde)
void p_engine_loadSpriteset (UINT8 l_bank, UINT8 v_fsprite, UINT8 v_lsprite, unsigned char v_spriteset [], UINT8 l_bnk) __nonbanked
{
SWITCH_ROM_MBC5 (l_bank);
set_sprite_data (v_fsprite, v_lsprite + 1, v_spriteset);
SWITCH_ROM_MBC5 (l_bnk);
}
///Lädt angegebenes Level in den Speicher, Aufruf: Leveldaten, Bank wo die Daten liegen, Rückkehrbank (wovon Funktion aufgerufen wurde)
void p_engine_loadMap (unsigned char l_lvldat [252], UINT8 l_bnk, UINT8 l_bank) __nonbanked
{
if (v_keyflag == 1)
{
DISPLAY_OFF;
SWITCH_ROM_MBC5 (l_bnk);
for (v_i = 0; v_i != 253; ++v_i) v_leveldaten [v_i] = l_lvldat [v_i];
SWITCH_ROM_MBC5 (l_bank);
}
}
///Levelwechsel, Level, XK-Spieler, YK-Spieler
void p_engine_changeLvl (UINT16 l_lvl, UINT8 l_xk, UINT8 l_yk) __nonbanked
{
if (v_keyflag == 1)
{
v_keyflag = 0;
if (v_kampf == TRUE) p_gegner_stop ();
delay (150);
v_aktion = TRUE;
v_lvl = l_lvl;
set_bkg_tiles (1, 1, 18, 14, v_leveldaten);
p_truhe_status ();
v_sxk = l_xk, v_syk = l_yk;
p_spieler_set_sprite ();
p_lvl_status ();
p_hud_showLvl ();
p_set_gegner ();
DISPLAY_ON;
}
}
///setzt in v_tile angegebenes Hintergrundtile an übergebene Position und Layer
void p_engine_set_tile (UINT8 l_xk, UINT8 l_yk, UINT8 l_layer) __nonbanked
{
if (l_layer == 1)
{
set_bkg_tiles (l_xk + 1, l_yk + 1, 1, 1, v_tile);
if (v_info == FALSE) v_leveldaten [l_xk + 18 * l_yk] = v_tile [0];
}
else if (l_layer == 2)
{
set_win_tiles (l_xk, l_yk, 1, 1, v_tile);
}
}
/*UINT8 p_genzufallszahl (void) __nonbanked
{
UWORD l_seed;
UINT8 l_wert;
l_seed = DIV_REG;
wait_vbl_done();
l_seed |= (UWORD) DIV_REG << 8;
initrand (l_seed);
//Zufallszahl zwischen 0-19
l_wert = ((rand() & 0xFF) * 20) >> 8;
//l_wert = l_wert % l_max + 1;
return (l_wert);
}*/
UINT8 p_calcMap (UINT8 w1, UINT8 w2) __nonbanked
{
return ((w1 - 16) / 8) + 18 * ((w2 - 24) / 8);
}