Compare commits

..

2 commits
master ... RAM

Author SHA1 Message Date
Telekatz
ce5c67e0da Adapt makefile 2017-07-05 23:28:48 +02:00
Telekatz
6202a9f8ef Reorganize repository structure 2017-07-05 22:48:01 +02:00
242 changed files with 3896 additions and 34640 deletions

78
.cproject Normal file
View file

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.481883884">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.481883884" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration buildProperties="" description="" id="0.481883884" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.481883884." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1715436414" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1715436414.885904395" name=""/>
<builder id="org.eclipse.cdt.build.core.settings.default.builder.1224554298" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.736682923" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1273008438" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.937300672" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.772385457" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1269038295" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.2137323592" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1752191090" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Boop.null.506503339" name="Boop"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.481883884">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="debug" path="boop/trunk" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>debug</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="boop/trunk" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="program" path="boop/trunk" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>program</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>
</storageModule>
</cproject>

File diff suppressed because it is too large Load diff

View file

@ -1,176 +0,0 @@
##############################################
# $Id: $
package main;
use strict;
use warnings;
use SetExtensions;
my %sets = (
"clear:noArg" => "",
"time:noArg" => "",
"raw" => "",
);
sub
Betty_Initialize($)
{
my ($hash) = @_;
$hash->{Match} = "^y.*";
$hash->{SetFn} = "Betty_Set";
$hash->{DefFn} = "Betty_Define";
$hash->{ParseFn} = "Betty_Parse";
$hash->{AttrList} = "IODev ". $readingFnAttributes;
}
###################################
sub
Betty_Set($@) {
my ($hash, @a) = @_;
return "set $hash->{NAME} needs at least one parameter" if(@a < 2);
my $me = shift @a;
my $cmd = shift @a;
my $arg = shift @a;
my $arg2 = shift @a;
return join(" ", sort keys %sets) if ($cmd eq "?");
if ($cmd eq "clear") {
my @cH = ($hash);
delete $_->{READINGS} foreach (@cH);
return undef;
} elsif ($cmd eq "raw") {
my $msg = $arg;
#IOWrite( $hash, $msg );
IOWrite( $hash, "y", $msg );
return undef;
} elsif ($cmd eq "time") {
my $address = $hash->{ADDRESS};
my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime;
my $m = sprintf("%02d%02d%02d%02d",$mday,$wday,$month+1, $year-100);
my $n = sprintf("%02d%02d%02d",$sec, $min, $hour );
my $msg = "w".$address;
IOWrite( $hash, "y", $msg );
$msg = "s0a".$address."0003".$m.$n;
IOWrite( $hash, "y", $msg );
return undef;
}
return "Unknown argument $cmd, choose one of ". join(" ", sort keys %sets);
}
#############################
sub
Betty_Define($$)
{
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
return "wrong syntax: define <name> Betty <address>"
if(int(@a) < 2 || int(@a) > 4);
my $address = uc($a[2]);
$hash->{ADDRESS} = $address;
$modules{Betty}{defptr}{$address} = $hash;
AssignIoPort($hash);
readingsSingleUpdate($hash, "state", "Initialized", 1);
return undef;
}
sub
Betty_Parse($$)
{
my ($hash,$msg) = @_;
my ($len,$dest,$src,$service,$data) = unpack 'x1A2A2A2A2A*',$msg;
my $def = $modules{Betty}{defptr}{$src};
if(!$def) {
DoTrigger("global","UNDEFINED Betty_$src Betty $src");
$def = $modules{Betty}{defptr}{$src};
if(!$def) {
Log3 $hash, 1, "Betty UNDEFINED, address $src";
return "UNDEFINED Betty_$src Betty $src";
}
}
$hash = $def;
my $name = $hash->{NAME};
# packet_RFenc
if ($service eq '04') {
my ($addr,$key) = unpack 'A2A2',$data;
if($hash->{helper}{lastkey } ne $key) {
$hash->{helper}{lastkey } = $key;
$key = sprintf "%02x", hex($key) & 0x7F;
readingsSingleUpdate($hash, "key", $addr."_".$key , 1);
}
# packet_test
} elsif ($service eq '01') {
$data = latin1ToUtf8(pack("H*",$data));
readingsSingleUpdate($hash, "test", $data , 1);
# packet_time
} elsif ($service eq '03') {
my ($request) = unpack 'A2',$data;
if($request eq "FF") {
my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime;
my $m = sprintf("%02d%02d%02d%02d",$mday,$wday,$month+1, $year-100);
my $n = sprintf("%02d%02d%02d",$sec, $min, $hour );
$msg = "s0a".$src."0003".$m.$n;
IOWrite( $hash, "y", $msg );
}
} else {
Log3 $hash, 4, "Betty UNKNOWN MESSAGE $service: $data";
}
return $name;
}
1;
=pod
=item summary devices communicating with the Betty remote control
=item summary_DE Anbindung der Betty Fernbedienung
=begin html
<a name="Betty"></a>
<h3>Betty</h3>
<ul>
Todo
</ul>
=end html
=cut

1
boop/Boop.pnproj Normal file
View file

@ -0,0 +1 @@
<Project name="Boop"><File path="Boop.pnproj"></File><File path="crt.s"></File><File path="externs.h"></File><File path="flash.c"></File><File path="flash.h"></File><File path="fonty.c"></File><File path="fonty.h"></File><File path="irq.c"></File><File path="irq.h"></File><File path="keyboard.c"></File><File path="keyboard.h"></File><File path="lcd.c"></File><File path="lcd.h"></File><File path="lpc2220.h"></File><File path="lpc2220.ld"></File><File path="main.c"></File><File path="Makefile"></File><File path="soundcore.c"></File><File path="soundcore.h"></File><File path="Makefile.local"></File><File path="lpc2220_rom.ld"></File><File path="serial.h"></File><File path="serial.c"></File></Project>

View file

@ -1,5 +1,4 @@
SUBDIRS := adc audio cc1100 display flash games gui infrared interrupt \
keyboard rtc serial timer tools
SRCS := crt.s main.c global.c buffer.c syscalls.c
SRCS := crt.s main.c global.c

View file

@ -1,11 +1,10 @@
###############################################################
#####
##### Makefile for boop - OpenSource firmware for Betty
##### Makefile for boop - communicate with betty
##### Created at 30.8.2007 02:26 am
#####
##### boop V0.1 by netguy - ck@mamalala.net
##### Makefile V0.1 by alterego - alteregon@gmx.net
##### Makefile v0.2 by Tobias - tobias-betty@23.gs
#####
###############################################################
@ -13,21 +12,17 @@
#####
##### PATHS (default installation)
#####
##### You can put your path-config into Makefile.local
##### You can put your path-config into Makefile.local
##### to override these defaults
#####
###############################################################
#ARMBASE = F:/Tools/GNU_Tools_ARM_Embedded/5.4
#INCLUDEPATH = $(ARMBASE)/arm-none-eabi/include
#LIBPATH = $(ARMBASE)/arm-none-eabi/lib
#ARMPATH = $(ARMBASE)/bin/
TOOLPREFIX = arm-none-eabi-
LPCTOOL = lpctool
OPENOCDPATH = F:\Tools\OpenOCD_0_10
#OPENOCD = $(OPENOCDPATH)\bin\openocd.exe -f $(OPENOCDPATH)\scripts\interface\jlink.cfg -f betty.cfg
OPENOCD = $(OPENOCDPATH)\bin\openocd.exe -f $(OPENOCDPATH)\scripts\interface\uniprog.cfg -f betty.cfg
#ARMBASE=/opt/toolchains/gcc-arm-none-eabi-4_9-2014q4
#INCLUDEPATH=$(ARMBASE)/include
#ARMPATH=$(ARMBASE)/bin
TOOLPREFIX= arm-none-eabi-
BOOTLOADER_DEVICE=/dev/ttyUSB0
###############################################################
#####
@ -35,32 +30,20 @@ OPENOCD = $(OPENOCDPATH)\bin\openocd.exe -f $(OPENOCDPATH)\scripts\interface\uni
#####
###############################################################
CC = $(ARMPATH)$(TOOLPREFIX)gcc
AS = $(ARMPATH)$(TOOLPREFIX)gcc
LD = $(ARMPATH)$(TOOLPREFIX)gcc
OC = $(ARMPATH)$(TOOLPREFIX)objcopy
OD = $(ARMPATH)$(TOOLPREFIX)objdump
SIZE = $(ARMPATH)$(TOOLPREFIX)size
CC=$(ARMPATH)$(TOOLPREFIX)gcc
AS=$(ARMPATH)$(TOOLPREFIX)as
#LD=$(ARMPATH)$(TOOLPREFIX)ld
LD=$(CC)
OC=$(ARMPATH)$(TOOLPREFIX)objcopy
OD=$(ARMPATH)$(TOOLPREFIX)objdump
CPUFLAGS = -mcpu=arm7tdmi-s
CFLAGS = -Wall -mthumb-interwork -g3 -c
INC = -I. -Iinterrupt -Idisplay -Ikeyboard -Iaudio -Iinfrared -Iserial -Iflash -Icc1100 -Igui -Itimer -Igames -Iadc -Irtc -Itools
ASFLAGS = -g -I. -mthumb-interwork
LDFLAGS = -mthumb-interwork -nostartfiles -Xlinker -Map -Xlinker boop.map -Tlpc2220_rom.ld
THUMBFLAGS = -mthumb
CPUFLAGS=-mcpu=arm7tdmi-s
OPTFLAGS=-Os
CFLAGS=$(CPUFLAGS) -c -Wall -mthumb-interwork -msoft-float -I$(INCLUDEPATH) -ggdb
ASFLAGS=$(CPUFLAGS) -D --gstabs -mthumb-interwork -mfpu=softfpa
LDFLAGS = -mthumb-interwork -nostartfiles -Xlinker -Map -Xlinker boop.map -Tlpc2220.ld
COMPILE = $(CC) $(CPUFLAGS) $(CFLAGS) $(INC)
ifeq ($(MAKECMDGOALS),debug)
COMPILE += -D DEBUGMODE
OPTFLAGS = -O0
else
OPTFLAGS = -Og
endif
ifeq ($(MAKECMDGOALS),release)
COMPILE += -D RELEASE
endif
THUMBFLAGS=-mthumb
-include Makefile.local
@ -70,88 +53,46 @@ endif
#####
###############################################################
# Recursive expansion of Makefile rules.
define expand_dir
# Reset vars for subdir for the case that Make.conf does not exist
SUBDIRS :=
SRCS :=
THUMBSRCS :=
THUMBSRCSUNOPT :=
-include $(1)Make.conf
ALLSRCS += $$(SRCS:%=$(1)%)
ALLTHUMBSRCS += $$(THUMBSRCS:%=$(1)%)
ALLTHUMBSRCSUNOPT += $$(THUMBSRCSUNOPT:%=$(1)%)
DEPS += $(1).deps
$$(foreach adir,$$(SUBDIRS),$$(eval $$(call expand_dir,$(1)$$(adir)/)))
endef
all: boop_rom.bin
ALLSRCS :=
ALLTHUMBSRCS :=
ALLTHUMBSRCSUNOPT :=
boop_rom.bin: boop_ram.elf
$(OC) -O binary boop_ram.elf boop_ram.bin
$(OC) -O ihex boop_ram.elf boop_ram.hex
$(eval $(call expand_dir,))
boop_ram.elf: crt.o lcd.o fonty.o main.o irq.o keyboard.o soundcore.o
$(LD) -o boop_ram.elf crt.o lcd.o fonty.o main.o irq.o keyboard.o soundcore.o $(LDFLAGS)
OBJS := $(patsubst %.s,%.o,$(ALLSRCS:.c=.o)) $(ALLTHUMBSRCS:.c=.thumb.o) $(ALLTHUMBSRCSUNOPT:.c=.thumbunopt.o)
test: boop_ram.elf
$(OD) -h boop_ram.elf
all: $(DEPS) boop_rom.bin boop_rom.hex
crt.o: crt.s
$(AS) $(ASFLAGS) -o crt.o crt.s
debug: $(DEPS) boop_rom.bin boop_rom.hex
irq.o: irq.c irq.h
$(CC) $(CFLAGS) $(OPTFLAGS) -o irq.o irq.c
release: clean version $(DEPS) boop_rom.bin boop_rom.hex
@echo -n '\n\nRelease erstellt SVN Version ++'
@cat .svn/entries | sed -n '4p'
version:
echo -n '#define SVNVERSION ' > version.h
svnversion -n |cut -f1 -d M -n >> version.h
echo >> version.h
keyboard.o: keyboard.c keyboard.h
$(CC) $(CFLAGS) -o keyboard.o keyboard.c
version.h:
echo -n '#define SVNVERSION ' > version.h
svnversion -n|cut -f1 -d M >> version.h
echo >> version.h
test: boop_rom.elf
$(OD) -h $<
soundcore.o: soundcore.c soundcore.h
$(CC) $(CFLAGS) -o soundcore.o soundcore.c
%.bin: %.elf
$(OC) -O binary $< $@
lcd.o: lcd.c lcd.h
$(CC) $(CFLAGS) $(OPTFLAGS) $(THUMBFLAGS) -o lcd.o lcd.c
%.hex: %.elf
$(OC) -O ihex $< $@
fonty.o: fonty.c fonty.h
$(CC) $(CFLAGS) $(OPTFLAGS) $(THUMBFLAGS) -o fonty.o fonty.c
boop_rom.elf: $(OBJS)
$(LD) $(LDFLAGS) -L$(LIBGCCPATH) -L$(LIBCPATH) -o $@ $^ $(LIBS)
arm-none-eabi-size $@
main.o: main.c
$(CC) $(CFLAGS) $(OPTFLAGS) -o main.o main.c
%.o: %.s
$(CC) $(ASFLAGS) -c -o $@ $<
ramload: boop_ram.bin
lpctool -d $(BOOTLOADER_DEVICE) -r boop_ram.bin
%.o: %.c
$(COMPILE) $(OPTFLAGS) -c -MMD -MF $(dir $<).deps/$(notdir $@) -o $@ $<
%.thumb.o: %.c
$(COMPILE) $(THUMBFLAGS) $(OPTFLAGS) -c -MMD -MF $(dir $<).deps/$(notdir $@) -o $@ $<
%.thumbunopt.o: %.c
$(COMPILE) $(THUMBFLAGS) -c -MMD -MF $(dir $<).deps/$(notdir $@) -o $@ $<
$(DEPS):
mkdir -p $@
uresident: resident
resident: boop_rom.bin
$(LPCTOOL) -i -v -e -a $<
program: boop_rom.bin
$(OPENOCD) -c init -c 'flash_boop $<' -c shutdown
resident: boop_ram.bin
lpctool -d $(BOOTLOADER_DEVICE) -i -v -e -a boop_ram.bin
clean:
-rm -Rf $(DEPS)
-rm -f $(OBJS) *.elf *.bin *.hex *.map *~
$(RM) -v *.o *.elf *.bin *.hex *~
clean2:
-rm -Rf $(DEPS)
-rm -f $(OBJS) *.elf *.hex *.map *~
-include $(DEPS:=/*)
### EOF

View file

@ -16,6 +16,5 @@ LIBPATH = $(ARMBASE)/arm-elf/lib/interwork
ARMPATH = $(ARMBASE)/bin
TOOLPREFIX = arm-elf-
LPCTOOL = lpctool.exe
OPENOCD = C:\OpenOCD\openocd.exe -f betty.cfg -f C:\OpenOCD\OpenOCD\interface\parport.cfg
######################## EOF ##################################

View file

@ -3,17 +3,23 @@
##### Makefile.local.linuxARM for boop
##### Created in the early morninghours
#####
##### Copy this to Makefile.local and modify for your Linux
##### installation
##### Makefile.local.linuxARM
#####
###############################################################
ARMBASE = /opt/arm-elf
INCLUDEPATH = $(ARMBASE)/include
LIBPATH = $(ARMBASE)/lib/gcc/arm-elf/4.1.1/interwork
ARMPATH = $(ARMBASE)/bin
TOOLPREFIX = arm-elf-
LPCTOOL = lpctool -d /dev/ttyUSB0
OPENOCD = openocd -f betty.cfg -f interface/parport.cfg
###############################################################
#####
##### PATHS (default installation)
#####
##### You can put your path-config into Makefile.local
##### to override these defaults
#####
###############################################################
ARMBASE=/opt/armtool/4.1.1
INCLUDEPATH=$(ARMBASE)/include
LIBPATH=$(ARMBASE)/arm-elf/lib/interwork
ARMPATH=$(ARMBASE)/bin
TOOLPREFIX=/arm-elf-
######################## EOF ##################################

View file

@ -1,3 +1,11 @@
24.7.2009:
boop for running in RAM. Created by telekatz for testing sound features.
Run it with
lpctool -r boop_rom.bin -d /dev/ttyUSB2
See Thread
http://bettyhacks.com/forum/index.php?topic=215.0
9.11.2007:
- serial console:

View file

@ -1 +0,0 @@
THUMBSRCS := adc.c adcirq.c

View file

@ -1,164 +0,0 @@
/*
adc.c - adc readout for battery status
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "irq.h"
#include "timerfuncs.h"
#include "adc.h"
#include "adcirq.h"
#include "lcd.h"
#include "fonty.h"
#include "lpc2220.h"
extern volatile unsigned int bat_adc;
extern volatile unsigned int bmax, bmin;
extern unsigned int is_drawing;
static unsigned short bat_max, bat_min;
static unsigned short diffs[4];
static unsigned short diff;
volatile unsigned char bat_state;
void draw_b(unsigned char x, unsigned char y)
{
unsigned char w;
if(!(is_drawing))
{
if(bat_state & BAT_DEBUG)
{
draw_block(4,0,108,24,3,DRAW_ERASE);
draw_numU(4,0,bat_min>>2,0,3,DRAW_PUT);
draw_numU(32,0,bat_max>>2,0,3,DRAW_PUT);
draw_numU(4,8,(bat_max>>2)-(bat_min>>2),0,3,DRAW_PUT);
draw_numU(60,0,bat_min,0,3,DRAW_PUT);
draw_numU(88,0,bat_max,0,3,DRAW_PUT);
draw_numU(60,8,bat_max-bat_min,0,3,DRAW_PUT);
if((bat_state & BAT_NORMAL))
draw_string(4,16,"Bat.Operation",3,DRAW_PUT);
if((bat_state & BAT_CHARGE))
draw_string(4,16,"Charging",3,DRAW_PUT);
if((bat_state & BAT_CHARGE_DONE))
draw_string(4,16,"Done Charging",3,DRAW_PUT);
}
if (bat_min<0x320)
w = 0;
else if (bat_min>0x380)
w = 12;
else
w = (bat_min-0x320)/8;
draw_block(x+1,y+1,12,5,3,DRAW_ERASE);
draw_rect(x,y,14,7,1,3,DRAW_PUT);
draw_vline(x+14,y+2,3,3,DRAW_PUT);
if(w>0)
draw_block(x+1,y+1,w,5,2,DRAW_PUT);
if(w<12)
draw_block(x+1+w,y+1,12-w,5,0,DRAW_PUT);
}
}
void calcBat(unsigned int cb)
{
ADCR |= ((1<<21) | (1<<24));
// ADCR |= (1<<24); /* Start A/D Conversion (START:0=1) */
ADINTEN = 1<<5;
}
void showBat(unsigned int cb)
{
static int cnt;
unsigned char x;
bat_max = bmax;
bat_min = bmin;
cnt &= 0x03;
diffs[cnt++] = bat_max - bat_min;
diff = 0;
for(x=0;x<4;x++)
diff += diffs[x];
diff >>= 2;
if(bat_state & BAT_NORMAL)
{
if(diff > 15)
{
bat_state |= BAT_CHARGE;
bat_state &= ~BAT_NORMAL;
}
}
else if(bat_state & BAT_CHARGE)
{
if(bat_max >= 1020)
{
bat_state |= BAT_CHARGE_DONE;
bat_state &= ~BAT_CHARGE;
}
}
else if(bat_state & BAT_CHARGE_DONE)
{
if(bat_max < 1000)
{
bat_state |= BAT_CHARGE;
bat_state &= ~BAT_CHARGE_DONE;
}
}
if((diff < 7) && (bat_min < 1000))
{
bat_state |= BAT_NORMAL;
bat_state &= ~BAT_CHARGE;
bat_state &= ~BAT_CHARGE_DONE;
}
draw_b(113,0);
bmin = bat_max;
bmax = bat_min;
}
void startADC(void)
{
ADCR = ( 1<<5 | ((15-1)<<8) /*| (1UL<<16)*/ | (1UL<<21) );
ADCR |= (1UL<<24); /* Start A/D Conversion (START:0=1) */
while ((ADDR & (1UL<<31)) == 0); /* Wait for the conversion to complete (DONE=1)*/
bmin = ((ADDR >> 6) & 0x03FF); /* Extract the A/D result */
ADCR &=~(1UL<<21);
bmax = bmin;
bat_max = bmin;
bat_min = bmin;
bat_state = BAT_NORMAL;
diffs[0] = 0;
diffs[0] = 1;
diffs[0] = 2;
diffs[0] = 3;
VICVectAddr14 = (unsigned long)&(adcIRQ);
VICVectCntl14 = VIC_SLOT_EN | INT_SRC_ADC;
VICIntEnable = INT_ADC;
startCB(addTimerCB(calcBat, 6));
startCB(addTimerCB(showBat, 220));
}

View file

@ -1,32 +0,0 @@
/*
adc.h - adc readout for battery status
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADC_H
#define ADC_H
#define BAT_NORMAL 0x01
#define BAT_CHARGE 0x02
#define BAT_CHARGE_DONE 0x04
#define BAT_DEBUG 0x80
void startADC(void);
void calcBat(unsigned int cb);
void showBat(unsigned int cb);
#endif

View file

@ -1,38 +0,0 @@
/*
adcirq.c - adc iinterrupt handler
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "irq.h"
#include "adcirq.h"
#include "adc.h"
#include "lpc2220.h"
volatile unsigned int bat_adc;
volatile unsigned int bmax, bmin;
void __attribute__ ((section(".text.fastcode"))) adcIRQ (void)
{
ADINTEN = 0;
bat_adc = ADDR;
bat_adc >>= 6;
bat_adc &= 0x03FF;
if(bmax < bat_adc)
bmax = bat_adc;
if(bmin > bat_adc)
bmin = bat_adc;
ADCR &=~(1UL<<21);
}

View file

@ -1,24 +0,0 @@
/*
adcirq.c - adc iinterrupt handler
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADCIRQ_H
#define ADCIRQ_H
void __attribute__ ((section(".text.fastcode"))) adcIRQ (void);
#endif

View file

@ -1,2 +0,0 @@
THUMBSRCS := sound.c sid.c
SRCS := soundirq.c

View file

@ -1,165 +0,0 @@
/*
sid.c - tone encoder routines
Copyright (C) 2008 Telekatz <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "irq.h"
#include "sid.h"
#include "sound.h"
#include "soundirq.h"
#include "lpc2220.h"
#include "timerfuncs.h"
unsigned int playtone_cb;
unsigned char *playtone[3];
unsigned char playstate;
unsigned char tonelen[3];
unsigned short playcounter;
unsigned short playcountermax;
const unsigned short AttackRate[16] = {19531,9766,2441,1628,1028,673,574,488,391,156,78,49,39,13,8,5};
const unsigned short DecayReleaseRate[16] = {6510,1628,814,543,343,233,191,163,130,52,16,13,4,3,2};
const unsigned char song2[] = { note_d,2, note_e,2, note_f,2, note_e,2, note_d,2, note_g,2, note_f,2, note_e,2,
note_d,2, note_e,2, note_f,2, note_g,2, note_a,2, note_g,2, note_f,2, note_e,2,
note_d,2, note_e,2, note_f,2, note_e,2, note_d,2, note_g,2, note_f,2, note_e,2,
note_cis,2, note_d,2, note_e,2, note_f,2, note_g,2, note_a,2, note_f,2, note_e,2,0};
const unsigned char song3[] = { note_0,1, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2,
note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2,
note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2,
note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,2, note_c,1,0};
const unsigned short notes[] = {0,4455,4720,5001,5298,5613,5947,6301,6676,7072,7493,7939,8411,0};
void SIDsetfrq(unsigned char voice, unsigned short frq) {
if (voice < voices) {
SID.reg[(voice * 7) + REG_FREQhi] = frq>>8;
SID.reg[(voice * 7) + REG_FREQlo] = frq & 0xFF;
}
}
void SIDsetadsr(unsigned char voice,unsigned char attack, unsigned char decay, unsigned char sustain, unsigned char release) {
if (voice < voices) {
SID.reg[(voice * 7) + REG_AttackDecay] = (attack<<4) + (decay&0x0f);
SID.reg[(voice * 7) + REG_SustainRelease] = (sustain<<4) + (release&0x0f);
}
}
void SIDsetwave(unsigned char voice,unsigned char wave) {
if (voice < voices) {
SID.reg[(voice * 7)+REG_Control] &= 0x0f;
SID.reg[(voice * 7)+REG_Control] |= wave;
}
}
void SIDplaytone(unsigned int cb) {
unsigned char tone;
unsigned char x;
switch (playstate) {
case 0x01:
playstate++;
setCBIntervall(playtone_cb,48);
for (x=0; x<3; x++) {
if (playtone[x]) {
if (!tonelen[x]) {
tone = *playtone[x];
if (tone) {
playtone[x]++;
tonelen[x] = *playtone[x];
playtone[x]++;
SIDsetfrq(x,notes[tone]);
SID.reg[(x*7)+REG_Control] |= GATE;
}
else {
playstate = 0x00;
playtone[0] = 0;
playtone[1] = 0;
playtone[2] = 0;
removeTimerCB(playtone_cb);
}
}
}
}
break;
case 0x02:
playstate = 0x01;
for (x=0; x<3; x++) {
if (playtone[x]) {
tonelen[x]--;
if (!tonelen[x])
SID.reg[(x*7)+REG_Control] &= ~GATE;
}
}
setCBIntervall(playtone_cb,2);
break;
default:
playstate = 0x00;
removeTimerCB(playtone_cb);
}
}
void SIDplaydump(unsigned int cb) {
unsigned char x;
if (playcounter++ < playcountermax) {
for (x=0;x<14;x++) {
SID.reg[x] = *playtone[0];
playtone[0]++;
}
}
else {
SID.reg[REG_Control] &= ~GATE;
SID.reg[7+REG_Control] &= ~GATE;
SID.reg[14+REG_Control] &= ~GATE;
playstate = 0x00;
playtone[0] =0;
removeTimerCB(playtone_cb);
}
}
void beepEnd(unsigned int cb) {
SID.reg[REG_Control] &= ~GATE;
SID.flags |= SID_AUTO_OFF;
removeTimerCB(cb);
}
void beep(unsigned char n) {
switch(n) {
case 1:
SIDsetwave(0,TRIANGLE);
SIDsetadsr(0,0,10,0,10);
SIDsetfrq(0,8411);
break;
default:
SIDsetwave(0,SAWTOOTH);
SIDsetadsr(0,1,5,10,5);
SIDsetfrq(0,5001);
break;
}
//PWMPR = 0;
switchSound(SOUND_ON);
SID.flags |= SIDenable;
SID.reg[REG_Control] |= GATE;
startCB(addTimerCB(beepEnd, 20));
}

View file

@ -1,118 +0,0 @@
/*
sid.h - tone encoder routines
Copyright (C) 2008 Telekatz <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SID_H
#define SID_H
// SID voice controll register bits
#define GATE (1<<0)
#define SYNC (1<<1)
#define RINGMOD (1<<2)
#define TEST (1<<3)
#define TRIANGLE (1<<4)
#define SAWTOOTH (1<<5)
#define RECTANGLE (1<<6)
#define NOISE (1<<7)
// SID RES/FILT ( reg.23 )
#define FILT1 (1<<0)
#define FILT2 (1<<1)
#define FILT3 (1<<2)
// SID MODE/VOL ( reg.24 )
#define VOICE3OFF (1<<7)
// SID registers
#define REG_FREQlo 00
#define REG_FREQhi 01
#define REG_PWlo 02
#define REG_PWhi 03
#define REG_Control 04
#define REG_AttackDecay 05
#define REG_SustainRelease 06
#define REG_FClo 21
#define REG_FChi 22
#define REG_ResFilt 23
#define REG_ModeVol 24
#define max_sid_registers 25
#define max_level 40000
#define voices 3
#define sustainstep 2666
//SID.flags
#define ATTACK 1
#define SIDenable (1<<3)
#define phaseoverflow (1<<4)
#define SID_AUTO_OFF (1<<5)
#define note_c 1
#define note_cis 2
#define note_d 3
#define note_dis 4
#define note_e 5
#define note_f 6
#define note_fis 7
#define note_g 8
#define note_gis 9
#define note_a 10
#define note_ais 11
#define note_h 12
#define note_0 13
extern const unsigned char song2[];
extern const unsigned char song3[];
extern const unsigned char song4[];
extern const unsigned short notes[];
const unsigned short AttackRate[16];
const unsigned short DecayReleaseRate[16];
struct voice_ {
unsigned short envelope;
unsigned short phase;
};
struct SID_ {
struct voice_ voice[3];
unsigned short noise;
unsigned char flags;
unsigned char reg[max_sid_registers];
};
struct SID_ SID;
extern unsigned int playtone_cb;
extern unsigned char *playtone[3];
extern unsigned char playstate;
extern unsigned char tonelen[3];
extern unsigned short playcounter;
extern unsigned short playcountermax;
void SIDsetfrq(unsigned char voice, unsigned short frq);
void SIDsetadsr(unsigned char voice,unsigned char attack, unsigned char decay, unsigned char sustain, unsigned char release);
void SIDsetwave(unsigned char voice,unsigned char wave);
void SIDplaytone(unsigned int cb);
void SIDplaydump(unsigned int cb);
void beep(unsigned char n);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,123 +0,0 @@
/*
sound.c - sound core routines
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "irq.h"
#include "sound.h"
#include "soundirq.h"
#include "lpc2220.h"
#include "pwm.h"
#define AUTO_OFF_TIME 0x4000
extern unsigned int tval;
extern unsigned char bl_val, cmp_val;
extern unsigned int slen;
extern unsigned char *sdata;
extern volatile unsigned char sact;
extern char out1;
extern char last_sample;
extern unsigned char sound_shutdown;
unsigned char timeout;
unsigned int auto_timeout;
void startSoundIRQ(void)
{/*
timeout = 0;
auto_timeout = 0;
out1 = 0;
PWMTC = 0;
// PWMPR = 0;
PWMPR = 7;
PWMMR0 = 0x1E6; // pwm rate
PWMMR2 = 0x00; // pwm value
PWMLER = 0x05;
PWMMCR = 0x03;
PWMPCR = (1<<10);
PWMTCR = 0x03;
PWMTCR = 0x09;
//VICVectAddr0 = (unsigned long)&(soundIRQ);
//VICVectCntl0 = VIC_SLOT_EN | INT_SRC_PWM;
VICIntSelect |= INT_PWM;
VICIntEnable = INT_PWM;
*/
}
void initSound(void)
{
slen = 0;
sdata = 0;
sact = 0;
tval = 0;
last_sample = 0;
bl_val = 0x3F;
timeout = 0;
auto_timeout = 0;
out1 = 0;
}
void switchSound(unsigned char onoff)
{
if(onoff)
{
PWM_set_frequency(30864);
sound_shutdown = 0;
PINSEL0 &= ~(3 << (2 * SND_PWM)); // IO
PINSEL0 |= (2 << (2 * SND_PWM)); // PWM
PINSEL0 &= ~(3 << (2 * SND_EN)); // IO
PINSEL0 &= ~(3 << (2 * SND_ON)); // IO
FIODIR0 |= (1<<SND_ON) | (1<<SND_EN);
FIOSET0 = (1<<SND_EN);
FIOCLR0 = (1<<SND_ON);
}
else
{
FIOCLR0 |= (1<<SND_EN);
sound_shutdown = 0xff;
}
}
void playSound(unsigned char *sound, unsigned long len)
{
PWMPR = 0;
PWMPC = 0;
sdata = sound;
slen = len;
tval = 0;
sact = 1;
switchSound(SOUND_ON);
}
void stopSound(void)
{
switchSound(SOUND_OFF);
PWMPR = 7;
sact = 0;
}
void waitSound(void)
{
while(sact) { }
}

View file

@ -1,217 +0,0 @@
/*
soundcore.c - sound core routines (output, ipol, mixing, ...)
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "irq.h"
#include "soundirq.h"
#include "sound.h"
#include "sid.h"
#include "lpc2220.h"
#include "pwm.h"
#define AUTO_OFF_TIME 0x4000
/*
extern volatile unsigned int tval;
extern volatile unsigned char bl_val, cmp_val;
extern volatile unsigned int slen;
extern volatile unsigned char *sdata;
extern volatile unsigned char sact;
extern volatile char out1;
extern volatile char last_sample;
*/
unsigned int tval;
unsigned int slen;
unsigned char *sdata;
unsigned char sact;
unsigned char out1;
unsigned char last_sample;
unsigned char sound_shutdown;
unsigned char tcount;
const unsigned char prevvoice[3] = {2,0,1};
void __attribute__ ((section(".text.fastcode"))) soundIRQ (void)
{
PWMIR = 0x01;
/*
// play sample
if(sact != 0)
{
out1++;
if(out1 == 2) // quik & dirty anti-aliasing filter
{ // (2 point linear interpolated 2x upsampling)
PWMMR2 = (sdata[tval] + last_sample) >> 1;
PWMLER = 0x04;
}
else
if(out1 == 4) // prepare next sample
{
out1 = 0;
last_sample = sdata[tval];
PWMMR2 = last_sample;
tval++;
if(tval >= slen)
{
tval = 0;
FIOCLR0 |= (1<<SND_EN);
sound_shutdown = 0xff;
sact = 0;
}
PWMLER = 0x04;
}
}
// synthesize
else */if(SID.flags & SIDenable)
{
unsigned short tempphase;
unsigned char x;
unsigned short sig[3];
signed short temp;
static unsigned char PWMcounter;
unsigned short noise8;
signed char wave[3];
unsigned short autooff = 0;
temp = 243;
noise8=SID.noise>>6;
for (x=0; x<3; x++) {
volatile unsigned char phase8;
unsigned char tempwave;
if ((SID.reg[(x * 7) + REG_Control] & SYNC) && (SID.flags & phaseoverflow))
SID.voice[x].phase = 0;
tempphase=SID.voice[x].phase + ((SID.reg[(x * 7) + REG_FREQlo] + (SID.reg[(x * 7) + REG_FREQhi]<<8))>>4);
phase8 = (SID.voice[x].phase)>>8;
switch (SID.reg[(x * 7) + REG_Control] & 0xf0) {
case TRIANGLE:
tempwave = phase8<<1;
if (phase8 & 0x80)
tempwave ^= 0xff;
if ((SID.reg[(x * 7) + REG_Control] & RINGMOD) && (SID.voice[prevvoice[x]].phase & 0x8000))
tempwave ^= 0xff;
wave[x] = tempwave - 128;
break;
case SAWTOOTH:
wave[x] = phase8 - 0x80;
break;
case RECTANGLE:
if(phase8 > ((SID.reg[(x * 7) + REG_PWlo] + (SID.reg[(x * 7) + REG_PWhi]<<8)) >> 4))
wave[x] = 127;
else
wave[x] = -128;
break;
case NOISE:
if(SID.voice[x].phase & 0x4000)
wave[x]=noise8;
break;
default:
wave[x] = 0;
}
sig[x]=((SID.voice[x].envelope)>>8) * (wave[x]);
if (SID.voice[x].phase > tempphase)
SID.flags |= phaseoverflow;
else
SID.flags &= ~phaseoverflow;
SID.voice[x].phase=tempphase;
if (!PWMcounter) {
signed int envelope;
if (SID.reg[(x * 7) + REG_Control] & GATE) {
if (!(SID.flags & (ATTACK<<x))) {
envelope = SID.voice[x].envelope + AttackRate[SID.reg[(x * 7) + REG_AttackDecay]>>4];
if (envelope > max_level) {
SID.voice[x].envelope = max_level;
SID.flags |= (ATTACK<<x);
}
else
SID.voice[x].envelope = envelope;
}
else {
envelope = SID.voice[x].envelope - DecayReleaseRate[SID.reg[(x * 7) + REG_AttackDecay] & 0x0f];
if (envelope <= (sustainstep * (SID.reg[(x * 7) + REG_SustainRelease]>>4)))
SID.voice[x].envelope = sustainstep * (SID.reg[(x * 7) + REG_SustainRelease]>>4);
else
SID.voice[x].envelope = envelope;
}
}
else {
SID.flags &= ~(ATTACK<<x);
envelope = SID.voice[x].envelope - DecayReleaseRate[SID.reg[(x * 7) + REG_SustainRelease] & 0x0f];
if (envelope < 0)
SID.voice[x].envelope = 0;
else
SID.voice[x].envelope = envelope;
}
}
if (!((x == 3) && (SID.reg[REG_ModeVol] & VOICE3OFF)))
temp+=(signed char)(sig[x]>>8);
autooff |= SID.voice[x].envelope;
}
PWMMR2 = temp;
PWMLER = 0x04;
if (!(PWMcounter--))
PWMcounter = 29;
temp = SID.noise;
SID.noise=SID.noise << 1;
temp ^= SID.noise;
if ( ( temp & 0x4000 ) == 0x4000 )
{
SID.noise |= 1;
}
if((SID.flags & SID_AUTO_OFF) && !autooff) {
FIOCLR0 |= (1<<SND_EN);
sound_shutdown = 0xff;
SID.flags = 0;
}
}
if(sound_shutdown) {
PWMPR = 0;
if(!--sound_shutdown) {
FIOSET0 |= (1<<SND_ON);
FIOCLR0 = (1<<SND_PWM);
FIODIR0 |= (1<<SND_PWM);
PINSEL0 &= ~(3 << (2 * SND_PWM)); // IO
PWMPR = 7;
}
}
}

