]> git.sur5r.net Git - cc65/blob - src/geos/headergen.sh
Fix problematic code. Use more stuff from the shared modules.
[cc65] / src / geos / headergen.sh
1 #!/bin/sh
2
3 # GEOS .cvt header generator...
4 # it's a really quick and dirty hack ... big and ugly...
5
6 # by Maciej 'YTM/Alliance' Witkowiak
7 # 9/10.3.2000
8
9 case "$1" in
10
11     *.res)
12
13 #include resource file
14
15     . $1
16
17 #test is arguments are really given, if not - set defaults
18
19 # binary file type
20 if [ -z "$progtype" ];  then progtype="APPLICATION"; fi
21
22 # filenames
23 if [ -z "$dosname" ];   then dosname="testapp"  ; fi
24 if [ -z "$dostype" ];   then dostype="USR"      ; fi
25
26 # date
27 if [ -z "$year" ];      then year=`date +%y`    ; fi
28 if [ -z "$month" ];     then month=`date +%m`   ; fi
29 if [ -z "$day" ];       then day=`date +%e`     ; fi
30 if [ -z "$hour" ];      then hour=`date +%k`    ; fi
31 if [ -z "$minute" ];    then minute=`date +%M`  ; fi
32
33 # screenmode
34 if [ -z "$screenmode" ]; then screenmode=0      ; fi
35
36 # names
37 if [ -z "$class" ];     then class="Programname"; fi
38 if [ -z "$version" ];   then version="V1.0"     ; fi
39 if [ -z "$author" ];    then author="cc65"; fi
40 if [ -z "$note" ];      then note="Program compiled with cc65 and GEOSLib."; fi
41
42 # start generator
43
44 cat << __END__
45
46 ; Maciej 'YTM/Alliance' Witkowiak
47 ; 28.02.2000
48
49 ; This is .cvt header for GEOS files, it is recognized by Convert v2.5 for GEOS
50 ; and Star Commander (when copying GEOS files to/from .d64 images)
51
52 ; currently only SEQUENTIAL structure is supported, no overlays
53
54 ; THIS IS GENERATED FILE, ANY CHANGES WILL BE LOST!!!
55
56                         .segment "HEADER"
57
58 ;
59 ;filetypes
60 ;       GEOS
61 NOT_GEOS                =       0
62 BASIC                   =       1
63 ASSEMBLY                =       2
64 DATA                    =       3
65 SYSTEM                  =       4
66 DESK_ACC                =       5
67 APPLICATION             =       6
68 APPL_DATA               =       7
69 FONT                    =       8
70 PRINTER                 =       9
71 INPUT_DEVICE            =       10
72 DISK_DEVICE             =       11
73 SYSTEM_BOOT             =       12
74 TEMPORARY               =       13
75 AUTO_EXEC               =       14
76 INPUT_128               =       15
77 NUMFILETYPES            =       16
78 ;       structure
79 SEQUENTIAL              =       0
80 VLIR                    =       1
81 ;       DOS
82 DEL                     =       0
83 SEQ                     =       1
84 PRG                     =       2
85 USR                     =       3
86 REL                     =       4
87 CBM                     =       5
88
89 __END__
90
91 echo -e ProgType\\t\\t=\\t$progtype
92 echo -e \\n\\t\\t.byte $dostype '| $80'\\t\\t'; DOS filetype'
93 echo -e \\t\\t.word 0\\t\\t'; T&S, will be fixed by converter'
94 echo $dosname | awk '
95 { len=length($0); printf "\t\t.byte %c%s%c\n", 34, substr($0,0,16), 34;
96   if (len<16) { len=15-len; printf "\t\t.byte $a0"
97   while (len>0) { printf ", $a0"; len-=1 } }
98   print ""
99   }'
100 echo -e \\t\\t.word 0\\t\\t'; header T&S'
101 echo -e \\t\\t.byte SEQUENTIAL
102 echo -e \\t\\t.byte ProgType
103 echo -e \\t\\t.byte $year
104 echo -e \\t\\t.byte $month
105 echo -e \\t\\t.byte $day
106 echo -e \\t\\t.byte $hour
107 echo -e \\t\\t.byte $minute
108 echo -e \\n\\t\\t.word 0
109 cat << __END__
110
111                 .byte "PRG formatted GEOS file V1.0"
112                                                 ; converter stamp
113                 .res \$c4                       ; some bytes are left
114             
115                 .byte 3, 21, 63 | \$80  ; icon picture header, 63 bytes follow
116
117                 ;** hey, uberhacker! edit icon here!!! ;-))    
118                 .byte %11111111, %11111111, %11111111
119                 .byte %10000000, %00000000, %00000001
120                 .byte %10000000, %00000000, %00000001
121                 .byte %10000000, %00000000, %00000001
122                 .byte %10000000, %00000000, %00000001
123                 .byte %10000000, %00000000, %00000001
124                 .byte %10000000, %00000000, %00000001
125                 .byte %10000000, %00000000, %00000001
126                 .byte %10000000, %00000000, %00000001
127                 .byte %10000000, %00000000, %00000001
128                 .byte %10000000, %00000000, %00000001
129                 .byte %10000000, %00000000, %00000001
130                 .byte %10000000, %00000000, %00000001
131                 .byte %10000000, %00000000, %00000001
132                 .byte %10000000, %00000000, %00000001
133                 .byte %10000000, %00000000, %00000001
134                 .byte %10000000, %00000000, %00000001
135                 .byte %10000000, %00000000, %00000001
136                 .byte %10000000, %00000000, %00000001
137                 .byte %10000000, %00000000, %00000001
138                 .byte %11111111, %11111111, %11111111
139
140 __END__
141
142 echo -e \\n\\t\\t.byte $dostype '| $80'\\t\\t';DOS filetype again'
143
144 cat << __END__
145                 .byte ProgType          ;again GEOS type
146                 .byte SEQUENTIAL        ;structure
147                 .word \$0400            ;ProgStart
148                 .word \$0400-1          ;ProgEnd (needs proper value for DESK_ACC)
149                 .word \$0400            ;ProgExec
150 __END__
151
152 echo -e \\t\\t'; GEOS class (11 chars padded with spaces, terminated with space (12th))'
153 echo $class | awk '
154 { len=length($0); printf "\t\t.byte %c%s%c\n", 34, substr($0,0,12), 34;
155   if (len<12) { len=11-len; printf "\t\t.byte $20"
156   while (len>0) { printf ", $20"; len-=1 } }
157   print ""
158   }'
159 echo -e \\t\\t'; version info (4 characters)'
160 echo -en \\t\\t.byte 
161 echo $version | awk '{ printf " %c%s%c\n", 34, substr($0,1,4), 34}'
162 echo -e \\t\\t.byte 0\\t\\t\\t';string terminator'
163 echo -e \\t\\t.word 0
164 echo -e \\n\\t\\t.byte $screenmode\\t\\t\\t';40/80 columns capability'
165 echo -e \\n\\t\\t'; author, up to 62 characters'
166 echo $author | awk '
167 { printf "\t\t.byte %c%s%c\n\t\t.byte 0\n\t\t.res (63-%i)\n", 34, substr($0,0,62), 34, length($0)+1; }'
168 echo -e \\n\\t\\t';note (up to 95 chars)'
169 echo $note | awk '
170 { printf "\t\t.byte %c%s%c\n\t\t.byte 0\n\t\t.res (96-%i)\n", 34, substr($0,0,95), 34, length($0)+1; }'
171 echo -e \\n\\n';end of .cvt header, real code follows'
172
173     ;;
174     *)
175 echo "This is GEOSLib .cvt header generator by Maciej Witkowiak"
176 echo "Usage:"
177 echo "  headergen resourcefile.res"
178 echo
179 echo "Contents of resource file are (case sensitive):"
180 echo "dostype=[PRG,SEQ,USR]"
181 echo "dosname=filename"
182 echo "progtype=[APPLICATION,ASSEMBLY,DESK_ACC,PRINTER,INPUT_DEVICE,AUTO_EXEC,INPUT_128]"
183 echo "         currently only APPLICATION is supported"
184 echo "year,month,date,hour,minute=XX - if not given current will be used"
185 echo "screenmode=[0,64,128,192] -"
186 echo "            0 - GEOS128 only 40 columns"
187 echo "           64 - GEOS128 both 40/80 columns"
188 echo "          128 - does not run under GEOS128"
189 echo "          192 - GEOS128 only 80 columns"  
190 echo "class=Class       - GEOS class name"
191 echo "author=Author     - author name"
192 echo "note=Note - note field"
193 echo 
194 echo "If any of those parameters is not given, default will be used"
195 echo "Output should be redirected to a file e.g. cvthead.s"
196 echo "compiled with ca65 and used in linking process as the first object file -"
197 echo "even before crt0.o"
198     ;;
199 esac