Skip to content

Commit

Permalink
New driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbontar committed Jan 21, 2016
1 parent 68fb5f4 commit 9206609
Show file tree
Hide file tree
Showing 8 changed files with 437 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/tools/nfs2ac/nfs2ac
src/tools/nfsperf/nfsperf
src/tools/texmapper/texmapper
src/tools/trackgen/trackgen
src/tags
*.a
*-bin
*.depend
Expand Down
29 changes: 29 additions & 0 deletions src/drivers/jz/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##############################################################################
#
# file : Makefile
# created : Thu Jan 21 11:41:38 CET 2016
# copyright : (C) 2002 Jure Zbontar
#
##############################################################################
#
# 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.
#
##############################################################################

ROBOT = jz
MODULE = ${ROBOT}.so
MODULEDIR = drivers/${ROBOT}
SOURCES = ${ROBOT}.cpp

SHIPDIR = drivers/${ROBOT}
SHIP = ${ROBOT}.xml pw-imprezawrc.rgb logo.rgb
SHIPSUBDIRS =

PKGSUBDIRS = ${SHIPSUBDIRS}
src-robots-jz_PKGFILES = $(shell find * -maxdepth 0 -type f -print)
src-robots-jz_PKGDIR = ${PACKAGE}-${VERSION}/$(subst ${TORCS_BASE},,$(shell pwd))

include ${MAKE_DEFAULT}
119 changes: 119 additions & 0 deletions src/drivers/jz/jz.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/***************************************************************************
file : jz.cpp
created : Thu Jan 21 11:41:38 CET 2016
copyright : (C) 2002 Jure Zbontar
***************************************************************************/

/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifdef _WIN32
#include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <tgf.h>
#include <track.h>
#include <car.h>
#include <raceman.h>
#include <robottools.h>
#include <robot.h>

static tTrack *curTrack;

static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s);
static void newrace(int index, tCarElt* car, tSituation *s);
static void drive(int index, tCarElt* car, tSituation *s);
static void endrace(int index, tCarElt *car, tSituation *s);
static void shutdown(int index);
static int InitFuncPt(int index, void *pt);


/*
* Module entry point
*/
extern "C" int
jz(tModInfo *modInfo)
{
memset(modInfo, 0, 10*sizeof(tModInfo));

modInfo->name = strdup("jz"); /* name of the module (short) */
modInfo->desc = strdup(""); /* description of the module (can be long) */
modInfo->fctInit = InitFuncPt; /* init function */
modInfo->gfId = ROB_IDENT; /* supported framework version */
modInfo->index = 1;

return 0;
}

/* Module interface initialization. */
static int
InitFuncPt(int index, void *pt)
{
tRobotItf *itf = (tRobotItf *)pt;

itf->rbNewTrack = initTrack; /* Give the robot the track view called */
/* for every track change or new race */
itf->rbNewRace = newrace; /* Start a new race */
itf->rbDrive = drive; /* Drive during race */
itf->rbPitCmd = NULL;
itf->rbEndRace = endrace; /* End of the current race */
itf->rbShutdown = shutdown; /* Called before the module is unloaded */
itf->index = index; /* Index used if multiple interfaces */
return 0;
}

/* Called for every track change or new race. */
static void
initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s)
{
curTrack = track;
*carParmHandle = NULL;
}

/* Start a new race. */
static void
newrace(int index, tCarElt* car, tSituation *s)
{
}

/* Drive during race. */
static void
drive(int index, tCarElt* car, tSituation *s)
{
memset((void *)&car->ctrl, 0, sizeof(tCarCtrl));
car->ctrl.brakeCmd = 1.0; /* all brakes on ... */
/*
* add the driving code here to modify the
* car->_steerCmd
* car->_accelCmd
* car->_brakeCmd
* car->_gearCmd
* car->_clutchCmd
*/
}

/* End of the current race */
static void
endrace(int index, tCarElt *car, tSituation *s)
{
}

/* Called before the module is unloaded */
static void
shutdown(int index)
{
}

19 changes: 19 additions & 0 deletions src/drivers/jz/jz.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
;
; file : jz.def
; created : Thu Jan 21 11:41:38 CET 2016
; copyright : (C) 2002 Jure Zbontar
;
;
; 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.
;

LIBRARY jz

SECTIONS .data READ WRITE

EXPORTS
jz

Loading

0 comments on commit 9206609

Please sign in to comment.