X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_head.h;h=d2619eb6546287df70d013bf09a64bd97e47841d;hb=a565be31ce92d6168ae6983042da75b0b683e52b;hp=87c70cf6e4c108b54fac0be22df6537dc998e763;hpb=9a04e5d11893c0b48a341fa8829e4924e68c08a4;p=16.git diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 87c70cf6..d2619eb6 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -1,5 +1,5 @@ /* Project 16 Source Code~ - * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669 + * Copyright (C) 2012-2019 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover * * This file is part of Project 16. * @@ -20,35 +20,44 @@ * */ -#if !defined(__LARGE__) && !defined(__COMPACT__) && !defined(__HUGE__) -#error Invalid memory model for compiling project 16 -#endif +//#if !defined(__LARGE__) && !defined(__COMPACT__) && !defined(__HUGE__) +//#error Invalid memory model for compiling project 16 +//#endif #if !defined(__i86__) && defined(__i386__) #error i8088 only #endif -#ifndef _LIBHEAD_H_ -#define _LIBHEAD_H_ +#ifndef __16_HEAD_H__ +#define __16_HEAD_H__ #include #include #include -#include // just for wait +#include // this is where Open Watcom hides the outp() etc. functions // just for wait #include // just for wait -#include #include #include #include #include #include #include +#include +#include +#include #ifdef __WATCOMC__ #include #include #include +#include //16_vrs.h +#endif +#ifdef __BORLANDC__ +#include +#include +#define TILEWH 16 #endif +#include "src/lib/16_t.h" +#include "src/lib/16_tdef.h" #include "src/lib/nyan/kitten.h" -#include "src/lib/types.h" #define VERSION __DATE__ " " __TIME__ @@ -144,68 +153,100 @@ #define KEY_MENU (0x75) */ -static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ +//static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ extern int profilehandle,debughandle; //make it into game global -#define __DEBUG__ +//#define OLD16_VL #define nil ((void *)0) -#ifdef __BORLANDC__ -#define _FCORELEFT 0x90000UL-16UL -#endif + #ifdef __WATCOMC__ -#define _FCORELEFT 0x90000UL+16UL +//----#define _FCORELEFT 0x90000UL+16UL +extern union REGS CPURegs; -#define peekb(segm,ofs) (*(byte far*)MK_FP((segm),(ofs))) -#define peekw(segm,ofs) (*(word far*)MK_FP((segm),(ofs))) -#define pokeb(segm,ofs,value) (peekb((segm),(ofs)) = (byte)(value)) -#define pokew(segm,ofs,value) (peekw((segm),(ofs)) = (word)(value)) +#define _AX CPURegs.x.ax +#define _BX CPURegs.x.bx +#define _CX CPURegs.x.cx +#define _DX CPURegs.x.dx -typedef union REGPACK regs_t; -#endif +#define _SI CPURegs.x.si +#define _DI CPURegs.x.di -#ifdef __WATCOMC__ -typedef void __based(__self) * memptr; -#endif -#ifdef __BORLANDC__ -typedef void _seg * memptr; -#endif +#define _AH CPURegs.h.ah +#define _AL CPURegs.h.al +#define _BH CPURegs.h.bh +#define _BL CPURegs.h.bl +#define _CH CPURegs.h.ch +#define _CL CPURegs.h.cl +#define _DH CPURegs.h.dh +#define _DL CPURegs.h.dl + +#define _CFLAG CPURegs.x.cflag + +#define geninterrupt(n) int86(n,&CPURegs,&CPURegs); -typedef struct -{ -// int showmemhandle; - int profilehandle,debughandle; - int heaphandle; -} handle_t; - -typedef struct -{ - word frames_per_second; - clock_t t; - dword tiku; //frames passed - word clock_start; //timer start - word *clock; //current time on clock - boolean fpscap; //cap the fps var -} kurokku_t; - -typedef struct -{ - long old_mode; //old video mode before game! -} video_t; - -typedef struct -{ - video_t video; // video settings variable - byte *pee; // message for fps - handle_t handle; //handles for file logging - kurokku_t kurokku; //clock struct -} global_game_variables_t; - -/* local function */ -void wait(clock_t wait); +typedef union REGPACK regs_t; +#endif + +// local function // long int filesize(FILE *fp); +void clrstdin(); +char *remove_ext(char* mystr, char dot, char sep); +void rotateR(byte arr[], byte n); +void rotateL(byte arr[], byte n); void printmeminfoline(byte *strc, const byte *pee, size_t h_total, size_t h_used, size_t h_free); int US_CheckParm(char *parm,char **strings); - -#endif/*_LIBHEAD_H_*/ +byte dirchar(byte in); +void print_mem(void const *vp, size_t n); +void hres (void); +void regidump(); + +//from https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format +//printf("Leading text "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(byte)); +//For multi-byte types +//printf("m: "BYTE_TO_BINARY_PATTERN" "BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(m>>8), BYTE_TO_BINARY(m)); +#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" +#define BYTE_TO_BINARY(byte) \ + (byte & 0x80 ? '1' : '0'), \ + (byte & 0x40 ? '1' : '0'), \ + (byte & 0x20 ? '1' : '0'), \ + (byte & 0x10 ? '1' : '0'), \ + (byte & 0x08 ? '1' : '0'), \ + (byte & 0x04 ? '1' : '0'), \ + (byte & 0x02 ? '1' : '0'), \ + (byte & 0x01 ? '1' : '0') + +#define WORD_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c" +#define WORD_TO_BINARY(word) \ + (word & 0x8000 ? '1' : '0'), \ + (word & 0x4000 ? '1' : '0'), \ + (word & 0x2000 ? '1' : '0'), \ + (word & 0x1000 ? '1' : '0'), \ + (word & 0x0800 ? '1' : '0'), \ + (word & 0x0400 ? '1' : '0'), \ + (word & 0x0200 ? '1' : '0'), \ + (word & 0x0100 ? '1' : '0'), \ + (word & 0x0080 ? '1' : '0'), \ + (word & 0x0040 ? '1' : '0'), \ + (word & 0x0020 ? '1' : '0'), \ + (word & 0x0010 ? '1' : '0'), \ + (word & 0x0008 ? '1' : '0'), \ + (word & 0x0004 ? '1' : '0'), \ + (word & 0x0002 ? '1' : '0'), \ + (word & 0x0001 ? '1' : '0') + +#define NIBBLE_TO_BINARY_PATTERN "%c%c%c%c" +#define NIBBLE_TO_BINARY(nibble) \ + (nibble & 0x08 ? '1' : '0'), \ + (nibble & 0x04 ? '1' : '0'), \ + (nibble & 0x02 ? '1' : '0'), \ + (nibble & 0x01 ? '1' : '0') + +#define BOOLEAN_TO_BINARY_PATTERN "%c" +#define BOOLEAN_TO_BINARY(boolean) \ + (boolean & 0x01 ? '1' : '0') + +#define PRINT_OPAQUE_STRUCT(p) print_mem((p), sizeof(*(p))) + +#endif/*__16_HEAD_H__*/