Standard escape codes are prefixed with Escape:
- Ctrl-Key:
^[ - Octal:
\033 - Unicode:
\u001b - Hexadecimal:
\x1B - Decimal:
27
| // color1 and color2 are R4G4B4 12bit RGB color values, alpha is 0-255 | |
| uint16_t blend_12bit( uint16_t color1, uint16_t color2, uint8_t alpha ) { | |
| uint64_t c1 = (uint64_t) color1; | |
| uint64_t c2 = (uint64_t) color2; | |
| uint64_t a = (uint64_t)( alpha >> 4 ); | |
| // bit magic to alpha blend R G B with single mul | |
| c1 = ( c1 | ( c1 << 12 ) ) & 0x0f0f0f; | |
| c2 = ( c2 | ( c2 << 12 ) ) & 0x0f0f0f; | |
| uint32_t o = ( ( ( ( c2 - c1 ) * a ) >> 4 ) + c1 ) & 0x0f0f0f; |
Memory Optimization (Christer Ericson, GDC 2003)
http://realtimecollisiondetection.net/pubs/GDC03_Ericson_Memory_Optimization.ppt
Cache coherency primer (Fabian Giesen)
https://fgiesen.wordpress.com/2014/07/07/cache-coherency/
Code Clinic 2015: How to Write Code the Compiler Can Actually Optimize (Mike Acton)
http://gdcvault.com/play/1021866/Code-Clinic-2015-How-to
| /* | |
| Packet sniffer using libpcap library | |
| */ | |
| #include<pcap.h> | |
| #include<stdio.h> | |
| #include<stdlib.h> // for exit() | |
| #include<string.h> //for memset | |
| #include<sys/socket.h> | |
| #include<arpa/inet.h> // for inet_ntoa() |
| // Exemplo de geração de números aleatórios | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <time.h> | |
| /* | |
| A função gerar_numero() retorna um número aleatório | |
| que pertence ao intervalo [lim_inf, lim_sup] | |
| // Credits: | |
| // Omar Mohammad. Maadi, Cairo, Egypt. (Original in Assembly) | |
| // Wagner Teixeira | |
| // Fred Nora | |
| //================================================================================== | |
| // Start - testing update_mouse | |
| //================================================================================== | |
| #define MOUSE_LEFT_BTN 0x01 |
| void | |
| refresh_rectangle ( unsigned long x, | |
| unsigned long y, | |
| unsigned long width, | |
| unsigned long height ) | |
| { | |
| void *p = (void *) FRONTBUFFER_ADDRESS; | |
| const void *q = (const void*) BACKBUFFER_ADDRESS; | |
| //#TEST |
| void *CreatePageDirectory (){ | |
| int i; | |
| unsigned long destAddressVA; //virtual. | |
| //alocaremos uma página apenas, pois tem 4KB. | |
| destAddressVA = (unsigned long) newPage (); | |
| if ( destAddressVA == 0 ) |
| unsigned long | |
| virtual_to_physical( unsigned long virtual_address, | |
| unsigned long dir_address ) | |
| { | |
| unsigned long address; | |
| unsigned long *dir = (unsigned long *) dir_address; | |
| unsigned long tmp; |