Thanks for using Compiler Explorer
C++
LLVM IR
MLIR
Cppx
Cppx-Gold
Cppx-Blue
C
OpenCL C
C++ for OpenCL
Rust
D
Erlang
Go
ispc
Haskell
Java
Kotlin
Scala
OCaml
Python
Swift
Pascal
Fortran
Assembly
Analysis
CUDA C++
Zig
Clean
Ada
Nim
Crystal
C++ (Circle)
Ruby
CMake
C#
F#
Visual Basic
Dart
TypeScript Native
Solidity
c++ source #1
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
g++-10.2.0-elf
g++-11.2.0-elf
g++-11.2.1b
g++-4.3.2-elf
g++-4.9.4-elf
g++-6.5.0-elf
g++-6.5.0b
Options
Source code
#include <math.h> #include <stdint.h> #include <string.h> #include <stdlib.h> #include <SDI_compiler.h> #define MULSL(a,b) \ "fmove.l " #b ",fp0" "\n\t" \ "muls.l " #a "," #b "\n\t" \ "bvc.b 1f" "\n\t" \ "fmul.s #796917760,fp0" "\n\t" \ "fmul.l " #a ",fp0" "\n\t" \ "fmove.l fp0," #a "\n\t" \ "bra.b 2f" "\n\t" \ "1:" "\n\t" \ "smi " #a "\n\t" \ "extb.l " #a "\n\t" \ "2:" #define MULSL_CLOBBER "fp0", #define DIVSL(a,b,c) \ "tst.l " #b "\n\t" \ "bne.b 2f" "\n\t" \ "tst.l " #c "\n\t" \ "blt.b 2f" "\n\t" \ "divs.l " #a "," #c "\n\t" \ "bra.b 3f" "\n\t" \ "2:" "\n\t" \ "fmove.l " #b ",fp0" "\n\t" \ "fmul.s #1333788672,fp0" "\n\t" \ "fmove.l " #c ",fp1" "\n\t" \ "tst.l " #c "\n\t" \ "bge.b 1f" "\n\t" \ "fadd.s #1333788672,fp1" "\n\t" \ "1:" "\n\t" \ "fadd.x fp1,fp0" "\n\t" \ "fdiv.l " #a ",fp0" "\n\t" \ "fintrz.x fp0" "\n\t" \ "fmove.l fp0," #c "\n\t" \ "3:" #define DIVSL_CLOBBER "fp0", "fp1", #define MULSCALESB(x) \ static inline int mulscale##x(int eax, int edx) __attribute__((always_inline)); \ static inline int mulscale##x(int eax, int edx) \ { \ register int _eax asm("d0") = eax; \ register int _edx asm("d1") = edx; \ asm volatile ( \ MULSL(d1,d0) "\n\t" \ "moveq #" #x ",d3" "\n\t" \ "moveq #32-" #x ",d2" "\n\t" \ "lsr.l d3,d0" "\n\t" \ "lsl.l d2,d1" "\n\t" \ "or.l d1,d0" \ : "=r" (_eax), "=r" (_edx) \ : "r" (_eax), "r" (_edx) \ : MULSL_CLOBBER "d2", "d3", "cc" \ ); \ return _eax; \ } MULSCALESB(16) extern void setupvlineasm(REG(d0,int)); extern int vlineasm1(REG(d0,int),REG(a0,void *),REG(d1,int),REG(d2,int),REG(a1,void *),REG(a2,void *)); extern int asm1, asm2, asm4, fpuasm, globalx3, globaly3; extern intptr_t asm3; /*static*/ extern int glogx, glogy, gbxinc, gbyinc, gpinc; /*static*/ extern unsigned char *gbuf, *gpal, *ghlinepal, *gtrans; #define EXTERN extern #define MAXXDIM 1600 #define MAXYDIM 1200 #define MAXTILES 4096 #define MAXPALOOKUPS 256 EXTERN int xdim, ydim, ylookup[MAXYDIM+1], numpages; EXTERN int yxaspect, xyaspect, pixelaspect, widescreen, tallscreen, viewingrange; extern int globalshade; extern short globalpicnum; extern int globalx1, globaly2; extern int globalorientation; extern char pow2char[8]; extern int pow2long[32]; extern int xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen, ydimenscale; extern unsigned char picsiz[MAXTILES]; extern int globalpal, cosglobalang, singlobalang; extern short umost[MAXXDIM], dmost[MAXXDIM]; extern int xres, yres, bpp, fullscreen, bytesperline, imageSize; EXTERN short tilesizx[MAXTILES], tilesizy[MAXTILES]; EXTERN unsigned char walock[MAXTILES]; EXTERN int numtiles, picanm[MAXTILES]; EXTERN intptr_t waloff[MAXTILES]; EXTERN unsigned char gotpic[(MAXTILES+7)>>3]; EXTERN unsigned char *palookup[MAXPALOOKUPS]; extern unsigned char globalxshift, globalyshift; extern int globalxpanning, globalypanning, globalshade; extern short globalpicnum, globalshiftval; extern int globalzd, globalyscale, globalorientation; extern int globalposx, globalposy, globalposz, globalhoriz; extern int globaluclip, globaldclip, globvis; extern intptr_t frameoffset; EXTERN short numpalookups; #ifndef min # define min(a,b) ( ((a) < (b)) ? (a) : (b) ) #endif #ifndef max # define max(a,b) ( ((a) > (b)) ? (a) : (b) ) #endif void faketimerhandler(void); void loadtile(short tilenume); static inline void setgotpic(int tilenume) { if (walock[tilenume] < 200) walock[tilenume] = 199; gotpic[tilenume>>3] |= pow2char[tilenume&7]; } //#define ENGINE_19960925 static inline int getpalookup(int davis, int dashade) { #ifdef ENGINE_19960925 int32_t qgetpalookup(int32_t a1, int32_t a2); return qgetpalookup(davis, dashade); #else return(min(max(dashade+(davis>>8),0),numpalookups-1)); #endif } /*static*/ void wallscan(int x1, int x2, short *uwal, short *dwal, int *swal, int *lwal) { int x, xnice, ynice; intptr_t i, fpalookup; int y1ve[4], y2ve[4], u4, d4, z, tsizx, tsizy; char bad; if (x2 >= xdim) x2 = xdim-1; tsizx = tilesizx[globalpicnum]; tsizy = tilesizy[globalpicnum]; setgotpic(globalpicnum); if ((tsizx <= 0) || (tsizy <= 0)) return; if ((uwal[x1] > ydimen) && (uwal[x2] > ydimen)) return; if ((dwal[x1] < 0) && (dwal[x2] < 0)) return; if (waloff[globalpicnum] == 0) loadtile(globalpicnum); xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx); if (xnice) tsizx--; ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy); if (ynice) tsizy = (picsiz[globalpicnum]>>4); fpalookup = (intptr_t)palookup[globalpal]; setupvlineasm(globalshiftval); const int mypalookups = numpalookups-1; const int myvis = globvis; const int myshade = globalshade; const int myxpanning = globalxpanning; const int myyscale = globalyscale; const int myzd = globalzd; const int myhoriz = globalhoriz; const intptr_t myframeoffset = frameoffset; const intptr_t mywaloff = waloff[globalpicnum]; const int mybpl = bytesperline; intptr_t mypalookupoffse, mybufplce; int myvince, myvplce; for(x=x1;x<=x2;x++) { y1ve[0] = max(uwal[x],umost[x]); y2ve[0] = min(dwal[x],dmost[x]); if (y2ve[0] <= y1ve[0]) continue; //palookupoffse[0] = fpalookup+(getpalookup((int)mulscale16(swal[x],globvis),globalshade)<<8); const int mywalvis = myshade+((int)mulscale16(swal[x],myvis)>>8); mypalookupoffse = fpalookup+(min(max(mywalvis,0),mypalookups)<<8); mybufplce = lwal[x] + myxpanning; if (mybufplce >= tsizx) { if (xnice == 0) mybufplce %= tsizx; else mybufplce &= tsizx; } if (ynice == 0) mybufplce *= tsizy; else mybufplce <<= tsizy; myvince = swal[x]*myyscale; myvplce = myzd + myvince*(y1ve[0]-myhoriz+1); vlineasm1(myvince,(void *)mypalookupoffse,y2ve[0]-y1ve[0]-1,myvplce,(void *)(mybufplce+mywaloff),(void *)(x+myframeoffset+mybpl*y1ve[0])); } faketimerhandler(); }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree