This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
acsim_toolbox_c [2006/08/01 20:27] audiocommander created v.0.0.5 |
acsim_toolbox_c [2007/11/17 16:48] smashtv move acsim.zip to "acsim" namespace |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | This page is part of the [[mios_c_simulator_-_debugger]] | ||
- | [[acsim_console_h|ACSim_console.h]]\\ | ||
- | [[acsim_console_c|ACSim_console.c]]\\ | ||
- | |||
- | **[[acsim_toolbox_c|ACSim_toolbox.c]]**\\ | ||
- | |||
- | [[acsim_mios_h|ACSim_mios.h]]\\ | ||
- | [[acsim_mios_c|ACSim_mios.c]]\\ | ||
- | |||
- | \\ | ||
- | <code c> | ||
- | /* | ||
- | * ACSim_toolbox.c | ||
- | * v 0.0.5 | ||
- | * | ||
- | * 2006 April 17 Created by Michael Markert, audiocommander.de | ||
- | * Copyright 2006 Michael Markert, http://www.audiocommander.de | ||
- | * hexview based on publicdomain code: http://www.eggdrop.ch/texts/cschnipsel/ | ||
- | * toolbox for mios: http://www.midibox.org | ||
- | * | ||
- | */ | ||
- | |||
- | /* | ||
- | * Released under GNU General Public License | ||
- | * http://www.gnu.org/licenses/gpl.html | ||
- | * | ||
- | * This program is free software; you can redistribute it and/or modify it under the terms | ||
- | * of the GNU General Public License as published by the Free Software Foundation | ||
- | * | ||
- | * YOU ARE ALLOWED TO COPY AND CHANGE | ||
- | * BUT YOU MUST RELEASE THE SOURCE TOO (UNDER GNU GPL) IF YOU RELEASE YOUR PRODUCT | ||
- | * YOU ARE NOT ALLOWED NOT USE IT WITHIN PROPRIETARY CLOSED-SOURCE PROJECTS | ||
- | */ | ||
- | |||
- | |||
- | #import <Stdio.h> | ||
- | |||
- | |||
- | #ifndef _ACSIM_TOOLBOX_C | ||
- | #define _ACSIM_TOOLBOX_C | ||
- | |||
- | |||
- | |||
- | |||
- | #pragma mark random numbers | ||
- | // generate some random numbers | ||
- | unsigned char ACRandomBool(void) { return (random() % 2); } | ||
- | signed char ACRandomEncoder(void) { return ((random() % 2) ? -1 : 1 ); } | ||
- | unsigned char ACRandomPin(void) { return (random() % DEBUG_AIN_NUM); } | ||
- | unsigned char ACRandomChar(void) { return (random() % 128); } | ||
- | unsigned int ACRandomInt(void) { return (random() % 1024); } | ||
- | |||
- | |||
- | |||
- | |||
- | #pragma mark HEXVIEW | ||
- | // hexview output | ||
- | #define HEXVIEW_COLUMNS 68 | ||
- | #define HEXVIEW_CHARS ((HEXVIEW_COLUMNS-1)/4) | ||
- | |||
- | void hexview(unsigned char *buf, int size) { | ||
- | /* usage: | ||
- | char buf[256]; | ||
- | strcpy(buf, "some data"); | ||
- | hexview(buf, sizeof(buf)); */ | ||
- | |||
- | int i; | ||
- | unsigned char c; | ||
- | |||
- | while (size>0) { | ||
- | for (i=0;i<HEXVIEW_CHARS;i++) { | ||
- | if (size-i>0) { | ||
- | printf("%02x ", (unsigned char)*(buf+i)); | ||
- | } else { | ||
- | printf(" "); | ||
- | } | ||
- | } | ||
- | printf(" "); | ||
- | for (i=0;i<HEXVIEW_CHARS&&size-i>0;i++) { | ||
- | c = (unsigned char)*(buf+i); | ||
- | printf("%c", c>=32&&c<127 ? c : '.'); | ||
- | } | ||
- | buf+=HEXVIEW_CHARS; | ||
- | size-=HEXVIEW_CHARS; | ||
- | printf("\n"); | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | #endif /* _ACSIM_TOOLBOX_C */ | ||
- | </code> |