24
boop/b.h Normal file
View file

@ -0,0 +1,24 @@
const unsigned char b_w = 128;
const unsigned char b_h = 160;
const char b_data[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x80,0xC0,0xE0,0xE0,0xC0,0xE0,0xF0,0xF0,0xE0,0xF0,0xE8,0xF8,0xF0,0xF8,0xE0,0xF8,0x64,0xF8,0x24,0xFC,0x30,0xFC,0x32,0xFC,0x3A,0xFE,0x78,0xFE,0xF8,0xFE,0xF9,0xFE,0xFD,0xFE,0xFD,0xFE,0xFD,0xFE,0xFF,0xFE,0xFF,0xFE,0xFD,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x05,0x07,0x0F,0x1F,0x2F,0x7F,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xFF,0x80,0xF8,0x07,0xC1,0x3E,0x07,0xF8,0xFF,0x00,0xFF,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0xFF,0x7F,0xBF,0x3F,0xFF,0xF0,0x08,0xC0,0xE0,0xC0,0xE0,0xE0,0xC0,0xE0,0xF0,0xE0,0xF0,0x80,0x60,0x80,0xC0,0x80,0xC0,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0xC0,0x80,0x80,0xC0,0x80,0xD0,0xF0,0xD0,0xF0,0xE0,0xE0,0xD0,0x80,0x40,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0xE0,0x40,0xE0,0x60,0xE0,0xE0,0xE1,0xE2,0xE3,0xFF,0xE7,0xDF,0xE7,0xDB,0xEF,0xF7,0xE7,0x7B,0xE7,0x3B,0xE7,0xBA,0xE3,0xB4,0xE3,0xB0,0xF1,0xE2,0xF1,0xE2,0xF1,0xF8,0xF9,0xF0,0xF8,0xFD,0xFC,0xF9,0xFC,0x7F,0xBE,0x4D,0xFF,0xCA,0xFF,0xFB,0xFF,0xFD,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF7,0xFF,0xE3,0xFF,0xE3,0xFF,0xE3,0xFF,0xE3,0xFF,0xE3,0xFF,0xE3,0xFF,0xE3,0xFF,0xC3,0xFF,0xC3,0xEF,0x97,0xCF,0xB7,0x9F,0x67,0x9F,0x6F,0x3F,0xDE,0x7E,0x9F,0xFE,0x3C,0xFC,0x7C,0xF8,0xFC,0xF8,0xFC,0xFC,0xFA,0xFE,0xFC,0x3C,0xD8,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x14,0x3C,0xD8,0xF8,0xFC,0xFC,0xF8,0xFE,0xC5,0xFF,0xC3,0xFF,0xE1,0xFF,0x71,0x7F,0xF9,0x7F,0xFF,0xFF,0x7F,0xFF,0x7F,0x7F,0xDF,0x5F,0x2F,0x1F,0x2F,0x1F,0x2F,0x1F,0x2F,0x1F,0x3F,0x1F,0x3F,0x3F,0x1F,0x3F,0x7F,0x18,0x67,0x3F,0x5C,0x1F,0x3F,0x1F,0x0F,0x0F,0x1F,0x0F,0x17,0x07,0x0F,0x07,0x0B,0x03,0x0F,0x8B,0x57,0x9F,0xCF,0x9F,0x8F,0x8F,0x17,0x03,0x0D,0x03,0x0D,0x03,0x05,0x03,0x1D,0x33,0x1D,0x7F,0x33,0x7F,0x3F,0x7F,0x3F,0x3F,0x5F,0x1F,0x7F,0x3F,0xDF,0x7F,0xBE,0xFE,0xFD,0xFE,0xF9,0xFF,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xF8,0xF6,0xE0,0xF0,0xE0,0xC0,0xE0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0xC0,0x80,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xCF,0xF3,0xFF,0xFF,0xFF,0xFF,0x3F,0xDF,0x1F,0xAC,0x00,0x1F,0x00,0x01,0x00,0x00,0x00,0x80,0xF0,0x08,0x1C,0x22,0x06,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x01,0x01,0x00,0x83,0x40,0x06,0x83,0x0C,0x86,0x08,0xD4,0x10,0x08,0x10,0x80,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x04,0x0E,0x15,0x1C,0x3F,0x1F,0xBC,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F,0x5F,0x0F,0x17,0x03,0x05,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x04,0x18,0x3C,0x38,0x30,0x30,0x78,0x70,0x31,0x71,0x60,0x71,0x60,0x71,0x21,0x33,0x61,0x1F,0x23,0x07,0x03,0x0E,0x07,0x0C,0x1E,0x38,0x10,0x60,0xD0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x03,0x07,0x8A,0x0F,0x96,0xF6,0x19,0xE0,0xF0,0xE0,0xF2,0x83,0x70,0x00,0x7D,0xF0,0x08,0x00,0x1F,0x04,0x0A,0x04,0x08,0x0C,0xD2,0x0E,0xDD,0x5C,0xA8,0x7C,0xFA,0xF0,0x6A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x1C,0xE1,0x83,0x04,0x02,0x01,0x01,0x12,0x03,0x34,0x07,0x73,0x37,0x4A,0x3F,0xDE,0x7C,0x9B,0x00,0x38,0x00,0x00,0x00,0x00,0x0C,0x32,0x3C,0xFE,0x7C,0xBA,0xFC,0x7F,0xFF,0x7E,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x71,0x70,0xF0,0x70,0x38,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x38,0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0xE3,0x1F,0xE7,0x3F,0xC7,0x5F,0xA3,0x00,0xE7,0x00,0x80,0x00,0x85,0x02,0x05,0x00,0x06,0x0C,0x00,0x00,0x04,0x04,0x09,0x00,0x1F,0x03,0x04,0x01,0x04,0x00,0x00,0x00,0x00,0x00,0x80,0x88,0x48,0xC8,0x98,0x80,0xC0,0x80,0xC0,0x80,0x00,0x80,0x00,0x00,0x80,0x80,0x03,0x81,0x00,0x80,0x07,0x82,0x01,0x00,0x82,0x02,0x85,0x00,0x83,0x01,0x82,0x00,0xC2,0x00,0xC0,0x00,0xC0,0x00,0x60,0x00,0x60,0x00,0x70,0x00,0x3F,0x00,0x1F,0x00,0x17,0x00,0x1F,0x00,0x3F,0x00,0x1F,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x72,0x23,0xE3,0x62,0xC3,0xE7,0xC3,0xC7,0xC7,0x83,0x87,0xC7,0x87,0x8E,0x8E,0x07,0x0E,0x8E,0x0C,0x9E,0x1C,0x08,0x18,0x30,0xE0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x03,0x00,0x03,0x00,0xFB,0xFC,0xFB,0xFE,0xFD,0xFE,0x7F,0xFE,0x7F,0xFF,0x2E,0xFF,0xFE,0x1F,0xEE,0x0F,0x1F,0x0F,0x07,0x0F,0x06,0x0F,0x1E,0x0F,0x1F,0x0F,0x1F,0x0F,0xDE,0xFF,0xCF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x1E,0xFF,0x0E,0xFE,0x8F,0xFE,0xFF,0xFC,0xFE,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x03,0x03,0x01,0x03,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xF8,0x77,0xFF,0xC7,0xFF,0x81,0xFF,0xFC,0xFF,0xF0,0xFB,0xE4,0xFF,0xE1,0xF0,0xCF,0x80,0x60,0x00,0xF0,0xC0,0x38,0xC0,0xB0,0xE0,0xF0,0xF8,0xF4,0xFF,0xF0,0xF9,0xE6,0xFF,0xF0,0xFF,0xFC,0xFF,0xFF,0xFF,0x0F,0xFF,0x00,0xFF,0xE0,0xFF,0xF8,0xFF,0xFF,0x7F,0xBF,0x0F,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0xC0,0xE0,0xC0,0xC0,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0xF9,0x06,0xFF,0x37,0xFF,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xFF,0x7F,0xFF,0xFE,0xFC,0xFB,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x3F,0xFF,0x1F,0xFF,0x8F,0xFF,0xEF,0xFF,0xEF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0x1F,0xAF,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF3,0x25,0xEF,0xF7,0xF9,0xE1,0xF1,0xE0,0xE1,0xE0,0xE1,0xC1,0xC1,0xC1,0xC1,0x83,0xC3,0x83,0x83,0xC7,0x87,0xC3,0x87,0x8E,0x8E,0x9C,0xF8,0xB4,0x00,0x80,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0xB0,0x00,0x98,0x08,0xD6,0x0F,0xDA,0x1F,0xC0,0x1F,0xF8,0x3F,0xDE,0x7F,0xBF,0x7F,0x9F,0x0F,0x35,0x0E,0x15,0x07,0x0A,0x07,0x0F,0x0F,0x97,0x9F,0x33,0x3F,0xF1,0xFF,0x78,0xFF,0xFC,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0x0F,0x3F,0x47,0x3F,0x46,0x3C,0x02,0x38,0x04,0x30,0x68,0x60,0x80,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x83,0x40,0xC0,0xE1,0xE0,0xE0,0xE0,0xF0,0xF0,0xE1,0xF0,0xE1,0xE1,0xF0,0xE1,0xE1,0xE1,0xC3,0xC3,0xE1,0xC3,0x83,0x83,0x07,0x07,0x03,0x07,0x07,0x07,0x0F,0x07,0x0F,0x0F,0x07,0x0F,0x0F,0x0F,0x1F,0x3F,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x04,0x3A,0x08,0xF7,0xCC,0x33,0x28,0x57,0x18,0x27,0x1C,0xE3,0x18,0xE7,0x10,0x29,0x00,0x39,0x10,0x29,0x10,0x29,0x00,0x3D,0x00,0xBF,0x00,0xFC,0x80,0x78,0xE1,0x1A,0x7D,0x82,0x1C,0xEF,0x0E,0xC5,0x07,0xC3,0x03,0xC1,0x01,0x83,0x01,0x80,0x00,0x81,0x00,0x80,0x80,0x00,0x80,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xE0,0x00,0xFF,0xC0,0x3F,0x3F,0xC0,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x11,0x38,0x11,0x70,0x30,0xE0,0x70,0xE0,0xE1,0xE0,0xC1,0xC1,0xE0,0xC1,0xC1,0xC1,0xC1,0xC1,0x83,0xC3,0x83,0xC3,0x87,0xC7,0xCE,0xFC,0x6A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x01,0xFE,0xF0,0x0E,0x00,0x00,0x00,0x07,0x00,0xFE,0x00,0x80,0x00,0xC0,0x00,0xE0,0xC0,0x38,0x38,0x46,0x0C,0x13,0x03,0x04,0x01,0x02,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x0F,0x0F,0x90,0x0F,0xF7,0x0F,0xF5,0x8F,0x76,0xCF,0xB2,0xFC,0xE3,0xFC,0x33,0x0E,0x31,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0xC0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xE1,0xF1,0xE1,0xE1,0xF3,0xE3,0xE1,0xE3,0xC3,0xC3,0xE3,0xC3,0x83,0x83,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x00,0x7E,0x01,0x1E,0x00,0x0F,0x01,0x1E,0x00,0xFE,0x00,0x80,0x00,0x1F,0xF8,0x07,0x18,0x67,0x03,0x1C,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x80,0x70,0xC0,0xB8,0xE0,0xDC,0xF0,0xEE,0xF8,0xF7,0xFC,0x7B,0xFE,0xFD,0xFF,0xFE,0x3F,0x5F,0x0F,0x17,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x11,0x38,0x11,0x70,0x30,0xE0,0x70,0xE0,0xE1,0xE0,0xC1,0xC1,0xE0,0xC1,0xC1,0xC1,0xC1,0xC1,0x83,0xC3,0x83,0xC3,0x87,0xC7,0xCE,0xFC,0x6A,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x63,0x9C,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3C,0xC3,0xFC,0x02,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x18,0xE6,0x04,0x0B,0x02,0x05,0x00,0x03,0x00,0x01,0x03,0x0C,0x1F,0x0F,0x07,0x0B,0x03,0x05,0x1F,0x27,0x3F,0x0F,0x01,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xA0,0xE0,0xE0,0xE0,0xF0,0xF0,0xE0,0xF0,0xE1,0xE1,0xF1,0xE1,0xE3,0xE3,0xC1,0xC3,0xE3,0xC3,0x83,0x83,0x83,0x03,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x78,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0xF8,0x07,0xF8,0x30,0xCF,0x00,0xF8,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x02,0x0D,0x00,0x3C,0x00,0xF0,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0xC0,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0xC0,0x00,0x40,0x00,0x80,0x00,0x80,0x00,0xC0,0x00,0x40,0x00,0xC0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0C,0x7E,0x7C,0x1E,0x3C,0x1C,0x1E,0x1C,0x3C,0x3C,0x18,0x3C,0x38,0x38,0x7C,0x79,0x3A,0x7B,0x7F,0x78,0xFD,0xF0,0x78,0xF0,0x70,0xE0,0xF0,0xE0,0xE1,0xE0,0xC1,0xC1,0xE1,0xC1,0xC3,0xC3,0x83,0xC7,0x83,0xCE,0x84,0xF8,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x1E,0x00,0xF0,0x00,0x80,0x00,0x0F,0x00,0xFF,0x00,0xF0,0x01,0x0E,0x1C,0xE3,0x60,0x9E,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x2C,0xD2,0xC0,0x26,0x80,0x41,0x80,0x40,0x00,0xFC,0x00,0x3D,0x01,0x02,0x00,0x1F,0x00,0xF6,0x20,0x12,0x70,0xA0,0xC0,0x20,0x00,0x00,0x00,0x00,0x00,0x30,0x10,0x78,0x70,0xC3,0x00,0x46,0x00,0x9C,0x20,0x59,0x20,0x13,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x01,0x01,0x01,0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x08,0x37,0x00,0xFF,0x03,0xFC,0x80,0x78,0x00,0x1F,0x00,0xFF,0x03,0xFC,0x1C,0xE3,0x00,0xF8,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x7F,0x80,0xC1,0xC3,0x84,0x40,0xAF,0xE0,0x1C,0x80,0x40,0x00,0xC0,0x00,0xF0,0x00,0xE0,0x00,0x20,0x00,0x47,0x4C,0xA0,0x4C,0xE2,0x2C,0xD2,0x00,0xA4,0x00,0x60,0x00,0x40,0x00,0x6F,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x05,0x0E,0x31,0xE0,0x1F,0x00,0x07,0x00,0xFF,0x00,0xD7,0xC0,0xBF,0xFC,0xE3,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0xBF,0x9F,0x60,0x9F,0x6F,0xCF,0x17,0x80,0x07,0x00,0x00,0x01,0x00,0x03,0x0D,0x1F,0x08,0x0E,0x19,0x0E,0x05,0x0E,0x05,0x0E,0x01,0x0E,0x05,0x0F,0x9C,0x1F,0x6C,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x70,0x28,0x78,0x07,0x78,0xE7,0x40,0xA1,0x3F,0xC0,0x3F,0x5F,0xFF,0x3F,0xF0,0x28,0xF0,0x00,0x78,0xF6,0x7F,0x3E,0x1F,0x3F,0x7F,0x3C,0x3F,0x48,0x03,0x2C,0x00,0x3E,0x00,0x38,0x00,0x20,0x00,0x60,0x00,0x40,0x00,0x47,0x02,0x45,0x00,0x67,0x00,0x61,0x00,0x65,0x00,0x76,0x00,0x66,0x20,0x56,0x04,0x60,0x20,0x1C,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

80
boop/batt.c Normal file
View file

@ -0,0 +1,80 @@
/*
batt.c -
Copyright (C) 2007
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lpc2220.h"
#include "batt.h"
#include "lcd.h"
void initADC(void)
{
/* Setup A/D: 10-bit AIN0 @ 4,2MHz "Non-Burst"-Mode */
//PINSEL1 |= (1UL<<28); // set function P0.29 as AIN2
// sample AIN0 only => bit 0 = 1
// CLKDIV = 14 (59/14 = 4.21 < 4.5 MHz) => Bits 8ff = 14-1
// BURST = 1 => set Bit 16 - wuff: disabled below
// PDN = 1 => set Bit 21
ADCR = ( 1<<5 | ((14-1)<<8) /*| (1UL<<16)*/ | (1UL<<21) );
}
unsigned int getADCvalue(void)
{
unsigned int val=0;
ADCR = ( 1<<5 | ((14-1)<<8) /*| (1UL<<16)*/ | (1UL<<21) );
ADCR |= (1UL<<24); /* Start A/D Conversion (START:0=1) */
while ((ADDR & (1UL<<31)) == 0); /* Wait for the conversion to complete (DONE=1)*/
val = ((ADDR >> 6) & 0x03FF); /* Extract the A/D result */
ADCR &=~(1UL<<21);
return val;
}
void draw_battery(unsigned char x, unsigned char y)
{
unsigned int val=0;
unsigned char w=0;
draw_rect(x,y,14,7,1,3,DRAW_PUT);
draw_vline(x+14,y+2,3,3,DRAW_PUT);
draw_block(x+1,y+1,12,5,2,DRAW_ERASE);
val=getADCvalue();
if (val<0x320)
val=0x320;
if (val>0x380)
val=0x380;
w= (val-0x320)/8;
draw_block(x+1,y+1,w,5,2,DRAW_PUT);
}
void draw_ant(unsigned char x, unsigned char y, unsigned char m) {
draw_vline(x+3,y,7,3,m);
draw_pixel(x,y,3,m);
draw_pixel(x+1,y+1,3,m);
draw_pixel(x+2,y+2,3,m);
draw_pixel(x+6,y,3,m);
draw_pixel(x+5,y+1,3,m);
draw_pixel(x+4,y+2,3,m);
}

View file

@ -1,6 +1,6 @@
/*
soundirq.h - sound interrupt handler
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
batt.h -
Copyright (C) 2007
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
@ -16,9 +16,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOUNDIRQ_H
#define SOUNDIRQ_H
#ifndef BATT_H
#define BATT_H
void __attribute__ ((section(".text.fastcode"))) soundIRQ (void);
void initADC(void);
unsigned int getADCvalue(void);
void draw_battery(unsigned char x, unsigned char y);
void draw_ant(unsigned char x, unsigned char y, unsigned char m);
#endif

View file

@ -1,122 +0,0 @@
# OpenOCD config file for Betty remote control
# http://bettyhacks.com/forum/index.php?topic=160.0
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME lpc2220
}
if { [info exists ENDIAN] } {
set _ENDIAN $ENDIAN
} else {
set _ENDIAN little
}
if { [info exists CPUTAPID ] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x4f1f0f0f
}
#coonfigure reset options
adapter_nsrst_delay 1
jtag_ntrst_delay 1
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config srst_only srst_pulls_trst trst_push_pull srst_push_pull
adapter_khz 1000
#jtag scan chain
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME
# Event handlers
$_TARGETNAME configure -event reset-start {adapter_khz 1000}
$_TARGETNAME configure -event reset-init {betty_init}
$_TARGETNAME configure -event gdb-attach {
halt
}
$_TARGETNAME configure -event gdb-attach {
reset init
}
arm7_9 dcc_downloads enable
$_TARGETNAME configure -work-area-phys 0x40000000 -work-area-size 0x10000 -work-area-backup 0
#flash bank <name> <driver> <base_addr> <size> <chip_width> <bus_width> <target_number> [<target_name> <banks> <sectors_per_bank> <pages_per_sector> <page_size> <num_nvmbits> <ext_freq_khz>]
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME cfi 0x80000000 0x00100000 2 2 $_TARGETNAME
#flash bank $_FLASHNAME cfi 0x82000000 0x00100000 2 2 $_TARGETNAME
arm7_9 fast_memory_access enable
proc betty_init { } {
# setup PLL
# PLLCON: Enable PLL, connect PLL
mww 0xe01fc080 0x03
# VBPDIV: no division
mww 0xe01fc100 0x02
# PLLCFG: 0x42 = psel = 10 (4) = msel= 00010 (3) = 240 mhz Fcco*/
mww 0xe01fc084 0x42
# Activate PLL settings
mww 0xe01fc08c 0xaa
mww 0xe01fc08c 0x55
#sleep 100
# Memory Bank Configuration
# BCFG0: 16bit, rble, 2wst - 30 mhz : Betty: FLASH 0 @ 0x80000000
mww 0xffe00000 0x10001CA0
# BCFG2: 16bit, rble, 2wst - 30 mhz : Betty: FLASH 1 @ 0x82000000
mww 0xffe00008 0x10001CA0
# BCFG1: 8 bit, 3 sram wst, rble, 5 wst 3 idcy : Betty: LCD @ 0x81000000
mww 0xffe00004 0x00000400
# GPIO Pin COnfiguration for Flash access
# PINSEL0:
mww 0xe002c000 0x00008005
# PINSEL1:
mww 0xe002c004 0x00000000
# PINSEL2:
mww 0xe002c014 0x0de049d4
# IO2SET: Set Outputs
mww 0xe0028024 0x1FC0000
# IO2DIR: Set Direction
mww 0xe0028028 0x1FC0000
# IO0DIR:
mww 0xe0028008 0x002018D0
# disable watchdog
mww 0xfffffd44 0x00008000
# enable user reset
mww 0xfffffd08 0xa5000001
}
proc flash_boop {IMAGE} {
reset init
flash erase_sector 0 0 0
flash erase_check 0
flash erase_sector 0 0 last
flash erase_check 0
flash write_bank 0 $IMAGE 0
reset run
}
proc start_debug {} {
reset halt
mwb 0xE000C01C 0x01
resume
}
# For more information about the configuration files, take a look at:
# openocd.texi

View file

@ -1,47 +0,0 @@
monitor reset 100
monitor halt
monitor endian little
# BCFG0: 16bit, rble, 6wst - 60 mhz : Betty: FLASH 0 @ 0x80000000
monitor memU32 0xFFE00000 = 0x100004A0
#BCFG2: 16bit, rble, 6wst - 60 mhz : Betty: FLASH 1 @ 0x82000000
monitor memU32 0xFFE00008 = 0x100004A0
#PINSEL0
monitor memU32 0xE002C000 = 0x00008005
#PINSEL1
monitor memU32 0xE002C004 = 0x00000000
#PINSEL2
monitor memU32 0xE002C014 = 0x0de049d4
#IO2SET
monitor memU32 0xE0028024 = 0x1FC0000
#IO2DIR
monitor memU32 0xe0028028 = 0x1FC0000
#IO0DIR
monitor memU32 0xE0028008 = 0x002018D0
#PLLCON: Enable PLL, connect PLL
monitor memU32 0xe01fc080 = 0xe01fc000
# VBPDIV:
monitor memU32 0xe01fc100 = 0x00000000
#PLLCFG:
monitor memU32 0xe01fc084 = 0x00000045
#Activate PLL settings
monitor memU32 0xe01fc08c = 0xaa
monitor memU32 0xe01fc08c = 0x55
# Enable Flash Breakpoints and Download
monitor WorkRAM = 0x40000000 - 0x2000FBFF
monitor flash CFI = 0x80000000 - 0x800FFFFF
monitor flash breakpoints = 1
monitor flash download = 1

1
boop/boop.pnps Normal file
View file

@ -0,0 +1 @@
<pd><ViewState><e p="Boop" x="true"></e></ViewState></pd>

1
boop/boop_flash.ppg Normal file
View file

@ -0,0 +1 @@
<Workspace name="New Project Group"><Project path="Boop.pnproj"></Project><Project path="L:\Betty\Neuer Ordner\trunk\Boop_flash.pnproj"></Project></Workspace>

Binary file not shown.

View file

@ -1,153 +0,0 @@
/*
buffer.c - functions for buffers
Copyright (C) 2008 Telekatz <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "buffer.h"
#include "global.h"
#include "irq.h"
void cBufferInit(struct cBuffer_ *buffer, unsigned char *start, unsigned short size) {
unsigned cpsr;
cpsr = disableIRQ();
buffer->data = start;
buffer->size = size;
buffer->len = 0;
buffer->index = 0;
restoreIRQ(cpsr);
}
void cBufferFlush(struct cBuffer_ *buffer) {
unsigned cpsr;
cpsr = disableIRQ();
buffer->len = 0;
buffer->index = 0;
restoreIRQ(cpsr);
}
unsigned char cBufferAdd(struct cBuffer_ *buffer, unsigned char data) {
unsigned cpsr;
cpsr = disableIRQ();
if(buffer->size > buffer->len) {
buffer->data[(buffer->index + buffer->len++) % buffer->size] = data;
restoreIRQ(cpsr);
return 1;
}
restoreIRQ(cpsr);
return 0;
}
unsigned short cBufferAddBuffer(struct cBuffer_ *buffer, unsigned char* data, unsigned short len) {
unsigned short lenw;
unsigned short start;
unsigned short end;
unsigned cpsr;
cpsr = disableIRQ();
lenw = 0;
if(buffer->size > buffer->len) {
start = (buffer->index + buffer->len) % buffer->size;
if(buffer->index)
end = buffer->index;
else
end = buffer->size;
if(end <= start) {
if(buffer->size - start < len) {
lenw = buffer->size - start;
memcpy(&buffer->data[start],data,lenw);
}
else {
memcpy(&buffer->data[start],data,len);
buffer->len += len;
restoreIRQ(cpsr);
return len;
}
start = 0;
}
if(end - start < len - lenw) {
memcpy(&buffer->data[start],&data[lenw],end - start);
buffer->len = buffer->size;
restoreIRQ(cpsr);
return lenw + end - start;
}
else {
memcpy(&buffer->data[start],&data[lenw],len-lenw);
buffer->len += len;
restoreIRQ(cpsr);
return len;
}
}
restoreIRQ(cpsr);
return 0;
}
unsigned char cBufferGet(struct cBuffer_ *buffer) {
unsigned char data = 0;
unsigned cpsr;
cpsr = disableIRQ();
if(buffer->len) {
data = buffer->data[buffer->index++];
buffer->index %= buffer->size;
buffer->len--;
}
restoreIRQ(cpsr);
return data;
}
unsigned short cBufferGetBuffer(struct cBuffer_ *buffer, unsigned char* data, unsigned short len) {
unsigned cpsr;
cpsr = disableIRQ();
if(buffer->len) {
if(len > buffer->len)
len = buffer->len;
if(buffer->index + len <= buffer->size) {
memcpy(data,&buffer->data[buffer->index],len);
}
else {
memcpy(data,&buffer->data[buffer->index],buffer->size - buffer->index);
memcpy(&data[buffer->size - buffer->index],buffer->data,len - (buffer->size - buffer->index));
}
buffer->index = (buffer->index + len) % buffer->size;
buffer->len -= len;
restoreIRQ(cpsr);
return len;
}
restoreIRQ(cpsr);
return 0;
}

View file

@ -1,35 +0,0 @@
/*
buffer.h - functions for buffers
Copyright (C) 2008 Telekatz <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BUFFER_H
#define BUFFER_H
struct cBuffer_ {
unsigned char* data;
unsigned short size;
unsigned short len;
unsigned short index;
};
void cBufferInit(struct cBuffer_ *buffer, unsigned char *start, unsigned short size);
void cBufferFlush(struct cBuffer_ *buffer);
unsigned char cBufferAdd(struct cBuffer_ *buffer, unsigned char data);
unsigned short cBufferAddBuffer(struct cBuffer_ *buffer, unsigned char* data, unsigned short len);
unsigned char cBufferGet(struct cBuffer_ *buffer);
unsigned short cBufferGetBuffer(struct cBuffer_ *buffer, unsigned char* data, unsigned short len);
#endif

158
boop/cc1100.c Normal file
View file

@ -0,0 +1,158 @@
/*
batt.c -
Copyright (C) 2007
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lpc2220.h"
#include "cc1100.h"
#include "irq.h"
const unsigned char conf[0x2F] = { 0x29 , 0x2E , 0x07 , 0x00 , 0xD3 , 0x91 , 0x3D , 0x0C ,
0x05 , 0x00 , 0x00 , 0x06 , 0x00 , 0x20 , 0x28 , 0xC5 ,
0xF5 , 0x75 , 0x83 , 0x22 , 0xE5 , 0x14 , 0x07 , 0x30 ,
0x18 , 0x16 , 0x6C , 0x03 , 0x40 , 0x91 , 0x87 , 0x6B ,
0xF8 , 0x56 , 0x10 , 0xE9 , 0x2A , 0x00 , 0x1F , 0x41 ,
0x00 , 0x59 , 0x7F , 0x3F , 0x81 , 0x35 , 0x09 };
volatile unsigned char cc1100rx;
void cc1100_init(void) {
unsigned long xx = 0x200;
PINSEL1 &= ~((1<<3) | (1<<5) | (1<<7));
PCONP &= 0xfffffbff;
PCONP |= (1<<21);
FIOSET0 = SCK1;
FIOCLR0 = MOSI1;
FIOCLR0 = CS1;
while(xx) {
asm volatile("nop" : :);
xx--;
}
FIOSET0 = CS1;
xx=0x200;
while(xx) {
asm volatile("nop" : :);
xx--;
}
FIOCLR0 = CS1;
FIOCLR0 = SCK1;
while (FIOPIN0 & MISO1);
PINSEL1 |= 0x000002A8; //((1<<3) | (1<<5) | (1<<7));
SSPCR0 = 0x0007;
SSPCPSR = 0x02;
SSPCR1 = 0x02;
SSPDR = SRES;
while (FIOPIN0 & MISO1);
while (SSPSR & (1<<4));
xx = SSPDR;
cc1100_write((0x00 | BURST ),conf,0x2f);
}
unsigned char cc1100_write(unsigned char addr,unsigned char* data, unsigned char lenght) {
unsigned short i;
unsigned char status;
unsigned char x;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | WRITE);
while ((SSPSR & (1<<4)));
status = SSPDR;
for (i=0; i < lenght; i++) {
SSPDR = data[i];
while ((SSPSR & (1<<4)));
x=SSPDR;
}
FIOSET0 = CS1;
return(status);
}
unsigned char cc1100_read(unsigned char addr, unsigned char* data, unsigned char lenght) {
unsigned short i;
unsigned char status;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | READ);
while ((SSPSR & (1<<4)));
status = SSPDR;
for (i=0; i < lenght; i++) {
SSPDR = 0x00;
while ((SSPSR & (1<<4)));
data[i]=SSPDR;
}
FIOSET0 = CS1;
return(status);
}
unsigned char cc1100_strobe(unsigned char cmd) {
unsigned short status;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = cmd;
while ((SSPSR & (1<<4)));
status = SSPDR;
FIOSET0 = CS1;
return(status);
}
void startcc1100IRQ(void) {
PINSEL1 |= 1;
EXTMODE |= 1;
EXTPOLAR |= 1;
EXTINT |= 1;
VICVectAddr1 = (unsigned long)&(cc1100IRQ);
VICVectCntl1 = VIC_SLOT_EN | INT_SRC_EINT0;
VICIntEnable = INT_EINT0;
}
void cc1100_getfifo(unsigned char* b) {
unsigned char cnt;
cc1100_read(RX_fifo, &cnt,1);
cc1100_read(RX_fifo, b,cnt+2);
b[cnt]=0;
}
void __attribute__ ((interrupt("IRQ"))) cc1100IRQ (void) {
EXTINT = 0x01;
cc1100rx =1;
VICVectAddr = 0;
}

56
boop/cc1100.h Normal file
View file

@ -0,0 +1,56 @@
/*
batt.h -
Copyright (C) 2007
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef cc1100_H
#define cc1100_H
#define MISO1 (1<<18)
#define MOSI1 (1<<19)
#define SCK1 (1<<17)
#define CS1 (1<<23)
#define WRITE 0x00
#define BURST 0x40
#define READ 0x80
#define TX_fifo 0x7F
#define RX_fifo 0xff
#define SRES 0x30
#define SFSTXON 0x31
#define SXOFF 0x32
#define SCLA 0x33
#define SRX 0x34
#define STX 0x35
#define SIDLE 0x36
#define SWOR 0x38
#define SPWD 0x39
#define SFRX 0x3A
#define SFTX 0x3B
#define SWORRST 0x3C
#define SNOP 0x3D
void cc1100_init(void);
unsigned char cc1100_write(unsigned char addr, unsigned char* data, unsigned char lenght);
unsigned char cc1100_read(unsigned char addr, unsigned char* data, unsigned char lenght);
unsigned char cc1100_strobe(unsigned char cmd);
void startcc1100IRQ(void);
void __attribute__ ((interrupt("IRQ"))) cc1100IRQ (void);
void cc1100_getfifo(unsigned char* b);
#endif

View file

@ -1 +0,0 @@
THUMBSRCS := cc1100.c rf.c fs20.c

View file

@ -1,343 +0,0 @@
/*
cc1100.c -
Copyright (C) 2007
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// CC1100 - http://focus.ti.com/docs/prod/folders/print/cc1100.html
// 27 MHz crystal
// http://en.wikipedia.org/wiki/ISM_band http://de.wikipedia.org/wiki/ISM-Band
// http://de.wikipedia.org/wiki/Short_Range_Devices http://en.wikipedia.org/wiki/Low-power_communication_device
// 433,05 MHz ... 434,79 MHz
#include "lpc2220.h"
#include "cc1100.h"
#include "irq.h"
// Deviation = 21.423340
// Base frequency = 433.254913
// Carrier frequency = 433.254913
// Channel number = 0
// Carrier frequency = 433.254913
// Modulated = true
// Modulation format = GFSK
// Manchester enable = false
// Sync word qualifier mode = 30/32 sync word bits detected
// Preamble count = 4
// Channel spacing = 184.982300
// Carrier frequency = 433.254913
// Data rate = 37.4908
// RX filter BW = 210.937500
// Data format = Normal mode
// CRC enable = true
// Whitening = false
// Device address = 1
// Address config = Address check and 0 (0x00) broadcast
// CRC autoflush = true
// PA ramping = false
// TX power = 0
// Rf settings for CC1101
const unsigned char conf[] = {
0x29, // IOCFG2 GDO2 Output Pin Configuration
0x2E, // IOCFG1 GDO1 Output Pin Configuration
0x06, // IOCFG0 GDO0 Output Pin Configuration
0x47, // FIFOTHR RX FIFO and TX FIFO Thresholds
0xD3, // SYNC1 Sync Word, High Byte
0x91, // SYNC0 Sync Word, Low Byte
0x3E, // PKTLEN Packet Length
0x1A, // PKTCTRL1 Packet Automation Control
0x05, // PKTCTRL0 Packet Automation Control
0x01, // ADDR Device Address
0x00, // CHANNR Channel Number
0x06, // FSCTRL1 Frequency Synthesizer Control
0x00, // FSCTRL0 Frequency Synthesizer Control
0x10, // FREQ2 Frequency Control Word, High Byte
0x0B, // FREQ1 Frequency Control Word, Middle Byte
0xE6, // FREQ0 Frequency Control Word, Low Byte
0x8A, // MDMCFG4 Modem Configuration
0x6C, // MDMCFG3 Modem Configuration
0x13, // MDMCFG2 Modem Configuration
0x22, // MDMCFG1 Modem Configuration
0xC1, // MDMCFG0 Modem Configuration
0x35, // DEVIATN Modem Deviation Setting
0x04, // MCSM2 Main Radio Control State Machine Configuration
0x0C, // MCSM1 Main Radio Control State Machine Configuration
0x38, // MCSM0 Main Radio Control State Machine Configuration
0x16, // FOCCFG Frequency Offset Compensation Configuration
0x6C, // BSCFG Bit Synchronization Configuration
0x43, // AGCCTRL2 AGC Control
0x40, // AGCCTRL1 AGC Control
0x91, // AGCCTRL0 AGC Control
0x46, // WOREVT1 High Byte Event0 Timeout
0x50, // WOREVT0 Low Byte Event0 Timeout
0x78, // WORCTRL Wake On Radio Control
0x56, // FREND1 Front End RX Configuration
0x10, // FREND0 Front End TX Configuration
0xE9, // FSCAL3 Frequency Synthesizer Calibration
0x2A, // FSCAL2 Frequency Synthesizer Calibration
0x00, // FSCAL1 Frequency Synthesizer Calibration
0x1F, // FSCAL0 Frequency Synthesizer Calibration
0x41, // RCCTRL1 RC Oscillator Configuration
0x00, // RCCTRL0 RC Oscillator Configuration
};
const unsigned char confasync[] = {
0x0D, // IOCFG2
0x0D, // IOCFG1
0x2E, // IOCFG0
0x47, // FIFOTHR
0xD3, // SYNC1
0x91, // SYNC0
0x3E, // PKTLEN
0x1A, // PKTCTRL1
0x32, // PKTCTRL0 | asynchronous serial mode
0x00, // ADDR
0x00, // CHANNR channel number
0x06, // FSCTRL1
0x00, // FSCTRL0
0x10, // FREQ2 #
0x12, // FREQ1 #
0x34, // FREQ0 # *27e6/2^16 = 433,919861 MHz base frequency
0x4A, // MDMCFG4 | channel bandwidth
0x84, // MDMCFG3
0x30, // MDMCFG2
// 0x00, // MDMCFG2 // 2-FSK
0x20, // MDMCFG1
0xe5, // MDMCFG0 CHANSPC_M Chann 49,95kHz | DRATE_E[3:0]
0x37, // DEVIATN
0x07, // MCSM2
0x30, // MCSM1 0c
0x18, // MCSM0
0x14, // FOCCFG
0x6C, // BSCFG
0x07, // AGCCTRL2
0x00, // AGCCTRL1
0x90, // AGCCTRL0
0x46, // WOREVT1
0x50, // WOREVT0
0x78, // WORCTRL
0x56, // FREND1
0x11, // FREND0
0xE9, // FSCAL3
0x2A, // FSCAL2
0x00, // FSCAL1
0x1F, // FSCAL0
0x41, // RCCTRL1
0x00, // RCCTRL0
};
void cc1100_init(void) {
unsigned long xx = 0x200;
PINSEL1 &= 0xffffff00; //GDO0 SCK1 MISO1 MOSI1 as GPIO
FIODIR0 |= (CS1 | MOSI1 | SCK1); //output
PCONP &= 0xfffffbff;
PCONP |= (1<<21);
FIOSET0 = SCK1;
FIOCLR0 = MOSI1;
FIOCLR0 = CS1;
while(xx) {
asm volatile("nop" : :);
xx--;
}
FIOSET0 = CS1;
xx=0x200;
while(xx) {
asm volatile("nop" : :);
xx--;
}
FIOCLR0 = CS1;
FIOCLR0 = SCK1;
while (FIOPIN0 & MISO1);
PINSEL1 |= 0x000002A8; //SCK1 MISO1 MOSI1 as SPI1
SSPCR0 = 0x0007;
SSPCPSR = 0x02;
SSPCR1 = 0x02;
SSPDR = SRES;
while (FIOPIN0 & MISO1);
while (SSPSR & (1<<4));
xx = SSPDR;
cc1100_write((0x00 | BURST ),(unsigned char*)conf,sizeof(conf));
cc1100_write1(PATABLE,0xC0);
cc1100_strobe(SIDLE);
cc1100_strobe(SPWD);
}
// write length bytes of data to addr in CC1100
unsigned char cc1100_write(unsigned char addr,unsigned char* data, unsigned char length) {
unsigned short i;
unsigned char status;
unsigned char x;
(void)(x);
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | WRITE);
while ((SSPSR & (1<<4)));
status = SSPDR;
for (i=0; i < length; i++) {
SSPDR = data[i];
while ((SSPSR & (1<<4)));
x=SSPDR;
}
FIOSET0 = CS1;
return(status);
}
// write on byte of data to addr in CC1100
// a few instructions faster than cc1100_write(addr, data, 1)
unsigned char cc1100_write1(unsigned char addr,unsigned char data) {
unsigned char status;
volatile unsigned char x=0;
(void)(x);
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | WRITE);
while ((SSPSR & (1<<4)));
status = SSPDR;
SSPDR = data;
while ((SSPSR & (1<<4)));
x=SSPDR;
FIOSET0 = CS1;
return(status);
}
unsigned char cc1100_read(unsigned char addr, unsigned char* data, unsigned char length) {
unsigned short i;
unsigned char status;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | READ);
while ((SSPSR & (1<<4)));
status = SSPDR;
for (i=0; i < length; i++) {
SSPDR = 0x00;
while ((SSPSR & (1<<4)));
data[i]=SSPDR;
}
FIOSET0 = CS1;
return(status);
}
unsigned char cc1100_read1(unsigned char addr) {
unsigned char r;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = (addr | READ);
while ((SSPSR & (1<<4)));
r = SSPDR;
SSPDR = 0x00;
while ((SSPSR & (1<<4)));
r=SSPDR;
FIOSET0 = CS1;
return(r);
}
unsigned char cc1100_strobe(unsigned char cmd) {
unsigned short status;
FIOCLR0 = CS1;
while (FIOPIN0 & MISO1);
SSPDR = cmd;
while ((SSPSR & (1<<4)));
status = SSPDR;
FIOSET0 = CS1;
return(status);
}
/*
// check that PLL has locked
unsigned char cc1100_pll_lock(void)
{
//~ To check that the PLL is in lock the user can
//~ program register IOCFGx.GDOx_CFG to 0x0A
//~ and use the lock detector output available on
//~ the GDOx pin as an interrupt for the MCU (x =
//~ 0,1, or 2). A positive transition on the GDOx
//~ pin means that the PLL is in lock. As an
//~ alternative the user can read register FSCAL1.
//~ The PLL is in lock if the register content is
//~ different from 0x3F. Refer also to the CC1100
//~ Errata Notes [1]. For more robust operation the
//~ source code could include a check so that the
//~ PLL is re-calibrated until PLL lock is achieved
//~ if the PLL does not lock the first time.
}
*/
/*
// get carrier frequency
unsigned char cc1100_carrier(void)
{
//~ f_carrier = fxosc/(2**16) * (FREQ + CHAN * (256+CHANSPC_M) * 2**(CHANSPC_E - 2))
}
// set intermediate frequency
unsigned char cc1100_if(void)
{
//~ FSCTRL1.FREQ_IF
//~ f_ = fxosc/(2**10) * FREQ_IF
}
// set channel spacing
unsigned char cc1100_chspc(void)
{
//~ MDMCFG0.CHANSPC_M
//~ MDMCFG1.CHANSPC_E r
}
// set channel
unsigned char cc1100_channel(void)
{
//~ CHANNR.CHAN
}
// set frequency
unsigned char cc1100_frequency(void)
{
//~ FREQ2, FREQ1, FREQ0
//~ This word will typically be set to the centre of the lowest channel frequency that is to be used.
}
// set modulation
unsigned char cc1100_modulation(void)
{
//~ MDMCFG2.MOD_FORMAT
//~ MDMCFG2.MANCHESTER_EN.
}
*/

