Changeset 524


Ignore:
Timestamp:
Apr 22, 2011, 4:12:53 AM (12 years ago)
Author:
Sam Hocevar
Message:

core: Get rid of mostly useless headers, move endianness handling to
common.h (and rewrite functions so that they do not need the SDL headers)
and move a few functions out of sdlport's video.cpp. These functions
were in the original video.cpp (which reappears) and shouldn't be part
of the SDL port.

Location:
abuse/trunk/src
Files:
1 added
3 deleted
55 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/chars.h

    r494 r524  
    1818#include "ability.h"
    1919#include "event.h"
    20 #include "macs.h"
    2120#include <stdarg.h>
    2221#include <time.h>
  • abuse/trunk/src/clisp.cpp

    r512 r524  
    1212
    1313#include <string.h>
     14#include <unistd.h>
    1415
    1516#include "common.h"
  • abuse/trunk/src/common.h

    r518 r524  
    1111#ifndef __COMMON_H__
    1212#define __COMMON_H__
     13
     14//
     15// Globally required headers
     16//
     17#include <stdint.h>
    1318
    1419//
     
    2631static inline float Max(float a, float b) { return a > b ? a : b; }
    2732
     33//
     34// Byte swapping
     35//
     36static inline int BigEndian()
     37{
     38    union { uint32_t const x; uint8_t t[4]; } const u = { 0x01ffff00 };
     39    return u.t[0];
     40}
     41
     42static inline uint16_t Swap16(uint16_t x)
     43{
     44    return ((uint16_t)x << 8 ) | ((uint16_t)x >> 8);
     45}
     46
     47static inline uint32_t Swap32(uint32_t x)
     48{
     49    return ((uint32_t)x >> 24) | (((uint32_t)x & 0x00ff0000) >> 8)
     50         | (((uint32_t)x & 0x0000ff00) << 8) | ((uint32_t)x << 24);
     51}
     52
     53#define uint16_to_intel(x) (BigEndian() ? Swap16((x)) : (x))
     54#define uint32_to_intel(x) (BigEndian() ? Swap32((x)) : (x))
     55#define big_uint16_to_local(x) (BigEndian() ? (x) : Swap16((x)))
     56#define big_uint32_to_local(x) (BigEndian() ? (x) : Swap32((x)))
     57#define uint16_to_local(x) (BigEndian() ? Swap16((x)) : (x))
     58#define uint32_to_local(x) (BigEndian() ? Swap32((x)) : (x))
     59
     60#define bltl(x) big_uint32_to_local(x)
     61#define bstl(x) big_uint16_to_local(x)
     62#define lltl(x) uint32_to_intel(x)
     63#define lstl(x) uint16_to_intel(x)
     64
     65#include <stdio.h>
     66#define ERROR(x,st) { if (!(x)) \
     67   { printf("Error on line %d of %s : %s\n", \
     68     __LINE__,__FILE__,st); exit(1); } }
     69
     70// These macros should be removed for the non-debugging version
     71#ifdef NO_CHECK
     72#   define CONDITION(x,st)
     73#   define CHECK(x)
     74#else
     75#   define CONDITION(x,st) ERROR(x,st)
     76#   define CHECK(x) CONDITION(x,"Check stop");
     77#endif
     78
    2879#endif // __COMMON_H__
    2980
  • abuse/trunk/src/compiled.cpp

    r494 r524  
    1515
    1616#include "lisp.h"
    17 #include "macs.h"
    1817
    1918extern int total_objects;
  • abuse/trunk/src/compiled.h

    r494 r524  
    1111#ifndef __COMPILED_HPP_
    1212#define __COMPILED_HPP_
    13 #include "macs.h"
     13
    1414extern int32_t S_fall_start,S_falling,S_landing,S_pounce_wait,
    1515            S_turn_around,S_fire_wait,S_ceil_fire,S_top_walk,
  • abuse/trunk/src/crc.h

    r494 r524  
    1212#define _CRC_HPP_
    1313#include "specs.h"
    14 #include "macs.h"
    1514
    1615uint16_t calc_crc(uint8_t *buf, int len);
  • abuse/trunk/src/demo.cpp

    r512 r524  
    1717#include "demo.h"
    1818#include "specs.h"
    19 #include "macs.h"
    2019#include "jwindow.h"
    2120#include "dprint.h"
  • abuse/trunk/src/extend.h

    r494 r524  
    2121#include "lisp/lisp.h"
    2222
    23 #include "macs.h"
    2423#include "morpher.h"
    2524#include "chars.h"
  • abuse/trunk/src/game.h

    r494 r524  
    1414#include "loader2.h"
    1515
    16 #include "macs.h"
    1716#include "image.h"
    1817#include "video.h"
  • abuse/trunk/src/imlib/Makefile.am

    r512 r524  
    2626    sprite.cpp sprite.h \
    2727    jwindow.cpp jwindow.h \
    28     macs.h video.h event.h mouse.h timing.h jdir.h \
    29     system.h \
     28    video.cpp video.h \
     29    event.h mouse.h timing.h jdir.h \
    3030    $(NULL)
    3131
  • abuse/trunk/src/imlib/dprint.cpp

    r494 r524  
    1515#include <stdio.h>
    1616
    17 #include "macs.h"
     17#include "common.h"
    1818
    1919void  (*dprint_fun)(char *) = NULL;
  • abuse/trunk/src/imlib/filesel.cpp

    r512 r524  
    1010
    1111#include "config.h"
     12
     13#include <unistd.h>
    1214
    1315#include "common.h"
  • abuse/trunk/src/imlib/filter.cpp

    r523 r524  
    1414
    1515#include "image.h"
    16 #include "macs.h"
    1716#include "filter.h"
    1817
  • abuse/trunk/src/imlib/glview.cpp

    r494 r524  
    1313#include <math.h>
    1414
    15 #include "macs.h"
    1615#include "mdlread.h"
    1716#include "video.h"
  • abuse/trunk/src/imlib/image.cpp

    r523 r524  
    1212
    1313#include <math.h>
    14 #ifdef __DOS
    15 #   include <dir.h>
    16 #else
    17 #   include <unistd.h>
    18 #endif
    1914#include <stdlib.h>
    2015
     
    2217
    2318#include "image.h"
    24 #include "macs.h"
    25 #include "system.h"
    26 #include "system.h"
    2719
    2820linked_list image_list; // FIXME: only jwindow.cpp needs this
  • abuse/trunk/src/imlib/image.h

    r523 r524  
    1515#include "linked.h"
    1616#include "palette.h"
    17 #include "system.h"
    1817#include "specs.h"
    1918#define MAX_DIRTY 200
  • abuse/trunk/src/imlib/input.cpp

    r512 r524  
    1616
    1717#include "input.h"
    18 #include "macs.h"
    19 
    2018
    2119void button::remap(filter *f)
  • abuse/trunk/src/imlib/palette.cpp

    r519 r524  
    1717#include "palette.h"
    1818#include "image.h"
    19 #include "macs.h"
    2019#include "video.h"
    2120#include "filter.h"
  • abuse/trunk/src/imlib/readwav.cpp

    r494 r524  
    1111#include "config.h"
    1212
     13#include "common.h"
     14
    1315#include "readwav.h"
    1416#include "specs.h"
    15 #include "macs.h"
    1617#include "dprint.h"
    1718
  • abuse/trunk/src/imlib/specs.cpp

    r512 r524  
    1717#include <fcntl.h>
    1818#include <math.h>
     19#include <unistd.h>
    1920#if (defined(__MACH__) || !defined(__APPLE__))
    2021#   include <sys/types.h>
     
    2728#include "palette.h"
    2829#include "specs.h"
    29 #include "system.h"
    3030#include "dprint.h"
    3131
  • abuse/trunk/src/imlib/specs.h

    r494 r524  
    1919
    2020#include "linked.h"
    21 #include "system.h"
    2221
    2322extern char const *spec_types[];
  • abuse/trunk/src/imlib/sprite.cpp

    r519 r524  
    1515#include "common.h"
    1616
    17 #include "macs.h"
    1817#include "video.h"
    1918#include "image.h"
  • abuse/trunk/src/imlib/sprite.h

    r494 r524  
    1111#ifndef __SPRITE_HPP
    1212#define __SPRITE_HPP
    13 #include "macs.h"
    1413#include "image.h"
    1514#include "linked.h"
  • abuse/trunk/src/imlib/status.cpp

    r512 r524  
    1515#include "common.h"
    1616
    17 #include "macs.h"
    1817#include "status.h"
    1918#include "dprint.h"
  • abuse/trunk/src/imlib/timage.h

    r521 r524  
    1313
    1414#include "image.h"
    15 #include "macs.h"
    1615#include "palette.h"
    1716#include "filter.h"
  • abuse/trunk/src/imlib/video.h

    r523 r524  
    1111#ifndef _VIDEO_HPP_
    1212#define _VIDEO_HPP_
    13 #include "system.h"
    1413
    1514#define TRI_1024x768x256 0x62
     
    3130void close_graphics();
    3231void fill_image(image *im, int x1, int y1, int x2, int y2);
     32void update_window_done();
     33
    3334void update_dirty(image *im, int xoff=0, int yoff=0);
    34 
     35void put_part_image(image *im, int x, int y, int x1, int y1, int x2, int y2);
     36void put_image(image * im, int x, int y);
    3537
    3638void clear_put_image(image *im, int x, int y);
  • abuse/trunk/src/innet.cpp

    r512 r524  
    1616
    1717#include "demo.h"
    18 #include "macs.h"
    1918#include "specs.h"
    2019#include "level.h"
  • abuse/trunk/src/intsect.cpp

    r494 r524  
    1212
    1313#include <stdlib.h>
    14 
    15 #include "macs.h"
    1614
    1715void pushback(int32_t x1,int32_t y1,int32_t &x2,int32_t &y2,
  • abuse/trunk/src/level.cpp

    r515 r524  
    1818#include <limits.h>
    1919#include <time.h>
     20#include <unistd.h>
    2021
    2122#include "common.h"
     
    3031#include "objects.h"
    3132#include "jrand.h"
    32 #include "macs.h"
    3333#include "clisp.h"
    3434#include "status.h"
  • abuse/trunk/src/level.h

    r494 r524  
    1414
    1515#include "specs.h"
    16 #include "macs.h"
    1716#include "objects.h"
    1817#include "view.h"
  • abuse/trunk/src/light.cpp

    r518 r524  
    1717#include "light.h"
    1818#include "image.h"
    19 #include "macs.h"
    2019#include "video.h"
    2120#include "palette.h"
  • abuse/trunk/src/lisp/lisp.cpp

    r512 r524  
    2929#else
    3030#   include "status.h"
    31 #   include "macs.h"
    3231#   include "specs.h"
    3332#   include "dprint.h"
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r501 r524  
    1818#ifdef NO_LIBS
    1919#include "fakelib.h"
    20 #else
    21 #include "macs.h"
    2220#endif
    2321
  • abuse/trunk/src/lisp/lisp_opt.cpp

    r494 r524  
    1313#ifdef NO_LIBS
    1414#include "fakelib.h"
    15 #else
    16 #include "macs.h"
    1715#endif
    1816
  • abuse/trunk/src/lisp/trig.cpp

    r494 r524  
    1111#include "config.h"
    1212
    13 #include "system.h"
     13#include "common.h"
    1414
    1515/* Python code to generate the tables:
  • abuse/trunk/src/net/Makefile.am

    r481 r524  
    88    sock.cpp sock.h \
    99    tcpip.cpp tcpip.h \
    10     indian.h ghandler.h undrv.h \
     10    ghandler.h undrv.h \
    1111    $(NULL)
    1212
  • abuse/trunk/src/net/engine.cpp

    r494 r524  
    1111#include "config.h"
    1212
    13 #include "indian.h"
     13#include "common.h"
     14
    1415#include "../inc/netface.h"      // net interface structures to the engine will use
    1516#include "netfile.h"
  • abuse/trunk/src/net/fileman.cpp

    r494 r524  
    1919#include <sys/stat.h>
    2020
    21 #include "macs.h"
     21#include "common.h"
    2222
    2323#include "fileman.h"
  • abuse/trunk/src/net/gserver.cpp

    r512 r524  
    2222#include "common.h"
    2323
    24 #include "system.h"
    25 #include "macs.h"
    2624#include "gserver.h"
    2725#include "netface.h"
  • abuse/trunk/src/net/netfile.cpp

    r494 r524  
    1111#include "config.h"
    1212
    13 #include "indian.h"
     13#include "common.h"
     14
    1415#include "netfile.h"
    1516#include "../inc/netface.h"
  • abuse/trunk/src/net/undrv.cpp

    r494 r524  
    2828#include <netdb.h>
    2929
    30 #include "indian.h"
     30#include "common.h"
     31
    3132#include "undrv.h"
    32 #include "../include/netface.h"      // net interface structures to the engine will use
    33 
    34 #include "../include/netface.h"
     33#include "../include/netface.h" // net interface structures the engine will use
    3534
    3635//#include "netdrv.h"
  • abuse/trunk/src/netface.h

    r494 r524  
    1414#define __NETFACE_HPP_
    1515
     16#include <stdint.h>
     17
    1618#define PACKET_MAX_SIZE 1024    // this is a game data packet (udp/ipx)
    1719#define READ_PACKET_SIZE 1024   // this is a file service packet (tcp/spx)
    1820#define NET_CRC_FILENAME "#net_crc"
    1921#define NET_STARTFILE    "netstart.spe"
    20 #include "indian.h"
     22
    2123#include <string.h>
    2224
  • abuse/trunk/src/newlight.cpp

    r518 r524  
    1515#include "light.h"
    1616#include "image.h"
    17 #include "macs.h"
    1817#include "video.h"
    1918#include "palette.h"
  • abuse/trunk/src/nfclient.cpp

    r512 r524  
    2020#include "common.h"
    2121
    22 #include "system.h"
    2322#include "netface.h"
    2423
  • abuse/trunk/src/nfserver.h

    r494 r524  
    1313
    1414#include "specs.h"
    15 #include "system.h"
    1615#include "netface.h"
    1716#include "sock.h"
  • abuse/trunk/src/particle.cpp

    r518 r524  
    1313#include "common.h"
    1414
    15 #include "macs.h"
    1615#include "particle.h"
    1716#include "view.h"
  • abuse/trunk/src/sdlport/event.cpp

    r519 r524  
    2525#include "common.h"
    2626
    27 #include "system.h"
    2827#include "image.h"
    2928#include "palette.h"
    3029#include "video.h"
    31 #include "macs.h"
    3230#include "mouse.h"
    3331#include "event.h"
  • abuse/trunk/src/sdlport/jnet.cpp

    r494 r524  
    3838
    3939#include "jnet.h"
    40 #include "macs.h"
    4140
    4241int current_sock_err;
  • abuse/trunk/src/sdlport/jnet.h

    r494 r524  
    1414#define __NET_HPP_
    1515
    16 #include "macs.h"
    1716#include "packet.h"
    1817
  • abuse/trunk/src/sdlport/video.cpp

    r523 r524  
    3636
    3737#include "filter.h"
    38 #include "system.h"
    3938#include "video.h"
    40 #include "macs.h"
    4139#include "image.h"
    4240#include "setup.h"
     
    5553#endif
    5654
    57 // Forward declarations
    58 void update_window_part(SDL_Rect *rect);
    59 void update_window_done();
     55static void update_window_part(SDL_Rect *rect);
    6056
    6157//
     
    339335
    340336//
    341 // put_image()
    342 // Draw the entire image
    343 //
    344 void put_image(image * im, int x, int y)
    345 {
    346     put_part_image(im, x, y, 0, 0, im->Size().x - 1, im->Size().y - 1);
    347 }
    348 
    349 //
    350 // update_dirty_window()
    351 // Update the dirty parts of the window
    352 //
    353 void update_dirty_window(image *im, int xoff, int yoff)
    354 {
    355     int count;
    356     dirty_rect *dr, *q;
    357     CHECK(im->m_special); // make sure the image has the ability to contain dirty areas
    358     if(im->m_special->keep_dirt == 0)
    359     {
    360         put_image(im, xoff, yoff);
    361     }
    362     else
    363     {
    364         count = im->m_special->dirties.number_nodes();
    365         if(!count)
    366             return;  // if nothing to update, return
    367         dr = (dirty_rect *)(im->m_special->dirties.first());
    368         while(count > 0)
    369         {
    370             put_part_image(im, xoff + dr->dx1, yoff + dr->dy1, dr->dx1, dr->dy1, dr->dx2 + 1, dr->dy2 + 1);
    371             q = dr;
    372             dr = (dirty_rect *)(dr->next());
    373             im->m_special->dirties.unlink(q);
    374             delete q;
    375             count--;
    376         }
    377     }
    378 }
    379 
    380 //
    381 // update_dirty()
    382 // Update the dirty parts of the image
    383 //
    384 void update_dirty(image *im, int xoff, int yoff)
    385 {
    386     update_dirty_window(im, xoff, yoff);
    387     update_window_done();
    388 }
    389 
    390 //
    391337// load()
    392338// Set the palette
     
    461407}
    462408
    463 void update_window_part(SDL_Rect *rect)
     409static void update_window_part(SDL_Rect *rect)
    464410{
    465411    // no partial blit's in case of opengl
  • abuse/trunk/src/seq.cpp

    r512 r524  
    1414
    1515#include "seq.h"
    16 #include "macs.h"
    1716#include "lisp.h"
    1817
  • abuse/trunk/src/status.cpp

    r494 r524  
    1313#include <string.h>
    1414
    15 #include "macs.h"
    1615#include "status.h"
    1716#include "dprint.h"
  • abuse/trunk/src/transp.h

    r494 r524  
    1212#define __TRANSP_HPP_
    1313#include "image.h"
    14 #include "macs.h"
    1514void transp_put(image *im, image *screen, uint8_t *table, int x, int y);
    1615
  • abuse/trunk/src/unixnfc.cpp

    r519 r524  
    2121#include <sys/fcntl.h>
    2222#include <fcntl.h>
    23 
    24 #include "system.h"
    25 #include "indian.h"
    2623
    2724#include "netface.h"
  • abuse/trunk/src/view.cpp

    r513 r524  
    1111#include "config.h"
    1212
     13#include <unistd.h>
     14
    1315#include "common.h"
    1416
    1517#include "game.h"
    1618
    17 #include "system.h"
    1819#include "view.h"
    1920#include "lisp.h"
Note: See TracChangeset for help on using the changeset viewer.