;; Ms. Pac-Man documented disassembly ;; ;; The copyright holders for the core program ;; included within this file are: ;; (c) 1980 NAMCO ;; (c) 1980 Bally/Midway ;; (c) 1981 General Computer Corporation (GCC) ;; ;; Research and compilation of the documentation by ;; Scott 'Jerry' Lawrence ;; pacman@umlautllama.com ;; ;; Documentation and Hack Contributors: ;; David Caldwell http://www.porkrind.org ;; Frederic Vecoven http://www.vecoven.com (Music, Sound) ;; Fred K "Juice" ;; Marcel "The Sil" Silvius http://home.kabelfoon.nl/~msilvius/ ;; Mark Spaeth http://rgvac.978.org/asm ;; Dave Widel http://www.widel.com/ ;; M.A.B. from Vigasoco ;; ;; $Id: mspac.asm,v 1.47 2008/06/21 05:43:48 sdl Exp $ ;; ;; ;; DISCLAIMER: ;; This project is a learning experience. The goal is to try ;; to figure out how the original programmers and subsequent ;; GCC programmers wrote Pac-Man, Crazy Otto, and Ms. Pac-Man. ;; This disassembly and comments are not sanctioned in any ;; way by any of the copyright holders of these programs. ;; ;; Over time, this document may transform from a documented disassembly ;; of the bootleg ms-pacman roms into a re-assemblable source file. ;; ;; This is also made to determine which spaces in the roms are available ;; for patches and extra functionality for your own hacks. ;; ;; NOTE: This disassembly is based on the base "bootleg" ;; version of Ms. Pac-Man. ("boot1" through "boot6") ;; rom images used: ;; 0x0000 - 0x0fff boot1 ;; 0x1000 - 0x1fff boot2 ;; 0x2000 - 0x2fff boot3 ;; 0x3000 - 0x3fff boot4 ;; 0x8000 - 0x8fff boot5 ;; 0x9000 - 0x9fff boot6 ;; ;; More information about the actual Ms. Pac-Man aux board is below. ;; ;; ;; IF YOU ARE AWARE OF ANY BITS OF CODE THAT ARE NOT DOCUMENTED ;; HERE, OR KNOW OF MORE RAM ADDRESSES OR SUCH, PLEASE EMAIL ;; ME SO THAT I MAY INTEGRATE YOUR INFORMATION INTO HERE. ;; ;; THANKS! ;; 2008-06-20 ;; Added content from Frederic Vecoven for all of the sound code ;; ;; 2007-09-03 ;; added more notes about mspac blocks in 8000/9000 ;; RAM layout, data tables from M.A.B. in the VIGASOCO project (pac) ;; ;; 2004-12-28 ;; added Interrupt Mode 1/2 documentation ;; ;; 2004-12-22 ;; added HACK12 - the C000 text mirror bug fix ;; ;; 2004-03-21 ;; added information for most of the reference tables for map-related-data ;; ;; 2004-03-15 ;; working on figuring out RST 28 ;; ;; 2004-03-09 ;; added comments about how the text rendering works (at 0x2c5e) ;; added more details about the text string look up table ;; added information about midway logo rendering at 0x964a ;; changed all of the RST 28 calls to have data after them ;; ;; 2004-03-03 ;; mapped out most of the patches in 8000-81ef range ;; (some are unused ff's, some I couldn't find...) ;; ;; 2004-03-02 ;; HACK10: Dave Widel's fast intermission fix (based on Dock Cutlip's code) ;; HACK11: Dave Widel's coin light blink with power pellets ;; ;; 2004-02-18 ;; HACK8: Mark Spaeth's "20 byte" level 255 Pac-Man rom fix ;; HACK9: Mark Spaeth's Ms. Pac-Man level fix ;; ;; 2004-01-10 ;; figured out some of the sound generation triggering ;; ;; 2004-01-09 ;; added notes about HACK7 : eliminating all of the startup tests ;; figured out the easter egg routine as well as storage method for data ;; ;; 2004-01-05 ;; added notes about HACK6 : the standard "HARD" romset ;; changed all of the HACK numbers ;; ;; 2004-01-04 ;; added notes from Fred K's roms about skipping the self test HACK4 ;; added notes about the pause routine HACK5 ;; added notes from Fred K about 018c game loop ;; ;; 2004-01-03 ;; added note about 0068-008c being junk - INCORRECT! (ed.) ;; ;; 2004-01-02 ;; added in more information about controllers ;; added info about the always-on fast upgrade HACK2 ;; added info about the P1P2 cheat HACK3 ;; ;; 2004-01-01 ;; integrated in Mark Spaeth's random fruit doc. ;; ;; 2003-07-16 ;; added in red ghost AI code documentation (2730, 9561) ;; ;; 2003-03-26 ;; changed some 'kick the dog' text ;; added a note about the checksum hack ; HACK1 ;; ;; 2003-03 ;; cleaned up some notes, added the "Made By Namco" egg notes ;; ;; + 2001-07-13 ;; more notes from David Widel. Ram variables, $2a23m $8768 ;; ;; + 2001-06-25,26 ;; integrated in some notes from David Widel (THANKS!) ;; ;; 2001-03-06 ;; integrated in Fred K's pacman notes. ;; ;; 2001-03-04 ;; corrected text strings in the lookup table at 36a5 ;; commented some of the text string routines ;; ;; 2001-02-28 ;; added text string lookup tables ;; added indirect lookup at 36a5 ;; added more commenting over from the pacman.asm file ;; ;; 2001-02-27 ;; table data pulled out, and bogus opcodes removed. ;; more score information found as well ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Documented Hacks HACK1 Skips the traditional bad-rom checksum routine. HACK2 Traditional "Fast Chip" hack HACK3 Dock Cutlip's Fast/Invincibility hack. Press P1 start for super speed Press P2 start for invincibility HACK4 Self-Test skip Reclaims rom space 3006 - 30c0 for custom code use HACK5 Game pause routine Press P1 start to pause Press P2 start to unpause HACK6 The standard "HARD" romset. Unknown exactly what the changes are. (data table) HACK7 Skips the Test startup display (Alternate) just skips the grid. HACK8 Mark Spaeth's level 255 Pac-Man fix Mspac never gets to 255, so this fix is pac-only HACK9 Mark Spaeth's level 141 Ms. Pac-Man fix http://www.funspotnh.com/discus/messages/10/508.html?1077146991 This fix is Ms. Pac only, but will work for pac as well. HACK10 Dave Widel's faster intermission fix Based on Dock Cutlip's code Pac moves at normal speeds in intermissions HACK11 Dave Widel's coin light blink with power pellets Coin lights blink when power pellets blink now ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Known Ms. Pac variants: ; (updated to come to this soon...) ; ; Ms. Pac-Man Original GCC/Midway w/ aux board ; Ms. Pac-Man Bootleg (various) decoded aux board ; Ms. Pac-Man Attack (code/map changes?) ; Miss Pac Plus (code/map changes?) (same as Attack, reversed) ; and of course, the "fast" and "cheat" versions of those above. ; similarly, Pac variants: ; Puckman Namco "original" ; Hanglyman Maze disappears sometimes, vertical tunnel? ; Pac-Man Namco/Midway ; Pac-Man Hard (table changes) ; Pac-Man Plus Midway upgrade ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; JUNK REGIONS OF ROMSPACE ; There are a few regions of rom space that are unused by the ms-pac program. These can be used for your own patches, or for data, or whatever. This list is most definitely incomplete. Not all of these regions have been tested. The list is inclusive of the start and end byte listed below. Some routines (like the self-test) can be dropped to give you more romspace to work with. You should be careful however in that some chunks of romspace might not be free with some rom hacks. (0f3c - 0f4b for example) 003b - 0041 7 bytes Tested 0f3c - 0fff 195 bytes Untested, nops 1fa9 - 1fff 87 bytes Untested, nops, 48 used for HACK3 cheat 2fba - 2fff 70 bytes Untested, nops 3ce0 - 3cff 32 bytes Untested, nops 8000 - 81ef 1f0 bytes Untested, bootleg hardware ONLY! 943c - 9469 2d bytes Untested, unknown - garbage bytes? 97c4 - 97cf c bytes Untested, FF's 97d0 - 97f0 30 bytes Untested, message 9800 - 9fff 400 bytes not available on "pure" mspac. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Ms Pacman Aux board information (GCC/Midway Pac-Man "Upgrade") ED note: The U5, U6 and U7 notes below have yet to be confirmed. It turns out the bootleg is the decrypted version with the checksum check removed and interrupt mode changed to 1. u7= boot 4($3000-$3fff) other than 4 bytes(checksum check and interupt mode) u6= boot 6($9000-$9fff). The second half of u6 gets mirrored Renders to the second half of boot5($8800-$8fff) where it is used. u5= first half of boot5($8000-$87ff) $8000-$81ef contain 8 byte patches that are overlayed on locations in $0000-$2fff The Ms Pacman aux board is not activated with the mainboard. As near as I can tell it requires a sequence of bytes starting at around 3176 and ending with 3196. The location of the bytes doesn't seem to matter, just that those bytes are executed. That sequence of bytes includes a write to 5006 so I'm using that to bankswitch, but that is not accurate. The actual change is I believe at $317D. The aux board can also be deactivated. A read to any of the several 8 byte chunks listed will cause the Ms Pac roms to disappear and Pacman to show up. As a result I couldn't verify what they contained. They should be the same as the pacman roms, but I don't see how it could matter. These areas can be accessed by the random number generator at $2a23 and the board is deactivated but is immediately reactivated. So the net result is no change. The exact trigger for this is not yet known. deactivation, 8 bytes starting at: $38,$3b0,$1600,$2120,$3ff0,$8000 David Widel d_widel@hotmail.com ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ram: ; 4c00 unused/unknown ; 4c01 unused/unknown ; ; Sprite variables ; ; 4c02 red ghost sprite number ; 4c03 red ghost color entry ; 4c04 pink ghost sprite number ; 4c05 pink ghost color entry ; 4c06 blue ghost sprite number ; 4c07 blue ghost color entry ; 4c08 orange ghost sprite number ; 4c09 orange ghost color entry ; 4c0a pacman sprite number ; 4c0b pacman color entry ; 4c0c fruit sprite number ; 4c0d fruit sprite entry ; ; 4c20 sprite data that goes to the hardware sprite system ; 4c3f ; 4c22-4c2f sprite positions for spriteram2 ; 4c32-4c3f sprite number and color for spriteram ; ; 4c40-4c7f unused/unknown ; ; Tasks and Timers ; ; 4c80 \ pointer to the end of the tasks list ; 4c81 / ; 4c82 \ pointer to the beginning of the tasks list ; 4c83 / ; 4c84 8 bit counter (0x00 to 0xff) used by sound routines ; 4c85 8 bit counter (0xff to 0x00) (unused) ; 4c86 counter 0: 0..5 10..15 20..25 .. 90..95 - hundreths ; 4c87 counter 1: 0..9 10..19 20..29 .. 50..59 - seconds ; 4c88 counter 2: 0..9 10..19 20..29 .. 50..59 - minutes ; 4c89 counter 3: 0..9 10..19 20..29 .. 90..99 - hours ; ; 4c8a number of counter limits changes in this frame (to init time) ; 0x01 1 hundredth ; 0x02 10 hundredths ; 0x03 1 second ; 0x04 10 seconds ; 0x05 1 minute ; 0x06 10 minutes ; 0x07 1 hour ; 0x08 10 hours ; 0x09 100 hours ; 4c8b random number generation (unused) ; 4c8c random number generation (unused) ; ; 4c90-4cbf scheduled tasks list (run inside IRQ) ; 16 entries, 16 bytes per entry ; Format: ; byte 0: scheduled time ; 7 6 5 4 3 2 1 0 ; | | | | | | | | ; | | ------------ number of time units to wait ; | | ; ---------------- time units ; 0x40 -> 10 hundredths ; 0x80 -> 1 second ; 0xc0 -> 10 seconds ; byte 1: index for the jump table ; byte 2: parameter for b ; ; 4cc0-4ccf tasks to execute outside of IRQ ; 0xFF fill for empty task ; 16 entries, 2 bytes per entry ; Format: ; byte 0: routine number ; byte 1: parameter ; ; Game variables ; ; 4d00 red ghost Y position (bottom to top = decreases) ; 4d01 red ghost X position (left to right = decreases) ; 4d02 pink ghost Y position (bottom to top = decreases) ; 4d03 pink ghost X position (left to right = decreases) ; 4d04 blue ghost Y position (bottom to top = decreases) ; 4d05 blue ghost X position (left to right = decreases) ; 4d06 orange ghost Y position (bottom to top = decreases) ; 4d07 orange ghost X position (left to right = decreases) ; ; 4d08 pacman Y position ; 4d09 pacman X position ; ; 4d0a red ghost Y tile pos (mid of tile) (bottom to top = decrease) ; 4d0b red ghost X tile pos (mid of tile) (left to right = decrease) ; 4d0c pink ghost Y tile pos (mid of tile) (bottom to top = decrease) ; 4d0d pink ghost X tile pos (mid of tile) (left to right = decrease) ; 4d0e blue ghost Y tile pos (mid of tile) (bottom to top = decrease) ; 4d0f blue ghost X tile pos (mid of tile) (left to right = decrease) ; 4d10 orange ghost Y tile pos (mid of tile) (bottom to top = decrease) ; 4d11 orange ghost X tile pos (mid of tile) (left to right = decrease) ; 4d12 pacman tile pos in demo and cut scenes ; 4d13 pacman tile pos in demo and cut scenes ; ; for the following, last move was ; (A) 0x00 = left/right, 0x01 = down, 0xff = up ; (B) 0x00 = up/down, 0x01 = left, 0xff = right ; 4d14 red ghost Y tile changes (A) ; 4d15 red ghost X tile changes (B) ; 4d16 pink ghost Y tile changes (A) ; 4d17 pink ghost X tile changes (B) ; 4d18 blue ghost Y tile changes (A) ; 4d19 blue ghost X tile changes (B) ; 4d1a orange ghost Y tile changes (A) ; 4d1b orange ghost X tile changes (B) ; 4d1c pacman Y tile changes (A) ; 4d1d pacman X tile changes (B) ; ; 4d1e red ghost y tile changes ; 4d1f red ghost x tile changes ; 4d20 pink ghost y tile changes ; 4d21 pink ghost x tile changes ; 4d22 blue ghost y tile changes ; 4d23 blue ghost x tile changes ; 4d24 orange ghost y tile changes ; 4d25 orange ghost x tile changes ; 4d26 wanted pacman tile changes ; 4d27 wanted pacman tile changes ; ; character orientations: ; 0 = right, 1 = down, 2 = left, 3 = up ; 4d28 previous red ghost orientation (stored middle of movement) ; 4d29 previous pink ghost orientation (stored middle of movement) ; 4d2a previous blue ghost orientation (stored middle of movement) ; 4d2b previous orange ghost orientation (stored middle of movement) ; 4d2c red ghost orientation (stored middle of movement) ; 4d2d pink ghost orientation (stored middle of movement) ; 4d2e blue ghost orientation (stored middle of movement) ; 4d2f orange ghost orientation (stored middle of movement) ; ; 4d30 pacman orientation ; ; these are updated after a move ; 4d31 red ghost Y tile position 2 (See 4d0a) ; 4d32 red ghost X tile position 2 (See 4d0b) ; 4d33 pink ghost Y tile position 2 ; 4d34 pink ghost X tile position 2 ; 4d35 blue ghost Y tile position 2 ; 4d36 blue ghost X tile position 2 ; 4d37 orange ghost Y tile position 2 ; 4d38 orange ghost X tile position 2 ; ; 4d39 pacman Y tile position (0x22..0x3e) (bottom-top = decrease) ; 4d3a pacman X tile position (0x1e..0x3d) (left-right = decrease) ; ; 4d3c wanted pacman orientation ; ; path finding algorithm: ; 4d3b best orientation found ; 4d3d saves the opposite orientation ; 4d3e-4d3f saves the current tile position ; 4d40-4d41 saves the destination tile position ; 4d42-4d43 temp resulting position ; 4d44-4d45 minimum distance^2 found ; ; 4dc7 current orientation we're trying ; 4d46-4d85 movement bit patterns (difficulty dependant) ; 4D46-4D49 movement bit patterns for pacman in normal state ; 4D4A-4D4D movement bit patterns for pacman in big pill state ; 4D4E-4D51 movement bit patterns for second difficulty flag ; 4D52-4D55 movement bit patterns for first difficulty flag ; 4D56-4D59 movement bit patterns for red ghost normal state ; 4D5A-4D5D movement bit patterns for red ghost blue state ; 4D5E-4D61 movement bit patterns for red ghost tunnel areas ; 4D62-4D65 movement bit patterns for pink ghost normal state ; 4D66-4D69 movement bit patterns for pink ghost blue state ; 4D6A-4D6D movement bit patterns for pink ghost tunnel areas ; 4D6E-4D71 movement bit patterns for blue ghost normal state ; 4D72-4D75 movement bit patterns for blue ghost blue state ; 4D76-4D79 movement bit patterns for blue ghost tunnel areas ; 4D7A-4D7D movement bit patterns for orange ghost normal state ; 4D7E-4D81 movement bit patterns for orange ghost blue state ; 4D82-4D83 movement bit patterns for orange ghost tunnel areas ; ; 4d86-4d93 ; Difficulty related table. Each entry is 2 bytes, and ; contains a counter value. when the counter at 4DC2 ; reaches each entry value, the ghosts changes their ; orientation and 4DC1 increments it's value to point to ; the next entry ; ; 4d94 counter related to ghost movement inside home ; 4d95-4d96 number of units before ghost leaves home (no change w/ pills) ; 4d97-4d98 inactivity counter for units of the above ; ; 4d99 aux var used by red ghost to check positions ; 4d9a aux var used by pink ghost to check positions ; 4d9b aux var used by blue ghost to check positions ; 4d9c aux var used by orange ghost to check positions ; ; 4d9d delay to update pacman movement ; not 0xff - the game doesn't move pacman, but decrements instead ; 0x01 when eating pill ; 0x06 when eating big pill ; 0xff when not eating a pill ; 4d9e related to number of pills eaten before last pacman move ; 4d9f eaten pills counter after pacman has died in a level ; used to make ghosts go out of home after # pills eaten ; ; ghost substates: ; 0 = at home ; 1 = going for pac-man ; 2 = crossing the door ; 3 = going to the door ; 4da0 red ghost substate (if alive) ; 4da1 pink ghost substate (if alive) ; 4da2 blue ghost substate (if alive) ; 4da3 orange ghost substate (if alive) ; 4da4 # of ghost killed but no collision for yet [0..4] ; 4da5 pacman dead animation state (0 if not dead) ; 4da6 pill effect (1=active, 0=no effect) ; ; 4da7 red ghost blue flag (0=not blue) ; 4da8 pink ghost blue flag (0=not blue) ; 4da9 blue ghost blue flag (0=not blue) ; 4daa orange ghost blue flag (0=not blue) ; ; 4dab killing ghost state ; 0 = nothing ; 1 = kill red ghost ; 2 = kill pink ghost ; 3 = kill blue ghost ; 4 = kill orange ghost ; ; ghost states: ; 0 = alive ; 1 = dead ; 2 = entering home after being killed ; 3 = go left after entering home after dead (blue) ; 3 = go right after entering home after dead (orange) ; 4dac red ghost state ; 4dad pink ghost state ; 4dae blue ghost state ; 4daf orange ghost state ; ; 4db0 related to difficulty ; ; with these, if they're set, ghosts change orientation ; 4db1 red ghost change orientation flag ; 4db2 pink ghost change orientation flag ; 4db3 blue ghost change orientation flag ; 4db4 orange ghost change orientation flag ; 4bd5 pacman change orientation flag ; ; Difficulty settings ; ; 4db6 1st difficulty flag (rel 4dbb) ; 0: red ghost sometimes goes to upper right corner ; 1: red goes for pacman ; 1 - faster ghosts, more dots ; 4db7 2nd difficulty flag (rel 4dbc) ; when set, red uses another bit movement pattern ; 0: random ghost movement, 1: normal movement (?) ; 4db8 pink ghost counter to go out of home limit (rel 4e0f) ; 4db9 blue ghost counter to go out of home limit (rel 4e10) ; 4dba orange ghost counter to go out of home limit (rel 4e11) ; 4dbb remainder of pills when first diff. flag is set ; 4dbc remainder of pills when second diff. flag is set ; 4dbd-4dbe Time the ghosts stay blue when pacman eats a big pill ; ; 4dbf 1=pacman about to enter a tunnel, otherwise 0 ; ; Counters ; ; 4dc0 changes every 8 frames; used for ghost animations ; 4dc1 orientation changes index [0..7]. used to get value 4d86-4d93 ; 0: random ghost movement, 1: normal movement (?) ; 4dc2-4dc3 counter related to ghost orientation changes ; 4dc4 counter 0..8 to handle things once every 8 times ; 4dc5-4dc6 counter started after pacman killed ; 4dc8 counter used to change ghost colors under big pill effects ; ; 4dc9-4dca pointer to pick a random value from the ROM (routine 2a23) ; ; 4dcb-4dcc counter while ghosts are blue. effect ceases at 0 ; 4dce counter started after insert coin (LED and 1UP/2UP blink) ; 4dcf counter to handle pill changes ; 4dd0 current number of killed ghosts (0..4) (rel 4da5) ; ; 4dd1 killed ghost animation state ; if 4da4 != 0: ; 4dd1 = 0: killed, showing points per kill ; 4dd1 = 1: wating ; 4dd1 = 2: clearing killed ghost, changing state to 0 ; 4dd2-4dd3 fruit position (sometimes for other sprite) ; ; 4dd4 entry to fruit points or 0 if no fruit ; 4dd6 used for LED state( 1: game waits for 1P/2P start button press) ; ; Main States ; ; 4ee0 main routine number ; 0: init ; 1: demo ; 2: coin inserted ; 3: playing ; 4e01 main routine 0, subroutine # ; 4e02 main routine 1, subroutine # (causes blue maze bug) ; 4e03 main routine 2, subroutine # ; 4e04 level state subroutine # ; 3=ghost move, 2=ghost wait for start ; (set to 2 to pause game) ; ; 4e06 state in first cutscene ; 4e07 state in second cutscene ; 4e08 state in third cutscene ; ; 4e09 current player number: 0=P1, 1=P2 ; ; 4e0a-4e0b pointer to current difficulty settings ; ; 4e0c first fruit flag (1 if fruit has appeared) ; 4e0d second fruit flag (1 if fruit has appeared) ; 4e0e number of pills eaten in this level ; 4e0f counter incremented if orange, blue and pink ghosts are home ; and pacman is eating pills. ; used to make pink ghost leave home (rel 4db8) ; 4e10 counter incremented if orange, blue and pink ghosts are home ; and pacman is eating pills. ; used to make blue ghost leave home (rel 4db9) ; 4e11 counter incremented if orange, blue and pink ghosts are home ; and pacman is eating pills. ; used to make orange ghost leave home (rel 4db9) ; 4e12 1 after dying in a level, reset to 0 if ghosts have left home ; because of 4d9f ; ; 4e13 current level ; 4e14 real number of lives ; 4e15 number of lives displayed ; ; 4e16-4e33 0x13 pill data entries. each bit means if a pill is there ; or not (1=yes 0=no) ; the pills start at upper right corner, go down, then left. ; first pill is bit 7 of 4e16 ; 4e34-4e37 big pills data entries ; 4e38-4e65 copy of level data (430a-4e37) ; ; coins, credits ; ; 4e66 last 4 SERVICE1 to detect transitions ; 4e67 last 4 COIN2 to detect transitions ; 4e68 last 4 COIN1 to detect transitions ; ; 4e69 coin counter (coin->credts, this gets decremented) ; 4e6a coin counter timeout, used to write coin counters ; ; these are copied from the dipswitches ; 4e6b number of coins per credit ; 4e6c number of coins inserted ; 4e6d number of credits per coin ; 4e6e number of credits, 0xff for free play ; 4e6f number of lives ; 4e70 number of players (0=1 player, 1=2 players) ; 4e71 bonus/life ; 0x10 = 10000 0x15 = 15000 ; 0x20 = 20000 0xff = none ; 4e72 cocktail mode (0=no, 1=yes) ; 4e73-4e74 pointer to difficulty settings ; 4e73: 68=normal 7d=hard checked at start of game ; 4e75 ghost names mode (0 or 1) ; ; SCORE AABBCC ; 4e80-4e82 score P1 80=CC 81=BB 82=CC ; 4e83 P1 got bonus life? 1=yes ; 4e84-4e86 score P1 84=CC 85=BB 86=CC ; 4e87 P1 got bonus life? 1=yes ; 4e88-4e8a high score 88=CC 89=BB 8A=CC ; ; Sound Registers ;; these 16 values are copied to the hardware every vblank interrupt. CH1_FREQ0 EQU 4e8c ; 20 bits CH1_FREQ1 EQU 4e8d CH1_FREQ2 EQU 4e8e CH1_FREQ3 EQU 4e8f CH1_FREQ4 EQU 4e90 CH1_VOL EQU 4e91 CH2_FREQ1 EQU 4e92 ; 16 bits CH2_FREQ2 EQU 4e93 CH2_FREQ3 EQU 4e94 CH2_FREQ4 EQU 4e95 CH2_VOL EQU 4e96 CH3_FREQ1 EQU 4e97 ; 16 bits CH3_FREQ2 EQU 4e98 CH3_FREQ3 EQU 4e99 CH3_FREQ4 EQU 4e9a CH3_VOL EQU 4e9b SOUND_COUNTER EQU 4c84 ; counter, incremented each VBLANK ; (used to adjust sound volume) EFFECT_TABLE_1 EQU 3b30 ; channel 1 effects. 8 bytes per effect EFFECT_TABLE_2 EQU 3b40 ; channel 2 effects. 8 bytes per effect EFFECT_TABLE_3 EQU 3b80 ; channel 3 effects. 8 bytes per effect #if MSPACMAN SONG_TABLE_1 EQU 9685 ; channel 1 song table SONG_TABLE_2 EQU 967d ; channel 2 song table SONG_TABLE_3 EQU 968d ; channel 3 song table #else SONG_TABLE_1 EQU 3bc8 SONG_TABLE_2 EQU 3bcc SONG_TABLE_3 EQU 3bd0 #endif CH1_E_NUM EQU 4e9c ; effects to play sequentially (bitmask) CH1_E_1 EQU 4e9d ; unused CH1_E_CUR_BIT EQU 4e9e ; current effect CH1_E_TABLE0 EQU 4e9f ; table of parameters, initially copied from ROM CH1_E_TABLE1 EQU 4ea0 CH1_E_TABLE2 EQU 4ea1 CH1_E_TABLE3 EQU 4ea2 CH1_E_TABLE4 EQU 4ea3 CH1_E_TABLE5 EQU 4ea4 CH1_E_TABLE6 EQU 4ea5 CH1_E_TABLE7 EQU 4ea6 CH1_E_TYPE EQU 4ea7 CH1_E_DURATION EQU 4ea8 CH1_E_DIR EQU 4ea9 CH1_E_BASE_FREQ EQU 4eaa CH1_E_VOL EQU 4eab ; 4EAC repeats the above for channel 2 ; 4EBC repeats the above for channel 3 CH1_W_NUM EQU 4ecc ; wave to play (bitmask) CH1_W_1 EQU 4ecd ; unused CH1_W_CUR_BIT EQU 4ece ; current wave CH1_W_SEL EQU 4ecf CH1_W_4 EQU 4ed0 CH1_W_5 EQU 4ed1 CH1_W_OFFSET1 EQU 4ed2 ; address in ROM to find the next byte CH1_W_OFFSET2 EQU 4ed3 ; (16 bits) CH1_W_8 EQU 4ed4 CH1_W_9 EQU 4ed5 CH1_W_A EQU 4ed6 CH1_W_TYPE EQU 4ed7 CH1_W_DURATION EQU 4ed8 CH1_W_DIR EQU 4ed9 CH1_W_BASE_FREQ EQU 4eda CH1_W_VOL EQU 4edb ; 4EDC repeats the above for channel 2 ; 4EEC repeats the above for channel 3 ; Runtime ; ; 4F00-4FBF Stack ; 4FC0-4FEF Unused ; 4FF0-4FFF Sprite RAM ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; PACMAN SPRITE CODES ; ; 00-07 fruits ; 08-0D naked ghosts for cutscenes ; 0E-0F empty ; 10-1B big pacman ; 1C-1D ghost in panic mode ; 1E-1F empty ; 20-27 ghosts ; 28-2B points ; 2C-2F pacmans ; 30 big pacman ; 31 explosion ; 32-33 broken ghost ; 34-3F pacman dead ; ; PACMAN TILE CODES ; ; 00-0F hex digits ; 10-15 pills ; 16-1F empty ; ... ; 40-5B space + ASCII chars ; 5C copyright ; 5D-5F PTS ; ... ; C0-FF map obstacles ; ; SPECIAL COLOR ENTRIES ; ; 18 for ghost's door ; 1A for pacman's and ghost's initial map positions ; 1B for tunnel area ; ; PACMAN TILE CONFIGURATION ; ; tile position x can go from 0x1e to 0x3d. ; 0x1d == wraparound -> 0x3d ; 0x3e == wraparound -> 0x1e ; tile position y can go from 0x22 to 0x3e. ; Why? ; Because of the graphics hardware. ; With that configuration, you can convert directly between ; tile position to hardware sprite positions ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; rst 0 - initialization ;; init 0000 f3 di ; Disable interrupts 0001 3e00 ld a,#00 ; 0 -> a 0003 ed47 ld i,a ; Clear interrupt status register 0005 c30b23 jp #230b ; startup test ;; PAC ;0001 3e3f ld a,#3f ;; rst 8 - memset() ;; Fill "hl" to "hl+b" with "a" 0008 77 ld (hl),a 0009 23 inc hl 000a 10fc djnz #0008 ; (-4) 000c c9 ret 000d c30e07 jp #070e ; junk ;; rst 10 (for dereferencing pointers to bytes) ;; hl = hl + a, (hl) -> a ; HL = base address of table ; A = index ; after the call, A gets the data in HL+A 0010 85 add a,l 0011 6f ld l,a 0012 3e00 ld a,#00 0014 8c adc a,h 0015 67 ld h,a 0016 7e ld a,(hl) 0017 c9 ret ;; rst 18 (for dereferencing pointers to words) ;; hl = hl + 2*b, (hl) -> e, (++hl) -> d, de -> hl ; HL = base address of table ; B = index ; after the call, DE gets the data in HL+(2*B) ; modified: DE, A 0018 78 ld a,b 0019 87 add a,a 001a d7 rst #10 001b 5f ld e,a ; E = (HL+2B) 001c 23 inc hl 001d 56 ld d,(hl) ; D = (HL+2B+1) 001e eb ex de,hl ; HL = (HL+2B) 001f c9 ret ;; rst 20 (jump table) ;; ;; jump to (HL+2*A) 0020 pop hl ; get HL from stack 0021 add a,a 0022 rst #10 ; HL += 2A A = (HL) 0023 ld e,a ; E = A = (HL) 0024 inc hl ; 0025 ld d,(hl) ; D = (HL+1) so DE = 16-bits at HL+2A 0026 ex de,hl ; DE <-> HL 0027 jp (hl) ; goto HL ;; rst 28 ; this is completely baffling me 0028 e1 pop hl ; next byte after call 0029 46 ld b,(hl) 002a 23 inc hl 002b 4e ld c,(hl) 002c 23 inc hl ; bc gets the word after the call 002d e5 push hl ; adjust return value 002e 1812 jr #0042 ; (18) ;; rst 30 0030 11904c ld de,#4c90 0033 0610 ld b,#10 0035 c35100 jp #0051 ;; rst 38 (vblank) ;; INTERRUPT MODE 1 handler 0038 c39b1f jp #1f9b ;; patched jump from pacman. 003b ----50 ;; junk 003c 320750 ld (#5007),a ;; junk 003f c33800 jp #0038 ;; junk ;; INTERRUPT MODE 2 (original hardware, non-bootlegs, puckman, pac plus) ;0038 af xor a ;0039 320050 ld (#5000),a ;003c 320750 ld (#5007),a ;003f c33800 jp #0038 ;; continuation of rst 28 ; bc has the word after the call (above) 0042 2a804c ld hl,(#4c80) ; hl = (4c80) 0045 70 ld (hl),b 0046 2c inc l 0047 71 ld (hl),c 0048 2c inc l ; ((4c80), (4c81)) = bc 0049 2002 jr nz,#004d 004b 2ec0 ld l,#c0 ; if( c==00 ) l = c0 (spins c0-ff) 004d 22804c ld (#4c80),hl ; (4c80, 4c81) = hl 0050 c9 ret ;; rst 30 continuation 0051 1a ld a,(de) 0052 a7 and a 0053 2806 jr z,#005b ; (6) 0055 1c inc e 0056 1c inc e 0057 1c inc e 0058 10f7 djnz #0051 ; (-9) 005a c9 ret 005b e1 pop hl 005c 0603 ld b,#03 005e 7e ld a,(hl) 005f 12 ld (de),a 0060 23 inc hl 0061 1c inc e 0062 10fa djnz #005e ; (-6) 0064 e9 jp (hl) ;; this is a common call 0065 c32d20 jp #202d ;; difficulty settings - normal 0068 offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 00000060 00 01 02 03 04 05 06 07 00000070 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 ;; difficulty settings - hard 007d offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 00000070 01 03 04 00000080 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 14 ;; part of the interrupt routine (non-test) ;; continuation of RST 38 partially... (vblank) ;; (gets called from the 1f9b patch, from 0038) 008d f5 push af 008e 32c050 ld (#50c0),a ; kick the dog 0091 af xor a ; 0 -> a 0092 320050 ld (#5000),a ; disable hardware interrupts 0095 f3 di ; disable cpu interrupts 0096 c5 push bc 0097 d5 push de 0098 e5 push hl 0099 dde5 push ix 009b fde5 push iy ;; ;; VBLANK - 1 (SOUND) ;; ;; load the sound into the hardware ;; 009d ld hl,#CH1_FREQ0 ; pointer to frequencies and volumes of the 3 voices 00a0 ld de,#5050 ; hardware address 00a3 ld bc,#0010 ; 16 bytes 00a6 ldir ; copy ! ;; voice 1 wave select 00a8 ld a,(#CH1_W_NUM) ; if we play a wave 00ab and a 00ac ld a,(#CH1_W_SEL) ; then WaveSelect = CH1_W_SEL 00af jr nz,#00b4 00b1 ld a,(#CH1_E_TABLE0) ; else WaveSelect = CH1_E_TABLE0 00b4 ld (#5045),a ; write WaveSelect to hardware ;; voice 2 wave select 00b7 ld a,(#CH2_W_NUM) 00ba and a 00bb ld a,(#CH2_W_SEL) 00be jr nz,#00c3 00c0 ld a,(#CH2_E_TABLE0) 00c3 ld (#504a),a ;; voice 3 wave select 00c6 ld a,(#CH3_W_NUM) 00c9 and a 00ca ld a,(#CH3_W_SEL) 00cd jr nz,#00d2 00cf ld a,(#CH3_E_TABLE0) 00d2 ld (#504f),a ; copy last frame calculated sprite data into sprite buffer 00d5 21024c ld hl,#4c02 00d8 11224c ld de,#4c22 00db 011c00 ld bc,#001c 00de edb0 ldir ; update sprite data, adjusting to hardware 00e0 dd21204c ld ix,#4c20 00e4 dd7e02 ld a,(ix+#02) ; move up for flip hardware 00e7 07 rlca 00e8 07 rlca 00e9 dd7702 ld (ix+#02),a 00ec dd7e04 ld a,(ix+#04) ; move sprite number 2 bits up 00ef 07 rlca 00f0 07 rlca 00f1 dd7704 ld (ix+#04),a 00f4 dd7e06 ld a,(ix+#06) ; move sprite number 2 bits up 00f7 07 rlca 00f8 07 rlca 00f9 dd7706 ld (ix+#06),a 00fc dd7e08 ld a,(ix+#08) ; move sprite number 2 bits up 00ff 07 rlca 0100 07 rlca 0101 dd7708 ld (ix+#08),a 0104 dd7e0a ld a,(ix+#0a) ; move sprite number 2 bits up 0107 07 rlca 0108 07 rlca 0109 dd770a ld (ix+#0a),a 010c dd7e0c ld a,(ix+#0c) ; move sprite number 2 bits up 010f 07 rlca 0110 07 rlca 0111 dd770c ld (ix+#0c),a 0114 3ad14d ld a,(#4dd1) ; ghost being killed? 0117 fe01 cp #01 0119 2038 jr nz,#0153 ; (56) 011b dd21204c ld ix,#4c20 ; IX is sprite data 011f 3aa44d ld a,(#4da4) ; gets the unhandled killed character 0122 87 add a,a 0123 5f ld e,a 0124 1600 ld d,#00 0126 dd19 add ix,de 0128 2a244c ld hl,(#4c24) ; swap sprite with 4c24/4c25 012b ed5b344c ld de,(#4c34) ; make it first displayed 012f dd7e00 ld a,(ix+#00) 0132 32244c ld (#4c24),a 0135 dd7e01 ld a,(ix+#01) 0138 32254c ld (#4c25),a 013b dd7e10 ld a,(ix+#10) 013e 32344c ld (#4c34),a 0141 dd7e11 ld a,(ix+#11) 0144 32354c ld (#4c35),a 0147 dd7500 ld (ix+#00),l 014a dd7401 ld (ix+#01),h 014d dd7310 ld (ix+#10),e 0150 dd7211 ld (ix+#11),d 0153 3aa64d ld a,(#4da6) ; skip if no big pill yet 0156 a7 and a 0157 ca7601 jp z,#0176 ; swap pac for first ghost 015a ed4b224c ld bc,(#4c22) ; highest priority sprite 015e ed5b324c ld de,(#4c32) 0162 2a2a4c ld hl,(#4c2a) 0165 22224c ld (#4c22),hl 0168 2a3a4c ld hl,(#4c3a) ; swap with first ghost 016b 22324c ld (#4c32),hl 016e ed432a4c ld (#4c2a),bc 0172 ed533a4c ld (#4c3a),de 0176 21224c ld hl,#4c22 ; copy data 0179 11f24f ld de,#4ff2 ; copy sprite pos to spriteram2 017c 010c00 ld bc,#000c 017f edb0 ldir 0181 21324c ld hl,#4c32 ; write updated sprite to spriteram 0184 116250 ld de,#5062 0187 010c00 ld bc,#000c 018a edb0 ldir ; core game loop 018c cddc01 call #01dc ; controls the game play - ; stops on game screen when disabled 018f cd2102 call #0221 ; controls the moving sprites 0192 cdc803 call #03c8 ; enable sound out and other stuff - ; blank screen if disabled 0195 3a004e ld a,(#4e00) ; check game mode 0198 a7 and a ; set flags 0199 2812 jr z,#01ad ; skip over next calls if no players 019b cd9d03 call #039d ; displays "READY!" ; pauses between plrs and men or levels 019e cd9014 call #1490 ; display sprites in intro and game 01a1 cd1f14 call #141f ; ? 01a4 cd6702 call #0267 ; debounce rack input / add credits 01a7 cdad02 call #02ad ; debounce coin input / add credits 01aa cdfd02 call #02fd ; blink coin lights ; print player 1 and player two ; check for game mode 3 ; draw cprt stuff 01ad 3a004e ld a,(#4e00) ; nplayers 01b0 3d dec a 01b1 2006 jr nz,#01b9 ; skip if intro mode 01b3 32ac4e ld (#4eac),a 01b6 32bc4e ld (#4ebc),a ;; ;; VBLANK - 2 (SOUND) ;; ;; Process sound 01b9 call #2d0c ; process effects 01bc call #2cc1 ; process waves 01bf fde1 pop iy 01c1 dde1 pop ix 01c3 e1 pop hl 01c4 d1 pop de 01c5 c1 pop bc 01c6 3a004e ld a,(#4e00) ; check players 01c9 a7 and a ; set flags 01ca 2808 jr z,#01d4 ; (8) 01cc 3a4050 ld a,(#5040) ; IN1 01cf e610 and #10 ; rack TEST ; elimiate test mode ; HACK7 ;01d1 00 nop ;01d2 00 nop ;01d3 00 nop 01d1 ca0000 jp z,#0000 ; reset if TEST is set 01d4 3e01 ld a,#01 ; a=1 01d6 320050 ld (#5000),a ; reenable hardware interrupts 01d9 fb ei ; enable cpu interrupts 01da f1 pop af 01db c9 ret ; end ;; controls the game play ; (stops on game screen when disabled) 01dc 21844c ld hl,#4c84 01df 34 inc (hl) 01e0 23 inc hl 01e1 35 dec (hl) 01e2 23 inc hl 01e3 111902 ld de,#0219 01e6 010104 ld bc,#0401 01e9 34 inc (hl) 01ea 7e ld a,(hl) 01eb e60f and #0f 01ed eb ex de,hl 01ee be cp (hl) 01ef 2013 jr nz,#0204 ; (19) 01f1 0c inc c 01f2 1a ld a,(de) 01f3 c610 add a,#10 01f5 e6f0 and #f0 01f7 12 ld (de),a 01f8 23 inc hl 01f9 be cp (hl) 01fa 2008 jr nz,#0204 ; (8) 01fc 0c inc c 01fd eb ex de,hl 01fe 3600 ld (hl),#00 0200 23 inc hl 0201 13 inc de 0202 10e5 djnz #01e9 ; (-27) 0204 218a4c ld hl,#4c8a 0207 71 ld (hl),c 0208 2c inc l 0209 7e ld a,(hl) 020a 87 add a,a 020b 87 add a,a 020c 86 add a,(hl) 020d 3c inc a 020e 77 ld (hl),a 020f 2c inc l 0210 7e ld a,(hl) 0211 87 add a,a 0212 86 add a,(hl) 0213 87 add a,a 0214 87 add a,a 0215 86 add a,(hl) 0216 3c inc a 0217 77 ld (hl),a 0218 c9 ret 0219 06a0 ld b,#a0 021b 0a ld a,(bc) 021c 60 ld h,b 021d 0a ld a,(bc) 021e 60 ld h,b 021f 0a ld a,(bc) 0220 a0 and b ;; controls the moving sprites ;; PAC ------- 0221 21904c ld hl,#4c90 0224 3a8a4c ld a,(#4c8a) 0227 4f ld c,a 0228 0610 ld b,#10 022a 7e ld a,(hl) 022b a7 and a 022c 282f jr z,#025d ; (47) 022e e6c0 and #c0 0230 07 rlca 0231 07 rlca 0232 b9 cp c 0233 3028 jr nc,#025d ; (40) 0235 35 dec (hl) 0236 7e ld a,(hl) 0237 e63f and #3f 0239 2022 jr nz,#025d ; (34) 023b 77 ld (hl),a 023c c5 push bc 023d e5 push hl 023e 2c inc l 023f 7e ld a,(hl) 0240 2c inc l 0241 46 ld b,(hl) 0242 215b02 ld hl,#025b 0245 e5 push hl 0246 e7 rst #20 0247 94 sub h 0248 08 ex af,af' 0249 a3 and e 024a 068e ld b,#8e 024c 05 dec b 024d 72 ld (hl),d 024e 12 ld (de),a 024f 00 nop 0250 100b djnz #025d ; (11) 0252 1063 djnz #02b7 ; (99) 0254 02 ld (bc),a 0255 2b dec hl 0256 21f021 ld hl,#21f0 0259 b9 cp c 025a 22e1c1 ld (#c1e1),hl 025d 2c inc l 025e 2c inc l 025f 2c inc l 0260 10c8 djnz #022a ; (-56) 0262 c9 ret ; clear ready message 0263 ef rst #28 ; add new current taks 1c 86 0264 1c86 0266 c9 ret ;; debounce rack input / add credits (if 99 or over, return) 0267 3a6e4e ld a,(#4e6e) ; number of current credits 026a fe99 cp #99 ; max coins 026c 17 rla ; then lockout 026d 320650 ld (#5006),a ; coin lockout 0270 1f rra 0271 d0 ret nc ; return if 99 credits 0272 3a0050 ld a,(#5000) ; check IN0 input 0275 47 ld b,a ; b=a 0276 cb00 rlc b ; rotate left 0278 3a664e ld a,(#4e66) ; ? 027b 17 rla ; rotate left with carry 027c e60f and #0f ; and it with 0f 027e 32664e ld (#4e66),a ; put it back 0281 d60c sub #0c ; a=a-$C 0283 ccdf02 call z,#02df ; call $2df if a==0 ; add coin 0286 cb00 rlc b 0288 3a674e ld a,(#4e67) 028b 17 rla 028c e60f and #0f 028e 32674e ld (#4e67),a 0291 d60c sub #0c 0293 c29a02 jp nz,#029a 0296 21694e ld hl,#4e69 ; increment credits 0299 34 inc (hl) 029a cb00 rlc b 029c 3a684e ld a,(#4e68) 029f 17 rla 02a0 e60f and #0f 02a2 32684e ld (#4e68),a 02a5 d60c sub #0c 02a7 c0 ret nz 02a8 21694e ld hl,#4e69 02ab 34 inc (hl) 02ac c9 ret ;; debounce coin input / add credits 02ad 3a694e ld a,(#4e69) ; increment credits 02b0 a7 and a 02b1 c8 ret z ; if it's zero, return 02b2 47 ld b,a 02b3 3a6a4e ld a,(#4e6a) ; 02b6 5f ld e,a 02b7 fe00 cp #00 02b9 c2c402 jp nz,#02c4 02bc 3e01 ld a,#01 02be 320750 ld (#5007),a 02c1 cddf02 call #02df 02c4 7b ld a,e 02c5 fe08 cp #08 02c7 c2ce02 jp nz,#02ce 02ca af xor a 02cb 320750 ld (#5007),a ; coin counter 02ce 1c inc e 02cf 7b ld a,e 02d0 326a4e ld (#4e6a),a ; credit memory = a 02d3 d610 sub #10 02d5 c0 ret nz 02d6 326a4e ld (#4e6a),a 02d9 05 dec b 02da 78 ld a,b 02db 32694e ld (#4e69),a 02de c9 ret ;; coins -> credits routine 02df 3a6b4e ld a,(#4e6b) ; #coins per #credits 02e2 216c4e ld hl,#4e6c ; leftover coins 02e5 34 inc (hl) ; add 1 02e6 96 sub (hl) 02e7 c0 ret nz ; not enough coins for credits 02e8 77 ld (hl),a ; store leftover coins 02e9 3a6d4e ld a,(#4e6d) ; #credits per #coins 02ec 216e4e ld hl,#4e6e ; #credits 02ef 86 add a,(hl) ; add # credits 02f0 27 daa 02f1 d2f602 jp nc,#02f6 02f4 3e99 ld a,#99 02f6 77 ld (hl),a ; store #credits, max 99 02f7 219c4e ld hl,#4e9c 02fa cbce set 1,(hl) ; set bit 1 of 4e9c (play a sound) 02fc c9 ret ;; blink coin lights, print player 1 and player 2, check for mode 3 02fd 21ce4d ld hl,#4dce 0300 34 inc (hl) ; increment whats in $4dce 0301 7e ld a,(hl) ; a = alue in 4cf 0302 e60f and #0f ; and with $0f 0304 201f jr nz,#0325 ; (31) if not 0, jump 0306 7e ld a,(hl) ; shift right 0307 0f rrca 0308 0f rrca 0309 0f rrca 030a 0f rrca 030b 47 ld b,a ; b=a ;; blink coin lights to pellets ; HACK11 ;030c 3aa74d ld a,(#4da7) ;030f 4f ld c,a ;0310 180b jr #0317 030c 3ad64d ld a,(#4dd6) 030f 2f cpl ; compliment 0310 b0 or b ; or b 0311 4f ld c,a ; c=a 0312 3a6e4e ld a,(#4e6e) ; a = number of credits 0315 d601 sub #01 ; subtract one from it. 0317 3002 jr nc,#031b ; (2) if carry not 0 then jump 0319 af xor a 031a 4f ld c,a 031b 2801 jr z,#031e ; (1) 031d 79 ld a,c 031e 320550 ld (#5005),a ; player 2 start lamp 0321 79 ld a,c 0322 320450 ld (#5004),a ; player 1 start lamp 0325 dd21d843 ld ix,#43d8 0329 fd21c543 ld iy,#43c5 ;; determine 1p or 2p 032d 3a004e ld a,(#4e00) ; game mode? 0330 fe03 cp #03 0332 ca4403 jp z,#0344 ; Jump if 1 or 2 players 0335 3a034e ld a,(#4e03) 0338 fe02 cp #02 033a d24403 jp nc,#0344 033d cd6903 call #0369 ; draw "1UP" 0340 cd7603 call #0376 ; draw "1UP" 0343 c9 ret ;; display and blink 1UP/2UP depending on player up 0344 3a094e ld a,(#4e09) 0347 a7 and a 0348 3ace4d ld a,(#4dce) 034b c25903 jp nz,#0359 034e cb67 bit 4,a 0350 cc6903 call z,#0369 ; draw "1UP" 0353 c48303 call nz,#0383 ; clear "1UP" 0356 c36103 jp #0361 0359 cb67 bit 4,a 035b cc7603 call z,#0376 ; draw "1UP" 035e c49003 call nz,#0390 ; clear "2UP" 0361 3a704e ld a,(#4e70) ; players 0=1 1=2 0364 a7 and a 0365 cc9003 call z,#0390 ; clear "2UP" 0368 c9 ret ; draw "1UP" 0369 dd360050 ld (ix+#00),#50 ; 'P' 036d dd360155 ld (ix+#01),#55 ; 'U' 0371 dd360231 ld (ix+#02),#31 ; '1' 0375 c9 ret ; draw "2UP" 0376 fd360050 ld (iy+#00),#50 ; 'P' 037a fd360155 ld (iy+#01),#55 ; 'U' 037e fd360232 ld (iy+#02),#32 ; '2' 0382 c9 ret ; clear "1UP" 0383 dd360040 ld (ix+#00),#40 ; ' ' 0387 dd360140 ld (ix+#01),#40 ; ' ' 038b dd360240 ld (ix+#02),#40 ; ' ' 038f c9 ret ; clear "2UP" 0390 fd360040 ld (iy+#00),#40 ; ' ' 0394 fd360140 ld (iy+#01),#40 ; ' ' 0398 fd360240 ld (iy+#02),#40 ; ' ' 039c c9 ret ;draws big pacman in intermission 039d 3a064e ld a,(#4e06) ; if 4e06 is <5, normal pac 03a0 d605 sub #05 03a2 d8 ret c ; draw big pac 03a3 2a084d ld hl,(#4d08) 03a6 0608 ld b,#08 03a8 0e10 ld c,#10 03aa 7d ld a,l 03ab 32064d ld (#4d06),a 03ae 32d24d ld (#4dd2),a 03b1 91 sub c 03b2 32024d ld (#4d02),a 03b5 32044d ld (#4d04),a 03b8 7c ld a,h 03b9 80 add a,b 03ba 32034d ld (#4d03),a 03bd 32074d ld (#4d07),a 03c0 91 sub c 03c1 32054d ld (#4d05),a 03c4 32d34d ld (#4dd3),a 03c7 c9 ret ;; enable sound out and other stuff 03c8 3a004e ld a,(#4e00) ; game mode 03cb e7 rst #20 ; stack = program counter @ rst 20 03cc d403 ;$03D4 ;$4E00 = 0 03ce fe03 ;$03FE ;$4E00 = 1 ;ALL ATTRACT MODES 03d0 e505 ;$05E5 ;$4E00 = 2 ;PLAYER 1 OR 2 SCRN 03d2 be06 ;$06BE ;$4E00 = 3 ;PLAYER 1OR2PLAYING 03d4 3a014e ld a,(#4e01) 03d5 e7 rst #20 03d8 dc030c call c,#0c03 03db 00 nop 03dc ef rst #28 03dd 0000 03df ef rst #28 03e0 0600 ;; this seems to execute oddly. 03e2 ef rst #28 03e3 0100 03e5 ef rst #28 03e6 1400 03e8 ef rst #28 03e9 1800 03eb ef rst #28 03ec 0400 03ee ef rst #28 03ef 1e00 03f1 ef rst #28 03f2 0700 03f4 21014e ld hl,#4e01 03f7 34 inc (hl) 03f8 210150 ld hl,#5001 ; enable sound 03fb 3601 ld (hl),#01 ; output 03fd c9 ret ; demo mode 03fe cda12b call #2ba1 ; write #credits on screen 0401 3a6e4e ld a,(#4e6e) ; get credits 0404 a7 and a ; set flags 0405 280c jr z,#0413 ; no credits -> 0x13 0407 af xor a 0408 32044e ld (#4e04),a ; level complete register 040b 32024e ld (#4e02),a 040e 21004e ld hl,#4e00 0411 34 inc (hl) ; start game mode 0412 c9 ret ; table lookup (mspac patch) 0413 c35c3e jp #3e5c ; no credits? 0416 e7 rst #20 ;; PAC ;0413 3a024e ld a,(#4e02) ; another address table of based off of 4e02 ; task routine to draw out the attract screen 0417 5f04 ;$045F ;($4e02)=0 0419 0c00 ;$000C ;($4e02)=1 RETURN 041b 7104 ;$0471 ;($4e02)=2 041d 0c00 ;$000C ;($4e02)=3 RETURN 041f 7f04 ;$047F ;($4e02)=4 0421 0C00 ;$000C ;($4e02)=5 RETURN 0423 8504 ;$0485 ;($4e02)=6 0425 0c00 ;$000C ;($4e02)=7 RETURN 0427 8b04 ;$048B ;($4e02)=8 0429 0c00 ;$000C ;($4e02)=9 RETURN 042b 9904 ;$0499 ;($4e02)=$0A 042d 0c00 ;$000C ;($4e02)=$0B RETURN 042f 9f04 ;$049F ;($4e02)=$0C 0431 0c00 ;$000C ;($4e02)=$0D RETURN 0433 a504 ;$04A5 ;($4e02)=$0E 0435 0c00 ;$000C ;($4e02)=$0F RETURN 0437 b304 ;$04B3 ;($4E02)=$10 0438 04 inc b 0439 0c inc c 043a 00 nop 043b b9 cp c 043c 04 inc b 043d 0c inc c 043e 00 nop 043f bf cp a 0440 04 inc b 0441 0c inc c 0442 00 nop 0443 cd040c call #0c04 0446 00 nop 0447 d304 out (#04),a 0449 0c inc c 044a 00 nop 044b d8 ret c 044c 04 inc b 044d 0c inc c 044e 00 nop 044f e0 ret po 0450 04 inc b 0451 0c inc c 0452 00 nop 0453 1c inc e 0454 05 dec b 0455 4b ld c,e 0456 05 dec b 0457 56 ld d,(hl) 0458 05 dec b 0459 61 ld h,c 045a 05 dec b 045b 6c ld l,h 045c 05 dec b 045d 7c ld a,h 045e 05 dec b ; code resumes here 045f ef rst #28 0460 0001 0462 ef rst #28 0464 0100 0465 ef rst #28 0466 0400 0468 ef rst #28 0469 1e00 046b 0e0c ld c,#0c 046d cd8505 call #0585 0470 c9 ret 0471 210443 ld hl,#4304 0474 3e01 ld a,#01 0476 cdbf05 call #05bf 0479 0e0c ld c,#0c 047b cd8505 call #0585 047e c9 ret 047f 0e14 ld c,#14 0481 cd9305 call #0593 0484 c9 ret 0485 0e0d ld c,#0d 0487 cd9305 call #0593 048a c9 ret 048b 210743 ld hl,#4307 048e 3e03 ld a,#03 0490 cdbf05 call #05bf 0493 0e0c ld c,#0c 0495 cd8505 call #0585 0498 c9 ret 0499 0e16 ld c,#16 049b cd9305 call #0593 049e c9 ret 049f 0e0f ld c,#0f 04a1 cd9305 call #0593 04a4 c9 ret 04a5 210a43 ld hl,#430a 04a8 3e05 ld a,#05 04aa cdbf05 call #05bf 04ad 0e0c ld c,#0c 04af cd8505 call #0585 04b2 c9 ret 04b3 0e33 ld c,#33 04b5 cd9305 call #0593 04b8 c9 ret 04b9 0e2f ld c,#2f 04bb cd9305 call #0593 04be c9 ret 04bf 210d43 ld hl,#430d 04c2 3e07 ld a,#07 04c4 cdbf05 call #05bf 04c7 0e0c ld c,#0c 04c9 cd8505 call #0585 04cc c9 ret 04cd 0e35 ld c,#35 04cf cd9305 call #0593 04d2 c9 ret 04d3 0e31 ld c,#31 04d5 c38005 jp #0580 04d8 ef rst #28 04d9 1c11 04da 0e12 ld c,#12 04dd c38505 jp #0585 04e0 0e13 ld c,#13 04e2 cd8505 call #0585 04e5 cd7908 call #0879 04e8 35 dec (hl) 04e9 ef rst #28 04ea 1100 04ec ef rst #28 04ed 05 dec b 04ee 01ef10 ld bc,#10ef 04f1 14 inc d 04f2 ef rst #28 04f3 0401 04f4 3e01 ld a,#01 04f7 32144e ld (#4e14),a ; number of lives left 04fa af xor a 04fb 32704e ld (#4e70),a ; number of players 0=1 1=2 04fe 32154e ld (#4e15),a ; number of lives displayed 0501 213243 ld hl,#4332 0504 3614 ld (hl),#14 0506 3efc ld a,#fc 0508 112000 ld de,#0020 050b 061c ld b,#1c 050d dd214040 ld ix,#4040 0511 dd7711 ld (ix+#11),a 0514 dd7713 ld (ix+#13),a 0517 dd19 add ix,de 0519 10f6 djnz #0511 ; (-10) 051b c9 ret ; check for moving through a tunnel? 051c 21a04d ld hl,#4da0 051f 0621 ld b,#21 0521 3a3a4d ld a,(#4d3a) 0524 90 sub b ; pac going through a tunnel? 0525 2005 jr nz,#052c ; (5) 0527 3601 ld (hl),#01 0529 c38e05 jp #058e ; another core game loop? 052c cd1710 call #1017 052f cd1710 call #1017 0532 cd230e call #0e23 0535 cd0d0c call #0c0d 0538 cdd60b call #0bd6 053b cda505 call #05a5 053e cdfe1e call #1efe 0541 cd251f call #1f25 0544 cd4c1f call #1f4c 0547 cd731f call #1f73 054a c9 ret 054b 21a14d ld hl,#4da1 054e 0620 ld b,#20 0550 3a324d ld a,(#4d32) 0553 c32405 jp #0524 0556 21a24d ld hl,#4da2 0559 0622 ld b,#22 055b 3a324d ld a,(#4d32) 055e c32405 jp #0524 0561 21a34d ld hl,#4da3 0564 0624 ld b,#24 0566 3a324d ld a,(#4d32) 0569 c32405 jp #0524 056c 3ad04d ld a,(#4dd0) 056f 47 ld b,a 0570 3ad14d ld a,(#4dd1) 0573 80 add a,b 0574 fe06 cp #06 0576 ca8e05 jp z,#058e 0579 c32c05 jp #052c 057c cdbe06 call #06be 057f c9 ret 0580 3a754e ld a,(#4e75) 0583 81 add a,c 0584 4f ld c,a 0585 061c ld b,#1c 0587 cd4200 call #0042 058a f7 rst #30 058b 4a ld c,d 058c 02 ld (bc),a 058d 00 nop 058e 21024e ld hl,#4e02 0591 34 inc (hl) 0592 c9 ret 0593 3a754e ld a,(#4e75) 0596 81 add a,c 0597 4f ld c,a 0598 061c ld b,#1c 059a cd4200 call #0042 059d f7 rst #30 059e 45 ld b,l 059f 02 ld (bc),a 05a0 00 nop 05a1 cd8e05 call #058e 05a4 c9 ret 05a5 3ab54d ld a,(#4db5) 05a8 a7 and a 05a9 c8 ret z 05aa af xor a 05ab 32b54d ld (#4db5),a 05ae 3a304d ld a,(#4d30) 05b1 ee02 xor #02 05b3 323c4d ld (#4d3c),a 05b6 47 ld b,a 05b7 21ff32 ld hl,#32ff 05ba df rst #18 05bb 22264d ld (#4d26),hl 05be c9 ret 05bf 36b1 ld (hl),#b1 05c1 2c inc l 05c2 36b3 ld (hl),#b3 05c4 2c inc l 05c5 36b5 ld (hl),#b5 05c7 011e00 ld bc,#001e 05ca 09 add hl,bc 05cb 36b0 ld (hl),#b0 05cd 2c inc l 05ce 36b2 ld (hl),#b2 05d0 2c inc l 05d1 36b4 ld (hl),#b4 05d3 110004 ld de,#0400 05d6 19 add hl,de 05d7 77 ld (hl),a 05d8 2d dec l 05d9 77 ld (hl),a 05da 2d dec l 05db 77 ld (hl),a 05dc a7 and a 05dd ed42 sbc hl,bc 05df 77 ld (hl),a 05e0 2d dec l 05e1 77 ld (hl),a 05e2 2d dec l 05e3 77 ld (hl),a 05e4 c9 ret 05e5 3a034e ld a,(#4e03) 05e8 e7 rst #20 05e9 f3 di 05ea 05 dec b 05eb 1b dec de 05ec 0674 ld b,#74 05ee 060c ld b,#0c 05f0 00 nop 05f1 a8 xor b 05f2 06cd ld b,#cd 05f4 a1 and c 05f5 2b dec hl 05f6 ef rst #28 05f7 0001 05f9 ef rst #28 05f8 0100 05fc ef rst #28 05fd 1c07 05ff ef rst #28 0600 1c0b 0602 ef rst #28 0603 1e0 0605 21034e ld hl,#4e03 0608 34 inc (hl) 0609 3e01 ld a,#01 060b 32d64d ld (#4dd6),a 060e 3a714e ld a,(#4e71) 0611 feff cp #ff 0613 c8 ret z 0614 ef rst #28 0615 1c0a 0617 ef rst #28 0618 1f00 061a c9 ret ; can't find a jump to here ;; display 1/2 player and check start buttons 061b cda12b call #2ba1 061e 3a6e4e ld a,(#4e6e) ; credits 0621 fe01 cp #01 ; is it 1? 0623 0609 ld b,#09 ; msg #9: 1 OR 2 PLAYERS 0625 2002 jr nz,#0629 ; (2) >2 credits 0627 0608 ld b,#08 ; msg #8: 1 PLAYER ONLY 0629 cd5e2c call #2c5e ; print message 062c 3a6e4e ld a,(#4e6e) ; get credits 062f fe01 cp #01 ; 1 credit 0631 3a4050 ld a,(#5040) ;; check in1 0634 280c jr z,#0642 ; (12) don't check p2 with 1 credit 0636 cb77 bit 6,a 0638 2008 jr nz,#0642 ; (8) 063a 3e01 ld a,#01 ; set 2 players 063c 32704e ld (#4e70),a ; players 0=1 1=2 players 063f c34906 jp #0649 0642 cb6f bit 5,a 0644 c0 ret nz 0645 af xor a 0646 32704e ld (#4e70),a 0649 3a6b4e ld a,(#4e6b) 064c a7 and a 064d 2815 jr z,#0664 ; (21) 064f 3a704e ld a,(#4e70) 0652 a7 and a 0653 3a6e4e ld a,(#4e6e) ; number of credits 0656 2803 jr z,#065b ; (3) 0658 c699 add a,#99 065a 27 daa 065b c699 add a,#99 065d 27 daa 065e 326e4e ld (#4e6e),a ; resave credits 0661 cda12b call #2ba1 0664 21034e ld hl,#4e03 0667 34 inc (hl) 0668 af xor a 0669 32d64d ld (#4dd6),a 066c 3c inc a 066d 32cc4e ld (#4ecc),a 0670 32dc4e ld (#4edc),a 0673 c9 ret 0674 ef rst #28 0675 0001 0677 ef rst #28 0678 0101 067a ef rst #28 067b 0200 067d ef rst #28 067e 1200 0680 ef rst #28 0681 0300 0683 ef rst #28 0684 1c03 0686 ef rst #28 0687 1c06 0689 ef rst #28 068a 1800 068c ef rst #28 068d 1b00 068f af xor a 0690 32134e ld (#4e13),a ; current board level = 0 0693 3a6f4e ld a,(#4e6f) ; number of lives to start 0696 32144e ld (#4e14),a ; number of lives 0699 32154e ld (#4e15),a ; number of lives displayed 069c ef rst #28 069d 1a00 069f f7 rst #30 06a0 57 ld d,a 06a1 010021 ld bc,#2100 06a4 03 inc bc 06a5 4e ld c,(hl) 06a6 34 inc (hl) 06a7 c9 ret ;; draw lives displayed onto the screen 06a8 21154e ld hl,#4e15 ; hl= lives displayed on screen loc 06ab 35 dec (hl) 06ac cd6a2b call #2b6a 06af af xor a 06b0 32034e ld (#4e03),a 06b3 32024e ld (#4e02),a 06b6 32044e ld (#4e04),a ; level complete register 06b9 21004e ld hl,#4e00 ; inc game mode 06bc 34 inc (hl) 06bd c9 ret 06be 3a044e ld a,(#4e04) 06c1 e7 rst #20 06c2 79 ld a,c 06c3 08 ex af,af' 06c4 99 sbc a,c 06c5 08 ex af,af' 06c6 0c inc c 06c7 00 nop 06c8 cd080d call #0d08 06cb 09 add hl,bc 06cc 0c inc c 06cd 00 nop 06ce 40 ld b,b 06cf 09 add hl,bc 06d0 0c inc c 06d1 00 nop 06d2 72 ld (hl),d 06d3 09 add hl,bc 06d4 88 adc a,b 06d5 09 add hl,bc 06d6 0c inc c 06d7 00 nop 06d8 d209d8 jp nc,#d809 06db 09 add hl,bc 06dc 0c inc c 06dd 00 nop 06de e8 ret pe 06df 09 add hl,bc 06e0 0c inc c 06e1 00 nop 06e2 fe09 cp #09 06e4 0c inc c 06e5 00 nop 06e6 02 ld (bc),a 06e7 0a ld a,(bc) 06e8 0c inc c 06e9 00 nop 06ea 04 inc b 06eb 0a ld a,(bc) 06ec 0c inc c 06ed 00 nop 06ee 060a ld b,#0a 06f0 0c inc c 06f1 00 nop 06f2 08 ex af,af' 06f3 0a ld a,(bc) 06f4 0c inc c 06f5 00 nop 06f6 0a ld a,(bc) 06f7 0a ld a,(bc) 06f8 0c inc c 06f9 00 nop 06fa 0c inc c 06fb 0a ld a,(bc) 06fc 0c inc c 06fd 00 nop 06fe 0e0a ld c,#0a 0700 0c inc c 0701 00 nop 0702 2c inc l 0703 0a ld a,(bc) 0704 0c inc c 0705 00 nop 0706 7c ld a,h 0707 0a ld a,(bc) 0708 a0 and b 0709 0a ld a,(bc) 070a 0c inc c 070b 00 nop 070c a3 and e 070d 0a ld a,(bc) 070e 78 ld a,b 070f a7 and a 0710 2004 jr nz,#0716 ; (4) 0712 2a0a4e ld hl,(#4e0a) 0715 7e ld a,(hl) 0716 dd219607 ld ix,#0796 071a 47 ld b,a 071b 87 add a,a 071c 87 add a,a 071d 80 add a,b 071e 80 add a,b 071f 5f ld e,a 0720 1600 ld d,#00 0722 dd19 add ix,de 0724 dd7e00 ld a,(ix+#00) 0727 87 add a,a 0728 47 ld b,a 0729 87 add a,a 072a 87 add a,a 072b 4f ld c,a 072c 87 add a,a 072d 87 add a,a 072e 81 add a,c 072f 80 add a,b 0730 5f ld e,a 0731 1600 ld d,#00 0733 210f33 ld hl,#330f 0736 19 add hl,de 0737 cd1408 call #0814 073a dd7e01 ld a,(ix+#01) 073d 32b04d ld (#4db0),a 0740 dd7e02 ld a,(ix+#02) 0743 47 ld b,a 0744 87 add a,a 0745 80 add a,b 0746 5f ld e,a 0747 1600 ld d,#00 0749 214308 ld hl,#0843 ; hard/easy data table check 074c 19 add hl,de 074d cd3a08 call #083a 0750 dd7e03 ld a,(ix+#03) 0753 87 add a,a 0754 5f ld e,a 0755 1600 ld d,#00 0757 fd214f08 ld iy,#084f ; another data table check 075b fd19 add iy,de 075d fd6e00 ld l,(iy+#00) 0760 fd6601 ld h,(iy+#01) 0763 22bb4d ld (#4dbb),hl 0766 dd7e04 ld a,(ix+#04) 0769 87 add a,a 076a 5f ld e,a 076b 1600 ld d,#00 076d fd216108 ld iy,#0861 0771 fd19 add iy,de 0773 fd6e00 ld l,(iy+#00) 0776 fd6601 ld h,(iy+#01) 0779 22bd4d ld (#4dbd),hl 077c dd7e05 ld a,(ix+#05) 077f 87 add a,a 0780 5f ld e,a 0781 1600 ld d,#00 0783 fd217308 ld iy,#0873 0787 fd19 add iy,de 0789 fd6e00 ld l,(iy+#00) 078c fd6601 ld h,(iy+#01) 078f 22954d ld (#4d95),hl 0792 cdea2b call #2bea 0795 c9 ret ; -- difficulty related table ; each entry is 6 bytes ; byte 0: (0..6) movement bit patterns and orientation changes (table at 330F) ; byte 1: (00, 01, 02) stored at 4DB0 - seems to be unused ; byte 2: (0..3) ghost counter table to exit home (table at 0843) ; byte 3: (0..7) remaining number of pills to set difficulty flags (table at 084F) ; byte 4: (0..8) ghost time to stay blue when pacman eats the big pill (table at 0861) ; byte 5: (0..2) number of units before a ghost goes out of home (table at 0873) 0796 03 01 01 00 02 00 079c 04 01 02 01 03 00 07a2 04 01 03 02 04 01 07a8 04 02 03 02 05 01 07ae 05 00 03 02 06 02 07b4 05 01 03 03 03 02 07ba 05 02 03 03 06 02 07c0 05 02 03 03 06 02 07c6 05 00 03 04 07 02 07cc 05 01 03 04 03 02 07d2 05 02 03 04 06 02 07d8 05 02 03 05 07 02 07de 05 00 03 05 07 02 07e4 05 02 03 05 05 02 07ea 05 01 03 06 07 02 07f0 05 02 03 06 07 02 07f6 05 02 03 06 08 02 07fc 05 02 03 06 07 02 0802 05 02 03 07 08 02 0808 05 02 03 07 08 02 080e 06 02 03 07 08 02 0814 11464d ld de,#4d46 0817 011c00 ld bc,#001c 081a edb0 ldir 081c 010c00 ld bc,#000c 081f a7 and a 0820 ed42 sbc hl,bc 0822 edb0 ldir 0824 010c00 ld bc,#000c 0827 a7 and a 0828 ed42 sbc hl,bc 082a edb0 ldir 082c 010c00 ld bc,#000c 082f a7 and a 0830 ed42 sbc hl,bc 0832 edb0 ldir 0834 010e00 ld bc,#000e 0837 edb0 ldir 0839 c9 ret 083a 11b84d ld de,#4db8 083d 010300 ld bc,#0003 0840 edb0 ldir 0842 c9 ret ;-- table related to difficulty - each entry is 3 bytes ; b0: when counter at 4E0F reaches this value, pink ghost goes out of home ; b1: when counter at 4E10 reaches this value, blue ghost goes out of home ; b2: when counter at 4E11 reaches this value, orange ghost goes out of home ; these don't seem to be used in ms-pac at all. 0843 14 1e 46 00 1e 3c 00 00 32 00 00 00 ; hard hack: HACK6 ; 0843 0f 14 37 04 18 34 02 06 28 00 04 08 ;-- difficulty table - each entry is 2 bytes ; b0: remaining number of pills when second difficulty flag is set ; b1: remaining number of pills when first difficulty flag is set 084f 14 0a 1e 0f 28 14 32 19 3c 1e 50 28 64 32 78 3c 085f 8c 46 ;difficulty table - Time the ghosts stay blue when pacman eats a big pill 0861 c0 03 03c0 (960) 0863 48 03 0348 (840) 0865 d0 02 02d0 (720) 0867 58 02 0258 (600) 0869 e0 01 01e0 (480) 086b 68 01 0168 (360) 086d f0 00 00f0 (240) 086f 78 00 0078 (120) 0871 01 00 0001 (1) ; difficulty table - numberof units before ghosts leaves home 0873 f0 00 00f0 (240) 0875 f0 00 00f0 (240) 0877 b4 00 00b4 (180) ; main routine #3 (playing) 0879 21094e ld hl,#4e09 087c af xor a 087d 060b ld b,#0b 087f cf rst #8 0880 cdc924 call #24c9 0883 2a734e ld hl,(#4e73) ; difficulty 0886 220a4e ld (#4e0a),hl 0889 210a4e ld hl,#4e0a 088c 11384e ld de,#4e38 088f 012e00 ld bc,#002e 0892 edb0 ldir 0894 21044e ld hl,#4e04 ; inc level complete register 0897 34 inc (hl) 0898 c9 ret 0899 3a004e ld a,(#4e00) ; game mode 089c 3d dec a ; check mode 089d 2006 jr nz,#08a5 ; jump if not in intro mode 089f 3e09 ld a,#09 08a1 32044e ld (#4e04),a ; set intro mode? 08a4 c9 ret 08a5 ef rst #28 08a6 1100 08a8 ef rst #28 08a9 1c83 08ab ef rst #28 08ac 0400 08ae ef rst #28 08af 0500 08b1 ef rst #28 08b2 1000 08b4 ef rst #28 08b5 1a00 08b7 f7 rst #30 08b8 54 ld d,h 08b9 00 nop 08ba 00 nop 08bb f7 rst #30 08bc 54 ld d,h 08bd 0600 ld b,#00 08bf 3a724e ld a,(#4e72) ; cocktail or upright 08c2 47 ld b,a 08c3 3a094e ld a,(#4e09) 08c6 a0 and b 08c7 320350 ld (#5003),a ; flip screen 08ca c39408 jp #0894 08cd 3a0050 ld a,(#5000) 08d0 cb67 bit 4,a ; rack test 08d2 c2de08 jp nz,#08de ; not on then continue game 08d5 21044e ld hl,#4e04 ; rack switch on, so advance 08d8 360e ld (hl),#0e ; level complete register gets $0E?? 08da ef rst #28 08db 1300 08dd c9 ret ;; routine to determine the number of pellets must be eaten 08de 3a0e4e ld a,(#4e0e) ; number of pellets eaten 08e1 c3a194 jp #94a1 ; jump to check routine 08e4 00 nop ; returns here 08e5 21044e ld hl,#4e04 08e8 360c ld (hl),#0c 08ea c9 ret ;; pacman original: ; 08de 3a0e4e ld a,(#4e0e) ;NUMBER OF PELLETS EATEN ; 08e1 fef4 cp #f4 ;COMPARE TO 244 ; 08e3 2006 jr nz,#08eb ;JUMP IF NOT 244 ; 08e5 21044e ld hl,#4e04 ;IF SO THEN $C->$4E04 ; 08e8 360c ld (hl),#0c ; 08ea c9 ret ; another core game loop? 08eb cd1710 call #1017 08ee cd1710 call #1017 08f1 cddd13 call #13dd 08f4 cd420c call #0c42 08f7 cd230e call #0e23 08fa cd360e call #0e36 08fd cdc30a call #0ac3 0900 cdd60b call #0bd6 0903 cd0d0c call #0c0d 0906 cd6c0e call #0e6c 0909 cdad0e call #0ead 090c c9 ret 090d 3e01 ld a,#01 090f 32124e ld (#4e12),a 0912 cd8724 call #2487 0915 21044e ld hl,#4e04 0918 34 inc (hl) 0919 3a144e ld a,(#4e14) ; number of lives left 091c a7 and a 091d 201f jr nz,#093e ; (31) 091f 3a704e ld a,(#4e70) 0922 a7 and a 0923 2819 jr z,#093e ; (25) 0925 3a424e ld a,(#4e42) 0928 a7 and a 0929 2813 jr z,#093e ; (19) 092b 3a094e ld a,(#4e09) 092e c603 add a,#03 0930 4f ld c,a 0931 061c ld b,#1c 0933 cd4200 call #0042 0936 ef rst #28 0937 1c05 0939 f7 rst #30 093a 54 ld d,h 093b 00 nop 093c 00 nop 093d c9 ret 093e 34 inc (hl) 093f c9 ret 0940 3a704e ld a,(#4e70) ; number of players 0943 a7 and a 0944 2806 jr z,#094c ; jump if 1 player 0946 3a424e ld a,(#4e42) 0949 a7 and a 094a 2015 jr nz,#0961 ; (21) 094c 3a144e ld a,(#4e14) ; number of lives left 094f a7 and a ; change 0950 to ; c36c09 jp 096c ; for never-ending pac goodness 0950 201a jr nz,#096c ; jump if lives left 0952 cda12b call #2ba1 ; draw # credits or free play ; on bottom of screen 0955 ef rst #28 0956 1c05 0958 f7 rst #30 0959 54 ld d,h 095a 00 nop 095b 00 nop 095c 21044e ld hl,#4e04 095f 34 inc (hl) ; increment level cleared 0960 c9 ret 0961 cda60a call #0aa6 0964 3a094e ld a,(#4e09) 0967 ee01 xor #01 0969 32094e ld (#4e09),a 096c 3e09 ld a,#09 096e 32044e ld (#4e04),a 0971 c9 ret ;; zero some important variables 0972 af xor a 0973 32024e ld (#4e02),a 0976 32044e ld (#4e04),a 0979 32704e ld (#4e70),a 097c 32094e ld (#4e09),a 097f 320350 ld (#5003),a ; flip screen 0982 3e01 ld a,#01 0984 32004e ld (#4e00),a 0987 c9 ret 0988 ef rst #28 0989 0001 098b ef rst #28 098c 0101 098e ef rst #28 098f 0200 0991 ef rst #28 0992 1100 0994 ef rst #28 0995 1300 0997 ef rst #28 0998 0300 099a ef rst #28 099b 0400 099d ef rst #28 099e 0500 09a0 ef rst #28 09a1 1000 09a3 ef rst #28 09a4 1a00 09a6 ef rst #28 09a7 1c06 09a8 3a004e ld a,(#4e00) 09ac fe03 cp #03 09ae 2806 jr z,#09b6 ; (6) 09b0 ef rst #28 09b1 1c05 09b3 ef rst #28 09b4 1d00 09b6 f7 rst #30 09b7 54 ld d,h 09b8 00 nop 09b9 00 nop 09ba 3a004e ld a,(#4e00) 09bd 3d dec a 09be 2804 jr z,#09c4 ; (4) 09c0 f7 rst #30 09c1 54 ld d,h 09c2 0600 ld b,#00 09c4 3a724e ld a,(#4e72) 09c7 47 ld b,a 09c8 3a094e ld a,(#4e09) 09cb a0 and b 09cc 320350 ld (#5003),a ; flip screen 09cf c39408 jp #0894 09d2 3e03 ld a,#03 09d4 32044e ld (#4e04),a 09d7 c9 ret 09d8 f7 rst #30 09d9 54 ld d,h 09da 00 nop 09db 00 nop 09dc 21044e ld hl,#4e04 09df 34 inc (hl) 09e0 af xor a 09e1 32ac4e ld (#4eac),a 09e4 32bc4e ld (#4ebc),a 09e7 c9 ret 09e8 0e02 ld c,#02 09ea 0601 ld b,#01 09ec cd4200 call #0042 09ef f7 rst #30 09f0 42 ld b,d 09f1 00 nop 09f2 00 nop 09f3 210000 ld hl,#0000 09f6 cd7e26 call #267e 09f9 21044e ld hl,#4e04 09fc 34 inc (hl) 09fd c9 ret 09fe 0e00 ld c,#00 0a00 18e8 jr #09ea ; (-24) 0a02 18e4 jr #09e8 ; (-28) 0a04 18f8 jr #09fe ; (-8) 0a06 18e0 jr #09e8 ; (-32) 0a08 18f4 jr #09fe ; (-12) 0a0a 18dc jr #09e8 ; (-36) 0a0c 18f0 jr #09fe ; (-16) 0a0e ef rst #28 0a0f 0001 0a11 ef rst #28 0a12 0600 0a14 ef rst #28 0a15 1100 0a17 ef rst #28 0a18 1300 0a1a ef rst #28 0a1b 0401 0a1d ef rst #28 0a1e 0501 0a20 ef rst #28 0a21 1013 0a23 f7 rst #30 0a24 43 ld b,e 0a25 00 nop 0a26 00 nop 0a27 21044e ld hl,#4e04 0a2a 34 inc (hl) 0a2b c9 ret 0a2c af xor a 0a2d 32ac4e ld (#4eac),a 0a30 32bc4e ld (#4ebc),a 0a33 1806 jr #0a3b ; (6) 0a35 32cc4e ld (#4ecc),a 0a38 32dc4e ld (#4edc),a 0a3b 3a134e ld a,(#4e13) ; current board level 0a3e fe14 cp #14 0a40 3802 jr c,#0a44 ; (2) 0a42 3e14 ld a,#14 0a44 e7 rst #20 ; jump table 0a45 6f 0a ; increment level state and stop sound 0a47 08 21 ; cut scene 1 0a49 6f 0a ; increment level state and stop sound 0a4b 6f 0a ; increment level state and stop sound 0a4d 9e 21 ; cut scene 2 0a4f 6f 0a ; increment level state and stop sound 0a51 6f 0a ; increment level state and stop sound 0a53 6f 0a ; increment level state and stop sound 0a55 97 22 ; cut scene 3 0a57 6f 0a ; increment level state and stop sound 0a59 6f 0a ; increment level state and stop sound 0a5b 6f 0a ; increment level state and stop sound 0a5d 97 22 ; cut scene 3 0a5f 6f 0a ; increment level state and stop sound 0a61 6f 0a ; increment level state and stop sound 0a63 6f 0a ; increment level state and stop sound 0a65 97 22 ; cut scene 3 0a67 6f 0a ; increment level state and stop sound 0a69 6f 0a ; increment level state and stop sound 0a6b 6f 0a ; increment level state and stop sound 0a6d 6f 0a ; increment level state and stop sound ; increment level state and stop sound 0a6f 21044e ld hl,#4e04 0a72 34 inc (hl) 0a73 34 inc (hl) 0a74 af xor a 0a75 32cc4e ld (#4ecc),a 0a78 32dc4e ld (#4edc),a 0a7b c9 ret ;; we're about to start the next board, (it's about to be drawn) 0a7c af xor a 0a7d 32cc4e ld (#4ecc),a 0a80 32dc4e ld (#4edc),a 0a83 0607 ld b,#07 0a85 210c4e ld hl,#4e0c 0a88 cf rst #8 0a89 cdc924 call #24c9 0a8c 21044e ld hl,#4e04 0a8f 34 inc (hl) ; level 255 pac fix ; HACK8 ;0a90 c3800f jp #0f88 ;0a93 00 nop ; level 141 mspac fix ; HACK9 ;0a90 c3960f jp #0f96 ;0a93 00 nop 0a90 21134e ld hl,#4e13 ;; current board level 0a93 34 inc (hl) ; increment board level 0a94 2a0a4e ld hl,(#4e0a) 0a97 7e ld a,(hl) 0a98 fe14 cp #14 0a9a c8 ret z 0a9b 23 inc hl 0a9c 220a4e ld (#4e0a),hl 0a9f c9 ret 0aa0 c38809 jp #0988 0aa3 c3d209 jp #09d2 0aa6 062e ld b,#2e 0aa8 dd210a4e ld ix,#4e0a 0aac fd21384e ld iy,#4e38 0ab0 dd5600 ld d,(ix+#00) 0ab3 fd5e00 ld e,(iy+#00) 0ab6 fd7200 ld (iy+#00),d 0ab9 dd7300 ld (ix+#00),e 0abc dd23 inc ix 0abe fd23 inc iy 0ac0 10ee djnz #0ab0 ; (-18) 0ac2 c9 ret 0ac3 3aa44d ld a,(#4da4) 0ac6 a7 and a 0ac7 c0 ret nz 0ac8 dd21004c ld ix,#4c00 0acc fd21c84d ld iy,#4dc8 0ad0 110001 ld de,#0100 0ad3 fdbe00 cp (iy+#00) 0ad6 c2d20b jp nz,#0bd2 0ad9 fd36000e ld (iy+#00),#0e 0add 3aa64d ld a,(#4da6) 0ae0 a7 and a 0ae1 281b jr z,#0afe ; (27) 0ae3 2acb4d ld hl,(#4dcb) 0ae6 a7 and a 0ae7 ed52 sbc hl,de 0ae9 3013 jr nc,#0afe ; (19) 0aeb 21ac4e ld hl,#4eac 0aee cbfe set 7,(hl) 0af0 3e09 ld a,#09 0af2 ddbe0b cp (ix+#0b) 0af5 2004 jr nz,#0afb ; (4) 0af7 cbbe res 7,(hl) 0af9 3e09 ld a,#09 0afb 320b4c ld (#4c0b),a 0afe 3aa74d ld a,(#4da7) 0b01 a7 and a 0b02 281d jr z,#0b21 ; (29) 0b04 2acb4d ld hl,(#4dcb) 0b07 a7 and a 0b08 ed52 sbc hl,de 0b0a 3027 jr nc,#0b33 ; (39) 0b0c 3e11 ld a,#11 0b0e ddbe03 cp (ix+#03) 0b11 2807 jr z,#0b1a ; (7) 0b13 dd360311 ld (ix+#03),#11 0b17 c3330b jp #0b33 0b1a dd360312 ld (ix+#03),#12 0b1e c3330b jp #0b33 0b21 3e01 ld a,#01 0b23 ddbe03 cp (ix+#03) 0b26 2807 jr z,#0b2f ; (7) 0b28 dd360301 ld (ix+#03),#01 0b2c c3330b jp #0b33 0b2f dd360301 ld (ix+#03),#01 0b33 3aa84d ld a,(#4da8) 0b36 a7 and a 0b37 281d jr z,#0b56 ; (29) 0b39 2acb4d ld hl,(#4dcb) 0b3c a7 and a 0b3d ed52 sbc hl,de 0b3f 3027 jr nc,#0b68 ; (39) 0b41 3e11 ld a,#11 0b43 ddbe05 cp (ix+#05) 0b46 2807 jr z,#0b4f ; (7) 0b48 dd360511 ld (ix+#05),#11 0b4c c3680b jp #0b68 0b4f dd360512 ld (ix+#05),#12 0b53 c3680b jp #0b68 0b56 3e03 ld a,#03 0b58 ddbe05 cp (ix+#05) 0b5b 2807 jr z,#0b64 ; (7) 0b5d dd360503 ld (ix+#05),#03 0b61 c3680b jp #0b68 0b64 dd360503 ld (ix+#05),#03 0b68 3aa94d ld a,(#4da9) 0b6b a7 and a 0b6c 281d jr z,#0b8b ; (29) 0b6e 2acb4d ld hl,(#4dcb) 0b71 a7 and a 0b72 ed52 sbc hl,de 0b74 3027 jr nc,#0b9d ; (39) 0b76 3e11 ld a,#11 0b78 ddbe07 cp (ix+#07) 0b7b 2807 jr z,#0b84 ; (7) 0b7d dd360711 ld (ix+#07),#11 0b81 c39d0b jp #0b9d 0b84 dd360712 ld (ix+#07),#12 0b88 c39d0b jp #0b9d 0b8b 3e05 ld a,#05 0b8d ddbe07 cp (ix+#07) 0b90 2807 jr z,#0b99 ; (7) 0b92 dd360705 ld (ix+#07),#05 0b96 c39d0b jp #0b9d 0b99 dd360705 ld (ix+#07),#05 0b9d 3aaa4d ld a,(#4daa) 0ba0 a7 and a 0ba1 281d jr z,#0bc0 ; (29) 0ba3 2acb4d ld hl,(#4dcb) 0ba6 a7 and a 0ba7 ed52 sbc hl,de 0ba9 3027 jr nc,#0bd2 ; (39) 0bab 3e11 ld a,#11 0bad ddbe09 cp (ix+#09) 0bb0 2807 jr z,#0bb9 ; (7) 0bb2 dd360911 ld (ix+#09),#11 0bb6 c3d20b jp #0bd2 0bb9 dd360912 ld (ix+#09),#12 0bbd c3d20b jp #0bd2 0bc0 3e07 ld a,#07 0bc2 ddbe09 cp (ix+#09) 0bc5 2807 jr z,#0bce ; (7) 0bc7 dd360907 ld (ix+#09),#07 0bcb c3d20b jp #0bd2 0bce dd360907 ld (ix+#09),#07 0bd2 fd3500 dec (iy+#00) 0bd5 c9 ret 0bd6 0619 ld b,#19 0bd8 3a024e ld a,(#4e02) 0bdb fe22 cp #22 0bdd c2e20b jp nz,#0be2 0be0 0600 ld b,#00 0be2 dd21004c ld ix,#4c00 0be6 3aac4d ld a,(#4dac) 0be9 a7 and a 0bea caf00b jp z,#0bf0 0bed dd7003 ld (ix+#03),b 0bf0 3aad4d ld a,(#4dad) 0bf3 a7 and a 0bf4 cafa0b jp z,#0bfa 0bf7 dd7005 ld (ix+#05),b 0bfa 3aae4d ld a,(#4dae) 0bfd a7 and a 0bfe ca040c jp z,#0c04 0c01 dd7007 ld (ix+#07),b 0c04 3aaf4d ld a,(#4daf) 0c07 a7 and a 0c08 c8 ret z 0c09 dd7009 ld (ix+#09),b 0c0c c9 ret 0c0d 21cf4d ld hl,#4dcf 0c10 34 inc (hl) 0c11 3e0a ld a,#0a 0c13 be cp (hl) 0c14 c0 ret nz 0c15 3600 ld (hl),#00 0c17 3a044e ld a,(#4e04) 0c1a fe03 cp #03 0c1c 2015 jr nz,#0c33 ; (21) 0c1e 216444 ld hl,#4464 0c21 c32495 jp #9524 0c24 2002 jr nz,#0c28 ; (2) 0c26 3e00 ld a,#00 0c28 77 ld (hl),a 0c29 327844 ld (#4478),a 0c2c 328447 ld (#4784),a 0c2f 329847 ld (#4798),a 0c32 c9 ret 0c33 213247 ld hl,#4732 0c36 3e10 ld a,#10 0c38 be cp (hl) 0c39 2002 jr nz,#0c3d ; (2) 0c3b 3e00 ld a,#00 0c3d 77 ld (hl),a 0c3e 327846 ld (#4678),a 0c41 c9 ret 0c42 3aa44d ld a,(#4da4) 0c45 a7 and a 0c46 c0 ret nz 0c47 3a944d ld a,(#4d94) 0c4a 07 rlca 0c4b 32944d ld (#4d94),a 0c4e d0 ret nc 0c4f 3aa04d ld a,(#4da0) 0c52 a7 and a 0c53 c2900c jp nz,#0c90 0c56 dd210533 ld ix,#3305 0c5a fd21004d ld iy,#4d00 0c5e cd0020 call #2000 0c61 22004d ld (#4d00),hl 0c64 3e03 ld a,#03 0c66 32284d ld (#4d28),a 0c69 322c4d ld (#4d2c),a 0c6c 3a004d ld a,(#4d00) 0c6f fe64 cp #64 0c71 c2900c jp nz,#0c90 0c74 212c2e ld hl,#2e2c 0c77 220a4d ld (#4d0a),hl 0c7a 210001 ld hl,#0100 0c7d 22144d ld (#4d14),hl 0c80 221e4d ld (#4d1e),hl 0c83 3e02 ld a,#02 0c85 32284d ld (#4d28),a 0c88 322c4d ld (#4d2c),a 0c8b 3e01 ld a,#01 0c8d 32a04d ld (#4da0),a 0c90 3aa14d ld a,(#4da1) 0c93 fe01 cp #01 0c95 cafb0c jp z,#0cfb 0c98 fe00 cp #00 0c9a c2c10c jp nz,#0cc1 0c9d 3a024d ld a,(#4d02) 0ca0 fe78 cp #78 0ca2 cc2e1f call z,#1f2e 0ca5 fe80 cp #80 0ca7 cc2e1f call z,#1f2e 0caa 3a2d4d ld a,(#4d2d) 0cad 32294d ld (#4d29),a 0cb0 dd21204d ld ix,#4d20 0cb4 fd21024d ld iy,#4d02 0cb8 cd0020 call #2000 0cbb 22024d ld (#4d02),hl 0cbe c3fb0c jp #0cfb 0cc1 dd210533 ld ix,#3305 0cc5 fd21024d ld iy,#4d02 0cc9 cd0020 call #2000 0ccc 22024d ld (#4d02),hl 0ccf 3e03 ld a,#03 0cd1 322d4d ld (#4d2d),a 0cd4 32294d ld (#4d29),a 0cd7 3a024d ld a,(#4d02) 0cda fe64 cp #64 0cdc c2fb0c jp nz,#0cfb 0cdf 212c2e ld hl,#2e2c 0ce2 220c4d ld (#4d0c),hl 0ce5 210001 ld hl,#0100 0ce8 22164d ld (#4d16),hl 0ceb 22204d ld (#4d20),hl 0cee 3e02 ld a,#02 0cf0 32294d ld (#4d29),a 0cf3 322d4d ld (#4d2d),a 0cf6 3e01 ld a,#01 0cf8 32a14d ld (#4da1),a 0cfb 3aa24d ld a,(#4da2) 0cfe fe01 cp #01 0d00 ca930d jp z,#0d93 0d03 fe00 cp #00 0d05 c22c0d jp nz,#0d2c 0d08 3a044d ld a,(#4d04) 0d0b fe78 cp #78 0d0d cc551f call z,#1f55 0d10 fe80 cp #80 0d12 cc551f call z,#1f55 0d15 3a2e4d ld a,(#4d2e) 0d18 322a4d ld (#4d2a),a 0d1b dd21224d ld ix,#4d22 0d1f fd21044d ld iy,#4d04 0d23 cd0020 call #2000 0d26 22044d ld (#4d04),hl 0d29 c3930d jp #0d93 0d2c 3aa24d ld a,(#4da2) 0d2f fe03 cp #03 0d31 c2590d jp nz,#0d59 0d34 dd21ff32 ld ix,#32ff 0d38 fd21044d ld iy,#4d04 0d3c cd0020 call #2000 0d3f 22044d ld (#4d04),hl 0d42 af xor a 0d43 322a4d ld (#4d2a),a 0d46 322e4d ld (#4d2e),a 0d49 3a054d ld a,(#4d05) 0d4c fe80 cp #80 0d4e c2930d jp nz,#0d93 0d51 3e02 ld a,#02 0d53 32a24d ld (#4da2),a 0d56 c3930d jp #0d93 0d59 dd210533 ld ix,#3305 0d5d fd21044d ld iy,#4d04 0d61 cd0020 call #2000 0d64 22044d ld (#4d04),hl 0d67 3e03 ld a,#03 0d69 322a4d ld (#4d2a),a 0d6c 322e4d ld (#4d2e),a 0d6f 3a044d ld a,(#4d04) 0d72 fe64 cp #64 0d74 c2930d jp nz,#0d93 0d77 212c2e ld hl,#2e2c 0d7a 220e4d ld (#4d0e),hl 0d7d 210001 ld hl,#0100 0d80 22184d ld (#4d18),hl 0d83 22224d ld (#4d22),hl 0d86 3e02 ld a,#02 0d88 322a4d ld (#4d2a),a 0d8b 322e4d ld (#4d2e),a 0d8e 3e01 ld a,#01 0d90 32a24d ld (#4da2),a 0d93 3aa34d ld a,(#4da3) 0d96 fe01 cp #01 0d98 c8 ret z 0d99 fe00 cp #00 0d9b c2c00d jp nz,#0dc0 0d9e 3a064d ld a,(#4d06) 0da1 fe78 cp #78 0da3 cc7c1f call z,#1f7c 0da6 fe80 cp #80 0da8 cc7c1f call z,#1f7c 0dab 3a2f4d ld a,(#4d2f) 0dae 322b4d ld (#4d2b),a 0db1 dd21244d ld ix,#4d24 0db5 fd21064d ld iy,#4d06 0db9 cd0020 call #2000 0dbc 22064d ld (#4d06),hl 0dbf c9 ret 0dc0 3aa34d ld a,(#4da3) 0dc3 fe03 cp #03 0dc5 c2ea0d jp nz,#0dea 0dc8 dd210333 ld ix,#3303 0dcc fd21064d ld iy,#4d06 0dd0 cd0020 call #2000 0dd3 22064d ld (#4d06),hl 0dd6 3e02 ld a,#02 0dd8 322b4d ld (#4d2b),a 0ddb 322f4d ld (#4d2f),a 0dde 3a074d ld a,(#4d07) 0de1 fe80 cp #80 0de3 c0 ret nz 0de4 3e02 ld a,#02 0de6 32a34d ld (#4da3),a 0de9 c9 ret 0dea dd210533 ld ix,#3305 0dee fd21064d ld iy,#4d06 0df2 cd0020 call #2000 0df5 22064d ld (#4d06),hl 0df8 3e03 ld a,#03 0dfa 322b4d ld (#4d2b),a 0dfd 322f4d ld (#4d2f),a 0e00 3a064d ld a,(#4d06) 0e03 fe64 cp #64 0e05 c0 ret nz 0e06 212c2e ld hl,#2e2c 0e09 22104d ld (#4d10),hl 0e0c 210001 ld hl,#0100 0e0f 221a4d ld (#4d1a),hl 0e12 22244d ld (#4d24),hl 0e15 3e02 ld a,#02 0e17 322b4d ld (#4d2b),a 0e1a 322f4d ld (#4d2f),a 0e1d 3e01 ld a,#01 0e1f 32a34d ld (#4da3),a 0e22 c9 ret 0e23 21c44d ld hl,#4dc4 0e26 34 inc (hl) 0e27 3e08 ld a,#08 0e29 be cp (hl) 0e2a c0 ret nz 0e2b 3600 ld (hl),#00 0e2d 3ac04d ld a,(#4dc0) 0e30 ee01 xor #01 0e32 32c04d ld (#4dc0),a 0e35 c9 ret 0e36 3aa64d ld a,(#4da6) 0e39 a7 and a 0e3a c0 ret nz 0e3b 3ac14d ld a,(#4dc1) 0e3e fe07 cp #07 0e40 c8 ret z 0e41 87 add a,a 0e42 2ac24d ld hl,(#4dc2) 0e45 23 inc hl 0e46 22c24d ld (#4dc2),hl 0e49 5f ld e,a 0e4a 1600 ld d,#00 0e4c dd21864d ld ix,#4d86 0e50 dd19 add ix,de 0e52 dd5e00 ld e,(ix+#00) 0e55 dd5601 ld d,(ix+#01) 0e58 a7 and a 0e59 ed52 sbc hl,de 0e5b c0 ret nz 0e5c af xor a 0e5d 00 nop 0e5e 3c inc a 0e5f 32c14d ld (#4dc1),a 0e62 210101 ld hl,#0101 0e65 22b14d ld (#4db1),hl 0e68 22b34d ld (#4db3),hl 0e6b c9 ret 0e6c 3aa54d ld a,(#4da5) 0e6f a7 and a 0e70 2805 jr z,#0e77 ; (5) 0e72 af xor a 0e73 32ac4e ld (#4eac),a 0e76 c9 ret 0e77 21ac4e ld hl,#4eac 0e7a 06e0 ld b,#e0 0e7c 3a0e4e ld a,(#4e0e) 0e7f fee4 cp #e4 0e81 3806 jr c,#0e89 ; (6) 0e83 78 ld a,b 0e84 a6 and (hl) 0e85 cbe7 set 4,a 0e87 77 ld (hl),a 0e88 c9 ret 0e89 fed4 cp #d4 0e8b 3806 jr c,#0e93 ; (6) 0e8d 78 ld a,b 0e8e a6 and (hl) 0e8f cbdf set 3,a 0e91 77 ld (hl),a 0e92 c9 ret 0e93 feb4 cp #b4 0e95 3806 jr c,#0e9d ; (6) 0e97 78 ld a,b 0e98 a6 and (hl) 0e99 cbd7 set 2,a 0e9b 77 ld (hl),a 0e9c c9 ret 0e9d fe74 cp #74 0e9f 3806 jr c,#0ea7 ; (6) 0ea1 78 ld a,b 0ea2 a6 and (hl) 0ea3 cbcf set 1,a 0ea5 77 ld (hl),a 0ea6 c9 ret 0ea7 78 ld a,b 0ea8 a6 and (hl) 0ea9 cbc7 set 0,a 0eab 77 ld (hl),a 0eac c9 ret 0ead c3ee86 jp #86ee 0eb0 a7 and a 0eb1 c0 ret nz 0eb2 3ad44d ld a,(#4dd4) 0eb5 a7 and a 0eb6 c0 ret nz 0eb7 3a0e4e ld a,(#4e0e) 0eba fe46 cp #46 0ebc 280e jr z,#0ecc ; (14) 0ebe feaa cp #aa 0ec0 c0 ret nz 0ec1 3a0d4e ld a,(#4e0d) 0ec4 a7 and a 0ec5 c0 ret nz 0ec6 210d4e ld hl,#4e0d 0ec9 34 inc (hl) 0eca 1809 jr #0ed5 ; (9) 0ecc 3a0c4e ld a,(#4e0c) 0ecf a7 and a 0ed0 c0 ret nz 0ed1 210c4e ld hl,#4e0c 0ed4 34 inc (hl) 0ed5 219480 ld hl,#8094 0ed8 22d24d ld (#4dd2),hl 0edb 21fd0e ld hl,#0efd 0ede 3a134e ld a,(#4e13) ; compare board level with 0ee1 fe14 cp #14 ; 14 0ee3 3802 jr c,#0ee7 ; (2) 0ee5 3e14 ld a,#14 0ee7 47 ld b,a 0ee8 87 add a,a 0ee9 80 add a,b 0eea d7 rst #10 0eeb 320c4c ld (#4c0c),a 0eee 23 inc hl 0eef 7e ld a,(hl) 0ef0 320d4c ld (#4c0d),a 0ef3 23 inc hl 0ef4 7e ld a,(hl) 0ef5 32d44d ld (#4dd4),a 0ef8 f7 rst #30 0ef9 8a adc a,d 0efa 04 inc b 0efb 00 nop 0efc c9 ret ;; $0efd - 0f3b = table for fruit shapes, colors, point value. ;; (the 3 bytes are stored in the above order) offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 00000ef0 00 14 06 | ...| 00000f00 01 0f 07 02 15 08 02 15 08 04 14 09 04 14 09 05 |................| 00000f10 17 0a 05 17 0a 06 09 0b 06 09 0b 03 16 0c 03 16 |................| 00000f20 0c 07 16 0d 07 16 0d 07 16 0d 07 16 0d 07 16 0d |................| 00000f30 07 16 0d 07 16 0d 07 16 0d 07 16 0d |............ | ;; shape 00 color 14 points 06 ;; shape 01 color 0f points 07 ;; etc... 0f3c 00 nop 0f3d 00 nop 0f3e 00 nop 0f3f 00 nop 0f40 00 nop 0f41 00 nop 0f42 00 nop 0f43 00 nop 0f44 00 nop 0f45 00 nop 0f46 00 nop 0f47 00 nop 0f48 00 nop 0f49 00 nop 0f4a 00 nop 0f4b 00 nop 0f4c 00 nop 0f4d 00 nop 0f4e 00 nop 0f4f 00 nop 0f50 00 nop 0f51 00 nop 0f52 00 nop 0f53 00 nop 0f54 00 nop 0f55 00 nop 0f56 00 nop 0f57 00 nop 0f58 00 nop 0f59 00 nop 0f5a 00 nop 0f5b 00 nop ; start at 0f5c since 0f3c-0f5b is used in other romsets. ;; Pause toggle ; HACK5 ; start 1 enters pause, start 2 leaves pause ;0f5c 3a4050 ld a,(#5040) ; IN1 ;0f5f e620 and #20 ; start 1 ;0f61 c2db1f jp nz,#1fdb ; nope. jump away ;1fd0 for HACK3 ; pause ;0f64 f5 push af ;0f65 af xor a ; a=0 ;0f66 320150 ld (#5001),a ; disable sound ;0f69 32c050 ld (#50c0),a ; kick dog ;0f6c 320050 ld (#5000),a ; disable interrupts ;0f6f f3 di ; disable interrupts ;0f70 af xor a ; a=0 ;0f71 32c050 ld (#50c0),a ; kick dog ;0f74 3a4050 ld a,(#5040) ; IN1 ;0f77 cb77 bit 6,a ; start 2 ;0f79 20f5 jr nz,#0f70 ; not pressed, loop back ; turn it back on ;0f7b 3e01 ld a,#01 ; a=1 ;0f7d 320050 ld (#5000),a ; enable interrupts ;0f80 320150 ld (#5001),a ; enable sound ;0f83 fb ei ; enable interrupts ;0f84 f1 pop af ; retore a ;0f85 c3db1f jp #1fdb ; jump back ; level 255 pac fix ; HACK8 ;0f88 3a134e ld a,(#4e13) ; board number ;0f8b 3c inc a ;0f8c feff cp #ff ;0f8e 2803 jr z,#0f93 ; don't store level if == 255 ;0f90 32134e ld (#4e13),a ; store new board number ;0f93 c3940a jp #0a94 ; jump back ; level 141 mspac fix ; HACK9 ;0f96 3a134e ld a,(#4e13) ; board number ;0f99 3c inc a ;0f9a f37b cp #7b ; compare to bad board point ;0f9c 2002 jr nz,#0fa0 ; don't store if out of range ;0f9e d608 sub #08 ; loop around for all 8 boards ;0fa0 32134e ld (#4e13),a ; store the level number ;0fa3 c3940a jp #0a94 ; return 0f5c 00 nop 0f5d 00 nop 0f5e 00 nop 0f5f 00 nop 0F60: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0F70: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0F80: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0F90: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FA0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FB0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FC0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FD0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FE0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 0FF0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 81 CE ................ 0ff7 0a ld a,(bc) 0ff8 ed0c tst c 0ffa 14 inc d 0ffb 0a ld a,(bc) 0ffc 00 nop 0ffd 08 ex af,af' 0ffe 48 ld c,b 0fff 36 ;; blink coin lights to pellets ; HACK11 0ffe e089 ; checksum patch ; clear fruit 1000 af xor a 1001 32d44d ld (#4dd4),a 1004 c9 ret 1005 00 nop 1006 00 nop 1007 22d24d ld (#4dd2),hl 100a c9 ret 100b c37836 jp #3678 100e 3a004e ld a,(#4e00) 1011 3d dec a 1012 c8 ret z 1013 ef rst #28 1014 1ca2 1016 c9 ret 1017 cd9112 call #1291 101a 3aa54d ld a,(#4da5) 101d a7 and a 101e c0 ret nz 101f cd6610 call #1066 1022 cd9410 call #1094 1025 cd9e10 call #109e 1028 cda810 call #10a8 102b cdb410 call #10b4 102e 3aa44d ld a,(#4da4) 1031 a7 and a 1032 ca3910 jp z,#1039 1035 cd3512 call #1235 1038 c9 ret 1039 cd1d17 call #171d 103c cd8917 call #1789 ; check for collision with blue ghost 103f 3aa44d ld a,(#4da4) 1042 a7 and a 1043 c0 ret nz 1044 cd0618 call #1806 1047 cd361b call #1b36 104a cd4b1c call #1c4b 104d cd221d call #1d22 1050 cdf91d call #1df9 1053 3a044e ld a,(#4e04) 1056 fe03 cp #03 1058 c0 ret nz 1059 cd7613 call #1376 ; control blue time 105c cd6920 call #2069 105f cd8c20 call #208c 1062 cdaf20 call #20af 1065 c9 ret 1066 3aab4d ld a,(#4dab) 1069 a7 and a 106a c8 ret z 106b 3d dec a 106c 2008 jr nz,#1076 ; (8) 106e 32ab4d ld (#4dab),a 1071 3c inc a 1072 32ac4d ld (#4dac),a 1075 c9 ret 1076 3d dec a 1077 2008 jr nz,#1081 ; (8) 1079 32ab4d ld (#4dab),a 107c 3c inc a 107d 32ad4d ld (#4dad),a 1080 c9 ret 1081 3d dec a 1082 2008 jr nz,#108c ; (8) 1084 32ab4d ld (#4dab),a 1087 3c inc a 1088 32ae4d ld (#4dae),a 108b c9 ret 108c 32af4d ld (#4daf),a 108f 3d dec a 1090 32ab4d ld (#4dab),a 1093 c9 ret 1094 3aac4d ld a,(#4dac) 1097 e7 rst #20 1098 0c inc c 1099 00 nop 109a c0 ret nz 109b 10d2 djnz #106f ; (-46) 109d 103a djnz #10d9 ; (58) 109f ad xor l 10a0 4d ld c,l 10a1 e7 rst #20 10a2 0c inc c 10a3 00 nop 10a4 1811 jr #10b7 ; (17) 10a6 2a113a ld hl,(#3a11) 10a9 ae xor (hl) 10aa 4d ld c,l 10ab e7 rst #20 10ac 0c inc c 10ad 00 nop 10ae 5c ld e,h 10af 116e11 ld de,#116e 10b2 8f adc a,a 10b3 113aaf ld de,#af3a 10b6 4d ld c,l 10b7 e7 rst #20 10b8 0c inc c 10b9 00 nop 10ba c9 ret 10bb 11db11 ld de,#11db 10be fc11cd call m,#cd11 10c1 d8 ret c 10c2 1b dec de 10c3 2a004d ld hl,(#4d00) 10c6 116480 ld de,#8064 10c9 a7 and a 10ca ed52 sbc hl,de 10cc c0 ret nz 10cd 21ac4d ld hl,#4dac 10d0 34 inc (hl) 10d1 c9 ret 10d2 dd210133 ld ix,#3301 10d6 fd21004d ld iy,#4d00 10da cd0020 call #2000 10dd 22004d ld (#4d00),hl 10e0 3e01 ld a,#01 10e2 32284d ld (#4d28),a 10e5 322c4d ld (#4d2c),a 10e8 3a004d ld a,(#4d00) 10eb fe80 cp #80 10ed c0 ret nz 10ee 212f2e ld hl,#2e2f 10f1 220a4d ld (#4d0a),hl 10f4 22314d ld (#4d31),hl 10f7 af xor a 10f8 32a04d ld (#4da0),a 10fb 32ac4d ld (#4dac),a 10fe 32a74d ld (#4da7),a 1101 dd21ac4d ld ix,#4dac 1105 ddb600 or (ix+#00) 1108 ddb601 or (ix+#01) 110b ddb602 or (ix+#02) 110e ddb603 or (ix+#03) 1111 c0 ret nz 1112 21ac4e ld hl,#4eac 1115 cbb6 res 6,(hl) 1117 c9 ret 1118 cdaf1c call #1caf 111b 2a024d ld hl,(#4d02) 111e 116480 ld de,#8064 1121 a7 and a 1122 ed52 sbc hl,de 1124 c0 ret nz 1125 21ad4d ld hl,#4dad 1128 34 inc (hl) 1129 c9 ret 112a dd210133 ld ix,#3301 112e fd21024d ld iy,#4d02 1132 cd0020 call #2000 1135 22024d ld (#4d02),hl 1138 3e01 ld a,#01 113a 32294d ld (#4d29),a 113d 322d4d ld (#4d2d),a 1140 3a024d ld a,(#4d02) 1143 fe80 cp #80 1145 c0 ret nz 1146 212f2e ld hl,#2e2f 1149 220c4d ld (#4d0c),hl 114c 22334d ld (#4d33),hl 114f af xor a 1150 32a14d ld (#4da1),a 1153 32ad4d ld (#4dad),a 1156 32a84d ld (#4da8),a 1159 c30111 jp #1101 115c cd861d call #1d86 115f 2a044d ld hl,(#4d04) 1162 116480 ld de,#8064 1165 a7 and a 1166 ed52 sbc hl,de 1168 c0 ret nz 1169 21ae4d ld hl,#4dae 116c 34 inc (hl) 116d c9 ret 116e dd210133 ld ix,#3301 1172 fd21044d ld iy,#4d04 1176 cd0020 call #2000 1179 22044d ld (#4d04),hl 117c 3e01 ld a,#01 117e 322a4d ld (#4d2a),a 1181 322e4d ld (#4d2e),a 1184 3a044d ld a,(#4d04) 1187 fe80 cp #80 1189 c0 ret nz 118a 21ae4d ld hl,#4dae 118d 34 inc (hl) 118e c9 ret 118f dd210333 ld ix,#3303 1193 fd21044d ld iy,#4d04 1197 cd0020 call #2000 119a 22044d ld (#4d04),hl 119d 3e02 ld a,#02 119f 322a4d ld (#4d2a),a 11a2 322e4d ld (#4d2e),a 11a5 3a054d ld a,(#4d05) 11a8 fe90 cp #90 11aa c0 ret nz 11ab 212f30 ld hl,#302f 11ae 220e4d ld (#4d0e),hl 11b1 22354d ld (#4d35),hl 11b4 3e01 ld a,#01 11b6 322a4d ld (#4d2a),a 11b9 322e4d ld (#4d2e),a 11bc af xor a 11bd 32a24d ld (#4da2),a 11c0 32ae4d ld (#4dae),a 11c3 32a94d ld (#4da9),a 11c6 c30111 jp #1101 11c9 cd5d1e call #1e5d 11cc 2a064d ld hl,(#4d06) 11cf 116480 ld de,#8064 11d2 a7 and a 11d3 ed52 sbc hl,de 11d5 c0 ret nz 11d6 21af4d ld hl,#4daf 11d9 34 inc (hl) 11da c9 ret 11db dd210133 ld ix,#3301 11df fd21064d ld iy,#4d06 11e3 cd0020 call #2000 11e6 22064d ld (#4d06),hl 11e9 3e01 ld a,#01 11eb 322b4d ld (#4d2b),a 11ee 322f4d ld (#4d2f),a 11f1 3a064d ld a,(#4d06) 11f4 fe80 cp #80 11f6 c0 ret nz 11f7 21af4d ld hl,#4daf 11fa 34 inc (hl) 11fb c9 ret 11fc dd21ff32 ld ix,#32ff 1200 fd21064d ld iy,#4d06 1204 cd0020 call #2000 1207 22064d ld (#4d06),hl 120a af xor a 120b 322b4d ld (#4d2b),a 120e 322f4d ld (#4d2f),a 1211 3a074d ld a,(#4d07) 1214 fe70 cp #70 1216 c0 ret nz 1217 212f2c ld hl,#2c2f 121a 22104d ld (#4d10),hl 121d 22374d ld (#4d37),hl 1220 3e01 ld a,#01 1222 322b4d ld (#4d2b),a 1225 322f4d ld (#4d2f),a 1228 af xor a 1229 32a34d ld (#4da3),a 122c 32af4d ld (#4daf),a 122f 32aa4d ld (#4daa),a 1232 c30111 jp #1101 1235 3ad14d ld a,(#4dd1) 1238 e7 rst #20 1239 3f ccf 123a 12 ld (de),a 123b 0c inc c 123c 00 nop 123d 3f ccf 123e 12 ld (de),a 123f 21004c ld hl,#4c00 1242 3aa44d ld a,(#4da4) 1245 87 add a,a 1246 5f ld e,a 1247 1600 ld d,#00 1249 19 add hl,de 124a 3ad14d ld a,(#4dd1) 124d a7 and a 124e 2027 jr nz,#1277 ; (39) 1250 3ad04d ld a,(#4dd0) 1253 0627 ld b,#27 1255 80 add a,b 1256 47 ld b,a 1257 3a724e ld a,(#4e72) 125a 4f ld c,a 125b 3a094e ld a,(#4e09) 125e a1 and c 125f 2804 jr z,#1265 ; (4) 1261 cbf0 set 6,b 1263 cbf8 set 7,b 1265 70 ld (hl),b 1266 23 inc hl 1267 3618 ld (hl),#18 1269 3e00 ld a,#00 126b 320b4c ld (#4c0b),a 126e f7 rst #30 126f 4a ld c,d 1270 03 inc bc 1271 00 nop 1272 21d14d ld hl,#4dd1 1275 34 inc (hl) 1276 c9 ret 1277 3620 ld (hl),#20 1279 3e09 ld a,#09 127b 320b4c ld (#4c0b),a 127e 3aa44d ld a,(#4da4) 1281 32ab4d ld (#4dab),a 1284 af xor a 1285 32a44d ld (#4da4),a 1288 32d14d ld (#4dd1),a 128b 21ac4e ld hl,#4eac 128e cbf6 set 6,(hl) 1290 c9 ret 1291 3aa54d ld a,(#4da5) 1294 e7 rst #20 ; dereferencing table of some kind 00c0 12b7 12b7 12b7 12b7 12bc 12f9 1306 etc... 1295 0c inc c 1296 00 nop 1297 b7 or a 1298 12 ld (de),a 1299 b7 or a 129a 12 ld (de),a 129b b7 or a 129c 12 ld (de),a 129d b7 or a 129e 12 ld (de),a 129f cb12 rl d 12a1 f9 ld sp,hl 12a2 12 ld (de),a 12a3 0613 ld b,#13 12a5 0e13 ld c,#13 12a7 1613 ld d,#13 12a9 1e13 ld e,#13 12ab 2613 ld h,#13 12ad 2e13 ld l,#13 12af 3613 ld (hl),#13 12b1 3e13 ld a,#13 12b3 46 ld b,(hl) 12b4 13 inc de 12b5 53 ld d,e 12b6 13 inc de 12b7 2ac54d ld hl,(#4dc5) 12ba 23 inc hl 12bb 22c54d ld (#4dc5),hl 12be 117800 ld de,#0078 12c1 a7 and a 12c2 ed52 sbc hl,de 12c4 c0 ret nz 12c5 3e05 ld a,#05 12c7 32a54d ld (#4da5),a 12ca c9 ret ; adjust mspac sprite animation? 12cb 210000 ld hl,#0000 12ce cd7e26 call #267e 12d1 3e34 ld a,#34 12d3 11b400 ld de,#00b4 12d6 4f ld c,a 12d7 3a724e ld a,(#4e72) 12da 47 ld b,a 12db 3a094e ld a,(#4e09) 12de a0 and b 12df 2804 jr z,#12e5 ; (4) 12e1 3ec0 ld a,#c0 12e3 b1 or c 12e4 4f ld c,a 12e5 79 ld a,c 12e6 320a4c ld (#4c0a),a ; mspac sprite number 12e9 2ac54d ld hl,(#4dc5) 12ec 23 inc hl 12ed 22c54d ld (#4dc5),hl 12f0 a7 and a 12f1 ed52 sbc hl,de 12f3 c0 ret nz 12f4 21a54d ld hl,#4da5 12f7 34 inc (hl) 12f8 c9 ret 12f9 21bc4e ld hl,#4ebc 12fc cbe6 set 4,(hl) 12fe 3e35 ld a,#35 1300 11c300 ld de,#00c3 1303 c3d612 jp #12d6 1306 3e36 ld a,#36 1308 11d200 ld de,#00d2 130b c3d612 jp #12d6 130e 3e37 ld a,#37 1310 11e100 ld de,#00e1 1313 c3d612 jp #12d6 1316 3e38 ld a,#38 1318 11f000 ld de,#00f0 131b c3d612 jp #12d6 131e 3e39 ld a,#39 1320 11ff00 ld de,#00ff 1323 c3d612 jp #12d6 1326 3e3a ld a,#3a 1328 110e01 ld de,#010e 132b c3d612 jp #12d6 132e 3e3b ld a,#3b 1330 111d01 ld de,#011d 1333 c3d612 jp #12d6 1336 3e3c ld a,#3c 1338 112c01 ld de,#012c 133b c3d612 jp #12d6 133e 3e3d ld a,#3d 1340 113b01 ld de,#013b 1343 c3d612 jp #12d6 1346 21bc4e ld hl,#4ebc 1349 3600 ld (hl),#00 134b 3e3e ld a,#3e 134d 115901 ld de,#0159 1350 c3d612 jp #12d6 ; game end tests? 1353 3e3f ld a,#3f 1355 320a4c ld (#4c0a),a ; mspac sprite number 1358 2ac54d ld hl,(#4dc5) 135b 23 inc hl 135c 22c54d ld (#4dc5),hl 135f 11b801 ld de,#01b8 1362 a7 and a 1363 ed52 sbc hl,de 1365 c0 ret nz ;; decrement lives ; this gets called after the death animation, but before the ; screen gets redrawn. ; -- probably a good hook point for 'insert coin to contunue' -- 1366 21144e ld hl,#4e14 ; hl = number of lives left 1369 35 dec (hl) ; subtract 1 136a 21154e ld hl,#4e15 ; hl = number of lives on screen 136d 35 dec (hl) ; subtract 1 136e cd7526 call #2675 1371 21044e ld hl,#4e04 ; 3=ghost move 2=ghost wait 1374 34 inc (hl) 1375 c9 ret ;; routine to control blue time ;; ret immediately to make ghosts stay blue till eaten 1376 3aa64d ld a,(#4da6) 1379 a7 and a 137a c8 ret z 137b dd21a74d ld ix,#4da7 137f dd7e00 ld a,(ix+#00) 1382 ddb601 or (ix+#01) 1385 ddb602 or (ix+#02) 1388 ddb603 or (ix+#03) 138b ca9813 jp z,#1398 138e 2acb4d ld hl,(#4dcb) 1391 2b dec hl 1392 22cb4d ld (#4dcb),hl 1395 7c ld a,h 1396 b5 or l 1397 c0 ret nz 1398 210b4c ld hl,#4c0b 139b 3609 ld (hl),#09 139d 3aac4d ld a,(#4dac) 13a0 a7 and a 13a1 c2a713 jp nz,#13a7 13a4 32a74d ld (#4da7),a 13a7 3aad4d ld a,(#4dad) 13aa a7 and a 13ab c2b113 jp nz,#13b1 13ae 32a84d ld (#4da8),a 13b1 3aae4d ld a,(#4dae) 13b4 a7 and a 13b5 c2bb13 jp nz,#13bb 13b8 32a94d ld (#4da9),a 13bb 3aaf4d ld a,(#4daf) 13be a7 and a 13bf c2c513 jp nz,#13c5 13c2 32aa4d ld (#4daa),a 13c5 af xor a 13c6 32cb4d ld (#4dcb),a 13c9 32cc4d ld (#4dcc),a 13cc 32a64d ld (#4da6),a 13cf 32c84d ld (#4dc8),a 13d2 32d04d ld (#4dd0),a 13d5 21ac4e ld hl,#4eac 13d8 cbae res 5,(hl) 13da cbbe res 7,(hl) 13dc c9 ret 13dd 219e4d ld hl,#4d9e 13e0 3a0e4e ld a,(#4e0e) 13e3 be cp (hl) 13e4 caee13 jp z,#13ee 13e7 210000 ld hl,#0000 13ea 22974d ld (#4d97),hl 13ed c9 ret 13ee 2a974d ld hl,(#4d97) 13f1 23 inc hl 13f2 22974d ld (#4d97),hl 13f5 ed5b954d ld de,(#4d95) 13f9 a7 and a 13fa ed52 sbc hl,de 13fc c0 ret nz 13fd 210000 ld hl,#0000 1400 22974d ld (#4d97),hl 1403 3aa14d ld a,(#4da1) 1406 a7 and a 1407 f5 push af 1408 cc8620 call z,#2086 140b f1 pop af 140c c8 ret z 140d 3aa24d ld a,(#4da2) 1410 a7 and a 1411 f5 push af 1412 cca920 call z,#20a9 1415 f1 pop af 1416 c8 ret z 1417 3aa34d ld a,(#4da3) 141a a7 and a 141b ccd120 call z,#20d1 141e c9 ret 141f 3a724e ld a,(#4e72) 1422 47 ld b,a 1423 3a094e ld a,(#4e09) 1426 a0 and b 1427 c8 ret z 1428 47 ld b,a 1429 dd21004c ld ix,#4c00 142d 1e08 ld e,#08 142f 0e08 ld c,#08 1431 1607 ld d,#07 ;; this looks to be some kind of data? it's ver repetitions till 1500 1433 3a004d ld a,(#4d00) 1436 83 add a,e 1437 dd7713 ld (ix+#13),a 143a 3a014d ld a,(#4d01) 143d 2f cpl 143e 82 add a,d 143f dd7712 ld (ix+#12),a 1442 3a024d ld a,(#4d02) 1445 83 add a,e 1446 dd7715 ld (ix+#15),a 1449 3a034d ld a,(#4d03) 144c 2f cpl 144d 82 add a,d 144e dd7714 ld (ix+#14),a 1451 3a044d ld a,(#4d04) 1454 83 add a,e 1455 dd7717 ld (ix+#17),a 1458 3a054d ld a,(#4d05) 145b 2f cpl 145c 81 add a,c 145d dd7716 ld (ix+#16),a 1460 3a064d ld a,(#4d06) 1463 83 add a,e 1464 dd7719 ld (ix+#19),a 1467 3a074d ld a,(#4d07) 146a 2f cpl 146b 81 add a,c 146c dd7718 ld (ix+#18),a 146f 3a084d ld a,(#4d08) 1472 83 add a,e 1473 dd771b ld (ix+#1b),a 1476 3a094d ld a,(#4d09) 1479 2f cpl 147a 81 add a,c 147b dd771a ld (ix+#1a),a 147e 3ad24d ld a,(#4dd2) 1481 83 add a,e 1482 dd771d ld (ix+#1d),a 1485 3ad34d ld a,(#4dd3) 1488 2f cpl 1489 81 add a,c 148a dd771c ld (ix+#1c),a 148d c3fe14 jp #14fe ;; display the sprites in the intro and game 1490 3a724e ld a,(#4e72) 1493 47 ld b,a 1494 3a094e ld a,(#4e09) 1497 a0 and b 1498 c0 ret nz 1499 47 ld b,a 149a 1e09 ld e,#09 149c 0e07 ld c,#07 149e 1606 ld d,#06 14a0 dd21004c ld ix,#4c00 14a4 3a004d ld a,(#4d00) 14a7 2f cpl 14a8 83 add a,e 14a9 dd7713 ld (ix+#13),a 14ac 3a014d ld a,(#4d01) 14af 82 add a,d 14b0 dd7712 ld (ix+#12),a 14b3 3a024d ld a,(#4d02) 14b6 2f cpl 14b7 83 add a,e 14b8 dd7715 ld (ix+#15),a 14bb 3a034d ld a,(#4d03) 14be 82 add a,d 14bf dd7714 ld (ix+#14),a 14c2 3a044d ld a,(#4d04) 14c5 2f cpl 14c6 83 add a,e 14c7 dd7717 ld (ix+#17),a 14ca 3a054d ld a,(#4d05) 14cd 81 add a,c 14ce dd7716 ld (ix+#16),a 14d1 3a064d ld a,(#4d06) 14d4 2f cpl 14d5 83 add a,e 14d6 dd7719 ld (ix+#19),a 14d9 3a074d ld a,(#4d07) 14dc 81 add a,c 14dd dd7718 ld (ix+#18),a 14e0 3a084d ld a,(#4d08) 14e3 2f cpl 14e4 83 add a,e 14e5 dd771b ld (ix+#1b),a 14e8 3a094d ld a,(#4d09) 14eb 81 add a,c 14ec dd771a ld (ix+#1a),a 14ef 3ad24d ld a,(#4dd2) 14f2 2f cpl 14f3 83 add a,e 14f4 dd771d ld (ix+#1d),a 14f7 3ad34d ld a,(#4dd3) 14fa 81 add a,c 14fb dd771c ld (ix+#1c),a 14fe 3aa54d ld a,(#4da5) 1501 a7 and a 1502 c24b15 jp nz,#154b 1505 3aa44d ld a,(#4da4) 1508 a7 and a 1509 c2b415 jp nz,#15b4 150c 211c15 ld hl,#151c 150f e5 push hl 1510 3a304d ld a,(#4d30) 1513 e7 rst #20 1514 8c adc a,h 1515 16b1 ld d,#b1 1517 16d6 ld d,#d6 1519 16f7 ld d,#f7 151b 1678 ld d,#78 151d a7 and a 151e 282b jr z,#154b ; (43) 1520 0ec0 ld c,#c0 1522 3a0a4c ld a,(#4c0a) ; mspac sprite number 1525 57 ld d,a 1526 a1 and c 1527 2005 jr nz,#152e ; (5) 1529 7a ld a,d 152a b1 or c 152b c34815 jp #1548 152e 3a304d ld a,(#4d30) 1531 fe02 cp #02 1533 2009 jr nz,#153e ; (9) 1535 cb7a bit 7,d 1537 2812 jr z,#154b ; (18) 1539 7a ld a,d 153a a9 xor c 153b c34815 jp #1548 153e fe03 cp #03 1540 2009 jr nz,#154b ; (9) 1542 cb72 bit 6,d 1544 2805 jr z,#154b ; (5) 1546 7a ld a,d 1547 a9 xor c 1548 320a4c ld (#4c0a),a ; mspac sprite number 154b 21c04d ld hl,#4dc0 154e 56 ld d,(hl) 154f 3e1c ld a,#1c 1551 82 add a,d 1552 dd7702 ld (ix+#02),a 1555 dd7704 ld (ix+#04),a 1558 dd7706 ld (ix+#06),a 155b dd7708 ld (ix+#08),a 155e 0e20 ld c,#20 1560 3aac4d ld a,(#4dac) 1563 a7 and a 1564 2006 jr nz,#156c ; (6) 1566 3aa74d ld a,(#4da7) 1569 a7 and a 156a 2009 jr nz,#1575 ; (9) 156c 3a2c4d ld a,(#4d2c) 156f 87 add a,a 1570 82 add a,d 1571 81 add a,c 1572 dd7702 ld (ix+#02),a 1575 3aad4d ld a,(#4dad) 1578 a7 and a 1579 2006 jr nz,#1581 ; (6) 157b 3aa84d ld a,(#4da8) 157e a7 and a 157f 2009 jr nz,#158a ; (9) 1581 3a2d4d ld a,(#4d2d) 1584 87 add a,a 1585 82 add a,d 1586 81 add a,c 1587 dd7704 ld (ix+#04),a 158a 3aae4d ld a,(#4dae) 158d a7 and a 158e 2006 jr nz,#1596 ; (6) 1590 3aa94d ld a,(#4da9) 1593 a7 and a 1594 2009 jr nz,#159f ; (9) 1596 3a2e4d ld a,(#4d2e) 1599 87 add a,a 159a 82 add a,d 159b 81 add a,c 159c dd7706 ld (ix+#06),a 159f 3aaf4d ld a,(#4daf) 15a2 a7 and a 15a3 2006 jr nz,#15ab ; (6) 15a5 3aaa4d ld a,(#4daa) 15a8 a7 and a 15a9 2009 jr nz,#15b4 ; (9) 15ab 3a2f4d ld a,(#4d2f) 15ae 87 add a,a 15af 82 add a,d 15b0 81 add a,c 15b1 dd7708 ld (ix+#08),a 15b4 cde615 call #15e6 15b7 cd2d16 call #162d 15ba cd5216 call #1652 15bd 78 ld a,b 15be a7 and a 15bf c8 ret z 15c0 0ec0 ld c,#c0 15c2 3a024c ld a,(#4c02) 15c5 b1 or c 15c6 32024c ld (#4c02),a 15c9 3a044c ld a,(#4c04) 15cc b1 or c 15cd 32044c ld (#4c04),a 15d0 3a064c ld a,(#4c06) 15d3 b1 or c 15d4 32064c ld (#4c06),a 15d7 3a084c ld a,(#4c08) 15da b1 or c 15db 32084c ld (#4c08),a 15de 3a0c4c ld a,(#4c0c) 15e1 b1 or c 15e2 320c4c ld (#4c0c),a 15e5 c9 ret 15e6 3a064e ld a,(#4e06) 15e9 d605 sub #05 15eb d8 ret c 15ec 3a094d ld a,(#4d09) 15ef e60f and #0f 15f1 fe0c cp #0c 15f3 3804 jr c,#15f9 ; (4) 15f5 1618 ld d,#18 15f7 1812 jr #160b ; (18) 15f9 fe08 cp #08 15fb 3804 jr c,#1601 ; (4) 15fd 1614 ld d,#14 15ff 180a jr #160b ; (10) 1601 fe04 cp #04 1603 3804 jr c,#1609 ; (4) 1605 1610 ld d,#10 1607 1802 jr #160b ; (2) 1609 1614 ld d,#14 160b dd7204 ld (ix+#04),d 160e 14 inc d 160f dd7206 ld (ix+#06),d 1612 14 inc d 1613 dd7208 ld (ix+#08),d 1616 14 inc d 1617 dd720c ld (ix+#0c),d 161a dd360a3f ld (ix+#0a),#3f 161e 1616 ld d,#16 1620 dd7205 ld (ix+#05),d 1623 dd7207 ld (ix+#07),d 1626 dd7209 ld (ix+#09),d 1629 dd720d ld (ix+#0d),d 162c c9 ret 162d 3a074e ld a,(#4e07) 1630 a7 and a 1631 c8 ret z ; check for pac moving though the other tunnel? 1632 57 ld d,a 1633 3a3a4d ld a,(#4d3a) 1636 d63d sub #3d 1638 2004 jr nz,#163e ; (4) 163a dd360b00 ld (ix+#0b),#00 163e 7a ld a,d 163f fe0a cp #0a 1641 d8 ret c 1642 dd360232 ld (ix+#02),#32 1646 dd36031d ld (ix+#03),#1d 164a fe0c cp #0c 164c d8 ret c 164d dd360233 ld (ix+#02),#33 1651 c9 ret 1652 3a084e ld a,(#4e08) ; partial difficulty? 1655 a7 and a 1656 c8 ret z 1657 57 ld d,a 1658 3a3a4d ld a,(#4d3a) 165b d63d sub #3d 165d 2004 jr nz,#1663 ; (4) 165f dd360b00 ld (ix+#0b),#00 1663 7a ld a,d 1664 fe01 cp #01 1666 d8 ret c 1667 3ac04d ld a,(#4dc0) 166a 1e08 ld e,#08 166c 83 add a,e 166d dd7702 ld (ix+#02),a 1670 7a ld a,d 1671 fe03 cp #03 1673 d8 ret c 1674 3a014d ld a,(#4d01) 1677 e608 and #08 1679 0f rrca 167a 0f rrca 167b 0f rrca 167c 1e0a ld e,#0a 167e 83 add a,e 167f dd770c ld (ix+#0c),a 1682 3c inc a 1683 3c inc a 1684 dd7702 ld (ix+#02),a 1687 dd360d1e ld (ix+#0d),#1e 168b c9 ret 168c c39c86 jp #869c 168f c9 ret 1690 07 rlca 1691 fe06 cp #06 1693 3805 jr c,#169a ; (5) 1695 dd360a30 ld (ix+#0a),#30 1699 c9 ret 169a fe04 cp #04 169c 3805 jr c,#16a3 ; (5) 169e dd360a2e ld (ix+#0a),#2e 16a2 c9 ret 16a3 fe02 cp #02 16a5 3805 jr c,#16ac ; (5) 16a7 dd360a2c ld (ix+#0a),#2c 16ab c9 ret 16ac dd360a2e ld (ix+#0a),#2e 16b0 c9 ret 16b1 c3b186 jp #86b1 16b4 c9 ret 16b5 07 rlca 16b6 fe06 cp #06 16b8 3805 jr c,#16bf ; (5) 16ba dd360a2f ld (ix+#0a),#2f 16be c9 ret 16bf fe04 cp #04 16c1 3805 jr c,#16c8 ; (5) 16c3 dd360a2d ld (ix+#0a),#2d 16c7 c9 ret 16c8 fe02 cp #02 16ca 3805 jr c,#16d1 ; (5) 16cc dd360a2f ld (ix+#0a),#2f 16d0 c9 ret 16d1 dd360a30 ld (ix+#0a),#30 16d5 c9 ret 16d6 3a094d ld a,(#4d09) 16d9 c3c586 jp #86c5 16dc c9 ret 16dd 3808 jr c,#16e7 ; (8) 16df 1e2e ld e,#2e 16e1 cbfb set 7,e 16e3 dd730a ld (ix+#0a),e 16e6 c9 ret 16e7 fe04 cp #04 16e9 3804 jr c,#16ef ; (4) 16eb 1e2c ld e,#2c 16ed 18f2 jr #16e1 ; (-14) 16ef fe02 cp #02 16f1 30ec jr nc,#16df ; (-20) 16f3 1e30 ld e,#30 16f5 18ea jr #16e1 ; (-22) 16f7 3a084d ld a,(#4d08) 16fa c3d986 jp #86d9 16fd c9 ret 16fe 3805 jr c,#1705 ; (5) 1700 dd360a30 ld (ix+#0a),#30 1704 c9 ret 1705 fe04 cp #04 1707 3808 jr c,#1711 ; (8) 1709 1e2f ld e,#2f 170b cbf3 set 6,e 170d dd730a ld (ix+#0a),e 1710 c9 ret 1711 fe02 cp #02 1713 3804 jr c,#1719 ; (4) 1715 1e2d ld e,#2d 1717 18f2 jr #170b ; (-14) 1719 1e2f ld e,#2f 171b 18ee jr #170b ; (-18) ;; normal ghost collision detect 171d 0604 ld b,#04 171f ed5b394d ld de,(#4d39) 1723 3aaf4d ld a,(#4daf) 1726 a7 and a 1727 2009 jr nz,#1732 ; (9) 1729 2a374d ld hl,(#4d37) 172c a7 and a 172d ed52 sbc hl,de 172f ca6317 jp z,#1763 ; check for collision with ghost 1732 05 dec b 1733 3aae4d ld a,(#4dae) 1736 a7 and a 1737 2009 jr nz,#1742 ; (9) 1739 2a354d ld hl,(#4d35) 173c a7 and a 173d ed52 sbc hl,de 173f ca6317 jp z,#1763 1742 05 dec b 1743 3aad4d ld a,(#4dad) 1746 a7 and a 1747 2009 jr nz,#1752 ; (9) 1749 2a334d ld hl,(#4d33) 174c a7 and a 174d ed52 sbc hl,de 174f ca6317 jp z,#1763 1752 05 dec b 1753 3aac4d ld a,(#4dac) 1756 a7 and a 1757 2009 jr nz,#1762 ; (9) 1759 2a314d ld hl,(#4d31) 175c a7 and a 175d ed52 sbc hl,de 175f ca6317 jp z,#1763 1762 05 dec b 1763 78 ld a,b ; collision detection routine 1764 32a44d ld (#4da4),a ; invincibility check ; HACK3 ;1764 c3b01f jp #1fb0 1767 32a54d ld (#4da5),a 176a a7 and a 176b c8 ret z 176c 21a64d ld hl,#4da6 ; check 176f 5f ld e,a 1770 1600 ld d,#00 1772 19 add hl,de 1773 7e ld a,(hl) 1774 a7 and a 1775 c8 ret z 1776 af xor a 1777 32a54d ld (#4da5),a 177a 21d04d ld hl,#4dd0 177d 34 inc (hl) 177e 46 ld b,(hl) 177f 04 inc b 1780 cd5a2a call #2a5a 1783 21bc4e ld hl,#4ebc 1786 cbde set 3,(hl) 1788 c9 ret ;; end normal ghost collision detect ;; blue ghost collision detect 1789 3aa44d ld a,(#4da4) 178c a7 and a 178d c0 ret nz 178e 3aa64d ld a,(#4da6) 1791 a7 and a 1792 c8 ret z 1793 0e04 ld c,#04 1795 0604 ld b,#04 1797 dd21084d ld ix,#4d08 179b 3aaf4d ld a,(#4daf) 179e a7 and a 179f 2013 jr nz,#17b4 ; (19) 17a1 3a064d ld a,(#4d06) 17a4 dd9600 sub (ix+#00) 17a7 b9 cp c 17a8 300a jr nc,#17b4 ; (10) 17aa 3a074d ld a,(#4d07) 17ad dd9601 sub (ix+#01) 17b0 b9 cp c 17b1 da6317 jp c,#1763 ; collision detection routine 17b4 05 dec b 17b5 3aae4d ld a,(#4dae) 17b8 a7 and a 17b9 2013 jr nz,#17ce ; (19) 17bb 3a044d ld a,(#4d04) 17be dd9600 sub (ix+#00) 17c1 b9 cp c 17c2 300a jr nc,#17ce ; (10) 17c4 3a054d ld a,(#4d05) 17c7 dd9601 sub (ix+#01) 17ca b9 cp c 17cb da6317 jp c,#1763 ; collision detection routine 17ce 05 dec b 17cf 3aad4d ld a,(#4dad) 17d2 a7 and a 17d3 2013 jr nz,#17e8 ; (19) 17d5 3a024d ld a,(#4d02) 17d8 dd9600 sub (ix+#00) 17db b9 cp c 17dc 300a jr nc,#17e8 ; (10) 17de 3a034d ld a,(#4d03) 17e1 dd9601 sub (ix+#01) 17e4 b9 cp c 17e5 da6317 jp c,#1763 ; check for collision with ghost 17e8 05 dec b 17e9 3aac4d ld a,(#4dac) 17ec a7 and a 17ed 2013 jr nz,#1802 ; (19) 17ef 3a004d ld a,(#4d00) 17f2 dd9600 sub (ix+#00) 17f5 b9 cp c 17f6 300a jr nc,#1802 ; (10) 17f8 3a014d ld a,(#4d01) 17fb dd9601 sub (ix+#01) 17fe b9 cp c 17ff da6317 jp c,#1763 ; check for collision with ghost 1802 05 dec b 1803 c36317 jp #1763 ; check for collision with ghost 1806 219d4d ld hl,#4d9d 1809 3eff ld a,#ff ;1809 c3c01f jp #1fc0 ; Intermission fast fix ; HACK10 ;1809 c3d01f jp #1fd0 ; P1P2 cheat ; HACK3 ;1809 c34c0f jp #0f4c ; pause cheat ; HACK5 180b be cp (hl) ; set 0xbe to 0x01 for fast cheat. ; HACK2 ; 180b 01 180c ca1118 jp z,#1811 180f 35 dec (hl) 1810 c9 ret 1811 3aa64d ld a,(#4da6) 1814 a7 and a 1815 ca2f18 jp z,#182f 1818 2a4c4d ld hl,(#4d4c) 181b 29 add hl,hl 181c 224c4d ld (#4d4c),hl 181f 2a4a4d ld hl,(#4d4a) 1822 ed6a adc hl,hl 1824 224a4d ld (#4d4a),hl 1827 d0 ret nc 1828 214c4d ld hl,#4d4c 182b 34 inc (hl) 182c c34318 jp #1843 182f 2a484d ld hl,(#4d48) 1832 29 add hl,hl 1833 22484d ld (#4d48),hl 1836 2a464d ld hl,(#4d46) 1839 ed6a adc hl,hl 183b 22464d ld (#4d46),hl 183e d0 ret nc 183f 21484d ld hl,#4d48 1842 34 inc (hl) 1843 3a0e4e ld a,(#4e0e) 1846 329e4d ld (#4d9e),a 1849 3a724e ld a,(#4e72) 184c 4f ld c,a 184d 3a094e ld a,(#4e09) 1850 a1 and c 1851 4f ld c,a 1852 213a4d ld hl,#4d3a 1855 7e ld a,(hl) 1856 0621 ld b,#21 1858 90 sub b 1859 3809 jr c,#1864 ; (9) 185b 7e ld a,(hl) 185c 063b ld b,#3b 185e 90 sub b 185f 3003 jr nc,#1864 ; (3) 1861 c3ab18 jp #18ab 1864 3e01 ld a,#01 1866 32bf4d ld (#4dbf),a 1869 3a004e ld a,(#4e00) 186c fe01 cp #01 186e ca191a jp z,#1a19 1871 3a044e ld a,(#4e04) 1874 fe10 cp #10 1876 d2191a jp nc,#1a19 1879 79 ld a,c 187a a7 and a 187b 2806 jr z,#1883 ; (6) ; check player 1 or player 2 depending on who is playing ; this seems like the hardware will jump to one of two loc