View file

@ -1,131 +0,0 @@
/*
cc1100.h -
Copyright (C) 2007
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef cc1100_H
#define cc1100_H
#define MISO1 (1<<18)
#define MOSI1 (1<<19)
#define SCK1 (1<<17)
#define CS1 (1<<23)
#define GDO0 (1<<16)
#define GDO1 (1<<18)
#define GDO2 (1<<24)
#define WRITE 0x00
#define BURST 0x40
#define READ 0x80
#define TX_fifo 0x7F
#define RX_fifo 0xff
#define PATABLE 0x3E
//Command Strobes
#define SRES 0x30
#define SFSTXON 0x31
#define SXOFF 0x32
#define SCAL 0x33
#define SRX 0x34
#define STX 0x35
#define SIDLE 0x36
#define SWOR 0x38
#define SPWD 0x39
#define SFRX 0x3A
#define SFTX 0x3B
#define SWORRST 0x3C
#define SNOP 0x3D
//Status Registers
#define PARTNUM (0x30 | READ | BURST)
#define VERSION (0x31 | READ | BURST)
#define FREQEST (0x32 | READ | BURST)
#define LQI (0x33 | READ | BURST)
#define RSSI (0x34 | READ | BURST)
#define MARCSTATE (0x35 | READ | BURST)
#define WORTIME1 (0x36 | READ | BURST)
#define WORTIME0 (0x37 | READ | BURST)
#define PKTSTATUS (0x38 | READ | BURST)
#define VCO_VC_DAC (0x39 | READ | BURST)
#define TXBYTES (0x3A | READ | BURST)
#define RXBYTES (0x3B | READ | BURST)
#define RCCTRL1_STATUS (0x3C | READ | BURST)
#define RCCTRL0_STATUS (0x3D | READ | BURST)
//Configuration Registers
#define IOCFG2 0x00 // GDO2 output pin configuration
#define IOCFG1 0x01 // GDO1 output pin configuration
#define IOCFG0 0x02 // GDO0 output pin configuration
#define FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds
#define SYNC1 0x04 // Sync word, high byte
#define SYNC0 0x05 // Sync word, low byte
#define PKTLEN 0x06 // Packet length
#define PKTCTRL1 0x07 // Packet automation control
#define PKTCTRL0 0x08 // Packet automation control
#define ADDR_ 0x09 // Device address
#define CHANNR 0x0A // Channel number
#define FSCTRL1 0x0B // Frequency synthesizer control
#define FSCTRL0 0x0C // Frequency synthesizer control
#define FREQ2 0x0D // Frequency control word, high byte
#define FREQ1 0x0E // Frequency control word, middle byte
#define FREQ0 0x0F // Frequency control word, low byte
#define MDMCFG4 0x10 // Modem configuration
#define MDMCFG3 0x11 // Modem configuration
#define MDMCFG2 0x12 // Modem configuration
#define MDMCFG1 0x13 // Modem configuration
#define MDMCFG0 0x14 // Modem configuration
#define DEVIATN 0x15 // Modem deviation setting
#define MCSM2 0x16 // Main Radio Cntrl State Machine config
#define MCSM1 0x17 // Main Radio Cntrl State Machine config
#define MCSM0 0x18 // Main Radio Cntrl State Machine config
#define FOCCFG 0x19 // Frequency Offset Compensation config
#define BSCFG 0x1A // Bit Synchronization configuration
#define AGCCTRL2 0x1B // AGC control
#define AGCCTRL1 0x1C // AGC control
#define AGCCTRL0 0x1D // AGC control
#define WOREVT1 0x1E // High byte Event 0 timeout
#define WOREVT0 0x1F // Low byte Event 0 timeout
#define WORCTRL 0x20 // Wake On Radio control
#define FREND1 0x21 // Front end RX configuration
#define FREND0 0x22 // Front end TX configuration
#define FSCAL3 0x23 // Frequency synthesizer calibration
#define FSCAL2 0x24 // Frequency synthesizer calibration
#define FSCAL1 0x25 // Frequency synthesizer calibration
#define FSCAL0 0x26 // Frequency synthesizer calibration
#define RCCTRL1 0x27 // RC oscillator configuration
#define RCCTRL0 0x28 // RC oscillator configuration
#define FSTEST 0x29 // Frequency synthesizer cal control
#define PTEST 0x2A // Production test
#define AGCTEST 0x2B // AGC test
#define TEST2 0x2C // Various test settings
#define TEST1 0x2D // Various test settings
#define TEST0 0x2E // Various test settings
#define MARCSTATE_IDLE 0x01
#define MARCSTATE_RX 0x0d
extern const unsigned char conf[]; //__attribute__((aligned(0x4)));
extern const unsigned char confasync[];// __attribute__((aligned(0x4)));
void cc1100_init(void);
unsigned char cc1100_write(unsigned char addr, unsigned char* data, unsigned char length);
unsigned char cc1100_write1(unsigned char addr,unsigned char data);
unsigned char cc1100_read(unsigned char addr, unsigned char* data, unsigned char length);
unsigned char cc1100_read1(unsigned char addr);
unsigned char cc1100_strobe(unsigned char cmd);
#endif

View file

@ -1,343 +0,0 @@
/*
fs20.c - FS20 functions
Copyright (C) 2009 <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lpc2220.h"
#include "fs20.h"
#include "rf.h"
#include "cc1100.h"
#include "fonty.h"
#include "rtc.h"
#include "global.h"
#include "lcd.h"
#include "keyboard.h"
#include "serial.h"
#include "timerfuncs.h"
#define FS20_BETWEEN(x, a, b) ((x >= a) && (x <= b))
extern const char hval[16];
#define PROTOCOL_UNKNOWN 0
#define PROTOCOL_FS20 1
#define PROTOCOL_WEATHER 2
#define PROTOCOL_WEATHER2 3
void fs20_decoder(void) {
unsigned char x;
unsigned char FS20laststate = 0;
unsigned char FS20preamble = 0;
unsigned char FS20parity = 0;
unsigned char FS20state = 0;
unsigned long FS20lasttime = 0;
unsigned char FS20bitcounter = 0;
unsigned char FS20bytecounter = 0;
unsigned char FS20inbyte[20];
unsigned char FS20inbit = 0;
unsigned char FS20protocol = PROTOCOL_UNKNOWN;
unsigned short tempbyte = 0;
// unsigned char finish = 0;
unsigned long pulse = 0;
unsigned long space = 0;
unsigned long now;
lcd_fill(0);
set_font(BOLDFONT);
draw_string (0, 0, "FS20 Decoder", LCD_COLOR_B, DRAW_PUT);
draw_block (0,10,128,2, LCD_COLOR_B, DRAW_PUT);
set_font(SMALLFONT);
RFasyncmode(true);
cc1100_write1(FREQ2,0x20);
cc1100_write1(FREQ1,0x29);
cc1100_write1(FREQ0,0x3E);
cc1100_write1(AGCCTRL2,0x07);
cc1100_write1(AGCCTRL1,0x00);
cc1100_write1(AGCCTRL0,0x91);
cc1100_strobe(SFRX);
cc1100_strobe(SRX);
serial_puts("\n\r");
while(KEY_Exit) {};
while(!KEY_Exit)
{
//internal receiver
if(FIOPIN0 & GDO2)
FS20state = 1;
else
FS20state = 0;
/*
//external rexeiver on pin 0.14
if(FIOPIN0 & (1<<14))
FS20state = 1;
else
FS20state = 0;
*/
if(FS20state != FS20laststate) {
FS20laststate = FS20state;
//Calculate pulse len
if(!FS20state) {
now = T0TC;
if(now > FS20lasttime)
pulse = now-FS20lasttime;
else
pulse = (now+5000)-FS20lasttime;
FS20lasttime = now;
}
//Calculate space len
else {
now = T0TC;
if(now > FS20lasttime)
space = now-FS20lasttime;
else
space = (now+5000)-FS20lasttime;
FS20lasttime = now;
}
//Decode
if(FS20state || (FS20protocol == PROTOCOL_WEATHER2)) {
if(FS20protocol == PROTOCOL_UNKNOWN) {
if((FS20_BETWEEN(pulse, 350, 450) && FS20_BETWEEN(space, 350, 450)) || (FS20_BETWEEN(pulse, 550, 650) && FS20_BETWEEN(space, 550, 650))) {
FS20protocol = PROTOCOL_FS20; //FS20, FHT
FS20inbyte[0] = 'F';
FS20bytecounter = 1;
FS20bitcounter = 0;
FS20preamble = PREAMBLELEN_FS20;
FS20parity = 0;
tempbyte = 0;
}
else if((FS20_BETWEEN(pulse, 200, 533) && FS20_BETWEEN(space, 685, 1020)) || (FS20_BETWEEN(pulse, 685, 1020) && FS20_BETWEEN(space, 200, 533))) {
FS20protocol = PROTOCOL_WEATHER; //KS200, KS300, S2XXX
FS20inbyte[0] = 'W';
FS20bytecounter = 1;
FS20bitcounter = 0;
FS20preamble = PREAMBLELEN_WEATHER;
tempbyte = 0;
}
else if(FS20_BETWEEN(pulse, 200, 300) && FS20_BETWEEN(space, 200, 300)) {
FS20protocol = PROTOCOL_WEATHER2; //ASH500
FS20inbyte[0] = 'S';
FS20bytecounter = 1;
FS20bitcounter = 0;
FS20preamble = PREAMBLELEN_WEATHER2;
tempbyte = 0;
}
}
if(FS20protocol == PROTOCOL_FS20) {
if(FS20_BETWEEN(pulse, 350, 450) && FS20_BETWEEN(space, 350, 450))
FS20inbit = 0;
else if(FS20_BETWEEN(pulse, 550, 650) && FS20_BETWEEN(space, 550, 650))
FS20inbit = 1;
else
FS20protocol = PROTOCOL_UNKNOWN;
if(FS20protocol != PROTOCOL_UNKNOWN) {
if(FS20preamble) {
if((FS20preamble > 1) && FS20inbit)
FS20preamble = PREAMBLELEN_FS20;
else if((FS20preamble > 1) && !FS20inbit) {
FS20preamble--;
}
else if((FS20preamble == 1) && FS20inbit) {
FS20preamble = 0;
}
}
else {
if(FS20bitcounter == 8) {
if(FS20inbit == FS20parity) {
FS20bitcounter = 0;
FS20bytecounter++;
FS20parity = 0;
}
else {
FS20protocol = PROTOCOL_UNKNOWN;
}
}
else {
FS20inbyte[FS20bytecounter] = (FS20inbyte[FS20bytecounter]<<1) | FS20inbit;
FS20parity ^= FS20inbit;
FS20bitcounter++;
}
}
}
}
if(FS20protocol == PROTOCOL_WEATHER) {
if(FS20_BETWEEN(pulse, 685, 1020) && FS20_BETWEEN(space, 200, 533))
FS20inbit = 0;
else if(FS20_BETWEEN(pulse, 200, 533) && FS20_BETWEEN(space, 685, 1020))
FS20inbit = (1<<3);
else
FS20protocol = PROTOCOL_UNKNOWN;
if(FS20protocol != PROTOCOL_UNKNOWN) {
if(FS20preamble) {
if((FS20preamble > 1) && FS20inbit)
FS20preamble = PREAMBLELEN_WEATHER;
else if((FS20preamble > 1) && !FS20inbit) {
FS20preamble--;
}
else if((FS20preamble == 1) && FS20inbit) {
FS20preamble = 0;
}
}
else {
if(FS20bitcounter == 4) {
tempbyte<<=8;
FS20bitcounter++;
}
else if(FS20bitcounter == 9) {
FS20bitcounter = 0;
}
else {
//tempbyte = (tempbyte>>=1) | FS20inbit;
tempbyte>>=1;
tempbyte |= FS20inbit;
if(FS20bitcounter++ == 8) {
FS20inbyte[FS20bytecounter] = tempbyte;
tempbyte = 0;
FS20bytecounter++;
}
}
}
}
}
if(FS20protocol == PROTOCOL_WEATHER2) {
if(FS20preamble) {
if((FS20_BETWEEN(pulse, 200, 300) && FS20_BETWEEN(space, 200, 300))) {
if (FS20preamble > 1)
FS20preamble--;
}
else if((FS20_BETWEEN(pulse, 400, 600) && FS20_BETWEEN(space, 200, 300))) {
if (FS20preamble == 1) {
FS20preamble = 0;
pulse = 0;
space = 0;
}
else
FS20protocol = PROTOCOL_UNKNOWN;
}
else
FS20protocol = PROTOCOL_UNKNOWN;
}
else {
if((FS20_BETWEEN(pulse + space, 400, 600)) ) {
if(FS20state)
FS20inbit = 1;
else
FS20inbit = 0;
pulse = 0;
space = 0;
if(FS20inbit)
FS20parity++;
if(FS20bitcounter == 8) {
if(!(FS20parity & 0x01)) {
FS20bitcounter = 0;
FS20bytecounter++;
FS20parity = 0;
if(FS20bytecounter == 0x0a) { //packet full received
for(x=9;x>1;x--) {
FS20inbyte[x] = (FS20inbyte[x-1] + 0x24) ^ FS20inbyte[x];
}
FS20inbyte[1] = FS20inbyte[1] ^ 0x89;
FS20protocol = PROTOCOL_UNKNOWN;
}
}
else {
FS20bytecounter = 0;
FS20protocol = PROTOCOL_UNKNOWN;
}
}
else {
FS20inbyte[FS20bytecounter] = (FS20inbyte[FS20bytecounter]<<1) | FS20inbit;
FS20bitcounter++;
}
}
else if(pulse && space) {
FS20bytecounter = 0;
FS20protocol = PROTOCOL_UNKNOWN;
}
}
}
if((FS20protocol == PROTOCOL_UNKNOWN && FS20bytecounter > 1)) {
char msbuffer[20];
draw_block(0,32,128,24,3,DRAW_ERASE);
//print time and protocol type
siprintf (msbuffer, "%02x:%02x:%02x.%02u %c ",rtc.time.hour,rtc.time.minute,rtc.time.second,(unsigned char)(T0overflow>>1) & 0xff, FS20inbyte[0]);
draw_string (0, 32, msbuffer, LCD_COLOR_B, DRAW_NORCU);
serial_puts(msbuffer);
//print received data
for(x=1;x<(FS20bytecounter);x++) {
draw_hexC (((x-1)*14), 40, FS20inbyte[x], LCD_COLOR_B, DRAW_NORCU);
serial_putbyte (' ');
putHexC(FS20inbyte[x]);
}
//print decoded data
if(FS20inbyte[0] == 'S') {
signed short temp;
temp = ((FS20inbyte[6] & 0x7F)<<8) | FS20inbyte[7];
if(temp & 0x4000) //negative
temp |=0x8000;
serial_putbyte (' ');
serial_putbyte (' ');
siprintf (msbuffer, "%4d °C %u%%", temp,FS20inbyte[8]);
msbuffer[4] = msbuffer[3];
msbuffer[3] = '.';
serial_puts(msbuffer);
msbuffer[5] = 0x15; //change °C on display
msbuffer[6] = ' ';
draw_string (0, 48, msbuffer, LCD_COLOR_B, DRAW_NORCU);
}
serial_puts("\n\r");
//finish = 0;
FS20bytecounter = 0;
FS20protocol = PROTOCOL_UNKNOWN;
}
}
}
}
RFasyncmode(false);
}

View file

