1
0
mirror of https://github.com/UzixLS/pacemuzx.git synced 2025-07-18 23:01:36 +03:00

pacemuzx v1.0

This commit is contained in:
Simon Owen
2011-11-08 23:49:42 +00:00
commit 9f263276fe
14 changed files with 2937 additions and 0 deletions

3
.gitattributes vendored Normal file
View File

@ -0,0 +1,3 @@
ReadMe.txt -crlf
make.bat -crlf
make.bat-dist -crlf

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
dist/
sprites.bin
tiles.bin
pacemuzx.tap

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
TAPE=pacemuzx.tap
ROMS=pacman.6e pacman.6f pacman.6h pacman.6j
.PHONY: dist clean
$(TAPE): loader.tap pacemuzx.o
cat loader.tap pacemuzx.o > $@
tiles.bin: tiles.png
./png2bin.pl $< 6
sprites.bin: sprites.png
./png2bin.pl $< 12
pacemuzx.o: pacemuzx.asm tiles.bin sprites.bin $(ROMS)
pasmo --tap pacemuzx.asm pacemuzx.o pacman.sym
dist: $(TAPE)
rm -rf dist
mkdir dist
cp ReadMe.txt dist/
cp Makefile-dist dist/Makefile
cp make.bat-dist dist/make.bat
./remove_rom.pl $(TAPE)
mv start.part end.part dist/
clean:
rm -f $(TAPE) pacemuzx.sym pacemuzx.o
rm -f tiles.bin sprites.bin start.part end.part
rm -rf dist

8
Makefile-dist Normal file
View File

@ -0,0 +1,8 @@
TAPE=pacemuzx.tap
ROMS=pacman.6e pacman.6f pacman.6h pacman.6j
$(TAPE): start.part $(ROMS) end.part
cat start.part $(ROMS) end.part > $(TAPE)
clean:
rm -f pacemuzx.tap

19
ReadMe.txt Normal file
View File

@ -0,0 +1,19 @@
Pac-Man Emulator for Sinclair Spectrum
--------------------------------------
This program requires a Spectrum +2A/+3, and will not work on earlier models.
The Pac-Man ROMs cannot be supplied with this program, so you must supply your
own copies of the following files:
pacman.6e pacman.6f pacman.6h pacman.6j
Copy them to the same directory as this file, then run make.bat (Windows) or
make (Mac/Linux/Un*x) to build the final pacemuzx.tap image file.
Enjoy!
---
Simon Owen
http://simonowen.com/spectrum/pacemuzx/

BIN
loader.tap Normal file

Binary file not shown.

29
make.bat Normal file
View File

@ -0,0 +1,29 @@
@echo off
if "%1"=="clean" goto clean
png2bin.pl tiles.png 6
png2bin.pl sprites.png 12
pasmo --tap pacemuzx.asm pacemuzx.o
copy /b loader.tap+pacemuzx.o pacemuzx.tap
if not "%1"=="dist" goto end
if not exist dist mkdir dist
copy ReadMe.txt dist\
copy Makefile-dist dist\Makefile
copy make.bat-dist dist\make.bat
remove_rom.pl
move start.part dist\
move end.part dist\
goto end
:clean
if exist pacemuzx.tap del pacemuzx.tap pacemuzx.sym pacemuzx.o
if exist tiles.bin del tiles.bin sprites.bin
if exist dist\ del dist\Makefile dist\make.bat dist\start.part dist\end.part dist\pacemuzx.tap
if exist dist\ rmdir dist
:end

30
make.bat-dist Normal file
View File

@ -0,0 +1,30 @@
@echo off
if not exist pacman.6e goto missing
if not exist pacman.6f goto missing
if not exist pacman.6h goto missing
if not exist pacman.6j goto missing
goto got_roms
:missing
echo.
echo ****************************************************************
echo.
echo The Pac-Man ROMs can't be distributed with this program, so you
echo must provide your own copies of:
echo.
echo pacman.6e pacman.6f pacman.6h pacman.6j
echo.
echo Copy them to this directory and re-run to generate: pacemuzx.tap
echo.
echo ****************************************************************
echo.
pause
goto end
:got_roms
copy /b start.part+pacman.6e+pacman.6f+pacman.6h+pacman.6j+end.part pacemuzx.tap
start pacemuzx.tap
:end

