This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of the TI BASIC PRNG | |
* | |
* Copyright (C) 2009, Tim Hentenaar | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* 1. Redistributions of source code must retain the above copyright notice, this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAND: | |
LI R4,>6FE5 ; R4 = >6fe5 | |
MPY @>83C0,R4 ; R4,R5 = R4 × @>83C0 (initially >3567 when BASIC loads) | |
AI R5,>7AB9 ; R5 += >7ab9 | |
MOV *R5,@>83C0 ; R5 -> @>83C0 | |
MOVB R13,R6 ; 'm' (>64 when called from BASIC) -> R6 | |
SRL R6,8 ; R6 & 0xff | |
INC R6 ; R6++ (prevent division by zero) | |
CLR R4 ; R4 = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4F00: ST @>834A,>3F ; Zero loop counter: >3F (63) | |
4F03: ST @>8310,>4B ; Number buffer address: >834B | |
4F06: RAND >63 ; Get a pseudo-random number (using 100 as the divisor) | |
4F08: CZ @>8378 ; If then number isn't zero, goto >4F16 | |
4F0A: BR >4F16 | |
4F0C: DEC @>834A ; Decrement the zero loop counter | |
4F0E: CZ @>834A ; If the zero loop counter is 0, goto >4F23 (return 0) | |
4F10: BS >4F23 | |
4F12: BR >4F06 ; Otherwise, continue the loop | |
4F14: RAND >63 ; Get the next pseudo-random number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint16_t seed; | |
/* RAND: Generate an 8-bit pseudo-random number */ | |
uint8_t gpl_rand(uint8_t divisor) { | |
/* Update the seed */ | |
seed = ((uint32_t)(seed * 0x6fe5) & 0xffff) + 0x7ab9; | |
/* Swap bytes, and compute modulus */ | |
return ((((seed & 0xff00) >> 8 ) | ((seed & 0x00ff) << 8 )) % (!divisor ? 1 : divisor)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Equivalent to PRINT RND in TI Basic */ | |
char *rnd() { | |
uint8_t rnds[7]; int i; char *n; | |
/* Try up to 64 times to come up with a non-zero pseudo-random integer */ | |
for (i=0;i<63;i++) if ((rnds[0] = gpl_rand(100)) != 0) break; | |
if (rnds[0] == 0) return strdup("0"); | |
/* Generate the rest of the set */ | |
for (i=1;i<7;i++) rnds[i] = gpl_rand(100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Brightness script for the ASUS G74SX | |
# | |
# Arguments: | |
# up - increase brightness by 1 | |
# down - decrease brightness by 1 | |
# | |
BRIGHTNESS=`cat /sys/devices/platform/asus-nb-wmi/leds/asus\:\:kbd_backlight/brightness` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; DOS 6+ Fix for PC/GEOS 1.x | |
; (and an example of an extremely simply file patcher) | |
; | |
; Copyright (C) 2013 Tim Hentenaar, http://hentenaar.com | |
; All rights reserved. | |
; | |
; Redistribution and use in source and binary forms, with or without | |
; modification, are permitted provided that the following conditions are met: | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Import text/calendar files from mutt | |
# to calcurse. | |
# | |
# Make sure calcurse is running | |
if [ ! -f "$HOME/.calcurse/.calcurse.pid" ]; then | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple echo server | |
* | |
* This program listens for connections on the | |
* loopback interface, on port 9999. Upon connecting, | |
* The first line we read, of up to BUF_LEN bytes, is | |
* then sent back to the sender, and the connection | |
* is closed. | |
*/ | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple echo server | |
* | |
* This program listens for connections on the | |
* loopback interface, on port 9999. Upon connecting, | |
* The first line we read, of up to BUF_LEN bytes, is | |
* then sent back to the sender, and the connection | |
* is closed. | |
* | |
* Refactor #1 - Move socket creation code into its own |
OlderNewer