@ -1,29 +0,0 @@
/*
fs20.h - FS20 functions
Copyright (C) 2009 <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FS20_H
#define FS20_H
#define extensionbit 0x20
#define PREAMBLELEN_FS20 10
#define PREAMBLELEN_WEATHER 7
#define PREAMBLELEN_WEATHER2 20
void fs20_decoder(void);
#endif

View file

@ -1,502 +0,0 @@
/*
rf.c -
Copyright (C) 2008
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lpc2220.h"
#include "rf.h"
#include "cc1100.h"
#include "timerfuncs.h"
#include "irq.h"
#include "cc1100.h"
#include "lcd.h"
#include "fonty.h"
#include "rtc.h"
#include "global.h"
#include "buffer.h"
#include "bfs.h"
unsigned char RFbuf[64];
struct RFendpoint_ rfendpoint[MAX_ENDPOINTS];
struct RF_ RF;
const struct RFsettings_ default_RFsettings =
{
0x01, //address
0x01 //channel
};
//*********************
//* Private functions *
//*********************
void switch_to_idle() {
cc1100_strobe(SIDLE);
while (cc1100_read1(MARCSTATE) != 01);
}
void WORsend_timeout(unsigned int cb) {
RF.state = RFsendworend;
}
void RF_timed_rx_timeout(unsigned int cb) {
stopCB(RF.timeout_cb);
removeTimerCB(RF.timeout_cb);
RF.timeout_cb = 0xff;
if(RF.flags & WORenabled)
RF_changestate(RFwor);
else
RF_changestate(RFidle);
}
void sendendpoint(struct RFendpoint_ *currentEP) {
unsigned char* epdata = 0;
unsigned short eplen;
struct cc1100frame_ *TXframe;
TXframe = (struct cc1100frame_ *)RFbuf;
//write header
eplen = currentEP->bufferlen;
switch ( currentEP->flags & EPtypemask) {
case EPtypedata:
if(eplen > 6)
eplen = 6;
epdata = currentEP->data;
break;
case EPtypebuffer:
if(eplen > 59)
eplen = 59;
epdata = currentEP->buffer;
break;
case EPtypecbuffer:
if(eplen > 59)
eplen = 59;
if(eplen > currentEP->cbuffer->len)
eplen = currentEP->cbuffer->len;
break;
}
TXframe->len = eplen + 3;
TXframe->destAddr = currentEP->dest;
TXframe->srcAddr = RF.addr;
TXframe->packetType = currentEP->type;
cc1100_write(TX_fifo | BURST,(unsigned char*)TXframe,4);
//write data
switch ( currentEP->flags & EPtypemask) {
case EPtypedata:
case EPtypebuffer:
cc1100_write(TX_fifo | BURST,epdata,eplen);
break;
case EPtypecbuffer:
if(currentEP->cbuffer->index + eplen <= currentEP->cbuffer->size) {
cc1100_write(TX_fifo | BURST,&(currentEP->cbuffer->data[currentEP->cbuffer->index]),eplen);
}
else {
cc1100_write(TX_fifo | BURST,&(currentEP->cbuffer->data[currentEP->cbuffer->index]), currentEP->cbuffer->size - currentEP->cbuffer->index);
cc1100_write(TX_fifo | BURST,currentEP->cbuffer->data,eplen - (currentEP->cbuffer->size - currentEP->cbuffer->index));
}
currentEP->cbuffer->index = (currentEP->cbuffer->index + eplen) % currentEP->cbuffer->size;
currentEP->cbuffer->len -= eplen;
break;
}
cc1100_strobe(STX);
currentEP->flags &= ~EPnewdata;
if(currentEP->flags & EPonce)
closeEP(currentEP);
}
void receiveendpoint(struct RFendpoint_ *currentEP) {
unsigned short eplen;
struct cc1100frame_ *RXframe;
RXframe = (struct cc1100frame_ *)RFbuf;
currentEP->dest = RXframe->srcAddr;
eplen = RXframe->len-3;
switch ( currentEP->flags & EPtypemask) {
case EPtypedata:
if(eplen > 6) {
eplen = 6;
currentEP->flags |= EPoverflow;
}
memcpy(&(currentEP->data[0]),RXframe->data,eplen);
break;
case EPtypebuffer:
if(eplen > currentEP->buffersize) {
eplen = currentEP->buffersize;
currentEP->flags |= EPoverflow;
}
memcpy(currentEP->buffer,RXframe->data,eplen);
break;
case EPtypecbuffer:
if(eplen > currentEP->cbuffer->size - currentEP->cbuffer->len) {
eplen = currentEP->cbuffer->size - currentEP->cbuffer->len;
currentEP->flags |= EPoverflow;
}
cBufferAddBuffer(currentEP->cbuffer, RXframe->data, eplen);
break;
}
currentEP->bufferlen = eplen;
if(currentEP->flags & EPnewdata)
currentEP->flags |= EPoverwritten;
else
currentEP->flags |= EPnewdata;
if(currentEP->flags & EPonce)
closeEP(currentEP);
}
void cc1100IRQ (void) {
unsigned char x;
switch_to_idle();
if (cc1100_read1(RXBYTES) > 0) {
cc1100_read(RX_fifo, RFbuf,1);
cc1100_read(RX_fifo, &RFbuf[1],RFbuf[0]);
struct cc1100frame_ *RXframe;
RXframe = (struct cc1100frame_ *)RFbuf;
if ((RXframe->len == 1) && (RF.flags & WORenabled) && ((RXframe->destAddr == RF.addr) || (RXframe->destAddr == 0x00))) {
if(RF.timeout_cb != 0xff || RF.state != RFrx)
RF_timed_rx(WORrx_time);
}
if (RXframe->len > 3) {
if (RF.timeout_cb != 0xff)
setCBIntervall(RF.timeout_cb,WORrx_time);
switch ( RXframe->packetType) {
case packet_test:
draw_block(0,50,128,10,3,DRAW_ERASE);
draw_string(0, 50, (char*)&RXframe->data[0], 3, DRAW_PUT);
break;
case packet_ping:
if (RXframe->data[0] == 0x01) {
struct RFendpoint_* cur_ep;
cur_ep = openEP(0,0, packet_ping);
if(cur_ep) {
cur_ep->dest = RXframe->srcAddr;
cur_ep->data[0] = 2;
cur_ep->bufferlen = 1;
cur_ep->flags |= EPenabled | EPoutput | EPnewdata | EPonce;
RF_changestate(RFtx);
}
}
else if (RXframe->data[0] == 0x02) {
RF.flags |= PingACK;
}
break;
case packet_time:
if ((RXframe->data[0] == 0xFF) && (timeInfo & TIME_ACCURATE)) {
send_time(RXframe->srcAddr,0);
}
else if (RXframe->len == 10) {
memcpy((unsigned char *)&rtc,&RXframe->data[0],7);
timeInfo |= SETNEWTIME;
VICSoftInt = INT_EINT2;
}
break;
default:
for(x=0; x<MAX_ENDPOINTS; x++) {
if((rfendpoint[x].type == RXframe->packetType) && ((rfendpoint[x].flags & (EPoutput | EPenabled)) == EPenabled)) {
receiveendpoint(&rfendpoint[x]);
break;
}
}
}
}
}
if(RF.state == RFtx) {
for(x=0; x<MAX_ENDPOINTS; x++) {
if((rfendpoint[x].type) && ((rfendpoint[x].flags & (EPoutput | EPnewdata | EPenabled)) == (EPoutput | EPnewdata | EPenabled))) {
if(rfendpoint[x].flags & EPsendwor) {
rfendpoint[x].flags &= ~EPsendwor;
cc1100_write1(MCSM0,conf[MCSM0] & 0xCF);
cc1100_strobe(SCAL);
while (cc1100_read1(MARCSTATE) != 01);
RF.wortimeout_cb = addTimerCB(WORsend_timeout, 101);
startCB(RF.wortimeout_cb);
RF.state = RFsendwor;
RF.tag = x;
}
else
sendendpoint(&rfendpoint[x]);
break;
}
}
if(x == MAX_ENDPOINTS) {
RF.state = RF.nextstate;
}
}
if(RF.state == RFsendwor) {
unsigned char b[2];
b[0]=0x01;
b[1]=rfendpoint[RF.tag].dest;
cc1100_write(TX_fifo | BURST,b,2);
cc1100_strobe(STX);
}
if(RF.state == RFsendworend) {
stopCB(RF.wortimeout_cb);
removeTimerCB(RF.wortimeout_cb);
RF.wortimeout_cb = 0xff;
cc1100_write1(MCSM0,conf[MCSM0]);
RF.state = RFtx;
sendendpoint(&rfendpoint[RF.tag]);
}
switch (RF.state) {
case RFpwrdown:
cc1100_strobe(SPWD);
break;
case RFwor:
if(!(RF.flags & RXueop)) {
cc1100_write1(0x16,conf[0x16]);
RF.flags |= RXueop;
}
cc1100_strobe(SWOR);
break;
case RFidle:
break;
case RFrx:
if(RF.flags & RXueop) {
cc1100_write1(0x16,0x07);
RF.flags &= ~RXueop;
}
cc1100_strobe(SFRX);
cc1100_strobe(SRX);
break;
case RFtx:
case RFsendwor:
break;
}
if(RF.state <= RFidle)
symbols &= ~symbolRF;
else
symbols |= symbolRF;
VICSoftIntClr = INT_EINT0;
EXTINT = 0x01;
}
//********************
//* Public functions *
//********************
unsigned char RF_sendping(unsigned char dest) {
struct RFendpoint_* cur_ep;
cur_ep = openEP(0,0, packet_ping);
if(cur_ep) {
cur_ep->dest = dest;
cur_ep->data[0] = 1;
cur_ep->bufferlen = 1;
cur_ep->flags |= EPenabled | EPoutput | EPnewdata | EPonce | EPsendwor;
RF.flags &= ~PingACK;
RF_changestate(RFtx);
RF_timed_rx(WORrx_time);
while ((RF.timeout_cb != 0xff) && !(RF.flags & PingACK));
if(RF.flags & PingACK)
return(1);
}
return(0);
}
void RF_init (void) {
cc1100_init();
RF.flags = 0;
RF.addr = conf[0x09];
RF.state = RFpwrdown;
RF.nextstate = RFpwrdown;
RF.timeout_cb = 0xff;
}
void RF_changestate (unsigned char state) {
unsigned char oldstate;
VICIntEnClr = INT_EINT0;
if(RF.state != state) {
oldstate = RF.state;
if((RF.state >= RFtx) && (state < RFtx)) {
RF.nextstate = state;
}
else {
switch (state) {
case RFpwrdown:
RF.state = RFpwrdown;
break;
case RFwor:
RF.state = RFwor;
RF.flags |= WORenabled;
break;
case RFidle:
RF.state = RFidle;
break;
case RFrx:
RF.state = RFrx;
break;
case RFtx:
if(RF.state < RFtx)
RF.state = RFtx;
if(oldstate == RFrx)
RF.nextstate = RFrx;
else if(RF.flags & WORenabled)
RF.nextstate = RFwor;
else
RF.nextstate = RFidle;
break;
case RFsendwor:
break;
}
}
if(oldstate != RF.state) {
VICSoftInt = INT_EINT0;
}
}
VICIntEnable = INT_EINT0;
}
void RF_timed_rx(unsigned short timeout) {
if (RF.timeout_cb != 0xff)
setCBIntervall(RF.timeout_cb,timeout);
else {
RF.timeout_cb = addTimerCB(RF_timed_rx_timeout, timeout);
startCB(RF.timeout_cb);
RF_changestate(RFrx);
}
}
void startRFIRQ(void) {
PINSEL1 |= 1; //GDO0 as EINT0
EXTMODE |= 1; //edge sensitive
EXTPOLAR |= 0; //falling edge
EXTWAKE |= 1;
EXTINT |= 1;
VICVectAddr2 = (unsigned long)&(cc1100IRQ);
VICVectCntl2 = VIC_SLOT_EN | INT_SRC_EINT0;
VICIntEnable = INT_EINT0;
}
void stopRFIRQ(void) {
VICIntEnClr = INT_EINT0;
}
struct RFendpoint_* openEP(void* buffer, unsigned short buffersize, unsigned char type) {
int i;
struct RFendpoint_* cur_ep;
if(!type)
return 0;
for(i=0; i<MAX_ENDPOINTS;i++) {
cur_ep = &rfendpoint[i];
if(!(cur_ep->type)) {
cur_ep->buffer = buffer;
cur_ep->buffersize = buffersize;
cur_ep->type = type;
cur_ep->bufferlen = 0;
cur_ep->dest = 0;
cur_ep->flags = 0;
if(!(buffer))
cur_ep->flags |= EPtypedata;
return cur_ep;
}
}
return 0;
}
void closeEP(struct RFendpoint_ *cur_ep) {
if(cur_ep) {
cur_ep->flags = 0;
cur_ep->buffer = 0;
cur_ep->type = 0;
}
}
void RF_setRegister(unsigned char reg, unsigned char data) {
unsigned long VICInt;
VICInt = VICIntEnable & INT_EINT0;
VICIntEnClr = INT_EINT0;
cc1100_write1(reg,data);
VICIntEnable |= VICInt;
}
void load_RF_setting(void) {
struct RFsettings_ RFsettings;
if(BFS_LoadFile(BFS_ID_RFsettings, sizeof(struct RFsettings_), (unsigned char*) &RFsettings) != sizeof(struct RFsettings_)) {
RFsettings = default_RFsettings;
BFS_SaveFile(BFS_ID_RFsettings, sizeof(struct RFsettings_), (unsigned char*) &RFsettings);
draw_string(0, 50, "default RF load", 3, DRAW_PUT);
}
RF_setRegister(0x09, RFsettings.address);
RF_setRegister(0x0a, RFsettings.channel);
RF.addr = RFsettings.address;
}
void RFasyncmode(unsigned char on) {
if(on) {
RF_changestate(RFidle);
while(RF.state != RFidle);
stopRFIRQ();
cc1100_write((0x00 | BURST ),(unsigned char*)confasync,sizeof((unsigned char*)confasync));
cc1100_write1(PATABLE,0xf0);
PINSEL1 &= 0xfffffffc; // GDO0 as GPIO
FIODIR0 |= GDO0; // output
}
else {
PINSEL1 |= 1; // GDO0 as EINT0
cc1100_write((0x00 | BURST ),(unsigned char*)conf,sizeof((unsigned char*)conf));
cc1100_write1(PATABLE,0xC0);
cc1100_strobe(SIDLE);
load_RF_setting();
startRFIRQ();
RF_changestate(RFwor);
}
}

View file

@ -1,110 +0,0 @@
/*
rf.h -
Copyright (C) 2008
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RF_H
#define RF_H
#define WORrx_time 200
#define packet_test 0x01
#define packet_ping 0x02
#define packet_time 0x03
#define packet_RFenc 0x04
#define packet_redirDAT 0x05
#define packet_redirCMD 0x06
#define MAX_ENDPOINTS 0x0F
struct cc1100frame_ {
unsigned char len;
unsigned char destAddr;
unsigned char srcAddr;
unsigned char packetType;
unsigned char data[];
};
struct RFendpoint_ {
union {
unsigned char* buffer;
struct cBuffer_* cbuffer;
unsigned char data[4];
};
unsigned short buffersize;
unsigned short bufferlen;
volatile unsigned short flags;
unsigned char dest;
unsigned char type;
};
//RFendpoints_.flags
#define EPenabled (1<<0)
#define EPoutput (1<<1)
#define EPinput 0
#define EPtypedata (1<<2)
#define EPtypebuffer 0
#define EPtypecbuffer (1<<3)
#define EPtypemask (1<<2 | 1<<3)
#define EPnewdata (1<<4)
#define EPoverwritten (1<<5)
#define EPoverflow (1<<6)
#define EPonce (1<<7)
#define EPsendwor (1<<8)
struct RFsettings_ {
unsigned char address;
unsigned char channel;
}__attribute__((aligned(0x4)));
const struct RFsettings_ default_RFsettings;
struct RF_ {
unsigned char addr;
volatile unsigned char flags;
volatile unsigned char state;
volatile unsigned char timeout_cb;
volatile unsigned char wortimeout_cb;
volatile unsigned char nextstate;
volatile unsigned char tag;
}__attribute__((aligned(0x4)));
struct RF_ RF;
//RF_.state
#define RFpwrdown 0x00
#define RFwor 0x01
#define RFidle 0x02
#define RFrx 0x03
#define RFtx 0x04
#define RFsendwor 0x05
#define RFsendworend 0x06
//RF.flags
#define PingACK (1<<0)
#define WORenabled (1<<1)
#define RXueop (1<<2) //MCSM2 RX_TIME: Until end of packet
void startRFIRQ(void);
void RF_init (void);
void RF_timed_rx(unsigned short timeout);
void RF_changestate (unsigned char state);
unsigned char RF_sendping(unsigned char dest);
struct RFendpoint_* openEP(void* buffer, unsigned short buffersize, unsigned char type);
void closeEP(struct RFendpoint_ *cur_ep);
void RF_setRegister(unsigned char reg, unsigned char data);
void load_RF_setting(void);
void RFasyncmode(unsigned char on);
#endif

View file

@ -1,151 +0,0 @@
//~ DN508 - Frequency Scanning using CC430Fx, CC110x, and CC111xFx
void scanFreqBands_autocal(void) {
UINT8 subBand;
UINT8 i;
UINT16 channel;
// 1) Loop through all sub bands
for (subBand = 0; subBand < NUMBER_OF_SUB_BANDS; subBand++)
{
// 1.1) Set the base freq. for the current sub band. The values for FREQ2, FREQ1, and FREQ0 can be found in
// freqSettings[subBand][n], where n = 0, 1, or 2
// 1.2) Set TEST0 register = 0x0B
// 1.3) Loop through all channels
for (channel = 0; channel <= lastChannel[subBand]; channel++ )
{
UINT8 pktStatus;
// 1.3.1) Set CHANNR register = channel
// 1.3.2) Change TEST0 register settings to 0x09 if freq is above 861 MHz
if (channel == limitTest0Reg[subBand])
{
// 1.3.2.1) Set TEST0 register = 0x09
}
// 1.3.3) Enter RX mode by issuing an SRX strobe command
// 1.3.4) Wait for radio to enter RX state (can be done by polling the MARCSTATE register)
// 1.3.5) Wait for RSSI to be valid (See DN505 [7] on how long to wait)
// 1.3.6) Read the PKTSTATUS register while the radio is in RX state (store it in pktStatus)
// 1.3.7) Enter IDLE state by issuing an SIDLE strobe command
// 1.3.8) Check if CS is asserted (use the value obtained in 1.3.6)
if (pktStatus & 0x40)
{
// CS is asserted
// 1.3.8.1) Read RSSI value and store it in rssi_dec
// 1.3.8.2) Calculate RSSI in dBm (rssi_dBm)(offset value found in rssi_offset[subBand])
// 1.3.8.3) Store the RSSI value and the corresponding channel number
rssiTable[carrierSenseCounter] = rssi_dBm;
channelNumber[carrierSenseCounter] = channel;
carrierSenseCounter++;
}
} // End Channel Loop
// 1.4) Before moving on to the next sub band, scan through the rssiTable to find the highest RSSI value. Store
// the RSSI value in highRSSI[subBand] and the corresponding channel number in selectedChannel[subBand]
for (i = 0; i < carrierSenseCounter; i++)
{
if (rssiTable[i] > highRSSI[subBand])
{
highRSSI[subBand] = rssiTable[i];
selectedChannel[subBand] = channelNumber[i];
}
}
// 1.5) Reset carrierSenseCounter
carrierSenseCounter = 0;
} // End Band Loop
// 2) When all sub bands have been scanned, find which sub band has the highest RSSI (Scan the highRSSI[subBand]
// table). Store the subBand (0, 1, or 2) and the corresponding channel in the global variables activeBand and
// activeChannel respectively
//~ {
INT16 tempRssi = -150;
for (subBand = 0; subBand < NUMBER_OF_SUB_BANDS; subBand++)
{
if (highRSSI[subBand] >= tempRssi)
{
tempRssi = highRSSI[subBand];
activeChannel = selectedChannel[subBand];
activeBand = subBand;
}
}
}
void scanFreqBands_noautocal(void) {
UINT8 subBand;
UINT8 i;
UINT16 channel;
// 1) Loop through all sub bands
for (subBand = 0; subBand < NUMBER_OF_SUB_BANDS; subBand++)
{
// 1.1) Set the base freq. for the current sub band. The values for FREQ2, FREQ1, and FREQ0 can be found in
// freqSettings[subBand][n], where n = 0, 1, or 2
// 1.2) Set TEST0 register = 0x0B
// 1.3) Reset Calibration Counter (calibration performed when counter is 0)
calCounter = 0;
// 1.4) Loop through all channels
for (channel = 0; channel <= lastChannel[subBand]; channel++ )
{
UINT8 pktStatus;
// 1.4.1) Set CHANNR register = channel
// 1.4.2) Change TEST0 register settings to 0x09 if freq is above 861 MHz. When TEST0 is changed to 0x09, it
// is important that FSCAL2 is set to 0x2A and that a new calibration is performed
if (channel == limitTest0Reg[subBand])
{
// 1.4.2.1) Set TEST0 register = 0x09
// 1.4.2.2) Set FSCAL2 register = 0x2A
// 1.4.2.3) Calibration is needed when TEST0 is changed
calCounter = 0;
}
// 1.4.3) Calibrate for every 5th ch. + at start of every sub band and every time the TEST0 reg. is changed
if (calCounter++ == 0)
{
// 1.4.3.1) Perform a manual calibration by issuing an SCAL strobe command
}
// 1.4.4)) Reset Calibration Counter (if calCounter = 5, we are 1 MHz away from the frequency where a
// calibration was performed)
if (calCounter == 5)
{
// 1.4.4.1) Calibration is performed if calCounter = 0
calCounter = 0;
}
// 1.4.5) Enter RX mode by issuing an SRX strobe command
// 1.4.6) Wait for radio to enter RX state (can be done by polling the MARCSTATE register)
// 1.4.7) Wait for RSSI to be valid (See DN505 [7] on how long to wait)
// 1.4.8) Read the PKTSTATUS register while the radio is in RX state (store it in pktStatus)
// 1.4.9) Enter IDLE state by issuing an SIDLE strobe command
// 1.4.10) Check if CS is asserted (use the value obtained in 1.4.8)
if (pktStatus & 0x40)
{ // CS is asserted
// 1.4.10.1) Read RSSI value and store it in rssi_dec
// 1.4.10.2) Calculate RSSI in dBm (rssi_dBm)(offset value found in rssi_offset[subBand])
// 1.4.10.3) Store the RSSI value and the corresponding channel number
rssiTable[carrierSenseCounter] = rssi_dBm;
channelNumber[carrierSenseCounter] = channel;
carrierSenseCounter++;
}
} // End Channel Loop
// 1.5) Before moving on to the next sub band, scan through the rssiTable to find the highest RSSI value. Store
// the RSSI value in highRSSI[subBand] and the corresponding channel number in selectedChannel[subBand]
for (i = 0; i < carrierSenseCounter; i++)
{
if (rssiTable[i] > highRSSI[subBand])
{
highRSSI[subBand] = rssiTable[i];
selectedChannel[subBand] = channelNumber[i];
}
}
// 1.6) Reset carrierSenseCounter
carrierSenseCounter = 0;
} // End Band Loop
// 2) When all sub bands have been scanned, find which sub band has the highest RSSI (Scan the highRSSI[subBand]
// table). Store the subBand (0, 1, or 2) and the corresponding channel in the global variables activeBand and
// activeChannel respectively
//~ {
INT16 tempRssi = -150;
for (subBand = 0; subBand < NUMBER_OF_SUB_BANDS; subBand++)
{
if (highRSSI[subBand] >= tempRssi)
{
tempRssi = highRSSI[subBand];
activeChannel = selectedChannel[subBand];
activeBand = subBand;
}
}
}

View file

@ -1,39 +0,0 @@
//~ DN508 - Frequency Scanning using CC430Fx, CC110x, and CC111xFx
#define NUMBER_OF_SUB_BANDS 3
// Variables used to calculate RSSI
UINT8 rssi_dec;
INT16 rssi_dBm;
UINT8 rssi_offset[NUMBER_OF_SUB_BANDS] = {77, 77, 77};
// Freq. Band Range Channel
// 0 779.009766 - 829.997314 0 - 255 All 0x0B
// 1 830.196869 - 881.184418 0 - 255 <- 154 = 0x0B, 155 -> = 0x09
// 2 881.384369 - 927.972992 0 - 233 All 0x09
INT16 rssiTable[256];
UINT16 channelNumber[256];
UINT8 carrierSenseCounter = 0; // Counter used to keep track on how many time CS has been asserted in one sub band
//(i.e. how many RSSI values are stored for each band)
// Stop Channel in each of the sub bands
UINT8 lastChannel[NUMBER_OF_SUB_BANDS] = { 255, 255, 233};
// Channel number for each of the sub bands where one should change from TEST0 = 0x0B to TEST0 = 0x09
UINT16 limitTest0Reg[NUMBER_OF_SUB_BANDS] = { 256, 155, 0 };
// Initialized to a value lower than the RSSI threshold
INT16 highRSSI[NUMBER_OF_SUB_BANDS] = { -150, -150, -150};
// Initialized to a value greater than the highest channel number
UINT16 selectedChannel[NUMBER_OF_SUB_BANDS] = { 300, 300, 300};
// {FREQ2, FREQ1, FREQ0}
UINT8 freqSettings[NUMBER_OF_SUB_BANDS][3] = { {0x1D, 0xF6, 0x40},
{0x1F, 0xEE, 0x3F},
{0x21, 0xE6, 0x3F}};
UINT8 activeBand; // After the scanFreqBands() function has run, this variable will contain the sub band where
// the strongest signal was found
UINT16 activeChannel; // After the scanFreqBands() function has run, this variable will contain the channel number
// where the strongest signal was found
UINT8 calCounter = 0; // This variable is only used when running the code shown in Figure 3

View file

@ -25,22 +25,22 @@
.global _stack
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000004 /* stack for "undefined instruction" interrupts is 4 bytes */
.set ABT_STACK_SIZE, 0x00000004 /* stack for "abort" interrupts is 4 bytes */
.set FIQ_STACK_SIZE, 0x00000104 /* stack for "FIQ" interrupts is 4 bytes */
.set IRQ_STACK_SIZE, 0X000003F0 /* stack for "IRQ" normal interrupts is 4 bytes */
.set SVC_STACK_SIZE, 0x00000004 /* stack for "SVC" supervisor mode is 4 bytes */
.set UND_STACK_SIZE, 0x00000004 /* stack for "undefined instruction" interrupts is 4 bytes */
.set ABT_STACK_SIZE, 0x00000004 /* stack for "abort" interrupts is 4 bytes */
.set FIQ_STACK_SIZE, 0x00000004 /* stack for "FIQ" interrupts is 4 bytes */
.set IRQ_STACK_SIZE, 0X00000100 /* stack for "IRQ" normal interrupts is 4 bytes */
.set SVC_STACK_SIZE, 0x00000004 /* stack for "SVC" supervisor mode is 4 bytes */
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs */
.set MODE_USR, 0x10 /* Normal User Mode */
.set MODE_FIQ, 0x11 /* FIQ Processing Fast Interrupts Mode */
.set MODE_IRQ, 0x12 /* IRQ Processing Standard Interrupts Mode */
.set MODE_SVC, 0x13 /* Supervisor Processing Software Interrupts Mode */
.set MODE_ABT, 0x17 /* Abort Processing memory Faults Mode */
.set MODE_UND, 0x1B /* Undefined Processing Undefined Instructions Mode */
.set MODE_SYS, 0x1F /* System Running Priviledged Operating System Tasks Mode */
.set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */
.set F_BIT, 0x40 /* when F bit is set, FIQ is disabled (program status registers) */
.set MODE_USR, 0x10 /* Normal User Mode */
.set MODE_FIQ, 0x11 /* FIQ Processing Fast Interrupts Mode */
.set MODE_IRQ, 0x12 /* IRQ Processing Standard Interrupts Mode */
.set MODE_SVC, 0x13 /* Supervisor Processing Software Interrupts Mode */
.set MODE_ABT, 0x17 /* Abort Processing memory Faults Mode */
.set MODE_UND, 0x1B /* Undefined Processing Undefined Instructions Mode */
.set MODE_SYS, 0x1F /* System Running Priviledged Operating System Tasks Mode */
.set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */
.set F_BIT, 0x40 /* when F bit is set, FIQ is disabled (program status registers) */
.text
@ -48,94 +48,41 @@
.global Reset_Handler
.global _startup
.section .text.fastcode
.global _endstartup
.global ramvectors
.func ramvectors
ramvectors:
ldr PC, Ram_Reset_Addr
ldr PC, Ram_Undef_Addr
ldr PC, Ram_SWI_Addr
ldr PC, Ram_PAbt_Addr
ldr PC, Ram_DAbt_Addr
nop /* Reserved Vector (holds Philips ISP checksum) */
ldr PC, do_vic_addr /* Route IRQ to VIC */
ldr PC, Ram_FIQ_Addr
ldr PC, Ram_Reset_Addr
ldr PC, Ram_Undef_Addr
ldr PC, Ram_SWI_Addr
ldr PC, Ram_PAbt_Addr
ldr PC, Ram_DAbt_Addr
nop /* Reserved Vector (holds Philips ISP checksum) */
ldr PC, [PC,#-0xFF0] /* Route IRQ to VIC */
ldr PC, Ram_FIQ_Addr
Ram_Reset_Addr: .word Reset_Handler /* defined in this module below */
Ram_Undef_Addr: .word UNDEF_Routine /* defined in main.c */
Ram_SWI_Addr: .word SWI_Routine /* defined in main.c */
Ram_PAbt_Addr: .word UNDEF_Routine /* defined in main.c */
Ram_DAbt_Addr: .word UNDEF_Routine /* defined in main.c */
do_vic_addr: .word do_vic
Ram_FIQ_Addr: .word do_fiq /* defined in main.c */
.word 0 /* rounds vectors to 64 bytes total */
Ram_Reset_Addr: .word Reset_Handler /* defined in this module below */
Ram_Undef_Addr: .word UNDEF_Routine /* defined in main.c */
Ram_SWI_Addr: .word SWI_Routine /* defined in main.c */
Ram_PAbt_Addr: .word UNDEF_Routine /* defined in main.c */
Ram_DAbt_Addr: .word UNDEF_Routine /* defined in main.c */
Ram_IRQ_Addr: .word IRQ_Routine /* defined in main.c */
Ram_FIQ_Addr: .word FIQ_Routine /* defined in main.c */
.word 0 /* rounds vectors to 64 bytes total */
.endfunc
.global do_vic
.func do_vic
do_vic:
stmfd sp!, { r0-r5, r12, lr } /* save work regs & spsr on stack */
ldr r4, =VICVectAddr /* get the ISR address from VIC */
ldr r5, [r4]
mov lr, pc /* set return to common exit of ISR */
bx r5 /* go handle the interrupt */
/* mov pc, r5 /* go handle the interrupt */
str lr, [r4] /* update VICVectAddr */
ldmfd sp!, { r0-r5, r12, lr } /* restore work regs and spsr_irq */
subs pc, lr, #0x4 /* return, restoring CPSR from SPSR */
/*
stmfd sp!, { lr }
mrs lr, spsr
stmfd sp!, { r4-r5, lr }
ldr r4, =VICVectAddr
ldr r5, [r4]
msr cpsr_c, #0x13
stmfd sp!, { r0-r3, r12, lr }
mov lr, pc
bx r5
ldmfd sp!, { r0-r3, r12, lr }
msr cpsr_c, #0x92
str lr, [r4]
ldmfd sp!, { r4-r5, lr }
msr spsr_cxsf, lr
ldmfd sp!, { lr }
subs pc, lr, #0x4
*/
.endfunc
.global do_fiq
.func do_fiq
do_fiq:
stmfd sp!, { r0-r7, lr }
ldr r8, =FIQ_Routine
mov lr, pc
bx r8
ldmfd sp!, { r0-r7, lr }
subs pc, lr, #0x4
.endfunc
.section .text
.func _startup
_startup:
# Exception Vectors
_vectors:
ldr PC, Reset_Addr
ldr PC, Reset_Addr
Reset_Addr: .word Reset_Handler
@ -143,126 +90,110 @@ Reset_Addr: .word Reset_Handler
Reset_Handler:
/* Setup a stack for each mode - note that this only sets up a usable stack
for User mode. Also each mode is setup with interrupts initially disabled. */
ldr r0, =_stack_end
msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode */
mov sp, r0
/* Setup a stack for each mode - note that this only sets up a usable stack
for User mode. Also each mode is setup with interrupts initially disabled. */
ldr r0, =_stack_end
msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode */
mov sp, r0
sub r0, r0, #UND_STACK_SIZE
msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */
mov sp, r0
sub r0, r0, #ABT_STACK_SIZE
msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */
mov sp, r0
sub r0, r0, #FIQ_STACK_SIZE
msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
sub r0, r0, #SVC_STACK_SIZE
msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* User Mode */
mov sp, r0
sub r0, r0, #UND_STACK_SIZE
msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */
mov sp, r0
/* Setup Pins and Memory */
ldr r0,=BCFG0
ldr r1, =0x10000420
str r1,[r0]
str r1,[r0,#0x08]
sub r0, r0, #ABT_STACK_SIZE
msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */
mov sp, r0
ldr r0, =BCFG1
ldr r1, =0xc42
str r1, [r0]
sub r0, r0, #FIQ_STACK_SIZE
msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
ldr r0, =PINSEL0
ldr r1, =0x00008005
str r1, [r0]
sub r0, r0, #IRQ_STACK_SIZE
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
ldr r0, =PINSEL1
ldr r1, =0x20000000
str r1, [r0]
sub r0, r0, #SVC_STACK_SIZE
msr CPSR_c, #MODE_SYS|I_BIT|F_BIT /* User Mode */
mov sp, r0
ldr r0, =PINSEL2
ldr r1, =0x0de049d4
str r1, [r0]
/* Setup Pins and Memory */
ldr r0,=BCFG0
/* W B R */
/* P S B */
/* B W E E L */
/* AT|MW|M|P|R|R|reserved|WST2 |E|WST1 |r|IDCY */
/* --+--+-+-+-+-+--------+-----+-------+-+---- */
/* 3 | 2| | | |2| 2 1| 1 | | 0 |0| 0 */
/* 1 | 8| | | |4| 0 6| 2 | | 8 |4| 0 */
/* --+--+-+-+-+-+--------+-----+-------+-+---- */
/* ldr r1, =0x10000400 /* 00|01|0|0|0|0|00000000|00000|1|00000|0|0000 16bit, rble, 3wst - 10 mhz*/
/* ldr r1, =0x10000420 /* 00|01|0|0|0|0|00000000|00000|1|00001|0|0000 16bit, rble, 4wst - 30 mhz*/
ldr r1, =0x10001CA0 /* 00|01|0|0|0|0|00000000|00101|1|00101|0|0000 16bit, rble, 6wst - 60 mhz*/
ldr r0, = IO2SET
ldr r1, =0x1FC0000
str r1, [r0]
str r1, [r0,#0x04]
str r1,[r0] /* set bcfg0 (flash) */
str r1,[r0,#0x08] /* set bcfg2 (flash) */
ldr r0, = IO0DIR
ldr r1, =0x002018D0
str r1, [r0]
ldr r0, =BCFG1
/* ldr r1, =0x00000422 /* 00|00|0|0|0|0|00000000|00000|1|00001|0|0010 8 bit, 3 sram wst, rble, 5 wst 3 idcy*/
ldr r1, =0x00000C42 /* 00|00|0|0|0|0|00000000|00001|1|00010|0|0010 8 bit, 3 sram wst, rble, 5 wst 3 idcy*/
str r1, [r0] /* set bcfg1 (lcd) */
ldr r0, =PINSEL0
ldr r1, =0x00008005
str r1, [r0]
ldr r0, =PINSEL1
ldr r1, =0x00000000 /* gpio 0.30 */
str r1, [r0]
ldr r0, =PINSEL2
ldr r1, =0x0de049d4
str r1, [r0]
ldr r0, = IO2SET
ldr r1, =0x1FC0000
str r1, [r0]
str r1, [r0,#0x04]
ldr r0, = IO0DIR
ldr r1, =0x002018D0
str r1, [r0]
/* Setup PLL */
ldr r0, =0xe01fc000
ldr r2, =0xaa
ldr r3, =0x55
ldr r1, =0x03
str r1, [r0,#0x80] /* set pllcon to 0x03 = pll enable (0x01) + pll connect (0x02) */
ldr r1, =0x0
str r1, [r0,#0x100] /* set vbpdiv to 0x00 = 1/4th; 0x01 = 1/1, 0x02 = 1/2*/
/* ldr r1, =0x42 */
ldr r1, =0x45
str r1,[r0,#0x84] /* set pllcfg to 0x42 = psel = 10 (4) = msel= 00010 (3) = 240 mhz Fcco*/
str r2, [r0,#0x8c]
str r3, [r0,#0x8c]
/* Copy .fastcode & .data section (Copy from ROM to RAM) */
ldr R0, =__fastcode_load /*_etext*/
ldr r3, entry_mask /* this and the next instruction are an workaround */
and r0, r0, r3 /* for some ugly bug in winarm to force msb to 0x80 */
ldr R1, =__fastcode_start /*_data*/
ldr R2, =_edata
/* Setup PLL */
ldr r0, =0xe01fc000
ldr r2, =0xaa
ldr r3, =0x55
ldr r1, =0x03
str r1, [r0,#0x80]
ldr r1, =0x0
str r1, [r0,#0x100]
ldr r1, =0x42
str r1,[r0,#0x84]
str r2, [r0,#0x8c]
str r3, [r0,#0x8c]
_endstartup:
/* Copy .fastcode & .data section (Copy from ROM to RAM) */
ldr R0, =ramvectors /*_etext*/
ldr r3, entry_mask /* this and the next instruction are an workaround */
and r0, r0, r3 /* for some ugly bug in winarm to force msb to 0x80 */
ldr R1, =0x40000000 /*_data*/
ldr R2, =_startup
1:
cmp r1,r2
ldmltia r0!,{r3}
stmltia r1!,{r3}
blt 1b
cmp r1,r2
ldmltia r0!,{r3}
stmltia r1!,{r3}
blt 1b
/* Clear .bss section (Zero init) */
mov R0, #0
ldr R1, =_bss_start
ldr R2, =_bss_end
/* Clear .bss section (Zero init) */
mov R0, #0
ldr R1, =_bss_start
ldr R2, =_bss_end
2:
cmp R1, R2
strlo R0, [R1], #4
blo 2b
cmp R1, R2
strlo R0, [R1], #4
blo 2b
ldr r0, =MEMMAP
ldr r1, =0x02 /* irq vectors in ram */
str r1, [r0]
mov r0,#0
mov r1,r0
mov r2,r0
mov fp,r0
mov r7,r0
ldr r10,=main
mov lr,pc
bx r10
ldr r0, =MEMMAP
ldr r1, =0x02 /* irq vectors in ram */
str r1, [r0]
mov r0,#0
mov r1,r0
mov r2,r0
mov fp,r0
mov r7,r0
ldr r10,=main
mov lr,pc
bx r10
.endfunc
entry_mask: .word 0x8FFFFFFF /* defined in this module below */
entry_mask: .word 0x4FFFFFFF /* defined in this module below */
.end

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -1 +0,0 @@
THUMBSRCS := lcd.c fonty.c drawDigit.c drawIcon.c backlight.c

View file

@ -1,113 +0,0 @@
/*
backlight.c - lcd backlight control
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lpc2220.h"
#include "timerfuncs.h"
#include "backlight.h"
// backlight PWM is done in soundirq
// backlight timing is done by timer functions
extern volatile unsigned char bl_val;
unsigned char bl_max;
unsigned int bl_cb;
unsigned char direction;
unsigned char bl_speed; // n*5 ms between two steps of brightness
unsigned int bl_timeout;
void autoBL(unsigned int cb)
{
switch(direction)
{
case 0:
if(bl_val < bl_max)
{
bl_val++;
}
else
{
direction = 1;
setCBIntervall(bl_cb, bl_timeout);
}
break;
case 1:
direction = 2;
setCBIntervall(bl_cb, bl_speed);
break;
case 2:
if(bl_val > 0x00)
{
bl_val--;
}
else
{
direction = 0;
stopCB(bl_cb);
}
break;
}
}
// adds function autoBL to timer
// initialises parameters // TODO: vgl. load_setting (settingsmenu.c)
void initBacklight(void)
{
direction = 1;
bl_speed = 2;
bl_timeout = 5000;
bl_max = 63;
bl_cb = addTimerCB(autoBL, bl_timeout);
startCB(bl_cb);
}
// set new brightness and set up fading and timout
void setBacklight(unsigned char level)
{
if(level == BL_AUTO)
{
stopCB(bl_cb);
direction = 0;
setCBIntervall(bl_cb, bl_speed);
startCB(bl_cb);
}
else if(level < BL_AUTO)
{
stopCB(bl_cb);
bl_val = level;
direction = 1;
setCBIntervall(bl_cb, bl_timeout);
startCB(bl_cb);
}
}
void setBLSpeed(unsigned char s)
{
if(s > 0)
bl_speed = s;
}
void setBLTimeout(unsigned int t)
{
if(t > 0)
bl_timeout = t;
}

View file

@ -1,29 +0,0 @@
/*
backlight.h - lcd backlight control
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BACKLIGHT_H
#define BACKLIGHT_H
#define BL_OFF 0x00
#define BL_AUTO 0x40
#define BL_ON 0x80
void initBacklight(void);
void setBacklight(unsigned char level);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,127 +0,0 @@
/**********************************************************************
@file drawDigit.c
@brief Draw a scalable 7-segment digit
-----------------------------------------------------------------------
@author 2010 Roman Steiger
LeoTheLoewe [at] gmx [dot] de
-----------------------------------------------------------------------
Following compile flags are usable:
-----------------------------------------------------------------------
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
@History
1.00 10012010 RSt Creation
@end
***********************************************************************/
#include "global.h"
#include "lcd.h"
#include "drawDigit.h"
// |<- w ->|
// | |
// |d|1| w1|1|d|
// ___ ______
// _ |_a_| _ _2_ ^
// | | | | |
// d | | f h1
// |_| ___ |_| ___ h
// _ |_b_| _ 1
// | | | |
// e | | g |
// |_| ___ |_| v
// |_c_| _2____
//
#define DIGIT_SEG_A _BV (0)
#define DIGIT_SEG_B _BV (1)
#define DIGIT_SEG_C _BV (2)
#define DIGIT_SEG_D _BV (3)
#define DIGIT_SEG_E _BV (4)
#define DIGIT_SEG_F _BV (5)
#define DIGIT_SEG_G _BV (6)
#define DIGIT_SEG_H _BV (7)
const unsigned char digitSegPattern [] =
{
/* 0 */ DIGIT_SEG_A | DIGIT_SEG_C | DIGIT_SEG_D | DIGIT_SEG_E | DIGIT_SEG_F | DIGIT_SEG_G,
/* 1 */ DIGIT_SEG_F | DIGIT_SEG_G,
/* 2 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_E | DIGIT_SEG_F ,
/* 3 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_F | DIGIT_SEG_G,
/* 4 */ DIGIT_SEG_B | DIGIT_SEG_D | DIGIT_SEG_F | DIGIT_SEG_G,
/* 5 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_D | DIGIT_SEG_G,
/* 6 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_D | DIGIT_SEG_E | DIGIT_SEG_G,
/* 7 */ DIGIT_SEG_A | DIGIT_SEG_F | DIGIT_SEG_G,
/* 8 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_D | DIGIT_SEG_E | DIGIT_SEG_F | DIGIT_SEG_G,
/* 9 */ DIGIT_SEG_A | DIGIT_SEG_B | DIGIT_SEG_C | DIGIT_SEG_D | DIGIT_SEG_F | DIGIT_SEG_G
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void drawDigit (unsigned char x, unsigned char y,
unsigned char w, unsigned char h,
unsigned char digit, unsigned char d, unsigned char c, unsigned char m)
{
char w1 = w - 2*d - 2;
char h1 = (h - 5) / 2;
unsigned char i, mode, pattern;
pattern = 0;
if (digit <= 9)
pattern = digitSegPattern [digit];
w1 = max (w1, 3);
h1 = max (h1, 3);
if (!d)
d = DIGIT_BAR_WIDTH;
for (i = 0; i < 3; i++)
{
mode = DRAW_ERASE;
if (pattern & _BV (i+0))
mode = m;
draw_block (x + d+1, y + i*(h1+1),
w1, d,
c, mode);
}
for (i = 0; i < 2; i++)
{
mode = DRAW_ERASE;
if (pattern & _BV (i+3))
mode = m;
draw_block (x, y + d-1 + i*(h1+1),
d, h1,
c, mode);
}
for (i = 0; i < 2; i++)
{
mode = DRAW_ERASE;
if (pattern & _BV (i+5))
mode = m;
draw_block (x + d + 1 + w1 + 1, y + d-1 + i*(h1+1),
d, h1,
c, mode);
}
} // drawDigit
//-----------------------------------------------------------------------------

View file

@ -1,68 +0,0 @@
/**********************************************************************
@file drawDigit.h
@brief Draw a scalable 7-segment digit
-----------------------------------------------------------------------
@author 2010 Roman Steiger
LeoTheLoewe [at] gmx [dot] de
-----------------------------------------------------------------------
Following compile flags are usable:
-----------------------------------------------------------------------
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
@History
1.00 10012010 RSt Creation
@end
***********************************************************************/
#ifndef __DRAW_DIGIT_H__
#define __DRAW_DIGIT_H__
#include "global.h"
#include "lcd.h"
#ifndef DIGIT_BAR_WIDTH
#define DIGIT_BAR_WIDTH 3
#endif
// |<- w ->|
// | |
// |d|1| w1|1|d|
// ___ ______
// _ |_a_| _ _2_ ^
// | | | | |
// d | | f h1
// |_| ___ |_| ___ h
// _ |_b_| _ 1
// | | | |
// e | | g |
// |_| ___ |_| v
// |_c_| _2____
//
//-----------------------------------------------------------------------------
void drawDigit (unsigned char x, unsigned char y,
unsigned char w, unsigned char h,
unsigned char digit, unsigned char d, unsigned char c, unsigned char m);
//-----------------------------------------------------------------------------
#endif // #ifndef __DRAW_DIGIT_H__

View file

@ -1,363 +0,0 @@
/**********************************************************************
@file drawIcon.c
@brief Draw Black/White and Gray scale icons with or without
Alpha channel (Transparency)
-----------------------------------------------------------------------
@author 2010 Roman Steiger
LeoTheLoewe [at] gmx [dot] de
-----------------------------------------------------------------------
Following compile flags are usable:
-----------------------------------------------------------------------
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
@History
1.00 20012010 RSt Creation
@end
***********************************************************************/
#include "global.h"
#include "lcd.h"
#include "icon.h"
//-----------------------------------------------------------------------------
// Internally used functions
static void _drawGray (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char m);
static void _drawBlackWhite (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char c, unsigned char m);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void drawIcon (unsigned char x, unsigned char y,
const icon_t const *pIcon, unsigned char c, unsigned char m)
{
if (!pIcon)
return;
drawIconExt (x, y, pIcon->data,
pIcon->width, pIcon->height, pIcon->info,
c, m);
} // drawIcon
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void drawIconExt (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char c, unsigned char m)
{
switch (iconInfo)
{
case ICON_BLACK_WHITE_TRANSPARENT: /// 2 bpp
case ICON_BLACK_WHITE: /// 1 bpp
_drawBlackWhite (x, y, pData,
width, height, iconInfo,
c, m);
break;
case ICON_GRAY_TRANSPARENT: /// 3 bpp
case ICON_GRAY: /// 2 bpp
_drawGray (x, y, pData,
width, height, iconInfo,
m);
break;
default:
if (x + width > LCD_SIZE_X)
width = LCD_SIZE_X - x;
if (y + height > LCD_SIZE_Y)
height = LCD_SIZE_Y - y;
draw_rect (x, y,
width, height,
1, LCD_COLOR_B, DRAW_XOR);
break;
} // switch (iconInfo)
} // drawIconExt
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static void _drawGray (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char m)
{
unsigned char alphaBuf [LCD_SIZE_X];
unsigned short ix;
unsigned short iy;
unsigned char iconWidth = width;
unsigned char bpp;
unsigned char* alphaBuf_p;
if(iconInfo==ICON_GRAY_TRANSPARENT)
{
alphaBuf_p = alphaBuf;
bpp=3;
}
else
{
alphaBuf_p = NULL;
bpp=2;
}
if (x + width > LCD_SIZE_X)
width = LCD_SIZE_X - x;
if (y + height > LCD_SIZE_Y)
height = LCD_SIZE_Y - y;
unsigned short idx = (width * bpp); // 3 byte per pixel
unsigned char s = y & 0x07;
is_drawing++;
if (s)
{
for (ix = 0; ix < width; ix++)
{
alphaBuf [ix] = 0;
drawbuf [1][ix] = 0;
drawbuf [0][ix] = 0;
} // for (ix = 0; ix < width; ix++)
for (iy = 0; iy < height; iy += 8)
{
// Need to process two icon lines for one drawbuf line
if (iy)
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+2] >> (8-s);
drawbuf [1][ix] = pData [idx+1] >> (8-s);
drawbuf [0][ix] = pData [idx] >> (8-s);
} // for (ix = 0; ix < width; ix++)
// go back to end of this page
idx += (width * bpp); // 3bpp
// goto next page
idx += (iconWidth * bpp); // 3bpp
}
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] |= pData [idx+2] << s;
drawbuf [1][ix] |= pData [idx+1] << s;
drawbuf [0][ix] |= pData [idx] << s;
}
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
// go back to end of this page
idx += (width * bpp); // 3bpp
} // for (iy = 0; iy < height; iy += 8)
/* Pixel in the last page: height & 0x07
(i.e. 13 hight => 5 pixel in last page) */
if (((height & 0x07) == 0) ||
((height & 0x07) > (8 - s)))
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+2] >> (8-s);
drawbuf [1][ix] = pData [idx+1] >> (8-s);
drawbuf [0][ix] = pData [idx] >> (8-s);
} // for (ix = 0; ix < width; ix++)
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
}
}
else
{
for (iy = 0; iy < height; iy += 8)
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+2];
drawbuf [1][ix] = pData [idx+1];
drawbuf [0][ix] = pData [idx];
}
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
// go back to end of this page
idx += (width * bpp); // 3bpp
// goto next page
idx += (iconWidth * bpp); // 3bpp
} // for (iy = 0; iy < height; iy += 8)
} // else if (s)
is_drawing--;
} // _drawGrayAlpha
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static void _drawBlackWhite (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char c, unsigned char m)
{
unsigned char alphaBuf [LCD_SIZE_X];
unsigned short ix;
unsigned short iy;
unsigned char iconWidth = width;
unsigned char bpp;
unsigned char* alphaBuf_p;
if(iconInfo==ICON_BLACK_WHITE_TRANSPARENT)
{
alphaBuf_p = alphaBuf;
bpp=2;
}
else
{
alphaBuf_p = NULL;
bpp=1;
}
if (x + width > LCD_SIZE_X)
width = LCD_SIZE_X - x;
if (y + height > LCD_SIZE_Y)
height = LCD_SIZE_Y - y;
unsigned short idx = width * bpp; // 1 byte per pixel
unsigned char s = y & 0x07;
is_drawing++;
if (s)
{
for (ix = 0; ix < width; ix++)
{
alphaBuf [ix] = 0;
drawbuf [1][ix] = 0;
drawbuf [0][ix] = 0;
} // for (ix = 0; ix < width; ix++)
for (iy = 0; iy < height; iy += 8)
{
// Need to process two icon lines for one drawbuf line
if (iy)
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+1] >> (8-s);
if (c & 0x02)
drawbuf [0][ix] = pData [idx] >> (8-s);
else
drawbuf [0][ix] = 0;
if (c & 0x01)
drawbuf [1][ix] = pData [idx] >> (8-s);
else
drawbuf [1][ix] = 0;
} // for (ix = 0; ix < width; ix++)
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
// go back to end of this page
idx += width * bpp; // 1bpp
// goto next page
idx += iconWidth * bpp; // 1bpp
}
for (ix = 0; ix < width; ix++)
{
idx -=bpp;
alphaBuf [ix] = pData [idx+1] << s;
if (c & 0x02)
drawbuf [0][ix] |= pData [idx] << s;
if (c & 0x01)
drawbuf [1][ix] |= pData [idx] << s;
}
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
// go back to end of this page
idx += width * bpp; // 1bpp
} // for (iy = 0; iy < height; iy += 8)
/* Pixel in the last page: height & 0x07
(i.e. 13 hight => 5 pixel in last page) */
if (((height & 0x07) == 0) ||
((height & 0x07) > (8 - s)))
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+1] >> (8-s);
if (c & 0x02)
drawbuf [0][ix] = pData [idx] >> (8-s);
else
drawbuf [0][ix] = 0;
if (c & 0x01)
drawbuf [1][ix] = pData [idx] >> (8-s);
else
drawbuf [1][ix] = 0;
} // for (ix = 0; ix < width; ix++)
do_rcuAlpha (x, y+iy, width, m, alphaBuf_p);
}
}
else
{
for (iy = 0; iy < height; iy += 8)
{
for (ix = 0; ix < width; ix++)
{
idx -= bpp;
alphaBuf [ix] = pData [idx+1];
if (c & 0x02)
drawbuf [0][ix] = pData [idx];
else
drawbuf [0][ix] = 0;
if (c & 0x01)
drawbuf [1][ix] = pData [idx];
else
drawbuf [1][ix] = 0;
}
do_rcuAlpha (x, y+iy, width, m, alphaBuf);
// go back to end of this page
idx += width * bpp; // 1bpp
// goto next page
idx += iconWidth * bpp; // 1bpp
} // for (iy = 0; iy < height; iy += 8)
} // else if (s)
is_drawing--;
} // _drawBlackWhiteAlpha
//-----------------------------------------------------------------------------

