Version 1.1

This commit is contained in:
nebiun 2020-05-25 18:02:06 +02:00
parent 77f1a41b34
commit 94e2ba84c5
137 changed files with 6807 additions and 2663 deletions

View File

@ -1,5 +1,5 @@
# ledHeadWii
Porting on Wii of Peter Hirschberg's LedHEAD (classic electronic LED handled game simulator)
Based on Peter Hirschberg's LedHEAD (classic electronic LED handled game simulator) source code.
## OVERVIEW
LEDhead is a program that simulates the classic electronic LED (light emitting diode) based handheld
@ -8,4 +8,12 @@ All games feature fully authentic sound-effects, and faithfully replicate the ga
Rather than using proprietary code or "ROM images", as is the case with emulators, LEDhead uses simple
but extremely clever imitation to ensure excruciating faithfulness to the games you grew up with.
Endless hours of painstaking effort have gone into ensuring the accuracy of each of these games.
Endless hours of painstaking effort have gone into ensuring the accuracy of each of these games.
## NOTE
Wii version have some games not present in original version. These games was developed from scratch.
## CREDITS
Thanks to Peter Hirschberg for the original source code.
Thanks to ArcadeUSA and Rick.R for playing real hardware games and telling me how they work.
And then for playing with the simulator to find the differences.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 852 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 339 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 B

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
data/images/slide1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

BIN
data/images/slide2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

BIN
data/images/slide3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

BIN
data/images/switch1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

BIN
data/images/switch2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

BIN
data/images/switch3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

BIN
data/images/switch4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
όόϋώφφγ6λ…tδΊ &ζΌ<CEB6>'λΧ5ήΫΟ<CF84>&εξ βυώμθττ&φυχϊσυ<CF83>ψω

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
data/wiimote/WKBLR1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
data/wiimote/WKD.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

BIN
data/wiimote/WKL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

BIN
data/wiimote/WKR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

BIN
data/wiimote/WKU.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

View File

@ -39,11 +39,13 @@ Website : http://www.peterhirschberg.com
#include "autorace.h"
#include "spacealert.h"
#include "basketball.h"
#include "basketball2.h"
#include "football.h"
#include "football2.h"
#include "hockey.h"
#include "hockeyca.h"
#include "soccer.h"
#include "soccer2.h"
#include "armorbattle.h"
#include "baseball.h"
#include "subchase.h"
@ -51,15 +53,19 @@ Website : http://www.peterhirschberg.com
#include "autorace_screen_png.h"
#include "baseball_screen_png.h"
#include "basketball_screen_png.h"
#include "basketball2_screen_png.h"
#include "football_screen_png.h"
#include "football2_screen_png.h"
#include "hockey_screen_png.h"
#include "hockeyca_screen_png.h"
#include "skislalom_screen_png.h"
#include "soccer_screen_png.h"
#include "soccer2_screen_png.h"
#include "spacealert_screen_png.h"
#include "missileattack_screen_png.h"
#include "subchase_screen_png.h"
#include "nodisp_screen_png.h"
//#define DEEP_DEBUG 1
GAMECONTEXT gGameContext[NUM_GAMES] =
{
@ -67,8 +73,7 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
{
GAME_ARMORBATTLE,
150,
"Armor Battle",
"armorbattle",
"Armor Battle (1978)",
ArmorBattle_Init,
ArmorBattle_DeInit,
ArmorBattle_Run,
@ -81,13 +86,13 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
ArmorBattle_GetSize,
armorbattle_screen_png,
ArmorBattle_Help,
NULL
},
// auto race
{
GAME_AUTORACE,
100,//65
"Auto Race",
"autorace",
"Auto Race (1976)",
AutoRace_Init,
AutoRace_DeInit,
AutoRace_Run,
@ -99,14 +104,14 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
AutoRace_Paint,
AutoRace_GetSize,
autorace_screen_png,
AutoRace_Help
AutoRace_Help,
NULL
},
// baseball
{
GAME_BASEBALL,
10,
"Baseball",
"baseball",
1,
"Baseball (1978)",
Baseball_Init,
Baseball_DeInit,
Baseball_Run,
@ -118,14 +123,18 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Baseball_Paint,
Baseball_GetSize,
baseball_screen_png,
Baseball_Help
Baseball_Help,
#ifdef DEEP_DEBUG
Baseball_Debug
#else
NULL
#endif
},
// basketball
{
GAME_BASKETBALL,
60,
"Basketball",
"basketball",
"Basketball (1978)",
Basketball_Init,
Basketball_DeInit,
Basketball_Run,
@ -137,33 +146,37 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Basketball_Paint,
Basketball_GetSize,
basketball_screen_png,
Basketball_Help
Basketball_Help,
NULL
},
// basketball 2
{
GAME_BASKETBALL2,
0,
"Basketball II",
"basketball2",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
nodisp_screen_png,
60,
"Basketball 2 (1979)",
Basketball2_Init,
Basketball2_DeInit,
Basketball2_Run,
Basketball2_SetSkill,
Basketball2_GetSkill,
Basketball2_PowerOn,
Basketball2_PowerOff,
Basketball2_GetPower,
Basketball2_Paint,
Basketball2_GetSize,
basketball2_screen_png,
Basketball2_Help,
#ifdef DEEP_DEBUG
Basketball2_Debug
#else
NULL
#endif
},
// football
{
GAME_FOOTBALL,
55,
"Football",
"football",
"Football (1977)",
Football_Init,
Football_DeInit,
Football_Run,
@ -176,13 +189,13 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Football_GetSize,
football_screen_png,
Football_Help,
NULL
},
// football 2
{
GAME_FOOTBALL2,
50,
"Football II",
"football2",
"Football II (1978)",
Football2_Init,
Football2_DeInit,
Football2_Run,
@ -195,13 +208,17 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Football2_GetSize,
football2_screen_png,
Football2_Help,
#ifdef DEEP_DEBUG
Football2_Debug
#else
NULL
#endif
},
// hockey
{
GAME_HOCKEY,
60,
"Hockey",
"hockey",
"Hockey (1978)",
Hockey_Init,
Hockey_DeInit,
Hockey_Run,
@ -213,14 +230,14 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Hockey_Paint,
Hockey_GetSize,
hockey_screen_png,
Hockey_Help
Hockey_Help,
NULL
},
// hockey (canadian)
{
GAME_HOCKEYCA,
60,
"Hockey (Canadian)",
"hockeyca",
"Hockey (Canadian) (1978)",
HockeyCa_Init,
HockeyCa_DeInit,
HockeyCa_Run,
@ -232,14 +249,14 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
HockeyCa_Paint,
HockeyCa_GetSize,
hockeyca_screen_png,
HockeyCa_Help
HockeyCa_Help,
NULL
},
// ski slalom
{
GAME_SKISLALOM,
65,
"Ski Slalom",
"skislalom",
"Ski Slalom (1980)",
SkiSlalom_Init,
AutoRace_DeInit,
AutoRace_Run,
@ -251,14 +268,14 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
AutoRace_Paint,
AutoRace_GetSize,
skislalom_screen_png,
SkiSlalom_Help
SkiSlalom_Help,
NULL
},
// soccer
{
GAME_SOCCER,
60,
"Soccer",
"soccer",
"Soccer (1978)",
Soccer_Init,
Soccer_DeInit,
Soccer_Run,
@ -270,33 +287,37 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
Soccer_Paint,
Soccer_GetSize,
soccer_screen_png,
Soccer_Help
Soccer_Help,
NULL
},
// soccer 2
{
GAME_SOCCER2,
0,
"Soccer II",
"soccer2",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
nodisp_screen_png,
60,
"Soccer 2 (1979)",
Soccer2_Init,
Soccer2_DeInit,
Soccer2_Run,
Soccer2_SetSkill,
Soccer2_GetSkill,
Soccer2_PowerOn,
Soccer2_PowerOff,
Soccer2_GetPower,
Soccer2_Paint,
Soccer2_GetSize,
soccer2_screen_png,
Soccer2_Help,
#ifdef DEEP_DEBUG
Soccer2_Debug
#else
NULL
#endif
},
// space alert
{
GAME_SPACEALERT,
110,
"Space Alert",
"spacealert",
"Space Alert (1978)",
SpaceAlert_Init,
SpaceAlert_DeInit,
SpaceAlert_Run,
@ -308,14 +329,41 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
SpaceAlert_Paint,
SpaceAlert_GetSize,
spacealert_screen_png,
SpaceAlert_Help
SpaceAlert_Help,
#ifdef DEEP_DEBUG
SpaceAlert_Debug
#else
NULL
#endif
},
// missile attack
{
GAME_MISSILEATTACK,
110,
"Missile Attack (1977)",
MissileAttack_Init,
SpaceAlert_DeInit,
SpaceAlert_Run,
NULL,
NULL,
SpaceAlert_PowerOn,
SpaceAlert_PowerOff,
SpaceAlert_GetPower,
SpaceAlert_Paint,
SpaceAlert_GetSize,
missileattack_screen_png,
MissileAttack_Help,
#ifdef DEEP_DEBUG
SpaceAlert_Debug
#else
NULL
#endif
},
// subchase
{
GAME_SUBCHASE,
60,
"Sub Chase",
"subchase",
"Sub Chase (1978)",
SubChase_Init,
SubChase_DeInit,
SubChase_Run,
@ -327,7 +375,8 @@ GAMECONTEXT gGameContext[NUM_GAMES] =
SubChase_Paint,
SubChase_GetSize,
subchase_screen_png,
SubChase_Help
SubChase_Help,
NULL
}
};