2503
pacemuzx.asm Normal file

File diff suppressed because it is too large Load Diff

196
pacman.sym Normal file
View File

@ -0,0 +1,196 @@
attr_colour EQU 00007H
attr_fill_lp EQU 0A21EH
attr_fill_lp2 EQU 0A220H
attr_lp EQU 0A0AEH
attr_same EQU 0A22FH
attr_scr_lp EQU 0A20EH
attract_mode EQU 0A27EH
bak_chars1 EQU 0B500H
bak_chars2 EQU 0B900H
blank_lp EQU 0A7CAH
blank_sprite EQU 0A7C4H
blockdown_de EQU 0AC12H
blockdown_hl EQU 0AC08H
border EQU 000FEH
chk_digit EQU 0A97AH
chk_fruit EQU 0A9C8H
chk_life EQU 0AA20H
clear_io EQU 0A0CDH
conv_86_lp EQU 0AB2BH
conv_8_6 EQU 0B000H
conv_x EQU 0B100H
conv_y EQU 0B200H
debug EQU 00000H
dip_5000 EQU 0A002H
dip_5040 EQU 0A003H
dip_5080 EQU 0A004H
div_lp EQU 0AA5EH
div_ok EQU 0AA6CH
do_flip EQU 0A1DBH
do_fruit EQU 0A988H
do_input EQU 0A371H
do_int_hook EQU 0A178H
do_lives EQU 0A9F2H
do_restore EQU 0A84FH
do_save EQU 0A7DAH
do_score1 EQU 0A8DCH
do_score2 EQU 0A92BH
do_sound EQU 0AAA4H
do_sprites EQU 0A89FH
do_tiles EQU 0A445H
do_trim EQU 0A76FH
draw_spr EQU 0A68EH
draw_spr2 EQU 0A6A6H
draw_tile EQU 0A5C7H
draw_tile_x EQU 0A5CAH
eat_sound EQU 0AAFEH
end_a000 EQU 0ADA5H
end_b000 EQU 0BD00H
end_tile_data EQU 0F6E4H
fail_msg EQU 0A02EH
find_change EQU 0AD00H
flash_colour EQU 00041H
flash_maze EQU 0A1F5H
flash_pills EQU 0A232H
fulldraw_alt EQU 0A474H
fulldraw_norm EQU 0A450H
int_chain EQU 0A1CBH
is_visible EQU 0A433H
kempston EQU 0001FH
keyboard EQU 000FEH
map_big EQU 0A74EH
map_ghost EQU 0A75BH
map_scared EQU 0A769H
map_sound EQU 0AACEH
map_spr EQU 0A729H
may_trim EQU 0A786H
maze_blue EQU 0A208H
mirror_lp EQU 0AB3EH
mk_lookups EQU 0AB27H
msg_lp EQU 0A027H
new_stack EQU 0B000H
no_shift EQU 0A3C3H
no_trim EQU 0A782H
not_0 EQU 0A3D3H
not_1 EQU 0A382H
not_123 EQU 0A38CH
not_2 EQU 0A387H
not_67890 EQU 0A3E7H
not_7 EQU 0A3E2H
not_8 EQU 0A3DDH
not_9 EQU 0A3D8H
not_a EQU 0A3F9H
not_down EQU 0A41EH
not_fire EQU 0A42AH
not_left EQU 0A419H
not_o EQU 0A407H
not_p EQU 0A402H
not_q EQU 0A3F0H
not_right EQU 0A414H
not_shift_5 EQU 0A3A7H
not_shift_7 EQU 0A3BCH
not_shift_8 EQU 0A3B7H
not_shift_t EQU 0A39DH
not_silent EQU 0AAECH
not_up EQU 0A423H
old_stack EQU 0A1C8H
pac_chars EQU 04040H
pac_footer EQU 04000H
pac_header EQU 043C0H
page_rom EQU 0A0ECH
page_screen EQU 0A0F8H
patch_rom EQU 0A103H
pill_1 EQU 0A29CH
pill_1_on EQU 0A2A4H
pill_2 EQU 0A2E2H
pill_clear_1 EQU 0A2C4H
pill_clear_2 EQU 0A325H
play_sound EQU 0AB09H
read_joy EQU 0A407H
read_qaop EQU 0A3E7H
restore_lp EQU 0A889H
rot_0_4 EQU 0A6B7H
rot_0_lp EQU 0A6EEH
rot_1_5 EQU 0A6D2H
rot_2_6 EQU 0A6C3H
rot_3_7 EQU 0A6DEH
rot_even EQU 0A6B4H
rot_odd EQU 0A6CFH
save_lp EQU 0A839H
scr_page EQU 0A1F4H
scradtab EQU 0B300H
scrinit_lp EQU 0A082H
scrtab_lp EQU 0ABDFH
set_attrs EQU 0A208H
set_int_chain EQU 0A1CEH
sinit_data EQU 0AA9BH
sinit_lp EQU 0AA8DH
sound_init EQU 0AA46H
sound_lp EQU 0AA49H
sound_table EQU 0C000H
spr_2 EQU 0A6EAH
spr_3 EQU 0A704H
spr_3_lp EQU 0A70DH
spr_data_0 EQU 05BE4H
spr_data_1 EQU 06304H
spr_data_2 EQU 06A24H
spr_data_3 EQU 07144H
spr_data_4 EQU 07864H
spr_data_5 EQU 07F84H
spr_data_6 EQU 08A34H
spr_data_7 EQU 094E4H
spr_data_end EQU 09F94H
spr_restore EQU 0A879H
spr_rot_lp EQU 0AB94H
spr_rot_lp2 EQU 0AB97H
spr_rot_lp3 EQU 0AB9FH
spr_rot_lp4 EQU 0ABB9H
spr_save EQU 0A821H
spr_save_2 EQU 05B00H
spr_save_3 EQU 05B26H
spr_save_4 EQU 05B4CH
spr_save_5 EQU 05B72H
spr_save_6 EQU 05B98H
spr_save_7 EQU 05BBEH
spr_save_end EQU 05BE4H
start EQU 0A000H
start2 EQU 0A005H
start3 EQU 0A04DH
strip_0 EQU 0A49EH
strip_0_alt EQU 0A517H
strip_1 EQU 0A4B1H
strip_1_alt EQU 0A52AH
strip_2 EQU 0A4CFH
strip_2_alt EQU 0A549H
strip_3 EQU 0A4E2H
strip_3_alt EQU 0A55CH
strip_4 EQU 0A501H
strip_4_alt EQU 0A57BH
strip_even EQU 0A49BH
strip_odd EQU 0A514H
text_fix EQU 0A172H
tile_0 EQU 0A5F6H
tile_0_lp EQU 0A5FDH
tile_2 EQU 0A66AH
tile_2_lp EQU 0A671H
tile_4 EQU 0A611H
tile_4_lp EQU 0A619H
tile_6 EQU 0A63FH
tile_62 EQU 0A63CH
tile_6_lp EQU 0A647H
tile_comp EQU 0A58EH
tile_data_0 EQU 0DBE4H
tile_data_2 EQU 0F264H
tile_data_4 EQU 0E964H
tile_data_6 EQU 0E064H
tile_exit EQU 0A685H
tile_mapped EQU 0A5AFH
tile_state EQU 0A448H
tile_strips EQU 0A498H
tilerot_lp EQU 0AB5DH
tilerot_lp2 EQU 0AB5FH
trim_edge EQU 0A799H
trim_line_lp EQU 0A7A7H
trim_lp EQU 0A774H
vis_lp EQU 0A43AH
xy_to_addr EQU 0ABEEH