View file

@ -1,113 +0,0 @@
/**********************************************************************
@file icon.c
@brief Definition of icon structure and appropriate functions
-----------------------------------------------------------------------
@author 2010 Roman Steiger
LeoTheLoewe [at] gmx [dot] de
-----------------------------------------------------------------------
Following compile flags are usable:
-----------------------------------------------------------------------
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-----------------------------------------------------------------------
@History
1.00 20012010 RSt Creation
@end
***********************************************************************/
#ifndef __ICON_H__
#define __ICON_H__
///////////////////////////////////////////////////////////////////
// ICON can be defined in the appropriate C file before
// including that header or the related icon files to define the
// actual type of the icon structure:
//
// >> #define ICON iconElement_t
//
///////////////////////////////////////////////////////////////////
#ifndef ICON
#define ICON icon_t
#endif
///////////////////////////////////////////////////////////////////
// ICON_INFO can be defined in the appropriate C file before
// including that header to save one byte in the icon structure:
//
// >> #define ICON_INFO(i)
//
///////////////////////////////////////////////////////////////////
#ifndef ICON_INFO
#define ICON_INFO(i) /* info = */ i,
#define ICON_INFO_ELEMENT unsigned char info; // additional one byte (iconType_t might be larger)
#endif
#ifndef ICON_INFO_ELEMENT
#define ICON_INFO_ELEMENT
//#define ICON_IS_GRAY(i) 0
#define ICON_IS_GRAY(i) (sizeof(i.data) > (i.height/8 + (i.height%8 ? 1 : 0)) * i.width + 2);
#else
#define ICON_IS_GRAY(i) ((i)->info >= ICON_GRAY)
#endif
typedef enum iconInfo_e
{
ICON_BLACK_WHITE, /// 1 bpp
ICON_BLACK_WHITE_TRANSPARENT, /// 2 bpp
ICON_GRAY, /// 2 bpp
ICON_GRAY_TRANSPARENT, /// 3 bpp
ICON_MAX
} iconInfo_t;
typedef struct icon_s
{
unsigned char width;
unsigned char height;
ICON_INFO_ELEMENT
unsigned char data [];
} icon_t, *icon_p;
typedef struct iconElement_s
{
unsigned char width;
unsigned char height;
unsigned char data [];
} iconElement_t, *iconElement_p;
#ifdef __cplusplus
extern "C" {
#endif
//-----------------------------------------------------------------------------
extern void drawIcon (unsigned char x, unsigned char y,
const icon_t const *pIcon,
unsigned char c, unsigned char m);
extern void drawIconExt (unsigned char x, unsigned char y,
const unsigned char const *pData,
unsigned char width, unsigned char height, iconInfo_t iconInfo,
unsigned char c, unsigned char m);
//-----------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif
#endif // #ifndef __ICON_H__

View file

@ -1,173 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\Hourglas.bmp
//
// ICON_GRAY - 2 bpp (Bit per Pixel)
// sizeof (iconHourglas.data) == 280
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconHourglas =
{
/* width = */ 28,
/* height = */ 40,
/* info = */ ICON_INFO (ICON_GRAY)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0x0e, 0x11,
0x3f, 0x1e,
0x7f, 0x3a,
0xff, 0x6a,
0xff, 0xca,
0xff, 0xca,
0x3f, 0x0a,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0xff, 0xca,
0xff, 0xca,
0xff, 0x6a,
0x7f, 0x3a,
0x3f, 0x1e,
0x0e, 0x11,
//--- Page 1 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x0f,
0xfe, 0xfd,
0x70, 0xb8,
0xe0, 0x70,
0xc0, 0xa0,
0x80, 0x50,
0x30, 0x80,
0xf0, 0x00,
0xf0, 0x00,
0xf0, 0x00,
0xf0, 0x08,
0x70, 0x88,
0xb0, 0xc8,
0xd8, 0x64,
0x78, 0xe4,
0x36, 0xf8,
0xfe, 0xfd,
0xff, 0x0f,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 2 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x00,
0xff, 0xff,
0x00, 0xff,
0x80, 0x80,
0xc1, 0xc0,
0x61, 0xb3,
0x3f, 0x12,
0x1c, 0x0f,
0x07, 0x00,
0x1d, 0x0e,
0x3f, 0x12,
0x63, 0xb5,
0xc1, 0xe2,
0x80, 0xc1,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x00,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 3 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0xfc,
0xff, 0x0f,
0x07, 0x0b,
0x81, 0x03,
0xc0, 0x01,
0xc0, 0x20,
0xe0, 0x10,
0xf0, 0x00,
0xf8, 0x00,
0xf0, 0x00,
0xe0, 0x10,
0xc0, 0x20,
0xc0, 0x01,
0x81, 0x03,
0x03, 0x87,
0x0e, 0x17,
0xff, 0x1f,
0xff, 0xf8,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 4 ---
0x70, 0x88,
0xfc, 0x78,
0xfe, 0x7c,
0xff, 0x76,
0xff, 0x77,
0xff, 0x77,
0xff, 0x74,
0xfe, 0x75,
0xff, 0x74,
0xff, 0x74,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xfe, 0x75,
0xff, 0x74,
0xff, 0x77,
0xff, 0x77,
0xff, 0x76,
0xfe, 0x7c,
0xfc, 0x78,
0x70, 0x88
}
};

View file

@ -1,173 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: L:\Betty\Sourcecode\SVN\Betty_sourceforge\boop\trunk\display\Hourglas_2bpp.bmp
//
// ICON_BLACK_WHITE - 1 bpp (Bit per Pixel)
// sizeof (iconHourglas2.data) == 140
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconHourglas2 =
{
/* width = */ 28,
/* height = */ 40,
/* info = */ ICON_INFO (ICON_BLACK_WHITE)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0x0e,
0x3f,
0x7f,
0xff,
0xff,
0xff,
0x3f,
0x3b,
0x3b,
0x3b,
0x3b,
0x3b,
0x3b,
0x3f,
0x3f,
0x3f,
0x3f,
0x3f,
0x3f,
0x3f,
0x3f,
0x3f,
0xff,
0xff,
0xff,
0x7f,
0x3f,
0x0e,
//--- Page 1 ---
0x00,
0x00,
0x00,
0x00,
0xff,
0xff,
0xfe,
0x70,
0xe0,
0xc0,
0x80,
0x30,
0xf0,
0xf0,
0xf0,
0xf0,
0x70,
0xb0,
0xd8,
0x78,
0x36,
0xfe,
0xff,
0xff,
0x00,
0x00,
0x00,
0x00,
//--- Page 2 ---
0x00,
0x00,
0x00,
0x00,
0xff,
0xff,
0xff,
0x00,
0x80,
0xc1,
0x61,
0x3f,
0x1c,
0x07,
0x1d,
0x3f,
0x63,
0xc1,
0x80,
0x00,
0x00,
0xff,
0xff,
0xff,
0x00,
0x00,
0x00,
0x00,
//--- Page 3 ---
0x00,
0x00,
0x00,
0x00,
0xff,
0xff,
0xff,
0x07,
0x81,
0xc0,
0xc0,
0xe0,
0xf0,
0xf8,
0xf0,
0xe0,
0xc0,
0xc0,
0x81,
0x03,
0x0e,
0xff,
0xff,
0xff,
0x00,
0x00,
0x00,
0x00,
//--- Page 4 ---
0x70,
0xfc,
0xfe,
0xff,
0xff,
0xff,
0xff,
0xfe,
0xff,
0xff,
0xf7,
0xf7,
0xf7,
0xf7,
0xf7,
0xff,
0xff,
0xff,
0xff,
0xff,
0xfe,
0xff,
0xff,
0xff,
0xff,
0xfe,
0xfc,
0x70
}
};

View file

@ -1,178 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: L:\Betty\Sourcecode\SVN\Betty_sourceforge\boop\trunk\display\Hourglas_t_3bpp_t.bmp
//
// ICON_BLACK_WHITE_TRANSPARENT - 2 bpp (Bit per Pixel)
// sizeof (iconHourglas2_t.data) == 280
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconHourglas2_t =
{
/* width = */ 28,
/* height = */ 40,
/* info = */ ICON_INFO (ICON_BLACK_WHITE_TRANSPARENT)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
// v--- Alpha Channel
0x1f, 0x1f,
0x3f, 0x3f,
0x7f, 0x7f,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0x3f, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x7f, 0x7f,
0x3f, 0x3f,
0x1f, 0x1f,
//--- Page 1 ---
// v--- Alpha Channel
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xf8, 0xff,
0xf0, 0xff,
0xe0, 0xff,
0xd0, 0xff,
0xb0, 0xff,
0xf0, 0xff,
0xf0, 0xff,
0xf0, 0xff,
0xf8, 0xff,
0xf8, 0xff,
0xf8, 0xff,
0xfc, 0xff,
0xfc, 0xff,
0xfe, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 2 ---
// v--- Alpha Channel
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x80, 0x80,
0xc1, 0xc1,
0xf3, 0xf3,
0x3f, 0xff,
0x1f, 0xff,
0x07, 0xff,
0x1f, 0xff,
0x3f, 0xff,
0xf7, 0xf7,
0xe3, 0xe3,
0xc1, 0xc1,
0x00, 0x00,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 3 ---
// v--- Alpha Channel
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x0f, 0xff,
0x83, 0xff,
0xc1, 0xff,
0xe0, 0xff,
0xf0, 0xff,
0xf0, 0xff,
0xf8, 0xff,
0xf0, 0xff,
0xf0, 0xff,
0xe0, 0xff,
0xc1, 0xff,
0x83, 0xff,
0x87, 0xff,
0x1f, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 4 ---
// v--- Alpha Channel
0xf8, 0xf8,
0xfc, 0xfc,
0xfe, 0xfe,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xff, 0xff,
0xfe, 0xfe,
0xfc, 0xfc,
0xf8, 0xf8
}
};

View file

@ -1,178 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\Hourglas_t.bmp
//
// ICON_GRAY_TRANSPARENT - 3 bpp (Bit per Pixel)
// sizeof (iconHourglas_t.data) == 420
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconHourglas_t =
{
/* width = */ 28,
/* height = */ 40,
/* info = */ ICON_INFO (ICON_GRAY_TRANSPARENT)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
// v--- Alpha Channel
0x0e, 0x11, 0x1f,
0x3f, 0x1e, 0x3f,
0x7f, 0x3a, 0x7f,
0xff, 0x6a, 0xff,
0xff, 0xca, 0xff,
0xff, 0xca, 0xff,
0x3f, 0x0a, 0xff,
0x3b, 0x0e, 0xff,
0x3b, 0x0e, 0xff,
0x3b, 0x0e, 0xff,
0x3b, 0x0e, 0xff,
0x3b, 0x0e, 0xff,
0x3b, 0x0e, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0x3f, 0x0a, 0xff,
0xff, 0xca, 0xff,
0xff, 0xca, 0xff,
0xff, 0x6a, 0xff,
0x7f, 0x3a, 0x7f,
0x3f, 0x1e, 0x3f,
0x0e, 0x11, 0x1f,
//--- Page 1 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0xff, 0xff,
0xff, 0xff, 0xff,
0xff, 0x0f, 0xff,
0xfe, 0xfd, 0xff,
0x70, 0xb8, 0xff,
0xe0, 0x70, 0xff,
0xc0, 0xa0, 0xff,
0x80, 0x50, 0xff,
0x30, 0x80, 0xff,
0xf0, 0x00, 0xff,
0xf0, 0x00, 0xff,
0xf0, 0x00, 0xff,
0xf0, 0x08, 0xff,
0x70, 0x88, 0xff,
0xb0, 0xc8, 0xff,
0xd8, 0x64, 0xff,
0x78, 0xe4, 0xff,
0x36, 0xf8, 0xff,
0xfe, 0xfd, 0xff,
0xff, 0x0f, 0xff,
0xff, 0xff, 0xff,
0x00, 0xff, 0xff,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
//--- Page 2 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0xff, 0xff,
0xff, 0xff, 0xff,
0xff, 0x00, 0xff,
0xff, 0xff, 0xff,
0x00, 0xff, 0xff,
0x80, 0x80, 0x80,
0xc1, 0xc0, 0xc1,
0x61, 0xb3, 0xf3,
0x3f, 0x12, 0xff,
0x1c, 0x0f, 0xff,
0x07, 0x00, 0xff,
0x1d, 0x0e, 0xff,
0x3f, 0x12, 0xff,
0x63, 0xb5, 0xf7,
0xc1, 0xe2, 0xe3,
0x80, 0xc1, 0xc1,
0x00, 0x00, 0x00,
0x00, 0xff, 0xff,
0xff, 0xff, 0xff,
0xff, 0x00, 0xff,
0xff, 0xff, 0xff,
0x00, 0xff, 0xff,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
//--- Page 3 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0xff, 0xff,
0xff, 0xff, 0xff,
0xff, 0xfc, 0xff,
0xff, 0x0f, 0xff,
0x07, 0x0b, 0xff,
0x81, 0x03, 0xff,
0xc0, 0x01, 0xff,
0xc0, 0x20, 0xff,
0xe0, 0x10, 0xff,
0xf0, 0x00, 0xff,
0xf8, 0x00, 0xff,
0xf0, 0x00, 0xff,
0xe0, 0x10, 0xff,
0xc0, 0x20, 0xff,
0xc0, 0x01, 0xff,
0x81, 0x03, 0xff,
0x03, 0x87, 0xff,
0x0e, 0x17, 0xff,
0xff, 0x1f, 0xff,
0xff, 0xf8, 0xff,
0xff, 0xff, 0xff,
0x00, 0xff, 0xff,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
//--- Page 4 ---
// v--- Alpha Channel
0x70, 0x88, 0xf8,
0xfc, 0x78, 0xfc,
0xfe, 0x7c, 0xfe,
0xff, 0x76, 0xff,
0xff, 0x77, 0xff,
0xff, 0x77, 0xff,
0xff, 0x74, 0xff,
0xfe, 0x75, 0xff,
0xff, 0x74, 0xff,
0xff, 0x74, 0xff,
0xf7, 0x7c, 0xff,
0xf7, 0x7c, 0xff,
0xf7, 0x7c, 0xff,
0xf7, 0x7c, 0xff,
0xf7, 0x7c, 0xff,
0xff, 0x74, 0xff,
0xff, 0x74, 0xff,
0xff, 0x74, 0xff,
0xff, 0x74, 0xff,
0xff, 0x74, 0xff,
0xfe, 0x75, 0xff,
0xff, 0x74, 0xff,
0xff, 0x77, 0xff,
0xff, 0x77, 0xff,
0xff, 0x76, 0xff,
0xfe, 0x7c, 0xfe,
0xfc, 0x78, 0xfc,
0x70, 0x88, 0xf8
}
};

File diff suppressed because it is too large Load diff

View file