View File

@ -33,7 +33,6 @@ Website : http://www.peterhirschberg.com
*/
#ifndef __GAMES_H__
#define __GAMES_H__
@ -51,9 +50,11 @@ Website : http://www.peterhirschberg.com
#define GAME_SOCCER 10
#define GAME_SOCCER2 11
#define GAME_SPACEALERT 12
#define GAME_SUBCHASE 13
#define GAME_MISSILEATTACK 13
#define GAME_SUBCHASE 14
#define NUM_GAMES 14
#define NUM_GAMES 15
typedef struct GAMECONTEXT
{
@ -64,7 +65,6 @@ typedef struct GAMECONTEXT
int tu;
char *szName;
char *szDir;
void (*Init)(void);
void (*DeInit)(void);
@ -78,6 +78,7 @@ typedef struct GAMECONTEXT
void (*GetSize)(int *w, int *h);
const u8 *screen;
void (*Help)(void);
void (*Debug)(int f);
}GAMECONTEXT;
extern GAMECONTEXT gGameContext[NUM_GAMES];

View File

@ -2,6 +2,10 @@
* LEDhead for Wii
* Copyright (C) 2017-2020 Nebiun
*
* Based on the handheld electronic games by Mattel Electronics.
* All trademarks copyrighted by their respective owners. This
* program is not affiliated or endorsed by Mattel Electronics.
*
* 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 3 of the License, or
@ -30,13 +34,18 @@
#define IR_X_CORRECTION 64
#define IR_Y_CORRECTION 20
#define realx(x) ((x) + (rmode->viWidth - 240)/2)
#define realy(y) ((y) + 20)
#define SCALE_X _scale_x
#define SCALE_Y _scale_y
#define realx(x) (((x)*SCALE_X) + (rmode->viWidth - 240*SCALE_X)/2)
#define realy(y) (((y)*SCALE_Y) + 20)
// draw_poweroff_a modes
#define POWER_POS_OFF 0
#define POWER_POS_MODE1 1
#define POWER_POS_MODE2 2
#define SWITCH_POS_OFF 0
#define SWITCH_POS_ON 1
#define SWITCH_POS_MODE1 2
#define SWITCH_POS_MODE2 3
#define SWITCH_POS_PRO1 4
#define SWITCH_POS_PRO2 5
// draw_vblip/draw_oblip modes
#define BLIP_TYPE_NORMAL 0
@ -48,17 +57,29 @@
#define DIGIT_TYPE_FLOAT 1
#define DIGIT_TYPE_SPECIAL 2
extern int trace;
// Switch types
#define SWITCH_TYPE_1 0 /* like baseball, football2 */
#define SWITCH_TYPE_2 1 /* like basketball, hockey, soccer */
#define SWITCH_TYPE_3 3 /* like football */
#define SWITCH_TYPE_4 4 /* like basketball2, soccer2 */
extern f32 _scale_x, _scale_y;
extern void print_text(int x, int y, u32 rgba, const char *fmt, ...);
extern int draw_digit(int x, int y, int val);
extern int print_digit(int x, int y, int pass, int val, int max);
extern int draw_digit_f(int x, int y, int val, int flag);
extern int draw_poweroff_a(int x, int y, int val);
extern int draw_vblip(int x, int y, int type);
extern int draw_oblip(int x, int y, int type);
extern int draw_gear(int x, int y, int pos);
extern void destroy_gear(void);
extern int draw_switch(int type, int x, int y, int pos);
extern void destroy_switch(void);
extern void debugPrintf(int x, int y, u32 rgba, const char *fmt, ...);
extern void debugDestroy(void);
#endif

View File

@ -2,6 +2,10 @@
* LEDhead for Wii
* Copyright (C) 2017-2020 Nebiun
*
* Based on the handheld electronic games by Mattel Electronics.
* All trademarks copyrighted by their respective owners. This
* program is not affiliated or endorsed by Mattel Electronics.
*
* 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 3 of the License, or
@ -15,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "LED_Handled.h"
#include "v_blip_png.h"
#include "o_blip_png.h"
@ -41,7 +45,7 @@ static inline int _drawBlip(int x, int y, int type, GRRLIB_texImg *blip)
idx = 0;
break;
}
GRRLIB_DrawTile(realx(x), realy(y), blip, 0, 1, 1, 0xFFFFFFFF, idx);
GRRLIB_DrawTile(realx(x), realy(y), blip, 0, SCALE_X, SCALE_Y, 0xFFFFFFFF, idx);
return idx;
}

View File