89
png2bin.pl Executable file
View File

@ -0,0 +1,89 @@
#!/usr/bin/perl -w
#
# Convert PNG image to Spectrum format sprite image data
#
# Input image should be palettised 1-bit with no transparency
#
# Simon Owen <simon@simonowen.com>
use Compress::Zlib;
use Getopt::Std;
# Allow -v option for verbose output
getopt('v');
# Strip path from input filename, and check
$0 =~ s/.*\///;
die "Usage: $0 <image> <sprite-width> [<sprite-height>]\n" unless @ARGV == 2 or @ARGV == 3;
# Input image and output data file
($file,$w,$h) = (@ARGV,$ARGV[1]); # height defaults to width if not provided
die "Input image must be in PNG format\n" unless $file =~ /.png$/i;
die "Sprite width should be 2-16 pixels\n" unless $w >= 2 && $w <= 16;
die "Sprite height should be at least 1 pixel\n" unless $h > 0;
# Slurp the entire PNG image
open INPUT, "<$file" and binmode INPUT or die "$file: $!\n";
read INPUT, $data='', -s $file;
close INPUT;
# Extract and check the image dimensions
$data =~ /IHDR(.{8})/s;
($iw,$ih) = unpack "N2", $1;
die "Input image (${iw}x${ih}) must be an exact multiple of sprite size (${w}x${h})\n" if ($iw%$w) or ($ih%$h);
# Extract and expand the compressed image data
($data) = $data =~ /IDAT(.*).{8}IEND/s;
$data = Compress::Zlib::uncompress($data);
# Remove the type byte from the start of each line, leaving just 0+1 pixel values
if (length($data) == (($iw+1)*$ih)) { # 8bpp?
$data =~ s/.(.{$iw})/$1/sg;
@data = map { $_&1 } unpack("C*", $data);
} elsif (length($data) == (($iw/2+1)*$ih)) { # 4bpp?
my $iw_2 = $iw/2;
$data =~ s/.(.{$iw_2})/$1/sg;
foreach (unpack("C*", $data)) {
push @data, ($_>>4)&1, $_&1;
}
} else {
die "Image data format is unsupported (size = ".@data." bytes)\n";
}
# Calculate rows+columns and the expected size of the output data
($c,$r) = ($iw/$w,$ih/$h);
$size = int(($w+7)/8)*$h*$r*$c;
print "Input image ($file) = ${iw}x${ih}, sprite = ${w}x${h}\n" if $opt_v;
foreach $y (0..$r-1)
{
foreach $x (0..$c-1)
{
foreach $l (0..$h-1) # line
{
# Calculate the offset of the required bit sequence
my $o = ((($y*$h+$l)*$c) + $x) * $w;
# Convert the individual bits to a binary string then a decimal value
my $n = unpack("N", pack("B32", substr("0"x32 . join('', @data[$o..$o+$w-1]), -32)));
# Pack into 1 or 2 bytes, with the bits left-aligned (MSB)
$output .= pack(($w<=8)?"C":"n", $n << (8-($w & 7)));
}
}
}
# Sanity check the output data size
die "Output data ", length($output), " is the wrong size! (should be $size)\n" unless length($output) == $size;
# The output file is the input filename with a .bin extension instead of .png
$file =~ s/png$/bin/i;
open OUTPUT, ">$file" and binmode OUTPUT or die "$file: $!\n";
# Determine the size of a single sprite, and strip blank sprites from the end of the data
$ss = length($output) / ($r*$c);
$output =~ s/(\0{$ss})*$//;
print "Output data ($file) = ", length($output), " bytes = ", length($output)/$ss, " sprites\n" if $opt_v;
print OUTPUT $output;
close OUTPUT;

26
remove_rom.pl Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/perl -w
# First 4K of Pac-Man ROM
$file = 'pacman.6e';
open FILE, "<$file" and binmode FILE or die "$file: $!\n";
read FILE, $rom='', -s $file;
close FILE;
# Full TAP image for emulator, including ROM
$file = 'pacemuzx.tap';
open FILE, "<$file" and binmode FILE or die "$file: $!\n";
read FILE, $data='', -s $file;
close FILE;
$index = index($data, $rom);
die "ROM image not found in TAP file!\n" if $index < 0;
$file = 'start.part';
open FILE, ">$file" and binmode FILE or die "$file: $!\n";
print FILE substr $data, 0, $index;
close FILE;
$file = 'end.part';
open FILE, ">$file" and binmode FILE or die "$file: $!\n";
print FILE substr $data, $index+16384;
close FILE;

BIN
sprites.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
tiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B