@ -1,153 +0,0 @@
/*
lcd.h - lcd control & graphics primitives
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LCD_H
#define LCD_H
// the lcd data & command ports
#define LCD_CMD (*((volatile unsigned char *) 0x81000000))
#define LCD_DATA (*((volatile unsigned char *) 0x81000001))
// LCD commands
#define LCD_CONTRAST 0x3A // original 0x3F (0..63)
#define LCD_GRAYMODE_88 0x00 // original 0x3F
#define LCD_GRAYMODE_89 0x00 // original 0x3F
#define LCD_GRAYMODE_8A 0x36 // original 0x33
#define LCD_GRAYMODE_8B 0x63 // original 0x33
#define LCD_GRAYMODE_8C 0x67 // original 0x66
#define LCD_GRAYMODE_8D 0x76 // original 0x66
#define LCD_GRAYMODE_8E 0xAC // original 0x99
#define LCD_GRAYMODE_8F 0xCA // original 0x99
#define LCD_DCDCx3 0x64 //
#define LCD_DCDCx4 0x65 //
#define LCD_DCDCx5 0x66 //
//~ #define LCD_DCDCx? 0x67 // ? datasheet p. 33
#define LCD_IRRR_1 0x20 //
#define LCD_IRRR_2 0x21 //
#define LCD_IRRR_3 0x22 //
#define LCD_IRRR_4 0x23 //
#define LCD_IRRR_5 0x24 //
#define LCD_IRRR_6 0x25 //
#define LCD_IRRR_7 0x26 //
#define LCD_IRRR_8 0x27 //
#define LCD_ALLON 0xA4 // black
#define LCD_ALLOFF 0xA5 // white
#define LCD_NORMAL 0xA6 //
#define LCD_REVERSE 0xA7 //
#define LCD_SLEEP 0xA9 // enter Sleep Mode. internal oscillator and LCD powersupply off
#define LCD_OSC_START 0xAB //
#define LCD_OFF 0xAE //
#define LCD_ON 0xAF //
#define LCD_WAKEUP 0xE1 //
#define LCD_RESET 0xE2 //
// drawmodes
#define DRAW_PUT 0
#define DRAW_XOR 1
#define DRAW_ERASE 2
#define DRAW_ALPHA 3
#define DRAW_NORCU 4
#define LCD_COLOR_W 0
#define LCD_COLOR_LG 1
#define LCD_COLOR_DG 2
#define LCD_COLOR_B 3
#define LCD_SIZE_X 128
#define LCD_SIZE_Y 160
#define ARROW_UP 1
#define ARROW_DOWN 2
#define ARROW_LEFT 3
#define ARROW_RIGHT 4
#define ARROW_LEN 4
#define TOP_LEFT 0
#define TOP_RIGHT 1
#define BOTTOM_LEFT 2
#define BOTTOM_RIGHT 3
#define BORDER_LEFT 0
#define BORDER_RIGHT 127
extern unsigned char drawbuf[2][LCD_SIZE_X];
extern unsigned int is_drawing;
extern volatile unsigned char symbols;
extern volatile unsigned char oldsymbols;
#define symbolRF (1<<0)
extern const unsigned char symIR[];
typedef void(*rcu_fn)(unsigned char x, unsigned char y, unsigned char l, unsigned char m);
typedef void (*rcuAlpha_fn) (unsigned char x, unsigned char y, unsigned char l, unsigned char m,
unsigned char* alphaBuf);
typedef void(*rcus_fn)(unsigned char x, unsigned char y, unsigned char m);
typedef void(*bl_fn)(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c, unsigned char m);
typedef void(*ln_fn)(unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m);
// Function pointer to section (".text.fastcode")
extern rcu_fn do_rcu;
extern rcuAlpha_fn do_rcuAlpha;
extern rcus_fn do_rcuS;
extern bl_fn draw_block;
extern ln_fn draw_hline;
extern ln_fn draw_vline;
extern void lcd_set (unsigned char s);
extern void lcd_init (unsigned char s);
extern void lcd_enable (unsigned char e);
//extern void do_rcu(unsigned char x, unsigned char y, unsigned char l, unsigned char m);
//extern void do_rcuAlpha (unsigned char x, unsigned char y, unsigned char l, unsigned char m,
// unsigned char* alphaBuf);
//extern void do_rcuS(unsigned char x, unsigned char y, unsigned char m);
extern void lcd_set_contrast(unsigned char c);
extern void lcd_fill (unsigned char f);
extern void draw_logo (void);
//extern void draw_block (unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c, unsigned char m);
//extern void draw_hline (unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m);
//extern void draw_vline (unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m);
extern void draw_rect (unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char lw, unsigned char c, unsigned char m);
extern void draw_pixel (unsigned char x, unsigned char y, unsigned char c, unsigned char m);
extern void draw_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char c, unsigned char m);
extern void draw_circle (unsigned char cx, unsigned char cy, unsigned char radius, unsigned char c, unsigned char m);
extern void draw_qcircle (unsigned char cx, unsigned char cy, unsigned char radius, unsigned char quarter, unsigned char c, unsigned char m);
extern void draw_disc (unsigned char cx, unsigned char cy, unsigned char radius, unsigned char c, unsigned char m);
extern void draw_qdisc (unsigned char cx, unsigned char cy, unsigned char radius, unsigned char quarter, unsigned char c, unsigned char m);
extern unsigned char draw_arrow (int x, int y, unsigned char ArrowDir, int ArrowLen, unsigned char Color, unsigned char Mode);
extern void draw_frame(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char t, unsigned char r, unsigned char c, unsigned char m);
extern void draw_symbol(unsigned char x, unsigned char y, unsigned char l,unsigned char* data, unsigned char c, unsigned char m);
extern void refresh_symbols(unsigned int cb);
extern void redraw_symbols(void);
extern void update_active_ind (void);
#endif

7
boop/externs.h Normal file
View file

@ -0,0 +1,7 @@
#ifndef EXTERNS_H
#define EXTERNS_H
extern unsigned int keys[2];
extern unsigned char autorepeat;
#endif

View file

@ -172,24 +172,3 @@ done:
return 0;
}
unsigned short getFlashID(void) {
unsigned short manufactor = 0;
unsigned short device = 0;
*((volatile unsigned short *) FLASH1_BASE + 0x555) = 0xAA;
*((volatile unsigned short *) FLASH1_BASE + 0x2AA) = 0x55;
*((volatile unsigned short *) FLASH1_BASE + 0x555) = 0x90;
manufactor = *((volatile unsigned short *) FLASH1_BASE + 0x100);
(*((volatile unsigned short *) FLASH1_BASE)) = 0xF0;
*((volatile unsigned short *) FLASH1_BASE + 0x555) = 0xAA;
*((volatile unsigned short *) FLASH1_BASE + 0x2AA) = 0x55;
*((volatile unsigned short *) FLASH1_BASE + 0x555) = 0x90;
device = *((volatile unsigned short *) FLASH1_BASE + 0x01);
(*((volatile unsigned short *) FLASH1_BASE)) = 0xF0;
return(((manufactor << 8) & 0xFF00) | (device & 0x00FF));
}

View file

@ -22,8 +22,6 @@
#define FLASH0_BASE 0x80000000
#define FLASH1_BASE 0x82000000
const unsigned long secaddr[19];
void prepareBulk(unsigned long dst);
void endBulk(unsigned long dst);
int eraseSector(unsigned char chip, unsigned char secnum);
@ -31,6 +29,5 @@ int eraseFlash(unsigned char chip);
int writeWord(unsigned long addr, unsigned short data);
int writeBulk(unsigned long src, unsigned long dst, unsigned long cnt);
void lcd_set(unsigned char s);
unsigned short getFlashID(void);
#endif

View file

@ -1 +0,0 @@
THUMBSRCS := flash.c bfs.c

View file

@ -1,730 +0,0 @@
/*
bfs.c - Betty File System
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "bfs.h"
#include "flash.h"
#include "lcd.h"
#include "fonty.h"
#include "global.h"
extern const unsigned long secaddr[19];
//Public functions
unsigned char BFS_Mount()
{
//Return true=ok
unsigned char BfsSector;
unsigned long Offset;
unsigned long FileHeaderAddress;
unsigned char RecordInfo;
unsigned long Id;
unsigned short Len;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
const unsigned long BfsVersion = BFS_VERSION;
//Format
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
//lcd_fill(0);//Clr screen
//draw_string(0, 70, "init file system", 3, DRAW_PUT);
//draw_string(0, 80,"BfsSektor:", 3, DRAW_PUT);
//draw_hexC(60,80,BfsSector, 3, DRAW_PUT);
if(!BFS_IsSectorFormated(BfsSector))
{
//Unformated sector
//Erase sector
if(eraseSector(BFS_CHIP, BFS_FIRST_SECTOR + BfsSector) != 0)
{
return false;//Error
}
//Write sector header
Offset = BFS_GetPhyByteAddrFromBfsSector(BfsSector);
writeBuffer(Offset, (unsigned char*)BFS_MAGIC, 4);
writeBuffer(Offset + 4, (unsigned char*)&BfsVersion, 4);
}
}
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
glBfsDeletedBytes[BfsSector] = 0;
glBfsOffsetToFreeRecord[BfsSector] = 0;
FileHeaderAddress = BFS_SECTOR_HEADER_LEN + BFS_GetPhyByteAddrFromBfsSector(BfsSector);
do
{
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &Id, &Len, &FileBodyAddress, &IsFree, &IsActive);
if(IsFree)
{
glBfsOffsetToFreeRecord[BfsSector] = FileHeaderAddress - BFS_GetPhyByteAddrFromBfsSector(BfsSector);
}
else
{
if(!IsActive)
{
//Deleted
glBfsDeletedBytes[BfsSector] += (FileBodyAddress - FileHeaderAddress) + Len;
}
FileHeaderAddress = FileBodyAddress + Len;
}
}while(!IsFree);
}
//Init fill order
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
glBfsFillOrder[BfsSector] = BfsSector;
}
//Sort fill order
BFS_SortArray();
//Free sector number
if(glBfsOffsetToFreeRecord[glBfsFillOrder[BFS_SECTORS-1]] > BFS_SECTOR_HEADER_LEN)
{
//No free sector
//ASSERT(false);
return false;//Error
}
return true;//OK
}
unsigned short BFS_LoadFile(unsigned long Id, unsigned short MaxLen, unsigned char *Buffer)
{
//Return: ReadLen
unsigned long FileHeaderAddress;
unsigned char RecordInfo;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
if(!BFS_GetFileHeaderAddress(Id, &FileHeaderAddress))
{
return 0;//File not found
}
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
memcpy(Buffer, (unsigned char*)FileBodyAddress, min(FileBodyLen, MaxLen));
return min(FileBodyLen, MaxLen);//Error
}
unsigned char BFS_CmpFile(unsigned long Id, unsigned short MaxLen, unsigned char *Buffer)
{
//Return: ReadLen
unsigned long FileHeaderAddress;
unsigned char RecordInfo;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
int x;
if(!BFS_GetFileHeaderAddress(Id, &FileHeaderAddress))
{
return 0;//File not found
}
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
x=memcmp(Buffer, (unsigned char*)FileBodyAddress, min(FileBodyLen, MaxLen));
if (x)
return 0;//not equal
return 1;
}
void* BFS_LoadFileAddr(unsigned long Id)
{
//Return: ReadLen
unsigned long FileHeaderAddress;
unsigned char RecordInfo;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
if(!BFS_GetFileHeaderAddress(Id, &FileHeaderAddress))
{
return 0;//File not found
}
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
return (void*)FileBodyAddress;
}
unsigned char BFS_SaveFile(unsigned long Id, unsigned short Len, unsigned char *Buffer)
{
//Return true=OK
unsigned char BfsSector;
unsigned char RecordInfo;
int i;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
unsigned char OverridePossible;
unsigned char CreateNewFile;
unsigned char Byte;
unsigned long FileHeaderAddress;
unsigned char HeaderSize;
CreateNewFile = false;
if(BFS_GetFileHeaderAddress(Id, &FileHeaderAddress))
{
//File is already present
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
//Same len?
OverridePossible = false;
if(Len == FileBodyLen)
{
//Is override possible (no change from 0 to 1)?
OverridePossible = true;
for(i=0; i<Len; i++)
{
if(((unsigned char*)Buffer)[i] & (0xFF ^ readByte(FileBodyAddress+i)))
{
//0->1 error
OverridePossible = false;
}
}
}
if(OverridePossible)
{
if(writeBuffer(FileBodyAddress, Buffer, Len) != 0)
{
return false;//Error
}
}
else
{
//Delete existing file
Byte = (RecordInfo & 0x3F) | (BFS_TYPE_DELETED << 6);
writeBuffer(FileHeaderAddress, &Byte, 1);
glBfsDeletedBytes[BFS_ByteAddressToBfsSector(FileHeaderAddress)] += (FileBodyAddress - FileHeaderAddress) + FileBodyLen;
CreateNewFile = true;
}
}
else
{
//File not present
CreateNewFile = true;
}
while(CreateNewFile)
{
//Check free space
//Start with the fullest, ignore the last empty one
for(i=0; (i<(BFS_SECTORS-1)) && CreateNewFile; i++)
{
BfsSector = glBfsFillOrder[i];
FileHeaderAddress = glBfsOffsetToFreeRecord[BfsSector];
if((FileHeaderAddress + BFS_MAX_RECORD_HEADER_LEN + Len) < BFS_SECTOR_SIZE)
{
//Enough space free
BFS_WriteAtAddress(BFS_GetPhyByteAddrFromBfsSector(BfsSector) + FileHeaderAddress, Id, Len, Buffer, &HeaderSize);
glBfsOffsetToFreeRecord[BfsSector] += HeaderSize + Len;
BFS_SortArray();
CreateNewFile = false;
}
}
if(CreateNewFile)
{
//No space free
//copy only active files (not the files markes as deleted) to the empty sector and erase the source sector
if(!BFS_MakeSpace(Len))
{
//Still not enough space free
return false;//Error
}
}
}
return true;//OK
}
unsigned char BFS_DeleteFile(unsigned long Id)
{
//Return true=OK
//Return false=File not found/File was already deleted
unsigned char RecordInfo;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
unsigned char Byte;
unsigned long FileHeaderAddress;
if(BFS_GetFileHeaderAddress(Id, &FileHeaderAddress))
{
//File is present
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
//Delete existing file
Byte = (RecordInfo & 0x3F) | (BFS_TYPE_DELETED << 6);
writeBuffer(FileHeaderAddress, &Byte, 1);
glBfsDeletedBytes[BFS_ByteAddressToBfsSector(FileHeaderAddress)] += (FileBodyAddress - FileHeaderAddress) + FileBodyLen;
return true;//OK
}
return false;//File not found/File was already deleted
}
unsigned char BFS_DeleteAllFiles()
{
//Return true=ok
unsigned char BfsSector;
unsigned long Offset;
const unsigned long BfsVersion = BFS_VERSION;
//Format
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
//Erase sector
if(eraseSector(BFS_CHIP, BFS_FIRST_SECTOR + BfsSector) != 0)
{
return false;//Error
}
//Write sector header
Offset = BFS_GetPhyByteAddrFromBfsSector(BfsSector);
writeBuffer(Offset, (unsigned char*)BFS_MAGIC, 4);
writeBuffer(Offset + 4, (unsigned char*)&BfsVersion, 4);
glBfsDeletedBytes[BfsSector] = 0;
glBfsOffsetToFreeRecord[BfsSector] = BFS_SECTOR_HEADER_LEN;
}
//Sort fill order
BFS_SortArray();
return true;//OK
}
//Internal functions
unsigned char BFS_FlashToFlashCopy(unsigned long DstByteAddr, unsigned long SrcByteAddr, unsigned short ByteLen)
{
//Return true=OK
//TODO: optimize with Bulk prog
writeBuffer(DstByteAddr, (unsigned char*)SrcByteAddr, ByteLen);
return true;//OK
}
unsigned char BFS_MakeSpace(unsigned short RequiredFileBodySize)
{
//Return true=OK (now it is space free for the required size)
unsigned char BfsSector;
unsigned long Offset;
unsigned long DstAddress;
unsigned long FileHeaderAddress;
unsigned long FileBodyAddress;
unsigned short FileBodyLen;
unsigned char IsFree;
unsigned char IsActive;
unsigned long Id;
unsigned char RecordInfo;
unsigned char BfsSectorWithMostDelFiles;
const unsigned long BfsVersion = BFS_VERSION;
do
{
BfsSector = glBfsFillOrder[BFS_SECTORS - 2];
FileHeaderAddress = glBfsOffsetToFreeRecord[BfsSector];
if((FileHeaderAddress + BFS_MAX_RECORD_HEADER_LEN + RequiredFileBodySize) < BFS_SECTOR_SIZE)
{
//Enough space free
return true;//OK
}
//copy only active files (not the files markes as deleted)
//to the empty sector and erase the source sector
//Calc sector with most bytes marked as deleted
BfsSectorWithMostDelFiles = 0;
for(BfsSector=0; BfsSector<(BFS_SECTORS-1); BfsSector++)
{
if(glBfsDeletedBytes[BfsSector] > glBfsDeletedBytes[BfsSectorWithMostDelFiles])
{
BfsSectorWithMostDelFiles = BfsSector;
}
}
if(glBfsDeletedBytes[BfsSectorWithMostDelFiles] == 0)
{
//No sector has files marked as deleted -> nothing to free
return false;//Not enough space free
}
//Copy active files to the empty bfs sector
BfsSector = glBfsFillOrder[BFS_SECTORS - 1];//The empty destination sector
DstAddress = BFS_GetPhyByteAddrFromBfsSector(BfsSector) + BFS_SECTOR_HEADER_LEN;
FileHeaderAddress = BFS_GetPhyByteAddrFromBfsSector(BfsSectorWithMostDelFiles) + BFS_SECTOR_HEADER_LEN;//Source
do
{
BFS_GetFileHeaderInfo(FileHeaderAddress, &RecordInfo, &Id, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
if(IsActive)
{
//Copy the active file to the destination sector
BFS_FlashToFlashCopy(DstAddress, FileHeaderAddress, (FileBodyAddress - FileHeaderAddress) + FileBodyLen);
DstAddress += (FileBodyAddress - FileHeaderAddress) + FileBodyLen;
glBfsOffsetToFreeRecord[BfsSector] += (FileBodyAddress - FileHeaderAddress) + FileBodyLen;
}
FileHeaderAddress = FileBodyAddress + FileBodyLen;
}while(!IsFree);
//Erase the source sector
if(eraseSector(BFS_CHIP, BFS_FIRST_SECTOR + BfsSectorWithMostDelFiles) != 0)
{
return false;//Error
}
//Write sector header
Offset = BFS_GetPhyByteAddrFromBfsSector(BfsSectorWithMostDelFiles);
writeBuffer(Offset, (unsigned char*)BFS_MAGIC, 4);
writeBuffer(Offset + 4, (unsigned char*)&BfsVersion, 4);
glBfsDeletedBytes[BfsSectorWithMostDelFiles] = 0;
glBfsOffsetToFreeRecord[BfsSectorWithMostDelFiles] = BFS_SECTOR_HEADER_LEN;
BFS_SortArray();
}while(1);
return false;//Not enough space free
}
void BFS_SortArray()
{
//Sort the glBfsFillOrder array
unsigned char RepeatSort;
unsigned char BfsSector;
unsigned char Byte;
do
{
RepeatSort = false;
for(BfsSector=0; BfsSector<(BFS_SECTORS-1); BfsSector++)
{
if(glBfsOffsetToFreeRecord[glBfsFillOrder[BfsSector]] < glBfsOffsetToFreeRecord[glBfsFillOrder[BfsSector+1]])
{
//Swap
Byte = glBfsFillOrder[BfsSector];
glBfsFillOrder[BfsSector] = glBfsFillOrder[BfsSector+1];
glBfsFillOrder[BfsSector+1] = Byte;
RepeatSort = true;
}
}
}while(RepeatSort);
}
unsigned long BFS_GetPhyByteAddrFromBfsSector(unsigned char BfsSector)
{
//BFS_FIRST_SECTOR + BfsSector = PhyFlashSector
//ASSERT((BFS_FIRST_SECTOR + BfsSector) < FLASH_SECTORS);
return BFS_FLASH_BASE + (secaddr[BfsSector + BFS_FIRST_SECTOR] * 2);
}
unsigned char BFS_IsSectorFormated(unsigned char BfsSector)
{
//Is the sector formated and is the version valid
unsigned long Offset;
unsigned long Version;
Offset = BFS_GetPhyByteAddrFromBfsSector(BfsSector);
if(memcmp((unsigned char*)Offset, BFS_MAGIC, 4) != 0)
{
return false;//Magic not found -> not formated
}
Version = *((unsigned long*) (Offset + 4));
if(Version != BFS_VERSION)
{
return false;//Magic found but wrong version
}
return true;//Formated
}
void BFS_GetFileHeaderInfo(unsigned long FileHeaderAddress, unsigned char *pRecordInfo, unsigned long *pId, unsigned short *pLen, unsigned long *pFileBodyAddress, unsigned char *pIsFree, unsigned char *pIsActive)
{
unsigned char State;
unsigned char IdByteCount;
unsigned char LenByteCount;
unsigned long Offset;
Offset = FileHeaderAddress;
*pRecordInfo = readByte(Offset++);
State = ((*pRecordInfo) >> 6) & 0x03;
IdByteCount = 1 + (((*pRecordInfo) >> 1) & 0x03);
LenByteCount = 1 + ((*pRecordInfo) & 0x01);
if(State == BFS_TYPE_FREE)
{
//Free
*pIsFree = true;
*pIsActive = false;
*pId = 0;
*pLen = 0;
*pFileBodyAddress = 0;
}
else
{
//Active or deleted
*pIsFree = false;
*pIsActive = (State == BFS_TYPE_ACTIVE) ? true : false;
*pId = readByte(Offset++);
if(IdByteCount > 1)
{
*pId |= readByte(Offset++) << 8;
}
if(IdByteCount > 2)
{
*pId |= readByte(Offset++) << 16;
}
if(IdByteCount > 3)
{
*pId |= readByte(Offset++) << 24;
}
*pLen = readByte(Offset++);
if(LenByteCount > 1)
{
*pLen |= readByte(Offset++) << 8;
}
*pFileBodyAddress = Offset;
}
}
unsigned char BFS_GetFileHeaderAddress(unsigned long Id, unsigned long *pFileHeaderAddress)
{
//Return true = File is present, pFileHeaderAddress is valid
//Return false = File not found (e.g. deleted), pFileHeaderAddress is invalid
unsigned char BfsSector;
unsigned long PhyAddr;
unsigned char RecordInfo;
unsigned long TempId;
unsigned short FileBodyLen;
unsigned long FileBodyAddress;
unsigned char IsFree;
unsigned char IsActive;
*pFileHeaderAddress = 0;
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
PhyAddr = BFS_GetPhyByteAddrFromBfsSector(BfsSector) + BFS_SECTOR_HEADER_LEN;
do
{
BFS_GetFileHeaderInfo(PhyAddr, &RecordInfo, &TempId, &FileBodyLen, &FileBodyAddress, &IsFree, &IsActive);
if(IsActive && (TempId == Id))
{
//Found the correct file
*pFileHeaderAddress = PhyAddr;
return true;//OK
}
if(!IsFree)
{
//Skip this file
PhyAddr = FileBodyAddress + FileBodyLen;
}
}while(!IsFree);
}
return false;//File not found
}
unsigned char BFS_ByteAddressToBfsSector(unsigned long FileHeaderAddress)
{
unsigned char BfsSector;
unsigned long ByteAddress;
for(BfsSector=0; BfsSector<BFS_SECTORS; BfsSector++)
{
ByteAddress = BFS_GetPhyByteAddrFromBfsSector(BfsSector);
if((FileHeaderAddress >= ByteAddress) && (FileHeaderAddress < (ByteAddress + BFS_SECTOR_SIZE)))
{
return BfsSector;
}
}
//ASSERT(false);
BfsSector = 0xFF;//Error
return BfsSector;
}
unsigned char BFS_WriteAtAddress(unsigned long FileHeaderAddress, unsigned long Id, unsigned short Len, unsigned char *Buffer, unsigned char *pHeaderSize)
{
//Return true=OK
unsigned char RecordHeaderPos;
unsigned char RecordInfo;
unsigned char RecordHeader[BFS_MAX_RECORD_HEADER_LEN];
unsigned char IdByteCount;
unsigned char LenByteCount;
//IdByteCount
if(Id & 0xFF000000)
{
IdByteCount = BFS_ID_4BYTES;
}
else
{
if(Id & 0xFF0000)
{
IdByteCount = BFS_ID_3BYTES;
}
else
{
if(Id & 0xFF00)
{
IdByteCount = BFS_ID_2BYTES;
}
else
{
IdByteCount = BFS_ID_1BYTE;
}
}
}
//LenByteCount
LenByteCount = (Len < 0x100) ? BFS_ONE_LEN_BYTE : BFS_TWO_LEN_BYTES;
//RecordInfo
RecordInfo = (BFS_TYPE_ACTIVE << 6) | (IdByteCount << 1) | LenByteCount;
RecordHeaderPos = 0;
RecordHeader[RecordHeaderPos++] = RecordInfo;
//Id
RecordHeader[RecordHeaderPos++] = Id & 0xFF;
if(Id >= 0x100)
{
RecordHeader[RecordHeaderPos++] = (Id >> 8) & 0xFF;
if(Id >= 0x10000)
{
RecordHeader[RecordHeaderPos++] = (Id >> 16) & 0xFF;
if(Id >= 0x1000000)
{
RecordHeader[RecordHeaderPos++] = (Id >> 24) & 0xFF;
}
}
}
//Len
RecordHeader[RecordHeaderPos++] = Len & 0xFF;
if(Len >= 0x100)
{
RecordHeader[RecordHeaderPos++] = (Len >> 8) & 0xFF;
}
//Write record header
writeBuffer(FileHeaderAddress, RecordHeader, RecordHeaderPos);
//Write record data
writeBuffer(FileHeaderAddress + RecordHeaderPos, Buffer, Len);
*pHeaderSize = RecordHeaderPos;
return true;//OK
}
unsigned char readByte(unsigned long ByteAddr)
{
unsigned char Byte;
Byte = ((unsigned char*) ByteAddr)[0];
return Byte;
}
unsigned short readWord(unsigned long WordAddr)
{
//addr = unsigned short address
//int Offset;
unsigned short Word;
//ASSERT((WordAddr * 2) >= FLASH1_BASE);
//ASSERT((WordAddr * 2) < (FLASH1_BASE + FLASH_SIZE));
//Offset = (WordAddr * 2) - FLASH1_BASE;
Word = *((unsigned short *)(WordAddr<<1));
return Word;
}
int writeBuffer(unsigned long ByteAddr, unsigned char *buffer, unsigned short len)
{
//Return 0=OK
int Offset;
unsigned short Word;
Offset = 0;
if(ByteAddr & 1)
{
//Not word boundary
Word = readWord(ByteAddr / 2);
Word &= (buffer[Offset] << 8) | 0xFF;
writeWord(ByteAddr & 0xFFFFFFFE, Word);
Offset++;
ByteAddr++;
len--;
}
while(len >= 2)
{
Word = readWord(ByteAddr / 2);
Word &= buffer[Offset] | (buffer[Offset + 1] << 8);
writeWord(ByteAddr, Word);
Offset += 2;
ByteAddr += 2;
len -= 2;
}
if(len == 1)
{
Word = readWord(ByteAddr / 2);
Word &= 0xFF00 | buffer[Offset];
writeWord(ByteAddr, Word);
Offset++;
ByteAddr++;
len--;
}
return 0;//OK
}

View file

@ -1,86 +0,0 @@
/*
bfs.h - Betty File System
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BFS_H
#define BFS_H
//Define here your file ids (range 1 - 0xFFFFFFFF)
#define BFS_ID_remotes 1
#define BFS_ID_settings 2
#define BFS_ID_RFsettings 3
#define BFS_ID_RAWslot0 4
#define BFS_ID_RAWslot1 5
#define BFS_ID_RAWslot2 6
#define BFS_ID_RAWslot3 7
//Use last 3 64 KByte sectors (16..18) of the second chip for BFS
#define BFS_FIRST_SECTOR 16
#define BFS_SECTORS 3
#define BFS_SECTOR_SIZE 0x10000
#define BFS_SECTOR_HEADER_LEN 0x10
#define BFS_MAGIC "BFS"
#define BFS_VERSION 1
#define BFS_CHIP 1
#define BFS_TYPE_DELETED 0
#define BFS_TYPE_ACTIVE 1
#define BFS_TYPE_FREE 3
#define BFS_ID_1BYTE 0
#define BFS_ID_2BYTES 1
#define BFS_ID_3BYTES 2
#define BFS_ID_4BYTES 3
#define BFS_ONE_LEN_BYTE 0
#define BFS_TWO_LEN_BYTES 1
//Max. 1 info byte, 4 ID bytes, 2 length bytes
#define BFS_MAX_RECORD_HEADER_LEN (1+4+2)
#define BFS_FLASH_BASE FLASH1_BASE
unsigned long glBfsOffsetToFreeRecord[BFS_SECTORS];//Based on sector start
unsigned short glBfsDeletedBytes[BFS_SECTORS];//FileHeader + FileBody
unsigned char glBfsFillOrder[BFS_SECTORS];//[0]=Fullest
//Public
unsigned char BFS_Mount();//Call this before calling other BFS functions
unsigned short BFS_LoadFile(unsigned long Id, unsigned short MaxLen, unsigned char *Buffer);
unsigned char BFS_CmpFile(unsigned long Id, unsigned short MaxLen, unsigned char *Buffer);
void* BFS_LoadFileAddr(unsigned long Id);
unsigned char BFS_SaveFile(unsigned long Id, unsigned short Len, unsigned char *Buffer);
unsigned char BFS_DeleteFile(unsigned long Id);
unsigned char BFS_DeleteAllFiles();
//Internal
unsigned char BFS_FlashToFlashCopy(unsigned long DstByteAddr, unsigned long SrcByteAddr, unsigned short ByteLen);
unsigned char BFS_MakeSpace(unsigned short RequiredFileBodySize);
void BFS_SortArray();
unsigned long BFS_GetPhyByteAddrFromBfsSector(unsigned char BfsSector);
unsigned char BFS_IsSectorFormated(unsigned char BfsSector);
void BFS_GetFileHeaderInfo(unsigned long FileHeaderAddress, unsigned char *pRecordInfo, unsigned long *pId, unsigned short *pLen, unsigned long *pFileBodyAddress, unsigned char *pIsFree, unsigned char *pIsActive);
unsigned char BFS_GetFileHeaderAddress(unsigned long Id, unsigned long *pFileHeaderAddress);
unsigned char BFS_ByteAddressToBfsSector(unsigned long FileHeaderAddress);
unsigned char BFS_WriteAtAddress(unsigned long FileHeaderAddress, unsigned long Id, unsigned short Len, unsigned char *Buffer, unsigned char *pHeaderSize);
unsigned char readByte(unsigned long ByteAddr);
unsigned short readWord(unsigned long WordAddr);
int writeBuffer(unsigned long ByteAddr, unsigned char *buffer, unsigned short len);
#endif

View file

@ -1,82 +1,64 @@
/*
fonty.c - drawing text & font handling
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
fonty.c - drawing text & font handling
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lcd.h"
#include "fonty.h"
#include "global.h"
#include "fonts/charset.info"
#include "fonts/charset.bits"
/*
#include "fonts/smooth.info"
#include "fonts/smooth.bits"
extern unsigned char drawbuf[2][128];
extern unsigned int is_drawing;
*/
static unsigned char tx, ty, coff, dbl;
unsigned char *font_bits, *font_info, font_dlines;
unsigned char *font_bitsUM, *font_bitsUL, *font_bitsMM, *font_bitsML, *font_bitsLM, *font_bitsLL;
unsigned char activefont;
void set_font(unsigned char f)
{
activefont = f;
{
switch(f)
{
case SMOOTHFONT:
coff = 0;
dbl = 16;
font_info = (unsigned char*) smooth_info;
font_bitsUM = (unsigned char*) smooth_mt_bits;
font_bitsUL = (unsigned char*) smooth_lt_bits;
font_bitsLM = (unsigned char*) smooth_mb_bits;
font_bitsLL = (unsigned char*) smooth_lb_bits;
font_dlines = smooth_dlines;
break;
case BOLDDOUBLEFONT:
coff = 96;
dbl = 1;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
case BOLDFONT:
coff = 96;
dbl = 0;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
case DOUBLEFONT:
coff = 0;
dbl = 1;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
/*
case 2:
coff = 0;
dbl = 16;
font_info = (unsigned char*) smooth_info;
font_bitsUM = (unsigned char*) smooth_mt_bits;
font_bitsUL = (unsigned char*) smooth_lt_bits;
font_bitsLM = (unsigned char*) smooth_mb_bits;
font_bitsLL = (unsigned char*) smooth_lb_bits;
font_dlines = smooth_dlines;
break;
*/
case 1:
coff = 0;
dbl = 1;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
default:
coff = 0;
dbl = 0;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
coff = 0;
dbl = 0;
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
font_dlines = charset_dlines;
break;
}
}
@ -84,7 +66,6 @@ void _draw_char(unsigned int ch, unsigned char c, unsigned char m)
{
unsigned char p,q,r,s,t;
unsigned int cpos, cnt;
is_drawing++;
cpos = 0;
@ -241,7 +222,7 @@ void _draw_char(unsigned int ch, unsigned char c, unsigned char m)
}
do_rcu(tx,ty+16,p,m);
} // if (ty & 0x07)
}
else
{
p <<= 1;
@ -305,11 +286,12 @@ void _draw_char(unsigned int ch, unsigned char c, unsigned char m)
drawbuf[1][r-1] = s;
}
do_rcu(tx,ty+8,p,m);
} // else if (ty & 0x07)
}
tx += p+2;
} // if (dbl == 1)
}
else
{
if(ty & 0x07)
{
s = ty & 0x07;
@ -341,7 +323,7 @@ void _draw_char(unsigned int ch, unsigned char c, unsigned char m)
drawbuf[1][p-cnt-1] = 0x00;
}
do_rcu(tx,ty+8,p,m);
} // if (ty & 0x07)
}
else
{
for(cnt=0;cnt<p;cnt++)
@ -357,18 +339,15 @@ void _draw_char(unsigned int ch, unsigned char c, unsigned char m)
drawbuf[1][p-cnt-1] = 0x00;
}
do_rcu(tx,ty,p,m);
} // else if (ty & 0x07)
}
tx += (p+1);
} // else if (dbl == 1)
is_drawing--;
} // _draw_char
}
}
/// Draw function for Smooth Font
void _draw_charB(unsigned int ch, unsigned char c, unsigned char m)
{
unsigned char p, s;
unsigned char p;
unsigned int cpos, cnt;
is_drawing++;
cpos = 0;
@ -381,37 +360,6 @@ void _draw_charB(unsigned int ch, unsigned char c, unsigned char m)
if(dbl == 16)
{
if (ty & 0x07)
{
s = ty & 0x07;
for (cnt=0;cnt<p;cnt++)
{
drawbuf[0][p-cnt-1] = font_bitsUM[cpos+cnt] << s;
drawbuf[1][p-cnt-1] = font_bitsUL[cpos+cnt] << s;
}
do_rcu (tx,ty,p,m);
for (cnt=0;cnt<p;cnt++)
{
drawbuf[0][p-cnt-1] = font_bitsUM[cpos+cnt] >> (8-s);
drawbuf[1][p-cnt-1] = font_bitsUL[cpos+cnt] >> (8-s);
}
do_rcu (tx,ty+8,p,m);
for (cnt=0;cnt<p;cnt++)
{
drawbuf[0][p-cnt-1] = font_bitsLM[cpos+cnt] << s;
drawbuf[1][p-cnt-1] = font_bitsLL[cpos+cnt] << s;
}
do_rcu (tx,ty+8,p,m);
for (cnt=0;cnt<p;cnt++)
{
drawbuf[0][p-cnt-1] = font_bitsLM[cpos+cnt] >> (8-s);
drawbuf[1][p-cnt-1] = font_bitsLL[cpos+cnt] >> (8-s);
}
do_rcu (tx,ty+16,p,m);
} // if (ty & 0x07)
else
{
for(cnt=0;cnt<p;cnt++)
{
drawbuf[0][p-cnt-1] = font_bitsUM[cpos+cnt];
@ -424,213 +372,62 @@ void _draw_charB(unsigned int ch, unsigned char c, unsigned char m)
drawbuf[1][p-cnt-1] = font_bitsLL[cpos+cnt];
}
do_rcu(tx,ty+8,p,m);
} // else if (ty & 0x07)
tx += (p+1);
}
is_drawing--;
} // _draw_charB
}
void draw_char(unsigned char x, unsigned char y, unsigned char ch, unsigned char c, unsigned char m)
{
is_drawing++;
tx = x;
ty = y;
_draw_char(ch+coff, c, m);
is_drawing--;
}
void draw_string(unsigned char x, unsigned char y, char *st, unsigned char c, unsigned char m)
{
unsigned char cp;
is_drawing++;
tx = x;
ty = y;
cp = 0;
while(st[cp] != 0)
{
if (st[cp] == '\n')
{
tx = x;
if(!dbl)
ty += 9;
else
ty += 18;
}
else if (st[cp] == '\t')
{
tx=((tx/tabstep)+1)*tabstep;
}
else
{
if(dbl < 15)
_draw_char(st[cp]+coff, c, m);
else
_draw_charB(st[cp]+coff, c, m);
}
cp++;
}
is_drawing--;
}
unsigned short get_stringwidth (const char *st)
{
unsigned char cp;
unsigned char p;
unsigned short width;
unsigned short prevwidth;
width = 0;
prevwidth = 0;
cp = 0;
while(st[cp] != 0)
if(dbl < 15)
{
p=0;
if(st[cp] == '\n')
while(st[cp] != 0)
{
prevwidth = max(width,prevwidth);
width = 0;
_draw_char(st[cp]+coff, c, m);
cp++;
}
else if(st[cp] == '\t')
{
// nothing ? TODO
}
else
{
if(dbl < 15)
{
p = font_info[(st[cp]+coff)>>1];
if((st[cp]+coff) & 0x01)
{
p &= 0x0F;
}
else
{
p >>= 4;
}
p +=1;
if(dbl == 1)
p <<= 1;
}
else
{
p = font_info[(unsigned char)(st[cp]+coff)];
p+=1;
}
}
width += p;
cp++;
}
width=max(width,prevwidth);
if (width)
width--;
return width;
}
unsigned short get_stringheight (const char *st)
{
unsigned char cp;
unsigned short height;
if(!dbl)
height = 8;
else
height = 16;
cp = 0;
while(st[cp] != 0)
{
if(st[cp] == '\n')
while(st[cp] != 0)
{
if(!dbl)
height += 9;
else
height += 18;
_draw_charB(st[cp]+coff, c, m);
cp++;
}
cp++;
}
return height;
}
extern char hval[16];
void draw_hexC(unsigned char x, unsigned char y, const unsigned char v, unsigned char c, unsigned char m)
{
is_drawing++;
tx = x;
ty = y;
_draw_char(hval[v>>4]+coff, c, m);
_draw_char(hval[v & 0x0F]+coff, c, m);
is_drawing--;
}
void draw_hexS(unsigned char x, unsigned char y, const unsigned short v, unsigned char c, unsigned char m)
{
is_drawing++;
tx = x;
ty = y;
draw_hexC(x, y, v >> 8, c, m);
draw_hexC(tx, ty, v & 0xFF, c, m);
is_drawing--;
}
void draw_hexW(unsigned char x, unsigned char y, const unsigned long v, unsigned char c, unsigned char m)
{
is_drawing++;
draw_hexS(x, y, v >> 16, c, m);
draw_hexS(tx, ty, v & 0xFFFF, c, m);
is_drawing--;
}
static unsigned long u_longval;
static unsigned char pos, inc;
static unsigned char num[12];
void get_digit(unsigned long tval)
{
unsigned char count;
count = 0;
while(u_longval >= tval)
{
count++;
u_longval -= tval;
}
num[pos] = '0' + count;
if(count)
inc = 1;
pos += inc;
}
void draw_numU(unsigned char x, unsigned char y, const unsigned long v, unsigned char z, unsigned char c, unsigned char m)
{
is_drawing++;
pos = 0;
u_longval = v;
if(z)
inc = 1;
else
inc = 0;
get_digit(1000000000);
get_digit(100000000);
get_digit(10000000);
get_digit(1000000);
get_digit(100000);
get_digit(10000);
get_digit(1000);
get_digit(100);
get_digit(10);
inc = 1;
get_digit(1);
num[pos] = 0x00;
draw_string(x, y, (char*)num, c, m);
is_drawing--;
}

View file