@ -2,6 +2,10 @@
* LEDhead for Wii
* Copyright (C) 2017-2020 Nebiun
*
* Based on the handheld electronic games by Mattel Electronics.
* All trademarks copyrighted by their respective owners. This
* program is not affiliated or endorsed by Mattel Electronics.
*
* 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 3 of the License, or
@ -15,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "LED_Handled.h"
#include "digits_f_png.h"
@ -48,13 +52,13 @@ int draw_digit_f(int x, int y, int val, int flag)
idx = 12 + val%10;
break;
case DIGIT_TYPE_SPECIAL:
idx = 23 + val%2;
idx = 22 + val%4;
break;
}
if(idx < 0)
return -1;
GRRLIB_DrawTile(realx(x), realy(y), digit, 0, 1, 1, 0xFFFFFFFF, idx);
GRRLIB_DrawTile(realx(x), realy(y), digit, 0, SCALE_X, SCALE_Y, 0xFFFFFFFF, idx);
return 0;
}

View File

@ -2,6 +2,10 @@
* LEDhead for Wii
* Copyright (C) 2017-2020 Nebiun
*
* Based on the handheld electronic games by Mattel Electronics.
* All trademarks copyrighted by their respective owners. This
* program is not affiliated or endorsed by Mattel Electronics.
*
* 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 3 of the License, or

View File

@ -50,8 +50,9 @@ Website : http://www.peterhirschberg.com
#define ARMORBATTLE_SOUND_HIT 4
#define ARMORBATTLE_SOUND_SCORE 5
#define ARMORBATTLE_SOUND_ENDGAME 6
#define ARMORBATTLE_SOUND_NSOUNDS 7
void ArmorBattle_Run();
void ArmorBattle_Run(int tu);
void ArmorBattle_SetSkill(int i);
int ArmorBattle_GetSkill();
void ArmorBattle_PowerOn();

View File

@ -50,8 +50,9 @@ Website : http://www.peterhirschberg.com
#define AUTORACE_SOUND_HIT 4
#define AUTORACE_SOUND_TIME 5
#define AUTORACE_SOUND_WIN 6
#define AUTORACE_SOUND_NSOUNDS 7
void AutoRace_Run();
void AutoRace_Run(int tu);
void AutoRace_SetSkill(int i);
int AutoRace_GetSkill();
void AutoRace_PowerOn();

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ Website : http://www.peterhirschberg.com
#ifndef __BASEBALL_H__
#define __BASEBALL_H__
#include <sys/time.h>
#include "Platform.h"
#include "Platform_Baseball.h"
@ -47,15 +47,10 @@ Website : http://www.peterhirschberg.com
#define BASEBALL_SOUND_STRIKE 3
#define BASEBALL_SOUND_ENDPOSSESSION 4
#define BASEBALL_SOUND_ENDGAME 5
#define BASEBALL_SOUND_NSOUNDS 6
void Baseball_Run();
void Baseball_SetSkill(int i);
int Baseball_GetSkill();
void Baseball_PowerOn();
void Baseball_PowerOff();
int Baseball_GetPower();
void Baseball_Run(int tu);
void Baseball_Debug(int f);
#endif

View File

