diff --git a/hardware/.gitignore b/hardware/.gitignore index 1339262..4908c68 100644 --- a/hardware/.gitignore +++ b/hardware/.gitignore @@ -1,3 +1,4 @@ startup sprites playfield1 +scoopex1 diff --git a/hardware/Makefile b/hardware/Makefile index d14184f..693f689 100644 --- a/hardware/Makefile +++ b/hardware/Makefile @@ -1,10 +1,10 @@ CC=vc +kick13 CFLAGS=-c99 -I$(NDK_INC) -DDEBUG -O2 -all: startup sprites playfield1 +all: startup sprites playfield1 scoopex1 clean: - rm -f *.o startup sprites playfield1 + rm -f *.o startup sprites playfield1 scoopex2 startup: startup.o common.o $(CC) $(CFLAGS) $^ -lamiga -lauto -o $@ @@ -14,3 +14,7 @@ sprites: sprites.o common.o playfield1: playfield1.o common.o $(CC) $(CFLAGS) $^ -lamiga -lauto -o $@ + +scoopex1: scoopex1.c + $(CC) $(CFLAGS) $^ -lamiga -lauto -o $@ + diff --git a/hardware/playfield1.c b/hardware/playfield1.c index fd0f8d8..2d8c202 100644 --- a/hardware/playfield1.c +++ b/hardware/playfield1.c @@ -27,6 +27,8 @@ * A simple setup to display a playfield with a depth of 1 bit. */ extern struct Custom custom; + +// version string for the version command to display char VERSION_STRING[] = "\0$VER: playfield1 1.0 (21.09.2016)\0"; static UWORD __chip coplist[] = { @@ -63,6 +65,7 @@ int main(int argc, char **argv) #endif custom.bplcon1 = 0; // horizontal scroll value = 0 for all playfields custom.bpl1mod = 0; // modulo = 0 for odd bitplanes + custom.dmacon = 0x20; custom.ddfstrt = DDFSTRT_VALUE; custom.ddfstop = DDFSTOP_VALUE; diff --git a/hardware/scoopex1.c b/hardware/scoopex1.c new file mode 100644 index 0000000..e0711b8 --- /dev/null +++ b/hardware/scoopex1.c @@ -0,0 +1,34 @@ +#include +#include + +extern struct Custom custom; +/* + * declare memory mapped chip areas as volatile to ensure + * the compiler does not optimize away the access. + */ +volatile UBYTE *ciaa_pra = (volatile UBYTE *) 0xbfe001; +volatile UBYTE *custom_vhposr= (volatile UBYTE *) 0xdff006; +#define PRA_FIR0_BIT (1 << 6) +#define COLOR_WHITE (0xfff) +#define COLOR_WBENCH_BG (0x05a) +#define TOP_POS (0x40) +#define BOTTOM_POS (0xf0) + +int main(int argc, char **argv) +{ + UBYTE pra_value = 0; + UBYTE pos = 0xac; + BYTE incr = 1; + + while ((*ciaa_pra & PRA_FIR0_BIT) != 0) { + while (*custom_vhposr != 0xff) ; // wait for vblank + while (*custom_vhposr != pos) ; // wait until position reached + custom.color[0] = COLOR_WHITE; + while (*custom_vhposr == pos) ; // wait while on the target position + custom.color[0] = COLOR_WBENCH_BG; + if (pos >= 0xf0) incr = -incr; + else if (pos <= 0x40) incr = -incr; + pos += incr; + } + return 0; +} diff --git a/utils/png2image.py b/utils/png2image.py index 4210a64..866cc3a 100755 --- a/utils/png2image.py +++ b/utils/png2image.py @@ -21,14 +21,11 @@ def color_to_plane_bits(color, depth): result[bit] = 1 return result -def write_amiga_image(image, outfile, img_name, use_intuition): + +def extract_planes(im, depth): imdata = im.getdata() width, height = im.size - # colors is a list of 3-integer lists ([[r1, g1, b1], ...]) - colors = [i for i in chunks([b for b in im.palette.tobytes()], 3)] - depth = round(math.log(len(colors), 2)) - map_words_per_row = int(width / 16) if width % 16 > 0: map_words_per_row += 1 @@ -50,7 +47,19 @@ def write_amiga_image(image, outfile, img_name, use_intuition): if planebits[planeidx]: planes[planeidx][pos] |= (1 << (15 - (x + i) % 16)) # 1 << ((x + i) % 16) x += 16 + return planes, map_words_per_row +def write_amiga_image(im, outfile, img_name, use_intuition, verbose): + imdata = im.getdata() + width, height = im.size + + # colors is a list of 3-integer lists ([[r1, g1, b1], ...]) + colors = [i for i in chunks([b for b in im.palette.tobytes()], 3)] + depth = round(math.log(len(colors), 2)) + planes, map_words_per_row = extract_planes(im, depth) + + if verbose: + print("image width: %d height: %d depth: %d" % (width, height, depth)) if use_intuition: outfile.write('#include \n\n') imgdata_varname = '%s_data' % img_name @@ -97,11 +106,13 @@ if __name__ == '__main__': parser.add_argument('headerfile', help="output header file") parser.add_argument('--img_name', default='image', help="variable name of the image") parser.add_argument('--use_intuition', action='store_true', help="generate data for Intuition") + parser.add_argument('--verbose', action='store_true', help="verbose mode") args = parser.parse_args() im = Image.open(args.pngfile) if not os.path.exists(args.headerfile): with open(args.headerfile, 'w') as outfile: - write_amiga_image(im, outfile, img_name=args.img_name, use_intuition=args.use_intuition) + write_amiga_image(im, outfile, img_name=args.img_name, use_intuition=args.use_intuition, + verbose=args.verbose) else: print("file '%s' already exists." % args.headerfile)