@ -19,21 +19,7 @@
#ifndef FONTY_H
#define FONTY_H
#define SMALLFONT 0
#define DOUBLEFONT 1
#define BOLDFONT 2
#define BOLDDOUBLEFONT 3
#define SMOOTHFONT 4
#define SMALLFONT_HEIGHT 8
#define DOUBLEFONT_HEIGHT 16
#define BOLDFONT_HEIGHT 8
#define BOLDDOUBLEFONT_HEIGHT 16
#define SMOOTHFONT_HEIGHT 16
#define tabstep 24
unsigned char activefont;
extern unsigned char drawbuf[2][128];
void set_font(unsigned char f);
void draw_char(unsigned char x, unsigned char y, unsigned char ch, unsigned char c, unsigned char m);
@ -42,8 +28,4 @@ void draw_hexC(unsigned char x, unsigned char y, const unsigned char v, unsigned
void draw_hexS(unsigned char x, unsigned char y, const unsigned short v, unsigned char c, unsigned char m);
void draw_hexW(unsigned char x, unsigned char y, const unsigned long v, unsigned char c, unsigned char m);
void draw_numU(unsigned char x, unsigned char y, const unsigned long v, unsigned char z, unsigned char c, unsigned char m);
unsigned short get_stringwidth (const char *st);
unsigned short get_stringheight (const char *st);
#endif

View file

@ -1 +0,0 @@
THUMBSRCS := gamesmenu.c tic_tac_toe.c sokoban.c connect4.c

View file

@ -1,64 +0,0 @@
const signed char map[7][6][14] =
{
{
{ 0, 24, 45, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 4, 24, 25, 49, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 8, 24, 25, 26, 53, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 12, 24, 25, 26, 60, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 16, 25, 26, 64, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 20, 26, 68, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
},
{
{ 0, 1, 27, 46, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 4, 5, 27, 28, 45, 50, -1, 0, 0, 0, 0, 0, 0, 0 },
{ 8, 9, 27, 28, 29, 49, 54, 60, -1, 0, 0, 0, 0, 0 },
{ 12, 13, 27, 28, 29, 53, 59, 64, -1, 0, 0, 0, 0, 0 },
{ 16, 17, 28, 29, 63, 68, -1, 0, 0, 0, 0, 0, 0, 0 },
{ 20, 21, 29, 67, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
},
{
{ 0, 1, 2, 30, 47, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 4, 5, 6, 30, 31, 46, 51, 60, -1, 0, 0, 0, 0, 0 },
{ 8, 9, 10, 30, 31, 32, 45, 50, 55, 59, 64, -1, 0, 0 },
{ 12, 13, 14, 30, 31, 32, 49, 54, 58, 63, 68, -1, 0, 0 },
{ 16, 17, 18, 31, 32, 53, 62, 67, -1, 0, 0, 0, 0, 0 },
{ 20, 21, 22, 32, 66, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
},
{
{ 0, 1, 2, 3, 33, 48, 60, -1, 0, 0, 0, 0, 0, 0 },
{ 4, 5, 6, 7, 33, 34, 47, 52, 59, 64, -1, 0, 0, 0 },
{ 8, 9, 10, 11, 33, 34, 35, 46, 51, 56, 58, 63, 68, -1 },
{ 12, 13, 14, 15, 33, 34, 35, 45, 50, 55, 57, 62, 67, -1 },
{ 16, 17, 18, 19, 34, 35, 49, 54, 61, 66, -1, 0, 0, 0 },
{ 20, 21, 22, 23, 35, 53, 65, -1, 0, 0, 0, 0, 0, 0 },
},
{
{ 1, 2, 3, 36, 59, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 5, 6, 7, 36, 37, 48, 58, 63, -1, 0, 0, 0, 0, 0 },
{ 9, 10, 11, 36, 37, 38, 47, 52, 57, 62, 67, -1, 0, 0 },
{ 13, 14, 15, 36, 37, 38, 46, 51, 56, 61, 66, -1, 0, 0 },
{ 17, 18, 19, 37, 38, 50, 55, 65, -1, 0, 0, 0, 0, 0 },
{ 21, 22, 23, 38, 54, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
},
{
{ 2, 3, 39, 58, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 6, 7, 39, 40, 57, 62, -1, 0, 0, 0, 0, 0, 0, 0 },
{ 10, 11, 39, 40, 41, 48, 61, 66, -1, 0, 0, 0, 0, 0 },
{ 14, 15, 39, 40, 41, 47, 52, 65, -1, 0, 0, 0, 0, 0 },
{ 18, 19, 40, 41, 51, 56, -1, 0, 0, 0, 0, 0, 0, 0 },
{ 22, 23, 41, 55, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
},
{
{ 3, 42, 57, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 7, 42, 43, 61, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 11, 42, 43, 44, 65, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 15, 42, 43, 44, 48, -1, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 19, 43, 44, 52, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 23, 44, 56, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
}
};
const signed char drop_order[7] =
{
3, 4, 2, 5, 1, 6, 0
};

View file

@ -1,965 +0,0 @@
/*
connect4.c - game
the bulk of this file is code reused from:
* Connect-4 Algorithm
* Version 3.10
* By Keith Pomakis
* (pomakis@pobox.com)
*April, 2005
modifications & adoption to boop:
Copyright (C) 2007 Ch. Klippel <ck@mamalala.org>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lcd.h"
#include "fonty.h"
#include "keyboard.h"
#include "timerfuncs.h"
#include "backlight.h"
#include "connect4.h"
extern unsigned char autorepeat;
unsigned int seed;
unsigned char c4_abort;
#define other(x) ((x) ^ 1)
#define real_player(x) ((x) & 1)
#define pop_state() \
(current_state = &state_stack[--depth])
/* The "goodness" of the current state with respect to a player is the */
/* score of that player minus the score of the player's opponent. A */
/* positive value will result if the specified player is in a better */
/* situation than his/her opponent. */
#define goodness_of(player) \
(current_state->score[player] - current_state->score[other(player)])
/* A local struct which defines the state of a game. */
#define C4_SIZEX 7
#define C4_SIZEY 6
#define C4_TOTALSIZE (C4_SIZEX*C4_SIZEY)
#define C4_MAGICWIN (1 << 4)
#define C4_WINPLACES 69
typedef int(*ev_fn)(int player, int level, int alpha, int beta);
typedef void(*ps_fn)(void);
typedef int(*dp_fn)(int player, int column);
typedef void(*mc_fn)(char *d, char *s, unsigned int cnt);
static ev_fn evaluate;
static ps_fn push_state;
static dp_fn drop_piece;
static mc_fn mcpy;
typedef struct {
char board[C4_SIZEX][C4_SIZEY]; /* The board configuration of the game state. */
/* board[x][y] specifies the position of the */
/* xth column and the yth row of the board, */
/* where column and row numbering starts at 0. */
/* (The 0th row is the bottom row.) */
/* A value of 0 specifies that the position is */
/* occupied by a piece owned by player 0, a */
/* value of 1 specifies that the position is */
/* occupied by a piece owned by player 1, and */
/* a value of C4_NONE specifies that the */
/* position is unoccupied. */
int score_array[2][C4_WINPLACES]; /* An array specifying statistics on both */
/* players. score_array[0] specifies the */
/* statistics for player 0, while */
/* score_array[1] specifies the statistics for */
/* player 1. */
int score[2]; /* The actual scores of each player, deducible */
/* from score_array, but kept separately for */
/* efficiency. The score of player x is the */
/* sum of score_array[x]. A score is */
/* basically a function of how many winning */
/* positions are still available to the */
/* and how close he/she is to achieving each */
/* of these positions. */
short int winner; /* The winner of the game - either 0, 1 or */
/* C4_NONE. Deducible from score_array, but */
/* kept separately for efficiency. */
int num_of_pieces; /* The number of pieces currently occupying */
/* board spaces. Deducible from board, but */
/* kept separately for efficiency. */
} Game_state;
/* Static global variables. */
#include "c4_map.h"
static Game_state *state_stack; //[C4_MAX_LEVEL+1];
static Game_state *current_state;
static int depth;
static int states_allocated = 0;
//static int drop_order[7];
unsigned long int rand31(void)
{
unsigned long int hi, lo;
lo = 16807 * (seed & 0xFFFF);
hi = 16807 * (seed >> 16);
lo += (hi & 0x7FFF) << 16;
lo += hi >> 15;
if(lo > 0x7FFFFFFF) lo -= 0x7FFFFFFF;
return(seed = (long)lo);
}
/****************************************************************************/
/** **/
/** This function sets up a new game. This must be called exactly once **/
/** before each game is started. Before it can be called a second time, **/
/** end_game() must be called to destroy the previous game. **/
/** **/
/** width and height are the desired dimensions of the game board, while **/
/** num is the number of pieces required to connect in a row in order to **/
/** win the game. **/
/** **/
/****************************************************************************/
void
c4_new_game(int width, int height, int num)
{
register int i, j;
depth = 0;
current_state = &state_stack[0];
for (i=0; i<C4_SIZEX; i++)
{
for (j=0; j<C4_SIZEY; j++)
current_state->board[i][j] = C4_NONE;
}
for (i=0; i<C4_WINPLACES; i++) {
current_state->score_array[0][i] = 1;
current_state->score_array[1][i] = 1;
}
current_state->score[0] = current_state->score[1] = C4_WINPLACES;
current_state->winner = C4_NONE;
current_state->num_of_pieces = 0;
states_allocated = 1;
}
/****************************************************************************/
/** **/
/** This function updates the score of the specified player in the **/
/** context of the current state, given that the player has just placed **/
/** a game piece in column x, row y. **/
/** **/
/****************************************************************************/
static void
update_score(int player, int x, int y)
{
register int i;
int win_index;
int this_difference = 0, other_difference = 0;
int other_player = other(player);
for (i=0; map[x][y][i] != -1; i++) {
win_index = map[x][y][i];
this_difference += current_state->score_array[player][win_index];
other_difference += current_state->score_array[other_player][win_index];
current_state->score_array[player][win_index] <<= 1;
current_state->score_array[other_player][win_index] = 0;
if (current_state->score_array[player][win_index] == C4_MAGICWIN)
if (current_state->winner == C4_NONE)
current_state->winner = player;
}
current_state->score[player] += this_difference;
current_state->score[other_player] -= other_difference;
}
/****************************************************************************/
/** **/
/** This function drops a piece of the specified player into the **/
/** specified column. The row where the piece ended up is returned, or **/
/** -1 if the drop was unsuccessful (i.e., the specified column is full). **/
/** **/
/****************************************************************************/
static int
_drop_piece(int player, int column)
{
int y = 0;
while (current_state->board[column][y] != C4_NONE && ++y < C4_SIZEY)
;
if (y == C4_SIZEY)
return -1;
current_state->board[column][y] = player;
current_state->num_of_pieces++;
update_score(player, column, y);
return y;
}
/****************************************************************************/
/** **/
/** This function drops a piece of the specified player into the **/
/** specified column. A value of TRUE is returned if the drop is **/
/** successful, or FALSE otherwise. A drop is unsuccessful if the **/
/** specified column number is invalid or full. If the drop is **/
/** successful and row is a non-NULL pointer, the row where the piece **/
/** ended up is returned through the row pointer. Note that column and **/
/** row numbering start at 0. **/
/** **/
/****************************************************************************/
Boolean
c4_make_move(int player, int column, int *row)
{
int result;
if (column >= C4_SIZEX || column < 0)
return FALSE;
result = drop_piece(real_player(player), column);
if (row && result >= 0)
*row = result;
return (result >= 0);
}
void __attribute__ ((section(".text.fastcode")))
_mcpy(char *d, char *s, unsigned int cnt)
{
unsigned int c = cnt;
do
{
d[c] = s[c];
} while(c--);
}
/****************************************************************************/
/** **/
/** This function pushes the current state onto a stack. pop_state() **/
/** is used to pop from this stack. **/
/** **/
/** Technically what it does, since the current state is considered to **/
/** be the top of the stack, is push a copy of the current state onto **/
/** the stack right above it. The stack pointer (depth) is then **/
/** incremented so that the new copy is considered to be the current **/
/** state. That way, all pop_state() has to do is decrement the stack **/
/** pointer. **/
/** **/
/** For efficiency, memory for each stack state used is only allocated **/
/** once per game, and reused for the remainder of the game. **/
/** **/
/****************************************************************************/
static void __attribute__ ((section(".text.fastcode")))
_push_state(void)
{
register int i;
Game_state *old_state, *new_state;
old_state = &state_stack[depth++];
new_state = &state_stack[depth];
/* Copy the board */
for (i=0; i<C4_SIZEX; i++)
mcpy((char*)new_state->board[i], (char*)old_state->board[i], C4_SIZEY);
/* Copy the score array */
mcpy((char*)new_state->score_array[0], (char*)old_state->score_array[0],
C4_WINPLACES*4);
mcpy((char*)new_state->score_array[1], (char*)old_state->score_array[1],
C4_WINPLACES*4);
new_state->score[0] = old_state->score[0];
new_state->score[1] = old_state->score[1];
new_state->winner = old_state->winner;
new_state->num_of_pieces = old_state->num_of_pieces;
current_state = new_state;
}
/****************************************************************************/
/** **/
/** This recursive function determines how good the current state may **/
/** turn out to be for the specified player. It does this by looking **/
/** ahead level moves. It is assumed that both the specified player and **/
/** the opponent may make the best move possible. alpha and beta are **/
/** used for alpha-beta cutoff so that the game tree can be pruned to **/
/** avoid searching unneccessary paths. **/
/** **/
/** The specified poll function (if any) is called at the appropriate **/
/** intervals. **/
/** **/
/** The worst goodness that the current state can produce in the number **/
/** of moves (levels) searched is returned. This is the best the **/
/** specified player can hope to achieve with this state (since it is **/
/** assumed that the opponent will make the best moves possible). **/
/** **/
/****************************************************************************/
static int __attribute__ ((section(".text.fastcode")))
_evaluate(int player, int level, int alpha, int beta)
{
int i, goodness, best, maxab;
if (current_state->winner == player)
return 0x7FFFFFFF - depth;
else if (current_state->winner == other(player))
return -(0x7FFFFFFF - depth);
else if (current_state->num_of_pieces == C4_TOTALSIZE)
return 0; /* a tie */
else if (level == depth)
return goodness_of(player);
else {
/* Assume it is the other player's turn. */
best = -(0x7FFFFFFF);
maxab = alpha;
for(i=0; i<C4_SIZEX; i++) {
if(c4_abort)
return 0;
if (current_state->board[drop_order[i]][C4_SIZEY-1] != C4_NONE)
continue; /* The column is full. */
push_state();
drop_piece(other(player), drop_order[i]);
goodness = evaluate(other(player), level, -beta, -maxab);
if (goodness > best) {
best = goodness;
if (best > maxab)
maxab = best;
}
pop_state();
if (best > beta)
break;
}
/* What's good for the other player is bad for this one. */
return -best;
}
}
/****************************************************************************/
/** **/
/** This function instructs the computer to make a move for the specified **/
/** player. level specifies the number of levels deep the computer **/
/** should search the game tree in order to make its decision. This **/
/** corresponds to the number of "moves" in the game, where each player's **/
/** turn is considered a move. A value of TRUE is returned if a move was **/
/** made, or FALSE otherwise (i.e. if the board is full). If a move was **/
/** made, the column and row where the piece ended up is returned through **/
/** the column and row pointers (unless a pointer is NULL, in which case **/
/** it won't be used to return any information). Note that column and **/
/** row numbering start at 0. Also note that for a standard 7x6 game of **/
/** Connect-4, the computer is brain-dead at levels of three or less, **/
/** while at levels of four or more the computer provides a challenge. **/
/** **/
/****************************************************************************/
Boolean
c4_auto_move(int player, int level, int *column, int *row)
{
int i, best_column = -1, goodness = 0, best_worst = -(0x7FFFFFFF);
int num_of_equal = 0, real_player, current_column, result;
real_player = real_player(player);
/* It has been proven that the best first move for a standard 7x6 game */
/* of connect-4 is the center column. See Victor Allis' masters thesis */
/* ("ftp://ftp.cs.vu.nl/pub/victor/connect4.ps") for this proof. */
if (current_state->num_of_pieces < 2 && (current_state->num_of_pieces == 0 ||
current_state->board[3][0] != C4_NONE)) {
if (column)
*column = 3;
if (row)
*row = current_state->num_of_pieces;
drop_piece(real_player, 3);
return TRUE;
}
/* Simulate a drop in each of the columns and see what the results are. */
for (i=0; i<C4_SIZEX; i++) {
push_state();
current_column = drop_order[i];
result = drop_piece(real_player, current_column);
/* If this column is full, ignore it as a possibility. */
if (result < 0) {
pop_state();
continue;
}
/* If this drop wins the game, take it! */
else if (current_state->winner == real_player) {
best_column = current_column;
pop_state();
break;
}
/* Otherwise, look ahead to see how good this move may turn out */
/* to be (assuming the opponent makes the best moves possible). */
else {
// next_poll = clock() + poll_interval;
goodness = evaluate(real_player, level, -(0x7FFFFFFF), -best_worst);
}
/* If this move looks better than the ones previously considered, */
/* remember it. */
if (goodness > best_worst) {
best_worst = goodness;
best_column = current_column;
num_of_equal = 1;
}
/* If two moves are equally as good, make a random decision. */
else if (goodness == best_worst) {
num_of_equal++;
if ((rand31()>>4) % num_of_equal == 0)
best_column = current_column;
}
pop_state();
if(c4_abort)
return 0;
}
/* Drop the piece in the column decided upon. */
if (best_column >= 0) {
result = drop_piece(real_player, best_column);
if (column)
*column = best_column;
if (row)
*row = result;
return TRUE;
}
else
return FALSE;
}
/****************************************************************************/
/** **/
/** This function returns the "score" of the specified player. This **/
/** score is a function of how many winning positions are still available **/
/** to the player and how close he/she is to achieving each of these **/
/** positions. The scores of both players can be compared to observe how **/
/** well they are doing relative to each other. **/
/** **/
/****************************************************************************/
int
c4_score_of_player(int player)
{
return current_state->score[real_player(player)];
}
/****************************************************************************/
/** **/
/** This function returns TRUE if the specified player has won the game, **/
/** and FALSE otherwise. **/
/** **/
/****************************************************************************/
Boolean
c4_is_winner(int player)
{
return (current_state->winner == real_player(player));
}
/****************************************************************************/
/** **/
/** This function returns TRUE if the board is completely full without a **/
/** winner, and FALSE otherwise. **/
/** **/
/****************************************************************************/
Boolean
c4_is_tie(void)
{
return (current_state->num_of_pieces == C4_TOTALSIZE &&
current_state->winner == C4_NONE);
}
/****************************************************************************/
/** **/
/** This function returns the coordinates of the winning connections of **/
/** the winning player. It is assumed that a player has indeed won the **/
/** game. The coordinates are returned in x1, y1, x2, y2, where (x1, y1) **/
/** specifies the lower-left piece of the winning connection, and **/
/** (x2, y2) specifies the upper-right piece of the winning connection. **/
/** If more than one winning connection exists, only one will be **/
/** returned. **/
/** **/
/****************************************************************************/
void
c4_win_coords(int *x1, int *y1, int *x2, int *y2)
{
register int i, j, k;
int winner, win_pos = 0;
Boolean found;
winner = current_state->winner;
while (current_state->score_array[winner][win_pos] != C4_MAGICWIN)
win_pos++;
found = FALSE;
for (j=0; j<C4_SIZEY && !found; j++)
for (i=0; i<C4_SIZEX && !found; i++)
for (k=0; map[i][j][k] != -1; k++)
if (map[i][j][k] == win_pos) {
*x1 = i;
*y1 = j;
found = TRUE;
break;
}
found = FALSE;
for (j=C4_SIZEY-1; j>=0 && !found; j--)
for (i=C4_SIZEX-1; i>=0 && !found; i--)
for (k=0; map[i][j][k] != -1; k++)
if (map[i][j][k] == win_pos) {
*x2 = i;
*y2 = j;
found = TRUE;
break;
}
}
/****************************************************************************/
/** **/
/** This function ends the current game. It is assumed that a game is **/
/** in progress. It is illegal to call any other game function **/
/** immediately after this one except for c4_new_game(), c4_poll() and **/
/** c4_reset(). **/
/** **/
/****************************************************************************/
void
c4_end_game(void)
{
states_allocated = 0;
}
/****************************************************************************/
/** **/
/** This function resets the state of the algorithm to the starting state **/
/** (i.e., no game in progress and a NULL poll function). There should **/
/** no reason to call this function unless for some reason the calling **/
/** algorithm loses track of the game state. It is illegal to call any **/
/** other game function immediately after this one except for **/
/** c4_new_game(), c4_poll() and c4_reset(). **/
/** **/
/****************************************************************************/
void
c4_reset(void)
{
c4_end_game();
}
int row, col, ccol;
unsigned int c4_cb, c4_wcb;
unsigned char c4_player, c4_moves, c4_level;
void draw_stone(unsigned char x, unsigned char y, unsigned char p)
{
unsigned char xx, yy;
xx = 10+(x*18);
yy = 46+(y*18);
switch(p)
{
case 0:
draw_disc(xx, yy, 7, 2, DRAW_PUT);
draw_disc(xx, yy, 5, 3, DRAW_XOR);
draw_disc(xx, yy, 2, 3, DRAW_XOR);
break;
case 1:
draw_disc(xx, yy, 7, 3, DRAW_PUT);
draw_disc(xx, yy, 5, 1, DRAW_ERASE);
draw_disc(xx, yy, 2, 1, DRAW_PUT);
break;
case 2:
draw_disc(xx, yy, 8, 3, DRAW_ERASE);
break;
case 3:
draw_disc(x, y, 7, 2, DRAW_PUT);
draw_disc(x, y, 5, 3, DRAW_XOR);
draw_disc(x, y, 2, 3, DRAW_XOR);
break;
case 4:
draw_disc(x, y, 7, 3, DRAW_PUT);
draw_disc(x, y, 5, 1, DRAW_ERASE);
draw_disc(x, y, 2, 1, DRAW_PUT);
break;
case 5:
draw_disc(xx, yy, 7, 3, DRAW_XOR);
break;
}
}
void progress_callback(unsigned int cb)
{
static unsigned char step = 0;
unsigned char x;
if(keys[0] || keys[1])
{
setBacklight(BL_AUTO);
if(KEY_Exit)
c4_abort = 1;
}
for(x=0;x<6;x++)
{
draw_char(40+(x<<3),24,224+step,3,DRAW_NORCU);
}
draw_hline(40,24,48,3,DRAW_PUT);
step--;
step &= 0x07;
}
void win_callback(unsigned int cb)
{
int x1, y1, x2, y2;
c4_win_coords(&x1, &y1, &x2, &y2);
if(x1 > x2)
x1 = 1;
else if(x1 < x2)
x1 = -1;
else
x1 = 0;
if(y1 > y2)
y1 = 1;
else if(y1 < y2)
y1 = -1;
else
y1 = 0;
draw_stone(x2,5-y2,5);
x2+=x1;
y2+=y1;
draw_stone(x2,5-y2,5);
x2+=x1;
y2+=y1;
draw_stone(x2,5-y2,5);
x2+=x1;
y2+=y1;
draw_stone(x2,5-y2,5);
x2+=x1;
y2+=y1;
}
void draw_marker(void)
{
draw_stone(10+(col*18), 22,c4_player+3);
draw_arrow(7+(col*18), 31, ARROW_DOWN, ARROW_LEN, 3, DRAW_PUT);
draw_arrow( 0, 152, ARROW_LEFT, ARROW_LEN, 3, DRAW_PUT);
draw_arrow( 6, 152, ARROW_RIGHT, ARROW_LEN, 3, DRAW_PUT);
draw_string(12,152,"Select",3,DRAW_PUT);
draw_arrow( 75, 153, ARROW_DOWN, ARROW_LEN, 3, DRAW_PUT);
draw_string(84,152,"Play move",3,DRAW_PUT);
}
void delete_marker(void)
{
draw_disc(10+(col*18), 22, 7, 3, DRAW_ERASE);
draw_arrow(7+(col*18), 31, ARROW_DOWN, ARROW_LEN, 3, DRAW_ERASE);
draw_block(0, 152, 128, 8, 3, DRAW_ERASE);
}
int checkwin(void)
{
if(c4_is_winner(0) || c4_is_winner(1) || c4_is_tie())
{
if(!c4_is_tie())
{
startCB(c4_wcb);
}
draw_block(0, 152, 128, 8, 3, DRAW_ERASE);
delete_marker();
set_font(BOLDFONT);
if(c4_is_winner(c4_player))
draw_string(19,14,"Spieler gewinnt!",3,DRAW_PUT);
else if(c4_is_tie())
draw_string(24,14,"Unentschieden!",3,DRAW_PUT);
else
draw_string(13,14,"Computer gewinnt!",3,DRAW_PUT);
draw_string(2,25,"OK: Nochmal Exit: Ende",3,DRAW_PUT);
return 1;
}
return 0;
}
void move(unsigned char p)
{
unsigned char pp;
if(p)
{
p = 1;
pp = 0;
}
else
pp = 1;
if(c4_make_move(p, col, &row))
{
draw_stone(col, 5-row, p);
draw_disc(10+(col*18), 23, 7, 3, DRAW_ERASE);
delete_marker();
if(!checkwin())
{
set_font(BOLDFONT);
draw_frame(35,13,57,22,5,5,3,DRAW_PUT);
draw_block(40,18,47,12,3,DRAW_PUT);
draw_string(40, 15, "Berechne", 3, DRAW_ERASE);
draw_string(0, 152, "Exit: Spiel abbrechen", 3, DRAW_PUT);
set_font(SMALLFONT);
progress_callback(0xff);
startCB(c4_cb);
c4_abort = 0;
c4_auto_move(~p, c4_level, &ccol, &row);
setBacklight(BL_AUTO);
stopCB(c4_cb);
draw_block(0,13,128,22,3,DRAW_ERASE);
draw_block(0, 152, 128, 8, 3, DRAW_ERASE);
draw_stone(ccol, 5-row, pp);
}
draw_marker();
c4_moves++;
checkwin();
}
}
void c4_selplayer(unsigned char p)
{
draw_string(30, 15, "Chooose Your", 3, DRAW_PUT);
draw_string(25, 26, "Colour & Level", 3, DRAW_PUT);
draw_arrow( 0, 154, ARROW_UP, ARROW_LEN, 3, DRAW_PUT);
draw_arrow(1 * 6, 154, ARROW_DOWN, ARROW_LEN, 3, DRAW_PUT);
draw_string(15,152,"Level",3,DRAW_PUT);
draw_arrow( 82, 153, ARROW_LEFT, ARROW_LEN, 3, DRAW_PUT);
draw_arrow( 88, 153, ARROW_RIGHT, ARROW_LEN, 3, DRAW_PUT);
draw_string(94,152,"Colour",3,DRAW_PUT);
draw_frame(1, 15, 19, 19, 1, 3, 3, DRAW_PUT);
draw_frame(108,15, 19, 19, 1, 3, 3, DRAW_PUT);
draw_disc(10, 24, 7, 3, DRAW_ERASE);
draw_stone(10, 24, p+3);
draw_disc(117, 24, 7, 3, DRAW_ERASE);
draw_stone(117,24, p+3);
}
void start_connect4(void)
{
unsigned char x,y;
Game_state s_stk[C4_MAX_LEVEL+1];
state_stack = s_stk;
evaluate = _evaluate;
push_state = _push_state;
drop_piece = _drop_piece;
mcpy = _mcpy;
seed = 0x86f2a981;
c4_cb = addTimerCB(progress_callback, 35);
c4_wcb = addTimerCB(win_callback, 100);
row = 0; ccol = 0;
c4_player = 0;
c4_level = 3;
lcd_fill(0);//Clr screen
set_font(BOLDFONT);
draw_string(0, 0, "Connect4", 3, DRAW_PUT);
draw_block(0,10,128,2,3,DRAW_PUT);
draw_block(0,149,128,2,3,DRAW_PUT);
draw_frame(1,37,127,109,9,9,3,DRAW_PUT);
draw_block(10,46,109,91,3,DRAW_PUT);
restart:
stopCB(c4_wcb);
col = 3;
draw_block(0,14,128,20,3,DRAW_ERASE);
draw_block(0, 152, 128, 8, 3, DRAW_ERASE);
c4_selplayer(c4_player);
draw_numU(48,152,c4_level,0,3,DRAW_PUT);
c4_moves = 0;
for(x=0;x<7;x++)
{
for(y=0;y<6;y++)
{
draw_disc(10+(x*18), 46+(y*18),8,3,DRAW_ERASE);
}
}
c4_reset();
c4_new_game(C4_SIZEX, C4_SIZEY, 4);
while(1)
{
wait4c:
waitKeyUpDown();
if((KEY_OK || KEY_0) && (c4_is_winner(0) || c4_is_winner(1) || c4_is_tie()) && (c4_moves != 0)) goto restart;
else if(KEY_0)
goto restart;
if(KEY_Exit)
{
stopCB(c4_cb);
stopCB(c4_wcb);
removeTimerCB(c4_cb);
removeTimerCB(c4_wcb);
return;
}
else if(c4_moves == 0)
{
if(KEY_Left || KEY_Right)
{
if(c4_player) c4_player=0; else c4_player = 1;
c4_selplayer(c4_player);
}
else if(KEY_OK && c4_player == 1)
{
delete_marker();
c4_auto_move(0, c4_level, &ccol, &row);
draw_stone(ccol, 5-row, 0);
draw_marker();
}
else if(KEY_Up)
{
draw_numU(48,152,c4_level,0,3,DRAW_ERASE);
c4_level++;
if(c4_level > C4_MAX_LEVEL)
c4_level = 1;
draw_numU(48,152,c4_level,0,3,DRAW_PUT);
}
else if(KEY_Down)
{
draw_numU(48,152,c4_level,0,3,DRAW_ERASE);
c4_level--;
if(c4_level < 1)
c4_level = C4_MAX_LEVEL;
draw_numU(48,152,c4_level,0,3,DRAW_PUT);
}
if(KEY_OK)
{
c4_moves++;
draw_block(0, 152, 128, 8, 3, DRAW_ERASE);
delete_marker();
draw_block(0,13,128,22,3,DRAW_ERASE);
set_font(SMALLFONT);
draw_marker();
}
goto wait4c;
}
else if(!c4_is_winner(0) && !c4_is_winner(1) && !c4_is_tie())
{
if(KEY_1 || KEY_2 || KEY_3 || KEY_4 || KEY_5 || KEY_6 || KEY_7)
{
delete_marker();
if(KEY_1)
col = 0;
else if(KEY_2)
col = 1;
else if(KEY_3)
col = 2;
else if(KEY_4)
col = 3;
else if(KEY_5)
col = 4;
else if(KEY_6)
col = 5;
else if(KEY_7)
col = 6;
draw_marker();
move(c4_player);
}
else if(KEY_Left || KEY_Right)
{
delete_marker();
if(KEY_Left)
col--;
else if(KEY_Right)
col++;
if(col > 6)
col = 0;
else if(col < 0)
col = 6;
draw_marker();
}
else if(KEY_Down || KEY_OK)
{
move(c4_player);
if(c4_abort)
{
c4_abort = 0;
goto restart;
}
}
}
}
}

View file

@ -1,39 +0,0 @@
/*
connect4.c - game
Copyright (C) 2007 Ch. Klippel <ck@mamalala.org>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONNECT4_H
#define CONNECT4_H
#ifndef Boolean
#define Boolean char
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define C4_NONE 2
#define C4_MAX_LEVEL 20
void start_connect4(void);
#endif

View file

@ -1,35 +0,0 @@
/*
testmenu.c - testmenu for menuing system
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "menu.h"
#include "tic_tac_toe.h"
#include "sokoban.h"
#include "connect4.h"
const struct MENU_ENTRY gamesMenuEntries[] =
{
{ &GameTicTacToe, 0, FUNCENTRY, "TicTacToe", "Play TicTacToe" },
{ &GameSokoban, 0, FUNCENTRY, "Sokoban", "Play Sokoban" },
{ &start_connect4, 0, FUNCENTRY, "Connect4", "Play Connect4" }
};
const struct MENU gamesMenu =
{
3, (MENU_ENTRY*)&gamesMenuEntries, "Games"
};

View file

@ -1,24 +0,0 @@
/*
mainmenu.h - the main menu for boop
Copyright (C) 2007 Ch. Klippel <ck@mamalala.net>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAINMENU_H
#define MAINMENU_H
extern const struct MENU gamesMenu;
#endif

View file

@ -1,614 +0,0 @@
/*
sokoban.c - game
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lcd.h"
#include "fonty.h"
#include "keyboard.h"
#include "sokoban.h"
#include "sokoban_levels.h"
//#include "stdio.h"
void GameSokoban_InitGameField(struct _SokobanGameInfo *pGI)
{
int SizeX;
int SizeY;
int x;
int y;
int Pos;
int i;
if((pGI->Level < 1) || (pGI->Level > SOKOBAN_LEVELS))
{
//Invalid level
pGI->Level = 1;
}
//Empty the game field
for(x=0; x<SOKOBAN_CELLS_X; x++)
{
for(y=0; y<SOKOBAN_CELLS_Y; y++)
{
pGI->G[x][y] = SPACE;
}
}
//Find the position to searched level
Pos = 0;
i = 1;
while(i<pGI->Level)
{
SizeX = Sokoban_Levels[Pos++];
SizeY = Sokoban_Levels[Pos++];
Pos += SizeY * ((SizeX+1)/2);
i++;
}
//Copy the (may be smaller) level to the center of the game field
SizeX = Sokoban_Levels[Pos++];
SizeY = Sokoban_Levels[Pos++];
for(y=0; y<SizeY; y++)
{
for(x=0; x<SizeX; x++)
{
if(x & 1)
{
//Odd x -> lo nibble
pGI->G[x+((SOKOBAN_CELLS_X-SizeX)/2)][y+((SOKOBAN_CELLS_Y-SizeY)/2)] = Sokoban_Levels[Pos + (y * ((SizeX+1)/2)) + (x/2)] & 0x0F;
}
else
{
//Even x -> hi nibble
pGI->G[x+((SOKOBAN_CELLS_X-SizeX)/2)][y+((SOKOBAN_CELLS_Y-SizeY)/2)] = (Sokoban_Levels[Pos + (y * ((SizeX+1)/2)) + (x/2)] >> 4) & 0x0F;
}
}
}
}
BOOL GameSokoban_IsSolved(BYTE G[SOKOBAN_CELLS_X][SOKOBAN_CELLS_Y])
{
//Return true=Solved
int x;
int y;
for(x=0; x<SOKOBAN_CELLS_X; x++)
{
for(y=0; y<SOKOBAN_CELLS_Y; y++)
{
if(G[x][y] & GOAL)
{
//Goal found
if(!(G[x][y] & PACKET))
{
//But no packet
return false;//Not solved
}
}
}
}
return true;//Solved
}
void GameSokoban_DrawCell(int x, int y, BYTE Object)
{
BYTE Color;
BYTE Mode;
int dx;
int dy;
Color = LCD_COLOR_B;
Mode = DRAW_PUT;
/*
ASSERT(x < SOKOBAN_CELLS_X);
ASSERT(y < SOKOBAN_CELLS_Y);
*/
dx = 1 + x * (SOKOBAN_CELL_SIZE+1);
dy = 16 + y * (SOKOBAN_CELL_SIZE+1) + 1;
//Clear first
draw_block(dx, dy, SOKOBAN_CELL_SIZE, SOKOBAN_CELL_SIZE, LCD_COLOR_B, DRAW_ERASE);
if(Object & GOAL)
{
draw_pixel(dx+1, dy+1, Color, Mode);
draw_pixel(dx+2, dy+2, Color, Mode);
draw_pixel(dx+3, dy+3, Color, Mode);
draw_pixel(dx+3, dy+1, Color, Mode);
draw_pixel(dx+1, dy+3, Color, Mode);
}
if(Object & PUSHER)
{
draw_pixel(dx+2, dy, Color, Mode);
draw_hline(dx, dy+1, SOKOBAN_CELL_SIZE, Color, Mode);
draw_pixel(dx+2, dy+2, Color, Mode);
draw_pixel(dx+1, dy+3, Color, Mode);
draw_pixel(dx+3, dy+3, Color, Mode);
draw_pixel(dx, dy+4, Color, Mode); //new maennchen
draw_pixel(dx+4, dy+4, Color, Mode);
// draw_hline(dx, dy+1, SOKOBAN_CELL_SIZE, Color, Mode);
// draw_hline(dx, dy+3, SOKOBAN_CELL_SIZE, Color, Mode);
// draw_vline(dx+1, dy, SOKOBAN_CELL_SIZE, Color, Mode);
// draw_vline(dx+3, dy, SOKOBAN_CELL_SIZE, Color, Mode); //old doppelkreuz :)
}
if(Object & PACKET)
{
draw_hline(dx+1, dy, 3, Color, Mode);
draw_hline(dx+1, dy+4, 3, Color, Mode);
draw_vline(dx, dy+1, 3, Color, Mode);
draw_vline(dx+4, dy+1, 3, Color, Mode);
}
if(Object & WALL)
{
draw_block(dx, dy, SOKOBAN_CELL_SIZE, SOKOBAN_CELL_SIZE, Color, Mode);
}
}
void GameSokoban_InitDisplayForNewGame(struct _SokobanGameInfo *pGI)
{
int x;
int y;
pGI->Moves = 0;
pGI->UndoCount = 0;
GameSokoban_InitGameField(pGI);
//Game field to display
for(x=0; x<SOKOBAN_CELLS_X; x++)
{
for(y=0; y<SOKOBAN_CELLS_Y; y++)
{
GameSokoban_DrawCell(x, y, pGI->G[x][y]);
if(pGI->G[x][y] & PUSHER)
{
pGI->PusherX = x;
pGI->PusherY = y;
}
}
}
}
void GameSokoban_Move(struct _SokobanGameInfo *pGI)
{
if(KEY_Up)
{
if(!(pGI->G[pGI->PusherX][pGI->PusherY - 1] & WALL))
{
//No wall
if(!(pGI->G[pGI->PusherX][pGI->PusherY - 1] & PACKET))
{
//No wall and no packet
GameSokoban_SaveUndo(pGI, 2, SOKOBAN_UNDO_DIR_UP);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX][pGI->PusherY-1] ^= PUSHER;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY-1, pGI->G[pGI->PusherX][pGI->PusherY-1]);
pGI->PusherY--;
pGI->Moves++;
}
else
{
//Packet -> check if it is space behind the packet
if(!(pGI->G[pGI->PusherX][pGI->PusherY - 2] & (PACKET | WALL)))
{
//No packet or wall behind the packet
GameSokoban_SaveUndo(pGI, 3, SOKOBAN_UNDO_DIR_UP);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX][pGI->PusherY - 1] ^= PUSHER;
//Move packet
pGI->G[pGI->PusherX][pGI->PusherY-1] ^= PACKET;
pGI->G[pGI->PusherX][pGI->PusherY-2] ^= PACKET;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY-1, pGI->G[pGI->PusherX][pGI->PusherY-1]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY-2, pGI->G[pGI->PusherX][pGI->PusherY-2]);
pGI->PusherY--;
pGI->Moves++;
}
}
}
}
if(KEY_Down)
{
if(!(pGI->G[pGI->PusherX][pGI->PusherY + 1] & WALL))
{
//No wall
if(!(pGI->G[pGI->PusherX][pGI->PusherY + 1] & PACKET))
{
//No wall and no packet
GameSokoban_SaveUndo(pGI, 2, SOKOBAN_UNDO_DIR_DOWN);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX][pGI->PusherY+1] ^= PUSHER;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY+1, pGI->G[pGI->PusherX][pGI->PusherY+1]);
pGI->PusherY++;
pGI->Moves++;
}
else
{
//Packet -> check if it is space behind the packet
if(!(pGI->G[pGI->PusherX][pGI->PusherY + 2] & (PACKET | WALL)))
{
//No packet or wall behind the packet
GameSokoban_SaveUndo(pGI, 3, SOKOBAN_UNDO_DIR_DOWN);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX][pGI->PusherY + 1] ^= PUSHER;
//Move packet
pGI->G[pGI->PusherX][pGI->PusherY+1] ^= PACKET;
pGI->G[pGI->PusherX][pGI->PusherY+2] ^= PACKET;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY+1, pGI->G[pGI->PusherX][pGI->PusherY+1]);
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY+2, pGI->G[pGI->PusherX][pGI->PusherY+2]);
pGI->PusherY++;
pGI->Moves++;
}
}
}
}
if(KEY_Left)
{
if(!(pGI->G[pGI->PusherX - 1][pGI->PusherY] & WALL))
{
//No wall
if(!(pGI->G[pGI->PusherX - 1][pGI->PusherY] & PACKET))
{
//No wall and no packet
GameSokoban_SaveUndo(pGI, 2, SOKOBAN_UNDO_DIR_LEFT);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX - 1][pGI->PusherY] ^= PUSHER;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX - 1, pGI->PusherY, pGI->G[pGI->PusherX - 1][pGI->PusherY]);
pGI->PusherX--;
pGI->Moves++;
}
else
{
//Packet -> check if it is space behind the packet
if(!(pGI->G[pGI->PusherX - 2][pGI->PusherY] & (PACKET | WALL)))
{
//No packet or wall behind the packet
GameSokoban_SaveUndo(pGI, 3, SOKOBAN_UNDO_DIR_LEFT);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX - 1][pGI->PusherY] ^= PUSHER;
//Move packet
pGI->G[pGI->PusherX - 1][pGI->PusherY] ^= PACKET;
pGI->G[pGI->PusherX - 2][pGI->PusherY] ^= PACKET;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX - 1, pGI->PusherY, pGI->G[pGI->PusherX - 1][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX - 2, pGI->PusherY, pGI->G[pGI->PusherX - 2][pGI->PusherY]);
pGI->PusherX--;
pGI->Moves++;
}
}
}
}
if(KEY_Right)
{
if(!(pGI->G[pGI->PusherX + 1][pGI->PusherY] & WALL))
{
//No wall
if(!(pGI->G[pGI->PusherX + 1][pGI->PusherY] & PACKET))
{
//No wall and no packet
GameSokoban_SaveUndo(pGI, 2, SOKOBAN_UNDO_DIR_RIGHT);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX + 1][pGI->PusherY] ^= PUSHER;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX + 1, pGI->PusherY, pGI->G[pGI->PusherX + 1][pGI->PusherY]);
pGI->PusherX++;
pGI->Moves++;
}
else
{
//Packet -> check if it is space behind the packet
if(!(pGI->G[pGI->PusherX + 2][pGI->PusherY] & (PACKET | WALL)))
{
//No packet or wall behind the packet
GameSokoban_SaveUndo(pGI, 3, SOKOBAN_UNDO_DIR_RIGHT);
//Move pusher
pGI->G[pGI->PusherX][pGI->PusherY] ^= PUSHER;
pGI->G[pGI->PusherX + 1][pGI->PusherY] ^= PUSHER;
//Move packet
pGI->G[pGI->PusherX + 1][pGI->PusherY] ^= PACKET;
pGI->G[pGI->PusherX + 2][pGI->PusherY] ^= PACKET;
//Draw changed cells
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY, pGI->G[pGI->PusherX][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX + 1, pGI->PusherY, pGI->G[pGI->PusherX + 1][pGI->PusherY]);
GameSokoban_DrawCell(pGI->PusherX + 2, pGI->PusherY, pGI->G[pGI->PusherX + 2][pGI->PusherY]);
pGI->PusherX++;
pGI->Moves++;
}
}
}
}
}
void GameSokoban_UndoAMove(struct _SokobanGameInfo *pGI)
{
//3 Byte UndoBuffer:
//[ 0 ][ 1 ][ 2 ]
//765432107654321076543210
//\-x-/\-y-/\/\o0/\o1/\o2/
BYTE Object[3];
BYTE Dir;
int i;
int Count;
if(pGI->UndoCount <= 0)
{
return;//No more undos available
}
pGI->UndoCount--;
pGI->PusherX = (pGI->UndoBuffer[pGI->UndoCount][0] >> 3) & 0x1F;
pGI->PusherY = (pGI->UndoBuffer[pGI->UndoCount][0] << 2) & 0x1F;
pGI->PusherY |= (pGI->UndoBuffer[pGI->UndoCount][1] >> 6) & 0x03;
Dir = (pGI->UndoBuffer[pGI->UndoCount][1] >> 4) & 0x03;
Object[0] = pGI->UndoBuffer[pGI->UndoCount][1] & 0x0F;
Object[1] = (pGI->UndoBuffer[pGI->UndoCount][2] >> 4) & 0x0F;
Object[2] = pGI->UndoBuffer[pGI->UndoCount][2] & 0x0F;
Count = (Object[2] == 0x0F) ? 2 : 3;
for(i=0; i<Count; i++)
{
switch(Dir)
{
case SOKOBAN_UNDO_DIR_LEFT:
pGI->G[pGI->PusherX - i][pGI->PusherY] = Object[i];
GameSokoban_DrawCell(pGI->PusherX - i, pGI->PusherY, pGI->G[pGI->PusherX - i][pGI->PusherY]);
break;
case SOKOBAN_UNDO_DIR_RIGHT:
pGI->G[pGI->PusherX + i][pGI->PusherY] = Object[i];
GameSokoban_DrawCell(pGI->PusherX + i, pGI->PusherY, pGI->G[pGI->PusherX + i][pGI->PusherY]);
break;
case SOKOBAN_UNDO_DIR_UP:
pGI->G[pGI->PusherX][pGI->PusherY - i] = Object[i];
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY - i, pGI->G[pGI->PusherX][pGI->PusherY - i]);
break;
case SOKOBAN_UNDO_DIR_DOWN:
pGI->G[pGI->PusherX][pGI->PusherY + i] = Object[i];
GameSokoban_DrawCell(pGI->PusherX, pGI->PusherY + i, pGI->G[pGI->PusherX][pGI->PusherY + i]);
break;
}
}
pGI->Moves--;
}
void GameSokoban_SaveUndo(struct _SokobanGameInfo *pGI, BYTE Count, BYTE Dir)
{
//3 Byte UndoBuffer:
//[ 0 ][ 1 ][ 2 ]
//765432107654321076543210
//\-x-/\-y-/\/\o0/\o1/\o2/
BYTE Object[3];
int i;
// ASSERT((Count == 2) || (Count == 3));
Object[2] = 0x0F;//Default value for not used
for(i=0; i<Count; i++)
{
switch(Dir)
{
case SOKOBAN_UNDO_DIR_LEFT:
Object[i] = pGI->G[pGI->PusherX - i][pGI->PusherY];
break;
case SOKOBAN_UNDO_DIR_RIGHT:
Object[i] = pGI->G[pGI->PusherX + i][pGI->PusherY];
break;
case SOKOBAN_UNDO_DIR_UP:
Object[i] = pGI->G[pGI->PusherX][pGI->PusherY - i];
break;
case SOKOBAN_UNDO_DIR_DOWN:
Object[i] = pGI->G[pGI->PusherX][pGI->PusherY + i];
break;
}
}
if(pGI->UndoCount >= SOKOBAN_MAX_UNDOS)
{
//Undo buffer is full -> free oldest
for(i=0; i<(SOKOBAN_MAX_UNDOS-1); i++)
{
pGI->UndoBuffer[i][0] = pGI->UndoBuffer[i+1][0];
pGI->UndoBuffer[i][1] = pGI->UndoBuffer[i+1][1];
pGI->UndoBuffer[i][2] = pGI->UndoBuffer[i+1][2];
}
pGI->UndoCount--;
}
pGI->UndoBuffer[pGI->UndoCount][0] = (pGI->PusherX & 0x1F) << 3;
pGI->UndoBuffer[pGI->UndoCount][0] |= ((pGI->PusherY & 0x1F) >> 2) & 0x07;
pGI->UndoBuffer[pGI->UndoCount][1] = (pGI->PusherY & 0x1F) << 6;
pGI->UndoBuffer[pGI->UndoCount][1] |= (Dir & 3) << 4;
pGI->UndoBuffer[pGI->UndoCount][1] |= Object[0] & 0x0F;
pGI->UndoBuffer[pGI->UndoCount][2] = (Object[1] & 0x0F) << 4;
pGI->UndoBuffer[pGI->UndoCount][2] |= Object[2] & 0x0F;
pGI->UndoCount++;
}
void GameSokoban()
{
struct _SokobanGameInfo GI;
int i;
GI.Level = 1;
restart:
//Init the display
lcd_fill(0);//Clr screen
//Title
draw_string(0, 0, "Sokoban", LCD_COLOR_B, DRAW_PUT);
//Grid
for(i=0; i<=SOKOBAN_CELLS_X; i++)
{
draw_vline(i*(SOKOBAN_CELL_SIZE+1),16,SOKOBAN_CELLS_Y*(SOKOBAN_CELL_SIZE+1)+1, LCD_COLOR_LG, DRAW_PUT);
}
for(i=0; i<=SOKOBAN_CELLS_Y; i++)
{
draw_hline(0, 16 + i*(SOKOBAN_CELL_SIZE+1),SOKOBAN_CELLS_X*(SOKOBAN_CELL_SIZE+1)+1, LCD_COLOR_LG, DRAW_PUT);
}
draw_string(0, 8, "Level: Moves:", LCD_COLOR_B, DRAW_PUT);
draw_char(98,8,'0',LCD_COLOR_B,DRAW_PUT);
draw_string(0, LCD_SIZE_Y - (8*3), "Program +/-:", LCD_COLOR_B, DRAW_PUT);
draw_string(65, LCD_SIZE_Y - (8*3), "Level +/- 1", LCD_COLOR_B, DRAW_PUT);
draw_string(0, LCD_SIZE_Y - (8*2), "Volume +/-:", LCD_COLOR_B, DRAW_PUT);
draw_string(65, LCD_SIZE_Y - (8*2), "Level +/- 20", LCD_COLOR_B, DRAW_PUT);
draw_arrow( 0, LCD_SIZE_Y - 8, ARROW_UP, ARROW_LEN, LCD_COLOR_B, DRAW_PUT);
draw_arrow(1 * 6, LCD_SIZE_Y - 8, ARROW_DOWN, ARROW_LEN, LCD_COLOR_B, DRAW_PUT);
draw_arrow(2 * 6, LCD_SIZE_Y - 8, ARROW_LEFT, ARROW_LEN, LCD_COLOR_B, DRAW_PUT);
draw_arrow(3 * 6, LCD_SIZE_Y - 8, ARROW_RIGHT, ARROW_LEN, LCD_COLOR_B, DRAW_PUT);
draw_string(32, LCD_SIZE_Y - 8, "Bewegen", LCD_COLOR_B, DRAW_PUT);
again:
GameSokoban_InitDisplayForNewGame(&GI);
draw_block(32, 8, 30, 8, LCD_COLOR_B, DRAW_ERASE);
draw_numU(32,8,GI.Level,0,LCD_COLOR_B,DRAW_PUT);
while(1)
{
if(KEY_Up || KEY_Down || KEY_Left || KEY_Right || KEY_8)
{
draw_block(98, 8, 30, 8, LCD_COLOR_B, DRAW_ERASE);
if(KEY_8)
GameSokoban_UndoAMove(&GI);
else
GameSokoban_Move(&GI);
if(GameSokoban_IsSolved(GI.G) && !KEY_8)
{
//Solved
GI.Level++;//Next level
if(GI.Level > SOKOBAN_LEVELS)
{
GI.Level = 1;
}
waitKeyUp();
goto restart;
}
draw_numU(98,8,GI.Moves,0,LCD_COLOR_B,DRAW_PUT);
}
//Footer
if(GI.Moves == 1)
{
draw_block(0, LCD_SIZE_Y - (8*3), LCD_SIZE_X, 16, LCD_COLOR_B, DRAW_ERASE);
draw_string(0, LCD_SIZE_Y - (8*3), "0", LCD_COLOR_B, DRAW_PUT);
draw_string(32, LCD_SIZE_Y - (8*3), "Neues Spiel", LCD_COLOR_B, DRAW_PUT);
draw_string(0, LCD_SIZE_Y - (8*2), "Exit", LCD_COLOR_B, DRAW_PUT);
draw_string(32, LCD_SIZE_Y - (8*2), "Spiel beenden", LCD_COLOR_B, DRAW_PUT);
}
waitKeyUpDown();
if(GI.Moves == 0)
{
if(KEY_Pplus || KEY_Pminus || KEY_Vplus || KEY_Vminus)
{
//Change level
//Program keys +/- 1
if(KEY_Pplus)
{
GI.Level++;
}
if(KEY_Pminus)
{
GI.Level--;
}
//Volume keys +/- 20
if(KEY_Vplus)
{
GI.Level += 20;
}
if(KEY_Vminus)
{
GI.Level -= 20;
}
//Wrap around if necessary
if(GI.Level < 1)
{
GI.Level += SOKOBAN_LEVELS;
}
if(GI.Level > SOKOBAN_LEVELS)
{
GI.Level -= SOKOBAN_LEVELS;
}
//New game
goto again;
}
}
if(KEY_0) goto restart;
if(KEY_Exit) return;
}
}