@ -131,7 +131,6 @@ static PLAYER defense[NUM_DEFENSEPLAYERS];
p.nColumn++; \
}
static BOOL ISBALL(int x, int y);
static BOOL ISBALL(int x, int y)
{
if ((ball.nColumn == x)
@ -142,7 +141,6 @@ static BOOL ISBALL(int x, int y)
return FALSE;
}
static BOOL ISPLAYER(int x, int y);
static BOOL ISPLAYER(int x, int y)
{
if ((player.nColumn == x)
@ -153,7 +151,6 @@ static BOOL ISPLAYER(int x, int y)
return FALSE;
}
static BOOL ISDEFENSE(int x, int y);
static BOOL ISDEFENSE(int x, int y)
{
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
@ -166,7 +163,6 @@ static BOOL ISDEFENSE(int x, int y)
return FALSE;
}
static BOOL ISOCCUPIED(int x, int y);
static BOOL ISOCCUPIED(int x, int y)
{
if (ISPLAYER(x,y)){
@ -178,7 +174,6 @@ static BOOL ISOCCUPIED(int x, int y)
return FALSE;
}
static int GETPLAYERAT(int x, int y);
static int GETPLAYERAT(int x, int y){
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if ((defense[i].nColumn == x)
@ -205,8 +200,6 @@ static int GETPLAYERAT(int x, int y){
#define ISPLAYERENABLED(p) \
(p.nBright)
// finite state machine stuff
static void fsmPlayStartWait();
@ -234,43 +227,7 @@ static FSMFCN fsmfcn[] = {
fsmGameOver
};
// proto's
static void InitGame();
static void DrawBlips();
static void EraseBlips();
BOOL Basketball_GetPower()
{
return (bPower ? TRUE : FALSE);
}
void Basketball_PowerOn()
{
InitGame();
bPower = TRUE;
}
void Basketball_PowerOff()
{
bPower = FALSE;
Basketball_StopSound();
}
void Basketball_SetSkill(int i){
if (i == 0){
bPro2 = FALSE;
} else {
bPro2 = TRUE;
}
}
int Basketball_GetSkill(){
return bPro2 ? 1 : 0;
}
void InitGame()
static void InitGame()
{
bHomeTeam = FALSE;
PlatformSetInput(bHomeTeam);
@ -285,40 +242,7 @@ void InitGame()
fsm = FSM_PLAYSTARTWAIT;
}
void Basketball_Run(int tu)
{
int x, y;
// prevent reentrancy
if (bInFrame){ return; }
bInFrame = TRUE;
// init the blips field
for (y = 0; y < BASKETBALL_BLIP_ROWS; y++){
for (x = 0; x < BASKETBALL_BLIP_COLUMNS; x++){
Blips[x][y] = BLIP_OFF;
}
}
if (!bPower){
Basketball_ClearScreen();
bInFrame = FALSE;
return;
}
Platform_StartDraw();
(fsmfcn[fsm])();
DrawBlips();
Platform_EndDraw();
bInFrame = FALSE;
}
void DrawBlips()
static void DrawBlips()
{
int x, y, nBright;
static BOOL bBlink = FALSE;
@ -377,16 +301,69 @@ void DrawBlips()
bBlink = !bBlink;
}
void EraseBlips()
BOOL Basketball_GetPower()
{
// erase the blips field
for (int y = 0; y < BASKETBALL_BLIP_ROWS; y++){
for (int x = 0; x < BASKETBALL_BLIP_COLUMNS; x++){
Basketball_DrawBlip(BLIP_OFF, x, y);
}
return (bPower ? TRUE : FALSE);
}
void Basketball_PowerOn()
{
InitGame();
bPower = TRUE;
}
void Basketball_PowerOff()
{
bPower = FALSE;
Basketball_StopSound();
}
void Basketball_SetSkill(int i){
if (i == 0){
bPro2 = FALSE;
} else {
bPro2 = TRUE;
}
}
int Basketball_GetSkill(){
return bPro2 ? 1 : 0;
}
void Basketball_Run(int tu)
{
int x, y;
// prevent reentrancy
if (bInFrame){ return; }
bInFrame = TRUE;
// init the blips field
for (y = 0; y < BASKETBALL_BLIP_ROWS; y++){
for (x = 0; x < BASKETBALL_BLIP_COLUMNS; x++){
Blips[x][y] = BLIP_OFF;
}
}
if (!bPower){
Basketball_ClearScreen();
bInFrame = FALSE;
return;
}
Platform_StartDraw();
(fsmfcn[fsm])();
DrawBlips();
Platform_EndDraw();
bInFrame = FALSE;
}
// FINITE STATE MACHINE STUFF
void fsmPlayStartWait()

View File

@ -49,8 +49,9 @@ Website : http://www.peterhirschberg.com
#define BASKETBALL_SOUND_ENDPLAY 3
#define BASKETBALL_SOUND_ENDQUARTER 4
#define BASKETBALL_SOUND_ENDGAME 5
#define BASKETBALL_SOUND_NSOUNDS 6
void Basketball_Run();
void Basketball_Run(int tu);
void Basketball_SetSkill(int i);
int Basketball_GetSkill();
void Basketball_PowerOn();

1340
source/game/Basketball2.c Normal file

File diff suppressed because it is too large Load Diff

55
source/game/Basketball2.h Normal file
View File

@ -0,0 +1,55 @@
/*
* LEDhead for Wii
* Copyright (C) 2017-2020 Nebiun
*
* Based on the handheld electronic games by Mattel Electronics.
* All trademarks copyrighted by their respective owners. This
* program is not affiliated or endorsed by Mattel Electronics.
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef __BASKETBALL2_H__
#define __BASKETBALL2_H__
#include "Platform.h"
#include "Platform_Basketball2.h"
#define BASKETBALL2_BLIP_ROWS 5
#define BASKETBALL2_BLIP_COLUMNS 7
#define BASKETBALL2_SOUND_TICK 0
#define BASKETBALL2_SOUND_BOUNCE 1
#define BASKETBALL2_SOUND_SCORE 2 // Four-note fanfare
#define BASKETBALL2_SOUND_ENDPLAY 3 // Two whistles
#define BASKETBALL2_SOUND_ENDQUARTER 4 // Buzzer
#define BASKETBALL2_SOUND_ENDGAME 5 // Long buzzer
#define BASKETBALL2_SOUND_SCORE3 6 // Double fanfare
#define BASKETBALL2_SOUND_FOUL 7 // One whistle
#define BASKETBALL2_SOUND_3SECS 8 // Three whistles
#define BASKETBALL2_SOUND_FREETHROW 9 // Two-note fanfare
#define BASKETBALL2_SOUND_OVERTIME 10 // Two buzzers
#define BASKETBALL2_SOUND_NSOUNDS 11
void Basketball2_Run(int tu);
void Basketball2_SetSkill(int i);
int Basketball2_GetSkill();
void Basketball2_PowerOn();
void Basketball2_PowerOff();
BOOL Basketball2_GetPower();
void Basketball2_Debug(int f);
#endif

View File

@ -181,18 +181,6 @@ static PLAYER player[NUM_DEFENSEPLAYERS];
} \
}
static BOOL ISBALL(int x, int y);
static BOOL ISBALL(int x, int y)
{
if ((ball.nColumn == x)
&& (ball.nLane == y)
&& (ball.nBright)){
return TRUE;
}
return FALSE;
}
static BOOL ISDEFENSE(int x, int y);
static BOOL ISDEFENSE(int x, int y)
{
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
@ -205,19 +193,6 @@ static BOOL ISDEFENSE(int x, int y)
return FALSE;
}
static BOOL ISOCCUPIED(int x, int y);
static BOOL ISOCCUPIED(int x, int y)
{
if (ISBALL(x,y)){
return TRUE;
}
if (ISDEFENSE(x,y)){
return TRUE;
}
return FALSE;
}
static int GETPLAYERAT(int x, int y);
static int GETPLAYERAT(int x, int y){
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if ((player[i].nColumn == x)
@ -238,8 +213,6 @@ static int GETPLAYERAT(int x, int y){
#define ISPLAYEROFFSCREEN(p) \
((p.nColumn > FOOTBALL_BLIP_COLUMNS-1) || (p.nColumn < 0))
// finite state machine stuff
static void fsmFormation();
@ -263,12 +236,93 @@ static FSMFCN fsmfcn[] = {
fsmGameOver
};
static void InitGame()
{
bHomeTeam = TRUE;
PlatformSetInput(bHomeTeam);
nHScore = 0;
nVScore = 0;
fGameTime = 15.0;
nDown = 0;
nQuarter = 0;
nCurrentYardline = 100 - 20;
nFirstDownYard = nCurrentYardline - 10;
// proto's
static void InitGame();
static void DrawBlips();
static void EraseBlips();
bDisplayScore = FALSE;
bDisplayTime = FALSE;
bDisplayYard = FALSE;
bDisplayDown = FALSE;
bDisplayBlips = TRUE;
fsm = FSM_FORMATION;
}
static void DrawBlips()
{
int x, y, nBright;
static int nBlinkTimer = 0;
static BOOL bBlink = FALSE;
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if (player[i].nBright != BLIP_OFF){
x = player[i].nColumn % 10;
y = player[i].nLane;
nBright = player[i].nBright;
Blips[x][y] = nBright;
}
}
if (ball.nBright != BLIP_OFF){
x = ball.nColumn % 10;
y = ball.nLane;
nBright = ball.nBright;
Blips[x][y] = nBright;
}
// draw the blips field
for (y = 0; y < FOOTBALL_BLIP_ROWS; y++){
for (x = 0; x < FOOTBALL_BLIP_COLUMNS; x++){
switch(Blips[x][y]){
case BLIP_OFF:
case BLIP_DIM:
case BLIP_BRIGHT:
Football_DrawBlip(Blips[x][y], x, y);
break;
case BLIP_DIMBLINK:
if (!bBlink){
Football_DrawBlip(BLIP_DIM, x, y);
} else {
Football_DrawBlip(BLIP_OFF, x, y);
}
break;
case BLIP_BRIGHTBLINK:
if (bBlink){
Football_DrawBlip(BLIP_BRIGHT, x, y);
} else {
Football_DrawBlip(BLIP_OFF, x, y);
}
break;
}
}
}
if (--nBlinkTimer <= 0){
nBlinkTimer = 4;
bBlink = !bBlink;
}
}
static void EraseBlips()
{
// erase the blips field
for (int y = 0; y < FOOTBALL_BLIP_ROWS; y++){
for (int x = 0; x < FOOTBALL_BLIP_COLUMNS; x++){
Football_DrawBlip(BLIP_OFF, x, y);
}
}
}
BOOL Football_GetPower()
{
@ -299,28 +353,6 @@ int Football_GetSkill(){
return bPro2 ? 1 : 0;
}
void InitGame()
{
bHomeTeam = TRUE;
PlatformSetInput(bHomeTeam);
nHScore = 0;
nVScore = 0;
fGameTime = 15.0;
nDown = 0;
nQuarter = 0;
nCurrentYardline = 100 - 20;
nFirstDownYard = nCurrentYardline - 10;
bDisplayScore = FALSE;
bDisplayTime = FALSE;
bDisplayYard = FALSE;
bDisplayDown = FALSE;
bDisplayBlips = TRUE;
fsm = FSM_FORMATION;
}
void Football_Run(int tu)
{
int x, y;
@ -388,72 +420,6 @@ void Football_Run(int tu)
}
void DrawBlips()
{
int x, y, nBright;
static int nBlinkTimer = 0;
static BOOL bBlink = FALSE;
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if (player[i].nBright != BLIP_OFF){
x = player[i].nColumn % 10;
y = player[i].nLane;
nBright = player[i].nBright;
Blips[x][y] = nBright;
}
}
if (ball.nBright != BLIP_OFF){
x = ball.nColumn % 10;
y = ball.nLane;
nBright = ball.nBright;
Blips[x][y] = nBright;
}
// draw the blips field
for (y = 0; y < FOOTBALL_BLIP_ROWS; y++){
for (x = 0; x < FOOTBALL_BLIP_COLUMNS; x++){
switch(Blips[x][y]){
case BLIP_OFF:
case BLIP_DIM:
case BLIP_BRIGHT:
Football_DrawBlip(Blips[x][y], x, y);
break;
case BLIP_DIMBLINK:
if (!bBlink){
Football_DrawBlip(BLIP_DIM, x, y);
} else {
Football_DrawBlip(BLIP_OFF, x, y);
}
break;
case BLIP_BRIGHTBLINK:
if (bBlink){
Football_DrawBlip(BLIP_BRIGHT, x, y);
} else {
Football_DrawBlip(BLIP_OFF, x, y);
}
break;
}
}
}
if (--nBlinkTimer <= 0){
nBlinkTimer = 4;
bBlink = !bBlink;
}
}
void EraseBlips()
{
// erase the blips field
for (int y = 0; y < FOOTBALL_BLIP_ROWS; y++){
for (int x = 0; x < FOOTBALL_BLIP_COLUMNS; x++){
Football_DrawBlip(BLIP_OFF, x, y);
}
}
}
// FINITE STATE MACHINE STUFF
static void fsmFormation()
@ -793,7 +759,6 @@ static void fsmPlayEnded()
}
static void fsmGameOver()
{
bDisplayTime = TRUE;
@ -802,8 +767,3 @@ static void fsmGameOver()
bDisplayDown = FALSE;
bDisplayBlips = FALSE;
}

View File

@ -44,12 +44,13 @@ Website : http://www.peterhirschberg.com
#define FOOTBALL_BLIP_ROWS 3
#define FOOTBALL_BLIP_COLUMNS 9
#define FOOTBALL_SOUND_TICK 0
#define FOOTBALL_SOUND_ENDPLAY 1
#define FOOTBALL_SOUND_TICK 0
#define FOOTBALL_SOUND_ENDPLAY 1
#define FOOTBALL_SOUND_ENDPOSSESSION 2
#define FOOTBALL_SOUND_SCORE 3
#define FOOTBALL_SOUND_NSOUDS 4
void Football_Run();
void Football_Run(int tu);
void Football_SetSkill(int i);
int Football_GetSkill();
void Football_PowerOn();

View File

@ -49,7 +49,6 @@ static BLIP Blips[FOOTBALL2_BLIP_COLUMNS][FOOTBALL2_BLIP_ROWS];
static BOOL bHomeTeam;
static BOOL bInFrame = FALSE;
static BOOL bPower;
static BOOL bPro2 = FALSE;
static BOOL bGotFirstDown;
static BOOL bDisplayScore;
@ -65,7 +64,7 @@ static int nFirstDownYard;
static int nDown;
static int nQuarter;
static int nCurrentYardline;
static int nLevel = -1;
static int nPassingStart;
static int nKickoffStart;
@ -190,7 +189,6 @@ static PLAYER player[NUM_DEFENSEPLAYERS];
} \
}
static BOOL ISBALL(int x, int y);
static BOOL ISBALL(int x, int y)
{
if ((ball.nColumn == x)
@ -201,7 +199,6 @@ static BOOL ISBALL(int x, int y)
return FALSE;
}
static BOOL ISRECEIVER(int x, int y);
static BOOL ISRECEIVER(int x, int y)
{
if ((receiver.nColumn == x)
@ -212,7 +209,6 @@ static BOOL ISRECEIVER(int x, int y)
return FALSE;
}
static BOOL ISDEFENSE(int x, int y);
static BOOL ISDEFENSE(int x, int y)
{
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
@ -225,7 +221,6 @@ static BOOL ISDEFENSE(int x, int y)
return FALSE;
}
static BOOL ISOCCUPIED(int x, int y);
static BOOL ISOCCUPIED(int x, int y)
{
if (ISBALL(x,y)){
@ -240,7 +235,6 @@ static BOOL ISOCCUPIED(int x, int y)
return FALSE;
}
static int GETPLAYERAT(int x, int y);
static int GETPLAYERAT(int x, int y){
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if ((player[i].nColumn == x)
@ -262,7 +256,6 @@ static int GETPLAYERAT(int x, int y){
((p.nColumn > FOOTBALL2_BLIP_COLUMNS-1) || (p.nColumn < 0))
// finite state machine stuff
static void fsmKickoffWait();
@ -277,8 +270,11 @@ static void fsmPassing();
static void fsmSafety();
static void fsmPlayEnded();
static void fsmGameOver();
static void fsmTurnover();
static void fsmOutPlay();
static enum FSM {
enum FSM {
FSM_INVALID=-1,
FSM_KICKOFFWAIT=0,
FSM_KICKOFFCHARGE,
FSM_KICKOFFMIDAIR,
@ -290,8 +286,12 @@ static enum FSM {
FSM_PASSING,
FSM_SAFETY,
FSM_PLAYENDED,
FSM_GAMEOVER
}fsm;
FSM_GAMEOVER,
FSM_TURNOVER,
FSM_OUTPLAY
};
static enum FSM fsm, nextFsm;
typedef void (*FSMFCN)();
@ -307,16 +307,99 @@ static FSMFCN fsmfcn[] = {
fsmPassing,
fsmSafety,
fsmPlayEnded,
fsmGameOver
fsmGameOver,
fsmTurnover,
fsmOutPlay
};
static void InitGame()
{
bHomeTeam = FALSE;
PlatformSetInput(bHomeTeam);
nHScore = 0;
nVScore = 0;
fGameTime = 15.0;
nDown = -1;
nQuarter = 0;
nCurrentYardline = 35;
// proto's
static void InitGame();
static void DrawBlips();
static void EraseBlips();
bDisplayScore = FALSE;
bDisplayTime = TRUE;
bDisplayYard = FALSE;
bDisplayDown = FALSE;
bDisplayBlips = TRUE;
fsm = FSM_KICKOFFWAIT;
}
static void DrawBlips()
{
int x, y, nBright;
static BOOL blink = FALSE;
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if (player[i].nBright != BLIP_OFF){
x = player[i].nColumn % 10;
y = player[i].nLane;
nBright = player[i].nBright;
Blips[x][y] = nBright;
}
}
if (receiver.nBright != BLIP_OFF){
x = receiver.nColumn % 10;
y = receiver.nLane;
nBright = receiver.nBright;
Blips[x][y] = nBright;
}
if (ball.nBright != BLIP_OFF){
x = ball.nColumn % 10;
y = ball.nLane;
nBright = ball.nBright;
Blips[x][y] = nBright;
}
// draw the blips field
for (y = 0; y < FOOTBALL2_BLIP_ROWS; y++){
for (x = 0; x < FOOTBALL2_BLIP_COLUMNS; x++){
switch(Blips[x][y]){
case BLIP_OFF:
case BLIP_DIM:
case BLIP_BRIGHT:
Football2_DrawBlip(Blips[x][y], x, y);
break;
case BLIP_DIMBLINK:
if (!blink){
Football2_DrawBlip(BLIP_DIM, x, y);
} else {
Football2_DrawBlip(BLIP_OFF, x, y);
}
break;
case BLIP_BRIGHTBLINK:
if (blink){
Football2_DrawBlip(BLIP_BRIGHT, x, y);
} else {
Football2_DrawBlip(BLIP_OFF, x, y);
}
break;
}
}
}
blink = !blink;
}
static void EraseBlips()
{
// erase the blips field
for (int y = 0; y < FOOTBALL2_BLIP_ROWS; y++){
for (int x = 0; x < FOOTBALL2_BLIP_COLUMNS; x++){
Football2_DrawBlip(BLIP_OFF, x, y);
}
}
}
int Football2_GetPower()
{
@ -339,36 +422,11 @@ void Football2_PowerOff()
}
void Football2_SetSkill(int i){
if (i == 0){
bPro2 = FALSE;
} else {
bPro2 = TRUE;
}
nLevel = i;
}
int Football2_GetSkill(){
return bPro2 ? 1 : 0;
}
void InitGame()
{
bHomeTeam = FALSE;
PlatformSetInput(bHomeTeam);
nHScore = 0;
nVScore = 0;
fGameTime = 15.0;
nDown = -1;
nQuarter = 0;
nCurrentYardline = 35;
bDisplayScore = FALSE;
bDisplayTime = TRUE;
bDisplayYard = FALSE;
bDisplayDown = FALSE;
bDisplayBlips = TRUE;
fsm = FSM_KICKOFFWAIT;
return nLevel;
}
void Football2_Run(int tu)
@ -432,75 +490,20 @@ void Football2_Run(int tu)
}
void DrawBlips()
{
int x, y, nBright;
static BOOL blink = FALSE;
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if (player[i].nBright != BLIP_OFF){
x = player[i].nColumn % 10;
y = player[i].nLane;
nBright = player[i].nBright;
Blips[x][y] = nBright;
}
}
if (receiver.nBright != BLIP_OFF){
x = receiver.nColumn % 10;
y = receiver.nLane;
nBright = receiver.nBright;
Blips[x][y] = nBright;
}
if (ball.nBright != BLIP_OFF){
x = ball.nColumn % 10;
y = ball.nLane;
nBright = ball.nBright;
Blips[x][y] = nBright;
}
// draw the blips field
for (y = 0; y < FOOTBALL2_BLIP_ROWS; y++){
for (x = 0; x < FOOTBALL2_BLIP_COLUMNS; x++){
switch(Blips[x][y]){
case BLIP_OFF:
case BLIP_DIM:
case BLIP_BRIGHT:
Football2_DrawBlip(Blips[x][y], x, y);
break;
case BLIP_DIMBLINK:
if (!blink){
Football2_DrawBlip(BLIP_DIM, x, y);
} else {
Football2_DrawBlip(BLIP_OFF, x, y);
}
break;
case BLIP_BRIGHTBLINK:
if (blink){
Football2_DrawBlip(BLIP_BRIGHT, x, y);
} else {
Football2_DrawBlip(BLIP_OFF, x, y);
}
break;
}
}
}
blink = !blink;
}
void EraseBlips()
{
// erase the blips field
for (int y = 0; y < FOOTBALL2_BLIP_ROWS; y++){
for (int x = 0; x < FOOTBALL2_BLIP_COLUMNS; x++){
Football2_DrawBlip(BLIP_OFF, x, y);
}
}
}
// FINITE STATE MACHINE STUFF
static void fsmTurnover()
{
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
fsm = nextFsm;
nextFsm = FSM_INVALID;
}
static void fsmOutPlay()
{
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
fsm = FSM_PLAYENDED;
}
static void fsmKickoffWait()
{
@ -792,20 +795,16 @@ static void fsmKickoffRunback()
Football2_ClearScreen();
Football2_PlaySound(FOOTBALL2_SOUND_TOUCHDOWN, PLAYSOUNDFLAGS_PRIORITY);
Platform_IsNewSecond();
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nCurrentYardline = 35;
fsm = FSM_KICKOFFWAIT;
nextFsm = FSM_KICKOFFWAIT;
fsm = FSM_TURNOVER;
return;
}
// check for collisions
if (ISDEFENSE(ball.nColumn, ball.nLane)){
// tackled!
Football2_ClearScreen();
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
int i = GETPLAYERAT(ball.nColumn, ball.nLane);
if (i != -1){
SETPLAYERBRIGHTNESS(player[i], BLIP_DIMBLINK);
@ -817,13 +816,13 @@ static void fsmKickoffRunback()
nFirstDownYard = ball.nYard - 10;
Platform_IsNewSecond();
fsm = FSM_PLAYENDED;
fsm = FSM_OUTPLAY;
return;
}
// move the defense randomly towards the ball
if (Platform_Random(100) < ((bPro2) ? 25 : 15)){
if (Platform_Random(100) < ((nLevel%2) ? 25 : 15)){
int i = Platform_Random(NUM_DEFENSEPLAYERS);
if (player[i].nBright){
// pick horizontal or vertical movement toward the ball
@ -875,7 +874,6 @@ static void fsmKickoffRunback()
if (ISDEFENSE(ball.nColumn, ball.nLane)){
// tackled!
Football2_ClearScreen();
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
int i = GETPLAYERAT(ball.nColumn, ball.nLane);
if (i != -1){
@ -888,7 +886,7 @@ static void fsmKickoffRunback()
nFirstDownYard = ball.nYard - 10;
Platform_IsNewSecond();
fsm = FSM_PLAYENDED;
fsm = FSM_OUTPLAY;
return;
}
@ -986,9 +984,6 @@ static void fsmFormation()
if (bChange)
{
// punt
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nCurrentYardline = ball.nYard;
@ -1006,7 +1001,8 @@ static void fsmFormation()
SETPLAYERBRIGHTNESS(ball, BLIP_BRIGHTBLINK);
Platform_IsNewSecond();
bPunting = TRUE;
fsm = FSM_KICKOFFMIDAIR;
nextFsm = FSM_KICKOFFMIDAIR;
fsm = FSM_TURNOVER;
return;
}
}
@ -1091,8 +1087,6 @@ static void fsmInPlay()
if (Football2_GetInputKICK(NULL) && bCanKick){
// field goal attempt!
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nKickoffStart = nCurrentYardline;
@ -1111,8 +1105,8 @@ static void fsmInPlay()
SETPLAYERBRIGHTNESS(ball, BLIP_BRIGHTBLINK);
Platform_IsNewSecond();
bFieldGoalAttempt = TRUE;
fsm = FSM_KICKOFFMIDAIR;
nextFsm = FSM_KICKOFFMIDAIR;
fsm = FSM_TURNOVER;
return;
}
@ -1146,10 +1140,9 @@ static void fsmInPlay()
Football2_ClearScreen();
Football2_PlaySound(FOOTBALL2_SOUND_TOUCHDOWN, PLAYSOUNDFLAGS_PRIORITY);
Platform_IsNewSecond();
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nCurrentYardline = 35;
fsm = FSM_KICKOFFWAIT;
nextFsm = FSM_KICKOFFWAIT;
fsm = FSM_TURNOVER;
return;
}
@ -1175,31 +1168,24 @@ static void fsmInPlay()
fsm = FSM_SAFETY;
return;
} else if ((++nDown >= 4) && (!bGotFirstDown)){
}
if ((++nDown >= 4) && (!bGotFirstDown)){
// give the ball to the other team
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nFirstDownYard = ball.nYard - 10;
Football2_PlaySound(FOOTBALL2_SOUND_ENDPOSSESSION, PLAYSOUNDFLAGS_PRIORITY);
fsm = FSM_PLAYENDED;
Football2_PlaySound(FOOTBALL2_SOUND_ENDPOSSESSION, PLAYSOUNDFLAGS_PRIORITY);
nextFsm = FSM_PLAYENDED;
fsm = FSM_TURNOVER;
return;
} else {
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
fsm = FSM_PLAYENDED;
return;
}
}
fsm = FSM_OUTPLAY;
return;
}
// move the defense randomly towards the ball
if (Platform_Random(100) < ((bPro2) ? 25 : 15)){
if (Platform_Random(100) < ((nLevel%2) ? 25 : 15)){
int i = Platform_Random(NUM_DEFENSEPLAYERS);
if (player[i].nBright){
// pick horizontal or vertical movement toward the ball
@ -1235,9 +1221,8 @@ static void fsmInPlay()
}
}
// move the receiver randomly
if (Platform_Random(100) < ((bPro2) ? 15 : 5)){
if (Platform_Random(100) < ((nLevel%2) ? 15 : 5)){
if (receiver.nBright){
// pick horizontal or vertical movement toward the ball
if (Platform_Random(4) == 0){
@ -1268,7 +1253,6 @@ static void fsmInPlay()
}
}
// check for collisions again
if (ISDEFENSE(ball.nColumn, ball.nLane)){
// tackled!
@ -1291,28 +1275,21 @@ static void fsmInPlay()
fsm = FSM_SAFETY;
return;
} else if ((++nDown >= 4) && (!bGotFirstDown)){
}
if ((++nDown >= 4) && (!bGotFirstDown)){
// give the ball to the other team
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nFirstDownYard = ball.nYard - 10;
Football2_PlaySound(FOOTBALL2_SOUND_ENDPOSSESSION, PLAYSOUNDFLAGS_PRIORITY);
fsm = FSM_PLAYENDED;
nextFsm = FSM_PLAYENDED;
fsm = FSM_TURNOVER;
return;
} else {
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
fsm = FSM_PLAYENDED;
return;
}
}
fsm = FSM_OUTPLAY;
return;
}
// count down the clock
if (Platform_IsNewSecond()){
if (fGameTime > 0.0){
@ -1330,8 +1307,7 @@ static void fsmInPlay()
static void fsmPassing()
{
static int i = 0;
BOOL bIntercepted = FALSE;
static int i = 0;
bDisplayTime = TRUE;
bDisplayScore = FALSE;
@ -1361,20 +1337,18 @@ BOOL bIntercepted = FALSE;
if ((++nDown >= 4) && (!bGotFirstDown)){
// give the ball to the other team
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nFirstDownYard = ball.nYard - 10;
Football2_PlaySound(FOOTBALL2_SOUND_ENDPOSSESSION, PLAYSOUNDFLAGS_PRIORITY);
} else {
Football2_PlaySound(FOOTBALL2_SOUND_ENDPLAY, PLAYSOUNDFLAGS_PRIORITY);
nextFsm = FSM_PLAYENDED;
fsm = FSM_TURNOVER;
}
else {
fsm = FSM_OUTPLAY;
}
Platform_IsNewSecond();
fsm = FSM_PLAYENDED;
} else if (ISDEFENSE(ball.nColumn, ball.nLane)){
@ -1399,14 +1373,13 @@ BOOL bIntercepted = FALSE;
UNMOVEPLAYER(ball);
// give the ball to the other team
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
nDown = 0;
ball.nYard = MAX_YARD - ball.nYard;
nFirstDownYard = ball.nYard - 10;
Platform_IsNewSecond();
fsm = FSM_PLAYENDED;
nextFsm = FSM_PLAYENDED;
fsm = FSM_TURNOVER;
}
}
}
@ -1459,8 +1432,6 @@ static void fsmSafety()
++nQuarter;
if (nQuarter == 2){
// halftime - force kickoff
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
ball.nYard = 35;
nCurrentYardline = ball.nYard;
nFirstDownYard = nCurrentYardline - 35;
@ -1473,11 +1444,11 @@ static void fsmSafety()
}
fGameTime = 15.0;
fsm = FSM_KICKOFFWAIT;
nextFsm = FSM_KICKOFFWAIT;
fsm = FSM_TURNOVER;
return;
} else {
fGameTime = 15.0;
}
}
fGameTime = 15.0;
}
// add 2 points and set up kickoff from 20 yardline
@ -1486,17 +1457,15 @@ static void fsmSafety()
} else {
nHScore += 2;
}
bHomeTeam = !bHomeTeam;
PlatformSetInput(bHomeTeam);
ball.nYard = 20;
nCurrentYardline = ball.nYard;
nFirstDownYard = nCurrentYardline - 10;
fsm = FSM_KICKOFFWAIT;
fsmKickoffWait();
nextFsm = FSM_KICKOFFWAIT;
fsm = FSM_TURNOVER;
// fsmKickoffWait();
return;
}
}
static void fsmPlayEnded()
@ -1554,7 +1523,15 @@ static void fsmGameOver()
}
#define LINE_STEP 20
void Football2_Debug(int f)
{
int w, h;
int y = 0;
Football2_GetSize(&w, &h);
debugPrintf(realx(w)+10, realy(y), 0xFFFFFFFF, "level =%d", nLevel);
y += LINE_STEP;
debugPrintf(realx(w)+10, realy(y), 0xFFFFFFFF, "fsm =%d", fsm);
y += LINE_STEP;
}

View File

@ -45,23 +45,24 @@ Website : http://www.peterhirschberg.com
#define FOOTBALL2_BLIP_ROWS 3
#define FOOTBALL2_BLIP_COLUMNS 10
#define FOOTBALL2_SOUND_CHARGESTART 0
#define FOOTBALL2_SOUND_CHARGE 1
#define FOOTBALL2_SOUND_CHARGESTART 0
#define FOOTBALL2_SOUND_CHARGE 1
#define FOOTBALL2_SOUND_TICK 2
#define FOOTBALL2_SOUND_RUNBACK 3
#define FOOTBALL2_SOUND_RUNBACK 3
#define FOOTBALL2_SOUND_FIRSTDOWN 4
#define FOOTBALL2_SOUND_ENDPLAY 5
#define FOOTBALL2_SOUND_ENDPLAY 5
#define FOOTBALL2_SOUND_ENDPOSSESSION 6
#define FOOTBALL2_SOUND_ENDQUARTER 7
#define FOOTBALL2_SOUND_ENDQUARTER 7
#define FOOTBALL2_SOUND_TOUCHDOWN 8
#define FOOTBALL2_SOUND_SAFETY 9
#define FOOTBALL2_SOUND_SAFETY 9
#define FOOTBALL2_SOUND_NSOUNDS 10
void Football2_Run();
void Football2_Run(int tu);
void Football2_SetSkill(int i);
int Football2_GetSkill();
void Football2_PowerOn();
void Football2_PowerOff();
int Football2_GetPower();
void Football2_Debug();
#endif

View File

@ -138,18 +138,6 @@ static PLAYER defense[NUM_DEFENSEPLAYERS];
p.nColumn++; \
}
static BOOL ISPUCK(int x, int y);
static BOOL ISPUCK(int x, int y)
{
if ((puck.nColumn == x)
&& (puck.nRow == y)
&& (puck.nBright)){
return TRUE;
}
return FALSE;
}
static BOOL ISPLAYER(int x, int y);
static BOOL ISPLAYER(int x, int y)
{
if ((player.nColumn == x)
@ -160,7 +148,6 @@ static BOOL ISPLAYER(int x, int y)
return FALSE;
}
static BOOL ISDEFENSE(int x, int y);
static BOOL ISDEFENSE(int x, int y)
{
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
@ -173,7 +160,6 @@ static BOOL ISDEFENSE(int x, int y)
return FALSE;
}
static BOOL ISOCCUPIED(int x, int y);
static BOOL ISOCCUPIED(int x, int y)
{
// easy way to keep player and defenders out of the non-playfield areas
@ -197,8 +183,8 @@ static BOOL ISOCCUPIED(int x, int y)
return FALSE;
}
static int GETPLAYERAT(int x, int y);
static int GETPLAYERAT(int x, int y){
static int GETPLAYERAT(int x, int y)
{
for (int i=0; i<NUM_DEFENSEPLAYERS; i++){
if ((defense[i].nColumn == x)
&& (defense[i].nRow == y)
@ -233,7 +219,6 @@ static void fsmInPlay();
static void fsmGoal();
static void fsmGameOver();
static enum FSM {
FSM_PLAYSTARTWAIT=0,
FSM_SHOWSTATS,
@ -252,44 +237,7 @@ static FSMFCN fsmfcn[] = {
fsmGameOver
};
// proto's
static void InitGame();
static void DrawBlips();
static void EraseBlips();
static BOOL PenaltyTest(int x, int y);
BOOL Hockey_GetPower()
{
return (bPower ? TRUE : FALSE);
}
void Hockey_PowerOn()
{
InitGame();
bPower = TRUE;
}
void Hockey_PowerOff()
{
bPower = FALSE;
Hockey_StopSound();
}
void Hockey_SetSkill(int i){
if (i == 0){
bPro2 = FALSE;
} else {
bPro2 = TRUE;
}
}
int Hockey_GetSkill(){
return bPro2 ? 1 : 0;
}
void InitGame()
static void InitGame()
{
bHomeTeam = FALSE;
PlatformSetInput(bHomeTeam);
@ -313,40 +261,7 @@ void InitGame()
fsmShowStats();
}
void Hockey_Run(int tu)
{
int x, y;
// prevent reentrancy
if (bInFrame){ return; }
bInFrame = TRUE;
// init the blips field
for (y = 0; y < HOCKEY_BLIP_ROWS; y++){
for (x = 0; x < HOCKEY_BLIP_COLUMNS; x++){
Blips[x][y] = BLIP_OFF;
}
}
if (!bPower){
Hockey_ClearScreen();
bInFrame = FALSE;
return;
}
Platform_StartDraw();
(fsmfcn[fsm])();
DrawBlips();
Platform_EndDraw();
bInFrame = FALSE;
}
void DrawBlips()
static void DrawBlips()
{
int x, y, nBright;
static BOOL bBlink = FALSE;
@ -416,20 +331,7 @@ void DrawBlips()
bBlink = !bBlink;
}
void EraseBlips()
{
// erase the blips field
for (int y = 1; y < HOCKEY_BLIP_ROWS; y++){
for (int x = 0; x < HOCKEY_BLIP_COLUMNS; x++){
Hockey_DrawBlip(BLIP_OFF, x, y);
}
}
// erase the blip behind the goal
Hockey_DrawBlip(BLIP_OFF, 2, 0);
}
BOOL PenaltyTest(int x, int y)
static BOOL PenaltyTest(int x, int y)
{
if (ISDEFENSE(x, y))
{
@ -466,6 +368,68 @@ BOOL PenaltyTest(int x, int y)
return FALSE;
}
BOOL Hockey_GetPower()
{
return (bPower ? TRUE : FALSE);
}
void Hockey_PowerOn()
{
InitGame();
bPower = TRUE;
}
void Hockey_PowerOff()
{
bPower = FALSE;
Hockey_StopSound();
}
void Hockey_SetSkill(int i){
if (i == 0){
bPro2 = FALSE;
} else {
bPro2 = TRUE;
}
}
int Hockey_GetSkill(){
return bPro2 ? 1 : 0;
}
void Hockey_Run(int tu)
{
int x, y;
// prevent reentrancy
if (bInFrame){ return; }
bInFrame = TRUE;
// init the blips field
for (y = 0; y < HOCKEY_BLIP_ROWS; y++){
for (x = 0; x < HOCKEY_BLIP_COLUMNS; x++){
Blips[x][y] = BLIP_OFF;
}
}
if (!bPower){
Hockey_ClearScreen();
bInFrame = FALSE;
return;
}
Platform_StartDraw();
(fsmfcn[fsm])();
DrawBlips();
Platform_EndDraw();
bInFrame = FALSE;
}
// FINITE STATE MACHINE STUFF
void fsmPlayStartWait()

View File

@ -53,8 +53,9 @@ Website : http://www.peterhirschberg.com
#define HOCKEY_SOUND_STEAL 6
#define HOCKEY_SOUND_ENDPERIOD 7
#define HOCKEY_SOUND_ENDGAME 8
#define HOCKEY_SOUND_NSOUNDS 9
void Hockey_Run();
void Hockey_Run(int tu);
void Hockey_SetSkill(int i);
int Hockey_GetSkill();
void Hockey_PowerOn();

Some files were not shown because too many files have changed in this diff Show More