dreamcast fighting game v0.2.4
by
jimbo : dcfighting source
Dan Potter and Jordan DeLong of Cryptic Allusion : KallistiOS version 1.1.6
Andrew Kieschnick of Napalm-X : dcloadip including dc-tool
Marcus Comstedt : maple and hardware info including scramble.c
Joerg Schilling : Schily's USER COMMANDS cdparanoia mkisofs cdrecord
Bjarne Stroustrup : the C language
SEGA/HITACHI/NEC : the cool hardware
Baltimore Gas & Electric: the electricity that powers it

thanks to Lyonhrt for the captures of v0.1.0: fighter1.jpg    fighter2.jpg    fighter3.jpg   


links:
IP.BIN - this one should work for you. looks for 1STREAD.BIN
dcfg022.nrg - 1732k - working nero image of version 0.2.2
dcfight020.nrg - 1768k - working nero image of version 0.2.0
dcf-0.1.8.nrg - 1732k - Nero image of dcfighting-0.1.8
mosh - the 3d development shell used to create the models in dcfighting

mosh tutorial - learn to model with mosh

   fighter_hand.mosh
  fighter_arm.mosh
 fighter_torso.mosh
   fighter_leg.mosh
  fighter_hips.mosh
fighter_carriage.mosh



linux starter page
unix/*nix cheat sheet - 8k - contains a list of useful commands.



latest: Fri Feb 15 15:31:28 EST 2002 dcfighting-0.2.4.tar.gz - 165k
Fri Feb 15 17:58:36 EST 2002
found a bug in pause condition when only ine controller is in...
 originally pointed out to me by Malakai.
  heres the old and the new code...

    /* v0.2.2: pause/menu condition
     * v0.2.41: fixed for one controller bug.
     *
     *
     if (   (!(cond.buttons & CONT_START)) 
     ||
     (!(cond2.buttons & CONT_START))    ) {
     */
    if (    (!(cond.buttons & CONT_START)) 
	    ||
	    ( 
	      ( player_count >= 2 ) 
	       && 
	      (!(cond2.buttons & CONT_START))   
	    )
       ) {

apparently an uninitialized cond2... i dont know.
 now the condition is fixed for 1 and 2 controllers. 

also tweaked the menu code(changed X to decrement camera_follow)
 and added instruction text to menu.

Thu Feb 14 15:10:25 EST 2002
check this out; its starting to look good.

adding height logic into fighting(high,mid,low).
 new moves: 
 - be_hit_middle
 - mid_reverse   DownX
 - knee          DownY
 - uppercut      UpX

added options to pause menu:
 - use stamina 
 - players 1/2
 - reset

added new camera modes:
 - static position, static focus (where it was when you set camera follow to 1)
 - static position, moving focus (10,3,10)
 - static position, moving focus overhead at (7,7,7)


next:
make stamina recharge more quickly when not moving.
 and keep score.
  and variable recoil for blocked/successful attacks - more for kick than jab.
   move numbers into dcf_globals.c - turn them into variables from constants.
    change blocking logic so you can hold A for optimal defense(blocking anyway...)
     getting a lot of exceptions just from pressing A.
      the camera follow works in most conditions, but fails near the corners for whatever reason...
       and the scramble makefile target dependency.

  add idle motion: 
   call after animation and consequence:
    if future list is empty, move particular parameters from fighting stance 1 to fs2.
     - like a breathing, rocking motion

  add partial presets:
   make fighters walk around the ring rather than slide.
    contiguous subs will make the most convenient partials, as the start and end of the anchor can be represented
     in the anchor pseudo-struct, or OFFSET_HACK




code:
dcf_animation.c
dcf_consequence.c
dcf_control.c
dcf_fighter.c
dcf_globals.c
dcf_mainloop.c
dcf_player.c


heres how to make a new fighter:
 - load the file in mosh    (./mosh fighter_carriage.mosh)
 - use the EXPORT command   (type export dcf_fighter.c)
 - copy the exported c file into dcfighting dir.  (cp ../../mosh/dcf_fighter.c)    .
 - hack in the + rotation for p[37] to make the fighters point at each other.
 - check the SPACIAL_OFFSET
 - make run

Thu Feb  7 22:17:48 EST 2002
should add logic to determine the speed of controller sequence...
 do a move too slowly and it wont count(add blanks into history repeatedly).
trying to integrate the old and new fighter code... have them fight each other.
 running into a logical wall: 
  dcf_fighter.c:87: previous declaration of `reverse_out'
  dcf_fighter2.c:623: redefinition of `round_kick_connect3'
  ...
   array names cannot be redeclared, at least in global space.
    a c++ class structure might clean this up - class statics... or structs perhaps...
     it needs to be able to store a bunch of static arrays, which are declared in the mosh-generated c source file.
      each fighter has different presets.
       but they are all unified in their abstract move capabilities - each can jab, reverse, kick, etc.
        the translation from MOVE_JAB to add_anchor(jab_out...) is found in a switch statement.
         each fighter code module will require its own version of this statement: this is mosh's move strings.
          support for partial presets here is greatly desirable; also quick shorthand for referencing sub-models
           presets.
            hopefully, this source can be generated by mosh... the move strings must be able to contain preset names,
             or preferably indices so exporting code is possible...
              but even then it might have to be operator modded... timings will export, but what about fighting state?



for making dcfighting from source: you gotta hack this glewLookAt( routine into kos.
 no big deal, just paste it into kos/addons/libgl/gltrans.c

/* jimbo 2002
 *  glewLookAt - only works for up vector 0,1,0.
 *   but performs like gluLookAt for the first 6 params.
 *
 */
void glewLookAt( GLdouble eyeX,    GLdouble eyeY,    GLdouble eyeZ, 
                 GLdouble centerX, GLdouble centerY, GLdouble centerZ ) {
  GLdouble upX = 0.0;
  GLdouble upY = 1.0;
  GLdouble upZ = 0.0;  
  GLdouble x_plus_z = 1.0;

  x_plus_z = hypot( eyeX-centerX, eyeZ-centerZ );
  glRotatef( -atan2( eyeY-centerY, x_plus_z ), 1.0, 0.0, 0.0 );
  glRotatef( atan2( eyeX-centerX, eyeZ-centerZ ), 0.0, 1.0, 0.0 );
  glTranslatef( -eyeX, -eyeY, -eyeZ );
}






code abstract:
------------------
 - animation.c   add_anchor, timestep functions.
 - consequence.c combat result determination
 - control.c     human and cpu(random) controller function, incl. 3d moving code
 - draw.c        text drawing on screen, hacked from Dan's kosh example.
 - fighter.c     3d fighter model code; generated and fully modular
 - globals.c     variables and macros, vector math and texture function
 - player.c      player{struct, init routine}, combat rule #defines
 - mainloop.c :

    init kos/dc;
    init fighters;
    find controllers;

    while(1) {
      read controller
      if state == fighting     control function
      if state == fighting || victory    animation timestep
      if state == fighting || victory     consequence
      draw scene 
      (
        background
        bars
        ground
        fighters
      );
 }







combat rules :
only one type of attack:
if youre within range, the following rules apply.

 short:  jab, knee, elbow, throw 
 middle: reverse, hook, front kick
 long:   round kick, side kick

       p1       p2         result
      -------------------------------
      attack   --         p2 hit; add anchor fall_down; subtract energy...
      attack   block      --
      attack   counter    p1 hit; 
      
      throw    block      p2 hit
      throw    throw      --
      throw    attack     p1 hit
      throw    counter    p2 hit




controls:
B button: jab

X button: punches
----------------
X      - reverse punch
downX  - reverse punch to midsection
upX    - uppercut

Y button: kicks
----------------
Y      - front kick
awayY  - side kick
downY  - knee kick

A button: defense
----------------
A        - block(hold/release)
towardsA - counter

A + X Buttons - reverse stance (hold A press X)

right trigger + B button - throw


start button pauses and brings up menu:
 - up,down to change choice
 - a to toggle chosen option






improvement :

v0.2.3:
Tue Feb 12 21:36:37 EST 2002
 added victory counter in player struct so the game can keep score.
  looking a lot more game-like...
   changing the paused state variable to a more flexible run state... paused, menu, etc.
    adding #defines to dcf_globals.c.
     fixed MAX_ENERGY to work right... should probably make this a variable.



v0.2.2:
 added frame rate counter - dcfg clocks at 60fps.
  added toggle for block damage in menu.

Sun Feb 10 22:17:25 EST 2002
 - added the position[4] field to the fighter_t struct.
 - added a toggle for camera follow... 
 - added a working direction comparison in the consequence function - for attacks and blocks.
    blocks have a wider threshold than attacks; both are stored as floats in dcf_globals.c and changeable.
     the threshold represents the angular pie slice of space a fighter may successfully attack and block in.
      this angle may be more suitable as an offset angle:
       due to the humanoid fighters structure, the back is more open than the chest...



Sat Feb  9 23:59:58 EST 2002
 found the problem with the strange-looking sidekick: the design of fighter_carriage.mosh
  the x rotation was done before the y, so whether he was tilting forward or back was dependent on his orientation.
   the problem has been fixed: y rotation is now first, and z rotation has also been added.
    this 3-axis rotation around a single point could possibly give rise to gimbal lock, so i threw in a
     TRANSLATE 0.001 0.0 0.0
      just in case.


from the dcdev mailing list:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Oops, nevermind. I found the functions I needed in rtc.h. The 
function does have some strageness where most of the time it returns 
(for example) 0x000031FA but sometimes it returns 0x31FA31FA. Simply 
& with 0xFFFF and I have a working frames/sec counter. 

Apparently 60fps for a 5k poly scene seems slow because I was used 
to getting 3000fps with a minimal scene :) Though theoretically I 
should be able to get 50k at 60fps ... time for more optimization.
-Trilinear

> The time.h functions have a one-second resolution, matching that of the
> DC's internal RTC. I've got some plans to make one of the other high-res
> timers supplement this for better timing but it's not done. If you feel
> courageous you could dig in there and attempt to do so manually (look at
> kernel/arch/dreamcast/kernel/timer.c)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

thanks Trilinear
 frame rate counter added.  dcfighting v0.2.1 runs at 60fps.
  working on a menu - trying out printing in different colors.
   want to be conscious of screen size/resolution. draw a black box under the text, etc.
    the menu states themselves should be cake.


Sat Feb  9 20:04:57 EST 2002
ive been working on the modeling toolchain for this system; integrating mosh into the process.
 i feel like it would be simpler to have these models in a pseudo-text format like mosh for maximum tradability,
  portability, etc.
   right now the model itself can be stored in text as well as parameters, names, and presets.
    sub-models contain presets, which could be useful in partial anchors for moves...
     but theres going to be a need for human-coder intermediary as long as fighting states are not accounted for by mosh.
      maybe mosh could add a few fields to each entity for static "state" variables...
       variables which wouldnt need to be interpolated, but would just assume the value of the last state change.




v0.2.1: modeling pipeline : this dcf_fighter.c is totally generated.
 Thu Feb  7 00:26:17 EST 2002
 importing code successfully from mosh.
   fighter model pipeline is almost complete.
    this SPACIAL_OFFSET special spatial offset , is the one flaw in the system.
     one never knows where the spatial parameters will occur in a heirarchical model file, so this
      #define must be changed manually.
    working on stamina tweak
     added a do_move function to ease the adding of new moves.
      now control function calls this, and theres a set of #defines in dcf_control.c for each type of move.
       anchorlists reside in do_move.
        abstracting all moves into dcf_control.c for now...
         this includes the moves from the conequence function...
    - be thrown
    - stagger high hit
    - mid
    - low
    - block attack- be countered
           attack moves moved into dcf_control.c.
            the vector calculation in consequence pushes the hittee back...
             but it references the player params array directly.
              perhaps we should treat spacial params diferently... 
  thinking of moving the location info into the offset hack...nah, no interpolation there.
   grepping for params[0]...
    - animation(walls)
    - consequence(kickback)
    - control(sidestep) 
    - mainloop init
    - mainloop midpoint for camera
  so far a #define is necessary to indicate the start of the spatial parameters...
   not exactly optimal...
     first param of draw_entity() is rotation... add it the the rotation param index of the model when drawing.
  Mon Feb  4 01:45:28 EST 2002
   v0.2.0:
    still needs a lot of tweaking in the timing values (and new moves), but playable.



v0.2.0: colors, textures, playability.
   color and texture switching...
    glColor3f(1.0f, 1.0f, 1.0f);
     glBindTexture(GL_TEXTURE_2D, texture2 );
   want to:
     - fix ducking (getting exceptions)
     - tweak move speeds/strengths and stamina debts
     - work on exploiting the speed/strength tradeoff during a game...
     - new models and moves.  probably a modular design to allow for homebrew fighters.
     - at DoomraiderC's and Ralph's request: blocking while being attacked still hurts, ~1/8 as much.  make changeable...
     - OPTIONS SCREEN
   golden mean ratio: Phi = 1.618033.. and Phi2 is 2.618033.. 
    ( sqrt(5) + 1 ) / 2
     1/phi == 0.61803399
   changed the value //  p->params[7]  for  p->opponent_rotation.  better for now.
   fixed the away/towards inversion bug.  
   obj support is working in mosh... i ran a version of this with an obj hat on the fighters' heads (al.obj)...
    but it took about a minute to compile... 
   dcf_fighter.c should be entirely generated, so dont read the source(the source actually ISNT the *source*...)


v0.1.9: reboot condition ABXYStart.
       attempt to split up source for readability

       got the sidestepping in 3d down... find the vector to your opponent.
        towards will increment your position by that vector, away decrements.
	 cross the opponent vector with the up vector.
          up and down add the cross product to a players position.

       putting in directional forces... punch a guy to the north, he'll move that way.
        this should be in the consequence function, as should gravity, walls, and any other
         rule-based interactions between entities.

       better note where we scope the opponent vector... save some recalculation.
       moved the static params array to within the player struct.


v0.1.8: added stamina to moves; a constantly increasing measure of how much speed a 
         fighter can put into the next move.  this way, rapid punching will not be such
          an unfair advantage (no chinos).

        hacked the glewLookAt() routine into kos.  now fighters can easily be drawn from any
         angle, and environment integration can begin.  it is unclear whether the controller
	  function will manipulate the fighter's position directly, or it will be a once-removed
	   request/reply type event, where the consequence function (main loop) will check the 
	    fighter's position against any walls, then apply the appropriate forces to the player.

	also added 100 slow motion frames after a player is knocked out.


v0.1.7: added throws into decision logic (which is now a function, should be a macro)
         and energy into player struct.  energy is deducted on each contact in the 
          consequence function, 5 for attack, 10 for counter and 15 for throw.
   
        the spatial relations b/w characters and the floor is now really hacky...
         ill need a glutLookAt() routine to facilitate the viewing of a more 3d space
          to fight in.  shouldnt be too hard.


v0.1.6: i have been wrestling this bug that causes an exception and fatal crash only 
         when ducking.  the duck loop uses logic similar to that of the a button, detecting
          release of the button for hold moves.  but when wrapped by the condition of the left
           trigger, perhaps thigs are different... maybe thats a stretch.  i havent quite 
            isolated the bug yet.

        working on some new moves for throws, counters, falling...
         this should also require a new classification of attack, namely by range (kicks are
          longer than punches) and impact height(high,mid,low:an int).
           consequence logic will also become more complicated, as a low block is no good
            against a mid attack, but a duck puts you under a high attack...
             true collision detections might be a little out of this machine's league...
              or are they?  i guess ill have to get to Dan and Marcus on that one.

        the idea is to encapsulate all state information about an attack in an int.
         1s place:  attack range
          10s place:  attack height
           100s and more: attack strength
            the logic will take this into account, and we will have slow kicks that reach longer
             than fast punches, as well as the ability to duck under, jump over, and properly
              defend against high, middle and low blows.


v0.1.5: relative rotation(dodging)
        this version introduces the concepts of rotation to the game.  some might call it 
	 a hack at this point:
	  three rotations describe the fighting situation: the global rotation of the center 
	   line(b/w the 2 fighters), and each fighter's individual rotation about his own
	    center.  using this notation, a strafe counter-clockwise(from above) is
	     equivalent to a clockwise rotation of the opponent.  this rotation is reduced
	      instantly to 0.0 upon input from the player; maybe that should me more smooth.
	       the effect is that it is possible to sidestep completely around a player who
	        does not turn to face you.
                 additionally, a float is kept to track the fighting_distance b/w fighters, 
                  and a float[2] to keep track of global displacement, which both players 
		   can modify by strafing(dpad).

	the illusion is pretty good; check it out for yourself.


v0.1.4: fighting state
        refined the notion of fighting state to be more like a power level...
	 denotes stamina when below 100 (a la hit points) and attack power when
	  above 130; in between lie the parry,counter,block,move,stand states.
	   each timestep changes fighting_state by 1 in the direction of their
	    default state, which is set at the anchor time of each move executed.
	     so player will spring back to default.
	      fighting state is also changed by move logic; i.e.attack/block, etc.
^
|
140 throw
130 attack
115 counter
110 block
105 parry
100 standing
95  moving
90  hit
80  stunned
70  staggering
30  falling
20  kneeling
10  down

        also, counters seem to work now, although the timing intervals are going to need
	 much tweaking.  an attack duration of 0.1 timestep units(currently set at 0.02: 
	  possible aliasing) is difficult to match with counter with a 0.15 timestep
           (with the same 0.07 latency as the jab), but possible.  requires more
	    experimentation.

	oh, and no reverses or kicks this time; the logic is being rewritten to an else-if
	 block of form if (  (A) && (X)  ).  so it will check every possibility in 
	  sequence; i thought there might be a way to reduce that.  maybe later.
           besides, it looks like this chip can handle it; and this code could go a long 
	    way toward optimization.
   	     also, switch stance is now A+X.

v0.1.3: touched up interaction
        the logic for interaction has been cleaned up; now all conditionals
	 are compounds (player1==ATTACK && player2==COUNTER).  much easier to read.
	  still needs tweaking for playability; now a stunned player (just hit by
	   an attack) will have no chance to block if the opponent can
	    continuously release a flurry of short jabs(B button).
	     parry and counter should still be possible in a stagger; maybe to
	      a varying degree (you get your ass kicked harder, you have less
	       chance/opportunity to pull off a counter).

v0.1.2: interaction paradigm
        a new block of code has been added after the interpolation loop:
         right now it's a block of if s corresponding to the table below.
          using the table's logic, that loop can add and remove anchors of
	   player1 and player2 according to their states.
	    add_anchor(fighter_t,double,double*,int) now takes a state as well
	     (final parameter) and dcf_animate has a list of #define
	      enumerated possible states.

v0.1.1: fighter structs
        each player==fighter now has his own struct(2 of them currently).
         now we have 2 players in space (thanks a bunch to Dan Potter for the hint).
          there's a loop that goes through the bus and checks each against 
	   MAPLE_FUNC_CONTROLLER.  i was neglecting to call maple_create_addr(p,u) 
	   on the unit,port pairs and hence  getting unusable addresses.

             remember to call :
              c = maple_create_addr( players[0][0] , players[0][1] ); 
               before :
                if (cont_get_cond(c, &cond) < 0) 








tarballs for your downloading pleasure...
collect the whole set!
or just take the new one.

dcfighting-0.2.4.tar.gz - 165k - 1/2 player modes in menu

dcfighting-0.2.3.tar.gz - 163k - win counter next to energy bar
dcfighting-0.2.2.tar.gz - 162k
dcfighting-0.2.1.tar.gz - 169k
dcfighting-0.2.0.tar.gz - 155k - red and blue fighter on sunrise
dcfighting-0.1.9.tar.gz - 49k
dcfighting-0.1.8.tar.gz - 39k - purple/yellow fractal brain version
dcfighting-0.1.7.tar.gz - 93k - snowy spruce version
dcfighting-0.1.6.tar.gz - 89k
dcfighting-0.1.5.tar.gz - 88k - barbecue version
dcfighting-0.1.4.tar.gz - 87k - splash version
dcfighting-0.1.3.tar.gz - 77k
dcfighting-0.1.2.tar.gz - 56k
dcfighting-0.1.1.tar.gz - 53k
dcfighting-0.1.0.tar.gz - 52k - sunrise version
dcfighting-0.0.8.tar.gz - 63k

heres where i took a bunch of the pictures below out of the tarball...
these archives are gone(links broken) to save server space, available upon request...

dc_dancer-0.0.7.tar.gz - 203k
dc_dancer-0.0.6.tar.gz - 128k
dc_dancer-0.0.5.tar.gz - 124k
dc_dancer-0.0.4.tar.gz - 118k
dc_dancer-0.0.3.tar.gz - 113k
dc_dancer-0.0.2.tar.gz - 112k
dc_dancer-0.0.1.tar.gz - 111k
dc_dancer-0.0.0.tar.gz - 61k



bonus: some 256x256x256 72dpi pcx texture files
bluedragon.pcx - 13k
brain.pcx - 17k
crate.pcx - 66k
fract.pcx - 5k
roots.pcx - 37k
skull.pcx - 41k
splash.pcx - 77k
sunrise.pcx - 62k
barbecue.pcx - 73k
spruce.pcx - 73k






down the chain we go...
installation:
## standard gzipped-tarball distribution.
## the makefile calls dc-tool, which is assumed to be in your path.
## dont forget your dependencies:
##  kos-1.1.5
##  the standard dc toolchain (check the sites,BooB,etc.)
tar xvzf dcfighting-WHATEVERVERSION.tar.gz
cd dcfighting
make
  ->  
dcfighting.elf - 353k dreamcast executable
##  File format is elf32-little, start address is 0x8c010000
##  Section .text, lma 0x8c010000, size 79328
##  Section .rodata, lma 0x8c0235e0, size 83240
##  Section .data, lma 0x8c037ba0, size 11628

sh-elf-objcopy -O binary dcf_animate.elf dcf_animate.bin
  ->   dcf_animate.bin - 254k stripped executable
scramble dcf_animate.bin 1ST_READ.BIN

ready to burn
cd binary
  ->   1ST_READ.BIN - 254k scrambled dreamcast executable
         the 0.1.7 scrambled binary is untested, but expected to be good.

dd if=/dev/zero bs=2352 count=300 of=audio.raw
cdrecord dev=0,0,0 -multi -audio audio.raw

# get the x,y 0,11702
cdrecord dev=0,0,0 -msinfo

mkisofs -l -C 0,11702 -o tmp.iso 1ST_READ.BIN
( cat IP.BIN ; dd if=tmp.iso bs=2048 skip=16 ) > data.raw
cdrecord dev=0,0,0 -multi -xa1 data.raw




more stuff:
if you could tell me anything about usb drivers, character devices, mknod, 
kudzu, /proc/bus/usb/devices, /dev/input/mice, ...talk to me.  id like to have a chat.






working on adding .obj file support, but running into the same odd kernel crashes when using mosh...
 2.4.17 + nvidia2313 + Netscape 4.76/U.S. + mosh == LOCK CONDITION:
   - ps and top will freeze; not terminate when launched.
   - reboot will initiate and hang on 'stopping rstat services'
      console's dead
      cant login
      cant ssh in
       only option is a hard restart, and sitting through the file system check.
2.4.13 + nvidia1541 is even worse: X server launches and displays vertical red and black lines.
 interface locks up completely; no virtual consoles, no nothing.  reboot by ssh possible.