View file

@ -1,64 +0,0 @@
/*
sokoban.h - game
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SOKOBAN_H
#define SOKOBAN_H
#include "../global.h"
#define SOKOBAN_MAX_UNDOS 100
#define SOKOBAN_UNDO_DIR_LEFT 0
#define SOKOBAN_UNDO_DIR_RIGHT 1
#define SOKOBAN_UNDO_DIR_UP 2
#define SOKOBAN_UNDO_DIR_DOWN 3
#define SPACE 0
#define GOAL 1
#define PUSHER 2
#define PACKET 4
#define WALL 8
#define PUSHER_ON_GOAL (PUSHER | GOAL)
#define PACKET_ON_GOAL (PACKET | GOAL)
#define SOKOBAN_CELLS_X 21
#define SOKOBAN_CELLS_Y 19
//Size without grid
#define SOKOBAN_CELL_SIZE 5
struct _SokobanGameInfo
{
BYTE G[SOKOBAN_CELLS_X][SOKOBAN_CELLS_Y];
short Level;
int PusherX;
int PusherY;
WORD Moves;
WORD UndoCount;
BYTE UndoBuffer[SOKOBAN_MAX_UNDOS][3];
};
void GameSokoban(void);
void GameSokoban_InitGameField(struct _SokobanGameInfo *pGI);
void GameSokoban_DrawCell(int x, int y, BYTE Object);
BOOL GameSokoban_IsSolved(BYTE G[SOKOBAN_CELLS_X][SOKOBAN_CELLS_Y]);
void GameSokoban_InitDisplayForNewGame(struct _SokobanGameInfo *pGI);
void GameSokoban_Move(struct _SokobanGameInfo *pGI);
void GameSokoban_SaveUndo(struct _SokobanGameInfo *pGI, BYTE Count, BYTE Dir);
void GameSokoban_UndoAMove(struct _SokobanGameInfo *pGI);
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,375 +0,0 @@
/*
tic_tac_toe.c - game
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lcd.h"
#include "fonty.h"
#include "keyboard.h"
#include "tic_tac_toe.h"
void GameTicTacToe(void)
{
BYTE Color;
BYTE Mode;
int i;
int k;
BOOL ComputerWon;
BOOL PlayerWon;
BYTE G[2][9];//GameArray [0=Computer / 1=Player][Game fields]
BOOL GameIsRunning = false;
BYTE Moves = 0;
int Pos;
Color = LCD_COLOR_B;
Mode = DRAW_PUT;
again:
//New game
//Init the display
lcd_fill(0);//Clr screen
//Title
set_font(SMALLFONT);
draw_string(0, 0, "TicTacToe", Color, Mode);
//Grid
draw_block(16, 16+30, 96, 3, Color, Mode);
draw_block(16, 16+30+3+30, 96, 3, Color, Mode);
draw_block(16+30, 16, 3, 96, Color, Mode);
draw_block(16+30+3+30, 16, 3, 96, Color, Mode);
//Reset game field
for(k=0; k<2; k++)
{
for(i=0; i<9; i++)
{
G[k][i] = 0;
}
}
Moves = 0;
GameIsRunning = true;
while(1)
{
Pos = -1;
if(KEY_1){Pos = 0;}
if(KEY_2){Pos = 1;}
if(KEY_3){Pos = 2;}
if(KEY_4){Pos = 3;}
if(KEY_5){Pos = 4;}
if(KEY_6){Pos = 5;}
if(KEY_7){Pos = 6;}
if(KEY_8){Pos = 7;}
if(KEY_9){Pos = 8;}
if((Pos >= 0) && (Pos <= 8))
{
if(GameIsRunning)
{
if((G[0][Pos] + G[1][Pos]) == 0)
{
//field is empty
G[1][Pos] = 1;
Moves++;
if(Moves < 9)
{
//Moves left
if(!GameTicTacToe_IsSolved(G, &ComputerWon, &PlayerWon))
{
//Not solved -> computer move
GameTicTacToe_ComputerMove(G);
Moves++;
}
}
GameTicTacToe_DrawGameField(G);
}
}
}
//Is solved?
GameTicTacToe_IsSolved(G, &ComputerWon, &PlayerWon);
if(ComputerWon)
{
draw_string(0, LCD_SIZE_Y - (8*4), "Computer hat gewonnen", Color, Mode);
GameIsRunning = false;
}
else
{
if(PlayerWon)
{
draw_string(0, LCD_SIZE_Y - (8*4), "Spieler hat gewonnen", Color, Mode);
GameIsRunning = false;
}
else
{
if(Moves == 9)
{
draw_string(0, LCD_SIZE_Y - (8*4), "Unentschieden", Color, Mode);
GameIsRunning = false;
}
}
}
//Footer
if(Moves > 0)
{
draw_string(0, LCD_SIZE_Y - (8*3), "0", Color, Mode);
draw_string(32, LCD_SIZE_Y - (8*3), "Neues Spiel", Color, Mode);
draw_string(0, LCD_SIZE_Y - (8*2), "Exit", Color, Mode);
draw_string(32, LCD_SIZE_Y - (8*2), "Spiel beenden", Color, Mode);
}
else
{
draw_block(0, LCD_SIZE_Y - (8*2), LCD_SIZE_X, 8, Color, DRAW_ERASE);
}
if(GameIsRunning)
{
draw_string(0, LCD_SIZE_Y - 8, "1-9", Color, Mode);
draw_string(32, LCD_SIZE_Y - 8, "Feld waehlen", Color, Mode);
}
else
{
draw_block(0, LCD_SIZE_Y - 8, LCD_SIZE_X, 8, Color, DRAW_ERASE);
}
waitKeyUpDown();
if(KEY_0) goto again;
if(KEY_Exit) return;
}
}
void GameTicTacToe_ComputerMove(BYTE G[2][9])
{
int Pos;
BYTE TempG[2][9];
BOOL ComputerWon;
BOOL PlayerWon;
for(Pos=0; Pos<9; Pos++)
{
TempG[0][Pos] = G[0][Pos];
TempG[1][Pos] = G[1][Pos];
}
//1: Check if the computer can win the game with the next move
for(Pos=0; Pos<9; Pos++)
{
if((G[0][Pos] + G[1][Pos]) == 0)
{
//Free pos
TempG[0][Pos] = 1;//Try this move
GameTicTacToe_IsSolved(TempG, &ComputerWon, &PlayerWon);
if(ComputerWon)
{
G[0][Pos] = 1;//Do the move
return;
}
TempG[0][Pos] = 0;//Undo the try
}
}
//2: Check if the computer can prohibit the player to win the game with the next move
for(Pos=0; Pos<9; Pos++)
{
if((G[0][Pos] + G[1][Pos]) == 0)
{
//Free pos
TempG[1][Pos] = 1;//Try this move
GameTicTacToe_IsSolved(TempG, &ComputerWon, &PlayerWon);
if(PlayerWon)
{
G[0][Pos] = 1;//Do the move
return;
}
TempG[1][Pos] = 0;//Undo the try
}
}
//The following strategy is not implemented to allow the player to win:
//3: Fork: threaten a win with two possible completions in two ways
//4: Block Fork 1: if there is a configuration where the opponent can fork, create two in a row to force a block
//5: Block Fork 2: if there is a configuration where the opponent can fork, block that fork
//6: Try to play the centre
if((G[0][4] + G[1][4]) == 0)
{
G[0][4] = 1;
return;
}
//7: If the Player is in a corner then try to play the opposite corner
if(((G[0][0] + G[1][0]) == 0) && (G[1][8]))
{
//Corner 0 is free and player is in corner 8
G[0][0] = 1;
return;
}
if(((G[0][2] + G[1][2]) == 0) && (G[1][6]))
{
//Corner 2 is free and player is in corner 6
G[0][2] = 1;
return;
}
if(((G[0][6] + G[1][6]) == 0) && (G[1][2]))
{
//Corner 6 is free and player is in corner 2
G[0][6] = 1;
return;
}
if(((G[0][8] + G[1][8]) == 0) && (G[1][0]))
{
//Corner 8 is free and player is in corner 0
G[0][8] = 1;
return;
}
//8: Try to play an free corner
Pos = 0;
if((G[0][Pos] + G[1][Pos]) == 0)
{
G[0][Pos] = 1;
return;
}
Pos = 2;
if((G[0][Pos] + G[1][Pos]) == 0)
{
G[0][Pos] = 1;
return;
}
Pos = 6;
if((G[0][Pos] + G[1][Pos]) == 0)
{
G[0][Pos] = 1;
return;
}
Pos = 8;
if((G[0][Pos] + G[1][Pos]) == 0)
{
G[0][Pos] = 1;
return;
}
//9: Play on a free pos
for(Pos=0; Pos<9; Pos++)
{
if((G[0][Pos] + G[1][Pos]) == 0)
{
//Free pos
G[0][Pos] = 1;//Do the move
return;
}
}
}
BOOL GameTicTacToe_IsSolved(BYTE G[2][9], BOOL *pComputerWon, BOOL *pPlayerWon)
{
//Return true=GameIsSolved
int k;
BYTE Result[2];
*pComputerWon = false;
*pPlayerWon = false;
//Is solved?
Result[0] = 0;
Result[1] = 0;
for(k=0; k<2; k++)
{
Result[k] |= 1 << (G[k][0] + G[k][1] + G[k][2]);//Row 1
Result[k] |= 1 << (G[k][3] + G[k][4] + G[k][5]);//Row 2
Result[k] |= 1 << (G[k][6] + G[k][7] + G[k][8]);//Row 3
Result[k] |= 1 << (G[k][0] + G[k][3] + G[k][6]);//Column 1
Result[k] |= 1 << (G[k][1] + G[k][4] + G[k][7]);//Column 2
Result[k] |= 1 << (G[k][2] + G[k][5] + G[k][8]);//Column 3
Result[k] |= 1 << (G[k][0] + G[k][4] + G[k][8]);//Diagonal
Result[k] |= 1 << (G[k][2] + G[k][4] + G[k][6]);//Diagonal
}
if(Result[0] & (1 << 3))
{
*pComputerWon = true;
return true;//Solved
}
if(Result[1] & (1 << 3))
{
*pPlayerWon = true;
return true;//Solved
}
return false;//Not solved
}
void GameTicTacToe_DrawGameField(BYTE G[2][9])
{
int Pos;
int x;
int y;
BYTE Color;
BYTE Mode;
Color = LCD_COLOR_B;
Mode = DRAW_PUT;
for(Pos=0; Pos<9; Pos++)
{
// x = Pos % 3;
// y = Pos / 3;
y = 0;
x = Pos;
while(x >= 3)
{
x -= 3;
y++;
}
if(G[0][Pos])
{
//Computer (O)
draw_disc(16+14 + (x*33), 16+14 + (y*33), 11, Color, Mode);
draw_disc(16+14 + (x*33), 16+14 + (y*33), 8, Color, DRAW_XOR);
}
else
{
if(G[1][Pos])
{
//Player (X)
draw_line(16+3 + (x*33), 16+3 + (y*33)+2, 16+3 + (x*33) + 23-2, 16+3 + (y*33) + 23, Color, Mode);
draw_line(16+3 + (x*33), 16+3 + (y*33)+1, 16+3 + (x*33) + 23-1, 16+3 + (y*33) + 23, Color, Mode);
draw_line(16+3 + (x*33), 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23, Color, Mode);
draw_line(16+3 + (x*33)+1, 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23-1, Color, Mode);
draw_line(16+3 + (x*33)+2, 16+3 + (y*33), 16+3 + (x*33) + 23, 16+3 + (y*33) + 23-2, Color, Mode);
draw_line(16+3-1+(x*33)+2, 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33)+2, Color, Mode);
draw_line(16+3-1+(x*33)+1, 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33)+1, Color, Mode);
draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1, 16+3+(x*33)+23, 16+3 + (y*33), Color, Mode);
draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1-1, 16+3+(x*33)+23-1, 16+3 + (y*33), Color, Mode);
draw_line(16+3-1+(x*33), 16+3+(y*33)+23+1-2, 16+3+(x*33)+23-2, 16+3 + (y*33), Color, Mode);
}
}
}
}

View file

@ -1,29 +0,0 @@
/*
tic_tac_toe.h - game
Copyright (C) 2007 Colibri <colibri_dvb@lycos.com>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TIC_TAC_TOE_H
#define TIC_TAC_TOE_H
#include "../global.h"
void GameTicTacToe(void);
void GameTicTacToe_DrawGameField(BYTE G[2][9]);
void GameTicTacToe_ComputerMove(BYTE G[2][9]);
BOOL GameTicTacToe_IsSolved(BYTE G[2][9], BOOL *pComputerWon, BOOL *pPlayerWon);
#endif

View file

@ -17,11 +17,6 @@
*/
#include "lpc2220.h"
#include "rf.h"
#include "global.h"
#define debugbuffersize 50
unsigned char debugoutbuf [debugbuffersize];
void *memcpy(void *dest,void *src,int count)
{
@ -44,88 +39,8 @@ int memcmp(const void * cs,const void * ct,int count)
return res;
}
unsigned char GetHWversion (void)
{
unsigned char GetHWversion(void) {
if(((IOPIN2 >> 28) & 3) == 3)
return(((((IOPIN0 >> 5) & 1) << 4) | (((IOPIN2 >> 30) & 1) << 3) | (((IOPIN2 >> 16) & 1) << 2) | 3));
return(((IOPIN2 >> 27) & 2) + ((IOPIN2 >> 29) & 1) + (((IOPIN1 >> 23) & 7) << 2));
}
int puts (const char* string)
{
struct RFendpoint_* cur_ep;
volatile unsigned char i;
cur_ep = openEP(debugoutbuf,0, packet_test);
if (cur_ep)
{
for (i=0; (i<debugbuffersize) && string[i];i++)
{
cur_ep->buffer[i] = string[i];
}
cur_ep->buffer[i] = 0;
cur_ep->bufferlen = i+1;
cur_ep->flags |= EPenabled | EPoutput | EPnewdata;
RF_changestate(RFtx);
// wait until all date are sent
while(cur_ep->flags & EPnewdata);
closeEP(cur_ep);
}
return 1;
}
/*
* The width of the CRC calculation and result.
* Modify the typedef for a 16 or 32-bit CRC standard.
*/
#define CRC_POLYNOMIAL 0x8005
#define CRC_WIDTH (8 * sizeof(crc))
#define CRC_TOPBIT (1 << (CRC_WIDTH - 1))
crc CRCs(char* message)
{
crc remainder = 0;
int byte;
unsigned char bit;
/*
* Perform modulo-2 division, a byte at a time.
*/
for (byte = 0; message[byte]; ++byte)
{
/*
* Bring the next byte into the remainder.
*/
remainder ^= (message[byte] << (CRC_WIDTH - 8));
/*
* Perform modulo-2 division, a bit at a time.
*/
for (bit = 8; bit > 0; --bit)
{
/*
* Try to divide the current data bit.
*/
if (remainder & CRC_TOPBIT)
{
remainder = (remainder << 1) ^ CRC_POLYNOMIAL;
}
else
{
remainder = (remainder << 1);
}
}
}
/*
* The final remainder is the CRC result.
*/
return (remainder);
} /* crcSlow() */

View file

@ -22,11 +22,6 @@
//Uncomment if you want compile with demo sound
//#define WITH_SOUND
// Set appropriate feature flags
#define FF_UART_REDIRECT 1
#define FF_LARGE_IDLE_CLOCK 0
#define FF_LARGE_MENU 1
#define FF_ICON_TRANSPARENT 1 // enable 3 BitPerPixel icons support
typedef unsigned char BOOL;
typedef unsigned char BYTE;
@ -36,59 +31,27 @@ typedef unsigned long DWORD;
#define false 0
#define true 1
#ifndef NULL
#define NULL 0
#endif
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif
#define NUM_OF_ELEMENTS(x) sizeof(x)/sizeof(x[0])
#define SPEED_30 0
#define SPEED_60 1
// Execute code in locked sequence
#define INT_LOCK(x) {unsigned cpsr = disableIRQ (); {x;} restoreIRQ (cpsr);}
/** Let the LPC2200 sleep until the next IRQ
*
* This function tries to enter the sleep mode and stays
* there until the next interrupt wakes up the CPU.
* If that is not possible, the function returns immediately.
*/
extern void cpu_idle (void);
#define SYS_NOIDLE 0x08 // No Idle Mode
#define SYS_NOPDOWN 0x10 // No Power Down
#define SYS_IR 0x20
#define SYS_KEY 0x40
#define SYS_TURBO 0x80
#include <stdio.h>
#define printd(...) printf(__VA_ARGS__)
#define debugbuffersize 50
extern unsigned char debugoutbuf [debugbuffersize];
#ifndef __MAIN_C__
extern char sysInfo;
#endif /* __MAIN_C__ */
extern unsigned char debugoutbuf [];
#define PCON_IDLE 0x01
#define PCON_PDOWN 0x02
typedef unsigned short crc;
void *memcpy(void *dest,void *src,int count);
int memcmp(const void * cs,const void * ct,int count);
unsigned char GetHWversion(void);
int puts(const char* string);
crc CRCs(char* message);
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View file

@ -1 +0,0 @@
THUMBSRCS := menu.c mainmenu.c testmenu.c settingsmenu.c controls.c

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

File diff suppressed because it is too large Load diff

View file

@ -1,194 +0,0 @@
/*
controls.h - GUI controls
Copyright (C) 2008 <telekatz@gmx.de>
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, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONTROLS_H
#define CONTROLS_H
#include "rtc.h"
#define BC_OKOnly 0
#define BC_YesNo 1
#define BC_nobuttons 2
#define BC_DefaultButton1 0
#define BC_DefaultButton2 4
#define BC_DefaultButton3 8
#define BC_OK 1
#define BC_Yes 2
#define BC_No 3
#define BC_NoTabStop 0x80
#define BC_Disabled 0x40
#define BC_Label 1
#define BC_Labelnotab (BC_Label | BC_NoTabStop)
#define BC_Button 2
#define BC_Numbox 3
#define BC_Txtbox 4
#define BC_Datebox 5
#define BC_Timebox 6
#define BC_Listbox 7
extern struct FORM dummyform;
extern struct CONTROL dummycontrol;
typedef void(*event)(struct FORM* form, struct CONTROL* control);
typedef void(*fevent)(struct FORM* form);
typedef struct CONTROL
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned char tag1;
unsigned char tag2;
char* caption;
event ONclick;
event ONchange;
} CONTROL;
typedef struct FORM
{
char* caption;
char* footer;
fevent load;
fevent close;
fevent timer;
unsigned long tag;
CONTROL* *controls;
unsigned char sel;
unsigned char controlcount;
unsigned char flags;
unsigned char intervall;
} FORM;
//form.flags
#define BC_Form_exit (1<<0)
#define BC_Timer_expired (1<<1)
#define BC_Form_redraw (1<<2)
typedef struct LABEL
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned short tag;
char* caption;
event ONclick;
} LABEL;
typedef struct BUTTON
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned short tag;
char* caption;
event ONclick;
} BUTTON;
typedef struct NUMBOX
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned short value;
unsigned short min;
unsigned short max;
event ONclick;
event ONchange;
} NUMBOX;
typedef struct TXTBOX
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned char maxlen;
unsigned char tag;
char* text;
event ONclick;
event ONchange;
} TXTBOX;
typedef struct DATEBOX
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned short tag;
struct date_ date;
event ONclick;
event ONchange;
} DATEBOX;
typedef struct TIMEBOX
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned short tag;
struct time_ time;
event ONclick;
event ONchange;
} TIMEBOX;
typedef struct LISTBOX
{
unsigned char type;
unsigned char left;
unsigned char top;
unsigned char width;
unsigned char height;
unsigned char font;
unsigned char listindex;
unsigned char listcount;
char* *list;
event ONclick;
event ONchange;
} LISTBOX;
unsigned char msgbox(unsigned char x,unsigned short flags, char *st);
void form_draw(FORM* form);
void control_draw(CONTROL* control, unsigned char select);
void form_exec(FORM* form);
void listbox_changevalue (LISTBOX* listbox);
#endif

View file

@ -1,144 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\Cross.bmp
//
// ICON_GRAY - 2 bpp (Bit per Pixel)
// sizeof (iconCross.data) == 224
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconCross =
{
/* width = */ 28,
/* height = */ 28,
/* info = */ ICON_INFO (ICON_GRAY)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0x00, 0x00,
0x00, 0x00,
0xc0, 0x80,
0xe0, 0xc0,
0xf0, 0xf0,
0x38, 0x70,
0x1c, 0x38,
0x1c, 0x1c,
0x0c, 0x0e,
0x0e, 0x04,
0x06, 0x0c,
0x06, 0x06,
0x06, 0x06,
0x07, 0xff,
0x07, 0xff,
0x06, 0x06,
0x06, 0x06,
0x06, 0x04,
0x0e, 0x04,
0x0c, 0x0e,
0x1c, 0x1c,
0x1c, 0x38,
0x38, 0x70,
0xf0, 0xf0,
0xe0, 0xc0,
0xc0, 0x80,
0x00, 0x00,
0x00, 0x00,
//--- Page 1 ---
0x60, 0x60,
0xfe, 0xf9,
0xff, 0xff,
0x03, 0x65,
0x00, 0x60,
0x00, 0x60,
0x00, 0x60,
0x00, 0x60,
0xf0, 0xf8,
0x6c, 0x94,
0x62, 0x9e,
0x62, 0x9d,
0x61, 0x9f,
0xff, 0x61,
0xff, 0x61,
0x61, 0x9f,
0x62, 0x9d,
0x62, 0x9e,
0x6c, 0x94,
0xf0, 0xf8,
0x00, 0x60,
0x00, 0x60,
0x00, 0x60,
0x00, 0x60,
0x03, 0x65,
0xff, 0xff,
0xfe, 0xf9,
0x60, 0x60,
//--- Page 2 ---
0x00, 0x00,
0x07, 0x09,
0x3f, 0x1f,
0x7c, 0x3a,
0xf0, 0xf0,
0xc0, 0xe0,
0x80, 0xc0,
0x80, 0x80,
0x00, 0x01,
0x03, 0x02,
0x04, 0x07,
0x04, 0x0b,
0x08, 0x0f,
0x0f, 0xf8,
0x0f, 0xf8,
0x08, 0x0f,
0x04, 0x0b,
0x04, 0x07,
0x03, 0x02,
0x00, 0x01,
0x80, 0x80,
0x80, 0xc0,
0xc0, 0xe0,
0xf0, 0xf0,
0x7c, 0x3a,
0x3f, 0x1f,
0x07, 0x09,
0x00, 0x00,
//--- Page 3 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x01, 0x00,
0x03, 0x01,
0x03, 0x03,
0x03, 0x07,
0x07, 0x02,
0x06, 0x03,
0x06, 0x06,
0x06, 0x06,
0x0e, 0x0f,
0x0e, 0x0f,
0x06, 0x06,
0x06, 0x06,
0x06, 0x02,
0x07, 0x02,
0x03, 0x07,
0x03, 0x03,
0x03, 0x01,
0x01, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00
}
};

View file

@ -1,148 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\Cross_t.bmp
//
// ICON_GRAY_TRANSPARENT - 3 bpp (Bit per Pixel)
// sizeof (iconCross_t.data) == 336
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconCross_t =
{
/* width = */ 28,
/* height = */ 28,
/* info = */ ICON_INFO (ICON_GRAY_TRANSPARENT)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x80, 0xc0, 0xc0,
0xe0, 0xc0, 0xe0,
0xf0, 0xf0, 0xf0,
0x38, 0x70, 0x78,
0x18, 0x3c, 0x3c,
0x1c, 0x1c, 0x1c,
0x0c, 0x0e, 0x0e,
0x0e, 0x04, 0x0e,
0x06, 0x0c, 0x0e,
0x06, 0x06, 0x06,
0x06, 0x06, 0x06,
0x07, 0xff, 0xff,
0x07, 0xff, 0xff,
0x06, 0x06, 0x06,
0x06, 0x06, 0x06,
0x06, 0x0c, 0x0e,
0x0e, 0x04, 0x0e,
0x0c, 0x0e, 0x0e,
0x1c, 0x1c, 0x1c,
0x18, 0x3c, 0x3c,
0x38, 0x70, 0x78,
0xf0, 0xf0, 0xf0,
0xe0, 0xc0, 0xe0,
0x80, 0xc0, 0xc0,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
//--- Page 1 ---
// v--- Alpha Channel
0x60, 0x60, 0x60,
0xfe, 0xf9, 0xff,
0xff, 0xff, 0xff,
0x03, 0x65, 0x67,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0xf0, 0xf8, 0xf8,
0x6c, 0x94, 0xfc,
0x62, 0x9e, 0xfe,
0x62, 0x9d, 0xff,
0x61, 0x9f, 0xff,
0xff, 0x61, 0xff,
0xff, 0x61, 0xff,
0x61, 0x9f, 0xff,
0x62, 0x9d, 0xff,
0x62, 0x9e, 0xfe,
0x6c, 0x94, 0xfc,
0xf0, 0xf8, 0xf8,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0x00, 0x60, 0x60,
0x03, 0x65, 0x67,
0xff, 0xff, 0xff,
0xfe, 0xf9, 0xff,
0x60, 0x60, 0x60,
//--- Page 2 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x07, 0x09, 0x0f,
0x1f, 0x3f, 0x3f,
0x7c, 0x3a, 0x7e,
0xf0, 0xf0, 0xf0,
0xc0, 0xe0, 0xe0,
0x80, 0xc0, 0xc0,
0x80, 0x80, 0x80,
0x00, 0x01, 0x01,
0x03, 0x02, 0x03,
0x04, 0x07, 0x07,
0x04, 0x0b, 0x0f,
0x08, 0x0f, 0x0f,
0x0f, 0xf8, 0xff,
0x0f, 0xf8, 0xff,
0x08, 0x0f, 0x0f,
0x04, 0x0b, 0x0f,
0x04, 0x07, 0x07,
0x03, 0x02, 0x03,
0x00, 0x01, 0x01,
0x80, 0x80, 0x80,
0x80, 0xc0, 0xc0,
0xc0, 0xe0, 0xe0,
0xf0, 0xf0, 0xf0,
0x7c, 0x3a, 0x7e,
0x1f, 0x3f, 0x3f,
0x07, 0x09, 0x0f,
0x00, 0x00, 0x00,
//--- Page 3 ---
// v--- Alpha Channel
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x01, 0x00, 0x01,
0x01, 0x03, 0x03,
0x03, 0x03, 0x03,
0x03, 0x07, 0x07,
0x07, 0x02, 0x07,
0x06, 0x03, 0x07,
0x06, 0x06, 0x06,
0x06, 0x06, 0x06,
0x0e, 0x0f, 0x0f,
0x0e, 0x0f, 0x0f,
0x06, 0x06, 0x06,
0x06, 0x06, 0x06,
0x06, 0x03, 0x07,
0x07, 0x02, 0x07,
0x03, 0x07, 0x07,
0x03, 0x03, 0x03,
0x01, 0x03, 0x03,
0x01, 0x00, 0x01,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00
}
};

View file

@ -1,56 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\FF.bmp
//
// ICON_GRAY - 2 bpp (Bit per Pixel)
// sizeof (iconFf.data) == 52
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconFf =
{
/* width = */ 13,
/* height = */ 13,
/* info = */ ICON_INFO (ICON_GRAY)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0xfc, 0xfa,
0x06, 0x03,
0x03, 0x00,
0xf9, 0xf9,
0xf1, 0xf9,
0xe1, 0xf1,
0x41, 0xe1,
0xf9, 0xf9,
0xf1, 0xf9,
0xe1, 0xf1,
0x43, 0xe0,
0x06, 0x03,
0xfc, 0xfa,
//--- Page 1 ---
0x07, 0x0b,
0x0c, 0x18,
0x18, 0x00,
0x13, 0x13,
0x11, 0x13,
0x10, 0x11,
0x10, 0x10,
0x13, 0x13,
0x11, 0x13,
0x10, 0x11,
0x10, 0x00,
0x08, 0x18,
0x07, 0x0b
}
};

View file

@ -1,56 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\FR.bmp
//
// ICON_GRAY - 2 bpp (Bit per Pixel)
// sizeof (iconFr.data) == 52
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconFr =
{
/* width = */ 13,
/* height = */ 13,
/* info = */ ICON_INFO (ICON_GRAY)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0xfc, 0xfa,
0x02, 0x03,
0x41, 0xe0,
0xe1, 0xf1,
0xf1, 0xf9,
0xf9, 0xf9,
0x41, 0xe1,
0xe1, 0xf1,
0xf1, 0xf9,
0xf9, 0xf9,
0x03, 0x00,
0x06, 0x03,
0xfc, 0xfa,
//--- Page 1 ---
0x07, 0x0b,
0x0c, 0x18,
0x18, 0x00,
0x10, 0x11,
0x11, 0x13,
0x13, 0x13,
0x10, 0x10,
0x10, 0x11,
0x11, 0x13,
0x13, 0x13,
0x18, 0x00,
0x0c, 0x18,
0x07, 0x0b
}
};

View file

@ -1,173 +0,0 @@
////////////////////////////////////////////////////
// This file was generated by the tool GrayScaler.
// Source bitmap: R:\Project\GrayScaler\Icons\Hourglas.bmp
//
// ICON_GRAY - 2 bpp (Bit per Pixel)
// sizeof (iconHourglas.data) == 280
//
////////////////////////////////////////////////////
#include "icon.h"
#ifndef ICON_INFO
#define ICON_INFO(i) i,
#endif
const ICON iconHourglas =
{
/* width = */ 28,
/* height = */ 40,
/* info = */ ICON_INFO (ICON_GRAY)
/* data [] = */
{
// Bit 0 is the upper most pixel
// of the page, which is 8 pixel high
//--- Page 0 ---
0x0e, 0x11,
0x3f, 0x1e,
0x7f, 0x3a,
0xff, 0x6a,
0xff, 0xca,
0xff, 0xca,
0x3f, 0x0a,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3b, 0x0e,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0x3f, 0x0a,
0xff, 0xca,
0xff, 0xca,
0xff, 0x6a,
0x7f, 0x3a,
0x3f, 0x1e,
0x0e, 0x11,
//--- Page 1 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x0f,
0xfe, 0xfd,
0x70, 0xb8,
0xe0, 0x70,
0xc0, 0xa0,
0x80, 0x50,
0x30, 0x80,
0xf0, 0x00,
0xf0, 0x00,
0xf0, 0x00,
0xf0, 0x08,
0x70, 0x88,
0xb0, 0xc8,
0xd8, 0x64,
0x78, 0xe4,
0x36, 0xf8,
0xfe, 0xfd,
0xff, 0x0f,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 2 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x00,
0xff, 0xff,
0x00, 0xff,
0x80, 0x80,
0xc1, 0xc0,
0x61, 0xb3,
0x3f, 0x12,
0x1c, 0x0f,
0x07, 0x00,
0x1d, 0x0e,
0x3f, 0x12,
0x63, 0xb5,
0xc1, 0xe2,
0x80, 0xc1,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0x00,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 3 ---
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0xff,
0xff, 0xff,
0xff, 0xfc,
0xff, 0x0f,
0x07, 0x0b,
0x81, 0x03,
0xc0, 0x01,
0xc0, 0x20,
0xe0, 0x10,
0xf0, 0x00,
0xf8, 0x00,
0xf0, 0x00,
0xe0, 0x10,
0xc0, 0x20,
0xc0, 0x01,
0x81, 0x03,
0x03, 0x87,
0x0e, 0x17,
0xff, 0x1f,
0xff, 0xf8,
0xff, 0xff,
0x00, 0xff,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
//--- Page 4 ---
0x70, 0x88,
0xfc, 0x78,
0xfe, 0x7c,
0xff, 0x76,
0xff, 0x77,
0xff, 0x77,
0xff, 0x74,
0xfe, 0x75,
0xff, 0x74,
0xff, 0x74,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xf7, 0x7c,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xff, 0x74,
0xfe, 0x75,
0xff, 0x74,
0xff, 0x77,
0xff, 0x77,
0xff, 0x76,
0xfe, 0x7c,
0xfc, 0x78,
0x70, 0x88
}
};

Some files were not shown because too many files have changed in this diff Show more